quantum.h 5.7 KB

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