diff options
Diffstat (limited to 'users/drashna/drashna.c')
| -rw-r--r-- | users/drashna/drashna.c | 271 |
1 files changed, 36 insertions, 235 deletions
diff --git a/users/drashna/drashna.c b/users/drashna/drashna.c index 8f10a530e..222824837 100644 --- a/users/drashna/drashna.c +++ b/users/drashna/drashna.c | |||
| @@ -16,8 +16,6 @@ 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 "tap_dances.h" | ||
| 20 | #include "rgb_stuff.h" | ||
| 21 | 19 | ||
| 22 | userspace_config_t userspace_config; | 20 | userspace_config_t userspace_config; |
| 23 | #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)) | 21 | #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)) |
| @@ -27,9 +25,6 @@ userspace_config_t userspace_config; | |||
| 27 | #define DRASHNA_UNICODE_MODE 2 | 25 | #define DRASHNA_UNICODE_MODE 2 |
| 28 | #endif | 26 | #endif |
| 29 | 27 | ||
| 30 | uint16_t copy_paste_timer; | ||
| 31 | // Helper Functions | ||
| 32 | |||
| 33 | 28 | ||
| 34 | // 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 |
| 35 | // the same thing, but with differring text sent. | 30 | // the same thing, but with differring text sent. |
| @@ -109,55 +104,9 @@ void bootmagic_lite(void) { | |||
| 109 | __attribute__ ((weak)) | 104 | __attribute__ ((weak)) |
| 110 | void matrix_init_keymap(void) {} | 105 | void matrix_init_keymap(void) {} |
| 111 | 106 | ||
| 112 | __attribute__ ((weak)) | ||
| 113 | void startup_keymap(void) {} | ||
| 114 | |||
| 115 | __attribute__ ((weak)) | ||
| 116 | void shutdown_keymap(void) {} | ||
| 117 | |||
| 118 | __attribute__ ((weak)) | ||
| 119 | void suspend_power_down_keymap(void) {} | ||
| 120 | |||
| 121 | __attribute__ ((weak)) | ||
| 122 | void suspend_wakeup_init_keymap(void) {} | ||
| 123 | |||
| 124 | __attribute__ ((weak)) | ||
| 125 | void matrix_scan_keymap(void) {} | ||
| 126 | |||
| 127 | __attribute__ ((weak)) | ||
| 128 | bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { | ||
| 129 | return true; | ||
| 130 | } | ||
| 131 | |||
| 132 | __attribute__ ((weak)) | ||
| 133 | bool process_record_secrets(uint16_t keycode, keyrecord_t *record) { | ||
| 134 | return true; | ||
| 135 | } | ||
| 136 | |||
| 137 | |||
| 138 | __attribute__ ((weak)) | ||
| 139 | uint32_t layer_state_set_keymap (uint32_t state) { | ||
| 140 | return state; | ||
| 141 | } | ||
| 142 | |||
| 143 | __attribute__ ((weak)) | ||
| 144 | uint32_t default_layer_state_set_keymap (uint32_t state) { | ||
| 145 | return state; | ||
| 146 | } | ||
| 147 | |||
| 148 | __attribute__ ((weak)) | ||
| 149 | void led_set_keymap(uint8_t usb_led) {} | ||
| 150 | |||
| 151 | __attribute__ ((weak)) | ||
| 152 | void eeconfig_init_keymap(void) {} | ||
| 153 | |||
| 154 | // Call user matrix init, set default RGB colors and then | 107 | // Call user matrix init, set default RGB colors and then |
| 155 | // call the keymap's init function | 108 | // call the keymap's init function |
| 156 | void matrix_init_user(void) { | 109 | void matrix_init_user(void) { |
| 157 | #if !defined(BOOTMAGIC_LITE) && !defined(BOOTMAGIC_ENABLE) | ||
| 158 | bootmagic_lite(); | ||
| 159 | #endif | ||
| 160 | |||
| 161 | userspace_config.raw = eeconfig_read_user(); | 110 | userspace_config.raw = eeconfig_read_user(); |
| 162 | 111 | ||
| 163 | #ifdef BOOTLOADER_CATERINA | 112 | #ifdef BOOTLOADER_CATERINA |
| @@ -178,40 +127,42 @@ void matrix_init_user(void) { | |||
| 178 | #endif //RGBLIGHT_ENABLE | 127 | #endif //RGBLIGHT_ENABLE |
| 179 | } | 128 | } |
| 180 | 129 | ||
| 181 | void startup_user (void) { | 130 | |
| 182 | // #ifdef RGBLIGHT_ENABLE | 131 | __attribute__ ((weak)) |
| 183 | // matrix_init_rgb(); | 132 | void shutdown_keymap(void) {} |
| 184 | // #endif //RGBLIGHT_ENABLE | ||
| 185 | startup_keymap(); | ||
| 186 | } | ||
| 187 | 133 | ||
| 188 | void shutdown_user (void) { | 134 | void shutdown_user (void) { |
| 189 | #ifdef RGBLIGHT_ENABLE | 135 | #ifdef RGBLIGHT_ENABLE |
| 190 | rgblight_enable_noeeprom(); | 136 | rgblight_enable_noeeprom(); |
| 191 | rgblight_mode_noeeprom(1); | 137 | rgblight_mode_noeeprom(1); |
| 192 | rgblight_setrgb_red(); | 138 | rgblight_setrgb_red(); |
| 193 | #endif // RGBLIGHT_ENABLE | 139 | #endif // RGBLIGHT_ENABLE |
| 194 | #ifdef RGB_MATRIX_ENABLE | 140 | #ifdef RGB_MATRIX_ENABLE |
| 195 | rgb_led led; | 141 | uint16_t timer_start = timer_read(); |
| 196 | for (int i = 0; i < DRIVER_LED_TOTAL; i++) { | 142 | rgb_matrix_set_color_all( 0xFF, 0x00, 0x00 ); |
| 197 | led = g_rgb_leds[i]; | 143 | while(timer_elapsed(timer_start) < 250) { wait_ms(1); } |
| 198 | if (led.matrix_co.raw < 0xFF) { | 144 | #endif //RGB_MATRIX_ENABLE |
| 199 | rgb_matrix_set_color( i, 0xFF, 0x00, 0x00 ); | ||
| 200 | } | ||
| 201 | } | ||
| 202 | #endif //RGB_MATRIX_ENABLE | ||
| 203 | shutdown_keymap(); | 145 | shutdown_keymap(); |
| 204 | } | 146 | } |
| 205 | 147 | ||
| 148 | __attribute__ ((weak)) | ||
| 149 | void suspend_power_down_keymap(void) {} | ||
| 150 | |||
| 206 | void suspend_power_down_user(void) { | 151 | void suspend_power_down_user(void) { |
| 207 | suspend_power_down_keymap(); | 152 | suspend_power_down_keymap(); |
| 208 | } | 153 | } |
| 209 | 154 | ||
| 155 | __attribute__ ((weak)) | ||
| 156 | void suspend_wakeup_init_keymap(void) {} | ||
| 157 | |||
| 210 | void suspend_wakeup_init_user(void) { | 158 | void suspend_wakeup_init_user(void) { |
| 211 | suspend_wakeup_init_keymap(); | 159 | suspend_wakeup_init_keymap(); |
| 212 | } | 160 | } |
| 213 | 161 | ||
| 214 | 162 | ||
| 163 | __attribute__ ((weak)) | ||
| 164 | void matrix_scan_keymap(void) {} | ||
| 165 | |||
| 215 | // No global matrix scan code, so just run keymap's matrix | 166 | // No global matrix scan code, so just run keymap's matrix |
| 216 | // scan function | 167 | // scan function |
| 217 | void matrix_scan_user(void) { | 168 | void matrix_scan_user(void) { |
| @@ -233,172 +184,11 @@ void matrix_scan_user(void) { | |||
| 233 | } | 184 | } |
| 234 | 185 | ||
| 235 | 186 | ||
| 236 | 187 | __attribute__ ((weak)) | |
| 237 | 188 | uint32_t layer_state_set_keymap (uint32_t state) { | |
| 238 | // Defines actions tor my global custom keycodes. Defined in drashna.h file | 189 | return state; |
| 239 | // Then runs the _keymap's record handier if not processed here | ||
| 240 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 241 | |||
| 242 | // If console is enabled, it will print the matrix position and status of each key pressed | ||
| 243 | #ifdef KEYLOGGER_ENABLE | ||
| 244 | #if defined(KEYBOARD_ergodox_ez) || defined(KEYBOARD_iris_rev2) | ||
| 245 | xprintf("KL: col: %u, row: %u, pressed: %u\n", record->event.key.row, record->event.key.col, record->event.pressed); | ||
| 246 | #else | ||
| 247 | xprintf("KL: col: %u, row: %u, pressed: %u\n", record->event.key.col, record->event.key.row, record->event.pressed); | ||
| 248 | #endif | ||
| 249 | #endif //KEYLOGGER_ENABLE | ||
| 250 | |||
| 251 | switch (keycode) { | ||
| 252 | case KC_QWERTY: | ||
| 253 | if (record->event.pressed) { | ||
| 254 | set_single_persistent_default_layer(_QWERTY); | ||
| 255 | } | ||
| 256 | break; | ||
| 257 | case KC_COLEMAK: | ||
| 258 | if (record->event.pressed) { | ||
| 259 | set_single_persistent_default_layer(_COLEMAK); | ||
| 260 | } | ||
| 261 | break; | ||
| 262 | case KC_DVORAK: | ||
| 263 | if (record->event.pressed) { | ||
| 264 | set_single_persistent_default_layer(_DVORAK); | ||
| 265 | } | ||
| 266 | break; | ||
| 267 | case KC_WORKMAN: | ||
| 268 | if (record->event.pressed) { | ||
| 269 | set_single_persistent_default_layer(_WORKMAN); | ||
| 270 | } | ||
| 271 | break; | ||
| 272 | |||
| 273 | |||
| 274 | case KC_MAKE: // Compiles the firmware, and adds the flash command based on keyboard bootloader | ||
| 275 | if (!record->event.pressed) { | ||
| 276 | uint8_t temp_mod = get_mods(); | ||
| 277 | uint8_t temp_osm = get_oneshot_mods(); | ||
| 278 | clear_mods(); clear_oneshot_mods(); | ||
| 279 | send_string_with_delay_P(PSTR("make " QMK_KEYBOARD ":" QMK_KEYMAP), 10); | ||
| 280 | if (temp_mod & MODS_SHIFT_MASK || temp_osm & MODS_SHIFT_MASK) { | ||
| 281 | #if defined(__ARM__) | ||
| 282 | send_string_with_delay_P(PSTR(":dfu-util"), 10); | ||
| 283 | #elif defined(BOOTLOADER_DFU) | ||
| 284 | send_string_with_delay_P(PSTR(":dfu"), 10); | ||
| 285 | #elif defined(BOOTLOADER_HALFKAY) | ||
| 286 | send_string_with_delay_P(PSTR(":teensy"), 10); | ||
| 287 | #elif defined(BOOTLOADER_CATERINA) | ||
| 288 | send_string_with_delay_P(PSTR(":avrdude"), 10); | ||
| 289 | #endif // bootloader options | ||
| 290 | } | ||
| 291 | #if defined(KEYBOARD_viterbi) | ||
| 292 | send_string_with_delay_P(PSTR(":dfu"), 10); | ||
| 293 | #endif | ||
| 294 | if (temp_mod & MODS_CTRL_MASK || temp_osm & MODS_CTRL_MASK) { send_string_with_delay_P(PSTR(" -j8 --output-sync"), 10); } | ||
| 295 | send_string_with_delay_P(PSTR(SS_TAP(X_ENTER)), 10); | ||
| 296 | set_mods(temp_mod); | ||
| 297 | } | ||
| 298 | break; | ||
| 299 | |||
| 300 | case VRSN: // Prints firmware version | ||
| 301 | if (record->event.pressed) { | ||
| 302 | send_string_with_delay_P(PSTR(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION ", Built on: " QMK_BUILDDATE), MACRO_TIMER); | ||
| 303 | } | ||
| 304 | break; | ||
| 305 | |||
| 306 | // These are a serious of gaming macros. | ||
| 307 | // Only enables for the viterbi, basically, | ||
| 308 | // to save on firmware space, since it's limited. | ||
| 309 | #ifdef MACROS_ENABLED | ||
| 310 | case KC_OVERWATCH: // Toggle's if we hit "ENTER" or "BACKSPACE" to input macros | ||
| 311 | if (record->event.pressed) { userspace_config.is_overwatch ^= 1; eeconfig_update_user(userspace_config.raw); } | ||
| 312 | #ifdef RGBLIGHT_ENABLE | ||
| 313 | userspace_config.is_overwatch ? rgblight_mode_noeeprom(17) : rgblight_mode_noeeprom(18); | ||
| 314 | #endif //RGBLIGHT_ENABLE | ||
| 315 | break; | ||
| 316 | case KC_SALT: | ||
| 317 | return send_game_macro("Salt, salt, salt...", record, false); | ||
| 318 | case KC_MORESALT: | ||
| 319 | return send_game_macro("Please sir, can I have some more salt?!", record, false); | ||
| 320 | case KC_SALTHARD: | ||
| 321 | return send_game_macro("Your salt only makes me harder, and even more aggressive!", record, false); | ||
| 322 | case KC_GOODGAME: | ||
| 323 | return send_game_macro("Good game, everyone!", record, false); | ||
| 324 | case KC_GLHF: | ||
| 325 | return send_game_macro("Good luck, have fun!!!", record, false); | ||
| 326 | case KC_SYMM: | ||
| 327 | return send_game_macro("Left click to win!", record, false); | ||
| 328 | case KC_JUSTGAME: | ||
| 329 | return send_game_macro("It may be a game, but if you don't want to actually try, please go play AI, so that people that actually want to take the game seriously and \"get good\" have a place to do so without trolls like you throwing games.", record, false); | ||
| 330 | case KC_TORB: | ||
| 331 | return send_game_macro("That was positively riveting!", record, false); | ||
| 332 | case KC_AIM: | ||
| 333 | send_game_macro("That aim is absolutely amazing. It's almost like you're a machine!", record, true); | ||
| 334 | return send_game_macro("Wait! That aim is TOO good! You're clearly using an aim hack! CHEATER!", record, false); | ||
| 335 | case KC_C9: | ||
| 336 | return send_game_macro("OMG!!! C9!!!", record, false); | ||
| 337 | case KC_GGEZ: | ||
| 338 | return send_game_macro("That was a fantastic game, though it was a bit easy. Try harder next time!", record, false); | ||
| 339 | #endif // MACROS_ENABLED | ||
| 340 | |||
| 341 | |||
| 342 | case KC_DIABLO_CLEAR: // reset all Diablo timers, disabling them | ||
| 343 | #ifdef TAP_DANCE_ENABLE | ||
| 344 | if (record->event.pressed) { | ||
| 345 | uint8_t dtime; | ||
| 346 | for (dtime = 0; dtime < 4; dtime++) { | ||
| 347 | diablo_key_time[dtime] = diablo_times[0]; | ||
| 348 | } | ||
| 349 | } | ||
| 350 | #endif // TAP_DANCE_ENABLE | ||
| 351 | break; | ||
| 352 | |||
| 353 | |||
| 354 | case KC_CCCV: // One key copy/paste | ||
| 355 | if(record->event.pressed){ | ||
| 356 | copy_paste_timer = timer_read(); | ||
| 357 | } else { | ||
| 358 | if (timer_elapsed(copy_paste_timer) > TAPPING_TERM) { // Hold, copy | ||
| 359 | register_code(KC_LCTL); | ||
| 360 | tap_code(KC_C); | ||
| 361 | unregister_code(KC_LCTL); | ||
| 362 | } else { // Tap, paste | ||
| 363 | register_code(KC_LCTL); | ||
| 364 | tap_code(KC_V); | ||
| 365 | unregister_code(KC_LCTL); | ||
| 366 | } | ||
| 367 | } | ||
| 368 | break; | ||
| 369 | #ifdef UNICODE_ENABLE | ||
| 370 | case UC_FLIP: // (ノಠ痊ಠ)ノ彡┻━┻ | ||
| 371 | if (record->event.pressed) { | ||
| 372 | send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B"); | ||
| 373 | } | ||
| 374 | break; | ||
| 375 | case UC_TABL: // ┬─┬ノ( º _ ºノ) | ||
| 376 | if (record->event.pressed) { | ||
| 377 | send_unicode_hex_string("252C 2500 252C 30CE 0028 0020 00BA 0020 005F 0020 00BA 30CE 0029"); | ||
| 378 | } | ||
| 379 | break; | ||
| 380 | case UC_SHRG: // ¯\_(ツ)_/¯ | ||
| 381 | if (record->event.pressed) { | ||
| 382 | send_unicode_hex_string("00AF 005C 005F 0028 30C4 0029 005F 002F 00AF"); | ||
| 383 | } | ||
| 384 | break; | ||
| 385 | case UC_DISA: // ಠ_ಠ | ||
| 386 | if (record->event.pressed) { | ||
| 387 | send_unicode_hex_string("0CA0 005F 0CA0"); | ||
| 388 | } | ||
| 389 | break; | ||
| 390 | #endif | ||
| 391 | } | ||
| 392 | return process_record_keymap(keycode, record) && | ||
| 393 | #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) | ||
| 394 | process_record_user_rgb(keycode, record) && | ||
| 395 | #endif // RGBLIGHT_ENABLE | ||
| 396 | process_record_secrets(keycode, record); | ||
| 397 | } | 190 | } |
| 398 | 191 | ||
| 399 | |||
| 400 | |||
| 401 | // Runs state check and changes underglow color and animation | ||
| 402 | // on layer change, no matter where the change was initiated | 192 | // on layer change, no matter where the change was initiated |
| 403 | // Then runs keymap's layer change check | 193 | // Then runs keymap's layer change check |
| 404 | uint32_t layer_state_set_user(uint32_t state) { | 194 | uint32_t layer_state_set_user(uint32_t state) { |
| @@ -410,6 +200,12 @@ uint32_t layer_state_set_user(uint32_t state) { | |||
| 410 | } | 200 | } |
| 411 | 201 | ||
| 412 | 202 | ||
| 203 | __attribute__ ((weak)) | ||
| 204 | uint32_t default_layer_state_set_keymap (uint32_t state) { | ||
| 205 | return state; | ||
| 206 | } | ||
| 207 | |||
| 208 | // Runs state check and changes underglow color and animation | ||
| 413 | uint32_t default_layer_state_set_user(uint32_t state) { | 209 | uint32_t default_layer_state_set_user(uint32_t state) { |
| 414 | state = default_layer_state_set_keymap(state); | 210 | state = default_layer_state_set_keymap(state); |
| 415 | #ifdef RGBLIGHT_ENABLE | 211 | #ifdef RGBLIGHT_ENABLE |
| @@ -418,6 +214,8 @@ uint32_t default_layer_state_set_user(uint32_t state) { | |||
| 418 | return state; | 214 | return state; |
| 419 | } | 215 | } |
| 420 | 216 | ||
| 217 | __attribute__ ((weak)) | ||
| 218 | void led_set_keymap(uint8_t usb_led) {} | ||
| 421 | 219 | ||
| 422 | // Any custom LED code goes here. | 220 | // Any custom LED code goes here. |
| 423 | // So far, I only have keyboard specific code, | 221 | // So far, I only have keyboard specific code, |
| @@ -426,6 +224,9 @@ void led_set_user(uint8_t usb_led) { | |||
| 426 | led_set_keymap(usb_led); | 224 | led_set_keymap(usb_led); |
| 427 | } | 225 | } |
| 428 | 226 | ||
| 227 | __attribute__ ((weak)) | ||
| 228 | void eeconfig_init_keymap(void) {} | ||
| 229 | |||
| 429 | void eeconfig_init_user(void) { | 230 | void eeconfig_init_user(void) { |
| 430 | userspace_config.raw = 0; | 231 | userspace_config.raw = 0; |
| 431 | userspace_config.rgb_layer_change = true; | 232 | userspace_config.rgb_layer_change = true; |
