]> git.donarmstrong.com Git - qmk_firmware.git/blob - quantum/quantum.h
Make `PREVENT_STUCK_MODIFIERS` the default (#3107)
[qmk_firmware.git] / quantum / quantum.h
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
19 #if defined(__AVR__)
20 #include <avr/pgmspace.h>
21 #include <avr/io.h>
22 #include <avr/interrupt.h>
23 #endif
24 #include "wait.h"
25 #include "matrix.h"
26 #include "keymap.h"
27 #ifdef BACKLIGHT_ENABLE
28     #include "backlight.h"
29 #endif
30 #if !defined(RGBLIGHT_ENABLE) && !defined(RGB_MATRIX_ENABLE)
31     #include "rgb.h"
32 #endif
33 #ifdef RGBLIGHT_ENABLE
34   #include "rgblight.h"
35 #else
36   #ifdef RGB_MATRIX_ENABLE
37     /* dummy define RGBLIGHT_MODE_xxxx */
38     #define RGBLIGHT_H_DUMMY_DEFINE
39     #include "rgblight.h"
40   #endif
41 #endif
42
43 #ifdef SPLIT_KEYBOARD
44     #include "split_flags.h"
45 #endif
46
47 #ifdef RGB_MATRIX_ENABLE
48     #include "rgb_matrix.h"
49 #endif
50
51 #include "action_layer.h"
52 #include "eeconfig.h"
53 #include <stddef.h>
54 #include "bootloader.h"
55 #include "timer.h"
56 #include "config_common.h"
57 #include "led.h"
58 #include "action_util.h"
59 #include <stdlib.h>
60 #include "print.h"
61 #include "send_string_keycodes.h"
62 #include "suspend.h"
63
64 extern uint32_t default_layer_state;
65
66 #ifndef NO_ACTION_LAYER
67     extern uint32_t layer_state;
68 #endif
69
70 #ifdef MIDI_ENABLE
71 #ifdef MIDI_ADVANCED
72     #include "process_midi.h"
73 #endif
74 #endif // MIDI_ENABLE
75
76 #ifdef AUDIO_ENABLE
77     #include "audio.h"
78     #include "process_audio.h"
79   #ifdef AUDIO_CLICKY
80     #include "process_clicky.h"
81   #endif // AUDIO_CLICKY
82 #endif
83
84 #ifdef STENO_ENABLE
85     #include "process_steno.h"
86 #endif
87
88 #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
89     #include "process_music.h"
90 #endif
91
92 #ifdef LEADER_ENABLE
93     #include "process_leader.h"
94 #endif
95
96 #ifdef UNICODE_ENABLE
97     #include "process_unicode.h"
98 #endif
99
100 #ifdef UCIS_ENABLE
101     #include "process_ucis.h"
102 #endif
103
104 #ifdef UNICODEMAP_ENABLE
105     #include "process_unicodemap.h"
106 #endif
107
108 #include "process_tap_dance.h"
109
110 #ifdef PRINTING_ENABLE
111     #include "process_printer.h"
112 #endif
113
114 #ifdef AUTO_SHIFT_ENABLE
115     #include "process_auto_shift.h"
116 #endif
117
118 #ifdef COMBO_ENABLE
119     #include "process_combo.h"
120 #endif
121
122 #ifdef KEY_LOCK_ENABLE
123     #include "process_key_lock.h"
124 #endif
125
126 #ifdef TERMINAL_ENABLE
127     #include "process_terminal.h"
128 #else
129     #include "process_terminal_nop.h"
130 #endif
131
132 #ifdef HD44780_ENABLE
133     #include "hd44780.h"
134 #endif
135
136 #define STRINGIZE(z) #z
137 #define ADD_SLASH_X(y) STRINGIZE(\x ## y)
138 #define SYMBOL_STR(x) ADD_SLASH_X(x)
139
140 #define SS_TAP(keycode) "\1" SYMBOL_STR(keycode)
141 #define SS_DOWN(keycode) "\2" SYMBOL_STR(keycode)
142 #define SS_UP(keycode) "\3" SYMBOL_STR(keycode)
143
144 #define SS_LCTRL(string) SS_DOWN(X_LCTRL) string SS_UP(X_LCTRL)
145 #define SS_LGUI(string) SS_DOWN(X_LGUI) string SS_UP(X_LGUI)
146 #define SS_LCMD(string) SS_LGUI(string)
147 #define SS_LWIN(string) SS_LGUI(string)
148 #define SS_LALT(string) SS_DOWN(X_LALT) string SS_UP(X_LALT)
149 #define SS_LSFT(string) SS_DOWN(X_LSHIFT) string SS_UP(X_LSHIFT)
150 #define SS_RALT(string) SS_DOWN(X_RALT) string SS_UP(X_RALT)
151
152 #define SEND_STRING(str) send_string_P(PSTR(str))
153 extern const bool ascii_to_shift_lut[0x80];
154 extern const uint8_t ascii_to_keycode_lut[0x80];
155 void send_string(const char *str);
156 void send_string_with_delay(const char *str, uint8_t interval);
157 void send_string_P(const char *str);
158 void send_string_with_delay_P(const char *str, uint8_t interval);
159 void send_char(char ascii_code);
160
161 // For tri-layer
162 void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3);
163 uint32_t update_tri_layer_state(uint32_t state, uint8_t layer1, uint8_t layer2, uint8_t layer3);
164
165 void set_single_persistent_default_layer(uint8_t default_layer);
166
167 void tap_random_base64(void);
168
169 #define IS_LAYER_ON(layer)  (layer_state & (1UL << (layer)))
170 #define IS_LAYER_OFF(layer) (~layer_state & (1UL << (layer)))
171
172 void matrix_init_kb(void);
173 void matrix_scan_kb(void);
174 void matrix_init_user(void);
175 void matrix_scan_user(void);
176 bool process_action_kb(keyrecord_t *record);
177 bool process_record_kb(uint16_t keycode, keyrecord_t *record);
178 bool process_record_user(uint16_t keycode, keyrecord_t *record);
179
180 void reset_keyboard(void);
181
182 void startup_user(void);
183 void shutdown_user(void);
184
185 void register_code16 (uint16_t code);
186 void unregister_code16 (uint16_t code);
187
188 #ifdef BACKLIGHT_ENABLE
189 void backlight_init_ports(void);
190 void backlight_task(void);
191
192 #ifdef BACKLIGHT_BREATHING
193 void breathing_enable(void);
194 void breathing_pulse(void);
195 void breathing_disable(void);
196 void breathing_self_disable(void);
197 void breathing_toggle(void);
198 bool is_breathing(void);
199
200 void breathing_intensity_default(void);
201 void breathing_period_default(void);
202 void breathing_period_set(uint8_t value);
203 void breathing_period_inc(void);
204 void breathing_period_dec(void);
205 #endif
206
207 #endif
208 void send_dword(uint32_t number);
209 void send_word(uint16_t number);
210 void send_byte(uint8_t number);
211 void send_nibble(uint8_t number);
212 uint16_t hex_to_keycode(uint8_t hex);
213
214 void led_set_user(uint8_t usb_led);
215 void led_set_kb(uint8_t usb_led);
216
217 void api_send_unicode(uint32_t unicode);
218
219 #endif