Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added XBox controller mapping for Chrome under Linux #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion example/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<!doctype html>
<html>
<head>
<script src="../gamepad.js"></script>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Gamepad.js Demo</title>
<script src="../gamepad_uncompressed.js"></script>
</head>
<body>
<h1 id='title'></h1>
Expand Down Expand Up @@ -81,8 +83,16 @@ <h1 id='title'></h1>
}
}

if (!Date.now) Date.now = function () { return new Date().getTime(); };
var lastTime = Date.now();
function update() {
window.requestAnimationFrame(update);
// limit framerate:
var time = Date.now();
if ((time - lastTime) < 100/3) {
return;
}
lastTime = time;

var pads = Gamepad.getStates();
for (var i = 0; i < pads.length; ++i) {
Expand Down
29 changes: 19 additions & 10 deletions gamepad_uncompressed.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.