mirror of
https://github.com/libretro/RetroArch.git
synced 2024-12-01 04:00:32 +00:00
(linuxraw) linuxraw_analog_pressed - reimplement to avoid LGTM warnings
This commit is contained in:
parent
986c1bb235
commit
26788850ae
@ -78,20 +78,31 @@ static void *linuxraw_input_init(const char *joypad_driver)
|
||||
static int16_t linuxraw_analog_pressed(linuxraw_input_t *linuxraw,
|
||||
const struct retro_keybind *binds, unsigned idx, unsigned id)
|
||||
{
|
||||
const struct retro_keybind *bind_minus, *bind_plus;
|
||||
int16_t pressed_minus = 0, pressed_plus = 0;
|
||||
unsigned id_minus = 0;
|
||||
unsigned id_plus = 0;
|
||||
|
||||
input_conv_analog_id_to_bind_id(idx, id, id_minus, id_plus);
|
||||
|
||||
if ((id_minus < RARCH_BIND_LIST_END) && binds->valid &&
|
||||
linuxraw->state[rarch_keysym_lut[(enum retro_key)binds[id_minus].key]]
|
||||
)
|
||||
pressed_minus = -0x7fff;
|
||||
if ((id_plus < RARCH_BIND_LIST_END) && binds->valid &&
|
||||
linuxraw->state[rarch_keysym_lut[(enum retro_key)binds[id_plus].key]]
|
||||
)
|
||||
pressed_plus = 0x7fff;
|
||||
bind_minus = &binds[id_minus];
|
||||
bind_plus = &binds[id_plus];
|
||||
|
||||
if (!bind_minus->valid || !bind_plus->valid)
|
||||
return 0;
|
||||
|
||||
if (bind_minus->key < RETROK_LAST)
|
||||
{
|
||||
unsigned sym = rarch_keysym_lut[(enum retro_key)bind_minus->key];
|
||||
if (linuxraw->state[sym] & 0x80)
|
||||
pressed_minus = -0x7fff;
|
||||
}
|
||||
if (bind_plus->key < RETROK_LAST)
|
||||
{
|
||||
unsigned sym = rarch_keysym_lut[(enum retro_key)bind_minus->key];
|
||||
if (linuxraw->state[sym] & 0x80)
|
||||
pressed_plus = 0x7fff;
|
||||
}
|
||||
|
||||
return pressed_plus + pressed_minus;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user