Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
219 lines (191 loc) · 6.35 KB

SDL_keyboard.h

File metadata and controls

219 lines (191 loc) · 6.35 KB
 
Jun 22, 2011
Jun 22, 2011
1
2
/*
Simple DirectMedia Layer
Dec 31, 2011
Dec 31, 2011
3
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
Jun 22, 2011
Jun 22, 2011
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/**
* \file SDL_keyboard.h
*
* Include file for SDL keyboard event handling
*/
#ifndef _SDL_keyboard_h
#define _SDL_keyboard_h
#include "SDL_stdinc.h"
#include "SDL_error.h"
#include "SDL_keycode.h"
#include "SDL_video.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C" {
/* *INDENT-ON* */
#endif
/**
* \brief The SDL keysym structure, used in key events.
*/
typedef struct SDL_Keysym
{
SDL_Scancode scancode; /**< SDL physical key code - see ::SDL_Scancode for details */
SDL_Keycode sym; /**< SDL virtual key code - see ::SDL_Keycode for details */
Uint16 mod; /**< current key modifiers */
Uint32 unicode; /**< \deprecated use SDL_TextInputEvent instead */
} SDL_Keysym;
/* Function prototypes */
/**
* \brief Get the window which currently has keyboard focus.
*/
extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void);
/**
* \brief Get a snapshot of the current state of the keyboard.
*
* \param numkeys if non-NULL, receives the length of the returned array.
*
* \return An array of key states. Indexes into this array are obtained by using ::SDL_Scancode values.
*
* \b Example:
* \code
* Uint8 *state = SDL_GetKeyboardState(NULL);
* if ( state[SDL_SCANCODE_RETURN] ) {
* printf("<RETURN> is pressed.\n");
* }
* \endcode
*/
extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys);
/**
* \brief Get the current key modifier state for the keyboard.
*/
extern DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void);
/**
* \brief Set the current key modifier state for the keyboard.
*
* \note This does not change the keyboard state, only the key modifier flags.
*/
extern DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate);
/**
* \brief Get the key code corresponding to the given scancode according
* to the current keyboard layout.
*
* See ::SDL_Keycode for details.
*
* \sa SDL_GetKeyName()
*/
extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode);
/**
* \brief Get the scancode corresponding to the given key code according to the
* current keyboard layout.
*
* See ::SDL_Scancode for details.
*
* \sa SDL_GetScancodeName()
*/
extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key);
/**
* \brief Get a human-readable name for a scancode.
*
Oct 25, 2011
Oct 25, 2011
114
115
* \return A pointer to the name for the scancode.
* If the scancode doesn't have a name, this function returns
Jun 22, 2011
Jun 22, 2011
116
117
118
119
* an empty string ("").
*
* \sa SDL_Scancode
*/
Oct 25, 2011
Oct 25, 2011
120
121
122
123
124
125
126
127
128
129
extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_Scancode scancode);
/**
* \brief Get a scancode from a human-readable name
*
* \return scancode, or SDL_SCANCODE_UNKNOWN if the name wasn't recognized
*
* \sa SDL_Scancode
*/
extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromName(const char *name);
Jun 22, 2011
Jun 22, 2011
130
131
132
133
134
135
136
137
138
139
140
141
142
/**
* \brief Get a human-readable name for a key.
*
* \return A pointer to a UTF-8 string that stays valid at least until the next
* call to this function. If you need it around any longer, you must
* copy it. If the key doesn't have a name, this function returns an
* empty string ("").
*
* \sa SDL_Key
*/
extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDL_Keycode key);
Oct 25, 2011
Oct 25, 2011
143
144
145
146
147
148
149
150
151
/**
* \brief Get a key code from a human-readable name
*
* \return key code, or SDLK_UNKNOWN if the name wasn't recognized
*
* \sa SDL_Keycode
*/
extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name);
Jun 22, 2011
Jun 22, 2011
152
153
/**
* \brief Start accepting Unicode text input events.
Nov 5, 2012
Nov 5, 2012
154
* This function will show the on-screen keyboard if supported.
Jun 22, 2011
Jun 22, 2011
155
156
157
*
* \sa SDL_StopTextInput()
* \sa SDL_SetTextInputRect()
Nov 5, 2012
Nov 5, 2012
158
* \sa SDL_HasScreenKeyboardSupport()
Jun 22, 2011
Jun 22, 2011
159
160
161
*/
extern DECLSPEC void SDLCALL SDL_StartTextInput(void);
Nov 5, 2012
Nov 5, 2012
162
163
164
165
166
167
168
169
/**
* \brief Return whether or not Unicode text input events are enabled.
*
* \sa SDL_StartTextInput()
* \sa SDL_StopTextInput()
*/
extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputActive(void);
Jun 22, 2011
Jun 22, 2011
170
171
/**
* \brief Stop receiving any text input events.
Nov 5, 2012
Nov 5, 2012
172
* This function will hide the on-screen keyboard if supported.
Jun 22, 2011
Jun 22, 2011
173
174
*
* \sa SDL_StartTextInput()
Nov 5, 2012
Nov 5, 2012
175
* \sa SDL_HasScreenKeyboardSupport()
Jun 22, 2011
Jun 22, 2011
176
177
178
179
180
*/
extern DECLSPEC void SDLCALL SDL_StopTextInput(void);
/**
* \brief Set the rectangle used to type Unicode text inputs.
Nov 5, 2012
Nov 5, 2012
181
* This is used as a hint for IME and on-screen keyboard placement.
Jun 22, 2011
Jun 22, 2011
182
183
184
185
186
*
* \sa SDL_StartTextInput()
*/
extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect);
Aug 11, 2012
Aug 11, 2012
187
188
189
190
191
192
193
194
195
/**
* \brief Returns whether the platform has some screen keyboard support.
*
* \return SDL_TRUE if some keyboard support is available else SDL_FALSE.
*
* \note Not all screen keyboard functions are supported on all platforms.
*
* \sa SDL_IsScreenKeyboardShown()
*/
Nov 5, 2012
Nov 5, 2012
196
extern DECLSPEC SDL_bool SDLCALL SDL_HasScreenKeyboardSupport();
Aug 11, 2012
Aug 11, 2012
197
198
199
200
201
202
203
204
205
206
207
/**
* \brief Returns whether the screen keyboard is shown for given window.
*
* \param window The window for which screen keyboard should be queried.
*
* \return SDL_TRUE if screen keyboard is shown else SDL_FALSE.
*
* \sa SDL_HasScreenKeyboardSupport()
*/
extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenKeyboardShown(SDL_Window *window);
Jun 22, 2011
Jun 22, 2011
208
209
210
211
212
213
214
215
216
217
218
219
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
}
/* *INDENT-ON* */
#endif
#include "close_code.h"
#endif /* _SDL_keyboard_h */
/* vi: set ts=4 sw=4 expandtab: */