1 /* Copyright 2016-2017 Erez Zukerman, Jack Humbert
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.
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.
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/>.
20 #include <avr/pgmspace.h>
22 #include <avr/interrupt.h>
27 #ifdef BACKLIGHT_ENABLE
28 #include "backlight.h"
30 #if !defined(RGBLIGHT_ENABLE) && !defined(RGB_MATRIX_ENABLE)
33 #ifdef RGBLIGHT_ENABLE
36 #ifdef RGB_MATRIX_ENABLE
37 /* dummy define RGBLIGHT_MODE_xxxx */
38 #define RGBLIGHT_H_DUMMY_DEFINE
44 #include "split_flags.h"
47 #ifdef RGB_MATRIX_ENABLE
48 #include "rgb_matrix.h"
51 #include "action_layer.h"
54 #include "bootloader.h"
56 #include "config_common.h"
58 #include "action_util.h"
61 #include "send_string_keycodes.h"
64 extern uint32_t default_layer_state;
66 #ifndef NO_ACTION_LAYER
67 extern uint32_t layer_state;
72 #include "process_midi.h"
78 #include "process_audio.h"
80 #include "process_clicky.h"
81 #endif // AUDIO_CLICKY
85 #include "process_steno.h"
88 #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
89 #include "process_music.h"
92 #ifndef DISABLE_LEADER
93 #include "process_leader.h"
96 #define DISABLE_CHORDING
97 #ifndef DISABLE_CHORDING
98 #include "process_chording.h"
101 #ifdef UNICODE_ENABLE
102 #include "process_unicode.h"
106 #include "process_ucis.h"
109 #ifdef UNICODEMAP_ENABLE
110 #include "process_unicodemap.h"
113 #include "process_tap_dance.h"
115 #ifdef PRINTING_ENABLE
116 #include "process_printer.h"
119 #ifdef AUTO_SHIFT_ENABLE
120 #include "process_auto_shift.h"
124 #include "process_combo.h"
127 #ifdef KEY_LOCK_ENABLE
128 #include "process_key_lock.h"
131 #ifdef TERMINAL_ENABLE
132 #include "process_terminal.h"
134 #include "process_terminal_nop.h"
137 #ifdef HD44780_ENABLE
141 #define STRINGIZE(z) #z
142 #define ADD_SLASH_X(y) STRINGIZE(\x ## y)
143 #define SYMBOL_STR(x) ADD_SLASH_X(x)
145 #define SS_TAP(keycode) "\1" SYMBOL_STR(keycode)
146 #define SS_DOWN(keycode) "\2" SYMBOL_STR(keycode)
147 #define SS_UP(keycode) "\3" SYMBOL_STR(keycode)
149 #define SS_LCTRL(string) SS_DOWN(X_LCTRL) string SS_UP(X_LCTRL)
150 #define SS_LGUI(string) SS_DOWN(X_LGUI) string SS_UP(X_LGUI)
151 #define SS_LCMD(string) SS_LGUI(string)
152 #define SS_LWIN(string) SS_LGUI(string)
153 #define SS_LALT(string) SS_DOWN(X_LALT) string SS_UP(X_LALT)
154 #define SS_LSFT(string) SS_DOWN(X_LSHIFT) string SS_UP(X_LSHIFT)
155 #define SS_RALT(string) SS_DOWN(X_RALT) string SS_UP(X_RALT)
157 #define SEND_STRING(str) send_string_P(PSTR(str))
158 extern const bool ascii_to_shift_lut[0x80];
159 extern const uint8_t ascii_to_keycode_lut[0x80];
160 void send_string(const char *str);
161 void send_string_with_delay(const char *str, uint8_t interval);
162 void send_string_P(const char *str);
163 void send_string_with_delay_P(const char *str, uint8_t interval);
164 void send_char(char ascii_code);
167 void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3);
168 uint32_t update_tri_layer_state(uint32_t state, uint8_t layer1, uint8_t layer2, uint8_t layer3);
170 void set_single_persistent_default_layer(uint8_t default_layer);
172 void tap_random_base64(void);
174 #define IS_LAYER_ON(layer) (layer_state & (1UL << (layer)))
175 #define IS_LAYER_OFF(layer) (~layer_state & (1UL << (layer)))
177 void matrix_init_kb(void);
178 void matrix_scan_kb(void);
179 void matrix_init_user(void);
180 void matrix_scan_user(void);
181 bool process_action_kb(keyrecord_t *record);
182 bool process_record_kb(uint16_t keycode, keyrecord_t *record);
183 bool process_record_user(uint16_t keycode, keyrecord_t *record);
185 void reset_keyboard(void);
187 void startup_user(void);
188 void shutdown_user(void);
190 void register_code16 (uint16_t code);
191 void unregister_code16 (uint16_t code);
193 #ifdef BACKLIGHT_ENABLE
194 void backlight_init_ports(void);
195 void backlight_task(void);
197 #ifdef BACKLIGHT_BREATHING
198 void breathing_enable(void);
199 void breathing_pulse(void);
200 void breathing_disable(void);
201 void breathing_self_disable(void);
202 void breathing_toggle(void);
203 bool is_breathing(void);
205 void breathing_intensity_default(void);
206 void breathing_period_default(void);
207 void breathing_period_set(uint8_t value);
208 void breathing_period_inc(void);
209 void breathing_period_dec(void);
213 void send_dword(uint32_t number);
214 void send_word(uint16_t number);
215 void send_byte(uint8_t number);
216 void send_nibble(uint8_t number);
217 uint16_t hex_to_keycode(uint8_t hex);
219 void led_set_user(uint8_t usb_led);
220 void led_set_kb(uint8_t usb_led);
222 void api_send_unicode(uint32_t unicode);