this repo has no description
dotfiles

Add Keyboardio Model 100 firmware

+1527
+48
keyboard/model100/Makefile
··· 1 + # This makefile for a Kaleidoscope sketch pulls in all the targets 2 + # required to build the example 3 + 4 + 5 + 6 + 7 + ifneq ($(KALEIDOSCOPE_DIR),) 8 + search_path += $(KALEIDOSCOPE_DIR) 9 + endif 10 + 11 + ifneq ($(ARDUINO_DIRECTORIES_USER),) 12 + search_path += $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope 13 + endif 14 + 15 + ifeq ($(shell uname -s),Darwin) 16 + search_path += $(HOME)/Documents/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope 17 + else 18 + search_path += $(HOME)/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope 19 + endif 20 + 21 + sketch_makefile := etc/makefiles/sketch.mk 22 + 23 + $(foreach candidate, $(search_path), $(if $(wildcard $(candidate)/$(sketch_makefile)), $(eval ks_dir ?= $(candidate)))) 24 + 25 + ifneq ($(ks_dir),) 26 + 27 + $(info Using Kaleidoscope from $(ks_dir)) 28 + 29 + export KALEIDOSCOPE_DIR := $(ks_dir) 30 + include $(ks_dir)/$(sketch_makefile) 31 + 32 + else 33 + 34 + $(info I can't find your Kaleidoscope installation.) 35 + $(info ) 36 + $(info I tried looking in:) 37 + $(info ) 38 + $(foreach candidate, $(search_path), $(info $(candidate))) 39 + $(info ) 40 + $(info The easiest way to fix this is to set the 'KALEIDOSCOPE_DIR' environment) 41 + $(info variable to the location of your Kaleidoscope directory.) 42 + 43 + endif 44 + 45 + 46 + null-target: 47 + $(info You should never see this message) 48 + @:
+769
keyboard/model100/firmware_sharparam.ino
··· 1 + // -*- mode: c++ -*- 2 + // Copyright 2016-2022 Keyboardio, inc. <jesse@keyboard.io> 3 + // See "LICENSE" for license details 4 + 5 + #ifndef BUILD_INFORMATION 6 + #define BUILD_INFORMATION "local build on " __DATE__ " at " __TIME__ 7 + #endif 8 + 9 + /** 10 + * These #include directives pull in the Kaleidoscope firmware core, 11 + * as well as the Kaleidoscope plugins we use in the Model 100's firmware 12 + */ 13 + 14 + // The Kaleidoscope core 15 + #include "Kaleidoscope.h" 16 + 17 + // Support for storing the keymap in EEPROM 18 + #include "Kaleidoscope-EEPROM-Settings.h" 19 + #include "Kaleidoscope-EEPROM-Keymap.h" 20 + 21 + // Support for communicating with the host via a simple Serial protocol 22 + #include "Kaleidoscope-FocusSerial.h" 23 + 24 + // Support for querying the firmware version via Focus 25 + #include "Kaleidoscope-FirmwareVersion.h" 26 + 27 + // Support for keys that move the mouse 28 + #include "Kaleidoscope-MouseKeys.h" 29 + 30 + // Support for macros 31 + #include "Kaleidoscope-Macros.h" 32 + 33 + // Support for controlling the keyboard's LEDs 34 + #include "Kaleidoscope-LEDControl.h" 35 + 36 + // Support for "Numpad" mode, which is mostly just the Numpad specific LED mode 37 + //#include "Kaleidoscope-NumPad.h" 38 + 39 + // Support for the "Boot greeting" effect, which pulses the 'LED' button for 10s 40 + // when the keyboard is connected to a computer (or that computer is powered on) 41 + #include "Kaleidoscope-LEDEffect-BootGreeting.h" 42 + 43 + // Support for LED modes that set all LEDs to a single color 44 + //#include "Kaleidoscope-LEDEffect-SolidColor.h" 45 + 46 + // Support for an LED mode that makes all the LEDs 'breathe' 47 + //#include "Kaleidoscope-LEDEffect-Breathe.h" 48 + 49 + // Support for an LED mode that makes a red pixel chase a blue pixel across the keyboard 50 + //#include "Kaleidoscope-LEDEffect-Chase.h" 51 + 52 + // Support for LED modes that pulse the keyboard's LED in a rainbow pattern 53 + //#include "Kaleidoscope-LEDEffect-Rainbow.h" 54 + 55 + // Support for an LED mode that lights up the keys as you press them 56 + #include "Kaleidoscope-LED-Stalker.h" 57 + 58 + // Support for an LED mode that prints the keys you press in letters 4px high 59 + #include "Kaleidoscope-LED-AlphaSquare.h" 60 + 61 + // Support for shared palettes for other plugins, like Colormap below 62 + #include "Kaleidoscope-LED-Palette-Theme.h" 63 + 64 + // Support for an LED mode that lets one configure per-layer color maps 65 + #include "Kaleidoscope-Colormap.h" 66 + 67 + // Support for turning the LEDs off after a certain amount of time 68 + #include "Kaleidoscope-IdleLEDs.h" 69 + 70 + // Support for setting and saving the default LED mode 71 + #include "Kaleidoscope-DefaultLEDModeConfig.h" 72 + 73 + // Support for changing the brightness of the LEDs 74 + #include "Kaleidoscope-LEDBrightnessConfig.h" 75 + 76 + // Support for Keyboardio's internal keyboard testing mode 77 + #include "Kaleidoscope-HardwareTestMode.h" 78 + 79 + // Support for host power management (suspend & wakeup) 80 + #include "Kaleidoscope-HostPowerManagement.h" 81 + 82 + // Support for magic combos (key chords that trigger an action) 83 + #include "Kaleidoscope-MagicCombo.h" 84 + 85 + // Support for USB quirks, like changing the key state report protocol 86 + #include "Kaleidoscope-USB-Quirks.h" 87 + 88 + // Support for secondary actions on keys 89 + #include "Kaleidoscope-Qukeys.h" 90 + 91 + // Support for one-shot modifiers and layer keys 92 + #include "Kaleidoscope-OneShot.h" 93 + #include "Kaleidoscope-Escape-OneShot.h" 94 + 95 + // Support for dynamic, Chrysalis-editable macros 96 + #include "Kaleidoscope-DynamicMacros.h" 97 + 98 + // Support for SpaceCadet keys 99 + //#include "Kaleidoscope-SpaceCadet.h" 100 + 101 + // Support for editable layer names 102 + #include "Kaleidoscope-LayerNames.h" 103 + 104 + // Support for the GeminiPR Stenography protocol 105 + #include "Kaleidoscope-Steno.h" 106 + 107 + /** This 'enum' is a list of all the macros used by the Model 100's firmware 108 + * The names aren't particularly important. What is important is that each 109 + * is unique. 110 + * 111 + * These are the names of your macros. They'll be used in two places. 112 + * The first is in your keymap definitions. There, you'll use the syntax 113 + * `M(MACRO_NAME)` to mark a specific keymap position as triggering `MACRO_NAME` 114 + * 115 + * The second usage is in the 'switch' statement in the `macroAction` function. 116 + * That switch statement actually runs the code associated with a macro when 117 + * a macro key is pressed. 118 + */ 119 + 120 + enum { 121 + MACRO_VERSION_INFO, 122 + MACRO_ANY, 123 + MACRO_TOGGLE_QUKEYS, 124 + MACRO_MOVETO_BASE_LAYER, 125 + MACRO_SWITCHTO_QWERTY, 126 + MACRO_SWITCHTO_DVORAK, 127 + MACRO_SWITCHTO_COLEMAK_DH 128 + }; 129 + 130 + 131 + /** The Model 100's key layouts are defined as 'keymaps'. By default, there are three 132 + * keymaps: The standard QWERTY keymap, the "Function layer" keymap and the "Numpad" 133 + * keymap. 134 + * 135 + * Each keymap is defined as a list using the 'KEYMAP_STACKED' macro, built 136 + * of first the left hand's layout, followed by the right hand's layout. 137 + * 138 + * Keymaps typically consist mostly of `Key_` definitions. There are many, many keys 139 + * defined as part of the USB HID Keyboard specification. You can find the names 140 + * (if not yet the explanations) for all the standard `Key_` defintions offered by 141 + * Kaleidoscope in these files: 142 + * https://github.com/keyboardio/Kaleidoscope/blob/master/src/kaleidoscope/key_defs/keyboard.h 143 + * https://github.com/keyboardio/Kaleidoscope/blob/master/src/kaleidoscope/key_defs/consumerctl.h 144 + * https://github.com/keyboardio/Kaleidoscope/blob/master/src/kaleidoscope/key_defs/sysctl.h 145 + * https://github.com/keyboardio/Kaleidoscope/blob/master/src/kaleidoscope/key_defs/keymaps.h 146 + * 147 + * Additional things that should be documented here include 148 + * using ___ to let keypresses fall through to the previously active layer 149 + * using XXX to mark a keyswitch as 'blocked' on this layer 150 + * using ShiftToLayer() and LockLayer() keys to change the active keymap. 151 + * keeping NUM and FN consistent and accessible on all layers 152 + * 153 + * The PROG key is special, since it is how you indicate to the board that you 154 + * want to flash the firmware. However, it can be remapped to a regular key. 155 + * When the keyboard boots, it first looks to see whether the PROG key is held 156 + * down; if it is, it simply awaits further flashing instructions. If it is 157 + * not, it continues loading the rest of the firmware and the keyboard 158 + * functions normally, with whatever binding you have set to PROG. More detail 159 + * here: https://community.keyboard.io/t/how-the-prog-key-gets-you-into-the-bootloader/506/8 160 + * 161 + * The "keymaps" data structure is a list of the keymaps compiled into the firmware. 162 + * The order of keymaps in the list is important, as the ShiftToLayer(#) and LockLayer(#) 163 + * macros switch to key layers based on this list. 164 + * 165 + * 166 + 167 + * A key defined as 'ShiftToLayer(FUNCTION)' will switch to FUNCTION while held. 168 + * Similarly, a key defined as 'LockLayer(NUMPAD)' will switch to NUMPAD when tapped. 169 + */ 170 + 171 + /** 172 + * Layers are "0-indexed" -- That is the first one is layer 0. The second one is layer 1. 173 + * The third one is layer 2. 174 + * This 'enum' lets us use names like QWERTY, FUNCTION, and NUMPAD in place of 175 + * the numbers 0, 1 and 2. 176 + * 177 + */ 178 + 179 + enum { 180 + PRIMARY, 181 + NUMPAD, 182 + FUNCTION, 183 + MOUSE 184 + }; // layers 185 + 186 + 187 + /** 188 + * To change your keyboard's layout from QWERTY to DVORAK or COLEMAK, comment out the line 189 + * 190 + * #define PRIMARY_KEYMAP_QWERTY 191 + * 192 + * by changing it to 193 + * 194 + * // #define PRIMARY_KEYMAP_QWERTY 195 + * 196 + * Then uncomment the line corresponding to the layout you want to use. 197 + * 198 + */ 199 + 200 + #define PRIMARY_KEYMAP_QWERTY 201 + // #define PRIMARY_KEYMAP_DVORAK 202 + // #define PRIMARY_KEYMAP_COLEMAK 203 + // #define PRIMARY_KEYMAP_CUSTOM 204 + 205 + 206 + /* This comment temporarily turns off astyle's indent enforcement 207 + * so we can make the keymaps actually resemble the physical key layout better 208 + */ 209 + // clang-format off 210 + 211 + KEYMAPS( 212 + 213 + #if defined (PRIMARY_KEYMAP_QWERTY) 214 + [PRIMARY] = KEYMAP_STACKED 215 + (___, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext, 216 + Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab, 217 + Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G, 218 + Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape, 219 + Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift, 220 + ShiftToLayer(FUNCTION), 221 + 222 + M(MACRO_ANY), Key_6, Key_7, Key_8, Key_9, Key_0, LockLayer(NUMPAD), 223 + Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals, 224 + Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote, 225 + Key_RightAlt, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus, 226 + Key_RightShift, Key_LeftAlt, Key_Spacebar, Key_RightControl, 227 + ShiftToLayer(FUNCTION)), 228 + 229 + #elif defined (PRIMARY_KEYMAP_DVORAK) 230 + 231 + [PRIMARY] = KEYMAP_STACKED 232 + (___, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext, 233 + Key_Backtick, Key_Quote, Key_Comma, Key_Period, Key_P, Key_Y, Key_Tab, 234 + Key_PageUp, Key_A, Key_O, Key_E, Key_U, Key_I, 235 + Key_PageDown, Key_Semicolon, Key_Q, Key_J, Key_K, Key_X, Key_Escape, 236 + Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift, 237 + ShiftToLayer(FUNCTION), 238 + 239 + M(MACRO_ANY), Key_6, Key_7, Key_8, Key_9, Key_0, LockLayer(NUMPAD), 240 + Key_Enter, Key_F, Key_G, Key_C, Key_R, Key_L, Key_Slash, 241 + Key_D, Key_H, Key_T, Key_N, Key_S, Key_Minus, 242 + Key_RightAlt, Key_B, Key_M, Key_W, Key_V, Key_Z, Key_Equals, 243 + Key_RightShift, Key_LeftAlt, Key_Spacebar, Key_RightControl, 244 + ShiftToLayer(FUNCTION)), 245 + 246 + #elif defined (PRIMARY_KEYMAP_COLEMAK) 247 + 248 + [PRIMARY] = KEYMAP_STACKED 249 + (___, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext, 250 + Key_Backtick, Key_Q, Key_W, Key_F, Key_P, Key_B, Key_Tab, 251 + Key_PageUp, Key_A, Key_R, Key_S, Key_T, Key_G, 252 + Key_PageDown, Key_Z, Key_X, Key_C, Key_D, Key_V, Key_Escape, 253 + Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift, 254 + ShiftToLayer(FUNCTION), 255 + 256 + M(MACRO_ANY), Key_6, Key_7, Key_8, Key_9, Key_0, LockLayer(NUMPAD), 257 + Key_Enter, Key_J, Key_L, Key_U, Key_Y, Key_Semicolon, Key_Equals, 258 + Key_M, Key_N, Key_E, Key_I, Key_O, Key_Quote, 259 + Key_RightAlt, Key_K, Key_H, Key_Comma, Key_Period, Key_Slash, Key_Minus, 260 + Key_RightShift, Key_LeftAlt, Key_Spacebar, Key_RightControl, 261 + ShiftToLayer(FUNCTION)), 262 + 263 + #elif defined (PRIMARY_KEYMAP_CUSTOM) 264 + // Edit this keymap to make a custom layout 265 + [PRIMARY] = KEYMAP_STACKED 266 + (___, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext, 267 + Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab, 268 + Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G, 269 + Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape, 270 + Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift, 271 + ShiftToLayer(FUNCTION), 272 + 273 + M(MACRO_ANY), Key_6, Key_7, Key_8, Key_9, Key_0, LockLayer(NUMPAD), 274 + Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals, 275 + Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote, 276 + Key_RightAlt, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus, 277 + Key_RightShift, Key_LeftAlt, Key_Spacebar, Key_RightControl, 278 + ShiftToLayer(FUNCTION)), 279 + 280 + #else 281 + 282 + #error "No default keymap defined. You should make sure that you have a line like '#define PRIMARY_KEYMAP_QWERTY' in your sketch" 283 + 284 + #endif 285 + 286 + 287 + 288 + [NUMPAD] = KEYMAP_STACKED 289 + (___, ___, ___, ___, ___, ___, ___, 290 + ___, ___, ___, ___, ___, ___, ___, 291 + ___, ___, ___, ___, ___, ___, 292 + ___, ___, ___, ___, ___, ___, ___, 293 + ___, ___, ___, ___, 294 + ___, 295 + 296 + M(MACRO_VERSION_INFO), ___, Key_7, Key_8, Key_9, Key_KeypadSubtract, ___, 297 + ___, ___, Key_4, Key_5, Key_6, Key_KeypadAdd, ___, 298 + ___, Key_1, Key_2, Key_3, Key_Equals, ___, 299 + ___, ___, Key_0, Key_Period, Key_KeypadMultiply, Key_KeypadDivide, Key_Enter, 300 + ___, ___, ___, ___, 301 + ___), 302 + 303 + [FUNCTION] = KEYMAP_STACKED 304 + (___, Key_F1, Key_F2, Key_F3, Key_F4, Key_F5, Key_CapsLock, 305 + Key_Tab, ___, Key_mouseUp, ___, Key_mouseBtnR, Key_mouseWarpEnd, Key_mouseWarpNE, 306 + Key_Home, Key_mouseL, Key_mouseDn, Key_mouseR, Key_mouseBtnL, Key_mouseWarpNW, 307 + Key_End, Key_PrintScreen, Key_Insert, ___, Key_mouseBtnM, Key_mouseWarpSW, Key_mouseWarpSE, 308 + ___, Key_Delete, ___, ___, 309 + ___, 310 + 311 + Consumer_ScanPreviousTrack, Key_F6, Key_F7, Key_F8, Key_F9, Key_F10, Key_F11, 312 + Consumer_PlaySlashPause, Consumer_ScanNextTrack, Key_LeftCurlyBracket, Key_RightCurlyBracket, Key_LeftBracket, Key_RightBracket, Key_F12, 313 + Key_LeftArrow, Key_DownArrow, Key_UpArrow, Key_RightArrow, ___, ___, 314 + Key_PcApplication, Consumer_Mute, Consumer_VolumeDecrement, Consumer_VolumeIncrement, ___, Key_Backslash, Key_Pipe, 315 + ___, ___, Key_Enter, ___, 316 + ___) 317 + ) // KEYMAPS( 318 + 319 + /* Re-enable astyle's indent enforcement */ 320 + // clang-format on 321 + 322 + /** versionInfoMacro handles the 'firmware version info' macro 323 + * When a key bound to the macro is pressed, this macro 324 + * prints out the firmware build information as virtual keystrokes 325 + */ 326 + 327 + static void versionInfoMacro(uint8_t key_state) { 328 + if (keyToggledOn(key_state)) { 329 + Macros.type(PSTR("Keyboardio Model 100 - Firmware version ")); 330 + Macros.type(PSTR(KALEIDOSCOPE_FIRMWARE_VERSION)); 331 + } 332 + } 333 + 334 + /** anyKeyMacro is used to provide the functionality of the 'Any' key. 335 + * 336 + * When the 'any key' macro is toggled on, a random alphanumeric key is 337 + * selected. While the key is held, the function generates a synthetic 338 + * keypress event repeating that randomly selected key. 339 + * 340 + */ 341 + 342 + static void anyKeyMacro(KeyEvent &event) { 343 + if (keyToggledOn(event.state)) { 344 + event.key.setKeyCode(Key_A.getKeyCode() + (uint8_t)(millis() % 36)); 345 + event.key.setFlags(0); 346 + } 347 + } 348 + 349 + static uint8_t baseLayerIndex = 0; 350 + 351 + static void moveToBaseLayer(KeyEvent &event) { 352 + if (!keyToggledOn(event.state)) { 353 + return; 354 + } 355 + 356 + Layer.move(baseLayerIndex); 357 + } 358 + 359 + static void switchToQwerty(KeyEvent &event) { 360 + if (!keyToggledOn(event.state)) { 361 + return; 362 + } 363 + 364 + baseLayerIndex = 0; 365 + Layer.move(baseLayerIndex); 366 + } 367 + 368 + static void switchToDvorak(KeyEvent &event) { 369 + if (!keyToggledOn(event.state)) { 370 + return; 371 + } 372 + 373 + baseLayerIndex = 3; 374 + Layer.move(baseLayerIndex); 375 + } 376 + 377 + static void switchToColemakDh(KeyEvent &event) { 378 + if (!keyToggledOn(event.state)) { 379 + return; 380 + } 381 + 382 + baseLayerIndex = 7; 383 + Layer.move(baseLayerIndex); 384 + } 385 + 386 + 387 + /** macroAction dispatches keymap events that are tied to a macro 388 + to that macro. It takes two uint8_t parameters. 389 + 390 + The first is the macro being called (the entry in the 'enum' earlier in this file). 391 + The second is the state of the keyswitch. You can use the keyswitch state to figure out 392 + if the key has just been toggled on, is currently pressed or if it's just been released. 393 + 394 + The 'switch' statement should have a 'case' for each entry of the macro enum. 395 + Each 'case' statement should call out to a function to handle the macro in question. 396 + 397 + */ 398 + 399 + const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) { 400 + switch (macro_id) { 401 + 402 + case MACRO_VERSION_INFO: 403 + versionInfoMacro(event.state); 404 + break; 405 + 406 + case MACRO_ANY: 407 + anyKeyMacro(event); 408 + break; 409 + 410 + case MACRO_TOGGLE_QUKEYS: 411 + if (keyToggledOn(event.state)) { 412 + Qukeys.toggle(); 413 + } 414 + break; 415 + 416 + case MACRO_MOVETO_BASE_LAYER: 417 + moveToBaseLayer(event); 418 + break; 419 + case MACRO_SWITCHTO_QWERTY: 420 + switchToQwerty(event); 421 + break; 422 + case MACRO_SWITCHTO_DVORAK: 423 + switchToDvorak(event); 424 + break; 425 + case MACRO_SWITCHTO_COLEMAK_DH: 426 + switchToColemakDh(event); 427 + break; 428 + } 429 + return MACRO_NONE; 430 + } 431 + 432 + 433 + // These 'solid' color effect definitions define a rainbow of 434 + // LED color modes calibrated to draw 500mA or less on the 435 + // Keyboardio Model 100. 436 + 437 + 438 + //static kaleidoscope::plugin::LEDSolidColor solidRed(160, 0, 0); 439 + //static kaleidoscope::plugin::LEDSolidColor solidOrange(140, 70, 0); 440 + //static kaleidoscope::plugin::LEDSolidColor solidYellow(130, 100, 0); 441 + //static kaleidoscope::plugin::LEDSolidColor solidGreen(0, 160, 0); 442 + //static kaleidoscope::plugin::LEDSolidColor solidBlue(0, 70, 130); 443 + //static kaleidoscope::plugin::LEDSolidColor solidIndigo(0, 0, 170); 444 + //static kaleidoscope::plugin::LEDSolidColor solidViolet(130, 0, 120); 445 + 446 + /** toggleLedsOnSuspendResume toggles the LEDs off when the host goes to sleep, 447 + * and turns them back on when it wakes up. 448 + */ 449 + void toggleLedsOnSuspendResume(kaleidoscope::plugin::HostPowerManagement::Event event) { 450 + switch (event) { 451 + case kaleidoscope::plugin::HostPowerManagement::Suspend: 452 + case kaleidoscope::plugin::HostPowerManagement::Sleep: 453 + LEDControl.disable(); 454 + break; 455 + case kaleidoscope::plugin::HostPowerManagement::Resume: 456 + LEDControl.enable(); 457 + break; 458 + } 459 + } 460 + 461 + /** hostPowerManagementEventHandler dispatches power management events (suspend, 462 + * resume, and sleep) to other functions that perform action based on these 463 + * events. 464 + */ 465 + void hostPowerManagementEventHandler(kaleidoscope::plugin::HostPowerManagement::Event event) { 466 + toggleLedsOnSuspendResume(event); 467 + } 468 + 469 + /** This 'enum' is a list of all the magic combos used by the Model 100's 470 + * firmware The names aren't particularly important. What is important is that 471 + * each is unique. 472 + * 473 + * These are the names of your magic combos. They will be used by the 474 + * `USE_MAGIC_COMBOS` call below. 475 + */ 476 + enum { 477 + // Toggle between Boot (6-key rollover; for BIOSes and early boot) and NKRO 478 + // mode. 479 + COMBO_TOGGLE_NKRO_MODE, 480 + // Enter test mode 481 + COMBO_ENTER_TEST_MODE 482 + }; 483 + 484 + /** Wrappers, to be used by MagicCombo. **/ 485 + 486 + /** 487 + * This simply toggles the keyboard protocol via USBQuirks, and wraps it within 488 + * a function with an unused argument, to match what MagicCombo expects. 489 + */ 490 + static void toggleKeyboardProtocol(uint8_t combo_index) { 491 + USBQuirks.toggleKeyboardProtocol(); 492 + } 493 + 494 + /** 495 + * Toggles between using the built-in keymap, and the EEPROM-stored one. 496 + */ 497 + static void toggleKeymapSource(uint8_t combo_index) { 498 + if (Layer.getKey == Layer.getKeyFromPROGMEM) { 499 + Layer.getKey = EEPROMKeymap.getKey; 500 + } else { 501 + Layer.getKey = Layer.getKeyFromPROGMEM; 502 + } 503 + } 504 + 505 + /** 506 + * This enters the hardware test mode 507 + */ 508 + static void enterHardwareTestMode(uint8_t combo_index) { 509 + HardwareTestMode.runTests(); 510 + } 511 + 512 + 513 + /** Magic combo list, a list of key combo and action pairs the firmware should 514 + * recognise. 515 + */ 516 + USE_MAGIC_COMBOS({.action = toggleKeyboardProtocol, 517 + // Left Fn + Esc + Shift 518 + .keys = {R3C6, R2C6, R3C7}}, 519 + {.action = enterHardwareTestMode, 520 + // Left Fn + Prog + LED 521 + .keys = {R3C6, R0C0, R0C6}}, 522 + {.action = toggleKeymapSource, 523 + // Left Fn + Prog + Shift 524 + .keys = {R3C6, R0C0, R3C7}}); 525 + 526 + // First, tell Kaleidoscope which plugins you want to use. 527 + // The order can be important. For example, LED effects are 528 + // added in the order they're listed here. 529 + KALEIDOSCOPE_INIT_PLUGINS( 530 + // ---------------------------------------------------------------------- 531 + // Chrysalis plugins 532 + 533 + // The EEPROMSettings & EEPROMKeymap plugins make it possible to have an 534 + // editable keymap in EEPROM. 535 + EEPROMSettings, 536 + EEPROMKeymap, 537 + 538 + // Focus allows bi-directional communication with the host, and is the 539 + // interface through which the keymap in EEPROM can be edited. 540 + Focus, 541 + 542 + // FocusSettingsCommand adds a few Focus commands, intended to aid in 543 + // changing some settings of the keyboard, such as the default layer (via the 544 + // `settings.defaultLayer` command) 545 + FocusSettingsCommand, 546 + 547 + // FocusEEPROMCommand adds a set of Focus commands, which are very helpful in 548 + // both debugging, and in backing up one's EEPROM contents. 549 + FocusEEPROMCommand, 550 + 551 + // The FirmwareVersion plugin lets Chrysalis query the version of the firmware 552 + // programmatically. 553 + FirmwareVersion, 554 + 555 + // The LayerNames plugin allows Chrysalis to display - and edit - custom layer 556 + // names, to be shown instead of the default indexes. 557 + LayerNames, 558 + 559 + // Enables setting, saving (via Chrysalis), and restoring (on boot) the 560 + // default LED mode. 561 + DefaultLEDModeConfig, 562 + 563 + // Enables controlling (and saving) the brightness of the LEDs via Focus. 564 + LEDBrightnessConfig, 565 + 566 + // ---------------------------------------------------------------------- 567 + // Keystroke-handling plugins 568 + 569 + // The Qukeys plugin enables the "Secondary action" functionality in 570 + // Chrysalis. Keys with secondary actions will have their primary action 571 + // performed when tapped, but the secondary action when held. 572 + Qukeys, 573 + 574 + // SpaceCadet can turn your shifts into parens on tap, while keeping them as 575 + // Shifts when held. SpaceCadetConfig lets Chrysalis configure some aspects of 576 + // the plugin. 577 + //SpaceCadet, 578 + //SpaceCadetConfig, 579 + 580 + // Enables the "Sticky" behavior for modifiers, and the "Layer shift when 581 + // held" functionality for layer keys. 582 + OneShot, 583 + OneShotConfig, 584 + EscapeOneShot, 585 + EscapeOneShotConfig, 586 + 587 + // The macros plugin adds support for macros 588 + Macros, 589 + 590 + // Enables dynamic, Chrysalis-editable macros. 591 + DynamicMacros, 592 + 593 + // The MouseKeys plugin lets you add keys to your keymap which move the mouse. 594 + MouseKeys, 595 + MouseKeysConfig, 596 + 597 + // The MagicCombo plugin lets you use key combinations to trigger custom 598 + // actions - a bit like Macros, but triggered by pressing multiple keys at the 599 + // same time. 600 + MagicCombo, 601 + 602 + // Enables the GeminiPR Stenography protocol. Unused by default, but with the 603 + // plugin enabled, it becomes configurable - and then usable - via Chrysalis. 604 + GeminiPR, 605 + 606 + // ---------------------------------------------------------------------- 607 + // LED mode plugins 608 + 609 + // The boot greeting effect pulses the LED button for 10 seconds after the 610 + // keyboard is first connected 611 + BootGreetingEffect, 612 + 613 + // LEDControl provides support for other LED modes 614 + LEDControl, 615 + 616 + // We start with the LED effect that turns off all the LEDs. 617 + LEDOff, 618 + 619 + // The rainbow effect changes the color of all of the keyboard's keys at the same time 620 + // running through all the colors of the rainbow. 621 + //LEDRainbowEffect, 622 + 623 + // The rainbow wave effect lights up your keyboard with all the colors of a rainbow 624 + // and slowly moves the rainbow across your keyboard 625 + //LEDRainbowWaveEffect, 626 + 627 + // The chase effect follows the adventure of a blue pixel which chases a red pixel across 628 + // your keyboard. Spoiler: the blue pixel never catches the red pixel 629 + //LEDChaseEffect, 630 + 631 + // These static effects turn your keyboard's LEDs a variety of colors 632 + //solidRed, 633 + //solidOrange, 634 + //solidYellow, 635 + //solidGreen, 636 + //solidBlue, 637 + //solidIndigo, 638 + //solidViolet, 639 + 640 + // The breathe effect slowly pulses all of the LEDs on your keyboard 641 + //LEDBreatheEffect, 642 + 643 + // The AlphaSquare effect prints each character you type, using your 644 + // keyboard's LEDs as a display 645 + AlphaSquareEffect, 646 + 647 + // The stalker effect lights up the keys you've pressed recently 648 + StalkerEffect, 649 + 650 + // The LED Palette Theme plugin provides a shared palette for other plugins, 651 + // like Colormap below 652 + LEDPaletteTheme, 653 + 654 + // The Colormap effect makes it possible to set up per-layer colormaps 655 + ColormapEffect, 656 + 657 + // The numpad plugin is responsible for lighting up the 'numpad' mode 658 + // with a custom LED effect 659 + //NumPad, 660 + 661 + // The HostPowerManagement plugin allows us to turn LEDs off when then host 662 + // goes to sleep, and resume them when it wakes up. 663 + HostPowerManagement, 664 + 665 + // Turns LEDs off after a configurable amount of idle time. 666 + IdleLEDs, 667 + PersistentIdleLEDs, 668 + 669 + // ---------------------------------------------------------------------- 670 + // Miscellaneous plugins 671 + 672 + // The USBQuirks plugin lets you do some things with USB that we aren't 673 + // comfortable - or able - to do automatically, but can be useful 674 + // nevertheless. Such as toggling the key report protocol between Boot (used 675 + // by BIOSes) and Report (NKRO). 676 + USBQuirks, 677 + 678 + // The hardware test mode, which can be invoked by tapping Prog, LED and the 679 + // left Fn button at the same time. 680 + HardwareTestMode //, 681 + ); 682 + 683 + /** The 'setup' function is one of the two standard Arduino sketch functions. 684 + * It's called when your keyboard first powers up. This is where you set up 685 + * Kaleidoscope and any plugins. 686 + */ 687 + void setup() { 688 + // QUKEYS( 689 + // kaleidoscope::plugin::Qukey(kaleidoscope::plugin::Qukeys::layer_wildcard, KeyAddr(3, 7), LSHIFT(Key_9)), 690 + // kaleidoscope::plugin::Qukey(kaleidoscope::plugin::Qukeys::layer_wildcard, KeyAddr(3, 8), LSHIFT(Key_0)) 691 + // ) 692 + 693 + // First, call Kaleidoscope's internal setup function 694 + Kaleidoscope.setup(); 695 + 696 + // Set the hue of the boot greeting effect to something that will result in a 697 + // nice green color. 698 + BootGreetingEffect.hue = 85; 699 + 700 + // While we hope to improve this in the future, the NumPad plugin 701 + // needs to be explicitly told which keymap layer is your numpad layer 702 + //NumPad.numPadLayer = NUMPAD; 703 + 704 + // We configure the AlphaSquare effect to use RED letters 705 + AlphaSquare.color = CRGB(255, 0, 0); 706 + 707 + // Set the rainbow effects to be reasonably bright, but low enough 708 + // to mitigate audible noise in some environments. 709 + //LEDRainbowEffect.brightness(170); 710 + //LEDRainbowWaveEffect.brightness(160); 711 + 712 + // Set the action key the test mode should listen for to Left Fn 713 + HardwareTestMode.setActionKey(R3C6); 714 + 715 + // The LED Stalker mode has a few effects. The one we like is called 716 + // 'BlazingTrail'. For details on other options, see 717 + // https://github.com/keyboardio/Kaleidoscope/blob/master/docs/plugins/LED-Stalker.md 718 + StalkerEffect.variant = STALKER(BlazingTrail); 719 + 720 + // To make the keymap editable without flashing new firmware, we store 721 + // additional layers in EEPROM. For now, we reserve space for eight layers. If 722 + // one wants to use these layers, just set the default layer to one in EEPROM, 723 + // by using the `settings.defaultLayer` Focus command, or by using the 724 + // `keymap.onlyCustom` command to use EEPROM layers only. 725 + EEPROMKeymap.setup(8); 726 + 727 + // We need to tell the Colormap plugin how many layers we want to have custom 728 + // maps for. To make things simple, we set it to eight layers, which is how 729 + // many editable layers we have (see above). 730 + ColormapEffect.max_layers(8); 731 + 732 + // For Dynamic Macros, we need to reserve storage space for the editable 733 + // macros. A kilobyte is a reasonable default. 734 + DynamicMacros.reserve_storage(1024); 735 + 736 + // If there's a default layer set in EEPROM, we should set that as the default 737 + // here. 738 + Layer.move(EEPROMSettings.default_layer()); 739 + 740 + // To avoid any surprises, SpaceCadet is turned off by default. However, it 741 + // can be permanently enabled via Chrysalis, so we should only disable it if 742 + // no configuration exists. 743 + //SpaceCadetConfig.disableSpaceCadetIfUnconfigured(); 744 + 745 + // Editable layer names are stored in EEPROM too, and we reserve 16 bytes per 746 + // layer for them. We need one extra byte per layer for bookkeeping, so we 747 + // reserve 17 / layer in total. 748 + LayerNames.reserve_storage(17 * 8); 749 + 750 + // Unless configured otherwise with Chrysalis, we want to make sure that the 751 + // firmware starts with LED effects off. This avoids over-taxing devices that 752 + // don't have a lot of power to share with USB devices 753 + DefaultLEDModeConfig.activateLEDModeIfUnconfigured(&LEDOff); 754 + 755 + // Qukeys config 756 + Qukeys.setOverlapThreshold(90); 757 + Qukeys.setMinimumHoldTime(100); 758 + } 759 + 760 + /** loop is the second of the standard Arduino sketch functions. 761 + * As you might expect, it runs in a loop, never exiting. 762 + * 763 + * For Kaleidoscope-based keyboard firmware, you usually just want to 764 + * call Kaleidoscope.loop(); and not do anything custom here. 765 + */ 766 + 767 + void loop() { 768 + Kaleidoscope.loop(); 769 + }
+704
keyboard/model100/firmware_sharparam.ino.bak
··· 1 + // -*- mode: c++ -*- 2 + // Copyright 2016-2022 Keyboardio, inc. <jesse@keyboard.io> 3 + // See "LICENSE" for license details 4 + 5 + #ifndef BUILD_INFORMATION 6 + #define BUILD_INFORMATION "local build on " __DATE__ " at " __TIME__ 7 + #endif 8 + 9 + /** 10 + * These #include directives pull in the Kaleidoscope firmware core, 11 + * as well as the Kaleidoscope plugins we use in the Model 100's firmware 12 + */ 13 + 14 + // The Kaleidoscope core 15 + #include "Kaleidoscope.h" 16 + 17 + // Support for storing the keymap in EEPROM 18 + #include "Kaleidoscope-EEPROM-Settings.h" 19 + #include "Kaleidoscope-EEPROM-Keymap.h" 20 + 21 + // Support for communicating with the host via a simple Serial protocol 22 + #include "Kaleidoscope-FocusSerial.h" 23 + 24 + // Support for querying the firmware version via Focus 25 + #include "Kaleidoscope-FirmwareVersion.h" 26 + 27 + // Support for keys that move the mouse 28 + #include "Kaleidoscope-MouseKeys.h" 29 + 30 + // Support for macros 31 + #include "Kaleidoscope-Macros.h" 32 + 33 + // Support for controlling the keyboard's LEDs 34 + #include "Kaleidoscope-LEDControl.h" 35 + 36 + // Support for "Numpad" mode, which is mostly just the Numpad specific LED mode 37 + //#include "Kaleidoscope-NumPad.h" 38 + 39 + // Support for the "Boot greeting" effect, which pulses the 'LED' button for 10s 40 + // when the keyboard is connected to a computer (or that computer is powered on) 41 + #include "Kaleidoscope-LEDEffect-BootGreeting.h" 42 + 43 + // Support for LED modes that set all LEDs to a single color 44 + //#include "Kaleidoscope-LEDEffect-SolidColor.h" 45 + 46 + // Support for an LED mode that makes all the LEDs 'breathe' 47 + //#include "Kaleidoscope-LEDEffect-Breathe.h" 48 + 49 + // Support for an LED mode that makes a red pixel chase a blue pixel across the keyboard 50 + //#include "Kaleidoscope-LEDEffect-Chase.h" 51 + 52 + // Support for LED modes that pulse the keyboard's LED in a rainbow pattern 53 + //#include "Kaleidoscope-LEDEffect-Rainbow.h" 54 + 55 + // Support for an LED mode that lights up the keys as you press them 56 + #include "Kaleidoscope-LED-Stalker.h" 57 + 58 + // Support for an LED mode that prints the keys you press in letters 4px high 59 + #include "Kaleidoscope-LED-AlphaSquare.h" 60 + 61 + // Support for shared palettes for other plugins, like Colormap below 62 + #include "Kaleidoscope-LED-Palette-Theme.h" 63 + 64 + // Support for an LED mode that lets one configure per-layer color maps 65 + #include "Kaleidoscope-Colormap.h" 66 + 67 + // Support for turning the LEDs off after a certain amount of time 68 + #include "Kaleidoscope-IdleLEDs.h" 69 + 70 + // Support for setting and saving the default LED mode 71 + #include "Kaleidoscope-DefaultLEDModeConfig.h" 72 + 73 + // Support for changing the brightness of the LEDs 74 + #include "Kaleidoscope-LEDBrightnessConfig.h" 75 + 76 + // Support for Keyboardio's internal keyboard testing mode 77 + #include "Kaleidoscope-HardwareTestMode.h" 78 + 79 + // Support for host power management (suspend & wakeup) 80 + #include "Kaleidoscope-HostPowerManagement.h" 81 + 82 + // Support for magic combos (key chords that trigger an action) 83 + #include "Kaleidoscope-MagicCombo.h" 84 + 85 + // Support for USB quirks, like changing the key state report protocol 86 + #include "Kaleidoscope-USB-Quirks.h" 87 + 88 + // Support for secondary actions on keys 89 + #include "Kaleidoscope-Qukeys.h" 90 + 91 + // Support for one-shot modifiers and layer keys 92 + #include "Kaleidoscope-OneShot.h" 93 + #include "Kaleidoscope-Escape-OneShot.h" 94 + 95 + // Support for dynamic, Chrysalis-editable macros 96 + #include "Kaleidoscope-DynamicMacros.h" 97 + 98 + // Support for SpaceCadet keys 99 + //#include "Kaleidoscope-SpaceCadet.h" 100 + 101 + // Support for editable layer names 102 + #include "Kaleidoscope-LayerNames.h" 103 + 104 + // Support for the GeminiPR Stenography protocol 105 + #include "Kaleidoscope-Steno.h" 106 + 107 + /** This 'enum' is a list of all the macros used by the Model 100's firmware 108 + * The names aren't particularly important. What is important is that each 109 + * is unique. 110 + * 111 + * These are the names of your macros. They'll be used in two places. 112 + * The first is in your keymap definitions. There, you'll use the syntax 113 + * `M(MACRO_NAME)` to mark a specific keymap position as triggering `MACRO_NAME` 114 + * 115 + * The second usage is in the 'switch' statement in the `macroAction` function. 116 + * That switch statement actually runs the code associated with a macro when 117 + * a macro key is pressed. 118 + */ 119 + 120 + enum { 121 + MACRO_VERSION_INFO, 122 + MACRO_ANY, 123 + MACRO_TOGGLE_QUKEYS 124 + }; 125 + 126 + 127 + /** The Model 100's key layouts are defined as 'keymaps'. By default, there are three 128 + * keymaps: The standard QWERTY keymap, the "Function layer" keymap and the "Numpad" 129 + * keymap. 130 + * 131 + * Each keymap is defined as a list using the 'KEYMAP_STACKED' macro, built 132 + * of first the left hand's layout, followed by the right hand's layout. 133 + * 134 + * Keymaps typically consist mostly of `Key_` definitions. There are many, many keys 135 + * defined as part of the USB HID Keyboard specification. You can find the names 136 + * (if not yet the explanations) for all the standard `Key_` defintions offered by 137 + * Kaleidoscope in these files: 138 + * https://github.com/keyboardio/Kaleidoscope/blob/master/src/kaleidoscope/key_defs/keyboard.h 139 + * https://github.com/keyboardio/Kaleidoscope/blob/master/src/kaleidoscope/key_defs/consumerctl.h 140 + * https://github.com/keyboardio/Kaleidoscope/blob/master/src/kaleidoscope/key_defs/sysctl.h 141 + * https://github.com/keyboardio/Kaleidoscope/blob/master/src/kaleidoscope/key_defs/keymaps.h 142 + * 143 + * Additional things that should be documented here include 144 + * using ___ to let keypresses fall through to the previously active layer 145 + * using XXX to mark a keyswitch as 'blocked' on this layer 146 + * using ShiftToLayer() and LockLayer() keys to change the active keymap. 147 + * keeping NUM and FN consistent and accessible on all layers 148 + * 149 + * The PROG key is special, since it is how you indicate to the board that you 150 + * want to flash the firmware. However, it can be remapped to a regular key. 151 + * When the keyboard boots, it first looks to see whether the PROG key is held 152 + * down; if it is, it simply awaits further flashing instructions. If it is 153 + * not, it continues loading the rest of the firmware and the keyboard 154 + * functions normally, with whatever binding you have set to PROG. More detail 155 + * here: https://community.keyboard.io/t/how-the-prog-key-gets-you-into-the-bootloader/506/8 156 + * 157 + * The "keymaps" data structure is a list of the keymaps compiled into the firmware. 158 + * The order of keymaps in the list is important, as the ShiftToLayer(#) and LockLayer(#) 159 + * macros switch to key layers based on this list. 160 + * 161 + * 162 + 163 + * A key defined as 'ShiftToLayer(FUNCTION)' will switch to FUNCTION while held. 164 + * Similarly, a key defined as 'LockLayer(NUMPAD)' will switch to NUMPAD when tapped. 165 + */ 166 + 167 + /** 168 + * Layers are "0-indexed" -- That is the first one is layer 0. The second one is layer 1. 169 + * The third one is layer 2. 170 + * This 'enum' lets us use names like QWERTY, FUNCTION, and NUMPAD in place of 171 + * the numbers 0, 1 and 2. 172 + * 173 + */ 174 + 175 + enum { 176 + PRIMARY, 177 + NUMPAD, 178 + FUNCTION, 179 + MOUSE 180 + }; // layers 181 + 182 + 183 + /** 184 + * To change your keyboard's layout from QWERTY to DVORAK or COLEMAK, comment out the line 185 + * 186 + * #define PRIMARY_KEYMAP_QWERTY 187 + * 188 + * by changing it to 189 + * 190 + * // #define PRIMARY_KEYMAP_QWERTY 191 + * 192 + * Then uncomment the line corresponding to the layout you want to use. 193 + * 194 + */ 195 + 196 + #define PRIMARY_KEYMAP_QWERTY 197 + // #define PRIMARY_KEYMAP_DVORAK 198 + // #define PRIMARY_KEYMAP_COLEMAK 199 + // #define PRIMARY_KEYMAP_CUSTOM 200 + 201 + 202 + /* This comment temporarily turns off astyle's indent enforcement 203 + * so we can make the keymaps actually resemble the physical key layout better 204 + */ 205 + // clang-format off 206 + 207 + KEYMAPS( 208 + 209 + #if defined (PRIMARY_KEYMAP_QWERTY) 210 + [PRIMARY] = KEYMAP_STACKED 211 + (___, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext, 212 + Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab, 213 + Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G, 214 + Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape, 215 + Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift, 216 + ShiftToLayer(FUNCTION), 217 + 218 + M(MACRO_ANY), Key_6, Key_7, Key_8, Key_9, Key_0, LockLayer(NUMPAD), 219 + Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals, 220 + Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote, 221 + Key_RightAlt, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus, 222 + Key_RightShift, Key_LeftAlt, Key_Spacebar, Key_RightControl, 223 + ShiftToLayer(FUNCTION)), 224 + 225 + #elif defined (PRIMARY_KEYMAP_DVORAK) 226 + 227 + [PRIMARY] = KEYMAP_STACKED 228 + (___, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext, 229 + Key_Backtick, Key_Quote, Key_Comma, Key_Period, Key_P, Key_Y, Key_Tab, 230 + Key_PageUp, Key_A, Key_O, Key_E, Key_U, Key_I, 231 + Key_PageDown, Key_Semicolon, Key_Q, Key_J, Key_K, Key_X, Key_Escape, 232 + Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift, 233 + ShiftToLayer(FUNCTION), 234 + 235 + M(MACRO_ANY), Key_6, Key_7, Key_8, Key_9, Key_0, LockLayer(NUMPAD), 236 + Key_Enter, Key_F, Key_G, Key_C, Key_R, Key_L, Key_Slash, 237 + Key_D, Key_H, Key_T, Key_N, Key_S, Key_Minus, 238 + Key_RightAlt, Key_B, Key_M, Key_W, Key_V, Key_Z, Key_Equals, 239 + Key_RightShift, Key_LeftAlt, Key_Spacebar, Key_RightControl, 240 + ShiftToLayer(FUNCTION)), 241 + 242 + #elif defined (PRIMARY_KEYMAP_COLEMAK) 243 + 244 + [PRIMARY] = KEYMAP_STACKED 245 + (___, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext, 246 + Key_Backtick, Key_Q, Key_W, Key_F, Key_P, Key_B, Key_Tab, 247 + Key_PageUp, Key_A, Key_R, Key_S, Key_T, Key_G, 248 + Key_PageDown, Key_Z, Key_X, Key_C, Key_D, Key_V, Key_Escape, 249 + Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift, 250 + ShiftToLayer(FUNCTION), 251 + 252 + M(MACRO_ANY), Key_6, Key_7, Key_8, Key_9, Key_0, LockLayer(NUMPAD), 253 + Key_Enter, Key_J, Key_L, Key_U, Key_Y, Key_Semicolon, Key_Equals, 254 + Key_M, Key_N, Key_E, Key_I, Key_O, Key_Quote, 255 + Key_RightAlt, Key_K, Key_H, Key_Comma, Key_Period, Key_Slash, Key_Minus, 256 + Key_RightShift, Key_LeftAlt, Key_Spacebar, Key_RightControl, 257 + ShiftToLayer(FUNCTION)), 258 + 259 + #elif defined (PRIMARY_KEYMAP_CUSTOM) 260 + // Edit this keymap to make a custom layout 261 + [PRIMARY] = KEYMAP_STACKED 262 + (___, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext, 263 + Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab, 264 + Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G, 265 + Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape, 266 + Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift, 267 + ShiftToLayer(FUNCTION), 268 + 269 + M(MACRO_ANY), Key_6, Key_7, Key_8, Key_9, Key_0, LockLayer(NUMPAD), 270 + Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals, 271 + Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote, 272 + Key_RightAlt, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus, 273 + Key_RightShift, Key_LeftAlt, Key_Spacebar, Key_RightControl, 274 + ShiftToLayer(FUNCTION)), 275 + 276 + #else 277 + 278 + #error "No default keymap defined. You should make sure that you have a line like '#define PRIMARY_KEYMAP_QWERTY' in your sketch" 279 + 280 + #endif 281 + 282 + 283 + 284 + [NUMPAD] = KEYMAP_STACKED 285 + (___, ___, ___, ___, ___, ___, ___, 286 + ___, ___, ___, ___, ___, ___, ___, 287 + ___, ___, ___, ___, ___, ___, 288 + ___, ___, ___, ___, ___, ___, ___, 289 + ___, ___, ___, ___, 290 + ___, 291 + 292 + M(MACRO_VERSION_INFO), ___, Key_7, Key_8, Key_9, Key_KeypadSubtract, ___, 293 + ___, ___, Key_4, Key_5, Key_6, Key_KeypadAdd, ___, 294 + ___, Key_1, Key_2, Key_3, Key_Equals, ___, 295 + ___, ___, Key_0, Key_Period, Key_KeypadMultiply, Key_KeypadDivide, Key_Enter, 296 + ___, ___, ___, ___, 297 + ___), 298 + 299 + [FUNCTION] = KEYMAP_STACKED 300 + (___, Key_F1, Key_F2, Key_F3, Key_F4, Key_F5, Key_CapsLock, 301 + Key_Tab, ___, Key_mouseUp, ___, Key_mouseBtnR, Key_mouseWarpEnd, Key_mouseWarpNE, 302 + Key_Home, Key_mouseL, Key_mouseDn, Key_mouseR, Key_mouseBtnL, Key_mouseWarpNW, 303 + Key_End, Key_PrintScreen, Key_Insert, ___, Key_mouseBtnM, Key_mouseWarpSW, Key_mouseWarpSE, 304 + ___, Key_Delete, ___, ___, 305 + ___, 306 + 307 + Consumer_ScanPreviousTrack, Key_F6, Key_F7, Key_F8, Key_F9, Key_F10, Key_F11, 308 + Consumer_PlaySlashPause, Consumer_ScanNextTrack, Key_LeftCurlyBracket, Key_RightCurlyBracket, Key_LeftBracket, Key_RightBracket, Key_F12, 309 + Key_LeftArrow, Key_DownArrow, Key_UpArrow, Key_RightArrow, ___, ___, 310 + Key_PcApplication, Consumer_Mute, Consumer_VolumeDecrement, Consumer_VolumeIncrement, ___, Key_Backslash, Key_Pipe, 311 + ___, ___, Key_Enter, ___, 312 + ___) 313 + ) // KEYMAPS( 314 + 315 + /* Re-enable astyle's indent enforcement */ 316 + // clang-format on 317 + 318 + /** versionInfoMacro handles the 'firmware version info' macro 319 + * When a key bound to the macro is pressed, this macro 320 + * prints out the firmware build information as virtual keystrokes 321 + */ 322 + 323 + static void versionInfoMacro(uint8_t key_state) { 324 + if (keyToggledOn(key_state)) { 325 + Macros.type(PSTR("Keyboardio Model 100 - Firmware version ")); 326 + Macros.type(PSTR(KALEIDOSCOPE_FIRMWARE_VERSION)); 327 + } 328 + } 329 + 330 + /** anyKeyMacro is used to provide the functionality of the 'Any' key. 331 + * 332 + * When the 'any key' macro is toggled on, a random alphanumeric key is 333 + * selected. While the key is held, the function generates a synthetic 334 + * keypress event repeating that randomly selected key. 335 + * 336 + */ 337 + 338 + static void anyKeyMacro(KeyEvent &event) { 339 + if (keyToggledOn(event.state)) { 340 + event.key.setKeyCode(Key_A.getKeyCode() + (uint8_t)(millis() % 36)); 341 + event.key.setFlags(0); 342 + } 343 + } 344 + 345 + 346 + /** macroAction dispatches keymap events that are tied to a macro 347 + to that macro. It takes two uint8_t parameters. 348 + 349 + The first is the macro being called (the entry in the 'enum' earlier in this file). 350 + The second is the state of the keyswitch. You can use the keyswitch state to figure out 351 + if the key has just been toggled on, is currently pressed or if it's just been released. 352 + 353 + The 'switch' statement should have a 'case' for each entry of the macro enum. 354 + Each 'case' statement should call out to a function to handle the macro in question. 355 + 356 + */ 357 + 358 + const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) { 359 + switch (macro_id) { 360 + 361 + case MACRO_VERSION_INFO: 362 + versionInfoMacro(event.state); 363 + break; 364 + 365 + case MACRO_ANY: 366 + anyKeyMacro(event); 367 + break; 368 + 369 + case MACRO_TOGGLE_QUKEYS: 370 + if (keyToggledOn(event.state)) { 371 + Qukeys.toggle(); 372 + } 373 + break; 374 + } 375 + return MACRO_NONE; 376 + } 377 + 378 + 379 + // These 'solid' color effect definitions define a rainbow of 380 + // LED color modes calibrated to draw 500mA or less on the 381 + // Keyboardio Model 100. 382 + 383 + 384 + //static kaleidoscope::plugin::LEDSolidColor solidRed(160, 0, 0); 385 + //static kaleidoscope::plugin::LEDSolidColor solidOrange(140, 70, 0); 386 + //static kaleidoscope::plugin::LEDSolidColor solidYellow(130, 100, 0); 387 + //static kaleidoscope::plugin::LEDSolidColor solidGreen(0, 160, 0); 388 + //static kaleidoscope::plugin::LEDSolidColor solidBlue(0, 70, 130); 389 + //static kaleidoscope::plugin::LEDSolidColor solidIndigo(0, 0, 170); 390 + //static kaleidoscope::plugin::LEDSolidColor solidViolet(130, 0, 120); 391 + 392 + /** toggleLedsOnSuspendResume toggles the LEDs off when the host goes to sleep, 393 + * and turns them back on when it wakes up. 394 + */ 395 + void toggleLedsOnSuspendResume(kaleidoscope::plugin::HostPowerManagement::Event event) { 396 + switch (event) { 397 + case kaleidoscope::plugin::HostPowerManagement::Suspend: 398 + case kaleidoscope::plugin::HostPowerManagement::Sleep: 399 + LEDControl.disable(); 400 + break; 401 + case kaleidoscope::plugin::HostPowerManagement::Resume: 402 + LEDControl.enable(); 403 + break; 404 + } 405 + } 406 + 407 + /** hostPowerManagementEventHandler dispatches power management events (suspend, 408 + * resume, and sleep) to other functions that perform action based on these 409 + * events. 410 + */ 411 + void hostPowerManagementEventHandler(kaleidoscope::plugin::HostPowerManagement::Event event) { 412 + toggleLedsOnSuspendResume(event); 413 + } 414 + 415 + /** This 'enum' is a list of all the magic combos used by the Model 100's 416 + * firmware The names aren't particularly important. What is important is that 417 + * each is unique. 418 + * 419 + * These are the names of your magic combos. They will be used by the 420 + * `USE_MAGIC_COMBOS` call below. 421 + */ 422 + enum { 423 + // Toggle between Boot (6-key rollover; for BIOSes and early boot) and NKRO 424 + // mode. 425 + COMBO_TOGGLE_NKRO_MODE, 426 + // Enter test mode 427 + COMBO_ENTER_TEST_MODE 428 + }; 429 + 430 + /** Wrappers, to be used by MagicCombo. **/ 431 + 432 + /** 433 + * This simply toggles the keyboard protocol via USBQuirks, and wraps it within 434 + * a function with an unused argument, to match what MagicCombo expects. 435 + */ 436 + static void toggleKeyboardProtocol(uint8_t combo_index) { 437 + USBQuirks.toggleKeyboardProtocol(); 438 + } 439 + 440 + /** 441 + * Toggles between using the built-in keymap, and the EEPROM-stored one. 442 + */ 443 + static void toggleKeymapSource(uint8_t combo_index) { 444 + if (Layer.getKey == Layer.getKeyFromPROGMEM) { 445 + Layer.getKey = EEPROMKeymap.getKey; 446 + } else { 447 + Layer.getKey = Layer.getKeyFromPROGMEM; 448 + } 449 + } 450 + 451 + /** 452 + * This enters the hardware test mode 453 + */ 454 + static void enterHardwareTestMode(uint8_t combo_index) { 455 + HardwareTestMode.runTests(); 456 + } 457 + 458 + 459 + /** Magic combo list, a list of key combo and action pairs the firmware should 460 + * recognise. 461 + */ 462 + USE_MAGIC_COMBOS({.action = toggleKeyboardProtocol, 463 + // Left Fn + Esc + Shift 464 + .keys = {R3C6, R2C6, R3C7}}, 465 + {.action = enterHardwareTestMode, 466 + // Left Fn + Prog + LED 467 + .keys = {R3C6, R0C0, R0C6}}, 468 + {.action = toggleKeymapSource, 469 + // Left Fn + Prog + Shift 470 + .keys = {R3C6, R0C0, R3C7}}); 471 + 472 + // First, tell Kaleidoscope which plugins you want to use. 473 + // The order can be important. For example, LED effects are 474 + // added in the order they're listed here. 475 + KALEIDOSCOPE_INIT_PLUGINS( 476 + // The EEPROMSettings & EEPROMKeymap plugins make it possible to have an 477 + // editable keymap in EEPROM. 478 + EEPROMSettings, 479 + EEPROMKeymap, 480 + 481 + // SpaceCadet can turn your shifts into parens on tap, while keeping them as 482 + // Shifts when held. SpaceCadetConfig lets Chrysalis configure some aspects of 483 + // the plugin. 484 + //SpaceCadet, 485 + //SpaceCadetConfig, 486 + 487 + // Focus allows bi-directional communication with the host, and is the 488 + // interface through which the keymap in EEPROM can be edited. 489 + Focus, 490 + 491 + // FocusSettingsCommand adds a few Focus commands, intended to aid in 492 + // changing some settings of the keyboard, such as the default layer (via the 493 + // `settings.defaultLayer` command) 494 + FocusSettingsCommand, 495 + 496 + // FocusEEPROMCommand adds a set of Focus commands, which are very helpful in 497 + // both debugging, and in backing up one's EEPROM contents. 498 + FocusEEPROMCommand, 499 + 500 + // The boot greeting effect pulses the LED button for 10 seconds after the 501 + // keyboard is first connected 502 + BootGreetingEffect, 503 + 504 + // The hardware test mode, which can be invoked by tapping Prog, LED and the 505 + // left Fn button at the same time. 506 + HardwareTestMode, 507 + 508 + // The Qukeys plugin enables the "Secondary action" functionality in 509 + // Chrysalis. Keys with secondary actions will have their primary action 510 + // performed when tapped, but the secondary action when held. 511 + Qukeys, 512 + 513 + // LEDControl provides support for other LED modes 514 + LEDControl, 515 + 516 + // We start with the LED effect that turns off all the LEDs. 517 + LEDOff, 518 + 519 + // The rainbow effect changes the color of all of the keyboard's keys at the same time 520 + // running through all the colors of the rainbow. 521 + //LEDRainbowEffect, 522 + 523 + // The rainbow wave effect lights up your keyboard with all the colors of a rainbow 524 + // and slowly moves the rainbow across your keyboard 525 + //LEDRainbowWaveEffect, 526 + 527 + // The chase effect follows the adventure of a blue pixel which chases a red pixel across 528 + // your keyboard. Spoiler: the blue pixel never catches the red pixel 529 + //LEDChaseEffect, 530 + 531 + // These static effects turn your keyboard's LEDs a variety of colors 532 + //solidRed, 533 + //solidOrange, 534 + //solidYellow, 535 + //solidGreen, 536 + //solidBlue, 537 + //solidIndigo, 538 + //solidViolet, 539 + 540 + // The breathe effect slowly pulses all of the LEDs on your keyboard 541 + //LEDBreatheEffect, 542 + 543 + // The AlphaSquare effect prints each character you type, using your 544 + // keyboard's LEDs as a display 545 + AlphaSquareEffect, 546 + 547 + // The stalker effect lights up the keys you've pressed recently 548 + StalkerEffect, 549 + 550 + // The LED Palette Theme plugin provides a shared palette for other plugins, 551 + // like Colormap below 552 + LEDPaletteTheme, 553 + 554 + // The Colormap effect makes it possible to set up per-layer colormaps 555 + ColormapEffect, 556 + 557 + // The numpad plugin is responsible for lighting up the 'numpad' mode 558 + // with a custom LED effect 559 + //NumPad, 560 + 561 + // The macros plugin adds support for macros 562 + Macros, 563 + 564 + // The MouseKeys plugin lets you add keys to your keymap which move the mouse. 565 + // The MouseKeysConfig plugin lets Chrysalis configure some aspects of the 566 + // plugin. 567 + MouseKeys, 568 + MouseKeysConfig, 569 + 570 + // The HostPowerManagement plugin allows us to turn LEDs off when then host 571 + // goes to sleep, and resume them when it wakes up. 572 + HostPowerManagement, 573 + 574 + // The MagicCombo plugin lets you use key combinations to trigger custom 575 + // actions - a bit like Macros, but triggered by pressing multiple keys at the 576 + // same time. 577 + MagicCombo, 578 + 579 + // The USBQuirks plugin lets you do some things with USB that we aren't 580 + // comfortable - or able - to do automatically, but can be useful 581 + // nevertheless. Such as toggling the key report protocol between Boot (used 582 + // by BIOSes) and Report (NKRO). 583 + USBQuirks, 584 + 585 + // Enables the "Sticky" behavior for modifiers, and the "Layer shift when 586 + // held" functionality for layer keys. 587 + OneShot, 588 + OneShotConfig, 589 + EscapeOneShot, 590 + EscapeOneShotConfig, 591 + 592 + // Turns LEDs off after a configurable amount of idle time. 593 + IdleLEDs, 594 + PersistentIdleLEDs, 595 + 596 + // Enables dynamic, Chrysalis-editable macros. 597 + DynamicMacros, 598 + 599 + // The FirmwareVersion plugin lets Chrysalis query the version of the firmware 600 + // programmatically. 601 + FirmwareVersion, 602 + 603 + // The LayerNames plugin allows Chrysalis to display - and edit - custom layer 604 + // names, to be shown instead of the default indexes. 605 + LayerNames, 606 + 607 + // Enables setting, saving (via Chrysalis), and restoring (on boot) the 608 + // default LED mode. 609 + DefaultLEDModeConfig, 610 + 611 + // Enables controlling (and saving) the brightness of the LEDs via Focus. 612 + LEDBrightnessConfig, 613 + 614 + // Enables the GeminiPR Stenography protocol. Unused by default, but with the 615 + // plugin enabled, it becomes configurable - and then usable - via Chrysalis. 616 + GeminiPR); 617 + 618 + /** The 'setup' function is one of the two standard Arduino sketch functions. 619 + * It's called when your keyboard first powers up. This is where you set up 620 + * Kaleidoscope and any plugins. 621 + */ 622 + void setup() { 623 + QUKEYS( 624 + kaleidoscope::plugin::Qukey(kaleidoscope::plugin::Qukeys::layer_wildcard, KeyAddr(3, 7), LSHIFT(Key_9)), 625 + kaleidoscope::plugin::Qukey(kaleidoscope::plugin::Qukeys::layer_wildcard, KeyAddr(3, 8), LSHIFT(Key_0)) 626 + ) 627 + 628 + // First, call Kaleidoscope's internal setup function 629 + Kaleidoscope.setup(); 630 + 631 + // Set the hue of the boot greeting effect to something that will result in a 632 + // nice green color. 633 + BootGreetingEffect.hue = 85; 634 + 635 + // While we hope to improve this in the future, the NumPad plugin 636 + // needs to be explicitly told which keymap layer is your numpad layer 637 + //NumPad.numPadLayer = NUMPAD; 638 + 639 + // We configure the AlphaSquare effect to use RED letters 640 + AlphaSquare.color = CRGB(255, 0, 0); 641 + 642 + // Set the rainbow effects to be reasonably bright, but low enough 643 + // to mitigate audible noise in some environments. 644 + //LEDRainbowEffect.brightness(170); 645 + //LEDRainbowWaveEffect.brightness(160); 646 + 647 + // Set the action key the test mode should listen for to Left Fn 648 + HardwareTestMode.setActionKey(R3C6); 649 + 650 + // The LED Stalker mode has a few effects. The one we like is called 651 + // 'BlazingTrail'. For details on other options, see 652 + // https://github.com/keyboardio/Kaleidoscope/blob/master/docs/plugins/LED-Stalker.md 653 + StalkerEffect.variant = STALKER(BlazingTrail); 654 + 655 + // To make the keymap editable without flashing new firmware, we store 656 + // additional layers in EEPROM. For now, we reserve space for eight layers. If 657 + // one wants to use these layers, just set the default layer to one in EEPROM, 658 + // by using the `settings.defaultLayer` Focus command, or by using the 659 + // `keymap.onlyCustom` command to use EEPROM layers only. 660 + EEPROMKeymap.setup(8); 661 + 662 + // We need to tell the Colormap plugin how many layers we want to have custom 663 + // maps for. To make things simple, we set it to eight layers, which is how 664 + // many editable layers we have (see above). 665 + ColormapEffect.max_layers(8); 666 + 667 + // For Dynamic Macros, we need to reserve storage space for the editable 668 + // macros. A kilobyte is a reasonable default. 669 + DynamicMacros.reserve_storage(1024); 670 + 671 + // If there's a default layer set in EEPROM, we should set that as the default 672 + // here. 673 + Layer.move(EEPROMSettings.default_layer()); 674 + 675 + // To avoid any surprises, SpaceCadet is turned off by default. However, it 676 + // can be permanently enabled via Chrysalis, so we should only disable it if 677 + // no configuration exists. 678 + //SpaceCadetConfig.disableSpaceCadetIfUnconfigured(); 679 + 680 + // Editable layer names are stored in EEPROM too, and we reserve 16 bytes per 681 + // layer for them. We need one extra byte per layer for bookkeeping, so we 682 + // reserve 17 / layer in total. 683 + LayerNames.reserve_storage(17 * 8); 684 + 685 + // Unless configured otherwise with Chrysalis, we want to make sure that the 686 + // firmware starts with LED effects off. This avoids over-taxing devices that 687 + // don't have a lot of power to share with USB devices 688 + DefaultLEDModeConfig.activateLEDModeIfUnconfigured(&LEDOff); 689 + 690 + // Qukeys config 691 + Qukeys.setOverlapThreshold(90); 692 + Qukeys.setMinimumHoldTime(100); 693 + } 694 + 695 + /** loop is the second of the standard Arduino sketch functions. 696 + * As you might expect, it runs in a loop, never exiting. 697 + * 698 + * For Kaleidoscope-based keyboard firmware, you usually just want to 699 + * call Kaleidoscope.loop(); and not do anything custom here. 700 + */ 701 + 702 + void loop() { 703 + Kaleidoscope.loop(); 704 + }
+6
keyboard/model100/sketch.json
··· 1 + { 2 + "cpu": { 3 + "fqbn": "keyboardio:gd32:keyboardio_model_100", 4 + "port": "" 5 + } 6 + }