From 558bbbb07ae0afa0108c1560915351cfa13442b7 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 6 Apr 2023 09:54:04 -0700
Subject: [PATCH] The latest Armor-X Pro firmware update fixes the sign on the
Z axis of the sensors
---
src/joystick/hidapi/SDL_hidapi_ps4.c | 35 ++++++----------------------
1 file changed, 7 insertions(+), 28 deletions(-)
diff --git a/src/joystick/hidapi/SDL_hidapi_ps4.c b/src/joystick/hidapi/SDL_hidapi_ps4.c
index ceb9a14ab07f..7dbc900e10cf 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps4.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps4.c
@@ -599,40 +599,19 @@ static void HIDAPI_DriverPS4_LoadCalibrationData(SDL_HIDAPI_Device *device)
if (i < 3) {
scale *= ((double)ctx->gyro_numerator / ctx->gyro_denominator) * SDL_PI_D / 180.0;
- if (device->vendor_id == USB_VENDOR_SONY &&
- device->product_id == USB_PRODUCT_SONY_DS4_STRIKEPAD) {
- /* The Armor-X Pro seems to only deliver half the rotation it should,
- * and in the opposite direction on the Z axis */
- switch (i) {
- case 0:
- case 1:
- scale *= 2.0;
- break;
- case 2:
- scale *= -2.0;
- break;
- default:
- break;
- }
- }
+ if (device->vendor_id == USB_VENDOR_SONY &&
+ device->product_id == USB_PRODUCT_SONY_DS4_STRIKEPAD) {
+ /* The Armor-X Pro seems to only deliver half the rotation it should */
+ scale *= 2.0;
+ }
} else {
scale *= ((double)ctx->accel_numerator / ctx->accel_denominator) * SDL_STANDARD_GRAVITY;
if (device->vendor_id == USB_VENDOR_SONY &&
device->product_id == USB_PRODUCT_SONY_DS4_STRIKEPAD) {
/* The Armor-X Pro seems to only deliver half the acceleration it should,
- * and in the opposite direction on the X and Y axes */
- switch (i) {
- case 3:
- case 4:
- scale *= -2.0;
- break;
- case 5:
- scale *= 2.0;
- break;
- default:
- break;
- }
+ * and in the opposite direction on all axes */
+ scale *= -2.0;
}
}
ctx->calibration[i].scale = (float)scale;