3 #include <keymap_colemak.h>
4 #include <sendstring_colemak.h>
6 extern keymap_config_t keymap_config;
10 _QWERTY, // OS-side Colemak. Default.
11 _COLEMAK, // Keyboard-side Colemak. Portability, emergency.
16 #define LAYER_N MO(_NUMERIC)
17 #define LAYER_C TG(_COLEMAK)
18 #define PASTE LSFT(KC_INS) // Terminal-compatible paste.
19 #define SLQ RALT(KC_9) // Single left-side quotation mark (in Colemak).
20 #define SRQ RALT(KC_0)
21 #define EMDASH RALT(LSFT(KC_MINUS)) // Em dash character (in Colemak).
22 #define BK_LCTL CTL_T(KC_LBRACKET)
23 #define BK_RCTL RCTL_T(KC_RBRACKET)
24 // TODO: Mod-tap ALT with a curvilinear brace.
25 // https://github.com/qmk/qmk_firmware/pull/2055
27 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
29 [_QWERTY] = LAYOUT_62key(
30 KC_VOLD, KC_VOLU, CM_W, CM_F, CM_P, CM_G,
31 KC_TAB, CM_Q, CM_R, CM_S, CM_T, CM_D,
32 KC_BSPC, CM_A, CM_X, CM_C, CM_V, CM_B,
33 SLQ, CM_Z, KC_HOME, KC_PGUP, KC_END,
34 KC_PGDN, KC_ENT, KC_SPC,
35 KC_LSPO, KC_LGUI, KC_MINS,
38 CM_J, CM_L, CM_U, CM_Y, KC_MPLY, KC_MUTE,
39 CM_H, CM_N, CM_E, CM_I, CM_SCLN, KC_BSLS,
40 CM_K, CM_M, KC_COMM, KC_DOT, CM_O, KC_QUOT,
41 KC_LEFT, KC_UP, KC_RGHT, KC_SLSH, SRQ,
42 KC_DEL, KC_ESC, KC_DOWN,
43 KC_EQL, LAYER_N, KC_RSPC,
47 [_COLEMAK] = LAYOUT_62key(
48 _______, _______, KC_W, KC_F, KC_P, KC_G,
49 _______, KC_Q, KC_R, KC_S, KC_T, KC_D,
50 _______, KC_A, KC_X, KC_C, KC_V, KC_B,
51 _______, KC_Z, _______, _______, _______,
52 _______, _______, _______,
53 _______, _______, _______,
56 KC_J, KC_L, KC_U, KC_Y, _______, _______,
57 KC_H, KC_N, KC_E, KC_I, KC_SCLN, _______,
58 KC_K, KC_M, _______, _______, KC_O, _______,
59 _______, _______, _______, _______, _______,
60 _______, _______, _______,
61 _______, _______, _______,
65 [_NUMERIC] = LAYOUT_62key(
66 LAYER_C, KC_INS, KC_F2, KC_F3, KC_F4, KC_F5,
67 KC_F12, KC_F1, KC_2, KC_3, KC_4, KC_5,
68 _______, KC_1, KC_AT, KC_HASH, KC_DLR, KC_PERC,
69 KC_GRV, KC_EXLM, KC_BTN1, KC_WH_U, KC_BTN2,
70 KC_WH_D, RGB_MOD, _______,
71 _______, _______, EMDASH,
74 KC_F6, KC_F7, KC_F8, KC_F9, RESET, KC_WAKE, // *
75 KC_6, KC_7, KC_8, KC_9, KC_F10, KC_F11,
76 KC_CIRC, KC_AMPR, KC_ASTR, KC_APP, KC_0, PASTE,
77 KC_MS_L, KC_MS_U, KC_MS_R, KC_PSCR, RGB_TOG,
78 KC_ACL1, KC_ACL2, KC_MS_D,
79 KC_ACL0, _______, _______,
83 // *KC_WAKE: Used in place of KC_SLEP because X11 with i3 on prerelease
84 // Debian 10 was seeing duplicate keypress and release events for sleep
85 // (regardless of i3 binding), which ruined the function.
89 The rest is all about lighting control.
90 The logic here represents a pretty poor compromise solution between the
93 - Feedback on active modifiers.
94 - Flexibility: Both sides of the keyboard are interchangeable.
95 - Regular QMK RBG lighting modes. Specifically, Knight and Xmas.
97 Currently, the last item suffers, because the first two seem to require
98 calling a function that implements the RGBLIGHT_SPLIT_SET_CHANGE_HSVS macro,
99 which most of the rgblight.c functions do not. In particular, functions that
100 target an individual LED do not do so correctly across the wire, so instead
101 we let HSV vary without ever targeting LEDs.
104 // How long to wait between animation steps for "Knight" animation:
105 const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {255, 200, 100};
107 bool _initialized = false;
108 bool _leds_dirty = false;
110 void modal_leds(void) {
111 uint8_t mods = get_mods();
112 uint16_t hue = 355; // Rough match to printed case.
113 uint8_t saturation = 255;
115 if (layer_state_is(_COLEMAK)) { hue -= 50; saturation -= 20; value += 20; };
116 if (layer_state_is(_NUMERIC)) { value += 30; };
117 if (mods & MOD_MASK_SHIFT) { saturation -= 20; value += 30; };
118 if (mods & MOD_MASK_ALT) { hue -= 100; saturation -= 20; value += 30; };
119 if (mods & MOD_MASK_CTRL) { hue -= 200; saturation -= 20; value += 30; };
120 // rgblight_sethsv_eeprom_helper is not a great API function but it does
121 // affect both halves of a split keyboard.
122 rgblight_sethsv_eeprom_helper(hue, saturation, value, false);
126 void matrix_init_user(void) {
129 void matrix_scan_user(void) {
130 if (_leds_dirty) { modal_leds(); };
133 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
135 // Static lighting is amenable to customization.
136 rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT);
139 if (keycode == KC_WAKE) {
140 // Turn the lights off before going to sleep.
141 rgblight_sethsv_eeprom_helper(0, 0, 0, false);