Skip to content

Commit

Permalink
Send numlock keypress when disabling the numpad layer.
Browse files Browse the repository at this point in the history
This avoids the OS being stuck with Numlock on, which leaves the LED on
if other keyboard are attached, and breaks FVWM.

See keyboardio/Model01-Firmware#42
  • Loading branch information
edanaher committed Feb 22, 2018
1 parent 952198a commit 1017cfd
Showing 1 changed file with 9 additions and 4 deletions.
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

0 comments on commit 1017cfd

Please sign in to comment.