diff options
-rw-r--r-- | .kaleidoscope-builder.conf | 1 | ||||
-rw-r--r-- | Model01-Firmware.ino | 660 | ||||
-rwxr-xr-x | build.sh | 12 |
3 files changed, 265 insertions, 408 deletions
diff --git a/.kaleidoscope-builder.conf b/.kaleidoscope-builder.conf index e4a5db4..2207380 100644 --- a/.kaleidoscope-builder.conf +++ b/.kaleidoscope-builder.conf @@ -1,3 +1,4 @@ # -*- mode: sh -*- DEFAULT_SKETCH=Model01-Firmware +LOCAL_CFLAGS="-DKALEIDOSCOPE_ENABLE_V1_PLUGIN_API=0" diff --git a/Model01-Firmware.ino b/Model01-Firmware.ino index 60d5f7c..9aa9899 100644 --- a/Model01-Firmware.ino +++ b/Model01-Firmware.ino @@ -1,253 +1,108 @@ // -*- mode: c++ -*- -// Copyright 2016 Keyboardio, inc. <jesse@keyboard.io> -// See "LICENSE" for license details #ifndef BUILD_INFORMATION #define BUILD_INFORMATION "locally built" #endif - -/** - * These #include directives pull in the Kaleidoscope firmware core, - * as well as the Kaleidoscope plugins we use in the Model 01's firmware - */ - - -// The Kaleidoscope core -#include "Kaleidoscope.h" - -// Support for storing the keymap in EEPROM -#include "Kaleidoscope-EEPROM-Settings.h" -#include "Kaleidoscope-EEPROM-Keymap.h" - -// Support for communicating with the host via a simple Serial protocol -#include "Kaleidoscope-FocusSerial.h" - -// Support for keys that move the mouse -#include "Kaleidoscope-MouseKeys.h" - -// Support for macros -#include "Kaleidoscope-Macros.h" - -// Support for controlling the keyboard's LEDs -#include "Kaleidoscope-LEDControl.h" - -// Support for "Numpad" mode, which is mostly just the Numpad specific LED mode -#include "Kaleidoscope-NumPad.h" - -// 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) -#include "Kaleidoscope-LEDEffect-BootGreeting.h" - -// Support for LED modes that set all LEDs to a single color -#include "Kaleidoscope-LEDEffect-SolidColor.h" - -// Support for an LED mode that makes all the LEDs 'breathe' -#include "Kaleidoscope-LEDEffect-Breathe.h" - -// Support for an LED mode that makes a red pixel chase a blue pixel across the keyboard -#include "Kaleidoscope-LEDEffect-Chase.h" - -// Support for LED modes that pulse the keyboard's LED in a rainbow pattern -#include "Kaleidoscope-LEDEffect-Rainbow.h" - -// Support for an LED mode that lights up the keys as you press them -#include "Kaleidoscope-LED-Stalker.h" - -// Support for an LED mode that prints the keys you press in letters 4px high -#include "Kaleidoscope-LED-AlphaSquare.h" - -// Support for shared palettes for other plugins, like Colormap below -#include "Kaleidoscope-LED-Palette-Theme.h" - -// Support for an LED mode that lets one configure per-layer color maps -#include "Kaleidoscope-Colormap.h" - -// Support for Keyboardio's internal keyboard testing mode -#include "Kaleidoscope-HardwareTestMode.h" - -// Support for host power management (suspend & wakeup) -#include "Kaleidoscope-HostPowerManagement.h" - -// Support for magic combos (key chords that trigger an action) -#include "Kaleidoscope-MagicCombo.h" - -// Support for USB quirks, like changing the key state report protocol -#include "Kaleidoscope-USB-Quirks.h" - -/** This 'enum' is a list of all the macros used by the Model 01's firmware - * The names aren't particularly important. What is important is that each - * is unique. - * - * These are the names of your macros. They'll be used in two places. - * The first is in your keymap definitions. There, you'll use the syntax - * `M(MACRO_NAME)` to mark a specific keymap position as triggering `MACRO_NAME` - * - * The second usage is in the 'switch' statement in the `macroAction` function. - * That switch statement actually runs the code associated with a macro when - * a macro key is pressed. - */ +#include <Kaleidoscope.h> +#include <Kaleidoscope-Macros.h> +#include <Kaleidoscope-LEDControl.h> +#include <Kaleidoscope-NumPad.h> +#include <Kaleidoscope-HardwareTestMode.h> +#include <Kaleidoscope-HostPowerManagement.h> +#include <Kaleidoscope-MagicCombo.h> +#include <Kaleidoscope-Qukeys.h> +#include <Kaleidoscope-USB-Quirks.h> +#include <Kaleidoscope-EEPROM-Settings.h> +#include <Kaleidoscope-EEPROM-Keymap.h> +#include <Kaleidoscope-HostOS.h> +#include <Kaleidoscope-Syster.h> +#include <Kaleidoscope-Unicode.h> +#include <kaleidoscope/hid.h> +//#include <Kaleidoscope-MacrosOnTheFly.h> +#include <Kaleidoscope-LEDEffect-BootGreeting.h> +#include <Kaleidoscope-LEDEffect-Breathe.h> +#include <Kaleidoscope-IdleLEDs.h> +#include <Kaleidoscope-LayerHighlighter.h> +#include <Kaleidoscope-SpaceCadet.h> +#include <Kaleidoscope-Heatmap.h> enum { MACRO_VERSION_INFO, - MACRO_ANY + MACRO_ANY, + WOW, + SAUCY, + LUL, + ZZZ, + GIVE_PLZ, + TAKE_NRG, + SEEMS_GOOD, + GASM }; +enum { PRIMARY, FUNCTION, NUMPAD, EMOTES }; // layers + +typedef struct { + uint8_t index; + const char *string; +} emote; + +const char wow[] PROGMEM = "eeriedWow"; +const char saucy[] PROGMEM = "eeriedSaucy"; +const char lul[] PROGMEM = "supert25LUL"; +const char zzz[] PROGMEM = "plasmoWife"; +const char givePLZ[] PROGMEM = "GivePLZ"; +const char takeNRG[] PROGMEM = "TakeNRG"; +const char seemsGood[] PROGMEM = "SeemsGood"; +const char gasm[] PROGMEM = "kdubGasm"; + +static const emote emotes[] = { + { WOW, wow }, + { SAUCY, saucy }, + { LUL, lul }, + { ZZZ, zzz }, + { GIVE_PLZ, givePLZ }, + { TAKE_NRG, takeNRG }, + { SEEMS_GOOD, seemsGood }, + { GASM, gasm }, + { 255, NULL } +}; - -/** The Model 01's key layouts are defined as 'keymaps'. By default, there are three - * keymaps: The standard QWERTY keymap, the "Function layer" keymap and the "Numpad" - * keymap. - * - * Each keymap is defined as a list using the 'KEYMAP_STACKED' macro, built - * of first the left hand's layout, followed by the right hand's layout. - * - * Keymaps typically consist mostly of `Key_` definitions. There are many, many keys - * defined as part of the USB HID Keyboard specification. You can find the names - * (if not yet the explanations) for all the standard `Key_` defintions offered by - * Kaleidoscope in these files: - * https://github.com/keyboardio/Kaleidoscope/blob/master/src/kaleidoscope/key_defs_keyboard.h - * https://github.com/keyboardio/Kaleidoscope/blob/master/src/kaleidoscope/key_defs_consumerctl.h - * https://github.com/keyboardio/Kaleidoscope/blob/master/src/kaleidoscope/key_defs_sysctl.h - * https://github.com/keyboardio/Kaleidoscope/blob/master/src/kaleidoscope/key_defs_keymaps.h - * - * Additional things that should be documented here include - * using ___ to let keypresses fall through to the previously active layer - * using XXX to mark a keyswitch as 'blocked' on this layer - * using ShiftToLayer() and LockLayer() keys to change the active keymap. - * keeping NUM and FN consistent and accessible on all layers - * - * The PROG key is special, since it is how you indicate to the board that you - * want to flash the firmware. However, it can be remapped to a regular key. - * When the keyboard boots, it first looks to see whether the PROG key is held - * down; if it is, it simply awaits further flashing instructions. If it is - * not, it continues loading the rest of the firmware and the keyboard - * functions normally, with whatever binding you have set to PROG. More detail - * here: https://community.keyboard.io/t/how-the-prog-key-gets-you-into-the-bootloader/506/8 - * - * The "keymaps" data structure is a list of the keymaps compiled into the firmware. - * The order of keymaps in the list is important, as the ShiftToLayer(#) and LockLayer(#) - * macros switch to key layers based on this list. - * - * - - * A key defined as 'ShiftToLayer(FUNCTION)' will switch to FUNCTION while held. - * Similarly, a key defined as 'LockLayer(NUMPAD)' will switch to NUMPAD when tapped. - */ - -/** - * Layers are "0-indexed" -- That is the first one is layer 0. The second one is layer 1. - * The third one is layer 2. - * This 'enum' lets us use names like QWERTY, FUNCTION, and NUMPAD in place of - * the numbers 0, 1 and 2. - * - */ - -enum { PRIMARY, NUMPAD, FUNCTION }; // layers - - -/** - * To change your keyboard's layout from QWERTY to DVORAK or COLEMAK, comment out the line - * - * #define PRIMARY_KEYMAP_QWERTY - * - * by changing it to - * - * // #define PRIMARY_KEYMAP_QWERTY - * - * Then uncomment the line corresponding to the layout you want to use. - * - */ - -#define PRIMARY_KEYMAP_QWERTY -// #define PRIMARY_KEYMAP_COLEMAK -// #define PRIMARY_KEYMAP_DVORAK -// #define PRIMARY_KEYMAP_CUSTOM - - - -/* This comment temporarily turns off astyle's indent enforcement - * so we can make the keymaps actually resemble the physical key layout better - */ // *INDENT-OFF* KEYMAPS( - -#if defined (PRIMARY_KEYMAP_QWERTY) [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, + (Key_Escape, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext, + Key_Backtick, Key_Quote, Key_Comma, Key_Period, Key_P, Key_Y, Key_Tab, + Key_PageUp, Key_A, Key_O, Key_E, Key_U, Key_I, + Key_PageDown, Key_Semicolon, Key_Q, Key_J, Key_K, Key_X, Key_LeftGui, + Key_LeftBracket, Key_Backspace, LSHIFT(Key_LeftBracket), LSHIFT(Key_9), + //Key_LeftControl, Key_Backspace, Key_LeftAlt, 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, + LockLayer(EMOTES), 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, + SYSTER, Key_B, Key_M, Key_W, Key_V, Key_Z, Key_Equals, + LSHIFT(Key_0), LSHIFT(Key_RightBracket), Key_Spacebar, Key_RightBracket, + //Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, ShiftToLayer(FUNCTION)), -#elif defined (PRIMARY_KEYMAP_DVORAK) - - [PRIMARY] = KEYMAP_STACKED - (___, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext, - Key_Backtick, Key_Quote, Key_Comma, Key_Period, Key_P, Key_Y, Key_Tab, - Key_PageUp, Key_A, Key_O, Key_E, Key_U, Key_I, - 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 - + [FUNCTION] = KEYMAP_STACKED + (___, Key_F1, Key_F2, Key_F3, Key_F4, Key_F5, Key_CapsLock, + Key_Tab, ___, Key_PageUp, Key_UpArrow, Key_PageDown, Key_Home, ___, + Key_Copy, ___, Key_LeftArrow, Key_DownArrow, Key_RightArrow, Key_End, + Key_Paste, Key_PrintScreen, Key_Insert, ___, Consumer_ScanPreviousTrack, Consumer_PlaySlashPause, Consumer_ScanNextTrack, + ___, Key_Delete, ___, ___, + ___, + ___, Key_F6, Key_F7, Key_F8, Key_F9, Key_F10, Key_F11, + Key_ScrollLock, Key_Home, Key_PageUp, Key_UpArrow, Key_PageDown, ___, Key_F12, + Key_End, Key_LeftArrow, Key_DownArrow, Key_RightArrow, ___, ___, + Key_PcApplication, Consumer_Mute, Consumer_VolumeDecrement, Consumer_VolumeIncrement, ___, Key_Backslash, Key_Pipe, + ___, ___, Key_Enter, ___, + ___), - [NUMPAD] = KEYMAP_STACKED + [NUMPAD] = KEYMAP_STACKED (___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, @@ -262,23 +117,22 @@ KEYMAPS( ___, ___, ___, ___, ___), - [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, ___, ___, + [EMOTES] = KEYMAP_STACKED + (___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, M(SEEMS_GOOD), + ___, M(ZZZ), ___, M(GASM), ___, ___, ___, + ___, ___, ___, ___, ___, - 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, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, M(WOW), ___, + ___, ___, ___, M(LUL), M(SAUCY), ___, + ___, ___, ___, M(GIVE_PLZ), M(TAKE_NRG), ___, ___, + ___, ___, ___, ___, ___) -) // KEYMAPS( +) -/* Re-enable astyle's indent enforcement */ // *INDENT-ON* /** versionInfoMacro handles the 'firmware version info' macro @@ -290,6 +144,7 @@ static void versionInfoMacro(uint8_t keyState) { if (keyToggledOn(keyState)) { Macros.type(PSTR("Keyboardio Model 01 - Kaleidoscope ")); Macros.type(PSTR(BUILD_INFORMATION)); + Unicode.type(0x2615); } } @@ -313,22 +168,20 @@ static void anyKeyMacro(uint8_t keyState) { Kaleidoscope.hid().keyboard().pressKey(lastKey, toggledOn); } - -/** macroAction dispatches keymap events that are tied to a macro - to that macro. It takes two uint8_t parameters. - - The first is the macro being called (the entry in the 'enum' earlier in this file). - The second is the state of the keyswitch. You can use the keyswitch state to figure out - if the key has just been toggled on, is currently pressed or if it's just been released. - - The 'switch' statement should have a 'case' for each entry of the macro enum. - Each 'case' statement should call out to a function to handle the macro in question. - - */ +const macro_t *emoteMacro(uint8_t macroIndex, uint8_t keyState) { + if (keyToggledOn(keyState)) { + for (int i = 0; emotes[i].index != 255; i++) { + if (emotes[i].index == macroIndex) { + Macros.type(emotes[i].string); + return MACRO_NONE; + } + } + } + return MACRO_NONE; +} const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) { switch (macroIndex) { - case MACRO_VERSION_INFO: versionInfoMacro(keyState); break; @@ -336,25 +189,14 @@ const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) { case MACRO_ANY: anyKeyMacro(keyState); break; + + default: + emoteMacro(macroIndex, keyState); } + return MACRO_NONE; } - - -// These 'solid' color effect definitions define a rainbow of -// LED color modes calibrated to draw 500mA or less on the -// Keyboardio Model 01. - - -static kaleidoscope::plugin::LEDSolidColor solidRed(160, 0, 0); -static kaleidoscope::plugin::LEDSolidColor solidOrange(140, 70, 0); -static kaleidoscope::plugin::LEDSolidColor solidYellow(130, 100, 0); -static kaleidoscope::plugin::LEDSolidColor solidGreen(0, 160, 0); -static kaleidoscope::plugin::LEDSolidColor solidBlue(0, 70, 130); -static kaleidoscope::plugin::LEDSolidColor solidIndigo(0, 0, 170); -static kaleidoscope::plugin::LEDSolidColor solidViolet(130, 0, 120); - /** toggleLedsOnSuspendResume toggles the LEDs off when the host goes to sleep, * and turns them back on when it wakes up. */ @@ -417,112 +259,66 @@ static void enterHardwareTestMode(uint8_t combo_index) { */ USE_MAGIC_COMBOS({.action = toggleKeyboardProtocol, // Left Fn + Esc + Shift - .keys = { R3C6, R2C6, R3C7 } -}, { - .action = enterHardwareTestMode, - // Left Fn + Prog + LED - .keys = { R3C6, R0C0, R0C6 } -}); + .keys = { R3C6, R2C6, R3C7 }}, + {.action = enterHardwareTestMode, + // Left Fn + Prog + LED + .keys = { R3C6, R0C0, R0C6 }}); + +static LayerHighlighter emoteHighlighter(EMOTES); // First, tell Kaleidoscope which plugins you want to use. // The order can be important. For example, LED effects are // added in the order they're listed here. -KALEIDOSCOPE_INIT_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 boot greeting effect pulses the LED button for 10 seconds after the - // keyboard is first connected - BootGreetingEffect, - - // The hardware test mode, which can be invoked by tapping Prog, LED and the - // left Fn button at the same time. - HardwareTestMode, +KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings, + //HostOS, + Unicode, + Qukeys, + //SpaceCadet, + //MacrosOnTheFly, + Syster, + // LEDControl provides support for other LED + // modes + LEDControl, + IdleLEDs, + BootGreetingEffect, + LEDBreatheEffect, + HeatmapEffect, + + // The numpad plugin is responsible for + // lighting up the 'numpad' mode with a + // custom LED effect + NumPad, + emoteHighlighter, + + // The macros plugin adds support for macros + Macros, + + // The HostPowerManagement plugin allows us + // to turn LEDs off when then host goes to + // sleep, and resume them when it wakes up. + //HostPowerManagement, + + // 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, + + // The USBQuirks plugin lets you do some + // things with USB that we aren't + // comfortable - or able - to do + // automatically, but can be useful + // nevertheless. Such as toggling the key + // report protocol between Boot (used by + // BIOSes) and Report (NKRO). + USBQuirks); - // LEDControl provides support for other LED modes - LEDControl, - - // We start with the LED effect that turns off all the LEDs. - LEDOff, - - // The rainbow effect changes the color of all of the keyboard's keys at the same time - // running through all the colors of the rainbow. - LEDRainbowEffect, - - // The rainbow wave effect lights up your keyboard with all the colors of a rainbow - // and slowly moves the rainbow across your keyboard - LEDRainbowWaveEffect, - - // The chase effect follows the adventure of a blue pixel which chases a red pixel across - // your keyboard. Spoiler: the blue pixel never catches the red pixel - LEDChaseEffect, - - // These static effects turn your keyboard's LEDs a variety of colors - solidRed, solidOrange, solidYellow, solidGreen, solidBlue, solidIndigo, solidViolet, - - // The breathe effect slowly pulses all of the LEDs on your keyboard - LEDBreatheEffect, - - // The AlphaSquare effect prints each character you type, using your - // keyboard's LEDs as a display - AlphaSquareEffect, - - // The stalker effect lights up the keys you've pressed recently - StalkerEffect, - - // The LED Palette Theme plugin provides a shared palette for other plugins, - // like Colormap below - LEDPaletteTheme, - - // The Colormap effect makes it possible to set up per-layer colormaps - ColormapEffect, - - // The numpad plugin is responsible for lighting up the 'numpad' mode - // with a custom LED effect - NumPad, - - // The macros plugin adds support for macros - Macros, - - // The MouseKeys plugin lets you add keys to your keymap which move the mouse. - MouseKeys, - - // The HostPowerManagement plugin allows us to turn LEDs off when then host - // goes to sleep, and resume them when it wakes up. - HostPowerManagement, - - // 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, +void setup() { + Serial.begin(9600); - // The USBQuirks plugin lets you do some things with USB that we aren't - // comfortable - or able - to do automatically, but can be useful - // nevertheless. Such as toggling the key report protocol between Boot (used - // by BIOSes) and Report (NKRO). - USBQuirks -); + // Necessary for FreeBSD, as it doesn't support NKRO. + BootKeyboard.default_protocol = HID_BOOT_PROTOCOL; -/** 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 - * Kaleidoscope and any plugins. - */ -void setup() { // First, call Kaleidoscope's internal setup function Kaleidoscope.setup(); @@ -530,47 +326,95 @@ void setup() { // needs to be explicitly told which keymap layer is your numpad layer NumPad.numPadLayer = NUMPAD; - // We configure the AlphaSquare effect to use RED letters - AlphaSquare.color = CRGB(255, 0, 0); - - // We set the brightness of the rainbow effects to 150 (on a scale of 0-255) - // This draws more than 500mA, but looks much nicer than a dimmer effect - LEDRainbowEffect.brightness(150); - LEDRainbowWaveEffect.brightness(150); - - // Set the action key the test mode should listen for to Left Fn - HardwareTestMode.setActionKey(R3C6); - - // The LED Stalker mode has a few effects. The one we like is called - // 'BlazingTrail'. For details on other options, see - // https://github.com/keyboardio/Kaleidoscope/blob/master/docs/plugins/LED-Stalker.md - 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 - // additional layers in EEPROM. For now, we reserve space for five layers. If - // one wants to use these layers, just set the default layer to one in EEPROM, - // by using the `settings.defaultLayer` Focus command, or by using the - // `keymap.onlyCustom` command to use EEPROM layers only. - EEPROMKeymap.setup(5); - - // We need to tell the Colormap plugin how many layers we want to have custom - // maps for. To make things simple, we set it to five layers, which is how - // many editable layers we have (see above). - ColormapEffect.max_layers(5); -} + emoteHighlighter.lockHue = 100; + emoteHighlighter.color = CRGB(255, 255, 0); + LEDBreatheEffect.hue = 212; -/** loop is the second of the standard Arduino sketch functions. - * As you might expect, it runs in a loop, never exiting. - * - * For Kaleidoscope-based keyboard firmware, you usually just want to - * call Kaleidoscope.loop(); and not do anything custom here. - */ + QUKEYS(kaleidoscope::plugin::Qukey(0, KeyAddr(3, 7), Key_LeftShift), + kaleidoscope::plugin::Qukey(0, KeyAddr(3, 8), Key_RightShift), + kaleidoscope::plugin::Qukey(0, KeyAddr(0, 7), Key_LeftControl), + kaleidoscope::plugin::Qukey(0, KeyAddr(0, 8), Key_RightControl), + kaleidoscope::plugin::Qukey(0, KeyAddr(2, 7), Key_LeftAlt), + kaleidoscope::plugin::Qukey(0, KeyAddr(2, 8), Key_RightAlt), + kaleidoscope::plugin::Qukey(0, KeyAddr(2, 9), Key_RightGui)); + Qukeys.setOverlapThreshold(25); + + IdleLEDs.setIdleTimeoutSeconds(300); +} void loop() { Kaleidoscope.loop(); } + +void systerAction(kaleidoscope::plugin::Syster::action_t action, const char *symbol) { + switch (action) { + case kaleidoscope::plugin::Syster::StartAction: + Unicode.type(0x2328); + break; + + case kaleidoscope::plugin::Syster::EndAction: + handleKeyswitchEvent(Key_Backspace, UnknownKeyswitchLocation, IS_PRESSED | INJECTED); + Kaleidoscope.hid().keyboard().sendReport(); + handleKeyswitchEvent(Key_Backspace, UnknownKeyswitchLocation, WAS_PRESSED | INJECTED); + Kaleidoscope.hid().keyboard().sendReport(); + break; + + case kaleidoscope::plugin::Syster::SymbolAction: + Serial.print("systerAction = "); + Serial.println(symbol); + if (strcmp(symbol, "coffee") == 0) { + Unicode.type(0x2615); + } else if (strcmp(symbol, "=/") == 0) { // =/ + Unicode.type(0x1f615); + } else if (strcmp(symbol, "=9") == 0) { // =( + Unicode.type(0x1f641); + } else if (strcmp(symbol, "=:") == 0) { // =) + Unicode.type(0x1f642); + } else if (strcmp(symbol, "9=") == 0) { // (= + Unicode.type(0x1f643); + } else if (strcmp(symbol, "=p") == 0) { // =P + Unicode.type(0x1f61b); + } else if (strcmp(symbol, "=x") == 0) { // =x + Unicode.type(0x1f636); + } else if (strcmp(symbol, "b:") == 0) { // B) + Unicode.type(0x1f60e); + } else if (strcmp(symbol, ";:") == 0) { // ;) + Unicode.type(0x1f609); + } else if (strcmp(symbol, "1::") == 0) { // 100 + Unicode.type(0x1f4af); + } else if (strcmp(symbol, "eye") == 0) { + Unicode.type(0x1f440); + + + } else if (strcmp(symbol, "heye") == 0) { + Unicode.type(0x1f60d); + } else if (strcmp(symbol, "think") == 0) { + Unicode.type(0x1f914); + } else if (strcmp(symbol, "party") == 0) { + Unicode.type(0x1f389); + } else if (strcmp(symbol, "flex") == 0) { + Unicode.type(0x1f4aa); + } else if (strcmp(symbol, "pray") == 0) { + Unicode.type(0x1f64f); + } else if (strcmp(symbol, "kiss") == 0) { + Unicode.type(0x1f618); + } else if (strcmp(symbol, "rip") == 0) { + Unicode.type(0x26b0); + } else if (strcmp(symbol, "dead") == 0) { + Unicode.type(0x1f480); + } else if (strcmp(symbol, "ok") == 0) { + Unicode.type(0x1f58f); + } else if (strcmp(symbol, "yes") == 0) { + Unicode.type(0x1f592); + } else if (strcmp(symbol, "no") == 0) { + Unicode.type(0x1f593); + } else if (strcmp(symbol, "fu") == 0) { + Unicode.type(0x1f595); + } else if (strcmp(symbol, "spy") == 0) { + Unicode.type(0x1f575); + } else if (strcmp(symbol, "ooo") == 0) { + Unicode.type(0x1f47b); + } + break; + } +} diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..cd592d4 --- /dev/null +++ b/build.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +ARDUINO_PATH=/usr/share/arduino +export ARDUINO_PATH +COMPILER_PATH=~/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/bin/ +export COMPILER_PATH +AVRDUDE=/usr/bin/avrdude +export AVRDUDE +AVRDUDE_CONF=/etc/avrdude.conf +export AVRDUDE_CONF + +make $@ |