327 #define NEOGFX_SCANCODE_MASK (1<<30)
328 #define NEOGFX_SCANCODE_TO_KEYCODE(X) (X | NEOGFX_SCANCODE_MASK)
629 return static_cast<keyboard_locks>(
static_cast<uint32_t
>(aLhs) |
static_cast<uint32_t
>(aRhs));
634 return static_cast<keyboard_locks>(
static_cast<uint32_t
>(aLhs) &
static_cast<uint32_t
>(aRhs));
672 struct no_grab :
std::logic_error { no_grab() : std::logic_error(
"neogfx::i_keyboard::no_grab") {} };
693 static uuid const&
iid() {
static uuid const sIid{ 0x878ef7c6, 0x8d4b, 0x4c0d, 0x81dd, { 0x70, 0xd1, 0x74, 0x3c, 0x6b, 0x82 } };
return sIid; }
706 typedef std::pair<key_code_e, std::set<key_modifiers_e>> combo_type;
707 typedef std::vector<combo_type> sequence_type;
709 explicit key_sequence(std::string
const& aSequence) : iText{ aSequence }
711 std::vector<neolib::ci_string> sequenceBits;
713 for (
auto const& combo : sequenceBits)
715 combo_type nextCombo;
718 for (std::size_t i = 0; i < comboBits.
size(); ++i)
720 if (i < comboBits.
size() - 1)
722 if (comboBits[i] ==
"Ctrl")
724 else if (comboBits[i] ==
"Alt")
726 else if (comboBits[i] ==
"Shift")
731 static const std::map<neolib::ci_string, key_code_e> sKeyNames
784 if (!comboBits[i].empty())
786 auto name = sKeyNames.find(comboBits[i]);
787 if (name == sKeyNames.end())
790 nextCombo.first = name->second;
796 iSequence.push_back(nextCombo);
802 return iSequence == aRhs.iSequence;
806 return !(*
this == aRhs);
809 template <
typename Iter>
812 std::size_t index = 0;
813 for (Iter next = aFirst; next != aLast; ++next, ++index)
820 return matches(0, aKeyCode, aKeyModifiers);
829 if (iSequence[aIndex].first != aKeyCode)
831 for (
auto m : iSequence[aIndex].second)
832 if ((aKeyModifiers & m) != 0)
843 sequence_type iSequence;
virtual bool key_released(scan_code_e aScanCode, key_code_e aKeyCode, key_modifiers_e aKeyModifiers)=0
virtual bool key_pressed(scan_code_e aScanCode, key_code_e aKeyCode, key_modifiers_e aKeyModifiers)=0
virtual bool sys_text_input(i_string const &aText)=0
virtual bool text_input(i_string const &aText)=0
virtual bool ime_open() const =0
virtual void open_ime()=0
virtual bool ime_active() const =0
virtual bool ime_active(i_widget const &aInputWidget) const =0
virtual void activate_ime(i_widget const &aInputWidget, optional_point const &aPosition={})=0
virtual point const & position() const =0
virtual void close_ime()=0
virtual void deactivate_ime(i_widget const &aInputWidget)=0
virtual i_widget const & input_widget() const =0
virtual void update_ime_position(point const &aPosition)=0
virtual bool has_ime() const =0
virtual ~i_keyboard_layout()=default
virtual bool is_keyboard_grabbed_by(i_keyboard_handler &aKeyboardHandler) const =0
virtual void ungrab_keyboard(i_keyboard_handler &aKeyboardHandler)=0
virtual key_code_e scan_code_to_key_code(scan_code_e aScanCode) const =0
virtual void grab_keyboard(i_keyboard_handler &aKeyboardHandler)=0
virtual i_keyboard_layout & layout() const =0
virtual key_modifiers_e event_modifiers() const =0
virtual bool is_keyboard_grabbed() const =0
virtual keyboard_locks locks() const =0
virtual void clear_event_modifiers()=0
virtual bool is_key_pressed(scan_code_e aScanCode) const =0
virtual bool is_front_grabber(i_keyboard_handler &aKeyboardHandler) const =0
virtual key_modifiers_e modifiers() const =0
virtual void set_event_modifiers(key_modifiers_e aModifiers)=0
declare_event(key_pressed, scan_code_e, key_code_e, key_modifiers_e) declare_event(key_released
virtual i_keyboard_handler & grabber() const =0
static uuid const & iid()
bool operator!=(const key_sequence &aRhs) const
key_sequence(std::string const &aSequence)
bool operator==(const key_sequence &aRhs) const
const i_string & as_text() const
match matches(key_code_e aKeyCode, key_modifiers_e aKeyModifiers) const
match matches(Iter aFirst, Iter aLast) const
size_type max_size() const
#define NEOGFX_SCANCODE_TO_KEYCODE(X)
constexpr style_aspect operator&(style_aspect aLhs, style_aspect aRhs)
@ KeyCode_THOUSANDSSEPARATOR
@ KeyCode_KP_DBLVERTICALBAR
@ KeyCode_CURRENCYSUBUNIT
@ KeyCode_DECIMALSEPARATOR
@ KeyCode_KP_DBLAMPERSAND
@ KeyCode_AUDIOFASTFORWARD
std::optional< key_sequence > optional_key_sequence
@ ScanCode_INTERNATIONAL5
@ ScanCode_INTERNATIONAL7
@ ScanCode_INTERNATIONAL3
@ ScanCode_KP_HEXADECIMAL
@ ScanCode_KP_DBLVERTICALBAR
@ ScanCode_INTERNATIONAL6
@ ScanCode_LOCKINGNUMLOCK
@ ScanCode_BRIGHTNESSDOWN
@ ScanCode_KP_VERTICALBAR
@ ScanCode_INTERNATIONAL2
@ ScanCode_KBDILLUMTOGGLE
@ ScanCode_THOUSANDSSEPARATOR
@ ScanCode_DECIMALSEPARATOR
@ ScanCode_AUDIOFASTFORWARD
@ ScanCode_KP_EQUALSAS400
@ ScanCode_KP_MEMSUBTRACT
@ ScanCode_LOCKINGSCROLLLOCK
@ ScanCode_KP_DBLAMPERSAND
@ ScanCode_KP_MEMMULTIPLY
@ ScanCode_INTERNATIONAL4
@ ScanCode_INTERNATIONAL9
@ ScanCode_LOCKINGCAPSLOCK
@ ScanCode_NONUSBACKSLASH
@ ScanCode_CURRENCYSUBUNIT
@ ScanCode_INTERNATIONAL8
@ ScanCode_INTERNATIONAL1
constexpr style_aspect operator|(style_aspect aLhs, style_aspect aRhs)
FwdIter1 tokens(FwdIter1 aFirst, FwdIter1 aLast, FwdIter2 aDelimeterFirst, FwdIter2 aDelimiterLast, ResultContainer &aTokens, std::size_t aMaxTokens=0, bool aSkipEmptyTokens=true, bool aDelimeterIsSubsequence=false)
ci_string make_ci_string(const std::string &s)
std::basic_string< char, ci_char_traits< std::char_traits< char > > > ci_string
std::basic_string< CharT, Traits, Alloc > to_lower(const std::basic_string< CharT, Traits, Alloc > &aString)
std::string make_string(const ci_string &s)
#define declare_event(declName,...)