Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support standard layout on Android #2557

Closed
1 of 10 tasks
divVerent opened this issue Jan 28, 2023 · 1 comment · Fixed by #2596
Closed
1 of 10 tasks

Support standard layout on Android #2557

divVerent opened this issue Jan 28, 2023 · 1 comment · Fixed by #2596

Comments

@divVerent
Copy link
Contributor

Operating System

  • Windows
  • macOS
  • Linux
  • FreeBSD
  • OpenBSD
  • Android
  • iOS
  • Nintendo Switch
  • Xbox
  • Web Browsers

What feature would you like to be added?

IsStandardGamepadLayoutSupported should be implemented for Android

Why is this needed?

SDL_GameControllerDB is far from complete for Android, and also Android already provides its own mostly correct mappings. Buttons and axes already are named similar to Linux standard layout ones.

This issue is similar to #2052 in that the solution is very similar. It appears like Android even uses the same axis/button constant naming as the Linux kernel itself, even though the documentation seems to swap ABS_RX/ABS_Z and ABS_RY/ABS_RZ between the two (but based on my sample size of ONE game pad, it's not actually swapped in the implementation).

@divVerent
Copy link
Contributor Author

Also, what makes this actually more important, it's sadly rather hard to actually make one's own SDL_gamecontrollerdb entry for Android, as IIRC no tools are available to build them.

@hajimehoshi hajimehoshi added this to the v2.6.0 milestone Jan 28, 2023
divVerent added a commit to divVerent/ebiten that referenced this issue Mar 11, 2023
This commit mirrors libsdl-org/SDL#7405
(libsdl-org/SDL@6f1f586).

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.

Fixes hajimehoshi#2557
@hajimehoshi hajimehoshi modified the milestones: v2.6.0, v2.5.0 Mar 12, 2023
hajimehoshi pushed a commit that referenced this issue Mar 12, 2023
This commit mirrors libsdl-org/SDL#7405
(libsdl-org/SDL@6f1f586).

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants