Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

120
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda