From 2cb3a132c6cad1b2f9cf22dd8a1d470bdc89a3b8 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 7 Mar 2020 17:00:38 -0800 Subject: [PATCH] Fix false positives in SDL_GameControllerRumble() support detection --- app/streaming/input.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/streaming/input.cpp b/app/streaming/input.cpp index 378ed3a7..3eeffb96 100644 --- a/app/streaming/input.cpp +++ b/app/streaming/input.cpp @@ -999,8 +999,10 @@ void SdlInputHandler::handleControllerDeviceEvent(SDL_ControllerDeviceEvent* eve state->jsId = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(state->controller)); #if SDL_VERSION_ATLEAST(2, 0, 9) - // Perform a no-op rumble to see if haptics are supported - hapticCaps = SDL_GameControllerRumble(controller, 0, 0, 0) == 0 ? + // Perform a tiny rumble to see if haptics are supported. + // NB: We cannot use zeros for rumble intensity or SDL will not actually call the JS driver + // and we'll get a (potentially false) success value returned. + hapticCaps = SDL_GameControllerRumble(controller, 1, 1, 1) == 0 ? ML_HAPTIC_GC_RUMBLE : 0; #else state->haptic = SDL_HapticOpenFromJoystick(SDL_GameControllerGetJoystick(state->controller));