21 void Keyboard::begin_text_input(
const SDL_TextInputType input_type,
const SDL_Capitalization capitals,
const bool multiline)
const noexcept
25 const auto props = SDL_CreateProperties();
26 SDL_SetNumberProperty(props, SDL_PROP_TEXTINPUT_TYPE_NUMBER, input_type);
27 SDL_SetNumberProperty(props, SDL_PROP_TEXTINPUT_CAPITALIZATION_NUMBER, capitals);
28 SDL_SetBooleanProperty(props, SDL_PROP_TEXTINPUT_AUTOCORRECT_BOOLEAN,
false);
29 SDL_SetBooleanProperty(props, SDL_PROP_TEXTINPUT_MULTILINE_BOOLEAN, multiline);
31 SDL_StartTextInputWithProperties(
m_window, props);
32 SDL_DestroyProperties(props);
38 return SDL_TextInputActive(
m_window);
53 return SDL_HasKeyboard();
58 return SDL_HasScreenKeyboardSupport();
63 return SDL_ScreenKeyboardShown(
m_window);
68 const auto mod =
static_cast<SDL_Keymod
>(modifier);
69 return SDL_GetModState() & mod;
74 const auto keys = SDL_GetKeyboardState(
nullptr);
75 return keys[
static_cast<SDL_Keycode
>(key)];
82 return SDL_GetScancodeFromKey(
static_cast<SDL_Keycode
>(key),
nullptr);
86 auto mod =
static_cast<SDL_Keymod
>(modifier);
87 return SDL_GetScancodeFromKey(
static_cast<SDL_Keycode
>(key), &mod);
Keyboard() noexcept
Constructor.
void clear_state() const noexcept
Will clear any existing keyboard state.
void end_text_input() const noexcept
Disable text input.
bool onscreen_keyboard_active() const noexcept
Check if onscreen keyboard is shown.
SDL_Scancode get_scancode(const Keys key, const KeyMods modifier=KeyMods::MOD_NONE) const noexcept
Get key scancode.
bool is_key_mod_down(const KeyMods modifier) const noexcept
See if a key mod is being held down.
~Keyboard() noexcept
Destructor.
bool has_keyboard() const noexcept
Check if there is a keyboard connected.
bool is_text_input_active() const noexcept
Is text input active?
void begin_text_input(const SDL_TextInputType input_type, const SDL_Capitalization capitals, const bool multiline) const noexcept
Enable window to begin processing text input.
bool is_key_down(const Keys key) const noexcept
See if a key is being held down.
bool has_onscreen_keyboard() const noexcept
Check if an onscreen keyboard is supported.
WindowBindable() noexcept
Constructor.
SDL_Window * m_window
Pointer to SDL_Window handle.
Keys
Enum class representing keys.
KeyMods
Enum class for key modifiers.