aboutsummaryrefslogtreecommitdiff
path: root/Model01-Firmware.ino
diff options
context:
space:
mode:
Diffstat (limited to 'Model01-Firmware.ino')
-rw-r--r--Model01-Firmware.ino191
1 files changed, 46 insertions, 145 deletions
diff --git a/Model01-Firmware.ino b/Model01-Firmware.ino
index fff564c..ca11319 100644
--- a/Model01-Firmware.ino
+++ b/Model01-Firmware.ino
@@ -140,106 +140,20 @@ enum { PRIMARY, NUMPAD, FUNCTION, FVWM }; // layers
#define PRIMARY_KEYMAP_QWERTY
// #define PRIMARY_KEYMAP_DVORAK
-
-
-/* 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,
- ShiftToLayer(FVWM),
-
- 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)),
-
-#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(FVWM),
-
- 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)),
-
-#else
-
-#error "No default keymap defined. You should make sure that you have a line like '#define PRIMARY_KEYMAP_QWERTY' in your sketch"
-
-#endif
-
-
-
- [NUMPAD] = KEYMAP_STACKED
- (___, ___, ___, ___, ___, ___, ___,
- ___, ___, ___, ___, ___, ___, ___,
- ___, ___, ___, ___, ___, ___,
- ___, ___, ___, ___, ___, ___, ___,
- ___, ___, ___, ___,
- ___,
-
- M(MACRO_VERSION_INFO), ___, Key_Keypad7, Key_Keypad8, Key_Keypad9, Key_KeypadSubtract, ___,
- ___, ___, Key_Keypad4, Key_Keypad5, Key_Keypad6, Key_KeypadAdd, ___,
- ___, Key_Keypad1, Key_Keypad2, Key_Keypad3, Key_Equals, ___,
- ___, ___, Key_Keypad0, Key_KeypadDot, Key_KeypadMultiply, Key_KeypadDivide, Key_Enter,
- ___, ___, ___, ___,
- ___),
-
- [FUNCTION] = KEYMAP_STACKED
- (___, Key_F1, Key_F2, Key_F3, Key_F4, Key_F5, Key_CapsLock,
- Key_Tab, ___, Key_mouseUp, ___, Key_mouseBtnR, Key_mouseWarpEnd, Key_mouseWarpNE,
- Key_Home, Key_mouseL, Key_mouseDn, Key_mouseR, Key_mouseBtnL, Key_mouseWarpNW,
- Key_End, Key_PrintScreen, Key_Insert, ___, Key_mouseBtnM, Key_mouseWarpSW, Key_mouseWarpSE,
- ___, Key_Delete, ___, ___,
- ___,
-
- ___, Key_F6, Key_F7, Key_F8, Key_F9, Key_F10, Key_F11,
- ___, ___, Key_LeftCurlyBracket, Key_RightCurlyBracket, Key_LeftBracket, Key_RightBracket, Key_F12,
- Key_LeftArrow, Key_DownArrow, Key_UpArrow, Key_RightArrow, ___, ___,
- Key_PcApplication, ___, ___, ___, ___, Key_Backslash, Key_Pipe,
- ___, ___, Key_Enter, ___,
- ___),
-
- [FVWM] = KEYMAP_STACKED
- (___, Key_BacklightDown, Key_BacklightUp, LALT(Key_F1), LALT(Key_F2), ___, ___,
- ___, ___, ___, ___, ___, ___, ___,
- ___, ___, LALT(Key_Keypad4), LALT(Key_Keypad2), LALT(Key_Keypad8), LALT(Key_Keypad6),
- ___, ___, ___, ___, ___, ___, LALT(Key_KeypadMultiply),
- ___, LALT(Key_Backtick), LSHIFT(LALT(Key_Backtick)), ___,
- ___,
-
- ___, Consumer_Mute, Consumer_VolumeDecrement, Consumer_VolumeIncrement, ___, Consumer_Eject, ___,
- ___, ___, ___, ___, ___, ___, LSHIFT(LALT(Key_KeypadDivide)),
- LALT(Key_LeftArrow), LALT(Key_DownArrow), LALT(Key_UpArrow), LALT(Key_RightArrow), ___, LSHIFT(LALT(Key_KeypadEnter)),
- LALT(Key_Pause), ___, ___, ___, ___, LALT(Key_M), LSHIFT(LALT(Key_KeypadDot)),
- ___, ___, ___, ___,
- ___)
-) // KEYMAPS(
-
-/* Re-enable astyle's indent enforcement */
-// *INDENT-ON*
-
class DakkarColor: public kaleidoscope::plugin::LEDMode {
+public:
+ class color {
+ public:
+ enum {
+ OFF,
+ BASE,
+ LAUNCH, WINDOW, VIEWPORT,
+ MOUSE, MOUSE_BUTTON, MOUSE_WARP,
+ FUNCTION,
+ };
+ };
+
+ DakkarColor(const cRGB _colors[], const uint8_t _map[][ROWS][COLS]) : colors(_colors), map(_map) { }
private:
static constexpr cRGB color_off = CRGB(0,0,0);
@@ -252,9 +166,8 @@ private:
static constexpr cRGB color_mouse_warp = CRGB(64,128,128);
static constexpr cRGB color_function = CRGB(64,128,64);
- cRGB color_layer;
-public:
- DakkarColor(cRGB layer) : color_layer(layer) { }
+ const cRGB *colors;
+ const uint8_t (*map)[ROWS][COLS];
protected:
void update(void) final {
for (uint8_t r = 0; r < ROWS; r++) {
@@ -264,52 +177,40 @@ protected:
}
}
void refreshAt(byte r, byte c) final {
- Key k = Layer.lookupOnActiveLayer(r, c);
- uint8_t current_layer = Layer.top();
- Key layer_key = Layer.getKey(current_layer, r, c);
- bool is_on_layer = (k == layer_key && k != Key_NoKey);
-
- cRGB color = color_off;
- if (current_layer == FVWM) { // FVWM keys
- if (is_on_layer) {
- color = color_window;
- }
- switch (k.keyCode) {
- case Key_F1.keyCode ... Key_F12.keyCode: case Key_Backtick.keyCode:
- color = color_lauch; break;
-
- case Key_LeftArrow.keyCode: case Key_RightArrow.keyCode: case Key_UpArrow.keyCode: case Key_DownArrow.keyCode:
- color = color_viewport; break;
- }
- if (k.flags & SHIFT_HELD) {
- color.r >>= 1; color.g >>= 1; color.b >>= 1;
- }
- }
- else if (current_layer == FUNCTION) {
- if (k.flags & IS_MOUSE_KEY) {
- switch (k.keyCode) {
- case Key_mouseUp.keyCode: case Key_mouseDn.keyCode: case Key_mouseL.keyCode: case Key_mouseR.keyCode:
- color = color_mouse; break;
- }
- if (k.keyCode & KEY_MOUSE_WARP) { color = color_mouse_warp; }
- else if (k.keyCode & KEY_MOUSE_BUTTON) { color = color_mouse_button; }
- }
- else if (is_on_layer) {
- color = color_function;
- }
- }
- else { // only light up keys that are specific to this layer
- if (k == layer_key && k != Key_NoKey) {
- color = color_layer;
- }
- }
-
- LEDControl.setCrgbAt(r, c, color);
+ LEDControl.setCrgbAt(r, c, colors[map[Layer.top()][r][c]]);
}
};
-static DakkarColor DakkarColorDark(CRGB(0,0,0));
-static DakkarColor DakkarColorBright(CRGB(0,0,150));
+#include "keymap-wrapper.h"
+
+static constexpr cRGB dark_colors[] =
+ {
+ [DakkarColor::color::OFF] = CRGB(0,0,0),
+ [DakkarColor::color::BASE] = CRGB(0,0,0),
+ [DakkarColor::color::LAUNCH] = CRGB(0,0,150),
+ [DakkarColor::color::WINDOW] = CRGB(150,0,0),
+ [DakkarColor::color::VIEWPORT] = CRGB(0,150,0),
+ [DakkarColor::color::MOUSE] = CRGB(100,100,0),
+ [DakkarColor::color::MOUSE_BUTTON] = CRGB(50,0,50),
+ [DakkarColor::color::MOUSE_WARP] = CRGB(0,50,50),
+ [DakkarColor::color::FUNCTION] = CRGB(100,100,100),
+ };
+
+static constexpr cRGB bright_colors[] =
+ {
+ [DakkarColor::color::OFF] = CRGB(0,0,0),
+ [DakkarColor::color::BASE] = CRGB(50,50,50),
+ [DakkarColor::color::LAUNCH] = CRGB(0,0,100),
+ [DakkarColor::color::WINDOW] = CRGB(100,0,0),
+ [DakkarColor::color::VIEWPORT] = CRGB(0,100,0),
+ [DakkarColor::color::MOUSE] = CRGB(50,50,0),
+ [DakkarColor::color::MOUSE_BUTTON] = CRGB(30,0,30),
+ [DakkarColor::color::MOUSE_WARP] = CRGB(0,30,30),
+ [DakkarColor::color::FUNCTION] = CRGB(50,50,80),
+ };
+
+static DakkarColor DakkarColorDark(dark_colors,color_keymaps);
+static DakkarColor DakkarColorBright(bright_colors,color_keymaps);
/** versionInfoMacro handles the 'firmware version info' macro
* When a key bound to the macro is pressed, this macro