2 // gamepad.h: Header file
5 // (C) 2013 Underground Software
11 #define JOY_KEY 0x000000
12 #define JOY_BUTTON 0x010000
13 #define JOY_HAT 0x020000
14 #define JOY_AXIS 0x040000
16 #define JOY_TYPE_MASK 0xFF0000
17 #define JOY_BUTTON_MASK 0x00FFFF
18 #define JOY_HATNUM_MASK 0x0000F8
19 #define JOY_HATBUT_MASK 0x000007
20 #define JOY_AXISNUM_MASK 0x00FFFE
21 #define JOY_AXISDIR_MASK 0x000001
26 // buttonID is the combination of the type (BUTTON, HAT) and the button #
27 // (0-255 for buttons, 0-31 for hats). Hats also have 0-7 for a button #
28 // that corresponds to a direction.
32 // really should make all methods and members be static so that we can
33 // call this stuff without instantiating one. :-)
39 static void AllocateJoysticks(void);
40 static void DeallocateJoysticks(void);
41 static const char * GetJoystickName(int joystickID);
42 static bool GetState(int joystickID, int buttonID);
43 static int CheckButtonPressed(void);
44 static int GetButtonID(void);
45 static int GetJoystickID(void);
46 static void Update(void);
48 // Support up to 8 gamepads
49 static int numJoysticks;
50 static SDL_Joystick * pad[8];
51 static const char * padName[8];
52 static int numButtons[8];
53 static int numAxes[8];
54 static int numHats[8];
55 static bool button[8][256];
56 static uint8_t hat[8][32];
57 static int32_t axis[8][32];
60 #endif // __GAMEPAD_H__