当前位置: 首页>>代码示例>>C++>>正文


C++ KeyCode::getModifierFlag方法代码示例

本文整理汇总了C++中KeyCode::getModifierFlag方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyCode::getModifierFlag方法的具体用法?C++ KeyCode::getModifierFlag怎么用?C++ KeyCode::getModifierFlag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KeyCode的用法示例。


在下文中一共展示了KeyCode::getModifierFlag方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: isKeyDownOrModifierDown

// ------------------------------------------------------------
bool EventType::isKeyDownOrModifierDown(KeyCode key, Flags flags) const {
  if (*this == EventType::DOWN) return true;
  if (*this == EventType::MODIFY) {
    return flags.isOn(key.getModifierFlag());
  }
  return false;
}
开发者ID:Beej126,项目名称:Karabiner,代码行数:8,代码来源:KeyCode.cpp

示例2: flags

    void
    SimultaneousKeyPresses::push_remapped(bool isKeyDown, const DeviceIdentifier& deviceIdentifier)
    {
      EventType eventType = isKeyDown ? EventType::DOWN : EventType::UP;

      KeyCode key = virtualkey_;
      if (isToRaw_) {
        key = toKey_raw_;
      }
      if (key == KeyCode::VK_NONE) return;

      Flags flags(0);
      if (isKeyDown) {
        flags.add(key.getModifierFlag());
        flags.stripNONE();
      }

      // ----------------------------------------
      Params_KeyboardEventCallBack::auto_ptr ptr(Params_KeyboardEventCallBack::alloc(eventType, flags, key, CommonData::getcurrent_keyboardType(), false));
      if (! ptr) return;

      Params_KeyboardEventCallBack& params = *ptr;
      bool retainFlagStatusTemporaryCount = false;
      bool push_back = false;
      EventInputQueue::enqueue_(params, retainFlagStatusTemporaryCount, deviceIdentifier, push_back);
    }
开发者ID:dengzhp,项目名称:KeyRemap4MacBook,代码行数:26,代码来源:SimultaneousKeyPresses.cpp

示例3: stfc

  void
  EventOutputQueue::FireKey::fire_downup(Flags flags, KeyCode key, KeyboardType keyboardType)
  {
    ModifierFlag f = key.getModifierFlag();

    if (f != ModifierFlag::ZERO) {
      FlagStatus::ScopedTemporaryFlagsChanger stfc(FlagStatus::globalFlagStatus(), flags);

      // We operate FlagStatus for the case "key == KeyCode::CAPSLOCK".
      FlagStatus::globalFlagStatus().increase(f);
      {
        Params_KeyboardEventCallBack::auto_ptr ptr(Params_KeyboardEventCallBack::alloc(EventType::MODIFY,
                                                                                       FlagStatus::globalFlagStatus().makeFlags(),
                                                                                       key,
                                                                                       keyboardType,
                                                                                       false));
        if (! ptr) return;
        FireKey::fire(*ptr);
      }

      FlagStatus::globalFlagStatus().decrease(f);
      {
        Params_KeyboardEventCallBack::auto_ptr ptr(Params_KeyboardEventCallBack::alloc(EventType::MODIFY,
                                                                                       FlagStatus::globalFlagStatus().makeFlags(),
                                                                                       key,
                                                                                       keyboardType,
                                                                                       false));
        if (! ptr) return;
        FireKey::fire(*ptr);
      }

    } else {
      {
        Params_KeyboardEventCallBack::auto_ptr ptr(Params_KeyboardEventCallBack::alloc(EventType::DOWN, flags, key, keyboardType, false));
        if (! ptr) return;
        FireKey::fire(*ptr);
      }
      {
        Params_KeyboardEventCallBack::auto_ptr ptr(Params_KeyboardEventCallBack::alloc(EventType::UP, flags, key, keyboardType, false));
        if (! ptr) return;
        FireKey::fire(*ptr);
      }
    }
  }
开发者ID:kurobeniq,项目名称:KeyRemap4MacBook,代码行数:44,代码来源:EventOutputQueue.cpp

示例4: push_remapped

