New input system: how to use game controllers?

Potentially related to How to get my MIDI device running in DT but separating on a different thread:

I’m trying to set up shortcuts to game controllers and I’m unable to get it to work.

Environment:

  • Kubuntu 21.10
  • Darktable 3.8.0, installed from OBS by adding the repository and apt install
  • Game controllers: VKB Gladiator Next, Thrustmaster TWCS (throttle + pedals). All of them appear available in the KDE game controller dialog and

Output of darktable -d input

0.388087 [input device] Input devices found:

0.388104 LogiOps Virtual Input (no cursor), source: GDK_SOURCE_KEYBOARD, mode: GDK_MODE_DISABLED, 0 axes, 0 keys
0.388107 
0.388108 Power Button (no cursor), source: GDK_SOURCE_KEYBOARD, mode: GDK_MODE_DISABLED, 0 axes, 0 keys
0.388109 
0.388111 Virtual core XTEST keyboard (no cursor), source: GDK_SOURCE_KEYBOARD, mode: GDK_MODE_DISABLED, 0 axes, 0 keys
0.388112 
0.388113 Logitech Gaming Keyboard G610 Keyboard (no cursor), source: GDK_SOURCE_KEYBOARD, mode: GDK_MODE_DISABLED, 0 axes, 0 keys
0.388115 
0.388116 Logitech Gaming Keyboard G610 (no cursor), source: GDK_SOURCE_KEYBOARD, mode: GDK_MODE_DISABLED, 0 axes, 0 keys
0.388117 
0.388118 Logitech Logitech G933 Gaming Wireless Headset (no cursor), source: GDK_SOURCE_KEYBOARD, mode: GDK_MODE_DISABLED, 0 axes, 0 keys
0.388119 
0.388120 Logitech Logitech G933 Gaming Wireless Headset Consumer Control (no cursor), source: GDK_SOURCE_KEYBOARD, mode: GDK_MODE_DISABLED, 0 axes, 0 keys
0.388121 
0.388122 Power Button (no cursor), source: GDK_SOURCE_KEYBOARD, mode: GDK_MODE_DISABLED, 0 axes, 0 keys
0.388123 
0.388127 LogiOps Virtual Input (no cursor), source: GDK_SOURCE_MOUSE, mode: GDK_MODE_DISABLED, 4 axes, 0 keys
0.388130   GDK_AXIS_IGNORE
0.388131   GDK_AXIS_IGNORE
0.388132   GDK_AXIS_IGNORE
0.388133   GDK_AXIS_IGNORE
0.388133 
0.388134 Virtual core XTEST pointer (no cursor), source: GDK_SOURCE_MOUSE, mode: GDK_MODE_DISABLED, 2 axes, 0 keys
0.388136   GDK_AXIS_IGNORE
0.388136   GDK_AXIS_IGNORE
0.388138 
1.540710 [gamepad_open_devices] SDL initialized

Current behavior:

  • When setting a new shortcut, none of the buttons or sliders of any of the three controllers I have do anything.

  • No output is printed in console at any point: when opening the shortcuts dialog, when selecting one action, when double clicking an action to set it up, or when pressing knobs, buttons or sliders in the controllers.

  • The shortcut dialog accepts any keyboard input normally, so everything seems to be working except recognizing the game devices.

  • When I add a logitech gamepad, the console output shows this at startup
    [gamepad_open_devices] opened game controller 'Logitech F310 Gamepad (XInput)'
    but the buttons are not recognized, like the other controllers.

Questions for the devs:

  • Is the new input system supposed to accept any game controller? From my very limited understanding all of them are abstracted to collections of buttons, toggles and analog axis, so all controllers should be supported. Is that assumption right?
  • If supported, is there any additional configuration option I should enable?
  • Any ideas to get this working? While the joystick is probably not very useful, the Thrustmaster throttle and pedals have a lot of very interesting inputs for darktable.

Thanks!

Also, separately from this issue resolution, a HUGE thank you for all the devs, maintainers, and people herders here in this forum. You are all rockstars!

Bump? Any suggestion?

Patience?

Aside from that, for all the devices listed in your first post, I see

Could that mean that those devices are disabled (i.e. not providing any input) at a level below darktable?
I think it’s to be expected that a disabled device doesn’t show anything in the dt shortcut dialog…

