diff options
Diffstat (limited to 'users/drashna/drashna.c')
| -rw-r--r-- | users/drashna/drashna.c | 75 |
1 files changed, 29 insertions, 46 deletions
diff --git a/users/drashna/drashna.c b/users/drashna/drashna.c index f72902f0b..20df2f4de 100644 --- a/users/drashna/drashna.c +++ b/users/drashna/drashna.c | |||
| @@ -16,16 +16,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 16 | */ | 16 | */ |
| 17 | 17 | ||
| 18 | #include "drashna.h" | 18 | #include "drashna.h" |
| 19 | #include "version.h" | ||
| 20 | #include "eeprom.h" | ||
| 21 | #include "tap_dances.h" | 19 | #include "tap_dances.h" |
| 22 | #include "rgb_stuff.h" | 20 | #include "rgb_stuff.h" |
| 23 | 21 | ||
| 24 | |||
| 25 | float tone_copy[][2] = SONG(SCROLL_LOCK_ON_SOUND); | ||
| 26 | float tone_paste[][2] = SONG(SCROLL_LOCK_OFF_SOUND); | ||
| 27 | |||
| 28 | static uint16_t copy_paste_timer; | ||
| 29 | userspace_config_t userspace_config; | 22 | userspace_config_t userspace_config; |
| 30 | 23 | ||
| 31 | // Helper Functions | 24 | // Helper Functions |
| @@ -35,8 +28,14 @@ userspace_config_t userspace_config; | |||
| 35 | // the same thing, but with differring text sent. | 28 | // the same thing, but with differring text sent. |
| 36 | bool send_game_macro(const char *str, keyrecord_t *record, bool override) { | 29 | bool send_game_macro(const char *str, keyrecord_t *record, bool override) { |
| 37 | if (!record->event.pressed || override) { | 30 | if (!record->event.pressed || override) { |
| 31 | uint16_t keycode; | ||
| 32 | if (userspace_config.is_overwatch) { | ||
| 33 | keycode = KC_BSPC; | ||
| 34 | } else { | ||
| 35 | keycode = KC_ENTER; | ||
| 36 | } | ||
| 38 | clear_keyboard(); | 37 | clear_keyboard(); |
| 39 | tap(userspace_config.is_overwatch ? KC_BSPC : KC_ENTER); | 38 | tap(keycode); |
| 40 | wait_ms(50); | 39 | wait_ms(50); |
| 41 | send_string_with_delay(str, MACRO_TIMER); | 40 | send_string_with_delay(str, MACRO_TIMER); |
| 42 | wait_ms(50); | 41 | wait_ms(50); |
| @@ -46,8 +45,6 @@ bool send_game_macro(const char *str, keyrecord_t *record, bool override) { | |||
| 46 | return false; | 45 | return false; |
| 47 | } | 46 | } |
| 48 | 47 | ||
| 49 | void tap(uint16_t keycode){ register_code(keycode); unregister_code(keycode); }; | ||
| 50 | |||
| 51 | bool mod_key_press_timer (uint16_t code, uint16_t mod_code, bool pressed) { | 48 | bool mod_key_press_timer (uint16_t code, uint16_t mod_code, bool pressed) { |
| 52 | static uint16_t this_timer; | 49 | static uint16_t this_timer; |
| 53 | if(pressed) { | 50 | if(pressed) { |
| @@ -94,6 +91,9 @@ __attribute__ ((weak)) | |||
| 94 | void startup_keymap(void) {} | 91 | void startup_keymap(void) {} |
| 95 | 92 | ||
| 96 | __attribute__ ((weak)) | 93 | __attribute__ ((weak)) |
| 94 | void shutdown_keymap(void) {} | ||
| 95 | |||
| 96 | __attribute__ ((weak)) | ||
| 97 | void suspend_power_down_keymap(void) {} | 97 | void suspend_power_down_keymap(void) {} |
| 98 | 98 | ||
| 99 | __attribute__ ((weak)) | 99 | __attribute__ ((weak)) |
| @@ -127,6 +127,7 @@ __attribute__ ((weak)) | |||
| 127 | void led_set_keymap(uint8_t usb_led) {} | 127 | void led_set_keymap(uint8_t usb_led) {} |
| 128 | 128 | ||
| 129 | 129 | ||
| 130 | |||
| 130 | // Call user matrix init, set default RGB colors and then | 131 | // Call user matrix init, set default RGB colors and then |
| 131 | // call the keymap's init function | 132 | // call the keymap's init function |
| 132 | void matrix_init_user(void) { | 133 | void matrix_init_user(void) { |
| @@ -158,6 +159,24 @@ void startup_user (void) { | |||
| 158 | startup_keymap(); | 159 | startup_keymap(); |
| 159 | } | 160 | } |
| 160 | 161 | ||
| 162 | void shutdown_user (void) { | ||
| 163 | #ifdef RGBLIGHT_ENABLE | ||
| 164 | rgblight_enable_noeeprom(); | ||
| 165 | rgblight_mode_noeeprom(1); | ||
| 166 | rgblight_setrgb_red(); | ||
| 167 | #endif // RGBLIGHT_ENABLE | ||
| 168 | #ifdef RGB_MATRIX_ENABLE | ||
| 169 | rgb_led led; | ||
| 170 | for (int i = 0; i < DRIVER_LED_TOTAL; i++) { | ||
| 171 | led = g_rgb_leds[i]; | ||
| 172 | if (led.matrix_co.raw < 0xFF) { | ||
| 173 | rgb_matrix_set_color( i, 0xFF, 0x00, 0x00 ); | ||
| 174 | } | ||
| 175 | } | ||
| 176 | #endif //RGB_MATRIX_ENABLE | ||
| 177 | shutdown_keymap(); | ||
| 178 | } | ||
| 179 | |||
| 161 | void suspend_power_down_user(void) | 180 | void suspend_power_down_user(void) |
| 162 | { | 181 | { |
| 163 | suspend_power_down_keymap(); | 182 | suspend_power_down_keymap(); |
| @@ -246,20 +265,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 246 | return false; | 265 | return false; |
| 247 | break; | 266 | break; |
| 248 | 267 | ||
| 249 | |||
| 250 | case KC_RESET: // Custom RESET code that sets RGBLights to RED | ||
| 251 | if (!record->event.pressed) { | ||
| 252 | #ifdef RGBLIGHT_ENABLE | ||
| 253 | rgblight_enable_noeeprom(); | ||
| 254 | rgblight_mode_noeeprom(1); | ||
| 255 | rgblight_setrgb_red(); | ||
| 256 | #endif // RGBLIGHT_ENABLE | ||
| 257 | reset_keyboard(); | ||
| 258 | } | ||
| 259 | return false; | ||
| 260 | break; | ||
| 261 | |||
| 262 | |||
| 263 | case EPRM: // Resets EEPROM | 268 | case EPRM: // Resets EEPROM |
| 264 | if (record->event.pressed) { | 269 | if (record->event.pressed) { |
| 265 | eeconfig_init(); | 270 | eeconfig_init(); |
| @@ -333,28 +338,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 333 | return false; break; | 338 | return false; break; |
| 334 | 339 | ||
| 335 | 340 | ||
| 336 | case KC_CCCV: // One key copy/paste | ||
| 337 | if(record->event.pressed){ | ||
| 338 | copy_paste_timer = timer_read(); | ||
| 339 | } else { | ||
| 340 | if (timer_elapsed(copy_paste_timer) > TAPPING_TERM) { // Hold, copy | ||
| 341 | register_code(KC_LCTL); | ||
| 342 | tap(KC_C); | ||
| 343 | unregister_code(KC_LCTL); | ||
| 344 | #ifdef AUDIO_ENABLE | ||
| 345 | PLAY_SONG(tone_copy); | ||
| 346 | #endif | ||
| 347 | } else { // Tap, paste | ||
| 348 | register_code(KC_LCTL); | ||
| 349 | tap(KC_V); | ||
| 350 | unregister_code(KC_LCTL); | ||
| 351 | #ifdef AUDIO_ENABLE | ||
| 352 | PLAY_SONG(tone_paste); | ||
| 353 | #endif | ||
| 354 | } | ||
| 355 | } | ||
| 356 | return false; | ||
| 357 | break; | ||
| 358 | case CLICKY_TOGGLE: | 341 | case CLICKY_TOGGLE: |
| 359 | #ifdef AUDIO_CLICKY | 342 | #ifdef AUDIO_CLICKY |
| 360 | userspace_config.clicky_enable = clicky_enable; | 343 | userspace_config.clicky_enable = clicky_enable; |
