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
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
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
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
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
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
* 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
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.