diff options
Diffstat (limited to 'keyboards/ergodox_ez/keymaps/rgb_layer/keymap.c')
| -rw-r--r-- | keyboards/ergodox_ez/keymaps/rgb_layer/keymap.c | 271 |
1 files changed, 271 insertions, 0 deletions
diff --git a/keyboards/ergodox_ez/keymaps/rgb_layer/keymap.c b/keyboards/ergodox_ez/keymaps/rgb_layer/keymap.c new file mode 100644 index 000000000..384d7d094 --- /dev/null +++ b/keyboards/ergodox_ez/keymaps/rgb_layer/keymap.c | |||
| @@ -0,0 +1,271 @@ | |||
| 1 | #include QMK_KEYBOARD_H | ||
| 2 | #include "version.h" | ||
| 3 | |||
| 4 | #define BASE 0 // default layer | ||
| 5 | #define SYMB 1 // symbols | ||
| 6 | #define MDIA 2 // media keys | ||
| 7 | |||
| 8 | enum custom_keycodes { | ||
| 9 | PLACEHOLDER = SAFE_RANGE, // can always be here | ||
| 10 | EPRM, | ||
| 11 | VRSN, | ||
| 12 | RGB_SLD, | ||
| 13 | RGB_LYR | ||
| 14 | }; | ||
| 15 | |||
| 16 | typedef union { | ||
| 17 | uint32_t raw; | ||
| 18 | struct { | ||
| 19 | bool rgb_layer_change :1; | ||
| 20 | }; | ||
| 21 | } user_config_t; | ||
| 22 | |||
| 23 | user_config_t user_config; | ||
| 24 | |||
| 25 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 26 | /* Keymap 0: Basic layer | ||
| 27 | * | ||
| 28 | * ,--------------------------------------------------. ,--------------------------------------------------. | ||
| 29 | * | = | 1 | 2 | 3 | 4 | 5 | LEFT | | RIGHT| 6 | 7 | 8 | 9 | 0 | - | | ||
| 30 | * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| | ||
| 31 | * | Del | Q | W | E | R | T | L1 | | L1 | Y | U | I | O | P | \ | | ||
| 32 | * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| | ||
| 33 | * | BkSp | A | S | D | F | G |------| |------| H | J | K | L |; / L2|' / Cmd | | ||
| 34 | * |--------+------+------+------+------+------| Hyper| | Meh |------+------+------+------+------+--------| | ||
| 35 | * | LShift |Z/Ctrl| X | C | V | B | | | | N | M | , | . |//Ctrl| RShift | | ||
| 36 | * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' | ||
| 37 | * |Grv/L1| '" |AltShf| Left | Right| | Up | Down | [ | ] | ~L1 | | ||
| 38 | * `----------------------------------' `----------------------------------' | ||
| 39 | * ,-------------. ,-------------. | ||
| 40 | * | App | LGui | | Alt |Ctrl/Esc| | ||
| 41 | * ,------|------|------| |------+--------+------. | ||
| 42 | * | | | Home | | PgUp | | | | ||
| 43 | * | Space|Backsp|------| |------| Tab |Enter | | ||
| 44 | * | |ace | End | | PgDn | | | | ||
| 45 | * `--------------------' `----------------------' | ||
| 46 | */ | ||
| 47 | // If it accepts an argument (i.e, is a function), it doesn't need KC_. | ||
| 48 | // Otherwise, it needs KC_* | ||
| 49 | [BASE] = LAYOUT_ergodox( // layer 0 : default | ||
| 50 | // left hand | ||
| 51 | KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, KC_LEFT, | ||
| 52 | KC_DELT, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(SYMB), | ||
| 53 | KC_BSPC, KC_A, KC_S, KC_D, KC_F, KC_G, | ||
| 54 | KC_LSFT, CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, ALL_T(KC_NO), | ||
| 55 | LT(SYMB,KC_GRV),KC_QUOT, LALT(KC_LSFT), KC_LEFT,KC_RGHT, | ||
| 56 | ALT_T(KC_APP), KC_LGUI, | ||
| 57 | KC_HOME, | ||
| 58 | KC_SPC,KC_BSPC,KC_END, | ||
| 59 | // right hand | ||
| 60 | KC_RGHT, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, | ||
| 61 | TG(SYMB), KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS, | ||
| 62 | KC_H, KC_J, KC_K, KC_L, LT(MDIA, KC_SCLN),GUI_T(KC_QUOT), | ||
| 63 | MEH_T(KC_NO),KC_N, KC_M, KC_COMM,KC_DOT, CTL_T(KC_SLSH), KC_RSFT, | ||
| 64 | KC_UP, KC_DOWN,KC_LBRC,KC_RBRC, TT(SYMB), | ||
| 65 | KC_LALT, CTL_T(KC_ESC), | ||
| 66 | KC_PGUP, | ||
| 67 | KC_PGDN,KC_TAB, KC_ENT | ||
| 68 | ), | ||
| 69 | /* Keymap 1: Symbol Layer | ||
| 70 | * | ||
| 71 | * ,---------------------------------------------------. ,--------------------------------------------------. | ||
| 72 | * |Version | F1 | F2 | F3 | F4 | F5 | | | | F6 | F7 | F8 | F9 | F10 | F11 | | ||
| 73 | * |---------+------+------+------+------+------+------| |------+------+------+------+------+------+--------| | ||
| 74 | * | | ! | @ | { | } | | | | | | Up | 7 | 8 | 9 | * | F12 | | ||
| 75 | * |---------+------+------+------+------+------| | | |------+------+------+------+------+--------| | ||
| 76 | * | | # | $ | ( | ) | ` |------| |------| Down | 4 | 5 | 6 | + | | | ||
| 77 | * |---------+------+------+------+------+------| | | |------+------+------+------+------+--------| | ||
| 78 | * | | % | ^ | [ | ] | ~ | | | | & | 1 | 2 | 3 | \ | | | ||
| 79 | * `---------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' | ||
| 80 | * | EPRM | | | | | | | . | 0 | = | | | ||
| 81 | * `-----------------------------------' `----------------------------------' | ||
| 82 | * ,-------------. ,-------------. | ||
| 83 | * |Animat| LYR | |Toggle|Solid | | ||
| 84 | * ,------|------|------| |------+------+------. | ||
| 85 | * |Bright|Bright| | | |Hue- |Hue+ | | ||
| 86 | * |ness- |ness+ |------| |------| | | | ||
| 87 | * | | | | | | | | | ||
| 88 | * `--------------------' `--------------------' | ||
| 89 | */ | ||
| 90 | // SYMBOLS | ||
| 91 | [SYMB] = LAYOUT_ergodox( | ||
| 92 | // left hand | ||
| 93 | VRSN, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS, | ||
| 94 | RESET, KC_EXLM,KC_AT, KC_LCBR,KC_RCBR,KC_PIPE,KC_TRNS, | ||
| 95 | KC_TRNS,KC_HASH,KC_DLR, KC_LPRN,KC_RPRN,KC_GRV, | ||
| 96 | EPRM,KC_PERC,KC_CIRC,KC_LBRC,KC_RBRC,KC_TILD,KC_TRNS, | ||
| 97 | KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS, | ||
| 98 | RGB_MOD,RGB_LYR, | ||
| 99 | KC_TRNS, | ||
| 100 | RGB_VAD,RGB_VAI,KC_TRNS, | ||
| 101 | // right hand | ||
| 102 | KC_TRNS, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, | ||
| 103 | KC_TRNS, KC_UP, KC_7, KC_8, KC_9, KC_ASTR, KC_F12, | ||
| 104 | KC_DOWN, KC_4, KC_5, KC_6, KC_PLUS, KC_TRNS, | ||
| 105 | KC_TRNS, KC_AMPR, KC_1, KC_2, KC_3, KC_BSLS, KC_TRNS, | ||
| 106 | KC_TRNS,KC_DOT, KC_0, KC_EQL, KC_TRNS, | ||
| 107 | RGB_TOG, RGB_SLD, | ||
| 108 | KC_TRNS, | ||
| 109 | KC_TRNS, RGB_HUD, RGB_HUI | ||
| 110 | ), | ||
| 111 | /* Keymap 2: Media and mouse keys | ||
| 112 | * | ||
| 113 | * ,--------------------------------------------------. ,--------------------------------------------------. | ||
| 114 | * | | | | | | | | | | | | | | | | | ||
| 115 | * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| | ||
| 116 | * | | | | MsUp | | | | | | | | | | | | | ||
| 117 | * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| | ||
| 118 | * | | |MsLeft|MsDown|MsRght| |------| |------| | | | | | Play | | ||
| 119 | * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| | ||
| 120 | * | | | | | | | | | | | | Prev | Next | | | | ||
| 121 | * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' | ||
| 122 | * | | | | Lclk | Rclk | |VolUp |VolDn | Mute | | | | ||
| 123 | * `----------------------------------' `----------------------------------' | ||
| 124 | * ,-------------. ,-------------. | ||
| 125 | * | | | | | | | ||
| 126 | * ,------|------|------| |------+------+------. | ||
| 127 | * | | | | | | |Brwser| | ||
| 128 | * | | |------| |------| |Back | | ||
| 129 | * | | | | | | | | | ||
| 130 | * `--------------------' `--------------------' | ||
| 131 | */ | ||
| 132 | // MEDIA AND MOUSE | ||
| 133 | [MDIA] = LAYOUT_ergodox( | ||
| 134 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
| 135 | KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_U, KC_TRNS, KC_TRNS, KC_TRNS, | ||
| 136 | KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_R, KC_TRNS, | ||
| 137 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
| 138 | KC_TRNS, KC_TRNS, KC_TRNS, KC_BTN1, KC_BTN2, | ||
| 139 | KC_TRNS, KC_TRNS, | ||
| 140 | KC_TRNS, | ||
| 141 | KC_TRNS, KC_TRNS, KC_TRNS, | ||
| 142 | // right hand | ||
| 143 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
| 144 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
| 145 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPLY, | ||
| 146 | KC_TRNS, KC_TRNS, KC_TRNS, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS, | ||
| 147 | KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS, | ||
| 148 | KC_TRNS, KC_TRNS, | ||
| 149 | KC_TRNS, | ||
| 150 | KC_TRNS, KC_TRNS, KC_WBAK | ||
| 151 | ), | ||
| 152 | }; | ||
| 153 | |||
| 154 | void eeconfig_init_user(void) { | ||
| 155 | rgblight_enable(); | ||
| 156 | rgblight_sethsv_cyan(); | ||
| 157 | rgblight_mode(1); | ||
| 158 | user_config.rgb_layer_change = true; | ||
| 159 | eeconfig_update_user(user_config.raw); | ||
| 160 | } | ||
| 161 | |||
| 162 | |||
| 163 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 164 | switch (keycode) { | ||
| 165 | // dynamically generate these. | ||
| 166 | case EPRM: | ||
| 167 | if (record->event.pressed) { | ||
| 168 | eeconfig_init(); | ||
| 169 | } | ||
| 170 | return false; | ||
| 171 | break; | ||
| 172 | case VRSN: | ||
| 173 | if (record->event.pressed) { | ||
| 174 | SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION); | ||
| 175 | } | ||
| 176 | return false; | ||
| 177 | break; | ||
| 178 | case RGB_SLD: | ||
| 179 | if (record->event.pressed) { | ||
| 180 | #ifdef RGBLIGHT_ENABLE | ||
| 181 | rgblight_mode(1); | ||
| 182 | #endif | ||
| 183 | } | ||
| 184 | return false; | ||
| 185 | break; | ||
| 186 | case RGB_LYR: // This allows me to use underglow as layer indication, or as normal | ||
| 187 | if (record->event.pressed) { | ||
| 188 | user_config.rgb_layer_change ^= 1; // Toggles the status | ||
| 189 | eeconfig_update_user(user_config.raw); // Writes the new status to EEPROM | ||
| 190 | if (user_config.rgb_layer_change) { // if layer state indication is enabled, | ||
| 191 | layer_state_set(layer_state); // then immediately update the layer color | ||
| 192 | } | ||
| 193 | } | ||
| 194 | return false; break; | ||
| 195 | case RGB_MODE_FORWARD ... RGB_MODE_GRADIENT: // For any of the RGB codes (see quantum_keycodes.h, L400 for reference) | ||
| 196 | if (record->event.pressed) { //This disables layer indication, as it's assumed that if you're changing this ... you want that disabled | ||
| 197 | if (user_config.rgb_layer_change) { // only if this is enabled | ||
| 198 | user_config.rgb_layer_change = false; // disable it, and | ||
| 199 | eeconfig_update_user(user_config.raw); // write the setings to EEPROM | ||
| 200 | } | ||
| 201 | } | ||
| 202 | return true; break; | ||
| 203 | } | ||
| 204 | return true; | ||
| 205 | } | ||
| 206 | |||
| 207 | void matrix_init_user(void) { | ||
| 208 | // Call the keymap level matrix init. | ||
| 209 | |||
| 210 | // Read the user config from EEPROM | ||
| 211 | user_config.raw = eeconfig_read_user(); | ||
| 212 | |||
| 213 | // Set default layer, if enabled | ||
| 214 | if (user_config.rgb_layer_change) { | ||
| 215 | rgblight_enable_noeeprom(); | ||
| 216 | rgblight_sethsv_noeeprom_cyan(); | ||
| 217 | rgblight_mode_noeeprom(1); | ||
| 218 | } | ||
| 219 | } | ||
| 220 | |||
| 221 | // Runs constantly in the background, in a loop. | ||
| 222 | void matrix_scan_user(void) { | ||
| 223 | |||
| 224 | }; | ||
| 225 | |||
| 226 | uint32_t layer_state_set_user(uint32_t state) { | ||
| 227 | ergodox_board_led_off(); | ||
| 228 | ergodox_right_led_1_off(); | ||
| 229 | ergodox_right_led_2_off(); | ||
| 230 | ergodox_right_led_3_off(); | ||
| 231 | switch (biton32(state)) { | ||
| 232 | case SYMB: | ||
| 233 | ergodox_right_led_1_on(); | ||
| 234 | if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom_red(); rgblight_mode_noeeprom(1); } | ||
| 235 | break; | ||
| 236 | case MDIA: | ||
| 237 | ergodox_right_led_2_on(); | ||
| 238 | if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom_green(); rgblight_mode_noeeprom(1); } | ||
| 239 | break; | ||
| 240 | case 3: | ||
| 241 | ergodox_right_led_3_on(); | ||
| 242 | if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom_blue(); rgblight_mode_noeeprom(1); } | ||
| 243 | break; | ||
| 244 | case 4: | ||
| 245 | ergodox_right_led_1_on(); | ||
| 246 | ergodox_right_led_2_on(); | ||
| 247 | if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom_orange(); rgblight_mode_noeeprom(1); } | ||
| 248 | break; | ||
| 249 | case 5: | ||
| 250 | ergodox_right_led_1_on(); | ||
| 251 | ergodox_right_led_3_on(); | ||
| 252 | if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom_yellow(); rgblight_mode_noeeprom(1); } | ||
| 253 | break; | ||
| 254 | case 6: | ||
| 255 | ergodox_right_led_2_on(); | ||
| 256 | ergodox_right_led_3_on(); | ||
| 257 | if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom_pink(); rgblight_mode_noeeprom(1); } | ||
| 258 | break; | ||
| 259 | case 7: | ||
| 260 | ergodox_right_led_1_on(); | ||
| 261 | ergodox_right_led_2_on(); | ||
| 262 | ergodox_right_led_3_on(); | ||
| 263 | if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom_white(); rgblight_mode_noeeprom(1); } | ||
| 264 | break; | ||
| 265 | default: // for any other layers, or the default layer | ||
| 266 | if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom_cyan(); rgblight_mode_noeeprom(1); } | ||
| 267 | break; | ||
| 268 | } | ||
| 269 | return state; | ||
| 270 | } | ||
| 271 | |||
