Fix analog triggers (#12151)

* Restore RETRO_DEVICE_ANALOG code while making less changes

* * When input_remap_binds_enable is true, input_driver_mapper is always
allocated and initialized - no need to NULL check
* Get rid of input_remote local variable for network gamepad code
This commit is contained in:
Autechre 2021-03-15 01:32:56 +01:00 committed by GitHub
parent 60d29d3792
commit a4836bbb17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22876,49 +22876,62 @@ static int16_t input_state_device(
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:
{ {
#if defined(HAVE_NETWORKGAMEPAD) || defined(HAVE_OVERLAY) #if defined(HAVE_NETWORKGAMEPAD) || defined(HAVE_OVERLAY)
#if defined(HAVE_NETWORKGAMEPAD) #ifdef HAVE_NETWORKGAMEPAD
input_remote_state_t *input_state = &p_rarch->remote_st_ptr; input_remote_state_t
*input_state = &p_rarch->remote_st_ptr;
#endif #endif
unsigned base = (idx == RETRO_DEVICE_INDEX_ANALOG_RIGHT) ? 2 : 0; unsigned base = (idx == RETRO_DEVICE_INDEX_ANALOG_RIGHT)
? 2 : 0;
if (id == RETRO_DEVICE_ID_ANALOG_Y) if (id == RETRO_DEVICE_ID_ANALOG_Y)
base += 1; base += 1;
#ifdef HAVE_NETWORKGAMEPAD #ifdef HAVE_NETWORKGAMEPAD
/* Don't process binds if input is coming from Remote RetroPad */ if (p_rarch->input_driver_remote
if (p_rarch->input_driver_remote && input_state && input_state && input_state->analog[base][port])
&& input_state->analog[base][port])
res = input_state->analog[base][port]; res = input_state->analog[base][port];
else else
#endif #endif
#endif #endif
{ {
if (input_remap_binds_enable) if (id < RARCH_FIRST_META_KEY)
{ {
bool bind_valid = p_rarch->libretro_input_binds[port] bool bind_valid = p_rarch->libretro_input_binds[port]
&& p_rarch->libretro_input_binds[port][id].valid; && p_rarch->libretro_input_binds[port][id].valid;
if (id < RARCH_FIRST_META_KEY && bind_valid)
if (bind_valid)
{
/* reset_state - used to reset input state of a button
* when the gamepad mapper is in action for that button*/
bool reset_state = false;
if (input_remap_binds_enable)
{ {
if (idx < 2 && id < 2) if (idx < 2 && id < 2)
{ {
unsigned offset = RARCH_FIRST_CUSTOM_BIND + unsigned offset = RARCH_FIRST_CUSTOM_BIND +
(idx * 4) + (id * 2); (idx * 4) + (id * 2);
if ( settings->uints.input_remap_ids if (settings->uints.input_remap_ids
[port][offset] == offset [port][offset] != offset)
|| settings->uints.input_remap_ids reset_state = true;
[port][offset+1] == (offset+1) else if (settings->uints.input_remap_ids
) [port][offset+1] != (offset+1))
reset_state = true;
}
}
if (reset_state)
res = 0;
else
{ {
res = ret; res = ret;
#ifdef HAVE_OVERLAY #ifdef HAVE_OVERLAY
if (port == 0) if ( p_rarch->overlay_ptr &&
p_rarch->overlay_ptr->alive && port == 0)
{ {
input_overlay_state_t *ol_state = input_overlay_state_t *ol_state =
&p_rarch->overlay_ptr->overlay_state; &p_rarch->overlay_ptr->overlay_state;
if ( if (ol_state->analog[base])
p_rarch->overlay_ptr
&& p_rarch->overlay_ptr->alive
&& ol_state
&& ol_state->analog[base])
res |= ol_state->analog[base]; res |= ol_state->analog[base];
} }
#endif #endif
@ -22926,9 +22939,8 @@ static int16_t input_state_device(
} }
} }
} }
}
if (p_rarch->input_driver_mapper) if (input_remap_binds_enable)
{ {
if (idx < 2 && id < 2) if (idx < 2 && id < 2)
{ {