void QOpenKODEWindow::processKeyEvents(const KDEvent *event) { #ifdef KD_ATX_keyboard //KD_KEY_PRESS_ATX 1 QEvent::Type keyPressed = QEvent::KeyRelease; if (event->data.keyboardInputKey.flags) keyPressed = QEvent::KeyPress; //KD_KEY_LOCATION_LEFT_ATX // don't care for now //KD_KEY_LOCATION_RIGHT_ATX //KD_KEY_LOCATION_NUMPAD_ATX Qt::KeyboardModifiers mod = Qt::NoModifier; int openkodeMods = event->data.keyboardInputKey.flags; if (openkodeMods & KD_KEY_MODIFIER_SHIFT_ATX) mod |= Qt::ShiftModifier; if (openkodeMods & KD_KEY_MODIFIER_CTRL_ATX) mod |= Qt::ControlModifier; if (openkodeMods & KD_KEY_MODIFIER_ALT_ATX) mod |= Qt::AltModifier; if (openkodeMods & KD_KEY_MODIFIER_META_ATX) mod |= Qt::MetaModifier; Qt::Key qtKey; QChar keyText; int key = event->data.keyboardInputKey.keycode; if (key >= 0x20 && key <= 0x0ff){ // 8 bit printable Latin1 qtKey = Qt::Key(key); keyText = QChar(event->data.keyboardInputKeyChar.character); if (!(mod & Qt::ShiftModifier)) keyText = keyText.toLower(); } else { qtKey = keyTranslator(key); } QWindowSystemInterface::handleKeyEvent(0,event->timestamp,keyPressed,qtKey,mod,keyText); #endif }
void QQnxScreenEventHandler::injectKeyboardEvent(int flags, int sym, int modifiers, int scan, int cap) { Q_UNUSED(scan); Qt::KeyboardModifiers qtMod = Qt::NoModifier; if (modifiers & KEYMOD_SHIFT) qtMod |= Qt::ShiftModifier; if (modifiers & KEYMOD_CTRL) qtMod |= Qt::ControlModifier; if (modifiers & KEYMOD_ALT) qtMod |= Qt::AltModifier; // determine event type QEvent::Type type = (flags & KEY_DOWN) ? QEvent::KeyPress : QEvent::KeyRelease; // Check if the key cap is valid if (flags & KEY_CAP_VALID) { Qt::Key key; QString keyStr; if (cap >= 0x20 && cap <= 0x0ff) { key = Qt::Key(std::toupper(cap)); // Qt expects the CAP to be upper case. if ( qtMod & Qt::ControlModifier ) { keyStr = QChar((int)(key & 0x3f)); } else { if (flags & KEY_SYM_VALID) { keyStr = QChar(sym); } } } else if ((cap > 0x0ff && cap < UNICODE_PRIVATE_USE_AREA_FIRST) || cap > UNICODE_PRIVATE_USE_AREA_LAST) { key = (Qt::Key)cap; keyStr = QChar(sym); } else { if (isKeypadKey(cap)) qtMod |= Qt::KeypadModifier; // Is this right? key = keyTranslator(cap); } QWindowSystemInterface::handleExtendedKeyEvent(QGuiApplication::focusWindow(), type, key, qtMod, scan, sym, modifiers, keyStr); qScreenEventDebug() << Q_FUNC_INFO << "Qt key t=" << type << ", k=" << key << ", s=" << keyStr; } }
void QBBEventThread::handleKeyboardEvent(screen_event_t event) { // get flags of key event errno = 0; int flags; int result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_FLAGS, &flags); if (result) { qFatal("QBB: failed to query event flags, errno=%d", errno); } // get key code errno = 0; int sym; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_SYM, &sym); if (result) { qFatal("QBB: failed to query event sym, errno=%d", errno); } int modifiers; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_MODIFIERS, &modifiers); if (result) { qFatal("QBB: failed to query event modifiers, errno=%d", errno); } int scan; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_SCAN, &scan); if (result) { qFatal("QBB: failed to query event modifiers, errno=%d", errno); } int cap; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_CAP, &cap); if (result) { qFatal("QBB: failed to query event cap, errno=%d", errno); } Qt::KeyboardModifiers qtMod = Qt::NoModifier; if (modifiers & KEYMOD_SHIFT) qtMod |= Qt::ShiftModifier; if (modifiers & KEYMOD_CTRL) qtMod |= Qt::ControlModifier; if (modifiers & KEYMOD_ALT) qtMod |= Qt::AltModifier; // determine event type QEvent::Type type = (flags & KEY_DOWN) ? QEvent::KeyPress : QEvent::KeyRelease; // Check if the key cap is valid if (flags & KEY_CAP_VALID) { Qt::Key key; QChar keyStr; if (cap >= 0x20 && cap <= 0x0ff) { // 8 bit printable Latin1 key = Qt::Key(std::toupper(cap)); // Qt expects the CAP to be upper case. if (flags & KEY_SYM_VALID) { keyStr = QChar(sym); } } else { if (isKeypadKey(cap)) qtMod |= Qt::KeypadModifier; // Is this right? key = keyTranslator(cap); // Some special keys do have a string switch( key ) { case Qt::Key_Backspace: keyStr = QChar('\b'); break; case Qt::Key_Return: keyStr = QChar('\n'); break; default: // No special charcode break; } } QWindowSystemInterface::handleKeyEvent(QApplication::activeWindow(), type, key, qtMod, keyStr); #if defined(QBBEVENTTHREAD_DEBUG) qDebug() << "QBB: Qt key t=" << type << ", k=" << key << ", s=" << keyStr; #endif } }