From 797d2c5957e36fe917443c66589f8f14220256ed Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 30 Jun 2019 22:48:13 -0700 Subject: [PATCH] Fixed bug 4436 - [OpenBSD] fix D-pad daniel.c.sinclair Hi, this patch breaks dpad/hat input on my PS4 controller. The attached patch restores functionality. Calling SDL_PrivateJoystickHat() at the end of BSD_JoystickUpdate was setting the hat state to zero on every kind of input, instead of just the HUG_DPAD events. --- src/joystick/bsd/SDL_sysjoystick.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/joystick/bsd/SDL_sysjoystick.c b/src/joystick/bsd/SDL_sysjoystick.c index fb632635468cf..4a2e887e380a2 100644 --- a/src/joystick/bsd/SDL_sysjoystick.c +++ b/src/joystick/bsd/SDL_sysjoystick.c @@ -623,14 +623,22 @@ BSD_JoystickUpdate(SDL_Joystick * joy) hitem.logical_minimum); } #ifdef __OpenBSD__ - else if (usage == HUG_DPAD_UP) + else if (usage == HUG_DPAD_UP) { dpad[0] = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); - else if (usage == HUG_DPAD_DOWN) + SDL_PrivateJoystickHat(joy, 0, dpad_to_sdl(dpad)); + } + else if (usage == HUG_DPAD_DOWN) { dpad[1] = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); - else if (usage == HUG_DPAD_RIGHT) + SDL_PrivateJoystickHat(joy, 0, dpad_to_sdl(dpad)); + } + else if (usage == HUG_DPAD_RIGHT) { dpad[2] = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); - else if (usage == HUG_DPAD_LEFT) + SDL_PrivateJoystickHat(joy, 0, dpad_to_sdl(dpad)); + } + else if (usage == HUG_DPAD_LEFT) { dpad[3] = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); + SDL_PrivateJoystickHat(joy, 0, dpad_to_sdl(dpad)); + } #endif break; } @@ -647,9 +655,6 @@ BSD_JoystickUpdate(SDL_Joystick * joy) break; } } -#ifdef __OpenBSD__ - SDL_PrivateJoystickHat(joy, 0, dpad_to_sdl(dpad)); -#endif hid_end_parse(hdata); } }