process_records.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #include "drashna.h"
  2. uint16_t copy_paste_timer;
  3. __attribute__((weak))
  4. bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; }
  5. __attribute__((weak))
  6. bool process_record_secrets(uint16_t keycode, keyrecord_t *record) { return true; }
  7. // Defines actions tor my global custom keycodes. Defined in drashna.h file
  8. // Then runs the _keymap's record handier if not processed here
  9. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  10. // If console is enabled, it will print the matrix position and status of each key pressed
  11. #ifdef KEYLOGGER_ENABLE
  12. # if defined(KEYBOARD_ergodox_ez) || defined(KEYBOARD_keebio_iris_rev2)
  13. xprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.row, record->event.key.col, record->event.pressed);
  14. # else
  15. xprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed);
  16. # endif
  17. #endif // KEYLOGGER_ENABLE
  18. switch (keycode) {
  19. case KC_QWERTY ... KC_WORKMAN:
  20. if (record->event.pressed) {
  21. uint8_t mods = mod_config(get_mods()|get_oneshot_mods());
  22. if (!mods) {
  23. set_single_persistent_default_layer(keycode - KC_QWERTY);
  24. } else if (mods & MOD_MASK_SHIFT) {
  25. set_single_persistent_default_layer(keycode - KC_QWERTY + 4);
  26. } else if (mods & MOD_MASK_CTRL) {
  27. set_single_persistent_default_layer(keycode - KC_QWERTY + 8);
  28. }
  29. }
  30. break;
  31. case KC_MAKE: // Compiles the firmware, and adds the flash command based on keyboard bootloader
  32. if (!record->event.pressed) {
  33. uint8_t temp_mod = mod_config(get_mods());
  34. uint8_t temp_osm = mod_config(get_oneshot_mods());
  35. clear_mods();
  36. clear_oneshot_mods();
  37. send_string_with_delay_P(PSTR("make " QMK_KEYBOARD ":" QMK_KEYMAP), TAP_CODE_DELAY);
  38. #ifndef MAKE_BOOTLOADER
  39. if ((temp_mod | temp_osm) & MOD_MASK_SHIFT)
  40. #endif
  41. {
  42. send_string_with_delay_P(PSTR(":flash"), TAP_CODE_DELAY);
  43. }
  44. if ((temp_mod | temp_osm) & MOD_MASK_CTRL) {
  45. send_string_with_delay_P(PSTR(" -j8 --output-sync"), TAP_CODE_DELAY);
  46. }
  47. #ifdef RGB_MATRIX_SPLIT_RIGHT
  48. send_string_with_delay_P(PSTR(" RGB_MATRIX_SPLIT_RIGHT=yes"), TAP_CODE_DELAY);
  49. # ifndef OLED_DRIVER_ENABLE
  50. send_string_with_delay_P(PSTR(" OLED_DRIVER_ENABLE=no"), TAP_CODE_DELAY);
  51. # endif
  52. #endif
  53. send_string_with_delay_P(PSTR(SS_TAP(X_ENTER)), TAP_CODE_DELAY);
  54. }
  55. break;
  56. case VRSN: // Prints firmware version
  57. if (record->event.pressed) {
  58. send_string_with_delay_P(PSTR(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION ", Built on: " QMK_BUILDDATE), TAP_CODE_DELAY);
  59. }
  60. break;
  61. case KC_DIABLO_CLEAR: // reset all Diablo timers, disabling them
  62. #ifdef TAP_DANCE_ENABLE
  63. if (record->event.pressed) {
  64. for (uint8_t index = 0; index < 4; index++) {
  65. diablo_timer[index].key_interval = 0;
  66. }
  67. }
  68. #endif // TAP_DANCE_ENABLE
  69. break;
  70. case KC_CCCV: // One key copy/paste
  71. if (record->event.pressed) {
  72. copy_paste_timer = timer_read();
  73. } else {
  74. if (timer_elapsed(copy_paste_timer) > TAPPING_TERM) { // Hold, copy
  75. register_code(KC_LCTL);
  76. tap_code(KC_C);
  77. unregister_code(KC_LCTL);
  78. } else { // Tap, paste
  79. register_code(KC_LCTL);
  80. tap_code(KC_V);
  81. unregister_code(KC_LCTL);
  82. }
  83. }
  84. break;
  85. #ifdef UNICODE_ENABLE
  86. case UC_FLIP: // (ノಠ痊ಠ)ノ彡┻━┻
  87. if (record->event.pressed) {
  88. send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B");
  89. }
  90. break;
  91. case UC_TABL: // ┬─┬ノ( º _ ºノ)
  92. if (record->event.pressed) {
  93. send_unicode_hex_string("252C 2500 252C 30CE 0028 0020 00BA 0020 005F 0020 00BA 30CE 0029");
  94. }
  95. break;
  96. case UC_SHRG: // ¯\_(ツ)_/¯
  97. if (record->event.pressed) {
  98. send_unicode_hex_string("00AF 005C 005F 0028 30C4 0029 005F 002F 00AF");
  99. }
  100. break;
  101. case UC_DISA: // ಠ_ಠ
  102. if (record->event.pressed) {
  103. send_unicode_hex_string("0CA0 005F 0CA0");
  104. }
  105. break;
  106. #endif
  107. }
  108. return process_record_keymap(keycode, record) &&
  109. #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
  110. process_record_user_rgb(keycode, record) &&
  111. #endif // RGBLIGHT_ENABLE
  112. process_record_secrets(keycode, record);
  113. }