Files
qmk/quantum/quantum.h
T

246 lines
5.5 KiB
C
Raw Normal View History

/* Copyright 2016-2018 Erez Zukerman, Jack Humbert, Yiancar
2017-03-28 15:20:36 -07:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
2016-05-15 00:27:32 -04:00
2016-07-01 17:04:53 +03:00
#if defined(__AVR__)
2019-08-30 11:19:03 -07:00
# include <avr/pgmspace.h>
# include <avr/io.h>
# include <avr/interrupt.h>
#endif
#if defined(PROTOCOL_CHIBIOS)
# include <hal.h>
# include "chibios_config.h"
2016-07-01 17:04:53 +03:00
#endif
2016-07-01 17:04:53 +03:00
#include "wait.h"
2016-05-15 00:27:32 -04:00
#include "matrix.h"
#include "keymap.h"
2016-05-15 00:27:32 -04:00
#ifdef BACKLIGHT_ENABLE
# include "backlight.h"
#endif
#ifdef LED_MATRIX_ENABLE
# include "led_matrix.h"
2016-05-15 00:27:32 -04:00
#endif
#if defined(RGBLIGHT_ENABLE)
2019-08-30 11:19:03 -07:00
# include "rgblight.h"
#elif defined(RGB_MATRIX_ENABLE)
2019-08-30 11:19:03 -07:00
// Dummy define RGBLIGHT_MODE_xxxx
# define RGBLIGHT_H_DUMMY_DEFINE
# include "rgblight.h"
2016-05-15 00:27:32 -04:00
#endif
2018-07-16 19:25:02 -07:00
#ifdef RGB_MATRIX_ENABLE
2019-08-30 11:19:03 -07:00
# include "rgb_matrix.h"
#endif
2018-07-16 19:25:02 -07:00
2016-05-15 00:27:32 -04:00
#include "action_layer.h"
#include "eeconfig.h"
#include "bootloader.h"
#include "bootmagic.h"
#include "timer.h"
2020-12-01 12:04:42 -06:00
#include "sync_timer.h"
#include "config_common.h"
2021-02-14 00:51:06 +00:00
#include "gpio.h"
#include "atomic_util.h"
#include "led.h"
#include "action_util.h"
2021-01-04 16:37:20 -08:00
#include "action_tapping.h"
2016-07-09 00:41:15 +03:00
#include "print.h"
#include "send_string.h"
#include "suspend.h"
#include <stddef.h>
#include <stdlib.h>
extern layer_state_t default_layer_state;
2016-05-15 00:27:32 -04:00
#ifndef NO_ACTION_LAYER
2019-08-30 11:19:03 -07:00
extern layer_state_t layer_state;
2016-05-15 00:27:32 -04:00
#endif
#if defined(SEQUENCER_ENABLE)
# include "sequencer.h"
# include "process_sequencer.h"
#endif
#if defined(MIDI_ENABLE) && defined(MIDI_ADVANCED)
2019-08-30 11:19:03 -07:00
# include "process_midi.h"
2016-05-18 23:47:16 -04:00
#endif
#ifdef AUDIO_ENABLE
2019-08-30 11:19:03 -07:00
# include "audio.h"
# include "process_audio.h"
# ifdef AUDIO_CLICKY
# include "process_clicky.h"
# endif
#endif
#ifdef STENO_ENABLE
2019-08-30 11:19:03 -07:00
# include "process_steno.h"
#endif
#if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
2019-08-30 11:19:03 -07:00
# include "process_music.h"
2016-05-18 23:47:16 -04:00
#endif
#if defined(BACKLIGHT_ENABLE) || defined(LED_MATRIX_ENABLE)
# include "process_backlight.h"
#endif
#ifdef LEADER_ENABLE
2019-08-30 11:19:03 -07:00
# include "process_leader.h"
2016-05-18 23:47:16 -04:00
#endif
2016-05-15 00:27:32 -04:00
#ifdef UNICODE_ENABLE
2019-08-30 11:19:03 -07:00
# include "process_unicode.h"
#endif
#ifdef UCIS_ENABLE
2019-08-30 11:19:03 -07:00
# include "process_ucis.h"
#endif
#ifdef UNICODEMAP_ENABLE
2019-08-30 11:19:03 -07:00
# include "process_unicodemap.h"
#endif
#ifdef TAP_DANCE_ENABLE
2019-08-30 11:19:03 -07:00
# include "process_tap_dance.h"
#endif
2016-10-16 16:03:33 -04:00
#ifdef PRINTING_ENABLE
2019-08-30 11:19:03 -07:00
# include "process_printer.h"
2016-10-16 16:03:33 -04:00
#endif
#ifdef AUTO_SHIFT_ENABLE
2019-08-30 11:19:03 -07:00
# include "process_auto_shift.h"
#endif
2016-12-10 00:49:11 +02:00
#ifdef COMBO_ENABLE
2019-08-30 11:19:03 -07:00
# include "process_combo.h"
2016-12-10 00:49:11 +02:00
#endif
#ifdef KEY_LOCK_ENABLE
2019-08-30 11:19:03 -07:00
# include "process_key_lock.h"
#endif
#ifdef TERMINAL_ENABLE
2019-08-30 11:19:03 -07:00
# include "process_terminal.h"
#else
2019-08-30 11:19:03 -07:00
# include "process_terminal_nop.h"
#endif
2019-04-29 22:21:46 -05:00
#ifdef SPACE_CADET_ENABLE
2019-08-30 11:19:03 -07:00
# include "process_space_cadet.h"
2019-04-29 22:21:46 -05:00
#endif
2019-12-03 19:48:55 +00:00
#ifdef MAGIC_KEYCODE_ENABLE
# include "process_magic.h"
#endif
2020-07-25 14:01:15 +02:00
#ifdef JOYSTICK_ENABLE
# include "process_joystick.h"
#endif
2020-02-05 02:49:10 +00:00
#ifdef GRAVE_ESC_ENABLE
# include "process_grave_esc.h"
#endif
2019-12-16 20:27:53 +00:00
#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
# include "process_rgb.h"
#endif
#ifdef HD44780_ENABLE
2019-08-30 11:19:03 -07:00
# include "hd44780.h"
#endif
#ifdef HAPTIC_ENABLE
2019-08-30 11:19:03 -07:00
# include "haptic.h"
#endif
2019-04-15 22:32:57 -05:00
#ifdef OLED_DRIVER_ENABLE
2019-08-30 11:19:03 -07:00
# include "oled_driver.h"
2019-04-15 22:32:57 -05:00
#endif
2019-09-03 08:34:31 -07:00
#ifdef DIP_SWITCH_ENABLE
# include "dip_switch.h"
2019-09-03 08:34:31 -07:00
#endif
#ifdef DYNAMIC_MACRO_ENABLE
# include "process_dynamic_macro.h"
#endif
2020-01-04 07:52:00 +11:00
#ifdef DYNAMIC_KEYMAP_ENABLE
# include "dynamic_keymap.h"
2020-01-04 07:52:00 +11:00
#endif
#ifdef VIA_ENABLE
# include "via.h"
2020-01-04 07:52:00 +11:00
#endif
#ifdef WPM_ENABLE
# include "wpm.h"
#endif
#ifdef USBPD_ENABLE
# include "usbpd.h"
#endif
#ifdef ENCODER_ENABLE
# include "encoder.h"
#endif
// For tri-layer
2019-08-30 11:19:03 -07:00
void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3);
layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_t layer2, uint8_t layer3);
2016-06-29 18:29:20 -04:00
void set_single_persistent_default_layer(uint8_t default_layer);
#define IS_LAYER_ON(layer) layer_state_is(layer)
#define IS_LAYER_OFF(layer) !layer_state_is(layer)
#define IS_LAYER_ON_STATE(state, layer) layer_state_cmp(state, layer)
#define IS_LAYER_OFF_STATE(state, layer) !layer_state_cmp(state, layer)
2019-08-30 11:19:03 -07:00
void matrix_init_kb(void);
void matrix_scan_kb(void);
void matrix_init_user(void);
void matrix_scan_user(void);
uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache);
uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache);
2019-08-30 11:19:03 -07:00
bool process_action_kb(keyrecord_t *record);
bool process_record_kb(uint16_t keycode, keyrecord_t *record);
bool process_record_user(uint16_t keycode, keyrecord_t *record);
void post_process_record_kb(uint16_t keycode, keyrecord_t *record);
void post_process_record_user(uint16_t keycode, keyrecord_t *record);
2016-07-13 16:38:02 +02:00
void reset_keyboard(void);
void startup_user(void);
void shutdown_user(void);
2016-05-18 23:14:00 -04:00
2018-11-27 23:29:59 +01:00
void register_code16(uint16_t code);
void unregister_code16(uint16_t code);
2018-12-14 09:01:58 -08:00
void tap_code16(uint16_t code);
void led_set_user(uint8_t usb_led);
void led_set_kb(uint8_t usb_led);
2019-11-06 11:42:16 +11:00
bool led_update_user(led_t led_state);
bool led_update_kb(led_t led_state);
2016-11-26 15:37:46 -05:00
void api_send_unicode(uint32_t unicode);