diff options
Diffstat (limited to 'quantum')
99 files changed, 378 insertions, 174 deletions
diff --git a/quantum/action_code.h b/quantum/action_code.h index 58d929016d..d9a575b518 100644 --- a/quantum/action_code.h +++ b/quantum/action_code.h @@ -17,6 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #pragma once +#include "modifiers.h" + /** \brief Action codes * * 16bit code: action_kind(4bit) + action_parameter(12bit) @@ -160,28 +162,6 @@ typedef union { #define ACTION_TRANSPARENT 1 #define ACTION(kind, param) ((kind) << 12 | (param)) -/** \brief Key Actions - * - * Mod bits: 43210 - * bit 0 ||||+- Control - * bit 1 |||+-- Shift - * bit 2 ||+--- Alt - * bit 3 |+---- Gui - * bit 4 +----- LR flag(Left:0, Right:1) - */ -enum mods_bit { - MOD_LCTL = 0x01, - MOD_LSFT = 0x02, - MOD_LALT = 0x04, - MOD_LGUI = 0x08, - MOD_RCTL = 0x11, - MOD_RSFT = 0x12, - MOD_RALT = 0x14, - MOD_RGUI = 0x18, -}; -#define MOD_HYPR (MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI) -#define MOD_MEH (MOD_LCTL | MOD_LSFT | MOD_LALT) - enum mods_codes { MODS_ONESHOT = 0x00, MODS_TAP_TOGGLE = 0x01, diff --git a/quantum/action_util.h b/quantum/action_util.h index 6f1f09c4bd..0ecf15ae4b 100644 --- a/quantum/action_util.h +++ b/quantum/action_util.h @@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <stdint.h> #include "report.h" +#include "modifiers.h" #ifdef __cplusplus extern "C" { diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c index ca78a483ad..2570ad9cd1 100644 --- a/quantum/audio/audio.c +++ b/quantum/audio/audio.c @@ -18,6 +18,7 @@ #include "eeconfig.h" #include "timer.h" #include "wait.h" +#include "util.h" /* audio system: * @@ -112,6 +113,10 @@ static bool audio_initialized = false; static bool audio_driver_stopped = true; audio_config_t audio_config; +void eeconfig_update_audio_current(void) { + eeconfig_update_audio(audio_config.raw); +} + void audio_init(void) { if (audio_initialized) { return; diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h index fe23cf3ed1..497f3dafd0 100644 --- a/quantum/audio/audio.h +++ b/quantum/audio/audio.h @@ -43,11 +43,6 @@ typedef union { }; } audio_config_t; -// AVR/LUFA has a MIN, arm/chibios does not -#ifndef MIN -# define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif - /* * a 'musical note' is represented by pitch and duration; a 'musical tone' adds intensity and timbre * https://en.wikipedia.org/wiki/Musical_tone @@ -64,6 +59,11 @@ typedef struct { // public interface /** + * @brief Save the current choices to the eeprom + */ +void eeconfig_update_audio_current(void); + +/** * @brief one-time initialization called by quantum/quantum.c * @details usually done lazy, when some tones are to be played * diff --git a/quantum/bootmagic/magic.c b/quantum/bootmagic/magic.c index f1cb11c395..d68df3fa58 100644 --- a/quantum/bootmagic/magic.c +++ b/quantum/bootmagic/magic.c @@ -19,7 +19,7 @@ #include "matrix.h" #include "bootloader.h" #include "debug.h" -#include "keymap.h" +#include "keycode_config.h" #include "host.h" #include "action_layer.h" #include "eeconfig.h" diff --git a/quantum/color.c b/quantum/color.c index c80078dbf2..767155c9db 100644 --- a/quantum/color.c +++ b/quantum/color.c @@ -17,6 +17,7 @@ #include "color.h" #include "led_tables.h" #include "progmem.h" +#include "util.h" RGB hsv_to_rgb_impl(HSV hsv, bool use_cie) { RGB rgb; @@ -109,9 +110,6 @@ RGB hsv_to_rgb_nocie(HSV hsv) { } #ifdef RGBW -# ifndef MIN -# define MIN(a, b) ((a) < (b) ? (a) : (b)) -# endif void convert_rgb_to_rgbw(LED_TYPE *led) { // Determine lowest value in all three colors, put that into // the white channel and then shift all colors by that amount diff --git a/quantum/command.c b/quantum/command.c index 84757b9b01..aa64b75064 100644 --- a/quantum/command.c +++ b/quantum/command.c @@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "wait.h" #include "keycode.h" #include "host.h" -#include "keymap.h" #include "print.h" #include "debug.h" #include "util.h" diff --git a/quantum/digitizer.h b/quantum/digitizer.h index b826ba8ac8..6a9c24ed34 100644 --- a/quantum/digitizer.h +++ b/quantum/digitizer.h @@ -13,17 +13,15 @@ * 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 -#include "quantum.h" +#pragma once #include <stdbool.h> -#include <stdint.h> /** - * \defgroup digitizer + * \file * - * HID Digitizer + * defgroup digitizer HID Digitizer * \{ */ diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c index c406be4585..90a0f20838 100644 --- a/quantum/dynamic_keymap.c +++ b/quantum/dynamic_keymap.c @@ -14,7 +14,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "keymap.h" // to get keymaps[][][] +#include "keymap_introspection.h" // to get keymaps[][][] #include "eeprom.h" #include "progmem.h" // to read default from flash #include "quantum.h" // for send_string() diff --git a/quantum/joystick.h b/quantum/joystick.h index 0ac99aa590..5de4ba66c6 100644 --- a/quantum/joystick.h +++ b/quantum/joystick.h @@ -22,9 +22,9 @@ #include "gpio.h" /** - * \defgroup joystick + * \file * - * HID Joystick + * \defgroup joystick HID Joystick * \{ */ diff --git a/quantum/keyboard.c b/quantum/keyboard.c index ec2f2e4496..6e7d40ddc7 100644 --- a/quantum/keyboard.c +++ b/quantum/keyboard.c @@ -114,7 +114,7 @@ uint32_t last_input_activity_time(void) { return last_input_modification_time; } uint32_t last_input_activity_elapsed(void) { - return timer_elapsed32(last_input_modification_time); + return sync_timer_elapsed32(last_input_modification_time); } static uint32_t last_matrix_modification_time = 0; @@ -122,10 +122,10 @@ uint32_t last_matrix_activity_time(void) { return last_matrix_modification_time; } uint32_t last_matrix_activity_elapsed(void) { - return timer_elapsed32(last_matrix_modification_time); + return sync_timer_elapsed32(last_matrix_modification_time); } void last_matrix_activity_trigger(void) { - last_matrix_modification_time = last_input_modification_time = timer_read32(); + last_matrix_modification_time = last_input_modification_time = sync_timer_read32(); } static uint32_t last_encoder_modification_time = 0; @@ -133,10 +133,16 @@ uint32_t last_encoder_activity_time(void) { return last_encoder_modification_time; } uint32_t last_encoder_activity_elapsed(void) { - return timer_elapsed32(last_encoder_modification_time); + return sync_timer_elapsed32(last_encoder_modification_time); } void last_encoder_activity_trigger(void) { - last_encoder_modification_time = last_input_modification_time = timer_read32(); + last_encoder_modification_time = last_input_modification_time = sync_timer_read32(); +} + +void set_activity_timestamps(uint32_t matrix_timestamp, uint32_t encoder_timestamp) { + last_matrix_modification_time = matrix_timestamp; + last_encoder_modification_time = encoder_timestamp; + last_input_modification_time = MAX(matrix_timestamp, encoder_timestamp); } // Only enable this if console is enabled to print to diff --git a/quantum/keyboard.h b/quantum/keyboard.h index d0b52dd13a..caf0fbd466 100644 --- a/quantum/keyboard.h +++ b/quantum/keyboard.h @@ -120,6 +120,8 @@ uint32_t last_matrix_activity_elapsed(void); // Number of milliseconds since the uint32_t last_encoder_activity_time(void); // Timestamp of the last encoder activity uint32_t last_encoder_activity_elapsed(void); // Number of milliseconds since the last encoder activity +void set_activity_timestamps(uint32_t matrix_timestamp, uint32_t encoder_timestamp); // Set the timestamps of the last matrix and encoder activity + uint32_t get_matrix_scan_rate(void); #ifdef __cplusplus diff --git a/quantum/keycode.h b/quantum/keycode.h index 701c078ad0..df1452d296 100644 --- a/quantum/keycode.h +++ b/quantum/keycode.h @@ -34,26 +34,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define IS_MOUSEKEY_WHEEL(code) (KC_MS_WH_UP <= (code) && (code) <= KC_MS_WH_RIGHT) #define IS_MOUSEKEY_ACCEL(code) (KC_MS_ACCEL0 <= (code) && (code) <= KC_MS_ACCEL2) -#define MOD_BIT(code) (1 << MOD_INDEX(code)) -#define MOD_INDEX(code) ((code)&0x07) - -#define MOD_MASK_CTRL (MOD_BIT(KC_LEFT_CTRL) | MOD_BIT(KC_RIGHT_CTRL)) -#define MOD_MASK_SHIFT (MOD_BIT(KC_LEFT_SHIFT) | MOD_BIT(KC_RIGHT_SHIFT)) -#define MOD_MASK_ALT (MOD_BIT(KC_LEFT_ALT) | MOD_BIT(KC_RIGHT_ALT)) -#define MOD_MASK_GUI (MOD_BIT(KC_LEFT_GUI) | MOD_BIT(KC_RIGHT_GUI)) -#define MOD_MASK_CS (MOD_MASK_CTRL | MOD_MASK_SHIFT) -#define MOD_MASK_CA (MOD_MASK_CTRL | MOD_MASK_ALT) -#define MOD_MASK_CG (MOD_MASK_CTRL | MOD_MASK_GUI) -#define MOD_MASK_SA (MOD_MASK_SHIFT | MOD_MASK_ALT) -#define MOD_MASK_SG (MOD_MASK_SHIFT | MOD_MASK_GUI) -#define MOD_MASK_AG (MOD_MASK_ALT | MOD_MASK_GUI) -#define MOD_MASK_CSA (MOD_MASK_CTRL | MOD_MASK_SHIFT | MOD_MASK_ALT) -#define MOD_MASK_CSG (MOD_MASK_CTRL | MOD_MASK_SHIFT | MOD_MASK_GUI) -#define MOD_MASK_CAG (MOD_MASK_CTRL | MOD_MASK_ALT | MOD_MASK_GUI) -#define MOD_MASK_SAG (MOD_MASK_SHIFT | MOD_MASK_ALT | MOD_MASK_GUI) -#define MOD_MASK_CSAG (MOD_MASK_CTRL | MOD_MASK_SHIFT | MOD_MASK_ALT | MOD_MASK_GUI) +#define MOD_BIT(code) (1 << ((code)&0x07)) // clang-format off // TODO: dd keycodes #include "keycodes.h" +#include "modifiers.h" diff --git a/quantum/keymap.h b/quantum/keymap.h index 0225f53362..1263ef188b 100644 --- a/quantum/keymap.h +++ b/quantum/keymap.h @@ -30,8 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "quantum_keycodes.h" -// translates key to keycode -uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key); +#include "keymap_common.h" #ifdef ENCODER_MAP_ENABLE // Ensure we have a forward declaration for the encoder map diff --git a/quantum/keymap_common.h b/quantum/keymap_common.h new file mode 100644 index 0000000000..20e70263f3 --- /dev/null +++ b/quantum/keymap_common.h @@ -0,0 +1,9 @@ +// Copyright 2023 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include <stdint.h> + +// translates key to keycode +uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key); diff --git a/quantum/keymap_extras/keymap_belgian.h b/quantum/keymap_extras/keymap_belgian.h index 1bf9549c5a..6851c6b4e8 100644 --- a/quantum/keymap_extras/keymap_belgian.h +++ b/quantum/keymap_extras/keymap_belgian.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_bepo.h b/quantum/keymap_extras/keymap_bepo.h index 12026ce649..448727dece 100644 --- a/quantum/keymap_extras/keymap_bepo.h +++ b/quantum/keymap_extras/keymap_bepo.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_brazilian_abnt2.h b/quantum/keymap_extras/keymap_brazilian_abnt2.h index 70a09a52be..8fac7666c2 100644 --- a/quantum/keymap_extras/keymap_brazilian_abnt2.h +++ b/quantum/keymap_extras/keymap_brazilian_abnt2.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_canadian_multilingual.h b/quantum/keymap_extras/keymap_canadian_multilingual.h index 44009f3aa2..5b9b03babb 100644 --- a/quantum/keymap_extras/keymap_canadian_multilingual.h +++ b/quantum/keymap_extras/keymap_canadian_multilingual.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_colemak.h b/quantum/keymap_extras/keymap_colemak.h index 5cb86bf441..d63309f010 100644 --- a/quantum/keymap_extras/keymap_colemak.h +++ b/quantum/keymap_extras/keymap_colemak.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_croatian.h b/quantum/keymap_extras/keymap_croatian.h index 1115592e17..3e7c681ced 100644 --- a/quantum/keymap_extras/keymap_croatian.h +++ b/quantum/keymap_extras/keymap_croatian.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_czech.h b/quantum/keymap_extras/keymap_czech.h index 02692002e3..351c51ad41 100644 --- a/quantum/keymap_extras/keymap_czech.h +++ b/quantum/keymap_extras/keymap_czech.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_danish.h b/quantum/keymap_extras/keymap_danish.h index 18107ccd53..cea9444896 100644 --- a/quantum/keymap_extras/keymap_danish.h +++ b/quantum/keymap_extras/keymap_danish.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_dvorak.h b/quantum/keymap_extras/keymap_dvorak.h index 5767530b3b..9205a72057 100644 --- a/quantum/keymap_extras/keymap_dvorak.h +++ b/quantum/keymap_extras/keymap_dvorak.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_dvorak_fr.h b/quantum/keymap_extras/keymap_dvorak_fr.h index 60675fbf13..b206767614 100644 --- a/quantum/keymap_extras/keymap_dvorak_fr.h +++ b/quantum/keymap_extras/keymap_dvorak_fr.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_dvorak_programmer.h b/quantum/keymap_extras/keymap_dvorak_programmer.h index 6e1ae17807..19187ed13b 100644 --- a/quantum/keymap_extras/keymap_dvorak_programmer.h +++ b/quantum/keymap_extras/keymap_dvorak_programmer.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_estonian.h b/quantum/keymap_extras/keymap_estonian.h index 462bcde429..ea9c56c12a 100644 --- a/quantum/keymap_extras/keymap_estonian.h +++ b/quantum/keymap_extras/keymap_estonian.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_finnish.h b/quantum/keymap_extras/keymap_finnish.h index 7e94896e2e..c0dc1af81e 100644 --- a/quantum/keymap_extras/keymap_finnish.h +++ b/quantum/keymap_extras/keymap_finnish.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_french.h b/quantum/keymap_extras/keymap_french.h index da9467a475..03dbb7bc40 100644 --- a/quantum/keymap_extras/keymap_french.h +++ b/quantum/keymap_extras/keymap_french.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_french_afnor.h b/quantum/keymap_extras/keymap_french_afnor.h index 259e0a30f4..869984c4d2 100644 --- a/quantum/keymap_extras/keymap_french_afnor.h +++ b/quantum/keymap_extras/keymap_french_afnor.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_french_mac_iso.h b/quantum/keymap_extras/keymap_french_mac_iso.h index 9a8ed72604..e5f7514a80 100644 --- a/quantum/keymap_extras/keymap_french_mac_iso.h +++ b/quantum/keymap_extras/keymap_french_mac_iso.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_german.h b/quantum/keymap_extras/keymap_german.h index 251491fb81..38b0c685ba 100644 --- a/quantum/keymap_extras/keymap_german.h +++ b/quantum/keymap_extras/keymap_german.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_german_mac_iso.h b/quantum/keymap_extras/keymap_german_mac_iso.h index de7b60546b..efa9099f20 100644 --- a/quantum/keymap_extras/keymap_german_mac_iso.h +++ b/quantum/keymap_extras/keymap_german_mac_iso.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_greek.h b/quantum/keymap_extras/keymap_greek.h index b4f5b5c5b3..01779cf2e8 100644 --- a/quantum/keymap_extras/keymap_greek.h +++ b/quantum/keymap_extras/keymap_greek.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_hebrew.h b/quantum/keymap_extras/keymap_hebrew.h index 372d7f2e93..284562072d 100644 --- a/quantum/keymap_extras/keymap_hebrew.h +++ b/quantum/keymap_extras/keymap_hebrew.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_hungarian.h b/quantum/keymap_extras/keymap_hungarian.h index 591d71c09c..fbc31ed155 100644 --- a/quantum/keymap_extras/keymap_hungarian.h +++ b/quantum/keymap_extras/keymap_hungarian.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_icelandic.h b/quantum/keymap_extras/keymap_icelandic.h index 800899b515..3bd71c19f2 100644 --- a/quantum/keymap_extras/keymap_icelandic.h +++ b/quantum/keymap_extras/keymap_icelandic.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_irish.h b/quantum/keymap_extras/keymap_irish.h index 2cd63a48e3..6e161628c8 100644 --- a/quantum/keymap_extras/keymap_irish.h +++ b/quantum/keymap_extras/keymap_irish.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_italian.h b/quantum/keymap_extras/keymap_italian.h index 95f3348f63..8092dc1301 100644 --- a/quantum/keymap_extras/keymap_italian.h +++ b/quantum/keymap_extras/keymap_italian.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_italian_mac_ansi.h b/quantum/keymap_extras/keymap_italian_mac_ansi.h index 5e7e2a37e8..ae1281be26 100644 --- a/quantum/keymap_extras/keymap_italian_mac_ansi.h +++ b/quantum/keymap_extras/keymap_italian_mac_ansi.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_italian_mac_iso.h b/quantum/keymap_extras/keymap_italian_mac_iso.h index 1d30451376..f3f01839c3 100644 --- a/quantum/keymap_extras/keymap_italian_mac_iso.h +++ b/quantum/keymap_extras/keymap_italian_mac_iso.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_japanese.h b/quantum/keymap_extras/keymap_japanese.h index 286863deea..947317833e 100644 --- a/quantum/keymap_extras/keymap_japanese.h +++ b/quantum/keymap_extras/keymap_japanese.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_korean.h b/quantum/keymap_extras/keymap_korean.h index 073647de7f..440a6b3b4d 100644 --- a/quantum/keymap_extras/keymap_korean.h +++ b/quantum/keymap_extras/keymap_korean.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_latvian.h b/quantum/keymap_extras/keymap_latvian.h index e3ac1cd433..2f26b1d8af 100644 --- a/quantum/keymap_extras/keymap_latvian.h +++ b/quantum/keymap_extras/keymap_latvian.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_lithuanian_azerty.h b/quantum/keymap_extras/keymap_lithuanian_azerty.h index 11de3ad030..f6dd94f0ca 100644 --- a/quantum/keymap_extras/keymap_lithuanian_azerty.h +++ b/quantum/keymap_extras/keymap_lithuanian_azerty.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_lithuanian_qwerty.h b/quantum/keymap_extras/keymap_lithuanian_qwerty.h index c27389971e..03c6b7a2af 100644 --- a/quantum/keymap_extras/keymap_lithuanian_qwerty.h +++ b/quantum/keymap_extras/keymap_lithuanian_qwerty.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_neo2.h b/quantum/keymap_extras/keymap_neo2.h index e8352ffa08..bc9445892f 100644 --- a/quantum/keymap_extras/keymap_neo2.h +++ b/quantum/keymap_extras/keymap_neo2.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_nordic.h b/quantum/keymap_extras/keymap_nordic.h index e336916713..6464966c71 100644 --- a/quantum/keymap_extras/keymap_nordic.h +++ b/quantum/keymap_extras/keymap_nordic.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_norman.h b/quantum/keymap_extras/keymap_norman.h index 1f773bb410..1a3a0bc53a 100644 --- a/quantum/keymap_extras/keymap_norman.h +++ b/quantum/keymap_extras/keymap_norman.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_norwegian.h b/quantum/keymap_extras/keymap_norwegian.h index 33193d6a4d..af16fec8d6 100644 --- a/quantum/keymap_extras/keymap_norwegian.h +++ b/quantum/keymap_extras/keymap_norwegian.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_plover.h b/quantum/keymap_extras/keymap_plover.h index b51e44b8bb..c0e3311e90 100644 --- a/quantum/keymap_extras/keymap_plover.h +++ b/quantum/keymap_extras/keymap_plover.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_plover_dvorak.h b/quantum/keymap_extras/keymap_plover_dvorak.h index f8341f8cbc..7feb52a25c 100644 --- a/quantum/keymap_extras/keymap_plover_dvorak.h +++ b/quantum/keymap_extras/keymap_plover_dvorak.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_polish.h b/quantum/keymap_extras/keymap_polish.h index 6b37d77a0a..40870ec237 100644 --- a/quantum/keymap_extras/keymap_polish.h +++ b/quantum/keymap_extras/keymap_polish.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_portuguese.h b/quantum/keymap_extras/keymap_portuguese.h index 17da9a6c11..b4570ad922 100644 --- a/quantum/keymap_extras/keymap_portuguese.h +++ b/quantum/keymap_extras/keymap_portuguese.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_portuguese_mac_iso.h b/quantum/keymap_extras/keymap_portuguese_mac_iso.h index 3d34a39ae5..57a27d04e9 100644 --- a/quantum/keymap_extras/keymap_portuguese_mac_iso.h +++ b/quantum/keymap_extras/keymap_portuguese_mac_iso.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_romanian.h b/quantum/keymap_extras/keymap_romanian.h index fb48a0fda7..cf4c17125f 100644 --- a/quantum/keymap_extras/keymap_romanian.h +++ b/quantum/keymap_extras/keymap_romanian.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_russian.h b/quantum/keymap_extras/keymap_russian.h index 3643718444..fd3a1604c8 100644 --- a/quantum/keymap_extras/keymap_russian.h +++ b/quantum/keymap_extras/keymap_russian.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_serbian.h b/quantum/keymap_extras/keymap_serbian.h index dd1bda7533..732e2e939d 100644 --- a/quantum/keymap_extras/keymap_serbian.h +++ b/quantum/keymap_extras/keymap_serbian.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_serbian_latin.h b/quantum/keymap_extras/keymap_serbian_latin.h index 83495b63be..5151696a10 100644 --- a/quantum/keymap_extras/keymap_serbian_latin.h +++ b/quantum/keymap_extras/keymap_serbian_latin.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_slovak.h b/quantum/keymap_extras/keymap_slovak.h index 10714f1be9..81a88fa25c 100644 --- a/quantum/keymap_extras/keymap_slovak.h +++ b/quantum/keymap_extras/keymap_slovak.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_slovenian.h b/quantum/keymap_extras/keymap_slovenian.h index 30910530e0..1e17342c27 100644 --- a/quantum/keymap_extras/keymap_slovenian.h +++ b/quantum/keymap_extras/keymap_slovenian.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_spanish.h b/quantum/keymap_extras/keymap_spanish.h index cac16c08a5..bcdd5af0c2 100644 --- a/quantum/keymap_extras/keymap_spanish.h +++ b/quantum/keymap_extras/keymap_spanish.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_spanish_dvorak.h b/quantum/keymap_extras/keymap_spanish_dvorak.h index 1feab96b8c..fb033df770 100644 --- a/quantum/keymap_extras/keymap_spanish_dvorak.h +++ b/quantum/keymap_extras/keymap_spanish_dvorak.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_steno.h b/quantum/keymap_extras/keymap_steno.h index 07d96b7465..852b2f7121 100644 --- a/quantum/keymap_extras/keymap_steno.h +++ b/quantum/keymap_extras/keymap_steno.h @@ -16,7 +16,7 @@ #pragma once -#include "keymap.h" +#include "keycodes.h" // List of keycodes for the steno keyboard. To prevent // errors, this must be <= 42 total entries in order to diff --git a/quantum/keymap_extras/keymap_swedish.h b/quantum/keymap_extras/keymap_swedish.h index 4cdf4879c3..acb49f7773 100644 --- a/quantum/keymap_extras/keymap_swedish.h +++ b/quantum/keymap_extras/keymap_swedish.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_swedish_mac_ansi.h b/quantum/keymap_extras/keymap_swedish_mac_ansi.h index 9649f59dd0..ef48a9e493 100644 --- a/quantum/keymap_extras/keymap_swedish_mac_ansi.h +++ b/quantum/keymap_extras/keymap_swedish_mac_ansi.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_swedish_mac_iso.h b/quantum/keymap_extras/keymap_swedish_mac_iso.h index 068c81b020..2eaef5e60c 100644 --- a/quantum/keymap_extras/keymap_swedish_mac_iso.h +++ b/quantum/keymap_extras/keymap_swedish_mac_iso.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_swedish_pro_mac_ansi.h b/quantum/keymap_extras/keymap_swedish_pro_mac_ansi.h index c0692ababd..d33a259023 100644 --- a/quantum/keymap_extras/keymap_swedish_pro_mac_ansi.h +++ b/quantum/keymap_extras/keymap_swedish_pro_mac_ansi.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_swedish_pro_mac_iso.h b/quantum/keymap_extras/keymap_swedish_pro_mac_iso.h index e01f0a7dc3..680bd1db9e 100644 --- a/quantum/keymap_extras/keymap_swedish_pro_mac_iso.h +++ b/quantum/keymap_extras/keymap_swedish_pro_mac_iso.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_swiss_de.h b/quantum/keymap_extras/keymap_swiss_de.h index 0a6e6e4918..69bba7293e 100644 --- a/quantum/keymap_extras/keymap_swiss_de.h +++ b/quantum/keymap_extras/keymap_swiss_de.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_swiss_fr.h b/quantum/keymap_extras/keymap_swiss_fr.h index 05a4a4c279..1e2f833db1 100644 --- a/quantum/keymap_extras/keymap_swiss_fr.h +++ b/quantum/keymap_extras/keymap_swiss_fr.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_turkish_f.h b/quantum/keymap_extras/keymap_turkish_f.h index 0dfc0236e8..4fdcf3f746 100644 --- a/quantum/keymap_extras/keymap_turkish_f.h +++ b/quantum/keymap_extras/keymap_turkish_f.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_turkish_q.h b/quantum/keymap_extras/keymap_turkish_q.h index cc64300b18..5a9362acb4 100644 --- a/quantum/keymap_extras/keymap_turkish_q.h +++ b/quantum/keymap_extras/keymap_turkish_q.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_uk.h b/quantum/keymap_extras/keymap_uk.h index ff6f8c9c2e..71e5f38f55 100644 --- a/quantum/keymap_extras/keymap_uk.h +++ b/quantum/keymap_extras/keymap_uk.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_ukrainian.h b/quantum/keymap_extras/keymap_ukrainian.h index b954bb2398..3f3ec4cec2 100644 --- a/quantum/keymap_extras/keymap_ukrainian.h +++ b/quantum/keymap_extras/keymap_ukrainian.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_us.h b/quantum/keymap_extras/keymap_us.h index 38df8c6336..6101c8d8ba 100644 --- a/quantum/keymap_extras/keymap_us.h +++ b/quantum/keymap_extras/keymap_us.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_us_extended.h b/quantum/keymap_extras/keymap_us_extended.h index c4f627c30d..90da98c756 100644 --- a/quantum/keymap_extras/keymap_us_extended.h +++ b/quantum/keymap_extras/keymap_us_extended.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_us_international.h b/quantum/keymap_extras/keymap_us_international.h index 1f2bc33476..bd5f21ec8c 100644 --- a/quantum/keymap_extras/keymap_us_international.h +++ b/quantum/keymap_extras/keymap_us_international.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_us_international_linux.h b/quantum/keymap_extras/keymap_us_international_linux.h index 16d072cc5b..4551cbe29f 100644 --- a/quantum/keymap_extras/keymap_us_international_linux.h +++ b/quantum/keymap_extras/keymap_us_international_linux.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_workman.h b/quantum/keymap_extras/keymap_workman.h index 5fe9d36b16..808caec054 100644 --- a/quantum/keymap_extras/keymap_workman.h +++ b/quantum/keymap_extras/keymap_workman.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_extras/keymap_workman_zxcvm.h b/quantum/keymap_extras/keymap_workman_zxcvm.h index 757f98e912..f8645ac4cf 100644 --- a/quantum/keymap_extras/keymap_workman_zxcvm.h +++ b/quantum/keymap_extras/keymap_workman_zxcvm.h @@ -24,7 +24,7 @@ *******************************************************************************/ #pragma once -#include "keymap.h" +#include "keycodes.h" // clang-format off // Aliases diff --git a/quantum/keymap_introspection.h b/quantum/keymap_introspection.h index a8df3928a6..201de937cb 100644 --- a/quantum/keymap_introspection.h +++ b/quantum/keymap_introspection.h @@ -3,6 +3,7 @@ #pragma once #include <stdint.h> +#include <stdbool.h> //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Key mapping diff --git a/quantum/leader.h b/quantum/leader.h index 1999006c56..3177fcd196 100644 --- a/quantum/leader.h +++ b/quantum/leader.h @@ -5,9 +5,9 @@ #include <stdint.h> /** - * \defgroup leader + * \file * - * Leader Key + * \defgroup leader Leader Key * \{ */ diff --git a/quantum/midi/midi.c b/quantum/midi/midi.c index 1ba3e73a40..1c481f2f0b 100644 --- a/quantum/midi/midi.c +++ b/quantum/midi/midi.c @@ -18,10 +18,7 @@ #include "midi.h" #include <string.h> //for memcpy - -#ifndef MIN -# define MIN(x, y) (((x) < (y)) ? (x) : (y)) -#endif +#include "util.h" #ifndef NULL # define NULL 0 diff --git a/quantum/modifiers.h b/quantum/modifiers.h new file mode 100644 index 0000000000..45bcd6508d --- /dev/null +++ b/quantum/modifiers.h @@ -0,0 +1,54 @@ +// Copyright 2023 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +/** \brief 5-bit packed modifiers + * + * Mod bits: 43210 + * bit 0 ||||+- Control + * bit 1 |||+-- Shift + * bit 2 ||+--- Alt + * bit 3 |+---- Gui + * bit 4 +----- LR flag(Left:0, Right:1) + */ +enum mods_5bit { + MOD_LCTL = 0x01, + MOD_LSFT = 0x02, + MOD_LALT = 0x04, + MOD_LGUI = 0x08, + MOD_RCTL = 0x11, + MOD_RSFT = 0x12, + MOD_RALT = 0x14, + MOD_RGUI = 0x18, +}; +#define MOD_HYPR (MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI) +#define MOD_MEH (MOD_LCTL | MOD_LSFT | MOD_LALT) + +/** \brief 8-bit packed modifiers + */ +enum mods_8bit { + MOD_BIT_LCTRL = 0b00000001, + MOD_BIT_LSHIFT = 0b00000010, + MOD_BIT_LALT = 0b00000100, + MOD_BIT_LGUI = 0b00001000, + MOD_BIT_RCTRL = 0b00010000, + MOD_BIT_RSHIFT = 0b00100000, + MOD_BIT_RALT = 0b01000000, + MOD_BIT_RGUI = 0b10000000, +}; +#define MOD_MASK_CTRL (MOD_BIT_LCTRL | MOD_BIT_RCTRL) +#define MOD_MASK_SHIFT (MOD_BIT_LSHIFT | MOD_BIT_RSHIFT) +#define MOD_MASK_ALT (MOD_BIT_LALT | MOD_BIT_RALT) +#define MOD_MASK_GUI (MOD_BIT_LGUI | MOD_BIT_RGUI) +#define MOD_MASK_CS (MOD_MASK_CTRL | MOD_MASK_SHIFT) +#define MOD_MASK_CA (MOD_MASK_CTRL | MOD_MASK_ALT) +#define MOD_MASK_CG (MOD_MASK_CTRL | MOD_MASK_GUI) +#define MOD_MASK_SA (MOD_MASK_SHIFT | MOD_MASK_ALT) +#define MOD_MASK_SG (MOD_MASK_SHIFT | MOD_MASK_GUI) +#define MOD_MASK_AG (MOD_MASK_ALT | MOD_MASK_GUI) +#define MOD_MASK_CSA (MOD_MASK_CTRL | MOD_MASK_SHIFT | MOD_MASK_ALT) +#define MOD_MASK_CSG (MOD_MASK_CTRL | MOD_MASK_SHIFT | MOD_MASK_GUI) +#define MOD_MASK_CAG (MOD_MASK_CTRL | MOD_MASK_ALT | MOD_MASK_GUI) +#define MOD_MASK_SAG (MOD_MASK_SHIFT | MOD_MASK_ALT | MOD_MASK_GUI) +#define MOD_MASK_CSAG (MOD_MASK_CTRL | MOD_MASK_SHIFT | MOD_MASK_ALT | MOD_MASK_GUI) diff --git a/quantum/painter/qp.h b/quantum/painter/qp.h index 00f5d7931a..7222d3b413 100644 --- a/quantum/painter/qp.h +++ b/quantum/painter/qp.h @@ -1,4 +1,4 @@ -// Copyright 2021 Nick Brassel (@tzarc) +// Copyright 2021-2023 Nick Brassel (@tzarc) // SPDX-License-Identifier: GPL-2.0-or-later #pragma once @@ -11,6 +11,22 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Quantum Painter global configurables (add to your keyboard's config.h) +#ifndef QUANTUM_PAINTER_DISPLAY_TIMEOUT +/** + * @def This controls the amount of time (in milliseconds) that all displays will remain on after the last user input. + * If set to 0, the display will remain on indefinitely. + */ +# define QUANTUM_PAINTER_DISPLAY_TIMEOUT 30000 +#endif // QUANTUM_PAINTER_DISPLAY_TIMEOUT + +#ifndef QUANTUM_PAINTER_TASK_THROTTLE +/** + * @def This controls the amount of time (in milliseconds) that the Quantum Painter internal task will wait between + * each execution. + */ +# define QUANTUM_PAINTER_TASK_THROTTLE 1 +#endif // QUANTUM_PAINTER_TASK_THROTTLE + #ifndef QUANTUM_PAINTER_NUM_IMAGES /** * @def This controls the maximum number of images that Quantum Painter can load at any one time. Images can be loaded @@ -53,7 +69,7 @@ * @def This controls the maximum size of the pixel data buffer used for single blocks of transmission. Larger buffers * means more data is processed at one time, with less frequent transmissions, at the cost of RAM. */ -# define QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE 32 +# define QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE 1024 #endif #ifndef QUANTUM_PAINTER_SUPPORTS_256_PALETTE @@ -442,34 +458,50 @@ int16_t qp_drawtext_recolor(painter_device_t device, uint16_t x, uint16_t y, pai #ifdef QUANTUM_PAINTER_RGB565_SURFACE_ENABLE # include "qp_rgb565_surface.h" +#else // QUANTUM_PAINTER_RGB565_SURFACE_ENABLE +# define RGB565_SURFACE_NUM_DEVICES 0 #endif // QUANTUM_PAINTER_RGB565_SURFACE_ENABLE #ifdef QUANTUM_PAINTER_ILI9163_ENABLE # include "qp_ili9163.h" +#else // QUANTUM_PAINTER_ILI9163_ENABLE +# define ILI9163_NUM_DEVICES 0 #endif // QUANTUM_PAINTER_ILI9163_ENABLE #ifdef QUANTUM_PAINTER_ILI9341_ENABLE # include "qp_ili9341.h" +#else // QUANTUM_PAINTER_ILI9341_ENABLE +# define ILI9341_NUM_DEVICES 0 #endif // QUANTUM_PAINTER_ILI9341_ENABLE #ifdef QUANTUM_PAINTER_ILI9488_ENABLE # include "qp_ili9488.h" +#else // QUANTUM_PAINTER_ILI9488_ENABLE +# define ILI9488_NUM_DEVICES 0 #endif // QUANTUM_PAINTER_ILI9488_ENABLE #ifdef QUANTUM_PAINTER_ST7789_ENABLE # include "qp_st7789.h" +#else // QUANTUM_PAINTER_ST7789_ENABLE +# define ST7789_NUM_DEVICES 0 #endif // QUANTUM_PAINTER_ST7789_ENABLE #ifdef QUANTUM_PAINTER_ST7735_ENABLE # include "qp_st7735.h" +#else // QUANTUM_PAINTER_ST7735_ENABLE +# define ST7735_NUM_DEVICES 0 #endif // QUANTUM_PAINTER_ST7735_ENABLE #ifdef QUANTUM_PAINTER_GC9A01_ENABLE # include "qp_gc9a01.h" +#else // QUANTUM_PAINTER_GC9A01_ENABLE +# define GC9A01_NUM_DEVICES 0 #endif // QUANTUM_PAINTER_GC9A01_ENABLE #ifdef QUANTUM_PAINTER_SSD1351_ENABLE # include "qp_ssd1351.h" +#else // QUANTUM_PAINTER_SSD1351_ENABLE +# define SSD1351_NUM_DEVICES 0 #endif // QUANTUM_PAINTER_SSD1351_ENABLE //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/quantum/painter/qp_draw_image.c b/quantum/painter/qp_draw_image.c index fa80617242..e722f3cf02 100644 --- a/quantum/painter/qp_draw_image.c +++ b/quantum/painter/qp_draw_image.c @@ -1,4 +1,4 @@ -// Copyright 2021 Nick Brassel (@tzarc) +// Copyright 2021-2023 Nick Brassel (@tzarc) // SPDX-License-Identifier: GPL-2.0-or-later #include "qp_internal.h" @@ -414,15 +414,3 @@ void qp_internal_animation_tick(void) { static uint32_t last_anim_exec = 0; deferred_exec_advanced_task(animation_executors, QUANTUM_PAINTER_CONCURRENT_ANIMATIONS, &last_anim_exec); } - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Quantum Painter Core API: qp_internal_task - -void qp_internal_task(void) { - qp_internal_animation_tick(); -#ifdef QUANTUM_PAINTER_LVGL_INTEGRATION_ENABLE - // Run LVGL ticks - void qp_lvgl_internal_tick(void); - qp_lvgl_internal_tick(); -#endif -} diff --git a/quantum/painter/qp_internal.c b/quantum/painter/qp_internal.c new file mode 100644 index 0000000000..ea23aef7c3 --- /dev/null +++ b/quantum/painter/qp_internal.c @@ -0,0 +1,96 @@ +// Copyright 2023 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "qp_internal.h" + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Quantum Painter Core API: device registration + +enum { + // Work out how many devices we're actually going to be instantiating + // NOTE: We intentionally do not include surfaces here, despite them conforming to the same API. + QP_NUM_DEVICES = (ILI9163_NUM_DEVICES) // ILI9163 + + (ILI9341_NUM_DEVICES) // ILI9341 + + (ILI9488_NUM_DEVICES) // ILI9488 + + (ST7789_NUM_DEVICES) // ST7789 + + (ST7735_NUM_DEVICES) // ST7735 + + (GC9A01_NUM_DEVICES) // GC9A01 + + (SSD1351_NUM_DEVICES) // SSD1351 +}; + +static painter_device_t qp_devices[QP_NUM_DEVICES] = {NULL}; + +bool qp_internal_register_device(painter_device_t driver) { + for (uint8_t i = 0; i < QP_NUM_DEVICES; i++) { + if (qp_devices[i] == NULL) { + qp_devices[i] = driver; + return true; + } + } + + // We should never get here -- someone has screwed up their device counts during config + qp_dprintf("qp_internal_register_device: no more space for devices!\n"); + return false; +} + +#if (QUANTUM_PAINTER_DISPLAY_TIMEOUT) > 0 +static void qp_internal_display_timeout_task(void) { + // Handle power on/off state + static bool display_on = true; + bool should_change_display_state = false; + bool target_display_state = false; + if (last_input_activity_elapsed() < (QUANTUM_PAINTER_DISPLAY_TIMEOUT)) { + should_change_display_state = display_on == false; + target_display_state = true; + } else { + should_change_display_state = display_on == true; + target_display_state = false; + } + + if (should_change_display_state) { + for (uint8_t i = 0; i < QP_NUM_DEVICES; i++) { + if (qp_devices[i] != NULL) { + qp_power(qp_devices[i], target_display_state); + } + } + + display_on = target_display_state; + } +} +#endif // (QUANTUM_PAINTER_DISPLAY_TIMEOUT) > 0 + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Quantum Painter Core API: qp_internal_task + +_Static_assert((QUANTUM_PAINTER_TASK_THROTTLE) > 0 && (QUANTUM_PAINTER_TASK_THROTTLE) < 1000, "QUANTUM_PAINTER_TASK_THROTTLE must be between 1 and 999"); + +void qp_internal_task(void) { + // Perform throttling of the internal processing of Quantum Painter + static uint32_t last_tick = 0; + uint32_t now = timer_read32(); + if (TIMER_DIFF_32(now, last_tick) < (QUANTUM_PAINTER_TASK_THROTTLE)) { + return; + } + last_tick = now; + +#if (QUANTUM_PAINTER_DISPLAY_TIMEOUT) > 0 + qp_internal_display_timeout_task(); +#endif // (QUANTUM_PAINTER_DISPLAY_TIMEOUT) > 0 + + // Handle animations + void qp_internal_animation_tick(void); + qp_internal_animation_tick(); + +#ifdef QUANTUM_PAINTER_LVGL_INTEGRATION_ENABLE + // Run LVGL ticks + void qp_lvgl_internal_tick(void); + qp_lvgl_internal_tick(); +#endif + + // Flush (render) dirty regions to corresponding displays + for (uint8_t i = 0; i < QP_NUM_DEVICES; i++) { + if (qp_devices[i] != NULL) { + qp_flush(qp_devices[i]); + } + } +} diff --git a/quantum/painter/qp_internal_driver.h b/quantum/painter/qp_internal_driver.h index 82a0178a73..c976ff9db7 100644 --- a/quantum/painter/qp_internal_driver.h +++ b/quantum/painter/qp_internal_driver.h @@ -1,4 +1,4 @@ -// Copyright 2021 Nick Brassel (@tzarc) +// Copyright 2021-2023 Nick Brassel (@tzarc) // SPDX-License-Identifier: GPL-2.0-or-later #pragma once @@ -82,3 +82,8 @@ struct painter_driver_t { // Comms config pointer -- needs to point to an appropriate comms config if the comms driver requires it. void *comms_config; }; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Device internals + +bool qp_internal_register_device(painter_device_t driver); diff --git a/quantum/painter/rules.mk b/quantum/painter/rules.mk index 199e406dd6..7752936cbd 100644 --- a/quantum/painter/rules.mk +++ b/quantum/painter/rules.mk @@ -24,6 +24,7 @@ SRC += \ $(QUANTUM_DIR)/unicode/utf8.c \ $(QUANTUM_DIR)/color.c \ $(QUANTUM_DIR)/painter/qp.c \ + $(QUANTUM_DIR)/painter/qp_internal.c \ $(QUANTUM_DIR)/painter/qp_stream.c \ $(QUANTUM_DIR)/painter/qgf.c \ $(QUANTUM_DIR)/painter/qff.c \ diff --git a/quantum/programmable_button.h b/quantum/programmable_button.h index e8c916d75c..4c2cd534fe 100644 --- a/quantum/programmable_button.h +++ b/quantum/programmable_button.h @@ -21,9 +21,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <stdbool.h> /** - * \defgroup programmable_button + * \file * - * HID Programmable Buttons + * \defgroup programmable_button HID Programmable Buttons * \{ */ diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c index 19d80e0097..02188df95b 100644 --- a/quantum/rgblight/rgblight.c +++ b/quantum/rgblight/rgblight.c @@ -21,6 +21,7 @@ #include "rgblight.h" #include "color.h" #include "debug.h" +#include "util.h" #include "led_tables.h" #include <lib/lib8tion/lib8tion.h> #ifdef EEPROM_ENABLE @@ -30,13 +31,6 @@ # include "velocikey.h" #endif -#ifndef MIN -# define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif -#ifndef MAX -# define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif - #ifdef RGBLIGHT_SPLIT /* for split keyboard */ # define RGBLIGHT_SPLIT_SET_CHANGE_MODE rgblight_status.change_flags |= RGBLIGHT_STATUS_CHANGE_MODE @@ -422,6 +416,10 @@ void rgblight_disable_noeeprom(void) { rgblight_set(); } +void rgblight_enabled_noeeprom(bool state) { + state ? rgblight_enable_noeeprom() : rgblight_disable_noeeprom(); +} + bool rgblight_is_enabled(void) { return rgblight_config.enable; } diff --git a/quantum/rgblight/rgblight.h b/quantum/rgblight/rgblight.h index 7693888462..c71da29332 100644 --- a/quantum/rgblight/rgblight.h +++ b/quantum/rgblight/rgblight.h @@ -321,6 +321,7 @@ void rgblight_enable(void); void rgblight_enable_noeeprom(void); void rgblight_disable(void); void rgblight_disable_noeeprom(void); +void rgblight_enabled_noeeprom(bool state); /* hue, sat, val change */ void rgblight_increase_hue(void); diff --git a/quantum/secure.h b/quantum/secure.h index bb2ba50f31..ae9b5b9045 100644 --- a/quantum/secure.h +++ b/quantum/secure.h @@ -3,10 +3,15 @@ #pragma once -/** \file +/** + * \file * - * Exposes a set of functionality to act as a virtual padlock for your device - * ... As long as that padlock is made of paper and its currently raining. + * \defgroup secure Secure API + * + * \brief Exposes a set of functionality to act as a virtual padlock for your device + * ...as long as that padlock is made of paper and it's currently raining. + * + * \{ */ #include <stdint.h> @@ -77,3 +82,5 @@ bool secure_hook_user(secure_status_t secure_status); /** \brief keyboard hook called when changing secure status device */ bool secure_hook_kb(secure_status_t secure_status); + +/** \} */ diff --git a/quantum/send_string/send_string.h b/quantum/send_string/send_string.h index 4eb55b88dc..dbaed43ebc 100644 --- a/quantum/send_string/send_string.h +++ b/quantum/send_string/send_string.h @@ -15,9 +15,11 @@ */ /** - * \defgroup send_string + * \file * - * Send String API. These functions allow you to create macros by typing out sequences of keystrokes. + * \defgroup send_string Send String API + * + * \brief These functions allow you to create macros by typing out sequences of keystrokes. * \{ */ diff --git a/quantum/split_common/transaction_id_define.h b/quantum/split_common/transaction_id_define.h index 18d3826b83..4932530aa3 100644 --- a/quantum/split_common/transaction_id_define.h +++ b/quantum/split_common/transaction_id_define.h @@ -92,6 +92,10 @@ enum serial_transaction_id { PUT_HAPTIC, #endif // defined(HAPTIC_ENABLE) && defined(SPLIT_HAPTIC_ENABLE) +#if defined(SPLIT_ACTIVITY_ENABLE) + PUT_ACTIVITY, +#endif // SPLIT_ACTIVITY_ENABLE + #if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) PUT_RPC_INFO, PUT_RPC_REQ_DATA, diff --git a/quantum/split_common/transactions.c b/quantum/split_common/transactions.c index 8e1961b586..ec34bbba60 100644 --- a/quantum/split_common/transactions.c +++ b/quantum/split_common/transactions.c @@ -790,6 +790,34 @@ static void haptic_handlers_slave(matrix_row_t master_matrix[], matrix_row_t sla #endif // defined(HAPTIC_ENABLE) && defined(SPLIT_HAPTIC_ENABLE) +#if defined(SPLIT_ACTIVITY_ENABLE) + +static bool activity_handlers_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { + static uint32_t last_update = 0; + split_slave_activity_sync_t activity_sync; + activity_sync.matrix_timestamp = last_matrix_activity_time(); + activity_sync.encoder_timestamp = last_encoder_activity_time(); + return send_if_data_mismatch(PUT_ACTIVITY, &last_update, &activity_sync, &split_shmem->activity_sync, sizeof(activity_sync)); +} + +static void activity_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { + set_activity_timestamps(split_shmem->activity_sync.matrix_timestamp, split_shmem->activity_sync.encoder_timestamp); +} + +// clang-format off +# define TRANSACTIONS_ACTIVITY_MASTER() TRANSACTION_HANDLER_MASTER(activity) +# define TRANSACTIONS_ACTIVITY_SLAVE() TRANSACTION_HANDLER_SLAVE_AUTOLOCK(activity) +# define TRANSACTIONS_ACTIVITY_REGISTRATIONS [PUT_ACTIVITY] = trans_initiator2target_initializer(activity_sync), +// clang-format on + +#else // defined(SPLIT_ACTIVITY_ENABLE) + +# define TRANSACTIONS_ACTIVITY_MASTER() +# define TRANSACTIONS_ACTIVITY_SLAVE() +# define TRANSACTIONS_ACTIVITY_REGISTRATIONS + +#endif // defined(SPLIT_ACTIVITY_ENABLE) + //////////////////////////////////////////////////// split_transaction_desc_t split_transaction_table[NUM_TOTAL_TRANSACTIONS] = { @@ -818,6 +846,7 @@ split_transaction_desc_t split_transaction_table[NUM_TOTAL_TRANSACTIONS] = { TRANSACTIONS_POINTING_REGISTRATIONS TRANSACTIONS_WATCHDOG_REGISTRATIONS TRANSACTIONS_HAPTIC_REGISTRATIONS + TRANSACTIONS_ACTIVITY_REGISTRATIONS // clang-format on #if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) @@ -846,6 +875,7 @@ bool transactions_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix TRANSACTIONS_POINTING_MASTER(); TRANSACTIONS_WATCHDOG_MASTER(); TRANSACTIONS_HAPTIC_MASTER(); + TRANSACTIONS_ACTIVITY_MASTER(); return true; } @@ -867,6 +897,7 @@ void transactions_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[ TRANSACTIONS_POINTING_SLAVE(); TRANSACTIONS_WATCHDOG_SLAVE(); TRANSACTIONS_HAPTIC_SLAVE(); + TRANSACTIONS_ACTIVITY_SLAVE(); } #if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) diff --git a/quantum/split_common/transport.h b/quantum/split_common/transport.h index adee4470d2..8f8c38461e 100644 --- a/quantum/split_common/transport.h +++ b/quantum/split_common/transport.h @@ -122,6 +122,14 @@ typedef struct _split_slave_haptic_sync_t { } split_slave_haptic_sync_t; #endif // defined(HAPTIC_ENABLE) && defined(SPLIT_HAPTIC_ENABLE) +#if defined(SPLIT_ACTIVITY_ENABLE) +# include "keyboard.h" +typedef struct _split_slave_activity_sync_t { + uint32_t matrix_timestamp; + uint32_t encoder_timestamp; +} split_slave_activity_sync_t; +#endif // defined(SPLIT_ACTIVITY_ENABLE) + #if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) typedef struct _rpc_sync_info_t { uint8_t checksum; @@ -204,6 +212,10 @@ typedef struct _split_shared_memory_t { split_slave_haptic_sync_t haptic_sync; #endif // defined(HAPTIC_ENABLE) +#if defined(SPLIT_ACTIVITY_ENABLE) + split_slave_activity_sync_t activity_sync; +#endif // defined(SPLIT_ACTIVITY_ENABLE) + #if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) rpc_sync_info_t rpc_info; uint8_t rpc_m2s_buffer[RPC_M2S_BUFFER_SIZE]; diff --git a/quantum/velocikey.c b/quantum/velocikey.c index 58e14215bb..03e91911f6 100644 --- a/quantum/velocikey.c +++ b/quantum/velocikey.c @@ -2,13 +2,7 @@ #include "timer.h" #include "eeconfig.h" #include "eeprom.h" - -#ifndef MIN -# define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif -#ifndef MAX -# define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif +#include "util.h" #define TYPING_SPEED_MAX_VALUE 200 uint8_t typing_speed = 0; |