|
|
@@ -156,6 +156,7 @@ typedef struct
|
|
|
Uint8 rgucTouchpadData1[3]; // 32 - X/Y, 12 bits per axis
|
|
|
Uint8 ucTouchpadCounter2; // 35 - high bit clear + counter
|
|
|
Uint8 rgucTouchpadData2[3]; // 36 - X/Y, 12 bits per axis
|
|
|
+ Uint8 rgucDeviceSpecific[8]; // 40
|
|
|
|
|
|
// There's more unknown data at the end, and a 32-bit CRC on Bluetooth
|
|
|
} PS5StatePacketAlt_t;
|
|
|
@@ -232,6 +233,9 @@ typedef struct
|
|
|
bool playerled_supported;
|
|
|
bool touchpad_supported;
|
|
|
bool effects_supported;
|
|
|
+ bool guitar_whammy_supported;
|
|
|
+ bool guitar_tilt_supported;
|
|
|
+ bool guitar_effects_selector_supported;
|
|
|
HIDAPI_PS5_EnhancedReportHint enhanced_report_hint;
|
|
|
bool enhanced_reports;
|
|
|
bool enhanced_mode;
|
|
|
@@ -448,6 +452,7 @@ static bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device)
|
|
|
if (size == 48 && data[2] == 0x28) {
|
|
|
Uint8 capabilities = data[4];
|
|
|
Uint8 capabilities2 = data[20];
|
|
|
+ Uint8 device_specific_capabilities = data[24];
|
|
|
Uint8 device_type = data[5];
|
|
|
|
|
|
#ifdef DEBUG_PS5_PROTOCOL
|
|
|
@@ -475,6 +480,15 @@ static bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device)
|
|
|
break;
|
|
|
case 0x01:
|
|
|
joystick_type = SDL_JOYSTICK_TYPE_GUITAR;
|
|
|
+ if (device_specific_capabilities & 0x01) {
|
|
|
+ ctx->guitar_effects_selector_supported = true;
|
|
|
+ }
|
|
|
+ if (device_specific_capabilities & 0x02) {
|
|
|
+ ctx->guitar_tilt_supported = true;
|
|
|
+ }
|
|
|
+ if (device_specific_capabilities & 0x04) {
|
|
|
+ ctx->guitar_whammy_supported = true;
|
|
|
+ }
|
|
|
break;
|
|
|
case 0x02:
|
|
|
joystick_type = SDL_JOYSTICK_TYPE_DRUM_KIT;
|
|
|
@@ -836,6 +850,11 @@ static void HIDAPI_DriverPS5_SetEnhancedModeAvailable(SDL_DriverPS5_Context *ctx
|
|
|
SDL_PrivateJoystickAddSensor(ctx->joystick, SDL_SENSOR_ACCEL, update_rate);
|
|
|
}
|
|
|
|
|
|
+ if (ctx->guitar_tilt_supported) {
|
|
|
+ float update_rate = 250.0f;
|
|
|
+ SDL_PrivateJoystickAddSensor(ctx->joystick, SDL_SENSOR_ACCEL, update_rate);
|
|
|
+ }
|
|
|
+
|
|
|
ctx->report_battery = true;
|
|
|
|
|
|
HIDAPI_UpdateDeviceProperties(ctx->device);
|
|
|
@@ -1127,7 +1146,7 @@ static bool HIDAPI_DriverPS5_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device
|
|
|
|
|
|
HIDAPI_DriverPS5_UpdateEnhancedModeOnApplicationUsage(ctx);
|
|
|
|
|
|
- if (!ctx->sensors_supported || (enabled && !ctx->enhanced_mode)) {
|
|
|
+ if ((!ctx->sensors_supported || (enabled && !ctx->enhanced_mode)) && !ctx->guitar_tilt_supported) {
|
|
|
return SDL_Unsupported();
|
|
|
}
|
|
|
|
|
|
@@ -1432,6 +1451,7 @@ static void HIDAPI_DriverPS5_HandleStatePacketAlt(SDL_Joystick *joystick, SDL_hi
|
|
|
static const float TOUCHPAD_SCALEY = 9.34579439e-4f; // 1.0f / 1070
|
|
|
bool touchpad_down;
|
|
|
int touchpad_x, touchpad_y;
|
|
|
+ Sint16 axis;
|
|
|
|
|
|
if (ctx->report_touchpad) {
|
|
|
touchpad_down = ((packet->ucTouchpadCounter1 & 0x80) == 0);
|
|
|
@@ -1447,6 +1467,30 @@ static void HIDAPI_DriverPS5_HandleStatePacketAlt(SDL_Joystick *joystick, SDL_hi
|
|
|
|
|
|
HIDAPI_DriverPS5_HandleStatePacketCommon(joystick, dev, ctx, (PS5StatePacketCommon_t *)packet, timestamp);
|
|
|
|
|
|
+ if (ctx->guitar_whammy_supported) {
|
|
|
+ axis = ((int)packet->rgucDeviceSpecific[1] * 257) - 32768;
|
|
|
+ SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTX, axis);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ctx->guitar_effects_selector_supported) {
|
|
|
+ // Align pickup selector mappings with PS3 instruments
|
|
|
+ static const Sint16 effects_mappings[] = {24576, 11008, -1792, -13568, -26880};
|
|
|
+ if (packet->rgucDeviceSpecific[0] < SDL_arraysize(effects_mappings)) {
|
|
|
+ SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, effects_mappings[packet->rgucDeviceSpecific[0]]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ctx->guitar_tilt_supported) {
|
|
|
+ float sensor_data[3];
|
|
|
+ sensor_data[0] = ((float)packet->rgucDeviceSpecific[2] / 255) * SDL_STANDARD_GRAVITY;
|
|
|
+ sensor_data[1] = 0;
|
|
|
+ sensor_data[2] = 0;
|
|
|
+ SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_ACCEL, timestamp, sensor_data, SDL_arraysize(sensor_data));
|
|
|
+
|
|
|
+ // Align tilt mappings with PS3 instruments
|
|
|
+ SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, packet->rgucDeviceSpecific[2] > 0xF0);
|
|
|
+ }
|
|
|
+
|
|
|
SDL_memcpy(&ctx->last_state, packet, sizeof(ctx->last_state));
|
|
|
}
|
|
|
|