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