11 #include <argos3/core/utility/configuration/argos_exception.h>
12 #include <argos3/core/utility/logging/argos_log.h>
22 if ( SDL_Init(SDL_INIT_JOYSTICK) == 0 ) {
24 for (i = 0; i < SDL_NumJoysticks(); i++) {
26 LOG <<
"[INFO] Found joystick #" << i <<
": \"" << SDL_JoystickName(i) <<
"\"" << std::endl;
95 Sint16 moved = SDL_JoystickGetAxis(
joystick, i);
97 if ( (moved != axes[i]) ) {
98 int deltaMoved = abs(axes[i] - moved);
102 axisRepeatTimers[i].restart();
109 axisRepeatTimers[i].restart();
114 Uint8 changed = SDL_JoystickGetButton(
joystick, i);
115 if ( (changed != buttons[i]) ) {
117 buttons[i] = changed;
118 buttonRepeatTimers[i].restart();
122 buttons[i] = changed;
125 buttonRepeatTimers[i].restart();
127 for (i = 0; i <
numHats; i++) {
128 Uint8 changed = SDL_JoystickGetHat(
joystick, i);
129 if ( (changed != hats[i]) ) {
132 hatRepeatTimers[i].restart();
139 hatRepeatTimers[i].restart();
144 SDL_JoystickGetBall(
joystick, i, &dx, &dy);
145 if ( dx != 0 || dy != 0 )
156 SDL_JoystickUpdate();
157 return SDL_JoystickGetAxis(
joystick, axis);
#define THROW_ARGOSEXCEPTION(message)
This macro throws an ARGoS exception with the passed message.
The namespace containing all the ARGoS related code.
CARGoSLog LOG(std::cout, SLogColor(ARGOS_LOG_ATTRIBUTE_BRIGHT, ARGOS_LOG_COLOR_GREEN))
void hatValueChanged(int hat, int value)
QStringList joystickNames
void buttonValueChanged(int button, bool value)
CQTOpenGLJoystick(QObject *parent=0, int joystickEventTimeout=SDL_JOYSTICK_DEFAULT_EVENT_TIMEOUT, bool doAutoRepeat=TRUE, int autoRepeatDelay=SDL_JOYSTICK_DEFAULT_AUTOREPEAT_DELAY)
void trackballValueChanged(int trackball, int deltaX, int deltaY)
QMap< int, int > deadzones
void axisValueChanged(int axis, int value)
QMap< int, int > sensitivities