Guard against doppleganger gamepad connection

Gamepad connect can fire twice in a row the event for the same device (tested on Mac OSX). Prevent that.
This commit is contained in:
Nilsen Filc
2015-07-15 04:51:31 +02:00
parent e9a579384f
commit 18f2e401d2

View File

@@ -144,9 +144,11 @@ class NativeApplication {
case CONNECT:
var gamepad = new Gamepad (gamepadEventInfo.id);
Gamepad.devices.set (gamepadEventInfo.id, gamepad);
parent.window.onGamepadConnect.dispatch (gamepad);
if (!Gamepad.devices.exists(gamepadEventInfo.id)) {
var gamepad = new Gamepad (gamepadEventInfo.id);
Gamepad.devices.set (gamepadEventInfo.id, gamepad);
parent.window.onGamepadConnect.dispatch (gamepad);
}
case DISCONNECT:
@@ -753,4 +755,4 @@ private class WindowEventInfo {
var WINDOW_RESIZE = 9;
var WINDOW_RESTORE = 10;
}
}