mavlink / qgroundcontrol

Cross-platform ground control station for drones (Android, iOS, Mac OS, Linux, Windows)
http://qgroundcontrol.io
3.22k stars 3.56k forks source link

Joystick mapping configuration is not handled correctly #9884

Open PPakalns opened 3 years ago

PPakalns commented 3 years ago

Expected Behavior

Joystick axis, buttons can be correctly configured and recognized by SDL library.

Joystick GameController configuration environment variable SDL_GAMECONTROLLERCONFIG must be correctly processed with the highest priority.

Current Behavior

Mapping from the SDL_GAMECONTROLLERCONFIG are not recognized.

It could be possible that the loading of GameController mappings from file hardcoded in compilation process overrides value set in SDL_GAMECONTROLLERCONFIG when SDL is initialized with SDL_INIT_GAMECONTROLLER flag.

See: https://github.com/mavlink/qgroundcontrol/blob/master/src/Joystick/JoystickSDL.cc#L99

Steps to Reproduce:

Please provide an unambiguous set of steps to reproduce the current behavior

  1. Attach joystick, create custom joystick mappings with different axis order than the default one. Mappings can be generated with any tool like https://generalarcade.com/gamepadtool/ .
  2. Check that the gamepad GUID is defined in the resource file to be sure that our configured mapping will be overrided. https://github.com/mavlink/qgroundcontrol/blob/master/src/Joystick/JoystickSDL.cc#L99
  3. Set the environment variable SDL_GAMECONTROLLERCONFIG with the mapping.
  4. Launch QGroundControl, go to joystick view, calibration and check that the mapping axis order is changed, that the new mapping is loaded. (It won't be)

System Information

When posting bug reports, include the following information

booo commented 3 years ago

Any suggestion how to solve this? Should we add a option for the mapping file to the application settings?

PPakalns commented 2 years ago

One possible solution: SDL_GAMECONTROLLERCONFIG environment variable value could be read and passed to https://wiki.libsdl.org/SDL_GameControllerAddMapping function after configuration from hardcoded file is loaded so that it overrides hardcoded configuration. https://github.com/mavlink/qgroundcontrol/blob/master/src/Joystick/JoystickSDL.cc#L111

Similar to what is done with the hardcoded configuration. I would do it myself but have problems with setting up Qt5 for compiling QGroundControl by myself.

julled commented 1 year ago

This would be very handy to map input from USB connected RC controls like the Radiomaster TX16S or Taranis X9D. Currently the axis cannot properly used via QGC.