24#ifndef GAMP_WTKEYEVENT_HPP_
25#define GAMP_WTKEYEVENT_HPP_
652 if(
'a' <= keyChar && keyChar <=
'z' ) {
760 static constexpr uint8_t F_MODIFIER_MASK = 1 << 0;
761 static constexpr uint8_t F_ACTION_MASK = 1 << 1;
762 static constexpr uint8_t F_PRINTABLE_MASK = 1 << 2;
764 std::string getEventTypeString()
const noexcept {
768 default:
return "unknown (" + std::to_string(
type()) +
")";
778 m_flags |= F_PRINTABLE_MASK;
780 m_flags |= F_MODIFIER_MASK;
783 m_flags |= F_ACTION_MASK;
806 constexpr uint16_t
keyChar() const noexcept {
return m_keyChar; }
819 constexpr bool isPrintableKey() const noexcept {
return 0 != ( F_PRINTABLE_MASK & m_flags ); }
831 constexpr bool isModifierKey() const noexcept {
return 0 != ( F_MODIFIER_MASK & m_flags ); }
843 constexpr bool isActionKey() const noexcept {
return 0 != ( F_ACTION_MASK & m_flags ); }
856 std::string res =
"KeyEvent[";
857 res.append(getEventTypeString()).append(
", sym ").append(
jau::to_hexstring(*m_keySym))
860 res.append(
" `").append(std::string(1, (
char)m_keyChar)).append(
"`");
864 res.append(
"printable");
866 res.append(
"modifier");
868 res.append(
"actionkey");
constexpr bool isPrintableKey() const noexcept
Returns true if key symbol and key char represents a printable character, i.e.
KeyEvent(uint16_t type, const jau::fraction_timespec &when, const WindowRef &source, InputModifier globalMods, VKeyCode keySym, InputModifier keySymMods, uint16_t keyChar) noexcept
constexpr uint16_t keyChar() const noexcept
Returns the UTF-16 character reflecting the key symbol incl.
std::string toString() const noexcept
constexpr bool isTyped() const noexcept
Returns true if event matches original key typed semantics, i.e.:
constexpr bool isActionKey() const noexcept
Returns true if key symbol represents a non-printable and non-modifier action key,...
constexpr bool isModifierKey() const noexcept
Returns true if key symbol represents a modifier key, otherwise false.
constexpr VKeyCode keySym() const noexcept
Returns the virtual key symbol reflecting the current keyboard layout.
Listener for multiple KeyEvent.
virtual void keyPressed(KeyEvent &, const KeyboardTracker &)
A key has been pressed, excluding auto-repeat modifier keys.
virtual void keyReleased(KeyEvent &, const KeyboardTracker &)
A key has been released, excluding auto-repeat modifier keys.
virtual ~KeyListener() noexcept=default
jau::bitfield< 256 > PressedKeyCodes
virtual const PressedKeyCodes & pressedKeyCodes() const noexcept=0
virtual bool isPressed(VKeyCode) const noexcept=0
virtual InputModifier modifier() const noexcept=0
virtual ~KeyboardTracker() noexcept=default
constexpr const WindowWeakPtr & source() const noexcept
constexpr const jau::fraction_timespec & when() const noexcept
constexpr uint16_t type() const noexcept
Simple bitfield template for efficient bit storage access in O(1).
constexpr bool has_any(const E mask, const E bits) noexcept
constexpr std::underlying_type_t< E > operator*(const E v) noexcept
constexpr bool operator==(const E lhs, const E rhs) noexcept
std::ostream & operator<<(std::ostream &os, const T v)
constexpr VKeyCode toVKeyCode(uint16_t keyChar) noexcept
std::shared_ptr< KeyListener > KeyListenerRef
constexpr bool isModifierKey(VKeyCode vKey)
Returns true if the given virtualKey represents a modifier key, otherwise false.
VKeyCode
Virtual key code following UTF16 specification.
bool isPrintableKey(uint16_t uniChar, bool isKeyChar) noexcept
Returns true if given uniChar represents a printable character, i.e.
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.
@ VK_QUOTEDBL
Constant for the """ key.
@ VK_F3
Constant for the F3 function key.
@ VK_SEMICOLON
Constant for the semicolon keyu, "u,".
@ VK_PLUS
Constant for the "+" key.
@ VK_F6
Constant for the F6 function key.
@ VK_HOME
Constant for the HOME function key.
@ VK_STOP
Constant for the Stop function key.
@ VK_QUESTIONMARK
Constant for the equals keyu, "?".
@ VK_F10
Constant for the F11 function key.
@ VK_ADD
Numeric keypad add key.
@ VK_ESCAPE
Constant for the ESCAPE function key.
@ VK_UNDERSCORE
Constant for the "_" key.
@ VK_COMPOSE
Constant for the Compose function key.
@ VK_ASTERISK
Constant for the "*" key.
@ VK_KEYBOARD_INVISIBLE
Constant for Keyboard became invisible, e.g.
@ VK_F5
Constant for the F5 function key.
@ VK_MODECHANGE
Constant for the Mode Change (?).
@ VK_META
Constant for the Meta function key.
@ VK_ACCEPT
Constant for the Accept or Commit function keyu, Japanese "kakutei".
@ VK_NUMPAD4
See VK_NUMPAD0.
@ VK_PERCENT
Constant for the "%" key.
@ VK_F23
Constant for the F23 function key.
@ VK_F7
Constant for the F7 function key.
@ VK_F8
Constant for the F8 function key.
@ VK_WINDOWS
Constant for the MS "Windows" function key.
@ VK_BACK_SPACE
Constant for the BACK SPACE key "\b"u, matching ASCII.
@ VK_ALL_CANDIDATES
Constant for the All Candidates function key.
@ VK_AMPERSAND
Constant for the "&" key.
@ VK_KANA_LOCK
Constant for the locking Kana function key.
@ VK_CONVERT
Constant for the Convert function keyu, Japanese "henkan".
@ VK_F15
Constant for the F15 function key.
@ VK_F13
Constant for the F13 function key.
@ VK_RIGHT
Constant for the cursor- or numerical-pad right arrow key.
@ VK_INPUT_METHOD_ON_OFF
Constant for the input method on/off key.
@ VK_F18
Constant for the F18 function key.
@ VK_PREVIOUS_CANDIDATE
Constant for the Previous Candidate function key.
@ VK_DIVIDE
Numeric keypad divide key.
@ VK_F22
Constant for the F22 function key.
@ VK_F24
Constant for the F24 function key.
@ VK_OPEN_BRACKET
Constant for the open bracket keyu, "[".
@ VK_HALF_WIDTH
Constant for the Half-Width Characters function key.
@ VK_KATAKANA
Constant for the Katakana function key.
@ VK_RIGHT_BRACE
Constant for the "}" key.
@ VK_DOWN
Constant for the cursor- or numerical pad down arrow key.
@ VK_NUMPAD2
See VK_NUMPAD0.
@ VK_ALPHANUMERIC
Constant for the Alphanumeric function key.
@ VK_HELP
Constant for the Help function key.
@ VK_DECIMAL
Numeric keypad decimal separator key.
@ VK_CONTROL
Constant for the CTRL function key.
@ VK_PRINTSCREEN
Constant for the PRINT function key.
@ VK_F1
Small UTF/ASCII 'a' thru 'z' (0x61 - 0x7a) - Not used for keyCode / keySym.
@ VK_COMMA
Constant for the comma keyu, "u,".
@ VK_A
VK_A thru VK_Z are the same as Capital UTF16/ASCII 'A' thru 'Z' (0x41 - 0x5A)
@ VK_F17
Constant for the F17 function key.
@ VK_F2
Constant for the F2 function key.
@ VK_ENTER
Constant for the ENTER keyu, i.e.
@ VK_F12
Constant for the F12 function key.
@ VK_PIPE
Constant for the "|" key.
@ VK_BACK_SLASH
Constant for the back slash keyu, "\".
@ VK_NUMPAD3
See VK_NUMPAD0.
@ VK_QUOTE
Constant for the "'" key.
@ VK_UP
Constant for the cursor- or numerical-pad up arrow key.
@ VK_NUMPAD6
See VK_NUMPAD0.
@ VK_BACK_QUOTE
Constant for the "`" key.
@ VK_EURO_SIGN
Constant for the Euro currency sign key.
@ VK_END
Constant for the END function key.
@ VK_SPACE
Constant for the SPACE function key.
@ VK_AT
Constant for the equals keyu, "@".
@ VK_LEFT_BRACE
Constant for the "{" key.
@ VK_FULL_WIDTH
Constant for the Full-Width Characters function key.
@ VK_CAPS_LOCK
Constant for the CAPS LOCK function key.
@ VK_CIRCUMFLEX
Constant for the "^" key.
@ VK_PERIOD
Constant for the period keyu, ".".
@ VK_NUMPAD7
See VK_NUMPAD0.
@ VK_NUMPAD9
See VK_NUMPAD0.
@ VK_TAB
Constant for the HORIZ TAB key "\t"u, matching ASCII.
@ VK_HIRAGANA
Constant for the Hiragana function key.
@ VK_PAGE_DOWN
Constant for the PAGE DOWN function key.
@ VK_NONCONVERT
Constant for the Don't Convert function keyu, Japanese "muhenkan".
@ VK_UNDEFINED
This value, {@value}, is used to indicate that the keyCode is unknown.
@ VK_LEFT
Constant for the cursor- or numerical-pad left arrow key.
@ VK_F4
Constant for the F4 function key.
@ VK_FINAL
Constant for the END function key.
@ VK_F16
Constant for the F16 function key.
@ VK_SHIFT
Constant for the SHIFT function key.
@ VK_F20
Constant for the F20 function key.
@ VK_NUMPAD5
See VK_NUMPAD0.
@ VK_COLON
Constant for the ":" key.
@ VK_F14
Constant for the F14 function key.
@ VK_CODE_INPUT
Constant for the Code Input function key.
@ VK_JAPANESE_HIRAGANA
Constant for the Japanese-Hiragana function key.
@ VK_CANCEL
Constant for the CANCEL function key.
@ VK_LEFT_PARENTHESIS
Constant for the "(" key.
@ VK_RIGHT_PARENTHESIS
Constant for the ")" key.
@ VK_0
VK_0 thru VK_9 are the same as UTF16/ASCII '0' thru '9' [0x30 - 0x39].
@ VK_JAPANESE_ROMAN
Constant for the Japanese-Roman function key.
@ VK_EQUALS
Constant for the equals keyu, "=".
@ VK_NUMPAD0
Numeric keypad VK_NUMPAD0 thru VK_NUMPAD9 are mapped to UTF control (0x80 - 0x89).
@ VK_CONTEXT_MENU
Constant for the Context Menu key.
@ VK_F9
Constant for the F9 function key.
@ VK_PAGE_UP
Constant for the PAGE UP function key.
@ VK_INVERTED_EXCLAMATION_MARK
Constant for the inverted exclamation mark key.
@ VK_CLOSE_BRACKET
Constant for the close bracket keyu, "]".
@ VK_NUMBER_SIGN
Constant for the "#" key.
@ VK_JAPANESE_KATAKANA
Constant for the Japanese-Katakana function key.
@ VK_ALT
Constant for the ALT function key.
@ VK_MINUS
Constant for the minus keyu, "-".
@ VK_SLASH
Constant for the forward slash keyu, "/".
@ VK_INSERT
Constant for the INSERT function key.
@ VK_F19
Constant for the F19 function key.
@ VK_ROMAN_CHARACTERS
Constant for the Roman Characters function key.
@ VK_PAUSE
Constant for the PAUSE function key.
@ VK_F11
Constant for the F11 function key.
@ VK_GREATER
Constant for the equals keyu, ">".
@ VK_SEPARATOR
Numeric keypad decimal separator key.
@ VK_NUMPAD1
See VK_NUMPAD0.
@ VK_SUBTRACT
Numeric keypad subtract key.
@ VK_BEGIN
Constant for the Begin function key.
@ VK_DOLLAR
Constant for the "$" key.
@ VK_LINEFEED
LINE_FEED "\n"u, matching ASCIIu, n/a on keyboard.
@ VK_LESS
Constant for the equals keyu, "<".
@ VK_EXCLAMATION_MARK
Constant for the "!" key.
@ VK_SCROLL_LOCK
scroll lock key.
@ VK_CLEAR
Constant for the CLEAR keyu, i.e.
@ VK_MULTIPLY
Numeric keypad multiply key.
@ VK_F21
Constant for the F21 function key.
@ VK_DELETE
Constant for the DEL keyu, matching ASCII.
@ VK_TILDE
Constant for the "~" keyu, matching ASCII.
@ VK_NUMPAD8
See VK_NUMPAD0.
@ VK_NUM_LOCK
Numeric keypad num lock key.
std::string to_hexstring(value_type const &v, const bool skipLeading0x=false) noexcept
Produce a lower-case hexadecimal string representation with leading 0x in MSB of the given pointer.
Timespec structure using int64_t for its components in analogy to struct timespec_t on 64-bit platfor...