Closed satoshinm closed 7 years ago
https://github.com/bwiklund/gamepad.js/blob/master/source/javascripts/all.js.coffee doesn't use gamepadconnected/disconnected events, instead, it polls navigator.getGamepads() in requestAnimationFrame().
Maybe use gamepadconnected as a hint and check the getGamepads() array for truth.
https://github.com/kripken/emscripten/pull/4292/files shows how to do it:
// For previously disconnected gamepads there should be an empty slot (null/undefined/false) at the index.
Fixing in https://github.com/satoshinm/emscripten/commit/608e1bb9cb860ab51fc95a8469a740c72d213d46 Change to sample gamepad data once per frame for glfw, ala GH-4292
Load up NetCraft in Google Chrome, with the controller off. Turn it on, press a button, it is detected (both standard and empty mapping):
then turn it off. Two new joysticks connect on disconnect(?):
These are correctly detected as disconnected on Safari TP 29. Why is Chrome firing ongamepadconnected instead of ongamepaddisconnected?
The test site http://html5gamepad.com/ correctly detects the gamepad disconnections, so check what they are doing. https://github.com/bwiklund/gamepad.js