Do you have a gamepad? Help me test a library!
(Source/Credits: https://dev.to/alvaromontoro/do-you-have-a-gamepad-help-me-test-a-library-1al1)
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.
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.
Comments section
johannesjo
•May 1, 2024
Nice library! Don't have gamepad with me atm, but I'll give it a go once I'm back in my flat.
mtpiercey
•May 1, 2024
Cool library! With my Logitech Attack 3 (amazon.com/9632910403-Logitech-Win...:)
With a cheapy usb "SNES" controller:
alvaromontoro Author
•May 1, 2024
By the way, we might have the same cheap USB "SNES" controller, because mine has the same issue with those buttons.
alvaromontoro Author
•May 1, 2024
Wow. That's some thorough testing. Thanks a lot! I will definitely need to create a mapping system, so users can "redefine" the buttons because it seems that the different gamepads all follow different layouts. Thanks again for your help.
7twin
•May 1, 2024
I have an xbox 360 controller clone from speedlink, the buttons match all fine (except 16, because that launches the windows game control center) - the joysticks don't light up at all though.
alvaromontoro Author
•May 1, 2024
Thanks for testing! Which example did you try? Was it this one?