# Documentation of the MLV-2.0.2 library

- Presentation
- Downloads
- Installation
- Compilation
- Examples
- API
- List of functions
- bugs
- FAQ
- contacts

MLV_keyboard.h
1 /*
2 * This file is part of the MLV Library.
3 *
4 * Copyright (C) 2010,2011,2012 Adrien Boussicault, Marc Zipstein
5 *
6 *
7 * This Library is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This Library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this Library. If not, see <http://www.gnu.org/licenses/>.
19 */
20
32 #ifndef __MLV__MLV_KEYBOARD_H__
33 #define __MLV__MLV_KEYBOARD_H__
34
35 #ifndef MEMORY_DEBUG
36 #include <SDL/SDL.h>
37 #else
38 #include "memory_debug.h"
39 #endif
40
41 #include "MLV_device_with_buttons.h"
42
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46
50 typedef enum {
51 MLV_KEYBOARD_NONE = SDLK_UNKNOWN,
52 MLV_KEYBOARD_UNKNOWN = SDLK_UNKNOWN,
53 MLV_KEYBOARD_FIRST = SDLK_FIRST,
54 MLV_KEYBOARD_BACKSPACE = SDLK_BACKSPACE,
55 MLV_KEYBOARD_TAB = SDLK_TAB,
56 MLV_KEYBOARD_CLEAR = SDLK_CLEAR,
57 MLV_KEYBOARD_RETURN = SDLK_RETURN,
58 MLV_KEYBOARD_PAUSE = SDLK_PAUSE,
59 MLV_KEYBOARD_ESCAPE = SDLK_ESCAPE,
60 MLV_KEYBOARD_SPACE = SDLK_SPACE,
61 MLV_KEYBOARD_EXCLAIM = SDLK_EXCLAIM,
62 MLV_KEYBOARD_QUOTEDBL = SDLK_QUOTEDBL,
63 MLV_KEYBOARD_HASH = SDLK_HASH,
64 MLV_KEYBOARD_DOLLAR = SDLK_DOLLAR,
65 MLV_KEYBOARD_AMPERSAND = SDLK_AMPERSAND,
66 MLV_KEYBOARD_QUOTE = SDLK_QUOTE,
67 MLV_KEYBOARD_LEFTPAREN = SDLK_LEFTPAREN,
68 MLV_KEYBOARD_RIGHTPAREN = SDLK_RIGHTPAREN,
69 MLV_KEYBOARD_ASTERISK = SDLK_ASTERISK,
70 MLV_KEYBOARD_PLUS = SDLK_PLUS,
71 MLV_KEYBOARD_COMMA = SDLK_COMMA,
72 MLV_KEYBOARD_MINUS = SDLK_MINUS,
73 MLV_KEYBOARD_PERIOD = SDLK_PERIOD,
74 MLV_KEYBOARD_SLASH = SDLK_SLASH,
75 MLV_KEYBOARD_0 = SDLK_0,
76 MLV_KEYBOARD_1 = SDLK_1,
77 MLV_KEYBOARD_2 = SDLK_2,
78 MLV_KEYBOARD_3 = SDLK_3,
79 MLV_KEYBOARD_4 = SDLK_4,
80 MLV_KEYBOARD_5 = SDLK_5,
81 MLV_KEYBOARD_6 = SDLK_6,
82 MLV_KEYBOARD_7 = SDLK_7,
83 MLV_KEYBOARD_8 = SDLK_8,
84 MLV_KEYBOARD_9 = SDLK_9,
85 MLV_KEYBOARD_COLON = SDLK_COLON,
86 MLV_KEYBOARD_SEMICOLON = SDLK_SEMICOLON,
87 MLV_KEYBOARD_LESS = SDLK_LESS,
88 MLV_KEYBOARD_EQUALS = SDLK_EQUALS,
89 MLV_KEYBOARD_GREATER = SDLK_GREATER,
90 MLV_KEYBOARD_QUESTION = SDLK_QUESTION,
91 MLV_KEYBOARD_AT = SDLK_AT,
92
93 MLV_KEYBOARD_LEFTBRACKET = SDLK_LEFTBRACKET,
94 MLV_KEYBOARD_BACKSLASH = SDLK_BACKSLASH,
95 MLV_KEYBOARD_RIGHTBRACKET = SDLK_RIGHTBRACKET,
96 MLV_KEYBOARD_CARET = SDLK_CARET,
97 MLV_KEYBOARD_UNDERSCORE = SDLK_UNDERSCORE,
98 MLV_KEYBOARD_BACKQUOTE = SDLK_BACKQUOTE,
99 MLV_KEYBOARD_a = SDLK_a,
100 MLV_KEYBOARD_b = SDLK_b,
101 MLV_KEYBOARD_c = SDLK_c,
102 MLV_KEYBOARD_d = SDLK_d,
103 MLV_KEYBOARD_e = SDLK_e,
104 MLV_KEYBOARD_f = SDLK_f,
105 MLV_KEYBOARD_g = SDLK_g,
106 MLV_KEYBOARD_h = SDLK_h,
107 MLV_KEYBOARD_i = SDLK_i,
108 MLV_KEYBOARD_j = SDLK_j,
109 MLV_KEYBOARD_k = SDLK_k,
110 MLV_KEYBOARD_l = SDLK_l,
111 MLV_KEYBOARD_m = SDLK_m,
112 MLV_KEYBOARD_n = SDLK_n,
113 MLV_KEYBOARD_o = SDLK_o,
114 MLV_KEYBOARD_p = SDLK_p,
115 MLV_KEYBOARD_q = SDLK_q,
116 MLV_KEYBOARD_r = SDLK_r,
117 MLV_KEYBOARD_s = SDLK_s,
118 MLV_KEYBOARD_t = SDLK_t,
119 MLV_KEYBOARD_u = SDLK_u,
120 MLV_KEYBOARD_v = SDLK_v,
121 MLV_KEYBOARD_w = SDLK_w,
122 MLV_KEYBOARD_x = SDLK_x,
123 MLV_KEYBOARD_y = SDLK_y,
124 MLV_KEYBOARD_z = SDLK_z,
125 MLV_KEYBOARD_DELETE = SDLK_DELETE,
126
127 MLV_KEYBOARD_WORLD_0 = SDLK_WORLD_0,
128 MLV_KEYBOARD_WORLD_1 = SDLK_WORLD_1,
129 MLV_KEYBOARD_WORLD_2 = SDLK_WORLD_2,
130 MLV_KEYBOARD_WORLD_3 = SDLK_WORLD_3,
131 MLV_KEYBOARD_WORLD_4 = SDLK_WORLD_4,
132 MLV_KEYBOARD_WORLD_5 = SDLK_WORLD_5,
133 MLV_KEYBOARD_WORLD_6 = SDLK_WORLD_6,
134 MLV_KEYBOARD_WORLD_7 = SDLK_WORLD_7,
135 MLV_KEYBOARD_WORLD_8 = SDLK_WORLD_8,
136 MLV_KEYBOARD_WORLD_9 = SDLK_WORLD_9,
137 MLV_KEYBOARD_WORLD_10 = SDLK_WORLD_10,
138 MLV_KEYBOARD_WORLD_11 = SDLK_WORLD_11,
139 MLV_KEYBOARD_WORLD_12 = SDLK_WORLD_12,
140 MLV_KEYBOARD_WORLD_13 = SDLK_WORLD_13,
141 MLV_KEYBOARD_WORLD_14 = SDLK_WORLD_14,
142 MLV_KEYBOARD_WORLD_15 = SDLK_WORLD_15,
143 MLV_KEYBOARD_WORLD_16 = SDLK_WORLD_16,
144 MLV_KEYBOARD_WORLD_17 = SDLK_WORLD_17,
145 MLV_KEYBOARD_WORLD_18 = SDLK_WORLD_18,
146 MLV_KEYBOARD_WORLD_19 = SDLK_WORLD_19,
147 MLV_KEYBOARD_WORLD_20 = SDLK_WORLD_20,
148 MLV_KEYBOARD_WORLD_21 = SDLK_WORLD_21,
149 MLV_KEYBOARD_WORLD_22 = SDLK_WORLD_22,
150 MLV_KEYBOARD_WORLD_23 = SDLK_WORLD_23,
151 MLV_KEYBOARD_WORLD_24 = SDLK_WORLD_24,
152 MLV_KEYBOARD_WORLD_25 = SDLK_WORLD_25,
153 MLV_KEYBOARD_WORLD_26 = SDLK_WORLD_26,
154 MLV_KEYBOARD_WORLD_27 = SDLK_WORLD_27,
155 MLV_KEYBOARD_WORLD_28 = SDLK_WORLD_28,
156 MLV_KEYBOARD_WORLD_29 = SDLK_WORLD_29,
157 MLV_KEYBOARD_WORLD_30 = SDLK_WORLD_30,
158 MLV_KEYBOARD_WORLD_31 = SDLK_WORLD_31,
159 MLV_KEYBOARD_WORLD_32 = SDLK_WORLD_32,
160 MLV_KEYBOARD_WORLD_33 = SDLK_WORLD_33,
161 MLV_KEYBOARD_WORLD_34 = SDLK_WORLD_34,
162 MLV_KEYBOARD_WORLD_35 = SDLK_WORLD_35,
163 MLV_KEYBOARD_WORLD_36 = SDLK_WORLD_36,
164 MLV_KEYBOARD_WORLD_37 = SDLK_WORLD_37,
165 MLV_KEYBOARD_WORLD_38 = SDLK_WORLD_38,
166 MLV_KEYBOARD_WORLD_39 = SDLK_WORLD_39,
167 MLV_KEYBOARD_WORLD_40 = SDLK_WORLD_40,
168 MLV_KEYBOARD_WORLD_41 = SDLK_WORLD_41,
169 MLV_KEYBOARD_WORLD_42 = SDLK_WORLD_42,
170 MLV_KEYBOARD_WORLD_43 = SDLK_WORLD_43,
171 MLV_KEYBOARD_WORLD_44 = SDLK_WORLD_44,
172 MLV_KEYBOARD_WORLD_45 = SDLK_WORLD_45,
173 MLV_KEYBOARD_WORLD_46 = SDLK_WORLD_46,
174 MLV_KEYBOARD_WORLD_47 = SDLK_WORLD_47,
175 MLV_KEYBOARD_WORLD_48 = SDLK_WORLD_48,
176 MLV_KEYBOARD_WORLD_49 = SDLK_WORLD_49,
177 MLV_KEYBOARD_WORLD_50 = SDLK_WORLD_50,
178 MLV_KEYBOARD_WORLD_51 = SDLK_WORLD_51,
179 MLV_KEYBOARD_WORLD_52 = SDLK_WORLD_52,
180 MLV_KEYBOARD_WORLD_53 = SDLK_WORLD_53,
181 MLV_KEYBOARD_WORLD_54 = SDLK_WORLD_54,
182 MLV_KEYBOARD_WORLD_55 = SDLK_WORLD_55,
183 MLV_KEYBOARD_WORLD_56 = SDLK_WORLD_56,
184 MLV_KEYBOARD_WORLD_57 = SDLK_WORLD_57,
185 MLV_KEYBOARD_WORLD_58 = SDLK_WORLD_58,
186 MLV_KEYBOARD_WORLD_59 = SDLK_WORLD_59,
187 MLV_KEYBOARD_WORLD_60 = SDLK_WORLD_60,
188 MLV_KEYBOARD_WORLD_61 = SDLK_WORLD_61,
189 MLV_KEYBOARD_WORLD_62 = SDLK_WORLD_62,
190 MLV_KEYBOARD_WORLD_63 = SDLK_WORLD_63,
191 MLV_KEYBOARD_WORLD_64 = SDLK_WORLD_64,
192 MLV_KEYBOARD_WORLD_65 = SDLK_WORLD_65,
193 MLV_KEYBOARD_WORLD_66 = SDLK_WORLD_66,
194 MLV_KEYBOARD_WORLD_67 = SDLK_WORLD_67,
195 MLV_KEYBOARD_WORLD_68 = SDLK_WORLD_68,
196 MLV_KEYBOARD_WORLD_69 = SDLK_WORLD_69,
197 MLV_KEYBOARD_WORLD_70 = SDLK_WORLD_70,
198 MLV_KEYBOARD_WORLD_71 = SDLK_WORLD_71,
199 MLV_KEYBOARD_WORLD_72 = SDLK_WORLD_72,
200 MLV_KEYBOARD_WORLD_73 = SDLK_WORLD_73,
201 MLV_KEYBOARD_WORLD_74 = SDLK_WORLD_74,
202 MLV_KEYBOARD_WORLD_75 = SDLK_WORLD_75,
203 MLV_KEYBOARD_WORLD_76 = SDLK_WORLD_76,
204 MLV_KEYBOARD_WORLD_77 = SDLK_WORLD_77,
205 MLV_KEYBOARD_WORLD_78 = SDLK_WORLD_78,
206 MLV_KEYBOARD_WORLD_79 = SDLK_WORLD_79,
207 MLV_KEYBOARD_WORLD_80 = SDLK_WORLD_80,
208 MLV_KEYBOARD_WORLD_81 = SDLK_WORLD_81,
209 MLV_KEYBOARD_WORLD_82 = SDLK_WORLD_82,
210 MLV_KEYBOARD_WORLD_83 = SDLK_WORLD_83,
211 MLV_KEYBOARD_WORLD_84 = SDLK_WORLD_84,
212 MLV_KEYBOARD_WORLD_85 = SDLK_WORLD_85,
213 MLV_KEYBOARD_WORLD_86 = SDLK_WORLD_86,
214 MLV_KEYBOARD_WORLD_87 = SDLK_WORLD_87,
215 MLV_KEYBOARD_WORLD_88 = SDLK_WORLD_88,
216 MLV_KEYBOARD_WORLD_89 = SDLK_WORLD_89,
217 MLV_KEYBOARD_WORLD_90 = SDLK_WORLD_90,
218 MLV_KEYBOARD_WORLD_91 = SDLK_WORLD_91,
219 MLV_KEYBOARD_WORLD_92 = SDLK_WORLD_92,
220 MLV_KEYBOARD_WORLD_93 = SDLK_WORLD_93,
221 MLV_KEYBOARD_WORLD_94 = SDLK_WORLD_94,
222 MLV_KEYBOARD_WORLD_95 = SDLK_WORLD_95,
223
224 MLV_KEYBOARD_KP0 = SDLK_KP0,
225 MLV_KEYBOARD_KP1 = SDLK_KP1,
226 MLV_KEYBOARD_KP2 = SDLK_KP2,
227 MLV_KEYBOARD_KP3 = SDLK_KP3,
228 MLV_KEYBOARD_KP4 = SDLK_KP4,
229 MLV_KEYBOARD_KP5 = SDLK_KP5,
230 MLV_KEYBOARD_KP6 = SDLK_KP6,
231 MLV_KEYBOARD_KP7 = SDLK_KP7,
232 MLV_KEYBOARD_KP8 = SDLK_KP8,
233 MLV_KEYBOARD_KP9 = SDLK_KP9,
234 MLV_KEYBOARD_KP_PERIOD = SDLK_KP_PERIOD,
235 MLV_KEYBOARD_KP_DIVIDE = SDLK_KP_DIVIDE,
236 MLV_KEYBOARD_KP_MULTIPLY = SDLK_KP_MULTIPLY,
237 MLV_KEYBOARD_KP_MINUS = SDLK_KP_MINUS,
238 MLV_KEYBOARD_KP_PLUS = SDLK_KP_PLUS,
239 MLV_KEYBOARD_KP_ENTER = SDLK_KP_ENTER,
240 MLV_KEYBOARD_KP_EQUALS = SDLK_KP_EQUALS,
241
242 MLV_KEYBOARD_UP = SDLK_UP,
243 MLV_KEYBOARD_DOWN = SDLK_DOWN,
244 MLV_KEYBOARD_RIGHT = SDLK_RIGHT,
245 MLV_KEYBOARD_LEFT = SDLK_LEFT,
246 MLV_KEYBOARD_INSERT = SDLK_INSERT,
247 MLV_KEYBOARD_HOME = SDLK_HOME,
248 MLV_KEYBOARD_END = SDLK_END,
249 MLV_KEYBOARD_PAGEUP = SDLK_PAGEUP,
250 MLV_KEYBOARD_PAGEDOWN = SDLK_PAGEDOWN,
251
252 MLV_KEYBOARD_F1 = SDLK_F1,
253 MLV_KEYBOARD_F2 = SDLK_F2,
254 MLV_KEYBOARD_F3 = SDLK_F3,
255 MLV_KEYBOARD_F4 = SDLK_F4,
256 MLV_KEYBOARD_F5 = SDLK_F5,
257 MLV_KEYBOARD_F6 = SDLK_F6,
258 MLV_KEYBOARD_F7 = SDLK_F7,
259 MLV_KEYBOARD_F8 = SDLK_F8,
260 MLV_KEYBOARD_F9 = SDLK_F9,
261 MLV_KEYBOARD_F10 = SDLK_F10,
262 MLV_KEYBOARD_F11 = SDLK_F11,
263 MLV_KEYBOARD_F12 = SDLK_F12,
264 MLV_KEYBOARD_F13 = SDLK_F13,
265 MLV_KEYBOARD_F14 = SDLK_F14,
266 MLV_KEYBOARD_F15 = SDLK_F15,
267
268 MLV_KEYBOARD_NUMLOCK = SDLK_NUMLOCK,
269 MLV_KEYBOARD_CAPSLOCK = SDLK_CAPSLOCK,
270 MLV_KEYBOARD_SCROLLOCK = SDLK_SCROLLOCK,
271 MLV_KEYBOARD_RSHIFT = SDLK_RSHIFT,
272 MLV_KEYBOARD_LSHIFT = SDLK_LSHIFT,
273 MLV_KEYBOARD_RCTRL = SDLK_RCTRL,
274 MLV_KEYBOARD_LCTRL = SDLK_LCTRL,
275 MLV_KEYBOARD_RALT = SDLK_RALT,
276 MLV_KEYBOARD_LALT = SDLK_LALT,
277 MLV_KEYBOARD_RMETA = SDLK_RMETA,
278 MLV_KEYBOARD_LMETA = SDLK_LMETA,
279 MLV_KEYBOARD_LSUPER = SDLK_LSUPER,
280 MLV_KEYBOARD_RSUPER = SDLK_RSUPER,
281 MLV_KEYBOARD_MODE = SDLK_MODE,
282 MLV_KEYBOARD_COMPOSE = SDLK_COMPOSE,
283
284 MLV_KEYBOARD_HELP = SDLK_HELP,
285 MLV_KEYBOARD_PRINT = SDLK_PRINT,
286 MLV_KEYBOARD_SYSREQ = SDLK_SYSREQ,
287 MLV_KEYBOARD_BREAK = SDLK_BREAK,
288 MLV_KEYBOARD_MENU = SDLK_MENU,
289 MLV_KEYBOARD_POWER = SDLK_POWER,
290 MLV_KEYBOARD_EURO = SDLK_EURO,
291 MLV_KEYBOARD_UNDO = SDLK_UNDO,
292
293 MLV_KEYBOARD_LAST = SDLK_LAST
294 } MLV_Keyboard_button;
295
299 typedef enum {
300 MLV_KEYBOARD_KMOD_NONE = KMOD_NONE,
301 MLV_KEYBOARD_KMOD_LSHIFT = KMOD_LSHIFT,
302 MLV_KEYBOARD_KMOD_RSHIFT = KMOD_RSHIFT,
303 MLV_KEYBOARD_KMOD_LCTRL = KMOD_LCTRL,
304 MLV_KEYBOARD_KMOD_RCTRL = KMOD_RCTRL,
305 MLV_KEYBOARD_KMOD_LALT = KMOD_LALT,
306 MLV_KEYBOARD_KMOD_RALT = KMOD_RALT,
307 MLV_KEYBOARD_KMOD_LMETA = KMOD_LMETA,
308 MLV_KEYBOARD_KMOD_RMETA = KMOD_RMETA,
309 MLV_KEYBOARD_KMOD_NUM = KMOD_NUM,
310 MLV_KEYBOARD_KMOD_CAPS = KMOD_CAPS,
311 MLV_KEYBOARD_KMOD_MODE = KMOD_MODE,
312 MLV_KEYBOARD_KMOD_RESERVED = KMOD_RESERVED
313 } MLV_Keyboard_modifier;
314
336 void MLV_wait_keyboard( MLV_Keyboard_button* sym, MLV_Keyboard_modifier* mod, int* unicode );
337
360 int MLV_wait_keyboard_or_seconds(
361 MLV_Keyboard_button* sym, MLV_Keyboard_modifier* mod, int* unicode, int seconds
362 );
363
364
373 MLV_Keyboard_button MLV_convert_string_to_keyboard_button( const char* key_string );
374
383 const char* MLV_convert_keyboard_button_to_string( MLV_Keyboard_button key_code );
384
393 char* MLV_convert_keyboard_mod_to_string( MLV_Keyboard_modifier keymod_code );
394
395
403 MLV_Button_state MLV_get_keyboard_state( MLV_Keyboard_button keyboard_code );
404
412 int MLV_shift_key_was_pressed( MLV_Keyboard_modifier modifier_code );
413
421 int MLV_left_shift_key_was_pressed( MLV_Keyboard_modifier modifier_code );
422
430 int MLV_right_shift_key_was_pressed( MLV_Keyboard_modifier modifier_code );
431
439 int MLV_left_ctrl_key_was_pressed( MLV_Keyboard_modifier modifier_code );
440
448 int MLV_right_ctrl_key_was_pressed( MLV_Keyboard_modifier modifier_code );
449
457 int MLV_ctrl_key_was_pressed( MLV_Keyboard_modifier modifier_code );
458
466 int MLV_left_alt_key_was_pressed( MLV_Keyboard_modifier modifier_code );
467
475 int MLV_right_alt_key_was_pressed( MLV_Keyboard_modifier modifier_code );
476
484 int MLV_alt_key_was_pressed( MLV_Keyboard_modifier modifier_code );
485
493 int MLV_left_meta_key_was_pressed( MLV_Keyboard_modifier modifier_code );
494
502 int MLV_right_meta_key_was_pressed( MLV_Keyboard_modifier modifier_code );
503
511 int MLV_meta_key_was_pressed( MLV_Keyboard_modifier modifier_code );
512
520 int MLV_num_key_was_pressed( MLV_Keyboard_modifier modifier_code );
521
529 int MLV_caps_key_was_pressed( MLV_Keyboard_modifier modifier_code );
530
538 int MLV_mode_key_was_pressed( MLV_Keyboard_modifier modifier_code );
539
540
541 #ifdef __cplusplus
542 }
543 #endif
544
545 #endif