MCPcopy Create free account
hub / github.com/AntiMicroX/antimicrox / X11KeySymToKeycode

Function X11KeySymToKeycode

src/event.cpp:594–643  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

592}
593
594int X11KeySymToKeycode(QString key)
595{
596 int tempcode = 0;
597
598#if defined(Q_OS_UNIX)
599 BaseEventHandler *handler = EventHandlerFactory::getInstance()->handler();
600 if (key.length() > 0)
601 {
602 #ifdef WITH_XTEST
603 if (handler->getIdentifier() == "xtest")
604 {
605 Display *display = X11Extras::getInstance()->display();
606 tempcode = XKeysymToKeycode(display, XStringToKeysym(key.toUtf8().data()));
607 }
608 #endif
609
610 #ifdef WITH_UINPUT
611 if (handler->getIdentifier() == "uinput")
612 {
613 tempcode = UInputHelper::getInstance()->getVirtualKey(key);
614 }
615 #endif
616 }
617#elif defined(Q_OS_WIN)
618 if (key.length() > 0)
619 {
620 tempcode = WinExtras::getVirtualKey(key);
621 if (tempcode <= 0 && key.length() == 1)
622 {
623 // qDebug() << "KEY: " << key;
624 // int oridnal = key.toUtf8().constData()[0];
625 int ordinal = QVariant(key.toUtf8().constData()[0]).toInt();
626 tempcode = VkKeyScan(ordinal);
627 int modifiers = tempcode >> 8;
628 tempcode = tempcode & 0xff;
629 if ((modifiers & 1) != 0)
630 tempcode |= VK_SHIFT;
631 if ((modifiers & 2) != 0)
632 tempcode |= VK_CONTROL;
633 if ((modifiers & 4) != 0)
634 tempcode |= VK_MENU;
635 // tempcode = VkKeyScan(QVariant(key.constData()).toInt());
636 // tempcode = OemKeyScan(key.toUtf8().toInt());
637 // tempcode = OemKeyScan(ordinal);
638 }
639 }
640
641#endif
642 return tempcode;
643}
644
645QString keycodeToKeyString(int keycode, int alias)
646{

Callers 2

VirtualKeyPushButtonMethod · 0.85
setDisplayStringMethod · 0.85

Calls 4

handlerMethod · 0.80
displayMethod · 0.80
getIdentifierMethod · 0.45
getVirtualKeyMethod · 0.45

Tested by

no test coverage detected