summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/gamepad/getgamepads-polling-manual.html
blob: 4330fec5a59340856ed24d37849f4896c0b584c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<!doctype html>
<html>
<head>
<title>Manual Gamepad getGamepads polling tests</title>
<link rel="help" href="https://w3c.github.io/gamepad/#navigator-interface-extension">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({explicit_timeout: true});
// Poll until we see a gamepad.
var id = setInterval(function() {
  var gamepads = navigator.getGamepads();
  var found = null;
  for (var i = 0; i < gamepads.length; i++) {
    if (gamepads[i]) {
      found = gamepads[i];
      break;
    }
  }
  if (found) {
    clearInterval(id);
    done();
  }
}, 15);
</script>
</head>
<body>
<p>This test requires a gamepad. Connect one and press any button to start the test.</p>
</body>
</html>