Deskflow 1.22.0.197
Keyboard and mouse sharing utility
Loading...
Searching...
No Matches
MSWindowsKeyState Class Reference

Microsoft Windows key mapper. More...

#include <MSWindowsKeyState.h>

Inheritance diagram for MSWindowsKeyState:
Collaboration diagram for MSWindowsKeyState:

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.
KeyModifierMaskgetActiveModifiersRValue () 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.

Detailed Description

Microsoft Windows key mapper.

This class maps KeyIDs to keystrokes.

Constructor & Destructor Documentation

◆ MSWindowsKeyState() [1/2]

MSWindowsKeyState::MSWindowsKeyState ( MSWindowsDesks * desks,
void * eventTarget,
IEventQueue * events,
std::vector< std::string > layouts,
bool isLangSyncEnabled )

◆ MSWindowsKeyState() [2/2]

MSWindowsKeyState::MSWindowsKeyState ( MSWindowsDesks * desks,
void * eventTarget,
IEventQueue * events,
deskflow::KeyMap & keyMap,
std::vector< std::string > layouts,
bool isLangSyncEnabled )

◆ ~MSWindowsKeyState()

MSWindowsKeyState::~MSWindowsKeyState ( )
virtual

Member Function Documentation

◆ didGroupsChange()

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().

◆ disable()

void MSWindowsKeyState::disable ( )

Handle screen disabling.

Called when screen is disabled. This is needed to deal with platform brokenness.

◆ fakeCtrlAltDel()

bool MSWindowsKeyState::fakeCtrlAltDel ( )
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.

◆ fakeKey()

void MSWindowsKeyState::fakeKey ( const Keystroke & keystroke)
overrideprotectedvirtual

Fake a key event.

Synthesize an event for keystroke.

Implements KeyState.

◆ fakeKeyDown()

void MSWindowsKeyState::fakeKeyDown ( KeyID id,
KeyModifierMask mask,
KeyButton button,
const std::string & lang )
overridevirtual

Fake a key press.

Synthesizes a key press event and updates the key state.

Reimplemented from KeyState.

◆ fakeKeyRepeat()

bool MSWindowsKeyState::fakeKeyRepeat ( KeyID id,
KeyModifierMask mask,
int32_t count,
KeyButton button,
const std::string & lang )
overridevirtual

Fake a key repeat.

Synthesizes a key repeat event and updates the key state.

Reimplemented from KeyState.

◆ getActiveModifiersRValue()

KeyModifierMask & MSWindowsKeyState::getActiveModifiersRValue ( )
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.

◆ getKeyID()

KeyID MSWindowsKeyState::getKeyID ( UINT virtualKey,
KeyButton button ) const

Map virtual key and button to KeyID.

Returns the KeyID for virtual key virtualKey and button button (button should include the extended key bit), or kKeyNone if there is no such key.

◆ getKeyMap()

void MSWindowsKeyState::getKeyMap ( deskflow::KeyMap & keyMap)
overrideprotectedvirtual

Get the keyboard map.

Fills keyMap with the current keyboard map.

Implements KeyState.

◆ getLastDown()

KeyButton MSWindowsKeyState::getLastDown ( ) const
inline

◆ getSavedModifiers()

KeyModifierMask MSWindowsKeyState::getSavedModifiers ( ) const
inline

◆ mapButtonToVirtualKey()

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.

◆ mapKeyFromEvent()

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.

◆ mapKeyToVirtualKey()

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.

◆ onKey()

void MSWindowsKeyState::onKey ( KeyButton button,
bool down,
KeyModifierMask newState )
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.

◆ pollActiveGroup()

int32_t MSWindowsKeyState::pollActiveGroup ( ) const
overridevirtual

Get the active keyboard layout from OS.

Returns the active keyboard layout according to the operating system.

Implements KeyState.

◆ pollActiveModifiers()

KeyModifierMask MSWindowsKeyState::pollActiveModifiers ( ) const
overridevirtual

Get the active modifiers from OS.

Returns the modifiers that are currently active according to the operating system.

Implements KeyState.

◆ pollPressedKeys()

void MSWindowsKeyState::pollPressedKeys ( KeyButtonSet & pressedKeys) const
overridevirtual

Get the keys currently pressed from OS.

Adds any keys that are currently pressed according to the operating system to pressedKeys.

Implements KeyState.

◆ saveModifiers()

void MSWindowsKeyState::saveModifiers ( )

Remember modifier state.

Records the current non-toggle modifier state.

◆ sendKeyEvent()

void MSWindowsKeyState::sendKeyEvent ( void * target,
bool press,
bool isAutoRepeat,
KeyID key,
KeyModifierMask mask,
int32_t count,
KeyButton button )
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.

◆ setKeyLayout()

void MSWindowsKeyState::setKeyLayout ( HKL keyLayout)

Set the active keyboard layout.

Uses keyLayout when querying the keyboard.

◆ setLastDown()

void MSWindowsKeyState::setLastDown ( KeyButton value)
inline

◆ setSavedModifiers()

void MSWindowsKeyState::setSavedModifiers ( KeyModifierMask value)
inline

◆ testAutoRepeat()

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.

◆ useSavedModifiers()

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.

◆ virtualKeyToButton()

KeyButton MSWindowsKeyState::virtualKeyToButton ( UINT virtualKey) const

Map a virtual key to a button.

Returns the button for the virtualKey.


The documentation for this class was generated from the following files: