64fd00690bf2e106baa661f10de0619a67d82fdd
[rocksndiamonds.git] / src / joystick.h
1 /***********************************************************
2 *  Rocks'n'Diamonds -- McDuffin Strikes Back!              *
3 *----------------------------------------------------------*
4 *  (c) 1995-98 Artsoft Entertainment                       *
5 *              Holger Schemel                              *
6 *              Oststrasse 11a                              *
7 *              33604 Bielefeld                             *
8 *              phone: ++49 +521 290471                     *
9 *              email: aeglos@valinor.owl.de                *
10 *----------------------------------------------------------*
11 *  joystick.h                                              *
12 ***********************************************************/
13
14 #ifndef JOYSTICK_H
15 #define JOYSTICK_H
16
17 #include "main.h"
18
19 /* values for the joystick */
20 #define JOYSTICK_OFF            0
21 #define JOYSTICK_AVAILABLE      1
22 #ifdef __FreeBSD__
23 #include <machine/joystick.h>
24 #define DEV_JOYSTICK_0          "/dev/joy0"
25 #define DEV_JOYSTICK_1          "/dev/joy1"
26 #define DEV_JOYSTICK_2          "/dev/joy2"
27 #define DEV_JOYSTICK_3          "/dev/joy3"
28 #else
29 #define DEV_JOYSTICK_0          "/dev/js0"
30 #define DEV_JOYSTICK_1          "/dev/js1"
31 #define DEV_JOYSTICK_2          "/dev/js2"
32 #define DEV_JOYSTICK_3          "/dev/js3"
33 #endif
34
35 /* get these values from the program 'js' from the joystick package, */
36 /* set JOYSTICK_PERCENT to a threshold appropriate for your joystick */
37
38 #ifdef USE_SDL_LIBRARY
39 #define JOYSTICK_XLEFT          -32767
40 #define JOYSTICK_XMIDDLE        0
41 #define JOYSTICK_XRIGHT         32767
42 #define JOYSTICK_YUPPER         -32767
43 #define JOYSTICK_YMIDDLE        0
44 #define JOYSTICK_YLOWER         32767
45 #else
46 #define JOYSTICK_XLEFT          30
47 #define JOYSTICK_XMIDDLE        530
48 #define JOYSTICK_XRIGHT         1250
49 #define JOYSTICK_YUPPER         40
50 #define JOYSTICK_YMIDDLE        680
51 #define JOYSTICK_YLOWER         1440
52 #endif
53
54 #define JOYSTICK_PERCENT        25
55
56 #define JOY_LEFT                MV_LEFT
57 #define JOY_RIGHT               MV_RIGHT
58 #define JOY_UP                  MV_UP
59 #define JOY_DOWN                MV_DOWN
60 #define JOY_BUTTON_1            (1<<4)
61 #define JOY_BUTTON_2            (1<<5)
62 #define JOY_BUTTON              (JOY_BUTTON_1 | JOY_BUTTON_2)
63
64 #define JOY_BUTTON_NOT_PRESSED  0
65 #define JOY_BUTTON_PRESSED      1
66 #define JOY_BUTTON_NEW_PRESSED  2
67 #define JOY_BUTTON_NEW_RELEASED 3
68
69 #ifdef NO_JOYSTICK
70 #define JOYSTICK_STATUS         JOYSTICK_OFF
71 #else
72 #define JOYSTICK_STATUS         JOYSTICK_AVAILABLE
73 #endif
74
75
76 #ifdef USE_SDL_LIBRARY
77 SDL_Joystick *Get_SDL_Joystick(int);
78 boolean Open_SDL_Joystick(int);
79 void Close_SDL_Joystick(int);
80 boolean Check_SDL_JoystickOpened(int);
81 void HandleJoystickEvent(Event *);
82 int Get_SDL_Joystick_Axis(int, int);
83 #endif
84
85 void CheckJoystickData(void);
86 int Joystick(int);
87 int JoystickButton(int);
88 int AnyJoystick(void);
89 int AnyJoystickButton(void);
90
91 #endif
92