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