SDL
2.0
|
#include "SDL_stdinc.h"
#include "SDL_error.h"
#include "SDL_keycode.h"
#include "SDL_video.h"
#include "begin_code.h"
#include "close_code.h"
Go to the source code of this file.
Data Structures | |
struct | SDL_Keysym |
The SDL keysym structure, used in key events. More... | |
Functions | |
SDL_Window * | SDL_GetKeyboardFocus (void) |
const Uint8 * | SDL_GetKeyboardState (int *numkeys) |
SDL_Keymod | SDL_GetModState (void) |
void | SDL_SetModState (SDL_Keymod modstate) |
SDL_Keycode | SDL_GetKeyFromScancode (SDL_Scancode scancode) |
SDL_Scancode | SDL_GetScancodeFromKey (SDL_Keycode key) |
const char * | SDL_GetScancodeName (SDL_Scancode scancode) |
SDL_Scancode | SDL_GetScancodeFromName (const char *name) |
const char * | SDL_GetKeyName (SDL_Keycode key) |
SDL_Keycode | SDL_GetKeyFromName (const char *name) |
void | SDL_StartTextInput (void) |
SDL_bool | SDL_IsTextInputActive (void) |
void | SDL_StopTextInput (void) |
void | SDL_SetTextInputRect (SDL_Rect *rect) |
SDL_bool | SDL_HasScreenKeyboardSupport (void) |
SDL_bool | SDL_IsScreenKeyboardShown (SDL_Window *window) |
Include file for SDL keyboard event handling
Definition in file SDL_keyboard.h.
SDL_Window* SDL_GetKeyboardFocus | ( | void | ) |
Query the window which currently has keyboard focus.
const Uint8* SDL_GetKeyboardState | ( | int * | numkeys | ) |
Get a snapshot of the current state of the keyboard.
The pointer returned is a pointer to an internal SDL array. It will be valid for the whole lifetime of the application and should not be freed by the caller.
A array element with a value of 1 means that the key is pressed and a value of 0 means that it is not. Indexes into this array are obtained by using SDL_Scancode values.
Use SDL_PumpEvents() to update the state array.
This function gives you the current state after all events have been processed, so if a key or button has been pressed and released before you process events, then the pressed state will never show up in the SDL_GetKeyboardState() calls.
Note: This function doesn't take into account whether shift has been pressed or not.
numkeys | if non-NULL, receives the length of the returned array |
SDL_Keycode SDL_GetKeyFromName | ( | const char * | name | ) |
Get a key code from a human-readable name.
name | the human-readable key name |
SDLK_UNKNOWN
if the name wasn't recognized; call SDL_GetError() for more information.SDL_Keycode SDL_GetKeyFromScancode | ( | SDL_Scancode | scancode | ) |
Get the key code corresponding to the given scancode according to the current keyboard layout.
See SDL_Keycode for details.
scancode | the desired SDL_Scancode to query |
const char* SDL_GetKeyName | ( | SDL_Keycode | key | ) |
Get a human-readable name for a key.
See SDL_Scancode and SDL_Keycode for details.
key | the desired SDL_Keycode to query |
SDL_Keymod SDL_GetModState | ( | void | ) |
Get the current key modifier state for the keyboard.
SDL_Scancode SDL_GetScancodeFromKey | ( | SDL_Keycode | key | ) |
Get the scancode corresponding to the given key code according to the current keyboard layout.
See SDL_Scancode for details.
key | the desired SDL_Keycode to query |
SDL_Scancode SDL_GetScancodeFromName | ( | const char * | name | ) |
Get a scancode from a human-readable name.
name | the human-readable scancode name |
SDL_SCANCODE_UNKNOWN
if the name wasn't recognized; call SDL_GetError() for more information.const char* SDL_GetScancodeName | ( | SDL_Scancode | scancode | ) |
Get a human-readable name for a scancode.
See SDL_Scancode for details.
Warning: The returned name is by design not stable across platforms, e.g. the name for SDL_SCANCODE_LGUI
is "Left GUI" under Linux but "Left
Windows" under Microsoft Windows, and some scancodes like SDL_SCANCODE_NONUSBACKSLASH
don't have any name at all. There are even scancodes that share names, e.g. SDL_SCANCODE_RETURN
and SDL_SCANCODE_RETURN2
(both called "Return"). This function is therefore unsuitable for creating a stable cross-platform two-way mapping between strings and scancodes.
scancode | the desired SDL_Scancode to query |
SDL_bool SDL_HasScreenKeyboardSupport | ( | void | ) |
Check whether the platform has screen keyboard support.
SDL_bool SDL_IsScreenKeyboardShown | ( | SDL_Window * | window | ) |
Check whether the screen keyboard is shown for given window.
window | the window for which screen keyboard should be queried |
SDL_bool SDL_IsTextInputActive | ( | void | ) |
Check whether or not Unicode text input events are enabled.
void SDL_SetModState | ( | SDL_Keymod | modstate | ) |
Set the current key modifier state for the keyboard.
The inverse of SDL_GetModState(), SDL_SetModState() allows you to impose modifier key states on your application. Simply pass your desired modifier states into modstate
. This value may be a bitwise, OR'd combination of SDL_Keymod values.
This does not change the keyboard state, only the key modifier flags that SDL reports.
modstate | the desired SDL_Keymod for the keyboard |
void SDL_SetTextInputRect | ( | SDL_Rect * | rect | ) |
Set the rectangle used to type Unicode text inputs.
rect | the SDL_Rect structure representing the rectangle to receive text (ignored if NULL) |
void SDL_StartTextInput | ( | void | ) |
Start accepting Unicode text input events.
This function will start accepting Unicode text input events in the focused SDL window, and start emitting SDL_TextInputEvent (SDL_TEXTINPUT) and SDL_TextEditingEvent (SDL_TEXTEDITING) events. Please use this function in pair with SDL_StopTextInput().
On some platforms using this function activates the screen keyboard.
void SDL_StopTextInput | ( | void | ) |
Stop receiving any text input events.