5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
28 #include <QStringList>
31 #define SDL_JOYSTICK_DEFAULT_EVENT_TIMEOUT 25
32 #define SDL_JOYSTICK_DEFAULT_AUTOREPEAT_DELAY 250
34 class Joystick
: public QObject
39 QStringList joystickNames
;
40 SDL_Joystick
*joystick
;
49 QMap
<int, int> deadzones
;
50 QMap
<int, int> sensitivities
;
52 Joystick(QObject
*parent
= 0,
53 int joystickEventTimeout
= SDL_JOYSTICK_DEFAULT_EVENT_TIMEOUT
,
54 bool doAutoRepeat
= true,
55 int autoRepeatDelay
= SDL_JOYSTICK_DEFAULT_AUTOREPEAT_DELAY
);
59 bool isOpen() { return joystick
!= NULL
; }
60 int getAxisValue(int);
63 QMap
<int, Sint16
> axes
;
64 QMap
<int, Uint8
> buttons
;
65 QMap
<int, Uint8
> hats
;
66 QMap
<int, QTime
> axisRepeatTimers
;
67 QMap
<int, QTime
> buttonRepeatTimers
;
68 QMap
<int, QTime
> hatRepeatTimers
;
71 void axisValueChanged(int axis
, int value
);
72 void buttonValueChanged(int button
, bool value
);
73 void hatValueChanged(int hat
, int value
);
74 void trackballValueChanged(int trackball
, int deltaX
, int deltaY
);
80 #endif // _JOYSTICK_H_