From the GTK3 documentation
`GDK_MODE_DISABLED the device is disabled and will not report any events.’
(italics mine).

Thank you rvietor for the suggestion.

Input NG uses SDL2 to interpret gamepad events, not GDK. SDL2 has a database of known devices and mappings of their buttons to “standard” gamepad layout. If it doesn’t know your device, dt won’t be able to open it (but you could add a definition yourself).

In this case, it looks like dt did open the Logitech F310 Gamepad, so I would expect pressing buttons on it to generate a message that they are not mapped and the visual shortcuts mapping mode (or shortcuts dialog) to allow to set up mappings. Does that not work?

1 Like

Thanks for the detailed response. I’ll check with the sdl library and see if my controllers are supported (they’re very common so I’d be surprised if they are not included already).

With regards to the Logitech gamepad, no, unfortunately I get no output at all in the logs when pressing any of the buttons, and dt does not acknowledge button presses while in the shortcut definition dialog/shortcut assignment.

Does it work with other sdl2 applications? For example SDL2 Gamepad Tool by General Arcade

Thanks for pointing me to the gamepad tool. I installed it and it recognizes both game controllers I have and allows me to assign bindings/create maps.

[LOG] SDL2 Gamepad Tool v1.2 by General Arcade (compiled with SDL version 2.0.7, DLL version 2.0.14)
[LOG] Website: http://generealarcade.com/gamepadtool/

[LOG] Searching gamepads...
[LOG] Found 2 gamepad(s):
[LOG] "© Alex Oz 2012-2019 VKB-Sim Gladiator NXT R", 030000001d2300000002000011010000
[LOG] "Thrustmaster TWCS Throttle", 030000004f04000087b6000011010000by 4 spaces

Hm. No simple solutions then. I’m not really sure what to suggest from here either, since I’m definitely not an SDL2 “expert”. The dt module itself is very minimal with no configuration options and all the device support is happening in SDL2. It works fine for all three controllers I own, both on Debian and Windows, but it is possible that nobody else has ever got it to work…

I really appreciate your help, thank you for trying! Happy New Year :slight_smile:

Thank you for reporting your experience. Without users like you we are working completely in the blind. Unfortunately sometimes even working together problems are not solved easily…

HNY to you too!

Just to add another data point here: I have the same logitech 310 gamepad. I am using NixOS. I added SDL2 to the package, plugged in the game pad. it is recognized. Pressing buttons gives me a toast message “button not mapped”. I went into the shortcuts prefs pane and mapped some buttons. They work for me. Not sure I’ll be productive with this particular gamepad, but its really cool.

Looking at the OBS spec file, I don’t see SDL2 listed. I don’t know if it needs to be added, but maybe that is it. I’ve asked @darix in chat. Perhaps @dterrahe can say for sure.

Yes, SDL2 us needed, but the OP got

which suggests all the dependencies are available.

The gamepad module is mostly there just to show that it could be done. And as a test bed for the overall infrastructure. They also happened to be devices that I own.

But I am imagining that a wireless DS4 (with its integrated track pad) could be used for relaxed basic editing/culling sessions from the couch with dt on the big screen. Never found the time to try that out in earnest.

I’m sure some random youtube video will come about and completely blow my mind :smiley:

Just thinking out loud @lighterino do you have steam or another game autostart that could possibly be stealing clicks?

Hm that’s a good suggestion. I’m not at my computer at the moment but I’ll disable steam and anything similar and try again.

I was hoping that the throttle would prove useful for setting slider values very precisely. Maybe it’s a folly, but I’m very curious about that use case. It also has twelve buttons or so so there are lots of actions that can be assigned to just the left hand. Anyways just curiosity, not a deal breaker.

The gamepad module only supports the SDL2 gamepad abstraction of the real device, which as much as possible lets it conform to the “standard” left/right joystick, d-pad + abxy buttons, 2 shoulder buttons and 2 triggers (the latter 2 don’t do anything in dt). If you have more or a different layout, you probably need to access them via the lower level joystick api, which needs a lot more configuration so therefore wasn’t the target of this minimalist approach. But someone else could definitely pick that up and build a separate module that feeds into the Input NG infrastructure.

Some thought then needs to go into how all the input configuration options are presented. Which is needed for more complex midi devices too.

If you want to move sliders with more accuracy you can define a “normal” “dynamic” shortcut (i.e. button/key + mouse scroll or move) and reduce its speed setting (in the configuration dialog). Or you can switch on “fallbacks” in the bottom of that dialog and hold ctrl while scroll via a shortcut, which reduces the speed to 1/10th (configurable).

I see, thank you for the explanation and your help. I incorrectly assumed that all controllers were abstracted into a collection of buttons and axis so all controllers would work out of the box.