Trying Qt Gamepad Simple example with a wheel steering gamepad
-
Hi,
I tried Qt Gamepad Simple example with a wheel steering gamepad( Thrustmaster T80) on Linux. It gets a good communication with that except some buttons don't work.
I can see Qt uses evdev as backend. I tested it with evtest and it recognizes every button. I saw it gives 8 Axes and 14 buttons on jtest-gtk and the structure is a bit different in qgamepadmanager.h. I tried to add more values to that but it was for nothing. Any idea about what would I have to change? Thanks
-
when interfacing with gamepads in linux I recommend using the system level event interface evdev (/dev/input/inputxx) instead of QtGamepad. It's lower level but gives more control. As long as the kernel driver correctly supports the gamepad then you can trap whatever events you wish.
-
@Kent-Dorfman That idea sounds very interesting, using evdev instead of QtGamepad. Would you have any example of it to learn how to do it?
-
There is programmimg information via google search.
You open the correct /dev/input/ device file in blocking mode (if you are using a separater polling thread), or nonblocking from your main thread event loop. read(2) calls return available events from the device, containing timestamp, event type, and value. There are also ioctl calls to filter noise and make axis less jittery, and increase center dead-zones.
livevdev is a higher level wrapper library available...YMMV
The main header of interest in linux is: /usr/include/linux/input.h
I generally register callback lambda functions to execute when an axist of interest value changes, or a button state changes. There are many options what you do with the raw events from your read() calls.
-
I answer myself about this question because the documentation about QtGamepad is very brief. After some investigation this is what you have to do to get every button working with QtGamepad. I used these sentences of code:
m_gamepad = new QGamepad(*gamepads.begin(), this); QGamepadManager* manager = QGamepadManager::instance(); manager->configureButton(m_gamepad->deviceId(), QGamepadManager::ButtonX);
You need to start your program and press which button you want as button X. I did that changing "QGamepadManager::ButtonX" for every button I had in my gamepad. It saved that configuration in this PC.
If you want to reset the configuration you registered:manager->resetConfiguration(m_gamepad->deviceId());
That's all.