neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
keyboard.hpp
Go to the documentation of this file.
1// keyboard.hpp
2/*
3 neogfx C++ App/Game Engine
4 Copyright (c) 2015, 2020 Leigh Johnston. All Rights Reserved.
5
6 This program is free software: you can redistribute it and / or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <neogfx/neogfx.hpp>
23#include <deque>
26
27namespace neogfx
28{
29 class keyboard;
30
32 {
33 public:
35 public:
36 bool key_pressed(scan_code_e aScanCode, key_code_e aKeyCode, key_modifiers_e aKeyModifiers) override;
37 bool key_released(scan_code_e aScanCode, key_code_e aKeyCode, key_modifiers_e aKeyModifiers) override;
38 bool text_input(i_string const& aText) override;
39 bool sys_text_input(i_string const& aText) override;
40 private:
41 keyboard& iKeyboard;
42 };
43
44 class keyboard : public hid_device<i_keyboard>
45 {
46 public:
49 define_declared_event(TextInput, text_input, std::string const&)
51 define_declared_event(InputLanguageChanged, input_language_changed)
52 private:
53 friend class keyboard_grabber;
54 public:
55 keyboard(const i_string& aName = string{ "Generic Keyboard" });
56 public:
58 void set_event_modifiers(key_modifiers_e aModifiers) override;
59 void clear_event_modifiers() override;
60 public:
61 bool is_keyboard_grabbed() const override;
62 bool is_keyboard_grabbed_by(i_keyboard_handler& aKeyboardHandler) const override;
63 bool is_front_grabber(i_keyboard_handler& aKeyboardHandler) const override;
64 void grab_keyboard(i_keyboard_handler& aKeyboardHandler) override;
65 void ungrab_keyboard(i_keyboard_handler& aKeyboardHandler) override;
66 i_keyboard_handler& grabber() const override;
67 private:
68 mutable keyboard_grabber iGrabber;
69 std::deque<i_keyboard_handler*> iGrabs;
70 std::optional<key_modifiers_e> iEventModifiers;
71 };
72}
bool key_pressed(scan_code_e aScanCode, key_code_e aKeyCode, key_modifiers_e aKeyModifiers) override
bool sys_text_input(i_string const &aText) override
bool key_released(scan_code_e aScanCode, key_code_e aKeyCode, key_modifiers_e aKeyModifiers) override
keyboard_grabber(keyboard &aKeyboard)
bool text_input(i_string const &aText) override
void ungrab_keyboard(i_keyboard_handler &aKeyboardHandler) override
bool is_keyboard_grabbed_by(i_keyboard_handler &aKeyboardHandler) const override
bool is_keyboard_grabbed() const override
void set_event_modifiers(key_modifiers_e aModifiers) override
void grab_keyboard(i_keyboard_handler &aKeyboardHandler) override
bool is_front_grabber(i_keyboard_handler &aKeyboardHandler) const override
define_declared_event(KeyPressed, key_pressed, scan_code_e, key_code_e, key_modifiers_e) define_declared_event(KeyReleased
void clear_event_modifiers() override
i_keyboard_handler & grabber() const override
key_modifiers_e sys_text_input
Definition keyboard.hpp:50
key_modifiers_e event_modifiers() const override
Definition plf_hive.h:79
#define define_declared_event(name, declName,...)
Definition event.hpp:195