Esempio n. 1
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;
  }
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();
    }
  }
}
Esempio n. 3
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;
}
Esempio n. 4
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();
  }
}
Esempio n. 5
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);
  }
}
Esempio n. 6
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;
}