From efdfb29d50ebba6b56a3a2a5bda7f22b9d4f2c93 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Jun 2017 08:12:53 +0200 Subject: [PATCH] Turn input_joypad_is_pressed into static inline function --- input/input_driver.c | 36 ------------------------------------ input/input_driver.h | 20 ++++++++++++++++++-- 2 files changed, 18 insertions(+), 38 deletions(-) diff --git a/input/input_driver.c b/input/input_driver.c index b62285fbbf..d302e88cf5 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -1370,42 +1370,6 @@ bool input_joypad_set_rumble(const input_device_driver_t *drv, return drv->set_rumble(joy_idx, effect, strength); } -/** - * input_joypad_is_pressed: - * @drv : Input device driver handle. - * @port : User number. - * @binds : Binds of user. - * @key : Identifier of key. - * - * Checks if key (@key) was being pressed by user - * with number @port with provided keybinds (@binds). - * - * Returns: true (1) if key was pressed, otherwise - * false (0). - **/ -bool input_joypad_pressed( - const input_device_driver_t *drv, - rarch_joypad_info_t joypad_info, - unsigned port, - const struct retro_keybind *binds, - unsigned key) -{ - /* Auto-binds are per joypad, not per user. */ - uint64_t joykey = (binds[key].joykey != NO_BTN) - ? binds[key].joykey : joypad_info.auto_binds[key].joykey; - - if ((uint16_t)joykey == NO_BTN || !drv->button(joypad_info.joy_idx, (uint16_t)joykey)) - { - uint32_t joyaxis = (binds[key].joyaxis != AXIS_NONE) - ? binds[key].joyaxis : joypad_info.auto_binds[key].joyaxis; - int16_t axis = drv->axis(joypad_info.joy_idx, joyaxis); - float scaled_axis = (float)abs(axis) / 0x8000; - return scaled_axis > joypad_info.axis_threshold; - } - - return true; -} - /** * input_joypad_analog: * @drv : Input device driver handle. diff --git a/input/input_driver.h b/input/input_driver.h index 3238b2469c..24841ba7a8 100644 --- a/input/input_driver.h +++ b/input/input_driver.h @@ -18,11 +18,13 @@ #define __INPUT_DRIVER__H #include +#include #include #include #include #include +#include #include #include "input_defines.h" @@ -443,11 +445,25 @@ void input_conv_analog_id_to_bind_id(unsigned idx, unsigned ident, * Returns: true (1) if key was pressed, otherwise * false (0). **/ -bool input_joypad_pressed(const input_device_driver_t *driver, +static INLINE bool input_joypad_pressed( + const input_device_driver_t *drv, rarch_joypad_info_t joypad_info, unsigned port, const struct retro_keybind *binds, - unsigned key); + unsigned key) +{ + /* Auto-binds are per joypad, not per user. */ + uint64_t joykey = (binds[key].joykey != NO_BTN) + ? binds[key].joykey : joypad_info.auto_binds[key].joykey; + uint32_t joyaxis = (binds[key].joyaxis != AXIS_NONE) + ? binds[key].joyaxis : joypad_info.auto_binds[key].joyaxis; + + if ((uint16_t)joykey != NO_BTN && drv->button(joypad_info.joy_idx, (uint16_t)joykey)) + return true; + + return ((float)abs(drv->axis(joypad_info.joy_idx, joyaxis)) / 0x8000) > joypad_info.axis_threshold; + +} /** * input_joypad_analog: