7#include "keyboard_key.hpp"
8#include "../text/grapheme.hpp"
9#include "../required.hpp"
10#include "../assert.hpp"
11#include "../command.hpp"
16enum class KeyboardState : uint8_t {
23[[nodiscard]]
constexpr KeyboardState operator|(KeyboardState lhs, KeyboardState rhs)
noexcept {
24 return static_cast<KeyboardState
>(
static_cast<uint8_t
>(lhs) |
static_cast<uint8_t
>(rhs));
27constexpr KeyboardState &operator|=(KeyboardState &lhs, KeyboardState rhs)
noexcept {
32[[nodiscard]]
constexpr bool operator>=(KeyboardState lhs, KeyboardState rhs)
noexcept {
33 ttlet lhs_ =
static_cast<uint8_t
>(lhs);
34 ttlet rhs_ =
static_cast<uint8_t
>(rhs);
35 return (lhs_ & rhs_) == rhs_;
40 enum class Type : uint8_t {
54 type(type), state(),
grapheme(), key() {}
58 keyboard_event(KeyboardState state, keyboard_modifiers modifiers, keyboard_virtual_key key) noexcept :
66 [[nodiscard]] friend
std::
string to_string(keyboard_event const &rhs) noexcept {
70 case Type::Idle: r +=
"Idle";
break;
74 default: tt_no_default();
78 r += to_string(rhs.grapheme);
80 r += to_string(rhs.key);
88 return lhs << to_string(rhs);
Definition keyboard_event.hpp:39
Type
Definition keyboard_event.hpp:40
@ Key
Key (+modifiers) was used to send a key.
@ Partialgrapheme
The user is combining a grapheme.
@ grapheme
The user has finished entering a grapheme.
keyboard_event(KeyboardState state, keyboard_modifiers modifiers, keyboard_virtual_key key) noexcept
Create a key-key keyboard event.
Definition keyboard_event.hpp:58
A key in combination with modifiers.
Definition keyboard_key.hpp:20
Definition grapheme.hpp:21