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