# Conflicts:
#	index.html
#	js/gamepad.js
This commit is contained in:
e7d 2017-05-09 23:26:10 +02:00
commit d99b4801d0
3 changed files with 15 additions and 14 deletions

View File

@ -14,7 +14,7 @@ body {
}
.no-gamepad {
position: absolute;
bottom: 0;
top: 20px;
display: none;
width: 100vw;
line-height: 2em;

View File

@ -8,12 +8,12 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="favicon.png">
<link rel="stylesheet" href="css/normalize.css?ef81677">
<link rel="stylesheet" href="css/main.css?ef81677">
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<div class="debug">Debug</div>
<div class="no-gamepad">No active gamepad. Press <kbd>H</kbd> to see how it works.</div>
<div class="no-gamepad">No active gamepad detected. Press <kbd>H</kbd> to read instructions.</div>
<div class="gamepad"></div>
<div class="help">
<h2>Help</h2>
@ -63,6 +63,6 @@
</div>
<script src="https://static.e7d.io/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="js/gamepad.js?ef81677"></script>
<script src="js/gamepad.js"></script>
</body>
</html>

View File

@ -1,4 +1,4 @@
// (function(window, document, undefined) {
(function(window, document, undefined) {
$.urlParam = function(name) {
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
if (results === null) {
@ -10,6 +10,7 @@
var haveEvents = 'ongamepadconnected' in window;
var debug = false;
var scanGamepadsDelay = 1000;
var gamepads = {};
var $gamepad = $('.gamepad');
var $nogamepad = $('.no-gamepad');
@ -17,20 +18,20 @@
var $help = $('.help');
var gamepadIdentifiers = {
'debug': {
'id': /xinput|XInput/,
'id': /debug/,
'colors': []
},
'ds4': {
'id': /054c.*?05c4/,
'colors': ['black', 'white', 'red', 'blue']
},
// 'xbox-one': {
// 'id': /xinput|XInput/,
// 'colors': ['black', 'white']
// }
'xbox-one': {
'id': /xinput|XInput/,
'colors': ['black', 'white']
}
};
var gamepadHelpTimeout = null;
var gamepadHelpDelay = 10000;
var gamepadHelpDelay = 5000;
var activeGamepadIndex = null;
var activeGamepadType = null;
var activeGamepadIdentifier = null;
@ -113,7 +114,7 @@
displayGamepadHelp();
}
setInterval(scanGamepads, 500);
setInterval(scanGamepads, scanGamepadsDelay);
function scanGamepads() {
if (null !== activeGamepadIndex) {
return;
@ -319,4 +320,4 @@
$debug[debug ? 'fadeIn' : 'fadeOut']();
}
// })(window, document);
})(window, document);