24#ifndef GAMP_WTKEYBOARD_HPP_
25#define GAMP_WTKEYBOARD_HPP_
50 return ( 0xFFFF & *keyCode ) < m_keybuffer.bit_size;
53 bool setPressed(
VKeyCode keyCode,
bool pressed) {
54 const size_t v = 0xFFFFU & *keyCode;
55 if( v < m_keybuffer.bit_size ) {
56 m_keybuffer.put(v, pressed);
69 const size_t v = 0xFFFFU & *keyCode;
70 if( v < m_keybuffer.bit_size ) {
71 return m_keybuffer.get(v);
83 m_modifiers |= keySymMods;
84 m_modifiers &= ~clrRepeatMod;
86 setPressed(keySym,
true);
89 kl->keyPressed(ke, *
this);
90 }
catch (std::exception &err) {
91 ERR_PRINT(
"KeyboardManager::dispatch (p): %s: Caught exception %s", ke.
toString().c_str(), err.what());
101 m_modifiers &= ~clrRepeatMod;
103 m_modifiers &= ~keySymMods;
104 setPressed(keySym,
false);
107 kl->keyReleased(ke, *
this);
108 }
catch (std::exception &err) {
109 ERR_PRINT(
"KeyboardManager::dispatch (r): %s: Caught exception %s", ke.
toString().c_str(), err.what());
118 return m_keyListener.erase_matching(l,
true,
123 const size_t count = m_keyListener.size();
124 m_keyListener.clear(
true);
const PressedKeyCodes & pressedKeyCodes() const noexcept override
size_t removeAllListener()
size_t removeListener(const KeyListenerRef &l)
void addListener(const KeyListenerRef &l)
bool isPressed(VKeyCode keyCode) const noexcept override
void dispatchReleased(const jau::fraction_timespec &when, const WindowRef &source, VKeyCode keySym, InputModifier keySymMods, uint16_t keyChar) noexcept
size_t listenerCount() const noexcept
InputModifier modifier() const noexcept override
void dispatchPressed(const jau::fraction_timespec &when, const WindowRef &source, VKeyCode keySym, InputModifier keySymMods, uint16_t keyChar) noexcept
KeyEventManager() noexcept
std::string toString() const noexcept
jau::bitfield< 256 > PressedKeyCodes
constexpr bool consumed() const noexcept
Consumed events will stop traversing through listener.
Implementation of a Copy-On-Write (CoW) using jau::darray as the underlying storage,...
#define ERR_PRINT(...)
Use for unconditional error messages, prefix '[elapsed_time] Error @ FILE:LINE FUNC: '.
constexpr bool is_set(const E mask, const E bits) noexcept
std::shared_ptr< KeyListener > KeyListenerRef
VKeyCode
Virtual key code following UTF16 specification.
static constexpr uint16_t EVENT_KEY_PRESSED
A key has been pressed, excluding auto-repeat-modifier keys.
std::shared_ptr< Window > WindowRef
static constexpr uint16_t EVENT_KEY_RELEASED
A key has been released, excluding auto-repeat-modifier keys.
@ repeat
Event is caused by auto-repeat.
Timespec structure using int64_t for its components in analogy to struct timespec_t on 64-bit platfor...