Switch to not trying to use 'Numlock' as a toggle.

pull/365/head
Jesse Vincent 7 years ago
parent 45a71751e8
commit 1333f30252

@ -5,7 +5,7 @@
byte NumLock_::row = 255, NumLock_::col = 255;
uint8_t NumLock_::numPadLayer;
bool NumLock_::isOn;
bool NumLock_::cleanupDone = true;
cRGB numpad_color = CRGB(255, 0, 0);
void NumLock_::begin(void) {
@ -16,25 +16,33 @@ void NumLock_::loopHook(bool postClear) {
if (!postClear)
return;
bool numState = !!(kaleidoscope::hid::getKeyboardLEDs() & LED_NUM_LOCK);
if (numState != isOn) {
isOn = numState;
if (isOn) {
Layer.on(numPadLayer);
} else {
Layer.off(numPadLayer);
if (!Layer.isOn(numPadLayer)) {
if (!cleanupDone) {
LEDControl.set_mode(LEDControl.get_mode_index());
cleanupDone = true;
}
return;
}
if (!isOn)
return;
cleanupDone = false;
bool numState = !!(kaleidoscope::hid::getKeyboardLEDs() & LED_NUM_LOCK);
if (!numState) {
kaleidoscope::hid::pressKey(Key_KeypadNumLock);
kaleidoscope::hid::sendKeyboardReport();
}
LEDControl.set_mode(LEDControl.get_mode_index());
for (uint8_t r = 0; r < ROWS; r++) {
for (uint8_t c = 0; c < COLS; c++) {
Key k = Layer.lookupOnActiveLayer(r, c);
Key layer_key = Layer.getKey(numPadLayer, r, c);
if (k == LockLayer(numPadLayer)) {
row = r;
col = c;
}
if ((k != layer_key) || (k.flags != KEY_FLAGS)) {
LEDControl.refreshAt(r, c);
} else {

@ -16,7 +16,7 @@ class NumLock_ : public KaleidoscopePlugin {
static void loopHook(const bool postClear);
static byte row, col;
static bool isOn;
static bool cleanupDone;
};
extern NumLock_ NumLock;

Loading…
Cancel
Save