-static SDL_Joystick *sdl_joystick[MAX_PLAYERS] = { NULL, NULL, NULL, NULL };
-static int sdl_js_axis[MAX_PLAYERS][2] = { {0, 0}, {0, 0}, {0, 0}, {0, 0} };
-static int sdl_js_button[MAX_PLAYERS][2] = { {0, 0}, {0, 0}, {0, 0}, {0, 0} };
-
-SDL_Joystick *Get_SDL_Joystick(int nr)
-{
- return sdl_joystick[nr];
-}
-
-boolean Open_SDL_Joystick(int nr)
-{
- if (nr < 0 || nr > MAX_PLAYERS)
- return FALSE;
-
- return ((sdl_joystick[nr] = SDL_JoystickOpen(nr)) == NULL ? FALSE : TRUE);
-}
-
-void Close_SDL_Joystick(int nr)
-{
- if (nr < 0 || nr > MAX_PLAYERS)
- return;
-
- SDL_JoystickClose(sdl_joystick[nr]);
-}
-
-boolean Check_SDL_JoystickOpened(int nr)
-{
- if (nr < 0 || nr > MAX_PLAYERS)
- return FALSE;
-
- return (SDL_JoystickOpened(nr) ? TRUE : FALSE);
-}
-
-void HandleJoystickEvent(Event *event)
-{
- switch(event->type)
- {
- case SDL_JOYAXISMOTION:
- if (event->jaxis.axis < 2)
- {
- sdl_js_axis[event->jaxis.which][event->jaxis.axis]= event->jaxis.value;
-
-#if 0
- printf("js_%d %s-axis: %d\n",
- event->jaxis.which,
- (event->jaxis.axis == 0 ? "x" : "y"),
- event->jaxis.value);
-#endif
- }
- break;
-
- case SDL_JOYBUTTONDOWN:
- if (event->jbutton.button < 2)
- {
- sdl_js_button[event->jbutton.which][event->jbutton.button] = TRUE;
-
-#if 0
- printf("js_%d button %d: pressed\n",
- event->jbutton.which,
- event->jbutton.button);
-#endif
- }
- break;
-
- case SDL_JOYBUTTONUP:
- if (event->jbutton.button < 2)
- {
- sdl_js_button[event->jbutton.which][event->jbutton.button] = FALSE;
-
-#if 0
- printf("js_%d button %d: released\n",
- event->jbutton.which,
- event->jbutton.button);
-#endif
- }
- break;
-
- default:
- break;
- }
-}
-
-int Get_SDL_Joystick_Axis(int nr, int axis)
-{
- if (nr < 0 || nr > MAX_PLAYERS)
- return 0;
-
- if (axis < 0 || axis > 1)
- return 0;
-
- return sdl_js_axis[nr][axis];