hajimehoshi / ebiten

Ebitengine - A dead simple 2D game engine for Go
https://ebitengine.org
Apache License 2.0
11.01k stars 659 forks source link

Different gamepad button numbers when running locally vs in wasm #3079

Closed Palessan closed 2 months ago

Palessan commented 2 months ago

Ebitengine Version

v2.7.8

Operating System

Go Version (go version)

1.22.5

What steps will reproduce the problem?

Run your examples\gamepad\main.go locally and on wasm. When you press the same buttons (for example middle central button and touchpad) you will see that they are are mapped to different button numbers:

    GPButtonMiddle    = ebiten.GamepadButton12
    GPButtonMiddleWeb = ebiten.GamepadButton16 // dpad-left on not wasm

    GPButtonTouchPad    = ebiten.GamepadButton13
    GPButtonTouchPadWeb = ebiten.GamepadButton17  // dpad-top on not wasm

This is a problem since the touchpad is the left DPad up for example

What is the expected result?

i would expect the same key number to be used in both local application and wasm

What happens instead?

different key numbers on same buttons when run in local application vs wasm

Anything else you feel useful to add?

If you would add the middle central button and touchpad as an ebiten.StandardGamepadButton, then i could use that instead of using the older(?) ebiten.GamepadButtonXX

hajimehoshi commented 2 months ago

This is expected. Button mappings vary among platforms.

To mitigate the issue, use StandardGamepadButton.

hajimehoshi commented 2 months ago

If you would add the middle central button and touchpad as an ebiten.StandardGamepadButton

Unfortunately I cannot control this (how the center touch pad is assigned)

hajimehoshi commented 2 months ago

b34f9977f6d36ca054178071641933a5ed24745c might change the situation as this updated the gamepad database.

Palessan commented 2 months ago

(forgot to mention that the gamepad is a PS4 controller) Found the StandardGamepadButtonCenterCenter as middle center which solves all my issues. Any idea about touchpad?

Palessan commented 2 months ago

b34f997 might change the situation as this updated the gamepad database.

no change unfortunately

hajimehoshi commented 2 months ago

Any idea about touchpad?

There is no easy solution. If a browser doesn't treat the touchpad as a pointer device, there is nothing we can do.