comparison ext/guichan-0.8.1/include/guichan/keyinput.hpp @ 0:4a0efb7baf70

* Datasets becomes the new trunk and retires after that :-)
author mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
date Sun, 29 Jun 2008 18:44:17 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4a0efb7baf70
1 /* _______ __ __ __ ______ __ __ _______ __ __
2 * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
3 * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
4 * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
5 * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
6 * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
7 * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
8 *
9 * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
10 *
11 *
12 * Per Larsson a.k.a finalman
13 * Olof Naessén a.k.a jansem/yakslem
14 *
15 * Visit: http://guichan.sourceforge.net
16 *
17 * License: (BSD)
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 * 1. Redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in
25 * the documentation and/or other materials provided with the
26 * distribution.
27 * 3. Neither the name of Guichan nor the names of its contributors may
28 * be used to endorse or promote products derived from this software
29 * without specific prior written permission.
30 *
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
36 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
37 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
38 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
39 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
40 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 */
43
44 #ifndef GCN_KEYINPUT_HPP
45 #define GCN_KEYINPUT_HPP
46
47 #include "guichan/key.hpp"
48 #include "guichan/platform.hpp"
49
50 namespace gcn
51 {
52 /**
53 * Internal class that represents key input. Generally you won't have to
54 * bother using this class unless you implement an Input class for
55 * a back end.
56 *
57 * @since 0.1.0
58 */
59 class GCN_CORE_DECLSPEC KeyInput
60 {
61 public:
62
63 /**
64 * Constructor.
65 */
66 KeyInput() { };
67
68 /**
69 * Constructor.
70 *
71 * @param key The key of the key input.
72 * @param type The type of key input.
73 */
74 KeyInput(const Key& key, unsigned int type);
75
76 /**
77 * Sets the type of the key input.
78 *
79 * @param type The type of key input.
80 * @see getType
81 */
82 void setType(unsigned int type);
83
84 /**
85 * Gets the type of the key input.
86 *
87 * @return the input type.
88 * @see setType
89 */
90 int getType() const;
91
92 /**
93 * Sets the key of the key input.
94 *
95 * @param key The key of the key input.
96 * @see getKey
97 */
98 void setKey(const Key& key);
99
100 /**
101 * Gets the key of the key input.
102 *
103 * @return The key of the key input.
104 * @see setKey
105 */
106 const Key& getKey() const;
107
108 /**
109 * Checks if shift is pressed.
110 *
111 * @return True if shift was pressed at the same
112 * time as the key, false otherwise.
113 * @see setShiftPressed
114 * @since 0.6.0
115 */
116 bool isShiftPressed() const;
117
118 /**
119 * Sets shift to be pressed at the same time as the key,
120 * or not.
121 *
122 * @param pressed True if shift is pressed, false otherwise.
123 * @see isShiftPressed
124 * @since 0.6.0
125 */
126 void setShiftPressed(bool pressed);
127
128 /**
129 * Checks if control is pressed.
130 *
131 * @return True if control was pressed at the same
132 * time as the key, false otherwise.
133 * @see setControlPressed
134 * @since 0.6.0
135 */
136 bool isControlPressed() const;
137
138 /**
139 * Sets control to be pressed at the same time as the key,
140 * or not.
141 *
142 * @param pressed True if control is pressed, false otherwise.
143 * @see isControlPressed
144 * @since 0.6.0
145 */
146 void setControlPressed(bool pressed);
147
148 /**
149 * Checks if alt is pressed.
150 *
151 * @return True if alt was pressed at the same
152 * time as the key, false otherwise.
153 * @see setAltPressed
154 * @since 0.6.0
155 */
156 bool isAltPressed() const;
157
158 /**
159 * Sets the alt to be pressed at the same time as the key,
160 * or not.
161 *
162 * @param pressed True if alt is pressed at the same
163 * time as the key, , false otherwise.
164 * @see isAltPressed
165 * @since 0.6.0
166 */
167 void setAltPressed(bool pressed);
168
169 /**
170 * Checks if meta is pressed.
171 *
172 * @return True if meta was pressed at the same
173 * time as the key, false otherwise.
174 * @see setMetaPressed
175 * @since 0.6.0
176 */
177 bool isMetaPressed() const;
178
179 /**
180 * Sets meta to be pressed at the same time as the key,
181 * or not.
182 *
183 * @param pressed True if meta is pressed at the same
184 * time as the key, false otherwise.
185 * @see isMetaPressed
186 * @since 0.6.0
187 */
188 void setMetaPressed(bool pressed);
189
190 /**
191 * Checks if the key was pressed at the numeric pad.
192 *
193 * @return True if key pressed at the numeric pad,
194 * false otherwise.
195 * @setNumericPad
196 * @since 0.6.0
197 */
198 bool isNumericPad() const;
199
200 /**
201 * Sets the key to be pressed at the numeric pad.
202 *
203 * @param numpad True if the key was pressed at the numeric
204 * pad, false otherwise.
205 * @see isNumericPad
206 * @since 0.6.0
207 */
208 void setNumericPad(bool numpad);
209
210 /**
211 * Key input types. This enum corresponds to the enum with event
212 * types on KeyEvent for easy mapping.
213 */
214 enum
215 {
216 PRESSED = 0,
217 RELEASED
218 };
219
220 protected:
221 /**
222 * Holds the key of the key input.
223 */
224 Key mKey;
225
226 /**
227 * Holds the type of the key input.
228 */
229 unsigned int mType;
230
231 /**
232 * True if shift was pressed at the same time as the key,
233 * false otherwise.
234 */
235 bool mShiftPressed;
236
237 /**
238 * True if control was pressed at the same time as the key,
239 * false otherwise.
240 */
241 bool mControlPressed;
242
243 /**
244 * True if alt was pressed at the same time as the key,
245 * false otherwise.
246 */
247 bool mAltPressed;
248
249 /**
250 * True if meta was pressed at the same time as the key,
251 * false otherwise.
252 */
253 bool mMetaPressed;
254
255 /**
256 * True if the numeric pad was used when the key was pressed,
257 * false otherwise.
258 */
259 bool mNumericPad;
260 };
261 }
262
263 #endif // end GCN_KEYINPUT_HPP