Don't send rumble to the Amazon Luna controller on macOS Sending rumble to the Amazon Luna controller on macOS gets there, but IOHIDDeviceSetReport() blocks for a long time and eventually fails. This appears to be a bug in the macOS Bluetooth stack, ref rdar://99265496
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 47 48 49 50 51
diff --git a/src/joystick/hidapi/SDL_hidapi_luna.c b/src/joystick/hidapi/SDL_hidapi_luna.c
index 3bcf3d0..c9cd281 100644
--- a/src/joystick/hidapi/SDL_hidapi_luna.c
+++ b/src/joystick/hidapi/SDL_hidapi_luna.c
@@ -35,6 +35,11 @@
/* Define this if you want to log all packets from the controller */
/*#define DEBUG_LUNA_PROTOCOL*/
+/* Sending rumble on macOS blocks for a long time and eventually fails */
+#if !defined(__MACOSX__)
+#define ENABLE_LUNA_BLUETOOTH_RUMBLE
+#endif
+
enum
{
SDL_CONTROLLER_BUTTON_LUNA_MIC = 15,
@@ -119,6 +124,7 @@ HIDAPI_DriverLuna_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick
static int
HIDAPI_DriverLuna_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
{
+#ifdef ENABLE_LUNA_BLUETOOTH_RUMBLE
if (device->product_id == BLUETOOTH_PRODUCT_LUNA_CONTROLLER) {
/* Same packet as on Xbox One controllers connected via Bluetooth */
Uint8 rumble_packet[] = { 0x03, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xEB };
@@ -132,10 +138,11 @@ HIDAPI_DriverLuna_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joysti
}
return 0;
- } else {
- /* FIXME: Is there a rumble packet over USB? */
- return SDL_Unsupported();
}
+#endif /* ENABLE_LUNA_BLUETOOTH_RUMBLE */
+
+ /* There is currently no rumble packet over USB */
+ return SDL_Unsupported();
}
static int
@@ -149,9 +156,11 @@ HIDAPI_DriverLuna_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystic
{
Uint32 result = 0;
+#ifdef ENABLE_LUNA_BLUETOOTH_RUMBLE
if (device->product_id == BLUETOOTH_PRODUCT_LUNA_CONTROLLER) {
result |= SDL_JOYCAP_RUMBLE;
}
+#endif
return result;
}