Skip to content

Commit

Permalink
remap-redux part2: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
andres-asm committed Apr 8, 2018
1 parent fa3dfd5 commit 3792a5e
Show file tree
Hide file tree
Showing 17 changed files with 12 additions and 61 deletions.
4 changes: 1 addition & 3 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -1605,9 +1605,7 @@ ifeq ($(HAVE_NETWORKING), 1)
$(LIBRETRO_COMM_DIR)/utils/md5.o
endif

ifeq ($(HAVE_KEYMAPPER), 1)
OBJ += input/input_mapper.o
endif
OBJ += input/input_mapper.o

ifeq ($(HAVE_NETWORKGAMEPAD), 1)
OBJ += input/input_remote.o \
Expand Down
1 change: 0 additions & 1 deletion Makefile.msvc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ HAVE_NETWORK_CMD := 1
HAVE_OVERLAY := 1
HAVE_LANGEXTRA := 1
HAVE_CHEEVOS := 1
HAVE_KEYMAPPER := 1
HAVE_SHADERPIPELINE := 1
HAVE_IMAGEVIEWER := 1

Expand Down
1 change: 0 additions & 1 deletion Makefile.vita
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ else
HAVE_ZLIB := 1
HAVE_7ZIP := 1
HAVE_VITA2D := 1
HAVE_KEYMAPPER := 1
HAVE_NETWORKING := 1
HAVE_SOCKET_LEGACY := 1
HAVE_MENU := 1
Expand Down
1 change: 0 additions & 1 deletion Makefile.wiiu
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ endif
HAVE_ZLIB = 1
HAVE_7ZIP = 1
HAVE_BUILTINZLIB = 1
HAVE_KEYMAPPER = 1
HAVE_LIBRETRODB = 1
HAVE_ZARCH = 0
HAVE_MATERIALUI = 1
Expand Down
6 changes: 0 additions & 6 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -1358,9 +1358,6 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings,
#ifdef HAVE_NETWORKGAMEPAD
SETTING_BOOL("network_remote_enable", &settings->bools.network_remote_enable, false, false /* TODO */, false);
#endif
#ifdef HAVE_KEYMAPPER
SETTING_BOOL("keymapper_enable", &settings->bools.keymapper_enable, true, true /* TODO */, false);
#endif
#ifdef HAVE_NETWORKING
SETTING_BOOL("netplay_nat_traversal", &settings->bools.netplay_nat_traversal, true, true, false);
#endif
Expand Down Expand Up @@ -1465,9 +1462,6 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings,
#ifdef HAVE_NETWORKGAMEPAD
SETTING_UINT("network_remote_base_port", &settings->uints.network_remote_base_port, true, network_remote_base_port, false);
#endif
#ifdef HAVE_KEYMAPPER
SETTING_UINT("keymapper_port", &settings->uints.keymapper_port, true, 0, false);
#endif
#ifdef GEKKO
SETTING_UINT("video_viwidth", &settings->uints.video_viwidth, true, video_viwidth, false);
#endif
Expand Down
2 changes: 0 additions & 2 deletions griffin/griffin.c
Original file line number Diff line number Diff line change
Expand Up @@ -1242,9 +1242,7 @@ MENU
#include "../cores/libretro-net-retropad/net_retropad_core.c"
#endif

#ifdef HAVE_KEYMAPPER
#include "../input/input_mapper.c"
#endif

#include "../command.c"

Expand Down
21 changes: 4 additions & 17 deletions input/input_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@
#include "input_remote.h"
#endif

#ifdef HAVE_KEYMAPPER
#include "input_mapper.h"
#endif

#include "input_driver.h"
#include "input_keymaps.h"
Expand Down Expand Up @@ -377,9 +375,7 @@ static command_t *input_driver_command = NULL;
#ifdef HAVE_NETWORKGAMEPAD
static input_remote_t *input_driver_remote = NULL;
#endif
#ifdef HAVE_KEYMAPPER
static input_mapper_t *input_driver_mapper = NULL;
#endif
static const input_driver_t *current_input = NULL;
static void *current_input_data = NULL;
static bool input_driver_block_hotkey = false;
Expand Down Expand Up @@ -605,10 +601,8 @@ void input_poll(void)
input_driver_axis_threshold);
#endif

#ifdef HAVE_KEYMAPPER
if (input_driver_mapper)
if (settings->bools.input_remap_binds_enable && input_driver_mapper)
input_mapper_poll(input_driver_mapper);
#endif

#ifdef HAVE_COMMAND
if (input_driver_command)
Expand Down Expand Up @@ -692,11 +686,9 @@ int16_t input_state(unsigned port, unsigned device,
}
}

#ifdef HAVE_KEYMAPPER
if (input_driver_mapper)
if (settings->bools.input_remap_binds_enable && input_driver_mapper)
input_mapper_state(input_driver_mapper,
&res, port, device, idx, id);
#endif

#ifdef HAVE_OVERLAY
if (overlay_ptr)
Expand Down Expand Up @@ -1368,11 +1360,9 @@ void input_driver_deinit_remote(void)

void input_driver_deinit_mapper(void)
{
#ifdef HAVE_KEYMAPPER
if (input_driver_mapper)
input_mapper_free(input_driver_mapper);
input_driver_mapper = NULL;
#endif
}

bool input_driver_init_remote(void)
Expand All @@ -1397,20 +1387,17 @@ bool input_driver_init_remote(void)

bool input_driver_init_mapper(void)
{
#ifdef HAVE_KEYMAPPER
settings_t *settings = config_get_ptr();

if (!settings->bools.keymapper_enable)
if (!settings->bools.input_remap_binds_enable)
return false;

input_driver_mapper = input_mapper_new(
settings->uints.keymapper_port);
input_driver_mapper = input_mapper_new();

if (input_driver_mapper)
return true;

RARCH_ERR("Failed to initialize input mapper.\n");
#endif
return false;
}

Expand Down
13 changes: 6 additions & 7 deletions input/input_mapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct input_mapper
retro_bits_t buttons[MAX_USERS];
};

input_mapper_t *input_mapper_new(uint16_t port)
input_mapper_t *input_mapper_new(void)
{
input_mapper_t* handle = (input_mapper_t*)
calloc(1, sizeof(*handle));
Expand All @@ -76,8 +76,6 @@ void input_mapper_free(input_mapper_t *handle)
free (handle);
}

bool flag = false;

bool input_mapper_button_pressed(input_mapper_t *handle, unsigned port, unsigned id)
{
return BIT256_GET(handle->buttons[port], id);
Expand Down Expand Up @@ -108,6 +106,8 @@ void input_mapper_poll(input_mapper_t *handle)
{
device = settings->uints.input_libretro_device[i];
device &= RETRO_DEVICE_MASK;

/* keyboard to gamepad remapping */
if (device == RETRO_DEVICE_KEYBOARD)
{
for (j = 0; j < RARCH_CUSTOM_BIND_LIST_END; j++)
Expand Down Expand Up @@ -137,7 +137,9 @@ void input_mapper_poll(input_mapper_t *handle)
}
}
}
if (device == RETRO_DEVICE_JOYPAD)

