]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: joystick.h | |
e54c96f1 | 3 | // Purpose: interface of wxJoystick |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxJoystick | |
11 | @wxheader{joystick.h} | |
7c913512 | 12 | |
23324ae1 | 13 | wxJoystick allows an application to control one or more joysticks. |
7c913512 | 14 | |
23324ae1 FM |
15 | @library{wxadv} |
16 | @category{FIXME} | |
7c913512 | 17 | |
e54c96f1 | 18 | @see wxJoystickEvent |
23324ae1 FM |
19 | */ |
20 | class wxJoystick : public wxObject | |
21 | { | |
22 | public: | |
23 | /** | |
4cc4bfaf | 24 | Constructor. @a joystick may be one of wxJOYSTICK1, wxJOYSTICK2, indicating the |
23324ae1 FM |
25 | joystick |
26 | controller of interest. | |
27 | */ | |
28 | wxJoystick(int joystick = wxJOYSTICK1); | |
29 | ||
30 | /** | |
31 | Destroys the wxJoystick object. | |
32 | */ | |
33 | ~wxJoystick(); | |
34 | ||
35 | //@{ | |
36 | /** | |
37 | Returns the state of the specified joystick button. | |
3c4f71cc | 38 | |
7c913512 | 39 | @param id |
4cc4bfaf | 40 | The button id to report, from 0 to GetNumberButtons() - 1 |
23324ae1 | 41 | */ |
328f5751 FM |
42 | int GetButtonState() const; |
43 | const bool GetButtonState(unsigned id) const; | |
23324ae1 FM |
44 | //@} |
45 | ||
46 | /** | |
47 | Returns the manufacturer id. | |
48 | */ | |
328f5751 | 49 | int GetManufacturerId() const; |
23324ae1 FM |
50 | |
51 | /** | |
52 | Returns the movement threshold, the number of steps outside which the joystick | |
53 | is deemed to have | |
54 | moved. | |
55 | */ | |
328f5751 | 56 | int GetMovementThreshold() const; |
23324ae1 FM |
57 | |
58 | /** | |
59 | Returns the number of axes for this joystick. | |
60 | */ | |
328f5751 | 61 | int GetNumberAxes() const; |
23324ae1 FM |
62 | |
63 | /** | |
64 | Returns the number of buttons for this joystick. | |
65 | */ | |
328f5751 | 66 | int GetNumberButtons() const; |
23324ae1 FM |
67 | |
68 | /** | |
69 | Returns the number of joysticks currently attached to the computer. | |
70 | */ | |
71 | static int GetNumberJoysticks(); | |
72 | ||
73 | /** | |
74 | Returns the point-of-view position, expressed in continuous, one-hundredth of a | |
75 | degree units. | |
76 | Returns -1 on error. | |
77 | */ | |
328f5751 | 78 | int GetPOVCTSPosition() const; |
23324ae1 FM |
79 | |
80 | /** | |
81 | Returns the point-of-view position, expressed in continuous, one-hundredth of a | |
82 | degree units, | |
83 | but limited to return 0, 9000, 18000 or 27000. | |
84 | Returns -1 on error. | |
85 | */ | |
328f5751 | 86 | int GetPOVPosition() const; |
23324ae1 FM |
87 | |
88 | /** | |
89 | Returns the maximum polling frequency. | |
90 | */ | |
328f5751 | 91 | int GetPollingMax() const; |
23324ae1 FM |
92 | |
93 | /** | |
94 | Returns the minimum polling frequency. | |
95 | */ | |
328f5751 | 96 | int GetPollingMin() const; |
23324ae1 FM |
97 | |
98 | //@{ | |
99 | /** | |
100 | Returns the position of the specified joystick axis. | |
3c4f71cc | 101 | |
7c913512 | 102 | @param axis |
4cc4bfaf | 103 | The joystick axis to report, from 0 to GetNumberAxes() - 1. |
23324ae1 | 104 | */ |
328f5751 FM |
105 | wxPoint GetPosition() const; |
106 | const int GetPosition(unsigned axis) const; | |
23324ae1 FM |
107 | //@} |
108 | ||
109 | /** | |
110 | Returns the product id for the joystick. | |
111 | */ | |
328f5751 | 112 | int GetProductId() const; |
23324ae1 FM |
113 | |
114 | /** | |
115 | Returns the product name for the joystick. | |
116 | */ | |
328f5751 | 117 | wxString GetProductName() const; |
23324ae1 FM |
118 | |
119 | /** | |
120 | Returns the maximum rudder position. | |
121 | */ | |
328f5751 | 122 | int GetRudderMax() const; |
23324ae1 FM |
123 | |
124 | /** | |
125 | Returns the minimum rudder position. | |
126 | */ | |
328f5751 | 127 | int GetRudderMin() const; |
23324ae1 FM |
128 | |
129 | /** | |
130 | Returns the rudder position. | |
131 | */ | |
328f5751 | 132 | int GetRudderPosition() const; |
23324ae1 FM |
133 | |
134 | /** | |
135 | Returns the maximum U position. | |
136 | */ | |
328f5751 | 137 | int GetUMax() const; |
23324ae1 FM |
138 | |
139 | /** | |
140 | Returns the minimum U position. | |
141 | */ | |
328f5751 | 142 | int GetUMin() const; |
23324ae1 FM |
143 | |
144 | /** | |
145 | Gets the position of the fifth axis of the joystick, if it exists. | |
146 | */ | |
328f5751 | 147 | int GetUPosition() const; |
23324ae1 FM |
148 | |
149 | /** | |
150 | Returns the maximum V position. | |
151 | */ | |
328f5751 | 152 | int GetVMax() const; |
23324ae1 FM |
153 | |
154 | /** | |
155 | Returns the minimum V position. | |
156 | */ | |
328f5751 | 157 | int GetVMin() const; |
23324ae1 FM |
158 | |
159 | /** | |
160 | Gets the position of the sixth axis of the joystick, if it exists. | |
161 | */ | |
328f5751 | 162 | int GetVPosition() const; |
23324ae1 FM |
163 | |
164 | /** | |
165 | Returns the maximum x position. | |
166 | */ | |
328f5751 | 167 | int GetXMax() const; |
23324ae1 FM |
168 | |
169 | /** | |
170 | Returns the minimum x position. | |
171 | */ | |
328f5751 | 172 | int GetXMin() const; |
23324ae1 FM |
173 | |
174 | /** | |
175 | Returns the maximum y position. | |
176 | */ | |
328f5751 | 177 | int GetYMax() const; |
23324ae1 FM |
178 | |
179 | /** | |
180 | Returns the minimum y position. | |
181 | */ | |
328f5751 | 182 | int GetYMin() const; |
23324ae1 FM |
183 | |
184 | /** | |
185 | Returns the maximum z position. | |
186 | */ | |
328f5751 | 187 | int GetZMax() const; |
23324ae1 FM |
188 | |
189 | /** | |
190 | Returns the minimum z position. | |
191 | */ | |
328f5751 | 192 | int GetZMin() const; |
23324ae1 FM |
193 | |
194 | /** | |
195 | Returns the z position of the joystick. | |
196 | */ | |
328f5751 | 197 | int GetZPosition() const; |
23324ae1 FM |
198 | |
199 | /** | |
200 | Returns @true if the joystick has a point of view control. | |
201 | */ | |
328f5751 | 202 | bool HasPOV() const; |
23324ae1 FM |
203 | |
204 | /** | |
205 | Returns @true if the joystick point-of-view supports discrete values (centered, | |
206 | forward, backward, left, and right). | |
207 | */ | |
328f5751 | 208 | bool HasPOV4Dir() const; |
23324ae1 FM |
209 | |
210 | /** | |
211 | Returns @true if the joystick point-of-view supports continuous degree bearings. | |
212 | */ | |
328f5751 | 213 | #define bool HasPOVCTS() const /* implementation is private */ |
23324ae1 FM |
214 | |
215 | /** | |
216 | Returns @true if there is a rudder attached to the computer. | |
217 | */ | |
328f5751 | 218 | bool HasRudder() const; |
23324ae1 FM |
219 | |
220 | /** | |
221 | Returns @true if the joystick has a U axis. | |
222 | */ | |
328f5751 | 223 | bool HasU() const; |
23324ae1 FM |
224 | |
225 | /** | |
226 | Returns @true if the joystick has a V axis. | |
227 | */ | |
328f5751 | 228 | bool HasV() const; |
23324ae1 FM |
229 | |
230 | /** | |
231 | Returns @true if the joystick has a Z axis. | |
232 | */ | |
328f5751 | 233 | bool HasZ() const; |
23324ae1 FM |
234 | |
235 | /** | |
236 | Returns @true if the joystick is functioning. | |
237 | */ | |
328f5751 | 238 | bool IsOk() const; |
23324ae1 FM |
239 | |
240 | /** | |
241 | Releases the capture set by @b SetCapture. | |
3c4f71cc | 242 | |
23324ae1 | 243 | @returns @true if the capture release succeeded. |
3c4f71cc | 244 | |
4cc4bfaf | 245 | @see SetCapture(), wxJoystickEvent |
23324ae1 FM |
246 | */ |
247 | bool ReleaseCapture(); | |
248 | ||
249 | /** | |
250 | Sets the capture to direct joystick events to @e win. | |
3c4f71cc | 251 | |
7c913512 | 252 | @param win |
4cc4bfaf | 253 | The window that will receive joystick events. |
7c913512 | 254 | @param pollingFreq |
4cc4bfaf FM |
255 | If zero, movement events are sent when above the |
256 | threshold. If greater than zero, events are received every pollingFreq | |
23324ae1 | 257 | milliseconds. |
3c4f71cc | 258 | |
23324ae1 | 259 | @returns @true if the capture succeeded. |
3c4f71cc | 260 | |
4cc4bfaf | 261 | @see ReleaseCapture(), wxJoystickEvent |
23324ae1 FM |
262 | */ |
263 | bool SetCapture(wxWindow* win, int pollingFreq = 0); | |
264 | ||
265 | /** | |
266 | Sets the movement threshold, the number of steps outside which the joystick is | |
267 | deemed to have | |
268 | moved. | |
269 | */ | |
270 | void SetMovementThreshold(int threshold); | |
271 | }; | |
e54c96f1 | 272 |