Deskflow 1.22.0.197
Keyboard and mouse sharing utility
Loading...
Searching...
No Matches
IKeyState.h
Go to the documentation of this file.
1/*
2 * Deskflow -- mouse and keyboard sharing utility
3 * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
4 * SPDX-FileCopyrightText: (C) 2003 Chris Schoeneman
5 * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
6 */
7
8#pragma once
9
10#include "base/Event.h"
11#include "base/EventTypes.h"
12#include "base/IEventQueue.h"
13#include "common/IInterface.h"
14#include "deskflow/KeyTypes.h"
15
16#include <set>
17
19
23class IKeyState : public IInterface
24{
25public:
26 explicit IKeyState(const IEventQueue *events);
27 inline static const auto s_numButtons = 0x200;
28
30 class KeyInfo
31 {
32 public:
33 static KeyInfo *alloc(KeyID, KeyModifierMask, KeyButton, int32_t count);
34 static KeyInfo *alloc(KeyID, KeyModifierMask, KeyButton, int32_t count, const std::set<std::string> &destinations);
35 static KeyInfo *alloc(const KeyInfo &);
36
37 static bool isDefault(const char *screens);
38 static bool contains(const char *screens, const std::string_view &name);
39 static bool equal(const KeyInfo *, const KeyInfo *);
40 static std::string join(const std::set<std::string> &destinations);
41 static void split(const char *screens, std::set<std::string> &);
42
43 public:
47 int32_t m_count;
48 char *m_screens;
50 };
51
52 using KeyButtonSet = std::set<KeyButton>;
53
55
56
58
62 virtual void updateKeyMap() = 0;
63
65
69 virtual void updateKeyState() = 0;
70
72
78
80
83 virtual void fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, const std::string &lang) = 0;
84
86
89 virtual bool
90 fakeKeyRepeat(KeyID id, KeyModifierMask mask, int32_t count, KeyButton button, const std::string &lang) = 0;
91
93
96 virtual bool fakeKeyUp(KeyButton button) = 0;
97
99
103 virtual void fakeAllKeysUp() = 0;
104
106
110 virtual bool fakeCtrlAltDel() = 0;
111
113
117 virtual bool fakeMediaKey(KeyID id) = 0;
118
120
122
124
128 virtual bool isKeyDown(KeyButton) const = 0;
129
131
136
138
143
145
148 virtual int32_t pollActiveGroup() const = 0;
149
151
155 virtual void pollPressedKeys(KeyButtonSet &pressedKeys) const = 0;
156
158};
static const struct sockaddr FAR * name
Definition ArchNetworkWinsock.cpp:27
uint32_t KeyID
Key ID.
Definition KeyTypes.h:22
uint16_t KeyButton
Key Code.
Definition KeyTypes.h:35
uint32_t KeyModifierMask
Modifier key mask.
Definition KeyTypes.h:45
Event queue interface.
Definition IEventQueue.h:32
Base class of interfaces.
Definition IInterface.h:18
Key event data.
Definition IKeyState.h:31
static void split(const char *screens, std::set< std::string > &)
Definition IKeyState.cpp:123
KeyModifierMask m_mask
Definition IKeyState.h:45
static std::string join(const std::set< std::string > &destinations)
Definition IKeyState.cpp:102
static bool equal(const KeyInfo *, const KeyInfo *)
Definition IKeyState.cpp:94
char * m_screens
Definition IKeyState.h:48
char m_screensBuffer[1]
Definition IKeyState.h:49
static bool contains(const char *screens, const std::string_view &name)
Definition IKeyState.cpp:75
KeyID m_key
Definition IKeyState.h:44
static bool isDefault(const char *screens)
Definition IKeyState.cpp:70
int32_t m_count
Definition IKeyState.h:47
static KeyInfo * alloc(KeyID, KeyModifierMask, KeyButton, int32_t count)
Definition IKeyState.cpp:27
KeyButton m_button
Definition IKeyState.h:46
std::set< KeyButton > KeyButtonSet
Definition IKeyState.h:52
virtual bool fakeKeyUp(KeyButton button)=0
Fake a key release.
virtual bool fakeKeyRepeat(KeyID id, KeyModifierMask mask, int32_t count, KeyButton button, const std::string &lang)=0
Fake a key repeat.
virtual void setHalfDuplexMask(KeyModifierMask)=0
Set half-duplex mask.
IKeyState(const IEventQueue *events)
Definition IKeyState.cpp:18
static const auto s_numButtons
Definition IKeyState.h:27
virtual void updateKeyMap()=0
Update the keyboard map.
virtual void fakeAllKeysUp()=0
Fake key releases for all fake pressed keys.
virtual KeyModifierMask pollActiveModifiers() const =0
Get the active modifiers from OS.
virtual void updateKeyState()=0
Update the key state.
virtual void fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, const std::string &lang)=0
Fake a key press.
virtual int32_t pollActiveGroup() const =0
Get the active keyboard layout from OS.
virtual bool isKeyDown(KeyButton) const =0
Test if key is pressed.
virtual bool fakeCtrlAltDel()=0
Fake ctrl+alt+del.
virtual void pollPressedKeys(KeyButtonSet &pressedKeys) const =0
Get the keys currently pressed from OS.
virtual bool fakeMediaKey(KeyID id)=0
Fake a media key.
virtual KeyModifierMask getActiveModifiers() const =0
Get the active modifiers.