Refactor/reimplement mapper

This commit is contained in:
twinaphex 2019-08-09 16:17:30 +02:00
parent 05187f1a8c
commit a643f9e07e
3 changed files with 23 additions and 13 deletions

View File

@ -45,6 +45,7 @@
void input_mapper_poll(input_mapper_t *handle,
void *ol_pointer,
void *settings_data,
void *input_data,
unsigned max_users,
bool poll_overlay)
{
@ -53,26 +54,15 @@ void input_mapper_poll(input_mapper_t *handle,
input_overlay_t *overlay_pointer = (input_overlay_t*)ol_pointer;
#endif
settings_t *settings = (settings_t*)settings_data;
input_bits_t *current_inputs = (input_bits_t*)input_data;
memset(handle->keys, 0, sizeof(handle->keys));
for (i = 0; i < max_users; i++)
{
input_bits_t current_input;
unsigned device = settings->uints.input_libretro_device[i]
& RETRO_DEVICE_MASK;
switch (device)
{
case RETRO_DEVICE_KEYBOARD:
case RETRO_DEVICE_JOYPAD:
case RETRO_DEVICE_ANALOG:
BIT256_CLEAR_ALL_PTR(&current_input);
input_get_state_for_port(settings, i, &current_input);
break;
default:
break;
}
input_bits_t current_input = *current_inputs++;
switch (device)
{

View File

@ -45,6 +45,7 @@ typedef struct input_mapper
void input_mapper_poll(input_mapper_t *handle,
void *overlay_pointer,
void *settings_data,
void *data,
unsigned max_users,
bool poll_overlay);

View File

@ -10649,6 +10649,7 @@ static void input_driver_poll(void)
size_t i;
settings_t *settings = configuration_settings;
uint8_t max_users = (uint8_t)input_driver_max_users;
input_bits_t current_inputs[MAX_USERS];
current_input->poll(current_input_data);
@ -10690,6 +10691,23 @@ static void input_driver_poll(void)
#endif
if (settings->bools.input_remap_binds_enable && input_driver_mapper)
{
for (i = 0; i < max_users; i++)
{
unsigned device = settings->uints.input_libretro_device[i] & RETRO_DEVICE_MASK;
switch (device)
{
case RETRO_DEVICE_KEYBOARD:
case RETRO_DEVICE_JOYPAD:
case RETRO_DEVICE_ANALOG:
BIT256_CLEAR_ALL_PTR(&current_inputs[i]);
input_get_state_for_port(settings, i, &current_inputs[i]);
break;
default:
break;
}
}
input_mapper_poll(input_driver_mapper,
#ifdef HAVE_OVERLAY
overlay_ptr,
@ -10697,6 +10715,7 @@ static void input_driver_poll(void)
NULL,
#endif
settings,
&current_inputs,
max_users,
#ifdef HAVE_OVERLAY
(overlay_ptr && overlay_ptr->alive)