(input_mapper.c) Some more refactors

This commit is contained in:
twinaphex 2018-04-08 23:08:21 +02:00
parent 4052ffe08e
commit bc70477005
1 changed files with 30 additions and 37 deletions

View File

@ -108,28 +108,24 @@ void input_mapper_poll(input_mapper_t *handle)
input_get_state_for_port(settings, i, &current_input); input_get_state_for_port(settings, i, &current_input);
for (j = 0; j < RARCH_CUSTOM_BIND_LIST_END; j++) for (j = 0; j < RARCH_CUSTOM_BIND_LIST_END; j++)
{ {
unsigned current_button_value = BIT256_GET(current_input, j);
unsigned remap_button = unsigned remap_button =
settings->uints.input_keymapper_ids[i][j]; settings->uints.input_keymapper_ids[i][j];
bool remap_valid = remap_button != RETROK_UNKNOWN;
if ( if (remap_valid)
(current_button_value == 1) &&
(j != remap_button) &&
(remap_button != RETROK_UNKNOWN)
)
{ {
MAPPER_SET_KEY (handle, unsigned current_button_value = BIT256_GET(current_input, j);
remap_button);
input_keyboard_event(true, if ((current_button_value == 1) && (j != remap_button))
remap_button, {
0, 0, RETRO_DEVICE_KEYBOARD); MAPPER_SET_KEY (handle,
key_event[j] = true; remap_button);
} input_keyboard_event(true,
else remap_button,
{ 0, 0, RETRO_DEVICE_KEYBOARD);
if ( (key_event[j] == false) && key_event[j] = true;
(remap_button != RETROK_UNKNOWN) }
) else if (!key_event[j])
{ {
input_keyboard_event(false, input_keyboard_event(false,
remap_button, remap_button,
@ -159,29 +155,26 @@ void input_mapper_poll(input_mapper_t *handle)
unsigned current_button_value = BIT256_GET(current_input, j); unsigned current_button_value = BIT256_GET(current_input, j);
unsigned remap_button = unsigned remap_button =
settings->uints.input_remap_ids[i][j]; settings->uints.input_remap_ids[i][j];
bool remap_valid = (current_button_value == 1) &&
(j != remap_button) && (remap_button != RARCH_UNMAPPED);
if ( if (remap_valid)
(current_button_value == 1) &&
(j != remap_button) &&
(remap_button != RARCH_UNMAPPED) &&
(remap_button < RARCH_FIRST_CUSTOM_BIND)
)
BIT256_SET(handle->buttons[i], remap_button);
else if (
(current_button_value == 1) &&
(j != remap_button) &&
(remap_button != RARCH_UNMAPPED) &&
(remap_button >= RARCH_FIRST_CUSTOM_BIND)
)
{ {
int invert = 1; if (remap_button < RARCH_FIRST_CUSTOM_BIND)
{
BIT256_SET(handle->buttons[i], remap_button);
}
else if (remap_button >= RARCH_FIRST_CUSTOM_BIND)
{
int invert = 1;
if (remap_button % 2 != 0) if (remap_button % 2 != 0)
invert = -1; invert = -1;
handle->analog_value[i][ handle->analog_value[i][
remap_button - RARCH_FIRST_CUSTOM_BIND] = remap_button - RARCH_FIRST_CUSTOM_BIND] =
32767 * invert; 32767 * invert;
}
} }
} }