@ -2,11 +2,17 @@
// Copyright 2016-2022 Keyboardio, inc. <jesse@keyboard.io>
// Copyright 2016-2022 Keyboardio, inc. <jesse@keyboard.io>
// See "LICENSE" for license details
// See "LICENSE" for license details
# ifndef BUILD_INFORMATION
# define BUILD_INFORMATION "locally built on " __DATE__ " at " __TIME__
# endif
/**
/**
* These # include directives pull in the Kaleidoscope firmware core ,
* These # include directives pull in the Kaleidoscope firmware core ,
* as well as the Kaleidoscope plugins we use in the Model 100 ' s firmware
* as well as the Kaleidoscope plugins we use in the Model 100 ' s firmware
*/
*/
// The Kaleidoscope core
// The Kaleidoscope core
# include "Kaleidoscope.h"
# include "Kaleidoscope.h"
@ -17,11 +23,8 @@
// Support for communicating with the host via a simple Serial protocol
// Support for communicating with the host via a simple Serial protocol
# include "Kaleidoscope-FocusSerial.h"
# include "Kaleidoscope-FocusSerial.h"
// Support for querying the firmware version via Focus
# include "Kaleidoscope-FirmwareVersion.h"
// Support for keys that move the mouse
// Support for keys that move the mouse
// #include "Kaleidoscope-MouseKeys.h"
# include "Kaleidoscope-MouseKeys.h"
// Support for macros
// Support for macros
# include "Kaleidoscope-Macros.h"
# include "Kaleidoscope-Macros.h"
@ -30,7 +33,7 @@
# include "Kaleidoscope-LEDControl.h"
# include "Kaleidoscope-LEDControl.h"
// Support for "Numpad" mode, which is mostly just the Numpad specific LED mode
// Support for "Numpad" mode, which is mostly just the Numpad specific LED mode
// #include "Kaleidoscope-NumPad.h"
# include "Kaleidoscope-NumPad.h"
// Support for the "Boot greeting" effect, which pulses the 'LED' button for 10s
// Support for the "Boot greeting" effect, which pulses the 'LED' button for 10s
// when the keyboard is connected to a computer (or that computer is powered on)
// when the keyboard is connected to a computer (or that computer is powered on)
@ -63,9 +66,6 @@
// Support for turning the LEDs off after a certain amount of time
// Support for turning the LEDs off after a certain amount of time
# include "Kaleidoscope-IdleLEDs.h"
# include "Kaleidoscope-IdleLEDs.h"
// Support for setting and saving the default LED mode
# include "Kaleidoscope-DefaultLEDModeConfig.h"
// Support for Keyboardio's internal keyboard testing mode
// Support for Keyboardio's internal keyboard testing mode
# include "Kaleidoscope-HardwareTestMode.h"
# include "Kaleidoscope-HardwareTestMode.h"
@ -88,15 +88,6 @@
// Support for dynamic, Chrysalis-editable macros
// Support for dynamic, Chrysalis-editable macros
# include "Kaleidoscope-DynamicMacros.h"
# include "Kaleidoscope-DynamicMacros.h"
// Support for SpaceCadet keys
# include "Kaleidoscope-SpaceCadet.h"
// Support for editable layer names
# include "Kaleidoscope-LayerNames.h"
// Support for the GeminiPR Stenography protocol
// #include "Kaleidoscope-Steno.h"
/** This 'enum' is a list of all the macros used by the Model 100's firmware
/** This 'enum' is a list of all the macros used by the Model 100's firmware
* The names aren ' t particularly important . What is important is that each
* The names aren ' t particularly important . What is important is that each
* is unique .
* is unique .
@ -166,9 +157,8 @@ enum {
enum {
enum {
PRIMARY ,
PRIMARY ,
// NUMPAD,
NUMPAD ,
FUNCTION ,
FUNCTION ,
ETC ,
} ; // layers
} ; // layers
@ -185,10 +175,10 @@ enum {
*
*
*/
*/
// #define PRIMARY_KEYMAP_QWERTY
# define PRIMARY_KEYMAP_QWERTY
// #define PRIMARY_KEYMAP_DVORAK
// #define PRIMARY_KEYMAP_DVORAK
// #define PRIMARY_KEYMAP_COLEMAK
// #define PRIMARY_KEYMAP_COLEMAK
# define PRIMARY_KEYMAP_CUSTOM
// #define PRIMARY_KEYMAP_CUSTOM
/* This comment temporarily turns off astyle's indent enforcement
/* This comment temporarily turns off astyle's indent enforcement
@ -198,37 +188,82 @@ enum {
KEYMAPS (
KEYMAPS (
# if defined (PRIMARY_KEYMAP_QWERTY)
[ PRIMARY ] = KEYMAP_STACKED
[ PRIMARY ] = KEYMAP_STACKED
( ___ , ___, ___ , ___ , ___ , ___ , Key_LEDEffectNext ,
( ___ , Key_1, Key_2 , Key_3 , Key_4 , Key_5 , Key_LEDEffectNext ,
___, Key_Q , Key_W , Key_D , Key_F , Key_K , Key_Tab ,
Key_Backtick, Key_Q , Key_W , Key_E , Key_R , Key_T , Key_Tab ,
___, Key_A , Key_S , Key_E , Key_T , Key_G ,
Key_PageUp, Key_A , Key_S , Key_D , Key_F , Key_G ,
Key_ Backtick, Key_Z , Key_X , Key_C , Key_V , Key_B , LCTRL ( LALT ( Key_LeftGui ) ) ,
Key_ PageDown, Key_Z , Key_X , Key_C , Key_V , Key_B , Key_Escape ,
GUI_T( Tab ) , ALT_T ( Backspace ) , CTL_T ( Escape ) , Key_LeftShift ,
Key_LeftControl, Key_Backspace , Key_LeftGui , Key_LeftShift ,
ShiftToLayer ( FUNCTION ) ,
ShiftToLayer ( FUNCTION ) ,
M ( MACRO_ANY ) , ___ , Key_LeftArrow , Key_DownArrow , Key_UpArrow , Key_RightArrow , ___ ,
M ( MACRO_ANY ) , Key_6 , Key_7 , Key_8 , Key_9 , Key_0 , LockLayer ( NUMPAD ) ,
Consumer_VolumeIncrement, Key_J , Key_U , Key_R , Key_L , Key_Semicolon , Key_Backslash ,
Key_Enter, Key_Y , Key_U , Key_I , Key_O , Key_P , Key_Equals ,
Key_Y , Key_N , Key_I , Key_O , Key_H , Key_Quote ,
Key_H , Key_J , Key_K , Key_L , Key_Semicolon , Key_Quote ,
Consumer_VolumeDecrement, Key_P , Key_M , Key_Comma , Key_Period , Key_Slash , ___ ,
Key_RightAlt, Key_N , Key_M , Key_Comma , Key_Period , Key_Slash , Key_Minus ,
Key_RightShift , ALT_T( Enter ) , Key_Spacebar , GUI_T ( Tab ) ,
Key_RightShift , Key_LeftAlt, Key_Spacebar , Key_RightControl ,
ShiftToLayer ( FUNCTION ) ) ,
ShiftToLayer ( FUNCTION ) ) ,
[ FUNCTION ] = KEYMAP_STACKED
# elif defined (PRIMARY_KEYMAP_DVORAK)
( ___ , Key_F1 , Key_F2 , Key_F3 , Key_F4 , Key_F5 , ___ ,
___ , LSHIFT ( Key_1 ) , LSHIFT ( Key_2 ) , LSHIFT ( Key_LeftBracket ) , LSHIFT ( Key_RightBracket ) , LSHIFT ( Key_Backslash ) , ___ ,
LSHIFT ( Key_7 ) , LSHIFT ( Key_3 ) , LSHIFT ( Key_4 ) , LSHIFT ( Key_9 ) , LSHIFT ( Key_0 ) , Key_Backslash ,
LSHIFT ( Key_Backtick ) , LSHIFT ( Key_5 ) , LSHIFT ( Key_6 ) , Key_LeftBracket , Key_RightBracket , LSHIFT ( Key_8 ) , ___ ,
___ , Key_Delete , ___ , ___ ,
___ ,
___ , Key_F6 , Key_F7 , Key_F8 , Key_F9 , Key_F10 , Key_F11 ,
[ PRIMARY ] = KEYMAP_STACKED
___ , Key_Equals , Key_7 , Key_8 , Key_9 , LSHIFT ( Key_Equals ) , Key_F12 ,
( ___ , Key_1 , Key_2 , Key_3 , Key_4 , Key_5 , Key_LEDEffectNext ,
Key_Minus , Key_4 , Key_5 , Key_6 , Key_Quote , ___ ,
Key_Backtick , Key_Quote , Key_Comma , Key_Period , Key_P , Key_Y , Key_Tab ,
___ , LSHIFT ( Key_Minus ) , Key_1 , Key_2 , Key_3 , LSHIFT ( Key_Quote ) , ___ ,
Key_PageUp , Key_A , Key_O , Key_E , Key_U , Key_I ,
___ , ___ , Key_Enter , Key_0 ,
Key_PageDown , Key_Semicolon , Key_Q , Key_J , Key_K , Key_X , Key_Escape ,
___ ) ,
Key_LeftControl , Key_Backspace , Key_LeftGui , Key_LeftShift ,
ShiftToLayer ( FUNCTION ) ,
M ( MACRO_ANY ) , Key_6 , Key_7 , Key_8 , Key_9 , Key_0 , LockLayer ( NUMPAD ) ,
Key_Enter , Key_F , Key_G , Key_C , Key_R , Key_L , Key_Slash ,
Key_D , Key_H , Key_T , Key_N , Key_S , Key_Minus ,
Key_RightAlt , Key_B , Key_M , Key_W , Key_V , Key_Z , Key_Equals ,
Key_RightShift , Key_LeftAlt , Key_Spacebar , Key_RightControl ,
ShiftToLayer ( FUNCTION ) ) ,
# elif defined (PRIMARY_KEYMAP_COLEMAK)
[ PRIMARY ] = KEYMAP_STACKED
( ___ , Key_1 , Key_2 , Key_3 , Key_4 , Key_5 , Key_LEDEffectNext ,
Key_Backtick , Key_Q , Key_W , Key_F , Key_P , Key_G , Key_Tab ,
Key_PageUp , Key_A , Key_R , Key_S , Key_T , Key_D ,
Key_PageDown , Key_Z , Key_X , Key_C , Key_V , Key_B , Key_Escape ,
Key_LeftControl , Key_Backspace , Key_LeftGui , Key_LeftShift ,
ShiftToLayer ( FUNCTION ) ,
M ( MACRO_ANY ) , Key_6 , Key_7 , Key_8 , Key_9 , Key_0 , LockLayer ( NUMPAD ) ,
Key_Enter , Key_J , Key_L , Key_U , Key_Y , Key_Semicolon , Key_Equals ,
Key_H , Key_N , Key_E , Key_I , Key_O , Key_Quote ,
Key_RightAlt , Key_K , Key_M , Key_Comma , Key_Period , Key_Slash , Key_Minus ,
Key_RightShift , Key_LeftAlt , Key_Spacebar , Key_RightControl ,
ShiftToLayer ( FUNCTION ) ) ,
# elif defined (PRIMARY_KEYMAP_CUSTOM)
// Edit this keymap to make a custom layout
[ PRIMARY ] = KEYMAP_STACKED
( ___ , Key_1 , Key_2 , Key_3 , Key_4 , Key_5 , Key_LEDEffectNext ,
Key_Backtick , Key_Q , Key_W , Key_E , Key_R , Key_T , Key_Tab ,
Key_PageUp , Key_A , Key_S , Key_D , Key_F , Key_G ,
Key_PageDown , Key_Z , Key_X , Key_C , Key_V , Key_B , Key_Escape ,
Key_LeftControl , Key_Backspace , Key_LeftGui , Key_LeftShift ,
ShiftToLayer ( FUNCTION ) ,
M ( MACRO_ANY ) , Key_6 , Key_7 , Key_8 , Key_9 , Key_0 , LockLayer ( NUMPAD ) ,
Key_Enter , Key_Y , Key_U , Key_I , Key_O , Key_P , Key_Equals ,
Key_H , Key_J , Key_K , Key_L , Key_Semicolon , Key_Quote ,
Key_RightAlt , Key_N , Key_M , Key_Comma , Key_Period , Key_Slash , Key_Minus ,
Key_RightShift , Key_LeftAlt , Key_Spacebar , Key_RightControl ,
ShiftToLayer ( FUNCTION ) ) ,
# else
# error "No default keymap defined. You should make sure that you have a line like '#define PRIMARY_KEYMAP_QWERTY' in your sketch"
# endif
[ ETC ] = KEYMAP_STACKED
[ NUMPAD ] = KEYMAP_STACKED
( ___ , ___ , ___ , ___ , ___ , ___ , ___ ,
( ___ , ___ , ___ , ___ , ___ , ___ , ___ ,
___ , ___ , ___ , ___ , ___ , ___ , ___ ,
___ , ___ , ___ , ___ , ___ , ___ , ___ ,
___ , ___ , ___ , ___ , ___ , ___ ,
___ , ___ , ___ , ___ , ___ , ___ ,
@ -236,13 +271,27 @@ KEYMAPS(
___ , ___ , ___ , ___ ,
___ , ___ , ___ , ___ ,
___ ,
___ ,
___, ___ , ___ , ___ , ___ , ___ , ___ ,
M( MACRO_VERSION_INFO ) , ___ , Key_7 , Key_8 , Key_9 , Key_KeypadSubtract , ___ ,
___ , ___ , Key_F7 , Key_F8 , Key_F9 , Key_Home , ___ ,
___ , ___ , Key_4 , Key_5 , Key_6 , Key_KeypadAdd , ___ ,
___ , Key_F4 , Key_F5 , Key_F6 , Key_End , ___ ,
___ , Key_1 , Key_2 , Key_3 , Key_Equals , ___ ,
___ , ___ , Key_F1 , Key_F2 , Key_F3 , Key_Insert , ___ ,
___ , ___ , Key_0 , Key_Period , Key_KeypadMultiply , Key_KeypadDivide , Key_Enter ,
___ , ___ , ___ , ___ ,
___ , ___ , ___ , ___ ,
___ )
___ ) ,
[ FUNCTION ] = KEYMAP_STACKED
( ___ , Key_F1 , Key_F2 , Key_F3 , Key_F4 , Key_F5 , Key_CapsLock ,
Key_Tab , ___ , Key_mouseUp , ___ , Key_mouseBtnR , Key_mouseWarpEnd , Key_mouseWarpNE ,
Key_Home , Key_mouseL , Key_mouseDn , Key_mouseR , Key_mouseBtnL , Key_mouseWarpNW ,
Key_End , Key_PrintScreen , Key_Insert , ___ , Key_mouseBtnM , Key_mouseWarpSW , Key_mouseWarpSE ,
___ , Key_Delete , ___ , ___ ,
___ ,
Consumer_ScanPreviousTrack , Key_F6 , Key_F7 , Key_F8 , Key_F9 , Key_F10 , Key_F11 ,
Consumer_PlaySlashPause , Consumer_ScanNextTrack , Key_LeftCurlyBracket , Key_RightCurlyBracket , Key_LeftBracket , Key_RightBracket , Key_F12 ,
Key_LeftArrow , Key_DownArrow , Key_UpArrow , Key_RightArrow , ___ , ___ ,
Key_PcApplication , Consumer_Mute , Consumer_VolumeDecrement , Consumer_VolumeIncrement , ___ , Key_Backslash , Key_Pipe ,
___ , ___ , Key_Enter , ___ ,
___ )
) // KEYMAPS(
) // KEYMAPS(
/* Re-enable astyle's indent enforcement */
/* Re-enable astyle's indent enforcement */
@ -255,8 +304,8 @@ KEYMAPS(
static void versionInfoMacro ( uint8_t key_state ) {
static void versionInfoMacro ( uint8_t key_state ) {
if ( keyToggledOn ( key_state ) ) {
if ( keyToggledOn ( key_state ) ) {
Macros . type ( PSTR ( " Keyboardio Model 100 - Firmware version " ) ) ;
Macros . type ( PSTR ( " Keyboardio Model 100 - Kaleidoscope " ) ) ;
Macros . type ( PSTR ( KALEIDOSCOPE_FIRMWARE_VERS ION) ) ;
Macros . type ( PSTR ( BUILD_INFORMAT ION) ) ;
}
}
}
}
@ -365,17 +414,6 @@ static void toggleKeyboardProtocol(uint8_t combo_index) {
USBQuirks . toggleKeyboardProtocol ( ) ;
USBQuirks . toggleKeyboardProtocol ( ) ;
}
}
/**
* Toggles between using the built - in keymap , and the EEPROM - stored one .
*/
static void toggleKeymapSource ( uint8_t combo_index ) {
if ( Layer . getKey = = Layer . getKeyFromPROGMEM ) {
Layer . getKey = EEPROMKeymap . getKey ;
} else {
Layer . getKey = Layer . getKeyFromPROGMEM ;
}
}
/**
/**
* This enters the hardware test mode
* This enters the hardware test mode
*/
*/
@ -392,10 +430,7 @@ USE_MAGIC_COMBOS({.action = toggleKeyboardProtocol,
. keys = { R3C6 , R2C6 , R3C7 } } ,
. keys = { R3C6 , R2C6 , R3C7 } } ,
{ . action = enterHardwareTestMode ,
{ . action = enterHardwareTestMode ,
// Left Fn + Prog + LED
// Left Fn + Prog + LED
. keys = { R3C6 , R0C0 , R0C6 } } ,
. keys = { R3C6 , R0C0 , R0C6 } } ) ;
{ . action = toggleKeymapSource ,
// Left Fn + Prog + Shift
. keys = { R3C6 , R0C0 , R3C7 } } ) ;
// First, tell Kaleidoscope which plugins you want to use.
// First, tell Kaleidoscope which plugins you want to use.
// The order can be important. For example, LED effects are
// The order can be important. For example, LED effects are
@ -406,12 +441,6 @@ KALEIDOSCOPE_INIT_PLUGINS(
EEPROMSettings ,
EEPROMSettings ,
EEPROMKeymap ,
EEPROMKeymap ,
// 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,
// Focus allows bi-directional communication with the host, and is the
// Focus allows bi-directional communication with the host, and is the
// interface through which the keymap in EEPROM can be edited.
// interface through which the keymap in EEPROM can be edited.
Focus ,
Focus ,
@ -479,13 +508,13 @@ KALEIDOSCOPE_INIT_PLUGINS(
// The numpad plugin is responsible for lighting up the 'numpad' mode
// The numpad plugin is responsible for lighting up the 'numpad' mode
// with a custom LED effect
// with a custom LED effect
// NumPad,
NumPad ,
// The macros plugin adds support for macros
// The macros plugin adds support for macros
Macros ,
Macros ,
// The MouseKeys plugin lets you add keys to your keymap which move the mouse.
// The MouseKeys plugin lets you add keys to your keymap which move the mouse.
// MouseKeys,
MouseKeys ,
// The HostPowerManagement plugin allows us to turn LEDs off when then host
// The HostPowerManagement plugin allows us to turn LEDs off when then host
// goes to sleep, and resume them when it wakes up.
// goes to sleep, and resume them when it wakes up.
@ -518,24 +547,7 @@ KALEIDOSCOPE_INIT_PLUGINS(
PersistentIdleLEDs ,
PersistentIdleLEDs ,
// Enables dynamic, Chrysalis-editable macros.
// Enables dynamic, Chrysalis-editable macros.
DynamicMacros ,
DynamicMacros ) ;
// 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 ,
// Enables setting, saving (via Chrysalis), and restoring (on boot) the
// default LED mode.
DefaultLEDModeConfig
// Enables the GeminiPR Stenography protocol. Unused by default, but with the
// plugin enabled, it becomes configurable - and then usable - via Chrysalis.
//GeminiPR
) ;
/** The 'setup' function is one of the two standard Arduino sketch functions.
/** The 'setup' function is one of the two standard Arduino sketch functions.
* It ' s called when your keyboard first powers up . This is where you set up
* It ' s called when your keyboard first powers up . This is where you set up
@ -551,7 +563,7 @@ void setup() {
// While we hope to improve this in the future, the NumPad plugin
// While we hope to improve this in the future, the NumPad plugin
// needs to be explicitly told which keymap layer is your numpad layer
// needs to be explicitly told which keymap layer is your numpad layer
// NumPad.numPadLayer = NUMPAD;
NumPad . numPadLayer = NUMPAD ;
// We configure the AlphaSquare effect to use RED letters
// We configure the AlphaSquare effect to use RED letters
AlphaSquare . color = CRGB ( 255 , 0 , 0 ) ;
AlphaSquare . color = CRGB ( 255 , 0 , 0 ) ;
@ -569,6 +581,11 @@ void setup() {
// https://github.com/keyboardio/Kaleidoscope/blob/master/docs/plugins/LED-Stalker.md
// https://github.com/keyboardio/Kaleidoscope/blob/master/docs/plugins/LED-Stalker.md
StalkerEffect . variant = STALKER ( BlazingTrail ) ;
StalkerEffect . variant = STALKER ( BlazingTrail ) ;
// We want to make sure that the firmware starts with LED effects off
// This avoids over-taxing devices that don't have a lot of power to share
// with USB devices
LEDOff . activate ( ) ;
// To make the keymap editable without flashing new firmware, we store
// To make the keymap editable without flashing new firmware, we store
// additional layers in EEPROM. For now, we reserve space for eight layers. If
// additional layers in EEPROM. For now, we reserve space for eight layers. If
// one wants to use these layers, just set the default layer to one in EEPROM,
// one wants to use these layers, just set the default layer to one in EEPROM,
@ -584,26 +601,6 @@ void setup() {
// For Dynamic Macros, we need to reserve storage space for the editable
// For Dynamic Macros, we need to reserve storage space for the editable
// macros. A kilobyte is a reasonable default.
// macros. A kilobyte is a reasonable default.
DynamicMacros . reserve_storage ( 1024 ) ;
DynamicMacros . reserve_storage ( 1024 ) ;
// If there's a default layer set in EEPROM, we should set that as the default
// here.
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();
// SpaceCadet.disable();
// Editable layer names are stored in EEPROM too, and we reserve 16 bytes per
// layer for them. We need one extra byte per layer for bookkeeping, so we
// reserve 17 / layer in total.
LayerNames . reserve_storage ( 17 * 8 ) ;
// Unless configured otherwise with Chrysalis, we want to make sure that the
// firmware starts with LED effects off. This avoids over-taxing devices that
// don't have a lot of power to share with USB devices
DefaultLEDModeConfig . activateLEDModeIfUnconfigured ( & LEDOff ) ;
}
}
/** loop is the second of the standard Arduino sketch functions.
/** loop is the second of the standard Arduino sketch functions.