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{
14 {
15 }
16
18 {
19 }
20
21 void Keyboard::begin_text_input(const SDL_TextInputType input_type, const SDL_Capitalization capitals, const bool multiline) const noexcept
22 {
23 if (!SDL_TextInputActive(m_window))
24 {
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);
30
31 SDL_StartTextInputWithProperties(m_window, props);
32 SDL_DestroyProperties(props);
33 }
34 }
35
36 void Keyboard::end_text_input() const noexcept
37 {
38 SDL_StopTextInput(m_window);
39 }
40
41 void Keyboard::clear_state() const noexcept
42 {
43 SDL_ResetKeyboard();
44 }
45
46 bool Keyboard::has_keyboard() const noexcept
47 {
48 return SDL_HasKeyboard();
49 }
50
51 bool Keyboard::has_onscreen_keyboard() const noexcept
52 {
53 return SDL_HasScreenKeyboardSupport();
54 }
55
57 {
58 return SDL_ScreenKeyboardShown(m_window);
59 }
60} // namespace galaxy
Keyboard() noexcept
Constructor.
Definition Keyboard.cpp:12
void clear_state() const noexcept
Will clear any existing keyboard state.
Definition Keyboard.cpp:41
void end_text_input() const noexcept
Disable text input.
Definition Keyboard.cpp:36
bool onscreen_keyboard_active() const noexcept
Check if onscreen keyboard is shown.
Definition Keyboard.cpp:56
~Keyboard() noexcept
Destructor.
Definition Keyboard.cpp:17
bool has_keyboard() const noexcept
Check if there is a keyboard connected.
Definition Keyboard.cpp:46
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:21
bool has_onscreen_keyboard() const noexcept
Check if an onscreen keyboard is supported.
Definition Keyboard.cpp:51
Allows you to bind a base class to the window.
SDL_Window * m_window
Pointer to SDL_Window handle.
Application.hpp galaxy.