SDL: Fix web crash for joystick without vibration

From 4a0d66116f956426c5b49860369c6d8b7787c98f Mon Sep 17 00:00:00 2001
From: Nintorch <[EMAIL REDACTED]>
Date: Fri, 12 Jun 2026 11:46:06 +0500
Subject: [PATCH] Fix web crash for joystick without vibration

---
 src/joystick/emscripten/SDL_sysjoystick.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/joystick/emscripten/SDL_sysjoystick.c b/src/joystick/emscripten/SDL_sysjoystick.c
index 91d3ef47bd942..2ff71d07858ed 100644
--- a/src/joystick/emscripten/SDL_sysjoystick.c
+++ b/src/joystick/emscripten/SDL_sysjoystick.c
@@ -502,7 +502,11 @@ 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 && 'vibrationActuator' in gamepad; // Don't check the vibrationActuator.effects array here, because it's not defined in Safari
+        // Don't check the vibrationActuator.effects array here, because it's not defined in Safari
+        if (!gamepad || !gamepad['vibrationActuator']) {
+            return false;
+        }
+        return true;
         }, item->index);
 
     if (item->rumble_available) {
@@ -512,7 +516,10 @@ 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 && 'vibrationActuator' in gamepad && 'effects' in gamepad['vibrationActuator'] && gamepad['vibrationActuator']['effects']['includes']('trigger-rumble');
+        if (!gamepad || !gamepad['vibrationActuator'] || !gamepad['vibrationActuator']['effects'] || !gamepad['vibrationActuator']['effects']['includes']('trigger-rumble')) {
+            return false;
+        }
+        return true;
         }, item->index);
 
     if (item->trigger_rumble_available) {