Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement idea for auto-detect buttons in browser ported games #3279

Open
Br4ssman opened this issue Oct 7, 2024 · 0 comments
Open

Improvement idea for auto-detect buttons in browser ported games #3279

Br4ssman opened this issue Oct 7, 2024 · 0 comments
Labels
Emscripten WebAssembly/JavaScript port for web browsers Enhancement Input Input related (gamepads, keyboard mappings, mouse support). For KeyInputProc, add event/interpreter

Comments

@Br4ssman
Copy link

Br4ssman commented Oct 7, 2024

I've been trying to update that function so that if I set up new buttons, all those buttons don't appear in the other games.
Maybe as a simple sketch it could be useful for you to be able to detect this in a different way so that each game loads its buttons.

function updateTouchControlsVisibility() {
  if (hasTouchscreen && Object.keys(gamepads).length === 0) {
    for (const elem of document.querySelectorAll('#dpad, #apad')) {
      elem.style.display = '';
    }

    const urlParams = new URLSearchParams(window.location.search);
    const gameParam = urlParams.get('game');

    if (gameParam !== 'powerchars') {
      const oneButton = document.querySelector('[data-key="One"]');
      if (oneButton) {
        oneButton.style.display = 'none';
      }
    }

  } else {
    for (const elem of document.querySelectorAll('#dpad, #apad')) {
      // Ocultar los controles táctiles
      elem.style.display = 'none';
    }
  }
}

Try in from a touch device or from the browser emulator, try the following links to see different buttons for each game:

Link1: https://netherwareentertainment.com/online/?game=powerchars
Link2: https://netherwareentertainment.com/online/?game=ian-precuela

Download index.html edited: index.zip

@Mimigris Mimigris added Feature Request Emscripten WebAssembly/JavaScript port for web browsers Enhancement Input Input related (gamepads, keyboard mappings, mouse support). For KeyInputProc, add event/interpreter and removed Feature Request labels Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Emscripten WebAssembly/JavaScript port for web browsers Enhancement Input Input related (gamepads, keyboard mappings, mouse support). For KeyInputProc, add event/interpreter
Development

No branches or pull requests

2 participants