comparison include/SDL_keyboard.h @ 1673:624e1412fbba SDL-1.3

Keyboard code update in progress
author Sam Lantinga <slouken@libsdl.org>
date Sat, 10 Jun 2006 09:11:59 +0000
parents 4da1ee79c9af
children 7688a73b25b1
comparison
equal deleted inserted replaced
1672:8e754b82cecc 1673:624e1412fbba
39 /* *INDENT-OFF* */ 39 /* *INDENT-OFF* */
40 extern "C" { 40 extern "C" {
41 /* *INDENT-ON* */ 41 /* *INDENT-ON* */
42 #endif 42 #endif
43 43
44 /* Keysym structure 44 /**
45 - The scancode is hardware dependent, and should not be used by general 45 * \struct SDL_keysym
46 applications. If no hardware scancode is available, it will be 0. 46 *
47 47 * \brief The SDL keysym structure, used in key events.
48 - The 'unicode' translated character is only available when character
49 translation is enabled by the SDL_EnableUNICODE() API. If non-zero,
50 this is a UNICODE character corresponding to the keypress. If the
51 high 9 bits of the character are 0, then this maps to the equivalent
52 ASCII character:
53 char ch;
54 if ( (keysym.unicode & 0xFF80) == 0 ) {
55 ch = keysym.unicode & 0x7F;
56 } else {
57 An international character..
58 }
59 */ 48 */
60 typedef struct SDL_keysym 49 typedef struct SDL_keysym
61 { 50 {
62 Uint8 scancode; /* hardware specific scancode */ 51 Uint8 scancode; /**< keyboard specific scancode */
63 SDLKey sym; /* SDL virtual keysym */ 52 SDLKey sym; /**< SDL virtual keysym */
64 SDLMod mod; /* current key modifiers */ 53 SDLMod mod; /**< current key modifiers */
65 Uint16 unicode; /* translated character */
66 } SDL_keysym; 54 } SDL_keysym;
67 55
68 /* This is the mask which refers to all hotkey bindings */ 56 /* Function prototypes */
69 #define SDL_ALL_HOTKEYS 0xFFFFFFFF
70 57
71 /* Function prototypes */ 58 /**
72 /* 59 * \fn int SDL_GetNumKeyboards(void)
73 * Enable/Disable UNICODE translation of keyboard input. 60 *
74 * This translation has some overhead, so translation defaults off. 61 * \brief Get the number of keyboard input devices available.
75 * If 'enable' is 1, translation is enabled. 62 *
76 * If 'enable' is 0, translation is disabled. 63 * \sa SDL_SelectKeyboard()
77 * If 'enable' is -1, the translation state is not changed. 64 */
78 * It returns the previous state of keyboard translation. 65 extern DECLSPEC int SDLCALL SDL_GetNumKeyboards(void);
66
67 /**
68 * \fn int SDL_SelectKeyboard(int index)
69 *
70 * \brief Set the index of the currently selected keyboard.
71 *
72 * \return The index of the previously selected keyboard.
73 *
74 * \note You can query the currently selected keyboard by passing an index of -1.
75 *
76 * \sa SDL_GetNumKeyboards()
77 */
78 extern DECLSPEC int SDLCALL SDL_SelectKeyboard(int index);
79
80 /**
81 * \fn int SDL_EnableUNICODE(int enable)
82 *
83 * \brief Enable/Disable UNICODE translation of keyboard input.
84 *
85 * \param enable 1 to enable translation, 0 to disable translation, -1 to query translation
86 *
87 * \return The previous state of keyboard translation
88 *
89 * \note This translation has some overhead, so translation defaults off.
79 */ 90 */
80 extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable); 91 extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
81 92
82 /* 93 /**
83 * Enable/Disable keyboard repeat. Keyboard repeat defaults to off. 94 * \fn int SDL_EnableKeyRepeat(int delay, int interval)
84 * 'delay' is the initial delay in ms between the time when a key is 95 *
85 * pressed, and keyboard repeat begins. 96 * \brief Enable keyboard repeat for the selected keyboard.
86 * 'interval' is the time in ms between keyboard repeat events. 97 *
98 * \param delay The initial delay in milliseconds between the time when a
99 * key is pressed and keyboard repeat begins. Setting a delay
100 * of 0 will disable keyboard repeat.
101 * \param interval The time in milliseconds between keyboard repeat events.
102 *
103 * \return 0 on success, or -1 if there was an error.
104 *
105 * \note Keyboard repeat defaults to off.
87 */ 106 */
88 #define SDL_DEFAULT_REPEAT_DELAY 500 107 #define SDL_DEFAULT_REPEAT_DELAY 500
89 #define SDL_DEFAULT_REPEAT_INTERVAL 30 108 #define SDL_DEFAULT_REPEAT_INTERVAL 30
90 /* 109 /**/
91 * If 'delay' is set to 0, keyboard repeat is disabled. 110 extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
111
112 /**
113 * \fn void SDL_GetKeyRepeat(int *delay, int *interval)
114 *
115 * \brief Get the current keyboard repeat setting for the selected keyboard.
92 */ 116 */
93 extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
94 extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval); 117 extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
95 118
96 /* 119 /**
97 * Get a snapshot of the current state of the keyboard. 120 * \fn Uint8 *SDL_GetKeyState(int *numkeys)
98 * Returns an array of keystates, indexed by the SDLK_* syms. 121 *
99 * Used: 122 * \brief Get a snapshot of the current state of the selected keyboard.
123 *
124 * \return An array of keystates, indexed by the SDLK_* syms.
125 *
126 * Example:
100 * Uint8 *keystate = SDL_GetKeyState(NULL); 127 * Uint8 *keystate = SDL_GetKeyState(NULL);
101 * if ( keystate[SDLK_RETURN] ) ... <RETURN> is pressed. 128 * if ( keystate[SDLK_RETURN] ) ... <RETURN> is pressed.
102 */ 129 */
103 extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyState(int *numkeys); 130 extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyState(int *numkeys);
104 131
105 /* 132 /**
106 * Get the current key modifier state 133 * \fn SDLMod SDL_GetModState(void)
134 *
135 * \brief Get the current key modifier state for the selected keyboard.
107 */ 136 */
108 extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void); 137 extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void);
109 138
110 /* 139 /**
111 * Set the current key modifier state 140 * \fn void SDL_SetModState(SDLMod modstate)
112 * This does not change the keyboard state, only the key modifier flags. 141 *
142 * \brief Set the current key modifier state for the selected keyboard.
143 *
144 * \note This does not change the keyboard state, only the key modifier flags.
113 */ 145 */
114 extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate); 146 extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate);
115 147
116 /* 148 /**
117 * Get the name of an SDL virtual keysym 149 * \fn const char *SDL_GetKeyName(SDLKey key)
150 *
151 * \brief Get the name of an SDL virtual keysym
118 */ 152 */
119 extern DECLSPEC char *SDLCALL SDL_GetKeyName(SDLKey key); 153 extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDLKey key);
120 154
121 155
122 /* Ends C function definitions when using C++ */ 156 /* Ends C function definitions when using C++ */
123 #ifdef __cplusplus 157 #ifdef __cplusplus
124 /* *INDENT-OFF* */ 158 /* *INDENT-OFF* */