1 struct InputSpecifier { enum { None, Up, Down, Left, Right, Lo, Hi, Trigger }; };
2 struct InputModifier { enum { None = 0, Shift = 1, Control = 2, Alt = 4, Super = 8 }; };
3 struct InputCategory { enum { Port1 = 0, Port2 = 1, UserInterface = 2, Hidden = 3 }; };
4 
5 struct InputGroup;
6 
7 struct MappedInput {
8   InputGroup *parent;
9   string name;
10   string label;
11   unsigned specifier;
12   unsigned modifier;
13   unsigned scancode;
14   bool modifierOverride;
15   int16_t state;
16   int16_t previousState;
17   int16_t cachedState;
18 
19   void bind();
20   virtual void poll() = 0;
21   virtual void cache();
22 
23   MappedInput(const char*, const char*);
24 };
25 
26 struct DigitalInput : MappedInput {
27   void poll();
28 
29   bool isPressed() const;
30   bool wasPressed() const;
31 
32   DigitalInput(const char*, const char*);
33 };
34 
35 struct AnalogInput : MappedInput {
36   void poll();
37 
38   AnalogInput(const char*, const char*);
39 };
40 
41 struct HotkeyInput : DigitalInput {
42   void poll();
pressedHotkeyInput43   virtual void pressed() {}
releasedHotkeyInput44   virtual void released() {}
45 
46   HotkeyInput(const char*, const char*);
47 };
48 
49 struct InputGroup : public array<MappedInput*> {
50   unsigned category;
51   string label;
52 
53   void attach(MappedInput*);
54   void bind();
55   void poll();
56   void cache();
57   void flushCache();
statusInputGroup58   virtual int16_t status(unsigned, unsigned) const { return 0; }
59 
60   InputGroup(unsigned, const char*);
61 };
62 
63 struct InputMapper : public array<InputGroup*> {
64   InputGroup *port1;
65   InputGroup *port2;
66 
67   bool calibrated;
68   bool isTrigger[Joypad::Count][Joypad::Axes];
69 
70   bool activeState;
71   int16_t stateTable[2][Scancode::Limit];
72   unsigned modifier;
73 
74   void calibrate();
75   void bind();
76   void poll();
77   void cache();
78   int16_t status(bool, unsigned, unsigned, unsigned);
79 
80   string modifierString() const;
81   int16_t state(uint16_t) const;
82   int16_t previousState(uint16_t) const;
83   unsigned distance(uint16_t) const;
84 
85   InputMapper();
86 };
87 
88 InputMapper& mapper();
89 
90 #include "controller.hpp"
91 #include "userinterface.hpp"
92