/*********************************************************************** * 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 #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). * * XXX doesn't work with repeats... * https://github.com/keyboardio/Kaleidoscope/issues/647 */ #define TopRow(k1, k2) \ if (keyToggledOn(event.state)) { \ if (Kaleidoscope.hid().keyboard().wasModifierKeyActive(Key_LeftControl) || \ Kaleidoscope.hid().keyboard().wasModifierKeyActive(Key_RightAlt)) \ return MACRO(Dr(k2)); \ else \ return MACRO(Dr(k1)); \ }; const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) { switch (macro_id) { 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; } }