Microsoft Windows key mapper. More...
#include <CMSWindowsKeyState.h>
Inherits CKeyState.
Public Member Functions | |
| CMSWindowsKeyState (CMSWindowsDesks *desks, void *eventTarget) | |
| CMSWindowsKeyState (CMSWindowsDesks *desks, void *eventTarget, IEventQueue &eventQueue, CKeyMap &keyMap) | |
| virtual void | fakeKeyDown (KeyID id, KeyModifierMask mask, KeyButton button) |
| Fake a key press. | |
| virtual bool | fakeKeyRepeat (KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button) |
| Fake a key repeat. | |
| virtual bool | fakeCtrlAltDel () |
| Fake ctrl+alt+del. | |
| virtual KeyModifierMask | pollActiveModifiers () const |
| Get the active modifiers from OS. | |
| virtual SInt32 | pollActiveGroup () const |
| Get the active keyboard layout from OS. | |
| virtual void | pollPressedKeys (KeyButtonSet &pressedKeys) const |
| Get the keys currently pressed from OS. | |
| 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, SInt32 count, KeyButton button) |
| Post a key event. | |
| KeyButton | getLastDown () const |
| void | setLastDown (KeyButton value) |
| KeyModifierMask | getSavedModifiers () const |
| void | setSavedModifiers (KeyModifierMask value) |
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. | |
Protected Member Functions | |
| virtual void | getKeyMap (CKeyMap &keyMap) |
| Get the keyboard map. | |
| virtual void | fakeKey (const Keystroke &keystroke) |
| Fake a key event. | |
| virtual KeyModifierMask & | getActiveModifiersRValue () |
| Get the active modifiers. | |
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. | |
| static KeyID | getKeyID (UINT virtualKey, KeyButton button) |
| Map virtual key and button to KeyID. | |
Microsoft Windows key mapper.
This class maps KeyIDs to keystrokes.
Definition at line 37 of file CMSWindowsKeyState.h.
| bool CMSWindowsKeyState::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().
Definition at line 738 of file CMSWindowsKeyState.cpp.
| void CMSWindowsKeyState::disable | ( | ) |
Handle screen disabling.
Called when screen is disabled. This is needed to deal with platform brokenness.
Definition at line 625 of file CMSWindowsKeyState.cpp.
References IEventQueue::deleteTimer(), CEvent::kTimer, and IEventQueue::removeHandler().
Referenced by CMSWindowsScreen::disable().
| bool CMSWindowsKeyState::fakeCtrlAltDel | ( | ) | [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 CKeyState.
Definition at line 809 of file CMSWindowsKeyState.cpp.
References fakeKeyDown(), virtualKeyToButton(), and CThread::wait().
| void CMSWindowsKeyState::fakeKey | ( | const Keystroke & | keystroke | ) | [protected, virtual] |
Fake a key event.
Synthesize an event for keystroke.
Implements CKeyState.
Definition at line 1244 of file CMSWindowsKeyState.cpp.
References CMSWindowsDesks::fakeKeyEvent(), CKeyState::getActiveModifiers(), CKeyState::getEffectiveGroup(), CKeyMap::Keystroke::kButton, CKeyMap::Keystroke::kGroup, and pollActiveGroup().
| void CMSWindowsKeyState::fakeKeyDown | ( | KeyID | id, | |
| KeyModifierMask | mask, | |||
| KeyButton | button | |||
| ) | [virtual] |
Fake a key press.
Synthesizes a key press event and updates the key state.
Reimplemented from CKeyState.
Definition at line 795 of file CMSWindowsKeyState.cpp.
Referenced by fakeCtrlAltDel().
| bool CMSWindowsKeyState::fakeKeyRepeat | ( | KeyID | id, | |
| KeyModifierMask | mask, | |||
| SInt32 | count, | |||
| KeyButton | button | |||
| ) | [virtual] |
Fake a key repeat.
Synthesizes a key repeat event and updates the key state.
Reimplemented from CKeyState.
Definition at line 802 of file CMSWindowsKeyState.cpp.
| KeyModifierMask & CMSWindowsKeyState::getActiveModifiersRValue | ( | ) | [protected, virtual] |
Get the active modifiers.
Returns the modifiers that are currently active according to our shadowed state. The state may be modified.
Reimplemented from CKeyState.
Definition at line 1300 of file CMSWindowsKeyState.cpp.
Referenced by useSavedModifiers().
| KeyID CMSWindowsKeyState::getKeyID | ( | UINT | virtualKey, | |
| KeyButton | button | |||
| ) | [static] |
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.
Definition at line 1424 of file CMSWindowsKeyState.cpp.
Referenced by getKeyMap(), and mapKeyFromEvent().
| void CMSWindowsKeyState::getKeyMap | ( | CKeyMap & | keyMap | ) | [protected, virtual] |
Get the keyboard map.
Fills keyMap with the current keyboard map.
Implements CKeyState.
Definition at line 927 of file CMSWindowsKeyState.cpp.
References getKeyID(), CKeyMap::initModifierKey(), CKeyMap::KeyItem::m_button, CKeyMap::KeyItem::m_client, CKeyMap::KeyItem::m_generates, CKeyMap::KeyItem::m_group, CKeyMap::KeyItem::m_id, CKeyMap::KeyItem::m_required, and CKeyMap::KeyItem::m_sensitive.
| KeyID CMSWindowsKeyState::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.
Definition at line 684 of file CMSWindowsKeyState.cpp.
References CKeyState::getActiveModifiers(), and getKeyID().
| UINT CMSWindowsKeyState::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.
Definition at line 745 of file CMSWindowsKeyState.cpp.
| void CMSWindowsKeyState::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 from CKeyState.
Definition at line 760 of file CMSWindowsKeyState.cpp.
| SInt32 CMSWindowsKeyState::pollActiveGroup | ( | ) | const [virtual] |
Get the active keyboard layout from OS.
Returns the active keyboard layout according to the operating system.
Implements CKeyState.
Definition at line 884 of file CMSWindowsKeyState.cpp.
Referenced by fakeKey().
| KeyModifierMask CMSWindowsKeyState::pollActiveModifiers | ( | ) | const [virtual] |
Get the active modifiers from OS.
Returns the modifiers that are currently active according to the operating system.
Implements CKeyState.
Definition at line 857 of file CMSWindowsKeyState.cpp.
References CKeyState::isKeyDown(), and virtualKeyToButton().
| void CMSWindowsKeyState::pollPressedKeys | ( | KeyButtonSet & | pressedKeys | ) | const [virtual] |
Get the keys currently pressed from OS.
Adds any keys that are currently pressed according to the operating system to pressedKeys.
Implements CKeyState.
Definition at line 912 of file CMSWindowsKeyState.cpp.
| void CMSWindowsKeyState::saveModifiers | ( | ) |
Remember modifier state.
Records the current non-toggle modifier state.
Definition at line 663 of file CMSWindowsKeyState.cpp.
References CKeyState::getActiveModifiers().
Referenced by CMSWindowsScreen::leave().
| void CMSWindowsKeyState::sendKeyEvent | ( | void * | target, | |
| bool | press, | |||
| bool | isAutoRepeat, | |||
| KeyID | key, | |||
| KeyModifierMask | mask, | |||
| SInt32 | 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 from CKeyState.
Definition at line 769 of file CMSWindowsKeyState.cpp.
| void CMSWindowsKeyState::setKeyLayout | ( | HKL | keyLayout | ) |
Set the active keyboard layout.
Uses keyLayout when querying the keyboard.
Definition at line 642 of file CMSWindowsKeyState.cpp.
Referenced by CMSWindowsScreen::leave().
| bool CMSWindowsKeyState::testAutoRepeat | ( | bool | press, | |
| bool | isRepeat, | |||
| KeyButton | button | |||
| ) |
Test and set autorepeat state.
Returns true if the given button is autorepeating and updates internal state.
Definition at line 648 of file CMSWindowsKeyState.cpp.
| void CMSWindowsKeyState::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.
Definition at line 670 of file CMSWindowsKeyState.cpp.
References CKeyState::getActiveModifiers(), and getActiveModifiersRValue().
| KeyButton CMSWindowsKeyState::virtualKeyToButton | ( | UINT | virtualKey | ) | const |
Map a virtual key to a button.
Returns the button for the virtualKey.
Definition at line 636 of file CMSWindowsKeyState.cpp.
Referenced by fakeCtrlAltDel(), and pollActiveModifiers().
1.7.1