Mercurial > sdl-ios-xcode
comparison include/SDL_keyboard.h @ 1895:c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 10 Jul 2006 21:04:37 +0000 |
parents | 1ff64ad478b2 |
children | 047245361002 |
comparison
equal
deleted
inserted
replaced
1894:c69cee13dd76 | 1895:c121d94672cb |
---|---|
18 | 18 |
19 Sam Lantinga | 19 Sam Lantinga |
20 slouken@libsdl.org | 20 slouken@libsdl.org |
21 */ | 21 */ |
22 | 22 |
23 /* Include file for SDL keyboard event handling */ | 23 /** |
24 * \file SDL_keyboard.h | |
25 * | |
26 * Include file for SDL keyboard event handling | |
27 */ | |
24 | 28 |
25 #ifndef _SDL_keyboard_h | 29 #ifndef _SDL_keyboard_h |
26 #define _SDL_keyboard_h | 30 #define _SDL_keyboard_h |
27 | 31 |
28 #include "SDL_stdinc.h" | 32 #include "SDL_stdinc.h" |
30 #include "SDL_keysym.h" | 34 #include "SDL_keysym.h" |
31 | 35 |
32 #include "begin_code.h" | 36 #include "begin_code.h" |
33 /* Set up for C function definitions, even when using C++ */ | 37 /* Set up for C function definitions, even when using C++ */ |
34 #ifdef __cplusplus | 38 #ifdef __cplusplus |
39 /* *INDENT-OFF* */ | |
35 extern "C" { | 40 extern "C" { |
41 /* *INDENT-ON* */ | |
36 #endif | 42 #endif |
37 | 43 |
38 /* Keysym structure | 44 /** |
39 - The scancode is hardware dependent, and should not be used by general | 45 * \struct SDL_keysym |
40 applications. If no hardware scancode is available, it will be 0. | 46 * |
41 | 47 * \brief The SDL keysym structure, used in key events. |
42 - The 'unicode' translated character is only available when character | |
43 translation is enabled by the SDL_EnableUNICODE() API. If non-zero, | |
44 this is a UNICODE character corresponding to the keypress. If the | |
45 high 9 bits of the character are 0, then this maps to the equivalent | |
46 ASCII character: | |
47 char ch; | |
48 if ( (keysym.unicode & 0xFF80) == 0 ) { | |
49 ch = keysym.unicode & 0x7F; | |
50 } else { | |
51 An international character.. | |
52 } | |
53 */ | 48 */ |
54 typedef struct SDL_keysym { | 49 typedef struct SDL_keysym |
55 Uint8 scancode; /* hardware specific scancode */ | 50 { |
56 SDLKey sym; /* SDL virtual keysym */ | 51 Uint8 scancode; /**< keyboard specific scancode */ |
57 SDLMod mod; /* current key modifiers */ | 52 Uint8 padding[3]; /**< alignment padding */ |
58 Uint16 unicode; /* translated character */ | 53 Uint16 sym; /**< SDL virtual keysym */ |
54 Uint16 mod; /**< current key modifiers */ | |
55 Uint32 unicode; /**< OBSOLETE, use SDL_TextInputEvent instead */ | |
59 } SDL_keysym; | 56 } SDL_keysym; |
60 | 57 |
61 /* This is the mask which refers to all hotkey bindings */ | 58 /* Function prototypes */ |
62 #define SDL_ALL_HOTKEYS 0xFFFFFFFF | |
63 | 59 |
64 /* Function prototypes */ | 60 /** |
65 /* | 61 * \fn int SDL_GetNumKeyboards(void) |
66 * Enable/Disable UNICODE translation of keyboard input. | 62 * |
67 * This translation has some overhead, so translation defaults off. | 63 * \brief Get the number of keyboard input devices available. |
68 * If 'enable' is 1, translation is enabled. | 64 * |
69 * If 'enable' is 0, translation is disabled. | 65 * \sa SDL_SelectKeyboard() |
70 * If 'enable' is -1, the translation state is not changed. | 66 */ |
71 * It returns the previous state of keyboard translation. | 67 extern DECLSPEC int SDLCALL SDL_GetNumKeyboards(void); |
68 | |
69 /** | |
70 * \fn int SDL_SelectKeyboard(int index) | |
71 * | |
72 * \brief Set the index of the currently selected keyboard. | |
73 * | |
74 * \return The index of the previously selected keyboard. | |
75 * | |
76 * \note You can query the currently selected keyboard by passing an index of -1. | |
77 * | |
78 * \sa SDL_GetNumKeyboards() | |
79 */ | |
80 extern DECLSPEC int SDLCALL SDL_SelectKeyboard(int index); | |
81 | |
82 /** | |
83 * \fn int SDL_EnableUNICODE(int enable) | |
84 * | |
85 * \brief Enable/Disable UNICODE translation of keyboard input. | |
86 * | |
87 * \param enable 1 to enable translation, 0 to disable translation, -1 to query translation | |
88 * | |
89 * \return The previous state of keyboard translation | |
90 * | |
91 * \note This translation has some overhead, so translation defaults off. | |
72 */ | 92 */ |
73 extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable); | 93 extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable); |
74 | 94 |
75 /* | 95 /** |
76 * Enable/Disable keyboard repeat. Keyboard repeat defaults to off. | 96 * \fn int SDL_EnableKeyRepeat(int delay, int interval) |
77 * 'delay' is the initial delay in ms between the time when a key is | 97 * |
78 * pressed, and keyboard repeat begins. | 98 * \brief Enable keyboard repeat for the selected keyboard. |
79 * 'interval' is the time in ms between keyboard repeat events. | 99 * |
100 * \param delay The initial delay in milliseconds between the time when a | |
101 * key is pressed and keyboard repeat begins. Setting a delay | |
102 * of 0 will disable keyboard repeat. | |
103 * \param interval The time in milliseconds between keyboard repeat events. | |
104 * | |
105 * \return 0 on success, or -1 if there was an error. | |
106 * | |
107 * \note Keyboard repeat defaults to off. | |
80 */ | 108 */ |
81 #define SDL_DEFAULT_REPEAT_DELAY 500 | 109 #define SDL_DEFAULT_REPEAT_DELAY 500 |
82 #define SDL_DEFAULT_REPEAT_INTERVAL 30 | 110 #define SDL_DEFAULT_REPEAT_INTERVAL 30 |
83 /* | 111 /**/ |
84 * If 'delay' is set to 0, keyboard repeat is disabled. | 112 extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval); |
113 | |
114 /** | |
115 * \fn void SDL_GetKeyRepeat(int *delay, int *interval) | |
116 * | |
117 * \brief Get the current keyboard repeat setting for the selected keyboard. | |
85 */ | 118 */ |
86 extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval); | |
87 extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval); | 119 extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval); |
88 | 120 |
89 /* | 121 /** |
90 * Get a snapshot of the current state of the keyboard. | 122 * \fn Uint8 *SDL_GetKeyState(int *numkeys) |
91 * Returns an array of keystates, indexed by the SDLK_* syms. | 123 * |
92 * Used: | 124 * \brief Get a snapshot of the current state of the selected keyboard. |
125 * | |
126 * \return An array of keystates, indexed by the SDLK_* syms. | |
127 * | |
128 * Example: | |
93 * Uint8 *keystate = SDL_GetKeyState(NULL); | 129 * Uint8 *keystate = SDL_GetKeyState(NULL); |
94 * if ( keystate[SDLK_RETURN] ) ... <RETURN> is pressed. | 130 * if ( keystate[SDLK_RETURN] ) ... <RETURN> is pressed. |
95 */ | 131 */ |
96 extern DECLSPEC Uint8 * SDLCALL SDL_GetKeyState(int *numkeys); | 132 extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyState(int *numkeys); |
97 | 133 |
98 /* | 134 /** |
99 * Get the current key modifier state | 135 * \fn SDLMod SDL_GetModState(void) |
136 * | |
137 * \brief Get the current key modifier state for the selected keyboard. | |
100 */ | 138 */ |
101 extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void); | 139 extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void); |
102 | 140 |
103 /* | 141 /** |
104 * Set the current key modifier state | 142 * \fn void SDL_SetModState(SDLMod modstate) |
105 * This does not change the keyboard state, only the key modifier flags. | 143 * |
144 * \brief Set the current key modifier state for the selected keyboard. | |
145 * | |
146 * \note This does not change the keyboard state, only the key modifier flags. | |
106 */ | 147 */ |
107 extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate); | 148 extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate); |
108 | 149 |
109 /* | 150 /** |
110 * Get the name of an SDL virtual keysym | 151 * \fn const char *SDL_GetKeyName(SDLKey key) |
152 * | |
153 * \brief Get the name of an SDL virtual keysym | |
111 */ | 154 */ |
112 extern DECLSPEC char * SDLCALL SDL_GetKeyName(SDLKey key); | 155 extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDLKey key); |
113 | 156 |
114 | 157 |
115 /* Ends C function definitions when using C++ */ | 158 /* Ends C function definitions when using C++ */ |
116 #ifdef __cplusplus | 159 #ifdef __cplusplus |
160 /* *INDENT-OFF* */ | |
117 } | 161 } |
162 /* *INDENT-ON* */ | |
118 #endif | 163 #endif |
119 #include "close_code.h" | 164 #include "close_code.h" |
120 | 165 |
121 #endif /* _SDL_keyboard_h */ | 166 #endif /* _SDL_keyboard_h */ |
167 | |
168 /* vi: set ts=4 sw=4 expandtab: */ |