# Documentation of the MLV-0.6.716 library

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

# MLV_keyboard.h

    00001 /*
    00002  *   This file is part of the MLV Library.
    00003  *
    00004  *   Copyright (C) 2010,2011,2012 Adrien Boussicault, Marc Zipstein
    00005  *
    00006  *
    00007  *    This Library is free software: you can redistribute it and/or modify
    00008  *    it under the terms of the GNU General Public License as published by
    00009  *    the Free Software Foundation, either version 3 of the License, or
    00010  *    (at your option) any later version.
    00011  *
    00012  *    This Library is distributed in the hope that it will be useful,
    00013  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
    00014  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00015  *    GNU General Public License for more details.
    00016  *
    00017  *    You should have received a copy of the GNU General Public License
    00018  *    along with this Library.  If not, see <http://www.gnu.org/licenses/>.
    00019  */
    00020
    00032 #ifndef __MLV__MLV_KEYBOARD_H__
    00033 #define __MLV__MLV_KEYBOARD_H__
    00034
    00035 #ifndef MEMORY_DEBUG
    00036 #include <SDL/SDL.h>
    00037 #else
    00038 #include "memory_debug.h"
    00039 #endif
    00040
    00041 #include "MLV_device_with_buttons.h"
    00042
    00043 #ifdef __cplusplus
    00044 extern "C" {
    00045 #endif
    00046
    00050 typedef enum {
    00051         MLV_KEYBOARD_UNKNOWN = SDLK_UNKNOWN,
    00052         MLV_KEYBOARD_FIRST = SDLK_FIRST,
    00053         MLV_KEYBOARD_BACKSPACE = SDLK_BACKSPACE,
    00054         MLV_KEYBOARD_TAB = SDLK_TAB,
    00055         MLV_KEYBOARD_CLEAR = SDLK_CLEAR,
    00056         MLV_KEYBOARD_RETURN = SDLK_RETURN,
    00057         MLV_KEYBOARD_PAUSE = SDLK_PAUSE,
    00058         MLV_KEYBOARD_ESCAPE = SDLK_ESCAPE,
    00059         MLV_KEYBOARD_SPACE = SDLK_SPACE,
    00060         MLV_KEYBOARD_EXCLAIM = SDLK_EXCLAIM,
    00061         MLV_KEYBOARD_QUOTEDBL = SDLK_QUOTEDBL,
    00062         MLV_KEYBOARD_HASH = SDLK_HASH,
    00063         MLV_KEYBOARD_DOLLAR = SDLK_DOLLAR,
    00064         MLV_KEYBOARD_AMPERSAND = SDLK_AMPERSAND,
    00065         MLV_KEYBOARD_QUOTE = SDLK_QUOTE,
    00066         MLV_KEYBOARD_LEFTPAREN = SDLK_LEFTPAREN,
    00067         MLV_KEYBOARD_RIGHTPAREN = SDLK_RIGHTPAREN,
    00068         MLV_KEYBOARD_ASTERISK = SDLK_ASTERISK,
    00069         MLV_KEYBOARD_PLUS = SDLK_PLUS,
    00070         MLV_KEYBOARD_COMMA = SDLK_COMMA,
    00071         MLV_KEYBOARD_MINUS = SDLK_MINUS,
    00072         MLV_KEYBOARD_PERIOD = SDLK_PERIOD,
    00073         MLV_KEYBOARD_SLASH = SDLK_SLASH,
    00074         MLV_KEYBOARD_0 = SDLK_0,
    00075         MLV_KEYBOARD_1 = SDLK_1,
    00076         MLV_KEYBOARD_2 = SDLK_2,
    00077         MLV_KEYBOARD_3 = SDLK_3,
    00078         MLV_KEYBOARD_4 = SDLK_4,
    00079         MLV_KEYBOARD_5 = SDLK_5,
    00080         MLV_KEYBOARD_6 = SDLK_6,
    00081         MLV_KEYBOARD_7 = SDLK_7,
    00082         MLV_KEYBOARD_8 = SDLK_8,
    00083         MLV_KEYBOARD_9 = SDLK_9,
    00084         MLV_KEYBOARD_COLON = SDLK_COLON,
    00085         MLV_KEYBOARD_SEMICOLON = SDLK_SEMICOLON,
    00086         MLV_KEYBOARD_LESS = SDLK_LESS,
    00087         MLV_KEYBOARD_EQUALS = SDLK_EQUALS,
    00088         MLV_KEYBOARD_GREATER = SDLK_GREATER,
    00089         MLV_KEYBOARD_QUESTION = SDLK_QUESTION,
    00090         MLV_KEYBOARD_AT = SDLK_AT,
    00091
    00092         MLV_KEYBOARD_LEFTBRACKET = SDLK_LEFTBRACKET,
    00093         MLV_KEYBOARD_BACKSLASH = SDLK_BACKSLASH,
    00094         MLV_KEYBOARD_RIGHTBRACKET = SDLK_RIGHTBRACKET,
    00095         MLV_KEYBOARD_CARET = SDLK_CARET,
    00096         MLV_KEYBOARD_UNDERSCORE = SDLK_UNDERSCORE,
    00097         MLV_KEYBOARD_BACKQUOTE = SDLK_BACKQUOTE,
    00098         MLV_KEYBOARD_a = SDLK_a,
    00099         MLV_KEYBOARD_b = SDLK_b,
    00100         MLV_KEYBOARD_c = SDLK_c,
    00101         MLV_KEYBOARD_d = SDLK_d,
    00102         MLV_KEYBOARD_e = SDLK_e,
    00103         MLV_KEYBOARD_f = SDLK_f,
    00104         MLV_KEYBOARD_g = SDLK_g,
    00105         MLV_KEYBOARD_h = SDLK_h,
    00106         MLV_KEYBOARD_i = SDLK_i,
    00107         MLV_KEYBOARD_j = SDLK_j,
    00108         MLV_KEYBOARD_k = SDLK_k,
    00109         MLV_KEYBOARD_l = SDLK_l,
    00110         MLV_KEYBOARD_m = SDLK_m,
    00111         MLV_KEYBOARD_n = SDLK_n,
    00112         MLV_KEYBOARD_o = SDLK_o,
    00113         MLV_KEYBOARD_p = SDLK_p,
    00114         MLV_KEYBOARD_q = SDLK_q,
    00115         MLV_KEYBOARD_r = SDLK_r,
    00116         MLV_KEYBOARD_s = SDLK_s,
    00117         MLV_KEYBOARD_t = SDLK_t,
    00118         MLV_KEYBOARD_u = SDLK_u,
    00119         MLV_KEYBOARD_v = SDLK_v,
    00120         MLV_KEYBOARD_w = SDLK_w,
    00121         MLV_KEYBOARD_x = SDLK_x,
    00122         MLV_KEYBOARD_y = SDLK_y,
    00123         MLV_KEYBOARD_z = SDLK_z,
    00124         MLV_KEYBOARD_DELETE = SDLK_DELETE,
    00125
    00126         MLV_KEYBOARD_WORLD_0 = SDLK_WORLD_0,
    00127         MLV_KEYBOARD_WORLD_1 = SDLK_WORLD_1,
    00128         MLV_KEYBOARD_WORLD_2 = SDLK_WORLD_2,
    00129         MLV_KEYBOARD_WORLD_3 = SDLK_WORLD_3,
    00130         MLV_KEYBOARD_WORLD_4 = SDLK_WORLD_4,
    00131         MLV_KEYBOARD_WORLD_5 = SDLK_WORLD_5,
    00132         MLV_KEYBOARD_WORLD_6 = SDLK_WORLD_6,
    00133         MLV_KEYBOARD_WORLD_7 = SDLK_WORLD_7,
    00134         MLV_KEYBOARD_WORLD_8 = SDLK_WORLD_8,
    00135         MLV_KEYBOARD_WORLD_9 = SDLK_WORLD_9,
    00136         MLV_KEYBOARD_WORLD_10 = SDLK_WORLD_10,
    00137         MLV_KEYBOARD_WORLD_11 = SDLK_WORLD_11,
    00138         MLV_KEYBOARD_WORLD_12 = SDLK_WORLD_12,
    00139         MLV_KEYBOARD_WORLD_13 = SDLK_WORLD_13,
    00140         MLV_KEYBOARD_WORLD_14 = SDLK_WORLD_14,
    00141         MLV_KEYBOARD_WORLD_15 = SDLK_WORLD_15,
    00142         MLV_KEYBOARD_WORLD_16 = SDLK_WORLD_16,
    00143         MLV_KEYBOARD_WORLD_17 = SDLK_WORLD_17,
    00144         MLV_KEYBOARD_WORLD_18 = SDLK_WORLD_18,
    00145         MLV_KEYBOARD_WORLD_19 = SDLK_WORLD_19,
    00146         MLV_KEYBOARD_WORLD_20 = SDLK_WORLD_20,
    00147         MLV_KEYBOARD_WORLD_21 = SDLK_WORLD_21,
    00148         MLV_KEYBOARD_WORLD_22 = SDLK_WORLD_22,
    00149         MLV_KEYBOARD_WORLD_23 = SDLK_WORLD_23,
    00150         MLV_KEYBOARD_WORLD_24 = SDLK_WORLD_24,
    00151         MLV_KEYBOARD_WORLD_25 = SDLK_WORLD_25,
    00152         MLV_KEYBOARD_WORLD_26 = SDLK_WORLD_26,
    00153         MLV_KEYBOARD_WORLD_27 = SDLK_WORLD_27,
    00154         MLV_KEYBOARD_WORLD_28 = SDLK_WORLD_28,
    00155         MLV_KEYBOARD_WORLD_29 = SDLK_WORLD_29,
    00156         MLV_KEYBOARD_WORLD_30 = SDLK_WORLD_30,
    00157         MLV_KEYBOARD_WORLD_31 = SDLK_WORLD_31,
    00158         MLV_KEYBOARD_WORLD_32 = SDLK_WORLD_32,
    00159         MLV_KEYBOARD_WORLD_33 = SDLK_WORLD_33,
    00160         MLV_KEYBOARD_WORLD_34 = SDLK_WORLD_34,
    00161         MLV_KEYBOARD_WORLD_35 = SDLK_WORLD_35,
    00162         MLV_KEYBOARD_WORLD_36 = SDLK_WORLD_36,
    00163         MLV_KEYBOARD_WORLD_37 = SDLK_WORLD_37,
    00164         MLV_KEYBOARD_WORLD_38 = SDLK_WORLD_38,
    00165         MLV_KEYBOARD_WORLD_39 = SDLK_WORLD_39,
    00166         MLV_KEYBOARD_WORLD_40 = SDLK_WORLD_40,
    00167         MLV_KEYBOARD_WORLD_41 = SDLK_WORLD_41,
    00168         MLV_KEYBOARD_WORLD_42 = SDLK_WORLD_42,
    00169         MLV_KEYBOARD_WORLD_43 = SDLK_WORLD_43,
    00170         MLV_KEYBOARD_WORLD_44 = SDLK_WORLD_44,
    00171         MLV_KEYBOARD_WORLD_45 = SDLK_WORLD_45,
    00172         MLV_KEYBOARD_WORLD_46 = SDLK_WORLD_46,
    00173         MLV_KEYBOARD_WORLD_47 = SDLK_WORLD_47,
    00174         MLV_KEYBOARD_WORLD_48 = SDLK_WORLD_48,
    00175         MLV_KEYBOARD_WORLD_49 = SDLK_WORLD_49,
    00176         MLV_KEYBOARD_WORLD_50 = SDLK_WORLD_50,
    00177         MLV_KEYBOARD_WORLD_51 = SDLK_WORLD_51,
    00178         MLV_KEYBOARD_WORLD_52 = SDLK_WORLD_52,
    00179         MLV_KEYBOARD_WORLD_53 = SDLK_WORLD_53,
    00180         MLV_KEYBOARD_WORLD_54 = SDLK_WORLD_54,
    00181         MLV_KEYBOARD_WORLD_55 = SDLK_WORLD_55,
    00182         MLV_KEYBOARD_WORLD_56 = SDLK_WORLD_56,
    00183         MLV_KEYBOARD_WORLD_57 = SDLK_WORLD_57,
    00184         MLV_KEYBOARD_WORLD_58 = SDLK_WORLD_58,
    00185         MLV_KEYBOARD_WORLD_59 = SDLK_WORLD_59,
    00186         MLV_KEYBOARD_WORLD_60 = SDLK_WORLD_60,
    00187         MLV_KEYBOARD_WORLD_61 = SDLK_WORLD_61,
    00188         MLV_KEYBOARD_WORLD_62 = SDLK_WORLD_62,
    00189         MLV_KEYBOARD_WORLD_63 = SDLK_WORLD_63,
    00190         MLV_KEYBOARD_WORLD_64 = SDLK_WORLD_64,
    00191         MLV_KEYBOARD_WORLD_65 = SDLK_WORLD_65,
    00192         MLV_KEYBOARD_WORLD_66 = SDLK_WORLD_66,
    00193         MLV_KEYBOARD_WORLD_67 = SDLK_WORLD_67,
    00194         MLV_KEYBOARD_WORLD_68 = SDLK_WORLD_68,
    00195         MLV_KEYBOARD_WORLD_69 = SDLK_WORLD_69,
    00196         MLV_KEYBOARD_WORLD_70 = SDLK_WORLD_70,
    00197         MLV_KEYBOARD_WORLD_71 = SDLK_WORLD_71,
    00198         MLV_KEYBOARD_WORLD_72 = SDLK_WORLD_72,
    00199         MLV_KEYBOARD_WORLD_73 = SDLK_WORLD_73,
    00200         MLV_KEYBOARD_WORLD_74 = SDLK_WORLD_74,
    00201         MLV_KEYBOARD_WORLD_75 = SDLK_WORLD_75,
    00202         MLV_KEYBOARD_WORLD_76 = SDLK_WORLD_76,
    00203         MLV_KEYBOARD_WORLD_77 = SDLK_WORLD_77,
    00204         MLV_KEYBOARD_WORLD_78 = SDLK_WORLD_78,
    00205         MLV_KEYBOARD_WORLD_79 = SDLK_WORLD_79,
    00206         MLV_KEYBOARD_WORLD_80 = SDLK_WORLD_80,
    00207         MLV_KEYBOARD_WORLD_81 = SDLK_WORLD_81,
    00208         MLV_KEYBOARD_WORLD_82 = SDLK_WORLD_82,
    00209         MLV_KEYBOARD_WORLD_83 = SDLK_WORLD_83,
    00210         MLV_KEYBOARD_WORLD_84 = SDLK_WORLD_84,
    00211         MLV_KEYBOARD_WORLD_85 = SDLK_WORLD_85,
    00212         MLV_KEYBOARD_WORLD_86 = SDLK_WORLD_86,
    00213         MLV_KEYBOARD_WORLD_87 = SDLK_WORLD_87,
    00214         MLV_KEYBOARD_WORLD_88 = SDLK_WORLD_88,
    00215         MLV_KEYBOARD_WORLD_89 = SDLK_WORLD_89,
    00216         MLV_KEYBOARD_WORLD_90 = SDLK_WORLD_90,
    00217         MLV_KEYBOARD_WORLD_91 = SDLK_WORLD_91,
    00218         MLV_KEYBOARD_WORLD_92 = SDLK_WORLD_92,
    00219         MLV_KEYBOARD_WORLD_93 = SDLK_WORLD_93,
    00220         MLV_KEYBOARD_WORLD_94 = SDLK_WORLD_94,
    00221         MLV_KEYBOARD_WORLD_95 = SDLK_WORLD_95,
    00222
    00223         MLV_KEYBOARD_KP0 = SDLK_KP0,
    00224         MLV_KEYBOARD_KP1 = SDLK_KP1,
    00225         MLV_KEYBOARD_KP2 = SDLK_KP2,
    00226         MLV_KEYBOARD_KP3 = SDLK_KP3,
    00227         MLV_KEYBOARD_KP4 = SDLK_KP4,
    00228         MLV_KEYBOARD_KP5 = SDLK_KP5,
    00229         MLV_KEYBOARD_KP6 = SDLK_KP6,
    00230         MLV_KEYBOARD_KP7 = SDLK_KP7,
    00231         MLV_KEYBOARD_KP8 = SDLK_KP8,
    00232         MLV_KEYBOARD_KP9 = SDLK_KP9,
    00233         MLV_KEYBOARD_KP_PERIOD = SDLK_KP_PERIOD,
    00234         MLV_KEYBOARD_KP_DIVIDE = SDLK_KP_DIVIDE,
    00235         MLV_KEYBOARD_KP_MULTIPLY = SDLK_KP_MULTIPLY,
    00236         MLV_KEYBOARD_KP_MINUS = SDLK_KP_MINUS,
    00237         MLV_KEYBOARD_KP_PLUS = SDLK_KP_PLUS,
    00238         MLV_KEYBOARD_KP_ENTER = SDLK_KP_ENTER,
    00239         MLV_KEYBOARD_KP_EQUALS = SDLK_KP_EQUALS,
    00240
    00241         MLV_KEYBOARD_UP = SDLK_UP,
    00242         MLV_KEYBOARD_DOWN = SDLK_DOWN,
    00243         MLV_KEYBOARD_RIGHT = SDLK_RIGHT,
    00244         MLV_KEYBOARD_LEFT = SDLK_LEFT,
    00245         MLV_KEYBOARD_INSERT = SDLK_INSERT,
    00246         MLV_KEYBOARD_HOME = SDLK_HOME,
    00247         MLV_KEYBOARD_END = SDLK_END,
    00248         MLV_KEYBOARD_PAGEUP = SDLK_PAGEUP,
    00249         MLV_KEYBOARD_PAGEDOWN = SDLK_PAGEDOWN,
    00250
    00251         MLV_KEYBOARD_F1 = SDLK_F1,
    00252         MLV_KEYBOARD_F2 = SDLK_F2,
    00253         MLV_KEYBOARD_F3 = SDLK_F3,
    00254         MLV_KEYBOARD_F4 = SDLK_F4,
    00255         MLV_KEYBOARD_F5 = SDLK_F5,
    00256         MLV_KEYBOARD_F6 = SDLK_F6,
    00257         MLV_KEYBOARD_F7 = SDLK_F7,
    00258         MLV_KEYBOARD_F8 = SDLK_F8,
    00259         MLV_KEYBOARD_F9 = SDLK_F9,
    00260         MLV_KEYBOARD_F10 = SDLK_F10,
    00261         MLV_KEYBOARD_F11 = SDLK_F11,
    00262         MLV_KEYBOARD_F12 = SDLK_F12,
    00263         MLV_KEYBOARD_F13 = SDLK_F13,
    00264         MLV_KEYBOARD_F14 = SDLK_F14,
    00265         MLV_KEYBOARD_F15 = SDLK_F15,
    00266
    00267         MLV_KEYBOARD_NUMLOCK = SDLK_NUMLOCK,
    00268         MLV_KEYBOARD_CAPSLOCK = SDLK_CAPSLOCK,
    00269         MLV_KEYBOARD_SCROLLOCK = SDLK_SCROLLOCK,
    00270         MLV_KEYBOARD_RSHIFT = SDLK_RSHIFT,
    00271         MLV_KEYBOARD_LSHIFT = SDLK_LSHIFT,
    00272         MLV_KEYBOARD_RCTRL = SDLK_RCTRL,
    00273         MLV_KEYBOARD_LCTRL = SDLK_LCTRL,
    00274         MLV_KEYBOARD_RALT = SDLK_RALT,
    00275         MLV_KEYBOARD_LALT = SDLK_LALT,
    00276         MLV_KEYBOARD_RMETA = SDLK_RMETA,
    00277         MLV_KEYBOARD_LMETA = SDLK_LMETA,
    00278         MLV_KEYBOARD_LSUPER = SDLK_LSUPER,
    00279         MLV_KEYBOARD_RSUPER = SDLK_RSUPER,
    00280         MLV_KEYBOARD_MODE = SDLK_MODE,
    00281         MLV_KEYBOARD_COMPOSE = SDLK_COMPOSE,
    00282
    00283         MLV_KEYBOARD_HELP = SDLK_HELP,
    00284         MLV_KEYBOARD_PRINT = SDLK_PRINT,
    00285         MLV_KEYBOARD_SYSREQ = SDLK_SYSREQ,
    00286         MLV_KEYBOARD_BREAK = SDLK_BREAK,
    00287         MLV_KEYBOARD_MENU = SDLK_MENU,
    00288         MLV_KEYBOARD_POWER = SDLK_POWER,
    00289         MLV_KEYBOARD_EURO = SDLK_EURO,
    00290         MLV_KEYBOARD_UNDO = SDLK_UNDO,
    00291
    00292         MLV_KEYBOARD_LAST = SDLK_LAST
    00293 } MLV_Keyboard_button;
    00294
    00298 typedef enum {
    00299         MLV_KEYBOARD_KMOD_NONE = KMOD_NONE,
    00300         MLV_KEYBOARD_KMOD_LSHIFT = KMOD_LSHIFT,
    00301         MLV_KEYBOARD_KMOD_RSHIFT = KMOD_RSHIFT,
    00302         MLV_KEYBOARD_KMOD_LCTRL = KMOD_LCTRL,
    00303         MLV_KEYBOARD_KMOD_RCTRL = KMOD_RCTRL,
    00304         MLV_KEYBOARD_KMOD_LALT = KMOD_LALT,
    00305         MLV_KEYBOARD_KMOD_RALT = KMOD_RALT,
    00306         MLV_KEYBOARD_KMOD_LMETA = KMOD_LMETA,
    00307         MLV_KEYBOARD_KMOD_RMETA = KMOD_RMETA,
    00308         MLV_KEYBOARD_KMOD_NUM = KMOD_NUM,
    00309         MLV_KEYBOARD_KMOD_CAPS = KMOD_CAPS,
    00310         MLV_KEYBOARD_KMOD_MODE = KMOD_MODE,
    00311         MLV_KEYBOARD_KMOD_RESERVED = KMOD_RESERVED
    00312 } MLV_Keyboard_modifier;
    00313
    00335 void MLV_wait_keyboard( MLV_Keyboard_button* sym, MLV_Keyboard_modifier* mod, int* unicode );
    00336
    00359 int MLV_wait_keyboard_or_seconds(
    00360         MLV_Keyboard_button* sym, MLV_Keyboard_modifier* mod, int* unicode, int seconds
    00361 );
    00362
    00363
    00372 MLV_Keyboard_button MLV_convert_string_to_keyboard_button( const char* key_string );
    00373
    00382 const char* MLV_convert_keyboard_button_to_string( MLV_Keyboard_button key_code );
    00383
    00392 char* MLV_convert_keyboard_mod_to_string( MLV_Keyboard_modifier keymod_code );
    00393
    00394
    00402 MLV_Button_state MLV_get_keyboard_state( MLV_Keyboard_button keyboard_code );
    00403
    00411 int MLV_shift_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00412
    00420 int MLV_left_shift_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00421
    00429 int MLV_right_shift_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00430
    00438 int MLV_left_ctrl_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00439
    00447 int MLV_right_ctrl_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00448
    00456 int MLV_ctrl_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00457
    00465 int MLV_left_alt_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00466
    00474 int MLV_right_alt_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00475
    00483 int MLV_alt_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00484
    00492 int MLV_left_meta_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00493
    00501 int MLV_right_meta_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00502
    00510 int MLV_meta_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00511
    00519 int MLV_num_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00520
    00528 int MLV_caps_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00529
    00537 int MLV_mode_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00538
    00539
    00540 #ifdef __cplusplus
    00541 }
    00542 #endif
    00543
    00544 #endif