quantum.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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. #include "platform_deps.h"
  18. #include "wait.h"
  19. #include "matrix.h"
  20. #include "keymap.h"
  21. #ifdef BACKLIGHT_ENABLE
  22. # include "backlight.h"
  23. #endif
  24. #ifdef LED_MATRIX_ENABLE
  25. # include "led_matrix.h"
  26. #endif
  27. #if defined(RGBLIGHT_ENABLE)
  28. # include "rgblight.h"
  29. #endif
  30. #ifdef RGB_MATRIX_ENABLE
  31. # include "rgb_matrix.h"
  32. #endif
  33. #include "action_layer.h"
  34. #include "eeconfig.h"
  35. #include "bootloader.h"
  36. #include "bootmagic.h"
  37. #include "timer.h"
  38. #include "sync_timer.h"
  39. #include "config_common.h"
  40. #include "gpio.h"
  41. #include "atomic_util.h"
  42. #include "led.h"
  43. #include "action_util.h"
  44. #include "action_tapping.h"
  45. #include "print.h"
  46. #include "suspend.h"
  47. #include <stddef.h>
  48. #include <stdlib.h>
  49. #ifdef DEFERRED_EXEC_ENABLE
  50. # include "deferred_exec.h"
  51. #endif
  52. extern layer_state_t default_layer_state;
  53. #ifndef NO_ACTION_LAYER
  54. extern layer_state_t layer_state;
  55. #endif
  56. #if defined(SEQUENCER_ENABLE)
  57. # include "sequencer.h"
  58. # include "process_sequencer.h"
  59. #endif
  60. #if defined(MIDI_ENABLE) && defined(MIDI_ADVANCED)
  61. # include "process_midi.h"
  62. #endif
  63. #ifdef AUDIO_ENABLE
  64. # include "audio.h"
  65. # include "process_audio.h"
  66. # ifdef AUDIO_CLICKY
  67. # include "process_clicky.h"
  68. # endif
  69. #endif
  70. #ifdef STENO_ENABLE
  71. # include "process_steno.h"
  72. #endif
  73. #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
  74. # include "process_music.h"
  75. #endif
  76. #if defined(BACKLIGHT_ENABLE) || defined(LED_MATRIX_ENABLE)
  77. # include "process_backlight.h"
  78. #endif
  79. #ifdef LEADER_ENABLE
  80. # include "process_leader.h"
  81. #endif
  82. #ifdef UNICODE_ENABLE
  83. # include "process_unicode.h"
  84. #endif
  85. #ifdef UCIS_ENABLE
  86. # include "process_ucis.h"
  87. #endif
  88. #ifdef UNICODEMAP_ENABLE
  89. # include "process_unicodemap.h"
  90. #endif
  91. #ifdef UNICODE_COMMON_ENABLE
  92. # include "unicode.h"
  93. # include "process_unicode_common.h"
  94. #endif
  95. #ifdef KEY_OVERRIDE_ENABLE
  96. # include "process_key_override.h"
  97. #endif
  98. #ifdef TAP_DANCE_ENABLE
  99. # include "process_tap_dance.h"
  100. #endif
  101. #ifdef AUTO_SHIFT_ENABLE
  102. # include "process_auto_shift.h"
  103. #endif
  104. #ifdef DYNAMIC_TAPPING_TERM_ENABLE
  105. # include "process_dynamic_tapping_term.h"
  106. #endif
  107. #ifdef COMBO_ENABLE
  108. # include "process_combo.h"
  109. #endif
  110. #ifdef KEY_LOCK_ENABLE
  111. # include "process_key_lock.h"
  112. #endif
  113. #ifdef SPACE_CADET_ENABLE
  114. # include "process_space_cadet.h"
  115. #endif
  116. #ifdef MAGIC_KEYCODE_ENABLE
  117. # include "process_magic.h"
  118. #endif
  119. #ifdef JOYSTICK_ENABLE
  120. # include "process_joystick.h"
  121. #endif
  122. #ifdef PROGRAMMABLE_BUTTON_ENABLE
  123. # include "process_programmable_button.h"
  124. #endif
  125. #ifdef GRAVE_ESC_ENABLE
  126. # include "process_grave_esc.h"
  127. #endif
  128. #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
  129. # include "process_rgb.h"
  130. #endif
  131. #ifdef HD44780_ENABLE
  132. # include "hd44780.h"
  133. #endif
  134. #ifdef SEND_STRING_ENABLE
  135. # include "send_string.h"
  136. #endif
  137. #ifdef HAPTIC_ENABLE
  138. # include "haptic.h"
  139. # include "process_haptic.h"
  140. #endif
  141. #ifdef OLED_ENABLE
  142. # include "oled_driver.h"
  143. #endif
  144. #ifdef ST7565_ENABLE
  145. # include "st7565.h"
  146. #endif
  147. #ifdef QUANTUM_PAINTER_ENABLE
  148. # include "qp.h"
  149. #endif
  150. #ifdef DIP_SWITCH_ENABLE
  151. # include "dip_switch.h"
  152. #endif
  153. #ifdef DYNAMIC_MACRO_ENABLE
  154. # include "process_dynamic_macro.h"
  155. #endif
  156. #ifdef SECURE_ENABLE
  157. # include "secure.h"
  158. # include "process_secure.h"
  159. #endif
  160. #ifdef DYNAMIC_KEYMAP_ENABLE
  161. # include "dynamic_keymap.h"
  162. #endif
  163. #ifdef JOYSTICK_ENABLE
  164. # include "joystick.h"
  165. #endif
  166. #ifdef DIGITIZER_ENABLE
  167. # include "digitizer.h"
  168. #endif
  169. #ifdef VIA_ENABLE
  170. # include "via.h"
  171. #endif
  172. #ifdef WPM_ENABLE
  173. # include "wpm.h"
  174. #endif
  175. #ifdef USBPD_ENABLE
  176. # include "usbpd.h"
  177. #endif
  178. #ifdef ENCODER_ENABLE
  179. # include "encoder.h"
  180. #endif
  181. #ifdef POINTING_DEVICE_ENABLE
  182. # include "pointing_device.h"
  183. #endif
  184. #ifdef CAPS_WORD_ENABLE
  185. # include "caps_word.h"
  186. # include "process_caps_word.h"
  187. #endif
  188. #ifdef AUTOCORRECT_ENABLE
  189. # include "process_autocorrect.h"
  190. #endif
  191. // For tri-layer
  192. void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3);
  193. layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_t layer2, uint8_t layer3);
  194. void set_single_persistent_default_layer(uint8_t default_layer);
  195. #define IS_LAYER_ON(layer) layer_state_is(layer)
  196. #define IS_LAYER_OFF(layer) !layer_state_is(layer)
  197. #define IS_LAYER_ON_STATE(state, layer) layer_state_cmp(state, layer)
  198. #define IS_LAYER_OFF_STATE(state, layer) !layer_state_cmp(state, layer)
  199. uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache);
  200. uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache);
  201. bool process_action_kb(keyrecord_t *record);
  202. bool process_record_kb(uint16_t keycode, keyrecord_t *record);
  203. bool process_record_user(uint16_t keycode, keyrecord_t *record);
  204. void post_process_record_kb(uint16_t keycode, keyrecord_t *record);
  205. void post_process_record_user(uint16_t keycode, keyrecord_t *record);
  206. void reset_keyboard(void);
  207. void soft_reset_keyboard(void);
  208. void startup_user(void);
  209. void shutdown_user(void);
  210. void register_code16(uint16_t code);
  211. void unregister_code16(uint16_t code);
  212. void tap_code16(uint16_t code);
  213. void tap_code16_delay(uint16_t code, uint16_t delay);
  214. const char *get_numeric_str(char *buf, size_t buf_len, uint32_t curr_num, char curr_pad);
  215. const char *get_u8_str(uint8_t curr_num, char curr_pad);
  216. const char *get_u16_str(uint16_t curr_num, char curr_pad);