mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-06 06:34:35 +00:00
emscripten: Fix crash on Safari when probing gamepad rumble support
Safari's older Gamepad API exposes `vibrationActuator` with `playEffect` and `reset` but no `effects` enumeration array. The probe added in651136ac7dereferences `vibrationActuator['effects']['includes']` unconditionally, throwing `TypeError: undefined is not an object` on every Safari client that opens a connected gamepad. Add the missing `['effects']` null check so the probe returns false on Safari instead of aborting. (cherry picked from commitdb7ac820f9)
This commit is contained in:
parent
f30c0e4ee2
commit
581c18f693
1 changed files with 2 additions and 2 deletions
|
|
@ -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']['includes']('dual-rumble');
|
||||
return gamepad && gamepad['vibrationActuator'] && gamepad['vibrationActuator']['effects'] && gamepad['vibrationActuator']['effects']['includes']('dual-rumble');
|
||||
}, item->index);
|
||||
|
||||
if (item->rumble_available) {
|
||||
|
|
@ -515,7 +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];
|
||||
return gamepad && gamepad['vibrationActuator'] && gamepad['vibrationActuator']['effects']['includes']('trigger-rumble');
|
||||
return gamepad && gamepad['vibrationActuator'] && gamepad['vibrationActuator']['effects'] && gamepad['vibrationActuator']['effects']['includes']('trigger-rumble');
|
||||
}, item->index);
|
||||
|
||||
if (item->trigger_rumble_available) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue