quantum.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /* Copyright 2016-2018 Erez Zukerman, Jack Humbert, Yiancar
  2. *
  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. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #pragma once
  17. #if defined(__AVR__)
  18. # include <avr/pgmspace.h>
  19. # include <avr/io.h>
  20. # include <avr/interrupt.h>
  21. #endif
  22. #if defined(PROTOCOL_CHIBIOS)
  23. # include <hal.h>
  24. # include "chibios_config.h"
  25. #endif
  26. #include "wait.h"
  27. #include "matrix.h"
  28. #include "keymap.h"
  29. #ifdef BACKLIGHT_ENABLE
  30. # include "backlight.h"
  31. #endif
  32. #ifdef LED_MATRIX_ENABLE
  33. # include "led_matrix.h"
  34. #endif
  35. #if defined(RGBLIGHT_ENABLE)
  36. # include "rgblight.h"
  37. #elif defined(RGB_MATRIX_ENABLE)
  38. // Dummy define RGBLIGHT_MODE_xxxx
  39. # define RGBLIGHT_H_DUMMY_DEFINE
  40. # include "rgblight.h"
  41. #endif
  42. #ifdef RGB_MATRIX_ENABLE
  43. # include "rgb_matrix.h"
  44. #endif
  45. #include "action_layer.h"
  46. #include "eeconfig.h"
  47. #include "bootloader.h"
  48. #include "bootmagic.h"
  49. #include "timer.h"
  50. #include "sync_timer.h"
  51. #include "config_common.h"
  52. #include "gpio.h"
  53. #include "atomic_util.h"
  54. #include "led.h"
  55. #include "action_util.h"
  56. #include "action_tapping.h"
  57. #include "print.h"
  58. #include "send_string.h"
  59. #include "suspend.h"
  60. #include <stddef.h>
  61. #include <stdlib.h>
  62. extern layer_state_t default_layer_state;
  63. #ifndef NO_ACTION_LAYER
  64. extern layer_state_t layer_state;
  65. #endif
  66. #if defined(SEQUENCER_ENABLE)
  67. # include "sequencer.h"
  68. # include "process_sequencer.h"
  69. #endif
  70. #if defined(MIDI_ENABLE) && defined(MIDI_ADVANCED)
  71. # include "process_midi.h"
  72. #endif
  73. #ifdef AUDIO_ENABLE
  74. # include "audio.h"
  75. # include "process_audio.h"
  76. # ifdef AUDIO_CLICKY
  77. # include "process_clicky.h"
  78. # endif
  79. #endif
  80. #ifdef STENO_ENABLE
  81. # include "process_steno.h"
  82. #endif
  83. #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
  84. # include "process_music.h"
  85. #endif
  86. #if defined(BACKLIGHT_ENABLE) || defined(LED_MATRIX_ENABLE)
  87. # include "process_backlight.h"
  88. #endif
  89. #ifdef LEADER_ENABLE
  90. # include "process_leader.h"
  91. #endif
  92. #ifdef UNICODE_ENABLE
  93. # include "process_unicode.h"
  94. #endif
  95. #ifdef UCIS_ENABLE
  96. # include "process_ucis.h"
  97. #endif
  98. #ifdef UNICODEMAP_ENABLE
  99. # include "process_unicodemap.h"
  100. #endif
  101. #ifdef KEY_OVERRIDE_ENABLE
  102. # include "process_key_override.h"
  103. #endif
  104. #ifdef TAP_DANCE_ENABLE
  105. # include "process_tap_dance.h"
  106. #endif
  107. #ifdef PRINTING_ENABLE
  108. # include "process_printer.h"
  109. #endif
  110. #ifdef AUTO_SHIFT_ENABLE
  111. # include "process_auto_shift.h"
  112. #endif
  113. #ifdef COMBO_ENABLE
  114. # include "process_combo.h"
  115. #endif
  116. #ifdef KEY_LOCK_ENABLE
  117. # include "process_key_lock.h"
  118. #endif
  119. #ifdef TERMINAL_ENABLE
  120. # include "process_terminal.h"
  121. #else
  122. # include "process_terminal_nop.h"
  123. #endif
  124. #ifdef SPACE_CADET_ENABLE
  125. # include "process_space_cadet.h"
  126. #endif
  127. #ifdef MAGIC_KEYCODE_ENABLE
  128. # include "process_magic.h"
  129. #endif
  130. #ifdef JOYSTICK_ENABLE
  131. # include "process_joystick.h"
  132. #endif
  133. #ifdef GRAVE_ESC_ENABLE
  134. # include "process_grave_esc.h"
  135. #endif
  136. #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
  137. # include "process_rgb.h"
  138. #endif
  139. #ifdef HD44780_ENABLE
  140. # include "hd44780.h"
  141. #endif
  142. #ifdef HAPTIC_ENABLE
  143. # include "haptic.h"
  144. #endif
  145. #ifdef OLED_DRIVER_ENABLE
  146. # include "oled_driver.h"
  147. #endif
  148. #ifdef ST7565_ENABLE
  149. # include "st7565.h"
  150. #endif
  151. #ifdef DIP_SWITCH_ENABLE
  152. # include "dip_switch.h"
  153. #endif
  154. #ifdef DYNAMIC_MACRO_ENABLE
  155. # include "process_dynamic_macro.h"
  156. #endif
  157. #ifdef DYNAMIC_KEYMAP_ENABLE
  158. # include "dynamic_keymap.h"
  159. #endif
  160. #ifdef VIA_ENABLE
  161. # include "via.h"
  162. #endif
  163. #ifdef WPM_ENABLE
  164. # include "wpm.h"
  165. #endif
  166. #ifdef USBPD_ENABLE
  167. # include "usbpd.h"
  168. #endif
  169. #ifdef ENCODER_ENABLE
  170. # include "encoder.h"
  171. #endif
  172. // For tri-layer
  173. void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3);
  174. layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_t layer2, uint8_t layer3);
  175. void set_single_persistent_default_layer(uint8_t default_layer);
  176. #define IS_LAYER_ON(layer) layer_state_is(layer)
  177. #define IS_LAYER_OFF(layer) !layer_state_is(layer)
  178. #define IS_LAYER_ON_STATE(state, layer) layer_state_cmp(state, layer)
  179. #define IS_LAYER_OFF_STATE(state, layer) !layer_state_cmp(state, layer)
  180. void matrix_init_kb(void);
  181. void matrix_scan_kb(void);
  182. void matrix_init_user(void);
  183. void matrix_scan_user(void);
  184. uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache);
  185. uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache);
  186. bool process_action_kb(keyrecord_t *record);
  187. bool process_record_kb(uint16_t keycode, keyrecord_t *record);
  188. bool process_record_user(uint16_t keycode, keyrecord_t *record);
  189. void post_process_record_kb(uint16_t keycode, keyrecord_t *record);
  190. void post_process_record_user(uint16_t keycode, keyrecord_t *record);
  191. void reset_keyboard(void);
  192. void startup_user(void);
  193. void shutdown_user(void);
  194. void register_code16(uint16_t code);
  195. void unregister_code16(uint16_t code);
  196. void tap_code16(uint16_t code);
  197. void led_set_user(uint8_t usb_led);
  198. void led_set_kb(uint8_t usb_led);
  199. bool led_update_user(led_t led_state);
  200. bool led_update_kb(led_t led_state);
  201. void api_send_unicode(uint32_t unicode);