You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

138 lines
3.9 KiB

  1. /**
  2. * Copyright (C) 2021 Jerrell, Jacob <@jjerrell>
  3. *
  4. * This file is part of qmk_firmware.
  5. *
  6. * qmk_firmware is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * qmk_firmware is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with qmk_firmware. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include "jjerrell.h"
  20. __attribute__((weak)) void matrix_scan_keymap(void) {}
  21. __attribute__((weak)) void leader_scan_secrets(void) {}
  22. #ifdef LEADER_ENABLE
  23. LEADER_EXTERNS();
  24. void matrix_scan_leader(void) {
  25. static uint8_t mods = 0;
  26. mods = get_mods();
  27. LEADER_DICTIONARY() {
  28. leading = false;
  29. leader_end();
  30. clear_mods();
  31. // Website Refresh / XCode "Run"
  32. SEQ_ONE_KEY(KC_R) {
  33. SEND_STRING(SS_LGUI("r"));
  34. }
  35. SEQ_TWO_KEYS(KC_B, KC_D) {
  36. send_string_with_delay_P(PSTR(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION " Built at: " QMK_BUILDDATE), TAP_CODE_DELAY);
  37. }
  38. SEQ_TWO_KEYS(KC_L, KC_C) {
  39. send_string_with_delay("/** */", TAP_CODE_DELAY);
  40. wait_ms(TAPPING_TERM);
  41. tap_code(KC_LEFT);
  42. tap_code(KC_LEFT);
  43. tap_code(KC_LEFT);
  44. if (!(mods & MOD_MASK_SHIFT)) {
  45. tap_code(KC_ENT);
  46. }
  47. }
  48. set_mods(mods);
  49. #ifndef NO_SECRETS
  50. leader_scan_secrets();
  51. #endif // !NO_SECRETS
  52. }
  53. }
  54. #endif
  55. static bool is_first_run = true;
  56. void matrix_scan_user(void) {
  57. if (is_first_run) {
  58. is_first_run = false;
  59. startup_user();
  60. }
  61. #ifdef LEADER_ENABLE
  62. matrix_scan_leader();
  63. #endif
  64. matrix_scan_keymap();
  65. }
  66. __attribute__((weak)) layer_state_t layer_state_set_keymap(layer_state_t state) { return state; }
  67. // on layer change, no matter where the change was initiated
  68. // Then runs keymap's layer change check
  69. layer_state_t layer_state_set_user(layer_state_t state) {
  70. if (!is_keyboard_master()) {
  71. return state;
  72. }
  73. state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST);
  74. state = layer_state_set_keymap(state);
  75. #if defined(RGBLIGHT_ENABLE)
  76. state = layer_state_set_rgb_light(state);
  77. #endif // RGBLIGHT_ENABLE
  78. return state;
  79. }
  80. __attribute__((weak)) void dip_switch_update_keymap(uint8_t index, bool active) {}
  81. void dip_switch_update_user(uint8_t index, bool active) {
  82. dip_switch_update_keymap(index, active);
  83. }
  84. __attribute__((weak)) bool music_mask_keymap(uint16_t keycode) { return true; }
  85. bool music_mask_user(uint16_t keycode) {
  86. switch (keycode){
  87. default:
  88. return music_mask_keymap(keycode);
  89. break;
  90. }
  91. }
  92. __attribute__((weak)) layer_state_t default_layer_state_set_keymap(layer_state_t state) { return state; }
  93. // Runs state check and changes underglow color and animation
  94. layer_state_t default_layer_state_set_user(layer_state_t state) {
  95. if (!is_keyboard_master()) {
  96. return state;
  97. }
  98. return default_layer_state_set_keymap(state);
  99. }
  100. #ifdef AUDIO_ENABLE
  101. __attribute__((weak)) void startup_keymap(void) {}
  102. void startup_user(void)
  103. {
  104. wait_ms(TAP_CODE_DELAY); // gets rid of tick
  105. startup_keymap();
  106. }
  107. __attribute__((weak)) void shutdown_keymap(void) {}
  108. void shutdown_user(void)
  109. {
  110. wait_ms(TAP_CODE_DELAY);
  111. stop_all_notes();
  112. shutdown_keymap();
  113. }
  114. __attribute__((weak)) void music_on_keymap(void) {}
  115. void music_on_user(void)
  116. {
  117. music_scale_user();
  118. music_on_keymap();
  119. }
  120. #endif // AUDIO_ENABLE