mirror of
https://github.com/libretro/RetroArch
synced 2025-04-01 04:20:27 +00:00
Refactor input_joypad_pressed somewhat
This commit is contained in:
parent
ec9f6272ca
commit
8349ade076
@ -154,12 +154,12 @@ bool input_joypad_set_rumble(const rarch_joypad_driver_t *drv,
|
|||||||
return drv->set_rumble(joy_idx, effect, strength);
|
return drv->set_rumble(joy_idx, effect, strength);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool input_joypad_pressed(const rarch_joypad_driver_t *drv,
|
static bool input_joypad_is_pressed(
|
||||||
unsigned port, const struct retro_keybind *binds, unsigned key)
|
const rarch_joypad_driver_t *drv,
|
||||||
|
unsigned port,
|
||||||
|
const struct retro_keybind *binds,
|
||||||
|
unsigned key)
|
||||||
{
|
{
|
||||||
if (!drv)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
unsigned int joy_idx = g_settings.input.joypad_map[port];
|
unsigned int joy_idx = g_settings.input.joypad_map[port];
|
||||||
if (joy_idx >= MAX_PLAYERS)
|
if (joy_idx >= MAX_PLAYERS)
|
||||||
return false;
|
return false;
|
||||||
@ -168,9 +168,6 @@ bool input_joypad_pressed(const rarch_joypad_driver_t *drv,
|
|||||||
const struct retro_keybind *auto_binds =
|
const struct retro_keybind *auto_binds =
|
||||||
g_settings.input.autoconf_binds[joy_idx];
|
g_settings.input.autoconf_binds[joy_idx];
|
||||||
|
|
||||||
if (!binds[key].valid)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
uint64_t joykey = binds[key].joykey;
|
uint64_t joykey = binds[key].joykey;
|
||||||
if (joykey == NO_BTN)
|
if (joykey == NO_BTN)
|
||||||
joykey = auto_binds[key].joykey;
|
joykey = auto_binds[key].joykey;
|
||||||
@ -187,6 +184,22 @@ bool input_joypad_pressed(const rarch_joypad_driver_t *drv,
|
|||||||
return scaled_axis > g_settings.input.axis_threshold;
|
return scaled_axis > g_settings.input.axis_threshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool input_joypad_pressed(const rarch_joypad_driver_t *drv,
|
||||||
|
unsigned port, const struct retro_keybind *binds, unsigned key)
|
||||||
|
{
|
||||||
|
if (!drv)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
if (!binds[key].valid)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (input_joypad_is_pressed(drv, port, binds, key))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int16_t input_joypad_analog(const rarch_joypad_driver_t *drv,
|
int16_t input_joypad_analog(const rarch_joypad_driver_t *drv,
|
||||||
unsigned port, unsigned idx, unsigned ident,
|
unsigned port, unsigned idx, unsigned ident,
|
||||||
const struct retro_keybind *binds)
|
const struct retro_keybind *binds)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user