/** * Parses the text contained within the given token stack */ int CodeParser::parseKeyword( Scope* scope, TokenStack* stack, const char* keyword ) { int errorCode = 0; // TODO delete, do-while, for, foreach // TODO if-else, try-catch, throw, while // handle the keyword switch( state->lookupKeyword( keyword ) ) { case KW_ABSTRACT: errorCode = updateModifiers( ABSTRACT, stack ); break; case KW_CLASS: errorCode = parseKeyword_Class( scope, stack ); break; case KW_FINAL: errorCode = updateModifiers( FINAL, stack ); break; case KW_IMPORT: errorCode = parseKeyword_Import( scope, stack ); break; case KW_NAMESPACE: errorCode = parseKeyword_NameSpace( scope, stack ); break; case KW_NEW: errorCode = parseKeyword_New( scope, stack ); break; case KW_PACKAGED: errorCode = updateModifiers( PACKAGE, stack ); break; case KW_PRIVATE: errorCode = updateModifiers( PRIVATE, stack ); break; case KW_PROTECTED: errorCode = updateModifiers( PROTECTED, stack ); break; case KW_PUBLIC: errorCode = updateModifiers( PUBLIC, stack ); break; case KW_RETURN: errorCode = parseKeyword_Return( scope, stack ); break; case KW_STATIC: errorCode = updateModifiers( STATIC, stack ); break; case KW_VIRTUAL: errorCode = updateModifiers( VIRTUAL, stack ); break; default: char *message = new char[256]; sprintf( message, "Keyword '%s' was not handled", keyword ); SYNTAX_ERROR( message, stack->last() ); delete message; errorCode = -1; } // success return errorCode; }
void CInputFilter::sendEvent(CEvent& event) { CEvent::Type type = event.getType(); // process keyboard modifiers here if (type == IPlatformScreen::getKeyDownEvent() || type == IPlatformScreen::getKeyUpEvent() || type == IPlatformScreen::getKeyRepeatEvent()) { // get CKeyInfo from event IPlatformScreen::CKeyInfo* kinfo = reinterpret_cast<IPlatformScreen::CKeyInfo*>(event.getData()); // save mask m_lastMask = kinfo->m_mask; // prepare new mask KeyModifierMask newMask = kinfo->m_mask; updateModifiers(); newMask &= ~m_clearMask; newMask |= m_modifierMask; // set new mask kinfo->m_mask = newMask; } // add event to eventqueue EVENTQUEUE->addEvent(event); }
BOOL LLKeyboardMacOSX::handleKeyUp(const U16 key, const U32 mask) { KEY translated_key = 0; U32 translated_mask = 0; BOOL handled = FALSE; translated_mask = updateModifiers(mask); if(translateNumpadKey(key, &translated_key)) { handled = handleTranslatedKeyUp(translated_key, translated_mask); } return handled; }
// mask is ignored, except for extended flag -- we poll the modifier keys for the other flags BOOL LLKeyboardWin32::handleKeyUp(const U16 key, MASK mask) { KEY translated_key; U32 translated_mask; BOOL handled = FALSE; translated_mask = updateModifiers(); if (translateExtendedKey(key, mask, &translated_key)) { handled = handleTranslatedKeyUp(translated_key, translated_mask); } return handled; }
static void kb_chvt(_self, int vt) { if (ioctl(self->fd, VT_ACTIVATE, vt)) perror("chvt: VT_ACTIVATE"); else { while (ioctl(self->fd, VT_WAITACTIVE, vt)) { if (EINTR == errno) continue; perror("VT_WAITACTIVE"); break; } updateModifiers(self->state= 0); } }
void CInputFilter::handleEvent(const CEvent& event, void* arg) { // get a modifiable copy of this event. // set target to us, set kDontFreeData and kDeliverImmediately because the // original event will be destroyed after this method exits. CEvent evt(event.getType(), this, event.getData(), event.getFlags() | CEvent::kDontFreeData | CEvent::kDeliverImmediately); // clear dirty flag m_dirtyFlag = kNotDirty; EActionMode actionMode = kModePass; // match event against filter rules and perform actions for (CRuleList::iterator rule = m_ruleList.begin(); rule != m_ruleList.end(); ++rule) { EFilterStatus conditionStatus; EFilterStatus actionStatus; conditionStatus = rule->first->match(evt, arg, actionMode); if (conditionStatus == kDiscard) { return; } else if (conditionStatus == kNoMatch) { continue; } actionStatus = rule->second->perform(evt, arg, actionMode); if (actionStatus == kDiscard) { // discard event return; } else if (actionStatus == kNotHandled) { continue; } else if (actionStatus == kUpdateModifiers) { updateModifiers(); return; } // if we got here then the rule has matched and action returned // kHandled, so send the event. break; } sendEvent(evt); }
BOOL LLKeyboardSDL::handleKeyUp(const U16 key, const U32 mask) { U16 adjusted_nativekey; KEY translated_key = 0; U32 translated_mask = MASK_NONE; BOOL handled = FALSE; adjusted_nativekey = adjustNativekeyFromUnhandledMask(key, mask); translated_mask = updateModifiers(mask); if(translateNumpadKey(adjusted_nativekey, &translated_key)) { handled = handleTranslatedKeyUp(translated_key, translated_mask); } return handled; }
bool Global::eventFilter(QObject * /*watched*/, QEvent * event) { // Every single event delivered by Qt go through this method first before // going to its target object, so keep it as lightweight as possible // It is used as a convenient way to fix a few event behaviours that were // not quite right out of the box. // --------------------- Detect modifier key presses -------------- // Detect modifier key presses (Shift, Ctrl, Alt, etc.) and update application // state accordingly (e.g., indicate which modifiers are pressed in the status bar, or // redraw the scene, since highlighting color depends on which modifiers are pressed) // If a modifier is pressed or released, update the modifier state, and emit a signal // if this state has changed // If a modifier is pressed or released, update the modifier state, and emit a signal // if this state has changed if(event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) { QKeyEvent * keyEvent = static_cast<QKeyEvent *>(event); if(keyEvent) { // Workaround for Mac delete key // This is needed because of a bug in QT 5 that has not been resolved as of 5.5.0 #ifdef Q_OS_MAC if(keyEvent->key() == Qt::Key_Backspace) { scene()->smartDelete(); } #endif if(keyEvent->key() == Qt::Key_Shift || keyEvent->key() == Qt::Key_Alt || keyEvent->key() == Qt::Key_Meta || keyEvent->key() == Qt::Key_AltGr || keyEvent->key() == Qt::Key_Control) { updateModifiers(); } } // Continue normal processing of the event return false; } else if(event->type() == QEvent::FocusIn ) { updateModifiers(); // Continue normal processing of the event return false; } // --------------------- Resolve shortcut overloads -------------- // Resolve shortcut overloads else if(event->type() == QEvent::Shortcut) { QShortcutEvent * shortcutEvent = static_cast<QShortcutEvent *>(event); if(shortcutEvent->isAmbiguous()) { QKeySequence key = shortcutEvent->key(); resolveAmbiguousShortcuts(key); // Stop processing of the event return true; } else { // Continue normal processing of the event return false; } } // --------------------- Keep standard behaviour -------------- // Continue normal processing of the event return false; }
static void kb_translate(_self, int code, int up) { static int prev= 0; unsigned short *keyMap= self->keyMaps[self->state]; int rep= (!up) && (prev == code); prev= up ? 0 : code; debugf("+++ code %d up %d prev %d rep %d map %p\n", code, up, prev, rep, keyMap); if (keyMap) { int sym= keyMap[code]; int type= KTYP(sym); debugf("+++ sym %x (%02x) type %d\n", sym, sym & 255, type); sym &= 255; if (type >= 0xf0) // shiftable type -= 0xf0; if (KT_LETTER == type) // lockable type= KT_LATIN; debugf("+++ type %d\n", type); switch (type) { case KT_LATIN: case KT_META: kb_post(self, sym, up); break; case KT_SHIFT: if (rep) break; else if (up) self->state &= ~(1 << sym); else self->state |= (1 << sym); updateModifiers(self->state); break; case KT_FN: case KT_SPEC: case KT_CUR: switch (K(type,sym)) { // FN case K_FIND: kb_post(self, 1, up); break; // home case K_INSERT: kb_post(self, 5, up); break; case K_SELECT: kb_post(self, 4, up); break; // end case K_PGUP: kb_post(self, 11, up); break; case K_PGDN: kb_post(self, 12, up); break; // SPEC case K_ENTER: kb_post(self, 13, up); break; // CUR case K_DOWN: kb_post(self, 31, up); break; case K_LEFT: kb_post(self, 28, up); break; case K_RIGHT: kb_post(self, 29, up); break; case K_UP: kb_post(self, 30, up); break; } break; case KT_CONS: if (self->vtSwitch && !self->vtLock) kb_chvt(self, sym + 1); break; default: if (type > KT_SLOCK) debugf("ignoring unknown scancode %d.%d\n", type, sym); break; } } }
void LLKeyboardMacOSX::handleModifier(MASK mask) { updateModifiers(mask); }
void Champion::updateCooldowns() { _ability->update(); updateModifiers(_flatModifiers); updateModifiers(_addativeModifiers); }