quantum.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. #ifdef RGBLIGHT_ENABLE
  30. #include "rgblight.h"
  31. #endif
  32. #include "action_layer.h"
  33. #include "eeconfig.h"
  34. #include <stddef.h>
  35. #include "bootloader.h"
  36. #include "timer.h"
  37. #include "config_common.h"
  38. #include "led.h"
  39. #include "action_util.h"
  40. #include <stdlib.h>
  41. #include "print.h"
  42. #include "send_string_keycodes.h"
  43. extern uint32_t default_layer_state;
  44. #ifndef NO_ACTION_LAYER
  45. extern uint32_t layer_state;
  46. #endif
  47. #ifdef MIDI_ENABLE
  48. #include <lufa.h>
  49. #ifdef MIDI_ADVANCED
  50. #include "process_midi.h"
  51. #endif
  52. #endif // MIDI_ENABLE
  53. #ifdef AUDIO_ENABLE
  54. #include "audio.h"
  55. #include "process_audio.h"
  56. #endif
  57. #ifdef STENO_ENABLE
  58. #include "process_steno.h"
  59. #endif
  60. #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
  61. #include "process_music.h"
  62. #endif
  63. #ifndef DISABLE_LEADER
  64. #include "process_leader.h"
  65. #endif
  66. #define DISABLE_CHORDING
  67. #ifndef DISABLE_CHORDING
  68. #include "process_chording.h"
  69. #endif
  70. #ifdef UNICODE_ENABLE
  71. #include "process_unicode.h"
  72. #endif
  73. #ifdef UCIS_ENABLE
  74. #include "process_ucis.h"
  75. #endif
  76. #ifdef UNICODEMAP_ENABLE
  77. #include "process_unicodemap.h"
  78. #endif
  79. #include "process_tap_dance.h"
  80. #ifdef PRINTING_ENABLE
  81. #include "process_printer.h"
  82. #endif
  83. #ifdef AUTO_SHIFT_ENABLE
  84. #include "process_auto_shift.h"
  85. #endif
  86. #ifdef COMBO_ENABLE
  87. #include "process_combo.h"
  88. #endif
  89. #ifdef KEY_LOCK_ENABLE
  90. #include "process_key_lock.h"
  91. #endif
  92. #ifdef TERMINAL_ENABLE
  93. #include "process_terminal.h"
  94. #else
  95. #include "process_terminal_nop.h"
  96. #endif
  97. #define STRINGIZE(z) #z
  98. #define ADD_SLASH_X(y) STRINGIZE(\x ## y)
  99. #define SYMBOL_STR(x) ADD_SLASH_X(x)
  100. #define SS_TAP(keycode) "\1" SYMBOL_STR(keycode)
  101. #define SS_DOWN(keycode) "\2" SYMBOL_STR(keycode)
  102. #define SS_UP(keycode) "\3" SYMBOL_STR(keycode)
  103. #define SS_LCTRL(string) SS_DOWN(X_LCTRL) string SS_UP(X_LCTRL)
  104. #define SS_LGUI(string) SS_DOWN(X_LGUI) string SS_UP(X_LGUI)
  105. #define SS_LALT(string) SS_DOWN(X_LALT) string SS_UP(X_LALT)
  106. #define SS_LSFT(string) SS_DOWN(X_LSHIFT) string SS_UP(X_LSHIFT)
  107. #define SEND_STRING(str) send_string_P(PSTR(str))
  108. extern const bool ascii_to_shift_lut[0x80];
  109. extern const uint8_t ascii_to_keycode_lut[0x80];
  110. void send_string(const char *str);
  111. void send_string_with_delay(const char *str, uint8_t interval);
  112. void send_string_P(const char *str);
  113. void send_string_with_delay_P(const char *str, uint8_t interval);
  114. void send_char(char ascii_code);
  115. // For tri-layer
  116. void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3);
  117. void set_single_persistent_default_layer(uint8_t default_layer);
  118. void tap_random_base64(void);
  119. #define IS_LAYER_ON(layer) (layer_state & (1UL << (layer)))
  120. #define IS_LAYER_OFF(layer) (~layer_state & (1UL << (layer)))
  121. void matrix_init_kb(void);
  122. void matrix_scan_kb(void);
  123. void matrix_init_user(void);
  124. void matrix_scan_user(void);
  125. bool process_action_kb(keyrecord_t *record);
  126. bool process_record_kb(uint16_t keycode, keyrecord_t *record);
  127. bool process_record_user(uint16_t keycode, keyrecord_t *record);
  128. void reset_keyboard(void);
  129. void startup_user(void);
  130. void shutdown_user(void);
  131. void register_code16 (uint16_t code);
  132. void unregister_code16 (uint16_t code);
  133. #ifdef BACKLIGHT_ENABLE
  134. void backlight_init_ports(void);
  135. void backlight_task(void);
  136. #ifdef BACKLIGHT_BREATHING
  137. void breathing_enable(void);
  138. void breathing_pulse(void);
  139. void breathing_disable(void);
  140. void breathing_self_disable(void);
  141. void breathing_toggle(void);
  142. bool is_breathing(void);
  143. void breathing_intensity_default(void);
  144. void breathing_period_default(void);
  145. void breathing_period_set(uint8_t value);
  146. void breathing_period_inc(void);
  147. void breathing_period_dec(void);
  148. #endif
  149. #endif
  150. void send_dword(uint32_t number);
  151. void send_word(uint16_t number);
  152. void send_byte(uint8_t number);
  153. void send_nibble(uint8_t number);
  154. uint16_t hex_to_keycode(uint8_t hex);
  155. void led_set_user(uint8_t usb_led);
  156. void led_set_kb(uint8_t usb_led);
  157. void api_send_unicode(uint32_t unicode);
  158. #endif