Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

121
Views
What do I have to add to my JS driven game to interact With an external game joystick/controller?

What do I have to add to my JS driven game to interact With an external game joystick/controller?

What I have is a JS-driven game with buttons to control movement of a Paddle so it can “hit” a game piece.

I only have <button>s to click. What do I have to add to my JS driven game to interact with an external game joystick/controller to click on.

I do nothing with mouseX or mouseY, just these clickable buttons.

The game piece bounces off 4 walls. It is the job of the user to steer the Paddle so it “hits” the game piece.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think you could use the html5 gamepad API if you're doing this in the browser. Just make sure to check out the browser compatibility section.

This blog post looks pretty good but here's a snippet from there.

// https://beej.us/blog/data/javascript-gamepad/
// Show button state

let gamepads = navigator.getGamepads();

// Blindly assuming this is connected
let gp = gamepads[0];

// Blindly assuming there's a button
let button = gp.buttons[0];

if (button.pressed) {
    console.log("Button pressed!");
} else {
    console.log("Button not pressed");
}

console.log("Button value: " + button.value);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!