QJoysticks
A simple way to use joysticks with your Qt application
|
Translates SDL events into QJoysticks
events.
More...
#include <SDL_Joysticks.h>
Public Slots | |
void | rumble (const QJoystickRumble &request) |
Signals | |
void | countChanged () |
void | POVEvent (const QJoystickPOVEvent &event) |
void | axisEvent (const QJoystickAxisEvent &event) |
void | buttonEvent (const QJoystickButtonEvent &event) |
Public Member Functions | |
SDL_Joysticks () | |
QList< QJoystickDevice * > | joysticks () |
Private Slots | |
void | update () |
void | configureJoystick (const SDL_Event *event) |
Private Member Functions | |
int | getDynamicID (int id) |
QJoystickDevice * | getJoystick (int id) |
QJoystickPOVEvent | getPOVEvent (const SDL_Event *sdl_event) |
QJoystickAxisEvent | getAxisEvent (const SDL_Event *sdl_event) |
QJoystickButtonEvent | getButtonEvent (const SDL_Event *sdl_event) |
Private Attributes | |
int | m_tracker |
QList< QJoystickDevice > | m_joysticks |
Translates SDL events into QJoysticks
events.
This class is in charge of managing and operating real joysticks through the SDL API. The implementation procedure is the same for every operating system.
The only thing that differs from each operating system is the backup mapping applied in the case that we do not know what mapping to apply to a joystick.
|
explicit |
Load a different generic/backup mapping for each operating system.
References update().
|
privateslot |
Checks if the joystick referenced by the event can be initialized. If not, the function will apply a generic mapping to the joystick and attempt to initialize the joystick again.
Referenced by update().
|
private |
Reads the contents of the given event and constructs a new QJoystickAxisEvent
to be used with the QJoysticks
system.
References QJoystickAxisEvent::axis, and getJoystick().
Referenced by update().
|
private |
Reads the contents of the given event and constructs a new QJoystickButtonEvent
to be used with the QJoysticks
system.
References QJoystickButtonEvent::button, and getJoystick().
Referenced by update().
|
private |
Returns a joystick ID compatible with the QJoysticks
system. SDL assigns an ID to each joystick based on the order that they are attached, but it does not decrease the ID counter when a joystick is removed.
As noted earlier, the QJoysticks
maintains an ID system similar to the one used by a QList
, since it eases the operation with most Qt classes and widgets.
Referenced by getJoystick().
|
private |
Returns the josytick device registered with the given id. If no joystick with the given id is found, then the function will warn the user through the console.
References QJoystickDevice::blacklisted, getDynamicID(), QJoystickDevice::id, QJoystickDevice::name, QJoystickDevice::numAxes, QJoystickDevice::numButtons, and QJoystickDevice::numPOVs.
Referenced by getAxisEvent(), getButtonEvent(), getPOVEvent(), and joysticks().
|
private |
Reads the contents of the given event and constructs a new QJoystickPOVEvent
to be used with the QJoysticks
system.
References getJoystick(), and QJoystickPOVEvent::pov.
Referenced by update().
QList< QJoystickDevice * > SDL_Joysticks::joysticks | ( | ) |
Returns a list with all the registered joystick devices
References getJoystick().
|
slot |
Based on the data contained in the request, this function will instruct the appropiate joystick to rumble for
References QJoystickDevice::id, QJoystickRumble::joystick, QJoystickRumble::length, and QJoystickRumble::strength.
|
privateslot |
Polls for new SDL events and reacts to each event accordingly.
References configureJoystick(), getAxisEvent(), getButtonEvent(), and getPOVEvent().
Referenced by SDL_Joysticks().