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 10 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 "advanced joystick howto" for EdgeTX/edgetx#4626 edgetx-user-manual#29 how to feed these half axis 2

  2. D-pad - check "advanced joystick howto" for EdgeTX/edgetx#4626 edgetx-user-manual#29 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
Copy link
Member

@pfeerick pfeerick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Did some ... testing ... with FPV Skydive on phone with TX16S as well as checking axis all seem ok on Computer using Gamepad tester.

Used recommended Android order with channels in RTAE order to get the axis right per matching "Gamepad Tester" controller layout on Android...
https://manual.edgetx.org/edgetx-how-to/configure-advanced-joystick-with-edgetx#common-axis-mapping

@pfeerick
Copy link
Member

pfeerick commented May 29, 2024

Can we get some translations for this please 😃 Will be merged in seven days or when translations complete, whichever comes first.

  • TR_VUSBJOYSTICK_CH_SIM has 4 additional values (last four) for the new axis
  • TR_VUSBJOYSTICK_CIRC_COUTOUT has 1 additional value (the last one) for the new circular cutout mode
#define TR_VUSBJOYSTICK_CH_SIM         "Ail","Ele","Rud","Thr","Acc","Brk","Steer","Dpad"
#define TR_VUSBJOYSTICK_CIRC_COUTOUT   "None","X-Y, Z-rX","X-Y, rX-rY","X-Y, Z-rZ"

@froqstar
Copy link

froqstar commented May 29, 2024

DE

#define TR_VUSBJOYSTICK_CH_SIM         "Quer","Höhe","Seite","Gas","Beschl.","Bremsen","Lenkung","Dpad"
#define TR_VUSBJOYSTICK_CIRC_COUTOUT   "kein","X-Y, Z-rX","X-Y, rX-rY","X-Y, Z-rZ"

How many chars do we have space for? I assumed 5 based on "Steer"

@zyren
Copy link
Contributor

zyren commented May 29, 2024

CN

#define TR_VUSBJOYSTICK_CH_SIM         "横滚","俯仰","航向","油门","加速","刹车","转盘","方向"
#define TR_VUSBJOYSTICK_CIRC_COUTOUT   "无","X-Y, Z-rX","X-Y, rX-rY","X-Y, Z-rZ"

TW

#define TR_VUSBJOYSTICK_CH_SIM         "橫滾","俯仰","航向","油門","加速","剎車","轉盤","方向"
#define TR_VUSBJOYSTICK_CIRC_COUTOUT   "無","X-Y, Z-rX","X-Y, rX-rY","X-Y, Z-rZ"

@pfeerick
Copy link
Member

How many chars do we have space for? I assumed 5 based on "Steer"

I would try to keep it under 9 characters... this is the space it would fit in... (it's the Sim axis value)
image

@Pat6874
Copy link
Contributor

Pat6874 commented May 29, 2024 via email

@robustini
Copy link
Contributor

IT

#define TR_VUSBJOYSTICK_CH_SIM "Ale","Ele","Dir","Mot","Acc","Fre","Sterz","Dpad"
#define TR_VUSBJOYSTICK_CIRC_COUTOUT "Nessuno","X-Y, Z-rX","X-Y, rX-rY","X-Y, Z-rZ"

@HThuren
Copy link
Contributor

HThuren commented May 29, 2024

DA (insert after line 160)
#define TR_VUSBJOYSTICK_CH_SIM
TR_STICK_NAMES3,TR_STICK_NAMES1,TR_STICK_NAMES0,TR_STICK_NAMES2,"Acc","Brems","Styr","Dpad"
#define TR_VUSBJOYSTICK_CIRC_COUTOUT "Ingen","X-Y, Z-rX","X-Y, rX-rY","X-Y, Z-rZ"

@Eldenroot
Copy link
Contributor

CZ:

#define TR_VUSBJOYSTICK_CH_SIM "Ail","Ele","Rud","Thr","Acc","Brk","Steer","Dpad"
#define TR_VUSBJOYSTICK_CIRC_COUTOUT "Žádný","X-Y, Z-rX","X-Y, rX-rY","X-Y, Z-rZ"

Quite difficult to translate some of them to Czech... because somebody uses translated ones. somebody uses English international names...

@zandorsp
Copy link
Contributor

zandorsp commented May 31, 2024

PT:
#define TR_VUSBJOYSTICK_CH_SIM "Ail","Pfd","Lem","Mot","Acc","Brk","Steer","Dpad"
#define TR_VUSBJOYSTICK_CIRC_COUTOUT "Nenh","X-Y, Z-rX","X-Y, rX-rY","X-Y, Z-rZ"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants