mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 22:13:51 +00:00
remap-redux part 2: allow multiple gamepads to work for the keymapper
This commit is contained in:
parent
9639389a66
commit
ed334cd1dd
@ -16,7 +16,7 @@ DEFINES :=
|
||||
ifeq ($(GRIFFIN_BUILD), 1)
|
||||
OBJ += griffin/griffin.o
|
||||
DEFINES += -DHAVE_GRIFFIN=1
|
||||
DEFINES += -DHAVE_NEON -DHAVE_MENU -DHAVE_XMB -DHAVE_MATERIALUI -DHAVE_LIBRETRODB
|
||||
DEFINES += -DHAVE_NEON -DHAVE_MENU -DHAVE_XMB -DHAVE_MATERIALUI -DHAVE_LIBRETRODB DEFINES -DHAVE_KEYMAPPER
|
||||
DEFINES += -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA -DWANT_ZLIB -DHAVE_CC_RESAMPLER
|
||||
ifeq ($(DEBUG), 1)
|
||||
DEFINES += -DHAVE_NETLOGGER
|
||||
@ -33,6 +33,7 @@ else
|
||||
HAVE_ZLIB := 1
|
||||
HAVE_7ZIP := 1
|
||||
HAVE_VITA2D := 1
|
||||
HAVE_KEYMAPPER := 1
|
||||
HAVE_NETWORKING := 1
|
||||
HAVE_SOCKET_LEGACY := 1
|
||||
HAVE_MENU := 1
|
||||
|
@ -380,6 +380,7 @@ typedef struct settings
|
||||
unsigned input_analog_dpad_mode[MAX_USERS];
|
||||
|
||||
unsigned input_keymapper_ids[RARCH_CUSTOM_BIND_LIST_END];
|
||||
unsigned input_keymapper_multi_ids[MAX_USERS][RARCH_CUSTOM_BIND_LIST_END];
|
||||
|
||||
unsigned input_remap_ids[MAX_USERS][RARCH_CUSTOM_BIND_LIST_END];
|
||||
|
||||
|
@ -47,6 +47,7 @@
|
||||
|
||||
#define MAPPER_GET_KEY(state, key) (((state)->keys[(key) / 32] >> ((key) % 32)) & 1)
|
||||
#define MAPPER_SET_KEY(state, key) (state)->keys[(key) / 32] |= 1 << ((key) % 32)
|
||||
#define MAPPER_UNSET_KEY(state, key) (state)->keys[(key) / 32] |= 0 << ((key) % 32)
|
||||
|
||||
struct input_mapper
|
||||
{
|
||||
@ -82,9 +83,10 @@ void input_mapper_free(input_mapper_t *handle)
|
||||
|
||||
void input_mapper_poll(input_mapper_t *handle)
|
||||
{
|
||||
int i;
|
||||
int i, j;
|
||||
settings_t *settings = config_get_ptr();
|
||||
unsigned device = settings->uints.input_libretro_device[handle->port];
|
||||
bool key_event[RARCH_CUSTOM_BIND_LIST_END];
|
||||
#ifdef HAVE_MENU
|
||||
bool menu_is_alive = menu_driver_is_alive();
|
||||
#endif
|
||||
@ -100,23 +102,33 @@ void input_mapper_poll(input_mapper_t *handle)
|
||||
#endif
|
||||
|
||||
memset(handle->keys, 0, sizeof(handle->keys));
|
||||
|
||||
for (i = 0; i < RARCH_CUSTOM_BIND_LIST_END; i++)
|
||||
i = 0;
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
if (i < RETROK_LAST)
|
||||
for (j = 0; j < RARCH_CUSTOM_BIND_LIST_END; j++)
|
||||
{
|
||||
if (input_state(handle->port, RETRO_DEVICE_JOYPAD, 0, i))
|
||||
if (j < RETROK_LAST)
|
||||
{
|
||||
MAPPER_SET_KEY (handle,
|
||||
settings->uints.input_keymapper_ids[i]);
|
||||
input_keyboard_event(true,
|
||||
settings->uints.input_keymapper_ids[i],
|
||||
0, 0, RETRO_DEVICE_KEYBOARD);
|
||||
if (input_state(i, RETRO_DEVICE_JOYPAD, 0, j) && settings->uints.input_keymapper_multi_ids[i][j] != RETROK_UNKNOWN)
|
||||
{
|
||||
MAPPER_SET_KEY (handle,
|
||||
settings->uints.input_keymapper_multi_ids[i][j]);
|
||||
input_keyboard_event(true,
|
||||
settings->uints.input_keymapper_multi_ids[i][j],
|
||||
0, 0, RETRO_DEVICE_KEYBOARD);
|
||||
key_event[j] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (key_event[j] == false &&
|
||||
settings->uints.input_keymapper_multi_ids[i][j] != RETROK_UNKNOWN)
|
||||
{
|
||||
input_keyboard_event(false,
|
||||
settings->uints.input_keymapper_multi_ids[i][j],
|
||||
0, 0, RETRO_DEVICE_KEYBOARD);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
input_keyboard_event(false,
|
||||
settings->uints.input_keymapper_ids[i],
|
||||
0, 0, RETRO_DEVICE_KEYBOARD);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98,6 +98,10 @@ bool input_remapping_load_file(void *data, const char *path)
|
||||
else
|
||||
settings->uints.input_keymapper_ids[j] = RETROK_UNKNOWN;
|
||||
}
|
||||
if (config_get_int(conf, keymapper_ident[j], &key_remap))
|
||||
settings->uints.input_keymapper_multi_ids[i][j] = key_remap;
|
||||
else
|
||||
settings->uints.input_keymapper_multi_ids[i][j] = RETROK_UNKNOWN;
|
||||
|
||||
|
||||
}
|
||||
@ -205,6 +209,7 @@ bool input_remapping_save_file(const char *path)
|
||||
if (settings->uints.keymapper_port == i &&
|
||||
settings->uints.input_keymapper_ids[j] != RETROK_UNKNOWN)
|
||||
config_set_int(conf, keymapper_ident[j], settings->uints.input_keymapper_ids[j]);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -631,15 +631,22 @@ static void menu_action_setting_disp_set_label_input_desc_kbd(
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
char desc[PATH_MAX_LENGTH];
|
||||
unsigned key_id;
|
||||
unsigned key_id, id;
|
||||
unsigned remap_id;
|
||||
unsigned offset = 0;
|
||||
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
if (!settings)
|
||||
return;
|
||||
|
||||
offset = type / ((MENU_SETTINGS_INPUT_DESC_KBD_END - (MENU_SETTINGS_INPUT_DESC_KBD_END - MENU_SETTINGS_INPUT_DESC_KBD_BEGIN))) - 1;
|
||||
|
||||
id = (type / (offset + 1)) - MENU_SETTINGS_INPUT_DESC_KBD_BEGIN;
|
||||
remap_id =
|
||||
settings->uints.input_keymapper_ids[type - MENU_SETTINGS_INPUT_DESC_KBD_BEGIN];
|
||||
settings->uints.input_keymapper_multi_ids[offset][id];
|
||||
|
||||
RARCH_LOG("o: %d, type: %d, remap_id: %d\n", offset, type, remap_id);
|
||||
|
||||
for (key_id = 0; key_id < MENU_SETTINGS_INPUT_DESC_KBD_END - MENU_SETTINGS_INPUT_DESC_KBD_BEGIN; key_id++)
|
||||
{
|
||||
|
@ -3280,6 +3280,7 @@ static int menu_displaylist_parse_options_remappings(
|
||||
|
||||
if (device == RETRO_DEVICE_KEYBOARD)
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
for (retro_id = 0; retro_id < RARCH_FIRST_CUSTOM_BIND; retro_id++)
|
||||
{
|
||||
unsigned user = settings->uints.keymapper_port + 1;
|
||||
@ -3288,9 +3289,9 @@ static int menu_displaylist_parse_options_remappings(
|
||||
const struct retro_keybind *auto_bind = NULL;
|
||||
const struct retro_keybind *keybind = NULL;
|
||||
|
||||
keybind = &input_config_binds[settings->uints.keymapper_port][retro_id];
|
||||
keybind = &input_config_binds[i][retro_id];
|
||||
auto_bind = (const struct retro_keybind*)
|
||||
input_config_get_bind_auto(settings->uints.keymapper_port, retro_id);
|
||||
input_config_get_bind_auto(i, retro_id);
|
||||
|
||||
input_config_get_bind_string(descriptor,
|
||||
keybind, auto_bind, sizeof(descriptor));
|
||||
@ -3298,14 +3299,14 @@ static int menu_displaylist_parse_options_remappings(
|
||||
if(!strstr(descriptor, "Auto"))
|
||||
{
|
||||
const struct retro_keybind *keyptr =
|
||||
&input_config_binds[settings->uints.keymapper_port][retro_id];
|
||||
&input_config_binds[i][retro_id];
|
||||
|
||||
strlcpy(descriptor, msg_hash_to_str(keyptr->enum_idx), sizeof(descriptor));
|
||||
}
|
||||
|
||||
menu_entries_append_enum(info->list, descriptor, "",
|
||||
MSG_UNKNOWN,
|
||||
MENU_SETTINGS_INPUT_DESC_KBD_BEGIN + retro_id, 0, 0);
|
||||
(MENU_SETTINGS_INPUT_DESC_KBD_BEGIN + retro_id) * (i + 1), 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ enum menu_settings_type
|
||||
MENU_SETTINGS_INPUT_DESC_BEGIN,
|
||||
MENU_SETTINGS_INPUT_DESC_END = MENU_SETTINGS_INPUT_DESC_BEGIN + (MAX_USERS * (RARCH_FIRST_CUSTOM_BIND + 4)),
|
||||
MENU_SETTINGS_INPUT_DESC_KBD_BEGIN,
|
||||
MENU_SETTINGS_INPUT_DESC_KBD_END = MENU_SETTINGS_INPUT_DESC_KBD_BEGIN + 135,
|
||||
MENU_SETTINGS_INPUT_DESC_KBD_END = (MENU_SETTINGS_INPUT_DESC_KBD_BEGIN + 135) * MAX_USERS,
|
||||
|
||||
MENU_SETTINGS_SUBSYSTEM_LOAD,
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user