Пример #1
0
void KeyCode::normalizeKey(KeyCode& key, Flags& flags, EventType eventType, KeyboardType keyboardType) {
  // We can drop NUMPAD flags, because we'll set these flags at reverseNormalizeKey.
  flags.stripNUMPAD();

  for (unsigned int i = 0; i < sizeof(fnkeyhack) / sizeof(fnkeyhack[0]); ++i) {
    if (fnkeyhack[i].normalize(key, flags, eventType)) break;
  }
}
Пример #2
0
  void
  KeyCode::reverseNormalizeKey(KeyCode& key, Flags& flags, EventType eventType, KeyboardType keyboardType)
  {
    if (! Config::get_essential_config(BRIDGE_ESSENTIAL_CONFIG_INDEX_general_disable_numpad_hack)) {
      for (unsigned int i = 0; i < sizeof(fnkeyhack) / sizeof(fnkeyhack[0]); ++i) {
        if (fnkeyhack[i].reverse(key, flags, eventType)) break;
      }
    }

    if (keyboardType == KeyboardType::POWERBOOK ||
        keyboardType == KeyboardType::POWERBOOK_G4 ||
        keyboardType == KeyboardType::POWERBOOK_G4_TI) {
      if (key == KeyCode::ENTER) { key = KeyCode::ENTER_POWERBOOK; }
    }

    // ------------------------------------------------------------
    // Don't add ModifierFlag::FN automatically for F-keys, PageUp/PageDown/Home/End and Forward Delete.
    //
    // PageUp/PageDown/Home/End and Forward Delete are entered by fn+arrow, fn+delete normally,
    // And, from Cocoa Application, F-keys and PageUp,... keys have Fn modifier
    // even if Fn key is not pressed actually.
    // So, it's natural adding ModifierFlag::FN to these keys.
    // However, there is a reason we must not add ModifierFlag::FN to there keys.
    //
    // Mission Control may have "fn" as shortcut key.
    // If we add ModifierFlag::FN here,
    // "XXX to PageUp" launches Mission Control because Mission Control recognizes fn key was pressed.
    //
    // It's not intended behavior from users.
    // Therefore, we don't add ModifierFlag::FN for these keys.

    // ------------------------------------------------------------
    // set ModifierFlag::NUMPAD
    flags.stripNUMPAD();

    // Note: KEYPAD_CLEAR, KEYPAD_COMMA have no ModifierFlag::NUMPAD bit.
    if (key == KeyCode::KEYPAD_0 || key == KeyCode::KEYPAD_1 || key == KeyCode::KEYPAD_2 ||
        key == KeyCode::KEYPAD_3 || key == KeyCode::KEYPAD_4 || key == KeyCode::KEYPAD_5 ||
        key == KeyCode::KEYPAD_6 || key == KeyCode::KEYPAD_7 || key == KeyCode::KEYPAD_8 ||
        key == KeyCode::KEYPAD_9 ||
        key == KeyCode::KEYPAD_DOT ||
        key == KeyCode::KEYPAD_MULTIPLY ||
        key == KeyCode::KEYPAD_PLUS ||
        key == KeyCode::KEYPAD_SLASH ||
        key == KeyCode::KEYPAD_MINUS ||
        key == KeyCode::KEYPAD_EQUAL) {
      flags.add(ModifierFlag::NUMPAD);
    }

    if (key == KeyCode::CURSOR_UP ||
        key == KeyCode::CURSOR_DOWN ||
        key == KeyCode::CURSOR_LEFT ||
        key == KeyCode::CURSOR_RIGHT) {
      flags.add(ModifierFlag::NUMPAD);
    }
  }
Пример #3
0
  void
  KeyCode::normalizeKey(KeyCode& key, Flags& flags, EventType eventType, KeyboardType keyboardType)
  {
    // We can drop NUMPAD flags, because we'll set these flags at reverseNormalizeKey.
    flags.stripNUMPAD();

    if (keyboardType == KeyboardType::POWERBOOK ||
        keyboardType == KeyboardType::POWERBOOK_G4 ||
        keyboardType == KeyboardType::POWERBOOK_G4_TI) {
      if (key == KeyCode::ENTER_POWERBOOK) { key = KeyCode::ENTER; }
    }

    if (! Config::get_essential_config(BRIDGE_ESSENTIAL_CONFIG_INDEX_general_disable_numpad_hack)) {
      for (unsigned int i = 0; i < sizeof(fnkeyhack) / sizeof(fnkeyhack[0]); ++i) {
        if (fnkeyhack[i].normalize(key, flags, eventType)) break;
      }
    }
  }