]> Shamusworld >> Repos - virtualjaguar/blob - src/gui/gamepad.h
More gamepad work.
[virtualjaguar] / src / gui / gamepad.h
1 //
2 // gamepad.h: Header file
3 //
4 // by James Hammons
5 // (C) 2013 Underground Software
6 //
7
8 #ifndef __GAMEPAD_H__
9 #define __GAMEPAD_H__
10
11 #define JOY_KEY                 0x000000
12 #define JOY_BUTTON              0x010000
13 #define JOY_HAT                 0x020000
14
15 #define JOY_TYPE_MASK   0xFF0000
16 #define JOY_BUTTON_MASK 0x00FFFF
17 #define JOY_HATNUM_MASK 0x0000F8
18 #define JOY_HATBUT_MASK 0x000007
19
20 #include <stdint.h>
21 #include "SDL.h"
22
23 // buttonID is the combination of the type (BUTTON, HAT) and the button #
24 // (0-255 for buttons, 0-31 for hats). Hats also have 0-7 for a button #
25 // that corresponds to a direction.
26
27 class Gamepad
28 {
29 // really should make all methods and members be static so that we can
30 // call this stuff without instantiating one. :-)
31         public:
32                 Gamepad();
33                 ~Gamepad();
34
35                 // Class methods...
36                 static void AllocateJoysticks(void);
37                 static void DeallocateJoysticks(void);
38                 static bool GetState(int joystickID, int buttonID);
39                 static int CheckButtonPressed(void);
40                 static int GetButtonID(void);
41                 static int GetJoystickID(void);
42                 static void Update(void);
43
44                 // Support up to 8 gamepads
45                 static int numJoysticks;
46                 static SDL_Joystick * pad[8];
47                 static int numButtons[8];
48                 static int numHats[8];
49                 static bool button[8][256];
50                 static uint8_t hat[8][32];
51 };
52
53 #endif  // __GAMEPAD_H__