bocaj.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /*
  2. Copyright 2018 Jacob Jerrell <jacob.jerrell@gmail.com> @JacobJerrell
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #include "bocaj.h"
  15. userspace_config_t userspace_config;
  16. #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE))
  17. #define BOCAJ_UNICODE_MODE UC_OSX
  18. #else
  19. // set to 2 for UC_WIN, set to 4 for UC_WINC
  20. #define BOCAJ_UNICODE_MODE 2
  21. #endif
  22. void tap(uint16_t keycode){ register_code(keycode); unregister_code(keycode); };
  23. // Add reconfigurable functions here, for keymap customization
  24. // This allows for a global, userspace functions, and continued
  25. // customization of the keymap. Use _keymap instead of _user
  26. // functions in the keymaps
  27. __attribute__ ((weak))
  28. void matrix_init_keymap(void) {}
  29. __attribute__ ((weak))
  30. void startup_keymap(void) {}
  31. __attribute__ ((weak))
  32. void suspend_power_down_keymap(void) {}
  33. __attribute__ ((weak))
  34. void suspend_wakeup_init_keymap(void) {}
  35. __attribute__ ((weak))
  36. void matrix_scan_keymap(void) {}
  37. __attribute__ ((weak))
  38. bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
  39. return true;
  40. }
  41. __attribute__ ((weak))
  42. void matrix_scan_secrets(void) {}
  43. __attribute__ ((weak))
  44. uint32_t layer_state_set_keymap (uint32_t state) {
  45. return state;
  46. }
  47. __attribute__ ((weak))
  48. uint32_t default_layer_state_set_keymap (uint32_t state) {
  49. return state;
  50. }
  51. __attribute__ ((weak))
  52. void led_set_keymap(uint8_t usb_led) {}
  53. // Call user matrix init, set default RGB colors and then
  54. // call the keymap's init function
  55. void matrix_init_user(void) {
  56. userspace_config.raw = eeconfig_read_user();
  57. #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE))
  58. set_unicode_input_mode(BOCAJ_UNICODE_MODE);
  59. get_unicode_input_mode();
  60. #endif //UNICODE_ENABLE
  61. matrix_init_keymap();
  62. }
  63. void startup_user (void) {
  64. startup_keymap();
  65. }
  66. void suspend_power_down_user(void)
  67. {
  68. suspend_power_down_keymap();
  69. }
  70. void suspend_wakeup_init_user(void)
  71. {
  72. suspend_wakeup_init_keymap();
  73. #ifdef KEYBOARD_ergodox_ez
  74. wait_ms(10);
  75. #endif
  76. }
  77. void eeconfig_init_user(void) {
  78. userspace_config.raw = 0;
  79. eeconfig_update_user(userspace_config.raw);
  80. #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE))
  81. set_unicode_input_mode(BOCAJ_UNICODE_MODE);
  82. get_unicode_input_mode();
  83. #else
  84. eeprom_update_byte(EECONFIG_UNICODEMODE, BOCAJ_UNICODE_MODE);
  85. #endif
  86. }
  87. LEADER_EXTERNS();
  88. // No global matrix scan code, so just run keymap's matrix
  89. // scan function
  90. void matrix_scan_user(void) {
  91. static bool has_ran_yet;
  92. if (!has_ran_yet) {
  93. has_ran_yet = true;
  94. startup_user();
  95. }
  96. LEADER_DICTIONARY() {
  97. leading = false;
  98. leader_end();
  99. // Mac Save (Leader -> s)
  100. SEQ_ONE_KEY(KC_S) {
  101. SEND_STRING(SS_LGUI("s"));
  102. }
  103. // Mac copy line down (Leader -> d, d)
  104. SEQ_TWO_KEYS(KC_D, KC_D) {
  105. register_code(KC_LSHIFT);
  106. register_code(KC_HOME);
  107. unregister_code(KC_HOME);
  108. unregister_code(KC_LSHIFT);
  109. SEND_STRING(SS_LGUI("c"));
  110. tap(KC_END);
  111. tap(KC_ENTER);
  112. SEND_STRING(SS_LGUI("v"));
  113. }
  114. // Mac copy line up (Leader -> u, u)
  115. SEQ_TWO_KEYS(KC_U, KC_U) {
  116. register_code(KC_LSHIFT);
  117. register_code(KC_HOME);
  118. unregister_code(KC_HOME);
  119. unregister_code(KC_LSHIFT);
  120. SEND_STRING(SS_LGUI("c"));
  121. tap(KC_UP);
  122. tap(KC_END);
  123. tap(KC_ENTER);
  124. SEND_STRING(SS_LGUI("v"));
  125. }
  126. // Mac VS Debug
  127. SEQ_ONE_KEY(KC_D) {
  128. tap(KC_F5);
  129. }
  130. // Mac VS Stop Debug
  131. SEQ_TWO_KEYS(KC_S, KC_D) {
  132. register_code(KC_LSHIFT);
  133. tap(KC_F5);
  134. unregister_code(KC_LSHIFT);
  135. }
  136. // Start Diablo 3
  137. SEQ_ONE_KEY(KC_3) {
  138. SEND_STRING(SS_LCTRL(" "));
  139. SEND_STRING("Diablo");
  140. tap(KC_ENTER);
  141. }
  142. SEQ_ONE_KEY(KC_B) {
  143. SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION " ");
  144. tap(KC_ENTER);
  145. SEND_STRING ("Built at: " QMK_BUILDDATE);
  146. }
  147. #ifndef NO_SECRETS
  148. matrix_scan_secrets();
  149. #endif // !NO_SECRETS
  150. }
  151. #ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code.
  152. run_diablo_macro_check();
  153. #endif // TAP_DANCE_ENABLE
  154. matrix_scan_keymap();
  155. }