jjerrell.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. void leader_end_user(void) {
  24. static uint8_t mods = 0;
  25. mods = get_mods();
  26. clear_mods();
  27. // Website Refresh / XCode "Run"
  28. if (leader_sequence_one_key(KC_R)) {
  29. SEND_STRING(SS_LGUI("r"));
  30. }
  31. if (leader_sequence_two_keys(KC_B, KC_D)) {
  32. send_string_with_delay_P(PSTR(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION " Built at: " QMK_BUILDDATE), TAP_CODE_DELAY);
  33. }
  34. if (leader_sequence_two_keys(KC_L, KC_C)) {
  35. send_string_with_delay("/** */", TAP_CODE_DELAY);
  36. wait_ms(TAPPING_TERM);
  37. tap_code(KC_LEFT);
  38. tap_code(KC_LEFT);
  39. tap_code(KC_LEFT);
  40. if (!(mods & MOD_MASK_SHIFT)) {
  41. tap_code(KC_ENT);
  42. }
  43. }
  44. set_mods(mods);
  45. #ifndef NO_SECRETS
  46. leader_scan_secrets();
  47. #endif // !NO_SECRETS
  48. }
  49. #endif
  50. static bool is_first_run = true;
  51. void matrix_scan_user(void) {
  52. if (is_first_run) {
  53. is_first_run = false;
  54. startup_user();
  55. }
  56. matrix_scan_keymap();
  57. }
  58. __attribute__((weak)) layer_state_t layer_state_set_keymap(layer_state_t state) { return state; }
  59. // on layer change, no matter where the change was initiated
  60. // Then runs keymap's layer change check
  61. layer_state_t layer_state_set_user(layer_state_t state) {
  62. if (!is_keyboard_master()) {
  63. return state;
  64. }
  65. state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST);
  66. state = layer_state_set_keymap(state);
  67. #if defined(RGBLIGHT_ENABLE)
  68. state = layer_state_set_rgb_light(state);
  69. #endif // RGBLIGHT_ENABLE
  70. return state;
  71. }
  72. __attribute__((weak)) void dip_switch_update_keymap(uint8_t index, bool active) {}
  73. void dip_switch_update_user(uint8_t index, bool active) {
  74. dip_switch_update_keymap(index, active);
  75. }
  76. __attribute__((weak)) bool music_mask_keymap(uint16_t keycode) { return true; }
  77. bool music_mask_user(uint16_t keycode) {
  78. switch (keycode){
  79. default:
  80. return music_mask_keymap(keycode);
  81. break;
  82. }
  83. }
  84. __attribute__((weak)) layer_state_t default_layer_state_set_keymap(layer_state_t state) { return state; }
  85. // Runs state check and changes underglow color and animation
  86. layer_state_t default_layer_state_set_user(layer_state_t state) {
  87. if (!is_keyboard_master()) {
  88. return state;
  89. }
  90. return default_layer_state_set_keymap(state);
  91. }
  92. #ifdef AUDIO_ENABLE
  93. __attribute__((weak)) void startup_keymap(void) {}
  94. void startup_user(void)
  95. {
  96. wait_ms(TAP_CODE_DELAY); // gets rid of tick
  97. startup_keymap();
  98. }
  99. __attribute__((weak)) void shutdown_keymap(void) {}
  100. void shutdown_user(void)
  101. {
  102. wait_ms(TAP_CODE_DELAY);
  103. stop_all_notes();
  104. shutdown_keymap();
  105. }
  106. __attribute__((weak)) void music_on_keymap(void) {}
  107. void music_on_user(void)
  108. {
  109. music_scale_user();
  110. music_on_keymap();
  111. }
  112. #endif // AUDIO_ENABLE