Fixed bug 4436 - [OpenBSD] fix D-pad
authorSam Lantinga <slouken@libsdl.org>
Sun, 30 Jun 2019 22:48:13 -0700
changeset 129110c19a7239a95
parent 12910 dd9169424181
child 12912 12a6ba543f44
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
     1.1 --- a/src/joystick/bsd/SDL_sysjoystick.c	Fri Jun 28 16:38:42 2019 +0200
     1.2 +++ b/src/joystick/bsd/SDL_sysjoystick.c	Sun Jun 30 22:48:13 2019 -0700
     1.3 @@ -623,14 +623,22 @@
     1.4                                                     hitem.logical_minimum);
     1.5                          }
     1.6  #ifdef __OpenBSD__
     1.7 -                        else if (usage == HUG_DPAD_UP)
     1.8 +                        else if (usage == HUG_DPAD_UP) {
     1.9                              dpad[0] = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem);
    1.10 -                        else if (usage == HUG_DPAD_DOWN)
    1.11 +                            SDL_PrivateJoystickHat(joy, 0, dpad_to_sdl(dpad));
    1.12 +                        }
    1.13 +                        else if (usage == HUG_DPAD_DOWN) {
    1.14                              dpad[1] = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem);
    1.15 -                        else if (usage == HUG_DPAD_RIGHT)
    1.16 +                            SDL_PrivateJoystickHat(joy, 0, dpad_to_sdl(dpad));
    1.17 +                        }
    1.18 +                        else if (usage == HUG_DPAD_RIGHT) {
    1.19                              dpad[2] = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem);
    1.20 -                        else if (usage == HUG_DPAD_LEFT)
    1.21 +                            SDL_PrivateJoystickHat(joy, 0, dpad_to_sdl(dpad));
    1.22 +                        }
    1.23 +                        else if (usage == HUG_DPAD_LEFT) {
    1.24                              dpad[3] = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem);
    1.25 +                            SDL_PrivateJoystickHat(joy, 0, dpad_to_sdl(dpad));
    1.26 +                        }
    1.27  #endif
    1.28                          break;
    1.29                      }
    1.30 @@ -647,9 +655,6 @@
    1.31                  break;
    1.32              }
    1.33          }
    1.34 -#ifdef __OpenBSD__
    1.35 -        SDL_PrivateJoystickHat(joy, 0, dpad_to_sdl(dpad));
    1.36 -#endif
    1.37          hid_end_parse(hdata);
    1.38      }
    1.39  }