Fix hidapi for unhandled DS4 headset microphone data corrupting controller state

This commit is contained in:
John "Nielk1" Klein 2020-11-11 03:47:08 -06:00
parent b6238c87e4
commit 067630aef3
1 changed files with 22 additions and 4 deletions

View File

@ -41,7 +41,15 @@ typedef enum
{ {
k_EPS4ReportIdUsbState = 1, k_EPS4ReportIdUsbState = 1,
k_EPS4ReportIdUsbEffects = 5, 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_EPS4ReportIdBluetoothEffects = 17,
k_EPS4ReportIdDisconnectMessage = 226, k_EPS4ReportIdDisconnectMessage = 226,
} EPS4ReportId; } EPS4ReportId;
@ -524,9 +532,19 @@ HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device)
case k_EPS4ReportIdUsbState: case k_EPS4ReportIdUsbState:
HIDAPI_DriverPS4_HandleStatePacket(joystick, device->dev, ctx, (PS4StatePacket_t *)&data[1]); HIDAPI_DriverPS4_HandleStatePacket(joystick, device->dev, ctx, (PS4StatePacket_t *)&data[1]);
break; break;
case k_EPS4ReportIdBluetoothState: case k_EPS4ReportIdBluetoothState1:
/* Bluetooth state packets have two additional bytes at the beginning */ case k_EPS4ReportIdBluetoothState2:
HIDAPI_DriverPS4_HandleStatePacket(joystick, device->dev, ctx, (PS4StatePacket_t *)&data[3]); 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; break;
default: default:
#ifdef DEBUG_JOYSTICK #ifdef DEBUG_JOYSTICK