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