Use PS4 rumble hint as the default for the PS5 rumble hint Existing SDL applications may not know about the need to set a specific hint to enable rumble on PS5 controllers, even though they may already set the equivalent SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE hint for PS4 controller rumble support. Rather than requiring those developers update their apps, let's use the SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE value as an indication of the behavior they are expected for all PlayStation controllers.
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 38 39 40 41 42 43 44 45 46
diff --git a/include/SDL_hints.h b/include/SDL_hints.h
index 2d5e04c..8575570 100644
--- a/include/SDL_hints.h
+++ b/include/SDL_hints.h
@@ -616,6 +616,11 @@ extern "C" {
*
* Once extended reports are enabled, they can not be disabled without
* power cycling the controller.
+ *
+ * For compatibility with applications written for versions of SDL prior
+ * to the introduction of PS5 controller support, this value will also
+ * control the state of extended reports on PS5 controllers when the
+ * SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE hint is not explicitly set.
*/
#define SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE "SDL_JOYSTICK_HIDAPI_PS4_RUMBLE"
@@ -642,6 +647,10 @@ extern "C" {
*
* Once extended reports are enabled, they can not be disabled without
* power cycling the controller.
+ *
+ * For compatibility with applications written for versions of SDL prior
+ * to the introduction of PS5 controller support, this value defaults to
+ * the value of SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE.
*/
#define SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE "SDL_JOYSTICK_HIDAPI_PS5_RUMBLE"
diff --git a/src/joystick/hidapi/SDL_hidapi_ps5.c b/src/joystick/hidapi/SDL_hidapi_ps5.c
index f6b658f..aa1967c 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps5.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps5.c
@@ -624,7 +624,13 @@ HIDAPI_DriverPS5_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
} else {
/* Connected over Bluetooth, using simple reports (DirectInput enabled) */
ctx->is_bluetooth = SDL_TRUE;
- enhanced_mode = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, SDL_FALSE);
+
+ /* Games written prior the introduction of PS5 controller support in SDL will not be aware of
+ SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, but they did know SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE.
+ To support apps that only knew about the PS4 hint, we'll use the PS4 hint as the default.
+ */
+ enhanced_mode = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE,
+ SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, SDL_FALSE));
}
if (enhanced_mode) {