Просмотр исходного кода

Fix web joystick vibration on Safari

Nintorch 2 недель назад
Родитель
Сommit
e0eb40f65f
1 измененных файлов с 2 добавлено и 1 удалено
  1. 2 1
      src/joystick/emscripten/SDL_sysjoystick.c

+ 2 - 1
src/joystick/emscripten/SDL_sysjoystick.c

@@ -506,7 +506,7 @@ static bool EMSCRIPTEN_JoystickOpen(SDL_Joystick *joystick, int device_index)
 
     item->rumble_available = MAIN_THREAD_EM_ASM_INT({
         let gamepad = navigator['getGamepads']()[$0];
-        return gamepad && gamepad['vibrationActuator'] && gamepad['vibrationActuator']['effects'] && gamepad['vibrationActuator']['effects']['includes']('dual-rumble');
+        return gamepad && gamepad['vibrationActuator']; // Don't check the vibrationActuator.effects array here, because it's not defined in Safari
         }, item->index);
 
     if (item->rumble_available) {
@@ -515,6 +515,7 @@ static bool EMSCRIPTEN_JoystickOpen(SDL_Joystick *joystick, int device_index)
 
     item->trigger_rumble_available = MAIN_THREAD_EM_ASM_INT({
         let gamepad = navigator['getGamepads']()[$0];
+        // This effect is not supported in Safari, so it's okay for us to check the vibrationActuator.effects array here for the browsers that do support it
         return gamepad && gamepad['vibrationActuator'] && gamepad['vibrationActuator']['effects'] && gamepad['vibrationActuator']['effects']['includes']('trigger-rumble');
         }, item->index);