diff options
Diffstat (limited to 'users/drashna/drashna.c')
| -rw-r--r-- | users/drashna/drashna.c | 198 |
1 files changed, 99 insertions, 99 deletions
diff --git a/users/drashna/drashna.c b/users/drashna/drashna.c index ec249dd22..7c60a2e4a 100644 --- a/users/drashna/drashna.c +++ b/users/drashna/drashna.c | |||
| @@ -19,78 +19,78 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 19 | 19 | ||
| 20 | userspace_config_t userspace_config; | 20 | userspace_config_t userspace_config; |
| 21 | #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)) | 21 | #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)) |
| 22 | #define DRASHNA_UNICODE_MODE UC_WIN | 22 | #define DRASHNA_UNICODE_MODE UC_WIN |
| 23 | #else | 23 | #else |
| 24 | // set to 2 for UC_WIN, set to 4 for UC_WINC | 24 | // set to 2 for UC_WIN, set to 4 for UC_WINC |
| 25 | #define DRASHNA_UNICODE_MODE 2 | 25 | #define DRASHNA_UNICODE_MODE 2 |
| 26 | #endif | 26 | #endif |
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | // This block is for all of the gaming macros, as they were all doing | 29 | // This block is for all of the gaming macros, as they were all doing |
| 30 | // the same thing, but with differring text sent. | 30 | // the same thing, but with differring text sent. |
| 31 | bool send_game_macro(const char *str, keyrecord_t *record, bool override) { | 31 | bool send_game_macro(const char *str, keyrecord_t *record, bool override) { |
| 32 | if (!record->event.pressed || override) { | 32 | if (!record->event.pressed || override) { |
| 33 | uint16_t keycode; | 33 | uint16_t keycode; |
| 34 | if (userspace_config.is_overwatch) { | 34 | if (userspace_config.is_overwatch) { |
| 35 | keycode = KC_BSPC; | 35 | keycode = KC_BSPC; |
| 36 | } else { | 36 | } else { |
| 37 | keycode = KC_ENTER; | 37 | keycode = KC_ENTER; |
| 38 | } | ||
| 39 | clear_keyboard(); | ||
| 40 | tap_code(keycode); | ||
| 41 | wait_ms(TAP_CODE_DELAY); | ||
| 42 | send_string_with_delay(str, TAP_CODE_DELAY); | ||
| 43 | wait_ms(TAP_CODE_DELAY); | ||
| 44 | tap_code(KC_ENTER); | ||
| 38 | } | 45 | } |
| 39 | clear_keyboard(); | 46 | if (override) wait_ms(3000); |
| 40 | tap_code(keycode); | 47 | return false; |
| 41 | wait_ms(TAP_CODE_DELAY); | ||
| 42 | send_string_with_delay(str, TAP_CODE_DELAY); | ||
| 43 | wait_ms(TAP_CODE_DELAY); | ||
| 44 | tap_code(KC_ENTER); | ||
| 45 | } | ||
| 46 | if (override) wait_ms(3000); | ||
| 47 | return false; | ||
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | bool mod_key_press_timer (uint16_t code, uint16_t mod_code, bool pressed) { | 50 | bool mod_key_press_timer (uint16_t code, uint16_t mod_code, bool pressed) { |
| 51 | static uint16_t this_timer; | 51 | static uint16_t this_timer; |
| 52 | if(pressed) { | 52 | if(pressed) { |
| 53 | this_timer= timer_read(); | 53 | this_timer= timer_read(); |
| 54 | } else { | 54 | } else { |
| 55 | if (timer_elapsed(this_timer) < TAPPING_TERM){ | 55 | if (timer_elapsed(this_timer) < TAPPING_TERM){ |
| 56 | tap_code(code); | 56 | tap_code(code); |
| 57 | } else { | 57 | } else { |
| 58 | register_code(mod_code); | 58 | register_code(mod_code); |
| 59 | tap_code(code); | 59 | tap_code(code); |
| 60 | unregister_code(mod_code); | 60 | unregister_code(mod_code); |
| 61 | } | 61 | } |
| 62 | } | 62 | } |
| 63 | return false; | 63 | return false; |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | bool mod_key_press (uint16_t code, uint16_t mod_code, bool pressed, uint16_t this_timer) { | 66 | bool mod_key_press (uint16_t code, uint16_t mod_code, bool pressed, uint16_t this_timer) { |
| 67 | if(pressed) { | 67 | if(pressed) { |
| 68 | this_timer= timer_read(); | 68 | this_timer= timer_read(); |
| 69 | } else { | 69 | } else { |
| 70 | if (timer_elapsed(this_timer) < TAPPING_TERM){ | 70 | if (timer_elapsed(this_timer) < TAPPING_TERM){ |
| 71 | tap_code(code); | 71 | tap_code(code); |
| 72 | } else { | 72 | } else { |
| 73 | register_code(mod_code); | 73 | register_code(mod_code); |
| 74 | tap_code(code); | 74 | tap_code(code); |
| 75 | unregister_code(mod_code); | 75 | unregister_code(mod_code); |
| 76 | } | 76 | } |
| 77 | } | 77 | } |
| 78 | return false; | 78 | return false; |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | void bootmagic_lite(void) { | 81 | void bootmagic_lite(void) { |
| 82 | matrix_scan(); | 82 | matrix_scan(); |
| 83 | #if defined(DEBOUNCING_DELAY) && DEBOUNCING_DELAY > 0 | 83 | #if defined(DEBOUNCING_DELAY) && DEBOUNCING_DELAY > 0 |
| 84 | wait_ms(DEBOUNCING_DELAY * 2); | 84 | wait_ms(DEBOUNCING_DELAY * 2); |
| 85 | #elif defined(DEBOUNCE) && DEBOUNCE > 0 | 85 | #elif defined(DEBOUNCE) && DEBOUNCE > 0 |
| 86 | wait_ms(DEBOUNCE * 2); | 86 | wait_ms(DEBOUNCE * 2); |
| 87 | #else | 87 | #else |
| 88 | wait_ms(30); | 88 | wait_ms(30); |
| 89 | #endif | 89 | #endif |
| 90 | matrix_scan(); | 90 | matrix_scan(); |
| 91 | if (matrix_get_row(BOOTMAGIC_LITE_ROW) & (1 << BOOTMAGIC_LITE_COLUMN)) { | 91 | if (matrix_get_row(BOOTMAGIC_LITE_ROW) & (1 << BOOTMAGIC_LITE_COLUMN)) { |
| 92 | bootloader_jump(); | 92 | bootloader_jump(); |
| 93 | } | 93 | } |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | // Add reconfigurable functions here, for keymap customization | 96 | // Add reconfigurable functions here, for keymap customization |
| @@ -103,21 +103,21 @@ void matrix_init_keymap(void) {} | |||
| 103 | // Call user matrix init, set default RGB colors and then | 103 | // Call user matrix init, set default RGB colors and then |
| 104 | // call the keymap's init function | 104 | // call the keymap's init function |
| 105 | void matrix_init_user(void) { | 105 | void matrix_init_user(void) { |
| 106 | userspace_config.raw = eeconfig_read_user(); | 106 | userspace_config.raw = eeconfig_read_user(); |
| 107 | 107 | ||
| 108 | #ifdef BOOTLOADER_CATERINA | 108 | #ifdef BOOTLOADER_CATERINA |
| 109 | DDRD &= ~(1<<5); | 109 | DDRD &= ~(1<<5); |
| 110 | PORTD &= ~(1<<5); | 110 | PORTD &= ~(1<<5); |
| 111 | 111 | ||
| 112 | DDRB &= ~(1<<0); | 112 | DDRB &= ~(1<<0); |
| 113 | PORTB &= ~(1<<0); | 113 | PORTB &= ~(1<<0); |
| 114 | #endif | 114 | #endif |
| 115 | 115 | ||
| 116 | #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)) | 116 | #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)) |
| 117 | set_unicode_input_mode(DRASHNA_UNICODE_MODE); | 117 | set_unicode_input_mode(DRASHNA_UNICODE_MODE); |
| 118 | get_unicode_input_mode(); | 118 | get_unicode_input_mode(); |
| 119 | #endif //UNICODE_ENABLE | 119 | #endif //UNICODE_ENABLE |
| 120 | matrix_init_keymap(); | 120 | matrix_init_keymap(); |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | __attribute__((weak)) | 123 | __attribute__((weak)) |
| @@ -125,26 +125,26 @@ void keyboard_post_init_keymap(void){ } | |||
| 125 | 125 | ||
| 126 | void keyboard_post_init_user(void){ | 126 | void keyboard_post_init_user(void){ |
| 127 | #ifdef RGBLIGHT_ENABLE | 127 | #ifdef RGBLIGHT_ENABLE |
| 128 | keyboard_post_init_rgb(); | 128 | keyboard_post_init_rgb(); |
| 129 | #endif | 129 | #endif |
| 130 | keyboard_post_init_keymap(); | 130 | keyboard_post_init_keymap(); |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | __attribute__ ((weak)) | 133 | __attribute__ ((weak)) |
| 134 | void shutdown_keymap(void) {} | 134 | void shutdown_keymap(void) {} |
| 135 | 135 | ||
| 136 | void shutdown_user (void) { | 136 | void shutdown_user (void) { |
| 137 | #ifdef RGBLIGHT_ENABLE | 137 | #ifdef RGBLIGHT_ENABLE |
| 138 | rgblight_enable_noeeprom(); | 138 | rgblight_enable_noeeprom(); |
| 139 | rgblight_mode_noeeprom(1); | 139 | rgblight_mode_noeeprom(1); |
| 140 | rgblight_setrgb_red(); | 140 | rgblight_setrgb_red(); |
| 141 | #endif // RGBLIGHT_ENABLE | 141 | #endif // RGBLIGHT_ENABLE |
| 142 | #ifdef RGB_MATRIX_ENABLE | 142 | #ifdef RGB_MATRIX_ENABLE |
| 143 | // uint16_t timer_start = timer_read(); | 143 | // uint16_t timer_start = timer_read(); |
| 144 | // rgb_matrix_set_color_all( 0xFF, 0x00, 0x00 ); | 144 | // rgb_matrix_set_color_all( 0xFF, 0x00, 0x00 ); |
| 145 | // while(timer_elapsed(timer_start) < 250) { wait_ms(1); } | 145 | // while(timer_elapsed(timer_start) < 250) { wait_ms(1); } |
| 146 | #endif //RGB_MATRIX_ENABLE | 146 | #endif //RGB_MATRIX_ENABLE |
| 147 | shutdown_keymap(); | 147 | shutdown_keymap(); |
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | __attribute__ ((weak)) | 150 | __attribute__ ((weak)) |
| @@ -158,7 +158,7 @@ __attribute__ ((weak)) | |||
| 158 | void suspend_wakeup_init_keymap(void) {} | 158 | void suspend_wakeup_init_keymap(void) {} |
| 159 | 159 | ||
| 160 | void suspend_wakeup_init_user(void) { | 160 | void suspend_wakeup_init_user(void) { |
| 161 | suspend_wakeup_init_keymap(); | 161 | suspend_wakeup_init_keymap(); |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | 164 | ||
| @@ -168,54 +168,54 @@ void matrix_scan_keymap(void) {} | |||
| 168 | // No global matrix scan code, so just run keymap's matrix | 168 | // No global matrix scan code, so just run keymap's matrix |
| 169 | // scan function | 169 | // scan function |
| 170 | void matrix_scan_user(void) { | 170 | void matrix_scan_user(void) { |
| 171 | static bool has_ran_yet; | 171 | static bool has_ran_yet; |
| 172 | if (!has_ran_yet) { | 172 | if (!has_ran_yet) { |
| 173 | has_ran_yet = true; | 173 | has_ran_yet = true; |
| 174 | startup_user(); | 174 | startup_user(); |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | #ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code. | 177 | #ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code. |
| 178 | run_diablo_macro_check(); | 178 | run_diablo_macro_check(); |
| 179 | #endif // TAP_DANCE_ENABLE | 179 | #endif // TAP_DANCE_ENABLE |
| 180 | 180 | ||
| 181 | #ifdef RGBLIGHT_ENABLE | 181 | #ifdef RGBLIGHT_ENABLE |
| 182 | matrix_scan_rgb(); | 182 | matrix_scan_rgb(); |
| 183 | #endif // RGBLIGHT_ENABLE | 183 | #endif // RGBLIGHT_ENABLE |
| 184 | 184 | ||
| 185 | matrix_scan_keymap(); | 185 | matrix_scan_keymap(); |
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | 188 | ||
| 189 | __attribute__ ((weak)) | 189 | __attribute__ ((weak)) |
| 190 | uint32_t layer_state_set_keymap (uint32_t state) { | 190 | uint32_t layer_state_set_keymap (uint32_t state) { |
| 191 | return state; | 191 | return state; |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | // on layer change, no matter where the change was initiated | 194 | // on layer change, no matter where the change was initiated |
| 195 | // Then runs keymap's layer change check | 195 | // Then runs keymap's layer change check |
| 196 | uint32_t layer_state_set_user(uint32_t state) { | 196 | uint32_t layer_state_set_user(uint32_t state) { |
| 197 | state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST); | 197 | state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST); |
| 198 | #ifdef RGBLIGHT_ENABLE | 198 | #ifdef RGBLIGHT_ENABLE |
| 199 | state = layer_state_set_rgb(state); | 199 | state = layer_state_set_rgb(state); |
| 200 | #endif // RGBLIGHT_ENABLE | 200 | #endif // RGBLIGHT_ENABLE |
| 201 | return layer_state_set_keymap (state); | 201 | return layer_state_set_keymap (state); |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | 204 | ||
| 205 | __attribute__ ((weak)) | 205 | __attribute__ ((weak)) |
| 206 | uint32_t default_layer_state_set_keymap (uint32_t state) { | 206 | uint32_t default_layer_state_set_keymap (uint32_t state) { |
| 207 | return state; | 207 | return state; |
| 208 | } | 208 | } |
| 209 | 209 | ||
| 210 | // Runs state check and changes underglow color and animation | 210 | // Runs state check and changes underglow color and animation |
| 211 | uint32_t default_layer_state_set_user(uint32_t state) { | 211 | uint32_t default_layer_state_set_user(uint32_t state) { |
| 212 | state = default_layer_state_set_keymap(state); | 212 | state = default_layer_state_set_keymap(state); |
| 213 | #if 0 | 213 | #if 0 |
| 214 | #ifdef RGBLIGHT_ENABLE | 214 | #ifdef RGBLIGHT_ENABLE |
| 215 | state = default_layer_state_set_rgb(state); | 215 | state = default_layer_state_set_rgb(state); |
| 216 | #endif // RGBLIGHT_ENABLE | 216 | #endif // RGBLIGHT_ENABLE |
| 217 | #endif | 217 | #endif |
| 218 | return state; | 218 | return state; |
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | __attribute__ ((weak)) | 221 | __attribute__ ((weak)) |
| @@ -225,16 +225,16 @@ void led_set_keymap(uint8_t usb_led) {} | |||
| 225 | // So far, I only have keyboard specific code, | 225 | // So far, I only have keyboard specific code, |
| 226 | // So nothing goes here. | 226 | // So nothing goes here. |
| 227 | void led_set_user(uint8_t usb_led) { | 227 | void led_set_user(uint8_t usb_led) { |
| 228 | led_set_keymap(usb_led); | 228 | led_set_keymap(usb_led); |
| 229 | } | 229 | } |
| 230 | 230 | ||
| 231 | __attribute__ ((weak)) | 231 | __attribute__ ((weak)) |
| 232 | void eeconfig_init_keymap(void) {} | 232 | void eeconfig_init_keymap(void) {} |
| 233 | 233 | ||
| 234 | void eeconfig_init_user(void) { | 234 | void eeconfig_init_user(void) { |
| 235 | userspace_config.raw = 0; | 235 | userspace_config.raw = 0; |
| 236 | userspace_config.rgb_layer_change = true; | 236 | userspace_config.rgb_layer_change = true; |
| 237 | eeconfig_update_user(userspace_config.raw); | 237 | eeconfig_update_user(userspace_config.raw); |
| 238 | #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)) | 238 | #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)) |
| 239 | set_unicode_input_mode(DRASHNA_UNICODE_MODE); | 239 | set_unicode_input_mode(DRASHNA_UNICODE_MODE); |
| 240 | get_unicode_input_mode(); | 240 | get_unicode_input_mode(); |
