void
 ListHookedConsumer::disableNumLock(void)
 {
   ListHookedConsumer::Item* p = static_cast<ListHookedConsumer::Item*>(get_replaced());
   if (p) {
     p->disableNumLock();
   }
 }
 void
 ListHookedConsumer::apply(const Params_KeyboardSpecialEventCallback& params)
 {
   ListHookedConsumer::Item* p = static_cast<ListHookedConsumer::Item*>(get_replaced());
   if (p) {
     p->apply(params);
   }
 }
  void
  ListHookedConsumer::disableNumLock(void)
  {
    IOLockWrapper::ScopedLock lk(list_lock_);
    if (! lk) return;

    ListHookedConsumer::Item* p = static_cast<ListHookedConsumer::Item*>(get_replaced_nolock());
    if (p) {
      p->disableNumLock();
    }
  }
  void
  ListHookedConsumer::apply(const Params_KeyboardSpecialEventCallback& params)
  {
    IOLockWrapper::ScopedLock lk(list_lock_);
    if (! lk) return;

    ListHookedConsumer::Item* p = static_cast<ListHookedConsumer::Item*>(get_replaced_nolock());
    if (p) {
      p->apply(params);
    }
  }
Esempio n. 5
0
// ----------------------------------------------------------------------
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();
}
Esempio n. 6
0
  // ----------------------------------------------------------------------
  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();
  }
  // ----------------------------------------------------------------------
  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();
  }