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

OS X key state. More...

#include <OSXKeyState.h>

Inheritance diagram for OSXKeyState:
Collaboration diagram for OSXKeyState:

Public Types

using KeyIDs = std::vector<KeyID>
Public Types inherited from IKeyState
using KeyButtonSet = std::set<KeyButton>

Public Member Functions

 OSXKeyState (IEventQueue *events, std::vector< std::string > layouts, bool isLangSyncEnabled)
 OSXKeyState (IEventQueue *events, deskflow::KeyMap &keyMap, std::vector< std::string > layouts, bool isLangSyncEnabled)
 ~OSXKeyState () override=default
modifiers
void handleModifierKeys (void *target, KeyModifierMask oldMask, KeyModifierMask newMask)
 Handle modifier key change.
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
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.
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 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

KeyModifierMask mapModifiersFromOSX (uint32_t mask) const
 Convert OS X modifier mask to deskflow mask.
KeyModifierMask mapModifiersToCarbon (uint32_t mask) const
 Convert CG flags-style modifier mask to old-style Carbon.
KeyButton mapKeyFromEvent (KeyIDs &ids, KeyModifierMask *maskOut, CGEventRef event) const
 Map key event to keys.
bool mapDeskflowHotKeyToMac (KeyID key, KeyModifierMask mask, uint32_t &macVirtualKey, uint32_t &macModifierMask) const
 Map key and mask to native values.
bool fakeCtrlAltDel () override
 Fake ctrl+alt+del.
bool fakeMediaKey (KeyID id) override
 Fake a media key.
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.
CGEventFlags getModifierStateAsOSXFlags () const
void getKeyMap (deskflow::KeyMap &keyMap) override
 Get the keyboard map.
void fakeKey (const Keystroke &keystroke) override
 Fake a key event.

Additional Inherited Members

Static Public Attributes inherited from IKeyState
static const auto s_numButtons = 0x200
using Keystroke = deskflow::KeyMap::Keystroke
Protected Member Functions inherited from KeyState
virtual KeyModifierMaskgetActiveModifiersRValue ()
 Get the active modifiers.
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

OS X key state.

A key state for OS X.

Member Typedef Documentation

◆ KeyIDs

using OSXKeyState::KeyIDs = std::vector<KeyID>

Constructor & Destructor Documentation

◆ OSXKeyState() [1/2]

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

◆ OSXKeyState() [2/2]

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

◆ ~OSXKeyState()

OSXKeyState::~OSXKeyState ( )
overridedefault

Member Function Documentation

◆ fakeCtrlAltDel()

bool OSXKeyState::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 OSXKeyState::fakeKey ( const Keystroke & keystroke)
overrideprotectedvirtual

Fake a key event.

Synthesize an event for keystroke.

Implements KeyState.

◆ fakeMediaKey()

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

Reimplemented from KeyState.

◆ getKeyMap()

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

Get the keyboard map.

Fills keyMap with the current keyboard map.

Implements KeyState.

◆ getModifierStateAsOSXFlags()

CGEventFlags OSXKeyState::getModifierStateAsOSXFlags ( ) const

◆ handleModifierKeys()

void OSXKeyState::handleModifierKeys ( void * target,
KeyModifierMask oldMask,
KeyModifierMask newMask )

Handle modifier key change.

Determines which modifier keys have changed and updates the modifier state and sends key events as appropriate.

◆ mapDeskflowHotKeyToMac()

bool OSXKeyState::mapDeskflowHotKeyToMac ( KeyID key,
KeyModifierMask mask,
uint32_t & macVirtualKey,
uint32_t & macModifierMask ) const

Map key and mask to native values.

Calculates mac virtual key and mask for a key key and modifiers mask. Returns true if the key can be mapped, false otherwise.

◆ mapKeyFromEvent()

KeyButton OSXKeyState::mapKeyFromEvent ( KeyIDs & ids,
KeyModifierMask * maskOut,
CGEventRef event ) const

Map key event to keys.

Converts a key event into a sequence of KeyIDs and the shadow modifier state to a modifier mask. The KeyIDs list, in order, the characters generated by the key press/release. It returns the id of the button that was pressed or released, or 0 if the button doesn't map to a known KeyID.

◆ mapModifiersFromOSX()

KeyModifierMask OSXKeyState::mapModifiersFromOSX ( uint32_t mask) const

Convert OS X modifier mask to deskflow mask.

Returns the deskflow modifier mask corresponding to the OS X modifier mask in mask.

◆ mapModifiersToCarbon()

KeyModifierMask OSXKeyState::mapModifiersToCarbon ( uint32_t mask) const

Convert CG flags-style modifier mask to old-style Carbon.

Still required in a few places for translation calls.

◆ pollActiveGroup()

int32_t OSXKeyState::pollActiveGroup ( ) const
overridevirtual

Get the active keyboard layout from OS.

Returns the active keyboard layout according to the operating system.

Implements KeyState.

◆ pollActiveModifiers()

KeyModifierMask OSXKeyState::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 OSXKeyState::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.


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