From e9f853ba93a24361add4442dca9a2b795ee24e17 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Dec 2016 08:44:55 +0100 Subject: [PATCH] Move (joykey == NO_BTN ) to input_joypad_driver --- input/drivers_hid/btstack_hid.c | 3 --- input/drivers_hid/iohidmanager_hid.c | 3 --- input/drivers_hid/libusb_hid.c | 3 --- input/drivers_hid/wiiusb_hid.c | 3 --- input/drivers_joypad/dinput_joypad.c | 9 ++------- input/drivers_joypad/mfi_joypad.m | 3 --- input/drivers_joypad/sdl_joypad.c | 9 ++------- input/drivers_joypad/xinput_joypad.c | 6 +----- input/input_joypad_driver.c | 2 +- 9 files changed, 6 insertions(+), 35 deletions(-) diff --git a/input/drivers_hid/btstack_hid.c b/input/drivers_hid/btstack_hid.c index 8eecfa613d..7ccab02f02 100644 --- a/input/drivers_hid/btstack_hid.c +++ b/input/drivers_hid/btstack_hid.c @@ -1372,9 +1372,6 @@ static bool btstack_hid_joypad_button(void *data, unsigned port, uint16_t joykey { uint64_t buttons = btstack_hid_joypad_get_buttons(data, port); - if (joykey == NO_BTN) - return false; - /* Check hat. */ if (GET_HAT_DIR(joykey)) return false; diff --git a/input/drivers_hid/iohidmanager_hid.c b/input/drivers_hid/iohidmanager_hid.c index 3948f111e9..45ff008eb6 100644 --- a/input/drivers_hid/iohidmanager_hid.c +++ b/input/drivers_hid/iohidmanager_hid.c @@ -73,9 +73,6 @@ static bool iohidmanager_hid_joypad_button(void *data, iohidmanager_hid_joypad_get_buttons(data, port); iohidmanager_hid_t *hid = (iohidmanager_hid_t*)data; - if (joykey == NO_BTN) - return false; - /* Check hat. */ if (GET_HAT_DIR(joykey)) return false; diff --git a/input/drivers_hid/libusb_hid.c b/input/drivers_hid/libusb_hid.c index b6ee3834d8..285e525a68 100644 --- a/input/drivers_hid/libusb_hid.c +++ b/input/drivers_hid/libusb_hid.c @@ -442,9 +442,6 @@ static bool libusb_hid_joypad_button(void *data, { uint64_t buttons = libusb_hid_joypad_get_buttons(data, port); - if (joykey == NO_BTN) - return false; - /* Check hat. */ if (GET_HAT_DIR(joykey)) return false; diff --git a/input/drivers_hid/wiiusb_hid.c b/input/drivers_hid/wiiusb_hid.c index d09f6d6c8c..386ad9a37d 100644 --- a/input/drivers_hid/wiiusb_hid.c +++ b/input/drivers_hid/wiiusb_hid.c @@ -493,9 +493,6 @@ static bool wiiusb_hid_joypad_button(void *data, unsigned port, uint16_t joykey) { uint64_t buttons = wiiusb_hid_joypad_get_buttons(data, port); - if (joykey == NO_BTN) - return false; - /* Check hat. */ if (GET_HAT_DIR(joykey)) return false; diff --git a/input/drivers_joypad/dinput_joypad.c b/input/drivers_joypad/dinput_joypad.c index db5db60810..36a2133b20 100644 --- a/input/drivers_joypad/dinput_joypad.c +++ b/input/drivers_joypad/dinput_joypad.c @@ -324,14 +324,9 @@ static bool dinput_joypad_init(void *data) static bool dinput_joypad_button(unsigned port_num, uint16_t joykey) { - const struct dinput_joypad *pad = NULL; unsigned hat_dir = 0; - - if (joykey == NO_BTN) - return false; - - pad = &g_pads[port_num]; - if (!pad->joypad) + const struct dinput_joypad *pad = &g_pads[port_num]; + if (!pad || !pad->joypad) return false; hat_dir = GET_HAT_DIR(joykey); diff --git a/input/drivers_joypad/mfi_joypad.m b/input/drivers_joypad/mfi_joypad.m index 377cea81a6..7349507812 100644 --- a/input/drivers_joypad/mfi_joypad.m +++ b/input/drivers_joypad/mfi_joypad.m @@ -207,9 +207,6 @@ static void apple_gamecontroller_joypad_destroy(void) static bool apple_gamecontroller_joypad_button(unsigned port, uint16_t joykey) { - if (joykey == NO_BTN) - return false; - /* Check hat. */ if (GET_HAT_DIR(joykey)) return false; diff --git a/input/drivers_joypad/sdl_joypad.c b/input/drivers_joypad/sdl_joypad.c index 59e7c69b86..9681000095 100644 --- a/input/drivers_joypad/sdl_joypad.c +++ b/input/drivers_joypad/sdl_joypad.c @@ -289,14 +289,9 @@ error: static bool sdl_joypad_button(unsigned port, uint16_t joykey) { - sdl_joypad_t *pad = NULL; unsigned hat_dir = 0; - - if (joykey == NO_BTN) - return false; - - pad = (sdl_joypad_t*)&sdl_pads[port]; - if (!pad->joypad) + sdl_joypad_t *pad = (sdl_joypad_t*)&sdl_pads[port]; + if (!pad || !pad->joypad) return false; hat_dir = GET_HAT_DIR(joykey); diff --git a/input/drivers_joypad/xinput_joypad.c b/input/drivers_joypad/xinput_joypad.c index 2f790ab814..7f8166fac6 100644 --- a/input/drivers_joypad/xinput_joypad.c +++ b/input/drivers_joypad/xinput_joypad.c @@ -318,15 +318,11 @@ static const uint16_t button_index_to_bitmap_code[] = { static bool xinput_joypad_button(unsigned port_num, uint16_t joykey) { - int xuser; uint16_t btn_word = 0; unsigned num_buttons = 0; unsigned hat_dir = 0; + int xuser = pad_index_to_xuser_index(port_num); - if (joykey == NO_BTN) - return false; - - xuser = pad_index_to_xuser_index(port_num); if (xuser == -1) return dinput_joypad.button(port_num, joykey); diff --git a/input/input_joypad_driver.c b/input/input_joypad_driver.c index 2aa4f9f898..216859e50c 100644 --- a/input/input_joypad_driver.c +++ b/input/input_joypad_driver.c @@ -250,7 +250,7 @@ bool input_joypad_pressed( uint64_t joykey = (binds[key].joykey != NO_BTN) ? binds[key].joykey : auto_binds[key].joykey; - if (!drv->button(joy_idx, (uint16_t)joykey)) + if ((uint16_t)joykey == NO_BTN || !drv->button(joy_idx, (uint16_t)joykey)) { uint32_t joyaxis = (binds[key].joyaxis != AXIS_NONE) ? binds[key].joyaxis : auto_binds[key].joyaxis;