Skip to content
This repository has been archived by the owner on Jul 13, 2021. It is now read-only.

Send numlock keypress when disabling the numpad layer. #2

Merged
merged 1 commit into from
Mar 9, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/Kaleidoscope-NumPad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,28 @@ void NumPad_::begin(void) {
Kaleidoscope.useLoopHook(loopHook);
}

static void syncNumlock(bool state) {
bool numState = !!(kaleidoscope::hid::getKeyboardLEDs() & LED_NUM_LOCK);
if (numState != state) {
kaleidoscope::hid::pressKey(Key_KeypadNumLock);
}
}

void NumPad_::loopHook(bool postClear) {
if (!postClear)
return;

if (!Layer.isOn(numPadLayer)) {
if (!cleanupDone) {
LEDControl.set_mode(LEDControl.get_mode_index());
syncNumlock(false);
cleanupDone = true;
}
return;
}

cleanupDone = false;
bool numState = !!(kaleidoscope::hid::getKeyboardLEDs() & LED_NUM_LOCK);
if (!numState) {
kaleidoscope::hid::pressKey(Key_KeypadNumLock);
}
syncNumlock(true);

LEDControl.set_mode(LEDControl.get_mode_index());

Expand Down