Home | History | Annotate | Download | only in os2

Lines Matching refs:joystick

26 /* OS/2 Joystick driver, contributed by Daniel Caetano */
41 HFILE hJoyPort = NULL; /* Joystick GAME$ Port Address */
43 #define MAX_AXES 4 /* each joystick can have up to 4 axes */
49 #define MAX_JOYNAME 128 /* Joystick name may have 128 characters */
55 /* Joystick data... hold information about detected devices */
85 /* Structure used to get values from Joystick Environment Variable */
106 /* joysticks. Joystick 0 should be the system default joystick. */
112 GAME_PORT_STRUCT stJoyStatus; /* Joystick Status Structure */
113 GAME_PARM_STRUCT stGameParms; /* Joystick Parameter Structure */
121 Uint8 ucNewJoystickMask; /* Mask for Joystick Detection */
127 if (rc != 0) return 0; /* Cannot open... report no joystick */
134 SDL_SetError("Could not read joystick port.");
154 ucNewJoystickMask = 0x0F; /* read all 4 joystick axis */
166 SDL_SetError("Could not call joystick port.");
181 /* If *any* joystick was detected... Let's configure SDL for them */
184 /* Verify if it is a "user defined" joystick */
222 /* Intialize Joystick Name */
262 /* One joystick only? */
265 /* If it is joystick A... */
281 /* If not, it is joystick B */
298 /* Hack to define Joystick Port Names */
301 SDL_snprintf (SYS_JoyData[i].szDeviceName, SDL_arraysize(SYS_JoyData[i].szDeviceName), "Default Joystick %c", 'A'+SYS_JoyData[i].id);
311 /* Function to get the device-dependent name of a joystick */
322 /* Function to open a joystick for use. */
323 /* The joystick to open is specified by the index field of the joystick. */
324 /* This should fill the nbuttons and naxes fields of the joystick structure. */
327 int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
329 int index; /* Index shortcut for index in joystick structure */
333 joystick->hwdata = (struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata));
334 if (joystick->hwdata == NULL)
340 SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
343 index = joystick->index;
345 joystick->hwdata->id = SYS_JoyData[index].id;
350 joystick->hwdata->transaxes[i].offset = ((AXIS_MAX + AXIS_MIN)>>1) - SYS_JoyData[index].axes_med[i];
351 //joystick->hwdata->transaxes[i].scale = (float)((AXIS_MAX - AXIS_MIN)/(SYS_JoyData[index].axes_max[i]-SYS_JoyData[index].axes_min[i]));
352 joystick->hwdata->transaxes[i].scale1 = (float)abs((AXIS_MIN/SYS_JoyData[index].axes_min[i]));
353 joystick->hwdata->transaxes[i].scale2 = (float)abs((AXIS_MAX/SYS_JoyData[index].axes_max[i]));
357 joystick->hwdata->transaxes[i].offset = 0;
358 //joystick->hwdata->transaxes[i].scale = 1.0; /* Just in case */
359 joystick->hwdata->transaxes[i].scale1 = 1.0; /* Just in case */
360 joystick->hwdata->transaxes[i].scale2 = 1.0; /* Just in case */
365 joystick->nbuttons = SYS_JoyData[index].buttons;
366 joystick->naxes = SYS_JoyData[index].axes;
367 /* joystick->nhats = SYS_JoyData[index].hats; */
368 joystick->nhats = 0; /* No support for hats at this time */
369 /* joystick->nballs = SYS_JoyData[index].balls; */
370 joystick->nballs = 0; /* No support for balls at this time */
377 /* Function to update the state of a joystick - called as a device poll. */
378 /* This function shouldn't update the joystick structure directly, */
380 /* and update joystick device state. */
382 void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
385 int index; /* index shortcurt to joystick index */
387 int normbut; /* Number of buttons reported by joystick */
393 GAME_STATUS_STRUCT stGameStatus; /* Joystick Status Structure */
400 SDL_SetError("Could not read joystick status.");
405 index = joystick->index;
406 /* joystick motion events */
430 transaxes = joystick->hwdata->transaxes;
431 for (i = 0; i < joystick->naxes; i++)
444 change = (value - joystick->axes[i]);
447 SDL_PrivateJoystickAxis(joystick, (Uint8)i, (Sint16)value);
451 /* joystick button A to D events */
455 if (joystick->nbuttons<normbut) normbut = joystick->nbuttons;
466 if ( ! joystick->buttons[i-corr] )
468 SDL_PrivateJoystickButton(joystick, (Uint8)(i-corr), SDL_PRESSED);
473 if ( joystick->buttons[i-corr] )
475 SDL_PrivateJoystickButton(joystick, (Uint8)(i-corr), SDL_RELEASED);
480 /* Joystick button E to H buttons */
487 if (joystick->nbuttons>=5)
489 if (stGameStatus.curdata.B.x < SYS_JoyData[index].buttoncalc[0]) SDL_PrivateJoystickButton(joystick, (Uint8)4, SDL_PRESSED);
490 else SDL_PrivateJoystickButton(joystick, (Uint8)4, SDL_RELEASED);
492 if (joystick->nbuttons>=6)
494 if (stGameStatus.curdata.B.y < SYS_JoyData[index].buttoncalc[1]) SDL_PrivateJoystickButton(joystick, (Uint8)5, SDL_PRESSED);
495 else SDL_PrivateJoystickButton(joystick, (Uint8)5, SDL_RELEASED);
497 if (joystick->nbuttons>=7)
499 if (stGameStatus.curdata.B.x > SYS_JoyData[index].buttoncalc[2]) SDL_PrivateJoystickButton(joystick, (Uint8)6, SDL_PRESSED);
500 else SDL_PrivateJoystickButton(joystick, (Uint8)6, SDL_RELEASED);
502 if (joystick->nbuttons>=8)
504 if (stGameStatus.curdata.B.y > SYS_JoyData[index].buttoncalc[3]) SDL_PrivateJoystickButton(joystick, (Uint8)7, SDL_PRESSED);
505 else SDL_PrivateJoystickButton(joystick, (Uint8)7, SDL_RELEASED);
508 /* joystick hat events */
510 /* joystick ball events */
517 /* Function to close a joystick after use */
519 void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
521 if (joystick->hwdata != NULL)
524 SDL_free(joystick->hwdata);
531 /* Function to perform any system-specific joystick related cleanup */
548 /* Open Joystick Port, if not opened yet */
554 ULONG ulVersion; /* Version of joystick driver */
564 SDL_SetError("Could not open Joystick Port.");
568 /* Get Joystick Driver Version... must be 2.0 or higher */
576 SDL_SetError("Could not get Joystick Driver version.");
602 /* Get SDL Joystick EnvVar */
611 /* Joystick Environment is defined! */