예제 #1
0
파일: fekbd.c 프로젝트: conioh/os-design
BOOL KbdNlsFuncTypeAlt(PVK_F pVkToF, PKE pKe, ULONG_PTR dwExtraInfo)
{
    WORD nMod;
    BOOL fRet = FALSE;

    if (pKe == NULL) {
        /*
         * Clear state and deactivate this key processor
         */
        return FALSE;
    }

    nMod = GetModificationNumber(&Modifiers_NLSKBD,
                                 GetModifierBits(&Modifiers_NLSKBD,
                                                 gafRawKeyState));

    if (nMod != SHFT_INVALID) {
        if (!(pKe->usFlaggedVk & KBDBREAK)) {
            if (pVkToF->NLSFEProcCurrent == KBDNLS_INDEX_ALT) {
                fRet = GenerateNlsVkAltKey(pVkToF, nMod, pKe, dwExtraInfo);
            } else {
                fRet = GenerateNlsVkKey(pVkToF, nMod, pKe, dwExtraInfo);
            }
            if (pVkToF->NLSFEProcSwitch & (1 << nMod)) {
                TAGMSG0(DBGTAG_IMM, "USERKM:FEKBD Switching Alt table\n");
                /*
                 * Switch to "alt".
                 */
                pVkToF->NLSFEProcCurrent = KBDNLS_INDEX_ALT;
            }
        } else {
            if (pVkToF->NLSFEProcCurrent == KBDNLS_INDEX_ALT) {
                fRet = GenerateNlsVkAltKey(pVkToF, nMod, pKe, dwExtraInfo);
                /*
                 * Back to "normal"
                 */
                pVkToF->NLSFEProcCurrent = KBDNLS_INDEX_NORMAL;
            } else {
                fRet = GenerateNlsVkKey(pVkToF, nMod, pKe, dwExtraInfo);
            }
        }
    }
    return fRet;
}
예제 #2
0
파일: fekbd.c 프로젝트: conioh/os-design
BOOL KbdNlsFuncTypeNormal(PVK_F pVkToF, PKE pKe, ULONG_PTR dwExtraInfo)
{
    WORD nMod;

    if (pKe == NULL) {
        /*
         * Clear state and deactivate this key processor
         */
        return FALSE;
    }

    nMod = GetModificationNumber(&Modifiers_NLSKBD,
                                 GetModifierBits(&Modifiers_NLSKBD,
                                                 gafRawKeyState));

    if (nMod != SHFT_INVALID) {
        return(GenerateNlsVkKey(pVkToF, nMod, pKe, dwExtraInfo));
    }
    return FALSE;
}
예제 #3
0
파일: keyboard.cpp 프로젝트: fluxer/warmux
bool Keyboard::HandleKeyEvent(const SDL_Event& evnt)
{
  // Not a registred event
  if (!IsRegistredEvent(evnt.type))
    return false;

  Key_Event_t event_type;
  switch(evnt.type) {
  case SDL_KEYDOWN:
    event_type = KEY_PRESSED;
    break;
  case SDL_KEYUP:
    event_type = KEY_RELEASED;
    break;
  default:
    return false;
  }

  //Handle input text for Chat session in Network game
  if (Game::GetInstance()->chatsession.CheckInput()) {
    if (event_type == KEY_PRESSED)
      Game::GetInstance()->chatsession.HandleKeyPressed(evnt);
    else if (event_type == KEY_RELEASED)
      Game::GetInstance()->chatsession.HandleKeyReleased(evnt);
    return false;
  }

  SDLKey basic_key_code = evnt.key.keysym.sym;

#ifdef DEBUG
  if (IsLOGGING("killsynchro")
      && basic_key_code == SDLK_k
      && event_type == KEY_RELEASED) {
    fprintf(stderr, "\n\nKILLING NETWORK SYNCHRONISATION!\n\n");
    RandomSync().SetSeed(0);
  }
#endif

  // Also ignore real key code of a modifier, fix bug #15238
  if (IsModifier(basic_key_code)) {
    int modifier_changed = modifier_only_bits ^ GetModifierBits();
    if (event_type == KEY_RELEASED) {
      for (std::set<SDLKey>::const_iterator it = pressed_keys.begin(); it != pressed_keys.end(); it++ ) {
        int key_code = *it + MODIFIER_OFFSET * modifier_changed;
        HandleKeyComboEvent(key_code, KEY_RELEASED);
      }
    } else if (modifier_only_bits && event_type == KEY_PRESSED) {
      for (std::set<SDLKey>::const_iterator it = pressed_keys.begin(); it != pressed_keys.end(); it++ ) {
        int key_code = *it + MODIFIER_OFFSET * modifier_only_bits;
        HandleKeyComboEvent(key_code, KEY_RELEASED);
      }
    }
    modifier_only_bits = GetModifierBits();
    return false;
  }
#ifdef MAEMO
  if (SDL_GetModState() & KMOD_MODE) {
    if (basic_key_code == SDLK_LEFT) basic_key_code = SDLK_UP;
    if (basic_key_code == SDLK_RIGHT) basic_key_code = SDLK_DOWN;
  }
#endif

  int key_code;
  int previous_modifier_bits = modifier_bits;
  modifier_bits = GetModifierBits();

  if (modifier_bits != previous_modifier_bits) {
    std::set<SDLKey>::const_iterator it = pressed_keys.find(basic_key_code);
    if (it !=  pressed_keys.end()) {
      key_code = basic_key_code + MODIFIER_OFFSET * previous_modifier_bits;
      HandleKeyComboEvent(key_code, KEY_RELEASED);
      if (key_code != basic_key_code)
        HandleKeyComboEvent(basic_key_code, KEY_RELEASED);
      pressed_keys.erase(basic_key_code);
      if (event_type == KEY_PRESSED) {
        key_code = basic_key_code + MODIFIER_OFFSET * modifier_bits;
        HandleKeyComboEvent(key_code, KEY_PRESSED);
        pressed_keys.insert(basic_key_code);
      }
      return true;
    }
  }

  if (event_type == KEY_PRESSED) {
    key_code = basic_key_code + (MODIFIER_OFFSET * modifier_bits);
    HandleKeyComboEvent(key_code, KEY_PRESSED);
    if (previous_modifier_bits ^ modifier_bits) {
      key_code = basic_key_code + (MODIFIER_OFFSET * previous_modifier_bits);
      HandleKeyComboEvent(key_code, KEY_RELEASED);
    }
    pressed_keys.insert(basic_key_code);
  } else {
    ASSERT(event_type == KEY_RELEASED);
    key_code = basic_key_code + (MODIFIER_OFFSET * previous_modifier_bits);
    HandleKeyComboEvent(key_code, KEY_RELEASED);
    if (key_code != basic_key_code)
      HandleKeyComboEvent(basic_key_code, KEY_RELEASED);
    pressed_keys.erase(basic_key_code);
  }
  return true;
}