| 643 | } |
| 644 | |
| 645 | QString keycodeToKeyString(int keycode, int alias) |
| 646 | { |
| 647 | QString newkey = QString(); |
| 648 | |
| 649 | Q_UNUSED(alias) |
| 650 | |
| 651 | #if defined(Q_OS_UNIX) |
| 652 | Q_UNUSED(alias); |
| 653 | |
| 654 | if (keycode <= 0) |
| 655 | { |
| 656 | newkey = "[NO KEY]"; |
| 657 | } else |
| 658 | { |
| 659 | BaseEventHandler *handler = EventHandlerFactory::getInstance()->handler(); |
| 660 | |
| 661 | #ifdef WITH_XTEST |
| 662 | if (handler->getIdentifier() == "xtest") |
| 663 | { |
| 664 | Display *display = X11Extras::getInstance()->display(); |
| 665 | newkey = QString("0x%1").arg(keycode, 0, 16); |
| 666 | QString tempkey = XKeysymToString(XkbKeycodeToKeysym(display, static_cast<KeyCode>(keycode), 0, 0)); |
| 667 | QString tempalias = X11Extras::getInstance()->getDisplayString(tempkey); |
| 668 | |
| 669 | if (!tempalias.isEmpty()) |
| 670 | { |
| 671 | newkey = tempalias; |
| 672 | } else |
| 673 | { |
| 674 | XKeyPressedEvent tempevent; |
| 675 | tempevent.keycode = keycode; |
| 676 | tempevent.type = KeyPress; |
| 677 | tempevent.display = display; |
| 678 | tempevent.state = 0; |
| 679 | |
| 680 | char tempstring[256]; |
| 681 | memset(tempstring, 0, sizeof(tempstring)); |
| 682 | int bitestoreturn = sizeof(tempstring) - 1; |
| 683 | int numchars = XLookupString(&tempevent, tempstring, bitestoreturn, nullptr, nullptr); |
| 684 | |
| 685 | if (numchars > 0) |
| 686 | { |
| 687 | tempstring[numchars] = '\0'; |
| 688 | newkey = QString::fromUtf8(tempstring); |
| 689 | |
| 690 | qDebug() << "NEWKEY:" << newkey; |
| 691 | qDebug() << "NEWKEY LEGNTH:" << numchars; |
| 692 | } else |
| 693 | { |
| 694 | newkey = tempkey; |
| 695 | } |
| 696 | } |
| 697 | } |
| 698 | #endif |
| 699 | |
| 700 | #ifdef WITH_UINPUT |
| 701 | if (handler->getIdentifier() == "uinput") |
| 702 | { |
no test coverage detected