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

Commit

Permalink
Merge pull request #2 from edanaher/fix-numlock-off
Browse files Browse the repository at this point in the history
Send numlock keypress when disabling the numpad layer.
  • Loading branch information
algernon authored Mar 9, 2018
2 parents 28bd356 + 1017cfd commit 3e7b4cb
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 3e7b4cb

Please sign in to comment.