Commit Graph

46 Commits

Author SHA1 Message Date
Hajime Hoshi
2c8a2a584f internal/gamepaddb: update the database
This adopts the commit e72ff9cb76

Closes #2766
2023-09-18 21:20:10 +09:00
Hajime Hoshi
0dcfa5f54b Revert "internal/gamepaddb: update the database"
This reverts commit 4375fffcbe.

Reason: test failures
2023-09-18 19:23:45 +09:00
Hajime Hoshi
4375fffcbe internal/gamepaddb: update the database
This adopts the commit 8adb15e0a2
2023-09-18 19:07:01 +09:00
divVerent
10c1b56e62
cmd/ebitenmobile: fix Xbox-ish gamepad axis assignment (#2596)
This commit mirrors https://github.com/libsdl-org/SDL/pull/7405
(6f1f586086).

Note that for SDL, this code is used a lot less than for Ebitengine, as SDL
mostly migrated to HIDAPI and direct USB device access rather than using
Android's APIs. For Bluetooth devices, however, the Java APIs are used the
same way.

This was the remaining problem to be solved to automatically support standard
layout on most standard gamepads (this should cover most Xbox-ish and PS-ish
gamepads on the market).

In particular this covers gamepads with the following assignment:

- Left stick = X/Y, right stick = Z/RZ, triggers = LEFTTRIGGER/RIGHTTRIGGER
  (which basically is what Android docs say and some PS gamepads do)

- Left stick = X/Y, right stick = RX/RY, triggers = Z/RZ
  (Xbox gamepad style, apparently)

- Left stick = X/Y, right stick = RX/RY, triggers = LEFTTRIGGER/RIGHTTRIGGER
  (Not sure if this exists, but it's conceivable)

As we found on the SDL pull request discussion, gamepads that offer flight
controls (e.g. THROTTLE and RUDDER) will likely not work well, before and
after this change.

Closes #2557
2023-03-12 22:32:30 +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
628418d88e internal/gamepaddb: update the database 2023-02-02 22:00:34 +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
Hajime Hoshi
6ed5293132 internal/gamepaddb: update gamepad db 2022-12-12 02:50:58 +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
a4b9d3c241 internal/gamepaddb: update the database
Adopts 74ebd51889
2022-08-19 02:54:03 +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
20beb9d2b8 internal/gamepaddb: update the database
Updates #1902
2022-04-06 11:41:05 +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
a89e9d9368 internal/gamepaddb: update the database file
Updates #1903
2021-12-27 01:18:03 +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
52d917eff0 go generate 2021-09-25 03:45:17 +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