Skip to content

Configurable USB Joystick interface - #2277

Closed
banyaszg wants to merge 1 commit into
EdgeTX:mainfrom
banyaszg:usb-joystick
Closed

Configurable USB Joystick interface#2277
banyaszg wants to merge 1 commit into
EdgeTX:mainfrom
banyaszg:usb-joystick

Conversation

@banyaszg

@banyaszg banyaszg commented Sep 5, 2022

Copy link
Copy Markdown
Contributor

Summary of changes:

Overview

In this implementation we can define an USB Joystick interface for each models.
This is a feature option at the build (USBJ_EX). The default is ON except the X9D+ 2019 where the deault is OFF because the firmware size error.

These are the settings:

  • In the model settings the Classic and the Advanced USB Joystick interface can be selected. All the other settings will open for the "Advanced" selection.
  • The type of the USB interface can be selected (Joystick, Gamepad, Multiaxis)
  • There is a USB Joystick interface configuration button, which opens the USB Joystick menu:
  • The mode of each mixer channels can be configured:
    • "None" - means disabled
    • "Button" - used for each type of buttons
      • The type of the switch (the number of positions) can be: Push, 2POS, 3POS, ... 8POS
      • In "Normal" mode each postion of a multiposition switch represented by a button. The current state represented by a continous button press.
      • The "Pulse" mode is sinilar like the "Normal" mode, but instead of continous button press everything represented by a short button press-release cycle.
      • The "SWEmu" means toggle switch emulation for a push button. The first press turns the virtual button on, the second press turns it off.
      • In "Delta" mode the change of the output channel is represented by 2 buttons. While the value is decreasing the first button is pressed, when the value is increasing the second button is pressed. If there is no change, then no buttons will be pressed.
    • There are general axes: X, Y, Z, rotX, rotY, rotZ, slider, dial, wheel - usually the games use these
    • There are simulation type axes: aileron, elevator, rudder, throttle - usually only the throttle is used by the games
  • Inversion can be set for each channel. It inverts the value before the report to the PC.
  • To prevent button reordering the device preallocates a lot of buttons (currently 32), and they can be selected for each button type channels.
  • During the USB Joystick connection the settings can be modified, but they won't be active. An "Apply settings" is needed for the activation of the new settings. The apply can mean software disconnection-reconnection if it is needed because the changes.
  • If there is a model selection during the USB Joystick connection, then the system checks whether the new model uses the same USB interface as the old one. If they differ, then a software disconnection-replug occurs to refresh the settings to the new model.
  • Circular cutout for axis pairs: Usually the range of the axis pairs is a rectangular area. With this option it will be a circle.
  • The UI doesn't prevent invalid settings, but shows the collisions:
    • If unique axes (X,Y,Z...) used multiple times, then the last will overwrite others.
    • If same virtual button number is used for multiple switches, then there will be a logical OR between them.

TODO

  • feature(color) Rewrite the channel button to use layout manager.
  • Companion support is missing

@banyaszg banyaszg changed the title Usb joystick Configurable USB Joystick interface Sep 5, 2022
@gagarinlg

gagarinlg commented Sep 5, 2022

Copy link
Copy Markdown
Member

On a first glance it looks nice.
You have to add the english texts to the other languages as well and then someone has to translate those. But without the english texts in those files, the other language will not compile.

@banyaszg

banyaszg commented Sep 5, 2022

Copy link
Copy Markdown
Contributor Author

I'm aware the translations. I did it before, then I realized it is better to finish the UI first, and copy the strings once at the end. So I will. However there is a big chance I will write a simple shell script for this task.

@gagarinlg

Copy link
Copy Markdown
Member

I'm aware the translations. I did it before, then I realized it is better to finish the UI first, and copy the strings once at the end. So I will. However there is a big chance I will write a simple shell script for this task.

There might be a script somwhere for this.
From my side this was just a reminder, in case you did not know.

@pfeerick

pfeerick commented Sep 7, 2022

Copy link
Copy Markdown
Member

There was a helper script - radio/src/translations/translation.py - but it wasn't updated during the LVGL transition, so still wants to edit the .h.txt files. It could just be a matter of changing that and it may be ready to go again.

Just so you know, this won't make 2.8 ... we're basically at feature freeze now - as should be starting to focus on fixing the last major bugs so we can move on to RCs. So there may also be some teething conflicts arising between now and starting onto 2.9. So that also means no pressure ;) This will be a great new addition, and I really do like like how you structured the menus and interface for this. Nice and intuitive if you're used to the current UI ;)

@pfeerick pfeerick added this to the 2.9 milestone Sep 7, 2022
@pfeerick pfeerick added the enhancement ✨ New feature or request label Sep 7, 2022
@banyaszg

banyaszg commented Sep 7, 2022

Copy link
Copy Markdown
Contributor Author

Thanks! I'll check that script.

No prob. about the 2.8. I'll have a version with that for private use, and I will follow the the modifications to resolve the conflicts. And the no pressure thing is good, because there is still a lot of work with the color GUI to make it nice :) Also I want to learn more about the LVGL, because it can be a thing in the ebmedded Linux systems too.

@pfeerick pfeerick linked an issue Sep 11, 2022 that may be closed by this pull request
1 task
@banyaszg
banyaszg force-pushed the usb-joystick branch 6 times, most recently from a5a4e6d to a6d02ee Compare September 17, 2022 09:56
@banyaszg

Copy link
Copy Markdown
Contributor Author

I finished the implementation of the feature. Only the companion part is missing.

@banyaszg
banyaszg force-pushed the usb-joystick branch 2 times, most recently from 1b4c09e to 74440b9 Compare October 14, 2022 06:28
@HThuren

