diff options
| author | Drashna Jaelre <drashna@live.com> | 2018-05-31 22:11:06 -0700 |
|---|---|---|
| committer | Jack Humbert <jack.humb@gmail.com> | 2018-06-01 01:11:06 -0400 |
| commit | 3d1349b280d9c0a57e37b5347a405426de6dba10 (patch) | |
| tree | 0b8c989d0c902115e2ce51c8bb9dc201b0e2eb0c /users/drashna/drashna.c | |
| parent | 8eaf23ae8146766615cc1cec3fc8e04111e8ef49 (diff) | |
| download | qmk_firmware-3d1349b280d9c0a57e37b5347a405426de6dba10.tar.gz qmk_firmware-3d1349b280d9c0a57e37b5347a405426de6dba10.zip | |
Big overhaul to Drashna keymaps and userspace (#3097)
* Optimize secrets code
* Orthodox tweaks
* rules.mk features
* Minor cleanup
* Revert mod bits
* Force Hold breaks One Shot Tap Toggle
* Cleanup
* Moke keymaps more consistent
* minor ergodox tweak
* More OSM for the Orthodox
* Cleanup of userspace
* Toggle Secrets
* Add hidden process record for super secret macros
* Make sure secret macros always compiles
* finish up making them super secret
* Add ColinTA's rgb twinkle as WIP
* Optimize RGB Twinkling for typing
Also, tweak RGB indicators.
AND WTF, I HAVE NO IDEA WHY THE INDICATORS ONLY WORK AS IS. The logical method for getting them working doesn't ... and it's beyond bizarre
* Make console logging more configurable
* Indicator travisty
* Clean up userspace rgb code
* Optimize RGB Twinking to work on default layer only, and to base it's color on the curent hue
* Eff it... rgblight_sethsv_at runs at every matrix scan
* RGB Twinkle cleanup
* Update Iris code for new board
* Move RGB Indicator and RGB Twinkle into userspace
* Move RGB Indicator code to rgb_stuff.c
* Major cleanup of RGB Code in userspace
* Additional cleanup of RGB code in userspace
* Use noeeprom functions to save my boards!
* Enable RGB Sleep on all boards now
* Add old iris board
* tapping tweak
* Use byte 19 for eeprom to prepare for possible merge of eeconfig function pr
* Add code to fix default layer after eeprom reset
Diffstat (limited to 'users/drashna/drashna.c')
| -rw-r--r-- | users/drashna/drashna.c | 340 |
1 files changed, 55 insertions, 285 deletions
diff --git a/users/drashna/drashna.c b/users/drashna/drashna.c index 6ce541bfb..8efd99f80 100644 --- a/users/drashna/drashna.c +++ b/users/drashna/drashna.c | |||
| @@ -17,119 +17,36 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 17 | 17 | ||
| 18 | #include "drashna.h" | 18 | #include "drashna.h" |
| 19 | #include "version.h" | 19 | #include "version.h" |
| 20 | 20 | #include "eeprom.h" | |
| 21 | #if (__has_include("secrets.h") && !defined(NO_SECRETS)) | 21 | #include "tap_dances.h" |
| 22 | #include "secrets.h" | 22 | #include "rgb_stuff.h" |
| 23 | #else | ||
| 24 | // `PROGMEM const char secret[][x]` may work better, but it takes up more space in the firmware | ||
| 25 | // And I'm not familiar enough to know which is better or why... | ||
| 26 | PROGMEM const char secret[][64] = { | ||
| 27 | "test1", | ||
| 28 | "test2", | ||
| 29 | "test3", | ||
| 30 | "test4", | ||
| 31 | "test5" | ||
| 32 | }; | ||
| 33 | #endif | ||
| 34 | 23 | ||
| 35 | 24 | ||
| 36 | float tone_copy[][2] = SONG(SCROLL_LOCK_ON_SOUND); | 25 | float tone_copy[][2] = SONG(SCROLL_LOCK_ON_SOUND); |
| 37 | float tone_paste[][2] = SONG(SCROLL_LOCK_OFF_SOUND); | 26 | float tone_paste[][2] = SONG(SCROLL_LOCK_OFF_SOUND); |
| 38 | 27 | ||
| 39 | |||
| 40 | static uint16_t copy_paste_timer; | 28 | static uint16_t copy_paste_timer; |
| 41 | userspace_config_t userspace_config; | 29 | userspace_config_t userspace_config; |
| 42 | 30 | ||
| 43 | // Helper Functions | 31 | // Helper Functions |
| 44 | void tap(uint16_t keycode){ register_code(keycode); unregister_code(keycode); }; | ||
| 45 | |||
| 46 | #ifdef RGBLIGHT_ENABLE | ||
| 47 | void rgblight_sethsv_default_helper(uint8_t index) { | ||
| 48 | uint8_t default_layer = eeconfig_read_default_layer(); | ||
| 49 | if (default_layer & (1UL << _COLEMAK)) { | ||
| 50 | rgblight_sethsv_at(300, 255, 255, index); | ||
| 51 | rgblight_sethsv_at(300, 255, 255, index); | ||
| 52 | } | ||
| 53 | else if (default_layer & (1UL << _DVORAK)) { | ||
| 54 | rgblight_sethsv_at(120, 255, 255, index); | ||
| 55 | rgblight_sethsv_at(120, 255, 255, index); | ||
| 56 | } | ||
| 57 | else if (default_layer & (1UL << _WORKMAN)) { | ||
| 58 | rgblight_sethsv_at(43, 255, 255, index); | ||
| 59 | rgblight_sethsv_at(43, 255, 255, index); | ||
| 60 | } | ||
| 61 | else { | ||
| 62 | rgblight_sethsv_at(180, 255, 255, index); | ||
| 63 | rgblight_sethsv_at(180, 255, 255, index); | ||
| 64 | } | ||
| 65 | } | ||
| 66 | #endif // RGBLIGHT_ENABLE | ||
| 67 | |||
| 68 | 32 | ||
| 69 | // ========================================= TAP DANCE ========================================= | ||
| 70 | #ifdef TAP_DANCE_ENABLE | ||
| 71 | //define diablo macro timer variables | ||
| 72 | static uint16_t diablo_timer[4]; | ||
| 73 | static uint8_t diablo_times[] = { 0, 1, 3, 5, 10, 30 }; | ||
| 74 | static uint8_t diablo_key_time[4]; | ||
| 75 | |||
| 76 | // has the correct number of seconds elapsed (as defined by diablo_times) | ||
| 77 | bool check_dtimer(uint8_t dtimer) { return (timer_elapsed(diablo_timer[dtimer]) < (diablo_key_time[dtimer] * 1000)) ? false : true; }; | ||
| 78 | |||
| 79 | // Cycle through the times for the macro, starting at 0, for disabled. | ||
| 80 | // Max of six values, so don't exceed | ||
| 81 | void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data, uint8_t diablo_key) { | ||
| 82 | if (state->count >= 7) { | ||
| 83 | diablo_key_time[diablo_key] = diablo_times[0]; | ||
| 84 | reset_tap_dance(state); | ||
| 85 | } else { | ||
| 86 | diablo_key_time[diablo_key] = diablo_times[state->count - 1]; | ||
| 87 | } | ||
| 88 | } | ||
| 89 | 33 | ||
| 90 | // Would rather have one function for all of this, but no idea how to do that... | 34 | // This block is for all of the gaming macros, as they were all doing |
| 91 | void diablo_tapdance1(qk_tap_dance_state_t *state, void *user_data) { diablo_tapdance_master(state, user_data, 0); } | 35 | // the same thing, but with differring text sent. |
| 92 | void diablo_tapdance2(qk_tap_dance_state_t *state, void *user_data) { diablo_tapdance_master(state, user_data, 1); } | 36 | bool send_game_macro(const char *str, keyrecord_t *record, bool override) { |
| 93 | void diablo_tapdance3(qk_tap_dance_state_t *state, void *user_data) { diablo_tapdance_master(state, user_data, 2); } | 37 | if (!record->event.pressed || override) { |
| 94 | void diablo_tapdance4(qk_tap_dance_state_t *state, void *user_data) { diablo_tapdance_master(state, user_data, 3); } | 38 | clear_keyboard(); |
| 95 | 39 | tap(userspace_config.is_overwatch ? KC_BSPC : KC_ENTER); | |
| 96 | //Tap Dance Definitions | 40 | wait_ms(50); |
| 97 | qk_tap_dance_action_t tap_dance_actions[] = { | 41 | send_string(str); |
| 98 | // tap once to disable, and more to enable timed micros | 42 | wait_ms(50); |
| 99 | [TD_D3_1] = ACTION_TAP_DANCE_FN(diablo_tapdance1), | 43 | tap(KC_ENTER); |
| 100 | [TD_D3_2] = ACTION_TAP_DANCE_FN(diablo_tapdance2), | ||
| 101 | [TD_D3_3] = ACTION_TAP_DANCE_FN(diablo_tapdance3), | ||
| 102 | [TD_D3_4] = ACTION_TAP_DANCE_FN(diablo_tapdance4), | ||
| 103 | }; | ||
| 104 | |||
| 105 | // Sends the key press to system, but only if on the Diablo layer | ||
| 106 | void send_diablo_keystroke(uint8_t diablo_key) { | ||
| 107 | if (biton32(layer_state) == _DIABLO) { | ||
| 108 | switch (diablo_key) { | ||
| 109 | case 0: | ||
| 110 | tap(KC_1); break; | ||
| 111 | case 1: | ||
| 112 | tap(KC_2); break; | ||
| 113 | case 2: | ||
| 114 | tap(KC_3); break; | ||
| 115 | case 3: | ||
| 116 | tap(KC_4); break; | ||
| 117 | } | ||
| 118 | } | 44 | } |
| 45 | if (override) wait_ms(3000); | ||
| 46 | return false; | ||
| 119 | } | 47 | } |
| 120 | 48 | ||
| 121 | // Checks each of the 4 timers/keys to see if enough time has elapsed | 49 | void tap(uint16_t keycode){ register_code(keycode); unregister_code(keycode); }; |
| 122 | // Runs the "send string" command if enough time has passed, and resets the timer. | ||
| 123 | void run_diablo_macro_check(void) { | ||
| 124 | uint8_t dtime; | ||
| 125 | for (dtime = 0; dtime < 4; dtime++) { | ||
| 126 | if (check_dtimer(dtime) && diablo_key_time[dtime]) { | ||
| 127 | diablo_timer[dtime] = timer_read(); | ||
| 128 | send_diablo_keystroke(dtime); | ||
| 129 | } | ||
| 130 | } | ||
| 131 | } | ||
| 132 | #endif // TAP_DANCE_ENABLE | ||
| 133 | 50 | ||
| 134 | 51 | ||
| 135 | // Add reconfigurable functions here, for keymap customization | 52 | // Add reconfigurable functions here, for keymap customization |
| @@ -148,6 +65,11 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { | |||
| 148 | } | 65 | } |
| 149 | 66 | ||
| 150 | __attribute__ ((weak)) | 67 | __attribute__ ((weak)) |
| 68 | bool process_record_secrets(uint16_t keycode, keyrecord_t *record) { | ||
| 69 | return true; | ||
| 70 | } | ||
| 71 | |||
| 72 | __attribute__ ((weak)) | ||
| 151 | uint32_t layer_state_set_keymap (uint32_t state) { | 73 | uint32_t layer_state_set_keymap (uint32_t state) { |
| 152 | return state; | 74 | return state; |
| 153 | } | 75 | } |
| @@ -159,9 +81,12 @@ void led_set_keymap(uint8_t usb_led) {} | |||
| 159 | // Call user matrix init, set default RGB colors and then | 81 | // Call user matrix init, set default RGB colors and then |
| 160 | // call the keymap's init function | 82 | // call the keymap's init function |
| 161 | void matrix_init_user(void) { | 83 | void matrix_init_user(void) { |
| 162 | uint8_t default_layer = eeconfig_read_default_layer(); | ||
| 163 | userspace_config.raw = eeprom_read_byte(EECONFIG_USERSPACE); | 84 | userspace_config.raw = eeprom_read_byte(EECONFIG_USERSPACE); |
| 164 | 85 | ||
| 86 | #ifdef AUDIO_CLICKY | ||
| 87 | clicky_enable = userspace_config.clicky_enable; | ||
| 88 | #endif | ||
| 89 | |||
| 165 | #ifdef BOOTLOADER_CATERINA | 90 | #ifdef BOOTLOADER_CATERINA |
| 166 | DDRD &= ~(1<<5); | 91 | DDRD &= ~(1<<5); |
| 167 | PORTD &= ~(1<<5); | 92 | PORTD &= ~(1<<5); |
| @@ -170,39 +95,15 @@ void matrix_init_user(void) { | |||
| 170 | PORTB &= ~(1<<0); | 95 | PORTB &= ~(1<<0); |
| 171 | #endif | 96 | #endif |
| 172 | 97 | ||
| 173 | if (userspace_config.rgb_layer_change) { | ||
| 174 | #ifdef RGBLIGHT_ENABLE | ||
| 175 | rgblight_enable(); | ||
| 176 | #endif // RGBLIGHT_ENABLE | ||
| 177 | if (default_layer & (1UL << _COLEMAK)) { | ||
| 178 | #ifdef RGBLIGHT_ENABLE | ||
| 179 | rgblight_sethsv_magenta(); | ||
| 180 | #endif // RGBLIGHT_ENABLE | ||
| 181 | } else if (default_layer & (1UL << _DVORAK)) { | ||
| 182 | #ifdef RGBLIGHT_ENABLE | ||
| 183 | rgblight_sethsv_green(); | ||
| 184 | #endif // RGBLIGHT_ENABLE | ||
| 185 | } else if (default_layer & (1UL << _WORKMAN)) { | ||
| 186 | #ifdef RGBLIGHT_ENABLE | ||
| 187 | rgblight_sethsv_goldenrod(); | ||
| 188 | #endif // RGBLIGHT_ENABLE | ||
| 189 | } else { | ||
| 190 | #ifdef RGBLIGHT_ENABLE | ||
| 191 | rgblight_sethsv_teal(); | ||
| 192 | #endif // RGBLIGHT_ENABLE | ||
| 193 | } | ||
| 194 | } | ||
| 195 | 98 | ||
| 196 | #ifdef AUDIO_CLICKY | 99 | #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)) |
| 197 | clicky_enable = userspace_config.clicky_enable; | ||
| 198 | #endif | ||
| 199 | |||
| 200 | #if ( defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE) ) | ||
| 201 | set_unicode_input_mode(UC_WINC); | 100 | set_unicode_input_mode(UC_WINC); |
| 202 | #endif //UNICODE_ENABLE | 101 | #endif //UNICODE_ENABLE |
| 203 | 102 | matrix_init_rgb(); | |
| 204 | matrix_init_keymap(); | 103 | matrix_init_keymap(); |
| 205 | } | 104 | } |
| 105 | |||
| 106 | |||
| 206 | // No global matrix scan code, so just run keymap's matrix | 107 | // No global matrix scan code, so just run keymap's matrix |
| 207 | // scan function | 108 | // scan function |
| 208 | void matrix_scan_user(void) { | 109 | void matrix_scan_user(void) { |
| @@ -211,24 +112,14 @@ void matrix_scan_user(void) { | |||
| 211 | run_diablo_macro_check(); | 112 | run_diablo_macro_check(); |
| 212 | #endif // TAP_DANCE_ENABLE | 113 | #endif // TAP_DANCE_ENABLE |
| 213 | 114 | ||
| 115 | #ifdef RGBLIGHT_ENABLE | ||
| 116 | matrix_scan_rgb(); | ||
| 117 | #endif // RGBLIGHT_ENABLE | ||
| 118 | |||
| 214 | matrix_scan_keymap(); | 119 | matrix_scan_keymap(); |
| 215 | } | 120 | } |
| 216 | 121 | ||
| 217 | 122 | ||
| 218 | // This block is for all of the gaming macros, as they were all doing | ||
| 219 | // the same thing, but with differring text sent. | ||
| 220 | bool send_game_macro(const char *str, keyrecord_t *record, bool override) { | ||
| 221 | if (!record->event.pressed || override) { | ||
| 222 | clear_keyboard(); | ||
| 223 | tap(userspace_config.is_overwatch ? KC_BSPC : KC_ENTER); | ||
| 224 | wait_ms(50); | ||
| 225 | send_string(str); | ||
| 226 | wait_ms(50); | ||
| 227 | tap(KC_ENTER); | ||
| 228 | } | ||
| 229 | if (override) wait_ms(3000); | ||
| 230 | return false; | ||
| 231 | } | ||
| 232 | 123 | ||
| 233 | 124 | ||
| 234 | // Defines actions tor my global custom keycodes. Defined in drashna.h file | 125 | // Defines actions tor my global custom keycodes. Defined in drashna.h file |
| @@ -236,10 +127,9 @@ bool send_game_macro(const char *str, keyrecord_t *record, bool override) { | |||
| 236 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | 127 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { |
| 237 | 128 | ||
| 238 | // If console is enabled, it will print the matrix position and status of each key pressed | 129 | // If console is enabled, it will print the matrix position and status of each key pressed |
| 239 | #ifdef CONSOLE_ENABLE | 130 | #ifdef KEYLOGGER_ENABLE |
| 240 | xprintf("KL: row: %u, column: %u, pressed: %u\n", record->event.key.col, record->event.key.row, record->event.pressed); | 131 | xprintf("KL: row: %u, column: %u, pressed: %u\n", record->event.key.col, record->event.key.row, record->event.pressed); |
| 241 | #endif //CONSOLE_ENABLE | 132 | #endif //KEYLOGGER_ENABLE |
| 242 | |||
| 243 | 133 | ||
| 244 | switch (keycode) { | 134 | switch (keycode) { |
| 245 | case KC_QWERTY: | 135 | case KC_QWERTY: |
| @@ -287,8 +177,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 287 | case KC_RESET: // Custom RESET code that sets RGBLights to RED | 177 | case KC_RESET: // Custom RESET code that sets RGBLights to RED |
| 288 | if (!record->event.pressed) { | 178 | if (!record->event.pressed) { |
| 289 | #ifdef RGBLIGHT_ENABLE | 179 | #ifdef RGBLIGHT_ENABLE |
| 290 | rgblight_enable(); | 180 | rgblight_enable_noeeprom(); |
| 291 | rgblight_mode(1); | 181 | rgblight_mode_noeeprom(1); |
| 292 | rgblight_setrgb_red(); | 182 | rgblight_setrgb_red(); |
| 293 | #endif // RGBLIGHT_ENABLE | 183 | #endif // RGBLIGHT_ENABLE |
| 294 | reset_keyboard(); | 184 | reset_keyboard(); |
| @@ -300,6 +190,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 300 | case EPRM: // Resets EEPROM | 190 | case EPRM: // Resets EEPROM |
| 301 | if (record->event.pressed) { | 191 | if (record->event.pressed) { |
| 302 | eeconfig_init(); | 192 | eeconfig_init(); |
| 193 | default_layer_set(1UL<<eeconfig_read_default_layer()); | ||
| 194 | layer_state_set(layer_state); | ||
| 303 | } | 195 | } |
| 304 | return false; | 196 | return false; |
| 305 | break; | 197 | break; |
| @@ -310,24 +202,24 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 310 | return false; | 202 | return false; |
| 311 | break; | 203 | break; |
| 312 | 204 | ||
| 313 | 205 | /* Code has been depreciated | |
| 314 | case KC_SECRET_1 ... KC_SECRET_5: // Secrets! Externally defined strings, not stored in repo | 206 | case KC_SECRET_1 ... KC_SECRET_5: // Secrets! Externally defined strings, not stored in repo |
| 315 | if (!record->event.pressed) { | 207 | if (!record->event.pressed) { |
| 316 | clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); | 208 | clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); |
| 317 | send_string_P(secret[keycode - KC_SECRET_1]); | 209 | send_string(decoy_secret[keycode - KC_SECRET_1]); |
| 318 | } | 210 | } |
| 319 | return false; | 211 | return false; |
| 320 | break; | 212 | break; |
| 321 | 213 | */ | |
| 322 | 214 | ||
| 323 | // These are a serious of gaming macros. | 215 | // These are a serious of gaming macros. |
| 324 | // Only enables for the viterbi, basically, | 216 | // Only enables for the viterbi, basically, |
| 325 | // to save on firmware space, since it's limited. | 217 | // to save on firmware space, since it's limited. |
| 326 | #if !(defined(KEYBOARD_orthodox_rev1) || defined(KEYBOARD_orthodox_rev3) || defined(KEYBOARD_ergodox_ez) || defined(KEYBOARD_iris_rev2)) | 218 | #ifdef MACROS_ENABLED |
| 327 | case KC_OVERWATCH: // Toggle's if we hit "ENTER" or "BACKSPACE" to input macros | 219 | case KC_OVERWATCH: // Toggle's if we hit "ENTER" or "BACKSPACE" to input macros |
| 328 | if (record->event.pressed) { userspace_config.is_overwatch ^= 1; eeprom_update_byte(EECONFIG_USERSPACE, userspace_config.raw); } | 220 | if (record->event.pressed) { userspace_config.is_overwatch ^= 1; eeprom_update_byte(EECONFIG_USERSPACE, userspace_config.raw); } |
| 329 | #ifdef RGBLIGHT_ENABLE | 221 | #ifdef RGBLIGHT_ENABLE |
| 330 | userspace_config.is_overwatch ? rgblight_mode(17) : rgblight_mode(18); | 222 | userspace_config.is_overwatch ? rgblight_mode_noeeprom(17) : rgblight_mode_noeeprom(18); |
| 331 | #endif //RGBLIGHT_ENABLE | 223 | #endif //RGBLIGHT_ENABLE |
| 332 | return false; break; | 224 | return false; break; |
| 333 | case KC_SALT: | 225 | case KC_SALT: |
| @@ -353,40 +245,19 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 353 | return send_game_macro("OMG!!! C9!!!", record, false); | 245 | return send_game_macro("OMG!!! C9!!!", record, false); |
| 354 | case KC_GGEZ: | 246 | case KC_GGEZ: |
| 355 | return send_game_macro("That was a fantastic game, though it was a bit easy. Try harder next time!", record, false); | 247 | return send_game_macro("That was a fantastic game, though it was a bit easy. Try harder next time!", record, false); |
| 356 | #endif // !(defined(KEYBOARD_orthodox_rev1) || defined(KEYBOARD_orthodox_rev3) || defined(KEYBOARD_ergodox_ez)) | 248 | #endif // MACROS_ENABLED |
| 357 | 249 | ||
| 358 | 250 | ||
| 359 | #ifdef TAP_DANCE_ENABLE | ||
| 360 | case KC_DIABLO_CLEAR: // reset all Diablo timers, disabling them | 251 | case KC_DIABLO_CLEAR: // reset all Diablo timers, disabling them |
| 252 | #ifdef TAP_DANCE_ENABLE | ||
| 361 | if (record->event.pressed) { | 253 | if (record->event.pressed) { |
| 362 | uint8_t dtime; | 254 | uint8_t dtime; |
| 363 | for (dtime = 0; dtime < 4; dtime++) { | 255 | for (dtime = 0; dtime < 4; dtime++) { |
| 364 | diablo_key_time[dtime] = diablo_times[0]; | 256 | diablo_key_time[dtime] = diablo_times[0]; |
| 365 | } | 257 | } |
| 366 | } | 258 | } |
| 259 | #endif // TAP_DANCE_ENABLE#endif | ||
| 367 | return false; break; | 260 | return false; break; |
| 368 | #endif // TAP_DANCE_ENABLE | ||
| 369 | |||
| 370 | |||
| 371 | case KC_RGB_T: // This allows me to use underglow as layer indication, or as normal | ||
| 372 | #ifdef RGBLIGHT_ENABLE | ||
| 373 | if (record->event.pressed) { | ||
| 374 | userspace_config.rgb_layer_change ^= 1; | ||
| 375 | eeprom_update_byte(EECONFIG_USERSPACE, userspace_config.raw); | ||
| 376 | if (userspace_config.rgb_layer_change) { | ||
| 377 | layer_state_set(layer_state); // This is needed to immediately set the layer color (looks better) | ||
| 378 | } | ||
| 379 | } | ||
| 380 | #endif // RGBLIGHT_ENABLE | ||
| 381 | return false; break; | ||
| 382 | #ifdef RGBLIGHT_ENABLE | ||
| 383 | case RGB_MODE_FORWARD ... RGB_MODE_GRADIENT: // quantum_keycodes.h L400 for definitions | ||
| 384 | if (record->event.pressed) { //This disables layer indication, as it's assumed that if you're changing this ... you want that disabled | ||
| 385 | userspace_config.rgb_layer_change = false; | ||
| 386 | eeprom_update_byte(EECONFIG_USERSPACE, userspace_config.raw); | ||
| 387 | } | ||
| 388 | return true; break; | ||
| 389 | #endif // RGBLIGHT_ENABLE | ||
| 390 | 261 | ||
| 391 | 262 | ||
| 392 | case KC_CCCV: // One key copy/paste | 263 | case KC_CCCV: // One key copy/paste |
| @@ -443,7 +314,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 443 | #endif // UNICODE_ENABLE | 314 | #endif // UNICODE_ENABLE |
| 444 | 315 | ||
| 445 | } | 316 | } |
| 446 | return process_record_keymap(keycode, record); | 317 | return process_record_keymap(keycode, record) && process_record_secrets(keycode, record) && process_record_user_rgb(keycode, record); |
| 447 | } | 318 | } |
| 448 | 319 | ||
| 449 | 320 | ||
| @@ -452,111 +323,10 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 452 | // on layer change, no matter where the change was initiated | 323 | // on layer change, no matter where the change was initiated |
| 453 | // Then runs keymap's layer change check | 324 | // Then runs keymap's layer change check |
| 454 | uint32_t layer_state_set_user(uint32_t state) { | 325 | uint32_t layer_state_set_user(uint32_t state) { |
| 455 | uint8_t default_layer = eeconfig_read_default_layer(); | ||
| 456 | state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST); | 326 | state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST); |
| 457 | |||
| 458 | switch (biton32(state)) { | ||
| 459 | case _MACROS: | ||
| 460 | #ifdef RGBLIGHT_ENABLE | ||
| 461 | if (userspace_config.rgb_layer_change) { | ||
| 462 | rgblight_sethsv_orange(); | ||
| 463 | userspace_config.is_overwatch ? rgblight_mode(17) : rgblight_mode(18); | ||
| 464 | } | ||
| 465 | #endif // RGBLIGHT_ENABLE | ||
| 466 | |||
| 467 | break; | ||
| 468 | case _MEDIA: | ||
| 469 | #ifdef RGBLIGHT_ENABLE | ||
| 470 | if (userspace_config.rgb_layer_change) { | ||
| 471 | rgblight_sethsv_chartreuse(); | ||
| 472 | rgblight_mode(22); | ||
| 473 | } | ||
| 474 | #endif // RGBLIGHT_ENABLE | ||
| 475 | |||
| 476 | break; | ||
| 477 | case _GAMEPAD: | ||
| 478 | #ifdef RGBLIGHT_ENABLE | ||
| 479 | if (userspace_config.rgb_layer_change) { | ||
| 480 | rgblight_sethsv_orange(); | ||
| 481 | rgblight_mode(17); | ||
| 482 | } | ||
| 483 | #endif // RGBLIGHT_ENABLE | ||
| 484 | |||
| 485 | break; | ||
| 486 | case _DIABLO: | ||
| 487 | #ifdef RGBLIGHT_ENABLE | ||
| 488 | if (userspace_config.rgb_layer_change) { | ||
| 489 | rgblight_sethsv_red(); | ||
| 490 | rgblight_mode(5); | ||
| 491 | } | ||
| 492 | #endif // RGBLIGHT_ENABLE | ||
| 493 | |||
| 494 | break; | ||
| 495 | case _RAISE: | ||
| 496 | #ifdef RGBLIGHT_ENABLE | 327 | #ifdef RGBLIGHT_ENABLE |
| 497 | if (userspace_config.rgb_layer_change) { | 328 | state = layer_state_set_rgb(state); |
| 498 | rgblight_sethsv_yellow(); | ||
| 499 | rgblight_mode(5); | ||
| 500 | } | ||
| 501 | #endif // RGBLIGHT_ENABLE | ||
| 502 | |||
| 503 | break; | ||
| 504 | case _LOWER: | ||
| 505 | #ifdef RGBLIGHT_ENABLE | ||
| 506 | if (userspace_config.rgb_layer_change) { | ||
| 507 | rgblight_sethsv_orange(); | ||
| 508 | rgblight_mode(5); | ||
| 509 | } | ||
| 510 | #endif // RGBLIGHT_ENABLE | ||
| 511 | |||
| 512 | break; | ||
| 513 | case _ADJUST: | ||
| 514 | #ifdef RGBLIGHT_ENABLE | ||
| 515 | if (userspace_config.rgb_layer_change) { | ||
| 516 | rgblight_sethsv_red(); | ||
| 517 | rgblight_mode(23); | ||
| 518 | } | ||
| 519 | #endif // RGBLIGHT_ENABLE | ||
| 520 | |||
| 521 | break; | ||
| 522 | default: // for any other layers, or the default layer | ||
| 523 | if (default_layer & (1UL << _COLEMAK)) { | ||
| 524 | #ifdef RGBLIGHT_ENABLE | ||
| 525 | if (userspace_config.rgb_layer_change) { rgblight_sethsv_magenta(); } | ||
| 526 | #endif // RGBLIGHT_ENABLE | ||
| 527 | |||
| 528 | } | ||
| 529 | else if (default_layer & (1UL << _DVORAK)) { | ||
| 530 | #ifdef RGBLIGHT_ENABLE | ||
| 531 | if (userspace_config.rgb_layer_change) { rgblight_sethsv_green(); } | ||
| 532 | #endif // RGBLIGHT_ENABLE | 329 | #endif // RGBLIGHT_ENABLE |
| 533 | |||
| 534 | } | ||
| 535 | else if (default_layer & (1UL << _WORKMAN)) { | ||
| 536 | #ifdef RGBLIGHT_ENABLE | ||
| 537 | if (userspace_config.rgb_layer_change) { rgblight_sethsv_goldenrod(); } | ||
| 538 | #endif // RGBLIGHT_ENABLE | ||
| 539 | |||
| 540 | } | ||
| 541 | else { | ||
| 542 | #ifdef RGBLIGHT_ENABLE | ||
| 543 | if (userspace_config.rgb_layer_change) { rgblight_sethsv_teal(); } | ||
| 544 | #endif // RGBLIGHT_ENABLE | ||
| 545 | |||
| 546 | } | ||
| 547 | if (biton32(state) == _MODS) { // If the non-OSM layer is enabled, then breathe | ||
| 548 | #ifdef RGBLIGHT_ENABLE | ||
| 549 | if (userspace_config.rgb_layer_change) { rgblight_mode(2); } | ||
| 550 | #endif // RGBLIGHT_ENABLE | ||
| 551 | |||
| 552 | } else { // otherwise, stay solid | ||
| 553 | #ifdef RGBLIGHT_ENABLE | ||
| 554 | if (userspace_config.rgb_layer_change) { rgblight_mode(1); } | ||
| 555 | #endif // RGBLIGHT_ENABLE | ||
| 556 | |||
| 557 | } | ||
| 558 | break; | ||
| 559 | } | ||
| 560 | return layer_state_set_keymap (state); | 330 | return layer_state_set_keymap (state); |
| 561 | } | 331 | } |
| 562 | 332 | ||
