Deskflow 1.22.0.197
Keyboard and mouse sharing utility
Loading...
Searching...
No Matches
KeyState Class Referenceabstract

Core key state. More...

#include <KeyState.h>

Inheritance diagram for KeyState:
Collaboration diagram for KeyState:

Classes

struct  AddActiveModifierContext

Public Member Functions

 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
manipulators
virtual void onKey (KeyButton button, bool down, KeyModifierMask newState)
 Handle key event.
virtual void sendKeyEvent (void *target, bool press, bool isAutoRepeat, KeyID key, KeyModifierMask mask, int32_t count, KeyButton button)
 Post a key event.
Public Member Functions inherited from IKeyState
 IKeyState (const IEventQueue *events)
Public Member Functions inherited from IInterface
virtual ~IInterface ()=default
 Interface destructor does nothing.

Protected Member Functions

protected manipulators
virtual void getKeyMap (deskflow::KeyMap &keyMap)=0
 Get the keyboard map.
virtual void fakeKey (const Keystroke &keystroke)=0
 Fake a key event.
virtual KeyModifierMaskgetActiveModifiersRValue ()
 Get the active modifiers.

accessors

using Keystroke = deskflow::KeyMap::Keystroke
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.
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 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.
bool fakeCtrlAltDel () override=0
 Fake ctrl+alt+del.
KeyModifierMask pollActiveModifiers () const override=0
 Get the active modifiers from OS.
int32_t pollActiveGroup () const override=0
 Get the active keyboard layout from OS.
void pollPressedKeys (KeyButtonSet &pressedKeys) const override=0
 Get the keys currently pressed from OS.
int32_t getKeyState (KeyButton keyButton) const

protected accessors

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.

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

Detailed Description

Core key state.

This class provides key state services. Subclasses must implement a few platform specific methods.

Member Typedef Documentation

◆ Keystroke

Constructor & Destructor Documentation

◆ KeyState() [1/2]

KeyState::KeyState ( IEventQueue * events,
std::vector< std::string > layouts,
bool isLangSyncEnabled )

◆ KeyState() [2/2]

KeyState::KeyState ( IEventQueue * events,
deskflow::KeyMap & keyMap,
std::vector< std::string > layouts,
bool isLangSyncEnabled )

◆ ~KeyState()

KeyState::~KeyState ( )
override

Member Function Documentation

◆ fakeAllKeysUp()

void KeyState::fakeAllKeysUp ( )
overridevirtual

Fake key releases for all fake pressed keys.

Synthesizes a key release event for every key that is synthetically pressed and updates the key state.

Implements IKeyState.

◆ fakeCtrlAltDel()

bool KeyState::fakeCtrlAltDel ( )
overridepure virtual

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 IKeyState.

Implemented in deskflow::EiKeyState, MSWindowsKeyState, OSXKeyState, and XWindowsKeyState.

◆ fakeKey()

virtual void KeyState::fakeKey ( const Keystroke & keystroke)
protectedpure virtual

Fake a key event.

Synthesize an event for keystroke.

Implemented in deskflow::EiKeyState, MSWindowsKeyState, OSXKeyState, and XWindowsKeyState.

◆ fakeKeyDown()

void KeyState::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.

Implements IKeyState.

Reimplemented in MSWindowsKeyState.

◆ fakeKeyRepeat()

bool KeyState::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.

Implements IKeyState.

Reimplemented in MSWindowsKeyState.

◆ fakeKeyUp()

bool KeyState::fakeKeyUp ( KeyButton button)
overridevirtual

Fake a key release.

Synthesizes a key release event and updates the key state.

Implements IKeyState.

◆ fakeMediaKey()

bool KeyState::fakeMediaKey ( KeyID id)
overridevirtual

Fake a media key.

Synthesizes a media key down and up. Only Mac would implement this by use cocoa appkit framework.

Implements IKeyState.

Reimplemented in OSXKeyState.

◆ getActiveModifiers()

KeyModifierMask KeyState::getActiveModifiers ( ) const
overridevirtual

