[Development] Gamepad support on Qt
Andrew.Knight at digia.com
Thu Aug 22 09:55:13 CEST 2013
While a plugin for Qt Sensors seems logical, a generic plugin would make sense (think evdev keyboard). QtGamePad uses an approach similar to what you describe: https://github.com/nezticle/qtgamepad, while existing input devices use QPA.
The tradeoff is whether you want custom events available to the entire windowing system or signals emitted from a specific object (as in the case of the Sensors API). Personally, I'd rather see these as input-style events because that's the way input devices (mice & keyboards) already work, and this seems to work fine with evdev at least. I can't say how well it would apply to non-Linux systems, but I assume they are all relatively event driven for gamepads as well, apart from perhaps polling for analog stick data. In any case, you can still poll inside a generic plugin and emit events when the values change.
From: development-bounces+andrew.knight=digia.com at qt-project.org [development-bounces+andrew.knight=digia.com at qt-project.org] on behalf of guillaume.belz at free.fr [guillaume.belz at free.fr]
Sent: Thursday, August 22, 2013 10:35 AM
To: development at qt-project.org
Subject: [Development] Gamepad support on Qt
A problem that is often asked on forums is how to use a gamepad with qt. Or how to integrate Qt with SFML or SDL to use a gamepad
As this is a request recurring, it would be interesting to provide gamepad support in Qt?
Several approaches would be possible:
1. integrated into the core to generate events gamepad (like the keyboard or mouse)
2. create specific classes
3. create classes for Qt Sensors
The third solution would be my preference.
The gamepad does not work (a priori) like the keyboard or mouse, you must read the values at regular interval. To test that, I'm writing an API, intermediate between MouseArea (gamepadX, gamepadY, gamepadZ, pressedButtons, etc) and Timer (interval, start, restart, stop, running). I also added a class for managing multiple pad (GamepadManager) and a widget to display the values of the pad (GamepadWidget). If it is worth adding that in Qt, I will send
Thank you for your opinion
More information about the Development