edgetx
edgetx copied to clipboard
Configurable USB Joystick interface
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
- Companion support missing
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.
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.
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.
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 ;)
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.
I finished the implementation of the feature. Only the companion part is missing.
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"
@HThuren Thanks for the translation! I added it.
Thanks for all your work on this @banyaszg, it has now been merged in via #3111.
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:
- 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.
- "There is a USB Joystick interface configuration button, which opens the USB Joystick menu:" I do not see this? Was this implemented?
- What is the Companion button mode do?
- 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
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.
Thanks for the information... I will update accordingly. BTW - the Companion mode is still a selectable option in the firmware...
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. https://github.com/EdgeTX/edgetx/pull/3111#issuecomment-1439245899
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.