Fixed sensor timestamp units for third-party PS5 controllers (cherry picked from commit a72dfa6a5fe8d8901175db852de8686b83487522) (cherry picked from commit 37dee79b74723b7021ccaa946e31872f0539df4a)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
diff --git a/src/joystick/hidapi/SDL_hidapi_ps5.c b/src/joystick/hidapi/SDL_hidapi_ps5.c
index e671b8a..68588c2 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps5.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps5.c
@@ -723,7 +723,7 @@ static void HIDAPI_DriverPS5_CheckPendingLEDReset(SDL_HIDAPI_Device *device)
SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)device->context;
SDL_bool led_reset_complete = SDL_FALSE;
- if (ctx->sensors_supported) {
+ if (ctx->enhanced_mode && ctx->sensors_supported && !ctx->use_alternate_report) {
const PS5StatePacketCommon_t *packet = &ctx->last_state.state;
/* Check the timer to make sure the Bluetooth connection LED animation is complete */
@@ -1253,6 +1253,9 @@ static void HIDAPI_DriverPS5_HandleStatePacketCommon(SDL_Joystick *joystick, SDL
ctx->timestamp = timestamp;
}
ctx->last_timestamp = timestamp;
+
+ /* Sensor timestamp is in 1us units */
+ timestamp_us = ctx->timestamp;
} else {
/* 32-bit timestamp */
Uint32 timestamp;
@@ -1274,10 +1277,10 @@ static void HIDAPI_DriverPS5_HandleStatePacketCommon(SDL_Joystick *joystick, SDL
ctx->timestamp = timestamp;
}
ctx->last_timestamp = timestamp;
- }
- /* Sensor timestamp is in 0.33us units */
- timestamp_us = ctx->timestamp / 3;
+ /* Sensor timestamp is in 0.33us units */
+ timestamp_us = ctx->timestamp / 3;
+ }
data[0] = HIDAPI_DriverPS5_ApplyCalibrationData(ctx, 0, LOAD16(packet->rgucGyroX[0], packet->rgucGyroX[1]));
data[1] = HIDAPI_DriverPS5_ApplyCalibrationData(ctx, 1, LOAD16(packet->rgucGyroY[0], packet->rgucGyroY[1]));