quantum.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /* Copyright 2016-2017 Erez Zukerman, Jack Humbert
  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. #ifndef QUANTUM_H
  17. #define QUANTUM_H
  18. #if defined(__AVR__)
  19. #include <avr/pgmspace.h>
  20. #include <avr/io.h>
  21. #include <avr/interrupt.h>
  22. #endif
  23. #include "wait.h"
  24. #include "matrix.h"
  25. #include "keymap.h"
  26. #ifdef BACKLIGHT_ENABLE
  27. #include "backlight.h"
  28. #endif
  29. #if !defined(RGBLIGHT_ENABLE) && !defined(RGB_MATRIX_ENABLE)
  30. #include "rgb.h"
  31. #endif
  32. #ifdef RGBLIGHT_ENABLE
  33. #include "rgblight.h"
  34. #endif
  35. #ifdef SPLIT_KEYBOARD
  36. #include "split_flags.h"
  37. #endif
  38. #ifdef RGB_MATRIX_ENABLE
  39. #include "rgb_matrix.h"
  40. #endif
  41. #include "action_layer.h"
  42. #include "eeconfig.h"
  43. #include <stddef.h>
  44. #include "bootloader.h"
  45. #include "timer.h"
  46. #include "config_common.h"
  47. #include "led.h"
  48. #include "action_util.h"
  49. #include <stdlib.h>
  50. #include "print.h"
  51. #include "send_string_keycodes.h"
  52. #include "suspend.h"
  53. extern uint32_t default_layer_state;
  54. #ifndef NO_ACTION_LAYER
  55. extern uint32_t layer_state;
  56. #endif
  57. #ifdef MIDI_ENABLE
  58. #ifdef MIDI_ADVANCED
  59. #include "process_midi.h"
  60. #endif
  61. #endif // MIDI_ENABLE
  62. #ifdef AUDIO_ENABLE
  63. #include "audio.h"
  64. #include "process_audio.h"
  65. #ifdef AUDIO_CLICKY
  66. #include "process_clicky.h"
  67. #endif // AUDIO_CLICKY
  68. #endif
  69. #ifdef STENO_ENABLE
  70. #include "process_steno.h"
  71. #endif
  72. #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
  73. #include "process_music.h"
  74. #endif
  75. #ifndef DISABLE_LEADER
  76. #include "process_leader.h"
  77. #endif
  78. #define DISABLE_CHORDING
  79. #ifndef DISABLE_CHORDING
  80. #include "process_chording.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. #include "process_tap_dance.h"
  92. #ifdef PRINTING_ENABLE
  93. #include "process_printer.h"
  94. #endif
  95. #ifdef AUTO_SHIFT_ENABLE
  96. #include "process_auto_shift.h"
  97. #endif
  98. #ifdef COMBO_ENABLE
  99. #include "process_combo.h"
  100. #endif
  101. #ifdef KEY_LOCK_ENABLE
  102. #include "process_key_lock.h"
  103. #endif
  104. #ifdef TERMINAL_ENABLE
  105. #include "process_terminal.h"
  106. #else
  107. #include "process_terminal_nop.h"
  108. #endif
  109. #ifdef HD44780_ENABLE
  110. #include "hd44780.h"
  111. #endif
  112. #define STRINGIZE(z) #z
  113. #define ADD_SLASH_X(y) STRINGIZE(\x ## y)
  114. #define SYMBOL_STR(x) ADD_SLASH_X(x)
  115. #define SS_TAP(keycode) "\1" SYMBOL_STR(keycode)
  116. #define SS_DOWN(keycode) "\2" SYMBOL_STR(keycode)
  117. #define SS_UP(keycode) "\3" SYMBOL_STR(keycode)
  118. #define SS_LCTRL(string) SS_DOWN(X_LCTRL) string SS_UP(X_LCTRL)
  119. #define SS_LGUI(string) SS_DOWN(X_LGUI) string SS_UP(X_LGUI)
  120. #define SS_LCMD(string) SS_LGUI(string)
  121. #define SS_LWIN(string) SS_LGUI(string)
  122. #define SS_LALT(string) SS_DOWN(X_LALT) string SS_UP(X_LALT)
  123. #define SS_LSFT(string) SS_DOWN(X_LSHIFT) string SS_UP(X_LSHIFT)
  124. #define SS_RALT(string) SS_DOWN(X_RALT) string SS_UP(X_RALT)
  125. #define SEND_STRING(str) send_string_P(PSTR(str))
  126. extern const bool ascii_to_shift_lut[0x80];
  127. extern const uint8_t ascii_to_keycode_lut[0x80];
  128. void send_string(const char *str);
  129. void send_string_with_delay(const char *str, uint8_t interval);
  130. void send_string_P(const char *str);
  131. void send_string_with_delay_P(const char *str, uint8_t interval);
  132. void send_char(char ascii_code);
  133. // For tri-layer
  134. void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3);
  135. uint32_t update_tri_layer_state(uint32_t state, uint8_t layer1, uint8_t layer2, uint8_t layer3);
  136. void set_single_persistent_default_layer(uint8_t default_layer);
  137. void tap_random_base64(void);
  138. #define IS_LAYER_ON(layer) (layer_state & (1UL << (layer)))
  139. #define IS_LAYER_OFF(layer) (~layer_state & (1UL << (layer)))
  140. void matrix_init_kb(void);
  141. void matrix_scan_kb(void);
  142. void matrix_init_user(void);
  143. void matrix_scan_user(void);
  144. bool process_action_kb(keyrecord_t *record);
  145. bool process_record_kb(uint16_t keycode, keyrecord_t *record);
  146. bool process_record_user(uint16_t keycode, keyrecord_t *record);
  147. void reset_keyboard(void);
  148. void startup_user(void);
  149. void shutdown_user(void);
  150. void register_code16 (uint16_t code);
  151. void unregister_code16 (uint16_t code);
  152. #ifdef BACKLIGHT_ENABLE
  153. void backlight_init_ports(void);
  154. void backlight_task(void);
  155. #ifdef BACKLIGHT_BREATHING
  156. void breathing_enable(void);
  157. void breathing_pulse(void);
  158. void breathing_disable(void);
  159. void breathing_self_disable(void);
  160. void breathing_toggle(void);
  161. bool is_breathing(void);
  162. void breathing_intensity_default(void);
  163. void breathing_period_default(void);
  164. void breathing_period_set(uint8_t value);
  165. void breathing_period_inc(void);
  166. void breathing_period_dec(void);
  167. #endif
  168. #endif
  169. void send_dword(uint32_t number);
  170. void send_word(uint16_t number);
  171. void send_byte(uint8_t number);
  172. void send_nibble(uint8_t number);
  173. uint16_t hex_to_keycode(uint8_t hex);
  174. void led_set_user(uint8_t usb_led);
  175. void led_set_kb(uint8_t usb_led);
  176. void api_send_unicode(uint32_t unicode);
  177. #endif