1#ifndef SDL3PP_KEYBOARD_H_
2#define SDL3PP_KEYBOARD_H_
4#include <SDL3/SDL_keyboard.h>
5#include "SDL3pp_keycode.h"
6#include "SDL3pp_scancode.h"
7#include "SDL3pp_stdinc.h"
8#include "SDL3pp_video.h"
72 auto data =
CheckError(SDL_GetKeyboards(&count));
93 return SDL_GetKeyboardNameForID(instance_id);
146 auto data = SDL_GetKeyboardState(&count);
147 return std::span{data, size_t(count)};
198 : m_keycode(SDL_GetKeyFromScancode(scancode, modstate, key_event))
203 : m_keycode(SDL_GetKeyFromName(name))
233 return SDL_GetKeyFromScancode(scancode, modstate, key_event);
257 return SDL_GetScancodeFromKey(key, modstate);
262 return SDL_GetScancodeFromKey(m_keycode, modstate);
282 CheckError(SDL_SetScancodeName(scancode, name));
287 CheckError(SDL_SetScancodeName(m_scancode, name));
315 return SDL_GetScancodeName(scancode);
320 return SDL_GetScancodeName(m_scancode);
340 return SDL_GetScancodeFromName(name);
344 : m_scancode(SDL_GetScancodeFromName(name))
370 return SDL_GetKeyName(m_keycode);
390 return SDL_GetKeyFromName(name);
439 SDL_TEXTINPUT_TYPE_TEXT;
442 SDL_TEXTINPUT_TYPE_TEXT_NAME;
445 SDL_TEXTINPUT_TYPE_TEXT_EMAIL;
448 SDL_TEXTINPUT_TYPE_TEXT_USERNAME;
451 SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_HIDDEN;
455 SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_VISIBLE;
459 SDL_TEXTINPUT_TYPE_NUMBER;
462 SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_HIDDEN;
466 SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_VISIBLE;
486 SDL_CAPITALIZE_SENTENCES;
490 SDL_CAPITALIZE_WORDS;
493 SDL_CAPITALIZE_LETTERS;
544 CheckError(SDL_StartTextInputWithProperties(window, props));
574 SDL_PROP_TEXTINPUT_AUTOCORRECT_BOOLEAN;
577 SDL_PROP_TEXTINPUT_MULTILINE_BOOLEAN;
580 SDL_PROP_TEXTINPUT_ANDROID_INPUTTYPE_NUMBER;
599 return SDL_TextInputActive(window);
671 CheckError(SDL_SetTextInputArea(window, &rect, cursor));
699 CheckError(SDL_GetTextInputArea(window, rect, cursor));
722 return SDL_HasScreenKeyboardSupport();
739 return SDL_ScreenKeyboardShown(window);
The SDL virtual key representation.
Definition SDL3pp_keycode.h:121
constexpr Keycode(KeycodeRaw keycode={}) noexcept
Wraps Keycode.
Definition SDL3pp_keycode.h:130
Base class for SDL memory allocated array wrap.
Definition SDL3pp_ownPtr.h:44
constexpr RawPointer get() const noexcept
Definition SDL3pp_resource.h:54
The SDL keyboard scancode representation.
Definition SDL3pp_scancode.h:47
constexpr Scancode(ScancodeRaw scancode={}) noexcept
Wraps Scancode.
Definition SDL3pp_scancode.h:56
Helpers to use C++ strings parameters.
Definition SDL3pp_strings.h:58
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition SDL3pp_error.h:199
constexpr TextInputType TEXTINPUT_TYPE_NUMBER_PASSWORD_HIDDEN
The input is a secure PIN that is hidden.
Definition SDL3pp_keyboard.h:461
void SetName(StringParam name)
Set a human-readable name for a scancode.
Definition SDL3pp_keyboard.h:285
void StopTextInput(WindowRef window)
Stop receiving any text input events in a window.
Definition SDL3pp_keyboard.h:622
const char * GetName() const
Get a human-readable name for a key.
Definition SDL3pp_keyboard.h:368
Keycode GetKeyFromScancode(Scancode scancode, Keymod modstate, bool key_event)
Get the key code corresponding to the given scancode according to the current keyboard layout.
Definition SDL3pp_keyboard.h:229
SDL_Capitalization Capitalization
Auto capitalization type.
Definition SDL3pp_keyboard.h:480
void ResetKeyboard()
Clear the state of the keyboard.
Definition SDL3pp_keyboard.h:161
void StopTextInput()
Stop receiving any text input events in a window.
Definition SDL3pp_keyboard.h:627
void SetTextInputArea(WindowRef window, const RectRaw &rect, int cursor)
Set the area used to type Unicode text input.
Definition SDL3pp_keyboard.h:669
void StartTextInput(WindowRef window)
Start accepting Unicode text input events in a window.
Definition SDL3pp_keyboard.h:418
bool HasKeyboard()
Return whether a keyboard is currently connected.
Definition SDL3pp_keyboard.h:48
void SetModState(Keymod modstate)
Set the current key modifier state for the keyboard.
Definition SDL3pp_keyboard.h:195
constexpr TextInputType TEXTINPUT_TYPE_TEXT_NAME
The input is a person's name.
Definition SDL3pp_keyboard.h:441
Keymod GetModState()
Get the current key modifier state for the keyboard.
Definition SDL3pp_keyboard.h:175
bool IsScreenKeyboardShown() const
Check whether the screen keyboard is shown for given window.
Definition SDL3pp_keyboard.h:742
const char * GetKeyboardNameForID(KeyboardID instance_id)
Get the name of a keyboard.
Definition SDL3pp_keyboard.h:91
WindowRef GetKeyboardFocus()
Query the window which currently has keyboard focus.
Definition SDL3pp_keyboard.h:105
const char * GetKeyName(Keycode key)
Get a human-readable name for a key.
Definition SDL3pp_keyboard.h:366
Scancode GetScancodeFromKey(Keycode key, Keymod *modstate=nullptr)
Get the scancode corresponding to the given key code according to the current keyboard layout.
Definition SDL3pp_keyboard.h:255
constexpr TextInputType TEXTINPUT_TYPE_TEXT_PASSWORD_HIDDEN
The input is a secure password that is hidden.
Definition SDL3pp_keyboard.h:450
void SetTextInputArea(const RectRaw &rect, int cursor)
Set the area used to type Unicode text input.
Definition SDL3pp_keyboard.h:674
constexpr TextInputType TEXTINPUT_TYPE_TEXT_EMAIL
The input is an e-mail address.
Definition SDL3pp_keyboard.h:444
constexpr Capitalization CAPITALIZE_SENTENCES
The first letter of sentences will be capitalized.
Definition SDL3pp_keyboard.h:485
void SetScancodeName(Scancode scancode, StringParam name)
Set a human-readable name for a scancode.
Definition SDL3pp_keyboard.h:280
void StartTextInputWithProperties(PropertiesRef props)
Start accepting Unicode text input events in a window, with properties describing the input.
Definition SDL3pp_keyboard.h:547
OwnArray< KeyboardID > GetKeyboards()
Get a list of currently connected keyboards.
Definition SDL3pp_keyboard.h:69
SDL_KeyboardID KeyboardID
This is a unique ID for a keyboard for the time it is connected to the system, and is never reused fo...
Definition SDL3pp_keyboard.h:35
Scancode GetScancodeFromName(StringParam name)
Get a scancode from a human-readable name.
Definition SDL3pp_keyboard.h:338
constexpr TextInputType TEXTINPUT_TYPE_TEXT_USERNAME
The input is a username.
Definition SDL3pp_keyboard.h:447
bool IsTextInputActive() const
Check whether or not Unicode text input events are enabled for a window.
Definition SDL3pp_keyboard.h:602
Keycode GetKeyFromName(StringParam name)
Get a key code from a human-readable name.
Definition SDL3pp_keyboard.h:388
constexpr TextInputType TEXTINPUT_TYPE_TEXT
The input is text.
Definition SDL3pp_keyboard.h:438
constexpr Capitalization CAPITALIZE_NONE
No auto-capitalization will be done.
Definition SDL3pp_keyboard.h:482
void ClearComposition(WindowRef window)
Dismiss the composition window/IME without disabling the subsystem.
Definition SDL3pp_keyboard.h:642
bool ScreenKeyboardShown(WindowRef window)
Check whether the screen keyboard is shown for given window.
Definition SDL3pp_keyboard.h:737
Scancode GetScancode(Keymod *modstate=nullptr) const
Get the scancode corresponding to the given key code according to the current keyboard layout.
Definition SDL3pp_keyboard.h:260
bool TextInputActive(WindowRef window)
Check whether or not Unicode text input events are enabled for a window.
Definition SDL3pp_keyboard.h:597
void GetTextInputArea(WindowRef window, RectRaw *rect, int *cursor)
Get the area used to type Unicode text input.
Definition SDL3pp_keyboard.h:697
const char * GetName() const
Get a human-readable name for a scancode.
Definition SDL3pp_keyboard.h:318
constexpr Capitalization CAPITALIZE_WORDS
The first letter of words will be capitalized.
Definition SDL3pp_keyboard.h:489
void StartTextInput()
Start accepting Unicode text input events in a window.
Definition SDL3pp_keyboard.h:423
constexpr TextInputType TEXTINPUT_TYPE_NUMBER
The input is a number.
Definition SDL3pp_keyboard.h:458
void GetTextInputArea(RectRaw *rect, int *cursor) const
Get the area used to type Unicode text input.
Definition SDL3pp_keyboard.h:702
constexpr TextInputType TEXTINPUT_TYPE_TEXT_PASSWORD_VISIBLE
The input is a secure password that is visible.
Definition SDL3pp_keyboard.h:454
void ClearComposition()
Dismiss the composition window/IME without disabling the subsystem.
Definition SDL3pp_keyboard.h:647
constexpr TextInputType TEXTINPUT_TYPE_NUMBER_PASSWORD_VISIBLE
The input is a secure PIN that is visible.
Definition SDL3pp_keyboard.h:465
void StartTextInputWithProperties(WindowRef window, PropertiesRef props)
Start accepting Unicode text input events in a window, with properties describing the input.
Definition SDL3pp_keyboard.h:542
SDL_TextInputType TextInputType
Text input type.
Definition SDL3pp_keyboard.h:436
constexpr Capitalization CAPITALIZE_LETTERS
All letters will be capitalized.
Definition SDL3pp_keyboard.h:492
bool HasScreenKeyboardSupport()
Check whether the platform has screen keyboard support.
Definition SDL3pp_keyboard.h:720
const char * GetScancodeName(Scancode scancode)
Get a human-readable name for a scancode.
Definition SDL3pp_keyboard.h:313
std::span< const bool > GetKeyboardState()
Get a snapshot of the current state of the keyboard.
Definition SDL3pp_keyboard.h:143
Uint16 Keymod
Valid key modifiers (possibly OR'd together).
Definition SDL3pp_keycode.h:35
ResourceRefT< PropertiesBase > PropertiesRef
Reference for Properties.
Definition SDL3pp_properties.h:56
SDL_Rect RectRaw
Alias to raw representation for Rect.
Definition SDL3pp_rect.h:34
ResourceRefT< WindowBase > WindowRef
Reference for Window.
Definition SDL3pp_video.h:57
Properties for text input to be used on StartTextInputWithProperties.
Definition SDL3pp_keyboard.h:557
constexpr auto AUTOCORRECT_BOOLEAN
Autocorrect enabled.
Definition SDL3pp_keyboard.h:573
constexpr auto ANDROID_INPUTTYPE_NUMBER
Number for android inputtype.
Definition SDL3pp_keyboard.h:579
constexpr auto MULTILINE_BOOLEAN
Multiline enabled.
Definition SDL3pp_keyboard.h:576
constexpr auto CAPITALIZATION_NUMBER
The auto-capitalization type to be used.
Definition SDL3pp_keyboard.h:571
constexpr auto TYPE_NUMBER
The type of text input to be used.
Definition SDL3pp_keyboard.h:564
Main include header for the SDL3pp library.