Commit Graph

29 Commits

Author SHA1 Message Date
Hajime Hoshi
b7dd45c0e4 internal/gamepad: ignore the very first MotionEvent with 0 value for Android
On Android, MotionEvent with 0 values might come for axes when connecting
a gamepad, even though a user didn't touch any axes. This is problematic
especially for tirgger axes, where the default value should be -1.

This change fixes the issue by adding a new state `axesReady` to check
if an axis is really touched or not. If an axis is not touched yet,
a button value for a standard (trigger) button always returns 0.

This change also removes an old hack to initialize axis values for
triggers.

Closes #2598
2024-03-21 22:28:48 +09:00
Hajime Hoshi
696938987d internal/gamepad: use locks for consistency
Perhaps Gamepad's m might not be needed, but let's use the lock for
consistency for the current situation.
2024-03-16 16:31:49 +09:00
Hajime Hoshi
047858aa59 internal/gamepaddb: rename functions 2024-03-16 15:16:29 +09:00
divVerent
809ad991c2
internal/gamepad: refactor standard layout support to allow remapping in the per-platform implementations. (#2588)
Refactors native standard layout so standard axes and buttons can be implemented using any of axes, buttons or hats.

This is required to be able to implement a native standard layout mapping for Linux, as e.g. shoulder buttons can be
backed either by an analog or digital input.

Precedes #2587

Updates #2052
2023-03-03 23:29:04 +09:00
Hajime Hoshi
b278e5521f internal/gamepad: rename variables 2023-03-03 21:17:47 +09:00
Pierre Curto
4de807cc44
all: fix typos (#2558)
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2023-01-28 19:06:38 +09:00
Artem Yadelskyi
10415d417a
all: replace interface{} with any (#2430)
Closes #2429
2022-11-03 15:33:09 +09:00
Hajime Hoshi
db1255cdf8 internal/gamepad: rename ButtonNum -> ButtonCount 2022-09-07 15:40:52 +09:00
Hajime Hoshi
094726915b
ebiten: add IsStandardGamepadAxisAvailable and IsStandardGamepadButtonAvailable (#2241)
Closes #2040
2022-08-11 12:35:20 +09:00
Hajime Hoshi
847c4f067a internal/gamepad: make nativeGamepad(s) interfaces
This is a preparation to switch the gamepad implementation for Xbox.

Updates #2084
2022-06-24 21:52:48 +09:00
Hajime Hoshi
0cd43bd081 internal/gamepad: stop embedding a member into a struct
This is a preparation to switch the gamepad implementation for Xbox.

Updates #2084
2022-06-24 19:01:50 +09:00
Hajime Hoshi
2eb4ef1a94 internal/gamepad: give a window from another package instead of GetActiveWindow
GetActiveWindow doesn't work on Xbox.

Updates #2084
2022-06-03 18:42:54 +09:00
Hajime Hoshi
07a7aca1b3 internal/gamepad: skip gamepads with more than 32 buttons
This change was removed at ef45058037
accidentally.

Updates #1173
Updates #2039
2022-04-01 02:24:15 +09:00
Hajime Hoshi
67663795fd internal/gamepaddb: move driver.StandardGamepadButton to gamepaddb.StandardButton 2022-02-05 23:11:09 +09:00
Hajime Hoshi
1bee10f999 internal/gamepad: move constants from internal/driver 2022-02-05 22:42:14 +09:00
Hajime Hoshi
f3f8f6177c internal/gamepad: add gamepad_null.go 2022-02-02 02:18:02 +09:00
Hajime Hoshi
ea39fca10c internal/gamepad: rename functions *Num -> *Count 2022-02-02 02:01:46 +09:00
Hajime Hoshi
a8576008f0 internal/gamepads: refactoring: remove a struct member 2022-02-02 00:32:29 +09:00
Hajime Hoshi
f5b68e5dc1 internal/gamepad: implement for Windows
Updates #1452
Updates #1764
2022-02-01 13:23:05 +09:00
Hajime Hoshi
e261951946 internal/gamepad: remove nativeGamepad.present 2022-01-30 18:59:25 +09:00
Hajime Hoshi
178a1d929c internal/gamepad: add comments and make Vibrate concurrent-safe 2022-01-29 03:50:43 +09:00
Hajime Hoshi
1d59023649 internal/gamepad: make the APIs concurrent-safe again 2022-01-29 03:41:47 +09:00
Hajime Hoshi
2e9ce94ed0 internal/gamepad: call init in update to make the initialization faster 2022-01-29 03:06:56 +09:00
Hajime Hoshi
d3cf8935e8 internal/gamepad: add comments 2022-01-29 02:22:10 +09:00
Hajime Hoshi
71e17efd80 internal/gamepad: simplify the implementation by making the APIs concurrent-unsafe 2022-01-29 02:07:15 +09:00
Hajime Hoshi
5edfd1b743 internal/gamepad: move the implementation of gamepad for GOOS=js
Updates #1957
2022-01-29 01:44:42 +09:00
Hajime Hoshi
fb3a022327 ebiten: use the DB's name for GamepadName
Updates #1949
2022-01-25 21:14:03 +09:00
Hajime Hoshi
580307f150 internal/gamepad: bug fix: go-vet failed
Updates #1452
2022-01-23 01:56:14 +09:00
Hajime Hoshi
ff24f7718c internal/uidriver/glfw: use an original implementation for macOS
Updates #1452
2022-01-23 01:48:24 +09:00