# Documentation of the MLV-0.6.705 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_KP0 = SDLK_KP0,
    00127         MLV_KEYBOARD_KP1 = SDLK_KP1,
    00128         MLV_KEYBOARD_KP2 = SDLK_KP2,
    00129         MLV_KEYBOARD_KP3 = SDLK_KP3,
    00130         MLV_KEYBOARD_KP4 = SDLK_KP4,
    00131         MLV_KEYBOARD_KP5 = SDLK_KP5,
    00132         MLV_KEYBOARD_KP6 = SDLK_KP6,
    00133         MLV_KEYBOARD_KP7 = SDLK_KP7,
    00134         MLV_KEYBOARD_KP8 = SDLK_KP8,
    00135         MLV_KEYBOARD_KP9 = SDLK_KP9,
    00136         MLV_KEYBOARD_KP_PERIOD = SDLK_KP_PERIOD,
    00137         MLV_KEYBOARD_KP_DIVIDE = SDLK_KP_DIVIDE,
    00138         MLV_KEYBOARD_KP_MULTIPLY = SDLK_KP_MULTIPLY,
    00139         MLV_KEYBOARD_KP_MINUS = SDLK_KP_MINUS,
    00140         MLV_KEYBOARD_KP_PLUS = SDLK_KP_PLUS,
    00141         MLV_KEYBOARD_KP_ENTER = SDLK_KP_ENTER,
    00142         MLV_KEYBOARD_KP_EQUALS = SDLK_KP_EQUALS,
    00143
    00144         MLV_KEYBOARD_UP = SDLK_UP,
    00145         MLV_KEYBOARD_DOWN = SDLK_DOWN,
    00146         MLV_KEYBOARD_RIGHT = SDLK_RIGHT,
    00147         MLV_KEYBOARD_LEFT = SDLK_LEFT,
    00148         MLV_KEYBOARD_INSERT = SDLK_INSERT,
    00149         MLV_KEYBOARD_HOME = SDLK_HOME,
    00150         MLV_KEYBOARD_END = SDLK_END,
    00151         MLV_KEYBOARD_PAGEUP = SDLK_PAGEUP,
    00152         MLV_KEYBOARD_PAGEDOWN = SDLK_PAGEDOWN,
    00153
    00154         MLV_KEYBOARD_F1 = SDLK_F1,
    00155         MLV_KEYBOARD_F2 = SDLK_F2,
    00156         MLV_KEYBOARD_F3 = SDLK_F3,
    00157         MLV_KEYBOARD_F4 = SDLK_F4,
    00158         MLV_KEYBOARD_F5 = SDLK_F5,
    00159         MLV_KEYBOARD_F6 = SDLK_F6,
    00160         MLV_KEYBOARD_F7 = SDLK_F7,
    00161         MLV_KEYBOARD_F8 = SDLK_F8,
    00162         MLV_KEYBOARD_F9 = SDLK_F9,
    00163         MLV_KEYBOARD_F10 = SDLK_F10,
    00164         MLV_KEYBOARD_F11 = SDLK_F11,
    00165         MLV_KEYBOARD_F12 = SDLK_F12,
    00166         MLV_KEYBOARD_F13 = SDLK_F13,
    00167         MLV_KEYBOARD_F14 = SDLK_F14,
    00168         MLV_KEYBOARD_F15 = SDLK_F15,
    00169
    00170         MLV_KEYBOARD_NUMLOCK = SDLK_NUMLOCK,
    00171         MLV_KEYBOARD_CAPSLOCK = SDLK_CAPSLOCK,
    00172         MLV_KEYBOARD_SCROLLOCK = SDLK_SCROLLOCK,
    00173         MLV_KEYBOARD_RSHIFT = SDLK_RSHIFT,
    00174         MLV_KEYBOARD_LSHIFT = SDLK_LSHIFT,
    00175         MLV_KEYBOARD_RCTRL = SDLK_RCTRL,
    00176         MLV_KEYBOARD_LCTRL = SDLK_LCTRL,
    00177         MLV_KEYBOARD_RALT = SDLK_RALT,
    00178         MLV_KEYBOARD_LALT = SDLK_LALT,
    00179         MLV_KEYBOARD_RMETA = SDLK_RMETA,
    00180         MLV_KEYBOARD_LMETA = SDLK_LMETA,
    00181         MLV_KEYBOARD_LSUPER = SDLK_LSUPER,
    00182         MLV_KEYBOARD_RSUPER = SDLK_RSUPER,
    00183         MLV_KEYBOARD_MODE = SDLK_MODE,
    00184         MLV_KEYBOARD_COMPOSE = SDLK_COMPOSE,
    00185
    00186         MLV_KEYBOARD_HELP = SDLK_HELP,
    00187         MLV_KEYBOARD_PRINT = SDLK_PRINT,
    00188         MLV_KEYBOARD_SYSREQ = SDLK_SYSREQ,
    00189         MLV_KEYBOARD_BREAK = SDLK_BREAK,
    00190         MLV_KEYBOARD_MENU = SDLK_MENU,
    00191         MLV_KEYBOARD_POWER = SDLK_POWER,
    00192         MLV_KEYBOARD_EURO = SDLK_EURO,
    00193         MLV_KEYBOARD_UNDO = SDLK_UNDO,
    00194
    00195         MLV_KEYBOARD_LAST = SDLK_LAST
    00196 } MLV_Keyboard_button;
    00197
    00201 typedef enum {
    00202         MLV_KEYBOARD_KMOD_NONE = KMOD_NONE,
    00203         MLV_KEYBOARD_KMOD_LSHIFT = KMOD_LSHIFT,
    00204         MLV_KEYBOARD_KMOD_RSHIFT = KMOD_RSHIFT,
    00205         MLV_KEYBOARD_KMOD_LCTRL = KMOD_LCTRL,
    00206         MLV_KEYBOARD_KMOD_RCTRL = KMOD_RCTRL,
    00207         MLV_KEYBOARD_KMOD_LALT = KMOD_LALT,
    00208         MLV_KEYBOARD_KMOD_RALT = KMOD_RALT,
    00209         MLV_KEYBOARD_KMOD_LMETA = KMOD_LMETA,
    00210         MLV_KEYBOARD_KMOD_RMETA = KMOD_RMETA,
    00211         MLV_KEYBOARD_KMOD_NUM = KMOD_NUM,
    00212         MLV_KEYBOARD_KMOD_CAPS = KMOD_CAPS,
    00213         MLV_KEYBOARD_KMOD_MODE = KMOD_MODE,
    00214         MLV_KEYBOARD_KMOD_RESERVED = KMOD_RESERVED
    00215 } MLV_Keyboard_modifier;
    00216
    00238 void MLV_wait_keyboard( MLV_Keyboard_button* sym, MLV_Keyboard_modifier* mod, int* unicode );
    00239
    00262 int MLV_wait_keyboard_or_seconds(
    00263         MLV_Keyboard_button* sym, MLV_Keyboard_modifier* mod, int* unicode, int seconds
    00264 );
    00265
    00266
    00275 MLV_Keyboard_button MLV_convert_string_to_keyboard_button( const char* key_string );
    00276
    00285 MLV_Keyboard_modifier MLV_convert_string_to_keyboard_mod( const char* key_string );
    00286
    00295 const char* MLV_convert_keyboard_button_to_string( MLV_Keyboard_button key_code );
    00296
    00305 const char* MLV_convert_keyboard_mod_to_string( MLV_Keyboard_modifier keymod_code );
    00306
    00307
    00315 MLV_Button_state MLV_get_keyboard_state( MLV_Keyboard_button keyboard_code );
    00316
    00324 int MLV_shift_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00325
    00333 int MLV_left_shift_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00334
    00342 int MLV_right_shift_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00343
    00351 int MLV_left_ctrl_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00352
    00360 int MLV_right_ctrl_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00361
    00369 int MLV_ctrl_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00370
    00378 int MLV_left_alt_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00379
    00387 int MLV_right_alt_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00388
    00396 int MLV_alt_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00397
    00405 int MLV_left_meta_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00406
    00414 int MLV_right_meta_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00415
    00423 int MLV_meta_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00424
    00432 int MLV_num_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00433
    00441 int MLV_caps_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00442
    00450 int MLV_mode_key_was_pressed( MLV_Keyboard_modifier modifier_code );
    00451
    00452
    00453 #ifdef __cplusplus
    00454 }
    00455 #endif
    00456
    00457 #endif