void ButtonEditDialog::keyReleaseEvent(QKeyEvent *event) { if (ui->actionNameLineEdit->hasFocus() || ui->buttonNameLineEdit->hasFocus()) { QDialog::keyReleaseEvent(event); } else if (ui->virtualKeyMouseTabWidget->isKeyboardTabVisible()) { int controlcode = event->nativeScanCode(); int virtualactual = event->nativeVirtualKey(); #ifdef Q_OS_WIN // Find more specific virtual key (VK_SHIFT -> VK_LSHIFT) // by checking for extended bit in scan code. int finalvirtual = WinInfo::correctVirtualKey(controlcode, virtualactual); int checkalias = AntKeyMapper::returnQtKey(virtualactual, controlcode); #else #if defined(WITH_X11) int finalvirtual = 0; int checkalias = 0; #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) if (QApplication::platformName() == QStringLiteral("xcb")) { #endif // Obtain group 1 X11 keysym. Removes effects from modifiers. finalvirtual = X11KeyCodeToX11KeySym(controlcode); #ifdef WITH_UINPUT // Find Qt Key corresponding to X11 KeySym. checkalias = x11KeyMapper.returnQtKey(finalvirtual); // Find corresponding Linux input key for the Qt key. finalvirtual = AntKeyMapper::returnVirtualKey(checkalias); #else // Check for alias against group 1 keysym. checkalias = AntKeyMapper::returnQtKey(finalvirtual); #endif #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) } else { // Not running on xcb platform. finalvirtual = controlcode; checkalias = AntKeyMapper::returnQtKey(finalvirtual); } #endif #else int finalvirtual = 0; int checkalias = 0; #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) if (QApplication::platformName() == QStringLiteral("xcb")) { #endif finalvirtual = AntKeyMapper::returnVirtualKey(event->key()); checkalias = AntKeyMapper::returnQtKey(finalvirtual); #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) } else { // Not running on xcb platform. finalvirtual = controlcode; checkalias = AntKeyMapper::returnQtKey(finalvirtual); } #endif #endif #endif if (!ignoreRelease) { if ((event->modifiers() & Qt::ControlModifier) && event->key() == Qt::Key_X) { controlcode = 0; ignoreRelease = true; emit selectionCleared(); } else if (controlcode <= 0) { controlcode = 0; } } else { controlcode = 0; ignoreRelease = false; } if (controlcode > 0) { if (checkalias > 0) { JoyButtonSlot *tempslot = new JoyButtonSlot(finalvirtual, checkalias, JoyButtonSlot::JoyKeyboard, this); emit keyGrabbed(tempslot); } else { JoyButtonSlot *tempslot = new JoyButtonSlot(virtualactual, JoyButtonSlot::JoyKeyboard, this); emit keyGrabbed(tempslot); } } } else { QDialog::keyReleaseEvent(event); } }
void ButtonEditDialog::keyReleaseEvent(QKeyEvent *event) { if (ui->actionNameLineEdit->hasFocus() || ui->buttonNameLineEdit->hasFocus()) { QDialog::keyReleaseEvent(event); } else if (ui->virtualKeyMouseTabWidget->isKeyboardTabVisible()) { int controlcode = event->nativeScanCode(); int virtualactual = event->nativeVirtualKey(); int checkalias = AntKeyMapper::returnQtKey(virtualactual); if (checkalias <= 0) { controlcode = 0; } #ifndef Q_OS_WIN Q_UNUSED(virtualactual); #endif #ifdef Q_OS_WIN int finalvirtual = WinInfo::correctVirtualKey(controlcode, virtualactual); #endif if (!ignoreRelease) { if ((event->modifiers() & Qt::ControlModifier) && event->key() == Qt::Key_X) { controlcode = 0; ignoreRelease = true; emit selectionCleared(); } else if (controlcode < 0) { controlcode = 0; } } else { controlcode = 0; ignoreRelease = false; } if (controlcode > 0) { #if defined (Q_OS_UNIX) JoyButtonSlot *tempslot = new JoyButtonSlot(virtualactual, JoyButtonSlot::JoyKeyboard, this); #elif defined (Q_OS_WIN) JoyButtonSlot *tempslot = new JoyButtonSlot(finalvirtual, JoyButtonSlot::JoyKeyboard, this); #endif emit keyGrabbed(tempslot); } } else { QDialog::keyReleaseEvent(event); } }