Skip to content

Commit

Permalink
XBOXOLD: fix analog hat readings
Browse files Browse the repository at this point in the history
Properly read left and right analog hat values as 16bit little endian integers.

Signed-off-by: Albert Herranz <[email protected]>
  • Loading branch information
herraa1 committed Jul 21, 2024
1 parent b92fa02 commit ca39e3a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions XBOXOLD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,10 @@ void XBOXOLD::readReport() {
for(uint8_t i = 0; i < sizeof (buttonValues); i++)
buttonValues[i] = readBuf[i + 4]; // A, B, X, Y, BLACK, WHITE, L1, and R1

hatValue[LeftHatX] = (int16_t)(((uint16_t)readBuf[12] << 8) | readBuf[13]);
hatValue[LeftHatY] = (int16_t)(((uint16_t)readBuf[14] << 8) | readBuf[15]);
hatValue[RightHatX] = (int16_t)(((uint16_t)readBuf[16] << 8) | readBuf[17]);
hatValue[RightHatY] = (int16_t)(((uint16_t)readBuf[18] << 8) | readBuf[19]);
hatValue[LeftHatX] = (int16_t)(((uint16_t)readBuf[13] << 8) | readBuf[12]);
hatValue[LeftHatY] = (int16_t)(((uint16_t)readBuf[15] << 8) | readBuf[14]);
hatValue[RightHatX] = (int16_t)(((uint16_t)readBuf[17] << 8) | readBuf[16]);
hatValue[RightHatY] = (int16_t)(((uint16_t)readBuf[19] << 8) | readBuf[18]);

//Notify(PSTR("\r\nButtonState"), 0x80);
//PrintHex<uint8_t>(ButtonState, 0x80);
Expand Down

0 comments on commit ca39e3a

Please sign in to comment.