From 0a598405163a45638e588dc1053f8354365cefe2 Mon Sep 17 00:00:00 2001 From: e7d Date: Wed, 14 Sep 2016 00:10:26 +0200 Subject: [PATCH] general fixes --- index.html | 2 +- js/gamepad.js | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index e5c7623..778ea6c 100644 --- a/index.html +++ b/index.html @@ -12,7 +12,7 @@ -
+
diff --git a/js/gamepad.js b/js/gamepad.js index f3309a8..846e653 100644 --- a/js/gamepad.js +++ b/js/gamepad.js @@ -1,13 +1,22 @@ +$.urlParam = function(name) { + var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href); + if (results === null) { + return null; + } else { + return decodeURIComponent(results[1]) || 0; + } +}; + var haveEvents = 'ongamepadconnected' in window; var gamepads = {}; var $gamepad = $('.gamepad'); var gamepadIdentifiers = { 'ds4': { - 'id': /Vendor: 054c Product: 05c4/, + 'id': /054c.*?05c4/, 'colors': ['black', 'white', 'red', 'blue'] }, 'xbox-one': { - 'id': /XInput/, + 'id': /xinput|XInput/, 'colors': ['black', 'white'] } }; @@ -130,6 +139,10 @@ function updateVisualStatus() { var gamepads = getGamepads(); var activeGamepad = gamepads[activeGamepadIndex]; + if (!activeGamepad) { + return; + } + var button; var $button; for (var buttonIndex = 0; buttonIndex < activeGamepad.buttons.length; buttonIndex++) {