void SimultaneousKeyPresses::push_remapped(bool isKeyDown, const DeviceIdentifier& deviceIdentifier, const ListHookedDevice::WeakPointer_Item& device) {
  EventType eventType = isKeyDown ? EventType::DOWN : EventType::UP;

  KeyCode key = virtualkey_;
  if (isToRaw_) {
    key = toKey_raw_;
  }
  if (key == KeyCode::VK_NONE) return;

  Flags flags(0);
  if (isKeyDown) {
    flags.add(key.getModifierFlag());
  }

  // ----------------------------------------
  Params_KeyboardEventCallBack params(eventType, flags, key, CommonData::getcurrent_keyboardType(), false);

  bool retainFlagStatusTemporaryCount = false;
  bool push_back = false;
  bool isSimultaneousKeyPressesTarget = false;
  EventInputQueue::enqueue_(params, retainFlagStatusTemporaryCount, deviceIdentifier, device, push_back, isSimultaneousKeyPressesTarget);
}
开发者ID:rraihansaputra,项目名称:Karabiner,代码行数:22,代码来源:SimultaneousKeyPresses.cpp

示例5: ptr

    bool
    KeyToKey::remap(RemapParams& remapParams)
    {
      if (remapParams.isremapped) return false;
      if (! fromkeychecker_.isFromKey(remapParams.params.ex_iskeydown, remapParams.params.key, FlagStatus::makeFlags(), fromKey_.key, fromKey_.flags)) return false;
      remapParams.isremapped = true;

      // ------------------------------------------------------------
      // handle EventType & Modifiers

      // Let's consider the following setting.
      //   __KeyToKey__ KeyCode::SHIFT_R, ModifierFlag::SHIFT_R | ModifierFlag::NONE, KeyCode::A, ModifierFlag::SHIFT_R
      // In this setting, we need decrease SHIFT_R only once.
      // So, we transform values of fromKey_.
      //
      // [before]
      //   fromKey_.key   : KeyCode::SHIFT_R
      //   fromKey_.flags : ModifierFlag::SHIFT_R | ModifierFlag::NONE
      //
      // [after]
      //   fromKey_.key   : KeyCode::SHIFT_R
      //   fromKey_.flags : ModifierFlag::NONE
      //
      // Note: we need to apply this transformation after calling fromkeychecker_.isFromKey.

      Flags fromFlags = fromKey_.flags;
      fromFlags.remove(fromKey_.key.getModifierFlag());

      if (remapParams.params.ex_iskeydown) {
        retractInput();
      } else {
        restoreInput();
      }

      // ----------------------------------------
      // Handle beforeKeys_
      if (remapParams.params.ex_iskeydown) {
        FlagStatus::temporary_decrease(fromFlags);

        for (size_t i = 0; i < beforeKeys_.size(); ++i) {
          FlagStatus::temporary_increase(beforeKeys_[i].flags);

          Flags f = FlagStatus::makeFlags();
          KeyboardType keyboardType = remapParams.params.keyboardType;

          EventOutputQueue::FireKey::fire_downup(f, beforeKeys_[i].key, keyboardType);

          FlagStatus::temporary_decrease(beforeKeys_[i].flags);
        }

        FlagStatus::temporary_increase(fromFlags);
      }

      // ----------------------------------------
      // Handle toKeys_
      switch (toKeys_.size()) {
        case 0:
          break;

        case 1:
        {
          EventType newEventType = remapParams.params.ex_iskeydown ? EventType::DOWN : EventType::UP;
          KeyCode toKey = toKeys_[0].key;
          ModifierFlag toModifierFlag = toKey.getModifierFlag();

          if (toModifierFlag == ModifierFlag::NONE && ! VirtualKey::isKeyLikeModifier(toKey)) {
            // toKey
            FlagStatus::temporary_decrease(fromFlags);
            FlagStatus::temporary_increase(toKeys_[0].flags);

          } else {
            // toModifier or VirtualKey::isKeyLikeModifier
            if (toModifierFlag != ModifierFlag::NONE) {
              newEventType = EventType::MODIFY;
            }

            if (remapParams.params.ex_iskeydown) {
              FlagStatus::increase(toKeys_[0].flags | toModifierFlag);
              FlagStatus::decrease(fromFlags);
            } else {
              FlagStatus::decrease(toKeys_[0].flags | toModifierFlag);
              FlagStatus::increase(fromFlags);
            }
          }

          // ----------------------------------------
          Params_KeyboardEventCallBack::auto_ptr ptr(Params_KeyboardEventCallBack::alloc(newEventType,
                                                                                         FlagStatus::makeFlags(),
                                                                                         toKey,
                                                                                         remapParams.params.keyboardType,
                                                                                         remapParams.params.repeat));
          if (! ptr) return false;
          Params_KeyboardEventCallBack& params = *ptr;

          if (remapParams.params.ex_iskeydown && ! isRepeatEnabled_) {
            KeyboardRepeat::cancel();
          } else {
            KeyboardRepeat::set(params);
          }
          EventOutputQueue::FireKey::fire(params);
//.........这里部分代码省略.........
开发者ID:Bilalh,项目名称:KeyRemap4MacBook,代码行数:101,代码来源:KeyToKey.cpp

示例6: p

// ======================================================================
void EventOutputQueue::FireKey::fire(const Params_KeyboardEventCallBack& params, AutogenId autogenId, PhysicalEventType physicalEventType) {
  if (VirtualKey::handle(params, autogenId, physicalEventType)) {
    CommonData::setcurrent_lastsentevent(params);
    return;
  }

  // ------------------------------------------------------------
  KeyCode newkeycode = params.key;
  Flags newflags = params.flags;

  KeyCode::reverseNormalizeKey(newkeycode, newflags, params.eventType, params.keyboardType);

  // skip no-outputable keycodes.
  // Note: check before FireModifiers to avoid meaningless modifier event.
  if (newkeycode == KeyCode::VK_NONE ||
      newkeycode == KeyCode::VK_PSEUDO_KEY) {
    // Do not call CommonData::setcurrent_lastsentevent.
    return;
  }
  if (newkeycode.isModifier() && newkeycode.getModifierFlag().getRawBits() == 0) {
    // virtual modifiers.
    CommonData::setcurrent_lastsentevent(params);
    return;
  }

  // Keep last modifier flags at EventType::UP to avoid unnecessary modifier events.
  //
  // For example, consider these rules:
  //
  //   * Change Shift-N to Control-N
  //   * Change Shift-P to Control-P
  //
  //   <autogen>__KeyToKey__ KeyCode::N, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_SHIFT, KeyCode::N, ModifierFlag::CONTROL_L</autogen>
  //   <autogen>__KeyToKey__ KeyCode::P, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_SHIFT, KeyCode::P, ModifierFlag::CONTROL_L</autogen>
  //
  // Case 1:
  //   Actual input:
  //     1. shift down
  //     2. p down
  //     3. p up
  //     4. n down
  //     5. n up
  //     6. shift up
  //
  //   Desirable results:
  //     1. shift down
  //     2. shift up, control down, p down
  //     3. p up
  //     4. n down
  //     5. n up
  //     6. control up
  //
  //
  // Case 2:
  //   Actual input:
  //     1. shift down
  //     2. p down
  //     3. command down
  //     4. p up
  //     5. shift up
  //     6. command up
  //
  //   Desirable results:
  //     1. shift down
  //     2. shift up, control down, p down
  //     3. control up, command down, shift down (== shift-command)
  //     4. p up
  //     5. shift up
  //     6. command up
  //
  //
  // Case 3:
  //   Actual input:
  //     1. shift down
  //     2. p down
  //     3. shift up
  //     4. p up
  //
  //   Desirable results:
  //     1. shift down
  //     2. shift up, control down, p down
  //     3. control up
  //     4. p up
  //
  //
  // Case 4:
  //   Actual input:
  //     1. shift down
  //     2. e down
  //     3. p down
  //     4. e up
  //     5. p up
  //     6. shift up
  //
  //   Desirable results:
  //     1. shift down
  //     2. e down
  //     3. shift up, control down, p down
  //     4. e up
//.........这里部分代码省略.........
开发者ID:LuizGsa21,项目名称:Karabiner,代码行数:101,代码来源:EventOutputQueue.cpp


注:本文中的KeyCode::getModifierFlag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。