5fd789d1f73bab4604f132e78038e15ecc050d68
[platform/upstream/SDL.git] / test / emscripten / joystick-pre.js
1 Module['arguments'] = ['0'];
2 //Gamepads don't appear until a button is pressed and the joystick/gamepad tests expect one to be connected
3 Module['preRun'].push(function()
4 {
5     Module['print']("Waiting for gamepad...");
6     Module['addRunDependency']("gamepad");
7     window.addEventListener('gamepadconnected', function()
8     {
9         //OK, got one
10         Module['removeRunDependency']("gamepad");
11     }, false);
12
13     //chrome
14     if(!!navigator.webkitGetGamepads)
15     {
16         var timeout = function()
17         {
18             if(navigator.webkitGetGamepads()[0] !== undefined)
19                 Module['removeRunDependency']("gamepad");
20             else
21                 setTimeout(timeout, 100);
22         }
23         setTimeout(timeout, 100);
24     }
25 });