From dd796290157af418b8366ef8f1b79f1188b09677 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 13 Jun 2020 02:13:32 +0200 Subject: [PATCH] (QNX) Get rid of qnx_is_pressed --- input/drivers/qnx_input.c | 64 +++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/input/drivers/qnx_input.c b/input/drivers/qnx_input.c index 6c99a92ac0..fe22277d08 100644 --- a/input/drivers/qnx_input.c +++ b/input/drivers/qnx_input.c @@ -743,32 +743,6 @@ static bool qnx_keyboard_pressed(qnx_input_t *qnx, unsigned id) return id < RETROK_LAST && BIT_GET(qnx->keyboard_state, bit); } -static int16_t qnx_is_pressed( - qnx_input_t *qnx, - const input_device_driver_t *joypad, - rarch_joypad_info_t *joypad_info, - const struct retro_keybind *binds, - unsigned port, unsigned id) -{ - const struct retro_keybind *bind = &binds[id]; - int key = bind->key; - /* Auto-binds are per joypad, not per user. */ - const uint64_t joykey = (binds[id].joykey != NO_BTN) - ? binds[id].joykey : joypad_info->auto_binds[id].joykey; - const uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE) - ? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis; - if (qnx_keyboard_pressed(qnx, key)) - if ((id == RARCH_GAME_FOCUS_TOGGLE) || !input_qnx.keyboard_mapping_blocked) - return 1; - if ((uint16_t)joykey != NO_BTN && joypad->button( - joypad_info->joy_idx, (uint16_t)joykey)) - return 1; - if (((float)abs(joypad->axis(joypad_info->joy_idx, joyaxis)) - / 0x8000) > joypad_info->axis_threshold) - return 1; - return 0; -} - static int16_t qnx_pointer_input_state(qnx_input_t *qnx, unsigned idx, unsigned id, bool screen) { @@ -815,14 +789,32 @@ static int16_t qnx_input_state(void *data, { unsigned i; int16_t ret = 0; - for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) + if (input_qnx.keyboard_mapping_blocked) { - if (binds[port][i].valid) + for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { - if (qnx_is_pressed( - qnx, qnx->joypad, - joypad_info, binds[port], port, i)) - ret |= (1 << i); + if (binds[port][i].valid) + { + if (button_is_pressed( + qnx->joypad, + joypad_info, binds[port], port, i)) + ret |= (1 << i); + } + } + } + else + { + for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) + { + if (binds[port][i].valid) + { + if (button_is_pressed( + qnx->joypad, + joypad_info, binds[port], port, i)) + ret |= (1 << i); + else if (qnx_keyboard_pressed(qnx, key)) + ret |= (1 << i); + } } } @@ -834,9 +826,15 @@ static int16_t qnx_input_state(void *data, { if (binds[port][id].valid) { - if (qnx_is_pressed(qnx, qnx->joypad, + if (button_is_pressed(qnx->joypad, joypad_info, binds[port], port, id)) return 1; + else if ( + ((id == RARCH_GAME_FOCUS_TOGGLE) || + !input_qnx.keyboard_mapping_blocked) && + qnx_keyboard_pressed(qnx, key) + ) + return 1; } } }