Fixed rumble strength on DualSense Edge and Bluetooth connected controllers

Fixes https://github.com/libsdl-org/SDL/issues/13771

(cherry picked from commit 25d9096d41)
This commit is contained in:
Sam Lantinga
2025-09-06 11:52:48 -07:00
parent 71af2c020c
commit 414ae344af

View File

@@ -251,6 +251,7 @@ typedef struct
Uint64 last_packet;
int player_index;
bool player_lights;
bool enhanced_rumble;
Uint8 rumble_left;
Uint8 rumble_right;
bool color_set;
@@ -432,6 +433,14 @@ static bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device)
}
}
if (device->vendor_id == USB_VENDOR_SONY) {
if (device->product_id == USB_PRODUCT_SONY_DS5_EDGE ||
ctx->firmware_version == 0 || // Assume that it's updated firmware over Bluetooth
ctx->firmware_version >= 0x0224) {
ctx->enhanced_rumble = true;
}
}
// Get the device capabilities
if (device->vendor_id == USB_VENDOR_SONY) {
ctx->sensors_supported = true;
@@ -684,17 +693,17 @@ static bool HIDAPI_DriverPS5_UpdateEffects(SDL_DriverPS5_Context *ctx, int effec
if (ctx->vibration_supported) {
if (ctx->rumble_left || ctx->rumble_right) {
if (ctx->firmware_version < 0x0224) {
if (ctx->enhanced_rumble) {
effects.ucEnableBits3 |= 0x04; // Enable improved rumble emulation on 2.24 firmware and newer
effects.ucRumbleLeft = ctx->rumble_left;
effects.ucRumbleRight = ctx->rumble_right;
} else {
effects.ucEnableBits1 |= 0x01; // Enable rumble emulation
// Shift to reduce effective rumble strength to match Xbox controllers
effects.ucRumbleLeft = ctx->rumble_left >> 1;
effects.ucRumbleRight = ctx->rumble_right >> 1;
} else {
effects.ucEnableBits3 |= 0x04; // Enable improved rumble emulation on 2.24 firmware and newer
effects.ucRumbleLeft = ctx->rumble_left;
effects.ucRumbleRight = ctx->rumble_right;
}
effects.ucEnableBits1 |= 0x02; // Disable audio haptics
} else {