Ejemplo n.º 1
0
void LastReleasedPhysicalKey::update(const Params_Base& newval) {
  {
    auto p = newval.get_Params_KeyboardEventCallBack();

    if (p && !p->ex_iskeydown) {
      datatype_ = BRIDGE_DATATYPE_KEYCODE;
      value_ = (p->key).get();
      ic_.begin();
    }
  }
  {
    auto p = newval.get_Params_KeyboardSpecialEventCallback();

    if (p && !p->ex_iskeydown) {
      datatype_ = BRIDGE_DATATYPE_CONSUMERKEYCODE;
      value_ = (p->key).get();
      ic_.begin();
    }
  }
  {
    auto p = newval.get_Params_RelativePointerEventCallback();

    if (p && p->ex_button != PointingButton::NONE && !p->ex_isbuttondown) {
      datatype_ = BRIDGE_DATATYPE_POINTINGBUTTON;
      value_ = (p->ex_button).get();
      ic_.begin();
    }
  }
}
Ejemplo n.º 2
0
  bool operator==(const Params_Base& paramsBase) const {
    switch (type_) {
    case Type::KEY: {
      auto p = paramsBase.get_Params_KeyboardEventCallBack();
      if (p) {
        return key_ == p->key;
      }
      break;
    }

    case Type::CONSUMER_KEY: {
      auto p = paramsBase.get_Params_KeyboardSpecialEventCallback();
      if (p) {
        return consumer_ == p->key;
      }
      break;
    }

    case Type::POINTING_BUTTON: {
      auto p = paramsBase.get_Params_RelativePointerEventCallback();
      if (p) {
        return button_ == p->ex_button;
      }
      break;
    }

    case Type::NONE:
      break;
    }
    return false;
  }
