Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

122
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda