Remove numlock state management logic from NumPad plugin

NOTE: This change depends on the keymap changing to use the numrow keys in the numpad layer.

Signed-off-by: Scott Perry <dev@numist.net>
pull/575/head
Scott Perry 6 years ago
parent 338fbd4c4f
commit c47bea391a

@ -1,7 +1,7 @@
# Kaleidoscope-NumPad
This is a plugin for [Kaleidoscope][fw], that adds a NumPad-specific LED
effect, along with a way to toggle to a numpad layer, and apply the effect.
effect and applies it when the numpad layer is active.
## Using the extension

@ -19,45 +19,19 @@
namespace kaleidoscope {
namespace plugin {
byte NumPad::numpadLayerToggleKeyRow = 255, NumPad::numpadLayerToggleKeyCol = 255;
// public:
uint8_t NumPad::numPadLayer;
bool NumPad::numlockUnsynced = false;
bool NumPad::originalNumLockState = false;
cRGB NumPad::color = CRGB(160, 0, 0);
uint8_t NumPad::lock_hue = 170;
// private:
byte NumPad::numpadLayerToggleKeyRow = 255, NumPad::numpadLayerToggleKeyCol = 255;
bool NumPad::numpadActive = false;
EventHandlerResult NumPad::onSetup(void) {
originalNumLockState = getNumlockState();
return EventHandlerResult::OK;
}
bool NumPad::getNumlockState() {
return !!(kaleidoscope::hid::getKeyboardLEDs() & LED_NUM_LOCK);
}
void NumPad::syncNumlockState(bool state) {
bool numLockLEDState = getNumlockState();
if (numLockLEDState != state) {
kaleidoscope::hid::pressKey(Key_KeypadNumLock);
}
}
void NumPad::cleanupNumlockState() {
if (!numlockUnsynced) {
bool numLockLEDState = getNumlockState();
::LEDControl.set_mode(::LEDControl.get_mode_index());
if (!originalNumLockState) {
syncNumlockState(false);
numLockLEDState = false;
}
originalNumLockState = numLockLEDState;
numlockUnsynced = true;
}
}
void NumPad::setKeyboardLEDColors(void) {
::LEDControl.set_mode(::LEDControl.get_mode_index());
@ -87,12 +61,13 @@ void NumPad::setKeyboardLEDColors(void) {
EventHandlerResult NumPad::afterEachCycle() {
if (!Layer.isActive(numPadLayer)) {
cleanupNumlockState();
if (numpadActive) {
::LEDControl.set_mode(::LEDControl.get_mode_index());
numpadActive = false;
}
} else {
if (numlockUnsynced) {
// If it's the first time we're in this loop after toggling the Numpad mode on
syncNumlockState(true);
numlockUnsynced = false;
if (!numpadActive) {
numpadActive = true;
}
setKeyboardLEDColors();
}

@ -34,15 +34,11 @@ class NumPad : public kaleidoscope::Plugin {
private:
void cleanupNumlockState(void);
void setKeyboardLEDColors(void);
bool getNumlockState(void);
void syncNumlockState(bool);
static uint8_t numpadLayerToggleKeyRow;
static uint8_t numpadLayerToggleKeyCol;
static bool numlockUnsynced;
static bool originalNumLockState;
static bool numpadActive;
};
}
}

Loading…
Cancel
Save