author | Tero Marttila <terom@fixme.fi> |
Thu, 22 Jan 2009 00:28:26 +0200 | |
branch | new_graphics |
changeset 416 | 38cba347a3a9 |
parent 414 | cede5463b845 |
permissions | -rw-r--r-- |
414
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
1 |
#ifndef GRAPHICS_INPUT_HH |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
2 |
#define GRAPHICS_INPUT_HH |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
3 |
|
414
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
4 |
#include "../Input.hh" |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
5 |
#include "../Timer.hh" |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
6 |
#include "../Types.hh" |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
7 |
|
416
38cba347a3a9
clean up InputHandler/GameView to use signals for input
Tero Marttila <terom@fixme.fi>
parents:
414
diff
changeset
|
8 |
#include <ClanLib/signals.h> |
230 | 9 |
#include <ClanLib/Display/input_device.h> |
221 | 10 |
#include <ClanLib/Display/keys.h> |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
11 |
|
414
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
12 |
#include <list> |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
13 |
|
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
14 |
namespace graphics |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
15 |
{ |
221 | 16 |
|
283
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
17 |
/** |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
18 |
* Flags to control input behaviour |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
19 |
*/ |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
20 |
enum InputFlagBits { |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
21 |
/** Default */ |
319
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
22 |
|
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
23 |
/** |
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
24 |
* The bit is not limited, i.e. it is set every time if it's present |
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
25 |
*/ |
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
26 |
INPUT_FLAG_UNLIMITED = 0x0000, |
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
27 |
|
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
28 |
/** |
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
29 |
* The bit is repeat-limited using INPUT_REPEAT_DELAY |
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
30 |
*/ |
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
31 |
INPUT_FLAG_SLOWREPEAT = 0x0001, |
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
32 |
|
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
33 |
/** |
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
34 |
* The bit is repeat-limited using an infinite delay, i.e. you must release the key to trigger it again |
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
35 |
*/ |
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
36 |
INPUT_FLAG_NOREPEAT = 0x0002, |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
37 |
}; |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
38 |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
39 |
|
283
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
40 |
/** |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
41 |
* 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
|
42 |
*/ |
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
|
43 |
enum GuiInputBit { |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
44 |
GUI_INPUT_NONE = 0x0000, |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
45 |
|
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
|
46 |
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
|
47 |
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
|
48 |
GUI_INPUT_DEBUG_PLAYER = 0x0004, |
389
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
319
diff
changeset
|
49 |
|
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
319
diff
changeset
|
50 |
GUI_INPUT_TOGGLE_FULLSCREEN = 0x0008, |
221 | 51 |
}; |
52 |
||
283
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
53 |
/** |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
54 |
* Bitmask of InputFlagBits |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
55 |
*/ |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
56 |
typedef uint8_t InputFlags; |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
57 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
58 |
/** |
283
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
59 |
* Bitmask for GuiInputBits |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
60 |
* |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
61 |
* @see GuiInputBit |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
62 |
*/ |
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
|
63 |
typedef uint16_t GuiInput; |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
64 |
|
283
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
65 |
/** |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
66 |
* Keymap definition struct |
283
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
67 |
*/ |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
68 |
template <typename BitEnumType> struct InputKeymapEntry { |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
69 |
/** |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
70 |
* The input bit to set if present |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
71 |
*/ |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
72 |
BitEnumType input; |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
73 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
74 |
/** |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
75 |
* Flags to use |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
76 |
* |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
77 |
* @see InputFlagBits |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
78 |
*/ |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
79 |
InputFlags flags; |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
80 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
81 |
/** |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
82 |
* Up to two keycodes to check |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
83 |
*/ |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
84 |
int keycodes[2]; |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
85 |
}; |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
86 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
87 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
88 |
/** |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
89 |
* A InputKeyRepeatQueue entry, this contains the input bit value itself, and then the remaining expire time |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
90 |
*/ |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
91 |
template <typename BitEnumType> struct InputKeyRepeatEntry { |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
92 |
BitEnumType value; |
319
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
93 |
|
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
94 |
/** |
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
95 |
* The remaining expire time. If this is zero, it never expires |
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
96 |
*/ |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
97 |
TimeMS expire; |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
98 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
99 |
public: |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
100 |
InputKeyRepeatEntry (BitEnumType value, TimeMS expire); |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
101 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
102 |
/** |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
103 |
* Since priority_queue always gives the greatest item, the one with the longest expire is the least item |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
104 |
*/ |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
105 |
bool operator< (const struct InputKeyRepeatEntry &other); |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
106 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
107 |
/** |
319
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
108 |
* Decrements expire, returning true if it has now expired, false otherwise. Always returns false if expire is |
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
109 |
* zero. |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
110 |
*/ |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
111 |
bool updateExpired (TimeMS dt); |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
112 |
}; |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
113 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
114 |
/** |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
115 |
* A InputKeyRepeatQueue maintains a list of InputKeyRepeatEntry's, lets you add new input values, find old ones, |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
116 |
* and update the list |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
117 |
*/ |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
118 |
template <typename BitEnumType> class InputKeyRepeatQueue { |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
119 |
private: |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
120 |
TimeMS expire; |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
121 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
122 |
typedef InputKeyRepeatEntry<BitEnumType> entry_type; |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
123 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
124 |
std::list<entry_type> list; |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
125 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
126 |
typedef typename std::list<entry_type>::iterator list_iterator; |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
127 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
128 |
public: |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
129 |
/** |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
130 |
* Constructs this queue to contain entries with the given expiry time |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
131 |
*/ |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
132 |
InputKeyRepeatQueue (TimeMS expire); |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
133 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
134 |
/** |
319
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
135 |
* Push a new input bit onto the queue. |
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
136 |
* |
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
137 |
* If expire is true, the bit will automatically expire after our expire time, otherwise, it iwll never expire |
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
138 |
* until forget()'d |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
139 |
*/ |
319
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
140 |
void push (BitEnumType bit, bool expire = true); |
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
141 |
|
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
142 |
/** |
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
143 |
* Remove any entry for the given bit |
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
144 |
*/ |
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
145 |
void forget (BitEnumType bit); |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
146 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
147 |
/** |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
148 |
* Checks if the given input is in the queue |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
149 |
*/ |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
150 |
bool find (BitEnumType bit); |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
151 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
152 |
/** |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
153 |
* Updates the list, removing expired items |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
154 |
*/ |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
155 |
void update (TimeMS dt); |
414
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
156 |
|
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
157 |
/** |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
158 |
* Clear the queue completely |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
159 |
*/ |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
160 |
void clear (void); |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
161 |
}; |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
162 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
163 |
/** |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
164 |
* An InputHandler uses an InputKeymapEntry to maintain a BitMaskType of current inputs |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
165 |
*/ |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
166 |
template <typename BitEnumType, typename BitMaskType> class InputHandler { |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
167 |
private: |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
168 |
/** |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
169 |
* The keyboard that we read input from |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
170 |
*/ |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
171 |
CL_InputDevice &keyboard; |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
172 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
173 |
/** |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
174 |
* The keymap that we use |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
175 |
*/ |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
176 |
InputKeymapEntry<BitEnumType> *keymap; |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
177 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
178 |
/** |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
179 |
* The current bitmask value |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
180 |
*/ |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
181 |
BitMaskType value; |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
182 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
183 |
/** |
319
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
184 |
* The previous value, used to detect key-up. This also includes keys that were filtered out |
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
185 |
*/ |
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
186 |
BitMaskType prev_value; |
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
187 |
|
9f6a838d58c4
improve input handling further, ROPE_THROW and DIG don't repeat at all now
terom
parents:
311
diff
changeset
|
188 |
/** |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
189 |
* How long the bitmask was held... |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
190 |
*/ |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
191 |
TimeMS dt; |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
192 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
193 |
/** |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
194 |
* The KeyRepeatQueue |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
195 |
*/ |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
196 |
InputKeyRepeatQueue<BitEnumType> queue; |
414
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
197 |
|
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
198 |
/** |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
199 |
* Are we enabled or not? |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
200 |
*/ |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
201 |
bool _enabled; |
416
38cba347a3a9
clean up InputHandler/GameView to use signals for input
Tero Marttila <terom@fixme.fi>
parents:
414
diff
changeset
|
202 |
|
38cba347a3a9
clean up InputHandler/GameView to use signals for input
Tero Marttila <terom@fixme.fi>
parents:
414
diff
changeset
|
203 |
/** |
38cba347a3a9
clean up InputHandler/GameView to use signals for input
Tero Marttila <terom@fixme.fi>
parents:
414
diff
changeset
|
204 |
* The keyevent signal |
38cba347a3a9
clean up InputHandler/GameView to use signals for input
Tero Marttila <terom@fixme.fi>
parents:
414
diff
changeset
|
205 |
*/ |
38cba347a3a9
clean up InputHandler/GameView to use signals for input
Tero Marttila <terom@fixme.fi>
parents:
414
diff
changeset
|
206 |
CL_Signal_v2<BitMaskType, TimeMS> _sig_input; |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
207 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
208 |
public: |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
209 |
/** |
414
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
210 |
* Constructs the InputHandler using the given keyboard, keymap and key-repeat expire time. |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
211 |
* |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
212 |
* The InputHandler is initially disabled, and must be enabled using enable() for use. |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
213 |
*/ |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
214 |
InputHandler (CL_InputDevice &keyboard, InputKeymapEntry<BitEnumType> *keymap, TimeMS keyrepeat_expire); |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
215 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
216 |
private: |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
217 |
/** |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
218 |
* Returns true if the keycode is valid, false if not. |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
219 |
* |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
220 |
* A positive keycode requires that the keycode be active, a negative keycode that the keycode be inactive, |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
221 |
* and a zero keycode always returns true. |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
222 |
* |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
223 |
* @param keycode A positive keycode to check that it's set, negative keycode to check that it's not set, or zero |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
224 |
* @returns bool true if positive+set/negavtive+notset/zero, false otherwise |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
225 |
*/ |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
226 |
bool checkKeycode (int keycode); |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
227 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
228 |
public: |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
229 |
/** |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
230 |
* Updates the keyrepeat queue |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
231 |
*/ |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
232 |
void update (TimeMS dt); |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
233 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
234 |
/** |
414
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
235 |
* Reads the current input mask value and length into mask and dt, and reset ours to zero. |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
236 |
* |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
237 |
* It is an error to attempt to read input while disabled. |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
238 |
* |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
239 |
* @param mask our BitMaskType value is returned using this |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
240 |
* @param dt how long the input was held for |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
241 |
*/ |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
242 |
void readValue (BitMaskType &mask, TimeMS &dt); |
414
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
243 |
|
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
244 |
/** |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
245 |
* Enables this input handler, collecting bits in value |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
246 |
*/ |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
247 |
void enable (void); |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
248 |
|
414
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
249 |
/** |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
250 |
* Disables this input handler, zeroing any state, so that enable() works cleanly |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
251 |
*/ |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
252 |
void disable (void); |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
253 |
|
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
254 |
/** |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
255 |
* Current enable/disable state |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
256 |
*/ |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
257 |
bool enabled (void) const { return _enabled; } |
416
38cba347a3a9
clean up InputHandler/GameView to use signals for input
Tero Marttila <terom@fixme.fi>
parents:
414
diff
changeset
|
258 |
|
38cba347a3a9
clean up InputHandler/GameView to use signals for input
Tero Marttila <terom@fixme.fi>
parents:
414
diff
changeset
|
259 |
/** |
38cba347a3a9
clean up InputHandler/GameView to use signals for input
Tero Marttila <terom@fixme.fi>
parents:
414
diff
changeset
|
260 |
* This signal is triggered whenever there is nonzero input, or when the input goes to zero |
38cba347a3a9
clean up InputHandler/GameView to use signals for input
Tero Marttila <terom@fixme.fi>
parents:
414
diff
changeset
|
261 |
*/ |
38cba347a3a9
clean up InputHandler/GameView to use signals for input
Tero Marttila <terom@fixme.fi>
parents:
414
diff
changeset
|
262 |
CL_Signal_v2<BitMaskType, TimeMS>& sig_input (void) { return _sig_input; } |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
263 |
}; |
235 | 264 |
|
283
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
265 |
/** |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
237
diff
changeset
|
266 |
* 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
|
267 |
*/ |
235 | 268 |
class Input { |
269 |
protected: |
|
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
270 |
/** |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
271 |
* The keyboard device that we use |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
272 |
*/ |
235 | 273 |
CL_InputDevice &keyboard; |
274 |
||
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
275 |
/** |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
276 |
* Our update timer |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
277 |
*/ |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
278 |
Timer update_timer; |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
279 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
280 |
CL_SlotContainer slots; |
414
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
281 |
|
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
282 |
public: |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
283 |
/** |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
284 |
* Our PlayerInput |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
285 |
*/ |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
286 |
InputHandler<PlayerInputBit, PlayerInput> player; |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
287 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
288 |
/** |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
289 |
* Our GuiInput |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
290 |
*/ |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
291 |
InputHandler<GuiInputBit, GuiInput> gui; |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
292 |
|
235 | 293 |
public: |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
294 |
/** |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
295 |
* Build the input handler using the given keyboard and the default keymaps |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
296 |
*/ |
235 | 297 |
Input (CL_InputDevice &keyboard); |
298 |
||
299 |
public: |
|
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
300 |
/** |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
301 |
* Reads the current PlayerInput value via mask, and the length of the input via dt |
235 | 302 |
*/ |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
303 |
void readPlayerInput (PlayerInput &mask, TimeMS &dt); |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
304 |
|
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
305 |
/** |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
306 |
* Reads the current GuiInput mask and returns it |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
300
diff
changeset
|
307 |
*/ |
235 | 308 |
GuiInput readGuiInput (void); |
309 |
}; |
|
230 | 310 |
|
414
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
311 |
} |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
312 |
|
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
313 |
|
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
314 |
|
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
315 |
/* |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
316 |
* Public template class method definitions |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
317 |
*/ |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
318 |
#include <cassert> |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
319 |
|
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
320 |
namespace graphics |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
321 |
{ |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
322 |
|
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
323 |
template <typename BitEnumType, typename BitMaskType> |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
324 |
void InputHandler<BitEnumType, BitMaskType>::enable (void) { |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
325 |
// sanity-check |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
326 |
assert(!_enabled); |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
327 |
|
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
328 |
// update state |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
329 |
_enabled = true; |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
330 |
} |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
331 |
|
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
332 |
template <typename BitEnumType, typename BitMaskType> |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
333 |
void InputHandler<BitEnumType, BitMaskType>::disable (void) { |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
334 |
// sanity-check |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
335 |
assert(_enabled); |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
336 |
|
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
337 |
// update state |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
338 |
value = prev_value = 0; |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
339 |
_enabled = false; |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
340 |
|
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
341 |
// and clear keyrepeat list |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
342 |
queue.clear(); |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
343 |
} |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
344 |
|
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
345 |
|
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
346 |
} |
cede5463b845
port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents:
389
diff
changeset
|
347 |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
348 |
#endif |