Skip to content

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

Open
@Br4ssman

Description

@Br4ssman

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    EmscriptenWebAssembly/JavaScript port for web browsersEnhancementInputInput related (gamepads, keyboard mappings, mouse support). For KeyInputProc, add event/interpreter

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions