Commit Graph

43 Commits

Author SHA1 Message Date
Kenny
941c97eba2
internal/gamepaddb: generate respective controller dbs for each platform (#2943)
Replace singular embedded controller database file with separate generated
files for each supported platform. The controller database file is some
~500KB, so this change should reduce the overall binary size per
platform.

Closes #2936
2024-03-29 13:17:16 +09:00
Hajime Hoshi
6552ae1dbe internal/gamepaddb: do not include the database for browsers
This reduces Wasm binary size by 525kb.
2024-03-24 20:16:11 +09:00
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
9faa3f4601 internal/gamepaddb: refactoring 2024-03-16 17:57:52 +09:00
Hajime Hoshi
209dc50f72 internal/gamepaddb: refactoring 2024-03-16 15:37:42 +09:00
Hajime Hoshi
047858aa59 internal/gamepaddb: rename functions 2024-03-16 15:16:29 +09:00
Hajime Hoshi
df68cbfc5b internal/gamepaddb: update the database 2024-02-21 20:36:46 +09:00
Hajime Hoshi
22715cd2d5 internal/gamepaddb: refactoring 2023-12-24 23:41:44 +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
divVerent
47de8027b9
internal/gamepaddb: fix mapping support for e.g. dpleft:-a0. (#2335)
SDL interprets this as "map -1 to 1, map 0 to -1", so we should do the same.

This fix contains two parts:
* Fix the intended output range.
* Also fix the formula to map a range to a range.
The fix does not change behavior if a "-a" mapping isn't used, as in any other case max-min == 1 or max+min == 0.

Fixes #2334
2022-09-20 00:34:46 +09:00
Hajime Hoshi
129f201be4 internal/gamepaddb: use go:embed
Updates #1258
2022-09-17 21:02:07 +09:00
Hajime Hoshi
619a2ee4dd internal/gamepaddb: use runtime.GOOS instead of a build tag
Updates #1415
2022-09-15 00:27:11 +09:00
Hajime Hoshi
47558d20c5 internal/gamepaddb: enable the database for Android
Before this fix, the button and axis IDs are from the OS. These
didn't match with the SDL game controller databaes unfortunately.

This fix changes the assignments of the buttons and the axes to match
with the database.

Closes #2312
2022-09-09 22:20:39 +09:00
Hajime Hoshi
a9653d1e7a internal/gamepaddb: fix hat assignments for Android
Now Ebitengine's original mapping works, but the database doesn't
work due to differences of button assignments. Fix this later.

Updates #2309
2022-09-08 00:20:31 +09:00
Hajime Hoshi
4a851bcf27 internal/gamepaddb: fix the assignment of axes for Android
Updates #2309
2022-09-07 23:09:58 +09:00
Hajime Hoshi
f414e25b9d internal/gamepaddb: fix some button assignments for Android
Updates #2309
2022-09-07 15:54:14 +09:00
Hajime Hoshi
b5d755b07a Revert "internal/gamepaddb: fix button assignments on Android"
This reverts commit e161b28bff.

Reason: this would break backward compatibility

Updates #2309
2022-09-07 15:37:22 +09:00
Hajime Hoshi
e161b28bff internal/gamepaddb: fix button assignments on Android
Updates #2309
2022-09-07 15:34:29 +09:00
Hajime Hoshi
f383580d7b internal/gamepad: bug fix: wrong ID usages on Android
* IDs should have been decoded to a byte slice before checking the
  value.
* Ebitengine doesn't treat HID devices on Android so far, so checking
  whether the device was HID or not didn't make sense.

Updates #2309
2022-09-07 01:05:14 +09:00
Hajime Hoshi
b858f36d54 remove the dependency on file2byteslice
Specify the version explicitly instead.
2022-08-23 16:34:55 +09:00
Hajime Hoshi
094726915b
ebiten: add IsStandardGamepadAxisAvailable and IsStandardGamepadButtonAvailable (#2241)
Closes #2040
2022-08-11 12:35:20 +09:00
divVerent
21207f827c
do not require installing file2byteslice to update go generate'd files. (#2221)
The tool is already referenced in go.mod, so it is trivial to just go run it -
that way, go generate can use it without the user explicitly installing it first.
2022-07-29 20:43:23 +09:00
Hajime Hoshi
3eeb401d22 internal/gamepaddb: refactoring 2022-07-29 12:17:55 +09:00
Hajime Hoshi
bacb630c5b internal/gamepaddb: bug fix: don't panic with invalid inputs
Closes #2218
2022-07-29 12:14:20 +09:00
Hajime Hoshi
dc811f9329 internal/gamepaddb: bug fix: crash at addAndroidDefaultMappings
Closes #2076
2022-04-19 23:36:02 +09:00
Hajime Hoshi
33078c764c internal/gamepaddb: make Update atomic
Closes #1978
2022-04-02 20:19:04 +09:00
Hajime Hoshi
93b2a0756b internal/gamepaddb: allow the standard layout mapping for any platforms
Closes #1957
2022-02-06 03:38:02 +09:00
Hajime Hoshi
67663795fd internal/gamepaddb: move driver.StandardGamepadButton to gamepaddb.StandardButton 2022-02-05 23:11:09 +09:00
Hajime Hoshi
d2afbd43cc internal/gamepaddb, mobile/ebitenmobileview: refactoring 2022-02-03 04:35:55 +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
edff1f0dd9 internal/gamepaddb: enable mappings for iOS
Updates #1557
Closes #1722
2022-01-09 17:57:09 +09:00
Hajime Hoshi
8334ca9a18 iternal/gamepaddb: update TODO comments 2022-01-09 04:02:00 +09:00
Hajime Hoshi
4106fb15fe internal/gamepaddb: implement the mappings for Android
Updates #1557
2022-01-09 03:29:19 +09:00
Hajime Hoshi
56c5bec908 internal/gamepaddb: Do not fetch the database file on go:generate
This is too aggressive and sometimes risky to update the database
file always when go-generate is executed.
2021-09-25 04:03:19 +09:00
Hajime Hoshi
9ab6758b7a internal/gamepaddb: Remove some hacks for wrong formats 2021-09-25 03:56:06 +09:00
Hajime Hoshi
a0be4a302c internal/gamepaddb: Bug fix: A mapping for an axis/button might be missing
Closes #1825
2021-09-25 00:58:06 +09:00
Hajime Hoshi
f64a946052 internal/gamepaddb: Use XInput's trigger threshold 2021-09-23 15:25:27 +09:00
Hajime Hoshi
226378da88 internal/gamepaddb: Bug fix: ButtonValue must return [0, 1] 2021-09-23 15:18:16 +09:00
Hajime Hoshi
ea12ede127 ebiten: Add StandardGamepadButtonValue
Closes #1721
2021-09-12 21:00:48 +09:00
Hajime Hoshi
f23dadb8ae
Add internal/gamepaddb (#1805)
This is basically a revert of 93a156a718.
This implements parsing the SDL gamepad mappings by Ebiten instead
of GLFW, so that Ebiten can handle parsing errors completely.

Closes #1802
2021-09-11 22:46:05 +09:00
Hajime Hoshi
93a156a718 internal/uidriver/glfw: Use glfwGameGamepadState
This change replaces the usage of gamepaddb package with glfwGetGamepadState.

Updates #1557
2021-07-21 16:09:30 +09:00
Hajime Hoshi
ee4ec5047e internal/gamepaddb: Support general XInput devices 2021-07-21 14:38:47 +09:00
Hajime Hoshi
aa694be6f6 ebiten: Add the standard gamepad layout
This change introduces the standard gamepad layout. This changes adds
these APIs:

  * func HasGamepadStandardLayoutMapping
  * func IsGamepadStandardButtonPressed
  * func GamepadStandardAxisValue
  * type StandardGamepadButton
  * type StandardGamepadAxis

The standard gamepad layout is based on the web standard. See
https://www.w3.org/TR/gamepad/#remapping.

On desktops, the SDL's gamecontrllerdb.txt is used. If the gamepad is
listed in the text file, the mapping works. GLFW's mapping featrue is
not used.

On browsers, the property of a gamepad 'mapping' is used. When the
mapping value is 'standard', the gamepad is recognized to have the
standard mapping.

On mobiles, the implementation is still WIP.

Updates #1557
2021-07-20 01:32:28 +09:00