aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2022-06-11 17:31:20 -0400
committerBrian Cully <bjc@kublai.com>2022-06-11 17:31:20 -0400
commitd5457762c53d753b16ef90951a8a229589b5ad2e (patch)
treea38f610c0afe446b7dfefd04da60e53b6f914367
parent149f6689b330aa4c13890ec88edf8496dd053776 (diff)
downloadModel01-Firmware-d5457762c53d753b16ef90951a8a229589b5ad2e.tar.gz
Model01-Firmware-d5457762c53d753b16ef90951a8a229589b5ad2e.zip
Add workman/dvorak toggle. Remove syster. Update for latest firmware
-rw-r--r--Model01-Firmware.ino241
1 files changed, 138 insertions, 103 deletions
diff --git a/Model01-Firmware.ino b/Model01-Firmware.ino
index 5973b2b..95282da 100644
--- a/Model01-Firmware.ino
+++ b/Model01-Firmware.ino
@@ -25,19 +25,20 @@
#include <Kaleidoscope-SpaceCadet.h>
#include <Kaleidoscope-Heatmap.h>
-enum { MACRO_VERSION_INFO,
- MACRO_ANY,
- WOW,
- SAUCY,
- LUL,
- ZZZ,
- GIVE_PLZ,
- TAKE_NRG,
- SEEMS_GOOD,
- GASM
- };
-
-enum { PRIMARY, FUNCTION, NUMPAD, EMOTES }; // layers
+enum {
+ MACRO_VERSION_INFO,
+ MACRO_ANY,
+ WOW,
+ SAUCY,
+ LUL,
+ ZZZ,
+ GIVE_PLZ,
+ TAKE_NRG,
+ SEEMS_GOOD,
+ GASM
+};
+
+enum { DVORAK, WORKMAN, QWERTY, FUNCTION, NUMPAD, EMOTES }; // layers
typedef struct {
uint8_t index;
@@ -68,68 +69,96 @@ static const emote emotes[] = {
// *INDENT-OFF*
KEYMAPS(
- [PRIMARY] = KEYMAP_STACKED
- (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,
- SYSTER, Key_A, Key_O, Key_E, Key_U, Key_I,
- Key_RightGui, 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),
-
- 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,
- Key_PcApplication, 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)),
-
- [FUNCTION] = KEYMAP_STACKED
- (___, Key_F1, Key_F2, Key_F3, Key_F4, Key_F5, Key_CapsLock,
- ___, ___, 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_ScanNextTrack, Consumer_PlaySlashPause, ___,
- ___, 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, ___, ___,
- ___, Consumer_Mute, Consumer_VolumeDecrement, Consumer_VolumeIncrement, ___, Key_Backslash, Key_Pipe,
- ___, ___, ___, ___,
- ___),
-
- [NUMPAD] = KEYMAP_STACKED
- (___, ___, ___, ___, ___, ___, ___,
- ___, ___, ___, ___, ___, ___, ___,
- ___, ___, ___, ___, ___, ___,
- ___, ___, ___, ___, ___, ___, ___,
- ___, ___, ___, ___,
- ___,
-
- M(MACRO_VERSION_INFO), ___, Key_7, Key_8, Key_9, Key_KeypadSubtract, ___,
- ___, ___, Key_4, Key_5, Key_6, Key_KeypadAdd, ___,
- ___, Key_1, Key_2, Key_3, Key_Equals, ___,
- ___, ___, Key_0, Key_Period, Key_KeypadMultiply, Key_KeypadDivide, Key_Enter,
- ___, ___, ___, ___,
- ___),
-
- [EMOTES] = KEYMAP_STACKED
- (___, ___, ___, ___, ___, ___, ___,
- ___, ___, ___, ___, ___, ___, ___,
- ___, ___, ___, ___, ___, M(SEEMS_GOOD),
- ___, M(ZZZ), ___, M(GASM), ___, ___, ___,
- ___, ___, ___, ___,
- ___,
-
- ___, ___, ___, ___, ___, ___, ___,
- ___, ___, ___, ___, ___, M(WOW), ___,
- ___, ___, ___, M(LUL), M(SAUCY), ___,
- ___, ___, ___, M(GIVE_PLZ), M(TAKE_NRG), ___, ___,
- ___, ___, ___, ___,
- ___)
-)
+ [DVORAK] = KEYMAP_STACKED
+ (Key_Escape, Key_1, Key_2, Key_3, Key_4, Key_5, Key_ScrollLock,
+ Key_Backtick, Key_Quote, Key_Comma, Key_Period, Key_P, Key_Y, Key_Tab,
+ MoveToLayer(WORKMAN), Key_A, Key_O, Key_E, Key_U, Key_I,
+ Key_RightGui, Key_Semicolon, Key_Q, Key_J, Key_K, Key_X, Key_LeftGui,
+ Key_LeftBracket, Key_Backspace, LSHIFT(Key_LeftBracket), LSHIFT(Key_9),
+ ShiftToLayer(FUNCTION),
+
+ 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,
+ Key_PcApplication, Key_B, Key_M, Key_W, Key_V, Key_Z, Key_Equals,
+ LSHIFT(Key_0), LSHIFT(Key_RightBracket), Key_Spacebar, Key_RightBracket,
+ ShiftToLayer(FUNCTION)),
+
+ [WORKMAN] = KEYMAP_STACKED
+ (Key_Escape, Key_1, Key_2, Key_3, Key_4, Key_5, Key_ScrollLock,
+ Key_Backtick, Key_Q, Key_D, Key_R, Key_W, Key_B, Key_Tab,
+ MoveToLayer(DVORAK), Key_A, Key_S, Key_H, Key_T, Key_G,
+ Key_RightGui, Key_Z, Key_X, Key_M, Key_C, Key_V, Key_LeftGui,
+ Key_LeftBracket, Key_Backspace, LSHIFT(Key_LeftBracket), LSHIFT(Key_9),
+ ShiftToLayer(FUNCTION),
+
+ LockLayer(EMOTES), Key_6, Key_7, Key_8, Key_9, Key_0, LockLayer(NUMPAD),
+ Key_Enter, Key_J, Key_F, Key_U, Key_P, Key_Semicolon, Key_Slash,
+ Key_Y, Key_N, Key_E, Key_O, Key_I, Key_Quote,
+ Key_PcApplication, Key_K, Key_L, Key_Comma, Key_Period, Key_Slash, Key_Equals,
+ LSHIFT(Key_0), LSHIFT(Key_RightBracket), Key_Spacebar, Key_RightBracket,
+ ShiftToLayer(FUNCTION)),
+
+ [QWERTY] = KEYMAP_STACKED
+ (Key_Escape, Key_1, Key_2, Key_3, Key_4, Key_5, Key_ScrollLock,
+ Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab,
+ MoveToLayer(DVORAK), Key_A, Key_S, Key_D, Key_F, Key_G,
+ Key_RightGui, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_LeftGui,
+ Key_LeftBracket, Key_Backspace, LSHIFT(Key_LeftBracket), LSHIFT(Key_9),
+ ShiftToLayer(FUNCTION),
+
+ LockLayer(EMOTES), 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_PcApplication, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus,
+ LSHIFT(Key_0), LSHIFT(Key_RightBracket), Key_Spacebar, Key_RightBracket,
+ ShiftToLayer(FUNCTION)),
+
+ [FUNCTION] = KEYMAP_STACKED
+ (Key_LEDEffectNext, Key_F1, Key_F2, Key_F3, Key_F4, Key_F5, LCTRL(Key_ScrollLock),
+ ___, ___, Key_PageUp, Key_UpArrow, Key_PageDown, Key_Home, Key_CapsLock,
+ Key_Copy, ___, Key_LeftArrow, Key_DownArrow, Key_RightArrow, Key_End,
+ Key_Paste, Key_PrintScreen, Key_Insert, Consumer_ScanPreviousTrack, Consumer_ScanNextTrack, Consumer_PlaySlashPause, ___,
+ ___, Key_Delete, ___, ___,
+ ___,
+
+ Key_CapsLock, Key_F6, Key_F7, Key_F8, Key_F9, Key_F10, Key_F11,
+ ___, Key_Home, Key_PageUp, Key_UpArrow, Key_PageDown, ___, Key_F12,
+ Key_End, Key_LeftArrow, Key_DownArrow, Key_RightArrow, ___, ___,
+ ___, Consumer_Mute, Consumer_VolumeDecrement, Consumer_VolumeIncrement, ___, Key_Backslash, Key_Pipe,
+ ___, ___, ___, ___,
+ ___),
+
+ [NUMPAD] = KEYMAP_STACKED
+ (___, ___, ___, ___, ___, ___, ___,
+ ___, ___, ___, ___, ___, ___, ___,
+ ___, ___, ___, ___, ___, ___,
+ ___, ___, ___, ___, ___, ___, ___,
+ ___, ___, ___, ___,
+ ___,
+
+ M(MACRO_VERSION_INFO), ___, Key_7, Key_8, Key_9, Key_KeypadSubtract, ___,
+ ___, ___, Key_4, Key_5, Key_6, Key_KeypadAdd, ___,
+ ___, Key_1, Key_2, Key_3, Key_Equals, ___,
+ ___, ___, Key_0, Key_Period, Key_KeypadMultiply, Key_KeypadDivide, Key_Enter,
+ ___, ___, ___, ___,
+ ___),
+
+ [EMOTES] = KEYMAP_STACKED
+ (___, ___, ___, ___, ___, ___, ___,
+ ___, ___, ___, ___, ___, ___, ___,
+ ___, ___, ___, ___, ___, M(SEEMS_GOOD),
+ ___, M(ZZZ), ___, M(GASM), ___, ___, ___,
+ ___, ___, ___, ___,
+ ___,
+
+ ___, ___, ___, ___, ___, ___, ___,
+ ___, ___, ___, ___, ___, M(WOW), ___,
+ ___, ___, ___, M(LUL), M(SAUCY), ___,
+ ___, ___, ___, M(GIVE_PLZ), M(TAKE_NRG), ___, ___,
+ ___, ___, ___, ___,
+ ___)
+ )
// *INDENT-ON*
@@ -153,45 +182,49 @@ static void versionInfoMacro(uint8_t keyState) {
* keypress event repeating that randomly selected key.
*
*/
-
-static void anyKeyMacro(uint8_t keyState) {
- static Key lastKey;
- bool toggledOn = false;
- if (keyToggledOn(keyState)) {
- lastKey.setKeyCode(Key_A.getKeyCode() + (uint8_t)(millis() % 36));
- toggledOn = true;
+static void anyKeyMacro(KeyEvent &event) {
+ if (keyToggledOn(event.state)) {
+ event.key.setKeyCode(Key_A.getKeyCode() + (uint8_t)(millis() % 36));
+ event.key.setFlags(0);
}
-
- if (keyIsPressed(keyState))
- Kaleidoscope.hid().keyboard().pressKey(lastKey, toggledOn);
}
-const macro_t *emoteMacro(uint8_t macroIndex, uint8_t keyState) {
- if (keyToggledOn(keyState)) {
+static void emoteMacro(uint8_t macroID, KeyEvent &event) {
+ if (keyToggledOn(event.state)) {
for (int i = 0; emotes[i].index != 255; i++) {
- if (emotes[i].index == macroIndex) {
+ if (emotes[i].index == macroID) {
Macros.type(emotes[i].string);
- return MACRO_NONE;
+ return;
}
}
}
- return MACRO_NONE;
}
-const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) {
- switch (macroIndex) {
+/** 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 *macroAction(uint8_t macroID, KeyEvent &event) {
+ switch (macroID) {
case MACRO_VERSION_INFO:
- versionInfoMacro(keyState);
+ versionInfoMacro(event.state);
break;
case MACRO_ANY:
- anyKeyMacro(keyState);
+ anyKeyMacro(event);
break;
default:
- emoteMacro(macroIndex, keyState);
+ emoteMacro(macroID, event);
}
-
return MACRO_NONE;
}
@@ -256,13 +289,13 @@ static void enterHardwareTestMode(uint8_t combo_index) {
* recognise.
*/
USE_MAGIC_COMBOS({.action = toggleKeyboardProtocol,
- // Left Fn + Esc + Shift
- .keys = { R3C6, R2C6, R3C7 }},
- {.action = enterHardwareTestMode,
- // Left Fn + Prog + LED
- .keys = { R3C6, R0C0, R0C6 }});
+ // Left Fn + Esc + Shift
+ .keys = { R3C6, R2C6, R3C7 }},
+ {.action = enterHardwareTestMode,
+ // Left Fn + Prog + LED
+ .keys = { R3C6, R0C0, R0C6 }});
-static LayerHighlighter emoteHighlighter(EMOTES);
+static kaleidoscope::plugin::LayerHighlighter emoteHighlighter(EMOTES);
// First, tell Kaleidoscope which plugins you want to use.
// The order can be important. For example, LED effects are
@@ -273,7 +306,7 @@ KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings,
Qukeys,
//SpaceCadet,
//MacrosOnTheFly,
- Syster,
+ //Syster,
// LEDControl provides support for other LED
// modes
LEDControl,
@@ -344,6 +377,7 @@ void loop() {
Kaleidoscope.loop();
}
+/*
void systerAction(kaleidoscope::plugin::Syster::action_t action, const char *symbol) {
switch (action) {
case kaleidoscope::plugin::Syster::StartAction:
@@ -416,3 +450,4 @@ void systerAction(kaleidoscope::plugin::Syster::action_t action, const char *sym
break;
}
}
+*/