galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
Keyboard.cpp
Go to the documentation of this file.
1
7
8#include "Keyboard.hpp"
9
10namespace galaxy
11{
13 {
14 }
15
17 {
18 }
19
20 void Keyboard::begin_text_input(const SDL_TextInputType input_type, const SDL_Capitalization capitals, const bool multiline) const noexcept
21 {
22 if (!SDL_TextInputActive(m_window))
23 {
24 const auto props = SDL_CreateProperties();
25 SDL_SetNumberProperty(props, SDL_PROP_TEXTINPUT_TYPE_NUMBER, input_type);
26 SDL_SetNumberProperty(props, SDL_PROP_TEXTINPUT_CAPITALIZATION_NUMBER, capitals);
27 SDL_SetBooleanProperty(props, SDL_PROP_TEXTINPUT_AUTOCORRECT_BOOLEAN, false);
28 SDL_SetBooleanProperty(props, SDL_PROP_TEXTINPUT_MULTILINE_BOOLEAN, multiline);
29
30 SDL_StartTextInputWithProperties(m_window, props);
31 SDL_DestroyProperties(props);
32 }
33 }
34
35 void Keyboard::end_text_input() const noexcept
36 {
37 SDL_StopTextInput(m_window);
38 }
39
40 void Keyboard::clear_state() const noexcept
41 {
42 SDL_ResetKeyboard();
43 }
44
45 bool Keyboard::has_keyboard() const noexcept
46 {
47 return SDL_HasKeyboard();
48 }
49
50 bool Keyboard::has_onscreen_keyboard() const noexcept
51 {
52 return SDL_HasScreenKeyboardSupport();
53 }
54
56 {
57 return SDL_ScreenKeyboardShown(m_window);
58 }
59} // namespace galaxy
Keyboard() noexcept
Constructor.
Definition Keyboard.cpp:12
void clear_state() const noexcept
Will clear any existing keyboard state.
Definition Keyboard.cpp:40
void end_text_input() const noexcept
Disable text input.
Definition Keyboard.cpp:35
bool onscreen_keyboard_active() const noexcept
Check if onscreen keyboard is shown.
Definition Keyboard.cpp:55
~Keyboard() noexcept
Destructor.
Definition Keyboard.cpp:16
bool has_keyboard() const noexcept
Check if there is a keyboard connected.
Definition Keyboard.cpp:45
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.
Definition Keyboard.cpp:20
bool has_onscreen_keyboard() const noexcept
Check if an onscreen keyboard is supported.
Definition Keyboard.cpp:50
SDL_Window * m_window
Pointer to SDL_Window handle.
Animated.cpp galaxy.
Definition Animated.cpp:16