| author | terom |
| Mon, 08 Dec 2008 16:23:30 +0000 | |
| changeset 290 | f8e69f493460 |
| parent 283 | 7540b0859579 |
| child 300 | 417183866f35 |
| permissions | -rw-r--r-- |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
1 |
#ifndef INPUT_HH |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
2 |
#define INPUT_HH |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
3 |
|
| 221 | 4 |
#include <stdint.h> |
| 230 | 5 |
#include <ClanLib/Display/input_device.h> |
| 221 | 6 |
#include <ClanLib/Display/keys.h> |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
7 |
|
|
283
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
8 |
// const TimeMS INPUT_INTERVAL_MS = 20; |
| 221 | 9 |
|
|
283
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
10 |
/** |
|
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
11 |
* The bits used in the PlayerInput bitmask, each represents a separate action handled by LocalPlayer::handleInput. |
|
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
12 |
* |
|
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
13 |
* @see LocalPlayer::handleInput |
|
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
14 |
*/ |
|
233
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
230
diff
changeset
|
15 |
enum PlayerInputBit {
|
|
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
230
diff
changeset
|
16 |
INPUT_NONE = 0x0000, |
|
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
230
diff
changeset
|
17 |
|
| 221 | 18 |
INPUT_AIM_UP = 0x0001, |
19 |
INPUT_AIM_DOWN = 0x0002, |
|
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
20 |
|
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
21 |
INPUT_MOVE_LEFT = 0x0004, |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
22 |
INPUT_MOVE_RIGHT = 0x0008, |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
23 |
|
| 221 | 24 |
INPUT_JUMP = 0x0010, |
25 |
INPUT_DIG = 0x0020, |
|
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
26 |
INPUT_SHOOT = 0x0040, |
| 237 | 27 |
INPUT_CHANGE_NEXT = 0x0080, |
28 |
INPUT_CHANGE_PREV = 0x0100, |
|
29 |
INPUT_ROPE = 0x0200, |
|
30 |
INPUT_UNROPE = 0x0400, |
|
31 |
INPUT_ROPE_UP = 0x0800, |
|
32 |
INPUT_ROPE_DOWN = 0x1000, |
|
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
33 |
}; |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
34 |
|
|
283
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
35 |
/** |
|
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
36 |
* The bits used in the GuiInput bitmask, each represents something handled locally by Graphics. |
|
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
37 |
*/ |
|
233
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
230
diff
changeset
|
38 |
enum GuiInputBit {
|
|
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
230
diff
changeset
|
39 |
GUI_INPUT_QUIT = 0x0001, |
|
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
230
diff
changeset
|
40 |
GUI_INPUT_DISPLAY_WEAPON = 0x0002, |
|
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
230
diff
changeset
|
41 |
GUI_INPUT_DEBUG_PLAYER = 0x0004, |
| 221 | 42 |
}; |
43 |
||
|
283
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
44 |
/** |
|
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
45 |
* Bitmask of PlayerInputBits |
|
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
46 |
* |
|
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
47 |
* @see PlayerInputBit |
|
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
48 |
*/ |
|
233
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
230
diff
changeset
|
49 |
typedef uint16_t PlayerInput; |
|
283
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
50 |
|
|
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
51 |
/** |
|
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
52 |
* Bitmask for GuiInputBits |
|
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
53 |
* |
|
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
54 |
* @see GuiInputBit |
|
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
55 |
*/ |
|
233
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
230
diff
changeset
|
56 |
typedef uint16_t GuiInput; |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
57 |
|
|
283
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
58 |
/** |
|
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
59 |
* Keymap definition used in Input.cc |
|
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
60 |
*/ |
| 235 | 61 |
template <typename BitEnumType> struct InputKeymapEntry; |
62 |
||
|
283
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
63 |
/** |
|
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
64 |
* Handles reading input from a keyboard and mapping it to PlayerInput/GuiInput bitmasks |
|
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
65 |
*/ |
| 235 | 66 |
class Input {
|
67 |
protected: |
|
68 |
CL_InputDevice &keyboard; |
|
69 |
||
70 |
public: |
|
71 |
Input (CL_InputDevice &keyboard); |
|
72 |
||
73 |
private: |
|
74 |
bool checkKeycode (int keycode); |
|
75 |
template <typename BitEnumType, typename BitMaskType> BitMaskType buildMask (InputKeymapEntry<BitEnumType> *keymap); |
|
76 |
||
77 |
public: |
|
78 |
/* |
|
79 |
* Reads the keyboard to determine current state of the Player/Gui input |
|
80 |
*/ |
|
81 |
PlayerInput readPlayerInput (void); |
|
82 |
GuiInput readGuiInput (void); |
|
83 |
}; |
|
| 230 | 84 |
|
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
85 |
#endif |