Line | |
---|
1 | /** |
---|
2 | * JOYSTICK.CPP - joystick class |
---|
3 | * |
---|
4 | * History |
---|
5 | * ver. 0.91 April 2003 - CCDOC |
---|
6 | * |
---|
7 | * @author Eugen Treise |
---|
8 | * @see: C++ Coding Standard and CCDOC in help.htm |
---|
9 | * @version 0.91 |
---|
10 | */ |
---|
11 | |
---|
12 | #ifndef __JOYSTICK_H |
---|
13 | #define __JOYSTICK_H |
---|
14 | |
---|
15 | //-------------------------------------------------------------------------- |
---|
16 | // I N C L U D E |
---|
17 | //-------------------------------------------------------------------------- |
---|
18 | |
---|
19 | #ifndef WIN32 // Linux |
---|
20 | |
---|
21 | #include <linux/joystick.h> |
---|
22 | |
---|
23 | #endif |
---|
24 | |
---|
25 | //-------------------------------------------------------------------------- |
---|
26 | // Class Joystick |
---|
27 | //-------------------------------------------------------------------------- |
---|
28 | |
---|
29 | // a common structure for 2 axes and 4 buttons |
---|
30 | typedef struct |
---|
31 | { |
---|
32 | int x; |
---|
33 | int y; |
---|
34 | bool button1; |
---|
35 | bool button2; |
---|
36 | bool button3; |
---|
37 | bool button4; |
---|
38 | } JoystickStatus; |
---|
39 | |
---|
40 | /* This class gives access to a joystick under Win32 and Linux. |
---|
41 | * 2 axes and 4 buttons are used at the moment. |
---|
42 | */ |
---|
43 | class Joystick |
---|
44 | { |
---|
45 | private: |
---|
46 | |
---|
47 | #ifndef WIN32 |
---|
48 | int joy_fd, num_of_axis, num_of_buttons; |
---|
49 | int* axis; |
---|
50 | char* button; |
---|
51 | struct js_event jse; |
---|
52 | #endif |
---|
53 | |
---|
54 | public: |
---|
55 | |
---|
56 | Joystick(); |
---|
57 | virtual ~Joystick(); |
---|
58 | |
---|
59 | bool init(); |
---|
60 | bool GetStatus(JoystickStatus& js); |
---|
61 | void close(); |
---|
62 | }; |
---|
63 | |
---|
64 | /* |
---|
65 | bool InitJoystick(); |
---|
66 | bool GetJoystickStatus(JoystickStatus& js); |
---|
67 | void CloseJoystick(); |
---|
68 | */ |
---|
69 | #endif // __JOYSTICK_H |
---|
Note: See
TracBrowser
for help on using the repository browser.