I built noordstar/elm-gamepad, a small library that helps users add controller support for their Elm apps. Using the following JavaScript function,
navigator.getGamepads();
Web developers can add support for controllers to their Elm apps (or games). If you port this function to Elm, you can use Gamepad.decoder
to decode the JSON, and then use the other functions to extract the right data from the file.
Please check out this live demo! Connect a game controller and test all the buttons.
As a sidenote, not all controllers function properly in the browser. So if you’d like to check the configuration of a controller, please send your test results to me, so that I can write a patch and add compatibility for unusual/off-brand/broken/old controllers.