kuchosauronad0.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*
  2. Copyright 2019 Andre Poley <andre.poley@mailbox.org>
  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 "quantum.h"
  15. #include "kuchosauronad0.h"
  16. userspace_config_t userspace_config;
  17. #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE))
  18. #define KUCHOSAURONAD0_UNICODE_MODE UC_WINC
  19. #else
  20. // set to 2 for UC_WIN, set to 4 for UC_WINC
  21. #define KUCHOSAURONAD0_UNICODE_MODE 2
  22. #endif
  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. // Call user matrix init, set default RGB colors and then
  30. // call the keymap's init function
  31. void matrix_init_user(void) {
  32. userspace_config.raw = eeconfig_read_user();
  33. #ifdef BOOTLOADER_CATERINA
  34. DDRD &= ~(1<<5);
  35. PORTD &= ~(1<<5);
  36. DDRB &= ~(1<<0);
  37. PORTB &= ~(1<<0);
  38. #endif
  39. #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE))
  40. set_unicode_input_mode(KUCHOSAURONAD0_UNICODE_MODE);
  41. get_unicode_input_mode();
  42. #endif //UNICODE_ENABLE
  43. matrix_init_keymap();
  44. }
  45. __attribute__((weak))
  46. void keyboard_post_init_keymap(void){ }
  47. void keyboard_post_init_user(void){
  48. #ifdef RGBLIGHT_ENABLE
  49. keyboard_post_init_rgb();
  50. #endif
  51. keyboard_post_init_keymap();
  52. }
  53. __attribute__ ((weak))
  54. void shutdown_keymap(void) {}
  55. void shutdown_user (void) {
  56. #ifdef RGBLIGHT_ENABLE
  57. rgblight_enable_noeeprom();
  58. rgblight_mode_noeeprom(1);
  59. rgblight_setrgb_red();
  60. #endif // RGBLIGHT_ENABLE
  61. #ifdef RGB_MATRIX_ENABLE
  62. // uint16_t timer_start = timer_read();
  63. // rgb_matrix_set_color_all( 0xFF, 0x00, 0x00 );
  64. // while(timer_elapsed(timer_start) < 250) { wait_ms(1); }
  65. #endif //RGB_MATRIX_ENABLE
  66. shutdown_keymap();
  67. }
  68. __attribute__ ((weak))
  69. void suspend_power_down_keymap(void) {}
  70. void suspend_power_down_user(void) {
  71. suspend_power_down_keymap();
  72. }
  73. __attribute__ ((weak))
  74. void suspend_wakeup_init_keymap(void) {}
  75. void suspend_wakeup_init_user(void) {
  76. suspend_wakeup_init_keymap();
  77. }
  78. __attribute__ ((weak))
  79. void matrix_scan_keymap(void) {}
  80. __attribute__ ((weak))
  81. void matrix_scan_user(void){
  82. static bool has_ran_yet;
  83. if (!has_ran_yet) {
  84. has_ran_yet = true;
  85. startup_user();
  86. }
  87. #ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code.
  88. // run_diablo_macro_check();
  89. #endif // TAP_DANCE_ENABLE
  90. #ifdef RGBLIGHT_ENABLE
  91. matrix_scan_rgb();
  92. #endif // RGBLIGHT_ENABLE
  93. matrix_scan_keymap();
  94. }
  95. __attribute__ ((weak))
  96. uint32_t layer_state_set_keymap (uint32_t state) {
  97. return state;
  98. }
  99. // on layer change, no matter where the change was initiated
  100. // Then runs keymap's layer change check
  101. uint32_t layer_state_set_user(uint32_t state) {
  102. state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST);
  103. #ifdef RGBLIGHT_ENABLE
  104. state = layer_state_set_rgb(state);
  105. #endif // RGBLIGHT_ENABLE
  106. return layer_state_set_keymap (state);
  107. }
  108. __attribute__ ((weak))
  109. uint32_t default_layer_state_set_keymap (uint32_t state) {
  110. return state;
  111. }
  112. // Runs state check and changes underglow color and animation
  113. uint32_t default_layer_state_set_user(uint32_t state) {
  114. state = default_layer_state_set_keymap(state);
  115. #if 0
  116. #ifdef RGBLIGHT_ENABLE
  117. state = default_layer_state_set_rgb(state);
  118. #endif // RGBLIGHT_ENABLE
  119. #endif
  120. return state;
  121. }
  122. __attribute__ ((weak))
  123. void led_set_keymap(uint8_t usb_led) {}
  124. // Any custom LED code goes here.
  125. // So far, I only have keyboard specific code,
  126. // So nothing goes here.
  127. void led_set_user(uint8_t usb_led) {
  128. led_set_keymap(usb_led);
  129. }
  130. __attribute__ ((weak))
  131. void eeconfig_init_keymap(void) {}
  132. void eeconfig_init_user(void) {
  133. userspace_config.raw = 0;
  134. userspace_config.rgb_layer_change = true;
  135. eeconfig_update_user(userspace_config.raw);
  136. #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE))
  137. set_unicode_input_mode(KUCHOSAURONAD0_UNICODE_MODE);
  138. get_unicode_input_mode();
  139. #else
  140. eeprom_update_byte(EECONFIG_UNICODEMODE, KUCHOSAURONAD0_UNICODE_MODE);
  141. #endif
  142. }
  143. // TMUX stuff
  144. void tmux_prefix(void) {
  145. register_code(KC_LCTL);
  146. tap_code(KC_B);
  147. unregister_code(KC_LCTL);
  148. }
  149. void tmux_pane_last(void) {
  150. tmux_prefix();
  151. tap_code(KC_SCLN);
  152. }
  153. void tmux_pane_switch_repeat(void) {
  154. tmux_pane_last();
  155. tap_code(KC_UP);
  156. tap_code(KC_ENT);
  157. tmux_pane_last();
  158. }
  159. /* vi: ft=c:tw=80:sw=2:ts=2:sts=2:et */