remap-redux part2: after 60 attempsts, new mapper works, N:1 mapping too

This commit is contained in:
radius 2018-04-02 00:08:40 -05:00
parent 7f5fe5ebff
commit be2c648596
3 changed files with 22 additions and 25 deletions

View file

@ -579,6 +579,8 @@ void input_poll(void)
if (input_driver_block_libretro_input)
return;
for (i = 0; i < max_users; i++)
{
if (libretro_input_binds[i][RARCH_TURBO_ENABLE].valid)
@ -603,6 +605,11 @@ void input_poll(void)
input_driver_axis_threshold);
#endif
#ifdef HAVE_KEYMAPPER
if (input_driver_mapper)
input_mapper_poll(input_driver_mapper);
#endif
#ifdef HAVE_COMMAND
if (input_driver_command)
command_poll(input_driver_command);
@ -612,11 +619,6 @@ void input_poll(void)
if (input_driver_remote)
input_remote_poll(input_driver_remote, max_users);
#endif
#ifdef HAVE_KEYMAPPER
if (input_driver_mapper)
input_mapper_poll(input_driver_mapper);
#endif
}
/**
@ -659,9 +661,7 @@ int16_t input_state(unsigned port, unsigned device,
{
case RETRO_DEVICE_JOYPAD:
if (id != settings->uints.input_remap_ids[port][id])
{
clear = true;
}
break;
case RETRO_DEVICE_ANALOG:
@ -687,8 +687,11 @@ int16_t input_state(unsigned port, unsigned device,
joypad_info.joy_idx = settings->uints.input_joypad_map[port];
joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx];
res = current_input->input_state(
current_input_data, joypad_info, libretro_input_binds, port, device, idx, id);
if (!clear)
res = current_input->input_state(
current_input_data, joypad_info, libretro_input_binds, port, device, idx, id);
else
res = 0;
}
}

View file

@ -58,7 +58,7 @@ struct input_mapper
/* the whole keyboard state */
uint32_t keys[RETROK_LAST / 32 + 1];
/* This is a bitmask of (1 << key_bind_id). */
uint64_t buttons;
retro_bits_t buttons;
};
input_mapper_t *input_mapper_new(uint16_t port)
@ -85,7 +85,7 @@ bool flag = false;
bool input_mapper_button_pressed(input_mapper_t *handle, int id)
{
return (handle->buttons >> id) & 1U;
return BIT256_GET(handle->buttons, id);
}
void input_mapper_poll(input_mapper_t *handle)
@ -141,23 +141,17 @@ void input_mapper_poll(input_mapper_t *handle)
}
if (device == RETRO_DEVICE_JOYPAD)
{
retro_bits_t current_input;
input_keys_pressed(settings, &current_input);
BIT256_CLEAR_ALL(handle->buttons);
for (i = 0; i < MAX_USERS; i++)
{
for (j = 0; j < RARCH_CUSTOM_BIND_LIST_END; j++)
{
if(input_state(i, RETRO_DEVICE_JOYPAD, i, j))
{
if (j != settings->uints.input_remap_ids[i][j])
{
RARCH_LOG("remapped button pressed: old:%d new: %d\n", j, settings->uints.input_remap_ids[i][j]);
handle->buttons |= 1 << settings->uints.input_remap_ids[i][j];
}
}
if(!input_state(i, RETRO_DEVICE_JOYPAD, i, j))
{
if (j != settings->uints.input_remap_ids[i][j])
handle->buttons &= ~(1 << settings->uints.input_remap_ids[i][j]);
}
int aux = BIT256_GET(current_input, j);
int remap = settings->uints.input_remap_ids[i][j];
if (aux == 1 && j != remap)
BIT256_SET(handle->buttons, remap);
}
}
}

View file

@ -557,7 +557,7 @@ static void menu_action_setting_disp_set_label_input_desc(
unsigned remap_id = 0;
if (!settings)
return 0;
return;
offset = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) / (RARCH_FIRST_CUSTOM_BIND + 8);