diff options
author | dakkar <dakkar@thenautilus.net> | 2019-02-22 12:24:18 +0000 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2019-02-22 12:26:05 +0000 |
commit | 17faf830fbe12222e64d9b92ac14cb1c8742ac96 (patch) | |
tree | 176699d113aa1d4c409898dc540769c9019d6cd9 /macros.h | |
parent | move layer declaration to its own header (diff) | |
download | keyboardio-model01-17faf830fbe12222e64d9b92ac14cb1c8742ac96.tar.gz keyboardio-model01-17faf830fbe12222e64d9b92ac14cb1c8742ac96.tar.bz2 keyboardio-model01-17faf830fbe12222e64d9b92ac14cb1c8742ac96.zip |
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.
Diffstat (limited to 'macros.h')
-rw-r--r-- | macros.h | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -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; } |