Home | History | Annotate | Download | only in win32

Lines Matching refs:joystick

26 /* Win32 MultiMedia Joystick driver, contributed by Andrei de A. Formiga */
39 #define MAX_AXES 6 /* each joystick can have up to 6 axes */
48 /* array to hold joystick ID values */
53 /* The private structure used to keep track of a joystick */
56 /* joystick ID */
75 see if there is a joystick for the current
99 /* find the registry key name for the joystick's properties */
101 SDL_snprintf(regvalue, SDL_arraysize(regvalue), "Joystick%d%s", index+1, REGSTR_VAL_JOYOEMNAME);
136 * joysticks. Joystick 0 should be the system default joystick.
148 /* Reset the joystick ID & name mapping tables */
154 /* Loop over all potential joystick devices */
175 /* Function to get the device-dependent name of a joystick */
185 /* Function to open a joystick for use.
186 The joystick to open is specified by the index field of the joystick.
187 This should fill the nbuttons and naxes fields of the joystick structure.
190 int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
199 index = joystick->index;
214 joystick->hwdata = (struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata));
215 if (joystick->hwdata == NULL)
220 SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
223 joystick->hwdata->id = SYS_JoystickID[index];
226 joystick->hwdata->transaxis[i].offset =
228 joystick->hwdata->transaxis[i].scale =
231 joystick->hwdata->transaxis[i].offset = 0;
232 joystick->hwdata->transaxis[i].scale = 1.0; /* Just in case */
237 joystick->nbuttons = SYS_Joystick[index].wNumButtons;
238 joystick->naxes = SYS_Joystick[index].wNumAxes;
240 joystick->nhats = 1;
242 joystick->nhats = 0;
269 /* Function to update the state of a joystick - called as a device poll.
270 * This function shouldn't update the joystick structure directly,
272 * and update joystick device state.
274 void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
287 if ( ! joystick->hats ) {
290 result = joyGetPosEx(joystick->hwdata->id, &joyinfo);
296 /* joystick motion events */
304 transaxis = joystick->hwdata->transaxis;
305 for (i = 0; i < joystick->naxes; i++) {
308 change = (value - joystick->axes[i]);
310 SDL_PrivateJoystickAxis(joystick, (Uint8)i, (Sint16)value);
315 /* joystick button events */
317 for ( i = 0; i < joystick->nbuttons; ++i ) {
319 if ( ! joystick->buttons[i] ) {
320 SDL_PrivateJoystickButton(joystick, (Uint8)i, SDL_PRESSED);
323 if ( joystick->buttons[i] ) {
324 SDL_PrivateJoystickButton(joystick, (Uint8)i, SDL_RELEASED);
330 /* joystick hat events */
335 if ( pos != joystick->hats[0] ) {
336 SDL_PrivateJoystickHat(joystick, 0, pos);
341 /* Function to close a joystick after use */
342 void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
344 if (joystick->hwdata != NULL) {
346 SDL_free(joystick->hwdata);
350 /* Function to perform any system-specific joystick related cleanup */
372 error = "Joystick driver not present";
385 error = "Joystick not attached";
389 error = "Can't capture joystick input";