21 #include "../SDL_internal.h" 29 #include "../video/SDL_sysvideo.h" 180 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
193 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
249 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
409 NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
423 NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
426 "ThousandsSeparator",
460 "Keypad MemSubtract",
461 "Keypad MemMultiply",
469 "Keypad Hexadecimal",
479 NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
480 NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
518 }
else if (ch <= 0x7FF) {
519 p[0] = 0xC0 | (
Uint8) ((ch >> 6) & 0x1F);
520 p[1] = 0x80 | (
Uint8) (ch & 0x3F);
522 }
else if (ch <= 0xFFFF) {
523 p[0] = 0xE0 | (
Uint8) ((ch >> 12) & 0x0F);
524 p[1] = 0x80 | (
Uint8) ((ch >> 6) & 0x3F);
525 p[2] = 0x80 | (
Uint8) (ch & 0x3F);
527 }
else if (ch <= 0x1FFFFF) {
528 p[0] = 0xF0 | (
Uint8) ((ch >> 18) & 0x07);
529 p[1] = 0x80 | (
Uint8) ((ch >> 12) & 0x3F);
530 p[2] = 0x80 | (
Uint8) ((ch >> 6) & 0x3F);
531 p[3] = 0x80 | (
Uint8) (ch & 0x3F);
533 }
else if (ch <= 0x3FFFFFF) {
534 p[0] = 0xF8 | (
Uint8) ((ch >> 24) & 0x03);
535 p[1] = 0x80 | (
Uint8) ((ch >> 18) & 0x3F);
536 p[2] = 0x80 | (
Uint8) ((ch >> 12) & 0x3F);
537 p[3] = 0x80 | (
Uint8) ((ch >> 6) & 0x3F);
538 p[4] = 0x80 | (
Uint8) (ch & 0x3F);
541 p[0] = 0xFC | (
Uint8) ((ch >> 30) & 0x01);
542 p[1] = 0x80 | (
Uint8) ((ch >> 24) & 0x3F);
543 p[2] = 0x80 | (
Uint8) ((ch >> 18) & 0x3F);
544 p[3] = 0x80 | (
Uint8) ((ch >> 12) & 0x3F);
545 p[4] = 0x80 | (
Uint8) ((ch >> 6) & 0x3F);
546 p[5] = 0x80 | (
Uint8) (ch & 0x3F);
569 #ifdef DEBUG_KEYBOARD 570 printf(
"Resetting keyboard\n");
608 return keyboard->
focus;
616 if (keyboard->
focus && !window) {
622 if (keyboard->
focus && keyboard->
focus != window) {
647 if (keyboard->
focus) {
674 #ifdef DEBUG_KEYBOARD 693 repeat = (state && keyboard->
keystate[scancode]);
694 if (keyboard->
keystate[scancode] == state && !repeat) {
696 printf(
"Keyboard event didn't change state - dropped!\n");
704 keycode = keyboard->
keymap[scancode];
761 event.key.type =
type;
762 event.key.state =
state;
763 event.key.repeat = repeat;
764 event.key.keysym.scancode = scancode;
765 event.key.keysym.sym = keycode;
767 event.key.windowID = keyboard->
focus ? keyboard->
focus->
id : 0;
780 if ((
unsigned char)*text <
' ' || *text == 127) {
789 event.text.windowID = keyboard->
focus ? keyboard->
focus->
id : 0;
807 event.edit.windowID = keyboard->
focus ? keyboard->
focus->
id : 0;
808 event.edit.start =
start;
809 event.edit.length =
length;
826 if (numkeys != (
int *) 0) {
871 return keyboard->
keymap[scancode];
882 if (keyboard->
keymap[scancode] == key) {
909 if (!name || !*name) {
956 if (key >=
'a' && key <=
'z') {
975 key = *(
const unsigned char *)name;
979 key = (
Uint16)(name[i]&0x07) << 18;
980 key |= (
Uint16)(name[++i]&0x3F) << 12;
981 key |= (
Uint16)(name[++i]&0x3F) << 6;
982 key |= (
Uint16)(name[++i]&0x3F);
986 }
else if (key >= 0xE0) {
989 key = (
Uint16)(name[i]&0x0F) << 12;
990 key |= (
Uint16)(name[++i]&0x3F) << 6;
991 key |= (
Uint16)(name[++i]&0x3F);
995 }
else if (key >= 0xC0) {
998 key = (
Uint16)(name[i]&0x1F) << 6;
999 key |= (
Uint16)(name[++i]&0x3F);
1005 if (key >=
'A' && key <=
'Z') {
void SDL_GetDefaultKeymap(SDL_Keycode *keymap)
void SDL_SetKeyboardFocus(SDL_Window *window)
uint32_t Uint32
An unsigned 32-bit integer type.
#define SDLK_SCANCODE_MASK
void(* StartTextInput)(_THIS)
SDL_Keycode keymap[SDL_NUM_SCANCODES]
SDL_Keycode SDL_GetKeyFromName(const char *name)
Get a key code from a human-readable name.
GLuint const GLchar * name
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
int SDL_KeyboardInit(void)
#define SDL_InvalidParamError(param)
Sint32 SDL_Keycode
The SDL virtual key representation.
SDL_Keycode SDL_GetKeyFromScancode(SDL_Scancode scancode)
Get the key code corresponding to the given scancode according to the current keyboard layout...
int SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode)
void SDL_SetKeymap(int start, SDL_Keycode *keys, int length)
static const char * SDL_scancode_names[SDL_NUM_SCANCODES]
const Uint8 * SDL_GetKeyboardState(int *numkeys)
Get a snapshot of the current state of the keyboard.
GLuint GLuint GLsizei GLenum type
char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]
void SDL_SetModState(SDL_Keymod modstate)
Set the current key modifier state for the keyboard.
#define SDL_GetEventState(type)
SDL_Scancode SDL_GetScancodeFromName(const char *name)
Get a scancode from a human-readable name.
uint8_t Uint8
An unsigned 8-bit integer type.
int SDL_SendKeyboardText(const char *text)
SDL_Keymod SDL_GetModState(void)
Get the current key modifier state for the keyboard.
const char * SDL_GetScancodeName(SDL_Scancode scancode)
Get a human-readable name for a scancode.
static const SDL_Keycode SDL_default_keymap[SDL_NUM_SCANCODES]
char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]
void(* StopTextInput)(_THIS)
SDL_Scancode SDL_GetScancodeFromKey(SDL_Keycode key)
Get the scancode corresponding to the given key code according to the current keyboard layout...
void SDL_SetScancodeName(SDL_Scancode scancode, const char *name)
void SDL_KeyboardQuit(void)
SDL_Keymod
Enumeration of valid key mods (possibly OR'd together).
void SDL_ToggleModState(const SDL_Keymod modstate, const SDL_bool toggle)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
#define SDL_assert(condition)
SDL_TextEditingEvent edit
char * SDL_UCS4ToUTF8(Uint32 ch, char *dst)
static char text[MAX_TEXT_LENGTH]
The type used to identify a window.
void SDL_ResetKeyboard(void)
static SDL_Keyboard SDL_keyboard
uint16_t Uint16
An unsigned 16-bit integer type.
SDL_VideoDevice * SDL_GetVideoDevice(void)
SDL_Window * SDL_GetKeyboardFocus(void)
Get the window which currently has keyboard focus.
#define SDL_arraysize(array)
const char * SDL_GetKeyName(SDL_Keycode key)
Get a human-readable name for a key.
GLuint GLsizei GLsizei * length
Uint8 keystate[SDL_NUM_SCANCODES]
SDL_Scancode
The SDL keyboard scancode representation.
int SDL_SendEditingText(const char *text, int start, int length)