void GHOST_NDOFManager::updateButton(int button_number, bool press, GHOST_TUns64 time) { GHOST_IWindow *window = m_system.getWindowManager()->getActiveWindow(); #ifdef DEBUG_NDOF_BUTTONS printf("ndof: button %d -> ", button_number); #endif NDOF_ButtonT button = (button_number < m_buttonCount) ? m_hidMap[button_number] : NDOF_BUTTON_NONE; switch (button) { case NDOF_BUTTON_NONE: #ifdef DEBUG_NDOF_BUTTONS printf("discarded\n"); #endif break; case NDOF_BUTTON_ESC: sendKeyEvent(GHOST_kKeyEsc, press, time, window); break; case NDOF_BUTTON_ALT: sendKeyEvent(GHOST_kKeyLeftAlt, press, time, window); break; case NDOF_BUTTON_SHIFT: sendKeyEvent(GHOST_kKeyLeftShift, press, time, window); break; case NDOF_BUTTON_CTRL: sendKeyEvent(GHOST_kKeyLeftControl, press, time, window); break; default: sendButtonEvent(button, press, time, window); } int mask = 1 << button_number; if (press) { m_buttons |= mask; // set this button's bit } else { m_buttons &= ~mask; // clear this button's bit } }
void UserDesktopWidget::keyReleaseEvent(QKeyEvent* event) { if(event->key() != Qt::Key_Escape) UserImageWidget::keyReleaseEvent(event); quint32 keycode; #if defined(Q_OS_WIN32) keycode = event->nativeScanCode(); #elif defined(Q_OS_DARWIN) switch(event->key()) { case Qt::Key_Control : keycode = kVK_Command; break; case Qt::Key_Alt : keycode = kVK_Option; break; case Qt::Key_Shift : keycode = kVK_Shift; break; case Qt::Key_Meta : keycode = kVK_Control; break; default : keycode = event->nativeVirtualKey(); break; } #else keycode = event->nativeVirtualKey(); #endif sendKeyEvent(keycode, DESKTOPKEYSTATE_UP); }
// Fixed: not working void X11Util::forwardHotKey(int keycode) { XEvent xevent; xevent.xkey.type = KeyPress; xevent.xkey.keycode = keycode; xevent.xkey.state = ControlMask | Mod1Mask; sendKeyEvent(QX11Info::display(), xevent); }
void OSXKeyState::handleModifierKey(void* target, UInt32 virtualKey, KeyID id, bool down, KeyModifierMask newMask) { KeyButton button = mapVirtualKeyToKeyButton(virtualKey); onKey(button, down, newMask); sendKeyEvent(target, down, false, id, newMask, 0, button); }
void KeyRepeater::autoRepeat() { /* key release event */ #if 0 sendKeyEvent( m_unicode, m_keycode, m_modifiers, FALSE, TRUE); /* key press event */ sendKeyEvent( m_unicode, m_keycode, m_modifiers, TRUE, TRUE); #else emit keyEvent( m_unicode, m_keycode, m_modifiers, FALSE, TRUE); /* key press event */ emit keyEvent( m_unicode, m_keycode, m_modifiers, TRUE, TRUE); #endif /* start auto repeat */ m_pTimer->start(m_repeatperiod); #if 0 qDebug("autoRepeat[%x][%x][%x]", m_unicode, m_keycode, m_modifiers); #endif }
/*Wrapper createKeyEvent*/ void SendKeyEvent(Display *display, Window &win, Window &winRoot, int type, int keycode, int modifiers) { Status err=sendKeyEvent(display,win, winRoot,type, keycode,modifiers); if (err==BadValue) { fprintf(stderr,"error : programm %s ,function createKeyEvent(..) return BadValue\n",NameProgramm); exit (1); } if (err==BadWindow) { fprintf(stderr,"error : programm %s ,function createKeyEvent(..) return BadWindow\n",NameProgramm); exit (1); } XFlush(display);//forza l'effettiva scrittura degli eventuali dati presenti nel buffer,in questo caso il display }
QSoftKeyManager::QSoftKeyManager() : #ifdef Q_WS_S60 QObject(*(new QSoftKeyManagerPrivateS60), 0) #else QObject(*(new QSoftKeyManagerPrivate), 0) #endif { } QAction *QSoftKeyManager::createAction(StandardSoftKey standardKey, QWidget *actionWidget) { const char* text = standardSoftKeyText(standardKey); QAction *action = new QAction(QSoftKeyManager::tr(text), actionWidget); QAction::SoftKeyRole softKeyRole = QAction::NoSoftKey; switch (standardKey) { case MenuSoftKey: // FALL-THROUGH action->setProperty(MENU_ACTION_PROPERTY, QVariant(true)); // TODO: can be refactored away to use _q_action_menubar case OkSoftKey: case SelectSoftKey: case DoneSoftKey: softKeyRole = QAction::PositiveSoftKey; break; case CancelSoftKey: softKeyRole = QAction::NegativeSoftKey; break; } action->setSoftKeyRole(softKeyRole); return action; } /*! \internal Creates a QAction and registers the 'triggered' signal to send the given key event to \a actionWidget as a convenience. */ QAction *QSoftKeyManager::createKeyedAction(StandardSoftKey standardKey, Qt::Key key, QWidget *actionWidget) { #ifndef QT_NO_ACTION QScopedPointer<QAction> action(createAction(standardKey, actionWidget)); connect(action.data(), SIGNAL(triggered()), QSoftKeyManager::instance(), SLOT(sendKeyEvent())); connect(action.data(), SIGNAL(destroyed(QObject*)), QSoftKeyManager::instance(), SLOT(cleanupHash(QObject*))); QSoftKeyManager::instance()->d_func()->keyedActions.insert(action.data(), key); return action.take(); #endif //QT_NO_ACTION }
void MainWindow::keyReleaseEvent(QKeyEvent * event) { if(!started) { event->ignore(); return; } if(event->key() == Qt::Key_Escape) { stopPlay(); //emit ui->disconnectButton->released(); return; } if(!event->isAutoRepeat()) { emit sendKeyEvent(event, -1); } else { QWidget::keyPressEvent(event); } }
void GHOST_NDOFManager::updateButton(int button_number, bool press, GHOST_TUns64 time) { GHOST_IWindow* window = m_system.getWindowManager()->getActiveWindow(); #ifdef DEBUG_NDOF_BUTTONS if (m_deviceType != NDOF_UnknownDevice) printf("ndof: button %d -> ", button_number); #endif switch (m_deviceType) { case NDOF_SpaceNavigator: sendButtonEvent(SpaceNavigator_HID_map[button_number], press, time, window); break; case NDOF_SpaceExplorer: switch (button_number) { case 6: sendKeyEvent(GHOST_kKeyEsc, press, time, window); break; case 7: sendKeyEvent(GHOST_kKeyLeftAlt, press, time, window); break; case 8: sendKeyEvent(GHOST_kKeyLeftShift, press, time, window); break; case 9: sendKeyEvent(GHOST_kKeyLeftControl, press, time, window); break; default: sendButtonEvent(SpaceExplorer_HID_map[button_number], press, time, window); } break; case NDOF_SpacePilotPro: switch (button_number) { case 22: sendKeyEvent(GHOST_kKeyEsc, press, time, window); break; case 23: sendKeyEvent(GHOST_kKeyLeftAlt, press, time, window); break; case 24: sendKeyEvent(GHOST_kKeyLeftShift, press, time, window); break; case 25: sendKeyEvent(GHOST_kKeyLeftControl, press, time, window); break; default: sendButtonEvent(SpacePilotPro_HID_map[button_number], press, time, window); } break; case NDOF_SpacePilot: switch (button_number) { case 10: sendKeyEvent(GHOST_kKeyEsc, press, time, window); break; case 11: sendKeyEvent(GHOST_kKeyLeftAlt, press, time, window); break; case 12: sendKeyEvent(GHOST_kKeyLeftShift, press, time, window); break; case 13: sendKeyEvent(GHOST_kKeyLeftControl, press, time, window); break; case 20: puts("ndof: ignoring CONFIG button"); break; default: sendButtonEvent(SpacePilot_HID_map[button_number], press, time, window); } break; case NDOF_UnknownDevice: printf("ndof: button %d on unknown device (ignoring)\n", button_number); } int mask = 1 << button_number; if (press) { m_buttons |= mask; // set this button's bit } else { m_buttons &= ~mask; // clear this button's bit } }