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