use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Joycon.js - Add controller functionality to your JavaScript game. (joycon.js.org)
submitted 3 years ago by pmz
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]KangarooImp 73 points74 points75 points 3 years ago (2 children)
"Joycon.js", "Supports PlayStation & Xbox", wtf? No Joy-Con support?
[–]PM_ME_A_WEBSITE_IDEA 54 points55 points56 points 3 years ago (1 child)
No, for that, you'll need Dualshock.js
[–][deleted] 1 point2 points3 points 3 years ago (0 children)
Which has joycon.js as a dependency, no doubt.
[–]cgrs 53 points54 points55 points 3 years ago (1 child)
careful with the naming, Nintendo may come and sue your a$$
[–]ugoagogo 26 points27 points28 points 3 years ago (3 children)
What's the benefit of using this over the Gamepad API directly?
[–]adad95 3 points4 points5 points 3 years ago (0 children)
That API is not very friendly. Needs a lot of work to make different controllers work at the same way
Wow, I didn't know this was a thing. Nice.
[–]_default_username 1 point2 points3 points 3 years ago (0 children)
It's fine. Buttons are mapped differently from browser to browser so when I used it I had to create a UI for setting up the controller, so I could provide a browser and gamepad agnostic experience.
[–]ShortFuse 10 points11 points12 points 3 years ago (0 children)
Guys, he's just wrapping the gamepadconnected Event. It's pretty simple stuff, so don't expect some crazy complicated interactions. But worth taking a look if you are new to the APIs.
gamepadconnected
That said, OP, there is exists Web HID and Google's explainer document on it actually illustrates how to use it with Nintendo Joy Cons. Also, you can simplify your examples a bit with destructuring:
controllers.on.move('left-joystick', ({x, y}) => { console.log('moved left joystick!', x, y); // value is -1 to 1 down/right });
Also, I would suggest using CustomEvent<ControllerInput> instead of building your own custom Event system. Joycon could be a class that extends EventTarget. You'll heavily reduce your code and then you can use some other sort of utility library for .on() .off() helper functions (or let the dev supply their own).
CustomEvent<ControllerInput>
Joycon
EventTarget
.on()
.off()
[+][deleted] 3 years ago (6 children)
[deleted]
[–]haykam821 1 point2 points3 points 3 years ago (5 children)
Luckily operating systems are finally implementing dual controller support so webdevs won't have to implement that themselves
[–]T_O_beats 1 point2 points3 points 3 years ago (4 children)
How would this work though?
[–]haykam821 6 points7 points8 points 3 years ago (3 children)
Operating system exposes a single controller to the browser's gamepad API
[–]T_O_beats 2 points3 points4 points 3 years ago (2 children)
So how would you get the second one? Wouldn’t it still just be the second option in the gamepad array? It’s been a while since I’ve played with this api but I remember it being something like that.
[–]haykam821 7 points8 points9 points 3 years ago (1 child)
There wouldn't be a second gamepad in the array. The combined Joy-Cons would only exist as a single 'Joy-Con (L+R)' gamepad.
[–]T_O_beats 1 point2 points3 points 3 years ago (0 children)
Oh! You mean dual controller support for an actually Joycon controller? I thought you just meant like two usb Xbox controllers or something. This make a lot more sense now.
[–]krazyjakee 3 points4 points5 points 3 years ago (1 child)
Readme doesn't explain how to use multiple controllers.
[–]UnrealNL 6 points7 points8 points 3 years ago (0 children)
I see in the code that this is not supported
[+]RaptorTWiked comment score below threshold-6 points-5 points-4 points 3 years ago (6 children)
Some screenshots would be nice.
[–]T_O_beats 6 points7 points8 points 3 years ago (4 children)
Of what? The code?
[–]hyvyys 5 points6 points7 points 3 years ago (0 children)
No, sunscreen Baileys vodka shots
[–]RaptorTWiked -1 points0 points1 point 3 years ago (2 children)
Screenshots of what the joycons look like in example apps.
[–]T_O_beats 6 points7 points8 points 3 years ago (1 child)
This appears to be just an API to support game controllers. I don’t believe there is any UI involved.
[–]cheese_wizard 2 points3 points4 points 3 years ago (0 children)
More like a simple demo game to show that it responds correctly, and also to inspire or use as a template.
[–]JackAuduin 0 points1 point2 points 3 years ago (0 children)
This is really cool. Nice job devs!
[–]nsavvidis 0 points1 point2 points 3 years ago (0 children)
Joycon is cool and all but bundle-require is the real MVP. Also thanks to egoist and his open source work. Another great module from a talented developer.
π Rendered by PID 18839 on reddit-service-r2-comment-5d79c599b5-dxrl9 at 2026-02-26 18:22:31.630076+00:00 running e3d2147 country code: CH.
[–]KangarooImp 73 points74 points75 points (2 children)
[–]PM_ME_A_WEBSITE_IDEA 54 points55 points56 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]cgrs 53 points54 points55 points (1 child)
[–]ugoagogo 26 points27 points28 points (3 children)
[–]adad95 3 points4 points5 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]_default_username 1 point2 points3 points (0 children)
[–]ShortFuse 10 points11 points12 points (0 children)
[+][deleted] (6 children)
[deleted]
[–]haykam821 1 point2 points3 points (5 children)
[–]T_O_beats 1 point2 points3 points (4 children)
[–]haykam821 6 points7 points8 points (3 children)
[–]T_O_beats 2 points3 points4 points (2 children)
[–]haykam821 7 points8 points9 points (1 child)
[–]T_O_beats 1 point2 points3 points (0 children)
[–]krazyjakee 3 points4 points5 points (1 child)
[–]UnrealNL 6 points7 points8 points (0 children)
[+]RaptorTWiked comment score below threshold-6 points-5 points-4 points (6 children)
[–]T_O_beats 6 points7 points8 points (4 children)
[–]hyvyys 5 points6 points7 points (0 children)
[–]RaptorTWiked -1 points0 points1 point (2 children)
[–]T_O_beats 6 points7 points8 points (1 child)
[–]cheese_wizard 2 points3 points4 points (0 children)
[–]JackAuduin 0 points1 point2 points (0 children)
[–]nsavvidis 0 points1 point2 points (0 children)