Deskflow 1.22.0.197
Keyboard and mouse sharing utility
|
Microsoft Windows key mapper. More...
#include <MSWindowsKeyState.h>
Public Member Functions | |
MSWindowsKeyState (MSWindowsDesks *desks, void *eventTarget, IEventQueue *events, std::vector< std::string > layouts, bool isLangSyncEnabled) | |
MSWindowsKeyState (MSWindowsDesks *desks, void *eventTarget, IEventQueue *events, deskflow::KeyMap &keyMap, std::vector< std::string > layouts, bool isLangSyncEnabled) | |
virtual | ~MSWindowsKeyState () |
manipulators | |
void | disable () |
Handle screen disabling. | |
void | setKeyLayout (HKL keyLayout) |
Set the active keyboard layout. | |
bool | testAutoRepeat (bool press, bool isRepeat, KeyButton) |
Test and set autorepeat state. | |
void | saveModifiers () |
Remember modifier state. | |
void | useSavedModifiers (bool enable) |
Set effective modifier state. | |
Public Member Functions inherited from KeyState | |
KeyState (IEventQueue *events, std::vector< std::string > layouts, bool isLangSyncEnabled) | |
KeyState (IEventQueue *events, deskflow::KeyMap &keyMap, std::vector< std::string > layouts, bool isLangSyncEnabled) | |
~KeyState () override | |
void | updateKeyMap (deskflow::KeyMap *existing) |
void | updateKeyMap () override |
Update the keyboard map. | |
void | updateKeyState () override |
Update the key state. | |
void | setHalfDuplexMask (KeyModifierMask) override |
Set half-duplex mask. | |
bool | fakeKeyUp (KeyButton button) override |
Fake a key release. | |
void | fakeAllKeysUp () override |
Fake key releases for all fake pressed keys. | |
bool | fakeMediaKey (KeyID id) override |
Fake a media key. | |
bool | isKeyDown (KeyButton) const override |
Test if key is pressed. | |
KeyModifierMask | getActiveModifiers () const override |
Get the active modifiers. | |
int32_t | getKeyState (KeyButton keyButton) const |
Public Member Functions inherited from IKeyState | |
IKeyState (const IEventQueue *events) | |
Public Member Functions inherited from IInterface | |
virtual | ~IInterface ()=default |
Interface destructor does nothing. |
accessors | |
KeyButton | virtualKeyToButton (UINT virtualKey) const |
Map a virtual key to a button. | |
KeyID | mapKeyFromEvent (WPARAM charAndVirtKey, LPARAM info, KeyModifierMask *maskOut) const |
Map key event to a key. | |
bool | didGroupsChange () const |
Check if keyboard groups have changed. | |
UINT | mapKeyToVirtualKey (KeyID key) const |
Map key to virtual key. | |
KeyID | getKeyID (UINT virtualKey, KeyButton button) const |
Map virtual key and button to KeyID. | |
UINT | mapButtonToVirtualKey (KeyButton button) const |
Map button to virtual key. | |
void | fakeKeyDown (KeyID id, KeyModifierMask mask, KeyButton button, const std::string &lang) override |
Fake a key press. | |
bool | fakeKeyRepeat (KeyID id, KeyModifierMask mask, int32_t count, KeyButton button, const std::string &lang) override |
Fake a key repeat. | |
bool | fakeCtrlAltDel () override |
Fake ctrl+alt+del. | |
KeyModifierMask | pollActiveModifiers () const override |
Get the active modifiers from OS. | |
int32_t | pollActiveGroup () const override |
Get the active keyboard layout from OS. | |
void | pollPressedKeys (KeyButtonSet &pressedKeys) const override |
Get the keys currently pressed from OS. | |
void | onKey (KeyButton button, bool down, KeyModifierMask newState) override |
Handle key event. | |
void | sendKeyEvent (void *target, bool press, bool isAutoRepeat, KeyID key, KeyModifierMask mask, int32_t count, KeyButton button) override |
Post a key event. | |
KeyButton | getLastDown () const |
void | setLastDown (KeyButton value) |
KeyModifierMask | getSavedModifiers () const |
void | setSavedModifiers (KeyModifierMask value) |
void | getKeyMap (deskflow::KeyMap &keyMap) override |
Get the keyboard map. | |
void | fakeKey (const Keystroke &keystroke) override |
Fake a key event. | |
KeyModifierMask & | getActiveModifiersRValue () override |
Get the active modifiers. |
Additional Inherited Members | |
Public Types inherited from IKeyState | |
using | KeyButtonSet = std::set<KeyButton> |
Static Public Attributes inherited from IKeyState | |
static const auto | s_numButtons = 0x200 |
using | Keystroke = deskflow::KeyMap::Keystroke |
Protected Member Functions inherited from KeyState | |
int32_t | getEffectiveGroup (int32_t group, int32_t offset) const |
Compute a group number. | |
virtual bool | isIgnoredKey (KeyID key, KeyModifierMask mask) const |
Check if key is ignored. | |
KeyButton | getButton (KeyID id, int32_t group) const |
Get button for a KeyID. |
Microsoft Windows key mapper.
This class maps KeyIDs to keystrokes.
MSWindowsKeyState::MSWindowsKeyState | ( | MSWindowsDesks * | desks, |
void * | eventTarget, | ||
IEventQueue * | events, | ||
std::vector< std::string > | layouts, | ||
bool | isLangSyncEnabled ) |
MSWindowsKeyState::MSWindowsKeyState | ( | MSWindowsDesks * | desks, |
void * | eventTarget, | ||
IEventQueue * | events, | ||
deskflow::KeyMap & | keyMap, | ||
std::vector< std::string > | layouts, | ||
bool | isLangSyncEnabled ) |
|
virtual |
bool MSWindowsKeyState::didGroupsChange | ( | ) | const |
Check if keyboard groups have changed.
Returns true iff the number or order of the keyboard groups have changed since the last call to updateKeys().
void MSWindowsKeyState::disable | ( | ) |
Handle screen disabling.
Called when screen is disabled. This is needed to deal with platform brokenness.
|
overridevirtual |
Fake ctrl+alt+del.
Synthesize a press of ctrl+alt+del. Return true if processing is complete and false if normal key processing should continue.
Implements KeyState.
|
overrideprotectedvirtual |
|
overridevirtual |
Fake a key press.
Synthesizes a key press event and updates the key state.
Reimplemented from KeyState.
|
overridevirtual |
Fake a key repeat.
Synthesizes a key repeat event and updates the key state.
Reimplemented from KeyState.
|
overrideprotectedvirtual |
Get the active modifiers.
Returns the modifiers that are currently active according to our shadowed state. The state may be modified.
Reimplemented from KeyState.
|
overrideprotectedvirtual |
|
inline |
|
inline |
UINT MSWindowsKeyState::mapButtonToVirtualKey | ( | KeyButton | button | ) | const |
Map button to virtual key.
Returns the virtual key for button button
(button should include the extended key bit), or kKeyNone if there is no such key.
KeyID MSWindowsKeyState::mapKeyFromEvent | ( | WPARAM | charAndVirtKey, |
LPARAM | info, | ||
KeyModifierMask * | maskOut ) const |
Map key event to a key.
Converts a key event into a KeyID and the shadow modifier state to a modifier mask.
UINT MSWindowsKeyState::mapKeyToVirtualKey | ( | KeyID | key | ) | const |
Map key to virtual key.
Returns the virtual key for key key
or 0 if there's no such virtual key.
|
overridevirtual |
Handle key event.
Sets the state of button
to down or up and updates the current modifier state to newState
. This method should be called by primary screens only in response to local events. For auto-repeat set down
to true
. Overrides must forward to the superclass.
Reimplemented from KeyState.
|
overridevirtual |
Get the active keyboard layout from OS.
Returns the active keyboard layout according to the operating system.
Implements KeyState.
|
overridevirtual |
Get the active modifiers from OS.
Returns the modifiers that are currently active according to the operating system.
Implements KeyState.
|
overridevirtual |
Get the keys currently pressed from OS.
Adds any keys that are currently pressed according to the operating system to pressedKeys
.
Implements KeyState.
void MSWindowsKeyState::saveModifiers | ( | ) |
Remember modifier state.
Records the current non-toggle modifier state.
|
overridevirtual |
Post a key event.
Posts a key event. This may adjust the event or post additional events in some circumstances. If this is overridden it must forward to the superclass.
Reimplemented from KeyState.
void MSWindowsKeyState::setKeyLayout | ( | HKL | keyLayout | ) |
Set the active keyboard layout.
Uses keyLayout
when querying the keyboard.
|
inline |
|
inline |
bool MSWindowsKeyState::testAutoRepeat | ( | bool | press, |
bool | isRepeat, | ||
KeyButton | button ) |
Test and set autorepeat state.
Returns true if the given button is autorepeating and updates internal state.
void MSWindowsKeyState::useSavedModifiers | ( | bool | enable | ) |
Set effective modifier state.
Temporarily sets the non-toggle modifier state to those saved by the last call to saveModifiers
if enable
is true
. Restores the modifier state to the current modifier state if enable
is false
. This is for synthesizing keystrokes on the primary screen when the cursor is on a secondary screen. When on a secondary screen we capture all non-toggle modifier state, track the state internally and do not pass it on. So if Alt+F1 synthesizes Alt+X we need to synthesize not just X but also Alt, despite the fact that our internal modifier state indicates Alt is down, because local apps never saw the Alt down event.
KeyButton MSWindowsKeyState::virtualKeyToButton | ( | UINT | virtualKey | ) | const |
Map a virtual key to a button.
Returns the button for the virtualKey
.