You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
[HTML5] Add checks to Gamepad API events.
In some conditions the events might be generated even when the `gamepad`
object is not accessible due to Security Context requirements.
This commit adds a check to avoid firing the handler in those cases.
(cherry picked from commit 91dbc288cc)
This commit is contained in:
committed by
Rémi Verschelde
parent
d70461b27e
commit
2a4efa3bcd
@@ -104,10 +104,14 @@ const GodotInputGamepads = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
GodotEventListeners.add(window, 'gamepadconnected', function (evt) {
|
GodotEventListeners.add(window, 'gamepadconnected', function (evt) {
|
||||||
|
if (evt.gamepad) {
|
||||||
add(evt.gamepad);
|
add(evt.gamepad);
|
||||||
|
}
|
||||||
}, false);
|
}, false);
|
||||||
GodotEventListeners.add(window, 'gamepaddisconnected', function (evt) {
|
GodotEventListeners.add(window, 'gamepaddisconnected', function (evt) {
|
||||||
|
if (evt.gamepad) {
|
||||||
onchange(evt.gamepad.index, 0);
|
onchange(evt.gamepad.index, 0);
|
||||||
|
}
|
||||||
}, false);
|
}, false);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user