Created
October 20, 2024 07:52
-
-
Save woochica/747a609e5e0d5c795c4568b39f74f1b5 to your computer and use it in GitHub Desktop.
Custom Atreus keyboard layout for Kaleidoscope
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* -*- mode: c++ -*- | |
* Atreus -- Chrysalis-enabled Sketch for the Keyboardio Atreus | |
* Copyright (C) 2018-2022 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 on " __DATE__ " at " __TIME__ | |
#endif | |
#include "Kaleidoscope.h" | |
#include "Kaleidoscope-EEPROM-Settings.h" | |
#include "Kaleidoscope-EEPROM-Keymap.h" | |
#include "Kaleidoscope-Escape-OneShot.h" | |
#include "Kaleidoscope-FirmwareVersion.h" | |
#include "Kaleidoscope-FocusSerial.h" | |
#include "Kaleidoscope-Macros.h" | |
#include "Kaleidoscope-MouseKeys.h" | |
#include "Kaleidoscope-OneShot.h" | |
#include "Kaleidoscope-Qukeys.h" | |
#include "Kaleidoscope-SpaceCadet.h" | |
#include "Kaleidoscope-DynamicMacros.h" | |
#include "Kaleidoscope-LayerNames.h" | |
#define MO(n) ShiftToLayer(n) | |
#define TG(n) LockLayer(n) | |
enum { | |
MACRO_QWERTY, | |
MACRO_VERSION_INFO | |
}; | |
#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) | |
enum { | |
QWERTY, | |
FUN, | |
UPPER | |
}; | |
KEYMAPS( | |
[QWERTY] = KEYMAP_STACKED | |
( | |
// left side | |
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_Tab | |
,TG(FUN) ,Key_Backslash ,Key_Backtick ,Key_LeftShift ,Key_Backspace ,Key_LeftControl | |
// right side | |
,Key_Y ,Key_U ,Key_I ,Key_O ,Key_P | |
,Key_H ,Key_J ,Key_K ,Key_L ,Key_Semicolon | |
,Key_Enter ,Key_N ,Key_M ,Key_Comma ,Key_Period ,Key_Slash | |
,Key_LeftControl ,Key_Space ,Key_Esc ,Key_Minus ,Key_Quote ,___ | |
), | |
[FUN] = KEYMAP_STACKED | |
( | |
// left side | |
Key_Exclamation ,Key_At ,Key_UpArrow ,Key_Dollar ,Key_Percent | |
,Key_LeftParen ,Key_LeftArrow ,Key_DownArrow ,Key_RightArrow ,Key_RightParen | |
,Key_LeftBracket ,Key_RightBracket ,Key_Hash ,Key_LeftCurlyBracket ,Key_RightCurlyBracket ,Key_Caret | |
,___ ,___ ,___ ,___ ,___ ,___ | |
// right side | |
,Key_Equals ,Key_7 ,Key_8 ,Key_9 ,___ | |
,Key_Plus ,Key_4 ,Key_5 ,Key_6 ,___ | |
,Key_And ,Key_Star ,Key_1 ,Key_2 ,Key_3 ,___ | |
,___ ,___ ,Key_0 ,___ ,___ ,___ | |
) | |
) | |
// clang-format on | |
KALEIDOSCOPE_INIT_PLUGINS( | |
// ---------------------------------------------------------------------- | |
// Chrysalis plugins | |
// The EEPROMSettings & EEPROMKeymap plugins make it possible to have an | |
// editable keymap in EEPROM. | |
EEPROMSettings, | |
EEPROMKeymap, | |
// Focus allows bi-directional communication with the host, and is the | |
// interface through which the keymap in EEPROM can be edited. | |
Focus, | |
// FocusSettingsCommand adds a few Focus commands, intended to aid in | |
// changing some settings of the keyboard, such as the default layer (via the | |
// `settings.defaultLayer` command) | |
FocusSettingsCommand, | |
// FocusEEPROMCommand adds a set of Focus commands, which are very helpful in | |
// both debugging, and in backing up one's EEPROM contents. | |
FocusEEPROMCommand, | |
// The FirmwareVersion plugin lets Chrysalis query the version of the firmware | |
// programmatically. | |
FirmwareVersion, | |
// The LayerNames plugin allows Chrysalis to display - and edit - custom layer | |
// names, to be shown instead of the default indexes. | |
LayerNames, | |
// ---------------------------------------------------------------------- | |
// Keystroke-handling plugins | |
// The Qukeys plugin enables the "Secondary action" functionality in | |
// Chrysalis. Keys with secondary actions will have their primary action | |
// performed when tapped, but the secondary action when held. | |
Qukeys, | |
// SpaceCadet can turn your shifts into parens on tap, while keeping them as | |
// Shifts when held. SpaceCadetConfig lets Chrysalis configure some aspects of | |
// the plugin. | |
SpaceCadet, | |
SpaceCadetConfig, | |
// Enables the "Sticky" behavior for modifiers, and the "Layer shift when | |
// held" functionality for layer keys. | |
OneShot, | |
OneShotConfig, | |
EscapeOneShot, | |
EscapeOneShotConfig, | |
// The macros plugin adds support for macros | |
Macros, | |
// Enables dynamic, Chrysalis-editable macros. | |
DynamicMacros, | |
// The MouseKeys plugin lets you add keys to your keymap which move the mouse. | |
MouseKeys, | |
MouseKeysConfig //, | |
// The MagicCombo plugin lets you use key combinations to trigger custom | |
// actions - a bit like Macros, but triggered by pressing multiple keys at the | |
// same time. | |
// MagicCombo, | |
// Enables the GeminiPR Stenography protocol. Unused by default, but with the | |
// plugin enabled, it becomes configurable - and then usable - via Chrysalis. | |
// GeminiPR, | |
); | |
const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) { | |
if (keyToggledOn(event.state)) { | |
switch (macro_id) { | |
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: | |
Macros.type(PSTR("Keyboardio Atreus - Kaleidoscope ")); | |
Macros.type(PSTR(BUILD_INFORMATION)); | |
break; | |
default: | |
break; | |
} | |
} | |
return MACRO_NONE; | |
} | |
void setup() { | |
QUKEYS( | |
kaleidoscope::plugin::Qukey(0, KeyAddr(3, 7), MO(FUN)), // Space/FUN | |
kaleidoscope::plugin::Qukey(0, KeyAddr(3, 4), Key_LeftAlt), // Backspace/Alt | |
kaleidoscope::plugin::Qukey(0, KeyAddr(3, 8), Key_LeftGui), // Esc/Meta | |
) | |
Qukeys.setHoldTimeout(250); // a lower value than this causes modifier or primary key sometimes not to register when they should | |
Qukeys.setOverlapThreshold(1); | |
Qukeys.setMinimumHoldTime(1); | |
Qukeys.setMinimumPriorInterval(1); | |
Qukeys.activate(); | |
Kaleidoscope.setup(); | |
EEPROMKeymap.setup(9); | |
DynamicMacros.reserve_storage(48); | |
LayerNames.reserve_storage(63); | |
Layer.move(EEPROMSettings.default_layer()); | |
// To avoid any surprises, SpaceCadet is turned off by default. However, it | |
// can be permanently enabled via Chrysalis, so we should only disable it if | |
// no configuration exists. | |
SpaceCadetConfig.disableSpaceCadetIfUnconfigured(); | |
} | |
void loop() { | |
Kaleidoscope.loop(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment