From 461109e695f163303549648d93dc7d9253e88b81 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Tue, 25 Jun 2019 13:56:52 +0200 Subject: For the top row, return the num key when a modifier is active. This is useful with a window manager like i3: without this macro it doesn't see the difference between $mod+R0C2 (switch to workspace #2) and $mod+shift+R0C2 (move focused container to workspace #2), as R0C2 triggers LSHIFT(Key_2). --- src/Macros.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/Macros.cpp (limited to 'src/Macros.cpp') diff --git a/src/Macros.cpp b/src/Macros.cpp new file mode 100644 index 0000000..2fd4229 --- /dev/null +++ b/src/Macros.cpp @@ -0,0 +1,52 @@ +/*********************************************************************** + * A firmware Sketch for the Keyboardio Model 01 + * Copyright © 2019 Guilhem Moulin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + **********************************************************************/ + +#include +#include "Macros.h" + +/* For the top row, return the num key (not the symbol) when the Control + * and/or Alt modifier is active. This is useful with a window manager + * like i3: without this macro it doesn't see the difference between + * $mod+R0C2 (switch to workspace #2) and $mod+shift+R0C2 (move focused + * container to workspace #2), as R0C2 triggers LSHIFT(Key_2). + */ +#define TopRow(k1, k2) \ + if (kaleidoscope::hid::isModifierKeyActive(Key_LeftControl) || \ + ::OneShot.isModifierActive(Key_LeftControl) || \ + kaleidoscope::hid::isModifierKeyActive(Key_RightAlt) || \ + ::OneShot.isModifierActive(Key_RightAlt)) \ + return MACRODOWN(Tr(k2)); \ + else \ + return MACRODOWN(Tr(k1)); \ + +const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) { + switch (macroIndex) { + case AT: TopRow(LSHIFT(Key_2), Key_2); + case STAR: TopRow(LSHIFT(Key_8), Key_3); + case DOLLAR: TopRow(LSHIFT(Key_4), Key_4); + case CARET: TopRow(LSHIFT(Key_6), Key_5); + case PERCENT: TopRow(LSHIFT(Key_5), Key_6); + case BANG: TopRow(LSHIFT(Key_1), Key_7); + case HASH: TopRow(LSHIFT(Key_3), Key_8); + case AMPERSAND: TopRow(LSHIFT(Key_7), Key_9); + case LEFT_BRACKET: TopRow(LSHIFT(Key_LeftBracket), Key_1); + case RIGHT_BRACKET: TopRow(LSHIFT(Key_RightBracket), Key_0); + default: + return MACRO_NONE; + } +} -- cgit v1.2.3