mirror of
https://github.com/libretro/RetroArch
synced 2025-03-23 10:20:57 +00:00
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:
parent
60d29d3792
commit
a4836bbb17
92
retroarch.c
92
retroarch.c
@ -22876,65 +22876,77 @@ 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)
|
|
||||||
input_remote_state_t *input_state = &p_rarch->remote_st_ptr;
|
|
||||||
#endif
|
|
||||||
unsigned base = (idx == RETRO_DEVICE_INDEX_ANALOG_RIGHT) ? 2 : 0;
|
|
||||||
if (id == RETRO_DEVICE_ID_ANALOG_Y)
|
|
||||||
base += 1;
|
|
||||||
#ifdef HAVE_NETWORKGAMEPAD
|
#ifdef HAVE_NETWORKGAMEPAD
|
||||||
/* Don't process binds if input is coming from Remote RetroPad */
|
input_remote_state_t
|
||||||
if (p_rarch->input_driver_remote && input_state
|
*input_state = &p_rarch->remote_st_ptr;
|
||||||
&& input_state->analog[base][port])
|
|
||||||
res = input_state->analog[base][port];
|
#endif
|
||||||
|
unsigned base = (idx == RETRO_DEVICE_INDEX_ANALOG_RIGHT)
|
||||||
|
? 2 : 0;
|
||||||
|
if (id == RETRO_DEVICE_ID_ANALOG_Y)
|
||||||
|
base += 1;
|
||||||
|
#ifdef HAVE_NETWORKGAMEPAD
|
||||||
|
if (p_rarch->input_driver_remote
|
||||||
|
&& input_state && 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 (idx < 2 && id < 2)
|
|
||||||
{
|
|
||||||
unsigned offset = RARCH_FIRST_CUSTOM_BIND +
|
|
||||||
(idx * 4) + (id * 2);
|
|
||||||
|
|
||||||
if ( settings->uints.input_remap_ids
|
if (bind_valid)
|
||||||
[port][offset] == offset
|
{
|
||||||
|| settings->uints.input_remap_ids
|
/* reset_state - used to reset input state of a button
|
||||||
[port][offset+1] == (offset+1)
|
* when the gamepad mapper is in action for that button*/
|
||||||
)
|
bool reset_state = false;
|
||||||
|
if (input_remap_binds_enable)
|
||||||
|
{
|
||||||
|
if (idx < 2 && id < 2)
|
||||||
{
|
{
|
||||||
res = ret;
|
unsigned offset = RARCH_FIRST_CUSTOM_BIND +
|
||||||
#ifdef HAVE_OVERLAY
|
(idx * 4) + (id * 2);
|
||||||
if (port == 0)
|
|
||||||
{
|
if (settings->uints.input_remap_ids
|
||||||
input_overlay_state_t *ol_state =
|
[port][offset] != offset)
|
||||||
&p_rarch->overlay_ptr->overlay_state;
|
reset_state = true;
|
||||||
if (
|
else if (settings->uints.input_remap_ids
|
||||||
p_rarch->overlay_ptr
|
[port][offset+1] != (offset+1))
|
||||||
&& p_rarch->overlay_ptr->alive
|
reset_state = true;
|
||||||
&& ol_state
|
|
||||||
&& ol_state->analog[base])
|
|
||||||
res |= ol_state->analog[base];
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (reset_state)
|
||||||
|
res = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
res = ret;
|
||||||
|
|
||||||
|
#ifdef HAVE_OVERLAY
|
||||||
|
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 (ol_state->analog[base])
|
||||||
|
res |= ol_state->analog[base];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_rarch->input_driver_mapper)
|
if (input_remap_binds_enable)
|
||||||
{
|
{
|
||||||
if (idx < 2 && id < 2)
|
if (idx < 2 && id < 2)
|
||||||
{
|
{
|
||||||
unsigned offset = 0 + (idx * 4) + (id * 2);
|
unsigned offset = 0 + (idx * 4) + (id * 2);
|
||||||
int val1 = p_rarch->input_driver_mapper->analog_value[port][offset];
|
int val1 = p_rarch->input_driver_mapper->analog_value[port][offset];
|
||||||
int val2 = p_rarch->input_driver_mapper->analog_value[port][offset+1];
|
int val2 = p_rarch->input_driver_mapper->analog_value[port][offset+1];
|
||||||
|
|
||||||
if (val1)
|
if (val1)
|
||||||
res |= val1;
|
res |= val1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user