/* gamepad remapping */
if (device == RETRO_DEVICE_JOYPAD || device == RETRO_DEVICE_ANALOG)
{
/* this loop iterates on all users and all buttons, and checks if a pressed button
is assigned to any other button than the default one, then it sets the bit on the
Expand Down Expand Up @@ -165,9 +167,6 @@ void input_mapper_poll(input_mapper_t *handle)
#endif
}
}



}

void input_mapper_state(
Expand Down
2 changes: 1 addition & 1 deletion input/input_mapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RETRO_BEGIN_DECLS

typedef struct input_mapper input_mapper_t;

input_mapper_t *input_mapper_new(uint16_t port);
input_mapper_t *input_mapper_new(void);

void input_mapper_free(input_mapper_t *handle);

Expand Down
4 changes: 0 additions & 4 deletions menu/cbs/menu_cbs_get_value.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,6 @@ static void menu_action_setting_disp_set_label_input_desc(
strlcpy(s2, path, len2);
}

#ifdef HAVE_KEYMAPPER
static void menu_action_setting_disp_set_label_input_desc_kbd(
file_list_t* list,
unsigned *w, unsigned type, unsigned i,
Expand Down Expand Up @@ -627,7 +626,6 @@ static void menu_action_setting_disp_set_label_input_desc_kbd(
*w = 19;
strlcpy(s2, path, len2);
}
#endif

static void menu_action_setting_disp_set_label_cheat(
file_list_t* list,
Expand Down Expand Up @@ -2076,14 +2074,12 @@ static int menu_cbs_init_bind_get_string_representation_compare_type(
BIND_ACTION_GET_VALUE(cbs,
menu_action_setting_disp_set_label_libretro_perf_counters);
}
#ifdef HAVE_KEYMAPPER
else if (type >= MENU_SETTINGS_INPUT_DESC_KBD_BEGIN
&& type <= MENU_SETTINGS_INPUT_DESC_KBD_END)
{
BIND_ACTION_GET_VALUE(cbs,
menu_action_setting_disp_set_label_input_desc_kbd);
}
#endif
else
{
switch (type)
Expand Down
4 changes: 0 additions & 4 deletions menu/cbs/menu_cbs_left.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ static int action_left_input_desc(unsigned type, const char *label,
return 0;
}

#ifdef HAVE_KEYMAPPER
static int action_left_input_desc_kbd(unsigned type, const char *label,
bool wraparound)
{
Expand Down Expand Up @@ -161,7 +160,6 @@ static int action_left_input_desc_kbd(unsigned type, const char *label,

return 0;
}
#endif

static int action_left_scroll(unsigned type, const char *label,
bool wraparound)
Expand Down Expand Up @@ -633,13 +631,11 @@ static int menu_cbs_init_bind_left_compare_type(menu_file_list_cbs_t *cbs,
{
BIND_ACTION_LEFT(cbs, action_left_input_desc);
}
#ifdef HAVE_KEYMAPPER
else if (type >= MENU_SETTINGS_INPUT_DESC_KBD_BEGIN
&& type <= MENU_SETTINGS_INPUT_DESC_KBD_END)
{
BIND_ACTION_LEFT(cbs, action_left_input_desc_kbd);
}
#endif
else if ((type >= MENU_SETTINGS_PLAYLIST_ASSOCIATION_START))
{
BIND_ACTION_LEFT(cbs, playlist_association_left);
Expand Down
4 changes: 0 additions & 4 deletions menu/cbs/menu_cbs_right.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ int action_right_cheat(unsigned type, const char *label,
wraparound);
}

#ifdef HAVE_KEYMAPPER
int action_right_input_desc_kbd(unsigned type, const char *label,
bool wraparound)
{
Expand Down Expand Up @@ -139,7 +138,6 @@ int action_right_input_desc_kbd(unsigned type, const char *label,

return 0;
}
#endif

/* fix-me: incomplete, lacks error checking */
int action_right_input_desc(unsigned type, const char *label,
Expand Down Expand Up @@ -503,13 +501,11 @@ static int menu_cbs_init_bind_right_compare_type(menu_file_list_cbs_t *cbs,
{
BIND_ACTION_RIGHT(cbs, action_right_input_desc);
}
#ifdef HAVE_KEYMAPPER
else if (type >= MENU_SETTINGS_INPUT_DESC_KBD_BEGIN
&& type <= MENU_SETTINGS_INPUT_DESC_KBD_END)
{
BIND_ACTION_RIGHT(cbs, action_right_input_desc_kbd);
}
#endif
else if ((type >= MENU_SETTINGS_PLAYLIST_ASSOCIATION_START))
{
BIND_ACTION_RIGHT(cbs, playlist_association_right);
Expand Down
4 changes: 0 additions & 4 deletions menu/cbs/menu_cbs_select.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,12 @@ static int action_select_input_desc(const char *path, const char *label, unsigne
return action_right_input_desc(type, label, true);
}

#ifdef HAVE_KEYMAPPER
static int action_select_input_desc_kbd(const char *path,
const char *label, unsigned type,
size_t idx)
{
return action_right_input_desc_kbd(type, label, true);
}
#endif

#ifdef HAVE_NETWORKING
static int action_select_netplay_connect_room(const char *path,
Expand Down Expand Up @@ -223,13 +221,11 @@ static int menu_cbs_init_bind_select_compare_type(
{
BIND_ACTION_SELECT(cbs, action_select_input_desc);
}
#ifdef HAVE_KEYMAPPER
else if (type >= MENU_SETTINGS_INPUT_DESC_KBD_BEGIN
&& type <= MENU_SETTINGS_INPUT_DESC_KBD_END)
{
BIND_ACTION_SELECT(cbs, action_select_input_desc_kbd);
}
#endif
else
{

Expand Down
2 changes: 0 additions & 2 deletions menu/cbs/menu_cbs_sublabel.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,13 +533,11 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,

BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_generic);

#ifdef HAVE_KEYMAPPER
if (type >= MENU_SETTINGS_INPUT_DESC_KBD_BEGIN
&& type <= MENU_SETTINGS_INPUT_DESC_KBD_END)
{
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_remap_kbd_sublabel);
}
#endif

if (type >= MENU_SETTINGS_INPUT_DESC_BEGIN
&& type <= MENU_SETTINGS_INPUT_DESC_END)
Expand Down
2 changes: 0 additions & 2 deletions menu/menu_displaylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -3282,7 +3282,6 @@ static int menu_displaylist_parse_options_remappings(
}
}
}
#ifdef HAVE_KEYMAPPER
if (system)
{
settings_t *settings = config_get_ptr();
Expand Down Expand Up @@ -3325,7 +3324,6 @@ static int menu_displaylist_parse_options_remappings(
}
}
}
#endif

return 0;
}
Expand Down
1 change: 0 additions & 1 deletion qb/config.libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ if [ "$HAVE_NETWORKING" = 'yes' ]; then
check_lib '' MINIUPNPC '-lminiupnpc'
else
die : 'Warning: All networking features have been disabled.'
HAVE_KEYMAPPER='no'
HAVE_NETWORK_CMD='no'
HAVE_NETWORKGAMEPAD='no'
HAVE_CHEEVOS='no'
Expand Down
1 change: 0 additions & 1 deletion qb/config.params.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ HAVE_SSA=auto # SSA/ASS for FFmpeg subtitle support
HAVE_DYLIB=auto # Dynamic loading support
HAVE_NETWORKING=auto # Networking features (recommended)
HAVE_NETWORKGAMEPAD=auto # Networked game pad (plus baked-in core)
HAVE_KEYMAPPER=yes # Networked game pad (plus baked-in core)
C89_NETWORKGAMEPAD=no
HAVE_MINIUPNPC=auto # Mini UPnP client library (for NAT traversal)
HAVE_BUILTINMINIUPNPC=yes # Bake in Mini UPnP client library (for NAT traversal)
Expand Down

0 comments on commit 3792a5e

Please sign in to comment.