Subversion Repositories Games.Rick Dangerous

Rev

Rev 1 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 pmbaty 1
/*
2
 * src/sysjoy.c
3
 *
4
 * Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
5
 *
6
 * The use and distribution terms for this software are contained in the file
7
 * named README, which can be found in the root of this distribution. By
8
 * using this software in any fashion, you are agreeing to be bound by the
9
 * terms of this license.
10
 *
11
 * You must not remove this notice, or any other, from this software.
12
 */
13
 
11 pmbaty 14
#include <SDL2/SDL.h>
1 pmbaty 15
 
16
#include "system.h"
17
 
18
static SDL_Joystick *j = NULL;
19
 
20
 
21
void sysjoy_init (void)
22
{
23
   U8 i, jcount;
24
 
25
   if (SDL_InitSubSystem (SDL_INIT_JOYSTICK) < 0)
26
      return;
27
 
28
   jcount = SDL_NumJoysticks ();
29
 
30
   if (!jcount)
31
      return; /* no joystick on this system */
32
 
33
   /* use the first joystick that we can open */
34
   for (i = 0; i < jcount; i++)
35
   {
36
      j = SDL_JoystickOpen (i);
37
      if (j)
38
         break;
39
   }
40
 
41
   /* enable events */
42
   SDL_JoystickEventState (SDL_ENABLE);
43
}
44
 
45
 
46
void sysjoy_shutdown (void)
47
{
48
   if (j)
49
      SDL_JoystickClose (j);
50
}