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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
diff --git a/src/joystick/bsd/SDL_sysjoystick.c b/src/joystick/bsd/SDL_sysjoystick.c
index fb63263..4a2e887 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);
}
}