[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.
This commit is contained in:
parent
f13c7fc83e
commit
91dbc288cc
1 changed files with 6 additions and 2 deletions
|
@ -104,10 +104,14 @@ const GodotInputGamepads = {
|
|||
}
|
||||
}
|
||||
GodotEventListeners.add(window, 'gamepadconnected', function (evt) {
|
||||
add(evt.gamepad);
|
||||
if (evt.gamepad) {
|
||||
add(evt.gamepad);
|
||||
}
|
||||
}, false);
|
||||
GodotEventListeners.add(window, 'gamepaddisconnected', function (evt) {
|
||||
onchange(evt.gamepad.index, 0);
|
||||
if (evt.gamepad) {
|
||||
onchange(evt.gamepad.index, 0);
|
||||
}
|
||||
}, false);
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue