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,26 +22876,34 @@ static int16_t input_state_device(
case RETRO_DEVICE_ANALOG:
{
#if defined(HAVE_NETWORKGAMEPAD) || defined(HAVE_OVERLAY)
#if defined(HAVE_NETWORKGAMEPAD)
input_remote_state_t *input_state = &p_rarch->remote_st_ptr;
#ifdef HAVE_NETWORKGAMEPAD
input_remote_state_t
*input_state = &p_rarch->remote_st_ptr;
#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)
base += 1;
#ifdef HAVE_NETWORKGAMEPAD
/* Don't process binds if input is coming from Remote RetroPad */
if (p_rarch->input_driver_remote && input_state
&& input_state->analog[base][port])
if (p_rarch->input_driver_remote
&& input_state && input_state->analog[base][port])
res = input_state->analog[base][port];
else
#endif
#endif
{
if (input_remap_binds_enable)
if (id < RARCH_FIRST_META_KEY)
{
bool bind_valid = p_rarch->libretro_input_binds[port]
&& 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)
{
@ -22903,22 +22911,27 @@ static int16_t input_state_device(
(idx * 4) + (id * 2);
if (settings->uints.input_remap_ids
[port][offset] == offset
|| settings->uints.input_remap_ids
[port][offset+1] == (offset+1)
)
[port][offset] != offset)
reset_state = true;
else if (settings->uints.input_remap_ids
[port][offset+1] != (offset+1))
reset_state = true;
}
}
if (reset_state)
res = 0;
else
{
res = ret;
#ifdef HAVE_OVERLAY
if (port == 0)
if ( p_rarch->overlay_ptr &&
p_rarch->overlay_ptr->alive && port == 0)
{
input_overlay_state_t *ol_state =
&p_rarch->overlay_ptr->overlay_state;
if (
p_rarch->overlay_ptr
&& p_rarch->overlay_ptr->alive
&& ol_state
&& ol_state->analog[base])
if (ol_state->analog[base])
res |= ol_state->analog[base];
}
#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)
{