HThuren commented Nov 4, 2022

Copy link
Copy Markdown
Contributor

DA translation

#define TR_USBJOYSTICK_LABEL "USB joystik"
#define TR_USBJOYSTICK_EXTMODE "Tilstand"
#define TR_VUSBJOYSTICK_EXTMODE "Klassisk","Advanceret"
#define TR_USBJOYSTICK_SETTINGS "Kanal indstillinger"
#define TR_USBJOYSTICK_IF_MODE TR("Intf. tils.","Interface tilstand")
#define TR_VUSBJOYSTICK_IF_MODE "Joystik","Gamepad","MultiAkse"
#define TR_USBJOYSTICK_CH_MODE "Tilstand"
#define TR_VUSBJOYSTICK_CH_MODE "Ingen","Knap","Akse","Sim"
#define TR_VUSBJOYSTICK_CH_MODE_S "-","B","A","S"
#define TR_USBJOYSTICK_CH_BTNMODE "Knap tilstand"
#define TR_VUSBJOYSTICK_CH_BTNMODE "Normal","Puls","SWEmu","Delta"
#define TR_VUSBJOYSTICK_CH_BTNMODE_S TR("Norm","Normal"),TR("Puls","Puls"),TR("SWEm","SWEmul"),TR("Delt","Delta")
#define TR_USBJOYSTICK_CH_SWPOS "Positioner"
#define TR_VUSBJOYSTICK_CH_SWPOS "Skub","2POS","3POS","4POS","5POS","6POS","7POS","8POS"
#define TR_USBJOYSTICK_CH_AXIS "Akse"
#define TR_VUSBJOYSTICK_CH_AXIS "X","Y","Z","rotX","rotY","rotZ","Skyder","Drej","Hjul"
#define TR_USBJOYSTICK_CH_SIM "Sim akse"
#define TR_VUSBJOYSTICK_CH_SIM "Kræ","Høj","Sid","Gas"
#define TR_USBJOYSTICK_CH_INVERSION "Omvendt"
#define TR_USBJOYSTICK_CH_BTNNUM "Knap #"
#define TR_USBJOYSTICK_BTN_COLLISION "!Knap # kollision!"
#define TR_USBJOYSTICK_AXIS_COLLISION "!Akse kollision!"
#define TR_USBJOYSTICK_CIRC_COUTOUT TR("Cirk. klip", "Cikulær klip")
#define TR_VUSBJOYSTICK_CIRC_COUTOUT "Ingen","X-Y, Z-rX","X-Y, rX-rY"
#define TR_USBJOYSTICK_APPLY_CHANGES "Gem ændringer"

@banyaszg

Copy link
Copy Markdown
Contributor Author

@HThuren
Thanks for the translation! I added it.

@pfeerick

Copy link
Copy Markdown
Member

Thanks for all your work on this @banyaszg, it has now been merged in via #3111.

@pfeerick pfeerick closed this Mar 22, 2023
@phileville

phileville commented May 4, 2023

Copy link
Copy Markdown
Collaborator

I am working on updating the EdgeTX User Manual to explain this new feature and I have some questions. I have been testing a bunch and some things are still not clear. Can you please explain the following points:

  1. What is the benefit of selecting the USB interface (Joystick, Gamepad, Multiaxis) - I do not see any difference in Windows USB gamepad manager when I switch between them.
  2. "There is a USB Joystick interface configuration button, which opens the USB Joystick menu:" I do not see this? Was this implemented?
  3. What is the Companion button mode do?
  4. Classic mode - Is this a correct description of how that works?
    "In Classic mode, the radio's configured output channels will be sent to the target device in numerical order and mapped to the device's preconfigured USB controller axes and buttons."

That is all I can think of for now - If anyone can shed some light, I would appreciate it. Great work on this by the way!
Kind Regards,
Phil

@pfeerick

pfeerick commented May 5, 2023

Copy link
Copy Markdown
Member

This functionality was implemented via #3111 as mentioned above, hence why it looks and behaves a bit differently as described in this PR. Companion button mode is no longer present AFAIK. There is now a single screen for the joystick settings on colorlcd, and a channel settings submenu on B&W. I can't tell you what the difference is between the modes other than that they exist and on Linux and mac a device will properly be detected as being either a joystick, gamepad or multi-axis (which is like a graphics tablet) The https://gamepad-tester.com site correctly detects the device differently. However, Windows has a major bug where it doesn't requery game controllers properly after the first connect of a device with a given VID:PID, so we need to get some more PIDs to work around that issue.

In classic mode, IIRC, only the first eight channels/mixers are used.

@phileville

Copy link
Copy Markdown
Collaborator

Thanks for the information... I will update accordingly. BTW - the Companion mode is still a selectable option in the firmware...

@pfeerick

pfeerick commented May 5, 2023

Copy link
Copy Markdown
Member

BTW - the Companion mode is still a selectable option in the firmware...

Ah, I see what you mean - advanced joystick button mode - ok, that is so fewer buttons are needed when used with Companion simulator.
#3111 (comment)

@banyaszg

banyaszg commented May 5, 2023

Copy link
Copy Markdown
Contributor Author

Regarding the Joystick, Gamepad, Multiaxis selection: These are the possible USB HID devices what we can simulate. Usually it doesn't matter what you choose, but as I tested there are cases when programs differentiate between these devices, and you should use a specific type. Especially games which handle the joysticks and gamepads differently. (I was going to use the TX as game controller for simulator type games too not just FPV simulators.) So I implemented this feature to have the maximum flexibility to fit to all the softwares.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement ✨ New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gamepad mode missing throttle axis on Android Chrome

5 participants