title: Do you have a gamepad? Help me test a library! published: true description: This past week I got to learn and play with the Gamepad API (which allows to control gamepads/joysticks on the browser using JavaScript)... and the result was GameController. tags: help,test,showdev,javascript cover_image: https://thepracticaldev.s3.amazonaws.com/i/fymrsphk1w4jhkd7rv9g.png canonical_url: https://alvaromontoro.com/blog/67840/do-you-have-a-gamepad-help-me-test-a-library


This past week I got to learn and play with the Gamepad API (which allows to control gamepads/joysticks on the browser using JavaScript)... and I must say, it was a lot of fun.

After running tests and creating some demos, the result was GameController.js: a lightweight JS library to simplify the API interface and make it easier to use on web applications and games. Still at an early stage, but fully working.

...But I have a problem: the gamepad I used for testing is a SNES replica that only has 8 buttons and 1 joystick/axe, and the API supports a standard 17-button and 2 joysticks/axes gamepad. So I haven't been able to test the whole functionality 😅

If you have a gamepad/joystick for your computer, please give it a try. Test the demo page below or the ones on github, and let me know what you think. All feedback is welcome.

Thanks! 😊


Demo (you may need to open it on a new page):

  • Select button will reset the game
  • Start button will start a new game after reset
  • Right/Left joystick/buttons to move the paddle

{% codepen https://codepen.io/alvaromontoro/pen/OJLpBbw %}

If you don't have a gamepad, you can see a video of the API at work here and another video here.