Browse Source

Fixed D-pad on Xbox One controllers using the HIDAPI driver

Sam Lantinga 1 year ago
parent
commit
aa3fc6e904
1 changed files with 4 additions and 4 deletions
  1. 4 4
      src/joystick/hidapi/SDL_hidapi_xboxone.c

+ 4 - 4
src/joystick/hidapi/SDL_hidapi_xboxone.c

@@ -673,16 +673,16 @@ static void HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_D
     if (ctx->last_state[1] != data[1]) {
     if (ctx->last_state[1] != data[1]) {
         Uint8 hat = 0;
         Uint8 hat = 0;
 
 
-        if (data[2] & 0x01) {
+        if (data[1] & 0x01) {
             hat |= SDL_HAT_UP;
             hat |= SDL_HAT_UP;
         }
         }
-        if (data[2] & 0x02) {
+        if (data[1] & 0x02) {
             hat |= SDL_HAT_DOWN;
             hat |= SDL_HAT_DOWN;
         }
         }
-        if (data[2] & 0x04) {
+        if (data[1] & 0x04) {
             hat |= SDL_HAT_LEFT;
             hat |= SDL_HAT_LEFT;
         }
         }
-        if (data[2] & 0x08) {
+        if (data[1] & 0x08) {
             hat |= SDL_HAT_RIGHT;
             hat |= SDL_HAT_RIGHT;
         }
         }
         SDL_SendJoystickHat(timestamp, joystick, 0, hat);
         SDL_SendJoystickHat(timestamp, joystick, 0, hat);