quantum.h 6.0 KB

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