MCPcopy Create free account
hub / github.com/KangLin/RabbitRemoteControl / KeyEvent

Method KeyEvent

Service/InputDeviceXLib.cpp:71–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69#endif
70
71int CInputDeviceXLib::KeyEvent(quint32 keysym, quint32 xtcode, bool down)
72{
73 int nRet = 0;
74
75 int keycode = 0;
76
77#ifdef HAVE_XTEST
78 Display *display = XOpenDisplay(NULL);
79 do {
80 // Use scan code if provided and mapping exists
81 if (codeMap && rawKeyboard && xtcode < codeMapLen)
82 keycode = codeMap[xtcode];
83
84 if (!keycode) {
85 if (pressedKeys.find(keysym) != pressedKeys.end())
86 keycode = pressedKeys[keysym];
87 else {
88 // XKeysymToKeycode() doesn't respect state, so we have to use
89 // something slightly more complex
90 keycode = XkbKeysymToKeycode(display, keysym);
91 }
92 }
93
94 if (!keycode) {
95 qCritical(LogInput) << "Could not map key event to X11 key code";
96 nRet = -2;
97 break;
98 }
99
100 if (down)
101 pressedKeys[keysym] = keycode;
102 else
103 pressedKeys.erase(keysym);
104
105 qDebug(LogInput, "%d %s", keycode, down ? "down" : "up");
106
107 XTestFakeKeyEvent(display, keycode, down, CurrentTime);
108 } while(0);
109 XCloseDisplay(display);
110#endif
111
112 return 0;
113}
114
115// Simulate mouse click
116void click(Display *display, int button, bool press)

Callers 2

keyEventMethod · 0.45
keyEventMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected