// ---------------------------------------------------------------------- void EventInputQueue::push_RelativePointerEventCallback(OSObject* target, int buttons_raw, int dx, int dy, AbsoluteTime ts, OSObject* sender, void* refcon) { GlobalLock::ScopedLock lk; if (!lk) return; Params_RelativePointerEventCallback::log(true, Buttons(buttons_raw), dx, dy); // ------------------------------------------------------------ Buttons buttons(buttons_raw); Buttons justPressed; Buttons justReleased; IOHIPointing* device = OSDynamicCast(IOHIPointing, sender); if (!device) return; ListHookedPointing::Item* item = static_cast<ListHookedPointing::Item*>(ListHookedPointing::instance().get(device)); if (!item) return; // ------------------------------------------------------------ CommonData::setcurrent_ts(ts); // ------------------------------------------------------------ justPressed = buttons.justPressed(item->get_previousbuttons()); justReleased = buttons.justReleased(item->get_previousbuttons()); item->set_previousbuttons(buttons); // ------------------------------------------------------------ // divide an event into button and cursormove events. for (int i = 0; i < ButtonStatus::MAXNUM; ++i) { PointingButton btn(1 << i); if (justPressed.isOn(btn)) { Params_RelativePointerEventCallback params(buttons, 0, 0, btn, true); bool retainFlagStatusTemporaryCount = Config::get_essential_config(BRIDGE_ESSENTIAL_CONFIG_INDEX_general_lazy_modifiers_with_mouse_event); enqueue_(params, retainFlagStatusTemporaryCount, item->getDeviceIdentifier()); } if (justReleased.isOn(btn)) { Params_RelativePointerEventCallback params(buttons, 0, 0, btn, false); bool retainFlagStatusTemporaryCount = Config::get_essential_config(BRIDGE_ESSENTIAL_CONFIG_INDEX_general_lazy_modifiers_with_mouse_event); enqueue_(params, retainFlagStatusTemporaryCount, item->getDeviceIdentifier()); } } // If (dx == 0 && dy == 0), the event is either needless event or just pressing/releasing buttons event. // About just pressing/releasing buttons event, we handled these in the above processes. // So, we can drop (dx == 0 && dy == 0) events in here. if (dx != 0 || dy != 0) { Params_RelativePointerEventCallback params(buttons, dx, dy, PointingButton::NONE, false); bool retainFlagStatusTemporaryCount = true; enqueue_(params, retainFlagStatusTemporaryCount, item->getDeviceIdentifier()); } setTimer(); }
void EventInputQueue::push_ScrollWheelEventCallback(OSObject* target, short deltaAxis1, short deltaAxis2, short deltaAxis3, IOFixed fixedDelta1, IOFixed fixedDelta2, IOFixed fixedDelta3, SInt32 pointDelta1, SInt32 pointDelta2, SInt32 pointDelta3, SInt32 options, AbsoluteTime ts, OSObject* sender, void* refcon) { GlobalLock::ScopedLock lk; if (! lk) return; Params_ScrollWheelEventCallback::log(true, deltaAxis1, deltaAxis2, deltaAxis3, fixedDelta1, fixedDelta2, fixedDelta3, pointDelta1, pointDelta2, pointDelta3, options); // ------------------------------------------------------------ Params_ScrollWheelEventCallback::auto_ptr ptr(Params_ScrollWheelEventCallback::alloc(deltaAxis1, deltaAxis2, deltaAxis3, fixedDelta1, fixedDelta2, fixedDelta3, pointDelta1, pointDelta2, pointDelta3, options)); if (! ptr) return; Params_ScrollWheelEventCallback& params = *ptr; // ------------------------------------------------------------ IOHIPointing* device = OSDynamicCast(IOHIPointing, sender); if (! device) return; ListHookedPointing::Item* item = static_cast<ListHookedPointing::Item*>(ListHookedPointing::instance().get(device)); if (! item) return; // ------------------------------------------------------------ CommonData::setcurrent_ts(ts); // ------------------------------------------------------------ bool retainFlagStatusTemporaryCount = Config::get_essential_config(BRIDGE_ESSENTIAL_CONFIG_INDEX_general_lazy_modifiers_with_mouse_event); enqueue_(params, retainFlagStatusTemporaryCount, item->getDeviceIdentifier()); setTimer(); }
void EventInputQueue::push_ScrollWheelEventCallback(OSObject* target, short deltaAxis1, short deltaAxis2, short deltaAxis3, IOFixed fixedDelta1, IOFixed fixedDelta2, IOFixed fixedDelta3, SInt32 pointDelta1, SInt32 pointDelta2, SInt32 pointDelta3, SInt32 options, AbsoluteTime ts, OSObject* sender, void* refcon) { IOLockWrapper::ScopedLock lk_eventlock(CommonData::getEventLock()); if (! lk_eventlock) return; IOLockWrapper::ScopedLock lk(timer_.getlock()); if (! lk) return; // ------------------------------------------------------------ Params_ScrollWheelEventCallback::auto_ptr ptr(Params_ScrollWheelEventCallback::alloc(deltaAxis1, deltaAxis2, deltaAxis3, fixedDelta1, fixedDelta2, fixedDelta3, pointDelta1, pointDelta2, pointDelta3, options)); if (! ptr) return; Params_ScrollWheelEventCallback& params = *ptr; // ------------------------------------------------------------ DeviceVendor deviceVendor(0); DeviceProduct deviceProduct(0); { IOLockWrapper::ScopedLock lk_device(ListHookedKeyboard::instance().getListLock()); if (! lk_device) return; IOHIPointing* device = OSDynamicCast(IOHIPointing, sender); if (! device) return; ListHookedPointing::Item* item = static_cast<ListHookedPointing::Item*>(ListHookedPointing::instance().get_nolock(device)); if (! item) return; // ------------------------------------------------------------ CommonData::setcurrent_ts(ts); deviceVendor = item->getVendor(); deviceProduct = item->getProduct(); } // ------------------------------------------------------------ bool retainFlagStatusTemporaryCount = Config::get_essential_config(BRIDGE_ESSENTIAL_CONFIG_INDEX_general_lazy_modifiers_with_mouse_event); bool updateWorkspaceData = false; enqueue_(params, retainFlagStatusTemporaryCount, updateWorkspaceData, deviceVendor, deviceProduct); setTimer(); }
// ---------------------------------------------------------------------- void EventInputQueue::push_KeyboardSpecialEventCallback(OSObject* target, unsigned int eventType, unsigned int flags, unsigned int key, unsigned int flavor, UInt64 guid, bool repeat, AbsoluteTime ts, OSObject* sender, void* refcon) { GlobalLock::ScopedLock lk; if (!lk) return; Params_KeyboardSpecialEventCallback::log(true, EventType(eventType), Flags(flags), ConsumerKeyCode(key), flavor, guid, repeat); // ------------------------------------------------------------ Params_KeyboardSpecialEventCallback params(EventType(eventType), Flags(flags), ConsumerKeyCode(key), flavor, guid, repeat); // ------------------------------------------------------------ IOHIKeyboard* device = OSDynamicCast(IOHIKeyboard, sender); if (!device) return; ListHookedConsumer::Item* item = static_cast<ListHookedConsumer::Item*>(ListHookedConsumer::instance().get(device)); if (!item) return; // ------------------------------------------------------------ // Device Hacks // Drop events if "Disable an internal keyboard while external keyboards are connected" is enabled. if (Config::get_essential_config(BRIDGE_ESSENTIAL_CONFIG_INDEX_general_disable_internal_keyboard_if_external_keyboard_exsits)) { if (item->isInternalDevice() && ListHookedKeyboard::instance().isExternalDevicesConnected()) { return; } } // ------------------------------------------------------------ CommonData::setcurrent_ts(ts); // ------------------------------------------------------------ // Because we handle the key repeat ourself, drop the key repeat by hardware. if (repeat) return; // ------------------------------------------------------------ bool retainFlagStatusTemporaryCount = false; enqueue_(params, retainFlagStatusTemporaryCount, item->getDeviceIdentifier()); setTimer(); }
// ---------------------------------------------------------------------- void EventInputQueue::push_KeyboardSpecialEventCallback(OSObject* target, unsigned int eventType, unsigned int flags, unsigned int key, unsigned int flavor, UInt64 guid, bool repeat, AbsoluteTime ts, OSObject* sender, void* refcon) { IOLockWrapper::ScopedLock lk_eventlock(CommonData::getEventLock()); if (! lk_eventlock) return; IOLockWrapper::ScopedLock lk(timer_.getlock()); if (! lk) return; // ------------------------------------------------------------ Params_KeyboardSpecialEventCallback::auto_ptr ptr(Params_KeyboardSpecialEventCallback::alloc(EventType(eventType), Flags(flags), ConsumerKeyCode(key), flavor, guid, repeat)); if (! ptr) return; Params_KeyboardSpecialEventCallback& params = *ptr; // ------------------------------------------------------------ DeviceVendor deviceVendor(0); DeviceProduct deviceProduct(0); { IOLockWrapper::ScopedLock lk_device(ListHookedKeyboard::instance().getListLock()); if (! lk_device) return; IOHIKeyboard* device = OSDynamicCast(IOHIKeyboard, sender); if (! device) return; ListHookedConsumer::Item* item = static_cast<ListHookedConsumer::Item*>(ListHookedConsumer::instance().get_nolock(device)); // ------------------------------------------------------------ CommonData::setcurrent_ts(ts); deviceVendor = item->getVendor(); deviceProduct = item->getProduct(); } // ------------------------------------------------------------ // Because we handle the key repeat ourself, drop the key repeat by hardware. if (repeat) return; // ------------------------------------------------------------ bool retainFlagStatusTemporaryCount = false; bool updateWorkspaceData = params.ex_iskeydown; enqueue_(params, retainFlagStatusTemporaryCount, updateWorkspaceData, deviceVendor, deviceProduct); setTimer(); }
bool enqueue( msg_type const& msg) { typename boost::mutex::scoped_lock lock( mtx_); if ( active_ == false) return false; not_full_cond_.wait( lock, boost::bind( & Queue< T, Q >::suppliers_activate_, this) ); if ( active_ != false) { enqueue_( msg); not_empty_cond_.notify_one(); return true; } else return false; }
// ---------------------------------------------------------------------- void EventInputQueue::push_KeyboardSpecialEventCallback(OSObject* target, unsigned int eventType, unsigned int flags, unsigned int key, unsigned int flavor, UInt64 guid, bool repeat, AbsoluteTime ts, OSObject* sender, void* refcon) { GlobalLock::ScopedLock lk; if (! lk) return; Params_KeyboardSpecialEventCallback::log(true, EventType(eventType), Flags(flags), ConsumerKeyCode(key), flavor, guid, repeat); // ------------------------------------------------------------ Params_KeyboardSpecialEventCallback::auto_ptr ptr(Params_KeyboardSpecialEventCallback::alloc(EventType(eventType), Flags(flags), ConsumerKeyCode(key), flavor, guid, repeat)); if (! ptr) return; Params_KeyboardSpecialEventCallback& params = *ptr; // ------------------------------------------------------------ IOHIKeyboard* device = OSDynamicCast(IOHIKeyboard, sender); if (! device) return; ListHookedConsumer::Item* item = static_cast<ListHookedConsumer::Item*>(ListHookedConsumer::instance().get(device)); if (! item) return; // ------------------------------------------------------------ CommonData::setcurrent_ts(ts); // ------------------------------------------------------------ // Because we handle the key repeat ourself, drop the key repeat by hardware. if (repeat) return; // ------------------------------------------------------------ bool retainFlagStatusTemporaryCount = false; enqueue_(params, retainFlagStatusTemporaryCount, item->getDeviceIdentifier()); setTimer(); }
static void enqueue_(const Params_Base& paramsBase, bool retainFlagStatusTemporaryCount, const DeviceIdentifier& di) { enqueue_(paramsBase, retainFlagStatusTemporaryCount, di, true, true); }
// ====================================================================== void EventInputQueue::push_KeyboardEventCallback(OSObject* target, unsigned int eventType, unsigned int flags, unsigned int key, unsigned int charCode, unsigned int charSet, unsigned int origCharCode, unsigned int origCharSet, unsigned int keyboardType, bool repeat, AbsoluteTime ts, OSObject* sender, void* refcon) { GlobalLock::ScopedLock lk; if (!lk) return; Params_KeyboardEventCallBack::log(true, EventType(eventType), Flags(flags), KeyCode(key), KeyboardType(keyboardType), repeat); // ------------------------------------------------------------ // Ignore unknown modifiers // // You can confirm an unknown modifier by setting key code to 255 on Seil. // This event also will be sent by Fn key on Leopold FC660M. // // KeyboardEventCallback [ caught]: eventType 12, flags 0x80000000, key 0x00ff, kbdType 43, repeat = 0 // // This key sends the same event at key pressing and key releasing. // Therefore, we cannot recognize whether key is pressed or key is released. // So, we have to ignore this key for PressingPhysicalKeys. // if (EventType::MODIFY == EventType(eventType)) { if (KeyCode(key).getModifierFlag() == ModifierFlag::ZERO) { IOLOG_DEBUG("An unknown modifier is pressed (KeyCode:0x%x, Flags:0x%x). Ignore it.\n", key, flags); return; } } // ------------------------------------------------------------ KeyboardType newkeyboardtype(keyboardType); RemapClassManager::remap_setkeyboardtype(newkeyboardtype); KeyCode newkey(key); Flags newflags(flags); KeyCode::normalizeKey(newkey, newflags, EventType(eventType), newkeyboardtype); // ------------------------------------------------------------ Params_KeyboardEventCallBack params(EventType(eventType), newflags, newkey, CharCode(charCode), CharSet(charSet), OrigCharCode(origCharCode), OrigCharSet(origCharSet), newkeyboardtype, repeat); // ------------------------------------------------------------ IOHIKeyboard* device = OSDynamicCast(IOHIKeyboard, sender); if (!device) return; ListHookedKeyboard::Item* item = static_cast<ListHookedKeyboard::Item*>(ListHookedKeyboard::instance().get(device)); if (!item) return; // ------------------------------------------------------------ // Device Hacks // Drop events if "Disable an internal keyboard while external keyboards are connected" is enabled. if (Config::get_essential_config(BRIDGE_ESSENTIAL_CONFIG_INDEX_general_disable_internal_keyboard_if_external_keyboard_exsits)) { if (item->isInternalDevice() && ListHookedKeyboard::instance().isExternalDevicesConnected()) { return; } } // Logitech Cordless Presenter (LCP) Hack // // When an LCP is first plugged in, it will send a CONTROL_L down event // when the first pageup/pagedown key is pressed without sending a corresponding // up event -- effectively rendering the device (and the Mac) useless until it is // unplugged from the system. // // Similarly, when the volume keys are first pressed, a SHIFT_L down event // is generated, with now up event. // // This code effectively throws these events away if they are received from an LCP. // // *** LCP has 6 keys (Page Up, Page Down, a 'B' key, an 'Esc' key, and volume up / down keys). *** // *** So, we can drop CONTROL_L and SHIFT_L without a problem. *** if ((item->getDeviceIdentifier()).isEqualVendorProduct(DeviceVendor::LOGITECH, DeviceProduct::LOGITECH_CORDLESS_PRESENTER)) { if (params.key == KeyCode::CONTROL_L) return; if (params.key == KeyCode::SHIFT_L) return; } // ------------------------------------------------------------ // NumLock Hacks // // As for some keypads, NumLock is off when it was connected. // We need to call setAlphaLock(true) to activate a device. RemapClassManager::remap_forcenumlockon(item); // ------------------------------------------------------------ CommonData::setcurrent_ts(ts); // ------------------------------------------------------------ // Because we handle the key repeat ourself, drop the key repeat by hardware. if (repeat) return; // ------------------------------------------------------------ bool retainFlagStatusTemporaryCount = false; bool push_back = true; bool isSimultaneousKeyPressesTarget = true; enqueue_(params, retainFlagStatusTemporaryCount, item->getDeviceIdentifier(), push_back, isSimultaneousKeyPressesTarget); setTimer(); }
// ---------------------------------------------------------------------- void EventInputQueue::push_RelativePointerEventCallback(OSObject* target, int buttons_raw, int dx, int dy, AbsoluteTime ts, OSObject* sender, void* refcon) { IOLockWrapper::ScopedLock lk_eventlock(CommonData::getEventLock()); if (! lk_eventlock) return; IOLockWrapper::ScopedLock lk(timer_.getlock()); if (! lk) return; // ------------------------------------------------------------ Buttons buttons(buttons_raw); Buttons justPressed; Buttons justReleased; DeviceVendor deviceVendor(0); DeviceProduct deviceProduct(0); { IOLockWrapper::ScopedLock lk_device(ListHookedKeyboard::instance().getListLock()); if (! lk_device) return; IOHIPointing* device = OSDynamicCast(IOHIPointing, sender); if (! device) return; ListHookedPointing::Item* item = static_cast<ListHookedPointing::Item*>(ListHookedPointing::instance().get_nolock(device)); if (! item) return; // ------------------------------------------------------------ CommonData::setcurrent_ts(ts); deviceVendor = item->getVendor(); deviceProduct = item->getProduct(); // ------------------------------------------------------------ justPressed = buttons.justPressed(item->get_previousbuttons()); justReleased = buttons.justReleased(item->get_previousbuttons()); item->set_previousbuttons(buttons); } // ------------------------------------------------------------ // divide an event into button and cursormove events. for (int i = 0; i < ButtonStatus::MAXNUM; ++i) { PointingButton btn(1 << i); if (justPressed.isOn(btn)) { Params_RelativePointerEventCallback::auto_ptr ptr(Params_RelativePointerEventCallback::alloc(buttons, 0, 0, btn, true)); if (! ptr) return; bool retainFlagStatusTemporaryCount = Config::get_essential_config(BRIDGE_ESSENTIAL_CONFIG_INDEX_general_lazy_modifiers_with_mouse_event); enqueue_(*ptr, retainFlagStatusTemporaryCount, deviceVendor, deviceProduct); } if (justReleased.isOn(btn)) { Params_RelativePointerEventCallback::auto_ptr ptr(Params_RelativePointerEventCallback::alloc(buttons, 0, 0, btn, false)); if (! ptr) return; bool retainFlagStatusTemporaryCount = Config::get_essential_config(BRIDGE_ESSENTIAL_CONFIG_INDEX_general_lazy_modifiers_with_mouse_event); enqueue_(*ptr, retainFlagStatusTemporaryCount, deviceVendor, deviceProduct); } } Params_RelativePointerEventCallback::auto_ptr ptr(Params_RelativePointerEventCallback::alloc(buttons, dx, dy, PointingButton::NONE, false)); if (! ptr) return; bool retainFlagStatusTemporaryCount = true; enqueue_(*ptr, retainFlagStatusTemporaryCount, deviceVendor, deviceProduct); setTimer(); }
// ====================================================================== void EventInputQueue::push_KeyboardEventCallback(OSObject* target, unsigned int eventType, unsigned int flags, unsigned int key, unsigned int charCode, unsigned int charSet, unsigned int origCharCode, unsigned int origCharSet, unsigned int keyboardType, bool repeat, AbsoluteTime ts, OSObject* sender, void* refcon) { IOLockWrapper::ScopedLock lk_eventlock(CommonData::getEventLock()); if (! lk_eventlock) return; IOLockWrapper::ScopedLock lk(timer_.getlock()); if (! lk) return; // ------------------------------------------------------------ KeyboardType newkeyboardtype(keyboardType); RemapClassManager::remap_setkeyboardtype(newkeyboardtype); KeyCode newkey(key); Flags newflags(flags); KeyCode::normalizeKey(newkey, newflags, EventType(eventType), newkeyboardtype); // ------------------------------------------------------------ Params_KeyboardEventCallBack::auto_ptr ptr(Params_KeyboardEventCallBack::alloc(EventType(eventType), newflags, newkey, CharCode(charCode), CharSet(charSet), OrigCharCode(origCharCode), OrigCharSet(origCharSet), newkeyboardtype, repeat)); if (! ptr) return; Params_KeyboardEventCallBack& params = *ptr; // ------------------------------------------------------------ DeviceVendor deviceVendor(0); DeviceProduct deviceProduct(0); { IOLockWrapper::ScopedLock lk_device(ListHookedKeyboard::instance().getListLock()); if (! lk_device) return; IOHIKeyboard* device = OSDynamicCast(IOHIKeyboard, sender); if (! device) return; ListHookedKeyboard::Item* item = static_cast<ListHookedKeyboard::Item*>(ListHookedKeyboard::instance().get_nolock(device)); if (! item) return; // ------------------------------------------------------------ // Logitech Cordless Presenter (LCP) Hack // // When an LCP is first plugged in, it will send a CONTROL_L down event // when the first pageup/pagedown key is pressed without sending a corresponding // up event -- effectively rendering the device (and the Mac) useless until it is // unplugged from the system. // // Similarly, when the volume keys are first pressed, a SHIFT_L down event // is generated, with now up event. // // This code effectively throws these events away if they are received from an LCP. // // *** LCP has 6 keys (Page Up, Page Down, a 'B' key, an 'Esc' key, and volume up / down keys). *** // *** So, we can drop CONTROL_L and SHIFT_L without a problem. *** if (item->isEqualVendorProduct(DeviceVendor::LOGITECH, DeviceProduct::LOGITECH_CORDLESS_PRESENTER)) { if (params.key == KeyCode::CONTROL_L) return; if (params.key == KeyCode::SHIFT_L) return; } // ------------------------------------------------------------ // "ts & keyboardType" are not used in filters like <not>/<only>. // Therefore, we can set current ts and keyboardType here. CommonData::setcurrent_ts(ts); CommonData::setcurrent_keyboardType(params.keyboardType); deviceVendor = item->getVendor(); deviceProduct = item->getProduct(); } // ------------------------------------------------------------ // Because we handle the key repeat ourself, drop the key repeat by hardware. if (repeat) return; // ------------------------------------------------------------ bool retainFlagStatusTemporaryCount = false; bool push_back = true; enqueue_(params, retainFlagStatusTemporaryCount, deviceVendor, deviceProduct, push_back); setTimer(); }