process_records.c 4.8 KB

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