From 17faf830fbe12222e64d9b92ac14cb1c8742ac96 Mon Sep 17 00:00:00 2001 From: dakkar Date: Fri, 22 Feb 2019 12:24:18 +0000 Subject: numlock as a macro Press the NumLock key, switch the layer. Previously, pressing the NumLock key was handled by the NumPad plugin (which mostly deals with LED colors). I stopped using that plugin when I built my own LED plugin. Also, recently the NumPad plugin stopped handling the NumLock press, so we really need to do it here. --- macros.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'macros.h') diff --git a/macros.h b/macros.h index 06df775..715d2bc 100644 --- a/macros.h +++ b/macros.h @@ -2,9 +2,11 @@ #pragma once #include "kaleidoscope/plugin/Macros.h" +#include "keymap-layers.h" enum { MACRO_VERSION_INFO, - MACRO_ANY + MACRO_ANY, + MACRO_NUMLOCK, }; #ifndef BUILD_INFORMATION @@ -30,6 +32,18 @@ static void anyKeyMacro(uint8_t keyState) { kaleidoscope::hid::pressKey(lastKey, toggledOn); } +static void numLockMacro(uint8_t keyState) { + if (keyToggledOn(keyState)) { + kaleidoscope::hid::pressKey(Key_KeypadNumLock); + if (Layer.isActive(NUMPAD)) { + Layer.deactivate(NUMPAD); + } + else { + Layer.activate(NUMPAD); + } + } +} + const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) { switch (macroIndex) { @@ -40,6 +54,10 @@ const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) { case MACRO_ANY: anyKeyMacro(keyState); break; + + case MACRO_NUMLOCK: + numLockMacro(keyState); + break; } return MACRO_NONE; } -- cgit v1.2.3