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