Parent directory

quantum.h

6152 bytes
  1/* Copyright 2016-2018 Erez Zukerman, Jack Humbert, Yiancar
  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#pragma once
 17
 18#include "platform_deps.h"
 19#include "wait.h"
 20#include "matrix.h"
 21#include "keyboard.h"
 22
 23#ifdef BACKLIGHT_ENABLE
 24#    include "backlight.h"
 25#endif
 26
 27#ifdef LED_MATRIX_ENABLE
 28#    include "led_matrix.h"
 29#endif
 30
 31#if defined(RGBLIGHT_ENABLE)
 32#    include "rgblight.h"
 33#endif
 34
 35#ifdef RGB_MATRIX_ENABLE
 36#    include "rgb_matrix.h"
 37#endif
 38
 39#include "keymap_common.h"
 40#include "quantum_keycodes.h"
 41#include "keycode_config.h"
 42#include "action_layer.h"
 43#include "eeconfig.h"
 44#include "bootloader.h"
 45#include "timer.h"
 46#include "sync_timer.h"
 47#include "gpio.h"
 48#include "atomic_util.h"
 49#include "host.h"
 50#include "led.h"
 51#include "action_util.h"
 52#include "action_tapping.h"
 53#include "print.h"
 54#include "debug.h"
 55#include "suspend.h"
 56#include <stddef.h>
 57#include <stdlib.h>
 58#include <stdio.h>
 59#include <string.h>
 60
 61#ifdef BOOTMAGIC_ENABLE
 62#    include "bootmagic.h"
 63#endif
 64
 65#ifdef DEFERRED_EXEC_ENABLE
 66#    include "deferred_exec.h"
 67#endif
 68
 69extern layer_state_t default_layer_state;
 70
 71#ifndef NO_ACTION_LAYER
 72extern layer_state_t layer_state;
 73#endif
 74
 75#if defined(SEQUENCER_ENABLE)
 76#    include "sequencer.h"
 77#    include "process_sequencer.h"
 78#endif
 79
 80#if defined(MIDI_ENABLE) && defined(MIDI_ADVANCED)
 81#    include "process_midi.h"
 82#endif
 83
 84#ifdef AUDIO_ENABLE
 85#    include "audio.h"
 86#    include "process_audio.h"
 87#    include "song_list.h"
 88#    ifdef AUDIO_CLICKY
 89#        include "process_clicky.h"
 90#    endif
 91#endif
 92
 93#ifdef STENO_ENABLE
 94#    include "process_steno.h"
 95#endif
 96
 97#if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
 98#    include "process_music.h"
 99#endif
100
101#ifdef LEADER_ENABLE
102#    include "leader.h"
103#endif
104
105#ifdef UNICODE_COMMON_ENABLE
106#    include "unicode.h"
107#endif
108
109#ifdef UCIS_ENABLE
110#    include "ucis.h"
111#endif
112
113#ifdef UNICODEMAP_ENABLE
114#    include "unicodemap.h"
115#endif
116
117#ifdef KEY_OVERRIDE_ENABLE
118#    include "process_key_override.h"
119#endif
120
121#ifdef TAP_DANCE_ENABLE
122#    include "process_tap_dance.h"
123#endif
124
125#ifdef AUTO_SHIFT_ENABLE
126#    include "process_auto_shift.h"
127#endif
128
129#ifdef DYNAMIC_TAPPING_TERM_ENABLE
130#    include "process_dynamic_tapping_term.h"
131#endif
132
133#ifdef COMBO_ENABLE
134#    include "process_combo.h"
135#endif
136
137#ifdef KEY_LOCK_ENABLE
138#    include "process_key_lock.h"
139#endif
140
141#ifdef SPACE_CADET_ENABLE
142#    include "process_space_cadet.h"
143#endif
144
145#ifdef PROGRAMMABLE_BUTTON_ENABLE
146#    include "programmable_button.h"
147#endif
148
149#ifdef HD44780_ENABLE
150#    include "hd44780.h"
151#endif
152
153#ifdef SEND_STRING_ENABLE
154#    include "send_string.h"
155#endif
156
157#ifdef HAPTIC_ENABLE
158#    include "haptic.h"
159#endif
160
161#ifdef OLED_ENABLE
162#    include "oled_driver.h"
163#endif
164
165#ifdef ST7565_ENABLE
166#    include "st7565.h"
167#endif
168
169#ifdef QUANTUM_PAINTER_ENABLE
170#    include "qp.h"
171#endif
172
173#ifdef DIP_SWITCH_ENABLE
174#    include "dip_switch.h"
175#endif
176
177#ifdef DYNAMIC_MACRO_ENABLE
178#    include "process_dynamic_macro.h"
179#endif
180
181#ifdef SECURE_ENABLE
182#    include "secure.h"
183#endif
184
185#ifdef DYNAMIC_KEYMAP_ENABLE
186#    include "dynamic_keymap.h"
187#endif
188
189#ifdef JOYSTICK_ENABLE
190#    include "joystick.h"
191#endif
192
193#ifdef DIGITIZER_ENABLE
194#    include "digitizer.h"
195#endif
196
197#ifdef VIA_ENABLE
198#    include "via.h"
199#endif
200
201#ifdef WPM_ENABLE
202#    include "wpm.h"
203#endif
204
205#ifdef USBPD_ENABLE
206#    include "usbpd.h"
207#endif
208
209#ifdef ENCODER_ENABLE
210#    include "encoder.h"
211#endif
212
213#ifdef POINTING_DEVICE_ENABLE
214#    include "pointing_device.h"
215#endif
216
217#ifdef MOUSEKEY_ENABLE
218#    include "mousekey.h"
219#endif
220
221#ifdef CAPS_WORD_ENABLE
222#    include "caps_word.h"
223#    include "process_caps_word.h"
224#endif
225
226#ifdef AUTOCORRECT_ENABLE
227#    include "process_autocorrect.h"
228#endif
229
230#ifdef TRI_LAYER_ENABLE
231#    include "tri_layer.h"
232#endif
233
234#ifdef REPEAT_KEY_ENABLE
235#    include "repeat_key.h"
236#    include "process_repeat_key.h"
237#endif
238
239#ifdef OS_DETECTION_ENABLE
240#    include "os_detection.h"
241#endif
242
243#ifdef LAYER_LOCK_ENABLE
244#    include "layer_lock.h"
245#endif
246
247void set_single_default_layer(uint8_t default_layer);
248void set_single_persistent_default_layer(uint8_t default_layer);
249
250#define IS_LAYER_ON(layer) layer_state_is(layer)
251#define IS_LAYER_OFF(layer) !layer_state_is(layer)
252
253#define IS_LAYER_ON_STATE(state, layer) layer_state_cmp(state, layer)
254#define IS_LAYER_OFF_STATE(state, layer) !layer_state_cmp(state, layer)
255
256uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache);
257uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache);
258bool     pre_process_record_quantum(keyrecord_t *record);
259bool     pre_process_record_kb(uint16_t keycode, keyrecord_t *record);
260bool     pre_process_record_user(uint16_t keycode, keyrecord_t *record);
261bool     process_action_kb(keyrecord_t *record);
262bool     process_record_kb(uint16_t keycode, keyrecord_t *record);
263bool     process_record_user(uint16_t keycode, keyrecord_t *record);
264void     post_process_record_kb(uint16_t keycode, keyrecord_t *record);
265void     post_process_record_user(uint16_t keycode, keyrecord_t *record);
266
267void reset_keyboard(void);
268void soft_reset_keyboard(void);
269
270bool shutdown_kb(bool jump_to_bootloader);
271bool shutdown_user(bool jump_to_bootloader);
272
273void register_code16(uint16_t code);
274void unregister_code16(uint16_t code);
275void tap_code16(uint16_t code);
276void tap_code16_delay(uint16_t code, uint16_t delay);
277
278const char *get_numeric_str(char *buf, size_t buf_len, uint32_t curr_num, char curr_pad);
279const char *get_u8_str(uint8_t curr_num, char curr_pad);
280const char *get_u16_str(uint16_t curr_num, char curr_pad);