mirror of
https://github.com/libretro/RetroArch
synced 2025-03-01 07:13:35 +00:00
Simplify input_mapper_state
This commit is contained in:
parent
24b694d674
commit
9bcaac1abc
@ -83,21 +83,16 @@ bool input_mapper_button_pressed(input_mapper_t *handle, unsigned port, unsigned
|
|||||||
|
|
||||||
void input_mapper_poll(input_mapper_t *handle)
|
void input_mapper_poll(input_mapper_t *handle)
|
||||||
{
|
{
|
||||||
int i, j, k;
|
int i, j;
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
input_bits_t current_input;
|
input_bits_t current_input;
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
unsigned max_users = *(input_driver_get_uint(INPUT_ACTION_MAX_USERS));
|
unsigned max_users = *(input_driver_get_uint(INPUT_ACTION_MAX_USERS));
|
||||||
unsigned device = 0;
|
unsigned device = 0;
|
||||||
unsigned current_button_value;
|
|
||||||
int16_t current_axis_value;
|
int16_t current_axis_value;
|
||||||
unsigned remap_button, remap_axis;
|
|
||||||
bool key_event[RARCH_CUSTOM_BIND_LIST_END];
|
bool key_event[RARCH_CUSTOM_BIND_LIST_END];
|
||||||
#ifdef HAVE_MENU
|
|
||||||
bool menu_is_alive = menu_driver_is_alive();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_MENU
|
#ifdef HAVE_MENU
|
||||||
if (menu_is_alive)
|
if (menu_driver_is_alive())
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -114,9 +109,9 @@ void input_mapper_poll(input_mapper_t *handle)
|
|||||||
input_get_state_for_port(settings, i, ¤t_input);
|
input_get_state_for_port(settings, i, ¤t_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);
|
||||||
current_button_value = BIT256_GET(current_input, j);
|
unsigned remap_button = settings->uints.input_keymapper_ids[i][j];
|
||||||
remap_button = settings->uints.input_keymapper_ids[i][j];
|
|
||||||
if (current_button_value == 1 && j != remap_button &&
|
if (current_button_value == 1 && j != remap_button &&
|
||||||
remap_button != RETROK_UNKNOWN)
|
remap_button != RETROK_UNKNOWN)
|
||||||
{
|
{
|
||||||
@ -139,7 +134,6 @@ void input_mapper_poll(input_mapper_t *handle)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* gamepad remapping */
|
/* gamepad remapping */
|
||||||
if (device == RETRO_DEVICE_JOYPAD || device == RETRO_DEVICE_ANALOG)
|
if (device == RETRO_DEVICE_JOYPAD || device == RETRO_DEVICE_ANALOG)
|
||||||
@ -155,8 +149,9 @@ void input_mapper_poll(input_mapper_t *handle)
|
|||||||
|
|
||||||
for (j = 0; j < RARCH_FIRST_CUSTOM_BIND; j++)
|
for (j = 0; j < RARCH_FIRST_CUSTOM_BIND; j++)
|
||||||
{
|
{
|
||||||
current_button_value = BIT256_GET(current_input, j);
|
unsigned current_button_value = BIT256_GET(current_input, j);
|
||||||
remap_button = settings->uints.input_remap_ids[i][j];
|
unsigned remap_button = settings->uints.input_remap_ids[i][j];
|
||||||
|
|
||||||
if (current_button_value == 1 && j != remap_button &&
|
if (current_button_value == 1 && j != remap_button &&
|
||||||
remap_button != RARCH_UNMAPPED && remap_button < RARCH_FIRST_CUSTOM_BIND)
|
remap_button != RARCH_UNMAPPED && remap_button < RARCH_FIRST_CUSTOM_BIND)
|
||||||
BIT256_SET(handle->buttons[i], remap_button);
|
BIT256_SET(handle->buttons[i], remap_button);
|
||||||
@ -176,8 +171,8 @@ void input_mapper_poll(input_mapper_t *handle)
|
|||||||
|
|
||||||
for (j = 0; j < 8; j++)
|
for (j = 0; j < 8; j++)
|
||||||
{
|
{
|
||||||
k = j + RARCH_FIRST_CUSTOM_BIND;
|
unsigned remap_axis;
|
||||||
|
unsigned k = j + RARCH_FIRST_CUSTOM_BIND;
|
||||||
current_axis_value = current_input.analogs[j];
|
current_axis_value = current_input.analogs[j];
|
||||||
remap_axis = settings->uints.input_remap_ids[i][k];
|
remap_axis = settings->uints.input_remap_ids[i][k];
|
||||||
|
|
||||||
@ -225,63 +220,20 @@ void input_mapper_state(
|
|||||||
*ret = 1;
|
*ret = 1;
|
||||||
break;
|
break;
|
||||||
case RETRO_DEVICE_ANALOG:
|
case RETRO_DEVICE_ANALOG:
|
||||||
|
if (idx < 2 && id < 2)
|
||||||
{
|
{
|
||||||
int val = 0;
|
int val = 0;
|
||||||
if (idx == 0)
|
unsigned offset = 0 + (idx * 4) + (id * 2);
|
||||||
{
|
|
||||||
if (id == 0)
|
|
||||||
{
|
|
||||||
if (handle->analog_value[port][0])
|
|
||||||
val = handle->analog_value[port][0];
|
|
||||||
else if (handle->analog_value[port][1])
|
|
||||||
val = handle->analog_value[port][1];
|
|
||||||
|
|
||||||
if(handle->analog_value[port][0] || handle->analog_value[port][1])
|
if (handle->analog_value[port][offset])
|
||||||
{
|
val = handle->analog_value[port][offset];
|
||||||
*ret |= val;
|
else if (handle->analog_value[port][offset+1])
|
||||||
}
|
val = handle->analog_value[port][offset+1];
|
||||||
}
|
|
||||||
if (id == 1)
|
|
||||||
{
|
|
||||||
if (handle->analog_value[port][2])
|
|
||||||
val = handle->analog_value[port][2];
|
|
||||||
else if (handle->analog_value[port][3])
|
|
||||||
val = handle->analog_value[port][3];
|
|
||||||
|
|
||||||
if(handle->analog_value[port][2] || handle->analog_value[port][3])
|
if ( handle->analog_value[port][offset] ||
|
||||||
{
|
handle->analog_value[port][offset+1])
|
||||||
*ret |= val;
|
*ret |= val;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
if (idx == 1)
|
|
||||||
{
|
|
||||||
if (id == 0)
|
|
||||||
{
|
|
||||||
if (handle->analog_value[port][4])
|
|
||||||
val = handle->analog_value[port][4];
|
|
||||||
else if (handle->analog_value[port][5])
|
|
||||||
val = handle->analog_value[port][5];
|
|
||||||
|
|
||||||
if(handle->analog_value[port][4] || handle->analog_value[port][5])
|
|
||||||
{
|
|
||||||
*ret |= val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (id == 1)
|
|
||||||
{
|
|
||||||
if (handle->analog_value[port][6])
|
|
||||||
val = handle->analog_value[port][6];
|
|
||||||
else if (handle->analog_value[port][7])
|
|
||||||
val = handle->analog_value[port][7];
|
|
||||||
|
|
||||||
if(handle->analog_value[port][6] || handle->analog_value[port][7])
|
|
||||||
{
|
|
||||||
*ret |= val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case RETRO_DEVICE_KEYBOARD:
|
case RETRO_DEVICE_KEYBOARD:
|
||||||
if (id < RETROK_LAST)
|
if (id < RETROK_LAST)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user