From 18f2e401d295bc246526efb44ef3e9994cd05e8c Mon Sep 17 00:00:00 2001 From: Nilsen Filc Date: Wed, 15 Jul 2015 04:51:31 +0200 Subject: [PATCH] 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. --- lime/_backend/native/NativeApplication.hx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lime/_backend/native/NativeApplication.hx b/lime/_backend/native/NativeApplication.hx index fc8645d0e..bfb02bf86 100644 --- a/lime/_backend/native/NativeApplication.hx +++ b/lime/_backend/native/NativeApplication.hx @@ -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; -} \ No newline at end of file +}