Ejemplo n.º 3
0
void remap_KeyboardSpecialEventCallback(const Params_Base& paramsBase) {
  auto params = paramsBase.get_Params_KeyboardSpecialEventCallback();
  if (!params) return;

  PhysicalEventType physicalEventType = PhysicalEventType::UP;
  if (params->ex_iskeydown) {
    physicalEventType = PhysicalEventType::DOWN;
  }
  RemapParams remapParams(*params, physicalEventType);
  RemapClassManager::prepare(remapParams);
  RemapClassManager::remap(remapParams);

  // ----------------------------------------
  if (!remapParams.isremapped) {
    Params_KeyboardSpecialEventCallback p(params->eventType,
                                          FlagStatus::globalFlagStatus().makeFlags(),
                                          params->key,
                                          params->flavor,
                                          params->guid,
                                          false);
    KeyboardRepeat::set(p, AutogenId::maxValue());
    EventOutputQueue::FireConsumer::fire(p, AutogenId::maxValue(), physicalEventType);
  }

  RemapFunc::PointingRelativeToScroll::cancelScroll();
}
Ejemplo n.º 4
0
// ----------------------------------------------------------------------
unsigned int
EventOutputQueue::calcDelay(const Params_Base& paramsBase) {
  // ----------------------------------------
  {
    // Delay before and after modifier
    //
    // We need to wait before and after a modifier event because
    // events will be dropped by window server if
    // we send a mouse click event and a modifier event at the same time.
    //
    // For example, change middle click to command-left click by this autogen.
    // We need to put a wait on this setting in Mail.app.
    //    <autogen>
    //      __KeyToKey__
    //      PointingButton::MIDDLE, ModifierFlag::NONE,
    //      PointingButton::LEFT, ModifierFlag::COMMAND_L,
    //    </autogen>
    //
    if (paramsBase.isModifier()) {
      return Config::get_wait_before_and_after_a_modifier_key_event();
    }
  }

  // ----------------------------------------
  {
    // Delay before and after modifier
    //
    // We need to wait before and after a pointing device click event because
    // events will be dropped by processes (eg. NetBeans) if
    // we send press button event and release button event at the same time.
    //

    auto params = paramsBase.get_Params_RelativePointerEventCallback();
    if (params) {
      if (params->buttons != previousButtons_) {
        previousButtons_ = params->buttons;
        return Config::get_wait_before_and_after_a_click_event();
      }
    }
  }

  // ----------------------------------------
  return 0;
}
Ejemplo n.º 5
0
bool FromEvent::isTargetEvent(bool& isDown, const Params_Base& paramsBase) const {
  switch (type_) {
  case Type::NONE: {
    return false;
  }

  case Type::KEY: {
    auto p = paramsBase.get_Params_KeyboardEventCallBack();
    if (!p) return false;

    if (p->key != key_) return false;

    isDown = p->ex_iskeydown;
    return true;
  }

  case Type::CONSUMER_KEY: {
    auto p = paramsBase.get_Params_KeyboardSpecialEventCallback();
    if (!p) return false;

    if (p->key != consumer_) return false;

    isDown = p->ex_iskeydown;
    return true;
  }

  case Type::POINTING_BUTTON: {
    auto p = paramsBase.get_Params_RelativePointerEventCallback();
    if (!p) return false;

    if (p->ex_button != button_) return false;

    isDown = p->ex_isbuttondown;
    return true;
  }
  }

  return false;
}
Ejemplo n.º 6
0
void remap_ScrollWheelEventCallback(const Params_Base& paramsBase) {
  auto params = paramsBase.get_Params_ScrollWheelEventCallback();
  if (!params) return;

  RemapParams remapParams(*params);
  RemapClassManager::prepare(remapParams);
  RemapClassManager::remap(remapParams);

  if (!remapParams.isremapped) {
    EventOutputQueue::FireScrollWheel::fire(*params);
    RemapFunc::PointingRelativeToScroll::cancelScroll();
  }
}
Ejemplo n.º 7
0
void remap_ScrollWheelEventCallback(const Params_Base& paramsBase) {
  auto params = paramsBase.get_Params_ScrollWheelEventCallback();
  if (!params) return;

  PhysicalEventType physicalEventType = PhysicalEventType::DOWN;
  RemapParams remapParams(*params, physicalEventType);
  RemapClassManager::prepare(remapParams);
  RemapClassManager::remap(remapParams);

  if (!remapParams.isremapped) {
    EventOutputQueue::FireScrollWheel::fire(*params, AutogenId::maxValue(), physicalEventType);
    RemapFunc::PointingRelativeToScroll::cancelScroll();
  }
}
Ejemplo n.º 8
0
// ======================================================================
void remap_KeyboardEventCallback(const Params_Base& paramsBase) {
  auto params = paramsBase.get_Params_KeyboardEventCallBack();
  if (!params) return;

  PhysicalEventType physicalEventType = PhysicalEventType::UP;
  if (params->ex_iskeydown) {
    physicalEventType = PhysicalEventType::DOWN;
  }
  RemapParams remapParams(*params, physicalEventType);

  // Call `prepare` before FlagStatus::set.
  //
  // For example, with this autogen:
  //
  //    <autogen>
  //      __HoldingKeyToKey__
  //      KeyCode::I,
  //      __{ KeyCode::A }__
  //      __{ KeyCode::B }__
  //    </autogen>
  //
  // Hitting `i` and `shift` immediately (`i` down, `shift` down, `i` up, `shift` up),
  // `a` and `shift` should be sent (`a` down, `shift` down, `a` up, `shift` up).
  //
  // If we call prepare after FlagStatus::set,
  // `shift-a` will be sent. It's not intended.

  RemapClassManager::prepare(remapParams);

  FlagStatus::globalFlagStatus().set(params->key, params->flags);

  RemapClassManager::remap(remapParams);

  // ------------------------------------------------------------
  if (!remapParams.isremapped) {
    Params_KeyboardEventCallBack p(params->eventType,
                                   FlagStatus::globalFlagStatus().makeFlags(),
                                   params->key,
                                   params->charCode,
                                   params->charSet,
                                   params->origCharCode,
                                   params->origCharSet,
                                   params->keyboardType,
                                   false);
    KeyboardRepeat::set(p, AutogenId::maxValue());
    EventOutputQueue::FireKey::fire(p, AutogenId::maxValue(), physicalEventType);
  }

  RemapFunc::PointingRelativeToScroll::cancelScroll();
}
Ejemplo n.º 9
0
void EventInputQueue::enqueue_(const Params_Base& paramsBase,
                               bool retainFlagStatusTemporaryCount,
                               const DeviceIdentifier& deviceIdentifier,
                               bool push_back,
                               bool isSimultaneousKeyPressesTarget) {
  // Because we handle the key repeat ourself, drop the key repeat.
  if (paramsBase.isRepeat()) return;

  Item* item = new Item(paramsBase, retainFlagStatusTemporaryCount, deviceIdentifier);
  if (item) {
    item->isSimultaneousKeyPressesTarget = isSimultaneousKeyPressesTarget;
    if (push_back) {
      queue_.push_back(item);
    } else {
      queue_.push_front(item);
    }
  }
}
Ejemplo n.º 10
0
void remap_RelativePointerEventCallback(const Params_Base& paramsBase) {
  auto params = paramsBase.get_Params_RelativePointerEventCallback();
  if (!params) return;

  ButtonStatus::set(params->ex_button, params->ex_isbuttondown);

  RemapParams remapParams(*params);
  RemapClassManager::prepare(remapParams);
  RemapClassManager::remap(remapParams);

  // ------------------------------------------------------------
  if (!remapParams.isremapped) {
    EventOutputQueue::FireRelativePointer::fire(ButtonStatus::makeButtons(), params->dx, params->dy);
  }

  if (params->ex_button != PointingButton::NONE) {
    resetWhenPressingPhysicalKeysIsEmpty();
  }
}
Ejemplo n.º 11
0
void remap_RelativePointerEventCallback(const Params_Base& paramsBase) {
  auto params = paramsBase.get_Params_RelativePointerEventCallback();
  if (!params) return;

  ButtonStatus::set(params->ex_button, params->ex_isbuttondown);

  PhysicalEventType physicalEventType = PhysicalEventType::UP;
  if (params->ex_button != PointingButton::NONE &&
      params->ex_isbuttondown) {
    physicalEventType = PhysicalEventType::DOWN;
  }
  RemapParams remapParams(*params, physicalEventType);
  RemapClassManager::prepare(remapParams);
  RemapClassManager::remap(remapParams);

  // ------------------------------------------------------------
  if (!remapParams.isremapped) {
    EventOutputQueue::FireRelativePointer::fire(AutogenId::maxValue(), physicalEventType, ButtonStatus::makeButtons(), params->dx, params->dy);
  }
}
Ejemplo n.º 12
0
void remap_KeyboardSpecialEventCallback(const Params_Base& paramsBase) {
  auto params = paramsBase.get_Params_KeyboardSpecialEventCallback();
  if (!params) return;

  RemapParams remapParams(*params);
  RemapClassManager::prepare(remapParams);
  RemapClassManager::remap(remapParams);

  // ----------------------------------------
  if (!remapParams.isremapped) {
    Params_KeyboardSpecialEventCallback p(params->eventType,
                                          FlagStatus::globalFlagStatus().makeFlags(),
                                          params->key,
                                          params->flavor,
                                          params->guid,
                                          false);
    KeyboardRepeat::set(p);
    EventOutputQueue::FireConsumer::fire(p);
  }

  resetWhenPressingPhysicalKeysIsEmpty();

  RemapFunc::PointingRelativeToScroll::cancelScroll();
}