Simplify overlay analogs handling.
This commit is contained in:
parent
04017b7fd7
commit
f61f42c68f
11
retroarch.c
11
retroarch.c
|
@ -636,15 +636,8 @@ static int16_t input_state(unsigned port, unsigned device, unsigned index, unsig
|
||||||
{
|
{
|
||||||
unsigned base = (index == RETRO_DEVICE_INDEX_ANALOG_RIGHT) ? 2 : 0;
|
unsigned base = (index == RETRO_DEVICE_INDEX_ANALOG_RIGHT) ? 2 : 0;
|
||||||
base += (id == RETRO_DEVICE_ID_ANALOG_Y) ? 1 : 0;
|
base += (id == RETRO_DEVICE_ID_ANALOG_Y) ? 1 : 0;
|
||||||
|
if (driver.overlay_state.analog[base])
|
||||||
// Simply adding here could overflow the int16_t.
|
res = driver.overlay_state.analog[base];
|
||||||
int sum = res + driver.overlay_state.analog[base];
|
|
||||||
if (sum > 0x7fff)
|
|
||||||
res = 0x7fff;
|
|
||||||
else if (sum < -0x7fff)
|
|
||||||
res = -0x7fff;
|
|
||||||
else
|
|
||||||
res = sum;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue