]> Shamusworld >> Repos - virtualjaguar/blob - src/gui/gamepad.h
350a91393c1b26b7035ad9d931cf2f120509bd54
[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_BUTTON              0x0100
12 #define JOY_HAT                 0x0200
13
14 #define JOY_TYPE_MASK   0xFF00
15 #define JOY_HATNUM_MASK 0x00F8
16 #define JOY_HATBUT_MASK 0x0007
17
18 #include <stdint.h>
19
20 uint8_t hatMask[8] = { 1, 2, 4, 8, 16, 32, 64, 128 };
21
22 // buttonID is the combination of the type (BUTTON, HAT) and the button #
23 // (0-255 for buttons, 0-31 for hats). Hats also have 0-7 for a button #
24 // that corresponds to a direction.
25
26 class Gamepad
27 {
28 // really should make all methods and members be static so that we can
29 // call this stuff without instantiating one. :-)
30         public:
31                 Gamepad();
32                 ~Gamepad();
33
34                 bool GetState(int joystickID, int buttonID);
35                 int GetButtonID(void);
36                 int GetJoystickID(void);
37 };
38
39 #endif  // __GAMEPAD_H__