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);
140 auto data = SDL_GetKeyboardState(&count);
141 return std::span{data, size_t(count)};
193 : m_keycode(SDL_GetKeyFromScancode(scancode, modstate, key_event))
198 : m_keycode(SDL_GetKeyFromName(name))
204 return SDL_GetScancodeFromKey(m_keycode, modstate);
209 CheckError(SDL_SetScancodeName(m_scancode, name));
214 return SDL_GetScancodeName(m_scancode);
218 : m_scancode(SDL_GetScancodeFromName(name))
224 return SDL_GetKeyName(m_keycode);
234 CheckError(SDL_StartTextInputWithProperties(m_resource, props));
251 SDL_TEXTINPUT_TYPE_TEXT;
254 SDL_TEXTINPUT_TYPE_TEXT_NAME;
257 SDL_TEXTINPUT_TYPE_TEXT_EMAIL;
260 SDL_TEXTINPUT_TYPE_TEXT_USERNAME;
263 SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_HIDDEN;
267 SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_VISIBLE;
271 SDL_TEXTINPUT_TYPE_NUMBER;
274 SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_HIDDEN;
278 SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_VISIBLE;
298 SDL_CAPITALIZE_SENTENCES;
302 SDL_CAPITALIZE_WORDS;
305 SDL_CAPITALIZE_LETTERS;
307namespace prop::TextInput {
309constexpr auto TYPE_NUMBER = SDL_PROP_TEXTINPUT_TYPE_NUMBER;
311constexpr auto CAPITALIZATION_NUMBER = SDL_PROP_TEXTINPUT_CAPITALIZATION_NUMBER;
313constexpr auto AUTOCORRECT_BOOLEAN = SDL_PROP_TEXTINPUT_AUTOCORRECT_BOOLEAN;
315constexpr auto MULTILINE_BOOLEAN = SDL_PROP_TEXTINPUT_MULTILINE_BOOLEAN;
317constexpr auto ANDROID_INPUTTYPE_NUMBER =
318 SDL_PROP_TEXTINPUT_ANDROID_INPUTTYPE_NUMBER;
324 return SDL_TextInputActive(m_resource);
339 CheckError(SDL_SetTextInputArea(m_resource, &rect, cursor));
344 CheckError(SDL_GetTextInputArea(m_resource, rect, cursor));
362 return SDL_HasScreenKeyboardSupport();
367 return SDL_ScreenKeyboardShown(m_resource);
constexpr Keycode(KeycodeRaw keycode={})
Wraps Keycode.
Definition: SDL3pp_keycode.h:125
Base class for SDL memory allocated array wrap.
Definition: SDL3pp_ownPtr.h:44
The SDL keyboard scancode representation.
Definition: SDL3pp_scancode.h:46
constexpr Scancode(ScancodeRaw scancode={})
Wraps Scancode.
Definition: SDL3pp_scancode.h:55
Helpers to use C++ strings parameters.
Definition: SDL3pp_strings.h:43
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition: SDL3pp_error.h:197
constexpr TextInputType TEXTINPUT_TYPE_NUMBER_PASSWORD_HIDDEN
The input is a secure PIN that is hidden.
Definition: SDL3pp_keyboard.h:273
void SetName(StringParam name)
Set a human-readable name for a scancode.
Definition: SDL3pp_keyboard.h:207
const char * GetName() const
Get a human-readable name for a key.
Definition: SDL3pp_keyboard.h:222
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
void ResetKeyboard()
Clear the state of the keyboard.
Definition: SDL3pp_keyboard.h:155
void GetTextInputArea(RectRaw *rect, int *cursor)
Get the area used to type Unicode text input.
Definition: SDL3pp_keyboard.h:342
bool HasKeyboard()
Return whether a keyboard is currently connected.
Definition: SDL3pp_keyboard.h:48
void ClearComposition()
Dismiss the composition window/IME without disabling the subsystem.
Definition: SDL3pp_keyboard.h:332
void SetModState(Keymod modstate)
Set the current key modifier state for the keyboard.
Definition: SDL3pp_keyboard.h:190
constexpr TextInputType TEXTINPUT_TYPE_TEXT_NAME
The input is a person's name.
Definition: SDL3pp_keyboard.h:253
Keymod GetModState()
Get the current key modifier state for the keyboard.
Definition: SDL3pp_keyboard.h:170
const char * GetKeyboardNameForID(KeyboardID instance_id)
Get the name of a keyboard.
Definition: SDL3pp_keyboard.h:91
void StartTextInput()
Start accepting Unicode text input events in a window.
Definition: SDL3pp_keyboard.h:227
WindowRef GetKeyboardFocus()
Query the window which currently has keyboard focus.
Definition: SDL3pp_keyboard.h:105
constexpr TextInputType TEXTINPUT_TYPE_TEXT_PASSWORD_HIDDEN
The input is a secure password that is hidden.
Definition: SDL3pp_keyboard.h:262
constexpr TextInputType TEXTINPUT_TYPE_TEXT_EMAIL
The input is an e-mail address.
Definition: SDL3pp_keyboard.h:256
constexpr Capitalization CAPITALIZE_SENTENCES
The first letter of sentences will be capitalized.
Definition: SDL3pp_keyboard.h:297
OwnArray< KeyboardID > GetKeyboards()
Get a list of currently connected keyboards.
Definition: SDL3pp_keyboard.h:69
constexpr TextInputType TEXTINPUT_TYPE_TEXT_USERNAME
The input is a username.
Definition: SDL3pp_keyboard.h:259
SDL_TextInputType TextInputType
Text input type.
Definition: SDL3pp_keyboard.h:248
bool IsTextInputActive() const
Check whether or not Unicode text input events are enabled for a window.
Definition: SDL3pp_keyboard.h:322
Scancode GetScancode(Keymod *modstate) const
Get the scancode corresponding to the given key code according to the current keyboard layout.
Definition: SDL3pp_keyboard.h:202
void StopTextInput()
Stop receiving any text input events in a window.
Definition: SDL3pp_keyboard.h:327
bool IsScreenKeyboardShown() const
Check whether the screen keyboard is shown for given window.
Definition: SDL3pp_keyboard.h:365
constexpr TextInputType TEXTINPUT_TYPE_TEXT
The input is text.
Definition: SDL3pp_keyboard.h:250
constexpr Capitalization CAPITALIZE_NONE
No auto-capitalization will be done.
Definition: SDL3pp_keyboard.h:294
SDL_Capitalization Capitalization
Auto capitalization type.
Definition: SDL3pp_keyboard.h:292
void SetTextInputArea(const RectRaw &rect, int cursor)
Set the area used to type Unicode text input.
Definition: SDL3pp_keyboard.h:337
const char * GetName() const
Get a human-readable name for a scancode.
Definition: SDL3pp_keyboard.h:212
constexpr Capitalization CAPITALIZE_WORDS
The first letter of words will be capitalized.
Definition: SDL3pp_keyboard.h:301
constexpr TextInputType TEXTINPUT_TYPE_NUMBER
The input is a number.
Definition: SDL3pp_keyboard.h:270
constexpr TextInputType TEXTINPUT_TYPE_TEXT_PASSWORD_VISIBLE
The input is a secure password that is visible.
Definition: SDL3pp_keyboard.h:266
constexpr TextInputType TEXTINPUT_TYPE_NUMBER_PASSWORD_VISIBLE
The input is a secure PIN that is visible.
Definition: SDL3pp_keyboard.h:277
constexpr Capitalization CAPITALIZE_LETTERS
All letters will be capitalized.
Definition: SDL3pp_keyboard.h:304
bool HasScreenKeyboardSupport()
Check whether the platform has screen keyboard support.
Definition: SDL3pp_keyboard.h:360
std::span< const bool > GetKeyboardState()
Get a snapshot of the current state of the keyboard.
Definition: SDL3pp_keyboard.h:137
Uint16 Keymod
Valid key modifiers (possibly OR'd together).
Definition: SDL3pp_keycode.h:34
SDL_Rect RectRaw
Alias to raw representation for Rect.
Definition: SDL3pp_rect.h:34
Main include header for the SDL3pp library.
Safely wrap Properties for non owning parameters.
Definition: SDL3pp_properties.h:52
Semi-safe reference for Window.
Definition: SDL3pp_video.h:2955