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

feat(joystick): add support for Android gamepad features #4626

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ThomasKuehne
Copy link
Contributor

@ThomasKuehne ThomasKuehne commented Feb 11, 2024

here be dragons - diverse tests required, USB HID support is sometimes ... picky

enhancements to the USB joystick - all Google mandated features for Android gamepads, except for the back key, are supported

  • new sim axis Accelerator (Acc), Break (Brk) and Steering (Steer)
  • new sim axis D-pad (dpad) also known as HAT switch
  • new joystick circular cutout mode "X-Y, Z-rZ"
  • mixing physical axis and sim axis now works
  • buttons are sparse - no need to configure buttons 0-5 if you only need button 6 or do remapping on the host

For Android use the USB Joystick Mode "Advanced" with "If.mode" Gamepad:

EdgeTX Android Linux USB HID
axis X left axis X ABS_X X
axis Y left axis Y ABS_Y Y
axis Z left axis X ABS_Z Z
axis rotZ left axis Y ABS_RZ Rz
sim Acc 1 right trigger ABS_GAS Accelerator
sim Brk 1 left trigger ABS_BRAKE Break
sim HAT 2 D-pad ABS_HAT0X / ABS_HAT0Y Hat Switch
button 0 A BTN_SOUTH Button 1
button 1 B BTN_EAST Button 2
button 2 C 3 BTN_C Button 3
button 3 X BTN_NORTH Button 4
button 4 Y BTN_WEST Button 5
button 5 Z 3 BTN_Z Button 6
button 6 left shoulder button BTN_TL Button 7
button 7 right shoulder button BTN_TR Button 8
button 8 L2 3 BTN_TL2 Button 9
button 9 R2 3 BTN_TR2 Button 10
button 10 select 3 BTN_SELECT Button 11
button 11 start 3 BTN_START Button 12
button 12 mode 3 BTN_MODE Button 13
button 13 left stick click BTN_THUMBL Buton 14
button 14 right stick click BTN_THUMBR Button 15

notes:

  • translation work required
    • TR_VUSBJOYSTICK_CH_SIM has 4 additional values for the new axis
    • TR_VUSBJOYSTICK_CIRC_COUTOUT has 1 additional value for the new circular cutout mode
  • button numbering between EdgeTX and the USB HID standard is off by one, resolving that would likely be a breaking change in the UI
  • is based on the battery capacity pull request feat: add battery level reporting to USB HID joystick #4602

Footnotes

  1. triggers - check Update contribute-to-the-user-manual.md edgetx-user-manual#11 how to feed these half axis 2

  2. D-pad - check Update contribute-to-the-user-manual.md edgetx-user-manual#11 how to feed this special axis

  3. these do work on most Android devices, however their support isn't mandatory 2 3 4 5 6 7

@ThomasKuehne ThomasKuehne changed the title feat(joystick) add support for all Android gamepad features feat(joystick) add support for Android gamepad features Feb 11, 2024
@ulfhedlund
Copy link
Contributor

ulfhedlund commented Feb 14, 2024

SE translation:
#define TR_VUSBJOYSTICK_CH_SIM "Ske","Hjd","Rod","Gas", "Acc", "Brms", "Styr","dpad"

@ThomasKuehne
Copy link
Contributor Author

ThomasKuehne commented Feb 17, 2024

Suggested layouts for tests:

channel Android Betaflight Dualsense EdgeTX pre 2.9 EdgeTX Classic
CH1 axis X axis X axis X axis X axis X
CH2 axis Y axis Y axis Y axis Y axis Y
CH3 axis Z axis Z axis Z axis Z axis Z
CH4 axis rotZ axis rotX axis rotZ axis rotX axis rotX
CH5 sim Brk axis rotZ axis rotX axis rotY axis rotY
CH6 sim Acc axis rotY axis rotY axis rotZ axis rotZ
CH7 - axis Slider - axis Slider axis Slider
CH8 sim Dpad axis Dial sim Dpad axis Slider axis Dial
CH9 button 0 button 0 button 0 button 0 button 0
CH10 button 1 button 1 button 1 button 1 button 1
CH11 - button 2 button 2 button 2 button 2
CH12 button 3 button 3 button 3 button 3 button 3
CH13 button 4 button 4 button 4 button 4 button 4
CH14 - button 5 button 5 button 5 button 5
CH15 button 6 button 6 button 6 button 6 button 6
CH16 button 7 button 7 button 7 button 7 button 7
CH17 button 8 - button 8 button 8 button 8
CH18 button 9 - button 9 button 9 button 9
CH19 button 10 - button 10 button 10 button 10
CH20 button 11 - button 11 button 11 button 11
CH21 button 12 - button 12 button 12 button 12
CH22 button 13 - button 13 button 13 button 13
CH23 button 14 - button 14 button 14 button 14
CH24 - - - button 8POS (15-23) button 8POS (15-23)

Stick to the order the axis are declared. Applications are supposed to read axis IDs however many do not and use different kinds of position index instead.

Similar layouts:

other controller use layout
OpenTX EdgeTX pre 2.9
Orqa FPV.Ctrl EdgeTX pre 2.9
Stadia Android - use buttons 0-1, 3-4, 6-7, 10-14 and 16-19
Xbox Android - use buttons 0-14

@ThomasKuehne ThomasKuehne marked this pull request as ready for review February 18, 2024 20:16
ThomasKuehne added a commit to ThomasKuehne/edgetx-user-manual that referenced this pull request Feb 28, 2024
@ThomasKuehne
Copy link
Contributor Author

Items resolved during compability testing:

  1. dpad axis was displaced by about 0.5%
  2. the sim Steering axis is commonly supported on Linux and on some Android devices
  3. an additional circular cutout mode "X-Y, Z-rZ" was needed

Anybody else finding functional items gets a cookie 🍪

@pfeerick pfeerick added this to the 2.11 milestone Mar 6, 2024
@pfeerick pfeerick self-requested a review March 18, 2024 09:53
@ThomasKuehne ThomasKuehne reopened this Apr 5, 2024
@ThomasKuehne
Copy link
Contributor Author

Sorry for that - commit history is now squashed and without any merge commits.

@pfeerick
Copy link
Member

pfeerick commented Apr 5, 2024 via email

@ThomasKuehne
Copy link
Contributor Author

No worries.
The cause for the initial merge approach were the concurrent translation updates - especially Portuguese and Ukrainian - leading to merge conflicts.

@pfeerick pfeerick changed the title feat(joystick) add support for Android gamepad features feat(joystick): add support for Android gamepad features May 12, 2024
Some applications with direct HID raw processing expect
require D-Pad keys instead of the POV axisw.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants