From a23928fb89fad881b78e3ff36a27708f3a53eaf5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 21 Jun 2019 12:49:33 +0200 Subject: [PATCH] Split up input_state into input_state_internal - no longer rely on recursion of function --- retroarch.c | 55 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/retroarch.c b/retroarch.c index 82cd369d47..d7b716fdfc 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2517,19 +2517,7 @@ static void input_poll(void) #endif } -/** - * input_state: - * @port : user number. - * @device : device identifier of user. - * @idx : index value of user. - * @id : identifier of key pressed by user. - * - * Input state callback function. - * - * Returns: Non-zero if the given key (identified by @id) - * was pressed by the user (assigned to @port). - **/ -int16_t input_state(unsigned port, unsigned device, +static int16_t input_state_internal(unsigned port, unsigned device, unsigned idx, unsigned id) { int16_t bsv_result; @@ -2541,17 +2529,6 @@ int16_t input_state(unsigned port, unsigned device, is in action for that button*/ bool reset_state = false; - if ( (device == RETRO_DEVICE_JOYPAD) && - (id == RETRO_DEVICE_ID_JOYPAD_MASK)) - { - unsigned i; - - for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) - if (input_state(port, device, idx, i)) - res |= (1 << i); - return res; - } - device &= RETRO_DEVICE_MASK; if (bsv_movie_get_input(&bsv_result)) @@ -2680,6 +2657,36 @@ int16_t input_state(unsigned port, unsigned device, return res; } +/** + * input_state: + * @port : user number. + * @device : device identifier of user. + * @idx : index value of user. + * @id : identifier of key pressed by user. + * + * Input state callback function. + * + * Returns: Non-zero if the given key (identified by @id) + * was pressed by the user (assigned to @port). + **/ +int16_t input_state(unsigned port, unsigned device, + unsigned idx, unsigned id) +{ + if ( (device == RETRO_DEVICE_JOYPAD) && + (id == RETRO_DEVICE_ID_JOYPAD_MASK)) + { + unsigned i; + int16_t res = 0; + + for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) + if (input_state_internal(port, device, idx, i)) + res |= (1 << i); + return res; + } + + return input_state_internal(port, device, idx, id); +} + /** * state_tracker_update_input: *