From 8349ade07682a4ddebe3cb4fbb30a110ba92869c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 25 Oct 2014 10:06:40 +0200 Subject: [PATCH] Refactor input_joypad_pressed somewhat --- input/input_common.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/input/input_common.c b/input/input_common.c index e19c759ec0..8aab4c7a5b 100644 --- a/input/input_common.c +++ b/input/input_common.c @@ -154,12 +154,12 @@ bool input_joypad_set_rumble(const rarch_joypad_driver_t *drv, return drv->set_rumble(joy_idx, effect, strength); } -bool input_joypad_pressed(const rarch_joypad_driver_t *drv, - unsigned port, const struct retro_keybind *binds, unsigned key) +static bool input_joypad_is_pressed( + 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]; if (joy_idx >= MAX_PLAYERS) return false; @@ -168,9 +168,6 @@ bool input_joypad_pressed(const rarch_joypad_driver_t *drv, const struct retro_keybind *auto_binds = g_settings.input.autoconf_binds[joy_idx]; - if (!binds[key].valid) - return false; - uint64_t joykey = binds[key].joykey; if (joykey == NO_BTN) 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; } +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, unsigned port, unsigned idx, unsigned ident, const struct retro_keybind *binds)