Exemplo n.º 1
0
bool ForceNumLockOn::remapForceNumLockOn(ListHookedKeyboard::Item* item) {
  if (!item) return false;
  if (index_ < 2) return false;

  if (!(item->getDeviceIdentifier()).isEqual(deviceIdentifier_)) return false;

  // NumLock Hacks
  //
  // As for some keypads, NumLock is off when it was connected.
  // We need to call setNumLock(true) to activate a device.
  IOHIKeyboard* kbd = OSDynamicCast(IOHIKeyboard, item->get());
  if (kbd) {
    GlobalLock::ScopedUnlock lk;
    if (!forceOffMode_) {
      if (!kbd->numLock()) {
        kbd->setNumLock(true);
      }
    } else {
      if (kbd->numLock()) {
        kbd->setNumLock(false);
      }
    }
  }

  return false;
}
Exemplo n.º 2
0
void ListHookedKeyboard::setcapslock_timer_callback(OSObject* owner, IOTimerEventSource* sender) {
  ListHookedKeyboard& self = ListHookedKeyboard::instance();

  if (Config::get_essential_config(BRIDGE_ESSENTIAL_CONFIG_INDEX_general_passthrough_capslock_led_status)) return;

  Flags flags = FlagStatus::globalFlagStatus().makeFlags();

  for (Item* p = static_cast<Item*>(self.list_.safe_front()); p; p = static_cast<Item*>(p->getnext())) {
    if (!p->isReplaced()) continue;

    // Don't call setAlphaLock on devices which have non-Apple driver.
    if (p->getDeviceType() != DeviceType::APPLE_INTERNAL &&
        p->getDeviceType() != DeviceType::APPLE_EXTERNAL) {
      continue;
    }

    IOHIKeyboard* kbd = OSDynamicCast(IOHIKeyboard, p->get());
    if (!kbd) continue;

    {
      GlobalLock::ScopedUnlock lk;

      // We call setAlphaLock to match a state of CapsLock of the hardware with remapped CapsLock.
      if (flags.isOn(ModifierFlag::CAPSLOCK)) {
        if (!kbd->alphaLock()) {
          kbd->setAlphaLock(true);
        }
      } else {
        if (kbd->alphaLock()) {
          kbd->setAlphaLock(false);
        }
      }
    }
  }
}
  void
  ListHookedConsumer::Item::disableNumLock(void)
  {
    IOHIKeyboard* kbd = OSDynamicCast(IOHIKeyboard, device_);
    if (! kbd) return;

    if (kbd->numLock()) {
      kbd->setNumLock(false);
    }
  }
bool VirtualKey::VK_IOHIKEYBOARD_TOGGLE_NUMLOCK::handle(const Params_KeyboardEventCallBack& params, AutogenId autogenId, PhysicalEventType physicalEventType) {
  if (params.key != KeyCode::VK_IOHIKEYBOARD_TOGGLE_NUMLOCK) return false;

  if (params.ex_iskeydown && params.repeat == false) {
    ListHookedKeyboard::Item* item = static_cast<ListHookedKeyboard::Item*>(ListHookedKeyboard::instance().get_replaced());
    if (item) {
      IOHIKeyboard* kbd = OSDynamicCast(IOHIKeyboard, item->get());
      if (kbd) {
        GlobalLock::ScopedUnlock lk;
        kbd->setNumLock(!kbd->numLock());
      }
    }
  }

  return true;
}
Exemplo n.º 5
0
void IOHIKeyboard::_autoRepeat(thread_call_param_t arg,
                               thread_call_param_t)         /* thread_call_func_t */
{
    IOHIKeyboard *self = (IOHIKeyboard *) arg;
    self->autoRepeat();
}