MCPcopy Create free account
hub / github.com/WarmUpTill/SceneSwitcher / PressKeys

Function PressKeys

plugins/base/utils/linux/linux.cpp:191–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189};
190
191void PressKeys(const std::vector<HotkeyType> &keys, int duration)
192{
193 if (!canSimulateKeyPresses) {
194 return;
195 }
196
197 Display *display = disp();
198 if (!display) {
199 return;
200 }
201
202 // Press keys
203 for (auto &key : keys) {
204 auto it = keyTable.find(key);
205 if (it == keyTable.end()) {
206 continue;
207 }
208 pressFunc(display, XKeysymToKeycode(display, it->second), true,
209 CurrentTime);
210 }
211 XFlush(display);
212
213 std::this_thread::sleep_for(std::chrono::milliseconds(duration));
214
215 // Release keys
216 for (auto &key : keys) {
217 auto it = keyTable.find(key);
218 if (it == keyTable.end()) {
219 continue;
220 }
221 pressFunc(display, XKeysymToKeycode(display, it->second), false,
222 CurrentTime);
223 }
224
225 XFlush(display);
226}
227
228} // namespace advss

Callers 1

SendCustomHotkeyMethod · 0.50

Calls 3

findMethod · 0.80
dispFunction · 0.70
endMethod · 0.45

Tested by

no test coverage detected