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