Get the active modifiers.

Returns the modifiers that are currently active according to our shadowed state.

Implements IKeyState.

◆ getActiveModifiersRValue()

KeyModifierMask & KeyState::getActiveModifiersRValue ( )
protectedvirtual

Get the active modifiers.

Returns the modifiers that are currently active according to our shadowed state. The state may be modified.

Reimplemented in MSWindowsKeyState.

◆ getButton()

KeyButton KeyState::getButton ( KeyID id,
int32_t group ) const
protected

Get button for a KeyID.

Return the button mapped to key id in group group if any, otherwise returns 0.

◆ getEffectiveGroup()

int32_t KeyState::getEffectiveGroup ( int32_t group,
int32_t offset ) const
protected

Compute a group number.

Returns the number of the group offset groups after group group.

◆ getKeyMap()

virtual void KeyState::getKeyMap ( deskflow::KeyMap & keyMap)
protectedpure virtual

Get the keyboard map.

Fills keyMap with the current keyboard map.

Implemented in deskflow::EiKeyState, MSWindowsKeyState, OSXKeyState, and XWindowsKeyState.

◆ getKeyState()

int32_t KeyState::getKeyState ( KeyButton keyButton) const
inline

◆ isIgnoredKey()

bool KeyState::isIgnoredKey ( KeyID key,
KeyModifierMask mask ) const
protectedvirtual

Check if key is ignored.

Returns true if and only if the key should always be ignored. The default returns true only for the toggle keys.

◆ isKeyDown()

bool KeyState::isKeyDown ( KeyButton ) const
overridevirtual

Test if key is pressed.

Returns true iff the given key is down. Half-duplex toggles always return false.

Implements IKeyState.

◆ onKey()

void KeyState::onKey ( KeyButton button,
bool down,
KeyModifierMask newState )
virtual

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 in MSWindowsKeyState.

◆ pollActiveGroup()

int32_t KeyState::pollActiveGroup ( ) const
overridepure virtual

Get the active keyboard layout from OS.

Returns the active keyboard layout according to the operating system.

Implements IKeyState.

Implemented in deskflow::EiKeyState, MSWindowsKeyState, OSXKeyState, and XWindowsKeyState.

◆ pollActiveModifiers()

KeyModifierMask KeyState::pollActiveModifiers ( ) const
overridepure virtual

Get the active modifiers from OS.

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

Implements IKeyState.

Implemented in deskflow::EiKeyState, MSWindowsKeyState, OSXKeyState, and XWindowsKeyState.

◆ pollPressedKeys()

void KeyState::pollPressedKeys ( KeyButtonSet & pressedKeys) const
overridepure virtual

Get the keys currently pressed from OS.

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

Implements IKeyState.

Implemented in deskflow::EiKeyState, MSWindowsKeyState, OSXKeyState, and XWindowsKeyState.

◆ sendKeyEvent()

void KeyState::sendKeyEvent ( void * target,
bool press,
bool isAutoRepeat,
KeyID key,
KeyModifierMask mask,
int32_t count,
KeyButton button )
virtual

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 in MSWindowsKeyState.

◆ setHalfDuplexMask()

void KeyState::setHalfDuplexMask ( KeyModifierMask )
overridevirtual

Set half-duplex mask.

Sets which modifier toggle keys are half-duplex. A half-duplex toggle key doesn't report a key release when toggled on and doesn't report a key press when toggled off.

Implements IKeyState.

◆ updateKeyMap() [1/2]

void KeyState::updateKeyMap ( )
inlineoverridevirtual

Update the keyboard map.

Causes the key state to get updated to reflect the current keyboard mapping.

Implements IKeyState.

◆ updateKeyMap() [2/2]

void KeyState::updateKeyMap ( deskflow::KeyMap * existing)

◆ updateKeyState()

void KeyState::updateKeyState ( )
overridevirtual

Update the key state.

Causes the key state to get updated to reflect the physical keyboard state.

Implements IKeyState.


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