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