Refactor some of the input_state_device code - some very messy code in

here
This commit is contained in:
twinaphex 2021-03-06 18:14:06 +01:00
parent f50906787f
commit fc65a939b7
1 changed files with 30 additions and 32 deletions

View File

@ -22541,37 +22541,36 @@ static int16_t input_state_device(
#endif #endif
) )
{ {
bool bind_valid = p_rarch->libretro_input_binds[port]
&& p_rarch->libretro_input_binds[port][id].valid;
if (input_remap_binds_enable && if (input_remap_binds_enable &&
id != settings->uints.input_remap_ids[port][id]) id != settings->uints.input_remap_ids[port][id])
res = 0; res = 0;
else if (bind_valid) else
{ {
if (button_mask) bool bind_valid = p_rarch->libretro_input_binds[port]
&& p_rarch->libretro_input_binds[port][id].valid;
if (bind_valid)
{ {
res = 0; if (button_mask)
if (ret & (1 << id)) {
res |= (1 << id); res = 0;
} if (ret & (1 << id))
else res |= (1 << id);
res = ret; }
else
res = ret;
#ifdef HAVE_OVERLAY #ifdef HAVE_OVERLAY
{
int16_t res_overlay = 0;
if ( p_rarch->overlay_ptr if ( p_rarch->overlay_ptr
&& p_rarch->overlay_ptr->alive
&& port == 0 && port == 0
&& p_rarch->overlay_ptr->alive) )
{ {
if ((BIT256_GET(p_rarch->overlay_ptr->overlay_state.buttons, id))) if ((BIT256_GET(p_rarch->overlay_ptr->overlay_state.buttons, id)))
res_overlay |= 1; res |= 1;
if (p_rarch->overlay_ptr->alive)
res |= res_overlay;
} }
}
#endif #endif
}
} }
} }
@ -22711,26 +22710,25 @@ static int16_t input_state_device(
res = ret; res = ret;
#ifdef HAVE_OVERLAY if (id < RETROK_LAST)
if (p_rarch->overlay_ptr && port == 0)
{ {
int16_t res_overlay = 0; #ifdef HAVE_OVERLAY
if (id < RETROK_LAST) if (p_rarch->overlay_ptr)
{ {
input_overlay_state_t *ol_state = &p_rarch->overlay_ptr->overlay_state; if (port == 0 && p_rarch->overlay_ptr->alive)
if (OVERLAY_GET_KEY(ol_state, id)) {
res_overlay |= 1; input_overlay_state_t
*ol_state = &p_rarch->overlay_ptr->overlay_state;
if (OVERLAY_GET_KEY(ol_state, id))
res |= 1;
}
} }
if (p_rarch->overlay_ptr->alive)
res |= res_overlay;
}
#endif #endif
if (input_remap_binds_enable && p_rarch->input_driver_mapper)
if (input_remap_binds_enable && p_rarch->input_driver_mapper)
if (id < RETROK_LAST)
if (MAPPER_GET_KEY(p_rarch->input_driver_mapper, id)) if (MAPPER_GET_KEY(p_rarch->input_driver_mapper, id))
res |= 1; res |= 1;
}
break; break;