general fixes

This commit is contained in:
e7d 2016-09-14 00:10:26 +02:00
parent c571069b2f
commit 0a59840516
2 changed files with 16 additions and 3 deletions

View File

@ -12,7 +12,7 @@
<script src="js/vendor/modernizr-2.8.3.min.js"></script>
</head>
<body>
<div class="gamepad white"></div>
<div class="gamepad"></div>
<script src="js/vendor/jquery-2.2.3.min.js"></script>
<script src="js/gamepad.js"></script>

View File

@ -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++) {