increased initial memory for Emscripten platform
[rocksndiamonds.git] / src / libgame / joystick.h
1 // ============================================================================
2 // Artsoft Retro-Game Library
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
5 //                  Holger Schemel
6 //                  info@artsoft.org
7 //                  https://www.artsoft.org/
8 // ----------------------------------------------------------------------------
9 // joystick.h
10 // ============================================================================
11
12 #ifndef JOYSTICK_H
13 #define JOYSTICK_H
14
15 #include "system.h"
16
17 #define JOYSTICK_NOT_AVAILABLE  0
18 #define JOYSTICK_AVAILABLE      (1 << 0)
19 #define JOYSTICK_ACTIVE         (1 << 1)
20 #define JOYSTICK_CONFIGURED     (1 << 2)
21 #define JOYSTICK_NOT_CONFIGURED (1 << 3)
22 #define JOYSTICK_ACTIVATED      (JOYSTICK_AVAILABLE | JOYSTICK_ACTIVE)
23
24 #define MAX_JOYSTICK_NAME_LEN   40
25
26 #if defined(PLATFORM_FREEBSD)
27 #define DEV_JOYSTICK_0          "/dev/joy0"
28 #define DEV_JOYSTICK_1          "/dev/joy1"
29 #define DEV_JOYSTICK_2          "/dev/joy2"
30 #define DEV_JOYSTICK_3          "/dev/joy3"
31 #else
32 #define DEV_JOYSTICK_0          "/dev/js0"
33 #define DEV_JOYSTICK_1          "/dev/js1"
34 #define DEV_JOYSTICK_2          "/dev/js2"
35 #define DEV_JOYSTICK_3          "/dev/js3"
36 #endif
37
38 // get these values from the program 'js' from the joystick package,
39 // set JOYSTICK_PERCENT to a threshold appropriate for your joystick
40
41 #define JOYSTICK_MAX_AXIS_POS   32767
42
43 #define JOYSTICK_XLEFT          -JOYSTICK_MAX_AXIS_POS
44 #define JOYSTICK_XMIDDLE        0
45 #define JOYSTICK_XRIGHT         +JOYSTICK_MAX_AXIS_POS
46 #define JOYSTICK_YUPPER         -JOYSTICK_MAX_AXIS_POS
47 #define JOYSTICK_YMIDDLE        0
48 #define JOYSTICK_YLOWER         +JOYSTICK_MAX_AXIS_POS
49
50 #define JOYSTICK_PERCENT        25
51
52 #define JOY_NO_ACTION           0
53 #define JOY_LEFT                MV_LEFT
54 #define JOY_RIGHT               MV_RIGHT
55 #define JOY_UP                  MV_UP
56 #define JOY_DOWN                MV_DOWN
57 #define JOY_BUTTON_1            KEY_BUTTON_1
58 #define JOY_BUTTON_2            KEY_BUTTON_2
59 #define JOY_BUTTON_SNAP         KEY_BUTTON_SNAP
60 #define JOY_BUTTON_DROP         KEY_BUTTON_DROP
61 #define JOY_MOTION              KEY_MOTION
62 #define JOY_BUTTON              KEY_BUTTON
63 #define JOY_ACTION              KEY_ACTION
64
65 #define JOY_BUTTON_NOT_PRESSED  0
66 #define JOY_BUTTON_PRESSED      1
67 #define JOY_BUTTON_NEW_PRESSED  2
68 #define JOY_BUTTON_NEW_RELEASED 3
69
70 char *getJoyNameFromJoySymbol(int);
71 int getJoySymbolFromJoyName(char *);
72 int getJoystickNrFromDeviceName(char *);
73 char *getDeviceNameFromJoystickNr(int);
74 char *getFormattedJoystickName(const char *);
75
76 void CheckJoystickData(void);
77 int Joystick(int);
78 int JoystickExt(int, boolean);
79 int JoystickButton(int);
80 int AnyJoystick(void);
81 int AnyJoystickButton(void);
82
83 void DeactivateJoystick(void);
84 void ActivateJoystick(void);
85
86 #endif  // JOYSTICK_H