Skip to content

Commit

Permalink
Fixed Xbox One Series X share button incorrectly triggering on newer …
Browse files Browse the repository at this point in the history
…firmware
  • Loading branch information
slouken committed Jan 8, 2021
1 parent b244947 commit a5dba7d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Empty file modified build-scripts/config.guess
100755 → 100644
Empty file.
Empty file modified build-scripts/config.sub
100755 → 100644
Empty file.
20 changes: 12 additions & 8 deletions src/joystick/hidapi/SDL_hidapi_xboxone.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,14 +488,18 @@ HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverXboxOne
}

if (ctx->has_share_button) {
/* Version 1 of the firmware for Xbox One Series X */
if (ctx->last_state[18] != data[18]) {
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1, (data[18] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
}

/* Version 2 of the firmware for Xbox One Series X */
if (ctx->last_state[22] != data[22]) {
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1, (data[22] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
/* Xbox Series X firmware version 5.0, report is 36 bytes, share button is in byte 18
* Xbox Series X firmware version 5.1, report is 44 bytes, share button is in byte 18
* Xbox Series X firmware version 5.5, report is 48 bytes, share button is in byte 22
*/
if (size < 48) {
if (ctx->last_state[18] != data[18]) {
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1, (data[18] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
}
} else {
if (ctx->last_state[22] != data[22]) {
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1, (data[22] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
}
}
}

Expand Down

0 comments on commit a5dba7d

Please sign in to comment.