Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* -*- mode: c++ -*-
- * Atreus -- Chrysalis-enabled Sketch for the Keyboardio Atreus
- * Copyright (C) 2018, 2019 Keyboard.io, Inc
- *
- * 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 2 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, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
- #ifndef BUILD_INFORMATION
- #define BUILD_INFORMATION "locally built"
- #endif
- #include "Kaleidoscope.h"
- #include "Kaleidoscope-Macros.h"
- #include "Kaleidoscope-OneShot.h"
- #include "Kaleidoscope-Qukeys.h"
- #include "Kaleidoscope-HostOS.h"
- #include "Kaleidoscope-Unicode.h"
- #define SHIFT(n) ShiftToLayer(n)
- // Macros
- enum {
- MACRO_QWERTY,
- MACRO_VERSION_INFO,
- EM_DASH,
- EN_DASH,
- LEFT_SINGLE_QUOTE,
- RIGHT_SINGLE_QUOTE,
- LEFT_DOUBLE_QUOTE,
- RIGHT_DOUBLE_QUOTE,
- ELLIPSIS,
- SMILEY,
- SAD,
- THINK,
- THUMB,
- HI_FIVE,
- SWEAT
- };
- #define Key_Exclamation LSHIFT(Key_1)
- #define Key_At LSHIFT(Key_2)
- #define Key_Hash LSHIFT(Key_3)
- #define Key_Dollar LSHIFT(Key_4)
- #define Key_Percent LSHIFT(Key_5)
- #define Key_Caret LSHIFT(Key_6)
- #define Key_And LSHIFT(Key_7)
- #define Key_Star LSHIFT(Key_8)
- #define Key_Plus LSHIFT(Key_Equals)
- #define Key_Pipe LSHIFT(Key_Backslash)
- #define Key_Question LSHIFT(Key_Slash)
- #define Key_Colon LSHIFT(Key_P) // P is ; in Colemak
- #define Key_Underscore LSHIFT(Key_Minus)
- #define Key_DoubleQuote LSHIFT(Key_Quote)
- #define Key_RightAngleBracket LSHIFT(Key_Period)
- // Layers
- enum {
- QWERTY,
- FUN,
- UPPER,
- SUPER
- };
- /* *INDENT-OFF* */
- KEYMAPS(
- [QWERTY] = KEYMAP_STACKED
- (
- Key_Q ,Key_W ,Key_E ,Key_R ,Key_T
- ,Key_A ,Key_S ,Key_D ,Key_F ,Key_G
- ,Key_Z ,Key_X ,Key_C ,Key_V ,Key_B ,Key_Backslash
- ,Key_Esc ,Key_CapsLock ,Key_Delete ,Key_Backspace ,Key_LeftShift ,Key_Tab
- ,Key_Y ,Key_U ,Key_I ,Key_O ,Key_Minus
- ,Key_H ,Key_J ,Key_K ,Key_L ,Key_Semicolon
- ,Key_Backtick ,Key_N ,Key_M ,Key_Comma ,Key_Period ,Key_Quote
- ,Key_Enter ,Key_Space ,OSL(FUN) ,Key_Tab ,Key_Enter ,Key_LeftGui
- ),
- [FUN] = KEYMAP_STACKED
- (
- Key_5 ,Key_6 ,Key_7 ,Key_8 ,Key_9
- ,Key_0 ,Key_1 ,Key_2 ,Key_3 ,Key_4
- ,M(LEFT_DOUBLE_QUOTE) ,M(RIGHT_DOUBLE_QUOTE) ,M(LEFT_SINGLE_QUOTE) ,M(THUMB) ,M(SWEAT) ,M(RIGHT_SINGLE_QUOTE)
- ,Key_RightControl ,___ ,Key_Delete ,Key_Backspace ,Key_LeftShift ,Key_LeftControl
- // RightControl is remapped to Calculator in SharpKeys
- ,M(HI_FIVE) ,Key_PageUp ,Key_UpArrow ,Key_PageDown ,Key_Minus
- ,Key_Home ,Key_LeftArrow ,Key_DownArrow ,Key_RightArrow ,Key_End
- ,M(THINK) ,M(SAD) ,M(SMILEY) ,Key_Comma ,Key_Period ,M(ELLIPSIS)
- ,Key_LeftAlt ,Key_Space ,___ ,Key_Tab ,Key_Enter ,___
- ),
- [UPPER] = KEYMAP_STACKED
- (
- M(EM_DASH) ,M(EN_DASH) ,Key_At ,Key_Hash ,Key_Percent
- ,Key_Question ,Key_Exclamation ,Key_Colon ,Key_Equals ,Key_Slash
- ,Key_PcApplication ,Key_Pipe ,Key_And ,Key_P ,Key_Dollar ,___ // P is ; in Colemak
- ,Key_ScrollLock ,Key_PrintScreen ,Key_Backspace ,___ ,Key_LeftShift ,Key_LeftControl
- // Application, ScrollLock, and PrintScreen are remapped to Volume Up/Down and Mute in SharpKeys
- // (Key_VolumeUp, Key_VolumeDown, and Key_Mute do not work for me)
- ,Key_Caret ,Key_LeftBracket ,Key_RightBracket ,___ ,Key_Underscore
- ,Key_Star ,Key_LeftParen ,Key_RightParen ,___ ,___
- ,___ ,Key_Plus ,Key_LeftCurlyBracket ,Key_RightCurlyBracket ,Key_RightAngleBracket ,Key_DoubleQuote
- ,Key_LeftAlt ,Key_Space ,XXX ,Key_Backspace ,Key_Enter ,___
- ),
- [SUPER] = KEYMAP_STACKED
- (
- Key_F13 ,Key_F14 ,Key_F15 ,Key_F16 ,Key_F11
- ,Key_F17 ,Key_F18 ,Key_F19 ,Key_F20 ,Key_F5
- ,Key_F21 ,Key_F22 ,Key_F23 ,Key_F24 ,Key_F2 ,Key_F3
- ,Key_F12 ,___ ,___ ,___ ,Key_LeftShift ,Key_LeftControl
- ,___ ,Key_F12 ,Key_F11 ,Key_F10 ,Key_F9
- ,___ ,Key_F8 ,Key_F7 ,Key_F6 ,Key_F5
- ,Key_F4 ,___ ,Key_F4 ,Key_F3 ,Key_F2 ,Key_F1
- ,Key_LeftAlt ,___ ,___ ,___ ,___ ,___
- )
- )
- /* *INDENT-ON* */
- KALEIDOSCOPE_INIT_PLUGINS(
- Qukeys,
- OneShot,
- Macros,
- HostOS,
- Unicode
- );
- static void unicode(uint32_t character, uint8_t keyState) {
- if (keyToggledOn(keyState)) {
- Unicode.type(character);
- }
- }
- const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) {
- switch (macroIndex) {
- case MACRO_QWERTY:
- // This macro is currently unused, but is kept around for compatibility
- // reasons. We used to use it in place of `MoveToLayer(QWERTY)`, but no
- // longer do. We keep it so that if someone still has the old layout with
- // the macro in EEPROM, it will keep working after a firmware update.
- Layer.move(QWERTY);
- break;
- case MACRO_VERSION_INFO:
- if (keyToggledOn(keyState)) {
- Macros.type(PSTR("Keyboardio Atreus - Kaleidoscope "));
- Macros.type(PSTR(BUILD_INFORMATION));
- }
- break;
- case EM_DASH:
- unicode(0x2014, keyState);
- break;
- case EN_DASH:
- unicode(0x2013, keyState);
- break;
- case LEFT_SINGLE_QUOTE:
- unicode(0x2018, keyState);
- break;
- case RIGHT_SINGLE_QUOTE:
- unicode(0x2019, keyState);
- break;
- case LEFT_DOUBLE_QUOTE:
- unicode(0x201C, keyState);
- break;
- case RIGHT_DOUBLE_QUOTE:
- unicode(0x201D, keyState);
- break;
- case ELLIPSIS:
- unicode(0x2026, keyState);
- break;
- case SAD:
- unicode(0x1F61E, keyState);
- break;
- case SMILEY:
- unicode(0x1F642, keyState);
- break;
- case THINK:
- unicode(0x1F914, keyState);
- break;
- case THUMB:
- unicode(0x1F44D, keyState);
- break;
- case HI_FIVE:
- unicode(0x1F64C, keyState);
- break;
- case SWEAT:
- unicode(0x1F605, keyState);
- break;
- }
- return MACRO_NONE;
- }
- void setup() {
- QUKEYS(
- kaleidoscope::plugin::Qukey(0, KeyAddr(3, 1), SHIFT(SUPER)), // CapsLock/Super
- kaleidoscope::plugin::Qukey(0, KeyAddr(3, 3), SHIFT(UPPER)), // Backspace/Upper
- kaleidoscope::plugin::Qukey(0, KeyAddr(3, 5), Key_LeftControl), // Tab/Ctrl
- kaleidoscope::plugin::Qukey(0, KeyAddr(3, 6), Key_LeftAlt), // Enter/Alt
- )
- Qukeys.setHoldTimeout(250); // a lower value than this causes modifier or primary key sometimes not to register when they should
- Qukeys.setOverlapThreshold(20);
- Qukeys.setMinimumHoldTime(20);
- Qukeys.setMinimumPriorInterval(200);
- Qukeys.activate();
- Kaleidoscope.setup();
- }
- void loop() {
- Kaleidoscope.loop();
- }
Add Comment
Please, Sign In to add comment