Cosmetics
This commit is contained in:
@@ -108,37 +108,43 @@ void Joystick::processEvents()
|
||||
}
|
||||
for (i = 0; i < numButtons; i++) {
|
||||
Uint8 changed = SDL_JoystickGetButton(joystick, i);
|
||||
if ( (changed != buttons[i]) ) {
|
||||
if (changed != buttons[i]) {
|
||||
emit buttonValueChanged(i, (bool) changed);
|
||||
buttons[i] = changed;
|
||||
buttonRepeatTimers[i].restart();
|
||||
} else if (autoRepeat && changed != 0) {
|
||||
}
|
||||
else if (autoRepeat && changed != 0) {
|
||||
if ( buttonRepeatTimers[i].elapsed() >= autoRepeatDelay ) {
|
||||
emit buttonValueChanged(i, (bool) changed);
|
||||
buttons[i] = changed;
|
||||
}
|
||||
} else
|
||||
}
|
||||
else {
|
||||
buttonRepeatTimers[i].restart();
|
||||
}
|
||||
}
|
||||
for (i = 0; i < numHats; i++) {
|
||||
Uint8 changed = SDL_JoystickGetHat(joystick, i);
|
||||
if ( (changed != hats[i]) ) {
|
||||
if (changed != hats[i]) {
|
||||
emit hatValueChanged(i, changed);
|
||||
hats[i] = changed;
|
||||
hatRepeatTimers[i].restart();
|
||||
} else if (autoRepeat && changed != 0) {
|
||||
if ( hatRepeatTimers[i].elapsed() >= autoRepeatDelay ) {
|
||||
}
|
||||
else if (autoRepeat && changed != 0) {
|
||||
if (hatRepeatTimers[i].elapsed() >= autoRepeatDelay) {
|
||||
emit hatValueChanged(i, changed);
|
||||
hats[i] = changed;
|
||||
}
|
||||
} else
|
||||
}
|
||||
else {
|
||||
hatRepeatTimers[i].restart();
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < numTrackballs; i++) {
|
||||
int dx, dy;
|
||||
SDL_JoystickGetBall(joystick, i, &dx, &dy);
|
||||
if ( dx != 0 || dy != 0 )
|
||||
if (dx != 0 || dy != 0)
|
||||
emit trackballValueChanged(i, dx, dy);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,14 +49,17 @@ class Joystick : public QObject
|
||||
QMap<int, int> deadzones;
|
||||
QMap<int, int> sensitivities;
|
||||
|
||||
Joystick(QObject *parent = 0,
|
||||
int joystickEventTimeout = SDL_JOYSTICK_DEFAULT_EVENT_TIMEOUT,
|
||||
bool doAutoRepeat = true,
|
||||
int autoRepeatDelay = SDL_JOYSTICK_DEFAULT_AUTOREPEAT_DELAY);
|
||||
~Joystick();
|
||||
explicit Joystick(QObject * parent = nullptr,
|
||||
int joystickEventTimeout = SDL_JOYSTICK_DEFAULT_EVENT_TIMEOUT,
|
||||
bool doAutoRepeat = true,
|
||||
int autoRepeatDelay = SDL_JOYSTICK_DEFAULT_AUTOREPEAT_DELAY);
|
||||
~Joystick() override;
|
||||
bool open(int);
|
||||
void close();
|
||||
bool isOpen() { return joystick != NULL; }
|
||||
bool isOpen()
|
||||
{
|
||||
return joystick != nullptr;
|
||||
}
|
||||
int getAxisValue(int);
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user