| 1 | /* | 
| 2 |   Simple DirectMedia Layer | 
| 3 |   Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> | 
| 4 |  | 
| 5 |   This software is provided 'as-is', without any express or implied | 
| 6 |   warranty.  In no event will the authors be held liable for any damages | 
| 7 |   arising from the use of this software. | 
| 8 |  | 
| 9 |   Permission is granted to anyone to use this software for any purpose, | 
| 10 |   including commercial applications, and to alter it and redistribute it | 
| 11 |   freely, subject to the following restrictions: | 
| 12 |  | 
| 13 |   1. The origin of this software must not be misrepresented; you must not | 
| 14 |      claim that you wrote the original software. If you use this software | 
| 15 |      in a product, an acknowledgment in the product documentation would be | 
| 16 |      appreciated but is not required. | 
| 17 |   2. Altered source versions must be plainly marked as such, and must not be | 
| 18 |      misrepresented as being the original software. | 
| 19 |   3. This notice may not be removed or altered from any source distribution. | 
| 20 | */ | 
| 21 | #include "SDL_internal.h" | 
| 22 |  | 
| 23 | #ifndef SDL_keyboard_c_h_ | 
| 24 | #define SDL_keyboard_c_h_ | 
| 25 |  | 
| 26 | #include "SDL_keymap_c.h" | 
| 27 |  | 
| 28 | // Keyboard events not associated with a specific input device | 
| 29 | #define SDL_GLOBAL_KEYBOARD_ID     0 | 
| 30 |  | 
| 31 | // The default keyboard input device, for platforms that don't have multiple keyboards | 
| 32 | #define SDL_DEFAULT_KEYBOARD_ID    1 | 
| 33 |  | 
| 34 | // Initialize the keyboard subsystem | 
| 35 | extern bool SDL_InitKeyboard(void); | 
| 36 |  | 
| 37 | // Return whether a device is actually a keyboard | 
| 38 | extern bool SDL_IsKeyboard(Uint16 vendor, Uint16 product, int num_keys); | 
| 39 |  | 
| 40 | // A keyboard has been added to the system | 
| 41 | extern void SDL_AddKeyboard(SDL_KeyboardID keyboardID, const char *name, bool send_event); | 
| 42 |  | 
| 43 | // A keyboard has been removed from the system | 
| 44 | extern void SDL_RemoveKeyboard(SDL_KeyboardID keyboardID, bool send_event); | 
| 45 |  | 
| 46 | // Set the mapping of scancode to key codes | 
| 47 | extern void SDL_SetKeymap(SDL_Keymap *keymap, bool send_event); | 
| 48 |  | 
| 49 | // Set the keyboard focus window | 
| 50 | extern bool SDL_SetKeyboardFocus(SDL_Window *window); | 
| 51 |  | 
| 52 | /* Send a character from an on-screen keyboard as scancode and modifier key events, | 
| 53 |    currently assuming ASCII characters on a US keyboard layout | 
| 54 |  */ | 
| 55 | extern void SDL_SendKeyboardUnicodeKey(Uint64 timestamp, Uint32 ch); | 
| 56 |  | 
| 57 | // Send a keyboard key event | 
| 58 | extern bool SDL_SendKeyboardKey(Uint64 timestamp, SDL_KeyboardID keyboardID, int rawcode, SDL_Scancode scancode, bool down); | 
| 59 | extern bool SDL_SendKeyboardKeyIgnoreModifiers(Uint64 timestamp, SDL_KeyboardID keyboardID, int rawcode, SDL_Scancode scancode, bool down); | 
| 60 | extern bool SDL_SendKeyboardKeyAutoRelease(Uint64 timestamp, SDL_Scancode scancode); | 
| 61 |  | 
| 62 | /* This is for platforms that don't know the keymap but can report scancode and keycode directly. | 
| 63 |    Most platforms should prefer to optionally call SDL_SetKeymap and then use SDL_SendKeyboardKey. */ | 
| 64 | extern bool SDL_SendKeyboardKeyAndKeycode(Uint64 timestamp, SDL_KeyboardID keyboardID, int rawcode, SDL_Scancode scancode, SDL_Keycode keycode, bool down); | 
| 65 |  | 
| 66 | // Release all the autorelease keys | 
| 67 | extern void SDL_ReleaseAutoReleaseKeys(void); | 
| 68 |  | 
| 69 | // Return true if any hardware key is pressed | 
| 70 | extern bool SDL_HardwareKeyboardKeyPressed(void); | 
| 71 |  | 
| 72 | // Send keyboard text input | 
| 73 | extern void SDL_SendKeyboardText(const char *text); | 
| 74 |  | 
| 75 | // Send editing text for selected range from start to end | 
| 76 | extern void SDL_SendEditingText(const char *text, int start, int length); | 
| 77 |  | 
| 78 | // Send editing text candidates, which will be copied into the event | 
| 79 | extern void SDL_SendEditingTextCandidates(char **candidates, int num_candidates, int selected_candidate, bool horizontal); | 
| 80 |  | 
| 81 | // Shutdown the keyboard subsystem | 
| 82 | extern void SDL_QuitKeyboard(void); | 
| 83 |  | 
| 84 | // Toggle on or off pieces of the keyboard mod state. | 
| 85 | extern void SDL_ToggleModState(SDL_Keymod modstate, bool toggle); | 
| 86 |  | 
| 87 | #endif // SDL_keyboard_c_h_ | 
| 88 |  |