Skip to content

Commit

Permalink
Fix hidapi for unhandled DS4 headset microphone data corrupting contr…
Browse files Browse the repository at this point in the history
…oller state
  • Loading branch information
John "Nielk1" Klein authored and John "Nielk1" Klein committed Nov 11, 2020
1 parent b6238c8 commit 067630a
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/joystick/hidapi/SDL_hidapi_ps4.c
Expand Up @@ -41,7 +41,15 @@ typedef enum
{
k_EPS4ReportIdUsbState = 1,
k_EPS4ReportIdUsbEffects = 5,
k_EPS4ReportIdBluetoothState = 17,
k_EPS4ReportIdBluetoothState1 = 17,
k_EPS4ReportIdBluetoothState2 = 18,
k_EPS4ReportIdBluetoothState3 = 19,
k_EPS4ReportIdBluetoothState4 = 20,
k_EPS4ReportIdBluetoothState5 = 21,
k_EPS4ReportIdBluetoothState6 = 22,
k_EPS4ReportIdBluetoothState7 = 23,
k_EPS4ReportIdBluetoothState8 = 24,
k_EPS4ReportIdBluetoothState9 = 25,
k_EPS4ReportIdBluetoothEffects = 17,
k_EPS4ReportIdDisconnectMessage = 226,
} EPS4ReportId;
Expand Down Expand Up @@ -524,9 +532,19 @@ HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device)
case k_EPS4ReportIdUsbState:
HIDAPI_DriverPS4_HandleStatePacket(joystick, device->dev, ctx, (PS4StatePacket_t *)&data[1]);
break;
case k_EPS4ReportIdBluetoothState:
/* Bluetooth state packets have two additional bytes at the beginning */
HIDAPI_DriverPS4_HandleStatePacket(joystick, device->dev, ctx, (PS4StatePacket_t *)&data[3]);
case k_EPS4ReportIdBluetoothState1:
case k_EPS4ReportIdBluetoothState2:
case k_EPS4ReportIdBluetoothState3:
case k_EPS4ReportIdBluetoothState4:
case k_EPS4ReportIdBluetoothState5:
case k_EPS4ReportIdBluetoothState6:
case k_EPS4ReportIdBluetoothState7:
case k_EPS4ReportIdBluetoothState8:
case k_EPS4ReportIdBluetoothState9:
/* Bluetooth state packets have two additional bytes at the beginning, the first notes if HID is present */
if (data[1] & 0x80) {
HIDAPI_DriverPS4_HandleStatePacket(joystick, device->dev, ctx, (PS4StatePacket_t*)&data[3]);
}
break;
default:
#ifdef DEBUG_JOYSTICK
Expand Down

0 comments on commit 067630a

Please sign in to comment.