Ejemplo n.º 1
0
TEST(Flags, stripCURSOR) {
  Flags mask = ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_R | ModifierFlag::COMMAND_R;
  Flags flags = mask;
  EXPECT_EQ(mask, flags.stripCURSOR());

  flags.add(ModifierFlag::CURSOR);
  EXPECT_EQ(mask, flags.stripCURSOR());
}
Ejemplo n.º 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::KEYPAD, ModifierFlag::CURSOR
    flags.stripCURSOR().stripKEYPAD();

    // Note: KEYPAD_CLEAR, KEYPAD_COMMA have no ModifierFlag::KEYPAD 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::KEYPAD);
    }

    if (key == KeyCode::CURSOR_UP ||
        key == KeyCode::CURSOR_DOWN ||
        key == KeyCode::CURSOR_LEFT ||
        key == KeyCode::CURSOR_RIGHT) {
      flags.add(ModifierFlag::CURSOR);
    }
  }
Ejemplo n.º 3
0
  void
  KeyCode::normalizeKey(KeyCode& key, Flags& flags, EventType eventType, KeyboardType keyboardType)
  {
    // We can drop CURSOR and KEYPAD flags, because we'll set these flags at reverseNormalizeKey.
    flags.stripCURSOR().stripKEYPAD();

    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;
      }
    }
  }