From d983251c10c4bb152c746dc4e94bc954b1b82c8c Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 29 Aug 2022 02:59:40 +1000 Subject: Switch over MANUFACTURER and PRODUCT to string literals (#18183) --- quantum/util.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'quantum') diff --git a/quantum/util.h b/quantum/util.h index ab96ce4bde..21c290013c 100644 --- a/quantum/util.h +++ b/quantum/util.h @@ -18,9 +18,6 @@ along with this program. If not, see . #include "bitwise.h" -// convert to L string -#define LSTR(s) XLSTR(s) -#define XLSTR(s) L## #s // convert to string #define STR(s) XSTR(s) #define XSTR(s) #s -- cgit v1.2.3 From f2edb73974d15b88ea9614002b18b045551b71d8 Mon Sep 17 00:00:00 2001 From: Drzony Date: Mon, 29 Aug 2022 06:34:42 +0200 Subject: Fix mouse report comparison failing on shared EP (#18060) Co-authored-by: Dasky <32983009+daskygit@users.noreply.github.com> --- quantum/pointing_device/pointing_device.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'quantum') diff --git a/quantum/pointing_device/pointing_device.c b/quantum/pointing_device/pointing_device.c index 505a7a6ffd..ae3f122e89 100644 --- a/quantum/pointing_device/pointing_device.c +++ b/quantum/pointing_device/pointing_device.c @@ -166,11 +166,9 @@ __attribute__((weak)) void pointing_device_send(void) { host_mouse_send(&local_mouse_report); } // send it and 0 it out except for buttons, so those stay until they are explicity over-ridden using update_pointing_device - local_mouse_report.x = 0; - local_mouse_report.y = 0; - local_mouse_report.v = 0; - local_mouse_report.h = 0; - + uint8_t buttons = local_mouse_report.buttons; + memset(&local_mouse_report, 0, sizeof(local_mouse_report)); + local_mouse_report.buttons = buttons; memcpy(&old_report, &local_mouse_report, sizeof(local_mouse_report)); } -- cgit v1.2.3 From d910e8df77150bab0b9cc2c3794554b4c8c81d71 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Mon, 29 Aug 2022 14:53:08 +1000 Subject: Use `TAP_CODE_DELAY` for encoder mapping by default (#18098) --- quantum/encoder.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'quantum') diff --git a/quantum/encoder.c b/quantum/encoder.c index 5f8a7ce080..1393e34868 100644 --- a/quantum/encoder.c +++ b/quantum/encoder.c @@ -24,7 +24,8 @@ #include #ifndef ENCODER_MAP_KEY_DELAY -# define ENCODER_MAP_KEY_DELAY 2 +# include "action.h" +# define ENCODER_MAP_KEY_DELAY TAP_CODE_DELAY #endif #if !defined(ENCODER_RESOLUTIONS) && !defined(ENCODER_RESOLUTION) @@ -143,9 +144,14 @@ void encoder_init(void) { static void encoder_exec_mapping(uint8_t index, bool clockwise) { // The delays below cater for Windows and its wonderful requirements. action_exec(clockwise ? ENCODER_CW_EVENT(index, true) : ENCODER_CCW_EVENT(index, true)); +# if ENCODER_MAP_KEY_DELAY > 0 wait_ms(ENCODER_MAP_KEY_DELAY); +# endif // ENCODER_MAP_KEY_DELAY > 0 + action_exec(clockwise ? ENCODER_CW_EVENT(index, false) : ENCODER_CCW_EVENT(index, false)); +# if ENCODER_MAP_KEY_DELAY > 0 wait_ms(ENCODER_MAP_KEY_DELAY); +# endif // ENCODER_MAP_KEY_DELAY > 0 } #endif // ENCODER_MAP_ENABLE -- cgit v1.2.3 From e99ec28f5fffc41ce2662e883f7e9b56383d758b Mon Sep 17 00:00:00 2001 From: Stefan Kerkmann Date: Mon, 29 Aug 2022 19:16:49 +0200 Subject: [Core] Introduce pointing device specific debug messages (#17663) --- quantum/pointing_device/pointing_device_drivers.c | 22 +++++++--------------- quantum/pointing_device_internal.h | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 15 deletions(-) create mode 100644 quantum/pointing_device_internal.h (limited to 'quantum') diff --git a/quantum/pointing_device/pointing_device_drivers.c b/quantum/pointing_device/pointing_device_drivers.c index b96f8ff4b3..096ad5d028 100644 --- a/quantum/pointing_device/pointing_device_drivers.c +++ b/quantum/pointing_device/pointing_device_drivers.c @@ -17,6 +17,7 @@ */ #include "pointing_device.h" +#include "pointing_device_internal.h" #include "debug.h" #include "wait.h" #include "timer.h" @@ -32,10 +33,7 @@ report_mouse_t adns5050_get_report(report_mouse_t mouse_report) { report_adns5050_t data = adns5050_read_burst(); if (data.dx != 0 || data.dy != 0) { -# ifdef CONSOLE_ENABLE - if (debug_mouse) dprintf("Raw ] X: %d, Y: %d\n", data.dx, data.dy); -# endif - + pd_dprintf("Raw ] X: %d, Y: %d\n", data.dx, data.dy); mouse_report.x = (mouse_xy_report_t)data.dx; mouse_report.y = (mouse_xy_report_t)data.dy; } @@ -76,9 +74,7 @@ const pointing_device_driver_t pointing_device_driver = { report_mouse_t analog_joystick_get_report(report_mouse_t mouse_report) { report_analog_joystick_t data = analog_joystick_read(); -# ifdef CONSOLE_ENABLE - if (debug_mouse) dprintf("Raw ] X: %d, Y: %d\n", data.x, data.y); -# endif + pd_dprintf("Raw ] X: %d, Y: %d\n", data.x, data.y); mouse_report.x = data.x; mouse_report.y = data.y; @@ -140,11 +136,9 @@ report_mouse_t cirque_pinnacle_get_report(report_mouse_t mouse_report) { return mouse_report; } -# if CONSOLE_ENABLE - if (debug_mouse && touchData.touchDown) { - dprintf("cirque_pinnacle touchData x=%4d y=%4d z=%2d\n", touchData.xValue, touchData.yValue, touchData.zValue); + if (touchData.touchDown) { + pd_dprintf("cirque_pinnacle touchData x=%4d y=%4d z=%2d\n", touchData.xValue, touchData.yValue, touchData.zValue); } -# endif // Scale coordinates to arbitrary X, Y resolution cirque_pinnacle_scale_data(&touchData, cirque_pinnacle_get_scale(), cirque_pinnacle_get_scale()); @@ -227,9 +221,7 @@ const pointing_device_driver_t pointing_device_driver = { report_mouse_t paw3204_get_report(report_mouse_t mouse_report) { report_paw3204_t data = paw3204_read(); if (data.isMotion) { -# ifdef CONSOLE_ENABLE - dprintf("Raw ] X: %d, Y: %d\n", data.x, data.y); -# endif + pd_dprintf("Raw ] X: %d, Y: %d\n", data.x, data.y); mouse_report.x = data.x; mouse_report.y = data.y; @@ -329,7 +321,7 @@ report_mouse_t pmw33xx_get_report(report_mouse_t mouse_report) { if (!in_motion) { in_motion = true; - dprintf("PWM3360 (0): starting motion\n"); + pd_dprintf("PWM3360 (0): starting motion\n"); } mouse_report.x = CONSTRAIN_HID_XY(report.delta_x); diff --git a/quantum/pointing_device_internal.h b/quantum/pointing_device_internal.h new file mode 100644 index 0000000000..ef649407ca --- /dev/null +++ b/quantum/pointing_device_internal.h @@ -0,0 +1,14 @@ +// Copyright 2022 Stefan Kerkmann +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#ifdef POINTING_DEVICE_DEBUG +# include "debug.h" +# include "print.h" +# define pd_dprintf(...) dprintf(__VA_ARGS__) +#else +# define pd_dprintf(...) \ + do { \ + } while (0) +#endif -- cgit v1.2.3 From 9632360caa5e6511b0ec13cb4c55eb64408232b5 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 30 Aug 2022 03:20:04 -0500 Subject: Use a macro to compute the size of arrays at compile time (#18044) * Add ARRAY_SIZE and CEILING utility macros * Apply a coccinelle patch to use ARRAY_SIZE * fix up some straggling items * Fix 'make test:secure' * Enhance ARRAY_SIZE macro to reject acting on pointers The previous definition would not produce a diagnostic for ``` int *p; size_t num_elem = ARRAY_SIZE(p) ``` but the new one will. * explicitly get definition of ARRAY_SIZE * Convert to ARRAY_SIZE when const is involved The following spatch finds additional instances where the array is const and the division is by the size of the type, not the size of the first element: ``` @ rule5a using "empty.iso" @ type T; const T[] E; @@ - (sizeof(E)/sizeof(T)) + ARRAY_SIZE(E) @ rule6a using "empty.iso" @ type T; const T[] E; @@ - sizeof(E)/sizeof(T) + ARRAY_SIZE(E) ``` * New instances of ARRAY_SIZE added since initial spatch run * Use `ARRAY_SIZE` in docs (found by grep) * Manually use ARRAY_SIZE hs_set is expected to be the same size as uint16_t, though it's made of two 8-bit integers * Just like char, sizeof(uint8_t) is guaranteed to be 1 This is at least true on any plausible system where qmk is actually used. Per my understanding it's universally true, assuming that uint8_t exists: https://stackoverflow.com/questions/48655310/can-i-assume-that-sizeofuint8-t-1 * Run qmk-format on core C files touched in this branch Co-authored-by: Stefan Kerkmann --- quantum/backlight/backlight_driver_common.c | 2 +- quantum/backlight/backlight_software.c | 2 +- quantum/dip_switch.c | 4 +- quantum/encoder.h | 8 ++-- quantum/process_keycode/process_leader.c | 2 +- quantum/process_keycode/process_unicode_common.c | 2 +- quantum/rgb_matrix/rgb_matrix_drivers.c | 2 +- quantum/secure.c | 3 +- quantum/util.h | 49 ++++++++++++++++-------- 9 files changed, 46 insertions(+), 28 deletions(-) (limited to 'quantum') diff --git a/quantum/backlight/backlight_driver_common.c b/quantum/backlight/backlight_driver_common.c index e4c2e90b5f..1eb8969084 100644 --- a/quantum/backlight/backlight_driver_common.c +++ b/quantum/backlight/backlight_driver_common.c @@ -9,7 +9,7 @@ #if defined(BACKLIGHT_PINS) static const pin_t backlight_pins[] = BACKLIGHT_PINS; # ifndef BACKLIGHT_LED_COUNT -# define BACKLIGHT_LED_COUNT (sizeof(backlight_pins) / sizeof(pin_t)) +# define BACKLIGHT_LED_COUNT ARRAY_SIZE(backlight_pins) # endif # define FOR_EACH_LED(x) \ diff --git a/quantum/backlight/backlight_software.c b/quantum/backlight/backlight_software.c index 3d412cab52..27ccbd2c9f 100644 --- a/quantum/backlight/backlight_software.c +++ b/quantum/backlight/backlight_software.c @@ -26,7 +26,7 @@ static const uint16_t backlight_duty_table[] = { 0b1110111011101110, 0b1111111111111111, }; -#define backlight_duty_table_size (sizeof(backlight_duty_table) / sizeof(backlight_duty_table[0])) +#define backlight_duty_table_size ARRAY_SIZE(backlight_duty_table) // clang-format on diff --git a/quantum/dip_switch.c b/quantum/dip_switch.c index eee29aaf91..e180cfccdf 100644 --- a/quantum/dip_switch.c +++ b/quantum/dip_switch.c @@ -33,7 +33,7 @@ #endif #ifdef DIP_SWITCH_PINS -# define NUMBER_OF_DIP_SWITCHES (sizeof(dip_switch_pad) / sizeof(pin_t)) +# define NUMBER_OF_DIP_SWITCHES (ARRAY_SIZE(dip_switch_pad)) static pin_t dip_switch_pad[] = DIP_SWITCH_PINS; #endif @@ -43,7 +43,7 @@ typedef struct matrix_index_t { uint8_t col; } matrix_index_t; -# define NUMBER_OF_DIP_SWITCHES (sizeof(dip_switch_pad) / sizeof(matrix_index_t)) +# define NUMBER_OF_DIP_SWITCHES (ARRAY_SIZE(dip_switch_pad)) static matrix_index_t dip_switch_pad[] = DIP_SWITCH_MATRIX_GRID; extern bool peek_matrix(uint8_t row_index, uint8_t col_index, bool read_raw); static uint16_t scan_count; diff --git a/quantum/encoder.h b/quantum/encoder.h index 82f95b4931..4eb67fa25d 100644 --- a/quantum/encoder.h +++ b/quantum/encoder.h @@ -32,17 +32,17 @@ void encoder_state_raw(uint8_t* slave_state); void encoder_update_raw(uint8_t* slave_state); # if defined(ENCODERS_PAD_A_RIGHT) -# define NUM_ENCODERS_LEFT (sizeof(((pin_t[])ENCODERS_PAD_A)) / sizeof(pin_t)) -# define NUM_ENCODERS_RIGHT (sizeof(((pin_t[])ENCODERS_PAD_A_RIGHT)) / sizeof(pin_t)) +# define NUM_ENCODERS_LEFT ARRAY_SIZE(((pin_t[])ENCODERS_PAD_A)) +# define NUM_ENCODERS_RIGHT ARRAY_SIZE(((pin_t[])ENCODERS_PAD_A_RIGHT)) # else -# define NUM_ENCODERS_LEFT (sizeof(((pin_t[])ENCODERS_PAD_A)) / sizeof(pin_t)) +# define NUM_ENCODERS_LEFT ARRAY_SIZE(((pin_t[])ENCODERS_PAD_A)) # define NUM_ENCODERS_RIGHT NUM_ENCODERS_LEFT # endif # define NUM_ENCODERS (NUM_ENCODERS_LEFT + NUM_ENCODERS_RIGHT) #else // SPLIT_KEYBOARD -# define NUM_ENCODERS (sizeof(((pin_t[])ENCODERS_PAD_A)) / sizeof(pin_t)) +# define NUM_ENCODERS ARRAY_SIZE(((pin_t[])ENCODERS_PAD_A)) # define NUM_ENCODERS_LEFT NUM_ENCODERS # define NUM_ENCODERS_RIGHT 0 diff --git a/quantum/process_keycode/process_leader.c b/quantum/process_keycode/process_leader.c index ae00b3227a..3593f75f0d 100644 --- a/quantum/process_keycode/process_leader.c +++ b/quantum/process_keycode/process_leader.c @@ -58,7 +58,7 @@ bool process_leader(uint16_t keycode, keyrecord_t *record) { keycode = keycode & 0xFF; } # endif // LEADER_KEY_STRICT_KEY_PROCESSING - if (leader_sequence_size < (sizeof(leader_sequence) / sizeof(leader_sequence[0]))) { + if (leader_sequence_size < ARRAY_SIZE(leader_sequence)) { leader_sequence[leader_sequence_size] = keycode; leader_sequence_size++; } else { diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 8de31c055c..1c1aab8f48 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -25,7 +25,7 @@ bool unicode_saved_num_lock; #if UNICODE_SELECTED_MODES != -1 static uint8_t selected[] = {UNICODE_SELECTED_MODES}; -static int8_t selected_count = sizeof selected / sizeof *selected; +static int8_t selected_count = ARRAY_SIZE(selected); static int8_t selected_index; #endif diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c index 27fa7369bf..99151e5a92 100644 --- a/quantum/rgb_matrix/rgb_matrix_drivers.c +++ b/quantum/rgb_matrix/rgb_matrix_drivers.c @@ -369,7 +369,7 @@ static inline void setled(int i, uint8_t r, uint8_t g, uint8_t b) { } static void setled_all(uint8_t r, uint8_t g, uint8_t b) { - for (int i = 0; i < sizeof(rgb_matrix_ws2812_array) / sizeof(rgb_matrix_ws2812_array[0]); i++) { + for (int i = 0; i < ARRAY_SIZE(rgb_matrix_ws2812_array); i++) { setled(i, r, g, b); } } diff --git a/quantum/secure.c b/quantum/secure.c index f07f6af2cb..f2a567f31d 100644 --- a/quantum/secure.c +++ b/quantum/secure.c @@ -3,6 +3,7 @@ #include "secure.h" #include "timer.h" +#include "util.h" #ifndef SECURE_UNLOCK_TIMEOUT # define SECURE_UNLOCK_TIMEOUT 5000 @@ -59,7 +60,7 @@ void secure_activity_event(void) { void secure_keypress_event(uint8_t row, uint8_t col) { static const uint8_t sequence[][2] = SECURE_UNLOCK_SEQUENCE; - static const uint8_t sequence_len = sizeof(sequence) / sizeof(sequence[0]); + static const uint8_t sequence_len = ARRAY_SIZE(sequence); static uint8_t offset = 0; if ((sequence[offset][0] == row) && (sequence[offset][1] == col)) { diff --git a/quantum/util.h b/quantum/util.h index 21c290013c..9c034cc404 100644 --- a/quantum/util.h +++ b/quantum/util.h @@ -1,19 +1,7 @@ -/* -Copyright 2011 Jun Wako - -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 . -*/ +// Copyright 2022 Stefan Kerkmann (KarlK90) +// Copyright 2011 Jun Wako +// SPDX-License-Identifier: GPL-2.0-or-later + #pragma once #include "bitwise.h" @@ -29,3 +17,32 @@ along with this program. If not, see . #if !defined(MAX) # define MAX(x, y) (((x) > (y)) ? (x) : (y)) #endif + +#if !defined(CEILING) +/** + * @brief Computes the rounded up result of a division of two integers at + * compile time. + */ +# define CEILING(dividend, divisor) (((dividend) + (divisor)-1) / (divisor)) +#endif + +#if !defined(IS_ARRAY) +/** + * @brief Returns true if the value is an array, false if it's a pointer. + * + * This macro is ill-formed for scalars, which is OK for its intended use in + * ARRAY_SIZE. + */ +# define IS_ARRAY(value) (!__builtin_types_compatible_p(typeof((value)), typeof(&(value)[0]))) +#endif + +#if !defined(ARRAY_SIZE) +/** + * @brief Computes the number of elements of the given array at compile time. + * + * This Macro can only be used for statically allocated arrays that have not + * been decayed into a pointer. This is detected at compile time, though the + * error message for scalar values is poor. + */ +# define ARRAY_SIZE(array) (__builtin_choose_expr(IS_ARRAY((array)), sizeof((array)) / sizeof((array)[0]), (void)0)) +#endif -- cgit v1.2.3 From e4bf8323688b56cd5fc0f4f27c531f3406d40f6d Mon Sep 17 00:00:00 2001 From: Joshua Diamond Date: Wed, 31 Aug 2022 19:39:16 -0400 Subject: Add unicode mode change callbacks (#18235) --- quantum/process_keycode/process_unicode_common.c | 17 +++++++++++++++++ quantum/process_keycode/process_unicode_common.h | 3 +++ 2 files changed, 20 insertions(+) (limited to 'quantum') diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 1c1aab8f48..94809cf029 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -29,6 +29,20 @@ static int8_t selected_count = ARRAY_SIZE(selected); static int8_t selected_index; #endif +/** \brief Uunicode input mode set at user level + * + * Run user code on unicode input mode change + */ +__attribute__((weak)) void unicode_input_mode_set_user(uint8_t input_mode) {} + +/** \brief unicode input mode set at keyboard level + * + * Run keyboard code on unicode input mode change + */ +__attribute__((weak)) void unicode_input_mode_set_kb(uint8_t input_mode) { + unicode_input_mode_set_user(input_mode); +} + void unicode_input_mode_init(void) { unicode_config.raw = eeprom_read_byte(EECONFIG_UNICODEMODE); #if UNICODE_SELECTED_MODES != -1 @@ -50,6 +64,7 @@ void unicode_input_mode_init(void) { unicode_config.input_mode = selected[selected_index = 0]; # endif #endif + unicode_input_mode_set_kb(unicode_config.input_mode); dprintf("Unicode input mode init to: %u\n", unicode_config.input_mode); } @@ -60,6 +75,7 @@ uint8_t get_unicode_input_mode(void) { void set_unicode_input_mode(uint8_t mode) { unicode_config.input_mode = mode; persist_unicode_input_mode(); + unicode_input_mode_set_kb(mode); dprintf("Unicode input mode set to: %u\n", unicode_config.input_mode); } @@ -73,6 +89,7 @@ void cycle_unicode_input_mode(int8_t offset) { # if UNICODE_CYCLE_PERSIST persist_unicode_input_mode(); # endif + unicode_input_mode_set_kb(unicode_config.input_mode); dprintf("Unicode input mode cycle to: %u\n", unicode_config.input_mode); #endif } diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index 15e798dbb3..bdc7a1dedd 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h @@ -87,6 +87,9 @@ void unicode_input_start(void); void unicode_input_finish(void); void unicode_input_cancel(void); +void unicode_input_mode_set_user(uint8_t input_mode); +void unicode_input_mode_set_kb(uint8_t input_mode); + void register_hex(uint16_t hex); void register_hex32(uint32_t hex); void register_unicode(uint32_t code_point); -- cgit v1.2.3 From 423826a34a2b5839a10188f2be84e518ac44bd47 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Thu, 1 Sep 2022 20:43:06 -0700 Subject: Better handle EEPROM reset keycode (#18244) --- quantum/quantum.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'quantum') diff --git a/quantum/quantum.c b/quantum/quantum.c index 9a0016b150..acafd8025c 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -361,8 +361,10 @@ bool process_record_quantum(keyrecord_t *record) { #endif return false; case QK_CLEAR_EEPROM: +#ifdef NO_RESET eeconfig_init(); -#ifndef NO_RESET +#else + eeconfig_disable(); soft_reset_keyboard(); #endif return false; -- cgit v1.2.3 From 8833b283610ce34e9be65ed3fc2c477258188de7 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 7 Sep 2022 03:07:08 +1000 Subject: Remove `UNICODE_KEY_OSX` and `UC_OSX` (#18290) --- quantum/process_keycode/process_unicode_common.h | 9 --------- 1 file changed, 9 deletions(-) (limited to 'quantum') diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index bdc7a1dedd..0fe672d26a 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h @@ -49,15 +49,6 @@ # define UNICODE_TYPE_DELAY 10 #endif -// Deprecated aliases -#if !defined(UNICODE_KEY_MAC) && defined(UNICODE_KEY_OSX) -# define UNICODE_KEY_MAC UNICODE_KEY_OSX -#endif -#if !defined(UNICODE_SONG_MAC) && defined(UNICODE_SONG_OSX) -# define UNICODE_SONG_MAC UNICODE_SONG_OSX -#endif -#define UC_OSX UC_MAC - enum unicode_input_modes { UC_MAC, // macOS using Unicode Hex Input UC_LNX, // Linux using IBus -- cgit v1.2.3 From f7d2b001bc4f79164e9ea3a4ff7faa54be0b7d82 Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 8 Sep 2022 04:59:24 +1000 Subject: Move Bluetooth-related function calls up to host/keyboard level (#18274) * Move Bluetooth-related function calls up to host/keyboard level * Remove pointless set_output() call * Move bluetooth (rn42) init to end of keyboard_init() * Enable SPI/UART for ChibiOS targets * Some more slight tweaks --- quantum/keyboard.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'quantum') diff --git a/quantum/keyboard.c b/quantum/keyboard.c index 1c62a43d9d..3b5e9b0200 100644 --- a/quantum/keyboard.c +++ b/quantum/keyboard.c @@ -107,6 +107,11 @@ along with this program. If not, see . #endif #ifdef BLUETOOTH_ENABLE # include "outputselect.h" +# ifdef BLUETOOTH_BLUEFRUIT_LE +# include "bluefruit_le.h" +# elif BLUETOOTH_RN42 +# include "rn42.h" +# endif #endif #ifdef CAPS_WORD_ENABLE # include "caps_word.h" @@ -346,9 +351,6 @@ void quantum_init(void) { #ifdef HAPTIC_ENABLE haptic_init(); #endif -#if defined(BLUETOOTH_ENABLE) && defined(OUTPUT_AUTO_ENABLE) - set_output(OUTPUT_AUTO); -#endif } /** \brief keyboard_init @@ -410,6 +412,9 @@ void keyboard_init(void) { // init after split init pointing_device_init(); #endif +#if defined(BLUETOOTH_RN42) + rn42_init(); +#endif #if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE) debug_enable = true; @@ -670,5 +675,9 @@ void keyboard_task(void) { programmable_button_send(); #endif +#ifdef BLUETOOTH_BLUEFRUIT_LE + bluefruit_le_task(); +#endif + led_task(); } -- cgit v1.2.3 From 3d667f09705fa780bd5881cfa3b3cb10fa41b1fe Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 13 Sep 2022 01:49:04 +1000 Subject: Refactor Unicode feature (#18333) --- quantum/painter/rules.mk | 5 +- quantum/process_keycode/process_ucis.c | 17 +- quantum/process_keycode/process_ucis.h | 6 +- quantum/process_keycode/process_unicode.c | 12 +- quantum/process_keycode/process_unicode.h | 5 +- quantum/process_keycode/process_unicode_common.c | 315 +------------------ quantum/process_keycode/process_unicode_common.h | 178 +---------- quantum/process_keycode/process_unicodemap.c | 5 + quantum/process_keycode/process_unicodemap.h | 6 +- quantum/quantum.h | 1 + quantum/unicode/unicode.c | 376 +++++++++++++++++++++++ quantum/unicode/unicode.h | 165 ++++++++++ quantum/unicode/utf8.c | 46 +++ quantum/unicode/utf8.h | 21 ++ quantum/utf8.c | 46 --- quantum/utf8.h | 21 -- 16 files changed, 654 insertions(+), 571 deletions(-) create mode 100644 quantum/unicode/unicode.c create mode 100644 quantum/unicode/unicode.h create mode 100644 quantum/unicode/utf8.c create mode 100644 quantum/unicode/utf8.h delete mode 100644 quantum/utf8.c delete mode 100644 quantum/utf8.h (limited to 'quantum') diff --git a/quantum/painter/rules.mk b/quantum/painter/rules.mk index 91787dfe0e..4420bccf63 100644 --- a/quantum/painter/rules.mk +++ b/quantum/painter/rules.mk @@ -8,9 +8,10 @@ VALID_QUANTUM_PAINTER_DRIVERS := ili9163_spi ili9341_spi ili9488_spi st7789_spi #------------------------------------------------------------------------------- OPT_DEFS += -DQUANTUM_PAINTER_ENABLE -COMMON_VPATH += $(QUANTUM_DIR)/painter +COMMON_VPATH += $(QUANTUM_DIR)/painter \ + $(QUANTUM_DIR)/unicode SRC += \ - $(QUANTUM_DIR)/utf8.c \ + $(QUANTUM_DIR)/unicode/utf8.c \ $(QUANTUM_DIR)/color.c \ $(QUANTUM_DIR)/painter/qp.c \ $(QUANTUM_DIR)/painter/qp_stream.c \ diff --git a/quantum/process_keycode/process_ucis.c b/quantum/process_keycode/process_ucis.c index 6a8d8f0ff6..646471bc4d 100644 --- a/quantum/process_keycode/process_ucis.c +++ b/quantum/process_keycode/process_ucis.c @@ -15,6 +15,9 @@ */ #include "process_ucis.h" +#include "unicode.h" +#include "keycode.h" +#include "wait.h" qk_ucis_state_t qk_ucis_state; @@ -26,9 +29,7 @@ void qk_ucis_start(void) { } __attribute__((weak)) void qk_ucis_start_user(void) { - unicode_input_start(); - register_hex(0x2328); // ⌨ - unicode_input_finish(); + register_unicode(0x2328); // ⌨ } __attribute__((weak)) void qk_ucis_success(uint8_t symbol_index) {} @@ -51,10 +52,7 @@ static bool is_uni_seq(char *seq) { __attribute__((weak)) void qk_ucis_symbol_fallback(void) { for (uint8_t i = 0; i < qk_ucis_state.count - 1; i++) { - uint8_t keycode = qk_ucis_state.codes[i]; - register_code(keycode); - unregister_code(keycode); - wait_ms(UNICODE_TYPE_DELAY); + tap_code(qk_ucis_state.codes[i]); } } @@ -63,7 +61,6 @@ __attribute__((weak)) void qk_ucis_cancel(void) {} void register_ucis(const uint32_t *code_points) { for (int i = 0; i < UCIS_MAX_CODE_POINTS && code_points[i]; i++) { register_unicode(code_points[i]); - wait_ms(UNICODE_TYPE_DELAY); } } @@ -94,9 +91,7 @@ bool process_ucis(uint16_t keycode, keyrecord_t *record) { case KC_ENTER: case KC_ESCAPE: for (uint8_t i = 0; i < qk_ucis_state.count; i++) { - register_code(KC_BACKSPACE); - unregister_code(KC_BACKSPACE); - wait_ms(UNICODE_TYPE_DELAY); + tap_code(KC_BACKSPACE); } if (keycode == KC_ESCAPE) { diff --git a/quantum/process_keycode/process_ucis.h b/quantum/process_keycode/process_ucis.h index a667430bda..3de0707762 100644 --- a/quantum/process_keycode/process_ucis.h +++ b/quantum/process_keycode/process_ucis.h @@ -16,8 +16,10 @@ #pragma once -#include "quantum.h" -#include "process_unicode_common.h" +#include +#include + +#include "action.h" #ifndef UCIS_MAX_SYMBOL_LENGTH # define UCIS_MAX_SYMBOL_LENGTH 32 diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c index 18a1d8bc1f..99cc2f5f26 100644 --- a/quantum/process_keycode/process_unicode.c +++ b/quantum/process_keycode/process_unicode.c @@ -15,14 +15,14 @@ */ #include "process_unicode.h" -#include "action_util.h" -#include "eeprom.h" +#include "unicode.h" +#include "quantum_keycodes.h" bool process_unicode(uint16_t keycode, keyrecord_t *record) { - if (keycode >= QK_UNICODE && keycode <= QK_UNICODE_MAX && record->event.pressed) { - unicode_input_start(); - register_hex(keycode & 0x7FFF); - unicode_input_finish(); + if (record->event.pressed) { + if (keycode >= QK_UNICODE && keycode <= QK_UNICODE_MAX) { + register_unicode(keycode & 0x7FFF); + } } return true; } diff --git a/quantum/process_keycode/process_unicode.h b/quantum/process_keycode/process_unicode.h index 22765ad560..341bc8d861 100644 --- a/quantum/process_keycode/process_unicode.h +++ b/quantum/process_keycode/process_unicode.h @@ -16,6 +16,9 @@ #pragma once -#include "process_unicode_common.h" +#include +#include + +#include "action.h" bool process_unicode(uint16_t keycode, keyrecord_t *record); diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 94809cf029..bd5fc560f3 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -15,306 +15,17 @@ */ #include "process_unicode_common.h" -#include "eeprom.h" -#include "utf8.h" +#include "unicode.h" +#include "action_util.h" +#include "keycode.h" -unicode_config_t unicode_config; -uint8_t unicode_saved_mods; -bool unicode_saved_caps_lock; -bool unicode_saved_num_lock; - -#if UNICODE_SELECTED_MODES != -1 -static uint8_t selected[] = {UNICODE_SELECTED_MODES}; -static int8_t selected_count = ARRAY_SIZE(selected); -static int8_t selected_index; -#endif - -/** \brief Uunicode input mode set at user level - * - * Run user code on unicode input mode change - */ -__attribute__((weak)) void unicode_input_mode_set_user(uint8_t input_mode) {} - -/** \brief unicode input mode set at keyboard level - * - * Run keyboard code on unicode input mode change - */ -__attribute__((weak)) void unicode_input_mode_set_kb(uint8_t input_mode) { - unicode_input_mode_set_user(input_mode); -} - -void unicode_input_mode_init(void) { - unicode_config.raw = eeprom_read_byte(EECONFIG_UNICODEMODE); -#if UNICODE_SELECTED_MODES != -1 -# if UNICODE_CYCLE_PERSIST - // Find input_mode in selected modes - int8_t i; - for (i = 0; i < selected_count; i++) { - if (selected[i] == unicode_config.input_mode) { - selected_index = i; - break; - } - } - if (i == selected_count) { - // Not found: input_mode isn't selected, change to one that is - unicode_config.input_mode = selected[selected_index = 0]; - } -# else - // Always change to the first selected input mode - unicode_config.input_mode = selected[selected_index = 0]; -# endif -#endif - unicode_input_mode_set_kb(unicode_config.input_mode); - dprintf("Unicode input mode init to: %u\n", unicode_config.input_mode); -} - -uint8_t get_unicode_input_mode(void) { - return unicode_config.input_mode; -} - -void set_unicode_input_mode(uint8_t mode) { - unicode_config.input_mode = mode; - persist_unicode_input_mode(); - unicode_input_mode_set_kb(mode); - dprintf("Unicode input mode set to: %u\n", unicode_config.input_mode); -} - -void cycle_unicode_input_mode(int8_t offset) { -#if UNICODE_SELECTED_MODES != -1 - selected_index = (selected_index + offset) % selected_count; - if (selected_index < 0) { - selected_index += selected_count; - } - unicode_config.input_mode = selected[selected_index]; -# if UNICODE_CYCLE_PERSIST - persist_unicode_input_mode(); -# endif - unicode_input_mode_set_kb(unicode_config.input_mode); - dprintf("Unicode input mode cycle to: %u\n", unicode_config.input_mode); -#endif -} - -void persist_unicode_input_mode(void) { - eeprom_update_byte(EECONFIG_UNICODEMODE, unicode_config.input_mode); -} - -__attribute__((weak)) void unicode_input_start(void) { - unicode_saved_caps_lock = host_keyboard_led_state().caps_lock; - unicode_saved_num_lock = host_keyboard_led_state().num_lock; - - // Note the order matters here! - // Need to do this before we mess around with the mods, or else - // UNICODE_KEY_LNX (which is usually Ctrl-Shift-U) might not work - // correctly in the shifted case. - if (unicode_config.input_mode == UC_LNX && unicode_saved_caps_lock) { - tap_code(KC_CAPS_LOCK); - } - - unicode_saved_mods = get_mods(); // Save current mods - clear_mods(); // Unregister mods to start from a clean state - clear_weak_mods(); - - switch (unicode_config.input_mode) { - case UC_MAC: - register_code(UNICODE_KEY_MAC); - break; - case UC_LNX: - tap_code16(UNICODE_KEY_LNX); - break; - case UC_WIN: - // For increased reliability, use numpad keys for inputting digits - if (!unicode_saved_num_lock) { - tap_code(KC_NUM_LOCK); - } - register_code(KC_LEFT_ALT); - wait_ms(UNICODE_TYPE_DELAY); - tap_code(KC_KP_PLUS); - break; - case UC_WINC: - tap_code(UNICODE_KEY_WINC); - tap_code(KC_U); - break; - case UC_EMACS: - // The usual way to type unicode in emacs is C-x-8 then the unicode number in hex - tap_code16(LCTL(KC_X)); - tap_code16(KC_8); - tap_code16(KC_ENTER); - break; - } - - wait_ms(UNICODE_TYPE_DELAY); -} - -__attribute__((weak)) void unicode_input_finish(void) { - switch (unicode_config.input_mode) { - case UC_MAC: - unregister_code(UNICODE_KEY_MAC); - break; - case UC_LNX: - tap_code(KC_SPACE); - if (unicode_saved_caps_lock) { - tap_code(KC_CAPS_LOCK); - } - break; - case UC_WIN: - unregister_code(KC_LEFT_ALT); - if (!unicode_saved_num_lock) { - tap_code(KC_NUM_LOCK); - } - break; - case UC_WINC: - tap_code(KC_ENTER); - break; - case UC_EMACS: - tap_code16(KC_ENTER); - break; - } - - set_mods(unicode_saved_mods); // Reregister previously set mods -} - -__attribute__((weak)) void unicode_input_cancel(void) { - switch (unicode_config.input_mode) { - case UC_MAC: - unregister_code(UNICODE_KEY_MAC); - break; - case UC_LNX: - tap_code(KC_ESCAPE); - if (unicode_saved_caps_lock) { - tap_code(KC_CAPS_LOCK); - } - break; - case UC_WINC: - tap_code(KC_ESCAPE); - break; - case UC_WIN: - unregister_code(KC_LEFT_ALT); - if (!unicode_saved_num_lock) { - tap_code(KC_NUM_LOCK); - } - break; - case UC_EMACS: - tap_code16(LCTL(KC_G)); // C-g cancels - break; - } - - set_mods(unicode_saved_mods); // Reregister previously set mods -} - -// clang-format off - -static void send_nibble_wrapper(uint8_t digit) { - if (unicode_config.input_mode == UC_WIN) { - uint8_t kc = digit < 10 - ? KC_KP_1 + (10 + digit - 1) % 10 - : KC_A + (digit - 10); - tap_code(kc); - return; - } - send_nibble(digit); -} - -// clang-format on - -void register_hex(uint16_t hex) { - for (int i = 3; i >= 0; i--) { - uint8_t digit = ((hex >> (i * 4)) & 0xF); - send_nibble_wrapper(digit); - } -} - -void register_hex32(uint32_t hex) { - bool onzerostart = true; - for (int i = 7; i >= 0; i--) { - if (i <= 3) { - onzerostart = false; - } - uint8_t digit = ((hex >> (i * 4)) & 0xF); - if (digit == 0) { - if (!onzerostart) { - send_nibble_wrapper(digit); - } - } else { - send_nibble_wrapper(digit); - onzerostart = false; - } - } -} - -void register_unicode(uint32_t code_point) { - if (code_point > 0x10FFFF || (code_point > 0xFFFF && unicode_config.input_mode == UC_WIN)) { - // Code point out of range, do nothing - return; - } - - unicode_input_start(); - if (code_point > 0xFFFF && unicode_config.input_mode == UC_MAC) { - // Convert code point to UTF-16 surrogate pair on macOS - code_point -= 0x10000; - uint32_t lo = code_point & 0x3FF, hi = (code_point & 0xFFC00) >> 10; - register_hex32(hi + 0xD800); - register_hex32(lo + 0xDC00); - } else { - register_hex32(code_point); - } - unicode_input_finish(); -} - -void send_unicode_string(const char *str) { - if (!str) { - return; - } - - while (*str) { - int32_t code_point = 0; - str = decode_utf8(str, &code_point); - - if (code_point >= 0) { - register_unicode(code_point); - } - } -} - -// clang-format off - -static void audio_helper(void) { -#ifdef AUDIO_ENABLE - switch (get_unicode_input_mode()) { -# ifdef UNICODE_SONG_MAC - static float song_mac[][2] = UNICODE_SONG_MAC; - case UC_MAC: - PLAY_SONG(song_mac); - break; -# endif -# ifdef UNICODE_SONG_LNX - static float song_lnx[][2] = UNICODE_SONG_LNX; - case UC_LNX: - PLAY_SONG(song_lnx); - break; -# endif -# ifdef UNICODE_SONG_WIN - static float song_win[][2] = UNICODE_SONG_WIN; - case UC_WIN: - PLAY_SONG(song_win); - break; -# endif -# ifdef UNICODE_SONG_BSD - static float song_bsd[][2] = UNICODE_SONG_BSD; - case UC_BSD: - PLAY_SONG(song_bsd); - break; -# endif -# ifdef UNICODE_SONG_WINC - static float song_winc[][2] = UNICODE_SONG_WINC; - case UC_WINC: - PLAY_SONG(song_winc); - break; -# endif - } +#if defined(UNICODE_ENABLE) +# include "process_unicode.h" +#elif defined(UNICODEMAP_ENABLE) +# include "process_unicodemap.h" +#elif defined(UCIS_ENABLE) +# include "process_ucis.h" #endif -} - -// clang-format on bool process_unicode_common(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { @@ -322,35 +33,27 @@ bool process_unicode_common(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case UNICODE_MODE_FORWARD: cycle_unicode_input_mode(shifted ? -1 : +1); - audio_helper(); break; case UNICODE_MODE_REVERSE: cycle_unicode_input_mode(shifted ? +1 : -1); - audio_helper(); break; case UNICODE_MODE_MAC: set_unicode_input_mode(UC_MAC); - audio_helper(); break; case UNICODE_MODE_LNX: set_unicode_input_mode(UC_LNX); - audio_helper(); break; case UNICODE_MODE_WIN: set_unicode_input_mode(UC_WIN); - audio_helper(); break; case UNICODE_MODE_BSD: set_unicode_input_mode(UC_BSD); - audio_helper(); break; case UNICODE_MODE_WINC: set_unicode_input_mode(UC_WINC); - audio_helper(); break; case UNICODE_MODE_EMACS: set_unicode_input_mode(UC_EMACS); - audio_helper(); break; } } diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index 0fe672d26a..fd09a41818 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h @@ -16,181 +16,9 @@ #pragma once -#include "quantum.h" +#include +#include -#if defined(UNICODE_ENABLE) + defined(UNICODEMAP_ENABLE) + defined(UCIS_ENABLE) > 1 -# error "Cannot enable more than one Unicode method (UNICODE, UNICODEMAP, UCIS) at the same time" -#endif - -// Keycodes used for starting Unicode input on different platforms -#ifndef UNICODE_KEY_MAC -# define UNICODE_KEY_MAC KC_LEFT_ALT -#endif -#ifndef UNICODE_KEY_LNX -# define UNICODE_KEY_LNX LCTL(LSFT(KC_U)) -#endif -#ifndef UNICODE_KEY_WINC -# define UNICODE_KEY_WINC KC_RIGHT_ALT -#endif - -// Comma-delimited, ordered list of input modes selected for use (e.g. in cycle) -// Example: #define UNICODE_SELECTED_MODES UC_WINC, UC_LNX -#ifndef UNICODE_SELECTED_MODES -# define UNICODE_SELECTED_MODES -1 -#endif - -// Whether input mode changes in cycle should be written to EEPROM -#ifndef UNICODE_CYCLE_PERSIST -# define UNICODE_CYCLE_PERSIST true -#endif - -// Delay between starting Unicode input and sending a sequence, in ms -#ifndef UNICODE_TYPE_DELAY -# define UNICODE_TYPE_DELAY 10 -#endif - -enum unicode_input_modes { - UC_MAC, // macOS using Unicode Hex Input - UC_LNX, // Linux using IBus - UC_WIN, // Windows using EnableHexNumpad - UC_BSD, // BSD (not implemented) - UC_WINC, // Windows using WinCompose (https://github.com/samhocevar/wincompose) - UC_EMACS, // Emacs is an operating system in search of a good text editor - UC__COUNT // Number of available input modes (always leave at the end) -}; - -typedef union { - uint32_t raw; - struct { - uint8_t input_mode : 8; - }; -} unicode_config_t; - -extern unicode_config_t unicode_config; - -void unicode_input_mode_init(void); -uint8_t get_unicode_input_mode(void); -void set_unicode_input_mode(uint8_t mode); -void cycle_unicode_input_mode(int8_t offset); -void persist_unicode_input_mode(void); - -void unicode_input_start(void); -void unicode_input_finish(void); -void unicode_input_cancel(void); - -void unicode_input_mode_set_user(uint8_t input_mode); -void unicode_input_mode_set_kb(uint8_t input_mode); - -void register_hex(uint16_t hex); -void register_hex32(uint32_t hex); -void register_unicode(uint32_t code_point); - -void send_unicode_string(const char *str); +#include "action.h" bool process_unicode_common(uint16_t keycode, keyrecord_t *record); - -#define UC_BSPC UC(0x0008) -#define UC_SPC UC(0x0020) - -#define UC_EXLM UC(0x0021) -#define UC_DQUT UC(0x0022) -#define UC_HASH UC(0x0023) -#define UC_DLR UC(0x0024) -#define UC_PERC UC(0x0025) -#define UC_AMPR UC(0x0026) -#define UC_QUOT UC(0x0027) -#define UC_LPRN UC(0x0028) -#define UC_RPRN UC(0x0029) -#define UC_ASTR UC(0x002A) -#define UC_PLUS UC(0x002B) -#define UC_COMM UC(0x002C) -#define UC_DASH UC(0x002D) -#define UC_DOT UC(0x002E) -#define UC_SLSH UC(0x002F) - -#define UC_0 UC(0x0030) -#define UC_1 UC(0x0031) -#define UC_2 UC(0x0032) -#define UC_3 UC(0x0033) -#define UC_4 UC(0x0034) -#define UC_5 UC(0x0035) -#define UC_6 UC(0x0036) -#define UC_7 UC(0x0037) -#define UC_8 UC(0x0038) -#define UC_9 UC(0x0039) - -#define UC_COLN UC(0x003A) -#define UC_SCLN UC(0x003B) -#define UC_LT UC(0x003C) -#define UC_EQL UC(0x003D) -#define UC_GT UC(0x003E) -#define UC_QUES UC(0x003F) -#define UC_AT UC(0x0040) - -#define UC_A UC(0x0041) -#define UC_B UC(0x0042) -#define UC_C UC(0x0043) -#define UC_D UC(0x0044) -#define UC_E UC(0x0045) -#define UC_F UC(0x0046) -#define UC_G UC(0x0047) -#define UC_H UC(0x0048) -#define UC_I UC(0x0049) -#define UC_J UC(0x004A) -#define UC_K UC(0x004B) -#define UC_L UC(0x004C) -#define UC_M UC(0x004D) -#define UC_N UC(0x004E) -#define UC_O UC(0x004F) -#define UC_P UC(0x0050) -#define UC_Q UC(0x0051) -#define UC_R UC(0x0052) -#define UC_S UC(0x0053) -#define UC_T UC(0x0054) -#define UC_U UC(0x0055) -#define UC_V UC(0x0056) -#define UC_W UC(0x0057) -#define UC_X UC(0x0058) -#define UC_Y UC(0x0059) -#define UC_Z UC(0x005A) - -#define UC_LBRC UC(0x005B) -#define UC_BSLS UC(0x005C) -#define UC_RBRC UC(0x005D) -#define UC_CIRM UC(0x005E) -#define UC_UNDR UC(0x005F) - -#define UC_GRV UC(0x0060) - -#define UC_a UC(0x0061) -#define UC_b UC(0x0062) -#define UC_c UC(0x0063) -#define UC_d UC(0x0064) -#define UC_e UC(0x0065) -#define UC_f UC(0x0066) -#define UC_g UC(0x0067) -#define UC_h UC(0x0068) -#define UC_i UC(0x0069) -#define UC_j UC(0x006A) -#define UC_k UC(0x006B) -#define UC_l UC(0x006C) -#define UC_m UC(0x006D) -#define UC_n UC(0x006E) -#define UC_o UC(0x006F) -#define UC_p UC(0x0070) -#define UC_q UC(0x0071) -#define UC_r UC(0x0072) -#define UC_s UC(0x0073) -#define UC_t UC(0x0074) -#define UC_u UC(0x0075) -#define UC_v UC(0x0076) -#define UC_w UC(0x0077) -#define UC_x UC(0x0078) -#define UC_y UC(0x0079) -#define UC_z UC(0x007A) - -#define UC_LCBR UC(0x007B) -#define UC_PIPE UC(0x007C) -#define UC_RCBR UC(0x007D) -#define UC_TILD UC(0x007E) -#define UC_DEL UC(0x007F) diff --git a/quantum/process_keycode/process_unicodemap.c b/quantum/process_keycode/process_unicodemap.c index 459397014d..979d773b05 100644 --- a/quantum/process_keycode/process_unicodemap.c +++ b/quantum/process_keycode/process_unicodemap.c @@ -15,6 +15,11 @@ */ #include "process_unicodemap.h" +#include "unicode.h" +#include "quantum_keycodes.h" +#include "keycode.h" +#include "action_util.h" +#include "host.h" __attribute__((weak)) uint16_t unicodemap_index(uint16_t keycode) { if (keycode >= QK_UNICODEMAP_PAIR) { diff --git a/quantum/process_keycode/process_unicodemap.h b/quantum/process_keycode/process_unicodemap.h index c429859bbb..73f5449864 100644 --- a/quantum/process_keycode/process_unicodemap.h +++ b/quantum/process_keycode/process_unicodemap.h @@ -16,7 +16,11 @@ #pragma once -#include "process_unicode_common.h" +#include +#include + +#include "action.h" +#include "progmem.h" extern const uint32_t PROGMEM unicode_map[]; diff --git a/quantum/quantum.h b/quantum/quantum.h index 8d74f2be38..51360c3d2a 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -109,6 +109,7 @@ extern layer_state_t layer_state; #endif #ifdef UNICODE_COMMON_ENABLE +# include "unicode.h" # include "process_unicode_common.h" #endif diff --git a/quantum/unicode/unicode.c b/quantum/unicode/unicode.c new file mode 100644 index 0000000000..f9f429e7af --- /dev/null +++ b/quantum/unicode/unicode.c @@ -0,0 +1,376 @@ +/* Copyright 2022 + * + * 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 . + */ + +#include "unicode.h" + +#include "eeprom.h" +#include "eeconfig.h" +#include "action.h" +#include "action_util.h" +#include "host.h" +#include "keycode.h" +#include "wait.h" +#include "audio.h" +#include "send_string.h" +#include "utf8.h" + +#if defined(UNICODE_ENABLE) + defined(UNICODEMAP_ENABLE) + defined(UCIS_ENABLE) > 1 +# error "Cannot enable more than one Unicode method (UNICODE, UNICODEMAP, UCIS) at the same time" +#endif + +// Keycodes used for starting Unicode input on different platforms +#ifndef UNICODE_KEY_MAC +# define UNICODE_KEY_MAC KC_LEFT_ALT +#endif +#ifndef UNICODE_KEY_LNX +# define UNICODE_KEY_LNX LCTL(LSFT(KC_U)) +#endif +#ifndef UNICODE_KEY_WINC +# define UNICODE_KEY_WINC KC_RIGHT_ALT +#endif + +// Comma-delimited, ordered list of input modes selected for use (e.g. in cycle) +// Example: #define UNICODE_SELECTED_MODES UC_WINC, UC_LNX +#ifndef UNICODE_SELECTED_MODES +# define UNICODE_SELECTED_MODES -1 +#endif + +// Whether input mode changes in cycle should be written to EEPROM +#ifndef UNICODE_CYCLE_PERSIST +# define UNICODE_CYCLE_PERSIST true +#endif + +// Delay between starting Unicode input and sending a sequence, in ms +#ifndef UNICODE_TYPE_DELAY +# define UNICODE_TYPE_DELAY 10 +#endif + +unicode_config_t unicode_config; +uint8_t unicode_saved_mods; +led_t unicode_saved_led_state; + +#if UNICODE_SELECTED_MODES != -1 +static uint8_t selected[] = {UNICODE_SELECTED_MODES}; +static int8_t selected_count = ARRAY_SIZE(selected); +static int8_t selected_index; +#endif + +/** \brief unicode input mode set at user level + * + * Run user code on unicode input mode change + */ +__attribute__((weak)) void unicode_input_mode_set_user(uint8_t input_mode) {} + +/** \brief unicode input mode set at keyboard level + * + * Run keyboard code on unicode input mode change + */ +__attribute__((weak)) void unicode_input_mode_set_kb(uint8_t input_mode) { + unicode_input_mode_set_user(input_mode); +} + +#ifdef AUDIO_ENABLE +# ifdef UNICODE_SONG_MAC +static float song_mac[][2] = UNICODE_SONG_MAC; +# endif +# ifdef UNICODE_SONG_LNX +static float song_lnx[][2] = UNICODE_SONG_LNX; +# endif +# ifdef UNICODE_SONG_WIN +static float song_win[][2] = UNICODE_SONG_WIN; +# endif +# ifdef UNICODE_SONG_BSD +static float song_bsd[][2] = UNICODE_SONG_BSD; +# endif +# ifdef UNICODE_SONG_WINC +static float song_winc[][2] = UNICODE_SONG_WINC; +# endif +# ifdef UNICODE_SONG_EMACS +static float song_emacs[][2] = UNICODE_SONG_EMACS; +# endif + +static void unicode_play_song(uint8_t mode) { + switch (mode) { +# ifdef UNICODE_SONG_MAC + case UC_MAC: + PLAY_SONG(song_mac); + break; +# endif +# ifdef UNICODE_SONG_LNX + case UC_LNX: + PLAY_SONG(song_lnx); + break; +# endif +# ifdef UNICODE_SONG_WIN + case UC_WIN: + PLAY_SONG(song_win); + break; +# endif +# ifdef UNICODE_SONG_BSD + case UC_BSD: + PLAY_SONG(song_bsd); + break; +# endif +# ifdef UNICODE_SONG_WINC + case UC_WINC: + PLAY_SONG(song_winc); + break; +# endif +# ifdef UNICODE_SONG_EMACS + case UC_EMACS: + PLAY_SONG(song_emacs); + break; +# endif + } +} +#endif + +void unicode_input_mode_init(void) { + unicode_config.raw = eeprom_read_byte(EECONFIG_UNICODEMODE); +#if UNICODE_SELECTED_MODES != -1 +# if UNICODE_CYCLE_PERSIST + // Find input_mode in selected modes + int8_t i; + for (i = 0; i < selected_count; i++) { + if (selected[i] == unicode_config.input_mode) { + selected_index = i; + break; + } + } + if (i == selected_count) { + // Not found: input_mode isn't selected, change to one that is + unicode_config.input_mode = selected[selected_index = 0]; + } +# else + // Always change to the first selected input mode + unicode_config.input_mode = selected[selected_index = 0]; +# endif +#endif + unicode_input_mode_set_kb(unicode_config.input_mode); + dprintf("Unicode input mode init to: %u\n", unicode_config.input_mode); +} + +uint8_t get_unicode_input_mode(void) { + return unicode_config.input_mode; +} + +void set_unicode_input_mode(uint8_t mode) { + unicode_config.input_mode = mode; + persist_unicode_input_mode(); +#ifdef AUDIO_ENABLE + unicode_play_song(mode); +#endif + unicode_input_mode_set_kb(mode); + dprintf("Unicode input mode set to: %u\n", unicode_config.input_mode); +} + +void cycle_unicode_input_mode(int8_t offset) { +#if UNICODE_SELECTED_MODES != -1 + selected_index = (selected_index + offset) % selected_count; + if (selected_index < 0) { + selected_index += selected_count; + } + unicode_config.input_mode = selected[selected_index]; +# if UNICODE_CYCLE_PERSIST + persist_unicode_input_mode(); +# endif +# ifdef AUDIO_ENABLE + unicode_play_song(unicode_config.input_mode); +# endif + unicode_input_mode_set_kb(unicode_config.input_mode); + dprintf("Unicode input mode cycle to: %u\n", unicode_config.input_mode); +#endif +} + +void persist_unicode_input_mode(void) { + eeprom_update_byte(EECONFIG_UNICODEMODE, unicode_config.input_mode); +} + +__attribute__((weak)) void unicode_input_start(void) { + unicode_saved_led_state = host_keyboard_led_state(); + + // Note the order matters here! + // Need to do this before we mess around with the mods, or else + // UNICODE_KEY_LNX (which is usually Ctrl-Shift-U) might not work + // correctly in the shifted case. + if (unicode_config.input_mode == UC_LNX && unicode_saved_led_state.caps_lock) { + tap_code(KC_CAPS_LOCK); + } + + unicode_saved_mods = get_mods(); // Save current mods + clear_mods(); // Unregister mods to start from a clean state + clear_weak_mods(); + + switch (unicode_config.input_mode) { + case UC_MAC: + register_code(UNICODE_KEY_MAC); + break; + case UC_LNX: + tap_code16(UNICODE_KEY_LNX); + break; + case UC_WIN: + // For increased reliability, use numpad keys for inputting digits + if (!unicode_saved_led_state.num_lock) { + tap_code(KC_NUM_LOCK); + } + register_code(KC_LEFT_ALT); + wait_ms(UNICODE_TYPE_DELAY); + tap_code(KC_KP_PLUS); + break; + case UC_WINC: + tap_code(UNICODE_KEY_WINC); + tap_code(KC_U); + break; + case UC_EMACS: + // The usual way to type unicode in emacs is C-x-8 then the unicode number in hex + tap_code16(LCTL(KC_X)); + tap_code16(KC_8); + tap_code16(KC_ENTER); + break; + } + + wait_ms(UNICODE_TYPE_DELAY); +} + +__attribute__((weak)) void unicode_input_finish(void) { + switch (unicode_config.input_mode) { + case UC_MAC: + unregister_code(UNICODE_KEY_MAC); + break; + case UC_LNX: + tap_code(KC_SPACE); + if (unicode_saved_led_state.caps_lock) { + tap_code(KC_CAPS_LOCK); + } + break; + case UC_WIN: + unregister_code(KC_LEFT_ALT); + if (!unicode_saved_led_state.num_lock) { + tap_code(KC_NUM_LOCK); + } + break; + case UC_WINC: + tap_code(KC_ENTER); + break; + case UC_EMACS: + tap_code16(KC_ENTER); + break; + } + + set_mods(unicode_saved_mods); // Reregister previously set mods +} + +__attribute__((weak)) void unicode_input_cancel(void) { + switch (unicode_config.input_mode) { + case UC_MAC: + unregister_code(UNICODE_KEY_MAC); + break; + case UC_LNX: + tap_code(KC_ESCAPE); + if (unicode_saved_led_state.caps_lock) { + tap_code(KC_CAPS_LOCK); + } + break; + case UC_WINC: + tap_code(KC_ESCAPE); + break; + case UC_WIN: + unregister_code(KC_LEFT_ALT); + if (!unicode_saved_led_state.num_lock) { + tap_code(KC_NUM_LOCK); + } + break; + case UC_EMACS: + tap_code16(LCTL(KC_G)); // C-g cancels + break; + } + + set_mods(unicode_saved_mods); // Reregister previously set mods +} + +// clang-format off + +static void send_nibble_wrapper(uint8_t digit) { + if (unicode_config.input_mode == UC_WIN) { + uint8_t kc = digit < 10 + ? KC_KP_1 + (10 + digit - 1) % 10 + : KC_A + (digit - 10); + tap_code(kc); + return; + } + send_nibble(digit); +} + +// clang-format on + +void register_hex(uint16_t hex) { + for (int i = 3; i >= 0; i--) { + uint8_t digit = ((hex >> (i * 4)) & 0xF); + send_nibble_wrapper(digit); + } +} + +void register_hex32(uint32_t hex) { + bool onzerostart = true; + for (int i = 7; i >= 0; i--) { + if (i <= 3) { + onzerostart = false; + } + uint8_t digit = ((hex >> (i * 4)) & 0xF); + if (digit == 0) { + if (!onzerostart) { + send_nibble_wrapper(digit); + } + } else { + send_nibble_wrapper(digit); + onzerostart = false; + } + } +} + +void register_unicode(uint32_t code_point) { + if (code_point > 0x10FFFF || (code_point > 0xFFFF && unicode_config.input_mode == UC_WIN)) { + // Code point out of range, do nothing + return; + } + + unicode_input_start(); + if (code_point > 0xFFFF && unicode_config.input_mode == UC_MAC) { + // Convert code point to UTF-16 surrogate pair on macOS + code_point -= 0x10000; + uint32_t lo = code_point & 0x3FF, hi = (code_point & 0xFFC00) >> 10; + register_hex32(hi + 0xD800); + register_hex32(lo + 0xDC00); + } else { + register_hex32(code_point); + } + unicode_input_finish(); +} + +void send_unicode_string(const char *str) { + if (!str) { + return; + } + + while (*str) { + int32_t code_point = 0; + str = decode_utf8(str, &code_point); + + if (code_point >= 0) { + register_unicode(code_point); + } + } +} diff --git a/quantum/unicode/unicode.h b/quantum/unicode/unicode.h new file mode 100644 index 0000000000..b3e43799ff --- /dev/null +++ b/quantum/unicode/unicode.h @@ -0,0 +1,165 @@ +/* Copyright 2022 + * + * 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 . + */ + +#pragma once + +#include + +#include "quantum.h" + +typedef union { + uint32_t raw; + struct { + uint8_t input_mode : 8; + }; +} unicode_config_t; + +extern unicode_config_t unicode_config; + +enum unicode_input_modes { + UC_MAC, // macOS using Unicode Hex Input + UC_LNX, // Linux using IBus + UC_WIN, // Windows using EnableHexNumpad + UC_BSD, // BSD (not implemented) + UC_WINC, // Windows using WinCompose (https://github.com/samhocevar/wincompose) + UC_EMACS, // Emacs is an operating system in search of a good text editor + UC__COUNT // Number of available input modes (always leave at the end) +}; + +void unicode_input_mode_init(void); +uint8_t get_unicode_input_mode(void); +void set_unicode_input_mode(uint8_t mode); +void cycle_unicode_input_mode(int8_t offset); +void persist_unicode_input_mode(void); + +void unicode_input_mode_set_user(uint8_t input_mode); +void unicode_input_mode_set_kb(uint8_t input_mode); + +void unicode_input_start(void); +void unicode_input_finish(void); +void unicode_input_cancel(void); + +void register_hex(uint16_t hex); +void register_hex32(uint32_t hex); +void register_unicode(uint32_t code_point); + +void send_unicode_string(const char *str); + +// clang-format off + +#define UC_BSPC UC(0x0008) // (backspace) + +#define UC_SPC UC(0x0020) // (space) +#define UC_EXLM UC(0x0021) // ! +#define UC_DQUT UC(0x0022) // " +#define UC_HASH UC(0x0023) // # +#define UC_DLR UC(0x0024) // $ +#define UC_PERC UC(0x0025) // % +#define UC_AMPR UC(0x0026) // & +#define UC_QUOT UC(0x0027) // ' +#define UC_LPRN UC(0x0028) // ( +#define UC_RPRN UC(0x0029) // ) +#define UC_ASTR UC(0x002A) // * +#define UC_PLUS UC(0x002B) // + +#define UC_COMM UC(0x002C) // , +#define UC_DASH UC(0x002D) // - +#define UC_DOT UC(0x002E) // . +#define UC_SLSH UC(0x002F) // / + +#define UC_0 UC(0x0030) // 0 +#define UC_1 UC(0x0031) // 1 +#define UC_2 UC(0x0032) // 2 +#define UC_3 UC(0x0033) // 3 +#define UC_4 UC(0x0034) // 4 +#define UC_5 UC(0x0035) // 5 +#define UC_6 UC(0x0036) // 6 +#define UC_7 UC(0x0037) // 7 +#define UC_8 UC(0x0038) // 8 +#define UC_9 UC(0x0039) // 9 +#define UC_COLN UC(0x003A) // : +#define UC_SCLN UC(0x003B) // ; +#define UC_LT UC(0x003C) // < +#define UC_EQL UC(0x003D) // = +#define UC_GT UC(0x003E) // > +#define UC_QUES UC(0x003F) // ? + +#define UC_AT UC(0x0040) // @ +#define UC_A UC(0x0041) // A +#define UC_B UC(0x0042) // B +#define UC_C UC(0x0043) // C +#define UC_D UC(0x0044) // D +#define UC_E UC(0x0045) // E +#define UC_F UC(0x0046) // F +#define UC_G UC(0x0047) // G +#define UC_H UC(0x0048) // H +#define UC_I UC(0x0049) // I +#define UC_J UC(0x004A) // J +#define UC_K UC(0x004B) // K +#define UC_L UC(0x004C) // L +#define UC_M UC(0x004D) // M +#define UC_N UC(0x004E) // N +#define UC_O UC(0x004F) // O + +#define UC_P UC(0x0050) // P +#define UC_Q UC(0x0051) // Q +#define UC_R UC(0x0052) // R +#define UC_S UC(0x0053) // S +#define UC_T UC(0x0054) // T +#define UC_U UC(0x0055) // U +#define UC_V UC(0x0056) // V +#define UC_W UC(0x0057) // W +#define UC_X UC(0x0058) // X +#define UC_Y UC(0x0059) // Y +#define UC_Z UC(0x005A) // Z +#define UC_LBRC UC(0x005B) // [ +#define UC_BSLS UC(0x005C) // (backslash) +#define UC_RBRC UC(0x005D) // ] +#define UC_CIRM UC(0x005E) // ^ +#define UC_UNDR UC(0x005F) // _ + +#define UC_GRV UC(0x0060) // ` +#define UC_a UC(0x0061) // a +#define UC_b UC(0x0062) // b +#define UC_c UC(0x0063) // c +#define UC_d UC(0x0064) // d +#define UC_e UC(0x0065) // e +#define UC_f UC(0x0066) // f +#define UC_g UC(0x0067) // g +#define UC_h UC(0x0068) // h +#define UC_i UC(0x0069) // i +#define UC_j UC(0x006A) // j +#define UC_k UC(0x006B) // k +#define UC_l UC(0x006C) // l +#define UC_m UC(0x006D) // m +#define UC_n UC(0x006E) // n +#define UC_o UC(0x006F) // o + +#define UC_p UC(0x0070) // p +#define UC_q UC(0x0071) // q +#define UC_r UC(0x0072) // r +#define UC_s UC(0x0073) // s +#define UC_t UC(0x0074) // t +#define UC_u UC(0x0075) // u +#define UC_v UC(0x0076) // v +#define UC_w UC(0x0077) // w +#define UC_x UC(0x0078) // x +#define UC_y UC(0x0079) // y +#define UC_z UC(0x007A) // z +#define UC_LCBR UC(0x007B) // { +#define UC_PIPE UC(0x007C) // | +#define UC_RCBR UC(0x007D) // } +#define UC_TILD UC(0x007E) // ~ +#define UC_DEL UC(0x007F) // (delete) diff --git a/quantum/unicode/utf8.c b/quantum/unicode/utf8.c new file mode 100644 index 0000000000..4b2cd4d8d4 --- /dev/null +++ b/quantum/unicode/utf8.c @@ -0,0 +1,46 @@ +/* Copyright 2021 QMK + * + * 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 . + */ + +#include "utf8.h" + +// Borrowed from https://nullprogram.com/blog/2017/10/06/ +const char *decode_utf8(const char *str, int32_t *code_point) { + const char *next; + + if (str[0] < 0x80) { // U+0000-007F + *code_point = str[0]; + next = str + 1; + } else if ((str[0] & 0xE0) == 0xC0) { // U+0080-07FF + *code_point = ((int32_t)(str[0] & 0x1F) << 6) | ((int32_t)(str[1] & 0x3F) << 0); + next = str + 2; + } else if ((str[0] & 0xF0) == 0xE0) { // U+0800-FFFF + *code_point = ((int32_t)(str[0] & 0x0F) << 12) | ((int32_t)(str[1] & 0x3F) << 6) | ((int32_t)(str[2] & 0x3F) << 0); + next = str + 3; + } else if ((str[0] & 0xF8) == 0xF0 && (str[0] <= 0xF4)) { // U+10000-10FFFF + *code_point = ((int32_t)(str[0] & 0x07) << 18) | ((int32_t)(str[1] & 0x3F) << 12) | ((int32_t)(str[2] & 0x3F) << 6) | ((int32_t)(str[3] & 0x3F) << 0); + next = str + 4; + } else { + *code_point = -1; + next = str + 1; + } + + // part of a UTF-16 surrogate pair - invalid + if (*code_point >= 0xD800 && *code_point <= 0xDFFF) { + *code_point = -1; + } + + return next; +} diff --git a/quantum/unicode/utf8.h b/quantum/unicode/utf8.h new file mode 100644 index 0000000000..521dd1918c --- /dev/null +++ b/quantum/unicode/utf8.h @@ -0,0 +1,21 @@ +/* Copyright 2021 QMK + * + * 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 . + */ + +#pragma once + +#include + +const char *decode_utf8(const char *str, int32_t *code_point); diff --git a/quantum/utf8.c b/quantum/utf8.c deleted file mode 100644 index 4b2cd4d8d4..0000000000 --- a/quantum/utf8.c +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2021 QMK - * - * 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 . - */ - -#include "utf8.h" - -// Borrowed from https://nullprogram.com/blog/2017/10/06/ -const char *decode_utf8(const char *str, int32_t *code_point) { - const char *next; - - if (str[0] < 0x80) { // U+0000-007F - *code_point = str[0]; - next = str + 1; - } else if ((str[0] & 0xE0) == 0xC0) { // U+0080-07FF - *code_point = ((int32_t)(str[0] & 0x1F) << 6) | ((int32_t)(str[1] & 0x3F) << 0); - next = str + 2; - } else if ((str[0] & 0xF0) == 0xE0) { // U+0800-FFFF - *code_point = ((int32_t)(str[0] & 0x0F) << 12) | ((int32_t)(str[1] & 0x3F) << 6) | ((int32_t)(str[2] & 0x3F) << 0); - next = str + 3; - } else if ((str[0] & 0xF8) == 0xF0 && (str[0] <= 0xF4)) { // U+10000-10FFFF - *code_point = ((int32_t)(str[0] & 0x07) << 18) | ((int32_t)(str[1] & 0x3F) << 12) | ((int32_t)(str[2] & 0x3F) << 6) | ((int32_t)(str[3] & 0x3F) << 0); - next = str + 4; - } else { - *code_point = -1; - next = str + 1; - } - - // part of a UTF-16 surrogate pair - invalid - if (*code_point >= 0xD800 && *code_point <= 0xDFFF) { - *code_point = -1; - } - - return next; -} diff --git a/quantum/utf8.h b/quantum/utf8.h deleted file mode 100644 index fb10910944..0000000000 --- a/quantum/utf8.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright 2021 QMK - * - * 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 . - */ - -#pragma once - -#include - -const char *decode_utf8(const char *str, int32_t *code_point); \ No newline at end of file -- cgit v1.2.3 From 8d715fc16b7c44007bc41117341fe92272e7ba2f Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Wed, 14 Sep 2022 19:15:57 +0100 Subject: Remove deprecated RESET keycode alias (#18271) --- quantum/keymap.h | 23 +---------------------- quantum/quantum_keycodes_legacy.h | 4 ++-- 2 files changed, 3 insertions(+), 24 deletions(-) (limited to 'quantum') diff --git a/quantum/keymap.h b/quantum/keymap.h index edff484129..67e35c4e2f 100644 --- a/quantum/keymap.h +++ b/quantum/keymap.h @@ -19,38 +19,17 @@ along with this program. If not, see . #include #include +#include "platform_deps.h" #include "action.h" -#if defined(__AVR__) -# include -#elif defined PROTOCOL_CHIBIOS -// We need to ensure that chibios is include before redefining reset -# include -#endif #include "keycode.h" #include "report.h" #include "host.h" -// #include "print.h" #include "debug.h" #include "keycode_config.h" #include "gpio.h" // for pin_t -// ChibiOS uses RESET in its FlagStatus enumeration -// Therefore define it as QK_BOOTLOADER here, to avoid name collision -#if defined(PROTOCOL_CHIBIOS) -# define RESET QK_BOOTLOADER -#endif -// Gross hack, remove me and change RESET keycode to QK_BOOT -#if defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) -# undef RESET -#endif - #include "quantum_keycodes.h" -// Gross hack, remove me and change RESET keycode to QK_BOOT -#if defined(MCU_RP) -# undef RESET -#endif - // translates key to keycode uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key); diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h index 51380d9c50..1de81b4c0f 100644 --- a/quantum/quantum_keycodes_legacy.h +++ b/quantum/quantum_keycodes_legacy.h @@ -4,7 +4,6 @@ // Deprecated Quantum keycodes -#define RESET QK_BOOTLOADER #define DEBUG QK_DEBUG_TOGGLE #define GRAVE_ESC QK_GRAVE_ESCAPE #define EEPROM_RESET QK_CLEAR_EEPROM @@ -13,4 +12,5 @@ #define EEP_RST QK_CLEAR_EEPROM #define TERM_ON _Static_assert(false, "The Terminal feature has been removed from QMK. Please remove use of TERM_ON/TERM_OFF from your keymap.") -#define TERM_OFF _Static_assert(false, "The Terminal feature has been removed from QMK.. Please remove use of TERM_ON/TERM_OFF from your keymap.") \ No newline at end of file +#define TERM_OFF _Static_assert(false, "The Terminal feature has been removed from QMK.. Please remove use of TERM_ON/TERM_OFF from your keymap.") +// #define RESET _Static_assert(false, "The RESET keycode has been removed from QMK.. Please remove use from your keymap.") -- cgit v1.2.3 From 40b0b3a9830097ac6be2a2acfd2aa3cf7300fd8f Mon Sep 17 00:00:00 2001 From: Dasky <32983009+daskygit@users.noreply.github.com> Date: Thu, 15 Sep 2022 07:48:43 +0100 Subject: Fix cirque tap from secondary side (#18351) --- quantum/pointing_device/pointing_device_drivers.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'quantum') diff --git a/quantum/pointing_device/pointing_device_drivers.c b/quantum/pointing_device/pointing_device_drivers.c index 096ad5d028..d7e0b90917 100644 --- a/quantum/pointing_device/pointing_device_drivers.c +++ b/quantum/pointing_device/pointing_device_drivers.c @@ -117,8 +117,11 @@ report_mouse_t cirque_pinnacle_get_report(report_mouse_t mouse_report) { pinnacle_data_t touchData = cirque_pinnacle_read_data(); mouse_xy_report_t report_x = 0, report_y = 0; static uint16_t x = 0, y = 0; +# if defined(CIRQUE_PINNACLE_TAP_ENABLE) + mouse_report.buttons = pointing_device_handle_buttons(mouse_report.buttons, false, POINTING_DEVICE_BUTTON1); +# endif # ifdef POINTING_DEVICE_GESTURES_CURSOR_GLIDE_ENABLE - cursor_glide_t glide_report = {0}; + cursor_glide_t glide_report = {0}; if (cursor_glide_enable) { glide_report = cursor_glide_check(&glide); -- cgit v1.2.3 From e1aed8da08468fd04bb9e33129a5a26b80c0e093 Mon Sep 17 00:00:00 2001 From: Dasky <32983009+daskygit@users.noreply.github.com> Date: Fri, 16 Sep 2022 00:06:00 +0100 Subject: Move fake EE_HANDS (#18352) --- quantum/eeconfig.c | 10 ---------- quantum/split_common/split_util.c | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'quantum') diff --git a/quantum/eeconfig.c b/quantum/eeconfig.c index 0ff9996ca4..0b7ae39907 100644 --- a/quantum/eeconfig.c +++ b/quantum/eeconfig.c @@ -57,16 +57,6 @@ void eeconfig_init_quantum(void) { eeprom_update_dword(EECONFIG_RGB_MATRIX, 0); eeprom_update_word(EECONFIG_RGB_MATRIX_EXTENDED, 0); - // TODO: Remove once ARM has a way to configure EECONFIG_HANDEDNESS - // within the emulated eeprom via dfu-util or another tool -#if defined INIT_EE_HANDS_LEFT -# pragma message "Faking EE_HANDS for left hand" - eeprom_update_byte(EECONFIG_HANDEDNESS, 1); -#elif defined INIT_EE_HANDS_RIGHT -# pragma message "Faking EE_HANDS for right hand" - eeprom_update_byte(EECONFIG_HANDEDNESS, 0); -#endif - #if defined(HAPTIC_ENABLE) haptic_reset(); #else diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c index 4892b7f8d8..0b3338ed6f 100644 --- a/quantum/split_common/split_util.c +++ b/quantum/split_common/split_util.c @@ -139,6 +139,20 @@ void split_pre_init(void) { if (!eeconfig_is_enabled()) { eeconfig_init(); } + // TODO: Remove once ARM has a way to configure EECONFIG_HANDEDNESS within the emulated eeprom via dfu-util or another tool +# if defined(INIT_EE_HANDS_LEFT) || defined(INIT_EE_HANDS_RIGHT) +# if defined(INIT_EE_HANDS_LEFT) +# pragma message "Faking EE_HANDS for left hand" + const bool should_be_left = true; +# else +# pragma message "Faking EE_HANDS for right hand" + const bool should_be_left = false; +# endif + bool is_left = eeconfig_read_handedness(); + if (is_left != should_be_left) { + eeconfig_update_handedness(should_be_left); + } +# endif // defined(INIT_EE_HANDS_LEFT) || defined(INIT_EE_HANDS_RIGHT) #endif isLeftHand = is_keyboard_left(); -- cgit v1.2.3 From a26f1ddafa05c04cc9446109db250c59f689b35a Mon Sep 17 00:00:00 2001 From: Joshua Diamond Date: Sat, 17 Sep 2022 01:48:09 -0400 Subject: Chromeos keycodes (#18212) --- quantum/keycode.h | 8 ++++++-- quantum/keymap_common.c | 2 +- quantum/via_ensure_keycode.h | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'quantum') diff --git a/quantum/keycode.h b/quantum/keycode.h index 3c80a386d1..c2103ebaa7 100644 --- a/quantum/keycode.h +++ b/quantum/keycode.h @@ -33,7 +33,7 @@ along with this program. If not, see . #define IS_SPECIAL(code) ((0xA5 <= (code) && (code) <= 0xDF) || (0xE8 <= (code) && (code) <= 0xFF)) #define IS_SYSTEM(code) (KC_PWR <= (code) && (code) <= KC_WAKE) -#define IS_CONSUMER(code) (KC_MUTE <= (code) && (code) <= KC_BRID) +#define IS_CONSUMER(code) (KC_MUTE <= (code) && (code) <= KC_ASST) #define IS_MOUSEKEY(code) (KC_MS_UP <= (code) && (code) <= KC_MS_ACCEL2) #define IS_MOUSEKEY_MOVE(code) (KC_MS_UP <= (code) && (code) <= KC_MS_RIGHT) @@ -205,6 +205,8 @@ along with this program. If not, see . #define KC_MRWD KC_MEDIA_REWIND #define KC_BRIU KC_BRIGHTNESS_UP #define KC_BRID KC_BRIGHTNESS_DOWN +#define KC_CPNL KC_CONTROL_PANEL +#define KC_ASST KC_ASSISTANT /* System Specific */ #define KC_BRMU KC_PAUSE @@ -502,7 +504,9 @@ enum internal_special_keycodes { KC_MEDIA_FAST_FORWARD, KC_MEDIA_REWIND, KC_BRIGHTNESS_UP, - KC_BRIGHTNESS_DOWN + KC_BRIGHTNESS_DOWN, + KC_CONTROL_PANEL, + KC_ASSISTANT // 0xC0 }; enum mouse_keys { diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 8d7a8bda9a..1d5ef9b403 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -61,7 +61,7 @@ action_t action_for_keycode(uint16_t keycode) { case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE: action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode)); break; - case KC_AUDIO_MUTE ... KC_BRIGHTNESS_DOWN: + case KC_AUDIO_MUTE ... KC_ASSISTANT: action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode)); break; #endif diff --git a/quantum/via_ensure_keycode.h b/quantum/via_ensure_keycode.h index 75f816b560..010e1d92d4 100644 --- a/quantum/via_ensure_keycode.h +++ b/quantum/via_ensure_keycode.h @@ -195,6 +195,8 @@ _Static_assert(KC_MFFD == 0x00BB, ""); _Static_assert(KC_MRWD == 0x00BC, ""); _Static_assert(KC_BRIU == 0x00BD, ""); _Static_assert(KC_BRID == 0x00BE, ""); +_Static_assert(KC_CPNL == 0x00BF, ""); +_Static_assert(KC_ASST == 0x00C0, ""); _Static_assert(KC_LEFT_CTRL == 0x00E0, ""); _Static_assert(KC_LEFT_SHIFT == 0x00E1, ""); -- cgit v1.2.3 From d67d388e776eeb8596181894639b6ed46c8a2d7d Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 16 Sep 2022 22:49:00 -0700 Subject: Move mousekey keycodes into newly freed up keycode block (#16076) --- quantum/keycode.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'quantum') diff --git a/quantum/keycode.h b/quantum/keycode.h index c2103ebaa7..b492e4292a 100644 --- a/quantum/keycode.h +++ b/quantum/keycode.h @@ -514,11 +514,11 @@ enum mouse_keys { #ifdef VIA_ENABLE KC_MS_UP = 0xF0, #else - KC_MS_UP = 0xED, + KC_MS_UP = 0xCD, #endif KC_MS_DOWN, KC_MS_LEFT, - KC_MS_RIGHT, // 0xF0 + KC_MS_RIGHT, KC_MS_BTN1, KC_MS_BTN2, KC_MS_BTN3, @@ -543,7 +543,7 @@ enum mouse_keys { /* Acceleration */ KC_MS_ACCEL0, KC_MS_ACCEL1, - KC_MS_ACCEL2 // 0xFF + KC_MS_ACCEL2 // 0xDF, or 0xFF if via enabled }; #include "keycode_legacy.h" -- cgit v1.2.3 From fb29c0ae53e32fb049516fcbe0f7863882ca9173 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Sat, 17 Sep 2022 00:50:54 -0700 Subject: [Core] Add getreuer's Autocorrect feature to core (#15699) Co-authored-by: Albert Y <76888457+filterpaper@users.noreply.github.com> --- quantum/eeconfig.c | 2 +- quantum/keycode_config.h | 1 + quantum/process_keycode/autocorrect_data_default.h | 85 ++++++ quantum/process_keycode/process_autocorrect.c | 287 +++++++++++++++++++++ quantum/process_keycode/process_autocorrect.h | 17 ++ quantum/quantum.c | 3 + quantum/quantum.h | 4 + quantum/quantum_keycodes.h | 8 + 8 files changed, 406 insertions(+), 1 deletion(-) create mode 100644 quantum/process_keycode/autocorrect_data_default.h create mode 100644 quantum/process_keycode/process_autocorrect.c create mode 100644 quantum/process_keycode/process_autocorrect.h (limited to 'quantum') diff --git a/quantum/eeconfig.c b/quantum/eeconfig.c index 0b7ae39907..7c0431fd12 100644 --- a/quantum/eeconfig.c +++ b/quantum/eeconfig.c @@ -46,7 +46,7 @@ void eeconfig_init_quantum(void) { eeprom_update_byte(EECONFIG_DEFAULT_LAYER, 0); default_layer_state = 0; eeprom_update_byte(EECONFIG_KEYMAP_LOWER_BYTE, 0); - eeprom_update_byte(EECONFIG_KEYMAP_UPPER_BYTE, 0x4); + eeprom_update_byte(EECONFIG_KEYMAP_UPPER_BYTE, 0xC); eeprom_update_byte(EECONFIG_MOUSEKEY_ACCEL, 0); eeprom_update_byte(EECONFIG_BACKLIGHT, 0); eeprom_update_byte(EECONFIG_AUDIO, 0xFF); // On by default diff --git a/quantum/keycode_config.h b/quantum/keycode_config.h index 81a8e61471..eef048d95c 100644 --- a/quantum/keycode_config.h +++ b/quantum/keycode_config.h @@ -39,6 +39,7 @@ typedef union { bool swap_rctl_rgui : 1; bool oneshot_enable : 1; bool swap_escape_capslock : 1; + bool autocorrect_enable : 1; }; } keymap_config_t; diff --git a/quantum/process_keycode/autocorrect_data_default.h b/quantum/process_keycode/autocorrect_data_default.h new file mode 100644 index 0000000000..bfc29666df --- /dev/null +++ b/quantum/process_keycode/autocorrect_data_default.h @@ -0,0 +1,85 @@ +// Generated code. + +// Autocorrection dictionary (70 entries): +// :guage -> gauge +// :the:the: -> the +// :thier -> their +// :ture -> true +// accomodate -> accommodate +// acommodate -> accommodate +// aparent -> apparent +// aparrent -> apparent +// apparant -> apparent +// apparrent -> apparent +// aquire -> acquire +// becuase -> because +// cauhgt -> caught +// cheif -> chief +// choosen -> chosen +// cieling -> ceiling +// collegue -> colleague +// concensus -> consensus +// contians -> contains +// cosnt -> const +// dervied -> derived +// fales -> false +// fasle -> false +// fitler -> filter +// flase -> false +// foward -> forward +// frequecy -> frequency +// gaurantee -> guarantee +// guaratee -> guarantee +// heigth -> height +// heirarchy -> hierarchy +// inclued -> include +// interator -> iterator +// intput -> input +// invliad -> invalid +// lenght -> length +// liasion -> liaison +// libary -> library +// listner -> listener +// looses: -> loses +// looup -> lookup +// manefist -> manifest +// namesapce -> namespace +// namespcae -> namespace +// occassion -> occasion +// occured -> occurred +// ouptut -> output +// ouput -> output +// overide -> override +// postion -> position +// priviledge -> privilege +// psuedo -> pseudo +// recieve -> receive +// refered -> referred +// relevent -> relevant +// repitition -> repetition +// retrun -> return +// retun -> return +// reuslt -> result +// reutrn -> return +// saftey -> safety +// seperate -> separate +// singed -> signed +// stirng -> string +// strign -> string +// swithc -> switch +// swtich -> switch +// thresold -> threshold +// udpate -> update +// widht -> width + +#define AUTOCORRECT_MIN_LENGTH 5 // ":ture" +#define AUTOCORRECT_MAX_LENGTH 10 // "accomodate" + +#define DICTIONARY_SIZE 1104 + +static const uint8_t autocorrect_data[DICTIONARY_SIZE] PROGMEM = {108, 43, 0, 6, 71, 0, 7, 81, 0, 8, 199, 0, 9, 240, 1, 10, 250, 1, 11, 26, 2, 17, 53, 2, 18, 190, 2, 19, 202, 2, 21, 212, 2, 22, 20, 3, 23, 67, 3, 28, 16, 4, 0, 72, 50, 0, 22, 60, 0, 0, 11, 23, 44, 8, 11, 23, 44, 0, 132, 0, 8, 22, 18, 18, 15, 0, 132, 115, 101, 115, 0, 11, 23, 12, 26, 22, 0, 129, 99, 104, 0, 68, 94, 0, 8, 106, 0, 15, 174, 0, 21, 187, 0, 0, 12, 15, 25, 17, 12, 0, 131, 97, 108, 105, 100, 0, 74, 119, 0, 12, 129, 0, 21, 140, 0, 24, 165, 0, 0, 17, 12, 22, 0, 131, 103, 110, 101, 100, 0, 25, 21, 8, 7, 0, 131, 105, 118, 101, 100, 0, 72, 147, 0, 24, 156, 0, 0, 9, 8, 21, 0, 129, 114, 101, 100, 0, 6, 6, 18, 0, 129, 114, 101, 100, 0, 15, 6, 17, 12, 0, 129, 100, 101, 0, 18, 22, 8, 21, 11, 23, 0, 130, 104, 111, + 108, 100, 0, 4, 26, 18, 9, 0, 131, 114, 119, 97, 114, 100, 0, 68, 233, 0, 6, 246, 0, 7, 4, 1, 8, 16, 1, 10, 52, 1, 15, 81, 1, 21, 90, 1, 22, 117, 1, 23, 144, 1, 24, 215, 1, 25, 228, 1, 0, 6, 19, 22, 8, 16, 4, 17, 0, 130, 97, 99, 101, 0, 19, 4, 22, 8, 16, 4, 17, 0, 131, 112, 97, 99, 101, 0, 12, 21, 8, 25, 18, 0, 130, 114, 105, 100, 101, 0, 23, 0, 68, 25, 1, 17, 36, 1, 0, 21, 4, 24, 10, 0, 130, 110, 116, 101, 101, 0, 4, 21, 24, 4, 10, 0, 135, 117, 97, 114, 97, 110, 116, 101, 101, 0, 68, 59, 1, 7, 69, 1, 0, 24, 10, 44, 0, 131, 97, 117, 103, 101, 0, 8, 15, 12, 25, 12, 21, 19, 0, 130, 103, 101, 0, 22, 4, 9, 0, 130, 108, 115, 101, 0, 76, 97, 1, 24, 109, 1, 0, 24, 20, 4, 0, 132, 99, 113, 117, 105, 114, 101, 0, 23, 44, 0, + 130, 114, 117, 101, 0, 4, 0, 79, 126, 1, 24, 134, 1, 0, 9, 0, 131, 97, 108, 115, 101, 0, 6, 8, 5, 0, 131, 97, 117, 115, 101, 0, 4, 0, 71, 156, 1, 19, 193, 1, 21, 203, 1, 0, 18, 16, 0, 80, 166, 1, 18, 181, 1, 0, 18, 6, 4, 0, 135, 99, 111, 109, 109, 111, 100, 97, 116, 101, 0, 6, 6, 4, 0, 132, 109, 111, 100, 97, 116, 101, 0, 7, 24, 0, 132, 112, 100, 97, 116, 101, 0, 8, 19, 8, 22, 0, 132, 97, 114, 97, 116, 101, 0, 10, 8, 15, 15, 18, 6, 0, 130, 97, 103, 117, 101, 0, 8, 12, 6, 8, 21, 0, 131, 101, 105, 118, 101, 0, 12, 8, 11, 6, 0, 130, 105, 101, 102, 0, 17, 0, 76, 3, 2, 21, 16, 2, 0, 15, 8, 12, 6, 0, 133, 101, 105, 108, 105, 110, 103, 0, 12, 23, 22, 0, 131, 114, 105, 110, 103, 0, 70, 33, 2, 23, 44, 2, 0, 12, 23, 26, 22, 0, 131, 105, + 116, 99, 104, 0, 10, 12, 8, 11, 0, 129, 104, 116, 0, 72, 69, 2, 10, 80, 2, 18, 89, 2, 21, 156, 2, 24, 167, 2, 0, 22, 18, 18, 11, 6, 0, 131, 115, 101, 110, 0, 12, 21, 23, 22, 0, 129, 110, 103, 0, 12, 0, 86, 98, 2, 23, 124, 2, 0, 68, 105, 2, 22, 114, 2, 0, 12, 15, 0, 131, 105, 115, 111, 110, 0, 4, 6, 6, 18, 0, 131, 105, 111, 110, 0, 76, 131, 2, 22, 146, 2, 0, 23, 12, 19, 8, 21, 0, 134, 101, 116, 105, 116, 105, 111, 110, 0, 18, 19, 0, 131, 105, 116, 105, 111, 110, 0, 23, 24, 8, 21, 0, 131, 116, 117, 114, 110, 0, 85, 174, 2, 23, 183, 2, 0, 23, 8, 21, 0, 130, 117, 114, 110, 0, 8, 21, 0, 128, 114, 110, 0, 7, 8, 24, 22, 19, 0, 131, 101, 117, 100, 111, 0, 24, 18, 18, 15, 0, 129, 107, 117, 112, 0, 72, 219, 2, 18, 3, 3, 0, 76, 229, 2, 15, 238, + 2, 17, 248, 2, 0, 11, 23, 44, 0, 130, 101, 105, 114, 0, 23, 12, 9, 0, 131, 108, 116, 101, 114, 0, 23, 22, 12, 15, 0, 130, 101, 110, 101, 114, 0, 23, 4, 21, 8, 23, 17, 12, 0, 135, 116, 101, 114, 97, 116, 111, 114, 0, 72, 30, 3, 17, 38, 3, 24, 51, 3, 0, 15, 4, 9, 0, 129, 115, 101, 0, 4, 12, 23, 17, 18, 6, 0, 131, 97, 105, 110, 115, 0, 22, 17, 8, 6, 17, 18, 6, 0, 133, 115, 101, 110, 115, 117, 115, 0, 74, 86, 3, 11, 96, 3, 15, 118, 3, 17, 129, 3, 22, 218, 3, 24, 232, 3, 0, 11, 24, 4, 6, 0, 130, 103, 104, 116, 0, 71, 103, 3, 10, 110, 3, 0, 12, 26, 0, 129, 116, 104, 0, 17, 8, 15, 0, 129, 116, 104, 0, 22, 24, 8, 21, 0, 131, 115, 117, 108, 116, 0, 68, 139, 3, 8, 150, 3, 22, 210, 3, 0, 21, 4, 19, 19, 4, 0, 130, 101, 110, 116, 0, 85, 157, + 3, 25, 200, 3, 0, 68, 164, 3, 21, 175, 3, 0, 19, 4, 0, 132, 112, 97, 114, 101, 110, 116, 0, 4, 19, 0, 68, 185, 3, 19, 193, 3, 0, 133, 112, 97, 114, 101, 110, 116, 0, 4, 0, 131, 101, 110, 116, 0, 8, 15, 8, 21, 0, 130, 97, 110, 116, 0, 18, 6, 0, 130, 110, 115, 116, 0, 12, 9, 8, 17, 4, 16, 0, 132, 105, 102, 101, 115, 116, 0, 83, 239, 3, 23, 6, 4, 0, 87, 246, 3, 24, 254, 3, 0, 17, 12, 0, 131, 112, 117, 116, 0, 18, 0, 130, 116, 112, 117, 116, 0, 19, 24, 18, 0, 131, 116, 112, 117, 116, 0, 70, 29, 4, 8, 41, 4, 11, 51, 4, 21, 69, 4, 0, 8, 24, 20, 8, 21, 9, 0, 129, 110, 99, 121, 0, 23, 9, 4, 22, 0, 130, 101, 116, 121, 0, 6, 21, 4, 21, 12, 8, 11, 0, 135, 105, 101, 114, 97, 114, 99, 104, 121, 0, 4, 5, 12, 15, 0, 130, 114, 97, 114, 121, 0}; diff --git a/quantum/process_keycode/process_autocorrect.c b/quantum/process_keycode/process_autocorrect.c new file mode 100644 index 0000000000..abae5e7811 --- /dev/null +++ b/quantum/process_keycode/process_autocorrect.c @@ -0,0 +1,287 @@ +// Copyright 2021 Google LLC +// Copyright 2021 @filterpaper +// SPDX-License-Identifier: Apache-2.0 +// Original source: https://getreuer.info/posts/keyboards/autocorrection + +#include "process_autocorrect.h" +#include +#include "keycode_config.h" + +#if __has_include("autocorrect_data.h") +# include "autocorrect_data.h" +#else +# pragma message "Autocorrect is using the default library." +# include "autocorrect_data_default.h" +#endif + +static uint8_t typo_buffer[AUTOCORRECT_MAX_LENGTH] = {KC_SPC}; +static uint8_t typo_buffer_size = 1; + +/** + * @brief function for querying the enabled state of autocorrect + * + * @return true if enabled + * @return false if disabled + */ +bool autocorrect_is_enabled(void) { + return keymap_config.autocorrect_enable; +} + +/** + * @brief Enables autocorrect and saves state to eeprom + * + */ +void autocorrect_enable(void) { + keymap_config.autocorrect_enable = true; + eeconfig_update_keymap(keymap_config.raw); +} + +/** + * @brief Disables autocorrect and saves state to eeprom + * + */ +void autocorrect_disable(void) { + keymap_config.autocorrect_enable = false; + typo_buffer_size = 0; + eeconfig_update_keymap(keymap_config.raw); +} + +/** + * @brief Toggles autocorrect's status and save state to eeprom + * + */ +void autocorrect_toggle(void) { + keymap_config.autocorrect_enable = !keymap_config.autocorrect_enable; + typo_buffer_size = 0; + eeconfig_update_keymap(keymap_config.raw); +} + +/** + * @brief handler for determining if autocorrect should process keypress + * + * @param keycode Keycode registered by matrix press, per keymap + * @param record keyrecord_t structure + * @param typo_buffer_size passed along to allow resetting of autocorrect buffer + * @param mods allow processing of mod status + * @return true Allow autocorection + * @return false Stop processing and escape from autocorrect. + */ +__attribute__((weak)) bool process_autocorrect_user(uint16_t *keycode, keyrecord_t *record, uint8_t *typo_buffer_size, uint8_t *mods) { + // See quantum_keycodes.h for reference on these matched ranges. + switch (*keycode) { + // Exclude these keycodes from processing. + case KC_LSFT: + case KC_RSFT: + case KC_CAPS: + case QK_TO ... QK_ONE_SHOT_LAYER_MAX: + case QK_LAYER_TAP_TOGGLE ... QK_LAYER_MOD_MAX: + case QK_ONE_SHOT_MOD ... QK_ONE_SHOT_MOD_MAX: + return false; + + // Mask for base keycode from shifted keys. + case QK_LSFT ... QK_LSFT + 255: + case QK_RSFT ... QK_RSFT + 255: + if (*keycode >= QK_LSFT && *keycode <= (QK_LSFT + 255)) { + *mods |= MOD_LSFT; + } else { + *mods |= MOD_RSFT; + } + *keycode &= 0xFF; // Get the basic keycode. + return true; +#ifndef NO_ACTION_TAPPING + // Exclude tap-hold keys when they are held down + // and mask for base keycode when they are tapped. + case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: +# ifdef NO_ACTION_LAYER + // Exclude Layer Tap, if layers are disabled + // but action tapping is still enabled. + return false; +# endif + case QK_MOD_TAP ... QK_MOD_TAP_MAX: + // Exclude hold keycode + if (!record->tap.count) { + return false; + } + *keycode &= 0xFF; + break; +#else + case QK_MOD_TAP ... QK_MOD_TAP_MAX: + case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: + // Exclude if disabled + return false; +#endif + // Exclude swap hands keys when they are held down + // and mask for base keycode when they are tapped. + case QK_SWAP_HANDS ... QK_SWAP_HANDS_MAX: +#ifdef SWAP_HANDS_ENABLE + if (*keycode >= 0x56F0 || !record->tap.count) { + return false; + } + *keycode &= 0xFF; + break; +#else + // Exclude if disabled + return false; +#endif + } + + // Disable autocorrect while a mod other than shift is active. + if ((*mods & ~MOD_MASK_SHIFT) != 0) { + *typo_buffer_size = 0; + return false; + } + + return true; +} + +/** + * @brief handling for when autocorrection has been triggered + * + * @param backspaces number of characters to remove + * @param str pointer to PROGMEM string to replace mistyped seletion with + * @return true apply correction + * @return false user handled replacement + */ +__attribute__((weak)) bool apply_autocorrect(uint8_t backspaces, const char *str) { + return true; +} + +/** + * @brief Process handler for autocorrect feature + * + * @param keycode Keycode registered by matrix press, per keymap + * @param record keyrecord_t structure + * @return true Continue processing keycodes, and send to host + * @return false Stop processing keycodes, and don't send to host + */ +bool process_autocorrect(uint16_t keycode, keyrecord_t *record) { + uint8_t mods = get_mods(); +#ifndef NO_ACTION_ONESHOT + mods |= get_oneshot_mods(); +#endif + + if ((keycode >= AUTOCORRECT_ON && keycode <= AUTOCORRECT_TOGGLE) && record->event.pressed) { + if (keycode == AUTOCORRECT_ON) { + autocorrect_enable(); + } else if (keycode == AUTOCORRECT_OFF) { + autocorrect_disable(); + } else if (keycode == AUTOCORRECT_TOGGLE) { + autocorrect_toggle(); + } else { + return true; + } + + return false; + } + + if (!keymap_config.autocorrect_enable) { + typo_buffer_size = 0; + return true; + } + + if (!record->event.pressed) { + return true; + } + + // autocorrect keycode verification and extraction + if (!process_autocorrect_user(&keycode, record, &typo_buffer_size, &mods)) { + return true; + } + + // keycode buffer check + switch (keycode) { + case KC_A ... KC_Z: + // process normally + break; + case KC_1 ... KC_0: + case KC_TAB ... KC_SEMICOLON: + case KC_GRAVE ... KC_SLASH: + // Set a word boundary if space, period, digit, etc. is pressed. + keycode = KC_SPC; + break; + case KC_ENTER: + // Behave more conservatively for the enter key. Reset, so that enter + // can't be used on a word ending. + typo_buffer_size = 0; + keycode = KC_SPC; + break; + case KC_BSPC: + // Remove last character from the buffer. + if (typo_buffer_size > 0) { + --typo_buffer_size; + } + return true; + case KC_QUOTE: + // Treat " (shifted ') as a word boundary. + if ((mods & MOD_MASK_SHIFT) != 0) { + keycode = KC_SPC; + } + break; + default: + // Clear state if some other non-alpha key is pressed. + typo_buffer_size = 0; + return true; + } + + // Rotate oldest character if buffer is full. + if (typo_buffer_size >= AUTOCORRECT_MAX_LENGTH) { + memmove(typo_buffer, typo_buffer + 1, AUTOCORRECT_MAX_LENGTH - 1); + typo_buffer_size = AUTOCORRECT_MAX_LENGTH - 1; + } + + // Append `keycode` to buffer. + typo_buffer[typo_buffer_size++] = keycode; + // Return if buffer is smaller than the shortest word. + if (typo_buffer_size < AUTOCORRECT_MIN_LENGTH) { + return true; + } + + // Check for typo in buffer using a trie stored in `autocorrect_data`. + uint16_t state = 0; + uint8_t code = pgm_read_byte(autocorrect_data + state); + for (int8_t i = typo_buffer_size - 1; i >= 0; --i) { + uint8_t const key_i = typo_buffer[i]; + + if (code & 64) { // Check for match in node with multiple children. + code &= 63; + for (; code != key_i; code = pgm_read_byte(autocorrect_data + (state += 3))) { + if (!code) return true; + } + // Follow link to child node. + state = (pgm_read_byte(autocorrect_data + state + 1) | pgm_read_byte(autocorrect_data + state + 2) << 8); + // Check for match in node with single child. + } else if (code != key_i) { + return true; + } else if (!(code = pgm_read_byte(autocorrect_data + (++state)))) { + ++state; + } + + // Stop if `state` becomes an invalid index. This should not normally + // happen, it is a safeguard in case of a bug, data corruption, etc. + if (state >= DICTIONARY_SIZE) { + return true; + } + + code = pgm_read_byte(autocorrect_data + state); + + if (code & 128) { // A typo was found! Apply autocorrect. + const uint8_t backspaces = (code & 63) + !record->event.pressed; + if (apply_autocorrect(backspaces, (char const *)(autocorrect_data + state + 1))) { + for (uint8_t i = 0; i < backspaces; ++i) { + tap_code(KC_BSPC); + } + send_string_P((char const *)(autocorrect_data + state + 1)); + } + + if (keycode == KC_SPC) { + typo_buffer[0] = KC_SPC; + typo_buffer_size = 1; + return true; + } else { + typo_buffer_size = 0; + return false; + } + } + } + return true; +} diff --git a/quantum/process_keycode/process_autocorrect.h b/quantum/process_keycode/process_autocorrect.h new file mode 100644 index 0000000000..c7596107e5 --- /dev/null +++ b/quantum/process_keycode/process_autocorrect.h @@ -0,0 +1,17 @@ +// Copyright 2021 Google LLC +// Copyright 2021 @filterpaper +// SPDX-License-Identifier: Apache-2.0 +// Original source: https://getreuer.info/posts/keyboards/autocorrection + +#pragma once + +#include "quantum.h" + +bool process_autocorrect(uint16_t keycode, keyrecord_t *record); +bool process_autocorrect_user(uint16_t *keycode, keyrecord_t *record, uint8_t *typo_buffer_size, uint8_t *mods); +bool apply_autocorrect(uint8_t backspaces, const char *str); + +bool autocorrect_is_enabled(void); +void autocorrect_enable(void); +void autocorrect_disable(void); +void autocorrect_toggle(void); diff --git a/quantum/quantum.c b/quantum/quantum.c index acafd8025c..9f1d3502fb 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -335,6 +335,9 @@ bool process_record_quantum(keyrecord_t *record) { #endif #ifdef PROGRAMMABLE_BUTTON_ENABLE process_programmable_button(keycode, record) && +#endif +#ifdef AUTOCORRECT_ENABLE + process_autocorrect(keycode, record) && #endif true)) { return false; diff --git a/quantum/quantum.h b/quantum/quantum.h index 51360c3d2a..9c1b9952b8 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -236,6 +236,10 @@ extern layer_state_t layer_state; # include "process_caps_word.h" #endif +#ifdef AUTOCORRECT_ENABLE +# include "process_autocorrect.h" +#endif + // For tri-layer 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); diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index c8f03fa1ce..abf3f1a384 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -611,6 +611,10 @@ enum quantum_keycodes { UNICODE_MODE_EMACS, + AUTOCORRECT_ON, + AUTOCORRECT_OFF, + AUTOCORRECT_TOGGLE, + // Start of custom keycode range for keyboards and keymaps - always leave at the end SAFE_RANGE }; @@ -799,6 +803,10 @@ enum quantum_keycodes { #define EH_LEFT MAGIC_EE_HANDS_LEFT #define EH_RGHT MAGIC_EE_HANDS_RIGHT +#define CRT_ON AUTOCORRECT_ON +#define CRT_OFF AUTOCORRECT_OFF +#define CRT_TOG AUTOCORRECT_TOGGLE + // GOTO layer - 256 layer max #define TO(layer) (QK_TO | ((layer)&0xFF)) -- cgit v1.2.3 From db6a637398a64df343f8317cd1f25dd4268e6a16 Mon Sep 17 00:00:00 2001 From: Dasky <32983009+daskygit@users.noreply.github.com> Date: Sat, 17 Sep 2022 20:58:46 +0100 Subject: Fix EECONFIG_KEYMAP_UPPER_BYTE init (#18394) Co-authored-by: Drashna Jaelre --- quantum/eeconfig.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'quantum') diff --git a/quantum/eeconfig.c b/quantum/eeconfig.c index 7c0431fd12..27a0f6d48f 100644 --- a/quantum/eeconfig.c +++ b/quantum/eeconfig.c @@ -46,7 +46,8 @@ void eeconfig_init_quantum(void) { eeprom_update_byte(EECONFIG_DEFAULT_LAYER, 0); default_layer_state = 0; eeprom_update_byte(EECONFIG_KEYMAP_LOWER_BYTE, 0); - eeprom_update_byte(EECONFIG_KEYMAP_UPPER_BYTE, 0xC); + // Enable oneshot and autocorrect by default: 0b0001 0100 + eeprom_update_byte(EECONFIG_KEYMAP_UPPER_BYTE, 0x14); eeprom_update_byte(EECONFIG_MOUSEKEY_ACCEL, 0); eeprom_update_byte(EECONFIG_BACKLIGHT, 0); eeprom_update_byte(EECONFIG_AUDIO, 0xFF); // On by default -- cgit v1.2.3 From a3a47a6556b42645cee43025fb0863e057d70a09 Mon Sep 17 00:00:00 2001 From: Joshua Diamond Date: Sun, 18 Sep 2022 11:51:04 -0400 Subject: Work around WinCompose issue for U+Axxx or U+Exxx (#18260) * Work around WinCompose issue for U+Axxx or U+Exxx * tzarc's more efficient version Co-authored-by: Thomas --- quantum/unicode/unicode.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'quantum') diff --git a/quantum/unicode/unicode.c b/quantum/unicode/unicode.c index f9f429e7af..3f934c9277 100644 --- a/quantum/unicode/unicode.c +++ b/quantum/unicode/unicode.c @@ -324,19 +324,26 @@ void register_hex(uint16_t hex) { } void register_hex32(uint32_t hex) { - bool onzerostart = true; + bool first_digit = true; + bool needs_leading_zero = (unicode_config.input_mode == UC_WINC); for (int i = 7; i >= 0; i--) { - if (i <= 3) { - onzerostart = false; - } + // Work out the digit we're going to transmit uint8_t digit = ((hex >> (i * 4)) & 0xF); - if (digit == 0) { - if (!onzerostart) { - send_nibble_wrapper(digit); - } - } else { + + // If we're still searching for the first digit, and found one + // that needs a leading zero sent out, send the zero. + if (first_digit && needs_leading_zero && digit > 9) { + send_nibble_wrapper(0); + } + + // Always send digits (including zero) if we're down to the last + // two bytes of nibbles. + bool must_send = i < 4; + + // If we've found a digit worth transmitting, do so. + if (digit != 0 || !first_digit || must_send) { send_nibble_wrapper(digit); - onzerostart = false; + first_digit = false; } } } -- cgit v1.2.3 From 1849897444629403fc2e473da6d6f74f8f4f1b8c Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Mon, 19 Sep 2022 07:30:08 +1000 Subject: [QP] Add RGB565 surface. Docs clarification, cleanup, tabsification, and reordering. (#18396) --- quantum/painter/qp.h | 4 ++++ quantum/painter/qp_draw_image.c | 43 ++++++++++++++++++++++++++---------- quantum/painter/qp_draw_text.c | 49 ++++++++++++++++++++++++++++------------- quantum/painter/qp_stream.c | 47 ++++++++++++++++++--------------------- quantum/painter/qp_stream.h | 5 ++++- quantum/painter/rules.mk | 29 ++++++++++++++++++------ 6 files changed, 116 insertions(+), 61 deletions(-) (limited to 'quantum') diff --git a/quantum/painter/qp.h b/quantum/painter/qp.h index fb6904de22..69bc435961 100644 --- a/quantum/painter/qp.h +++ b/quantum/painter/qp.h @@ -432,6 +432,10 @@ int16_t qp_drawtext_recolor(painter_device_t device, uint16_t x, uint16_t y, pai //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Quantum Painter Drivers +#ifdef QUANTUM_PAINTER_RGB565_SURFACE_ENABLE +# include "qp_rgb565_surface.h" +#endif // QUANTUM_PAINTER_RGB565_SURFACE_ENABLE + #ifdef QUANTUM_PAINTER_ILI9163_ENABLE # include "qp_ili9163.h" #endif // QUANTUM_PAINTER_ILI9163_ENABLE diff --git a/quantum/painter/qp_draw_image.c b/quantum/painter/qp_draw_image.c index 5822758dce..e9b975f23a 100644 --- a/quantum/painter/qp_draw_image.c +++ b/quantum/painter/qp_draw_image.c @@ -25,10 +25,10 @@ typedef struct qgf_image_handle_t { static qgf_image_handle_t image_descriptors[QUANTUM_PAINTER_NUM_IMAGES] = {0}; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Quantum Painter External API: qp_load_image_mem +// Helper: load image from stream -painter_image_handle_t qp_load_image_mem(const void *buffer) { - qp_dprintf("qp_load_image_mem: entry\n"); +static painter_image_handle_t qp_load_image_internal(bool (*stream_factory)(qgf_image_handle_t *image, void *arg), void *arg) { + qp_dprintf("qp_load_image: entry\n"); qgf_image_handle_t *image = NULL; // Find a free slot @@ -41,20 +41,18 @@ painter_image_handle_t qp_load_image_mem(const void *buffer) { // Drop out if not found if (!image) { - qp_dprintf("qp_load_image_mem: fail (no free slot)\n"); + qp_dprintf("qp_load_image: fail (no free slot)\n"); return NULL; } - // Assume we can read the graphics descriptor - image->mem_stream = qp_make_memory_stream((void *)buffer, sizeof(qgf_graphics_descriptor_v1_t)); - - // Update the length of the stream to match, and rewind to the start - image->mem_stream.length = qgf_get_total_size(&image->stream); - image->mem_stream.position = 0; + if (!stream_factory(image, arg)) { + qp_dprintf("qp_load_image: fail (could not create stream)\n"); + return NULL; + } // Now that we know the length, validate the input data if (!qgf_validate_stream(&image->stream)) { - qp_dprintf("qp_load_image_mem: fail (failed validation)\n"); + qp_dprintf("qp_load_image: fail (failed validation)\n"); return NULL; } @@ -63,10 +61,30 @@ painter_image_handle_t qp_load_image_mem(const void *buffer) { // Validation success, we can return the handle image->validate_ok = true; - qp_dprintf("qp_load_image_mem: ok\n"); + qp_dprintf("qp_load_image: ok\n"); return (painter_image_handle_t)image; } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Quantum Painter External API: qp_load_image_mem + +static inline bool image_mem_stream_factory(qgf_image_handle_t *image, void *arg) { + void *buffer = arg; + + // Assume we can read the graphics descriptor + image->mem_stream = qp_make_memory_stream((void *)buffer, sizeof(qgf_graphics_descriptor_v1_t)); + + // Update the length of the stream to match, and rewind to the start + image->mem_stream.length = qgf_get_total_size(&image->stream); + image->mem_stream.position = 0; + + return true; +} + +painter_image_handle_t qp_load_image_mem(const void *buffer) { + return qp_load_image_internal(image_mem_stream_factory, (void *)buffer); +} + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Quantum Painter External API: qp_close_image @@ -79,6 +97,7 @@ bool qp_close_image(painter_image_handle_t image) { // Free up this image for use elsewhere. qgf_image->validate_ok = false; + qp_stream_close(&qgf_image->stream); return true; } diff --git a/quantum/painter/qp_draw_text.c b/quantum/painter/qp_draw_text.c index f99e082cad..0f5473abd0 100644 --- a/quantum/painter/qp_draw_text.c +++ b/quantum/painter/qp_draw_text.c @@ -36,10 +36,10 @@ typedef struct qff_font_handle_t { static qff_font_handle_t font_descriptors[QUANTUM_PAINTER_NUM_FONTS] = {0}; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Quantum Painter External API: qp_load_font_mem +// Helper: load font from stream -painter_font_handle_t qp_load_font_mem(const void *buffer) { - qp_dprintf("qp_load_font_mem: entry\n"); +static painter_font_handle_t qp_load_font_internal(bool (*stream_factory)(qff_font_handle_t *font, void *arg), void *arg) { + qp_dprintf("qp_load_font: entry\n"); qff_font_handle_t *font = NULL; // Find a free slot @@ -52,20 +52,18 @@ painter_font_handle_t qp_load_font_mem(const void *buffer) { // Drop out if not found if (!font) { - qp_dprintf("qp_load_font_mem: fail (no free slot)\n"); + qp_dprintf("qp_load_font: fail (no free slot)\n"); return NULL; } - // Assume we can read the graphics descriptor - font->mem_stream = qp_make_memory_stream((void *)buffer, sizeof(qff_font_descriptor_v1_t)); - - // Update the length of the stream to match, and rewind to the start - font->mem_stream.length = qff_get_total_size(&font->stream); - font->mem_stream.position = 0; + if (!stream_factory(font, arg)) { + qp_dprintf("qp_load_font: fail (could not create stream)\n"); + return NULL; + } // Now that we know the length, validate the input data if (!qff_validate_stream(&font->stream)) { - qp_dprintf("qp_load_font_mem: fail (failed validation)\n"); + qp_dprintf("qp_load_font: fail (failed validation)\n"); return NULL; } @@ -76,12 +74,12 @@ painter_font_handle_t qp_load_font_mem(const void *buffer) { void *ram_buffer = malloc(font->mem_stream.length); if (ram_buffer == NULL) { - qp_dprintf("qp_load_font_mem: could not allocate enough RAM for font, falling back to original\n"); + qp_dprintf("qp_load_font: could not allocate enough RAM for font, falling back to original\n"); } else { do { // Copy the data into RAM if (qp_stream_read(ram_buffer, 1, font->mem_stream.length, &font->mem_stream) != font->mem_stream.length) { - qp_dprintf("qp_load_font_mem: could not copy from flash to RAM, falling back to original\n"); + qp_dprintf("qp_load_font: could not copy from flash to RAM, falling back to original\n"); break; } @@ -102,17 +100,37 @@ painter_font_handle_t qp_load_font_mem(const void *buffer) { qff_read_font_descriptor(&font->stream, &font->base.line_height, &font->has_ascii_table, &font->num_unicode_glyphs, &font->bpp, &font->has_palette, &font->compression_scheme, NULL); if (!qp_internal_bpp_capable(font->bpp)) { - qp_dprintf("qp_load_font_mem: fail (image bpp too high (%d), check QUANTUM_PAINTER_SUPPORTS_256_PALETTE)\n", (int)font->bpp); + qp_dprintf("qp_load_font: fail (image bpp too high (%d), check QUANTUM_PAINTER_SUPPORTS_256_PALETTE)\n", (int)font->bpp); qp_close_font((painter_font_handle_t)font); return NULL; } // Validation success, we can return the handle font->validate_ok = true; - qp_dprintf("qp_load_font_mem: ok\n"); + qp_dprintf("qp_load_font: ok\n"); return (painter_font_handle_t)font; } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Quantum Painter External API: qp_load_font_mem + +static inline bool font_mem_stream_factory(qff_font_handle_t *font, void *arg) { + void *buffer = arg; + + // Assume we can read the graphics descriptor + font->mem_stream = qp_make_memory_stream(buffer, sizeof(qff_font_descriptor_v1_t)); + + // Update the length of the stream to match, and rewind to the start + font->mem_stream.length = qff_get_total_size(&font->stream); + font->mem_stream.position = 0; + + return true; +} + +painter_font_handle_t qp_load_font_mem(const void *buffer) { + return qp_load_font_internal(font_mem_stream_factory, (void *)buffer); +} + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Quantum Painter External API: qp_close_font @@ -133,6 +151,7 @@ bool qp_close_font(painter_font_handle_t font) { #endif // QUANTUM_PAINTER_LOAD_FONTS_TO_RAM // Free up this font for use elsewhere. + qp_stream_close(&qff_font->stream); qff_font->validate_ok = false; return true; } diff --git a/quantum/painter/qp_stream.c b/quantum/painter/qp_stream.c index f00ae5ed38..1198cf793d 100644 --- a/quantum/painter/qp_stream.c +++ b/quantum/painter/qp_stream.c @@ -38,7 +38,7 @@ uint32_t qp_stream_write_impl(const void *input_buf, uint32_t member_size, uint3 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Memory streams -int16_t mem_get(qp_stream_t *stream) { +static inline int16_t mem_get(qp_stream_t *stream) { qp_memory_stream_t *s = (qp_memory_stream_t *)stream; if (s->position >= s->length) { s->is_eof = true; @@ -47,7 +47,7 @@ int16_t mem_get(qp_stream_t *stream) { return s->buffer[s->position++]; } -bool mem_put(qp_stream_t *stream, uint8_t c) { +static inline bool mem_put(qp_stream_t *stream, uint8_t c) { qp_memory_stream_t *s = (qp_memory_stream_t *)stream; if (s->position >= s->length) { s->is_eof = true; @@ -57,7 +57,7 @@ bool mem_put(qp_stream_t *stream, uint8_t c) { return true; } -int mem_seek(qp_stream_t *stream, int32_t offset, int origin) { +static inline int mem_seek(qp_stream_t *stream, int32_t offset, int origin) { qp_memory_stream_t *s = (qp_memory_stream_t *)stream; // Handle as per fseek @@ -95,26 +95,23 @@ int mem_seek(qp_stream_t *stream, int32_t offset, int origin) { return 0; } -int32_t mem_tell(qp_stream_t *stream) { +static inline int32_t mem_tell(qp_stream_t *stream) { qp_memory_stream_t *s = (qp_memory_stream_t *)stream; return s->position; } -bool mem_is_eof(qp_stream_t *stream) { +static inline bool mem_is_eof(qp_stream_t *stream) { qp_memory_stream_t *s = (qp_memory_stream_t *)stream; return s->is_eof; } +static inline void mem_close(qp_stream_t *stream) { + // No-op. +} + qp_memory_stream_t qp_make_memory_stream(void *buffer, int32_t length) { qp_memory_stream_t stream = { - .base = - { - .get = mem_get, - .put = mem_put, - .seek = mem_seek, - .tell = mem_tell, - .is_eof = mem_is_eof, - }, + .base = {.get = mem_get, .put = mem_put, .seek = mem_seek, .tell = mem_tell, .is_eof = mem_is_eof, .close = mem_close}, .buffer = (uint8_t *)buffer, .length = length, .position = 0, @@ -127,43 +124,41 @@ qp_memory_stream_t qp_make_memory_stream(void *buffer, int32_t length) { #ifdef QP_STREAM_HAS_FILE_IO -int16_t file_get(qp_stream_t *stream) { +static inline int16_t file_get(qp_stream_t *stream) { qp_file_stream_t *s = (qp_file_stream_t *)stream; int c = fgetc(s->file); if (c < 0 || feof(s->file)) return STREAM_EOF; return (uint16_t)c; } -bool file_put(qp_stream_t *stream, uint8_t c) { +static inline bool file_put(qp_stream_t *stream, uint8_t c) { qp_file_stream_t *s = (qp_file_stream_t *)stream; return fputc(c, s->file) == c; } -int file_seek(qp_stream_t *stream, int32_t offset, int origin) { +static inline int file_seek(qp_stream_t *stream, int32_t offset, int origin) { qp_file_stream_t *s = (qp_file_stream_t *)stream; return fseek(s->file, offset, origin); } -int32_t file_tell(qp_stream_t *stream) { +static inline int32_t file_tell(qp_stream_t *stream) { qp_file_stream_t *s = (qp_file_stream_t *)stream; return (int32_t)ftell(s->file); } -bool file_is_eof(qp_stream_t *stream) { +static inline bool file_is_eof(qp_stream_t *stream) { qp_file_stream_t *s = (qp_file_stream_t *)stream; return (bool)feof(s->file); } +static inline void file_close(qp_stream_t *stream) { + qp_file_stream_t *s = (qp_file_stream_t *)stream; + fclose(s->file); +} + qp_file_stream_t qp_make_file_stream(FILE *f) { qp_file_stream_t stream = { - .base = - { - .get = file_get, - .put = file_put, - .seek = file_seek, - .tell = file_tell, - .is_eof = file_is_eof, - }, + .base = {.get = file_get, .put = file_put, .seek = file_seek, .tell = file_tell, .is_eof = file_is_eof, .close = file_close}, .file = f, }; return stream; diff --git a/quantum/painter/qp_stream.h b/quantum/painter/qp_stream.h index 878b9bf530..c0e745adc1 100644 --- a/quantum/painter/qp_stream.h +++ b/quantum/painter/qp_stream.h @@ -41,6 +41,8 @@ typedef struct qp_stream_t qp_stream_t; uint32_t qp_stream_read_impl(void *output_buf, uint32_t member_size, uint32_t num_members, qp_stream_t *stream); uint32_t qp_stream_write_impl(const void *input_buf, uint32_t member_size, uint32_t num_members, qp_stream_t *stream); +#define qp_stream_close(stream_ptr) (((qp_stream_t *)(stream_ptr))->close((qp_stream_t *)(stream_ptr))) + #define STREAM_EOF ((int16_t)(-1)) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -52,6 +54,7 @@ struct qp_stream_t { int (*seek)(qp_stream_t *stream, int32_t offset, int origin); int32_t (*tell)(qp_stream_t *stream); bool (*is_eof)(qp_stream_t *stream); + void (*close)(qp_stream_t *stream); }; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -77,6 +80,6 @@ typedef struct qp_file_stream_t { FILE * file; } qp_file_stream_t; -qp_file_stream_t qo_make_file_stream(FILE *f); +qp_file_stream_t qp_make_file_stream(FILE *f); #endif // QP_STREAM_HAS_FILE_IO diff --git a/quantum/painter/rules.mk b/quantum/painter/rules.mk index 4420bccf63..5ac374a96e 100644 --- a/quantum/painter/rules.mk +++ b/quantum/painter/rules.mk @@ -3,7 +3,15 @@ QUANTUM_PAINTER_DRIVERS ?= QUANTUM_PAINTER_ANIMATIONS_ENABLE ?= yes # The list of permissible drivers that can be listed in QUANTUM_PAINTER_DRIVERS -VALID_QUANTUM_PAINTER_DRIVERS := ili9163_spi ili9341_spi ili9488_spi st7789_spi st7735_spi gc9a01_spi ssd1351_spi +VALID_QUANTUM_PAINTER_DRIVERS := \ + rgb565_surface \ + ili9163_spi \ + ili9341_spi \ + ili9488_spi \ + st7735_spi \ + st7789_spi \ + gc9a01_spi \ + ssd1351_spi #------------------------------------------------------------------------------- @@ -40,6 +48,13 @@ define handle_quantum_painter_driver ifeq ($$(filter $$(strip $$(CURRENT_PAINTER_DRIVER)),$$(VALID_QUANTUM_PAINTER_DRIVERS)),) $$(error "$$(CURRENT_PAINTER_DRIVER)" is not a valid Quantum Painter driver) + else ifeq ($$(strip $$(CURRENT_PAINTER_DRIVER)),rgb565_surface) + OPT_DEFS += -DQUANTUM_PAINTER_RGB565_SURFACE_ENABLE + COMMON_VPATH += \ + $(DRIVER_PATH)/painter/generic + SRC += \ + $(DRIVER_PATH)/painter/generic/qp_rgb565_surface.c \ + else ifeq ($$(strip $$(CURRENT_PAINTER_DRIVER)),ili9163_spi) QUANTUM_PAINTER_NEEDS_COMMS_SPI := yes QUANTUM_PAINTER_NEEDS_COMMS_SPI_DC_RESET := yes @@ -73,27 +88,27 @@ define handle_quantum_painter_driver $(DRIVER_PATH)/painter/tft_panel/qp_tft_panel.c \ $(DRIVER_PATH)/painter/ili9xxx/qp_ili9488.c \ - else ifeq ($$(strip $$(CURRENT_PAINTER_DRIVER)),st7789_spi) + else ifeq ($$(strip $$(CURRENT_PAINTER_DRIVER)),st7735_spi) QUANTUM_PAINTER_NEEDS_COMMS_SPI := yes QUANTUM_PAINTER_NEEDS_COMMS_SPI_DC_RESET := yes - OPT_DEFS += -DQUANTUM_PAINTER_ST7789_ENABLE -DQUANTUM_PAINTER_ST7789_SPI_ENABLE + OPT_DEFS += -DQUANTUM_PAINTER_ST7735_ENABLE -DQUANTUM_PAINTER_ST7735_SPI_ENABLE COMMON_VPATH += \ $(DRIVER_PATH)/painter/tft_panel \ $(DRIVER_PATH)/painter/st77xx SRC += \ $(DRIVER_PATH)/painter/tft_panel/qp_tft_panel.c \ - $(DRIVER_PATH)/painter/st77xx/qp_st7789.c + $(DRIVER_PATH)/painter/st77xx/qp_st7735.c - else ifeq ($$(strip $$(CURRENT_PAINTER_DRIVER)),st7735_spi) + else ifeq ($$(strip $$(CURRENT_PAINTER_DRIVER)),st7789_spi) QUANTUM_PAINTER_NEEDS_COMMS_SPI := yes QUANTUM_PAINTER_NEEDS_COMMS_SPI_DC_RESET := yes - OPT_DEFS += -DQUANTUM_PAINTER_ST7735_ENABLE -DQUANTUM_PAINTER_ST7735_SPI_ENABLE + OPT_DEFS += -DQUANTUM_PAINTER_ST7789_ENABLE -DQUANTUM_PAINTER_ST7789_SPI_ENABLE COMMON_VPATH += \ $(DRIVER_PATH)/painter/tft_panel \ $(DRIVER_PATH)/painter/st77xx SRC += \ $(DRIVER_PATH)/painter/tft_panel/qp_tft_panel.c \ - $(DRIVER_PATH)/painter/st77xx/qp_st7735.c + $(DRIVER_PATH)/painter/st77xx/qp_st7789.c else ifeq ($$(strip $$(CURRENT_PAINTER_DRIVER)),gc9a01_spi) QUANTUM_PAINTER_NEEDS_COMMS_SPI := yes -- cgit v1.2.3 From 2aa3a8e0598336b035ce4a16e41b03c6a79888e5 Mon Sep 17 00:00:00 2001 From: Stefan Kerkmann Date: Mon, 19 Sep 2022 18:05:31 +0200 Subject: [Core] remove busy waiting from rgblight functions (#18418) --- quantum/rgblight/rgblight.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'quantum') diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c index e5d3a98bea..73b352cea8 100644 --- a/quantum/rgblight/rgblight.c +++ b/quantum/rgblight/rgblight.c @@ -16,7 +16,6 @@ #include #include #include -#include "wait.h" #include "progmem.h" #include "sync_timer.h" #include "rgblight.h" @@ -410,7 +409,6 @@ void rgblight_disable(void) { dprintf("rgblight disable [EEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable); rgblight_timer_disable(); RGBLIGHT_SPLIT_SET_CHANGE_MODE; - wait_ms(50); rgblight_set(); } @@ -419,7 +417,6 @@ void rgblight_disable_noeeprom(void) { dprintf("rgblight disable [NOEEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable); rgblight_timer_disable(); RGBLIGHT_SPLIT_SET_CHANGE_MODE; - wait_ms(50); rgblight_set(); } @@ -704,7 +701,6 @@ void rgblight_setrgb_range(uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8 #endif } rgblight_set(); - wait_ms(1); } void rgblight_sethsv_range(uint8_t hue, uint8_t sat, uint8_t val, uint8_t start, uint8_t end) { -- cgit v1.2.3 From 36c410592dbd35da33ccc5fd6d2a5cbf4b25a708 Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 23 Sep 2022 22:46:23 +1000 Subject: Change `DRIVER_LED_COUNT` to `{LED,RGB}_MATRIX_LED_COUNT` (#18399) --- quantum/led_matrix/led_matrix.c | 8 ++++---- quantum/led_matrix/led_matrix.h | 16 ++++++++-------- quantum/led_matrix/led_matrix_drivers.c | 2 +- quantum/led_matrix/led_matrix_types.h | 4 ++-- quantum/rgb_matrix/animations/jellybean_raindrops_anim.h | 2 +- quantum/rgb_matrix/animations/pixel_flow_anim.h | 4 ++-- quantum/rgb_matrix/animations/pixel_rain_anim.h | 2 +- quantum/rgb_matrix/animations/raindrops_anim.h | 2 +- quantum/rgb_matrix/rgb_matrix.c | 8 ++++---- quantum/rgb_matrix/rgb_matrix.h | 16 ++++++++-------- quantum/rgb_matrix/rgb_matrix_drivers.c | 6 +++--- quantum/rgb_matrix/rgb_matrix_types.h | 4 ++-- 12 files changed, 37 insertions(+), 37 deletions(-) (limited to 'quantum') diff --git a/quantum/led_matrix/led_matrix.c b/quantum/led_matrix/led_matrix.c index 14dd0dd48a..5bff154480 100644 --- a/quantum/led_matrix/led_matrix.c +++ b/quantum/led_matrix/led_matrix.c @@ -170,7 +170,7 @@ void led_matrix_set_value(int index, uint8_t value) { void led_matrix_set_value_all(uint8_t value) { #if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) - for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) + for (uint8_t i = 0; i < LED_MATRIX_LED_COUNT; i++) led_matrix_set_value(i, value); #else # ifdef USE_CIE1931_CURVE @@ -399,13 +399,13 @@ void led_matrix_indicators_advanced(effect_params_t *params) { * and not sure which would be better. Otherwise, this should be called from * led_task_render, right before the iter++ line. */ -#if defined(LED_MATRIX_LED_PROCESS_LIMIT) && LED_MATRIX_LED_PROCESS_LIMIT > 0 && LED_MATRIX_LED_PROCESS_LIMIT < DRIVER_LED_TOTAL +#if defined(LED_MATRIX_LED_PROCESS_LIMIT) && LED_MATRIX_LED_PROCESS_LIMIT > 0 && LED_MATRIX_LED_PROCESS_LIMIT < LED_MATRIX_LED_COUNT uint8_t min = LED_MATRIX_LED_PROCESS_LIMIT * (params->iter - 1); uint8_t max = min + LED_MATRIX_LED_PROCESS_LIMIT; - if (max > DRIVER_LED_TOTAL) max = DRIVER_LED_TOTAL; + if (max > LED_MATRIX_LED_COUNT) max = LED_MATRIX_LED_COUNT; #else uint8_t min = 0; - uint8_t max = DRIVER_LED_TOTAL; + uint8_t max = LED_MATRIX_LED_COUNT; #endif led_matrix_indicators_advanced_kb(min, max); led_matrix_indicators_advanced_user(min, max); diff --git a/quantum/led_matrix/led_matrix.h b/quantum/led_matrix/led_matrix.h index 446f293c78..db4f223d5b 100644 --- a/quantum/led_matrix/led_matrix.h +++ b/quantum/led_matrix/led_matrix.h @@ -42,15 +42,15 @@ #endif #ifndef LED_MATRIX_LED_PROCESS_LIMIT -# define LED_MATRIX_LED_PROCESS_LIMIT (DRIVER_LED_TOTAL + 4) / 5 +# define LED_MATRIX_LED_PROCESS_LIMIT (LED_MATRIX_LED_COUNT + 4) / 5 #endif -#if defined(LED_MATRIX_LED_PROCESS_LIMIT) && LED_MATRIX_LED_PROCESS_LIMIT > 0 && LED_MATRIX_LED_PROCESS_LIMIT < DRIVER_LED_TOTAL +#if defined(LED_MATRIX_LED_PROCESS_LIMIT) && LED_MATRIX_LED_PROCESS_LIMIT > 0 && LED_MATRIX_LED_PROCESS_LIMIT < LED_MATRIX_LED_COUNT # if defined(LED_MATRIX_SPLIT) # define LED_MATRIX_USE_LIMITS(min, max) \ uint8_t min = LED_MATRIX_LED_PROCESS_LIMIT * params->iter; \ uint8_t max = min + LED_MATRIX_LED_PROCESS_LIMIT; \ - if (max > DRIVER_LED_TOTAL) max = DRIVER_LED_TOTAL; \ + if (max > LED_MATRIX_LED_COUNT) max = LED_MATRIX_LED_COUNT; \ uint8_t k_led_matrix_split[2] = LED_MATRIX_SPLIT; \ if (is_keyboard_left() && (max > k_led_matrix_split[0])) max = k_led_matrix_split[0]; \ if (!(is_keyboard_left()) && (min < k_led_matrix_split[0])) min = k_led_matrix_split[0]; @@ -58,20 +58,20 @@ # define LED_MATRIX_USE_LIMITS(min, max) \ uint8_t min = LED_MATRIX_LED_PROCESS_LIMIT * params->iter; \ uint8_t max = min + LED_MATRIX_LED_PROCESS_LIMIT; \ - if (max > DRIVER_LED_TOTAL) max = DRIVER_LED_TOTAL; + if (max > LED_MATRIX_LED_COUNT) max = LED_MATRIX_LED_COUNT; # endif #else # if defined(LED_MATRIX_SPLIT) # define LED_MATRIX_USE_LIMITS(min, max) \ uint8_t min = 0; \ - uint8_t max = DRIVER_LED_TOTAL; \ + uint8_t max = LED_MATRIX_LED_COUNT; \ const uint8_t k_led_matrix_split[2] = LED_MATRIX_SPLIT; \ if (is_keyboard_left() && (max > k_led_matrix_split[0])) max = k_led_matrix_split[0]; \ if (!(is_keyboard_left()) && (min < k_led_matrix_split[0])) min = k_led_matrix_split[0]; # else # define LED_MATRIX_USE_LIMITS(min, max) \ uint8_t min = 0; \ - uint8_t max = DRIVER_LED_TOTAL; + uint8_t max = LED_MATRIX_LED_COUNT; # endif #endif @@ -181,9 +181,9 @@ static inline bool led_matrix_check_finished_leds(uint8_t led_idx) { uint8_t k_led_matrix_split[2] = LED_MATRIX_SPLIT; return led_idx < k_led_matrix_split[0]; } else - return led_idx < DRIVER_LED_TOTAL; + return led_idx < LED_MATRIX_LED_COUNT; #else - return led_idx < DRIVER_LED_TOTAL; + return led_idx < LED_MATRIX_LED_COUNT; #endif } diff --git a/quantum/led_matrix/led_matrix_drivers.c b/quantum/led_matrix/led_matrix_drivers.c index f01b395c15..2c09ba82b1 100644 --- a/quantum/led_matrix/led_matrix_drivers.c +++ b/quantum/led_matrix/led_matrix_drivers.c @@ -96,7 +96,7 @@ static void init(void) { # endif # endif - for (int index = 0; index < DRIVER_LED_TOTAL; index++) { + for (int index = 0; index < LED_MATRIX_LED_COUNT; index++) { # if defined(IS31FL3731) IS31FL3731_set_led_control_register(index, true); # elif defined(IS31FL3733) diff --git a/quantum/led_matrix/led_matrix_types.h b/quantum/led_matrix/led_matrix_types.h index 3dc533100f..6d79a3592d 100644 --- a/quantum/led_matrix/led_matrix_types.h +++ b/quantum/led_matrix/led_matrix_types.h @@ -76,8 +76,8 @@ typedef struct PACKED { typedef struct PACKED { uint8_t matrix_co[MATRIX_ROWS][MATRIX_COLS]; - led_point_t point[DRIVER_LED_TOTAL]; - uint8_t flags[DRIVER_LED_TOTAL]; + led_point_t point[LED_MATRIX_LED_COUNT]; + uint8_t flags[LED_MATRIX_LED_COUNT]; } led_config_t; typedef union { diff --git a/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h b/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h index 31dffcbc5a..69bf265d14 100644 --- a/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h +++ b/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h @@ -13,7 +13,7 @@ bool JELLYBEAN_RAINDROPS(effect_params_t* params) { if (!params->init) { // Change one LED every tick, make sure speed is not 0 if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 16)) % 5 == 0) { - jellybean_raindrops_set_color(rand() % DRIVER_LED_TOTAL, params); + jellybean_raindrops_set_color(rand() % RGB_MATRIX_LED_COUNT, params); } return false; } diff --git a/quantum/rgb_matrix/animations/pixel_flow_anim.h b/quantum/rgb_matrix/animations/pixel_flow_anim.h index 714f5d174e..8628c3c2ec 100644 --- a/quantum/rgb_matrix/animations/pixel_flow_anim.h +++ b/quantum/rgb_matrix/animations/pixel_flow_anim.h @@ -7,7 +7,7 @@ RGB_MATRIX_EFFECT(PIXEL_FLOW) static bool PIXEL_FLOW(effect_params_t* params) { // LED state array - static RGB led[DRIVER_LED_TOTAL]; + static RGB led[RGB_MATRIX_LED_COUNT]; static uint32_t wait_timer = 0; if (wait_timer > g_rgb_timer) { @@ -21,7 +21,7 @@ static bool PIXEL_FLOW(effect_params_t* params) { if (params->init) { // Clear LEDs and fill the state array rgb_matrix_set_color_all(0, 0, 0); - for (uint8_t j = 0; j < DRIVER_LED_TOTAL; ++j) { + for (uint8_t j = 0; j < RGB_MATRIX_LED_COUNT; ++j) { led[j] = (random8() & 2) ? (RGB){0, 0, 0} : hsv_to_rgb((HSV){random8(), qadd8(random8() >> 1, 127), rgb_matrix_config.hsv.v}); } } diff --git a/quantum/rgb_matrix/animations/pixel_rain_anim.h b/quantum/rgb_matrix/animations/pixel_rain_anim.h index ce2528a26d..fded60340f 100644 --- a/quantum/rgb_matrix/animations/pixel_rain_anim.h +++ b/quantum/rgb_matrix/animations/pixel_rain_anim.h @@ -41,7 +41,7 @@ static bool PIXEL_RAIN(effect_params_t* params) { RGB_MATRIX_USE_LIMITS(led_min, led_max); if (g_rgb_timer > wait_timer) { - rain_pixel(mod8(random8(), DRIVER_LED_TOTAL), params, random8() & 2); + rain_pixel(mod8(random8(), RGB_MATRIX_LED_COUNT), params, random8() & 2); } return rgb_matrix_check_finished_leds(led_max); } diff --git a/quantum/rgb_matrix/animations/raindrops_anim.h b/quantum/rgb_matrix/animations/raindrops_anim.h index a508e51183..6b92d649ad 100644 --- a/quantum/rgb_matrix/animations/raindrops_anim.h +++ b/quantum/rgb_matrix/animations/raindrops_anim.h @@ -24,7 +24,7 @@ bool RAINDROPS(effect_params_t* params) { if (!params->init) { // Change one LED every tick, make sure speed is not 0 if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 16)) % 10 == 0) { - raindrops_set_color(random8() % DRIVER_LED_TOTAL, params); + raindrops_set_color(random8() % RGB_MATRIX_LED_COUNT, params); } } else { for (int i = led_min; i < led_max; i++) { diff --git a/quantum/rgb_matrix/rgb_matrix.c b/quantum/rgb_matrix/rgb_matrix.c index 2730686839..ae61e75535 100644 --- a/quantum/rgb_matrix/rgb_matrix.c +++ b/quantum/rgb_matrix/rgb_matrix.c @@ -202,7 +202,7 @@ void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) - for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) + for (uint8_t i = 0; i < RGB_MATRIX_LED_COUNT; i++) rgb_matrix_set_color(i, red, green, blue); #else rgb_matrix_driver.set_color_all(red, green, blue); @@ -461,13 +461,13 @@ void rgb_matrix_indicators_advanced(effect_params_t *params) { * and not sure which would be better. Otherwise, this should be called from * rgb_task_render, right before the iter++ line. */ -#if defined(RGB_MATRIX_LED_PROCESS_LIMIT) && RGB_MATRIX_LED_PROCESS_LIMIT > 0 && RGB_MATRIX_LED_PROCESS_LIMIT < DRIVER_LED_TOTAL +#if defined(RGB_MATRIX_LED_PROCESS_LIMIT) && RGB_MATRIX_LED_PROCESS_LIMIT > 0 && RGB_MATRIX_LED_PROCESS_LIMIT < RGB_MATRIX_LED_COUNT uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * (params->iter - 1); uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT; - if (max > DRIVER_LED_TOTAL) max = DRIVER_LED_TOTAL; + if (max > RGB_MATRIX_LED_COUNT) max = RGB_MATRIX_LED_COUNT; #else uint8_t min = 0; - uint8_t max = DRIVER_LED_TOTAL; + uint8_t max = RGB_MATRIX_LED_COUNT; #endif rgb_matrix_indicators_advanced_kb(min, max); rgb_matrix_indicators_advanced_user(min, max); diff --git a/quantum/rgb_matrix/rgb_matrix.h b/quantum/rgb_matrix/rgb_matrix.h index fc9fc3e020..0b35e98f45 100644 --- a/quantum/rgb_matrix/rgb_matrix.h +++ b/quantum/rgb_matrix/rgb_matrix.h @@ -47,15 +47,15 @@ #endif #ifndef RGB_MATRIX_LED_PROCESS_LIMIT -# define RGB_MATRIX_LED_PROCESS_LIMIT (DRIVER_LED_TOTAL + 4) / 5 +# define RGB_MATRIX_LED_PROCESS_LIMIT (RGB_MATRIX_LED_COUNT + 4) / 5 #endif -#if defined(RGB_MATRIX_LED_PROCESS_LIMIT) && RGB_MATRIX_LED_PROCESS_LIMIT > 0 && RGB_MATRIX_LED_PROCESS_LIMIT < DRIVER_LED_TOTAL +#if defined(RGB_MATRIX_LED_PROCESS_LIMIT) && RGB_MATRIX_LED_PROCESS_LIMIT > 0 && RGB_MATRIX_LED_PROCESS_LIMIT < RGB_MATRIX_LED_COUNT # if defined(RGB_MATRIX_SPLIT) # define RGB_MATRIX_USE_LIMITS(min, max) \ uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * params->iter; \ uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT; \ - if (max > DRIVER_LED_TOTAL) max = DRIVER_LED_TOTAL; \ + if (max > RGB_MATRIX_LED_COUNT) max = RGB_MATRIX_LED_COUNT; \ uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; \ if (is_keyboard_left() && (max > k_rgb_matrix_split[0])) max = k_rgb_matrix_split[0]; \ if (!(is_keyboard_left()) && (min < k_rgb_matrix_split[0])) min = k_rgb_matrix_split[0]; @@ -63,20 +63,20 @@ # define RGB_MATRIX_USE_LIMITS(min, max) \ uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * params->iter; \ uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT; \ - if (max > DRIVER_LED_TOTAL) max = DRIVER_LED_TOTAL; + if (max > RGB_MATRIX_LED_COUNT) max = RGB_MATRIX_LED_COUNT; # endif #else # if defined(RGB_MATRIX_SPLIT) # define RGB_MATRIX_USE_LIMITS(min, max) \ uint8_t min = 0; \ - uint8_t max = DRIVER_LED_TOTAL; \ + uint8_t max = RGB_MATRIX_LED_COUNT; \ const uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; \ if (is_keyboard_left() && (max > k_rgb_matrix_split[0])) max = k_rgb_matrix_split[0]; \ if (!(is_keyboard_left()) && (min < k_rgb_matrix_split[0])) min = k_rgb_matrix_split[0]; # else # define RGB_MATRIX_USE_LIMITS(min, max) \ uint8_t min = 0; \ - uint8_t max = DRIVER_LED_TOTAL; + uint8_t max = RGB_MATRIX_LED_COUNT; # endif #endif @@ -246,9 +246,9 @@ static inline bool rgb_matrix_check_finished_leds(uint8_t led_idx) { uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; return led_idx < k_rgb_matrix_split[0]; } else - return led_idx < DRIVER_LED_TOTAL; + return led_idx < RGB_MATRIX_LED_COUNT; #else - return led_idx < DRIVER_LED_TOTAL; + return led_idx < RGB_MATRIX_LED_COUNT; #endif } diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c index 99151e5a92..e75b2c6c9d 100644 --- a/quantum/rgb_matrix/rgb_matrix_drivers.c +++ b/quantum/rgb_matrix/rgb_matrix_drivers.c @@ -106,7 +106,7 @@ static void init(void) { # endif # endif - for (int index = 0; index < DRIVER_LED_TOTAL; index++) { + for (int index = 0; index < RGB_MATRIX_LED_COUNT; index++) { bool enabled = true; // This only caches it for later @@ -336,13 +336,13 @@ const rgb_matrix_driver_t rgb_matrix_driver = { # endif // LED color buffer -LED_TYPE rgb_matrix_ws2812_array[DRIVER_LED_TOTAL]; +LED_TYPE rgb_matrix_ws2812_array[RGB_MATRIX_LED_COUNT]; static void init(void) {} static void flush(void) { // Assumes use of RGB_DI_PIN - ws2812_setleds(rgb_matrix_ws2812_array, DRIVER_LED_TOTAL); + ws2812_setleds(rgb_matrix_ws2812_array, RGB_MATRIX_LED_COUNT); } // Set an led in the buffer to a color diff --git a/quantum/rgb_matrix/rgb_matrix_types.h b/quantum/rgb_matrix/rgb_matrix_types.h index d0ac4e4466..eea603c41c 100644 --- a/quantum/rgb_matrix/rgb_matrix_types.h +++ b/quantum/rgb_matrix/rgb_matrix_types.h @@ -78,8 +78,8 @@ typedef struct PACKED { typedef struct PACKED { uint8_t matrix_co[MATRIX_ROWS][MATRIX_COLS]; - led_point_t point[DRIVER_LED_TOTAL]; - uint8_t flags[DRIVER_LED_TOTAL]; + led_point_t point[RGB_MATRIX_LED_COUNT]; + uint8_t flags[RGB_MATRIX_LED_COUNT]; } led_config_t; typedef union { -- cgit v1.2.3 From 7c1797f52f74c9614615c0632ea1a2f5f11d3af6 Mon Sep 17 00:00:00 2001 From: Alabastard-64 <96358682+Alabastard-64@users.noreply.github.com> Date: Sat, 24 Sep 2022 00:43:55 -0600 Subject: [Core] Pointing Device Automatic Mouse Layer (#17962) Co-authored-by: Drashna Jaelre Co-authored-by: Stefan Kerkmann --- quantum/pointing_device/pointing_device.c | 4 + quantum/pointing_device/pointing_device.h | 4 + .../pointing_device/pointing_device_auto_mouse.c | 384 +++++++++++++++++++++ .../pointing_device/pointing_device_auto_mouse.h | 87 +++++ quantum/pointing_device/pointing_device_drivers.c | 13 + quantum/quantum.c | 3 + 6 files changed, 495 insertions(+) create mode 100644 quantum/pointing_device/pointing_device_auto_mouse.c create mode 100644 quantum/pointing_device/pointing_device_auto_mouse.h (limited to 'quantum') diff --git a/quantum/pointing_device/pointing_device.c b/quantum/pointing_device/pointing_device.c index ae3f122e89..e91de018f1 100644 --- a/quantum/pointing_device/pointing_device.c +++ b/quantum/pointing_device/pointing_device.c @@ -267,6 +267,10 @@ __attribute__((weak)) void pointing_device_task(void) { #else local_mouse_report = pointing_device_adjust_by_defines(local_mouse_report); local_mouse_report = pointing_device_task_kb(local_mouse_report); +#endif + // automatic mouse layer function +#ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE + pointing_device_task_auto_mouse(local_mouse_report); #endif // combine with mouse report to ensure that the combined is sent correctly #ifdef MOUSEKEY_ENABLE diff --git a/quantum/pointing_device/pointing_device.h b/quantum/pointing_device/pointing_device.h index 77db5471ea..a002bd4b25 100644 --- a/quantum/pointing_device/pointing_device.h +++ b/quantum/pointing_device/pointing_device.h @@ -21,6 +21,10 @@ along with this program. If not, see . #include "host.h" #include "report.h" +#ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE +# include "pointing_device_auto_mouse.h" +#endif + #if defined(POINTING_DEVICE_DRIVER_adns5050) # include "drivers/sensors/adns5050.h" #elif defined(POINTING_DEVICE_DRIVER_adns9800) diff --git a/quantum/pointing_device/pointing_device_auto_mouse.c b/quantum/pointing_device/pointing_device_auto_mouse.c new file mode 100644 index 0000000000..edffd44787 --- /dev/null +++ b/quantum/pointing_device/pointing_device_auto_mouse.c @@ -0,0 +1,384 @@ +/* Copyright 2021 Christopher Courtney, aka Drashna Jael're (@drashna) + * Copyright 2022 Alabastard + * + * 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 . + */ + +#ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE + +# include "pointing_device_auto_mouse.h" + +/* local data structure for tracking auto mouse */ +static auto_mouse_context_t auto_mouse_context = {.config.layer = (uint8_t)AUTO_MOUSE_DEFAULT_LAYER}; + +/* local functions */ +static bool is_mouse_record(uint16_t keycode, keyrecord_t* record); +static void auto_mouse_reset(void); + +/* check for target layer deactivation overrides */ +static inline bool layer_hold_check(void) { + return get_auto_mouse_toggle() || +# ifndef NO_ACTION_ONESHOT + get_oneshot_layer() == (AUTO_MOUSE_TARGET_LAYER) || +# endif + false; +} + +/* check all layer activation criteria */ +static inline bool is_auto_mouse_active(void) { + return auto_mouse_context.status.is_activated || auto_mouse_context.status.mouse_key_tracker || layer_hold_check(); +} + +/** + * @brief Get auto mouse enable state + * + * Return is_enabled value + * + * @return bool true: auto mouse enabled false: auto mouse disabled + */ +bool get_auto_mouse_enable(void) { + return auto_mouse_context.config.is_enabled; +} + +/** + * @brief get current target layer index + * + * NOTE: (AUTO_MOUSE_TARGET_LAYER) is an alias for this function + * + * @return uint8_t target layer index + */ +uint8_t get_auto_mouse_layer(void) { + return auto_mouse_context.config.layer; +} + +/** + * @brief get layer_toggled value + * + * @return bool of current layer_toggled state + */ +bool get_auto_mouse_toggle(void) { + return auto_mouse_context.status.is_toggled; +} + +/** + * @brief Reset auto mouse context + * + * Clear timers and status + * + * NOTE: this will set is_toggled to false so careful when using it + */ +static void auto_mouse_reset(void) { + memset(&auto_mouse_context.status, 0, sizeof(auto_mouse_context.status)); + memset(&auto_mouse_context.timer, 0, sizeof(auto_mouse_context.timer)); +} + +/** + * @brief Set auto mouse enable state + * + * Set local auto mouse enabled state + * + * @param[in] state bool + */ +void set_auto_mouse_enable(bool enable) { + // skip if unchanged + if (auto_mouse_context.config.is_enabled == enable) return; + auto_mouse_context.config.is_enabled = enable; + auto_mouse_reset(); +} + +/** + * @brief Change target layer for auto mouse + * + * Sets input as the new target layer if different from current and resets auto mouse + * + * NOTE: remove_auto_mouse_layer(state, false) or auto_mouse_layer_off should be called + * before this function to avoid issues with layers getting stuck + * + * @param[in] layer uint8_t + */ +void set_auto_mouse_layer(uint8_t layer) { + // skip if unchanged + if (auto_mouse_context.config.layer == layer) return; + auto_mouse_context.config.layer = layer; + auto_mouse_reset(); +} + +/** + * @brief toggle mouse layer setting + * + * Change state of local layer_toggled bool meant to track when the mouse layer is toggled on by other means + * + * NOTE: While is_toggled is true it will prevent deactiving target layer (but not activation) + */ +void auto_mouse_toggle(void) { + auto_mouse_context.status.is_toggled ^= 1; + auto_mouse_context.timer.delay = 0; +} + +/** + * @brief Remove current auto mouse target layer from layer state + * + * Will remove auto mouse target layer from given layer state if appropriate. + * + * NOTE: Removal can be forced, ignoring appropriate critera + * + * @params state[in] layer_state_t original layer state + * @params force[in] bool force removal + * + * @return layer_state_t modified layer state + */ +layer_state_t remove_auto_mouse_layer(layer_state_t state, bool force) { + if (force || ((AUTO_MOUSE_ENABLED) && !layer_hold_check())) { + state &= ~((layer_state_t)1 << (AUTO_MOUSE_TARGET_LAYER)); + } + return state; +} + +/** + * @brief Disable target layer + * + * Will disable target layer if appropriate. + * NOTE: NOT TO BE USED in layer_state_set stack!!! + */ +void auto_mouse_layer_off(void) { + if (layer_state_is((AUTO_MOUSE_TARGET_LAYER)) && (AUTO_MOUSE_ENABLED) && !layer_hold_check()) { + layer_off((AUTO_MOUSE_TARGET_LAYER)); + } +} + +/** + * @brief Weak function to handel testing if pointing_device is active + * + * Will trigger target layer activation(if delay timer has expired) and prevent deactivation when true. + * May be replaced by bool in report_mouse_t in future + * + * NOTE: defined weakly to allow for changing and adding conditions for specific hardware/customization + * + * @param[in] mouse_report report_mouse_t + * @return bool of pointing_device activation + */ +__attribute__((weak)) bool auto_mouse_activation(report_mouse_t mouse_report) { + return mouse_report.x != 0 || mouse_report.y != 0 || mouse_report.h != 0 || mouse_report.v != 0 || mouse_report.buttons; +} + +/** + * @brief Update the auto mouse based on mouse_report + * + * Handel activation/deactivation of target layer based on auto_mouse_activation and state timers and local key/layer tracking data + * + * @param[in] mouse_report report_mouse_t + */ +void pointing_device_task_auto_mouse(report_mouse_t mouse_report) { + // skip if disabled, delay timer running, or debounce + if (!(AUTO_MOUSE_ENABLED) || timer_elapsed(auto_mouse_context.timer.active) <= AUTO_MOUSE_DEBOUNCE || timer_elapsed(auto_mouse_context.timer.delay) <= AUTO_MOUSE_DELAY) { + return; + } + // update activation and reset debounce + auto_mouse_context.status.is_activated = auto_mouse_activation(mouse_report); + if (is_auto_mouse_active()) { + auto_mouse_context.timer.active = timer_read(); + auto_mouse_context.timer.delay = 0; + if (!layer_state_is((AUTO_MOUSE_TARGET_LAYER))) { + layer_on((AUTO_MOUSE_TARGET_LAYER)); + } + } else if (layer_state_is((AUTO_MOUSE_TARGET_LAYER)) && timer_elapsed(auto_mouse_context.timer.active) > AUTO_MOUSE_TIME) { + layer_off((AUTO_MOUSE_TARGET_LAYER)); + auto_mouse_context.timer.active = 0; + } +} + +/** + * @brief Handle mouskey event + * + * Increments/decrements mouse_key_tracker and restart active timer + * + * @param[in] pressed bool + */ +void auto_mouse_keyevent(bool pressed) { + if (pressed) { + auto_mouse_context.status.mouse_key_tracker++; + } else { + auto_mouse_context.status.mouse_key_tracker--; + } + auto_mouse_context.timer.delay = 0; +} + +/** + * @brief Handle auto mouse non mousekey reset + * + * Start/restart delay timer and reset auto mouse on keydown as well as turn the + * target layer off if on and reset toggle status + * + * NOTE: NOT TO BE USED in layer_state_set stack!!! + * + * @param[in] pressed bool + */ +void auto_mouse_reset_trigger(bool pressed) { + if (pressed) { + if (layer_state_is((AUTO_MOUSE_TARGET_LAYER))) { + layer_off((AUTO_MOUSE_TARGET_LAYER)); + }; + auto_mouse_reset(); + } + auto_mouse_context.timer.delay = timer_read(); +} + +/** + * @brief handle key events processing for auto mouse + * + * Will process keys differently depending on if key is defined as mousekey or not. + * Some keys have built in behaviour(not overwritable): + * mouse buttons : auto_mouse_keyevent() + * non-mouse keys : auto_mouse_reset_trigger() + * mod keys : skip auto mouse key processing + * mod tap : skip on hold (mod keys) + * QK mods e.g. LCTL(kc): default to non-mouse key, add at kb/user level as needed + * non target layer keys: skip auto mouse key processing (same as mod keys) + * MO(target layer) : auto_mouse_keyevent() + * target layer toggles : auto_mouse_toggle() (on both key up and keydown) + * target layer tap : default processing on tap mouse key on hold + * all other keycodes : default to non-mouse key, add at kb/user level as needed + * + * Will deactivate target layer once a non mouse key is pressed if nothing is holding the layer active + * such as held mousekey, toggled current target layer, or auto_mouse_activation is true + * + * @params keycode[in] uint16_t + * @params record[in] keyrecord_t pointer + */ +bool process_auto_mouse(uint16_t keycode, keyrecord_t* record) { + // skip if not enabled or mouse_layer not set + if (!(AUTO_MOUSE_ENABLED)) return true; + + switch (keycode) { + // Skip Mod keys to avoid layer reset + case KC_LEFT_CTRL ... KC_RIGHT_GUI: + case QK_MODS ... QK_MODS_MAX: + break; + // TO((AUTO_MOUSE_TARGET_LAYER))------------------------------------------------------------------------------- + case QK_TO ... QK_TO_MAX: // same proccessing as next + // TG((AUTO_MOUSE_TARGET_LAYER))------------------------------------------------------------------------------- + case QK_TOGGLE_LAYER ... QK_TOGGLE_LAYER_MAX: + if ((keycode & 0xff) == (AUTO_MOUSE_TARGET_LAYER)) { + if (!(record->event.pressed)) auto_mouse_toggle(); + } + break; + // MO((AUTO_MOUSE_TARGET_LAYER))------------------------------------------------------------------------------- + case QK_MOMENTARY ... QK_MOMENTARY_MAX: + if ((keycode & 0xff) == (AUTO_MOUSE_TARGET_LAYER)) { + auto_mouse_keyevent(record->event.pressed); + } + // DF --------------------------------------------------------------------------------------------------------- + case QK_DEF_LAYER ... QK_DEF_LAYER_MAX: +# ifndef NO_ACTION_ONESHOT + // OSL((AUTO_MOUSE_TARGET_LAYER))------------------------------------------------------------------------------ + case QK_ONE_SHOT_LAYER ... QK_ONE_SHOT_LAYER_MAX: + case QK_ONE_SHOT_MOD ... QK_ONE_SHOT_MOD_MAX: +# endif + break; + // LM((AUTO_MOUSE_TARGET_LAYER), mod)-------------------------------------------------------------------------- + case QK_LAYER_MOD ... QK_LAYER_MOD_MAX: + if (((keycode >> 8) & 0x0f) == (AUTO_MOUSE_TARGET_LAYER)) { + auto_mouse_keyevent(record->event.pressed); + } + break; + // TT((AUTO_MOUSE_TARGET_LAYER))--------------------------------------------------------------------------- +# ifndef NO_ACTION_TAPPING + case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX: + if ((keycode & 0xff) == (AUTO_MOUSE_TARGET_LAYER)) { + auto_mouse_keyevent(record->event.pressed); +# if TAPPING_TOGGLE != 0 + if (record->tap.count == TAPPING_TOGGLE) { + if (record->event.pressed) { + auto_mouse_context.status.mouse_key_tracker--; + } else { + auto_mouse_toggle(); + auto_mouse_context.status.mouse_key_tracker++; + } + } +# endif + } + break; + // LT((AUTO_MOUSE_TARGET_LAYER), kc)--------------------------------------------------------------------------- + case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: + if (!record->tap.count) { + if (((keycode >> 8) & 0x0f) == (AUTO_MOUSE_TARGET_LAYER)) { + auto_mouse_keyevent(record->event.pressed); + } + break; + } + // MT(kc) only skip on hold + case QK_MOD_TAP ... QK_MOD_TAP_MAX: + if (!record->tap.count) break; +# endif + // QK_MODS goes to default + default: + // skip on no event + if (IS_NOEVENT(record->event)) break; + // check if keyrecord is mousekey + if (is_mouse_record(keycode, record)) { + auto_mouse_keyevent(record->event.pressed); + } else if (!is_auto_mouse_active()) { + // all non-mousekey presses restart delay timer and reset status + auto_mouse_reset_trigger(record->event.pressed); + } + } + if (auto_mouse_context.status.mouse_key_tracker < 0) { + auto_mouse_context.status.mouse_key_tracker = 0; + dprintf("key tracker error (<0) \n"); + } + return true; +} + +/** + * @brief Local function to handle checking if a keycode is a mouse button + * + * Starts code stack for checking keyrecord if defined as mousekey + * + * @params keycode[in] uint16_t + * @params record[in] keyrecord_t pointer + * @return bool true: keyrecord is mousekey false: keyrecord is not mousekey + */ +static bool is_mouse_record(uint16_t keycode, keyrecord_t* record) { + // allow for keyboard to hook in and override if need be + if (is_mouse_record_kb(keycode, record) || IS_MOUSEKEY(keycode)) return true; + return false; +} + +/** + * @brief Weakly defined keyboard level callback for adding keyrecords as mouse keys + * + * Meant for redefinition at keyboard level and should return is_mouse_record_user by default at end of function + * + * @params keycode[in] uint16_t + * @params record[in] keyrecord_t pointer + * @return bool true: keyrecord is defined as mouse key false: keyrecord is not defined as mouse key + */ +__attribute__((weak)) bool is_mouse_record_kb(uint16_t keycode, keyrecord_t* record) { + return is_mouse_record_user(keycode, record); +} + +/** + * @brief Weakly defined keymap/user level callback for adding keyrecords as mouse keys + * + * Meant for redefinition at keymap/user level and should return false by default at end of function + * + * @params keycode[in] uint16_t + * @params record[in] keyrecord_t pointer + * @return bool true: keyrecord is defined as mouse key false: keyrecord is not defined as mouse key + */ +__attribute__((weak)) bool is_mouse_record_user(uint16_t keycode, keyrecord_t* record) { + return false; +} + +#endif // POINTING_DEVICE_AUTO_MOUSE_ENABLE diff --git a/quantum/pointing_device/pointing_device_auto_mouse.h b/quantum/pointing_device/pointing_device_auto_mouse.h new file mode 100644 index 0000000000..eaa6aa2c09 --- /dev/null +++ b/quantum/pointing_device/pointing_device_auto_mouse.h @@ -0,0 +1,87 @@ +/* Copyright 2022 Alabastard + * + * 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 . + */ + +#pragma once + +#include + +#include "quantum.h" +#include "pointing_device.h" +#include "print.h" + +/* check settings and set defaults */ +#ifndef POINTING_DEVICE_AUTO_MOUSE_ENABLE +# error "POINTING_DEVICE_AUTO_MOUSE_ENABLE not defined! check config settings" +#endif + +#ifndef AUTO_MOUSE_DEFAULT_LAYER +# define AUTO_MOUSE_DEFAULT_LAYER 1 +#endif +#ifndef AUTO_MOUSE_TIME +# define AUTO_MOUSE_TIME 650 +#endif +#ifndef AUTO_MOUSE_DELAY + #define AUTO_MOUSE_DELAY GET_TAPPING_TERM(KC_MS_BTN1, &(keyrecord_t){}) +#endif +#ifndef AUTO_MOUSE_DEBOUNCE +# define AUTO_MOUSE_DEBOUNCE 25 +#endif + +/* data structure */ +typedef struct { + struct { + bool is_enabled; + uint8_t layer; + } config; + struct { + uint16_t active; + uint16_t delay; + } timer; + struct { + bool is_activated; + bool is_toggled; + int8_t mouse_key_tracker; + } status; +} auto_mouse_context_t; + +/* ----------Set up and control------------------------------------------------------------------------------ */ +void set_auto_mouse_enable(bool enable); // enable/disable auto mouse feature +bool get_auto_mouse_enable(void); // get auto_mouse_enable +void set_auto_mouse_layer(uint8_t layer); // set target layer by index +uint8_t get_auto_mouse_layer(void); // get target layer index +void auto_mouse_layer_off(void); // disable target layer if appropriate (DO NOT USE in layer_state_set stack!!) +layer_state_t remove_auto_mouse_layer(layer_state_t state, bool force); // remove auto mouse target layer from state if appropriate (can be forced) + +/* ----------For custom pointing device activation----------------------------------------------------------- */ +bool auto_mouse_activation(report_mouse_t mouse_report); // handles pointing device trigger conditions for target layer activation (overwritable) + +/* ----------Handling keyevents------------------------------------------------------------------------------ */ +void auto_mouse_keyevent(bool pressed); // trigger auto mouse keyevent: mouse_keytracker increment/decrement on press/release +void auto_mouse_reset_trigger(bool pressed); // trigger non mouse keyevent: reset and start delay timer (DO NOT USE in layer_state_set stack!!) +void auto_mouse_toggle(void); // toggle mouse layer flag disables mouse layer deactivation while on (meant for tap toggle or toggle of target) +bool get_auto_mouse_toggle(void); // get toggle mouse layer flag value + +/* ----------Callbacks for adding keycodes to mouse record checking------------------------------------------ */ +bool is_mouse_record_kb(uint16_t keycode, keyrecord_t* record); +bool is_mouse_record_user(uint16_t keycode, keyrecord_t* record); + +/* ----------Core functions (only used in custom pointing devices or key processing)------------------------- */ +void pointing_device_task_auto_mouse(report_mouse_t mouse_report); // add to pointing_device_task_* +bool process_auto_mouse(uint16_t keycode, keyrecord_t* record); // add to process_record_* + +/* ----------Macros/Aliases---------------------------------------------------------------------------------- */ +#define AUTO_MOUSE_TARGET_LAYER get_auto_mouse_layer() +#define AUTO_MOUSE_ENABLED get_auto_mouse_enable() diff --git a/quantum/pointing_device/pointing_device_drivers.c b/quantum/pointing_device/pointing_device_drivers.c index d7e0b90917..172c9f36d7 100644 --- a/quantum/pointing_device/pointing_device_drivers.c +++ b/quantum/pointing_device/pointing_device_drivers.c @@ -113,6 +113,15 @@ void cirque_pinnacle_configure_cursor_glide(float trigger_px) { # endif # if CIRQUE_PINNACLE_POSITION_MODE + +# ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE +static bool is_touch_down; + +bool auto_mouse_activation(report_mouse_t mouse_report) { + return is_touch_down || mouse_report.x != 0 || mouse_report.y != 0 || mouse_report.h != 0 || mouse_report.v != 0 || mouse_report.buttons; +} +# endif + report_mouse_t cirque_pinnacle_get_report(report_mouse_t mouse_report) { pinnacle_data_t touchData = cirque_pinnacle_read_data(); mouse_xy_report_t report_x = 0, report_y = 0; @@ -143,6 +152,10 @@ report_mouse_t cirque_pinnacle_get_report(report_mouse_t mouse_report) { pd_dprintf("cirque_pinnacle touchData x=%4d y=%4d z=%2d\n", touchData.xValue, touchData.yValue, touchData.zValue); } +# ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE + is_touch_down = touchData.touchDown; +# endif + // Scale coordinates to arbitrary X, Y resolution cirque_pinnacle_scale_data(&touchData, cirque_pinnacle_get_scale(), cirque_pinnacle_get_scale()); diff --git a/quantum/quantum.c b/quantum/quantum.c index 9f1d3502fb..ff36e14775 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -271,6 +271,9 @@ bool process_record_quantum(keyrecord_t *record) { #endif #if defined(VIA_ENABLE) process_record_via(keycode, record) && +#endif +#if defined(POINTING_DEVICE_ENABLE) && defined(POINTING_DEVICE_AUTO_MOUSE_ENABLE) + process_auto_mouse(keycode, record) && #endif process_record_kb(keycode, record) && #if defined(SECURE_ENABLE) -- cgit v1.2.3 From df30327c19d15552f88af5ff65c0fa6c7245d77a Mon Sep 17 00:00:00 2001 From: QMK Bot Date: Sat, 24 Sep 2022 00:34:44 -0700 Subject: Format code according to conventions (#18466) --- quantum/pointing_device/pointing_device_auto_mouse.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'quantum') diff --git a/quantum/pointing_device/pointing_device_auto_mouse.h b/quantum/pointing_device/pointing_device_auto_mouse.h index eaa6aa2c09..0f26af79e6 100644 --- a/quantum/pointing_device/pointing_device_auto_mouse.h +++ b/quantum/pointing_device/pointing_device_auto_mouse.h @@ -34,7 +34,7 @@ # define AUTO_MOUSE_TIME 650 #endif #ifndef AUTO_MOUSE_DELAY - #define AUTO_MOUSE_DELAY GET_TAPPING_TERM(KC_MS_BTN1, &(keyrecord_t){}) +# define AUTO_MOUSE_DELAY GET_TAPPING_TERM(KC_MS_BTN1, &(keyrecord_t){}) #endif #ifndef AUTO_MOUSE_DEBOUNCE # define AUTO_MOUSE_DEBOUNCE 25 -- cgit v1.2.3 From 94d5fe6f908077e22a2445b3accda8d130135156 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sat, 24 Sep 2022 17:44:14 +0200 Subject: Allow Active High for Pointing Device Motion Pin (#18404) Needed by the Cirque Trackpad for motion detection --- quantum/pointing_device/pointing_device.c | 8 ++++++++ quantum/pointing_device/pointing_device.h | 6 ++++++ 2 files changed, 14 insertions(+) (limited to 'quantum') diff --git a/quantum/pointing_device/pointing_device.c b/quantum/pointing_device/pointing_device.c index e91de018f1..6981f850d0 100644 --- a/quantum/pointing_device/pointing_device.c +++ b/quantum/pointing_device/pointing_device.c @@ -144,7 +144,11 @@ __attribute__((weak)) void pointing_device_init(void) { { pointing_device_driver.init(); #ifdef POINTING_DEVICE_MOTION_PIN +# ifdef POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW setPinInputHigh(POINTING_DEVICE_MOTION_PIN); +# else + setPinInput(POINTING_DEVICE_MOTION_PIN); +# endif #endif } @@ -236,7 +240,11 @@ __attribute__((weak)) void pointing_device_task(void) { # if defined(SPLIT_POINTING_ENABLE) # error POINTING_DEVICE_MOTION_PIN not supported when sharing the pointing device report between sides. # endif +# ifdef POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW if (!readPin(POINTING_DEVICE_MOTION_PIN)) +# else + if (readPin(POINTING_DEVICE_MOTION_PIN)) +# endif #endif #if defined(SPLIT_POINTING_ENABLE) diff --git a/quantum/pointing_device/pointing_device.h b/quantum/pointing_device/pointing_device.h index a002bd4b25..27a3f95e32 100644 --- a/quantum/pointing_device/pointing_device.h +++ b/quantum/pointing_device/pointing_device.h @@ -27,18 +27,22 @@ along with this program. If not, see . #if defined(POINTING_DEVICE_DRIVER_adns5050) # include "drivers/sensors/adns5050.h" +# define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW #elif defined(POINTING_DEVICE_DRIVER_adns9800) # include "spi_master.h" # include "drivers/sensors/adns9800.h" +# define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW #elif defined(POINTING_DEVICE_DRIVER_analog_joystick) # include "analog.h" # include "drivers/sensors/analog_joystick.h" +# define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW #elif defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_i2c) || defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_spi) # include "drivers/sensors/cirque_pinnacle.h" # include "drivers/sensors/cirque_pinnacle_gestures.h" # include "pointing_device_gestures.h" #elif defined(POINTING_DEVICE_DRIVER_paw3204) # include "drivers/sensors/paw3204.h" +# define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW #elif defined(POINTING_DEVICE_DRIVER_pimoroni_trackball) # include "i2c_master.h" # include "drivers/sensors/pimoroni_trackball.h" @@ -52,9 +56,11 @@ along with this program. If not, see . # ifdef PIMORONI_TRACKBALL_ROTATE # define POINTING_DEVICE_ROTATION_90 # endif +# define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW #elif defined(POINTING_DEVICE_DRIVER_pmw3360) || defined(POINTING_DEVICE_DRIVER_pmw3389) # include "spi_master.h" # include "drivers/sensors/pmw33xx_common.h" +# define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW #else void pointing_device_driver_init(void); report_mouse_t pointing_device_driver_get_report(report_mouse_t mouse_report); -- cgit v1.2.3 From ea2819b2c2f1fbb9bf85010602758166530939ce Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 26 Sep 2022 14:40:15 +1000 Subject: Change `{LED,RGB}_DISABLE_TIMEOUT` to `{LED,RGB}_MATRIX_TIMEOUT` (#18415) --- quantum/led_matrix/led_matrix.c | 30 +++++++++++++----------------- quantum/rgb_matrix/rgb_matrix.c | 30 +++++++++++++----------------- 2 files changed, 26 insertions(+), 34 deletions(-) (limited to 'quantum') diff --git a/quantum/led_matrix/led_matrix.c b/quantum/led_matrix/led_matrix.c index 5bff154480..c26b1ad19b 100644 --- a/quantum/led_matrix/led_matrix.c +++ b/quantum/led_matrix/led_matrix.c @@ -54,12 +54,8 @@ const led_point_t k_led_matrix_center = LED_MATRIX_CENTER; // -----End led effect includes macros------- // ------------------------------------------ -#if defined(LED_DISABLE_AFTER_TIMEOUT) && !defined(LED_DISABLE_TIMEOUT) -# define LED_DISABLE_TIMEOUT (LED_DISABLE_AFTER_TIMEOUT * 1200UL) -#endif - -#ifndef LED_DISABLE_TIMEOUT -# define LED_DISABLE_TIMEOUT 0 +#ifndef LED_MATRIX_TIMEOUT +# define LED_MATRIX_TIMEOUT 0 #endif #if !defined(LED_MATRIX_MAXIMUM_BRIGHTNESS) || LED_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX @@ -103,9 +99,9 @@ static uint8_t led_last_enable = UINT8_MAX; static uint8_t led_last_effect = UINT8_MAX; static effect_params_t led_effect_params = {0, LED_FLAG_ALL, false}; static led_task_states led_task_state = SYNCING; -#if LED_DISABLE_TIMEOUT > 0 +#if LED_MATRIX_TIMEOUT > 0 static uint32_t led_anykey_timer; -#endif // LED_DISABLE_TIMEOUT > 0 +#endif // LED_MATRIX_TIMEOUT > 0 // double buffers static uint32_t led_timer_buffer; @@ -185,9 +181,9 @@ void process_led_matrix(uint8_t row, uint8_t col, bool pressed) { #ifndef LED_MATRIX_SPLIT if (!is_keyboard_master()) return; #endif -#if LED_DISABLE_TIMEOUT > 0 +#if LED_MATRIX_TIMEOUT > 0 led_anykey_timer = 0; -#endif // LED_DISABLE_TIMEOUT > 0 +#endif // LED_MATRIX_TIMEOUT > 0 #ifdef LED_MATRIX_KEYREACTIVE_ENABLED uint8_t led[LED_HITS_TO_REMEMBER]; @@ -237,13 +233,13 @@ static bool led_matrix_none(effect_params_t *params) { } static void led_task_timers(void) { -#if defined(LED_MATRIX_KEYREACTIVE_ENABLED) || LED_DISABLE_TIMEOUT > 0 +#if defined(LED_MATRIX_KEYREACTIVE_ENABLED) || LED_MATRIX_TIMEOUT > 0 uint32_t deltaTime = sync_timer_elapsed32(led_timer_buffer); -#endif // defined(LED_MATRIX_KEYREACTIVE_ENABLED) || LED_DISABLE_TIMEOUT > 0 +#endif // defined(LED_MATRIX_KEYREACTIVE_ENABLED) || LED_MATRIX_TIMEOUT > 0 led_timer_buffer = sync_timer_read32(); // Update double buffer timers -#if LED_DISABLE_TIMEOUT > 0 +#if LED_MATRIX_TIMEOUT > 0 if (led_anykey_timer < UINT32_MAX) { if (UINT32_MAX - deltaTime < led_anykey_timer) { led_anykey_timer = UINT32_MAX; @@ -251,7 +247,7 @@ static void led_task_timers(void) { led_anykey_timer += deltaTime; } } -#endif // LED_DISABLE_TIMEOUT > 0 +#endif // LED_MATRIX_TIMEOUT > 0 // Update double buffer last hit timers #ifdef LED_MATRIX_KEYREACTIVE_ENABLED @@ -357,9 +353,9 @@ void led_matrix_task(void) { // Ideally we would also stop sending zeros to the LED driver PWM buffers // while suspended and just do a software shutdown. This is a cheap hack for now. bool suspend_backlight = suspend_state || -#if LED_DISABLE_TIMEOUT > 0 - (led_anykey_timer > (uint32_t)LED_DISABLE_TIMEOUT) || -#endif // LED_DISABLE_TIMEOUT > 0 +#if LED_MATRIX_TIMEOUT > 0 + (led_anykey_timer > (uint32_t)LED_MATRIX_TIMEOUT) || +#endif // LED_MATRIX_TIMEOUT > 0 false; uint8_t effect = suspend_backlight || !led_matrix_eeconfig.enable ? 0 : led_matrix_eeconfig.mode; diff --git a/quantum/rgb_matrix/rgb_matrix.c b/quantum/rgb_matrix/rgb_matrix.c index ae61e75535..8b335c017d 100644 --- a/quantum/rgb_matrix/rgb_matrix.c +++ b/quantum/rgb_matrix/rgb_matrix.c @@ -56,12 +56,8 @@ __attribute__((weak)) RGB rgb_matrix_hsv_to_rgb(HSV hsv) { // -----End rgb effect includes macros------- // ------------------------------------------ -#if defined(RGB_DISABLE_AFTER_TIMEOUT) && !defined(RGB_DISABLE_TIMEOUT) -# define RGB_DISABLE_TIMEOUT (RGB_DISABLE_AFTER_TIMEOUT * 1200UL) -#endif - -#ifndef RGB_DISABLE_TIMEOUT -# define RGB_DISABLE_TIMEOUT 0 +#ifndef RGB_MATRIX_TIMEOUT +# define RGB_MATRIX_TIMEOUT 0 #endif #if !defined(RGB_MATRIX_MAXIMUM_BRIGHTNESS) || RGB_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX @@ -126,9 +122,9 @@ static uint8_t rgb_last_enable = UINT8_MAX; static uint8_t rgb_last_effect = UINT8_MAX; static effect_params_t rgb_effect_params = {0, LED_FLAG_ALL, false}; static rgb_task_states rgb_task_state = SYNCING; -#if RGB_DISABLE_TIMEOUT > 0 +#if RGB_MATRIX_TIMEOUT > 0 static uint32_t rgb_anykey_timer; -#endif // RGB_DISABLE_TIMEOUT > 0 +#endif // RGB_MATRIX_TIMEOUT > 0 // double buffers static uint32_t rgb_timer_buffer; @@ -213,9 +209,9 @@ void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) { #ifndef RGB_MATRIX_SPLIT if (!is_keyboard_master()) return; #endif -#if RGB_DISABLE_TIMEOUT > 0 +#if RGB_MATRIX_TIMEOUT > 0 rgb_anykey_timer = 0; -#endif // RGB_DISABLE_TIMEOUT > 0 +#endif // RGB_MATRIX_TIMEOUT > 0 #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED uint8_t led[LED_HITS_TO_REMEMBER]; @@ -296,17 +292,17 @@ static bool rgb_matrix_none(effect_params_t *params) { } static void rgb_task_timers(void) { -#if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0 +#if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_MATRIX_TIMEOUT > 0 uint32_t deltaTime = sync_timer_elapsed32(rgb_timer_buffer); -#endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0 +#endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_MATRIX_TIMEOUT > 0 rgb_timer_buffer = sync_timer_read32(); // Update double buffer timers -#if RGB_DISABLE_TIMEOUT > 0 +#if RGB_MATRIX_TIMEOUT > 0 if (rgb_anykey_timer + deltaTime <= UINT32_MAX) { rgb_anykey_timer += deltaTime; } -#endif // RGB_DISABLE_TIMEOUT > 0 +#endif // RGB_MATRIX_TIMEOUT > 0 // Update double buffer last hit timers #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED @@ -419,9 +415,9 @@ void rgb_matrix_task(void) { // Ideally we would also stop sending zeros to the LED driver PWM buffers // while suspended and just do a software shutdown. This is a cheap hack for now. bool suspend_backlight = suspend_state || -#if RGB_DISABLE_TIMEOUT > 0 - (rgb_anykey_timer > (uint32_t)RGB_DISABLE_TIMEOUT) || -#endif // RGB_DISABLE_TIMEOUT > 0 +#if RGB_MATRIX_TIMEOUT > 0 + (rgb_anykey_timer > (uint32_t)RGB_MATRIX_TIMEOUT) || +#endif // RGB_MATRIX_TIMEOUT > 0 false; uint8_t effect = suspend_backlight || !rgb_matrix_config.enable ? 0 : rgb_matrix_config.mode; -- cgit v1.2.3 From d909038b28c553f5eb0ecec74f58792155c4d49d Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Mon, 26 Sep 2022 20:49:15 -0700 Subject: Move Oneshot mod callbacks to after mods are set (#18101) --- quantum/action.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'quantum') diff --git a/quantum/action.c b/quantum/action.c index 6b2e9104e0..a1476131b9 100644 --- a/quantum/action.c +++ b/quantum/action.c @@ -403,9 +403,9 @@ void process_action(keyrecord_t *record, action_t action) { # if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1 } else if (tap_count == ONESHOT_TAP_TOGGLE) { dprint("MODS_TAP: Toggling oneshot"); + register_mods(mods); clear_oneshot_mods(); set_oneshot_locked_mods(mods | get_oneshot_locked_mods()); - register_mods(mods); # endif } else { register_mods(mods | get_oneshot_mods()); @@ -418,16 +418,16 @@ void process_action(keyrecord_t *record, action_t action) { // Retain Oneshot mods # if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1 if (mods & get_mods()) { + unregister_mods(mods); clear_oneshot_mods(); set_oneshot_locked_mods(~mods & get_oneshot_locked_mods()); - unregister_mods(mods); } } else if (tap_count == ONESHOT_TAP_TOGGLE) { // Toggle Oneshot Layer # endif } else { - clear_oneshot_mods(); unregister_mods(mods); + clear_oneshot_mods(); } } } -- cgit v1.2.3 From fb400f2ac2c57fa0fc82ca803f6450b818bb32f9 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Mon, 26 Sep 2022 20:49:32 -0700 Subject: Enabling Pointing Device support in register code functions (#18363) --- quantum/action.c | 8 ++++++++ quantum/pointing_device/pointing_device.c | 8 ++++++++ quantum/pointing_device/pointing_device.h | 1 + 3 files changed, 17 insertions(+) (limited to 'quantum') diff --git a/quantum/action.c b/quantum/action.c index a1476131b9..4f01acb96e 100644 --- a/quantum/action.c +++ b/quantum/action.c @@ -918,6 +918,10 @@ __attribute__((weak)) void register_code(uint8_t code) { mousekey_on(code); mousekey_send(); } +#elif defined(POINTING_DEVICE_ENABLE) + else if IS_MOUSEKEY (code) { + pointing_device_keycode_handler(code, true); + } #endif } @@ -978,6 +982,10 @@ __attribute__((weak)) void unregister_code(uint8_t code) { mousekey_off(code); mousekey_send(); } +#elif defined(POINTING_DEVICE_ENABLE) + else if IS_MOUSEKEY (code) { + pointing_device_keycode_handler(code, false); + } #endif } diff --git a/quantum/pointing_device/pointing_device.c b/quantum/pointing_device/pointing_device.c index 6981f850d0..75bb5f81fc 100644 --- a/quantum/pointing_device/pointing_device.c +++ b/quantum/pointing_device/pointing_device.c @@ -22,6 +22,7 @@ #ifdef MOUSEKEY_ENABLE # include "mousekey.h" #endif + #if (defined(POINTING_DEVICE_ROTATION_90) + defined(POINTING_DEVICE_ROTATION_180) + defined(POINTING_DEVICE_ROTATION_270)) > 1 # error More than one rotation selected. This is not supported. #endif @@ -479,3 +480,10 @@ __attribute__((weak)) report_mouse_t pointing_device_task_combined_user(report_m return pointing_device_combine_reports(left_report, right_report); } #endif + +__attribute__((weak)) void pointing_device_keycode_handler(uint16_t keycode, bool pressed) { + if IS_MOUSEKEY_BUTTON (keycode) { + local_mouse_report.buttons = pointing_device_handle_buttons(local_mouse_report.buttons, pressed, keycode - KC_MS_BTN1); + pointing_device_send(); + } +} diff --git a/quantum/pointing_device/pointing_device.h b/quantum/pointing_device/pointing_device.h index 27a3f95e32..d430e6cfa4 100644 --- a/quantum/pointing_device/pointing_device.h +++ b/quantum/pointing_device/pointing_device.h @@ -110,6 +110,7 @@ report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report); report_mouse_t pointing_device_task_user(report_mouse_t mouse_report); uint8_t pointing_device_handle_buttons(uint8_t buttons, bool pressed, pointing_device_buttons_t button); report_mouse_t pointing_device_adjust_by_defines(report_mouse_t mouse_report); +void pointing_device_keycode_handler(uint16_t keycode, bool pressed); #if defined(SPLIT_POINTING_ENABLE) void pointing_device_set_shared_report(report_mouse_t report); -- cgit v1.2.3 From be8907d634ac8967de1ae2ac8346b845f738c9e6 Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 27 Sep 2022 18:37:13 +1000 Subject: Further refactoring of joystick feature (#18437) --- quantum/joystick.c | 98 ++++++++++++++++++- quantum/joystick.h | 28 +++++- quantum/process_keycode/process_joystick.c | 152 ++++------------------------- quantum/process_keycode/process_joystick.h | 21 +++- 4 files changed, 155 insertions(+), 144 deletions(-) (limited to 'quantum') diff --git a/quantum/joystick.c b/quantum/joystick.c index 86b2c64036..d285dcdb5e 100644 --- a/quantum/joystick.c +++ b/quantum/joystick.c @@ -1,5 +1,24 @@ +/* Copyright 2022 + * + * 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 . + */ + #include "joystick.h" +#include "analog.h" +#include "wait.h" + // clang-format off joystick_t joystick_status = { .buttons = {0}, @@ -15,12 +34,13 @@ joystick_t joystick_status = { // array defining the reading of analog values for each axis __attribute__((weak)) joystick_config_t joystick_axes[JOYSTICK_AXES_COUNT] = {}; -// to be implemented in the hid protocol library -void send_joystick_packet(joystick_t *joystick); +__attribute__((weak)) void joystick_task(void) { + joystick_read_axes(); +} void joystick_flush(void) { if ((joystick_status.status & JS_UPDATED) > 0) { - send_joystick_packet(&joystick_status); + host_joystick_send(&joystick_status); joystick_status.status &= ~JS_UPDATED; } } @@ -36,3 +56,75 @@ void unregister_joystick_button(uint8_t button) { joystick_status.status |= JS_UPDATED; joystick_flush(); } + +int16_t joystick_read_axis(uint8_t axis) { + // disable pull-up resistor + writePinLow(joystick_axes[axis].input_pin); + + // if pin was a pull-up input, we need to uncharge it by turning it low + // before making it a low input + setPinOutput(joystick_axes[axis].input_pin); + + wait_us(10); + + if (joystick_axes[axis].output_pin != JS_VIRTUAL_AXIS) { + setPinOutput(joystick_axes[axis].output_pin); + writePinHigh(joystick_axes[axis].output_pin); + } + + if (joystick_axes[axis].ground_pin != JS_VIRTUAL_AXIS) { + setPinOutput(joystick_axes[axis].ground_pin); + writePinLow(joystick_axes[axis].ground_pin); + } + + wait_us(10); + + setPinInput(joystick_axes[axis].input_pin); + + wait_us(10); + +#if defined(ANALOG_JOYSTICK_ENABLE) && (defined(__AVR__) || defined(PROTOCOL_CHIBIOS)) + int16_t axis_val = analogReadPin(joystick_axes[axis].input_pin); +#else + // default to resting position + int16_t axis_val = joystick_axes[axis].mid_digit; +#endif + + // test the converted value against the lower range + int32_t ref = joystick_axes[axis].mid_digit; + int32_t range = joystick_axes[axis].min_digit; + int32_t ranged_val = ((axis_val - ref) * -JOYSTICK_RESOLUTION) / (range - ref); + + if (ranged_val > 0) { + // the value is in the higher range + range = joystick_axes[axis].max_digit; + ranged_val = ((axis_val - ref) * JOYSTICK_RESOLUTION) / (range - ref); + } + + // clamp the result in the valid range + ranged_val = ranged_val < -JOYSTICK_RESOLUTION ? -JOYSTICK_RESOLUTION : ranged_val; + ranged_val = ranged_val > JOYSTICK_RESOLUTION ? JOYSTICK_RESOLUTION : ranged_val; + + return ranged_val; +} + +void joystick_read_axes() { +#if JOYSTICK_AXES_COUNT > 0 + for (int i = 0; i < JOYSTICK_AXES_COUNT; ++i) { + if (joystick_axes[i].input_pin == JS_VIRTUAL_AXIS) { + continue; + } + + joystick_set_axis(i, joystick_read_axis(i)); + } + + joystick_flush(); +#endif +} + +void joystick_set_axis(uint8_t axis, int16_t value) { + if (value != joystick_status.axes[axis]) { + joystick_status.axes[axis] = value; + joystick_status.status |= JS_UPDATED; + } +} diff --git a/quantum/joystick.h b/quantum/joystick.h index 5d81b14ef2..ee966fdb1a 100644 --- a/quantum/joystick.h +++ b/quantum/joystick.h @@ -1,3 +1,19 @@ +/* Copyright 2022 + * + * 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 . + */ + #pragma once #include @@ -54,7 +70,10 @@ typedef struct { extern joystick_config_t joystick_axes[JOYSTICK_AXES_COUNT]; -enum joystick_status { JS_INITIALIZED = 1, JS_UPDATED = 2 }; +enum joystick_status { + JS_INITIALIZED = 1, + JS_UPDATED, +}; typedef struct { uint8_t buttons[(JOYSTICK_BUTTON_COUNT - 1) / 8 + 1]; @@ -65,7 +84,14 @@ typedef struct { extern joystick_t joystick_status; +void joystick_task(void); void joystick_flush(void); void register_joystick_button(uint8_t button); void unregister_joystick_button(uint8_t button); + +int16_t joystick_read_axis(uint8_t axis); +void joystick_read_axes(void); +void joystick_set_axis(uint8_t axis, int16_t value); + +void host_joystick_send(joystick_t *joystick); diff --git a/quantum/process_keycode/process_joystick.c b/quantum/process_keycode/process_joystick.c index e867606074..af69d3aa05 100644 --- a/quantum/process_keycode/process_joystick.c +++ b/quantum/process_keycode/process_joystick.c @@ -1,10 +1,21 @@ -#include "joystick.h" -#include "process_joystick.h" - -#include "analog.h" +/* Copyright 2022 + * + * 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 . + */ -#include -#include +#include "process_joystick.h" +#include "joystick.h" bool process_joystick(uint16_t keycode, keyrecord_t *record) { switch (keycode) { @@ -18,132 +29,3 @@ bool process_joystick(uint16_t keycode, keyrecord_t *record) { } return true; } - -__attribute__((weak)) void joystick_task(void) { - if (process_joystick_analogread()) { - joystick_flush(); - } -} - -uint16_t savePinState(pin_t pin) { -#ifdef __AVR__ - uint8_t pinNumber = pin & 0xF; - return ((PORTx_ADDRESS(pin) >> pinNumber) & 0x1) << 1 | ((DDRx_ADDRESS(pin) >> pinNumber) & 0x1); -#elif defined(PROTOCOL_CHIBIOS) - /* - The pin configuration is backed up in the following format : - bit 15 9 8 7 6 5 4 3 2 1 0 - |unused|ODR|IDR|PUPDR|OSPEEDR|OTYPER|MODER| - */ - return ((PAL_PORT(pin)->MODER >> (2 * PAL_PAD(pin))) & 0x3) | (((PAL_PORT(pin)->OTYPER >> (1 * PAL_PAD(pin))) & 0x1) << 2) | (((PAL_PORT(pin)->OSPEEDR >> (2 * PAL_PAD(pin))) & 0x3) << 3) | (((PAL_PORT(pin)->PUPDR >> (2 * PAL_PAD(pin))) & 0x3) << 5) | (((PAL_PORT(pin)->IDR >> (1 * PAL_PAD(pin))) & 0x1) << 7) | (((PAL_PORT(pin)->ODR >> (1 * PAL_PAD(pin))) & 0x1) << 8); -#else - return 0; -#endif -} - -void restorePinState(pin_t pin, uint16_t restoreState) { -#if defined(PROTOCOL_LUFA) - uint8_t pinNumber = pin & 0xF; - PORTx_ADDRESS(pin) = (PORTx_ADDRESS(pin) & ~_BV(pinNumber)) | (((restoreState >> 1) & 0x1) << pinNumber); - DDRx_ADDRESS(pin) = (DDRx_ADDRESS(pin) & ~_BV(pinNumber)) | ((restoreState & 0x1) << pinNumber); -#elif defined(PROTOCOL_CHIBIOS) - PAL_PORT(pin)->MODER = (PAL_PORT(pin)->MODER & ~(0x3 << (2 * PAL_PAD(pin)))) | (restoreState & 0x3) << (2 * PAL_PAD(pin)); - PAL_PORT(pin)->OTYPER = (PAL_PORT(pin)->OTYPER & ~(0x1 << (1 * PAL_PAD(pin)))) | ((restoreState >> 2) & 0x1) << (1 * PAL_PAD(pin)); - PAL_PORT(pin)->OSPEEDR = (PAL_PORT(pin)->OSPEEDR & ~(0x3 << (2 * PAL_PAD(pin)))) | ((restoreState >> 3) & 0x3) << (2 * PAL_PAD(pin)); - PAL_PORT(pin)->PUPDR = (PAL_PORT(pin)->PUPDR & ~(0x3 << (2 * PAL_PAD(pin)))) | ((restoreState >> 5) & 0x3) << (2 * PAL_PAD(pin)); - PAL_PORT(pin)->IDR = (PAL_PORT(pin)->IDR & ~(0x1 << (1 * PAL_PAD(pin)))) | ((restoreState >> 7) & 0x1) << (1 * PAL_PAD(pin)); - PAL_PORT(pin)->ODR = (PAL_PORT(pin)->ODR & ~(0x1 << (1 * PAL_PAD(pin)))) | ((restoreState >> 8) & 0x1) << (1 * PAL_PAD(pin)); -#else - return; -#endif -} - -__attribute__((weak)) bool process_joystick_analogread() { - return process_joystick_analogread_quantum(); -} - -bool process_joystick_analogread_quantum() { -#if JOYSTICK_AXES_COUNT > 0 - for (int axis_index = 0; axis_index < JOYSTICK_AXES_COUNT; ++axis_index) { - if (joystick_axes[axis_index].input_pin == JS_VIRTUAL_AXIS) { - continue; - } - - // save previous input pin status as well - uint16_t inputSavedState = savePinState(joystick_axes[axis_index].input_pin); - - // disable pull-up resistor - writePinLow(joystick_axes[axis_index].input_pin); - - // if pin was a pull-up input, we need to uncharge it by turning it low - // before making it a low input - setPinOutput(joystick_axes[axis_index].input_pin); - - wait_us(10); - - // save and apply output pin status - uint16_t outputSavedState = 0; - if (joystick_axes[axis_index].output_pin != JS_VIRTUAL_AXIS) { - // save previous output pin status - outputSavedState = savePinState(joystick_axes[axis_index].output_pin); - - setPinOutput(joystick_axes[axis_index].output_pin); - writePinHigh(joystick_axes[axis_index].output_pin); - } - - uint16_t groundSavedState = 0; - if (joystick_axes[axis_index].ground_pin != JS_VIRTUAL_AXIS) { - // save previous output pin status - groundSavedState = savePinState(joystick_axes[axis_index].ground_pin); - - setPinOutput(joystick_axes[axis_index].ground_pin); - writePinLow(joystick_axes[axis_index].ground_pin); - } - - wait_us(10); - - setPinInput(joystick_axes[axis_index].input_pin); - - wait_us(10); - -# if defined(ANALOG_JOYSTICK_ENABLE) && (defined(__AVR__) || defined(PROTOCOL_CHIBIOS)) - int16_t axis_val = analogReadPin(joystick_axes[axis_index].input_pin); -# else - // default to resting position - int16_t axis_val = joystick_axes[axis_index].mid_digit; -# endif - - // test the converted value against the lower range - int32_t ref = joystick_axes[axis_index].mid_digit; - int32_t range = joystick_axes[axis_index].min_digit; - int32_t ranged_val = ((axis_val - ref) * -JOYSTICK_RESOLUTION) / (range - ref); - - if (ranged_val > 0) { - // the value is in the higher range - range = joystick_axes[axis_index].max_digit; - ranged_val = ((axis_val - ref) * JOYSTICK_RESOLUTION) / (range - ref); - } - - // clamp the result in the valid range - ranged_val = ranged_val < -JOYSTICK_RESOLUTION ? -JOYSTICK_RESOLUTION : ranged_val; - ranged_val = ranged_val > JOYSTICK_RESOLUTION ? JOYSTICK_RESOLUTION : ranged_val; - - if (ranged_val != joystick_status.axes[axis_index]) { - joystick_status.axes[axis_index] = ranged_val; - joystick_status.status |= JS_UPDATED; - } - - // restore output, ground and input status - if (joystick_axes[axis_index].output_pin != JS_VIRTUAL_AXIS) { - restorePinState(joystick_axes[axis_index].output_pin, outputSavedState); - } - if (joystick_axes[axis_index].ground_pin != JS_VIRTUAL_AXIS) { - restorePinState(joystick_axes[axis_index].ground_pin, groundSavedState); - } - - restorePinState(joystick_axes[axis_index].input_pin, inputSavedState); - } - -#endif - return true; -} diff --git a/quantum/process_keycode/process_joystick.h b/quantum/process_keycode/process_joystick.h index 7a8b82913a..1fb8757708 100644 --- a/quantum/process_keycode/process_joystick.h +++ b/quantum/process_keycode/process_joystick.h @@ -1,11 +1,22 @@ +/* Copyright 2022 + * + * 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 . + */ + #pragma once #include #include "quantum.h" bool process_joystick(uint16_t keycode, keyrecord_t *record); - -void joystick_task(void); - -bool process_joystick_analogread(void); -bool process_joystick_analogread_quantum(void); -- cgit v1.2.3 From 703d8cd417115d6e37090e26e358cf73f6346113 Mon Sep 17 00:00:00 2001 From: izmishi <31067139+izmishi@users.noreply.github.com> Date: Wed, 28 Sep 2022 18:16:24 +0100 Subject: Fix retain brightness when val is changed while a layer is active (#18426) * Fix retain brightness when val is changed while a layer is active * Fix retain brightness for RGBLIGHT_MODE_STATIC_GRADIENT * Fix formatting --- quantum/rgblight/rgblight.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'quantum') diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c index 73b352cea8..37cd7a66ab 100644 --- a/quantum/rgblight/rgblight.c +++ b/quantum/rgblight/rgblight.c @@ -523,10 +523,19 @@ void rgblight_sethsv_noeeprom_old(uint8_t hue, uint8_t sat, uint8_t val) { void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) { if (rgblight_config.enable) { +#ifdef RGBLIGHT_SPLIT + if (rgblight_config.hue != hue || rgblight_config.sat != sat || rgblight_config.val != val) { + RGBLIGHT_SPLIT_SET_CHANGE_HSVS; + } +#endif rgblight_status.base_mode = mode_base_table[rgblight_config.mode]; if (rgblight_config.mode == RGBLIGHT_MODE_STATIC_LIGHT) { // same static color LED_TYPE tmp_led; +#ifdef RGBLIGHT_LAYERS_RETAIN_VAL + // needed for rgblight_layers_write() to get the new val, since it reads rgblight_config.val + rgblight_config.val = val; +#endif sethsv(hue, sat, val, &tmp_led); rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b); } else { @@ -568,15 +577,14 @@ void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool w dprintf("rgblight rainbow set hsv: %d,%d,%d,%u\n", i, _hue, direction, range); sethsv(_hue, sat, val, (LED_TYPE *)&led[i + rgblight_ranges.effect_start_pos]); } +# ifdef RGBLIGHT_LAYERS_RETAIN_VAL + // needed for rgblight_layers_write() to get the new val, since it reads rgblight_config.val + rgblight_config.val = val; +# endif rgblight_set(); } #endif } -#ifdef RGBLIGHT_SPLIT - if (rgblight_config.hue != hue || rgblight_config.sat != sat || rgblight_config.val != val) { - RGBLIGHT_SPLIT_SET_CHANGE_HSVS; - } -#endif rgblight_config.hue = hue; rgblight_config.sat = sat; rgblight_config.val = val; -- cgit v1.2.3 From cbbb45c13f3de5ec28f62b6cd4a8b77143026500 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Fri, 30 Sep 2022 03:25:55 +1000 Subject: Start moving towards introspection-based data retrieval (#18441) --- quantum/dynamic_keymap.c | 25 +++++++++++++------------ quantum/keyboard.c | 5 ++--- quantum/keymap.h | 2 -- quantum/keymap_common.c | 6 +++--- quantum/keymap_introspection.c | 22 ++++++++++++++++++++++ quantum/keymap_introspection.h | 10 ++++++++++ 6 files changed, 50 insertions(+), 20 deletions(-) (limited to 'quantum') diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c index 01be9806e4..e9529ed14e 100644 --- a/quantum/dynamic_keymap.c +++ b/quantum/dynamic_keymap.c @@ -153,7 +153,7 @@ void dynamic_keymap_reset(void) { for (int row = 0; row < MATRIX_ROWS; row++) { for (int column = 0; column < MATRIX_COLS; column++) { if (layer < keymap_layer_count()) { - dynamic_keymap_set_keycode(layer, row, column, pgm_read_word(&keymaps[layer][row][column])); + dynamic_keymap_set_keycode(layer, row, column, keycode_at_keymap_location_raw(layer, row, column)); } else { dynamic_keymap_set_keycode(layer, row, column, KC_TRANSPARENT); } @@ -162,8 +162,8 @@ void dynamic_keymap_reset(void) { #ifdef ENCODER_MAP_ENABLE for (int encoder = 0; encoder < NUM_ENCODERS; encoder++) { if (layer < encodermap_layer_count()) { - dynamic_keymap_set_encoder(layer, encoder, true, pgm_read_word(&encoder_map[layer][encoder][0])); - dynamic_keymap_set_encoder(layer, encoder, false, pgm_read_word(&encoder_map[layer][encoder][1])); + dynamic_keymap_set_encoder(layer, encoder, true, keycode_at_encodermap_location_raw(layer, encoder, true)); + dynamic_keymap_set_encoder(layer, encoder, false, keycode_at_encodermap_location_raw(layer, encoder, false)); } else { dynamic_keymap_set_encoder(layer, encoder, true, KC_TRANSPARENT); dynamic_keymap_set_encoder(layer, encoder, false, KC_TRANSPARENT); @@ -201,20 +201,21 @@ void dynamic_keymap_set_buffer(uint16_t offset, uint16_t size, uint8_t *data) { } } -// This overrides the one in quantum/keymap_common.c -uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key) { - if (layer < DYNAMIC_KEYMAP_LAYER_COUNT && key.row < MATRIX_ROWS && key.col < MATRIX_COLS) { - return dynamic_keymap_get_keycode(layer, key.row, key.col); +uint16_t keycode_at_keymap_location(uint8_t layer_num, uint8_t row, uint8_t column) { + if (layer_num < DYNAMIC_KEYMAP_LAYER_COUNT && row < MATRIX_ROWS && column < MATRIX_COLS) { + return dynamic_keymap_get_keycode(layer_num, row, column); } + return KC_NO; +} + #ifdef ENCODER_MAP_ENABLE - else if (layer < DYNAMIC_KEYMAP_LAYER_COUNT && key.row == KEYLOC_ENCODER_CW && key.col < NUM_ENCODERS) { - return dynamic_keymap_get_encoder(layer, key.col, true); - } else if (layer < DYNAMIC_KEYMAP_LAYER_COUNT && key.row == KEYLOC_ENCODER_CCW && key.col < NUM_ENCODERS) { - return dynamic_keymap_get_encoder(layer, key.col, false); +uint16_t keycode_at_encodermap_location(uint8_t layer_num, uint8_t encoder_idx, bool clockwise) { + if (layer_num < DYNAMIC_KEYMAP_LAYER_COUNT && encoder_idx < NUM_ENCODERS) { + return dynamic_keymap_get_encoder(layer_num, encoder_idx, clockwise); } -#endif // ENCODER_MAP_ENABLE return KC_NO; } +#endif // ENCODER_MAP_ENABLE uint8_t dynamic_keymap_macro_get_count(void) { return DYNAMIC_KEYMAP_MACRO_COUNT; diff --git a/quantum/keyboard.c b/quantum/keyboard.c index 3b5e9b0200..c8025d059b 100644 --- a/quantum/keyboard.c +++ b/quantum/keyboard.c @@ -175,12 +175,11 @@ uint32_t get_matrix_scan_rate(void) { #endif #ifdef MATRIX_HAS_GHOST -extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; -static matrix_row_t get_real_keys(uint8_t row, matrix_row_t rowdata) { +static matrix_row_t get_real_keys(uint8_t row, matrix_row_t rowdata) { matrix_row_t out = 0; for (uint8_t col = 0; col < MATRIX_COLS; col++) { // read each key in the row data and check if the keymap defines it as a real key - if (pgm_read_byte(&keymaps[0][row][col]) && (rowdata & (1 << col))) { + if (keycode_at_keymap_location(0, row, col) && (rowdata & (1 << col))) { // this creates new row data, if a key is defined in the keymap, it will be set here out |= 1 << col; } diff --git a/quantum/keymap.h b/quantum/keymap.h index 67e35c4e2f..0225f53362 100644 --- a/quantum/keymap.h +++ b/quantum/keymap.h @@ -33,8 +33,6 @@ along with this program. If not, see . // translates key to keycode uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key); -extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; - #ifdef ENCODER_MAP_ENABLE // Ensure we have a forward declaration for the encoder map # include "encoder.h" diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 1d5ef9b403..5e8a043470 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -147,13 +147,13 @@ action_t action_for_keycode(uint16_t keycode) { // translates key to keycode __attribute__((weak)) uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key) { if (key.row < MATRIX_ROWS && key.col < MATRIX_COLS) { - return pgm_read_word(&keymaps[layer][key.row][key.col]); + return keycode_at_keymap_location(layer, key.row, key.col); } #ifdef ENCODER_MAP_ENABLE else if (key.row == KEYLOC_ENCODER_CW && key.col < NUM_ENCODERS) { - return pgm_read_word(&encoder_map[layer][key.col][0]); + return keycode_at_encodermap_location(layer, key.col, true); } else if (key.row == KEYLOC_ENCODER_CCW && key.col < NUM_ENCODERS) { - return pgm_read_word(&encoder_map[layer][key.col][1]); + return keycode_at_encodermap_location(layer, key.col, false); } #endif // ENCODER_MAP_ENABLE return KC_NO; diff --git a/quantum/keymap_introspection.c b/quantum/keymap_introspection.c index 179b5eb037..93aab82fcc 100644 --- a/quantum/keymap_introspection.c +++ b/quantum/keymap_introspection.c @@ -19,6 +19,17 @@ uint8_t keymap_layer_count(void) { _Static_assert(NUM_KEYMAP_LAYERS <= MAX_LAYER, "Number of keymap layers exceeds maximum set by LAYER_STATE_(8|16|32)BIT"); +uint16_t keycode_at_keymap_location_raw(uint8_t layer_num, uint8_t row, uint8_t column) { + if (layer_num < NUM_KEYMAP_LAYERS && row < MATRIX_ROWS && column < MATRIX_COLS) { + return pgm_read_word(&keymaps[layer_num][row][column]); + } + return KC_NO; +} + +__attribute__((weak)) uint16_t keycode_at_keymap_location(uint8_t layer_num, uint8_t row, uint8_t column) { + return keycode_at_keymap_location_raw(layer_num, row, column); +} + #if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) # define NUM_ENCODERMAP_LAYERS ((uint8_t)(sizeof(encoder_map) / ((NUM_ENCODERS) * (2) * sizeof(uint16_t)))) @@ -29,4 +40,15 @@ uint8_t encodermap_layer_count(void) { _Static_assert(NUM_KEYMAP_LAYERS == NUM_ENCODERMAP_LAYERS, "Number of encoder_map layers doesn't match the number of keymap layers"); +uint16_t keycode_at_encodermap_location_raw(uint8_t layer_num, uint8_t encoder_idx, bool clockwise) { + if (layer_num < NUM_ENCODERMAP_LAYERS && encoder_idx < NUM_ENCODERS) { + return pgm_read_word(&encoder_map[layer_num][encoder_idx][clockwise ? 0 : 1]); + } + return KC_NO; +} + +__attribute__((weak)) uint16_t keycode_at_encodermap_location(uint8_t layer_num, uint8_t encoder_idx, bool clockwise) { + return keycode_at_encodermap_location_raw(layer_num, encoder_idx, clockwise); +} + #endif // defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) diff --git a/quantum/keymap_introspection.h b/quantum/keymap_introspection.h index 23f6f2016f..9de706a021 100644 --- a/quantum/keymap_introspection.h +++ b/quantum/keymap_introspection.h @@ -7,9 +7,19 @@ // Get the number of layers defined in the keymap uint8_t keymap_layer_count(void); +// Get the keycode for the keymap location, stored in firmware rather than any other persistent storage +uint16_t keycode_at_keymap_location_raw(uint8_t layer_num, uint8_t row, uint8_t column); +// Get the keycode for the keymap location, potentially stored dynamically +uint16_t keycode_at_keymap_location(uint8_t layer_num, uint8_t row, uint8_t column); + #if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) // Get the number of layers defined in the encoder map uint8_t encodermap_layer_count(void); +// Get the keycode for the encoder mapping location, stored in firmware rather than any other persistent storage +uint16_t keycode_at_encodermap_location_raw(uint8_t layer_num, uint8_t encoder_idx, bool clockwise); +// Get the keycode for the encoder mapping location, potentially stored dynamically +uint16_t keycode_at_encodermap_location(uint8_t layer_num, uint8_t encoder_idx, bool clockwise); + #endif // defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) -- cgit v1.2.3 From f80058d96e2f1606f648166d320cda15986ced4c Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 30 Sep 2022 03:38:09 +1000 Subject: Start Bluetooth API (#18366) --- quantum/keyboard.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'quantum') diff --git a/quantum/keyboard.c b/quantum/keyboard.c index c8025d059b..626e0a7ee1 100644 --- a/quantum/keyboard.c +++ b/quantum/keyboard.c @@ -106,12 +106,7 @@ along with this program. If not, see . # include "split_util.h" #endif #ifdef BLUETOOTH_ENABLE -# include "outputselect.h" -# ifdef BLUETOOTH_BLUEFRUIT_LE -# include "bluefruit_le.h" -# elif BLUETOOTH_RN42 -# include "rn42.h" -# endif +# include "bluetooth.h" #endif #ifdef CAPS_WORD_ENABLE # include "caps_word.h" @@ -411,8 +406,8 @@ void keyboard_init(void) { // init after split init pointing_device_init(); #endif -#if defined(BLUETOOTH_RN42) - rn42_init(); +#ifdef BLUETOOTH_ENABLE + bluetooth_init(); #endif #if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE) @@ -674,8 +669,8 @@ void keyboard_task(void) { programmable_button_send(); #endif -#ifdef BLUETOOTH_BLUEFRUIT_LE - bluefruit_le_task(); +#ifdef BLUETOOTH_ENABLE + bluetooth_task(); #endif led_task(); -- cgit v1.2.3 From dbe214c3268d9a316a137471a7679f7e45046e49 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Thu, 29 Sep 2022 10:50:47 -0700 Subject: Handle mouse keys more consistently (#18513) --- quantum/action.c | 100 ++++++++++++++++++++++++------------------------ quantum/keymap_common.c | 2 - 2 files changed, 51 insertions(+), 51 deletions(-) (limited to 'quantum') diff --git a/quantum/action.c b/quantum/action.c index 4f01acb96e..259c4349c3 100644 --- a/quantum/action.c +++ b/quantum/action.c @@ -293,19 +293,56 @@ void process_record_handler(keyrecord_t *record) { process_action(record, action); } -#if defined(PS2_MOUSE_ENABLE) || defined(POINTING_DEVICE_ENABLE) -void register_button(bool pressed, enum mouse_buttons button) { -# ifdef PS2_MOUSE_ENABLE - tp_buttons = pressed ? tp_buttons | button : tp_buttons & ~button; -# endif -# ifdef POINTING_DEVICE_ENABLE - report_mouse_t currentReport = pointing_device_get_report(); - currentReport.buttons = pressed ? currentReport.buttons | button : currentReport.buttons & ~button; - pointing_device_set_report(currentReport); +/** + * @brief handles all the messy mouse stuff + * + * Handles all the edgecases and special stuff that is needed for coexistense + * of the multiple mouse subsystems. + * + * @param mouse_keycode[in] uint8_t mouse keycode + * @param pressed[in] bool + */ + +void register_mouse(uint8_t mouse_keycode, bool pressed) { +#ifdef MOUSEKEY_ENABLE + // if mousekeys is enabled, let it do the brunt of the work + if (pressed) { + mousekey_on(mouse_keycode); + } else { + mousekey_off(mouse_keycode); + } + // should mousekeys send report, or does something else handle this? + switch (mouse_keycode) { +# if defined(PS2_MOUSE_ENABLE) || defined(POINTING_DEVICE_ENABLE) + case KC_MS_BTN1 ... KC_MS_BTN8: + // let pointing device handle the buttons + // expand if/when it handles more of the code +# if defined(POINTING_DEVICE_ENABLE) + pointing_device_keycode_handler(mouse_keycode, pressed); +# endif + break; # endif -} + default: + mousekey_send(); + break; + } +#elif defined(POINTING_DEVICE_ENABLE) + // if mousekeys isn't enabled, and pointing device is enabled, then + // let pointing device do all the heavy lifting, then + if IS_MOUSEKEY (mouse_keycode) { + pointing_device_keycode_handler(mouse_keycode, pressed); + } #endif +#ifdef PS2_MOUSE_ENABLE + // make sure that ps2 mouse has button report synced + if (KC_MS_BTN1 <= mouse_keycode && mouse_keycode <= KC_MS_BTN3) { + uint8_t tmp_button_msk = MOUSE_BTN_MASK(mouse_keycode - KC_MS_BTN1); + tp_buttons = pressed ? tp_buttons | tmp_button_msk : tp_buttons & ~tmp_button_msk; + } +#endif +} + /** \brief Take an action and processes it. * * FIXME: Needs documentation. @@ -506,30 +543,10 @@ void process_action(keyrecord_t *record, action_t action) { } break; #endif -#ifdef MOUSEKEY_ENABLE /* Mouse key */ case ACT_MOUSEKEY: - if (event.pressed) { - mousekey_on(action.key.code); - } else { - mousekey_off(action.key.code); - } - switch (action.key.code) { -# if defined(PS2_MOUSE_ENABLE) || defined(POINTING_DEVICE_ENABLE) -# ifdef POINTING_DEVICE_ENABLE - case KC_MS_BTN1 ... KC_MS_BTN8: -# else - case KC_MS_BTN1 ... KC_MS_BTN3: -# endif - register_button(event.pressed, MOUSE_BTN_MASK(action.key.code - KC_MS_BTN1)); - break; -# endif - default: - mousekey_send(); - break; - } + register_mouse(action.key.code, event.pressed); break; -#endif #ifndef NO_ACTION_LAYER case ACT_LAYER: if (action.layer_bitop.on == 0) { @@ -913,16 +930,9 @@ __attribute__((weak)) void register_code(uint8_t code) { host_consumer_send(KEYCODE2CONSUMER(code)); } #endif -#ifdef MOUSEKEY_ENABLE else if IS_MOUSEKEY (code) { - mousekey_on(code); - mousekey_send(); + register_mouse(code, true); } -#elif defined(POINTING_DEVICE_ENABLE) - else if IS_MOUSEKEY (code) { - pointing_device_keycode_handler(code, true); - } -#endif } /** \brief Utilities for actions. (FIXME: Needs better description) @@ -976,17 +986,9 @@ __attribute__((weak)) void unregister_code(uint8_t code) { host_system_send(0); } else if IS_CONSUMER (code) { host_consumer_send(0); + } else if IS_MOUSEKEY (code) { + register_mouse(code, false); } -#ifdef MOUSEKEY_ENABLE - else if IS_MOUSEKEY (code) { - mousekey_off(code); - mousekey_send(); - } -#elif defined(POINTING_DEVICE_ENABLE) - else if IS_MOUSEKEY (code) { - pointing_device_keycode_handler(code, false); - } -#endif } /** \brief Tap a keycode with a delay. diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 5e8a043470..50e581cd87 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -65,11 +65,9 @@ action_t action_for_keycode(uint16_t keycode) { action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode)); break; #endif -#ifdef MOUSEKEY_ENABLE case KC_MS_UP ... KC_MS_ACCEL2: action.code = ACTION_MOUSEKEY(keycode); break; -#endif case KC_TRANSPARENT: action.code = ACTION_TRANSPARENT; break; -- cgit v1.2.3 From 2c96c7526356ba76400c6fa61bd0805e81c5aa31 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 1 Oct 2022 06:29:24 +1000 Subject: Small un/register_code() cleanups (#18544) --- quantum/action.c | 50 ++++++++++++++++++++------------------------------ quantum/action_code.h | 6 +++++- 2 files changed, 25 insertions(+), 31 deletions(-) (limited to 'quantum') diff --git a/quantum/action.c b/quantum/action.c index 259c4349c3..78322e4a83 100644 --- a/quantum/action.c +++ b/quantum/action.c @@ -527,18 +527,10 @@ void process_action(keyrecord_t *record, action_t action) { case ACT_USAGE: switch (action.usage.page) { case PAGE_SYSTEM: - if (event.pressed) { - host_system_send(action.usage.code); - } else { - host_system_send(0); - } + host_system_send(event.pressed ? action.usage.code : 0); break; case PAGE_CONSUMER: - if (event.pressed) { - host_consumer_send(action.usage.code); - } else { - host_consumer_send(0); - } + host_consumer_send(event.pressed ? action.usage.code : 0); break; } break; @@ -852,9 +844,9 @@ void process_action(keyrecord_t *record, action_t action) { __attribute__((weak)) void register_code(uint8_t code) { if (code == KC_NO) { return; - } + #ifdef LOCKING_SUPPORT_ENABLE - else if (KC_LOCKING_CAPS_LOCK == code) { + } else if (KC_LOCKING_CAPS_LOCK == code) { # ifdef LOCKING_RESYNC_ENABLE // Resync: ignore if caps lock already is on if (host_keyboard_leds() & (1 << USB_LED_CAPS_LOCK)) return; @@ -864,9 +856,8 @@ __attribute__((weak)) void register_code(uint8_t code) { wait_ms(TAP_HOLD_CAPS_DELAY); del_key(KC_CAPS_LOCK); send_keyboard_report(); - } - else if (KC_LOCKING_NUM_LOCK == code) { + } else if (KC_LOCKING_NUM_LOCK == code) { # ifdef LOCKING_RESYNC_ENABLE if (host_keyboard_leds() & (1 << USB_LED_NUM_LOCK)) return; # endif @@ -875,9 +866,8 @@ __attribute__((weak)) void register_code(uint8_t code) { wait_ms(100); del_key(KC_NUM_LOCK); send_keyboard_report(); - } - else if (KC_LOCKING_SCROLL_LOCK == code) { + } else if (KC_LOCKING_SCROLL_LOCK == code) { # ifdef LOCKING_RESYNC_ENABLE if (host_keyboard_leds() & (1 << USB_LED_SCROLL_LOCK)) return; # endif @@ -886,10 +876,9 @@ __attribute__((weak)) void register_code(uint8_t code) { wait_ms(100); del_key(KC_SCROLL_LOCK); send_keyboard_report(); - } #endif - else if IS_KEY (code) { + } else if IS_KEY (code) { // TODO: should push command_proc out of this block? if (command_proc(code)) return; @@ -922,15 +911,15 @@ __attribute__((weak)) void register_code(uint8_t code) { } else if IS_MOD (code) { add_mods(MOD_BIT(code)); send_keyboard_report(); - } + #ifdef EXTRAKEY_ENABLE - else if IS_SYSTEM (code) { + } else if IS_SYSTEM (code) { host_system_send(KEYCODE2SYSTEM(code)); } else if IS_CONSUMER (code) { host_consumer_send(KEYCODE2CONSUMER(code)); - } #endif - else if IS_MOUSEKEY (code) { + + } else if IS_MOUSEKEY (code) { register_mouse(code, true); } } @@ -942,9 +931,9 @@ __attribute__((weak)) void register_code(uint8_t code) { __attribute__((weak)) void unregister_code(uint8_t code) { if (code == KC_NO) { return; - } + #ifdef LOCKING_SUPPORT_ENABLE - else if (KC_LOCKING_CAPS_LOCK == code) { + } else if (KC_LOCKING_CAPS_LOCK == code) { # ifdef LOCKING_RESYNC_ENABLE // Resync: ignore if caps lock already is off if (!(host_keyboard_leds() & (1 << USB_LED_CAPS_LOCK))) return; @@ -953,9 +942,8 @@ __attribute__((weak)) void unregister_code(uint8_t code) { send_keyboard_report(); del_key(KC_CAPS_LOCK); send_keyboard_report(); - } - else if (KC_LOCKING_NUM_LOCK == code) { + } else if (KC_LOCKING_NUM_LOCK == code) { # ifdef LOCKING_RESYNC_ENABLE if (!(host_keyboard_leds() & (1 << USB_LED_NUM_LOCK))) return; # endif @@ -963,9 +951,8 @@ __attribute__((weak)) void unregister_code(uint8_t code) { send_keyboard_report(); del_key(KC_NUM_LOCK); send_keyboard_report(); - } - else if (KC_LOCKING_SCROLL_LOCK == code) { + } else if (KC_LOCKING_SCROLL_LOCK == code) { # ifdef LOCKING_RESYNC_ENABLE if (!(host_keyboard_leds() & (1 << USB_LED_SCROLL_LOCK))) return; # endif @@ -973,19 +960,22 @@ __attribute__((weak)) void unregister_code(uint8_t code) { send_keyboard_report(); del_key(KC_SCROLL_LOCK); send_keyboard_report(); - } #endif - else if IS_KEY (code) { + } else if IS_KEY (code) { del_key(code); send_keyboard_report(); } else if IS_MOD (code) { del_mods(MOD_BIT(code)); send_keyboard_report(); + +#ifdef EXTRAKEY_ENABLE } else if IS_SYSTEM (code) { host_system_send(0); } else if IS_CONSUMER (code) { host_consumer_send(0); +#endif + } else if IS_MOUSEKEY (code) { register_mouse(code, false); } diff --git a/quantum/action_code.h b/quantum/action_code.h index e107f0a740..14cfd025f1 100644 --- a/quantum/action_code.h +++ b/quantum/action_code.h @@ -192,7 +192,11 @@ enum mods_codes { /** \brief Other Keys */ -enum usage_pages { PAGE_SYSTEM, PAGE_CONSUMER }; +enum usage_pages { + PAGE_SYSTEM, + PAGE_CONSUMER, +}; + #define ACTION_USAGE_SYSTEM(id) ACTION(ACT_USAGE, PAGE_SYSTEM << 10 | (id)) #define ACTION_USAGE_CONSUMER(id) ACTION(ACT_USAGE, PAGE_CONSUMER << 10 | (id)) #define ACTION_MOUSEKEY(key) ACTION(ACT_MOUSEKEY, key) -- cgit v1.2.3 From e78fa1fbf00fed10399b70c212f00668d7745b17 Mon Sep 17 00:00:00 2001 From: precondition <57645186+precondition@users.noreply.github.com> Date: Sat, 1 Oct 2022 10:52:46 +0200 Subject: Fix comment of CM_QUES (Colemak question mark) (#18557) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `#define CM_QUES S(CM_SLSH) // /` → `#define CM_QUES S(CM_SLSH) // ?` --- quantum/keymap_extras/keymap_colemak.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'quantum') diff --git a/quantum/keymap_extras/keymap_colemak.h b/quantum/keymap_extras/keymap_colemak.h index 6658cc1301..e7b5c97ccb 100644 --- a/quantum/keymap_extras/keymap_colemak.h +++ b/quantum/keymap_extras/keymap_colemak.h @@ -122,4 +122,4 @@ // Row 4 #define CM_LABK S(CM_COMM) // < #define CM_RABK S(CM_DOT) // > -#define CM_QUES S(CM_SLSH) // / +#define CM_QUES S(CM_SLSH) // ? -- cgit v1.2.3 From c0e6a28bc62f659b0564a203df670d81a89a3bb4 Mon Sep 17 00:00:00 2001 From: Jason Ken Adhinarta <35003073+jasonkena@users.noreply.github.com> Date: Mon, 3 Oct 2022 03:26:47 -0400 Subject: Prevent tap dance from wiping dynamic macros (#17880) --- quantum/process_keycode/process_dynamic_macro.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'quantum') diff --git a/quantum/process_keycode/process_dynamic_macro.c b/quantum/process_keycode/process_dynamic_macro.c index a7555fdd40..41207092a9 100644 --- a/quantum/process_keycode/process_dynamic_macro.c +++ b/quantum/process_keycode/process_dynamic_macro.c @@ -45,6 +45,10 @@ __attribute__((weak)) void dynamic_macro_record_end_user(int8_t direction) { dynamic_macro_led_blink(); } +__attribute__((weak)) bool dynamic_macro_valid_key_user(uint16_t keycode, keyrecord_t *record) { + return true; +} + /* Convenience macros used for retrieving the debug info. All of them * need a `direction` variable accessible at the call site. */ @@ -252,14 +256,16 @@ bool process_dynamic_macro(uint16_t keycode, keyrecord_t *record) { return false; #endif default: - /* Store the key in the macro buffer and process it normally. */ - switch (macro_id) { - case 1: - dynamic_macro_record_key(macro_buffer, ¯o_pointer, r_macro_end, +1, record); - break; - case 2: - dynamic_macro_record_key(r_macro_buffer, ¯o_pointer, macro_end, -1, record); - break; + if (dynamic_macro_valid_key_user(keycode, record)) { + /* Store the key in the macro buffer and process it normally. */ + switch (macro_id) { + case 1: + dynamic_macro_record_key(macro_buffer, ¯o_pointer, r_macro_end, +1, record); + break; + case 2: + dynamic_macro_record_key(r_macro_buffer, ¯o_pointer, macro_end, -1, record); + break; + } } return true; break; -- cgit v1.2.3 From ca0c12847a97a62f887fd4625673395104a7257b Mon Sep 17 00:00:00 2001 From: Sergey Vlasov Date: Mon, 3 Oct 2022 12:48:16 +0300 Subject: Fix layer switching from tap dances by redoing the keymap lookup (#17935) --- quantum/process_keycode/process_tap_dance.c | 12 +++++++++--- quantum/process_keycode/process_tap_dance.h | 2 +- quantum/quantum.c | 6 +++++- 3 files changed, 15 insertions(+), 5 deletions(-) (limited to 'quantum') diff --git a/quantum/process_keycode/process_tap_dance.c b/quantum/process_keycode/process_tap_dance.c index 3270a1b000..6e8e596673 100644 --- a/quantum/process_keycode/process_tap_dance.c +++ b/quantum/process_keycode/process_tap_dance.c @@ -115,12 +115,12 @@ static inline void process_tap_dance_action_on_dance_finished(qk_tap_dance_actio } } -void preprocess_tap_dance(uint16_t keycode, keyrecord_t *record) { +bool preprocess_tap_dance(uint16_t keycode, keyrecord_t *record) { qk_tap_dance_action_t *action; - if (!record->event.pressed) return; + if (!record->event.pressed) return false; - if (!active_td || keycode == active_td) return; + if (!active_td || keycode == active_td) return false; action = &tap_dance_actions[TD_INDEX(active_td)]; action->state.interrupted = true; @@ -130,6 +130,12 @@ void preprocess_tap_dance(uint16_t keycode, keyrecord_t *record) { // Tap dance actions can leave some weak mods active (e.g., if the tap dance is mapped to a keycode with // modifiers), but these weak mods should not affect the keypress which interrupted the tap dance. clear_weak_mods(); + + // Signal that a tap dance has been finished due to being interrupted, + // therefore the keymap lookup for the currently processed event needs to + // be repeated with the current layer state that might have been updated by + // the finished tap dance. + return true; } bool process_tap_dance(uint16_t keycode, keyrecord_t *record) { diff --git a/quantum/process_keycode/process_tap_dance.h b/quantum/process_keycode/process_tap_dance.h index d97900d96b..d6d6c136dc 100644 --- a/quantum/process_keycode/process_tap_dance.h +++ b/quantum/process_keycode/process_tap_dance.h @@ -81,7 +81,7 @@ void reset_tap_dance(qk_tap_dance_state_t *state); /* To be used internally */ -void preprocess_tap_dance(uint16_t keycode, keyrecord_t *record); +bool preprocess_tap_dance(uint16_t keycode, keyrecord_t *record); bool process_tap_dance(uint16_t keycode, keyrecord_t *record); void tap_dance_task(void); diff --git a/quantum/quantum.c b/quantum/quantum.c index ff36e14775..5b5364c8f1 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -251,7 +251,11 @@ bool process_record_quantum(keyrecord_t *record) { #endif #ifdef TAP_DANCE_ENABLE - preprocess_tap_dance(keycode, record); + if (preprocess_tap_dance(keycode, record)) { + // The tap dance might have updated the layer state, therefore the + // result of the keycode lookup might change. + keycode = get_record_keycode(record, true); + } #endif if (!( -- cgit v1.2.3 From 56f7b34289e7f80ac540a7c9c01a5c3a3838cd7c Mon Sep 17 00:00:00 2001 From: Stefan Kerkmann Date: Tue, 4 Oct 2022 20:49:29 +0200 Subject: [Core] rewrite locking in split transaction handlers (#18417) --- quantum/split_common/transactions.c | 121 ++++++++++++++++++++++++++---------- 1 file changed, 88 insertions(+), 33 deletions(-) (limited to 'quantum') diff --git a/quantum/split_common/transactions.c b/quantum/split_common/transactions.c index 719068908f..13fd8a761e 100644 --- a/quantum/split_common/transactions.c +++ b/quantum/split_common/transactions.c @@ -76,7 +76,26 @@ static bool transaction_handler_master(matrix_row_t master_matrix[], matrix_row_ if (!transaction_handler_master(master_matrix, slave_matrix, #prefix, &prefix##_handlers_master)) return false; \ } while (0) +/** + * @brief Constructs a transaction handler that doesn't acquire a lock to the + * split shared memory. Therefore the locking and unlocking has to be done + * manually inside the handler. Use this macro only if the handler is + * non-deterministic in runtime and thus needs a manual lock unlock + * implementation to hold the lock for the shortest possible time. + */ #define TRANSACTION_HANDLER_SLAVE(prefix) \ + do { \ + prefix##_handlers_slave(master_matrix, slave_matrix); \ + } while (0) + +/** + * @brief Constructs a transaction handler that automatically acquires a lock to + * safely access the split shared memory and releases the lock again after + * processing the handler. Use this macro if the handler is fast and + * deterministic in runtime and thus holds the lock only for a very short time. + * If not fallback to manually locking and unlocking inside the handler. + */ +#define TRANSACTION_HANDLER_SLAVE_AUTOLOCK(prefix) \ do { \ split_shared_memory_lock(); \ prefix##_handlers_slave(master_matrix, slave_matrix); \ @@ -139,7 +158,7 @@ static void slave_matrix_handlers_slave(matrix_row_t master_matrix[], matrix_row // clang-format off #define TRANSACTIONS_SLAVE_MATRIX_MASTER() TRANSACTION_HANDLER_MASTER(slave_matrix) -#define TRANSACTIONS_SLAVE_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(slave_matrix) +#define TRANSACTIONS_SLAVE_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE_AUTOLOCK(slave_matrix) #define TRANSACTIONS_SLAVE_MATRIX_REGISTRATIONS \ [GET_SLAVE_MATRIX_CHECKSUM] = trans_target2initiator_initializer(smatrix.checksum), \ [GET_SLAVE_MATRIX_DATA] = trans_target2initiator_initializer(smatrix.matrix), @@ -161,7 +180,7 @@ static void master_matrix_handlers_slave(matrix_row_t master_matrix[], matrix_ro } # define TRANSACTIONS_MASTER_MATRIX_MASTER() TRANSACTION_HANDLER_MASTER(master_matrix) -# define TRANSACTIONS_MASTER_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(master_matrix) +# define TRANSACTIONS_MASTER_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE_AUTOLOCK(master_matrix) # define TRANSACTIONS_MASTER_MATRIX_REGISTRATIONS [PUT_MASTER_MATRIX] = trans_initiator2target_initializer(mmatrix.matrix), #else // SPLIT_TRANSPORT_MIRROR @@ -197,7 +216,7 @@ static void encoder_handlers_slave(matrix_row_t master_matrix[], matrix_row_t sl // clang-format off # define TRANSACTIONS_ENCODERS_MASTER() TRANSACTION_HANDLER_MASTER(encoder) -# define TRANSACTIONS_ENCODERS_SLAVE() TRANSACTION_HANDLER_SLAVE(encoder) +# define TRANSACTIONS_ENCODERS_SLAVE() TRANSACTION_HANDLER_SLAVE_AUTOLOCK(encoder) # define TRANSACTIONS_ENCODERS_REGISTRATIONS \ [GET_ENCODERS_CHECKSUM] = trans_target2initiator_initializer(encoders.checksum), \ [GET_ENCODERS_DATA] = trans_target2initiator_initializer(encoders.state), @@ -239,7 +258,7 @@ static void sync_timer_handlers_slave(matrix_row_t master_matrix[], matrix_row_t } # define TRANSACTIONS_SYNC_TIMER_MASTER() TRANSACTION_HANDLER_MASTER(sync_timer) -# define TRANSACTIONS_SYNC_TIMER_SLAVE() TRANSACTION_HANDLER_SLAVE(sync_timer) +# define TRANSACTIONS_SYNC_TIMER_SLAVE() TRANSACTION_HANDLER_SLAVE_AUTOLOCK(sync_timer) # define TRANSACTIONS_SYNC_TIMER_REGISTRATIONS [PUT_SYNC_TIMER] = trans_initiator2target_initializer(sync_timer), #else // DISABLE_SYNC_TIMER @@ -273,7 +292,7 @@ static void layer_state_handlers_slave(matrix_row_t master_matrix[], matrix_row_ // clang-format off # define TRANSACTIONS_LAYER_STATE_MASTER() TRANSACTION_HANDLER_MASTER(layer_state) -# define TRANSACTIONS_LAYER_STATE_SLAVE() TRANSACTION_HANDLER_SLAVE(layer_state) +# define TRANSACTIONS_LAYER_STATE_SLAVE() TRANSACTION_HANDLER_SLAVE_AUTOLOCK(layer_state) # define TRANSACTIONS_LAYER_STATE_REGISTRATIONS \ [PUT_LAYER_STATE] = trans_initiator2target_initializer(layers.layer_state), \ [PUT_DEFAULT_LAYER_STATE] = trans_initiator2target_initializer(layers.default_layer_state), @@ -304,7 +323,7 @@ static void led_state_handlers_slave(matrix_row_t master_matrix[], matrix_row_t } # define TRANSACTIONS_LED_STATE_MASTER() TRANSACTION_HANDLER_MASTER(led_state) -# define TRANSACTIONS_LED_STATE_SLAVE() TRANSACTION_HANDLER_SLAVE(led_state) +# define TRANSACTIONS_LED_STATE_SLAVE() TRANSACTION_HANDLER_SLAVE_AUTOLOCK(led_state) # define TRANSACTIONS_LED_STATE_REGISTRATIONS [PUT_LED_STATE] = trans_initiator2target_initializer(led_state), #else // SPLIT_LED_STATE_ENABLE @@ -353,10 +372,15 @@ static bool mods_handlers_master(matrix_row_t master_matrix[], matrix_row_t slav } static void mods_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { - set_mods(split_shmem->mods.real_mods); - set_weak_mods(split_shmem->mods.weak_mods); + split_shared_memory_lock(); + split_mods_sync_t mods; + memcpy(&mods, &split_shmem->mods, sizeof(split_mods_sync_t)); + split_shared_memory_unlock(); + + set_mods(mods.real_mods); + set_weak_mods(mods.weak_mods); # ifndef NO_ACTION_ONESHOT - set_oneshot_mods(split_shmem->mods.oneshot_mods); + set_oneshot_mods(mods.oneshot_mods); # endif } @@ -384,7 +408,11 @@ static bool backlight_handlers_master(matrix_row_t master_matrix[], matrix_row_t } static void backlight_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { - backlight_set(split_shmem->backlight_level); + split_shared_memory_lock(); + uint8_t backlight_level = split_shmem->backlight_level; + split_shared_memory_unlock(); + + backlight_set(backlight_level); } # define TRANSACTIONS_BACKLIGHT_MASTER() TRANSACTION_HANDLER_MASTER(backlight) @@ -417,10 +445,15 @@ static bool rgblight_handlers_master(matrix_row_t master_matrix[], matrix_row_t } static void rgblight_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { + split_shared_memory_lock(); // Update the RGB with the new data - if (split_shmem->rgblight_sync.status.change_flags != 0) { - rgblight_update_sync(&split_shmem->rgblight_sync, false); - split_shmem->rgblight_sync.status.change_flags = 0; + rgblight_syncinfo_t rgblight_sync; + memcpy(&rgblight_sync, &split_shmem->rgblight_sync, sizeof(rgblight_syncinfo_t)); + split_shmem->rgblight_sync.status.change_flags = 0; + split_shared_memory_unlock(); + + if (rgblight_sync.status.change_flags != 0) { + rgblight_update_sync(&rgblight_sync, false); } } @@ -450,8 +483,12 @@ static bool led_matrix_handlers_master(matrix_row_t master_matrix[], matrix_row_ } static void led_matrix_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { + split_shared_memory_lock(); memcpy(&led_matrix_eeconfig, &split_shmem->led_matrix_sync.led_matrix, sizeof(led_eeconfig_t)); - led_matrix_set_suspend_state(split_shmem->led_matrix_sync.led_suspend_state); + bool led_suspend_state = split_shmem->led_matrix_sync.led_suspend_state; + split_shared_memory_unlock(); + + led_matrix_set_suspend_state(led_suspend_state); } # define TRANSACTIONS_LED_MATRIX_MASTER() TRANSACTION_HANDLER_MASTER(led_matrix) @@ -480,8 +517,12 @@ static bool rgb_matrix_handlers_master(matrix_row_t master_matrix[], matrix_row_ } static void rgb_matrix_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { + split_shared_memory_lock(); memcpy(&rgb_matrix_config, &split_shmem->rgb_matrix_sync.rgb_matrix, sizeof(rgb_config_t)); - rgb_matrix_set_suspend_state(split_shmem->rgb_matrix_sync.rgb_suspend_state); + bool rgb_suspend_state = split_shmem->rgb_matrix_sync.rgb_suspend_state; + split_shared_memory_unlock(); + + rgb_matrix_set_suspend_state(rgb_suspend_state); } # define TRANSACTIONS_RGB_MATRIX_MASTER() TRANSACTION_HANDLER_MASTER(rgb_matrix) @@ -512,7 +553,7 @@ static void wpm_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_ } # define TRANSACTIONS_WPM_MASTER() TRANSACTION_HANDLER_MASTER(wpm) -# define TRANSACTIONS_WPM_SLAVE() TRANSACTION_HANDLER_SLAVE(wpm) +# define TRANSACTIONS_WPM_SLAVE() TRANSACTION_HANDLER_SLAVE_AUTOLOCK(wpm) # define TRANSACTIONS_WPM_REGISTRATIONS [PUT_WPM] = trans_initiator2target_initializer(current_wpm), #else // defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE) @@ -535,7 +576,11 @@ static bool oled_handlers_master(matrix_row_t master_matrix[], matrix_row_t slav } static void oled_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { - if (split_shmem->current_oled_state) { + split_shared_memory_lock(); + uint8_t current_oled_state = split_shmem->current_oled_state; + split_shared_memory_unlock(); + + if (current_oled_state) { oled_on(); } else { oled_off(); @@ -566,7 +611,11 @@ static bool st7565_handlers_master(matrix_row_t master_matrix[], matrix_row_t sl } static void st7565_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { - if (split_shmem->current_st7565_state) { + split_shared_memory_lock(); + uint8_t current_st7565_state = split_shmem->current_st7565_state; + split_shared_memory_unlock(); + + if (current_st7565_state) { st7565_on(); } else { st7565_off(); @@ -574,7 +623,7 @@ static void st7565_handlers_slave(matrix_row_t master_matrix[], matrix_row_t sla } # define TRANSACTIONS_ST7565_MASTER() TRANSACTION_HANDLER_MASTER(st7565) -# define TRANSACTIONS_ST7565_SLAVE() TRANSACTION_HANDLER_SLAVE(st7565) +# define TRANSACTIONS_ST7565_SLAVE() TRANSACTION_HANDLER_SLAVE_AUTOLOCK(st7565) # define TRANSACTIONS_ST7565_REGISTRATIONS [PUT_ST7565] = trans_initiator2target_initializer(current_st7565_state), #else // defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE) @@ -607,9 +656,9 @@ static bool pointing_handlers_master(matrix_row_t master_matrix[], matrix_row_t bool okay = read_if_checksum_mismatch(GET_POINTING_CHECKSUM, GET_POINTING_DATA, &last_update, &temp_state, &split_shmem->pointing.report, sizeof(temp_state)); if (okay) pointing_device_set_shared_report(temp_state); temp_cpi = pointing_device_get_shared_cpi(); - if (temp_cpi && memcmp(&last_cpi, &temp_cpi, sizeof(temp_cpi)) != 0) { - memcpy(&split_shmem->pointing.cpi, &temp_cpi, sizeof(temp_cpi)); - okay = transport_write(PUT_POINTING_CPI, &split_shmem->pointing.cpi, sizeof(split_shmem->pointing.cpi)); + if (temp_cpi && last_cpi != temp_cpi) { + split_shmem->pointing.cpi = temp_cpi; + okay = transport_write(PUT_POINTING_CPI, &split_shmem->pointing.cpi, sizeof(split_shmem->pointing.cpi)); if (okay) { last_cpi = temp_cpi; } @@ -629,8 +678,6 @@ static void pointing_handlers_slave(matrix_row_t master_matrix[], matrix_row_t s return; } # endif - report_mouse_t temp_report; - uint16_t temp_cpi; # if (POINTING_DEVICE_TASK_THROTTLE_MS > 0) static uint32_t last_exec = 0; if (timer_elapsed32(last_exec) < POINTING_DEVICE_TASK_THROTTLE_MS) { @@ -638,17 +685,25 @@ static void pointing_handlers_slave(matrix_row_t master_matrix[], matrix_row_t s } last_exec = timer_read32(); # endif - temp_cpi = !pointing_device_driver.get_cpi ? 0 : pointing_device_driver.get_cpi(); // check for NULL - if (split_shmem->pointing.cpi && memcmp(&split_shmem->pointing.cpi, &temp_cpi, sizeof(temp_cpi)) != 0) { - if (pointing_device_driver.set_cpi) { - pointing_device_driver.set_cpi(split_shmem->pointing.cpi); - } + + uint16_t temp_cpi = !pointing_device_driver.get_cpi ? 0 : pointing_device_driver.get_cpi(); // check for NULL + + split_shared_memory_lock(); + split_slave_pointing_sync_t pointing; + memcpy(&pointing, &split_shmem->pointing, sizeof(split_slave_pointing_sync_t)); + split_shared_memory_unlock(); + + if (pointing.cpi && pointing.cpi != temp_cpi && pointing_device_driver.set_cpi) { + pointing_device_driver.set_cpi(pointing.cpi); } - memset(&temp_report, 0, sizeof(temp_report)); - temp_report = pointing_device_driver.get_report(temp_report); - memcpy(&split_shmem->pointing.report, &temp_report, sizeof(temp_report)); + + pointing.report = pointing_device_driver.get_report((report_mouse_t){0}); // Now update the checksum given that the pointing has been written to - split_shmem->pointing.checksum = crc8(&temp_report, sizeof(temp_report)); + pointing.checksum = crc8(&pointing.report, sizeof(report_mouse_t)); + + split_shared_memory_lock(); + memcpy(&split_shmem->pointing, &pointing, sizeof(split_slave_pointing_sync_t)); + split_shared_memory_unlock(); } # define TRANSACTIONS_POINTING_MASTER() TRANSACTION_HANDLER_MASTER(pointing) -- cgit v1.2.3 From 996a9006d3f101dc5c48b58339e2e7323040fd59 Mon Sep 17 00:00:00 2001 From: Stefan Kerkmann Date: Tue, 4 Oct 2022 23:10:24 +0200 Subject: [Core] PWM Backlight for RP2040 (#17706) --- quantum/backlight/backlight_chibios.c | 51 ++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 21 deletions(-) (limited to 'quantum') diff --git a/quantum/backlight/backlight_chibios.c b/quantum/backlight/backlight_chibios.c index e8f9e70f78..30e95bd5c8 100644 --- a/quantum/backlight/backlight_chibios.c +++ b/quantum/backlight/backlight_chibios.c @@ -40,16 +40,22 @@ # endif #endif -static PWMConfig pwmCFG = {0xFFFF, /* PWM clock frequency */ - 256, /* PWM period (in ticks) 1S (1/10kHz=0.1mS 0.1ms*10000 ticks=1S) */ - NULL, /* Breathing Callback */ - { /* Default all channels to disabled - Channels will be configured durring init */ - {PWM_OUTPUT_DISABLED, NULL}, - {PWM_OUTPUT_DISABLED, NULL}, - {PWM_OUTPUT_DISABLED, NULL}, - {PWM_OUTPUT_DISABLED, NULL}}, - 0, /* HW dependent part.*/ - 0}; +#ifndef BACKLIGHT_PWM_COUNTER_FREQUENCY +# define BACKLIGHT_PWM_COUNTER_FREQUENCY 0xFFFF +#endif + +#ifndef BACKLIGHT_PWM_PERIOD +# define BACKLIGHT_PWM_PERIOD 256 +#endif + +static PWMConfig pwmCFG = { + .frequency = BACKLIGHT_PWM_COUNTER_FREQUENCY, /* PWM clock frequency */ + .period = BACKLIGHT_PWM_PERIOD, /* PWM period in counter ticks. e.g. clock frequency is 10KHz, period is 256 ticks then t_period is 25.6ms */ +}; + +#ifdef BACKLIGHT_BREATHING +static virtual_timer_t breathing_vt; +#endif // See http://jared.geek.nz/2013/feb/linear-led-pwm static uint16_t cie_lightness(uint16_t v) { @@ -60,10 +66,11 @@ static uint16_t cie_lightness(uint16_t v) { // to get a useful result with integer division, we shift left in the expression above // and revert what we've done again after squaring. y = y * y * y >> 8; - if (y > 0xFFFFUL) // prevent overflow + if (y > 0xFFFFUL) { // prevent overflow return 0xFFFFU; - else + } else { return (uint16_t)y; + } } } @@ -85,6 +92,7 @@ void backlight_init_ports(void) { backlight_set(get_backlight_level()); #ifdef BACKLIGHT_BREATHING + chVTObjectInit(&breathing_vt); if (is_backlight_breathing()) { breathing_enable(); } @@ -92,7 +100,9 @@ void backlight_init_ports(void) { } void backlight_set(uint8_t level) { - if (level > BACKLIGHT_LEVELS) level = BACKLIGHT_LEVELS; + if (level > BACKLIGHT_LEVELS) { + level = BACKLIGHT_LEVELS; + } if (level == 0) { // Turn backlight off @@ -115,20 +125,19 @@ void backlight_task(void) {} */ static const uint8_t breathing_table[BREATHING_STEPS] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 17, 20, 24, 28, 32, 36, 41, 46, 51, 57, 63, 70, 76, 83, 91, 98, 106, 113, 121, 129, 138, 146, 154, 162, 170, 178, 185, 193, 200, 207, 213, 220, 225, 231, 235, 240, 244, 247, 250, 252, 253, 254, 255, 254, 253, 252, 250, 247, 244, 240, 235, 231, 225, 220, 213, 207, 200, 193, 185, 178, 170, 162, 154, 146, 138, 129, 121, 113, 106, 98, 91, 83, 76, 70, 63, 57, 51, 46, 41, 36, 32, 28, 24, 20, 17, 15, 12, 10, 8, 6, 5, 4, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -void breathing_callback(PWMDriver *pwmp); +static void breathing_callback(virtual_timer_t *vtp, void *p); bool is_breathing(void) { - return pwmCFG.callback != NULL; + return chVTIsArmed(&breathing_vt); } void breathing_enable(void) { - pwmCFG.callback = breathing_callback; - pwmEnablePeriodicNotification(&BACKLIGHT_PWM_DRIVER); + /* Update frequency is 256Hz -> 3906us intervals */ + chVTSetContinuous(&breathing_vt, TIME_US2I(3906), breathing_callback, NULL); } void breathing_disable(void) { - pwmCFG.callback = NULL; - pwmDisablePeriodicNotification(&BACKLIGHT_PWM_DRIVER); + chVTReset(&breathing_vt); // Restore backlight level backlight_set(get_backlight_level()); @@ -139,7 +148,7 @@ static inline uint16_t scale_backlight(uint16_t v) { return v / BACKLIGHT_LEVELS * get_backlight_level(); } -void breathing_callback(PWMDriver *pwmp) { +static void breathing_callback(virtual_timer_t *vtp, void *p) { uint8_t breathing_period = get_breathing_period(); uint16_t interval = (uint16_t)breathing_period * 256 / BREATHING_STEPS; @@ -150,7 +159,7 @@ void breathing_callback(PWMDriver *pwmp) { uint32_t duty = cie_lightness(rescale_limit_val(scale_backlight(breathing_table[index] * 256))); chSysLockFromISR(); - pwmEnableChannelI(pwmp, BACKLIGHT_PWM_CHANNEL - 1, PWM_FRACTION_TO_WIDTH(&BACKLIGHT_PWM_DRIVER, 0xFFFF, duty)); + pwmEnableChannelI(&BACKLIGHT_PWM_DRIVER, BACKLIGHT_PWM_CHANNEL - 1, PWM_FRACTION_TO_WIDTH(&BACKLIGHT_PWM_DRIVER, 0xFFFF, duty)); chSysUnlockFromISR(); } -- cgit v1.2.3 From 64b1ed45507a15d5594b1f90b936c2096918f5a4 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Tue, 4 Oct 2022 15:24:22 -0700 Subject: Fix Per Key LED Indicator Callbacks (#18450) Co-authored-by: Dasky <32983009+daskygit@users.noreply.github.com> Co-authored-by: Nick Brassel --- quantum/led_matrix/led_matrix.c | 16 ++++++++++++---- quantum/led_matrix/led_matrix.h | 8 ++++---- quantum/rgb_matrix/rgb_matrix.c | 18 ++++++++++++------ quantum/rgb_matrix/rgb_matrix.h | 8 ++++---- 4 files changed, 32 insertions(+), 18 deletions(-) (limited to 'quantum') diff --git a/quantum/led_matrix/led_matrix.c b/quantum/led_matrix/led_matrix.c index c26b1ad19b..e215c2c2c3 100644 --- a/quantum/led_matrix/led_matrix.c +++ b/quantum/led_matrix/led_matrix.c @@ -385,9 +385,13 @@ void led_matrix_indicators(void) { led_matrix_indicators_user(); } -__attribute__((weak)) void led_matrix_indicators_kb(void) {} +__attribute__((weak)) bool led_matrix_indicators_kb(void) { + return led_matrix_indicators_user(); +} -__attribute__((weak)) void led_matrix_indicators_user(void) {} +__attribute__((weak)) bool led_matrix_indicators_user(void) { + return true; +} void led_matrix_indicators_advanced(effect_params_t *params) { /* special handling is needed for "params->iter", since it's already been incremented. @@ -407,9 +411,13 @@ void led_matrix_indicators_advanced(effect_params_t *params) { led_matrix_indicators_advanced_user(min, max); } -__attribute__((weak)) void led_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) {} +__attribute__((weak)) bool led_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) { + return led_matrix_indicators_advanced_user(led_min, led_max); +} -__attribute__((weak)) void led_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {} +__attribute__((weak)) bool led_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { + return true; +} void led_matrix_init(void) { led_matrix_driver.init(); diff --git a/quantum/led_matrix/led_matrix.h b/quantum/led_matrix/led_matrix.h index db4f223d5b..c7d360f366 100644 --- a/quantum/led_matrix/led_matrix.h +++ b/quantum/led_matrix/led_matrix.h @@ -120,12 +120,12 @@ void led_matrix_task(void); // This runs after another backlight effect and replaces // values already set void led_matrix_indicators(void); -void led_matrix_indicators_kb(void); -void led_matrix_indicators_user(void); +bool led_matrix_indicators_kb(void); +bool led_matrix_indicators_user(void); void led_matrix_indicators_advanced(effect_params_t *params); -void led_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max); -void led_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max); +bool led_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max); +bool led_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max); void led_matrix_init(void); diff --git a/quantum/rgb_matrix/rgb_matrix.c b/quantum/rgb_matrix/rgb_matrix.c index 8b335c017d..539ca0e100 100644 --- a/quantum/rgb_matrix/rgb_matrix.c +++ b/quantum/rgb_matrix/rgb_matrix.c @@ -444,12 +444,15 @@ void rgb_matrix_task(void) { void rgb_matrix_indicators(void) { rgb_matrix_indicators_kb(); - rgb_matrix_indicators_user(); } -__attribute__((weak)) void rgb_matrix_indicators_kb(void) {} +__attribute__((weak)) bool rgb_matrix_indicators_kb(void) { + return rgb_matrix_indicators_user(); +} -__attribute__((weak)) void rgb_matrix_indicators_user(void) {} +__attribute__((weak)) bool rgb_matrix_indicators_user(void) { + return true; +} void rgb_matrix_indicators_advanced(effect_params_t *params) { /* special handling is needed for "params->iter", since it's already been incremented. @@ -466,12 +469,15 @@ void rgb_matrix_indicators_advanced(effect_params_t *params) { uint8_t max = RGB_MATRIX_LED_COUNT; #endif rgb_matrix_indicators_advanced_kb(min, max); - rgb_matrix_indicators_advanced_user(min, max); } -__attribute__((weak)) void rgb_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) {} +__attribute__((weak)) bool rgb_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) { + return rgb_matrix_indicators_advanced_user(led_min, led_max); +} -__attribute__((weak)) void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {} +__attribute__((weak)) bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { + return true; +} void rgb_matrix_init(void) { rgb_matrix_driver.init(); diff --git a/quantum/rgb_matrix/rgb_matrix.h b/quantum/rgb_matrix/rgb_matrix.h index 0b35e98f45..1cd054abc4 100644 --- a/quantum/rgb_matrix/rgb_matrix.h +++ b/quantum/rgb_matrix/rgb_matrix.h @@ -129,12 +129,12 @@ void rgb_matrix_task(void); // This runs after another backlight effect and replaces // colors already set void rgb_matrix_indicators(void); -void rgb_matrix_indicators_kb(void); -void rgb_matrix_indicators_user(void); +bool rgb_matrix_indicators_kb(void); +bool rgb_matrix_indicators_user(void); void rgb_matrix_indicators_advanced(effect_params_t *params); -void rgb_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max); -void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max); +bool rgb_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max); +bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max); void rgb_matrix_init(void); -- cgit v1.2.3 From d1b6b062024dddf047f760efbad21edb2acca394 Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 6 Oct 2022 02:21:40 +1100 Subject: Remove legacy locking caps/num/scroll keycodes (#18601) --- quantum/keycode_legacy.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'quantum') diff --git a/quantum/keycode_legacy.h b/quantum/keycode_legacy.h index 0317a05534..9169f3cb89 100644 --- a/quantum/keycode_legacy.h +++ b/quantum/keycode_legacy.h @@ -19,9 +19,6 @@ #define KC__MUTE KC_KB_MUTE #define KC__VOLUP KC_KB_VOLUME_UP #define KC__VOLDOWN KC_KB_VOLUME_DOWN -#define KC_LOCKING_CAPS KC_LOCKING_CAPS_LOCK -#define KC_LOCKING_NUM KC_LOCKING_NUM_LOCK -#define KC_LOCKING_SCROLL KC_LOCKING_SCROLL_LOCK #define KC_LANG1 KC_LANGUAGE_1 #define KC_LANG2 KC_LANGUAGE_2 #define KC_LANG3 KC_LANGUAGE_3 -- cgit v1.2.3 From c76d2074b68b1fdaa48e7af7ce93275fe418f538 Mon Sep 17 00:00:00 2001 From: Stefan Kerkmann Date: Wed, 5 Oct 2022 19:22:57 +0200 Subject: [Bug] Fix ST7565 handler deadlock (#18609) --- quantum/split_common/transactions.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'quantum') diff --git a/quantum/split_common/transactions.c b/quantum/split_common/transactions.c index 13fd8a761e..67986e4340 100644 --- a/quantum/split_common/transactions.c +++ b/quantum/split_common/transactions.c @@ -623,7 +623,7 @@ static void st7565_handlers_slave(matrix_row_t master_matrix[], matrix_row_t sla } # define TRANSACTIONS_ST7565_MASTER() TRANSACTION_HANDLER_MASTER(st7565) -# define TRANSACTIONS_ST7565_SLAVE() TRANSACTION_HANDLER_SLAVE_AUTOLOCK(st7565) +# define TRANSACTIONS_ST7565_SLAVE() TRANSACTION_HANDLER_SLAVE(st7565) # define TRANSACTIONS_ST7565_REGISTRATIONS [PUT_ST7565] = trans_initiator2target_initializer(current_st7565_state), #else // defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE) -- cgit v1.2.3 From 49030e3e5bdd412f44a886be6349ebfd2c05bbf2 Mon Sep 17 00:00:00 2001 From: precondition <57645186+precondition@users.noreply.github.com> Date: Wed, 5 Oct 2022 19:42:05 +0200 Subject: Use get_u16_str instead of snprintf in autoshift_timer_report (#18606) --- quantum/process_keycode/process_auto_shift.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'quantum') diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index 3ff188ba7e..644ad2cbaf 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c @@ -17,7 +17,6 @@ #ifdef AUTO_SHIFT_ENABLE # include -# include # include "process_auto_shift.h" # ifndef AUTO_SHIFT_DISABLED_AT_STARTUP @@ -331,11 +330,12 @@ void autoshift_disable(void) { # ifndef AUTO_SHIFT_NO_SETUP void autoshift_timer_report(void) { # ifdef SEND_STRING_ENABLE - char display[8]; - - snprintf(display, 8, "\n%d\n", autoshift_timeout); - - send_string((const char *)display); + const char *autoshift_timeout_str = get_u16_str(autoshift_timeout, ' '); + // Skip padding spaces + while (*autoshift_timeout_str == ' ') { + autoshift_timeout_str++; + } + send_string(autoshift_timeout_str); # endif } # endif -- cgit v1.2.3 From c255174cf3e55483f14351a69689e24e849445a0 Mon Sep 17 00:00:00 2001 From: Dasky <32983009+daskygit@users.noreply.github.com> Date: Thu, 6 Oct 2022 10:52:42 +0100 Subject: Implement split comms watchdog (#18599) --- quantum/keyboard.c | 4 +++ quantum/split_common/split_util.c | 43 ++++++++++++++++++++++++++++ quantum/split_common/split_util.h | 4 +++ quantum/split_common/transaction_id_define.h | 4 +++ quantum/split_common/transactions.c | 33 +++++++++++++++++++++ quantum/split_common/transport.h | 4 +++ 6 files changed, 92 insertions(+) (limited to 'quantum') diff --git a/quantum/keyboard.c b/quantum/keyboard.c index 626e0a7ee1..280532a5fd 100644 --- a/quantum/keyboard.c +++ b/quantum/keyboard.c @@ -586,6 +586,10 @@ void keyboard_task(void) { quantum_task(); +#if defined(SPLIT_WATCHDOG_ENABLE) + split_watchdog_task(); +#endif + #if defined(RGBLIGHT_ENABLE) rgblight_task(); #endif diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c index 0b3338ed6f..9f57c7b9fc 100644 --- a/quantum/split_common/split_util.c +++ b/quantum/split_common/split_util.c @@ -74,6 +74,46 @@ static inline bool usbIsActive(void) { } #endif +#if defined(SPLIT_WATCHDOG_ENABLE) +# if !defined(SPLIT_WATCHDOG_TIMEOUT) +# if defined(SPLIT_USB_TIMEOUT) +# define SPLIT_WATCHDOG_TIMEOUT (SPLIT_USB_TIMEOUT + 100) +# else +# define SPLIT_WATCHDOG_TIMEOUT 3000 +# endif +# endif +# if defined(SPLIT_USB_DETECT) +_Static_assert(SPLIT_USB_TIMEOUT < SPLIT_WATCHDOG_TIMEOUT, "SPLIT_WATCHDOG_TIMEOUT should not be below SPLIT_USB_TIMEOUT."); +# endif +_Static_assert(SPLIT_MAX_CONNECTION_ERRORS > 0, "SPLIT_WATCHDOG_ENABLE requires SPLIT_MAX_CONNECTION_ERRORS be above 0 for a functioning disconnection check."); + +static uint32_t split_watchdog_started = 0; +static bool split_watchdog_done = false; + +void split_watchdog_init(void) { + split_watchdog_started = timer_read32(); +} + +void split_watchdog_update(bool done) { + split_watchdog_done = done; +} + +bool split_watchdog_check(void) { + if (!is_transport_connected()) { + split_watchdog_done = false; + } + return split_watchdog_done; +} + +void split_watchdog_task(void) { + if (!split_watchdog_done && !is_keyboard_master()) { + if (timer_elapsed32(split_watchdog_started) > SPLIT_WATCHDOG_TIMEOUT) { + mcu_reset(); + } + } +} +#endif // defined(SPLIT_WATCHDOG_ENABLE) + #ifdef SPLIT_HAND_MATRIX_GRID void matrix_io_delay(void); @@ -179,6 +219,9 @@ void split_pre_init(void) { void split_post_init(void) { if (!is_keyboard_master()) { transport_slave_init(); +#if defined(SPLIT_WATCHDOG_ENABLE) + split_watchdog_init(); +#endif } } diff --git a/quantum/split_common/split_util.h b/quantum/split_common/split_util.h index c7eabea233..5c9a260a14 100644 --- a/quantum/split_common/split_util.h +++ b/quantum/split_common/split_util.h @@ -14,3 +14,7 @@ void split_post_init(void); bool transport_master_if_connected(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]); bool is_transport_connected(void); + +void split_watchdog_update(bool done); +void split_watchdog_task(void); +bool split_watchdog_check(void); \ No newline at end of file diff --git a/quantum/split_common/transaction_id_define.h b/quantum/split_common/transaction_id_define.h index 761a8884f4..8c19948107 100644 --- a/quantum/split_common/transaction_id_define.h +++ b/quantum/split_common/transaction_id_define.h @@ -84,6 +84,10 @@ enum serial_transaction_id { PUT_POINTING_CPI, #endif // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) +#if defined(SPLIT_WATCHDOG_ENABLE) + PUT_WATCHDOG, +#endif // defined(SPLIT_WATCHDOG_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 67986e4340..527b2f4caf 100644 --- a/quantum/split_common/transactions.c +++ b/quantum/split_common/transactions.c @@ -718,6 +718,36 @@ static void pointing_handlers_slave(matrix_row_t master_matrix[], matrix_row_t s #endif // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) +//////////////////////////////////////////////////// +// WATCHDOG + +#if defined(SPLIT_WATCHDOG_ENABLE) + +static bool watchdog_handlers_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { + bool okay = true; + if (!split_watchdog_check()) { + okay = transport_write(PUT_WATCHDOG, &okay, sizeof(okay)); + split_watchdog_update(okay); + } + return okay; +} + +static void watchdog_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { + split_watchdog_update(split_shmem->watchdog_pinged); +} + +# define TRANSACTIONS_WATCHDOG_MASTER() TRANSACTION_HANDLER_MASTER(watchdog) +# define TRANSACTIONS_WATCHDOG_SLAVE() TRANSACTION_HANDLER_SLAVE_AUTOLOCK(watchdog) +# define TRANSACTIONS_WATCHDOG_REGISTRATIONS [PUT_WATCHDOG] = trans_initiator2target_initializer(watchdog_pinged), + +#else // defined(SPLIT_WATCHDOG_ENABLE) + +# define TRANSACTIONS_WATCHDOG_MASTER() +# define TRANSACTIONS_WATCHDOG_SLAVE() +# define TRANSACTIONS_WATCHDOG_REGISTRATIONS + +#endif // defined(SPLIT_WATCHDOG_ENABLE) + //////////////////////////////////////////////////// split_transaction_desc_t split_transaction_table[NUM_TOTAL_TRANSACTIONS] = { @@ -744,6 +774,7 @@ split_transaction_desc_t split_transaction_table[NUM_TOTAL_TRANSACTIONS] = { TRANSACTIONS_OLED_REGISTRATIONS TRANSACTIONS_ST7565_REGISTRATIONS TRANSACTIONS_POINTING_REGISTRATIONS + TRANSACTIONS_WATCHDOG_REGISTRATIONS // clang-format on #if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) @@ -770,6 +801,7 @@ bool transactions_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix TRANSACTIONS_OLED_MASTER(); TRANSACTIONS_ST7565_MASTER(); TRANSACTIONS_POINTING_MASTER(); + TRANSACTIONS_WATCHDOG_MASTER(); return true; } @@ -789,6 +821,7 @@ void transactions_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[ TRANSACTIONS_OLED_SLAVE(); TRANSACTIONS_ST7565_SLAVE(); TRANSACTIONS_POINTING_SLAVE(); + TRANSACTIONS_WATCHDOG_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 06778ad14a..833633edc2 100644 --- a/quantum/split_common/transport.h +++ b/quantum/split_common/transport.h @@ -188,6 +188,10 @@ typedef struct _split_shared_memory_t { split_slave_pointing_sync_t pointing; #endif // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) +#if defined(SPLIT_WATCHDOG_ENABLE) + bool watchdog_pinged; +#endif // defined(SPLIT_WATCHDOG_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]; -- cgit v1.2.3 From cbe1c22d468d64d7a3274061ce9c2073ecb208a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Thu, 6 Oct 2022 12:24:41 +0200 Subject: quantum: led: split out led_update_ports() for customization of led behaviour (#14452) --- quantum/led.c | 48 ++++++++++++++++++++++++++---------------------- quantum/led.h | 1 + 2 files changed, 27 insertions(+), 22 deletions(-) (limited to 'quantum') diff --git a/quantum/led.c b/quantum/led.c index 444d38f751..7db38bb88c 100644 --- a/quantum/led.c +++ b/quantum/led.c @@ -92,32 +92,36 @@ __attribute__((weak)) bool led_update_user(led_t led_state) { __attribute__((weak)) bool led_update_kb(led_t led_state) { bool res = led_update_user(led_state); if (res) { -#if defined(LED_NUM_LOCK_PIN) || defined(LED_CAPS_LOCK_PIN) || defined(LED_SCROLL_LOCK_PIN) || defined(LED_COMPOSE_PIN) || defined(LED_KANA_PIN) -# if LED_PIN_ON_STATE == 0 - // invert the whole thing to avoid having to conditionally !led_state.x later - led_state.raw = ~led_state.raw; -# endif - -# ifdef LED_NUM_LOCK_PIN - writePin(LED_NUM_LOCK_PIN, led_state.num_lock); -# endif -# ifdef LED_CAPS_LOCK_PIN - writePin(LED_CAPS_LOCK_PIN, led_state.caps_lock); -# endif -# ifdef LED_SCROLL_LOCK_PIN - writePin(LED_SCROLL_LOCK_PIN, led_state.scroll_lock); -# endif -# ifdef LED_COMPOSE_PIN - writePin(LED_COMPOSE_PIN, led_state.compose); -# endif -# ifdef LED_KANA_PIN - writePin(LED_KANA_PIN, led_state.kana); -# endif -#endif + led_update_ports(led_state); } return res; } +/** \brief Write LED state to hardware + */ +__attribute__((weak)) void led_update_ports(led_t led_state) { +#if LED_PIN_ON_STATE == 0 + // invert the whole thing to avoid having to conditionally !led_state.x later + led_state.raw = ~led_state.raw; +#endif + +#ifdef LED_NUM_LOCK_PIN + writePin(LED_NUM_LOCK_PIN, led_state.num_lock); +#endif +#ifdef LED_CAPS_LOCK_PIN + writePin(LED_CAPS_LOCK_PIN, led_state.caps_lock); +#endif +#ifdef LED_SCROLL_LOCK_PIN + writePin(LED_SCROLL_LOCK_PIN, led_state.scroll_lock); +#endif +#ifdef LED_COMPOSE_PIN + writePin(LED_COMPOSE_PIN, led_state.compose); +#endif +#ifdef LED_KANA_PIN + writePin(LED_KANA_PIN, led_state.kana); +#endif +} + /** \brief Initialise any LED related hardware and/or state */ __attribute__((weak)) void led_init_ports(void) { diff --git a/quantum/led.h b/quantum/led.h index b8262cbd8e..d12e519ea2 100644 --- a/quantum/led.h +++ b/quantum/led.h @@ -60,6 +60,7 @@ void led_set_user(uint8_t usb_led); void led_set_kb(uint8_t usb_led); bool led_update_user(led_t led_state); bool led_update_kb(led_t led_state); +void led_update_ports(led_t led_state); uint32_t last_led_activity_time(void); // Timestamp of the LED activity uint32_t last_led_activity_elapsed(void); // Number of milliseconds since the last LED activity -- cgit v1.2.3 From f090cfe75ca3978c08d22b77bb478fb22638b3d9 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Fri, 7 Oct 2022 23:36:38 +0100 Subject: Relocate US ANSI shifted keycode aliases (#18634) --- quantum/keymap_extras/keymap_us.h | 72 +++++++++++++++++++++++++++++++++++++++ quantum/quantum_keycodes.h | 62 +-------------------------------- quantum/sequencer/tests/rules.mk | 2 +- 3 files changed, 74 insertions(+), 62 deletions(-) create mode 100644 quantum/keymap_extras/keymap_us.h (limited to 'quantum') diff --git a/quantum/keymap_extras/keymap_us.h b/quantum/keymap_extras/keymap_us.h new file mode 100644 index 0000000000..b18c701679 --- /dev/null +++ b/quantum/keymap_extras/keymap_us.h @@ -0,0 +1,72 @@ +// Copyright 2022 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "keymap.h" + +// clang-format off + +/* Shifted symbols + * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ + * │ ~ │ ! │ @ │ # │ $ │ % │ ^ │ & │ * │ ( │ ) │ _ │ + │ │ + * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ + * │ │ │ │ │ │ │ │ │ │ │ │ { │ } │ | │ + * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ + * │ │ │ │ │ │ │ │ │ │ │ : │ " │ │ + * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤ + * │ │ │ │ │ │ │ │ │ < │ > │ ? │ │ + * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ + * │ │ │ │ │ │ │ │ │ + * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘ + */ +// Row 1 +#define KC_TILD S(KC_GRAVE) // ~ +#define KC_EXLM S(KC_1) // ! +#define KC_AT S(KC_2) // @ +#define KC_HASH S(KC_3) // # +#define KC_DLR S(KC_4) // $ +#define KC_PERC S(KC_5) // % +#define KC_CIRC S(KC_6) // ^ +#define KC_AMPR S(KC_7) // & +#define KC_ASTR S(KC_8) // * +#define KC_LPRN S(KC_9) // ( +#define KC_RPRN S(KC_0) // ) +#define KC_UNDS S(KC_MINUS) // _ +#define KC_PLUS S(KC_EQUAL) // + +// Row 2 +#define KC_LCBR S(KC_LEFT_BRACKET) // { +#define KC_RCBR S(KC_RIGHT_BRACKET) // } +#define KC_PIPE S(KC_BACKSLASH) // | +// Row 3 +#define KC_COLN S(KC_SEMICOLON) // : +#define KC_DQUO S(KC_QUOTE) // " +// Row 4 +#define KC_LABK S(KC_COMMA) // < +#define KC_RABK S(KC_DOT) // > +#define KC_QUES S(KC_SLASH) // ? + +// alias stuff +#define KC_TILDE KC_TILD +#define KC_EXCLAIM KC_EXLM +#define KC_DOLLAR KC_DLR +#define KC_PERCENT KC_PERC +#define KC_CIRCUMFLEX KC_CIRC +#define KC_AMPERSAND KC_AMPR +#define KC_ASTERISK KC_ASTR +#define KC_LEFT_PAREN KC_LPRN +#define KC_RIGHT_PAREN KC_RPRN +#define KC_UNDERSCORE KC_UNDS + +#define KC_LEFT_CURLY_BRACE KC_LCBR +#define KC_RIGHT_CURLY_BRACE KC_RCBR + +#define KC_COLON KC_COLN +#define KC_DOUBLE_QUOTE KC_DQUO +#define KC_DQT KC_DQUO + +#define KC_LEFT_ANGLE_BRACKET KC_LABK +#define KC_LT KC_LABK +#define KC_RIGHT_ANGLE_BRACKET KC_RABK +#define KC_GT KC_RABK +#define KC_QUESTION KC_QUES diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index abf3f1a384..939fab9298 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -656,67 +656,7 @@ enum quantum_keycodes { #define MOD_MEH 0x7 // US ANSI shifted keycode aliases -#define KC_TILDE LSFT(KC_GRAVE) // ~ -#define KC_TILD KC_TILDE - -#define KC_EXCLAIM LSFT(KC_1) // ! -#define KC_EXLM KC_EXCLAIM - -#define KC_AT LSFT(KC_2) // @ - -#define KC_HASH LSFT(KC_3) // # - -#define KC_DOLLAR LSFT(KC_4) // $ -#define KC_DLR KC_DOLLAR - -#define KC_PERCENT LSFT(KC_5) // % -#define KC_PERC KC_PERCENT - -#define KC_CIRCUMFLEX LSFT(KC_6) // ^ -#define KC_CIRC KC_CIRCUMFLEX - -#define KC_AMPERSAND LSFT(KC_7) // & -#define KC_AMPR KC_AMPERSAND - -#define KC_ASTERISK LSFT(KC_8) // * -#define KC_ASTR KC_ASTERISK - -#define KC_LEFT_PAREN LSFT(KC_9) // ( -#define KC_LPRN KC_LEFT_PAREN - -#define KC_RIGHT_PAREN LSFT(KC_0) // ) -#define KC_RPRN KC_RIGHT_PAREN - -#define KC_UNDERSCORE LSFT(KC_MINUS) // _ -#define KC_UNDS KC_UNDERSCORE - -#define KC_PLUS LSFT(KC_EQUAL) // + - -#define KC_LEFT_CURLY_BRACE LSFT(KC_LEFT_BRACKET) // { -#define KC_LCBR KC_LEFT_CURLY_BRACE - -#define KC_RIGHT_CURLY_BRACE LSFT(KC_RIGHT_BRACKET) // } -#define KC_RCBR KC_RIGHT_CURLY_BRACE - -#define KC_LEFT_ANGLE_BRACKET LSFT(KC_COMMA) // < -#define KC_LABK KC_LEFT_ANGLE_BRACKET -#define KC_LT KC_LEFT_ANGLE_BRACKET - -#define KC_RIGHT_ANGLE_BRACKET LSFT(KC_DOT) // > -#define KC_RABK KC_RIGHT_ANGLE_BRACKET -#define KC_GT KC_RIGHT_ANGLE_BRACKET - -#define KC_COLON LSFT(KC_SEMICOLON) // : -#define KC_COLN KC_COLON - -#define KC_PIPE LSFT(KC_BACKSLASH) // | - -#define KC_QUESTION LSFT(KC_SLASH) // ? -#define KC_QUES KC_QUESTION - -#define KC_DOUBLE_QUOTE LSFT(KC_QUOTE) // " -#define KC_DQUO KC_DOUBLE_QUOTE -#define KC_DQT KC_DOUBLE_QUOTE +#include "keymap_us.h" #define KC_DELT KC_DELETE // Del key (four letter code) diff --git a/quantum/sequencer/tests/rules.mk b/quantum/sequencer/tests/rules.mk index a3bbd80513..611459e060 100644 --- a/quantum/sequencer/tests/rules.mk +++ b/quantum/sequencer/tests/rules.mk @@ -2,7 +2,7 @@ # - it is consistent with the example that is used as a reference in the Unit Testing article (https://docs.qmk.fm/#/unit_testing?id=adding-tests-for-new-or-existing-features) # - Neither `make test:sequencer` or `make test:SEQUENCER` work when using SCREAMING_SNAKE_CASE -sequencer_DEFS := -DNO_DEBUG -DMIDI_MOCKED +sequencer_DEFS := -DMATRIX_ROWS=1 -DMATRIX_COLS=1 -DNO_DEBUG -DMIDI_MOCKED sequencer_SRC := \ $(QUANTUM_PATH)/sequencer/tests/midi_mock.c \ -- cgit v1.2.3 From 86938fd958836e86cced081f46e8901bad245df8 Mon Sep 17 00:00:00 2001 From: jpe230 Date: Sat, 8 Oct 2022 11:13:58 -0500 Subject: Allow QK_MAKE to work with converters (#18637) --- quantum/quantum.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'quantum') diff --git a/quantum/quantum.c b/quantum/quantum.c index 5b5364c8f1..0f94e3855d 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -422,7 +422,11 @@ bool process_record_quantum(keyrecord_t *record) { } else { SEND_STRING_DELAY(" compile ", TAP_CODE_DELAY); } +# if defined(CONVERTER_ENABLED) + SEND_STRING_DELAY("-kb " QMK_KEYBOARD " -km " QMK_KEYMAP " -e CONVERT_TO=" CONVERTER_TARGET SS_TAP(X_ENTER), TAP_CODE_DELAY); +# else SEND_STRING_DELAY("-kb " QMK_KEYBOARD " -km " QMK_KEYMAP SS_TAP(X_ENTER), TAP_CODE_DELAY); +# endif if (temp_mod & MOD_MASK_SHIFT && temp_mod & MOD_MASK_CTRL) { reset_keyboard(); } -- cgit v1.2.3 From 4b2d71de52b561c77da4bdb2275b1c6bb2415f54 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 9 Oct 2022 14:51:09 +1100 Subject: Remove legacy international keycodes (#18588) --- quantum/keycode_legacy.h | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'quantum') diff --git a/quantum/keycode_legacy.h b/quantum/keycode_legacy.h index 9169f3cb89..9c66f8fa51 100644 --- a/quantum/keycode_legacy.h +++ b/quantum/keycode_legacy.h @@ -19,15 +19,6 @@ #define KC__MUTE KC_KB_MUTE #define KC__VOLUP KC_KB_VOLUME_UP #define KC__VOLDOWN KC_KB_VOLUME_DOWN -#define KC_LANG1 KC_LANGUAGE_1 -#define KC_LANG2 KC_LANGUAGE_2 -#define KC_LANG3 KC_LANGUAGE_3 -#define KC_LANG4 KC_LANGUAGE_4 -#define KC_LANG5 KC_LANGUAGE_5 -#define KC_LANG6 KC_LANGUAGE_6 -#define KC_LANG7 KC_LANGUAGE_7 -#define KC_LANG8 KC_LANGUAGE_8 -#define KC_LANG9 KC_LANGUAGE_9 #define KC_ALT_ERASE KC_ALTERNATE_ERASE #define KC_SYSREQ KC_SYSTEM_REQUEST @@ -36,15 +27,6 @@ #define KC_RCTRL KC_RIGHT_CTRL #define KC_RSHIFT KC_RIGHT_SHIFT -#define KC_ZKHK KC_GRAVE -#define KC_RO KC_INTERNATIONAL_1 -#define KC_KANA KC_INTERNATIONAL_2 -#define KC_JYEN KC_INTERNATIONAL_3 -#define KC_HENK KC_INTERNATIONAL_4 -#define KC_MHEN KC_INTERNATIONAL_5 -#define KC_HAEN KC_LANGUAGE_1 -#define KC_HANJ KC_LANGUAGE_2 - #define KC_CLCK KC_CAPS_LOCK #define KC_SLCK KC_SCROLL_LOCK #define KC_NLCK KC_NUM_LOCK -- cgit v1.2.3 From 9d43cc319c5928a595d38f92e8d80c5af29f54c3 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Mon, 10 Oct 2022 02:00:26 +0100 Subject: Fix mouse use within send_string (#18659) --- quantum/send_string/send_string_keycodes.h | 36 ++++++++++++++++++------------ 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'quantum') diff --git a/quantum/send_string/send_string_keycodes.h b/quantum/send_string/send_string_keycodes.h index 802d9a8240..12e4cf83d2 100644 --- a/quantum/send_string/send_string_keycodes.h +++ b/quantum/send_string/send_string_keycodes.h @@ -375,20 +375,6 @@ #define X_MS_BTN6 f8 #define X_MS_BTN7 f8 #define X_MS_BTN8 f8 -#else -#define X_MS_UP ed -#define X_MS_DOWN ee -#define X_MS_LEFT ef -#define X_MS_RIGHT f0 -#define X_MS_BTN1 f1 -#define X_MS_BTN2 f2 -#define X_MS_BTN3 f3 -#define X_MS_BTN4 f4 -#define X_MS_BTN5 f5 -#define X_MS_BTN6 f6 -#define X_MS_BTN7 f7 -#define X_MS_BTN8 f8 -#endif #define X_MS_WH_UP f9 #define X_MS_WH_DOWN fa #define X_MS_WH_LEFT fb @@ -396,6 +382,28 @@ #define X_MS_ACCEL0 fd #define X_MS_ACCEL1 fe #define X_MS_ACCEL2 ff +#else +#define X_MS_UP cd +#define X_MS_DOWN ce +#define X_MS_LEFT cf +#define X_MS_RIGHT d0 +#define X_MS_BTN1 d1 +#define X_MS_BTN2 d2 +#define X_MS_BTN3 d3 +#define X_MS_BTN4 d4 +#define X_MS_BTN5 d5 +#define X_MS_BTN6 d6 +#define X_MS_BTN7 d7 +#define X_MS_BTN8 d8 +#define X_MS_WH_UP d9 +#define X_MS_WH_DOWN da +#define X_MS_WH_LEFT db +#define X_MS_WH_RIGHT dc +#define X_MS_ACCEL0 dd +#define X_MS_ACCEL1 de +#define X_MS_ACCEL2 df +#endif + // Send string macros #define STRINGIZE(z) #z -- cgit v1.2.3 From c6f1b594a2085e67219bd5f0f7ba7898429d331c Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 11 Oct 2022 06:06:26 +1100 Subject: Remove legacy keycodes, part 2 (#18660) * `KC_SYSREQ` -> `KC_SYRQ` And one `KC_ALT_ERASE` -> `KC_ERAS` * `KC_NONUS_BSLASH` -> `KC_NUBS` * `KC_NUMLOCK` -> `KC_NUM` * `KC_CLCK` -> `KC_CAPS` * `KC_SCROLLLOCK` -> `KC_SCRL` * `KC_LBRACKET` -> `KC_LBRC` * `KC_RBRACKET` -> `KC_RBRC` * `KC_CAPSLOCK` -> `KC_CAPS` --- quantum/keycode_legacy.h | 9 --------- 1 file changed, 9 deletions(-) (limited to 'quantum') diff --git a/quantum/keycode_legacy.h b/quantum/keycode_legacy.h index 9c66f8fa51..16318423a8 100644 --- a/quantum/keycode_legacy.h +++ b/quantum/keycode_legacy.h @@ -5,28 +5,19 @@ // These keycode names have been deprecated #define KC_BSPACE KC_BACKSPACE -#define KC_LBRACKET KC_LEFT_BRACKET -#define KC_RBRACKET KC_RIGHT_BRACKET #define KC_BSLASH KC_BACKSLASH #define KC_SCOLON KC_SEMICOLON -#define KC_CAPSLOCK KC_CAPS_LOCK #define KC_PSCREEN KC_PRINT_SCREEN -#define KC_SCROLLLOCK KC_SCROLL_LOCK #define KC_PGDOWN KC_PAGE_DOWN -#define KC_NUMLOCK KC_NUM_LOCK -#define KC_NONUS_BSLASH KC_NONUS_BACKSLASH #define KC_POWER KC_KB_POWER #define KC__MUTE KC_KB_MUTE #define KC__VOLUP KC_KB_VOLUME_UP #define KC__VOLDOWN KC_KB_VOLUME_DOWN -#define KC_ALT_ERASE KC_ALTERNATE_ERASE -#define KC_SYSREQ KC_SYSTEM_REQUEST #define KC_LCTRL KC_LEFT_CTRL #define KC_LSHIFT KC_LEFT_SHIFT #define KC_RCTRL KC_RIGHT_CTRL #define KC_RSHIFT KC_RIGHT_SHIFT -#define KC_CLCK KC_CAPS_LOCK #define KC_SLCK KC_SCROLL_LOCK #define KC_NLCK KC_NUM_LOCK -- cgit v1.2.3 From e96d8297246f6858adf257a8892e719695f83c45 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 12 Oct 2022 00:21:47 +1100 Subject: Remove legacy keycodes, part 3 (#18669) * `KC__VOLDOWN` -> `KC_VOLD` * `KC__VOLUP` -> `KC_VOLU` * `KC__MUTE` -> `KC_MUTE` * `KC_POWER` -> `KC_PWR` --- quantum/keycode_legacy.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'quantum') diff --git a/quantum/keycode_legacy.h b/quantum/keycode_legacy.h index 16318423a8..2147b9370e 100644 --- a/quantum/keycode_legacy.h +++ b/quantum/keycode_legacy.h @@ -9,10 +9,6 @@ #define KC_SCOLON KC_SEMICOLON #define KC_PSCREEN KC_PRINT_SCREEN #define KC_PGDOWN KC_PAGE_DOWN -#define KC_POWER KC_KB_POWER -#define KC__MUTE KC_KB_MUTE -#define KC__VOLUP KC_KB_VOLUME_UP -#define KC__VOLDOWN KC_KB_VOLUME_DOWN #define KC_LCTRL KC_LEFT_CTRL #define KC_LSHIFT KC_LEFT_SHIFT -- cgit v1.2.3 From 41159326ca7c366b50edad1392369131c4ce4008 Mon Sep 17 00:00:00 2001 From: James Thomson Date: Tue, 11 Oct 2022 19:33:02 +0100 Subject: Fix boundary in `RGB_MATRIX_INDICATOR_SET_COLOR` (#18650) --- quantum/rgb_matrix/rgb_matrix.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'quantum') diff --git a/quantum/rgb_matrix/rgb_matrix.h b/quantum/rgb_matrix/rgb_matrix.h index 1cd054abc4..e1bdad42e0 100644 --- a/quantum/rgb_matrix/rgb_matrix.h +++ b/quantum/rgb_matrix/rgb_matrix.h @@ -81,7 +81,7 @@ #endif #define RGB_MATRIX_INDICATOR_SET_COLOR(i, r, g, b) \ - if (i >= led_min && i <= led_max) { \ + if (i >= led_min && i < led_max) { \ rgb_matrix_set_color(i, r, g, b); \ } -- cgit v1.2.3 From 5629ba18077ee5dcde72e497ddf46d848817dd5c Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 14 Oct 2022 04:28:14 +1100 Subject: Remove legacy keycodes, part 4 (#18683) * `KC_PGDOWN` -> `KC_PGDN` * `KC_PSCREEN` -> `KC_PSCR` * `KC_SCOLON` -> `KC_SCLN` * `KC_BSLASH` -> `KC_BSLS` * `KC_BSPACE` -> `KC_BSPC` --- quantum/keycode_legacy.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'quantum') diff --git a/quantum/keycode_legacy.h b/quantum/keycode_legacy.h index 2147b9370e..03dcfabc45 100644 --- a/quantum/keycode_legacy.h +++ b/quantum/keycode_legacy.h @@ -4,12 +4,6 @@ // These keycode names have been deprecated -#define KC_BSPACE KC_BACKSPACE -#define KC_BSLASH KC_BACKSLASH -#define KC_SCOLON KC_SEMICOLON -#define KC_PSCREEN KC_PRINT_SCREEN -#define KC_PGDOWN KC_PAGE_DOWN - #define KC_LCTRL KC_LEFT_CTRL #define KC_LSHIFT KC_LEFT_SHIFT #define KC_RCTRL KC_RIGHT_CTRL -- cgit v1.2.3 From f0b2bfd5ca5b416a9c7c9bef8c2850f1084bd106 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 15 Oct 2022 14:33:24 +1100 Subject: Programmable Button API refactor and improve docs (#18641) --- quantum/action.c | 1 - quantum/keyboard.c | 7 -- .../process_keycode/process_programmable_button.c | 4 +- quantum/programmable_button.c | 27 +++++--- quantum/programmable_button.h | 75 ++++++++++++++++++++-- 5 files changed, 89 insertions(+), 25 deletions(-) (limited to 'quantum') diff --git a/quantum/action.c b/quantum/action.c index 78322e4a83..abf9834d2f 100644 --- a/quantum/action.c +++ b/quantum/action.c @@ -1081,7 +1081,6 @@ void clear_keyboard_but_mods_and_keys() { #endif #ifdef PROGRAMMABLE_BUTTON_ENABLE programmable_button_clear(); - programmable_button_send(); #endif } diff --git a/quantum/keyboard.c b/quantum/keyboard.c index 280532a5fd..eb5e4b583a 100644 --- a/quantum/keyboard.c +++ b/quantum/keyboard.c @@ -66,9 +66,6 @@ along with this program. If not, see . #ifdef JOYSTICK_ENABLE # include "process_joystick.h" #endif -#ifdef PROGRAMMABLE_BUTTON_ENABLE -# include "programmable_button.h" -#endif #ifdef HD44780_ENABLE # include "hd44780.h" #endif @@ -669,10 +666,6 @@ void keyboard_task(void) { digitizer_task(); #endif -#ifdef PROGRAMMABLE_BUTTON_ENABLE - programmable_button_send(); -#endif - #ifdef BLUETOOTH_ENABLE bluetooth_task(); #endif diff --git a/quantum/process_keycode/process_programmable_button.c b/quantum/process_keycode/process_programmable_button.c index c6e77faacc..6379698848 100644 --- a/quantum/process_keycode/process_programmable_button.c +++ b/quantum/process_keycode/process_programmable_button.c @@ -22,9 +22,9 @@ bool process_programmable_button(uint16_t keycode, keyrecord_t *record) { if (keycode >= PROGRAMMABLE_BUTTON_MIN && keycode <= PROGRAMMABLE_BUTTON_MAX) { uint8_t button = keycode - PROGRAMMABLE_BUTTON_MIN + 1; if (record->event.pressed) { - programmable_button_on(button); + programmable_button_register(button); } else { - programmable_button_off(button); + programmable_button_unregister(button); } } return true; diff --git a/quantum/programmable_button.c b/quantum/programmable_button.c index a3ef42d82b..b6c9ad3189 100644 --- a/quantum/programmable_button.c +++ b/quantum/programmable_button.c @@ -24,27 +24,38 @@ static uint32_t programmable_button_report = 0; void programmable_button_clear(void) { programmable_button_report = 0; + programmable_button_flush(); } -void programmable_button_send(void) { - host_programmable_button_send(programmable_button_report); -} - -void programmable_button_on(uint8_t index) { +void programmable_button_add(uint8_t index) { programmable_button_report |= REPORT_BIT(index); } -void programmable_button_off(uint8_t index) { +void programmable_button_remove(uint8_t index) { programmable_button_report &= ~REPORT_BIT(index); } +void programmable_button_register(uint8_t index) { + programmable_button_add(index); + programmable_button_flush(); +} + +void programmable_button_unregister(uint8_t index) { + programmable_button_remove(index); + programmable_button_flush(); +} + bool programmable_button_is_on(uint8_t index) { return !!(programmable_button_report & REPORT_BIT(index)); -}; +} + +void programmable_button_flush(void) { + host_programmable_button_send(programmable_button_report); +} uint32_t programmable_button_get_report(void) { return programmable_button_report; -}; +} void programmable_button_set_report(uint32_t report) { programmable_button_report = report; diff --git a/quantum/programmable_button.h b/quantum/programmable_button.h index e89b8b9fd6..e8c916d75c 100644 --- a/quantum/programmable_button.h +++ b/quantum/programmable_button.h @@ -19,12 +19,73 @@ along with this program. If not, see . #include #include -#include "report.h" -void programmable_button_clear(void); -void programmable_button_send(void); -void programmable_button_on(uint8_t index); -void programmable_button_off(uint8_t index); -bool programmable_button_is_on(uint8_t index); +/** + * \defgroup programmable_button + * + * HID Programmable Buttons + * \{ + */ + +/** + * \brief Clear the programmable button report. + */ +void programmable_button_clear(void); + +/** + * \brief Set the state of a button. + * + * \param index The index of the button to press, from 0 to 31. + */ +void programmable_button_add(uint8_t index); + +/** + * \brief Reset the state of a button. + * + * \param index The index of the button to release, from 0 to 31. + */ +void programmable_button_remove(uint8_t index); + +/** + * \brief Set the state of a button, and flush the report. + * + * \param index The index of the button to press, from 0 to 31. + */ +void programmable_button_register(uint8_t index); + +/** + * \brief Reset the state of a button, and flush the report. + * + * \param index The index of the button to release, from 0 to 31. + */ +void programmable_button_unregister(uint8_t index); + +/** + * \brief Get the state of a button. + * + * \param index The index of the button to check, from 0 to 31. + * + * \return `true` if the button is pressed. + */ +bool programmable_button_is_on(uint8_t index); + +/** + * \brief Send the programmable button report to the host. + */ +void programmable_button_flush(void); + +/** + * \brief Get the programmable button report. + * + * \return The bitmask of programmable button states. + */ uint32_t programmable_button_get_report(void); -void programmable_button_set_report(uint32_t report); + +/** + * \brief Set the programmable button report. + * + * \param report A bitmask of programmable button states. + */ +void programmable_button_set_report(uint32_t report); + +/** \} */ -- cgit v1.2.3 From 5e4b076af3c99d36632d6b92f3ddd046f38a01af Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 16 Oct 2022 08:29:43 +1100 Subject: Remove legacy keycodes, part 5 (#18710) * `KC_SLCK` -> `KC_SCRL` * `KC_NLCK` -> `KC_NUM` --- quantum/keycode_legacy.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'quantum') diff --git a/quantum/keycode_legacy.h b/quantum/keycode_legacy.h index 03dcfabc45..d69d141291 100644 --- a/quantum/keycode_legacy.h +++ b/quantum/keycode_legacy.h @@ -8,6 +8,3 @@ #define KC_LSHIFT KC_LEFT_SHIFT #define KC_RCTRL KC_RIGHT_CTRL #define KC_RSHIFT KC_RIGHT_SHIFT - -#define KC_SLCK KC_SCROLL_LOCK -#define KC_NLCK KC_NUM_LOCK -- cgit v1.2.3 From 74223c34a969c0877bde035c721c21a1f25890fa Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 17 Oct 2022 00:14:40 +1100 Subject: Remove legacy keycodes, part 6 (#18740) * `KC_RSHIFT` -> `KC_RSFT` * `KC_RCTRL` -> `KC_RCTL` * `KC_LSHIFT` -> `KC_LSFT` * `KC_LCTRL` -> `KC_LCTL` --- quantum/keycode.h | 2 -- quantum/keycode_legacy.h | 10 ---------- 2 files changed, 12 deletions(-) delete mode 100644 quantum/keycode_legacy.h (limited to 'quantum') diff --git a/quantum/keycode.h b/quantum/keycode.h index b492e4292a..2e9a85ee66 100644 --- a/quantum/keycode.h +++ b/quantum/keycode.h @@ -545,5 +545,3 @@ enum mouse_keys { KC_MS_ACCEL1, KC_MS_ACCEL2 // 0xDF, or 0xFF if via enabled }; - -#include "keycode_legacy.h" diff --git a/quantum/keycode_legacy.h b/quantum/keycode_legacy.h deleted file mode 100644 index d69d141291..0000000000 --- a/quantum/keycode_legacy.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -// clang-format off - -// These keycode names have been deprecated - -#define KC_LCTRL KC_LEFT_CTRL -#define KC_LSHIFT KC_LEFT_SHIFT -#define KC_RCTRL KC_RIGHT_CTRL -#define KC_RSHIFT KC_RIGHT_SHIFT -- cgit v1.2.3 From bad8c5992bf68b6f2218b9b7a0b31c6ee7a03796 Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 17 Oct 2022 23:45:23 +1100 Subject: Remove legacy sendstring keycodes (#18749) --- quantum/send_string/send_string_keycodes.h | 574 +++++++++++++++-------------- 1 file changed, 299 insertions(+), 275 deletions(-) (limited to 'quantum') diff --git a/quantum/send_string/send_string_keycodes.h b/quantum/send_string/send_string_keycodes.h index 12e4cf83d2..f9e1c101ff 100644 --- a/quantum/send_string/send_string_keycodes.h +++ b/quantum/send_string/send_string_keycodes.h @@ -21,45 +21,53 @@ /* Punctuation */ #define X_ENT X_ENTER #define X_ESC X_ESCAPE -#define X_BSPC X_BSPACE +#define X_BSPC X_BACKSPACE #define X_SPC X_SPACE #define X_MINS X_MINUS #define X_EQL X_EQUAL -#define X_LBRC X_LBRACKET -#define X_RBRC X_RBRACKET -#define X_BSLS X_BSLASH +#define X_LBRC X_LEFT_BRACKET +#define X_RBRC X_RIGHT_BRACKET +#define X_BSLS X_BACKSLASH #define X_NUHS X_NONUS_HASH -#define X_SCLN X_SCOLON +#define X_SCLN X_SEMICOLON #define X_QUOT X_QUOTE #define X_GRV X_GRAVE #define X_COMM X_COMMA #define X_SLSH X_SLASH -#define X_NUBS X_NONUS_BSLASH +#define X_NUBS X_NONUS_BACKSLASH /* Lock Keys */ -#define X_CLCK X_CAPSLOCK -#define X_CAPS X_CAPSLOCK -#define X_SLCK X_SCROLLLOCK -#define X_NLCK X_NUMLOCK -#define X_LCAP X_LOCKING_CAPS -#define X_LNUM X_LOCKING_NUM -#define X_LSCR X_LOCKING_SCROLL +#define X_CAPS X_CAPS_LOCK +#define X_SCRL X_SCROLL_LOCK +#define X_NUM X_NUM_LOCK +#define X_LCAP X_LOCKING_CAPS_LOCK +#define X_LNUM X_LOCKING_NUM_LOCK +#define X_LSCR X_LOCKING_SCROLL_LOCK /* Commands */ -#define X_PSCR X_PSCREEN +#define X_PSCR X_PRINT_SCREEN #define X_PAUS X_PAUSE #define X_BRK X_PAUSE #define X_INS X_INSERT +#define X_PGUP X_PAGE_UP #define X_DEL X_DELETE -#define X_PGDN X_PGDOWN +#define X_PGDN X_PAGE_DOWN #define X_RGHT X_RIGHT #define X_APP X_APPLICATION #define X_EXEC X_EXECUTE #define X_SLCT X_SELECT #define X_AGIN X_AGAIN #define X_PSTE X_PASTE -#define X_ERAS X_ALT_ERASE +#define X_ERAS X_ALTERNATE_ERASE +#define X_SYRQ X_SYSTEM_REQUEST +#define X_CNCL X_CANCEL #define X_CLR X_CLEAR +#define X_PRIR X_PRIOR +#define X_RETN X_RETURN +#define X_SEPR X_SEPARATOR +#define X_CLAG X_CLEAR_AGAIN +#define X_CRSL X_CRSEL +#define X_EXSL X_EXSEL /* Keypad */ #define X_PSLS X_KP_SLASH @@ -81,30 +89,42 @@ #define X_PEQL X_KP_EQUAL #define X_PCMM X_KP_COMMA -/* Japanese specific */ -#define X_ZKHK X_GRAVE -#define X_RO X_INT1 -#define X_KANA X_INT2 -#define X_JYEN X_INT3 -#define X_HENK X_INT4 -#define X_MHEN X_INT5 - -/* Korean specific */ -#define X_HAEN X_LANG1 -#define X_HANJ X_LANG2 +/* Language Specific */ +#define X_INT1 X_INTERNATIONAL_1 +#define X_INT2 X_INTERNATIONAL_2 +#define X_INT3 X_INTERNATIONAL_3 +#define X_INT4 X_INTERNATIONAL_4 +#define X_INT5 X_INTERNATIONAL_5 +#define X_INT6 X_INTERNATIONAL_6 +#define X_INT7 X_INTERNATIONAL_7 +#define X_INT8 X_INTERNATIONAL_8 +#define X_INT9 X_INTERNATIONAL_9 +#define X_LNG1 X_LANGUAGE_1 +#define X_LNG2 X_LANGUAGE_2 +#define X_LNG3 X_LANGUAGE_3 +#define X_LNG4 X_LANGUAGE_4 +#define X_LNG5 X_LANGUAGE_5 +#define X_LNG6 X_LANGUAGE_6 +#define X_LNG7 X_LANGUAGE_7 +#define X_LNG8 X_LANGUAGE_8 +#define X_LNG9 X_LANGUAGE_9 /* Modifiers */ -#define X_LCTL X_LCTRL -#define X_LSFT X_LSHIFT -#define X_LOPT X_LALT -#define X_LCMD X_LGUI -#define X_LWIN X_LGUI -#define X_RCTL X_RCTRL -#define X_RSFT X_RSHIFT -#define X_ALGR X_RALT -#define X_ROPT X_RALT -#define X_RCMD X_RGUI -#define X_RWIN X_RGUI +#define X_LCTL X_LEFT_CTRL +#define X_LSFT X_LEFT_SHIFT +#define X_LALT X_LEFT_ALT +#define X_LOPT X_LEFT_ALT +#define X_LGUI X_LEFT_GUI +#define X_LCMD X_LEFT_GUI +#define X_LWIN X_LEFT_GUI +#define X_RCTL X_RIGHT_CTRL +#define X_RSFT X_RIGHT_SHIFT +#define X_RALT X_RIGHT_ALT +#define X_ALGR X_RIGHT_ALT +#define X_ROPT X_RIGHT_ALT +#define X_RGUI X_RIGHT_GUI +#define X_RCMD X_RIGHT_GUI +#define X_RWIN X_RIGHT_GUI /* Generic Desktop Page (0x01) */ #define X_PWR X_SYSTEM_POWER @@ -134,10 +154,12 @@ #define X_MRWD X_MEDIA_REWIND #define X_BRIU X_BRIGHTNESS_UP #define X_BRID X_BRIGHTNESS_DOWN +#define X_CPNL X_CONTROL_PANEL +#define X_ASST X_ASSISTANT /* System Specific */ #define X_BRMU X_PAUSE -#define X_BRMD X_SCROLLLOCK +#define X_BRMD X_SCROLL_LOCK /* Mouse Keys */ #define X_MS_U X_MS_UP @@ -149,6 +171,9 @@ #define X_BTN3 X_MS_BTN3 #define X_BTN4 X_MS_BTN4 #define X_BTN5 X_MS_BTN5 +#define X_BTN6 X_MS_BTN6 +#define X_BTN7 X_MS_BTN7 +#define X_BTN8 X_MS_BTN8 #define X_WH_U X_MS_WH_UP #define X_WH_D X_MS_WH_DOWN #define X_WH_L X_MS_WH_LEFT @@ -158,250 +183,252 @@ #define X_ACL2 X_MS_ACCEL2 /* Keyboard/Keypad Page (0x07) */ -#define X_A 04 -#define X_B 05 -#define X_C 06 -#define X_D 07 -#define X_E 08 -#define X_F 09 -#define X_G 0a -#define X_H 0b -#define X_I 0c -#define X_J 0d -#define X_K 0e -#define X_L 0f -#define X_M 10 -#define X_N 11 -#define X_O 12 -#define X_P 13 -#define X_Q 14 -#define X_R 15 -#define X_S 16 -#define X_T 17 -#define X_U 18 -#define X_V 19 -#define X_W 1a -#define X_X 1b -#define X_Y 1c -#define X_Z 1d -#define X_1 1e -#define X_2 1f -#define X_3 20 -#define X_4 21 -#define X_5 22 -#define X_6 23 -#define X_7 24 -#define X_8 25 -#define X_9 26 -#define X_0 27 -#define X_ENTER 28 -#define X_ESCAPE 29 -#define X_BSPACE 2a -#define X_TAB 2b -#define X_SPACE 2c -#define X_MINUS 2d -#define X_EQUAL 2e -#define X_LBRACKET 2f -#define X_RBRACKET 30 -#define X_BSLASH 31 -#define X_NONUS_HASH 32 -#define X_SCOLON 33 -#define X_QUOTE 34 -#define X_GRAVE 35 -#define X_COMMA 36 -#define X_DOT 37 -#define X_SLASH 38 -#define X_CAPSLOCK 39 -#define X_F1 3a -#define X_F2 3b -#define X_F3 3c -#define X_F4 3d -#define X_F5 3e -#define X_F6 3f -#define X_F7 40 -#define X_F8 41 -#define X_F9 42 -#define X_F10 43 -#define X_F11 44 -#define X_F12 45 -#define X_PSCREEN 46 -#define X_SCROLLLOCK 47 -#define X_PAUSE 48 -#define X_INSERT 49 -#define X_HOME 4a -#define X_PGUP 4b -#define X_DELETE 4c -#define X_END 4d -#define X_PGDOWN 4e -#define X_RIGHT 4f -#define X_LEFT 50 -#define X_DOWN 51 -#define X_UP 52 -#define X_NUMLOCK 53 -#define X_KP_SLASH 54 -#define X_KP_ASTERISK 55 -#define X_KP_MINUS 56 -#define X_KP_PLUS 57 -#define X_KP_ENTER 58 -#define X_KP_1 59 -#define X_KP_2 5a -#define X_KP_3 5b -#define X_KP_4 5c -#define X_KP_5 5d -#define X_KP_6 5e -#define X_KP_7 5f -#define X_KP_8 60 -#define X_KP_9 61 -#define X_KP_0 62 -#define X_KP_DOT 63 -#define X_NONUS_BSLASH 64 -#define X_APPLICATION 65 -#define X_POWER 66 -#define X_KP_EQUAL 67 -#define X_F13 68 -#define X_F14 69 -#define X_F15 6a -#define X_F16 6b -#define X_F17 6c -#define X_F18 6d -#define X_F19 6e -#define X_F20 6f -#define X_F21 70 -#define X_F22 71 -#define X_F23 72 -#define X_F24 73 -#define X_EXECUTE 74 -#define X_HELP 75 -#define X_MENU 76 -#define X_SELECT 77 -#define X_STOP 78 -#define X_AGAIN 79 -#define X_UNDO 7a -#define X_CUT 7b -#define X_COPY 7c -#define X_PASTE 7d -#define X_FIND 7e -#define X__MUTE 7f -#define X__VOLUP 80 -#define X__VOLDOWN 81 -#define X_LOCKING_CAPS 82 -#define X_LOCKING_NUM 83 -#define X_LOCKING_SCROLL 84 -#define X_KP_COMMA 85 -#define X_KP_EQUAL_AS400 86 -#define X_INT1 87 -#define X_INT2 88 -#define X_INT3 89 -#define X_INT4 8a -#define X_INT5 8b -#define X_INT6 8c -#define X_INT7 8d -#define X_INT8 8e -#define X_INT9 8f -#define X_LANG1 90 -#define X_LANG2 91 -#define X_LANG3 92 -#define X_LANG4 93 -#define X_LANG5 94 -#define X_LANG6 95 -#define X_LANG7 96 -#define X_LANG8 97 -#define X_LANG9 98 -#define X_ALT_ERASE 99 -#define X_SYSREQ 9a -#define X_CANCEL 9b -#define X_CLEAR 9c -#define X_PRIOR 9d -#define X_RETURN 9e -#define X_SEPARATOR 9f -#define X_OUT a0 -#define X_OPER a1 -#define X_CLEAR_AGAIN a2 -#define X_CRSEL a3 -#define X_EXSEL a4 +#define X_A 04 +#define X_B 05 +#define X_C 06 +#define X_D 07 +#define X_E 08 +#define X_F 09 +#define X_G 0a +#define X_H 0b +#define X_I 0c +#define X_J 0d +#define X_K 0e +#define X_L 0f +#define X_M 10 +#define X_N 11 +#define X_O 12 +#define X_P 13 +#define X_Q 14 +#define X_R 15 +#define X_S 16 +#define X_T 17 +#define X_U 18 +#define X_V 19 +#define X_W 1a +#define X_X 1b +#define X_Y 1c +#define X_Z 1d +#define X_1 1e +#define X_2 1f +#define X_3 20 +#define X_4 21 +#define X_5 22 +#define X_6 23 +#define X_7 24 +#define X_8 25 +#define X_9 26 +#define X_0 27 +#define X_ENTER 28 +#define X_ESCAPE 29 +#define X_BACKSPACE 2a +#define X_TAB 2b +#define X_SPACE 2c +#define X_MINUS 2d +#define X_EQUAL 2e +#define X_LEFT_BRACKET 2f +#define X_RIGHT_BRACKET 30 +#define X_BACKSLASH 31 +#define X_NONUS_HASH 32 +#define X_SEMICOLON 33 +#define X_QUOTE 34 +#define X_GRAVE 35 +#define X_COMMA 36 +#define X_DOT 37 +#define X_SLASH 38 +#define X_CAPS_LOCK 39 +#define X_F1 3a +#define X_F2 3b +#define X_F3 3c +#define X_F4 3d +#define X_F5 3e +#define X_F6 3f +#define X_F7 40 +#define X_F8 41 +#define X_F9 42 +#define X_F10 43 +#define X_F11 44 +#define X_F12 45 +#define X_PRINT_SCREEN 46 +#define X_SCROLL_LOCK 47 +#define X_PAUSE 48 +#define X_INSERT 49 +#define X_HOME 4a +#define X_PAGE_UP 4b +#define X_DELETE 4c +#define X_END 4d +#define X_PAGE_DOWN 4e +#define X_RIGHT 4f +#define X_LEFT 50 +#define X_DOWN 51 +#define X_UP 52 +#define X_NUM_LOCK 53 +#define X_KP_SLASH 54 +#define X_KP_ASTERISK 55 +#define X_KP_MINUS 56 +#define X_KP_PLUS 57 +#define X_KP_ENTER 58 +#define X_KP_1 59 +#define X_KP_2 5a +#define X_KP_3 5b +#define X_KP_4 5c +#define X_KP_5 5d +#define X_KP_6 5e +#define X_KP_7 5f +#define X_KP_8 60 +#define X_KP_9 61 +#define X_KP_0 62 +#define X_KP_DOT 63 +#define X_NONUS_BACKSLASH 64 +#define X_APPLICATION 65 +#define X_KB_POWER 66 +#define X_KP_EQUAL 67 +#define X_F13 68 +#define X_F14 69 +#define X_F15 6a +#define X_F16 6b +#define X_F17 6c +#define X_F18 6d +#define X_F19 6e +#define X_F20 6f +#define X_F21 70 +#define X_F22 71 +#define X_F23 72 +#define X_F24 73 +#define X_EXECUTE 74 +#define X_HELP 75 +#define X_MENU 76 +#define X_SELECT 77 +#define X_STOP 78 +#define X_AGAIN 79 +#define X_UNDO 7a +#define X_CUT 7b +#define X_COPY 7c +#define X_PASTE 7d +#define X_FIND 7e +#define X_KB_MUTE 7f +#define X_KB_VOLUME_UP 80 +#define X_KB_VOLUME_DOWN 81 +#define X_LOCKING_CAPS_LOCK 82 +#define X_LOCKING_NUM_LOCK 83 +#define X_LOCKING_SCROLL_LOCK 84 +#define X_KP_COMMA 85 +#define X_KP_EQUAL_AS400 86 +#define X_INTERNATIONAL_1 87 +#define X_INTERNATIONAL_2 88 +#define X_INTERNATIONAL_3 89 +#define X_INTERNATIONAL_4 8a +#define X_INTERNATIONAL_5 8b +#define X_INTERNATIONAL_6 8c +#define X_INTERNATIONAL_7 8d +#define X_INTERNATIONAL_8 8e +#define X_INTERNATIONAL_9 8f +#define X_LANGUAGE_1 90 +#define X_LANGUAGE_2 91 +#define X_LANGUAGE_3 92 +#define X_LANGUAGE_4 93 +#define X_LANGUAGE_5 94 +#define X_LANGUAGE_6 95 +#define X_LANGUAGE_7 96 +#define X_LANGUAGE_8 97 +#define X_LANGUAGE_9 98 +#define X_ALTERNATE_ERASE 99 +#define X_SYSTEM_REQUEST 9a +#define X_CANCEL 9b +#define X_CLEAR 9c +#define X_PRIOR 9d +#define X_RETURN 9e +#define X_SEPARATOR 9f +#define X_OUT a0 +#define X_OPER a1 +#define X_CLEAR_AGAIN a2 +#define X_CRSEL a3 +#define X_EXSEL a4 /* Modifiers */ -#define X_LCTRL e0 -#define X_LSHIFT e1 -#define X_LALT e2 -#define X_LGUI e3 -#define X_RCTRL e4 -#define X_RSHIFT e5 -#define X_RALT e6 -#define X_RGUI e7 +#define X_LEFT_CTRL e0 +#define X_LEFT_SHIFT e1 +#define X_LEFT_ALT e2 +#define X_LEFT_GUI e3 +#define X_RIGHT_CTRL e4 +#define X_RIGHT_SHIFT e5 +#define X_RIGHT_ALT e6 +#define X_RIGHT_GUI e7 /* Media and Function keys */ /* Generic Desktop Page (0x01) */ -#define X_SYSTEM_POWER a5 -#define X_SYSTEM_SLEEP a6 -#define X_SYSTEM_WAKE a7 +#define X_SYSTEM_POWER a5 +#define X_SYSTEM_SLEEP a6 +#define X_SYSTEM_WAKE a7 /* Consumer Page (0x0C) */ -#define X_AUDIO_MUTE a8 -#define X_AUDIO_VOL_UP a9 -#define X_AUDIO_VOL_DOWN aa -#define X_MEDIA_NEXT_TRACK ab -#define X_MEDIA_PREV_TRACK ac -#define X_MEDIA_STOP ad -#define X_MEDIA_PLAY_PAUSE ae -#define X_MEDIA_SELECT af -#define X_MEDIA_EJECT b0 -#define X_MAIL b1 -#define X_CALCULATOR b2 -#define X_MY_COMPUTER b3 -#define X_WWW_SEARCH b4 -#define X_WWW_HOME b5 -#define X_WWW_BACK b6 -#define X_WWW_FORWARD b7 -#define X_WWW_STOP b8 -#define X_WWW_REFRESH b9 -#define X_WWW_FAVORITES ba -#define X_MEDIA_FAST_FORWARD bb -#define X_MEDIA_REWIND bc -#define X_BRIGHTNESS_UP bd -#define X_BRIGHTNESS_DOWN be +#define X_AUDIO_MUTE a8 +#define X_AUDIO_VOL_UP a9 +#define X_AUDIO_VOL_DOWN aa +#define X_MEDIA_NEXT_TRACK ab +#define X_MEDIA_PREV_TRACK ac +#define X_MEDIA_STOP ad +#define X_MEDIA_PLAY_PAUSE ae +#define X_MEDIA_SELECT af +#define X_MEDIA_EJECT b0 +#define X_MAIL b1 +#define X_CALCULATOR b2 +#define X_MY_COMPUTER b3 +#define X_WWW_SEARCH b4 +#define X_WWW_HOME b5 +#define X_WWW_BACK b6 +#define X_WWW_FORWARD b7 +#define X_WWW_STOP b8 +#define X_WWW_REFRESH b9 +#define X_WWW_FAVORITES ba +#define X_MEDIA_FAST_FORWARD bb +#define X_MEDIA_REWIND bc +#define X_BRIGHTNESS_UP bd +#define X_BRIGHTNESS_DOWN be +#define X_CONTROL_PANEL bf +#define X_ASSISTANT c0 /* Mouse Buttons (unallocated range in HID spec) */ #ifdef VIA_ENABLE -#define X_MS_UP f0 -#define X_MS_DOWN f1 -#define X_MS_LEFT f2 -#define X_MS_RIGHT f3 -#define X_MS_BTN1 f4 -#define X_MS_BTN2 f5 -#define X_MS_BTN3 f6 -#define X_MS_BTN4 f7 -#define X_MS_BTN5 f8 -#define X_MS_BTN6 f8 -#define X_MS_BTN7 f8 -#define X_MS_BTN8 f8 -#define X_MS_WH_UP f9 -#define X_MS_WH_DOWN fa -#define X_MS_WH_LEFT fb -#define X_MS_WH_RIGHT fc -#define X_MS_ACCEL0 fd -#define X_MS_ACCEL1 fe -#define X_MS_ACCEL2 ff +#define X_MS_UP f0 +#define X_MS_DOWN f1 +#define X_MS_LEFT f2 +#define X_MS_RIGHT f3 +#define X_MS_BTN1 f4 +#define X_MS_BTN2 f5 +#define X_MS_BTN3 f6 +#define X_MS_BTN4 f7 +#define X_MS_BTN5 f8 +#define X_MS_BTN6 f8 +#define X_MS_BTN7 f8 +#define X_MS_BTN8 f8 +#define X_MS_WH_UP f9 +#define X_MS_WH_DOWN fa +#define X_MS_WH_LEFT fb +#define X_MS_WH_RIGHT fc +#define X_MS_ACCEL0 fd +#define X_MS_ACCEL1 fe +#define X_MS_ACCEL2 ff #else -#define X_MS_UP cd -#define X_MS_DOWN ce -#define X_MS_LEFT cf -#define X_MS_RIGHT d0 -#define X_MS_BTN1 d1 -#define X_MS_BTN2 d2 -#define X_MS_BTN3 d3 -#define X_MS_BTN4 d4 -#define X_MS_BTN5 d5 -#define X_MS_BTN6 d6 -#define X_MS_BTN7 d7 -#define X_MS_BTN8 d8 -#define X_MS_WH_UP d9 -#define X_MS_WH_DOWN da -#define X_MS_WH_LEFT db -#define X_MS_WH_RIGHT dc -#define X_MS_ACCEL0 dd -#define X_MS_ACCEL1 de -#define X_MS_ACCEL2 df +#define X_MS_UP cd +#define X_MS_DOWN ce +#define X_MS_LEFT cf +#define X_MS_RIGHT d0 +#define X_MS_BTN1 d1 +#define X_MS_BTN2 d2 +#define X_MS_BTN3 d3 +#define X_MS_BTN4 d4 +#define X_MS_BTN5 d5 +#define X_MS_BTN6 d6 +#define X_MS_BTN7 d7 +#define X_MS_BTN8 d8 +#define X_MS_WH_UP d9 +#define X_MS_WH_DOWN da +#define X_MS_WH_LEFT db +#define X_MS_WH_RIGHT dc +#define X_MS_ACCEL0 dd +#define X_MS_ACCEL1 de +#define X_MS_ACCEL2 df #endif @@ -439,6 +466,3 @@ #define SS_ROPT(string) SS_RALT(string) #define SS_RCMD(string) SS_RGUI(string) #define SS_RWIN(string) SS_RGUI(string) - -// DEPRECATED -#define SS_LCTRL(string) SS_LCTL(string) -- cgit v1.2.3 From 9d4c4ceee13bfa229de6be2255e83c9c324259d6 Mon Sep 17 00:00:00 2001 From: Jamal Bouajjaj Date: Mon, 17 Oct 2022 17:26:58 -0400 Subject: 4 Driver support for IS31FL3737 (#18750) * Added 4 driver support for the IS31FL3737 LED driver * Updated docs for IS31FL3737 to support 4 drivers --- quantum/rgb_matrix/rgb_matrix_drivers.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'quantum') diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c index e75b2c6c9d..b4d23f8201 100644 --- a/quantum/rgb_matrix/rgb_matrix_drivers.c +++ b/quantum/rgb_matrix/rgb_matrix_drivers.c @@ -76,6 +76,12 @@ static void init(void) { IS31FL3737_init(DRIVER_ADDR_1); # if defined(DRIVER_ADDR_2) IS31FL3737_init(DRIVER_ADDR_2); +# if defined(DRIVER_ADDR_3) + IS31FL3737_init(DRIVER_ADDR_3); +# if defined(DRIVER_ADDR_4) + IS31FL3737_init(DRIVER_ADDR_4); +# endif +# endif # endif # elif defined(IS31FL3741) @@ -154,6 +160,12 @@ static void init(void) { IS31FL3737_update_led_control_registers(DRIVER_ADDR_1, 0); # if defined(DRIVER_ADDR_2) IS31FL3737_update_led_control_registers(DRIVER_ADDR_2, 1); +# if defined(DRIVER_ADDR_3) + IS31FL3737_update_led_control_registers(DRIVER_ADDR_3, 2); +# if defined(DRIVER_ADDR_4) + IS31FL3737_update_led_control_registers(DRIVER_ADDR_4, 3); +# endif +# endif # endif # elif defined(IS31FL3741) @@ -235,6 +247,12 @@ static void flush(void) { IS31FL3737_update_pwm_buffers(DRIVER_ADDR_1, 0); # if defined(DRIVER_ADDR_2) IS31FL3737_update_pwm_buffers(DRIVER_ADDR_2, 1); +# if defined(DRIVER_ADDR_3) + IS31FL3737_update_pwm_buffers(DRIVER_ADDR_3, 2); +# if defined(DRIVER_ADDR_4) + IS31FL3737_update_pwm_buffers(DRIVER_ADDR_4, 3); +# endif +# endif # endif } -- cgit v1.2.3 From e59cb51be01cf0428524596490eb1bff91e566bd Mon Sep 17 00:00:00 2001 From: QMK Bot Date: Mon, 17 Oct 2022 14:29:19 -0700 Subject: [CI] Format code according to conventions (#18756) --- quantum/rgb_matrix/rgb_matrix_drivers.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'quantum') diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c index b4d23f8201..5b81915845 100644 --- a/quantum/rgb_matrix/rgb_matrix_drivers.c +++ b/quantum/rgb_matrix/rgb_matrix_drivers.c @@ -76,12 +76,12 @@ static void init(void) { IS31FL3737_init(DRIVER_ADDR_1); # if defined(DRIVER_ADDR_2) IS31FL3737_init(DRIVER_ADDR_2); -# if defined(DRIVER_ADDR_3) +# if defined(DRIVER_ADDR_3) IS31FL3737_init(DRIVER_ADDR_3); -# if defined(DRIVER_ADDR_4) +# if defined(DRIVER_ADDR_4) IS31FL3737_init(DRIVER_ADDR_4); -# endif -# endif +# endif +# endif # endif # elif defined(IS31FL3741) @@ -160,12 +160,12 @@ static void init(void) { IS31FL3737_update_led_control_registers(DRIVER_ADDR_1, 0); # if defined(DRIVER_ADDR_2) IS31FL3737_update_led_control_registers(DRIVER_ADDR_2, 1); -# if defined(DRIVER_ADDR_3) +# if defined(DRIVER_ADDR_3) IS31FL3737_update_led_control_registers(DRIVER_ADDR_3, 2); -# if defined(DRIVER_ADDR_4) +# if defined(DRIVER_ADDR_4) IS31FL3737_update_led_control_registers(DRIVER_ADDR_4, 3); -# endif -# endif +# endif +# endif # endif # elif defined(IS31FL3741) @@ -247,12 +247,12 @@ static void flush(void) { IS31FL3737_update_pwm_buffers(DRIVER_ADDR_1, 0); # if defined(DRIVER_ADDR_2) IS31FL3737_update_pwm_buffers(DRIVER_ADDR_2, 1); -# if defined(DRIVER_ADDR_3) +# if defined(DRIVER_ADDR_3) IS31FL3737_update_pwm_buffers(DRIVER_ADDR_3, 2); -# if defined(DRIVER_ADDR_4) +# if defined(DRIVER_ADDR_4) IS31FL3737_update_pwm_buffers(DRIVER_ADDR_4, 3); -# endif -# endif +# endif +# endif # endif } -- cgit v1.2.3 From 18dc851e37a203b32db0261c365dd300488e1c71 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 19 Oct 2022 21:33:05 +1100 Subject: Remove legacy Debug keycode (#18769) * `DEBUG` -> `DB_TOGG`, default-ish keymaps * `DEBUG` -> `DB_TOGG`, user keymaps * `DEBUG` -> `DB_TOGG`, community layouts * `DEBUG` -> `DB_TOGG`, userspace * `DEBUG` -> `DB_TOGG`, docs & core --- quantum/quantum_keycodes_legacy.h | 1 - 1 file changed, 1 deletion(-) (limited to 'quantum') diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h index 1de81b4c0f..4a47b92847 100644 --- a/quantum/quantum_keycodes_legacy.h +++ b/quantum/quantum_keycodes_legacy.h @@ -4,7 +4,6 @@ // Deprecated Quantum keycodes -#define DEBUG QK_DEBUG_TOGGLE #define GRAVE_ESC QK_GRAVE_ESCAPE #define EEPROM_RESET QK_CLEAR_EEPROM -- cgit v1.2.3 From c347e732be6b50500c1651b3fb8c0753b0c9c40d Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 20 Oct 2022 22:20:07 +1100 Subject: Remove legacy EEPROM clear keycodes (#18782) * `EEP_RST` -> `EE_CLR`, default-ish keymaps * `EEP_RST` -> `EE_CLR`, user keymaps * `EEP_RST` -> `EE_CLR`, community layouts * `EEP_RST` -> `EE_CLR`, userspace * `EEP_RST` -> `EE_CLR`, docs & core --- quantum/quantum_keycodes_legacy.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'quantum') diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h index 4a47b92847..21a90a35f0 100644 --- a/quantum/quantum_keycodes_legacy.h +++ b/quantum/quantum_keycodes_legacy.h @@ -5,10 +5,8 @@ // Deprecated Quantum keycodes #define GRAVE_ESC QK_GRAVE_ESCAPE -#define EEPROM_RESET QK_CLEAR_EEPROM #define KC_GESC QK_GRAVE_ESCAPE -#define EEP_RST QK_CLEAR_EEPROM #define TERM_ON _Static_assert(false, "The Terminal feature has been removed from QMK. Please remove use of TERM_ON/TERM_OFF from your keymap.") #define TERM_OFF _Static_assert(false, "The Terminal feature has been removed from QMK.. Please remove use of TERM_ON/TERM_OFF from your keymap.") -- cgit v1.2.3 From af678521c1d786fe5578f82c2f671f5553b08dfe Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 21 Oct 2022 00:41:45 +1100 Subject: Remove quantum/audio from global VPATH (#18753) --- quantum/config_common.h | 4 +++- quantum/unicode/unicode.c | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'quantum') diff --git a/quantum/config_common.h b/quantum/config_common.h index d93477b27e..6ab8a2aa7d 100644 --- a/quantum/config_common.h +++ b/quantum/config_common.h @@ -24,4 +24,6 @@ #define COL2ROW 0 #define ROW2COL 1 -#include "song_list.h" +#ifdef AUDIO_ENABLE +# include "song_list.h" +#endif diff --git a/quantum/unicode/unicode.c b/quantum/unicode/unicode.c index 3f934c9277..e2bfd68a3a 100644 --- a/quantum/unicode/unicode.c +++ b/quantum/unicode/unicode.c @@ -23,10 +23,13 @@ #include "host.h" #include "keycode.h" #include "wait.h" -#include "audio.h" #include "send_string.h" #include "utf8.h" +#if defined(AUDIO_ENABLE) +# include "audio.h" +#endif + #if defined(UNICODE_ENABLE) + defined(UNICODEMAP_ENABLE) + defined(UCIS_ENABLE) > 1 # error "Cannot enable more than one Unicode method (UNICODE, UNICODEMAP, UCIS) at the same time" #endif -- cgit v1.2.3 From 1cb1a5a3744dc569fbe25c44004d860241fd26b1 Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 21 Oct 2022 12:04:11 +1100 Subject: Remove legacy Grave Escape keycodes (#18787) --- quantum/quantum_keycodes_legacy.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'quantum') diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h index 21a90a35f0..3a468d61f5 100644 --- a/quantum/quantum_keycodes_legacy.h +++ b/quantum/quantum_keycodes_legacy.h @@ -4,10 +4,6 @@ // Deprecated Quantum keycodes -#define GRAVE_ESC QK_GRAVE_ESCAPE - -#define KC_GESC QK_GRAVE_ESCAPE - #define TERM_ON _Static_assert(false, "The Terminal feature has been removed from QMK. Please remove use of TERM_ON/TERM_OFF from your keymap.") #define TERM_OFF _Static_assert(false, "The Terminal feature has been removed from QMK.. Please remove use of TERM_ON/TERM_OFF from your keymap.") // #define RESET _Static_assert(false, "The RESET keycode has been removed from QMK.. Please remove use from your keymap.") -- cgit v1.2.3 From b33fc349671148bff6f0a60172b53c51e59cda49 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 22 Oct 2022 00:25:54 +1100 Subject: Deprecate `KC_LEAD` for `QK_LEAD` (#18792) --- quantum/process_keycode/process_leader.c | 2 +- quantum/quantum.c | 2 +- quantum/quantum_keycodes.h | 5 ++++- quantum/quantum_keycodes_legacy.h | 2 ++ 4 files changed, 8 insertions(+), 3 deletions(-) (limited to 'quantum') diff --git a/quantum/process_keycode/process_leader.c b/quantum/process_keycode/process_leader.c index 3593f75f0d..7e6f3ad73c 100644 --- a/quantum/process_keycode/process_leader.c +++ b/quantum/process_keycode/process_leader.c @@ -72,7 +72,7 @@ bool process_leader(uint16_t keycode, keyrecord_t *record) { return false; } } else { - if (keycode == KC_LEAD) { + if (keycode == QK_LEADER) { qk_leader_start(); } } diff --git a/quantum/quantum.c b/quantum/quantum.c index 0f94e3855d..add7402550 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -225,7 +225,7 @@ bool process_record_quantum(keyrecord_t *record) { uint16_t keycode = get_record_keycode(record, true); // This is how you use actions here - // if (keycode == KC_LEAD) { + // if (keycode == QK_LEADER) { // action_t action; // action.code = ACTION_DEFAULT_LAYER_SET(0); // process_action(record, action); diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 939fab9298..f9268c833d 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -465,7 +465,7 @@ enum quantum_keycodes { JS_BUTTON31, // 5D28 // Leader Key - KC_LEAD, // 5D29 + QK_LEADER, // 5D29 // Bluetooth: output selection (continued) OUT_BT, // 5D2A @@ -846,6 +846,9 @@ enum quantum_keycodes { #define UC_M_WC UNICODE_MODE_WINC #define UC_M_EM UNICODE_MODE_EMACS +// Leader key +#define QK_LEAD QK_LEADER + // Swap Hands #define SH_T(kc) (QK_SWAP_HANDS | (kc)) #define SH_TG (QK_SWAP_HANDS | OP_SH_TOGGLE) diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h index 3a468d61f5..73c486492f 100644 --- a/quantum/quantum_keycodes_legacy.h +++ b/quantum/quantum_keycodes_legacy.h @@ -4,6 +4,8 @@ // Deprecated Quantum keycodes +#define KC_LEAD QK_LEADER + #define TERM_ON _Static_assert(false, "The Terminal feature has been removed from QMK. Please remove use of TERM_ON/TERM_OFF from your keymap.") #define TERM_OFF _Static_assert(false, "The Terminal feature has been removed from QMK.. Please remove use of TERM_ON/TERM_OFF from your keymap.") // #define RESET _Static_assert(false, "The RESET keycode has been removed from QMK.. Please remove use from your keymap.") -- cgit v1.2.3 From 7cbff9d921879ef3c54837cb2ffc455e019f45b4 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 22 Oct 2022 01:46:10 +1100 Subject: Deprecate `KC_LOCK` for `QK_LOCK` (#18796) --- quantum/process_keycode/process_key_lock.c | 8 ++++---- quantum/quantum_keycodes.h | 2 +- quantum/quantum_keycodes_legacy.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'quantum') diff --git a/quantum/process_keycode/process_key_lock.c b/quantum/process_keycode/process_key_lock.c index 941a2c5780..2542e32ec2 100644 --- a/quantum/process_keycode/process_key_lock.c +++ b/quantum/process_keycode/process_key_lock.c @@ -70,7 +70,7 @@ bool process_key_lock(uint16_t *keycode, keyrecord_t *record) { // reset the state in our map and return false. When the user releases the // key, the up event will no longer be masked and the OS will observe the // released key. - // 3. KC_LOCK was just pressed. In this case, we set up the state machine + // 3. QK_LOCK was just pressed. In this case, we set up the state machine // to watch for the next key down event, and finish processing // 4. The keycode is below 0xFF, and we are watching for new keys. In this case, // we will send the key down event to the os, and set the key_state for that @@ -95,20 +95,20 @@ bool process_key_lock(uint16_t *keycode, keyrecord_t *record) { if (record->event.pressed) { // Non-standard keycode, reset and return - if (!(IS_STANDARD_KEYCODE(translated_keycode) || translated_keycode == KC_LOCK)) { + if (!(IS_STANDARD_KEYCODE(translated_keycode) || translated_keycode == QK_LOCK)) { watching = false; return true; } // If we're already watching, turn off the watch. - if (translated_keycode == KC_LOCK) { + if (translated_keycode == QK_LOCK) { watching = !watching; return false; } if (IS_STANDARD_KEYCODE(translated_keycode)) { // We check watching first. This is so that in the following scenario, we continue to - // hold the key: KC_LOCK, KC_F, KC_LOCK, KC_F + // hold the key: QK_LOCK, KC_F, QK_LOCK, KC_F // If we checked in reverse order, we'd end up holding the key pressed after the second // KC_F press is registered, when the user likely meant to hold F if (watching) { diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index f9268c833d..57dbfa0509 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -471,7 +471,7 @@ enum quantum_keycodes { OUT_BT, // 5D2A // Lock Key - KC_LOCK, // 5D2B + QK_LOCK, // 5D2B // Unused slots UNUSED_000, // 5D2C diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h index 73c486492f..6a847f71a6 100644 --- a/quantum/quantum_keycodes_legacy.h +++ b/quantum/quantum_keycodes_legacy.h @@ -3,8 +3,8 @@ // clang-format off // Deprecated Quantum keycodes - #define KC_LEAD QK_LEADER +#define KC_LOCK QK_LOCK #define TERM_ON _Static_assert(false, "The Terminal feature has been removed from QMK. Please remove use of TERM_ON/TERM_OFF from your keymap.") #define TERM_OFF _Static_assert(false, "The Terminal feature has been removed from QMK.. Please remove use of TERM_ON/TERM_OFF from your keymap.") -- cgit v1.2.3 From 4f3af0920903b2253ea80fce9de55ed669ba2e8d Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 22 Oct 2022 07:43:55 +1100 Subject: Remove legacy fauxclicky and unicode keycodes (#18800) --- quantum/quantum_keycodes.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'quantum') diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 57dbfa0509..caf4d2b395 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -680,10 +680,6 @@ enum quantum_keycodes { #define CK_DOWN CLICKY_DOWN #define CK_ON CLICKY_ENABLE #define CK_OFF CLICKY_DISABLE -// Fauxclicky (deprecated) redirects to Audio Clicky -#define FC_ON CLICKY_ENABLE -#define FC_OFF CLICKY_DISABLE -#define FC_TOGG CLICKY_TOGGLE // RGB aliases #define RGB_MOD RGB_MODE_FORWARD @@ -838,8 +834,6 @@ enum quantum_keycodes { #define UC_RMOD UNICODE_MODE_REVERSE #define UC_M_MA UNICODE_MODE_MAC -#define UNICODE_MODE_OSX UNICODE_MODE_MAC // Deprecated alias -#define UC_M_OS UNICODE_MODE_MAC // Deprecated alias #define UC_M_LN UNICODE_MODE_LNX #define UC_M_WI UNICODE_MODE_WIN #define UC_M_BS UNICODE_MODE_BSD -- cgit v1.2.3 From 74484e21afc819b8e20f408aebc5c4e6cfdcc991 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 23 Oct 2022 07:45:20 +1100 Subject: Deprecate `VLK_TOG` for `VK_TOGG` (#18807) --- quantum/quantum.c | 2 +- quantum/quantum_keycodes.h | 5 ++++- quantum/quantum_keycodes_legacy.h | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'quantum') diff --git a/quantum/quantum.c b/quantum/quantum.c index add7402550..2c55f45e3b 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -379,7 +379,7 @@ bool process_record_quantum(keyrecord_t *record) { #endif return false; #ifdef VELOCIKEY_ENABLE - case VLK_TOG: + case QK_VELOCIKEY_TOGGLE: velocikey_toggle(); return false; #endif diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index caf4d2b395..44702a362d 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -359,7 +359,7 @@ enum quantum_keycodes { RGB_MODE_RGBTEST, // 5CD6 // Velocikey - VLK_TOG, // 5CD7 + QK_VELOCIKEY_TOGGLE, // 5CD7 // Space Cadet KC_LSPO, // 5CD8 @@ -743,6 +743,9 @@ enum quantum_keycodes { #define CRT_OFF AUTOCORRECT_OFF #define CRT_TOG AUTOCORRECT_TOGGLE +// Velocikey +#define VK_TOGG QK_VELOCIKEY_TOGGLE + // GOTO layer - 256 layer max #define TO(layer) (QK_TO | ((layer)&0xFF)) diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h index 6a847f71a6..db13d5973d 100644 --- a/quantum/quantum_keycodes_legacy.h +++ b/quantum/quantum_keycodes_legacy.h @@ -6,6 +6,8 @@ #define KC_LEAD QK_LEADER #define KC_LOCK QK_LOCK +#define VLK_TOG QK_VELOCIKEY_TOGGLE + #define TERM_ON _Static_assert(false, "The Terminal feature has been removed from QMK. Please remove use of TERM_ON/TERM_OFF from your keymap.") #define TERM_OFF _Static_assert(false, "The Terminal feature has been removed from QMK.. Please remove use of TERM_ON/TERM_OFF from your keymap.") // #define RESET _Static_assert(false, "The RESET keycode has been removed from QMK.. Please remove use from your keymap.") -- cgit v1.2.3 From 6bbe8b6eddc56d43f4db07c665bf1791ea2ab871 Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 25 Oct 2022 01:50:33 +1100 Subject: Normalise Joystick and Programmable Button keycodes (#18832) --- quantum/process_keycode/process_joystick.c | 6 +- .../process_keycode/process_programmable_button.c | 4 +- quantum/quantum_keycodes.h | 233 ++++++++++++--------- quantum/quantum_keycodes_legacy.h | 66 ++++++ 4 files changed, 204 insertions(+), 105 deletions(-) (limited to 'quantum') diff --git a/quantum/process_keycode/process_joystick.c b/quantum/process_keycode/process_joystick.c index af69d3aa05..c4c6fb59a8 100644 --- a/quantum/process_keycode/process_joystick.c +++ b/quantum/process_keycode/process_joystick.c @@ -19,11 +19,11 @@ bool process_joystick(uint16_t keycode, keyrecord_t *record) { switch (keycode) { - case JS_BUTTON0 ... JS_BUTTON_MAX: + case QK_JOYSTICK_BUTTON_MIN ... QK_JOYSTICK_BUTTON_MAX: if (record->event.pressed) { - register_joystick_button(keycode - JS_BUTTON0); + register_joystick_button(keycode - QK_JOYSTICK_BUTTON_MIN); } else { - unregister_joystick_button(keycode - JS_BUTTON0); + unregister_joystick_button(keycode - QK_JOYSTICK_BUTTON_MIN); } return false; } diff --git a/quantum/process_keycode/process_programmable_button.c b/quantum/process_keycode/process_programmable_button.c index 6379698848..d6a14e120c 100644 --- a/quantum/process_keycode/process_programmable_button.c +++ b/quantum/process_keycode/process_programmable_button.c @@ -19,8 +19,8 @@ along with this program. If not, see . #include "programmable_button.h" bool process_programmable_button(uint16_t keycode, keyrecord_t *record) { - if (keycode >= PROGRAMMABLE_BUTTON_MIN && keycode <= PROGRAMMABLE_BUTTON_MAX) { - uint8_t button = keycode - PROGRAMMABLE_BUTTON_MIN + 1; + if (keycode >= QK_PROGRAMMABLE_BUTTON_MIN && keycode <= QK_PROGRAMMABLE_BUTTON_MAX) { + uint8_t button = keycode - QK_PROGRAMMABLE_BUTTON_MIN + 1; if (record->event.pressed) { programmable_button_register(button); } else { diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 44702a362d..ac3968895b 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -431,38 +431,38 @@ enum quantum_keycodes { DYN_MACRO_PLAY2, // 5D08 // Joystick - JS_BUTTON0, // 5D09 - JS_BUTTON1, // 5D0A - JS_BUTTON2, // 5D0B - JS_BUTTON3, // 5D0C - JS_BUTTON4, // 5D0D - JS_BUTTON5, // 5D0E - JS_BUTTON6, // 5D0F - JS_BUTTON7, // 5D10 - JS_BUTTON8, // 5D11 - JS_BUTTON9, // 5D12 - JS_BUTTON10, // 5D13 - JS_BUTTON11, // 5D14 - JS_BUTTON12, // 5D15 - JS_BUTTON13, // 5D16 - JS_BUTTON14, // 5D17 - JS_BUTTON15, // 5D18 - JS_BUTTON16, // 5D19 - JS_BUTTON17, // 5D1A - JS_BUTTON18, // 5D1B - JS_BUTTON19, // 5D1C - JS_BUTTON20, // 5D1D - JS_BUTTON21, // 5D1E - JS_BUTTON22, // 5D1F - JS_BUTTON23, // 5D20 - JS_BUTTON24, // 5D21 - JS_BUTTON25, // 5D22 - JS_BUTTON26, // 5D23 - JS_BUTTON27, // 5D24 - JS_BUTTON28, // 5D25 - JS_BUTTON29, // 5D26 - JS_BUTTON30, // 5D27 - JS_BUTTON31, // 5D28 + QK_JOYSTICK_BUTTON_0, // 5D09 + QK_JOYSTICK_BUTTON_1, // 5D0A + QK_JOYSTICK_BUTTON_2, // 5D0B + QK_JOYSTICK_BUTTON_3, // 5D0C + QK_JOYSTICK_BUTTON_4, // 5D0D + QK_JOYSTICK_BUTTON_5, // 5D0E + QK_JOYSTICK_BUTTON_6, // 5D0F + QK_JOYSTICK_BUTTON_7, // 5D10 + QK_JOYSTICK_BUTTON_8, // 5D11 + QK_JOYSTICK_BUTTON_9, // 5D12 + QK_JOYSTICK_BUTTON_10, // 5D13 + QK_JOYSTICK_BUTTON_11, // 5D14 + QK_JOYSTICK_BUTTON_12, // 5D15 + QK_JOYSTICK_BUTTON_13, // 5D16 + QK_JOYSTICK_BUTTON_14, // 5D17 + QK_JOYSTICK_BUTTON_15, // 5D18 + QK_JOYSTICK_BUTTON_16, // 5D19 + QK_JOYSTICK_BUTTON_17, // 5D1A + QK_JOYSTICK_BUTTON_18, // 5D1B + QK_JOYSTICK_BUTTON_19, // 5D1C + QK_JOYSTICK_BUTTON_20, // 5D1D + QK_JOYSTICK_BUTTON_21, // 5D1E + QK_JOYSTICK_BUTTON_22, // 5D1F + QK_JOYSTICK_BUTTON_23, // 5D20 + QK_JOYSTICK_BUTTON_24, // 5D21 + QK_JOYSTICK_BUTTON_25, // 5D22 + QK_JOYSTICK_BUTTON_26, // 5D23 + QK_JOYSTICK_BUTTON_27, // 5D24 + QK_JOYSTICK_BUTTON_28, // 5D25 + QK_JOYSTICK_BUTTON_29, // 5D26 + QK_JOYSTICK_BUTTON_30, // 5D27 + QK_JOYSTICK_BUTTON_31, // 5D28 // Leader Key QK_LEADER, // 5D29 @@ -526,38 +526,38 @@ enum quantum_keycodes { DT_DOWN, // Programmable Button - PROGRAMMABLE_BUTTON_1, - PROGRAMMABLE_BUTTON_2, - PROGRAMMABLE_BUTTON_3, - PROGRAMMABLE_BUTTON_4, - PROGRAMMABLE_BUTTON_5, - PROGRAMMABLE_BUTTON_6, - PROGRAMMABLE_BUTTON_7, - PROGRAMMABLE_BUTTON_8, - PROGRAMMABLE_BUTTON_9, - PROGRAMMABLE_BUTTON_10, - PROGRAMMABLE_BUTTON_11, - PROGRAMMABLE_BUTTON_12, - PROGRAMMABLE_BUTTON_13, - PROGRAMMABLE_BUTTON_14, - PROGRAMMABLE_BUTTON_15, - PROGRAMMABLE_BUTTON_16, - PROGRAMMABLE_BUTTON_17, - PROGRAMMABLE_BUTTON_18, - PROGRAMMABLE_BUTTON_19, - PROGRAMMABLE_BUTTON_20, - PROGRAMMABLE_BUTTON_21, - PROGRAMMABLE_BUTTON_22, - PROGRAMMABLE_BUTTON_23, - PROGRAMMABLE_BUTTON_24, - PROGRAMMABLE_BUTTON_25, - PROGRAMMABLE_BUTTON_26, - PROGRAMMABLE_BUTTON_27, - PROGRAMMABLE_BUTTON_28, - PROGRAMMABLE_BUTTON_29, - PROGRAMMABLE_BUTTON_30, - PROGRAMMABLE_BUTTON_31, - PROGRAMMABLE_BUTTON_32, + QK_PROGRAMMABLE_BUTTON_1, + QK_PROGRAMMABLE_BUTTON_2, + QK_PROGRAMMABLE_BUTTON_3, + QK_PROGRAMMABLE_BUTTON_4, + QK_PROGRAMMABLE_BUTTON_5, + QK_PROGRAMMABLE_BUTTON_6, + QK_PROGRAMMABLE_BUTTON_7, + QK_PROGRAMMABLE_BUTTON_8, + QK_PROGRAMMABLE_BUTTON_9, + QK_PROGRAMMABLE_BUTTON_10, + QK_PROGRAMMABLE_BUTTON_11, + QK_PROGRAMMABLE_BUTTON_12, + QK_PROGRAMMABLE_BUTTON_13, + QK_PROGRAMMABLE_BUTTON_14, + QK_PROGRAMMABLE_BUTTON_15, + QK_PROGRAMMABLE_BUTTON_16, + QK_PROGRAMMABLE_BUTTON_17, + QK_PROGRAMMABLE_BUTTON_18, + QK_PROGRAMMABLE_BUTTON_19, + QK_PROGRAMMABLE_BUTTON_20, + QK_PROGRAMMABLE_BUTTON_21, + QK_PROGRAMMABLE_BUTTON_22, + QK_PROGRAMMABLE_BUTTON_23, + QK_PROGRAMMABLE_BUTTON_24, + QK_PROGRAMMABLE_BUTTON_25, + QK_PROGRAMMABLE_BUTTON_26, + QK_PROGRAMMABLE_BUTTON_27, + QK_PROGRAMMABLE_BUTTON_28, + QK_PROGRAMMABLE_BUTTON_29, + QK_PROGRAMMABLE_BUTTON_30, + QK_PROGRAMMABLE_BUTTON_31, + QK_PROGRAMMABLE_BUTTON_32, // Dedicated macro keys for Configurator and VIA MACRO_0, @@ -876,8 +876,40 @@ enum quantum_keycodes { #define DM_PLY2 DYN_MACRO_PLAY2 // Joystick aliases -#define JS_BUTTON_MIN JS_BUTTON0 -#define JS_BUTTON_MAX JS_BUTTON31 +#define JS_0 QK_JOYSTICK_BUTTON_0 +#define JS_1 QK_JOYSTICK_BUTTON_1 +#define JS_2 QK_JOYSTICK_BUTTON_2 +#define JS_3 QK_JOYSTICK_BUTTON_3 +#define JS_4 QK_JOYSTICK_BUTTON_4 +#define JS_5 QK_JOYSTICK_BUTTON_5 +#define JS_6 QK_JOYSTICK_BUTTON_6 +#define JS_7 QK_JOYSTICK_BUTTON_7 +#define JS_8 QK_JOYSTICK_BUTTON_8 +#define JS_9 QK_JOYSTICK_BUTTON_9 +#define JS_10 QK_JOYSTICK_BUTTON_10 +#define JS_11 QK_JOYSTICK_BUTTON_11 +#define JS_12 QK_JOYSTICK_BUTTON_12 +#define JS_13 QK_JOYSTICK_BUTTON_13 +#define JS_14 QK_JOYSTICK_BUTTON_14 +#define JS_15 QK_JOYSTICK_BUTTON_15 +#define JS_16 QK_JOYSTICK_BUTTON_16 +#define JS_17 QK_JOYSTICK_BUTTON_17 +#define JS_18 QK_JOYSTICK_BUTTON_18 +#define JS_19 QK_JOYSTICK_BUTTON_19 +#define JS_20 QK_JOYSTICK_BUTTON_20 +#define JS_21 QK_JOYSTICK_BUTTON_21 +#define JS_22 QK_JOYSTICK_BUTTON_22 +#define JS_23 QK_JOYSTICK_BUTTON_23 +#define JS_24 QK_JOYSTICK_BUTTON_24 +#define JS_25 QK_JOYSTICK_BUTTON_25 +#define JS_26 QK_JOYSTICK_BUTTON_26 +#define JS_27 QK_JOYSTICK_BUTTON_27 +#define JS_28 QK_JOYSTICK_BUTTON_28 +#define JS_29 QK_JOYSTICK_BUTTON_29 +#define JS_30 QK_JOYSTICK_BUTTON_30 +#define JS_31 QK_JOYSTICK_BUTTON_31 +#define QK_JOYSTICK_BUTTON_MIN QK_JOYSTICK_BUTTON_0 +#define QK_JOYSTICK_BUTTON_MAX QK_JOYSTICK_BUTTON_31 // One Shot aliases #define OS_TOGG ONESHOT_TOGGLE @@ -885,40 +917,41 @@ enum quantum_keycodes { #define OS_OFF ONESHOT_DISABLE // Programmable Button aliases -#define PB_1 PROGRAMMABLE_BUTTON_1 -#define PB_2 PROGRAMMABLE_BUTTON_2 -#define PB_3 PROGRAMMABLE_BUTTON_3 -#define PB_4 PROGRAMMABLE_BUTTON_4 -#define PB_5 PROGRAMMABLE_BUTTON_5 -#define PB_6 PROGRAMMABLE_BUTTON_6 -#define PB_7 PROGRAMMABLE_BUTTON_7 -#define PB_8 PROGRAMMABLE_BUTTON_8 -#define PB_9 PROGRAMMABLE_BUTTON_9 -#define PB_10 PROGRAMMABLE_BUTTON_10 -#define PB_11 PROGRAMMABLE_BUTTON_11 -#define PB_12 PROGRAMMABLE_BUTTON_12 -#define PB_13 PROGRAMMABLE_BUTTON_13 -#define PB_14 PROGRAMMABLE_BUTTON_14 -#define PB_15 PROGRAMMABLE_BUTTON_15 -#define PB_16 PROGRAMMABLE_BUTTON_16 -#define PB_17 PROGRAMMABLE_BUTTON_17 -#define PB_18 PROGRAMMABLE_BUTTON_18 -#define PB_19 PROGRAMMABLE_BUTTON_19 -#define PB_20 PROGRAMMABLE_BUTTON_20 -#define PB_21 PROGRAMMABLE_BUTTON_21 -#define PB_22 PROGRAMMABLE_BUTTON_22 -#define PB_23 PROGRAMMABLE_BUTTON_23 -#define PB_24 PROGRAMMABLE_BUTTON_24 -#define PB_25 PROGRAMMABLE_BUTTON_25 -#define PB_26 PROGRAMMABLE_BUTTON_26 -#define PB_27 PROGRAMMABLE_BUTTON_27 -#define PB_28 PROGRAMMABLE_BUTTON_28 -#define PB_29 PROGRAMMABLE_BUTTON_29 -#define PB_30 PROGRAMMABLE_BUTTON_30 -#define PB_31 PROGRAMMABLE_BUTTON_31 -#define PB_32 PROGRAMMABLE_BUTTON_32 -#define PROGRAMMABLE_BUTTON_MIN PROGRAMMABLE_BUTTON_1 -#define PROGRAMMABLE_BUTTON_MAX PROGRAMMABLE_BUTTON_32 +#define PB_1 QK_PROGRAMMABLE_BUTTON_1 +#define PB_2 QK_PROGRAMMABLE_BUTTON_2 +#define PB_3 QK_PROGRAMMABLE_BUTTON_3 +#define PB_4 QK_PROGRAMMABLE_BUTTON_4 +#define PB_5 QK_PROGRAMMABLE_BUTTON_5 +#define PB_6 QK_PROGRAMMABLE_BUTTON_6 +#define PB_7 QK_PROGRAMMABLE_BUTTON_7 +#define PB_8 QK_PROGRAMMABLE_BUTTON_8 +#define PB_9 QK_PROGRAMMABLE_BUTTON_9 +#define PB_10 QK_PROGRAMMABLE_BUTTON_10 +#define PB_11 QK_PROGRAMMABLE_BUTTON_11 +#define PB_12 QK_PROGRAMMABLE_BUTTON_12 +#define PB_13 QK_PROGRAMMABLE_BUTTON_13 +#define PB_14 QK_PROGRAMMABLE_BUTTON_14 +#define PB_15 QK_PROGRAMMABLE_BUTTON_15 +#define PB_16 QK_PROGRAMMABLE_BUTTON_16 +#define PB_17 QK_PROGRAMMABLE_BUTTON_17 +#define PB_18 QK_PROGRAMMABLE_BUTTON_18 +#define PB_19 QK_PROGRAMMABLE_BUTTON_19 +#define PB_20 QK_PROGRAMMABLE_BUTTON_20 +#define PB_21 QK_PROGRAMMABLE_BUTTON_21 +#define PB_22 QK_PROGRAMMABLE_BUTTON_22 +#define PB_23 QK_PROGRAMMABLE_BUTTON_23 +#define PB_24 QK_PROGRAMMABLE_BUTTON_24 +#define PB_25 QK_PROGRAMMABLE_BUTTON_25 +#define PB_26 QK_PROGRAMMABLE_BUTTON_26 +#define PB_27 QK_PROGRAMMABLE_BUTTON_27 +#define PB_28 QK_PROGRAMMABLE_BUTTON_28 +#define PB_29 QK_PROGRAMMABLE_BUTTON_29 +#define PB_30 QK_PROGRAMMABLE_BUTTON_30 +#define PB_31 QK_PROGRAMMABLE_BUTTON_31 +#define PB_32 QK_PROGRAMMABLE_BUTTON_32 +#define QK_PROGRAMMABLE_BUTTON_MIN QK_PROGRAMMABLE_BUTTON_1 +#define QK_PROGRAMMABLE_BUTTON_MAX QK_PROGRAMMABLE_BUTTON_32 + #define CAPSWRD CAPS_WORD #include "quantum_keycodes_legacy.h" diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h index db13d5973d..bab34025cf 100644 --- a/quantum/quantum_keycodes_legacy.h +++ b/quantum/quantum_keycodes_legacy.h @@ -8,6 +8,72 @@ #define VLK_TOG QK_VELOCIKEY_TOGGLE +#define PROGRAMMABLE_BUTTON_1 QK_PROGRAMMABLE_BUTTON_1 +#define PROGRAMMABLE_BUTTON_2 QK_PROGRAMMABLE_BUTTON_2 +#define PROGRAMMABLE_BUTTON_3 QK_PROGRAMMABLE_BUTTON_3 +#define PROGRAMMABLE_BUTTON_4 QK_PROGRAMMABLE_BUTTON_4 +#define PROGRAMMABLE_BUTTON_5 QK_PROGRAMMABLE_BUTTON_5 +#define PROGRAMMABLE_BUTTON_6 QK_PROGRAMMABLE_BUTTON_6 +#define PROGRAMMABLE_BUTTON_7 QK_PROGRAMMABLE_BUTTON_7 +#define PROGRAMMABLE_BUTTON_8 QK_PROGRAMMABLE_BUTTON_8 +#define PROGRAMMABLE_BUTTON_9 QK_PROGRAMMABLE_BUTTON_9 +#define PROGRAMMABLE_BUTTON_10 QK_PROGRAMMABLE_BUTTON_10 +#define PROGRAMMABLE_BUTTON_11 QK_PROGRAMMABLE_BUTTON_11 +#define PROGRAMMABLE_BUTTON_12 QK_PROGRAMMABLE_BUTTON_12 +#define PROGRAMMABLE_BUTTON_13 QK_PROGRAMMABLE_BUTTON_13 +#define PROGRAMMABLE_BUTTON_14 QK_PROGRAMMABLE_BUTTON_14 +#define PROGRAMMABLE_BUTTON_15 QK_PROGRAMMABLE_BUTTON_15 +#define PROGRAMMABLE_BUTTON_16 QK_PROGRAMMABLE_BUTTON_16 +#define PROGRAMMABLE_BUTTON_17 QK_PROGRAMMABLE_BUTTON_17 +#define PROGRAMMABLE_BUTTON_18 QK_PROGRAMMABLE_BUTTON_18 +#define PROGRAMMABLE_BUTTON_19 QK_PROGRAMMABLE_BUTTON_19 +#define PROGRAMMABLE_BUTTON_20 QK_PROGRAMMABLE_BUTTON_20 +#define PROGRAMMABLE_BUTTON_21 QK_PROGRAMMABLE_BUTTON_21 +#define PROGRAMMABLE_BUTTON_22 QK_PROGRAMMABLE_BUTTON_22 +#define PROGRAMMABLE_BUTTON_23 QK_PROGRAMMABLE_BUTTON_23 +#define PROGRAMMABLE_BUTTON_24 QK_PROGRAMMABLE_BUTTON_24 +#define PROGRAMMABLE_BUTTON_25 QK_PROGRAMMABLE_BUTTON_25 +#define PROGRAMMABLE_BUTTON_26 QK_PROGRAMMABLE_BUTTON_26 +#define PROGRAMMABLE_BUTTON_27 QK_PROGRAMMABLE_BUTTON_27 +#define PROGRAMMABLE_BUTTON_28 QK_PROGRAMMABLE_BUTTON_28 +#define PROGRAMMABLE_BUTTON_29 QK_PROGRAMMABLE_BUTTON_29 +#define PROGRAMMABLE_BUTTON_30 QK_PROGRAMMABLE_BUTTON_30 +#define PROGRAMMABLE_BUTTON_31 QK_PROGRAMMABLE_BUTTON_31 +#define PROGRAMMABLE_BUTTON_32 QK_PROGRAMMABLE_BUTTON_32 + +#define JS_BUTTON0 QK_JOYSTICK_BUTTON_0 +#define JS_BUTTON1 QK_JOYSTICK_BUTTON_1 +#define JS_BUTTON2 QK_JOYSTICK_BUTTON_2 +#define JS_BUTTON3 QK_JOYSTICK_BUTTON_3 +#define JS_BUTTON4 QK_JOYSTICK_BUTTON_4 +#define JS_BUTTON5 QK_JOYSTICK_BUTTON_5 +#define JS_BUTTON6 QK_JOYSTICK_BUTTON_6 +#define JS_BUTTON7 QK_JOYSTICK_BUTTON_7 +#define JS_BUTTON8 QK_JOYSTICK_BUTTON_8 +#define JS_BUTTON9 QK_JOYSTICK_BUTTON_9 +#define JS_BUTTON10 QK_JOYSTICK_BUTTON_10 +#define JS_BUTTON11 QK_JOYSTICK_BUTTON_11 +#define JS_BUTTON12 QK_JOYSTICK_BUTTON_12 +#define JS_BUTTON13 QK_JOYSTICK_BUTTON_13 +#define JS_BUTTON14 QK_JOYSTICK_BUTTON_14 +#define JS_BUTTON15 QK_JOYSTICK_BUTTON_15 +#define JS_BUTTON16 QK_JOYSTICK_BUTTON_16 +#define JS_BUTTON17 QK_JOYSTICK_BUTTON_17 +#define JS_BUTTON18 QK_JOYSTICK_BUTTON_18 +#define JS_BUTTON19 QK_JOYSTICK_BUTTON_19 +#define JS_BUTTON20 QK_JOYSTICK_BUTTON_20 +#define JS_BUTTON21 QK_JOYSTICK_BUTTON_21 +#define JS_BUTTON22 QK_JOYSTICK_BUTTON_22 +#define JS_BUTTON23 QK_JOYSTICK_BUTTON_23 +#define JS_BUTTON24 QK_JOYSTICK_BUTTON_24 +#define JS_BUTTON25 QK_JOYSTICK_BUTTON_25 +#define JS_BUTTON26 QK_JOYSTICK_BUTTON_26 +#define JS_BUTTON27 QK_JOYSTICK_BUTTON_27 +#define JS_BUTTON28 QK_JOYSTICK_BUTTON_28 +#define JS_BUTTON29 QK_JOYSTICK_BUTTON_29 +#define JS_BUTTON30 QK_JOYSTICK_BUTTON_30 +#define JS_BUTTON31 QK_JOYSTICK_BUTTON_31 + #define TERM_ON _Static_assert(false, "The Terminal feature has been removed from QMK. Please remove use of TERM_ON/TERM_OFF from your keymap.") #define TERM_OFF _Static_assert(false, "The Terminal feature has been removed from QMK.. Please remove use of TERM_ON/TERM_OFF from your keymap.") // #define RESET _Static_assert(false, "The RESET keycode has been removed from QMK.. Please remove use from your keymap.") -- cgit v1.2.3 From a80b886751aaddb0e030a14a82cf99b6778145b4 Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 25 Oct 2022 03:30:37 +1100 Subject: Deprecate `CAPS_WORD`/`CAPSWRD` for `CW_TOGG` (#18834) --- quantum/process_keycode/process_caps_word.c | 2 +- quantum/quantum_keycodes.h | 7 ++++--- quantum/quantum_keycodes_legacy.h | 2 ++ 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'quantum') diff --git a/quantum/process_keycode/process_caps_word.c b/quantum/process_keycode/process_caps_word.c index 1b9583196d..7a83f7bf49 100644 --- a/quantum/process_keycode/process_caps_word.c +++ b/quantum/process_keycode/process_caps_word.c @@ -15,7 +15,7 @@ #include "process_caps_word.h" bool process_caps_word(uint16_t keycode, keyrecord_t* record) { - if (keycode == CAPSWRD) { // Pressing CAPSWRD toggles Caps Word. + if (keycode == QK_CAPS_WORD_TOGGLE) { if (record->event.pressed) { caps_word_toggle(); } diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index ac3968895b..2e2ba8cd81 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -603,7 +603,7 @@ enum quantum_keycodes { SECURE_TOGGLE, SECURE_REQUEST, - CAPS_WORD, + QK_CAPS_WORD_TOGGLE, MAGIC_SWAP_ESCAPE_CAPSLOCK, MAGIC_UNSWAP_ESCAPE_CAPSLOCK, @@ -846,6 +846,9 @@ enum quantum_keycodes { // Leader key #define QK_LEAD QK_LEADER +// Caps Word +#define CW_TOGG QK_CAPS_WORD_TOGGLE + // Swap Hands #define SH_T(kc) (QK_SWAP_HANDS | (kc)) #define SH_TG (QK_SWAP_HANDS | OP_SH_TOGGLE) @@ -952,6 +955,4 @@ enum quantum_keycodes { #define QK_PROGRAMMABLE_BUTTON_MIN QK_PROGRAMMABLE_BUTTON_1 #define QK_PROGRAMMABLE_BUTTON_MAX QK_PROGRAMMABLE_BUTTON_32 -#define CAPSWRD CAPS_WORD - #include "quantum_keycodes_legacy.h" diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h index bab34025cf..40aa0f49a1 100644 --- a/quantum/quantum_keycodes_legacy.h +++ b/quantum/quantum_keycodes_legacy.h @@ -7,6 +7,8 @@ #define KC_LOCK QK_LOCK #define VLK_TOG QK_VELOCIKEY_TOGGLE +#define CAPSWRD QK_CAPS_WORD_TOGGLE +#define CAPS_WORD QK_CAPS_WORD_TOGGLE #define PROGRAMMABLE_BUTTON_1 QK_PROGRAMMABLE_BUTTON_1 #define PROGRAMMABLE_BUTTON_2 QK_PROGRAMMABLE_BUTTON_2 -- cgit v1.2.3 From e863c431f61565f41cf28fa7e981bdb3cba4f642 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Mon, 24 Oct 2022 23:02:21 -0600 Subject: added BS_TOGG so BS_SWAP and BS_NORM can be on a single key (#18837) Co-authored-by: Selene ToyKeeper --- quantum/process_keycode/process_magic.c | 4 ++++ quantum/quantum_keycodes.h | 3 +++ 2 files changed, 7 insertions(+) (limited to 'quantum') diff --git a/quantum/process_keycode/process_magic.c b/quantum/process_keycode/process_magic.c index ae60f29bf5..50816c5261 100644 --- a/quantum/process_keycode/process_magic.c +++ b/quantum/process_keycode/process_magic.c @@ -45,6 +45,7 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) { case MAGIC_SWAP_LCTL_LGUI ... MAGIC_EE_HANDS_RIGHT: case MAGIC_TOGGLE_GUI: case MAGIC_TOGGLE_CONTROL_CAPSLOCK: + case MAGIC_TOGGLE_BACKSLASH_BACKSPACE: case MAGIC_SWAP_ESCAPE_CAPSLOCK ... MAGIC_TOGGLE_ESCAPE_CAPSLOCK: /* keymap config */ keymap_config.raw = eeconfig_read_keymap(); @@ -163,6 +164,9 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) { } #endif break; + case MAGIC_TOGGLE_BACKSLASH_BACKSPACE: + keymap_config.swap_backslash_backspace = !keymap_config.swap_backslash_backspace; + break; case MAGIC_TOGGLE_NKRO: clear_keyboard(); // clear first buffer to prevent stuck keys keymap_config.nkro = !keymap_config.nkro; diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 2e2ba8cd81..7bd270cfd5 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -615,6 +615,8 @@ enum quantum_keycodes { AUTOCORRECT_OFF, AUTOCORRECT_TOGGLE, + MAGIC_TOGGLE_BACKSLASH_BACKSPACE, + // Start of custom keycode range for keyboards and keymaps - always leave at the end SAFE_RANGE }; @@ -731,6 +733,7 @@ enum quantum_keycodes { #define BS_SWAP MAGIC_SWAP_BACKSLASH_BACKSPACE #define BS_NORM MAGIC_UNSWAP_BACKSLASH_BACKSPACE +#define BS_TOGG MAGIC_TOGGLE_BACKSLASH_BACKSPACE #define NK_ON MAGIC_HOST_NKRO #define NK_OFF MAGIC_UNHOST_NKRO -- cgit v1.2.3 From 4f63be4d1d44c7d4a154c14a982186e0ca27ceba Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Tue, 25 Oct 2022 06:07:34 +0100 Subject: Remove some assumptions on sequential keycode ranges (#18838) --- quantum/process_keycode/process_autocorrect.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'quantum') diff --git a/quantum/process_keycode/process_autocorrect.c b/quantum/process_keycode/process_autocorrect.c index abae5e7811..f19ca4a90b 100644 --- a/quantum/process_keycode/process_autocorrect.c +++ b/quantum/process_keycode/process_autocorrect.c @@ -73,8 +73,13 @@ __attribute__((weak)) bool process_autocorrect_user(uint16_t *keycode, keyrecord case KC_LSFT: case KC_RSFT: case KC_CAPS: - case QK_TO ... QK_ONE_SHOT_LAYER_MAX: - case QK_LAYER_TAP_TOGGLE ... QK_LAYER_MOD_MAX: + case QK_TO ... QK_TO_MAX: + case QK_MOMENTARY ... QK_MOMENTARY_MAX: + case QK_DEF_LAYER ... QK_DEF_LAYER_MAX: + case QK_TOGGLE_LAYER ... QK_TOGGLE_LAYER_MAX: + case QK_ONE_SHOT_LAYER ... QK_ONE_SHOT_LAYER_MAX: + case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX: + case QK_LAYER_MOD ... QK_LAYER_MOD_MAX: case QK_ONE_SHOT_MOD ... QK_ONE_SHOT_MOD_MAX: return false; -- cgit v1.2.3 From 1d34f380eb2717169c59fb4eb59bb1824a1f7187 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 26 Oct 2022 00:45:57 +1100 Subject: Deprecate `KEY_OVERRIDE_*` keycodes for `KO_*` (#18843) --- quantum/process_keycode/process_key_override.c | 6 +++--- quantum/quantum_keycodes.h | 11 ++++++++--- quantum/quantum_keycodes_legacy.h | 4 ++++ 3 files changed, 15 insertions(+), 6 deletions(-) (limited to 'quantum') diff --git a/quantum/process_keycode/process_key_override.c b/quantum/process_keycode/process_key_override.c index ad9683d106..9c5abccd4f 100644 --- a/quantum/process_keycode/process_key_override.c +++ b/quantum/process_keycode/process_key_override.c @@ -406,15 +406,15 @@ bool process_key_override(const uint16_t keycode, const keyrecord_t *const recor if (key_down) { switch (keycode) { - case KEY_OVERRIDE_TOGGLE: + case QK_KEY_OVERRIDE_TOGGLE: key_override_toggle(); return false; - case KEY_OVERRIDE_ON: + case QK_KEY_OVERRIDE_ON: key_override_on(); return false; - case KEY_OVERRIDE_OFF: + case QK_KEY_OVERRIDE_OFF: key_override_off(); return false; diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 7bd270cfd5..06cc7835ae 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -513,9 +513,9 @@ enum quantum_keycodes { RGB_MODE_TWINKLE, // Key Overrides - KEY_OVERRIDE_TOGGLE, - KEY_OVERRIDE_ON, - KEY_OVERRIDE_OFF, + QK_KEY_OVERRIDE_TOGGLE, + QK_KEY_OVERRIDE_ON, + QK_KEY_OVERRIDE_OFF, // Additional magic key MAGIC_TOGGLE_GUI, @@ -852,6 +852,11 @@ enum quantum_keycodes { // Caps Word #define CW_TOGG QK_CAPS_WORD_TOGGLE +// Key Overrides +#define KO_TOGG QK_KEY_OVERRIDE_TOGGLE +#define KO_ON QK_KEY_OVERRIDE_ON +#define KO_OFF QK_KEY_OVERRIDE_OFF + // Swap Hands #define SH_T(kc) (QK_SWAP_HANDS | (kc)) #define SH_TG (QK_SWAP_HANDS | OP_SH_TOGGLE) diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h index 40aa0f49a1..858875a58d 100644 --- a/quantum/quantum_keycodes_legacy.h +++ b/quantum/quantum_keycodes_legacy.h @@ -10,6 +10,10 @@ #define CAPSWRD QK_CAPS_WORD_TOGGLE #define CAPS_WORD QK_CAPS_WORD_TOGGLE +#define KEY_OVERRIDE_TOGGLE QK_KEY_OVERRIDE_TOGGLE +#define KEY_OVERRIDE_ON QK_KEY_OVERRIDE_ON +#define KEY_OVERRIDE_OFF QK_KEY_OVERRIDE_OFF + #define PROGRAMMABLE_BUTTON_1 QK_PROGRAMMABLE_BUTTON_1 #define PROGRAMMABLE_BUTTON_2 QK_PROGRAMMABLE_BUTTON_2 #define PROGRAMMABLE_BUTTON_3 QK_PROGRAMMABLE_BUTTON_3 -- cgit v1.2.3 From 812001de7fd0926f59fd399550f902ef4ec03ee6 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 26 Oct 2022 03:50:22 +1100 Subject: Deprecate `ONESHOT_*` keycodes for `QK_ONE_SHOT_*` (#18844) * Deprecate `ONESHOT_*` keycodes for `QK_ONE_SHOT_*` * Docs --- quantum/quantum.c | 6 +++--- quantum/quantum_keycodes.h | 12 ++++++------ quantum/quantum_keycodes_legacy.h | 4 ++++ 3 files changed, 13 insertions(+), 9 deletions(-) (limited to 'quantum') diff --git a/quantum/quantum.c b/quantum/quantum.c index 2c55f45e3b..2333357be1 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -395,13 +395,13 @@ bool process_record_quantum(keyrecord_t *record) { return false; #endif #ifndef NO_ACTION_ONESHOT - case ONESHOT_TOGGLE: + case QK_ONE_SHOT_TOGGLE: oneshot_toggle(); break; - case ONESHOT_ENABLE: + case QK_ONE_SHOT_ON: oneshot_enable(); break; - case ONESHOT_DISABLE: + case QK_ONE_SHOT_OFF: oneshot_disable(); break; #endif diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 06cc7835ae..8689b913ed 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -505,9 +505,9 @@ enum quantum_keycodes { #define SQ_T(n) (n < SEQUENCER_TRACKS ? SEQUENCER_TRACK_MIN + n : KC_NO) // One Shot - ONESHOT_ENABLE, - ONESHOT_DISABLE, - ONESHOT_TOGGLE, + QK_ONE_SHOT_ON, + QK_ONE_SHOT_OFF, + QK_ONE_SHOT_TOGGLE, // RGB underglow/matrix (continued) RGB_MODE_TWINKLE, @@ -923,9 +923,9 @@ enum quantum_keycodes { #define QK_JOYSTICK_BUTTON_MAX QK_JOYSTICK_BUTTON_31 // One Shot aliases -#define OS_TOGG ONESHOT_TOGGLE -#define OS_ON ONESHOT_ENABLE -#define OS_OFF ONESHOT_DISABLE +#define OS_TOGG QK_ONE_SHOT_TOGGLE +#define OS_ON QK_ONE_SHOT_ON +#define OS_OFF QK_ONE_SHOT_OFF // Programmable Button aliases #define PB_1 QK_PROGRAMMABLE_BUTTON_1 diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h index 858875a58d..f53b8ef72a 100644 --- a/quantum/quantum_keycodes_legacy.h +++ b/quantum/quantum_keycodes_legacy.h @@ -14,6 +14,10 @@ #define KEY_OVERRIDE_ON QK_KEY_OVERRIDE_ON #define KEY_OVERRIDE_OFF QK_KEY_OVERRIDE_OFF +#define ONESHOT_ENABLE QK_ONE_SHOT_ON +#define ONESHOT_DISABLE QK_ONE_SHOT_OFF +#define ONESHOT_TOGGLE QK_ONE_SHOT_TOGGLE + #define PROGRAMMABLE_BUTTON_1 QK_PROGRAMMABLE_BUTTON_1 #define PROGRAMMABLE_BUTTON_2 QK_PROGRAMMABLE_BUTTON_2 #define PROGRAMMABLE_BUTTON_3 QK_PROGRAMMABLE_BUTTON_3 -- cgit v1.2.3 From ec2414c0742277488adf83d26451e07d0e0402de Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Tue, 25 Oct 2022 22:59:17 +0100 Subject: Deprecate `SECURE_*` keycodes for `QK_SECURE_*` (#18847) * Deprecate SECURE_* keycodes for QK_SECURE_* * Update keycode process * Update process_secure.c * Apply suggestions from code review Co-authored-by: Ryan Co-authored-by: Ryan --- quantum/process_keycode/process_secure.c | 8 ++++---- quantum/quantum_keycodes.h | 14 ++++++++++---- quantum/quantum_keycodes_legacy.h | 5 +++++ 3 files changed, 19 insertions(+), 8 deletions(-) (limited to 'quantum') diff --git a/quantum/process_keycode/process_secure.c b/quantum/process_keycode/process_secure.c index 3224104c99..894051fb33 100644 --- a/quantum/process_keycode/process_secure.c +++ b/quantum/process_keycode/process_secure.c @@ -23,19 +23,19 @@ bool preprocess_secure(uint16_t keycode, keyrecord_t *record) { bool process_secure(uint16_t keycode, keyrecord_t *record) { #ifndef SECURE_DISABLE_KEYCODES if (!record->event.pressed) { - if (keycode == SECURE_LOCK) { + if (keycode == QK_SECURE_LOCK) { secure_lock(); return false; } - if (keycode == SECURE_UNLOCK) { + if (keycode == QK_SECURE_UNLOCK) { secure_unlock(); return false; } - if (keycode == SECURE_TOGGLE) { + if (keycode == QK_SECURE_TOGGLE) { secure_is_locked() ? secure_unlock() : secure_lock(); return false; } - if (keycode == SECURE_REQUEST) { + if (keycode == QK_SECURE_REQUEST) { secure_request_unlock(); return false; } diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 8689b913ed..c5b9342b17 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -598,10 +598,10 @@ enum quantum_keycodes { QK_MAKE, QK_REBOOT, - SECURE_LOCK, - SECURE_UNLOCK, - SECURE_TOGGLE, - SECURE_REQUEST, + QK_SECURE_LOCK, + QK_SECURE_UNLOCK, + QK_SECURE_TOGGLE, + QK_SECURE_REQUEST, QK_CAPS_WORD_TOGGLE, @@ -857,6 +857,12 @@ enum quantum_keycodes { #define KO_ON QK_KEY_OVERRIDE_ON #define KO_OFF QK_KEY_OVERRIDE_OFF +// Secure +#define SE_LOCK QK_SECURE_LOCK +#define SE_UNLK QK_SECURE_UNLOCK +#define SE_TOGG QK_SECURE_TOGGLE +#define SE_REQ QK_SECURE_REQUEST + // Swap Hands #define SH_T(kc) (QK_SWAP_HANDS | (kc)) #define SH_TG (QK_SWAP_HANDS | OP_SH_TOGGLE) diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h index f53b8ef72a..652aaaa9a8 100644 --- a/quantum/quantum_keycodes_legacy.h +++ b/quantum/quantum_keycodes_legacy.h @@ -84,6 +84,11 @@ #define JS_BUTTON30 QK_JOYSTICK_BUTTON_30 #define JS_BUTTON31 QK_JOYSTICK_BUTTON_31 +#define SECURE_LOCK QK_SECURE_LOCK +#define SECURE_UNLOCK QK_SECURE_UNLOCK +#define SECURE_TOGGLE QK_SECURE_TOGGLE +#define SECURE_REQUEST QK_SECURE_REQUEST + #define TERM_ON _Static_assert(false, "The Terminal feature has been removed from QMK. Please remove use of TERM_ON/TERM_OFF from your keymap.") #define TERM_OFF _Static_assert(false, "The Terminal feature has been removed from QMK.. Please remove use of TERM_ON/TERM_OFF from your keymap.") // #define RESET _Static_assert(false, "The RESET keycode has been removed from QMK.. Please remove use from your keymap.") -- cgit v1.2.3 From 2a61bfc27d6915877d18a09bc440d462a2051857 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Wed, 26 Oct 2022 13:49:44 -0600 Subject: add "inertia" mode for mouse keys (#18774) Co-authored-by: Selene ToyKeeper --- quantum/mousekey.c | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++++ quantum/mousekey.h | 39 ++++++++++---- 2 files changed, 175 insertions(+), 11 deletions(-) (limited to 'quantum') diff --git a/quantum/mousekey.c b/quantum/mousekey.c index 25a89bdba7..b91db80de6 100644 --- a/quantum/mousekey.c +++ b/quantum/mousekey.c @@ -37,6 +37,13 @@ static void mousekey_debug(void); static uint8_t mousekey_accel = 0; static uint8_t mousekey_repeat = 0; static uint8_t mousekey_wheel_repeat = 0; +#ifdef MOUSEKEY_INERTIA +static uint8_t mousekey_frame = 0; // track whether gesture is inactive, first frame, or repeating +static int8_t mousekey_x_dir = 0; // -1 / 0 / 1 = left / neutral / right +static int8_t mousekey_y_dir = 0; // -1 / 0 / 0 = up / neutral / down +static int8_t mousekey_x_inertia = 0; // current velocity, limit +/- MOUSEKEY_TIME_TO_MAX +static int8_t mousekey_y_inertia = 0; // ... +#endif #ifdef MK_KINETIC_SPEED static uint16_t mouse_timer = 0; #endif @@ -76,6 +83,7 @@ uint8_t mk_wheel_time_to_max = MOUSEKEY_WHEEL_TIME_TO_MAX; # ifndef MK_COMBINED # ifndef MK_KINETIC_SPEED +# ifndef MOUSEKEY_INERTIA /* Default accelerated mode */ @@ -97,6 +105,53 @@ static uint8_t move_unit(void) { return (unit > MOUSEKEY_MOVE_MAX ? MOUSEKEY_MOVE_MAX : (unit == 0 ? 1 : unit)); } +# else // MOUSEKEY_INERTIA mode + +static int8_t move_unit(uint8_t axis) { + int16_t unit; + + // handle X or Y axis + int8_t inertia, dir; + if (axis) { + inertia = mousekey_y_inertia; + dir = mousekey_y_dir; + } else { + inertia = mousekey_x_inertia; + dir = mousekey_x_dir; + } + + if (mousekey_frame < 2) { // first frame(s): initial keypress moves one pixel + mousekey_frame = 1; + unit = dir * MOUSEKEY_MOVE_DELTA; + } else { // acceleration + // linear acceleration (is here for reference, but doesn't feel as good during use) + // unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed * inertia) / mk_time_to_max; + + // x**2 acceleration (quadratic, more precise for short movements) + int16_t percent = (inertia << 8) / mk_time_to_max; + percent = (percent * percent) >> 8; + if (inertia < 0) percent = -percent; + + // unit = sign(inertia) + (percent of max speed) + if (inertia > 0) + unit = 1; + else if (inertia < 0) + unit = -1; + else + unit = 0; + + unit = unit + ((mk_max_speed * percent) >> 8); + } + + if (unit > MOUSEKEY_MOVE_MAX) + unit = MOUSEKEY_MOVE_MAX; + else if (unit < -MOUSEKEY_MOVE_MAX) + unit = -MOUSEKEY_MOVE_MAX; + return unit; +} + +# endif // end MOUSEKEY_INERTIA mode + static uint8_t wheel_unit(void) { uint16_t unit; if (mousekey_accel & (1 << 0)) { @@ -213,6 +268,28 @@ static uint8_t wheel_unit(void) { # endif /* #ifndef MK_COMBINED */ +# ifdef MOUSEKEY_INERTIA + +static int8_t calc_inertia(int8_t direction, int8_t velocity) { + // simulate acceleration and deceleration + + // deceleration + if ((direction > -1) && (velocity < 0)) + velocity = (velocity + 1) * (256 - MOUSEKEY_FRICTION) / 256; + else if ((direction < 1) && (velocity > 0)) + velocity = velocity * (256 - MOUSEKEY_FRICTION) / 256; + + // acceleration + if ((direction > 0) && (velocity < mk_time_to_max)) + velocity++; + else if ((direction < 0) && (velocity > -mk_time_to_max)) + velocity--; + + return velocity; +} + +# endif + void mousekey_task(void) { // report cursor and scroll movement independently report_mouse_t tmpmr = mouse_report; @@ -222,6 +299,32 @@ void mousekey_task(void) { mouse_report.v = 0; mouse_report.h = 0; +# ifdef MOUSEKEY_INERTIA + + // if an animation is in progress and it's time for the next frame + if ((mousekey_frame) && timer_elapsed(last_timer_c) > ((mousekey_frame > 1) ? mk_interval : mk_delay * 10)) { + mousekey_x_inertia = calc_inertia(mousekey_x_dir, mousekey_x_inertia); + mousekey_y_inertia = calc_inertia(mousekey_y_dir, mousekey_y_inertia); + + mouse_report.x = move_unit(0); + mouse_report.y = move_unit(1); + + // prevent sticky "drift" + if ((!mousekey_x_dir) && (!mousekey_x_inertia)) tmpmr.x = 0; + if ((!mousekey_y_dir) && (!mousekey_y_inertia)) tmpmr.y = 0; + + if (mousekey_frame < 2) mousekey_frame++; + } + + // reset if not moving and no movement keys are held + if ((!mousekey_x_dir) && (!mousekey_y_dir) && (!mousekey_x_inertia) && (!mousekey_y_inertia)) { + mousekey_frame = 0; + tmpmr.x = 0; + tmpmr.y = 0; + } + +# else // default acceleration + if ((tmpmr.x || tmpmr.y) && timer_elapsed(last_timer_c) > (mousekey_repeat ? mk_interval : mk_delay * 10)) { if (mousekey_repeat != UINT8_MAX) mousekey_repeat++; if (tmpmr.x != 0) mouse_report.x = move_unit() * ((tmpmr.x > 0) ? 1 : -1); @@ -239,6 +342,9 @@ void mousekey_task(void) { } } } + +# endif // MOUSEKEY_INERTIA or not + if ((tmpmr.v || tmpmr.h) && timer_elapsed(last_timer_w) > (mousekey_wheel_repeat ? mk_wheel_interval : mk_wheel_delay * 10)) { if (mousekey_wheel_repeat != UINT8_MAX) mousekey_wheel_repeat++; if (tmpmr.v != 0) mouse_report.v = wheel_unit() * ((tmpmr.v > 0) ? 1 : -1); @@ -260,6 +366,7 @@ void mousekey_task(void) { if (has_mouse_report_changed(&mouse_report, &tmpmr) || should_mousekey_report_send(&mouse_report)) { mousekey_send(); } + // save the state for later memcpy(&mouse_report, &tmpmr, sizeof(tmpmr)); } @@ -270,6 +377,19 @@ void mousekey_on(uint8_t code) { } # endif /* #ifdef MK_KINETIC_SPEED */ +# ifdef MOUSEKEY_INERTIA + + // initial keypress sets impulse and activates first frame of movement + if ((code == KC_MS_UP) || (code == KC_MS_DOWN)) { + mousekey_y_dir = (code == KC_MS_DOWN) ? 1 : -1; + if (mousekey_frame < 2) mouse_report.y = move_unit(1); + } else if ((code == KC_MS_LEFT) || (code == KC_MS_RIGHT)) { + mousekey_x_dir = (code == KC_MS_RIGHT) ? 1 : -1; + if (mousekey_frame < 2) mouse_report.x = move_unit(0); + } + +# else // no inertia + if (code == KC_MS_UP) mouse_report.y = move_unit() * -1; else if (code == KC_MS_DOWN) @@ -278,6 +398,9 @@ void mousekey_on(uint8_t code) { mouse_report.x = move_unit() * -1; else if (code == KC_MS_RIGHT) mouse_report.x = move_unit(); + +# endif // inertia or not + else if (code == KC_MS_WH_UP) mouse_report.v = wheel_unit(); else if (code == KC_MS_WH_DOWN) @@ -297,6 +420,20 @@ void mousekey_on(uint8_t code) { } void mousekey_off(uint8_t code) { +# ifdef MOUSEKEY_INERTIA + + // key release clears impulse unless opposite direction is held + if ((code == KC_MS_UP) && (mousekey_y_dir < 1)) + mousekey_y_dir = 0; + else if ((code == KC_MS_DOWN) && (mousekey_y_dir > -1)) + mousekey_y_dir = 0; + else if ((code == KC_MS_LEFT) && (mousekey_x_dir < 1)) + mousekey_x_dir = 0; + else if ((code == KC_MS_RIGHT) && (mousekey_x_dir > -1)) + mousekey_x_dir = 0; + +# else // no inertia + if (code == KC_MS_UP && mouse_report.y < 0) mouse_report.y = 0; else if (code == KC_MS_DOWN && mouse_report.y > 0) @@ -305,6 +442,9 @@ void mousekey_off(uint8_t code) { mouse_report.x = 0; else if (code == KC_MS_RIGHT && mouse_report.x > 0) mouse_report.x = 0; + +# endif // inertia or not + else if (code == KC_MS_WH_UP && mouse_report.v > 0) mouse_report.v = 0; else if (code == KC_MS_WH_DOWN && mouse_report.v < 0) @@ -476,6 +616,13 @@ void mousekey_clear(void) { mousekey_repeat = 0; mousekey_wheel_repeat = 0; mousekey_accel = 0; +#ifdef MOUSEKEY_INERTIA + mousekey_frame = 0; + mousekey_x_inertia = 0; + mousekey_y_inertia = 0; + mousekey_x_dir = 0; + mousekey_y_dir = 0; +#endif } static void mousekey_debug(void) { diff --git a/quantum/mousekey.h b/quantum/mousekey.h index da2edb481a..e968e000c0 100644 --- a/quantum/mousekey.h +++ b/quantum/mousekey.h @@ -36,34 +36,48 @@ along with this program. If not, see . # endif # ifndef MOUSEKEY_MOVE_DELTA -# ifndef MK_KINETIC_SPEED -# define MOUSEKEY_MOVE_DELTA 8 -# else +# if defined(MK_KINETIC_SPEED) # define MOUSEKEY_MOVE_DELTA 16 +# elif defined(MOUSEKEY_INERTIA) +# define MOUSEKEY_MOVE_DELTA 1 +# else +# define MOUSEKEY_MOVE_DELTA 8 # endif # endif # ifndef MOUSEKEY_WHEEL_DELTA # define MOUSEKEY_WHEEL_DELTA 1 # endif # ifndef MOUSEKEY_DELAY -# ifndef MK_KINETIC_SPEED -# define MOUSEKEY_DELAY 10 -# else +# if defined(MK_KINETIC_SPEED) # define MOUSEKEY_DELAY 5 +# elif defined(MOUSEKEY_INERTIA) +# define MOUSEKEY_DELAY 150 // allow single-pixel movements before repeat activates +# else +# define MOUSEKEY_DELAY 10 # endif # endif # ifndef MOUSEKEY_INTERVAL -# ifndef MK_KINETIC_SPEED -# define MOUSEKEY_INTERVAL 20 -# else +# if defined(MK_KINETIC_SPEED) # define MOUSEKEY_INTERVAL 10 +# elif defined(MOUSEKEY_INERTIA) +# define MOUSEKEY_INTERVAL 16 // 60 fps +# else +# define MOUSEKEY_INTERVAL 20 # endif # endif # ifndef MOUSEKEY_MAX_SPEED -# define MOUSEKEY_MAX_SPEED 10 +# if defined(MOUSEKEY_INERTIA) +# define MOUSEKEY_MAX_SPEED 32 +# else +# define MOUSEKEY_MAX_SPEED 10 +# endif # endif # ifndef MOUSEKEY_TIME_TO_MAX -# define MOUSEKEY_TIME_TO_MAX 30 +# if defined(MOUSEKEY_INERTIA) +# define MOUSEKEY_TIME_TO_MAX 32 +# else +# define MOUSEKEY_TIME_TO_MAX 30 +# endif # endif # ifndef MOUSEKEY_WHEEL_DELAY # define MOUSEKEY_WHEEL_DELAY 10 @@ -78,6 +92,9 @@ along with this program. If not, see . # define MOUSEKEY_WHEEL_TIME_TO_MAX 40 # endif +# ifndef MOUSEKEY_FRICTION +# define MOUSEKEY_FRICTION 24 // 0 to 255 +# endif # ifndef MOUSEKEY_INITIAL_SPEED # define MOUSEKEY_INITIAL_SPEED 100 # endif -- cgit v1.2.3 From 91b1e8a3e563addc1492cabc78466c8142edcf91 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Thu, 27 Oct 2022 18:29:26 +1100 Subject: Allow overriding of dynamic keymap start address. (#18867) --- quantum/dynamic_keymap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'quantum') diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c index e9529ed14e..d800bbab84 100644 --- a/quantum/dynamic_keymap.c +++ b/quantum/dynamic_keymap.c @@ -24,7 +24,9 @@ # include "via.h" // for VIA_EEPROM_CONFIG_END # define DYNAMIC_KEYMAP_EEPROM_START (VIA_EEPROM_CONFIG_END) #else -# define DYNAMIC_KEYMAP_EEPROM_START (EECONFIG_SIZE) +# ifndef DYNAMIC_KEYMAP_EEPROM_START +# define DYNAMIC_KEYMAP_EEPROM_START (EECONFIG_SIZE) +# endif #endif #ifdef ENCODER_ENABLE -- cgit v1.2.3 From 8e0945c82224ca2fdcc21eb7184520f879804fb6 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Thu, 27 Oct 2022 09:52:51 +0100 Subject: Fix rgb_matrix_set_flags_noeeprom declaration (#18860) --- quantum/rgb_matrix/rgb_matrix.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'quantum') diff --git a/quantum/rgb_matrix/rgb_matrix.h b/quantum/rgb_matrix/rgb_matrix.h index e1bdad42e0..62078f6e60 100644 --- a/quantum/rgb_matrix/rgb_matrix.h +++ b/quantum/rgb_matrix/rgb_matrix.h @@ -182,8 +182,8 @@ void rgb_matrix_increase_speed_noeeprom(void); void rgb_matrix_decrease_speed(void); void rgb_matrix_decrease_speed_noeeprom(void); led_flags_t rgb_matrix_get_flags(void); -led_flags_t rgb_matrix_get_flags_noeeprom(void); void rgb_matrix_set_flags(led_flags_t flags); +void rgb_matrix_set_flags_noeeprom(led_flags_t flags); #ifndef RGBLIGHT_ENABLE # define eeconfig_update_rgblight_current eeconfig_update_rgb_matrix -- cgit v1.2.3 From 002b58f0e4ea64eb5b06e36d988160bbb907cb83 Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 27 Oct 2022 21:19:16 +1100 Subject: Normalise Space Cadet keycodes (#18864) --- quantum/process_keycode/process_space_cadet.c | 14 +++++++------- quantum/quantum_keycodes.h | 22 +++++++++++++++------- quantum/quantum_keycodes_legacy.h | 8 ++++++++ quantum/via_ensure_keycode.h | 14 +++++++------- 4 files changed, 37 insertions(+), 21 deletions(-) (limited to 'quantum') diff --git a/quantum/process_keycode/process_space_cadet.c b/quantum/process_keycode/process_space_cadet.c index 0997e7b7f3..a62cd60a70 100644 --- a/quantum/process_keycode/process_space_cadet.c +++ b/quantum/process_keycode/process_space_cadet.c @@ -122,31 +122,31 @@ void perform_space_cadet(keyrecord_t *record, uint16_t sc_keycode, uint8_t holdM bool process_space_cadet(uint16_t keycode, keyrecord_t *record) { switch (keycode) { - case KC_LSPO: { + case QK_SPACE_CADET_LEFT_SHIFT_PARENTHESIS_OPEN: { perform_space_cadet(record, keycode, LSPO_KEYS); return false; } - case KC_RSPC: { + case QK_SPACE_CADET_RIGHT_SHIFT_PARENTHESIS_CLOSE: { perform_space_cadet(record, keycode, RSPC_KEYS); return false; } - case KC_LCPO: { + case QK_SPACE_CADET_LEFT_CTRL_PARENTHESIS_OPEN: { perform_space_cadet(record, keycode, LCPO_KEYS); return false; } - case KC_RCPC: { + case QK_SPACE_CADET_RIGHT_CTRL_PARENTHESIS_CLOSE: { perform_space_cadet(record, keycode, RCPC_KEYS); return false; } - case KC_LAPO: { + case QK_SPACE_CADET_LEFT_ALT_PARENTHESIS_OPEN: { perform_space_cadet(record, keycode, LAPO_KEYS); return false; } - case KC_RAPC: { + case QK_SPACE_CADET_RIGHT_ALT_PARENTHESIS_CLOSE: { perform_space_cadet(record, keycode, RAPC_KEYS); return false; } - case KC_SFTENT: { + case QK_SPACE_CADET_RIGHT_SHIFT_ENTER: { perform_space_cadet(record, keycode, SFTENT_KEYS); return false; } diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index c5b9342b17..c2b707fbf0 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -362,9 +362,9 @@ enum quantum_keycodes { QK_VELOCIKEY_TOGGLE, // 5CD7 // Space Cadet - KC_LSPO, // 5CD8 - KC_RSPC, // 5CD9 - KC_SFTENT, // 5CDA + QK_SPACE_CADET_LEFT_SHIFT_PARENTHESIS_OPEN, // 5CD8 + QK_SPACE_CADET_RIGHT_SHIFT_PARENTHESIS_CLOSE, // 5CD9 + QK_SPACE_CADET_RIGHT_SHIFT_ENTER, // 5CDA // Thermal Printer PRINT_ON, // 5CDB @@ -402,10 +402,10 @@ enum quantum_keycodes { HPT_DWLD, // 5CF3 // Space Cadet (continued) - KC_LCPO, // 5CF4 - KC_RCPC, // 5CF5 - KC_LAPO, // 5CF6 - KC_RAPC, // 5CF7 + QK_SPACE_CADET_LEFT_CTRL_PARENTHESIS_OPEN, // 5CF4 + QK_SPACE_CADET_RIGHT_CTRL_PARENTHESIS_CLOSE, // 5CF5 + QK_SPACE_CADET_LEFT_ALT_PARENTHESIS_OPEN, // 5CF6 + QK_SPACE_CADET_RIGHT_ALT_PARENTHESIS_CLOSE, // 5CF7 // Combos CMB_ON, // 5CF8 @@ -863,6 +863,14 @@ enum quantum_keycodes { #define SE_TOGG QK_SECURE_TOGGLE #define SE_REQ QK_SECURE_REQUEST +// Space Cadet +#define SC_LSPO QK_SPACE_CADET_LEFT_SHIFT_PARENTHESIS_OPEN +#define SC_RSPC QK_SPACE_CADET_RIGHT_SHIFT_PARENTHESIS_CLOSE +#define SC_LCPO QK_SPACE_CADET_LEFT_CTRL_PARENTHESIS_OPEN +#define SC_RCPC QK_SPACE_CADET_RIGHT_CTRL_PARENTHESIS_CLOSE +#define SC_LAPO QK_SPACE_CADET_LEFT_ALT_PARENTHESIS_OPEN +#define SC_RAPC QK_SPACE_CADET_RIGHT_ALT_PARENTHESIS_CLOSE + // Swap Hands #define SH_T(kc) (QK_SWAP_HANDS | (kc)) #define SH_TG (QK_SWAP_HANDS | OP_SH_TOGGLE) diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h index 652aaaa9a8..92ec68b622 100644 --- a/quantum/quantum_keycodes_legacy.h +++ b/quantum/quantum_keycodes_legacy.h @@ -89,6 +89,14 @@ #define SECURE_TOGGLE QK_SECURE_TOGGLE #define SECURE_REQUEST QK_SECURE_REQUEST +#define KC_LSPO QK_SPACE_CADET_LEFT_SHIFT_PARENTHESIS_OPEN +#define KC_RSPC QK_SPACE_CADET_RIGHT_SHIFT_PARENTHESIS_CLOSE +#define KC_LCPO QK_SPACE_CADET_LEFT_CTRL_PARENTHESIS_OPEN +#define KC_RCPC QK_SPACE_CADET_RIGHT_CTRL_PARENTHESIS_CLOSE +#define KC_LAPO QK_SPACE_CADET_LEFT_ALT_PARENTHESIS_OPEN +#define KC_RAPC QK_SPACE_CADET_RIGHT_ALT_PARENTHESIS_CLOSE +#define KC_SFTENT QK_SPACE_CADET_RIGHT_SHIFT_ENTER + #define TERM_ON _Static_assert(false, "The Terminal feature has been removed from QMK. Please remove use of TERM_ON/TERM_OFF from your keymap.") #define TERM_OFF _Static_assert(false, "The Terminal feature has been removed from QMK.. Please remove use of TERM_ON/TERM_OFF from your keymap.") // #define RESET _Static_assert(false, "The RESET keycode has been removed from QMK.. Please remove use from your keymap.") diff --git a/quantum/via_ensure_keycode.h b/quantum/via_ensure_keycode.h index 010e1d92d4..48e611d0fa 100644 --- a/quantum/via_ensure_keycode.h +++ b/quantum/via_ensure_keycode.h @@ -296,14 +296,14 @@ _Static_assert(RGB_M_X == 0x5CD3, ""); _Static_assert(RGB_M_G == 0x5CD4, ""); _Static_assert(RGB_M_T == 0x5CD5, ""); -_Static_assert(KC_LSPO == 0x5CD7, ""); -_Static_assert(KC_RSPC == 0x5CD8, ""); -_Static_assert(KC_SFTENT == 0x5CD9, ""); +_Static_assert(SC_LSPO == 0x5CD7, ""); +_Static_assert(SC_RSPC == 0x5CD8, ""); +_Static_assert(SC_SENT == 0x5CD9, ""); -_Static_assert(KC_LCPO == 0x5CF3, ""); -_Static_assert(KC_RCPC == 0x5CF4, ""); -_Static_assert(KC_LAPO == 0x5CF5, ""); -_Static_assert(KC_RAPC == 0x5CF6, ""); +_Static_assert(SC_LCPO == 0x5CF3, ""); +_Static_assert(SC_RCPC == 0x5CF4, ""); +_Static_assert(SC_LAPO == 0x5CF5, ""); +_Static_assert(SC_RAPC == 0x5CF6, ""); _Static_assert(FN_MO13 == 0x5F10, ""); _Static_assert(FN_MO23 == 0x5F11, ""); -- cgit v1.2.3 From 8436f0dfa6ee35a33080237280b55a89adbb5f7e Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 27 Oct 2022 23:08:14 +1100 Subject: Add missing Space Cadet alias (#18876) --- quantum/quantum_keycodes.h | 1 + 1 file changed, 1 insertion(+) (limited to 'quantum') diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index c2b707fbf0..36cb01b5f5 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -870,6 +870,7 @@ enum quantum_keycodes { #define SC_RCPC QK_SPACE_CADET_RIGHT_CTRL_PARENTHESIS_CLOSE #define SC_LAPO QK_SPACE_CADET_LEFT_ALT_PARENTHESIS_OPEN #define SC_RAPC QK_SPACE_CADET_RIGHT_ALT_PARENTHESIS_CLOSE +#define SC_SENT QK_SPACE_CADET_RIGHT_SHIFT_ENTER // Swap Hands #define SH_T(kc) (QK_SWAP_HANDS | (kc)) -- cgit v1.2.3 From efe520645ec8b67d306eb63f54b0a52380269596 Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 27 Oct 2022 23:59:58 +1100 Subject: Normalise Combo keycodes (#18877) --- quantum/process_keycode/process_combo.c | 6 +++--- quantum/quantum_keycodes.h | 11 ++++++++--- quantum/quantum_keycodes_legacy.h | 4 ++++ 3 files changed, 15 insertions(+), 6 deletions(-) (limited to 'quantum') diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c index e5135e5a64..d8b089db16 100644 --- a/quantum/process_keycode/process_combo.c +++ b/quantum/process_keycode/process_combo.c @@ -531,17 +531,17 @@ bool process_combo(uint16_t keycode, keyrecord_t *record) { bool is_combo_key = false; bool no_combo_keys_pressed = true; - if (keycode == CMB_ON && record->event.pressed) { + if (keycode == QK_COMBO_ON && record->event.pressed) { combo_enable(); return true; } - if (keycode == CMB_OFF && record->event.pressed) { + if (keycode == QK_COMBO_OFF && record->event.pressed) { combo_disable(); return true; } - if (keycode == CMB_TOG && record->event.pressed) { + if (keycode == QK_COMBO_TOGGLE && record->event.pressed) { combo_toggle(); return true; } diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 36cb01b5f5..a3f9888ffc 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -408,9 +408,9 @@ enum quantum_keycodes { QK_SPACE_CADET_RIGHT_ALT_PARENTHESIS_CLOSE, // 5CF7 // Combos - CMB_ON, // 5CF8 - CMB_OFF, // 5CF9 - CMB_TOG, // 5CFA + QK_COMBO_ON, // 5CF8 + QK_COMBO_OFF, // 5CF9 + QK_COMBO_TOGGLE, // 5CFA // Magic (continued) MAGIC_SWAP_LCTL_LGUI, // 5CFB @@ -872,6 +872,11 @@ enum quantum_keycodes { #define SC_RAPC QK_SPACE_CADET_RIGHT_ALT_PARENTHESIS_CLOSE #define SC_SENT QK_SPACE_CADET_RIGHT_SHIFT_ENTER +// Combos +#define CM_ON QK_COMBO_ON +#define CM_OFF QK_COMBO_OFF +#define CM_TOGG QK_COMBO_TOGGLE + // Swap Hands #define SH_T(kc) (QK_SWAP_HANDS | (kc)) #define SH_TG (QK_SWAP_HANDS | OP_SH_TOGGLE) diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h index 92ec68b622..a6023dee30 100644 --- a/quantum/quantum_keycodes_legacy.h +++ b/quantum/quantum_keycodes_legacy.h @@ -18,6 +18,10 @@ #define ONESHOT_DISABLE QK_ONE_SHOT_OFF #define ONESHOT_TOGGLE QK_ONE_SHOT_TOGGLE +#define CMB_ON QK_COMBO_ON +#define CMB_OFF QK_COMBO_OFF +#define CMB_TOG QK_COMBO_TOGGLE + #define PROGRAMMABLE_BUTTON_1 QK_PROGRAMMABLE_BUTTON_1 #define PROGRAMMABLE_BUTTON_2 QK_PROGRAMMABLE_BUTTON_2 #define PROGRAMMABLE_BUTTON_3 QK_PROGRAMMABLE_BUTTON_3 -- cgit v1.2.3 From 90f6b75873ff1304b517bc30d43440d3c0bd95a4 Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 28 Oct 2022 05:33:38 +1100 Subject: Remove `KC_DELT` (#18882) --- quantum/quantum_keycodes.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'quantum') diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index a3f9888ffc..9d332ffb11 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -660,8 +660,6 @@ enum quantum_keycodes { // US ANSI shifted keycode aliases #include "keymap_us.h" -#define KC_DELT KC_DELETE // Del key (four letter code) - // Modified keycode aliases #define C(kc) LCTL(kc) #define S(kc) LSFT(kc) -- cgit v1.2.3 From 7407347be1df69928d27ea9b6a4fe094429f2a55 Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 28 Oct 2022 09:50:14 +1100 Subject: Remove rgblight_list.h (#18878) * Remove rgblight_list defines with no usage * Remove rgblight_setrgb_*[_at] defines * Remove rgblight_sethsv_* defines * Remove rgblight_sethsv_noeeprom_* defines * Delete rgblight_list.h and remove all references --- quantum/rgblight/rgblight.h | 1 - quantum/rgblight/rgblight_list.h | 136 --------------------------------------- 2 files changed, 137 deletions(-) delete mode 100644 quantum/rgblight/rgblight_list.h (limited to 'quantum') diff --git a/quantum/rgblight/rgblight.h b/quantum/rgblight/rgblight.h index a08b9a7b6b..46e8e07212 100644 --- a/quantum/rgblight/rgblight.h +++ b/quantum/rgblight/rgblight.h @@ -181,7 +181,6 @@ enum RGBLIGHT_EFFECT_MODE { #include "eeconfig.h" #include "ws2812.h" #include "color.h" -#include "rgblight_list.h" #ifdef RGBLIGHT_LAYERS typedef struct { diff --git a/quantum/rgblight/rgblight_list.h b/quantum/rgblight/rgblight_list.h deleted file mode 100644 index 0fd68b75f3..0000000000 --- a/quantum/rgblight/rgblight_list.h +++ /dev/null @@ -1,136 +0,0 @@ -/* Copyright 2018 Jack Humbert - * - * 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 . - */ -#pragma once - -#include "color.h" - -/* -######################################################################################## -## ## -## ## -## ## -## The functions below have been deprecated and may be removed in a future release. ## -## ## -## Please use the values in color.h with the RGB functions. ## -## ## -## ## -## ## -######################################################################################## -*/ - -/* SET RGB List */ -#define rgblight_setrgb_white() rgblight_setrgb(RGB_WHITE) -#define rgblight_setrgb_red() rgblight_setrgb(RGB_RED) -#define rgblight_setrgb_coral() rgblight_setrgb(RGB_CORAL) -#define rgblight_setrgb_orange() rgblight_setrgb(RGB_ORANGE) -#define rgblight_setrgb_goldenrod() rgblight_setrgb(RGB_GOLDENROD) -#define rgblight_setrgb_gold() rgblight_setrgb(RGB_GOLD) -#define rgblight_setrgb_yellow() rgblight_setrgb(RGB_YELLOW) -#define rgblight_setrgb_chartreuse() rgblight_setrgb(RGB_CHARTREUSE) -#define rgblight_setrgb_green() rgblight_setrgb(RGB_GREEN) -#define rgblight_setrgb_springgreen() rgblight_setrgb(RGB_SPRINGGREEN) -#define rgblight_setrgb_turquoise() rgblight_setrgb(RGB_TURQUOISE) -#define rgblight_setrgb_teal() rgblight_setrgb(RGB_TEAL) -#define rgblight_setrgb_cyan() rgblight_setrgb(RGB_CYAN) -#define rgblight_setrgb_azure() rgblight_setrgb(RGB_AZURE) -#define rgblight_setrgb_blue() rgblight_setrgb(RGB_BLUE) -#define rgblight_setrgb_purple() rgblight_setrgb(RGB_PURPLE) -#define rgblight_setrgb_magenta() rgblight_setrgb(RGB_MAGENTA) -#define rgblight_setrgb_pink() rgblight_setrgb(RGB_PINK) - -/* SET RGB List */ -#define rgblight_setrgb_white_at(at) rgblight_setrgb_at(RGB_WHITE, at) -#define rgblight_setrgb_red_at(at) rgblight_setrgb_at(RGB_RED, at) -#define rgblight_setrgb_coral_at(at) rgblight_setrgb_at(RGB_CORAL, at) -#define rgblight_setrgb_orange_at(at) rgblight_setrgb_at(RGB_ORANGE at) -#define rgblight_setrgb_goldenrod_at(at) rgblight_setrgb_at(RGB_GOLDENROD, at) -#define rgblight_setrgb_gold_at(at) rgblight_setrgb_at(RGB_GOLD, at) -#define rgblight_setrgb_yellow_at(at) rgblight_setrgb_at(RGB_YELLOW, at) -#define rgblight_setrgb_chartreuse_at(at) rgblight_setrgb_at(RGB_CHARTREUSE, at) -#define rgblight_setrgb_green_at(at) rgblight_setrgb_at(RGB_GREEN, at) -#define rgblight_setrgb_springgreen_at(at) rgblight_setrgb_at(RGB_SPRINGGREEN, at) -#define rgblight_setrgb_turquoise_at(at) rgblight_setrgb_at(RGB_TURQUOISE, at) -#define rgblight_setrgb_teal_at(at) rgblight_setrgb_at(RGB_TEAL, at) -#define rgblight_setrgb_cyan_at(at) rgblight_setrgb_at(RGB_CYAN, at) -#define rgblight_setrgb_azure_at(at) rgblight_setrgb_at(RGB_AZURE, at) -#define rgblight_setrgb_blue_at(at) rgblight_setrgb_at(RGB_BLUE, at) -#define rgblight_setrgb_purple_at(at) rgblight_setrgb_at(RGB_PURPLE, at) -#define rgblight_setrgb_magenta_at(at) rgblight_setrgb_at(RGB_MAGENTA, at) -#define rgblight_setrgb_pink_at(at) rgblight_setrgb_at(RGB_PINK, at) - -/* SET HSV List */ -#define rgblight_sethsv_white() rgblight_sethsv(HSV_WHITE) -#define rgblight_sethsv_red() rgblight_sethsv(HSV_RED) -#define rgblight_sethsv_coral() rgblight_sethsv(HSV_CORAL) -#define rgblight_sethsv_orange() rgblight_sethsv(HSV_ORANGE) -#define rgblight_sethsv_goldenrod() rgblight_sethsv(HSV_GOLDENROD) -#define rgblight_sethsv_gold() rgblight_sethsv(HSV_GOLD) -#define rgblight_sethsv_yellow() rgblight_sethsv(HSV_YELLOW) -#define rgblight_sethsv_chartreuse() rgblight_sethsv(HSV_CHARTREUSE) -#define rgblight_sethsv_green() rgblight_sethsv(HSV_GREEN) -#define rgblight_sethsv_springgreen() rgblight_sethsv(HSV_SPRINGGREEN) -#define rgblight_sethsv_turquoise() rgblight_sethsv(HSV_TURQUOISE) -#define rgblight_sethsv_teal() rgblight_sethsv(HSV_TEAL) -#define rgblight_sethsv_cyan() rgblight_sethsv(HSV_CYAN) -#define rgblight_sethsv_azure() rgblight_sethsv(HSV_AZURE) -#define rgblight_sethsv_blue() rgblight_sethsv(HSV_BLUE) -#define rgblight_sethsv_purple() rgblight_sethsv(HSV_PURPLE) -#define rgblight_sethsv_magenta() rgblight_sethsv(HSV_MAGENTA) -#define rgblight_sethsv_pink() rgblight_sethsv(HSV_PINK) - -/* SET HSV List */ -/* If you're doing layer indication, this is best, as it won't */ -/* write to the eeprom, since it's limited (very high value). */ -/* If you want to use modes with this (since you can), then you */ -/* want to use rgblight_mode_noeeprom(x) instead. */ -#define rgblight_sethsv_noeeprom_white() rgblight_sethsv_noeeprom(HSV_WHITE) -#define rgblight_sethsv_noeeprom_red() rgblight_sethsv_noeeprom(HSV_RED) -#define rgblight_sethsv_noeeprom_coral() rgblight_sethsv_noeeprom(HSV_CORAL) -#define rgblight_sethsv_noeeprom_orange() rgblight_sethsv_noeeprom(HSV_ORANGE) -#define rgblight_sethsv_noeeprom_goldenrod() rgblight_sethsv_noeeprom(HSV_GOLDENROD) -#define rgblight_sethsv_noeeprom_gold() rgblight_sethsv_noeeprom(HSV_GOLD) -#define rgblight_sethsv_noeeprom_yellow() rgblight_sethsv_noeeprom(HSV_YELLOW) -#define rgblight_sethsv_noeeprom_chartreuse() rgblight_sethsv_noeeprom(HSV_CHARTREUSE) -#define rgblight_sethsv_noeeprom_green() rgblight_sethsv_noeeprom(HSV_GREEN) -#define rgblight_sethsv_noeeprom_springgreen() rgblight_sethsv_noeeprom(HSV_SPRINGGREEN) -#define rgblight_sethsv_noeeprom_turquoise() rgblight_sethsv_noeeprom(HSV_TURQUOISE) -#define rgblight_sethsv_noeeprom_teal() rgblight_sethsv_noeeprom(HSV_TEAL) -#define rgblight_sethsv_noeeprom_cyan() rgblight_sethsv_noeeprom(HSV_CYAN) -#define rgblight_sethsv_noeeprom_azure() rgblight_sethsv_noeeprom(HSV_AZURE) -#define rgblight_sethsv_noeeprom_blue() rgblight_sethsv_noeeprom(HSV_BLUE) -#define rgblight_sethsv_noeeprom_purple() rgblight_sethsv_noeeprom(HSV_PURPLE) -#define rgblight_sethsv_noeeprom_magenta() rgblight_sethsv_noeeprom(HSV_MAGENTA) -#define rgblight_sethsv_noeeprom_pink() rgblight_sethsv_noeeprom(HSV_PINK) - -/* SET HSV List */ -#define rgblight_sethsv_white_at(at) rgblight_sethsv_at(HSV_WHITE, at) -#define rgblight_sethsv_red_at(at) rgblight_sethsv_at(HSV_RED, at) -#define rgblight_sethsv_coral_at(at) rgblight_sethsv_at(HSV_CORAL, at) -#define rgblight_sethsv_orange_at(at) rgblight_sethsv_at(HSV_ORANGE, at) -#define rgblight_sethsv_goldenrod_at(at) rgblight_sethsv_at(HSV_GOLDENROD, at) -#define rgblight_sethsv_gold_at(at) rgblight_sethsv_at(HSV_GOLD, at) -#define rgblight_sethsv_yellow_at(at) rgblight_sethsv_at(HSV_YELLOW, at) -#define rgblight_sethsv_chartreuse_at(at) rgblight_sethsv_at(HSV_CHARTREUSE, at) -#define rgblight_sethsv_green_at(at) rgblight_sethsv_at(HSV_GREEN, at) -#define rgblight_sethsv_springgreen_at(at) rgblight_sethsv_at(HSV_SPRINGGREEN, at) -#define rgblight_sethsv_turquoise_at(at) rgblight_sethsv_at(HSV_TURQUOISE, at) -#define rgblight_sethsv_teal_at(at) rgblight_sethsv_at(HSV_TEAL, at) -#define rgblight_sethsv_cyan_at(at) rgblight_sethsv_at(HSV_CYAN, at) -#define rgblight_sethsv_azure_at(at) rgblight_sethsv_at(HSV_AZURE, at) -#define rgblight_sethsv_blue_at(at) rgblight_sethsv_at(HSV_BLUE, at) -#define rgblight_sethsv_purple_at(at) rgblight_sethsv_at(HSV_PURPLE, at) -#define rgblight_sethsv_magenta_at(at) rgblight_sethsv_at(HSV_MAGENTA, at) -#define rgblight_sethsv_pink_at(at) rgblight_sethsv_at(HSV_PINK, at) -- cgit v1.2.3 From 2ff1d852909daaaf94433fab202e7bf94274d67b Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 28 Oct 2022 22:21:24 +1100 Subject: Normalise Autocorrect keycodes (#18893) --- quantum/process_keycode/process_autocorrect.c | 8 ++++---- quantum/quantum_keycodes.h | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'quantum') diff --git a/quantum/process_keycode/process_autocorrect.c b/quantum/process_keycode/process_autocorrect.c index f19ca4a90b..e3fcbc34ae 100644 --- a/quantum/process_keycode/process_autocorrect.c +++ b/quantum/process_keycode/process_autocorrect.c @@ -165,12 +165,12 @@ bool process_autocorrect(uint16_t keycode, keyrecord_t *record) { mods |= get_oneshot_mods(); #endif - if ((keycode >= AUTOCORRECT_ON && keycode <= AUTOCORRECT_TOGGLE) && record->event.pressed) { - if (keycode == AUTOCORRECT_ON) { + if ((keycode >= QK_AUTOCORRECT_ON && keycode <= QK_AUTOCORRECT_TOGGLE) && record->event.pressed) { + if (keycode == QK_AUTOCORRECT_ON) { autocorrect_enable(); - } else if (keycode == AUTOCORRECT_OFF) { + } else if (keycode == QK_AUTOCORRECT_OFF) { autocorrect_disable(); - } else if (keycode == AUTOCORRECT_TOGGLE) { + } else if (keycode == QK_AUTOCORRECT_TOGGLE) { autocorrect_toggle(); } else { return true; diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 9d332ffb11..0be090e48b 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -611,9 +611,9 @@ enum quantum_keycodes { UNICODE_MODE_EMACS, - AUTOCORRECT_ON, - AUTOCORRECT_OFF, - AUTOCORRECT_TOGGLE, + QK_AUTOCORRECT_ON, + QK_AUTOCORRECT_OFF, + QK_AUTOCORRECT_TOGGLE, MAGIC_TOGGLE_BACKSLASH_BACKSPACE, @@ -740,9 +740,9 @@ enum quantum_keycodes { #define EH_LEFT MAGIC_EE_HANDS_LEFT #define EH_RGHT MAGIC_EE_HANDS_RIGHT -#define CRT_ON AUTOCORRECT_ON -#define CRT_OFF AUTOCORRECT_OFF -#define CRT_TOG AUTOCORRECT_TOGGLE +#define AC_ON QK_AUTOCORRECT_ON +#define AC_OFF QK_AUTOCORRECT_OFF +#define AC_TOGG QK_AUTOCORRECT_TOGGLE // Velocikey #define VK_TOGG QK_VELOCIKEY_TOGGLE -- cgit v1.2.3 From 22be7e79ac6a328ed5a7dc8c4e6f17d749852221 Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 28 Oct 2022 23:53:15 +1100 Subject: Normalise Auto Shift keycodes (#18892) * Normalise Auto Shift keycodes * Add keycode table to main list * Add old keycodes to legacy header --- quantum/process_keycode/process_auto_shift.c | 12 ++++++------ quantum/quantum_keycodes.h | 20 ++++++++++++++------ quantum/quantum_keycodes_legacy.h | 7 +++++++ 3 files changed, 27 insertions(+), 12 deletions(-) (limited to 'quantum') diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index 644ad2cbaf..35d4851ee5 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c @@ -375,24 +375,24 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { } switch (keycode) { - case KC_ASTG: + case AS_TOGG: autoshift_toggle(); break; - case KC_ASON: + case AS_ON: autoshift_enable(); break; - case KC_ASOFF: + case AS_OFF: autoshift_disable(); break; # ifndef AUTO_SHIFT_NO_SETUP - case KC_ASUP: + case AS_UP: autoshift_timeout += 5; break; - case KC_ASDN: + case AS_DOWN: autoshift_timeout -= 5; break; - case KC_ASRP: + case AS_RPT: autoshift_timer_report(); break; # endif diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 0be090e48b..6c9a262484 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -105,12 +105,12 @@ enum quantum_keycodes { QK_GRAVE_ESCAPE, // 5C16 // Auto Shift - KC_ASUP, // 5C17 - KC_ASDN, // 5C18 - KC_ASRP, // 5C19 - KC_ASTG, // 5C1A - KC_ASON, // 5C1B - KC_ASOFF, // 5C1C + QK_AUTO_SHIFT_UP, // 5C17 + QK_AUTO_SHIFT_DOWN, // 5C18 + QK_AUTO_SHIFT_REPORT, // 5C19 + QK_AUTO_SHIFT_TOGGLE, // 5C1A + QK_AUTO_SHIFT_ON, // 5C1B + QK_AUTO_SHIFT_OFF, // 5C1C // Audio AU_ON, // 5C1D @@ -844,6 +844,14 @@ enum quantum_keycodes { #define UC_M_WC UNICODE_MODE_WINC #define UC_M_EM UNICODE_MODE_EMACS +// Auto Shift +#define AS_UP QK_AUTO_SHIFT_UP +#define AS_DOWN QK_AUTO_SHIFT_DOWN +#define AS_RPT QK_AUTO_SHIFT_REPORT +#define AS_TOGG QK_AUTO_SHIFT_TOGGLE +#define AS_ON QK_AUTO_SHIFT_ON +#define AS_OFF QK_AUTO_SHIFT_OFF + // Leader key #define QK_LEAD QK_LEADER diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h index a6023dee30..3baf37d378 100644 --- a/quantum/quantum_keycodes_legacy.h +++ b/quantum/quantum_keycodes_legacy.h @@ -6,6 +6,13 @@ #define KC_LEAD QK_LEADER #define KC_LOCK QK_LOCK +#define KC_ASUP QK_AUTO_SHIFT_UP +#define KC_ASDN QK_AUTO_SHIFT_DOWN +#define KC_ASRP QK_AUTO_SHIFT_REPORT +#define KC_ASTG QK_AUTO_SHIFT_TOGGLE +#define KC_ASON QK_AUTO_SHIFT_ON +#define KC_ASOFF QK_AUTO_SHIFT_OFF + #define VLK_TOG QK_VELOCIKEY_TOGGLE #define CAPSWRD QK_CAPS_WORD_TOGGLE #define CAPS_WORD QK_CAPS_WORD_TOGGLE -- cgit v1.2.3 From 5974d989fe72f6c576901a065bee4487a58c351d Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 1 Nov 2022 08:15:12 +1100 Subject: Normalise Unicode keycodes (#18898) * `UC_MOD`/`UC_RMOD` -> `UC_NEXT`/`UC_PREV` * `UNICODE_MODE_*` -> `QK_UNICODE_MODE_*` * `UC_MAC` -> `UNICODE_MODE_MACOS` * `UC_LNX` -> `UNICODE_MODE_LINUX` * `UC_WIN` -> `UNICODE_MODE_WINDOWS` * `UC_BSD` -> `UNICODE_MODE_BSD` * `UC_WINC` -> `UNICODE_MODE_WINCOMPOSE` * `UC_EMACS` -> `UNICODE_MODE_EMACS` * `UC__COUNT` -> `UNICODE_MODE_COUNT` * `UC_M_MA` -> `UC_MAC` * `UC_M_LN` -> `UC_LINX` * `UC_M_WI` -> `UC_WIN` * `UC_M_BS` -> `UC_BSD` * `UC_M_WC` -> `UC_WINC` * `UC_M_EM` -> `UC_EMAC` * Docs * Update quantum/unicode/unicode.h --- quantum/process_keycode/process_unicode_common.c | 28 ++++++------ quantum/quantum_keycodes.h | 32 +++++++------- quantum/quantum_keycodes_legacy.h | 9 ++++ quantum/unicode/unicode.c | 54 ++++++++++++------------ quantum/unicode/unicode.h | 15 ++++--- 5 files changed, 74 insertions(+), 64 deletions(-) (limited to 'quantum') diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index bd5fc560f3..a0b9010027 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -31,29 +31,29 @@ bool process_unicode_common(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { bool shifted = get_mods() & MOD_MASK_SHIFT; switch (keycode) { - case UNICODE_MODE_FORWARD: + case QK_UNICODE_MODE_NEXT: cycle_unicode_input_mode(shifted ? -1 : +1); break; - case UNICODE_MODE_REVERSE: + case QK_UNICODE_MODE_PREVIOUS: cycle_unicode_input_mode(shifted ? +1 : -1); break; - case UNICODE_MODE_MAC: - set_unicode_input_mode(UC_MAC); + case QK_UNICODE_MODE_MACOS: + set_unicode_input_mode(UNICODE_MODE_MACOS); break; - case UNICODE_MODE_LNX: - set_unicode_input_mode(UC_LNX); + case QK_UNICODE_MODE_LINUX: + set_unicode_input_mode(UNICODE_MODE_LINUX); break; - case UNICODE_MODE_WIN: - set_unicode_input_mode(UC_WIN); + case QK_UNICODE_MODE_WINDOWS: + set_unicode_input_mode(UNICODE_MODE_WINDOWS); break; - case UNICODE_MODE_BSD: - set_unicode_input_mode(UC_BSD); + case QK_UNICODE_MODE_BSD: + set_unicode_input_mode(UNICODE_MODE_BSD); break; - case UNICODE_MODE_WINC: - set_unicode_input_mode(UC_WINC); + case QK_UNICODE_MODE_WINCOMPOSE: + set_unicode_input_mode(UNICODE_MODE_WINCOMPOSE); break; - case UNICODE_MODE_EMACS: - set_unicode_input_mode(UC_EMACS); + case QK_UNICODE_MODE_EMACS: + set_unicode_input_mode(UNICODE_MODE_EMACS); break; } } diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 6c9a262484..2f9e211cc1 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -378,13 +378,13 @@ enum quantum_keycodes { QK_CLEAR_EEPROM, // 5CDF // Unicode - UNICODE_MODE_FORWARD, // 5CE0 - UNICODE_MODE_REVERSE, // 5CE1 - UNICODE_MODE_MAC, // 5CE2 - UNICODE_MODE_LNX, // 5CE3 - UNICODE_MODE_WIN, // 5CE4 - UNICODE_MODE_BSD, // 5CE5 - UNICODE_MODE_WINC, // 5CE6 + QK_UNICODE_MODE_NEXT, // 5CE0 + QK_UNICODE_MODE_PREVIOUS, // 5CE1 + QK_UNICODE_MODE_MACOS, // 5CE2 + QK_UNICODE_MODE_LINUX, // 5CE3 + QK_UNICODE_MODE_WINDOWS, // 5CE4 + QK_UNICODE_MODE_BSD, // 5CE5 + QK_UNICODE_MODE_WINCOMPOSE, // 5CE6 // Haptic HPT_ON, // 5CE7 @@ -609,7 +609,7 @@ enum quantum_keycodes { MAGIC_UNSWAP_ESCAPE_CAPSLOCK, MAGIC_TOGGLE_ESCAPE_CAPSLOCK, - UNICODE_MODE_EMACS, + QK_UNICODE_MODE_EMACS, QK_AUTOCORRECT_ON, QK_AUTOCORRECT_OFF, @@ -834,15 +834,15 @@ enum quantum_keycodes { #define X(i) (QK_UNICODEMAP | (i)) #define XP(i, j) (QK_UNICODEMAP_PAIR | ((i)&0x7F) | (((j)&0x7F) << 7)) // 127 max i and j -#define UC_MOD UNICODE_MODE_FORWARD -#define UC_RMOD UNICODE_MODE_REVERSE +#define UC_NEXT QK_UNICODE_MODE_NEXT +#define UC_PREV QK_UNICODE_MODE_PREVIOUS -#define UC_M_MA UNICODE_MODE_MAC -#define UC_M_LN UNICODE_MODE_LNX -#define UC_M_WI UNICODE_MODE_WIN -#define UC_M_BS UNICODE_MODE_BSD -#define UC_M_WC UNICODE_MODE_WINC -#define UC_M_EM UNICODE_MODE_EMACS +#define UC_MAC QK_UNICODE_MODE_MACOS +#define UC_LINX QK_UNICODE_MODE_LINUX +#define UC_WIN QK_UNICODE_MODE_WINDOWS +#define UC_BSD QK_UNICODE_MODE_BSD +#define UC_WINC QK_UNICODE_MODE_WINCOMPOSE +#define UC_EMAC QK_UNICODE_MODE_EMACS // Auto Shift #define AS_UP QK_AUTO_SHIFT_UP diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h index 3baf37d378..68771baece 100644 --- a/quantum/quantum_keycodes_legacy.h +++ b/quantum/quantum_keycodes_legacy.h @@ -29,6 +29,15 @@ #define CMB_OFF QK_COMBO_OFF #define CMB_TOG QK_COMBO_TOGGLE +#define UC_MOD QK_UNICODE_MODE_NEXT +#define UC_RMOD QK_UNICODE_MODE_PREVIOUS +#define UC_M_MA QK_UNICODE_MODE_MACOS +#define UC_M_LN QK_UNICODE_MODE_LINUX +#define UC_M_WI QK_UNICODE_MODE_WINDOWS +#define UC_M_BS QK_UNICODE_MODE_BSD +#define UC_M_WC QK_UNICODE_MODE_WINCOMPOSE +#define UC_M_EM QK_UNICODE_MODE_EMACS + #define PROGRAMMABLE_BUTTON_1 QK_PROGRAMMABLE_BUTTON_1 #define PROGRAMMABLE_BUTTON_2 QK_PROGRAMMABLE_BUTTON_2 #define PROGRAMMABLE_BUTTON_3 QK_PROGRAMMABLE_BUTTON_3 diff --git a/quantum/unicode/unicode.c b/quantum/unicode/unicode.c index e2bfd68a3a..35cb62e700 100644 --- a/quantum/unicode/unicode.c +++ b/quantum/unicode/unicode.c @@ -46,7 +46,7 @@ #endif // Comma-delimited, ordered list of input modes selected for use (e.g. in cycle) -// Example: #define UNICODE_SELECTED_MODES UC_WINC, UC_LNX +// Example: #define UNICODE_SELECTED_MODES UNICODE_MODE_WINCOMPOSE, UNICODE_MODE_LINUX #ifndef UNICODE_SELECTED_MODES # define UNICODE_SELECTED_MODES -1 #endif @@ -108,32 +108,32 @@ static float song_emacs[][2] = UNICODE_SONG_EMACS; static void unicode_play_song(uint8_t mode) { switch (mode) { # ifdef UNICODE_SONG_MAC - case UC_MAC: + case UNICODE_MODE_MACOS: PLAY_SONG(song_mac); break; # endif # ifdef UNICODE_SONG_LNX - case UC_LNX: + case UNICODE_MODE_LINUX: PLAY_SONG(song_lnx); break; # endif # ifdef UNICODE_SONG_WIN - case UC_WIN: + case UNICODE_MODE_WINDOWS: PLAY_SONG(song_win); break; # endif # ifdef UNICODE_SONG_BSD - case UC_BSD: + case UNICODE_MODE_BSD: PLAY_SONG(song_bsd); break; # endif # ifdef UNICODE_SONG_WINC - case UC_WINC: + case UNICODE_MODE_WINCOMPOSE: PLAY_SONG(song_winc); break; # endif # ifdef UNICODE_SONG_EMACS - case UC_EMACS: + case UNICODE_MODE_EMACS: PLAY_SONG(song_emacs); break; # endif @@ -209,7 +209,7 @@ __attribute__((weak)) void unicode_input_start(void) { // Need to do this before we mess around with the mods, or else // UNICODE_KEY_LNX (which is usually Ctrl-Shift-U) might not work // correctly in the shifted case. - if (unicode_config.input_mode == UC_LNX && unicode_saved_led_state.caps_lock) { + if (unicode_config.input_mode == UNICODE_MODE_LINUX && unicode_saved_led_state.caps_lock) { tap_code(KC_CAPS_LOCK); } @@ -218,13 +218,13 @@ __attribute__((weak)) void unicode_input_start(void) { clear_weak_mods(); switch (unicode_config.input_mode) { - case UC_MAC: + case UNICODE_MODE_MACOS: register_code(UNICODE_KEY_MAC); break; - case UC_LNX: + case UNICODE_MODE_LINUX: tap_code16(UNICODE_KEY_LNX); break; - case UC_WIN: + case UNICODE_MODE_WINDOWS: // For increased reliability, use numpad keys for inputting digits if (!unicode_saved_led_state.num_lock) { tap_code(KC_NUM_LOCK); @@ -233,11 +233,11 @@ __attribute__((weak)) void unicode_input_start(void) { wait_ms(UNICODE_TYPE_DELAY); tap_code(KC_KP_PLUS); break; - case UC_WINC: + case UNICODE_MODE_WINCOMPOSE: tap_code(UNICODE_KEY_WINC); tap_code(KC_U); break; - case UC_EMACS: + case UNICODE_MODE_EMACS: // The usual way to type unicode in emacs is C-x-8 then the unicode number in hex tap_code16(LCTL(KC_X)); tap_code16(KC_8); @@ -250,25 +250,25 @@ __attribute__((weak)) void unicode_input_start(void) { __attribute__((weak)) void unicode_input_finish(void) { switch (unicode_config.input_mode) { - case UC_MAC: + case UNICODE_MODE_MACOS: unregister_code(UNICODE_KEY_MAC); break; - case UC_LNX: + case UNICODE_MODE_LINUX: tap_code(KC_SPACE); if (unicode_saved_led_state.caps_lock) { tap_code(KC_CAPS_LOCK); } break; - case UC_WIN: + case UNICODE_MODE_WINDOWS: unregister_code(KC_LEFT_ALT); if (!unicode_saved_led_state.num_lock) { tap_code(KC_NUM_LOCK); } break; - case UC_WINC: + case UNICODE_MODE_WINCOMPOSE: tap_code(KC_ENTER); break; - case UC_EMACS: + case UNICODE_MODE_EMACS: tap_code16(KC_ENTER); break; } @@ -278,25 +278,25 @@ __attribute__((weak)) void unicode_input_finish(void) { __attribute__((weak)) void unicode_input_cancel(void) { switch (unicode_config.input_mode) { - case UC_MAC: + case UNICODE_MODE_MACOS: unregister_code(UNICODE_KEY_MAC); break; - case UC_LNX: + case UNICODE_MODE_LINUX: tap_code(KC_ESCAPE); if (unicode_saved_led_state.caps_lock) { tap_code(KC_CAPS_LOCK); } break; - case UC_WINC: + case UNICODE_MODE_WINCOMPOSE: tap_code(KC_ESCAPE); break; - case UC_WIN: + case UNICODE_MODE_WINDOWS: unregister_code(KC_LEFT_ALT); if (!unicode_saved_led_state.num_lock) { tap_code(KC_NUM_LOCK); } break; - case UC_EMACS: + case UNICODE_MODE_EMACS: tap_code16(LCTL(KC_G)); // C-g cancels break; } @@ -307,7 +307,7 @@ __attribute__((weak)) void unicode_input_cancel(void) { // clang-format off static void send_nibble_wrapper(uint8_t digit) { - if (unicode_config.input_mode == UC_WIN) { + if (unicode_config.input_mode == UNICODE_MODE_WINDOWS) { uint8_t kc = digit < 10 ? KC_KP_1 + (10 + digit - 1) % 10 : KC_A + (digit - 10); @@ -328,7 +328,7 @@ void register_hex(uint16_t hex) { void register_hex32(uint32_t hex) { bool first_digit = true; - bool needs_leading_zero = (unicode_config.input_mode == UC_WINC); + bool needs_leading_zero = (unicode_config.input_mode == UNICODE_MODE_WINCOMPOSE); for (int i = 7; i >= 0; i--) { // Work out the digit we're going to transmit uint8_t digit = ((hex >> (i * 4)) & 0xF); @@ -352,13 +352,13 @@ void register_hex32(uint32_t hex) { } void register_unicode(uint32_t code_point) { - if (code_point > 0x10FFFF || (code_point > 0xFFFF && unicode_config.input_mode == UC_WIN)) { + if (code_point > 0x10FFFF || (code_point > 0xFFFF && unicode_config.input_mode == UNICODE_MODE_WINDOWS)) { // Code point out of range, do nothing return; } unicode_input_start(); - if (code_point > 0xFFFF && unicode_config.input_mode == UC_MAC) { + if (code_point > 0xFFFF && unicode_config.input_mode == UNICODE_MODE_MACOS) { // Convert code point to UTF-16 surrogate pair on macOS code_point -= 0x10000; uint32_t lo = code_point & 0x3FF, hi = (code_point & 0xFFC00) >> 10; diff --git a/quantum/unicode/unicode.h b/quantum/unicode/unicode.h index b3e43799ff..6f1e35d554 100644 --- a/quantum/unicode/unicode.h +++ b/quantum/unicode/unicode.h @@ -30,13 +30,14 @@ typedef union { extern unicode_config_t unicode_config; enum unicode_input_modes { - UC_MAC, // macOS using Unicode Hex Input - UC_LNX, // Linux using IBus - UC_WIN, // Windows using EnableHexNumpad - UC_BSD, // BSD (not implemented) - UC_WINC, // Windows using WinCompose (https://github.com/samhocevar/wincompose) - UC_EMACS, // Emacs is an operating system in search of a good text editor - UC__COUNT // Number of available input modes (always leave at the end) + UNICODE_MODE_MACOS, // macOS using Unicode Hex Input + UNICODE_MODE_LINUX, // Linux using IBus + UNICODE_MODE_WINDOWS, // Windows using EnableHexNumpad + UNICODE_MODE_BSD, // BSD (not implemented) + UNICODE_MODE_WINCOMPOSE, // Windows using WinCompose (https://github.com/samhocevar/wincompose) + UNICODE_MODE_EMACS, // Emacs is an operating system in search of a good text editor + + UNICODE_MODE_COUNT // Number of available input modes (always leave at the end) }; void unicode_input_mode_init(void); -- cgit v1.2.3 From ae5f818d5a1efa321ffc0c6e659fa8fb47e79a01 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Mon, 31 Oct 2022 18:02:43 -0700 Subject: Simplify Keymap Config EEPROM (#18886) * Simplify Keymap Config EEPROM * Decrement eeconfig magic number due to eeconfig changes * Update quantum/eeconfig.h Co-authored-by: Joel Challis --- quantum/eeconfig.c | 11 ++++------- quantum/eeconfig.h | 11 +++-------- 2 files changed, 7 insertions(+), 15 deletions(-) (limited to 'quantum') diff --git a/quantum/eeconfig.c b/quantum/eeconfig.c index 27a0f6d48f..2e2df11d69 100644 --- a/quantum/eeconfig.c +++ b/quantum/eeconfig.c @@ -45,10 +45,8 @@ void eeconfig_init_quantum(void) { eeprom_update_byte(EECONFIG_DEBUG, 0); eeprom_update_byte(EECONFIG_DEFAULT_LAYER, 0); default_layer_state = 0; - eeprom_update_byte(EECONFIG_KEYMAP_LOWER_BYTE, 0); - // Enable oneshot and autocorrect by default: 0b0001 0100 - eeprom_update_byte(EECONFIG_KEYMAP_UPPER_BYTE, 0x14); - eeprom_update_byte(EECONFIG_MOUSEKEY_ACCEL, 0); + // Enable oneshot and autocorrect by default: 0b0001 0100 0000 0000 + eeprom_update_word(EECONFIG_KEYMAP, 0x1400); eeprom_update_byte(EECONFIG_BACKLIGHT, 0); eeprom_update_byte(EECONFIG_AUDIO, 0xFF); // On by default eeprom_update_dword(EECONFIG_RGBLIGHT, 0); @@ -167,15 +165,14 @@ void eeconfig_update_default_layer(uint8_t val) { * FIXME: needs doc */ uint16_t eeconfig_read_keymap(void) { - return (eeprom_read_byte(EECONFIG_KEYMAP_LOWER_BYTE) | (eeprom_read_byte(EECONFIG_KEYMAP_UPPER_BYTE) << 8)); + return eeprom_read_word(EECONFIG_KEYMAP); } /** \brief eeconfig update keymap * * FIXME: needs doc */ void eeconfig_update_keymap(uint16_t val) { - eeprom_update_byte(EECONFIG_KEYMAP_LOWER_BYTE, val & 0xFF); - eeprom_update_byte(EECONFIG_KEYMAP_UPPER_BYTE, (val >> 8) & 0xFF); + eeprom_update_word(EECONFIG_KEYMAP, val); } /** \brief eeconfig read audio diff --git a/quantum/eeconfig.h b/quantum/eeconfig.h index 565a0dbe5b..9c4617c962 100644 --- a/quantum/eeconfig.h +++ b/quantum/eeconfig.h @@ -21,7 +21,7 @@ along with this program. If not, see . #include #ifndef EECONFIG_MAGIC_NUMBER -# define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEE8 // When changing, decrement this value to avoid future re-init issues +# define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEE7 // When changing, decrement this value to avoid future re-init issues #endif #define EECONFIG_MAGIC_NUMBER_OFF (uint16_t)0xFFFF @@ -29,8 +29,7 @@ along with this program. If not, see . #define EECONFIG_MAGIC (uint16_t *)0 #define EECONFIG_DEBUG (uint8_t *)2 #define EECONFIG_DEFAULT_LAYER (uint8_t *)3 -#define EECONFIG_KEYMAP (uint8_t *)4 -#define EECONFIG_MOUSEKEY_ACCEL (uint8_t *)5 +#define EECONFIG_KEYMAP (uint16_t *)4 #define EECONFIG_BACKLIGHT (uint8_t *)6 #define EECONFIG_AUDIO (uint8_t *)7 #define EECONFIG_RGBLIGHT (uint32_t *)8 @@ -51,10 +50,8 @@ along with this program. If not, see . #define EECONFIG_LED_MATRIX_EXTENDED (uint16_t *)32 #define EECONFIG_RGB_MATRIX_EXTENDED (uint16_t *)32 -// TODO: Combine these into a single word and single block of EEPROM -#define EECONFIG_KEYMAP_UPPER_BYTE (uint8_t *)34 // Size of EEPROM being used, other code can refer to this for available EEPROM -#define EECONFIG_SIZE 35 +#define EECONFIG_SIZE 34 /* debug bit */ #define EECONFIG_DEBUG_ENABLE (1 << 0) #define EECONFIG_DEBUG_MATRIX (1 << 1) @@ -71,8 +68,6 @@ along with this program. If not, see . #define EECONFIG_KEYMAP_SWAP_BACKSLASH_BACKSPACE (1 << 6) #define EECONFIG_KEYMAP_NKRO (1 << 7) -#define EECONFIG_KEYMAP_LOWER_BYTE EECONFIG_KEYMAP - bool eeconfig_is_enabled(void); bool eeconfig_is_disabled(void); -- cgit v1.2.3 From f11a247127c82bc207f20e0b1be2cf6efea3a129 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Thu, 3 Nov 2022 20:44:36 +0000 Subject: Reduce includes for sequencer header (#18946) --- quantum/sequencer/sequencer.c | 2 ++ quantum/sequencer/sequencer.h | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'quantum') diff --git a/quantum/sequencer/sequencer.c b/quantum/sequencer/sequencer.c index 2e92f7b3eb..ff243c870b 100644 --- a/quantum/sequencer/sequencer.c +++ b/quantum/sequencer/sequencer.c @@ -15,6 +15,8 @@ */ #include "sequencer.h" +#include "debug.h" +#include "timer.h" #ifdef MIDI_ENABLE # include "process_midi.h" diff --git a/quantum/sequencer/sequencer.h b/quantum/sequencer/sequencer.h index a8ea16eece..a6498ed413 100644 --- a/quantum/sequencer/sequencer.h +++ b/quantum/sequencer/sequencer.h @@ -17,8 +17,7 @@ #pragma once #include -#include "debug.h" -#include "timer.h" +#include // Maximum number of steps: 256 #ifndef SEQUENCER_STEPS @@ -42,7 +41,18 @@ * Make sure that the items of this enumeration follow the powers of 2, separated by a ternary variant. * Check the implementation of `get_step_duration` for further explanation. */ -typedef enum { SQ_RES_2, SQ_RES_2T, SQ_RES_4, SQ_RES_4T, SQ_RES_8, SQ_RES_8T, SQ_RES_16, SQ_RES_16T, SQ_RES_32, SEQUENCER_RESOLUTIONS } sequencer_resolution_t; +typedef enum { + SQ_RES_2, // + SQ_RES_2T, + SQ_RES_4, + SQ_RES_4T, + SQ_RES_8, + SQ_RES_8T, + SQ_RES_16, + SQ_RES_16T, + SQ_RES_32, + SEQUENCER_RESOLUTIONS +} sequencer_resolution_t; typedef struct { bool enabled; -- cgit v1.2.3 From 3de296f42014c489682730d9ab554d25ba8953a4 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Thu, 3 Nov 2022 21:36:58 +0000 Subject: Reduce includes for crc header (#18947) --- quantum/crc.c | 28 ++++++++++++++++++++++------ quantum/crc.h | 5 +++-- 2 files changed, 25 insertions(+), 8 deletions(-) (limited to 'quantum') diff --git a/quantum/crc.c b/quantum/crc.c index 0d8b9d6017..6b406df64a 100644 --- a/quantum/crc.c +++ b/quantum/crc.c @@ -16,16 +16,32 @@ #include "crc.h" -__attribute__((weak)) void crc_init(void){ - /* Software implementation nothing todo here. */ -}; +__attribute__((weak)) void crc_init(void) { + // Software implementation nothing todo here. +} #if defined(CRC8_USE_TABLE) /** * Static table used for the table_driven implementation. */ -static const crc_t crc_table[256] = {0x00, 0x07, 0x0e, 0x09, 0x1c, 0x1b, 0x12, 0x15, 0x38, 0x3f, 0x36, 0x31, 0x24, 0x23, 0x2a, 0x2d, 0x70, 0x77, 0x7e, 0x79, 0x6c, 0x6b, 0x62, 0x65, 0x48, 0x4f, 0x46, 0x41, 0x54, 0x53, 0x5a, 0x5d, 0xe0, 0xe7, 0xee, 0xe9, 0xfc, 0xfb, 0xf2, 0xf5, 0xd8, 0xdf, 0xd6, 0xd1, 0xc4, 0xc3, 0xca, 0xcd, 0x90, 0x97, 0x9e, 0x99, 0x8c, 0x8b, 0x82, 0x85, 0xa8, 0xaf, 0xa6, 0xa1, 0xb4, 0xb3, 0xba, 0xbd, 0xc7, 0xc0, 0xc9, 0xce, 0xdb, 0xdc, 0xd5, 0xd2, 0xff, 0xf8, 0xf1, 0xf6, 0xe3, 0xe4, 0xed, 0xea, 0xb7, 0xb0, 0xb9, 0xbe, 0xab, 0xac, 0xa5, 0xa2, 0x8f, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9d, 0x9a, 0x27, 0x20, 0x29, 0x2e, 0x3b, 0x3c, 0x35, 0x32, 0x1f, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0d, 0x0a, 0x57, 0x50, 0x59, 0x5e, 0x4b, 0x4c, 0x45, 0x42, 0x6f, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7d, 0x7a, - 0x89, 0x8e, 0x87, 0x80, 0x95, 0x92, 0x9b, 0x9c, 0xb1, 0xb6, 0xbf, 0xb8, 0xad, 0xaa, 0xa3, 0xa4, 0xf9, 0xfe, 0xf7, 0xf0, 0xe5, 0xe2, 0xeb, 0xec, 0xc1, 0xc6, 0xcf, 0xc8, 0xdd, 0xda, 0xd3, 0xd4, 0x69, 0x6e, 0x67, 0x60, 0x75, 0x72, 0x7b, 0x7c, 0x51, 0x56, 0x5f, 0x58, 0x4d, 0x4a, 0x43, 0x44, 0x19, 0x1e, 0x17, 0x10, 0x05, 0x02, 0x0b, 0x0c, 0x21, 0x26, 0x2f, 0x28, 0x3d, 0x3a, 0x33, 0x34, 0x4e, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5c, 0x5b, 0x76, 0x71, 0x78, 0x7f, 0x6a, 0x6d, 0x64, 0x63, 0x3e, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2c, 0x2b, 0x06, 0x01, 0x08, 0x0f, 0x1a, 0x1d, 0x14, 0x13, 0xae, 0xa9, 0xa0, 0xa7, 0xb2, 0xb5, 0xbc, 0xbb, 0x96, 0x91, 0x98, 0x9f, 0x8a, 0x8d, 0x84, 0x83, 0xde, 0xd9, 0xd0, 0xd7, 0xc2, 0xc5, 0xcc, 0xcb, 0xe6, 0xe1, 0xe8, 0xef, 0xfa, 0xfd, 0xf4, 0xf3}; +static const crc_t crc_table[256] = { + 0x00, 0x07, 0x0e, 0x09, 0x1c, 0x1b, 0x12, 0x15, 0x38, 0x3f, 0x36, 0x31, 0x24, 0x23, 0x2a, 0x2d, // + 0x70, 0x77, 0x7e, 0x79, 0x6c, 0x6b, 0x62, 0x65, 0x48, 0x4f, 0x46, 0x41, 0x54, 0x53, 0x5a, 0x5d, // + 0xe0, 0xe7, 0xee, 0xe9, 0xfc, 0xfb, 0xf2, 0xf5, 0xd8, 0xdf, 0xd6, 0xd1, 0xc4, 0xc3, 0xca, 0xcd, // + 0x90, 0x97, 0x9e, 0x99, 0x8c, 0x8b, 0x82, 0x85, 0xa8, 0xaf, 0xa6, 0xa1, 0xb4, 0xb3, 0xba, 0xbd, // + 0xc7, 0xc0, 0xc9, 0xce, 0xdb, 0xdc, 0xd5, 0xd2, 0xff, 0xf8, 0xf1, 0xf6, 0xe3, 0xe4, 0xed, 0xea, // + 0xb7, 0xb0, 0xb9, 0xbe, 0xab, 0xac, 0xa5, 0xa2, 0x8f, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9d, 0x9a, // + 0x27, 0x20, 0x29, 0x2e, 0x3b, 0x3c, 0x35, 0x32, 0x1f, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0d, 0x0a, // + 0x57, 0x50, 0x59, 0x5e, 0x4b, 0x4c, 0x45, 0x42, 0x6f, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7d, 0x7a, // + 0x89, 0x8e, 0x87, 0x80, 0x95, 0x92, 0x9b, 0x9c, 0xb1, 0xb6, 0xbf, 0xb8, 0xad, 0xaa, 0xa3, 0xa4, // + 0xf9, 0xfe, 0xf7, 0xf0, 0xe5, 0xe2, 0xeb, 0xec, 0xc1, 0xc6, 0xcf, 0xc8, 0xdd, 0xda, 0xd3, 0xd4, // + 0x69, 0x6e, 0x67, 0x60, 0x75, 0x72, 0x7b, 0x7c, 0x51, 0x56, 0x5f, 0x58, 0x4d, 0x4a, 0x43, 0x44, // + 0x19, 0x1e, 0x17, 0x10, 0x05, 0x02, 0x0b, 0x0c, 0x21, 0x26, 0x2f, 0x28, 0x3d, 0x3a, 0x33, 0x34, // + 0x4e, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5c, 0x5b, 0x76, 0x71, 0x78, 0x7f, 0x6a, 0x6d, 0x64, 0x63, // + 0x3e, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2c, 0x2b, 0x06, 0x01, 0x08, 0x0f, 0x1a, 0x1d, 0x14, 0x13, // + 0xae, 0xa9, 0xa0, 0xa7, 0xb2, 0xb5, 0xbc, 0xbb, 0x96, 0x91, 0x98, 0x9f, 0x8a, 0x8d, 0x84, 0x83, // + 0xde, 0xd9, 0xd0, 0xd7, 0xc2, 0xc5, 0xcc, 0xcb, 0xe6, 0xe1, 0xe8, 0xef, 0xfa, 0xfd, 0xf4, 0xf3 // +}; __attribute__((weak)) uint8_t crc8(const void *data, size_t data_len) { const uint8_t *d = (const uint8_t *)data; @@ -56,4 +72,4 @@ __attribute__((weak)) uint8_t crc8(const void *data, size_t data_len) { } return crc; } -#endif \ No newline at end of file +#endif diff --git a/quantum/crc.h b/quantum/crc.h index c17f5888e2..86635847d0 100644 --- a/quantum/crc.h +++ b/quantum/crc.h @@ -16,7 +16,8 @@ #pragma once -#include "quantum.h" +#include +#include /** * The type of the CRC values. @@ -41,4 +42,4 @@ __attribute__((weak)) void crc_init(void); * \param[in] data_len Number of bytes in the \a data buffer. * \return The calculated crc value. */ -__attribute__((weak)) uint8_t crc8(const void *data, size_t data_len); \ No newline at end of file +__attribute__((weak)) uint8_t crc8(const void *data, size_t data_len); -- cgit v1.2.3 From fe18df9d4186c7f2c97a2bfccf3cc0e11615c728 Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 4 Nov 2022 10:01:06 +1100 Subject: Normalise Dynamic Macro keycodes (#18939) * `DYN_REC_START1` -> `QK_DYNAMIC_MACRO_RECORD_START_1` * `DYN_REC_START2` -> `QK_DYNAMIC_MACRO_RECORD_START_2` * `DYN_MACRO_PLAY1` -> `QK_DYNAMIC_MACRO_PLAY_1` * `DYN_MACRO_PLAY2` -> `QK_DYNAMIC_MACRO_PLAY_2` * `DYN_REC_STOP` -> `QK_DYNAMIC_MACRO_RECORD_STOP` * Update docs --- quantum/dynamic_macro.h | 16 +++++++-------- quantum/process_keycode/process_dynamic_macro.c | 26 ++++++++++++------------- quantum/quantum_keycodes.h | 20 +++++++++---------- quantum/quantum_keycodes_legacy.h | 6 ++++++ 4 files changed, 37 insertions(+), 31 deletions(-) (limited to 'quantum') diff --git a/quantum/dynamic_macro.h b/quantum/dynamic_macro.h index fe9de6fa65..64c532e6ce 100644 --- a/quantum/dynamic_macro.h +++ b/quantum/dynamic_macro.h @@ -129,7 +129,7 @@ void dynamic_macro_record_end(keyrecord_t *macro_buffer, keyrecord_t *macro_poin dynamic_macro_led_blink(); /* Do not save the keys being held when stopping the recording, - * i.e. the keys used to access the layer DYN_REC_STOP is on. + * i.e. the keys used to access the layer DM_RSTP is on. */ while (macro_pointer != macro_buffer && (macro_pointer - direction)->event.pressed) { dprintln("dynamic macro: trimming a trailing key-down event"); @@ -202,18 +202,18 @@ bool process_record_dynamic_macro(uint16_t keycode, keyrecord_t *record) { /* No macro recording in progress. */ if (!record->event.pressed) { switch (keycode) { - case DYN_REC_START1: + case QK_DYNAMIC_MACRO_RECORD_START_1: dynamic_macro_record_start(¯o_pointer, macro_buffer); macro_id = 1; return false; - case DYN_REC_START2: + case QK_DYNAMIC_MACRO_RECORD_START_2: dynamic_macro_record_start(¯o_pointer, r_macro_buffer); macro_id = 2; return false; - case DYN_MACRO_PLAY1: + case QK_DYNAMIC_MACRO_PLAY_1: dynamic_macro_play(macro_buffer, macro_end, +1); return false; - case DYN_MACRO_PLAY2: + case QK_DYNAMIC_MACRO_PLAY_2: dynamic_macro_play(r_macro_buffer, r_macro_end, -1); return false; } @@ -221,7 +221,7 @@ bool process_record_dynamic_macro(uint16_t keycode, keyrecord_t *record) { } else { /* A macro is being recorded right now. */ switch (keycode) { - case DYN_REC_STOP: + case QK_DYNAMIC_MACRO_RECORD_STOP: /* Stop the macro recording. */ if (record->event.pressed) { /* Ignore the initial release * just after the recoding @@ -237,8 +237,8 @@ bool process_record_dynamic_macro(uint16_t keycode, keyrecord_t *record) { macro_id = 0; } return false; - case DYN_MACRO_PLAY1: - case DYN_MACRO_PLAY2: + case QK_DYNAMIC_MACRO_PLAY_1: + case QK_DYNAMIC_MACRO_PLAY_2: dprintln("dynamic macro: ignoring macro play key while recording"); return false; default: diff --git a/quantum/process_keycode/process_dynamic_macro.c b/quantum/process_keycode/process_dynamic_macro.c index 41207092a9..c2e7e7716f 100644 --- a/quantum/process_keycode/process_dynamic_macro.c +++ b/quantum/process_keycode/process_dynamic_macro.c @@ -139,7 +139,7 @@ void dynamic_macro_record_end(keyrecord_t *macro_buffer, keyrecord_t *macro_poin dynamic_macro_record_end_user(direction); /* Do not save the keys being held when stopping the recording, - * i.e. the keys used to access the layer DYN_REC_STOP is on. + * i.e. the keys used to access the layer DM_RSTP is on. */ while (macro_pointer != macro_buffer && (macro_pointer - direction)->event.pressed) { dprintln("dynamic macro: trimming a trailing key-down event"); @@ -212,18 +212,18 @@ bool process_dynamic_macro(uint16_t keycode, keyrecord_t *record) { /* No macro recording in progress. */ if (!record->event.pressed) { switch (keycode) { - case DYN_REC_START1: + case QK_DYNAMIC_MACRO_RECORD_START_1: dynamic_macro_record_start(¯o_pointer, macro_buffer); macro_id = 1; return false; - case DYN_REC_START2: + case QK_DYNAMIC_MACRO_RECORD_START_2: dynamic_macro_record_start(¯o_pointer, r_macro_buffer); macro_id = 2; return false; - case DYN_MACRO_PLAY1: + case QK_DYNAMIC_MACRO_PLAY_1: dynamic_macro_play(macro_buffer, macro_end, +1); return false; - case DYN_MACRO_PLAY2: + case QK_DYNAMIC_MACRO_PLAY_2: dynamic_macro_play(r_macro_buffer, r_macro_end, -1); return false; } @@ -231,13 +231,13 @@ bool process_dynamic_macro(uint16_t keycode, keyrecord_t *record) { } else { /* A macro is being recorded right now. */ switch (keycode) { - case DYN_REC_START1: - case DYN_REC_START2: - case DYN_REC_STOP: + case QK_DYNAMIC_MACRO_RECORD_START_1: + case QK_DYNAMIC_MACRO_RECORD_START_2: + case QK_DYNAMIC_MACRO_RECORD_STOP: /* Stop the macro recording. */ - if (record->event.pressed ^ (keycode != DYN_REC_STOP)) { /* Ignore the initial release - * just after the recording - * starts for DYN_REC_STOP. */ + if (record->event.pressed ^ (keycode != QK_DYNAMIC_MACRO_RECORD_STOP)) { /* Ignore the initial release + * just after the recording + * starts for DM_RSTP. */ switch (macro_id) { case 1: dynamic_macro_record_end(macro_buffer, macro_pointer, +1, ¯o_end); @@ -250,8 +250,8 @@ bool process_dynamic_macro(uint16_t keycode, keyrecord_t *record) { } return false; #ifdef DYNAMIC_MACRO_NO_NESTING - case DYN_MACRO_PLAY1: - case DYN_MACRO_PLAY2: + case QK_DYNAMIC_MACRO_PLAY_1: + case QK_DYNAMIC_MACRO_PLAY_2: dprintln("dynamic macro: ignoring macro play key while recording"); return false; #endif diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 2f9e211cc1..2df733fe1f 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -424,11 +424,11 @@ enum quantum_keycodes { MAGIC_EE_HANDS_RIGHT, // 5D03 // Dynamic Macros - DYN_REC_START1, // 5D04 - DYN_REC_START2, // 5D05 - DYN_REC_STOP, // 5D06 - DYN_MACRO_PLAY1, // 5D07 - DYN_MACRO_PLAY2, // 5D08 + QK_DYNAMIC_MACRO_RECORD_START_1, // 5D04 + QK_DYNAMIC_MACRO_RECORD_START_2, // 5D05 + QK_DYNAMIC_MACRO_RECORD_STOP, // 5D06 + QK_DYNAMIC_MACRO_PLAY_1, // 5D07 + QK_DYNAMIC_MACRO_PLAY_2, // 5D08 // Joystick QK_JOYSTICK_BUTTON_0, // 5D09 @@ -906,11 +906,11 @@ enum quantum_keycodes { #define MIDI_CHANNEL_MAX MI_CH16 // Dynamic Macros aliases -#define DM_REC1 DYN_REC_START1 -#define DM_REC2 DYN_REC_START2 -#define DM_RSTP DYN_REC_STOP -#define DM_PLY1 DYN_MACRO_PLAY1 -#define DM_PLY2 DYN_MACRO_PLAY2 +#define DM_REC1 QK_DYNAMIC_MACRO_RECORD_START_1 +#define DM_REC2 QK_DYNAMIC_MACRO_RECORD_START_2 +#define DM_RSTP QK_DYNAMIC_MACRO_RECORD_STOP +#define DM_PLY1 QK_DYNAMIC_MACRO_PLAY_1 +#define DM_PLY2 QK_DYNAMIC_MACRO_PLAY_2 // Joystick aliases #define JS_0 QK_JOYSTICK_BUTTON_0 diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h index 68771baece..8f325251bc 100644 --- a/quantum/quantum_keycodes_legacy.h +++ b/quantum/quantum_keycodes_legacy.h @@ -38,6 +38,12 @@ #define UC_M_WC QK_UNICODE_MODE_WINCOMPOSE #define UC_M_EM QK_UNICODE_MODE_EMACS +#define DYN_REC_START1 QK_DYNAMIC_MACRO_RECORD_START_1 +#define DYN_REC_START2 QK_DYNAMIC_MACRO_RECORD_START_2 +#define DYN_REC_STOP QK_DYNAMIC_MACRO_RECORD_STOP +#define DYN_MACRO_PLAY1 QK_DYNAMIC_MACRO_PLAY_1 +#define DYN_MACRO_PLAY2 QK_DYNAMIC_MACRO_PLAY_2 + #define PROGRAMMABLE_BUTTON_1 QK_PROGRAMMABLE_BUTTON_1 #define PROGRAMMABLE_BUTTON_2 QK_PROGRAMMABLE_BUTTON_2 #define PROGRAMMABLE_BUTTON_3 QK_PROGRAMMABLE_BUTTON_3 -- cgit v1.2.3 From 1249f74b31863bc0118057884abae10de698e4a5 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Thu, 3 Nov 2022 23:42:58 +0000 Subject: Reduce includes for caps_word header (#18948) --- quantum/caps_word.c | 6 ++++++ quantum/caps_word.h | 27 ++++++++++++++++----------- 2 files changed, 22 insertions(+), 11 deletions(-) (limited to 'quantum') diff --git a/quantum/caps_word.c b/quantum/caps_word.c index 5b83659f28..66fd0e8afb 100644 --- a/quantum/caps_word.c +++ b/quantum/caps_word.c @@ -12,7 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include #include "caps_word.h" +#include "timer.h" +#include "action.h" +#include "action_util.h" /** @brief True when Caps Word is active. */ static bool caps_word_active = false; @@ -36,6 +40,8 @@ void caps_word_task(void) { void caps_word_reset_idle_timer(void) { idle_timer = timer_read() + CAPS_WORD_IDLE_TIMEOUT; } +#else +void caps_word_task(void) {} #endif // CAPS_WORD_IDLE_TIMEOUT > 0 void caps_word_on(void) { diff --git a/quantum/caps_word.h b/quantum/caps_word.h index b83f73371e..078d29ead0 100644 --- a/quantum/caps_word.h +++ b/quantum/caps_word.h @@ -14,26 +14,31 @@ #pragma once -#include "quantum.h" +#include #ifndef CAPS_WORD_IDLE_TIMEOUT # define CAPS_WORD_IDLE_TIMEOUT 5000 // Default timeout of 5 seconds. -#endif // CAPS_WORD_IDLE_TIMEOUT +#endif -#if CAPS_WORD_IDLE_TIMEOUT > 0 /** @brief Matrix scan task for Caps Word feature */ void caps_word_task(void); +#if CAPS_WORD_IDLE_TIMEOUT > 0 /** @brief Resets timer for Caps Word idle timeout. */ void caps_word_reset_idle_timer(void); -#else -static inline void caps_word_task(void) {} -#endif // CAPS_WORD_IDLE_TIMEOUT > 0 - -void caps_word_on(void); /**< Activates Caps Word. */ -void caps_word_off(void); /**< Deactivates Caps Word. */ -void caps_word_toggle(void); /**< Toggles Caps Word. */ -bool is_caps_word_on(void); /**< Gets whether currently active. */ +#endif + +/** @brief Activates Caps Word. */ +void caps_word_on(void); + +/** @brief Deactivates Caps Word. */ +void caps_word_off(void); + +/** @brief Toggles Caps Word. */ +void caps_word_toggle(void); + +/** @brief Gets whether currently active. */ +bool is_caps_word_on(void); /** * @brief Caps Word set callback. -- cgit v1.2.3 From fb96b88842f4481df8942768f43813b489ca5c3a Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Fri, 4 Nov 2022 00:50:59 +0000 Subject: Reduce includes for wpm header (#18949) --- quantum/wpm.c | 4 +++- quantum/wpm.h | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'quantum') diff --git a/quantum/wpm.c b/quantum/wpm.c index b2e6fe0430..6a4e39a8d6 100644 --- a/quantum/wpm.c +++ b/quantum/wpm.c @@ -16,7 +16,9 @@ */ #include "wpm.h" - +#include "timer.h" +#include "keycode.h" +#include "quantum_keycodes.h" #include // WPM Stuff diff --git a/quantum/wpm.h b/quantum/wpm.h index 305d75b450..87a55fd422 100644 --- a/quantum/wpm.h +++ b/quantum/wpm.h @@ -17,7 +17,8 @@ #pragma once -#include "quantum.h" +#include +#include #ifndef WPM_ESTIMATED_WORD_SIZE # define WPM_ESTIMATED_WORD_SIZE 5 -- cgit v1.2.3 From ea98aa8e5ef8bebac52a76ad22ddd22e6d7f289e Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Fri, 4 Nov 2022 11:54:35 +0000 Subject: Reduce includes for dip_switch header (#18951) --- quantum/dip_switch.c | 8 +++++--- quantum/dip_switch.h | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'quantum') diff --git a/quantum/dip_switch.c b/quantum/dip_switch.c index e180cfccdf..6e254578d1 100644 --- a/quantum/dip_switch.c +++ b/quantum/dip_switch.c @@ -16,14 +16,16 @@ * along with this program. If not, see . */ +#include // for memcpy + #include "dip_switch.h" +#include "gpio.h" +#include "util.h" + #ifdef SPLIT_KEYBOARD # include "split_common/split_util.h" #endif -// for memcpy -#include - #if !defined(DIP_SWITCH_PINS) && !defined(DIP_SWITCH_MATRIX_GRID) # error "Either DIP_SWITCH_PINS or DIP_SWITCH_MATRIX_GRID must be defined." #endif diff --git a/quantum/dip_switch.h b/quantum/dip_switch.h index 058a10f41f..6e79dcb0bf 100644 --- a/quantum/dip_switch.h +++ b/quantum/dip_switch.h @@ -18,7 +18,8 @@ #pragma once -#include "quantum.h" +#include +#include bool dip_switch_update_kb(uint8_t index, bool active); bool dip_switch_update_user(uint8_t index, bool active); -- cgit v1.2.3 From f82e90bdeaab1b2ec5c96716731f0a4c63193de9 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Sat, 5 Nov 2022 06:20:11 +1100 Subject: Formalise keyboard- and user-specific EEPROM blocks (#18874) * Formalise keyboard and user eeconfig datablocks. * Add debounce helper that checks a condition and issues post-write function invocation. * Naming. --- quantum/dynamic_keymap.c | 4 +-- quantum/eeconfig.c | 66 +++++++++++++++++++++++++++++++++++++++++++++ quantum/eeconfig.h | 70 +++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 130 insertions(+), 10 deletions(-) (limited to 'quantum') diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c index d800bbab84..e9529ed14e 100644 --- a/quantum/dynamic_keymap.c +++ b/quantum/dynamic_keymap.c @@ -24,9 +24,7 @@ # include "via.h" // for VIA_EEPROM_CONFIG_END # define DYNAMIC_KEYMAP_EEPROM_START (VIA_EEPROM_CONFIG_END) #else -# ifndef DYNAMIC_KEYMAP_EEPROM_START -# define DYNAMIC_KEYMAP_EEPROM_START (EECONFIG_SIZE) -# endif +# define DYNAMIC_KEYMAP_EEPROM_START (EECONFIG_SIZE) #endif #ifdef ENCODER_ENABLE diff --git a/quantum/eeconfig.c b/quantum/eeconfig.c index 2e2df11d69..3b4d690e42 100644 --- a/quantum/eeconfig.c +++ b/quantum/eeconfig.c @@ -1,3 +1,4 @@ +#include #include #include #include "eeprom.h" @@ -23,13 +24,17 @@ void eeconfig_init_via(void); * FIXME: needs doc */ __attribute__((weak)) void eeconfig_init_user(void) { +#if (EECONFIG_USER_DATA_SIZE) == 0 // Reset user EEPROM value to blank, rather than to a set value eeconfig_update_user(0); +#endif } __attribute__((weak)) void eeconfig_init_kb(void) { +#if (EECONFIG_KB_DATA_SIZE) == 0 // Reset Keyboard EEPROM value to blank, rather than to a set value eeconfig_update_kb(0); +#endif eeconfig_init_user(); } @@ -64,6 +69,19 @@ void eeconfig_init_quantum(void) { // when a haptic-enabled firmware is loaded onto the keyboard. eeprom_update_dword(EECONFIG_HAPTIC, 0); #endif + +#if (EECONFIG_KB_DATA_SIZE) > 0 + eeprom_update_dword(EECONFIG_KEYBOARD, (EECONFIG_KB_DATA_VERSION)); + uint8_t dummy_kb[(EECONFIG_KB_DATA_SIZE)] = {0}; + eeprom_update_block(EECONFIG_KB_DATABLOCK, dummy_kb, (EECONFIG_KB_DATA_SIZE)); +#endif + +#if (EECONFIG_USER_DATA_SIZE) > 0 + eeprom_update_dword(EECONFIG_USER, (EECONFIG_USER_DATA_VERSION)); + uint8_t dummy_user[(EECONFIG_USER_DATA_SIZE)] = {0}; + eeprom_update_block(EECONFIG_USER_DATABLOCK, dummy_user, (EECONFIG_USER_DATA_SIZE)); +#endif + #if defined(VIA_ENABLE) // Invalidate VIA eeprom config, and then reset. // Just in case if power is lost mid init, this makes sure that it pets @@ -190,6 +208,7 @@ void eeconfig_update_audio(uint8_t val) { eeprom_update_byte(EECONFIG_AUDIO, val); } +#if (EECONFIG_KB_DATA_SIZE) == 0 /** \brief eeconfig read kb * * FIXME: needs doc @@ -204,7 +223,9 @@ uint32_t eeconfig_read_kb(void) { void eeconfig_update_kb(uint32_t val) { eeprom_update_dword(EECONFIG_KEYBOARD, val); } +#endif // (EECONFIG_KB_DATA_SIZE) == 0 +#if (EECONFIG_USER_DATA_SIZE) == 0 /** \brief eeconfig read user * * FIXME: needs doc @@ -219,6 +240,7 @@ uint32_t eeconfig_read_user(void) { void eeconfig_update_user(uint32_t val) { eeprom_update_dword(EECONFIG_USER, val); } +#endif // (EECONFIG_USER_DATA_SIZE) == 0 /** \brief eeconfig read haptic * @@ -249,3 +271,47 @@ bool eeconfig_read_handedness(void) { void eeconfig_update_handedness(bool val) { eeprom_update_byte(EECONFIG_HANDEDNESS, !!val); } + +#if (EECONFIG_KB_DATA_SIZE) > 0 +/** \brief eeconfig read keyboard data block + * + * FIXME: needs doc + */ +void eeconfig_read_kb_datablock(void *data) { + if (eeprom_read_dword(EECONFIG_KEYBOARD) == (EECONFIG_KB_DATA_VERSION)) { + eeprom_read_block(data, EECONFIG_KB_DATABLOCK, (EECONFIG_KB_DATA_SIZE)); + } else { + memset(data, 0, (EECONFIG_KB_DATA_SIZE)); + } +} +/** \brief eeconfig update keyboard data block + * + * FIXME: needs doc + */ +void eeconfig_update_kb_datablock(const void *data) { + eeprom_update_dword(EECONFIG_KEYBOARD, (EECONFIG_KB_DATA_VERSION)); + eeprom_update_block(data, EECONFIG_KB_DATABLOCK, (EECONFIG_KB_DATA_SIZE)); +} +#endif // (EECONFIG_KB_DATA_SIZE) > 0 + +#if (EECONFIG_USER_DATA_SIZE) > 0 +/** \brief eeconfig read user data block + * + * FIXME: needs doc + */ +void eeconfig_read_user_datablock(void *data) { + if (eeprom_read_dword(EECONFIG_USER) == (EECONFIG_USER_DATA_VERSION)) { + eeprom_read_block(data, EECONFIG_USER_DATABLOCK, (EECONFIG_USER_DATA_SIZE)); + } else { + memset(data, 0, (EECONFIG_USER_DATA_SIZE)); + } +} +/** \brief eeconfig update user data block + * + * FIXME: needs doc + */ +void eeconfig_update_user_datablock(const void *data) { + eeprom_update_dword(EECONFIG_USER, (EECONFIG_USER_DATA_VERSION)); + eeprom_update_block(data, EECONFIG_USER_DATABLOCK, (EECONFIG_USER_DATA_SIZE)); +} +#endif // (EECONFIG_USER_DATA_SIZE) > 0 diff --git a/quantum/eeconfig.h b/quantum/eeconfig.h index 9c4617c962..9fc563d09c 100644 --- a/quantum/eeconfig.h +++ b/quantum/eeconfig.h @@ -50,8 +50,29 @@ along with this program. If not, see . #define EECONFIG_LED_MATRIX_EXTENDED (uint16_t *)32 #define EECONFIG_RGB_MATRIX_EXTENDED (uint16_t *)32 +// Size of EEPROM being used for core data storage +#define EECONFIG_BASE_SIZE 34 + +// Size of EEPROM dedicated to keyboard- and user-specific data +#ifndef EECONFIG_KB_DATA_SIZE +# define EECONFIG_KB_DATA_SIZE 0 +#endif +#ifndef EECONFIG_KB_DATA_VERSION +# define EECONFIG_KB_DATA_VERSION (EECONFIG_KB_DATA_SIZE) +#endif +#ifndef EECONFIG_USER_DATA_SIZE +# define EECONFIG_USER_DATA_SIZE 0 +#endif +#ifndef EECONFIG_USER_DATA_VERSION +# define EECONFIG_USER_DATA_VERSION (EECONFIG_USER_DATA_SIZE) +#endif + +#define EECONFIG_KB_DATABLOCK ((uint8_t *)(EECONFIG_BASE_SIZE)) +#define EECONFIG_USER_DATABLOCK ((uint8_t *)((EECONFIG_BASE_SIZE) + (EECONFIG_KB_DATA_SIZE))) + // Size of EEPROM being used, other code can refer to this for available EEPROM -#define EECONFIG_SIZE 34 +#define EECONFIG_SIZE ((EECONFIG_BASE_SIZE) + (EECONFIG_KB_DATA_SIZE) + (EECONFIG_USER_DATA_SIZE)) + /* debug bit */ #define EECONFIG_DEBUG_ENABLE (1 << 0) #define EECONFIG_DEBUG_MATRIX (1 << 1) @@ -94,10 +115,15 @@ uint8_t eeconfig_read_audio(void); void eeconfig_update_audio(uint8_t val); #endif +#if (EECONFIG_KB_DATA_SIZE) == 0 uint32_t eeconfig_read_kb(void); void eeconfig_update_kb(uint32_t val); +#endif // (EECONFIG_KB_DATA_SIZE) == 0 + +#if (EECONFIG_USER_DATA_SIZE) == 0 uint32_t eeconfig_read_user(void); void eeconfig_update_user(uint32_t val); +#endif // (EECONFIG_USER_DATA_SIZE) == 0 #ifdef HAPTIC_ENABLE uint32_t eeconfig_read_haptic(void); @@ -107,16 +133,36 @@ void eeconfig_update_haptic(uint32_t val); bool eeconfig_read_handedness(void); void eeconfig_update_handedness(bool val); -#define EECONFIG_DEBOUNCE_HELPER(name, offset, config) \ +#if (EECONFIG_KB_DATA_SIZE) > 0 +void eeconfig_read_kb_datablock(void *data); +void eeconfig_update_kb_datablock(const void *data); +#endif // (EECONFIG_KB_DATA_SIZE) > 0 + +#if (EECONFIG_USER_DATA_SIZE) > 0 +void eeconfig_read_user_datablock(void *data); +void eeconfig_update_user_datablock(const void *data); +#endif // (EECONFIG_USER_DATA_SIZE) > 0 + +// Any "checked" debounce variant used requires implementation of: +// -- bool eeconfig_check_valid_##name(void) +// -- void eeconfig_post_flush_##name(void) +#define EECONFIG_DEBOUNCE_HELPER_CHECKED(name, offset, config) \ static uint8_t dirty_##name = false; \ \ + bool eeconfig_check_valid_##name(void); \ + void eeconfig_post_flush_##name(void); \ + \ static inline void eeconfig_init_##name(void) { \ - eeprom_read_block(&config, offset, sizeof(config)); \ - dirty_##name = false; \ + dirty_##name = true; \ + if (eeconfig_check_valid_##name()) { \ + eeprom_read_block(&config, offset, sizeof(config)); \ + dirty_##name = false; \ + } \ } \ static inline void eeconfig_flush_##name(bool force) { \ if (force || dirty_##name) { \ eeprom_update_block(&config, offset, sizeof(config)); \ + eeconfig_post_flush_##name(); \ dirty_##name = false; \ } \ } \ @@ -130,7 +176,17 @@ void eeconfig_update_handedness(bool val); static inline void eeconfig_flag_##name(bool v) { \ dirty_##name |= v; \ } \ - static inline void eeconfig_write_##name(typeof(config) conf) { \ - memcpy(&config, &conf, sizeof(config)); \ - eeconfig_flag_##name(true); \ + static inline void eeconfig_write_##name(typeof(config) *conf) { \ + if (memcmp(&config, conf, sizeof(config)) != 0) { \ + memcpy(&config, conf, sizeof(config)); \ + eeconfig_flag_##name(true); \ + } \ } + +#define EECONFIG_DEBOUNCE_HELPER(name, offset, config) \ + EECONFIG_DEBOUNCE_HELPER_CHECKED(name, offset, config) \ + \ + bool eeconfig_check_valid_##name(void) { \ + return true; \ + } \ + void eeconfig_post_flush_##name(void) {} -- cgit v1.2.3 From a69ab05dd687cb9aa38e0c125e4f64956c7da6c7 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Sat, 5 Nov 2022 10:30:09 +0000 Subject: Initial DD keycode migration (#18643) * Initial DD keycode migration * Sort magic keycodes --- quantum/action_code.h | 3 + quantum/keycode.h | 497 +-------- quantum/keycodes.h | 1115 ++++++++++++++++++++ quantum/keymap_common.c | 6 +- quantum/process_keycode/process_joystick.c | 6 +- quantum/process_keycode/process_magic.c | 270 +++-- .../process_keycode/process_programmable_button.c | 4 +- quantum/quantum_keycodes.h | 903 +--------------- quantum/send_string/send_string_keycodes.h | 61 +- quantum/via.c | 1 - quantum/via.h | 11 +- quantum/via_ensure_keycode.h | 344 ------ 12 files changed, 1342 insertions(+), 1879 deletions(-) create mode 100644 quantum/keycodes.h delete mode 100644 quantum/via_ensure_keycode.h (limited to 'quantum') diff --git a/quantum/action_code.h b/quantum/action_code.h index 14cfd025f1..58d929016d 100644 --- a/quantum/action_code.h +++ b/quantum/action_code.h @@ -179,6 +179,9 @@ enum mods_bit { 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/keycode.h b/quantum/keycode.h index 2e9a85ee66..45736e92f1 100644 --- a/quantum/keycode.h +++ b/quantum/keycode.h @@ -26,16 +26,14 @@ along with this program. If not, see . /* FIXME: Add doxygen comments here */ -#define IS_ERROR(code) (KC_ROLL_OVER <= (code) && (code) <= KC_UNDEFINED) #define IS_ANY(code) (KC_A <= (code) && (code) <= 0xFF) -#define IS_KEY(code) (KC_A <= (code) && (code) <= KC_EXSEL) -#define IS_MOD(code) (KC_LEFT_CTRL <= (code) && (code) <= KC_RIGHT_GUI) +#define IS_KEY(code) IS_BASIC_KEYCODE(code) +#define IS_MOD(code) IS_MODIFIERS_KEYCODE(code) -#define IS_SPECIAL(code) ((0xA5 <= (code) && (code) <= 0xDF) || (0xE8 <= (code) && (code) <= 0xFF)) -#define IS_SYSTEM(code) (KC_PWR <= (code) && (code) <= KC_WAKE) -#define IS_CONSUMER(code) (KC_MUTE <= (code) && (code) <= KC_ASST) +#define IS_SYSTEM(code) IS_SYSTEM_KEYCODE(code) +#define IS_CONSUMER(code) IS_MEDIA_KEYCODE(code) -#define IS_MOUSEKEY(code) (KC_MS_UP <= (code) && (code) <= KC_MS_ACCEL2) +#define IS_MOUSEKEY(code) IS_MOUSE_KEYCODE(code) #define IS_MOUSEKEY_MOVE(code) (KC_MS_UP <= (code) && (code) <= KC_MS_RIGHT) #define IS_MOUSEKEY_BUTTON(code) (KC_MS_BTN1 <= (code) && (code) <= KC_MS_BTN8) #define IS_MOUSEKEY_WHEEL(code) (KC_MS_WH_UP <= (code) && (code) <= KC_MS_WH_RIGHT) @@ -62,486 +60,5 @@ along with this program. If not, see . // clang-format off -/* - * Short names for ease of definition of keymap - */ -/* Transparent */ -#define KC_TRANSPARENT 0x01 -#define KC_TRNS KC_TRANSPARENT - -/* Punctuation */ -#define KC_ENT KC_ENTER -#define KC_ESC KC_ESCAPE -#define KC_BSPC KC_BACKSPACE -#define KC_SPC KC_SPACE -#define KC_MINS KC_MINUS -#define KC_EQL KC_EQUAL -#define KC_LBRC KC_LEFT_BRACKET -#define KC_RBRC KC_RIGHT_BRACKET -#define KC_BSLS KC_BACKSLASH -#define KC_NUHS KC_NONUS_HASH -#define KC_SCLN KC_SEMICOLON -#define KC_QUOT KC_QUOTE -#define KC_GRV KC_GRAVE -#define KC_COMM KC_COMMA -#define KC_SLSH KC_SLASH -#define KC_NUBS KC_NONUS_BACKSLASH - -/* Lock Keys */ -#define KC_CAPS KC_CAPS_LOCK -#define KC_SCRL KC_SCROLL_LOCK -#define KC_NUM KC_NUM_LOCK -#define KC_LCAP KC_LOCKING_CAPS_LOCK -#define KC_LNUM KC_LOCKING_NUM_LOCK -#define KC_LSCR KC_LOCKING_SCROLL_LOCK - -/* Commands */ -#define KC_PSCR KC_PRINT_SCREEN -#define KC_PAUS KC_PAUSE -#define KC_BRK KC_PAUSE -#define KC_INS KC_INSERT -#define KC_PGUP KC_PAGE_UP -#define KC_DEL KC_DELETE -#define KC_PGDN KC_PAGE_DOWN -#define KC_RGHT KC_RIGHT -#define KC_APP KC_APPLICATION -#define KC_EXEC KC_EXECUTE -#define KC_SLCT KC_SELECT -#define KC_AGIN KC_AGAIN -#define KC_PSTE KC_PASTE -#define KC_ERAS KC_ALTERNATE_ERASE -#define KC_SYRQ KC_SYSTEM_REQUEST -#define KC_CNCL KC_CANCEL -#define KC_CLR KC_CLEAR -#define KC_PRIR KC_PRIOR -#define KC_RETN KC_RETURN -#define KC_SEPR KC_SEPARATOR -#define KC_CLAG KC_CLEAR_AGAIN -#define KC_CRSL KC_CRSEL -#define KC_EXSL KC_EXSEL - -/* Keypad */ -#define KC_PSLS KC_KP_SLASH -#define KC_PAST KC_KP_ASTERISK -#define KC_PMNS KC_KP_MINUS -#define KC_PPLS KC_KP_PLUS -#define KC_PENT KC_KP_ENTER -#define KC_P1 KC_KP_1 -#define KC_P2 KC_KP_2 -#define KC_P3 KC_KP_3 -#define KC_P4 KC_KP_4 -#define KC_P5 KC_KP_5 -#define KC_P6 KC_KP_6 -#define KC_P7 KC_KP_7 -#define KC_P8 KC_KP_8 -#define KC_P9 KC_KP_9 -#define KC_P0 KC_KP_0 -#define KC_PDOT KC_KP_DOT -#define KC_PEQL KC_KP_EQUAL -#define KC_PCMM KC_KP_COMMA - -/* Language Specific */ -#define KC_INT1 KC_INTERNATIONAL_1 -#define KC_INT2 KC_INTERNATIONAL_2 -#define KC_INT3 KC_INTERNATIONAL_3 -#define KC_INT4 KC_INTERNATIONAL_4 -#define KC_INT5 KC_INTERNATIONAL_5 -#define KC_INT6 KC_INTERNATIONAL_6 -#define KC_INT7 KC_INTERNATIONAL_7 -#define KC_INT8 KC_INTERNATIONAL_8 -#define KC_INT9 KC_INTERNATIONAL_9 -#define KC_LNG1 KC_LANGUAGE_1 -#define KC_LNG2 KC_LANGUAGE_2 -#define KC_LNG3 KC_LANGUAGE_3 -#define KC_LNG4 KC_LANGUAGE_4 -#define KC_LNG5 KC_LANGUAGE_5 -#define KC_LNG6 KC_LANGUAGE_6 -#define KC_LNG7 KC_LANGUAGE_7 -#define KC_LNG8 KC_LANGUAGE_8 -#define KC_LNG9 KC_LANGUAGE_9 - -/* Modifiers */ -#define KC_LCTL KC_LEFT_CTRL -#define KC_LSFT KC_LEFT_SHIFT -#define KC_LALT KC_LEFT_ALT -#define KC_LOPT KC_LEFT_ALT -#define KC_LGUI KC_LEFT_GUI -#define KC_LCMD KC_LEFT_GUI -#define KC_LWIN KC_LEFT_GUI -#define KC_RCTL KC_RIGHT_CTRL -#define KC_RSFT KC_RIGHT_SHIFT -#define KC_RALT KC_RIGHT_ALT -#define KC_ALGR KC_RIGHT_ALT -#define KC_ROPT KC_RIGHT_ALT -#define KC_RGUI KC_RIGHT_GUI -#define KC_RCMD KC_RIGHT_GUI -#define KC_RWIN KC_RIGHT_GUI - -/* Generic Desktop Page (0x01) */ -#define KC_PWR KC_SYSTEM_POWER -#define KC_SLEP KC_SYSTEM_SLEEP -#define KC_WAKE KC_SYSTEM_WAKE - -/* Consumer Page (0x0C) */ -#define KC_MUTE KC_AUDIO_MUTE -#define KC_VOLU KC_AUDIO_VOL_UP -#define KC_VOLD KC_AUDIO_VOL_DOWN -#define KC_MNXT KC_MEDIA_NEXT_TRACK -#define KC_MPRV KC_MEDIA_PREV_TRACK -#define KC_MSTP KC_MEDIA_STOP -#define KC_MPLY KC_MEDIA_PLAY_PAUSE -#define KC_MSEL KC_MEDIA_SELECT -#define KC_EJCT KC_MEDIA_EJECT -#define KC_CALC KC_CALCULATOR -#define KC_MYCM KC_MY_COMPUTER -#define KC_WSCH KC_WWW_SEARCH -#define KC_WHOM KC_WWW_HOME -#define KC_WBAK KC_WWW_BACK -#define KC_WFWD KC_WWW_FORWARD -#define KC_WSTP KC_WWW_STOP -#define KC_WREF KC_WWW_REFRESH -#define KC_WFAV KC_WWW_FAVORITES -#define KC_MFFD KC_MEDIA_FAST_FORWARD -#define KC_MRWD KC_MEDIA_REWIND -#define KC_BRIU KC_BRIGHTNESS_UP -#define KC_BRID KC_BRIGHTNESS_DOWN -#define KC_CPNL KC_CONTROL_PANEL -#define KC_ASST KC_ASSISTANT - -/* System Specific */ -#define KC_BRMU KC_PAUSE -#define KC_BRMD KC_SCROLL_LOCK - -/* Mouse Keys */ -#define KC_MS_U KC_MS_UP -#define KC_MS_D KC_MS_DOWN -#define KC_MS_L KC_MS_LEFT -#define KC_MS_R KC_MS_RIGHT -#define KC_BTN1 KC_MS_BTN1 -#define KC_BTN2 KC_MS_BTN2 -#define KC_BTN3 KC_MS_BTN3 -#define KC_BTN4 KC_MS_BTN4 -#define KC_BTN5 KC_MS_BTN5 -#define KC_BTN6 KC_MS_BTN6 -#define KC_BTN7 KC_MS_BTN7 -#define KC_BTN8 KC_MS_BTN8 -#define KC_WH_U KC_MS_WH_UP -#define KC_WH_D KC_MS_WH_DOWN -#define KC_WH_L KC_MS_WH_LEFT -#define KC_WH_R KC_MS_WH_RIGHT -#define KC_ACL0 KC_MS_ACCEL0 -#define KC_ACL1 KC_MS_ACCEL1 -#define KC_ACL2 KC_MS_ACCEL2 - -// clang-format on - -/* Keyboard/Keypad Page (0x07) */ -enum hid_keyboard_keypad_usage { - KC_NO = 0x00, - KC_ROLL_OVER, - KC_POST_FAIL, - KC_UNDEFINED, - KC_A, - KC_B, - KC_C, - KC_D, - KC_E, - KC_F, - KC_G, - KC_H, - KC_I, - KC_J, - KC_K, - KC_L, - KC_M, // 0x10 - KC_N, - KC_O, - KC_P, - KC_Q, - KC_R, - KC_S, - KC_T, - KC_U, - KC_V, - KC_W, - KC_X, - KC_Y, - KC_Z, - KC_1, - KC_2, - KC_3, // 0x20 - KC_4, - KC_5, - KC_6, - KC_7, - KC_8, - KC_9, - KC_0, - KC_ENTER, - KC_ESCAPE, - KC_BACKSPACE, - KC_TAB, - KC_SPACE, - KC_MINUS, - KC_EQUAL, - KC_LEFT_BRACKET, - KC_RIGHT_BRACKET, // 0x30 - KC_BACKSLASH, - KC_NONUS_HASH, - KC_SEMICOLON, - KC_QUOTE, - KC_GRAVE, - KC_COMMA, - KC_DOT, - KC_SLASH, - KC_CAPS_LOCK, - KC_F1, - KC_F2, - KC_F3, - KC_F4, - KC_F5, - KC_F6, - KC_F7, // 0x40 - KC_F8, - KC_F9, - KC_F10, - KC_F11, - KC_F12, - KC_PRINT_SCREEN, - KC_SCROLL_LOCK, - KC_PAUSE, - KC_INSERT, - KC_HOME, - KC_PAGE_UP, - KC_DELETE, - KC_END, - KC_PAGE_DOWN, - KC_RIGHT, - KC_LEFT, // 0x50 - KC_DOWN, - KC_UP, - KC_NUM_LOCK, - KC_KP_SLASH, - KC_KP_ASTERISK, - KC_KP_MINUS, - KC_KP_PLUS, - KC_KP_ENTER, - KC_KP_1, - KC_KP_2, - KC_KP_3, - KC_KP_4, - KC_KP_5, - KC_KP_6, - KC_KP_7, - KC_KP_8, // 0x60 - KC_KP_9, - KC_KP_0, - KC_KP_DOT, - KC_NONUS_BACKSLASH, - KC_APPLICATION, - KC_KB_POWER, - KC_KP_EQUAL, - KC_F13, - KC_F14, - KC_F15, - KC_F16, - KC_F17, - KC_F18, - KC_F19, - KC_F20, - KC_F21, // 0x70 - KC_F22, - KC_F23, - KC_F24, - KC_EXECUTE, - KC_HELP, - KC_MENU, - KC_SELECT, - KC_STOP, - KC_AGAIN, - KC_UNDO, - KC_CUT, - KC_COPY, - KC_PASTE, - KC_FIND, - KC_KB_MUTE, - KC_KB_VOLUME_UP, // 0x80 - KC_KB_VOLUME_DOWN, - KC_LOCKING_CAPS_LOCK, - KC_LOCKING_NUM_LOCK, - KC_LOCKING_SCROLL_LOCK, - KC_KP_COMMA, - KC_KP_EQUAL_AS400, - KC_INTERNATIONAL_1, - KC_INTERNATIONAL_2, - KC_INTERNATIONAL_3, - KC_INTERNATIONAL_4, - KC_INTERNATIONAL_5, - KC_INTERNATIONAL_6, - KC_INTERNATIONAL_7, - KC_INTERNATIONAL_8, - KC_INTERNATIONAL_9, - KC_LANGUAGE_1, // 0x90 - KC_LANGUAGE_2, - KC_LANGUAGE_3, - KC_LANGUAGE_4, - KC_LANGUAGE_5, - KC_LANGUAGE_6, - KC_LANGUAGE_7, - KC_LANGUAGE_8, - KC_LANGUAGE_9, - KC_ALTERNATE_ERASE, - KC_SYSTEM_REQUEST, - KC_CANCEL, - KC_CLEAR, - KC_PRIOR, - KC_RETURN, - KC_SEPARATOR, - KC_OUT, // 0xA0 - KC_OPER, - KC_CLEAR_AGAIN, - KC_CRSEL, - KC_EXSEL, - -#if 0 - // *************************************************************** - // These keycodes are present in the HID spec, but are * - // nonfunctional on modern OSes. QMK uses this range (0xA5-0xDF) * - // for the media and function keys instead - see below. * - // *************************************************************** - - KC_KP_00 = 0xB0, - KC_KP_000, - KC_THOUSANDS_SEPARATOR, - KC_DECIMAL_SEPARATOR, - KC_CURRENCY_UNIT, - KC_CURRENCY_SUB_UNIT, - KC_KP_LEFT_PARENTHESIS, - KC_KP_RIGHT_PARENTHESIS, - KC_KP_LEFT_BRACE, - KC_KP_RIGHT_BRACE, - KC_KP_TAB, - KC_KP_BACKSPACE, - KC_KP_A, - KC_KP_B, - KC_KP_C, - KC_KP_D, - KC_KP_E, //0xC0 - KC_KP_F, - KC_KP_XOR, - KC_KP_HAT, - KC_KP_PERCENT, - KC_KP_LESS_THAN, - KC_KP_GREATER_THAN, - KC_KP_AND, - KC_KP_LAZY_AND, - KC_KP_OR, - KC_KP_LAZY_OR, - KC_KP_COLON, - KC_KP_HASH, - KC_KP_SPACE, - KC_KP_AT, - KC_KP_EXCLAMATION, - KC_KP_MEM_STORE, //0xD0 - KC_KP_MEM_RECALL, - KC_KP_MEM_CLEAR, - KC_KP_MEM_ADD, - KC_KP_MEM_SUB, - KC_KP_MEM_MUL, - KC_KP_MEM_DIV, - KC_KP_PLUS_MINUS, - KC_KP_CLEAR, - KC_KP_CLEAR_ENTRY, - KC_KP_BINARY, - KC_KP_OCTAL, - KC_KP_DECIMAL, - KC_KP_HEXADECIMAL, -#endif - - /* Modifiers */ - KC_LEFT_CTRL = 0xE0, - KC_LEFT_SHIFT, - KC_LEFT_ALT, - KC_LEFT_GUI, - KC_RIGHT_CTRL, - KC_RIGHT_SHIFT, - KC_RIGHT_ALT, - KC_RIGHT_GUI - - // ********************************************** - // * 0xF0-0xFF are unallocated in the HID spec. * - // * QMK uses these for Mouse Keys - see below. * - // ********************************************** -}; - -/* Media and Function keys */ -enum internal_special_keycodes { - /* Generic Desktop Page (0x01) */ - KC_SYSTEM_POWER = 0xA5, - KC_SYSTEM_SLEEP, - KC_SYSTEM_WAKE, - - /* Consumer Page (0x0C) */ - KC_AUDIO_MUTE, - KC_AUDIO_VOL_UP, - KC_AUDIO_VOL_DOWN, - KC_MEDIA_NEXT_TRACK, - KC_MEDIA_PREV_TRACK, - KC_MEDIA_STOP, - KC_MEDIA_PLAY_PAUSE, - KC_MEDIA_SELECT, - KC_MEDIA_EJECT, // 0xB0 - KC_MAIL, - KC_CALCULATOR, - KC_MY_COMPUTER, - KC_WWW_SEARCH, - KC_WWW_HOME, - KC_WWW_BACK, - KC_WWW_FORWARD, - KC_WWW_STOP, - KC_WWW_REFRESH, - KC_WWW_FAVORITES, - KC_MEDIA_FAST_FORWARD, - KC_MEDIA_REWIND, - KC_BRIGHTNESS_UP, - KC_BRIGHTNESS_DOWN, - KC_CONTROL_PANEL, - KC_ASSISTANT // 0xC0 -}; - -enum mouse_keys { -/* Mouse Buttons */ -#ifdef VIA_ENABLE - KC_MS_UP = 0xF0, -#else - KC_MS_UP = 0xCD, -#endif - KC_MS_DOWN, - KC_MS_LEFT, - KC_MS_RIGHT, - KC_MS_BTN1, - KC_MS_BTN2, - KC_MS_BTN3, - KC_MS_BTN4, - KC_MS_BTN5, -#ifdef VIA_ENABLE - KC_MS_BTN6 = KC_MS_BTN5, - KC_MS_BTN7 = KC_MS_BTN5, - KC_MS_BTN8 = KC_MS_BTN5, -#else - KC_MS_BTN6, - KC_MS_BTN7, - KC_MS_BTN8, -#endif - - /* Mouse Wheel */ - KC_MS_WH_UP, - KC_MS_WH_DOWN, - KC_MS_WH_LEFT, - KC_MS_WH_RIGHT, - - /* Acceleration */ - KC_MS_ACCEL0, - KC_MS_ACCEL1, - KC_MS_ACCEL2 // 0xDF, or 0xFF if via enabled -}; +// TODO: dd keycodes +#include "keycodes.h" diff --git a/quantum/keycodes.h b/quantum/keycodes.h new file mode 100644 index 0000000000..6772bb6a4a --- /dev/null +++ b/quantum/keycodes.h @@ -0,0 +1,1115 @@ +// Copyright 2022 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +/******************************************************************************* + 88888888888 888 d8b .d888 d8b 888 d8b + 888 888 Y8P d88P" Y8P 888 Y8P + 888 888 888 888 + 888 88888b. 888 .d8888b 888888 888 888 .d88b. 888 .d8888b + 888 888 "88b 888 88K 888 888 888 d8P Y8b 888 88K + 888 888 888 888 "Y8888b. 888 888 888 88888888 888 "Y8888b. + 888 888 888 888 X88 888 888 888 Y8b. 888 X88 + 888 888 888 888 88888P' 888 888 888 "Y8888 888 88888P' + 888 888 + 888 888 + 888 888 + .d88b. .d88b. 88888b. .d88b. 888d888 8888b. 888888 .d88b. .d88888 + d88P"88b d8P Y8b 888 "88b d8P Y8b 888P" "88b 888 d8P Y8b d88" 888 + 888 888 88888888 888 888 88888888 888 .d888888 888 88888888 888 888 + Y88b 888 Y8b. 888 888 Y8b. 888 888 888 Y88b. Y8b. Y88b 888 + "Y88888 "Y8888 888 888 "Y8888 888 "Y888888 "Y888 "Y8888 "Y88888 + 888 + Y8b d88P + "Y88P" +*******************************************************************************/ + +#pragma once +// clang-format off + +enum qk_keycode_ranges { +// Ranges + QK_BASIC = 0x0000, + QK_BASIC_MAX = 0x00FF, + QK_MODS = 0x0100, + QK_MODS_MAX = 0x1FFF, + QK_MOD_TAP = 0x2000, + QK_MOD_TAP_MAX = 0x3FFF, + QK_LAYER_TAP = 0x4000, + QK_LAYER_TAP_MAX = 0x4FFF, + QK_LAYER_MOD = 0x5000, + QK_LAYER_MOD_MAX = 0x51FF, + QK_TO = 0x5200, + QK_TO_MAX = 0x521F, + QK_MOMENTARY = 0x5220, + QK_MOMENTARY_MAX = 0x523F, + QK_DEF_LAYER = 0x5240, + QK_DEF_LAYER_MAX = 0x525F, + QK_TOGGLE_LAYER = 0x5260, + QK_TOGGLE_LAYER_MAX = 0x527F, + QK_ONE_SHOT_LAYER = 0x5280, + QK_ONE_SHOT_LAYER_MAX = 0x529F, + QK_ONE_SHOT_MOD = 0x52A0, + QK_ONE_SHOT_MOD_MAX = 0x52BF, + QK_LAYER_TAP_TOGGLE = 0x52C0, + QK_LAYER_TAP_TOGGLE_MAX = 0x52DF, + QK_SWAP_HANDS = 0x5600, + QK_SWAP_HANDS_MAX = 0x56FF, + QK_TAP_DANCE = 0x5700, + QK_TAP_DANCE_MAX = 0x57FF, + QK_MAGIC = 0x7000, + QK_MAGIC_MAX = 0x70FF, + QK_MIDI = 0x7100, + QK_MIDI_MAX = 0x71FF, + QK_SEQUENCER = 0x7200, + QK_SEQUENCER_MAX = 0x73FF, + QK_JOYSTICK = 0x7400, + QK_JOYSTICK_MAX = 0x743F, + QK_PROGRAMMABLE_BUTTON = 0x7440, + QK_PROGRAMMABLE_BUTTON_MAX = 0x747F, + QK_AUDIO = 0x7480, + QK_AUDIO_MAX = 0x74BF, + QK_STENO = 0x74C0, + QK_STENO_MAX = 0x74FF, + QK_MACRO = 0x7700, + QK_MACRO_MAX = 0x777F, + QK_LIGHTING = 0x7800, + QK_LIGHTING_MAX = 0x78FF, + QK_QUANTUM = 0x7C00, + QK_QUANTUM_MAX = 0x7DFF, + QK_KB = 0x7E00, + QK_KB_MAX = 0x7EFF, + QK_USER = 0x7F00, + QK_USER_MAX = 0x7FFF, + QK_UNICODE = 0x8000, + QK_UNICODE_MAX = 0xFFFF, +}; + +enum qk_keycode_defines { +// Keycodes + KC_NO = 0x0000, + KC_TRANSPARENT = 0x0001, + KC_A = 0x0004, + KC_B = 0x0005, + KC_C = 0x0006, + KC_D = 0x0007, + KC_E = 0x0008, + KC_F = 0x0009, + KC_G = 0x000A, + KC_H = 0x000B, + KC_I = 0x000C, + KC_J = 0x000D, + KC_K = 0x000E, + KC_L = 0x000F, + KC_M = 0x0010, + KC_N = 0x0011, + KC_O = 0x0012, + KC_P = 0x0013, + KC_Q = 0x0014, + KC_R = 0x0015, + KC_S = 0x0016, + KC_T = 0x0017, + KC_U = 0x0018, + KC_V = 0x0019, + KC_W = 0x001A, + KC_X = 0x001B, + KC_Y = 0x001C, + KC_Z = 0x001D, + KC_1 = 0x001E, + KC_2 = 0x001F, + KC_3 = 0x0020, + KC_4 = 0x0021, + KC_5 = 0x0022, + KC_6 = 0x0023, + KC_7 = 0x0024, + KC_8 = 0x0025, + KC_9 = 0x0026, + KC_0 = 0x0027, + KC_ENTER = 0x0028, + KC_ESCAPE = 0x0029, + KC_BACKSPACE = 0x002A, + KC_TAB = 0x002B, + KC_SPACE = 0x002C, + KC_MINUS = 0x002D, + KC_EQUAL = 0x002E, + KC_LEFT_BRACKET = 0x002F, + KC_RIGHT_BRACKET = 0x0030, + KC_BACKSLASH = 0x0031, + KC_NONUS_HASH = 0x0032, + KC_SEMICOLON = 0x0033, + KC_QUOTE = 0x0034, + KC_GRAVE = 0x0035, + KC_COMMA = 0x0036, + KC_DOT = 0x0037, + KC_SLASH = 0x0038, + KC_CAPS_LOCK = 0x0039, + KC_F1 = 0x003A, + KC_F2 = 0x003B, + KC_F3 = 0x003C, + KC_F4 = 0x003D, + KC_F5 = 0x003E, + KC_F6 = 0x003F, + KC_F7 = 0x0040, + KC_F8 = 0x0041, + KC_F9 = 0x0042, + KC_F10 = 0x0043, + KC_F11 = 0x0044, + KC_F12 = 0x0045, + KC_PRINT_SCREEN = 0x0046, + KC_SCROLL_LOCK = 0x0047, + KC_PAUSE = 0x0048, + KC_INSERT = 0x0049, + KC_HOME = 0x004A, + KC_PAGE_UP = 0x004B, + KC_DELETE = 0x004C, + KC_END = 0x004D, + KC_PAGE_DOWN = 0x004E, + KC_RIGHT = 0x004F, + KC_LEFT = 0x0050, + KC_DOWN = 0x0051, + KC_UP = 0x0052, + KC_NUM_LOCK = 0x0053, + KC_KP_SLASH = 0x0054, + KC_KP_ASTERISK = 0x0055, + KC_KP_MINUS = 0x0056, + KC_KP_PLUS = 0x0057, + KC_KP_ENTER = 0x0058, + KC_KP_1 = 0x0059, + KC_KP_2 = 0x005A, + KC_KP_3 = 0x005B, + KC_KP_4 = 0x005C, + KC_KP_5 = 0x005D, + KC_KP_6 = 0x005E, + KC_KP_7 = 0x005F, + KC_KP_8 = 0x0060, + KC_KP_9 = 0x0061, + KC_KP_0 = 0x0062, + KC_KP_DOT = 0x0063, + KC_NONUS_BACKSLASH = 0x0064, + KC_APPLICATION = 0x0065, + KC_KB_POWER = 0x0066, + KC_KP_EQUAL = 0x0067, + KC_F13 = 0x0068, + KC_F14 = 0x0069, + KC_F15 = 0x006A, + KC_F16 = 0x006B, + KC_F17 = 0x006C, + KC_F18 = 0x006D, + KC_F19 = 0x006E, + KC_F20 = 0x006F, + KC_F21 = 0x0070, + KC_F22 = 0x0071, + KC_F23 = 0x0072, + KC_F24 = 0x0073, + KC_EXECUTE = 0x0074, + KC_HELP = 0x0075, + KC_MENU = 0x0076, + KC_SELECT = 0x0077, + KC_STOP = 0x0078, + KC_AGAIN = 0x0079, + KC_UNDO = 0x007A, + KC_CUT = 0x007B, + KC_COPY = 0x007C, + KC_PASTE = 0x007D, + KC_FIND = 0x007E, + KC_KB_MUTE = 0x007F, + KC_KB_VOLUME_UP = 0x0080, + KC_KB_VOLUME_DOWN = 0x0081, + KC_LOCKING_CAPS_LOCK = 0x0082, + KC_LOCKING_NUM_LOCK = 0x0083, + KC_LOCKING_SCROLL_LOCK = 0x0084, + KC_KP_COMMA = 0x0085, + KC_KP_EQUAL_AS400 = 0x0086, + KC_INTERNATIONAL_1 = 0x0087, + KC_INTERNATIONAL_2 = 0x0088, + KC_INTERNATIONAL_3 = 0x0089, + KC_INTERNATIONAL_4 = 0x008A, + KC_INTERNATIONAL_5 = 0x008B, + KC_INTERNATIONAL_6 = 0x008C, + KC_INTERNATIONAL_7 = 0x008D, + KC_INTERNATIONAL_8 = 0x008E, + KC_INTERNATIONAL_9 = 0x008F, + KC_LANGUAGE_1 = 0x0090, + KC_LANGUAGE_2 = 0x0091, + KC_LANGUAGE_3 = 0x0092, + KC_LANGUAGE_4 = 0x0093, + KC_LANGUAGE_5 = 0x0094, + KC_LANGUAGE_6 = 0x0095, + KC_LANGUAGE_7 = 0x0096, + KC_LANGUAGE_8 = 0x0097, + KC_LANGUAGE_9 = 0x0098, + KC_ALTERNATE_ERASE = 0x0099, + KC_SYSTEM_REQUEST = 0x009A, + KC_CANCEL = 0x009B, + KC_CLEAR = 0x009C, + KC_PRIOR = 0x009D, + KC_RETURN = 0x009E, + KC_SEPARATOR = 0x009F, + KC_OUT = 0x00A0, + KC_OPER = 0x00A1, + KC_CLEAR_AGAIN = 0x00A2, + KC_CRSEL = 0x00A3, + KC_EXSEL = 0x00A4, + KC_SYSTEM_POWER = 0x00A5, + KC_SYSTEM_SLEEP = 0x00A6, + KC_SYSTEM_WAKE = 0x00A7, + KC_AUDIO_MUTE = 0x00A8, + KC_AUDIO_VOL_UP = 0x00A9, + KC_AUDIO_VOL_DOWN = 0x00AA, + KC_MEDIA_NEXT_TRACK = 0x00AB, + KC_MEDIA_PREV_TRACK = 0x00AC, + KC_MEDIA_STOP = 0x00AD, + KC_MEDIA_PLAY_PAUSE = 0x00AE, + KC_MEDIA_SELECT = 0x00AF, + KC_MEDIA_EJECT = 0x00B0, + KC_MAIL = 0x00B1, + KC_CALCULATOR = 0x00B2, + KC_MY_COMPUTER = 0x00B3, + KC_WWW_SEARCH = 0x00B4, + KC_WWW_HOME = 0x00B5, + KC_WWW_BACK = 0x00B6, + KC_WWW_FORWARD = 0x00B7, + KC_WWW_STOP = 0x00B8, + KC_WWW_REFRESH = 0x00B9, + KC_WWW_FAVORITES = 0x00BA, + KC_MEDIA_FAST_FORWARD = 0x00BB, + KC_MEDIA_REWIND = 0x00BC, + KC_BRIGHTNESS_UP = 0x00BD, + KC_BRIGHTNESS_DOWN = 0x00BE, + KC_CONTROL_PANEL = 0x00BF, + KC_ASSISTANT = 0x00C0, + KC_MS_UP = 0x00CD, + KC_MS_DOWN = 0x00CE, + KC_MS_LEFT = 0x00CF, + KC_MS_RIGHT = 0x00D0, + KC_MS_BTN1 = 0x00D1, + KC_MS_BTN2 = 0x00D2, + KC_MS_BTN3 = 0x00D3, + KC_MS_BTN4 = 0x00D4, + KC_MS_BTN5 = 0x00D5, + KC_MS_BTN6 = 0x00D6, + KC_MS_BTN7 = 0x00D7, + KC_MS_BTN8 = 0x00D8, + KC_MS_WH_UP = 0x00D9, + KC_MS_WH_DOWN = 0x00DA, + KC_MS_WH_LEFT = 0x00DB, + KC_MS_WH_RIGHT = 0x00DC, + KC_MS_ACCEL0 = 0x00DD, + KC_MS_ACCEL1 = 0x00DE, + KC_MS_ACCEL2 = 0x00DF, + KC_LEFT_CTRL = 0x00E0, + KC_LEFT_SHIFT = 0x00E1, + KC_LEFT_ALT = 0x00E2, + KC_LEFT_GUI = 0x00E3, + KC_RIGHT_CTRL = 0x00E4, + KC_RIGHT_SHIFT = 0x00E5, + KC_RIGHT_ALT = 0x00E6, + KC_RIGHT_GUI = 0x00E7, + SH_TG = 0x56F0, + SH_TT = 0x56F1, + SH_MON = 0x56F2, + SH_MOFF = 0x56F3, + SH_OFF = 0x56F4, + SH_ON = 0x56F5, + SH_OS = 0x56F6, + MAGIC_SWAP_CONTROL_CAPSLOCK = 0x7000, + MAGIC_UNSWAP_CONTROL_CAPSLOCK = 0x7001, + MAGIC_TOGGLE_CONTROL_CAPSLOCK = 0x7002, + MAGIC_UNCAPSLOCK_TO_CONTROL = 0x7003, + MAGIC_CAPSLOCK_TO_CONTROL = 0x7004, + MAGIC_SWAP_LALT_LGUI = 0x7005, + MAGIC_UNSWAP_LALT_LGUI = 0x7006, + MAGIC_SWAP_RALT_RGUI = 0x7007, + MAGIC_UNSWAP_RALT_RGUI = 0x7008, + MAGIC_UNNO_GUI = 0x7009, + MAGIC_NO_GUI = 0x700A, + MAGIC_TOGGLE_GUI = 0x700B, + MAGIC_SWAP_GRAVE_ESC = 0x700C, + MAGIC_UNSWAP_GRAVE_ESC = 0x700D, + MAGIC_SWAP_BACKSLASH_BACKSPACE = 0x700E, + MAGIC_UNSWAP_BACKSLASH_BACKSPACE = 0x700F, + MAGIC_TOGGLE_BACKSLASH_BACKSPACE = 0x7010, + MAGIC_HOST_NKRO = 0x7011, + MAGIC_UNHOST_NKRO = 0x7012, + MAGIC_TOGGLE_NKRO = 0x7013, + MAGIC_SWAP_ALT_GUI = 0x7014, + MAGIC_UNSWAP_ALT_GUI = 0x7015, + MAGIC_TOGGLE_ALT_GUI = 0x7016, + MAGIC_SWAP_LCTL_LGUI = 0x7017, + MAGIC_UNSWAP_LCTL_LGUI = 0x7018, + MAGIC_SWAP_RCTL_RGUI = 0x7019, + MAGIC_UNSWAP_RCTL_RGUI = 0x701A, + MAGIC_SWAP_CTL_GUI = 0x701B, + MAGIC_UNSWAP_CTL_GUI = 0x701C, + MAGIC_TOGGLE_CTL_GUI = 0x701D, + MAGIC_EE_HANDS_LEFT = 0x701E, + MAGIC_EE_HANDS_RIGHT = 0x701F, + MAGIC_SWAP_ESCAPE_CAPSLOCK = 0x7020, + MAGIC_UNSWAP_ESCAPE_CAPSLOCK = 0x7021, + MAGIC_TOGGLE_ESCAPE_CAPSLOCK = 0x7022, + MI_ON = 0x7100, + MI_OFF = 0x7101, + MI_TOG = 0x7102, + MI_C = 0x7110, + MI_Cs = 0x7111, + MI_D = 0x7112, + MI_Ds = 0x7113, + MI_E = 0x7114, + MI_F = 0x7115, + MI_Fs = 0x7116, + MI_G = 0x7117, + MI_Gs = 0x7118, + MI_A = 0x7119, + MI_As = 0x711A, + MI_B = 0x711B, + MI_C_1 = 0x7120, + MI_Cs_1 = 0x7121, + MI_D_1 = 0x7122, + MI_Ds_1 = 0x7123, + MI_E_1 = 0x7124, + MI_F_1 = 0x7125, + MI_Fs_1 = 0x7126, + MI_G_1 = 0x7127, + MI_Gs_1 = 0x7128, + MI_A_1 = 0x7129, + MI_As_1 = 0x712A, + MI_B_1 = 0x712B, + MI_C_2 = 0x7130, + MI_Cs_2 = 0x7131, + MI_D_2 = 0x7132, + MI_Ds_2 = 0x7133, + MI_E_2 = 0x7134, + MI_F_2 = 0x7135, + MI_Fs_2 = 0x7136, + MI_G_2 = 0x7137, + MI_Gs_2 = 0x7138, + MI_A_2 = 0x7139, + MI_As_2 = 0x713A, + MI_B_2 = 0x713B, + MI_C_3 = 0x7140, + MI_Cs_3 = 0x7141, + MI_D_3 = 0x7142, + MI_Ds_3 = 0x7143, + MI_E_3 = 0x7144, + MI_F_3 = 0x7145, + MI_Fs_3 = 0x7146, + MI_G_3 = 0x7147, + MI_Gs_3 = 0x7148, + MI_A_3 = 0x7149, + MI_As_3 = 0x714A, + MI_B_3 = 0x714B, + MI_C_4 = 0x7150, + MI_Cs_4 = 0x7151, + MI_D_4 = 0x7152, + MI_Ds_4 = 0x7153, + MI_E_4 = 0x7154, + MI_F_4 = 0x7155, + MI_Fs_4 = 0x7156, + MI_G_4 = 0x7157, + MI_Gs_4 = 0x7158, + MI_A_4 = 0x7159, + MI_As_4 = 0x715A, + MI_B_4 = 0x715B, + MI_C_5 = 0x7160, + MI_Cs_5 = 0x7161, + MI_D_5 = 0x7162, + MI_Ds_5 = 0x7163, + MI_E_5 = 0x7164, + MI_F_5 = 0x7165, + MI_Fs_5 = 0x7166, + MI_G_5 = 0x7167, + MI_Gs_5 = 0x7168, + MI_A_5 = 0x7169, + MI_As_5 = 0x716A, + MI_B_5 = 0x716B, + MI_OCT_N2 = 0x7170, + MI_OCT_N1 = 0x7171, + MI_OCT_0 = 0x7172, + MI_OCT_1 = 0x7173, + MI_OCT_2 = 0x7174, + MI_OCT_3 = 0x7175, + MI_OCT_4 = 0x7176, + MI_OCT_5 = 0x7177, + MI_OCT_6 = 0x7178, + MI_OCT_7 = 0x7179, + MI_OCTD = 0x717A, + MI_OCTU = 0x717B, + MI_TRNS_N6 = 0x7180, + MI_TRNS_N5 = 0x7181, + MI_TRNS_N4 = 0x7182, + MI_TRNS_N3 = 0x7183, + MI_TRNS_N2 = 0x7184, + MI_TRNS_N1 = 0x7185, + MI_TRNS_0 = 0x7186, + MI_TRNS_1 = 0x7187, + MI_TRNS_2 = 0x7188, + MI_TRNS_3 = 0x7189, + MI_TRNS_4 = 0x718A, + MI_TRNS_5 = 0x718B, + MI_TRNS_6 = 0x718C, + MI_TRNSD = 0x718D, + MI_TRNSU = 0x718E, + MI_VEL_0 = 0x7190, + MI_VEL_1 = 0x7191, + MI_VEL_2 = 0x7192, + MI_VEL_3 = 0x7193, + MI_VEL_4 = 0x7194, + MI_VEL_5 = 0x7195, + MI_VEL_6 = 0x7196, + MI_VEL_7 = 0x7197, + MI_VEL_8 = 0x7198, + MI_VEL_9 = 0x7199, + MI_VEL_10 = 0x719A, + MI_VELD = 0x719B, + MI_VELU = 0x719C, + MI_CH1 = 0x71A0, + MI_CH2 = 0x71A1, + MI_CH3 = 0x71A2, + MI_CH4 = 0x71A3, + MI_CH5 = 0x71A4, + MI_CH6 = 0x71A5, + MI_CH7 = 0x71A6, + MI_CH8 = 0x71A7, + MI_CH9 = 0x71A8, + MI_CH10 = 0x71A9, + MI_CH11 = 0x71AA, + MI_CH12 = 0x71AB, + MI_CH13 = 0x71AC, + MI_CH14 = 0x71AD, + MI_CH15 = 0x71AE, + MI_CH16 = 0x71AF, + MI_CHD = 0x71B0, + MI_CHU = 0x71B1, + MI_ALLOFF = 0x71C0, + MI_SUS = 0x71C1, + MI_PORT = 0x71C2, + MI_SOST = 0x71C3, + MI_SOFT = 0x71C4, + MI_LEG = 0x71C5, + MI_MOD = 0x71C6, + MI_MODSD = 0x71C7, + MI_MODSU = 0x71C8, + MI_BENDD = 0x71C9, + MI_BENDU = 0x71CA, + SQ_ON = 0x7200, + SQ_OFF = 0x7201, + SQ_TOG = 0x7202, + SQ_TMPD = 0x7203, + SQ_TMPU = 0x7204, + SQ_RESD = 0x7205, + SQ_RESU = 0x7206, + SQ_SALL = 0x7207, + SQ_SCLR = 0x7208, + QK_JOYSTICK_BUTTON_0 = 0x7400, + QK_JOYSTICK_BUTTON_1 = 0x7401, + QK_JOYSTICK_BUTTON_2 = 0x7402, + QK_JOYSTICK_BUTTON_3 = 0x7403, + QK_JOYSTICK_BUTTON_4 = 0x7404, + QK_JOYSTICK_BUTTON_5 = 0x7405, + QK_JOYSTICK_BUTTON_6 = 0x7406, + QK_JOYSTICK_BUTTON_7 = 0x7407, + QK_JOYSTICK_BUTTON_8 = 0x7408, + QK_JOYSTICK_BUTTON_9 = 0x7409, + QK_JOYSTICK_BUTTON_10 = 0x740A, + QK_JOYSTICK_BUTTON_11 = 0x740B, + QK_JOYSTICK_BUTTON_12 = 0x740C, + QK_JOYSTICK_BUTTON_13 = 0x740D, + QK_JOYSTICK_BUTTON_14 = 0x740E, + QK_JOYSTICK_BUTTON_15 = 0x740F, + QK_JOYSTICK_BUTTON_16 = 0x7410, + QK_JOYSTICK_BUTTON_17 = 0x7411, + QK_JOYSTICK_BUTTON_18 = 0x7412, + QK_JOYSTICK_BUTTON_19 = 0x7413, + QK_JOYSTICK_BUTTON_20 = 0x7414, + QK_JOYSTICK_BUTTON_21 = 0x7415, + QK_JOYSTICK_BUTTON_22 = 0x7416, + QK_JOYSTICK_BUTTON_23 = 0x7417, + QK_JOYSTICK_BUTTON_24 = 0x7418, + QK_JOYSTICK_BUTTON_25 = 0x7419, + QK_JOYSTICK_BUTTON_26 = 0x741A, + QK_JOYSTICK_BUTTON_27 = 0x741B, + QK_JOYSTICK_BUTTON_28 = 0x741C, + QK_JOYSTICK_BUTTON_29 = 0x741D, + QK_JOYSTICK_BUTTON_30 = 0x741E, + QK_JOYSTICK_BUTTON_31 = 0x741F, + QK_PROGRAMMABLE_BUTTON_1 = 0x7440, + QK_PROGRAMMABLE_BUTTON_2 = 0x7441, + QK_PROGRAMMABLE_BUTTON_3 = 0x7442, + QK_PROGRAMMABLE_BUTTON_4 = 0x7443, + QK_PROGRAMMABLE_BUTTON_5 = 0x7444, + QK_PROGRAMMABLE_BUTTON_6 = 0x7445, + QK_PROGRAMMABLE_BUTTON_7 = 0x7446, + QK_PROGRAMMABLE_BUTTON_8 = 0x7447, + QK_PROGRAMMABLE_BUTTON_9 = 0x7448, + QK_PROGRAMMABLE_BUTTON_10 = 0x7449, + QK_PROGRAMMABLE_BUTTON_11 = 0x744A, + QK_PROGRAMMABLE_BUTTON_12 = 0x744B, + QK_PROGRAMMABLE_BUTTON_13 = 0x744C, + QK_PROGRAMMABLE_BUTTON_14 = 0x744D, + QK_PROGRAMMABLE_BUTTON_15 = 0x744E, + QK_PROGRAMMABLE_BUTTON_16 = 0x744F, + QK_PROGRAMMABLE_BUTTON_17 = 0x7450, + QK_PROGRAMMABLE_BUTTON_18 = 0x7451, + QK_PROGRAMMABLE_BUTTON_19 = 0x7452, + QK_PROGRAMMABLE_BUTTON_20 = 0x7453, + QK_PROGRAMMABLE_BUTTON_21 = 0x7454, + QK_PROGRAMMABLE_BUTTON_22 = 0x7455, + QK_PROGRAMMABLE_BUTTON_23 = 0x7456, + QK_PROGRAMMABLE_BUTTON_24 = 0x7457, + QK_PROGRAMMABLE_BUTTON_25 = 0x7458, + QK_PROGRAMMABLE_BUTTON_26 = 0x7459, + QK_PROGRAMMABLE_BUTTON_27 = 0x745A, + QK_PROGRAMMABLE_BUTTON_28 = 0x745B, + QK_PROGRAMMABLE_BUTTON_29 = 0x745C, + QK_PROGRAMMABLE_BUTTON_30 = 0x745D, + QK_PROGRAMMABLE_BUTTON_31 = 0x745E, + QK_PROGRAMMABLE_BUTTON_32 = 0x745F, + AU_ON = 0x7480, + AU_OFF = 0x7481, + AU_TOG = 0x7482, + CLICKY_TOGGLE = 0x748A, + CLICKY_ENABLE = 0x748B, + CLICKY_DISABLE = 0x748C, + CLICKY_UP = 0x748D, + CLICKY_DOWN = 0x748E, + CLICKY_RESET = 0x748F, + MU_ON = 0x7490, + MU_OFF = 0x7491, + MU_TOG = 0x7492, + MU_MOD = 0x7493, + MUV_IN = 0x7494, + MUV_DE = 0x7495, + QK_STENO_BOLT = 0x74F0, + QK_STENO_GEMINI = 0x74F1, + QK_STENO_COMB = 0x74F2, + QK_STENO_COMB_MAX = 0x74FC, + MACRO_0 = 0x7700, + MACRO_1 = 0x7701, + MACRO_2 = 0x7702, + MACRO_3 = 0x7703, + MACRO_4 = 0x7704, + MACRO_5 = 0x7705, + MACRO_6 = 0x7706, + MACRO_7 = 0x7707, + MACRO_8 = 0x7708, + MACRO_9 = 0x7709, + MACRO_10 = 0x770A, + MACRO_11 = 0x770B, + MACRO_12 = 0x770C, + MACRO_13 = 0x770D, + MACRO_14 = 0x770E, + MACRO_15 = 0x770F, + MACRO_16 = 0x7710, + MACRO_17 = 0x7711, + MACRO_18 = 0x7712, + MACRO_19 = 0x7713, + MACRO_20 = 0x7714, + MACRO_21 = 0x7715, + MACRO_22 = 0x7716, + MACRO_23 = 0x7717, + MACRO_24 = 0x7718, + MACRO_25 = 0x7719, + MACRO_26 = 0x771A, + MACRO_27 = 0x771B, + MACRO_28 = 0x771C, + MACRO_29 = 0x771D, + MACRO_30 = 0x771E, + MACRO_31 = 0x771F, + BL_ON = 0x7800, + BL_OFF = 0x7801, + BL_DEC = 0x7802, + BL_INC = 0x7803, + BL_TOGG = 0x7804, + BL_STEP = 0x7805, + BL_BRTG = 0x7806, + RGB_TOG = 0x7820, + RGB_MODE_FORWARD = 0x7821, + RGB_MODE_REVERSE = 0x7822, + RGB_HUI = 0x7823, + RGB_HUD = 0x7824, + RGB_SAI = 0x7825, + RGB_SAD = 0x7826, + RGB_VAI = 0x7827, + RGB_VAD = 0x7828, + RGB_SPI = 0x7829, + RGB_SPD = 0x782A, + RGB_MODE_PLAIN = 0x782B, + RGB_MODE_BREATHE = 0x782C, + RGB_MODE_RAINBOW = 0x782D, + RGB_MODE_SWIRL = 0x782E, + RGB_MODE_SNAKE = 0x782F, + RGB_MODE_KNIGHT = 0x7830, + RGB_MODE_XMAS = 0x7831, + RGB_MODE_GRADIENT = 0x7832, + RGB_MODE_RGBTEST = 0x7833, + RGB_MODE_TWINKLE = 0x7834, + QK_BOOTLOADER = 0x7C00, + QK_REBOOT = 0x7C01, + QK_DEBUG_TOGGLE = 0x7C02, + QK_CLEAR_EEPROM = 0x7C03, + QK_MAKE = 0x7C04, + QK_AUTO_SHIFT_DOWN = 0x7C10, + QK_AUTO_SHIFT_UP = 0x7C11, + QK_AUTO_SHIFT_REPORT = 0x7C12, + QK_AUTO_SHIFT_ON = 0x7C13, + QK_AUTO_SHIFT_OFF = 0x7C14, + QK_AUTO_SHIFT_TOGGLE = 0x7C15, + QK_GRAVE_ESCAPE = 0x7C16, + QK_VELOCIKEY_TOGGLE = 0x7C17, + QK_SPACE_CADET_LEFT_CTRL_PARENTHESIS_OPEN = 0x7C18, + QK_SPACE_CADET_RIGHT_CTRL_PARENTHESIS_CLOSE = 0x7C19, + QK_SPACE_CADET_LEFT_SHIFT_PARENTHESIS_OPEN = 0x7C1A, + QK_SPACE_CADET_RIGHT_SHIFT_PARENTHESIS_CLOSE = 0x7C1B, + QK_SPACE_CADET_LEFT_ALT_PARENTHESIS_OPEN = 0x7C1C, + QK_SPACE_CADET_RIGHT_ALT_PARENTHESIS_CLOSE = 0x7C1D, + QK_SPACE_CADET_RIGHT_SHIFT_ENTER = 0x7C1E, + OUT_AUTO = 0x7C20, + OUT_USB = 0x7C21, + OUT_BT = 0x7C22, + QK_UNICODE_MODE_NEXT = 0x7C30, + QK_UNICODE_MODE_PREVIOUS = 0x7C31, + QK_UNICODE_MODE_MACOS = 0x7C32, + QK_UNICODE_MODE_LINUX = 0x7C33, + QK_UNICODE_MODE_WINDOWS = 0x7C34, + QK_UNICODE_MODE_BSD = 0x7C35, + QK_UNICODE_MODE_WINCOMPOSE = 0x7C36, + QK_UNICODE_MODE_EMACS = 0x7C37, + HPT_ON = 0x7C40, + HPT_OFF = 0x7C41, + HPT_TOG = 0x7C42, + HPT_RST = 0x7C43, + HPT_FBK = 0x7C44, + HPT_BUZ = 0x7C45, + HPT_MODI = 0x7C46, + HPT_MODD = 0x7C47, + HPT_CONT = 0x7C48, + HPT_CONI = 0x7C49, + HPT_COND = 0x7C4A, + HPT_DWLI = 0x7C4B, + HPT_DWLD = 0x7C4C, + QK_COMBO_ON = 0x7C50, + QK_COMBO_OFF = 0x7C51, + QK_COMBO_TOGGLE = 0x7C52, + QK_DYNAMIC_MACRO_RECORD_START_1 = 0x7C53, + QK_DYNAMIC_MACRO_RECORD_START_2 = 0x7C54, + QK_DYNAMIC_MACRO_RECORD_STOP = 0x7C55, + QK_DYNAMIC_MACRO_PLAY_1 = 0x7C56, + QK_DYNAMIC_MACRO_PLAY_2 = 0x7C57, + QK_LEADER = 0x7C58, + QK_LOCK = 0x7C59, + QK_ONE_SHOT_ON = 0x7C5A, + QK_ONE_SHOT_OFF = 0x7C5B, + QK_ONE_SHOT_TOGGLE = 0x7C5C, + QK_KEY_OVERRIDE_TOGGLE = 0x7C5D, + QK_KEY_OVERRIDE_ON = 0x7C5E, + QK_KEY_OVERRIDE_OFF = 0x7C5F, + QK_SECURE_LOCK = 0x7C60, + QK_SECURE_UNLOCK = 0x7C61, + QK_SECURE_TOGGLE = 0x7C62, + QK_SECURE_REQUEST = 0x7C63, + DT_PRNT = 0x7C70, + DT_UP = 0x7C71, + DT_DOWN = 0x7C72, + PRINT_ON = 0x7C73, + PRINT_OFF = 0x7C74, + QK_CAPS_WORD_TOGGLE = 0x7C75, + QK_AUTOCORRECT_ON = 0x7C76, + QK_AUTOCORRECT_OFF = 0x7C77, + QK_AUTOCORRECT_TOGGLE = 0x7C78, + SAFE_RANGE = 0x7E00, + +// Alias + XXXXXXX = KC_NO, + _______ = KC_TRANSPARENT, + KC_TRNS = KC_TRANSPARENT, + KC_ENT = KC_ENTER, + KC_ESC = KC_ESCAPE, + KC_BSPC = KC_BACKSPACE, + KC_SPC = KC_SPACE, + KC_MINS = KC_MINUS, + KC_EQL = KC_EQUAL, + KC_LBRC = KC_LEFT_BRACKET, + KC_RBRC = KC_RIGHT_BRACKET, + KC_BSLS = KC_BACKSLASH, + KC_NUHS = KC_NONUS_HASH, + KC_SCLN = KC_SEMICOLON, + KC_QUOT = KC_QUOTE, + KC_GRV = KC_GRAVE, + KC_COMM = KC_COMMA, + KC_SLSH = KC_SLASH, + KC_CAPS = KC_CAPS_LOCK, + KC_PSCR = KC_PRINT_SCREEN, + KC_SCRL = KC_SCROLL_LOCK, + KC_BRMD = KC_SCROLL_LOCK, + KC_PAUS = KC_PAUSE, + KC_BRK = KC_PAUSE, + KC_BRMU = KC_PAUSE, + KC_INS = KC_INSERT, + KC_PGUP = KC_PAGE_UP, + KC_DEL = KC_DELETE, + KC_PGDN = KC_PAGE_DOWN, + KC_RGHT = KC_RIGHT, + KC_NUM = KC_NUM_LOCK, + KC_PSLS = KC_KP_SLASH, + KC_PAST = KC_KP_ASTERISK, + KC_PMNS = KC_KP_MINUS, + KC_PPLS = KC_KP_PLUS, + KC_PENT = KC_KP_ENTER, + KC_P1 = KC_KP_1, + KC_P2 = KC_KP_2, + KC_P3 = KC_KP_3, + KC_P4 = KC_KP_4, + KC_P5 = KC_KP_5, + KC_P6 = KC_KP_6, + KC_P7 = KC_KP_7, + KC_P8 = KC_KP_8, + KC_P9 = KC_KP_9, + KC_P0 = KC_KP_0, + KC_PDOT = KC_KP_DOT, + KC_NUBS = KC_NONUS_BACKSLASH, + KC_APP = KC_APPLICATION, + KC_PEQL = KC_KP_EQUAL, + KC_EXEC = KC_EXECUTE, + KC_SLCT = KC_SELECT, + KC_AGIN = KC_AGAIN, + KC_PSTE = KC_PASTE, + KC_LCAP = KC_LOCKING_CAPS_LOCK, + KC_LNUM = KC_LOCKING_NUM_LOCK, + KC_LSCR = KC_LOCKING_SCROLL_LOCK, + KC_PCMM = KC_KP_COMMA, + KC_INT1 = KC_INTERNATIONAL_1, + KC_INT2 = KC_INTERNATIONAL_2, + KC_INT3 = KC_INTERNATIONAL_3, + KC_INT4 = KC_INTERNATIONAL_4, + KC_INT5 = KC_INTERNATIONAL_5, + KC_INT6 = KC_INTERNATIONAL_6, + KC_INT7 = KC_INTERNATIONAL_7, + KC_INT8 = KC_INTERNATIONAL_8, + KC_INT9 = KC_INTERNATIONAL_9, + KC_LNG1 = KC_LANGUAGE_1, + KC_LNG2 = KC_LANGUAGE_2, + KC_LNG3 = KC_LANGUAGE_3, + KC_LNG4 = KC_LANGUAGE_4, + KC_LNG5 = KC_LANGUAGE_5, + KC_LNG6 = KC_LANGUAGE_6, + KC_LNG7 = KC_LANGUAGE_7, + KC_LNG8 = KC_LANGUAGE_8, + KC_LNG9 = KC_LANGUAGE_9, + KC_ERAS = KC_ALTERNATE_ERASE, + KC_SYRQ = KC_SYSTEM_REQUEST, + KC_CNCL = KC_CANCEL, + KC_CLR = KC_CLEAR, + KC_PRIR = KC_PRIOR, + KC_RETN = KC_RETURN, + KC_SEPR = KC_SEPARATOR, + KC_CLAG = KC_CLEAR_AGAIN, + KC_CRSL = KC_CRSEL, + KC_EXSL = KC_EXSEL, + KC_PWR = KC_SYSTEM_POWER, + KC_SLEP = KC_SYSTEM_SLEEP, + KC_WAKE = KC_SYSTEM_WAKE, + KC_MUTE = KC_AUDIO_MUTE, + KC_VOLU = KC_AUDIO_VOL_UP, + KC_VOLD = KC_AUDIO_VOL_DOWN, + KC_MNXT = KC_MEDIA_NEXT_TRACK, + KC_MPRV = KC_MEDIA_PREV_TRACK, + KC_MSTP = KC_MEDIA_STOP, + KC_MPLY = KC_MEDIA_PLAY_PAUSE, + KC_MSEL = KC_MEDIA_SELECT, + KC_EJCT = KC_MEDIA_EJECT, + KC_CALC = KC_CALCULATOR, + KC_MYCM = KC_MY_COMPUTER, + KC_WSCH = KC_WWW_SEARCH, + KC_WHOM = KC_WWW_HOME, + KC_WBAK = KC_WWW_BACK, + KC_WFWD = KC_WWW_FORWARD, + KC_WSTP = KC_WWW_STOP, + KC_WREF = KC_WWW_REFRESH, + KC_WFAV = KC_WWW_FAVORITES, + KC_MFFD = KC_MEDIA_FAST_FORWARD, + KC_MRWD = KC_MEDIA_REWIND, + KC_BRIU = KC_BRIGHTNESS_UP, + KC_BRID = KC_BRIGHTNESS_DOWN, + KC_CPNL = KC_CONTROL_PANEL, + KC_ASST = KC_ASSISTANT, + KC_MS_U = KC_MS_UP, + KC_MS_D = KC_MS_DOWN, + KC_MS_L = KC_MS_LEFT, + KC_MS_R = KC_MS_RIGHT, + KC_BTN1 = KC_MS_BTN1, + KC_BTN2 = KC_MS_BTN2, + KC_BTN3 = KC_MS_BTN3, + KC_BTN4 = KC_MS_BTN4, + KC_BTN5 = KC_MS_BTN5, + KC_BTN6 = KC_MS_BTN6, + KC_BTN7 = KC_MS_BTN7, + KC_BTN8 = KC_MS_BTN8, + KC_WH_U = KC_MS_WH_UP, + KC_WH_D = KC_MS_WH_DOWN, + KC_WH_L = KC_MS_WH_LEFT, + KC_WH_R = KC_MS_WH_RIGHT, + KC_ACL0 = KC_MS_ACCEL0, + KC_ACL1 = KC_MS_ACCEL1, + KC_ACL2 = KC_MS_ACCEL2, + KC_LCTL = KC_LEFT_CTRL, + KC_LSFT = KC_LEFT_SHIFT, + KC_LALT = KC_LEFT_ALT, + KC_LOPT = KC_LEFT_ALT, + KC_LGUI = KC_LEFT_GUI, + KC_LCMD = KC_LEFT_GUI, + KC_LWIN = KC_LEFT_GUI, + KC_RCTL = KC_RIGHT_CTRL, + KC_RSFT = KC_RIGHT_SHIFT, + KC_RALT = KC_RIGHT_ALT, + KC_ROPT = KC_RIGHT_ALT, + KC_ALGR = KC_RIGHT_ALT, + KC_RGUI = KC_RIGHT_GUI, + KC_RCMD = KC_RIGHT_GUI, + KC_RWIN = KC_RIGHT_GUI, + CL_SWAP = MAGIC_SWAP_CONTROL_CAPSLOCK, + CL_NORM = MAGIC_UNSWAP_CONTROL_CAPSLOCK, + CL_TOGG = MAGIC_TOGGLE_CONTROL_CAPSLOCK, + CL_CAPS = MAGIC_UNCAPSLOCK_TO_CONTROL, + CL_CTRL = MAGIC_CAPSLOCK_TO_CONTROL, + LAG_SWP = MAGIC_SWAP_LALT_LGUI, + LAG_NRM = MAGIC_UNSWAP_LALT_LGUI, + RAG_SWP = MAGIC_SWAP_RALT_RGUI, + RAG_NRM = MAGIC_UNSWAP_RALT_RGUI, + GUI_ON = MAGIC_UNNO_GUI, + GUI_OFF = MAGIC_NO_GUI, + GUI_TOG = MAGIC_TOGGLE_GUI, + GE_SWAP = MAGIC_SWAP_GRAVE_ESC, + GE_NORM = MAGIC_UNSWAP_GRAVE_ESC, + BS_SWAP = MAGIC_SWAP_BACKSLASH_BACKSPACE, + BS_NORM = MAGIC_UNSWAP_BACKSLASH_BACKSPACE, + BS_TOGG = MAGIC_TOGGLE_BACKSLASH_BACKSPACE, + NK_ON = MAGIC_HOST_NKRO, + NK_OFF = MAGIC_UNHOST_NKRO, + NK_TOGG = MAGIC_TOGGLE_NKRO, + AG_SWAP = MAGIC_SWAP_ALT_GUI, + AG_NORM = MAGIC_UNSWAP_ALT_GUI, + AG_TOGG = MAGIC_TOGGLE_ALT_GUI, + LCG_SWP = MAGIC_SWAP_LCTL_LGUI, + LCG_NRM = MAGIC_UNSWAP_LCTL_LGUI, + RCG_SWP = MAGIC_SWAP_RCTL_RGUI, + RCG_NRM = MAGIC_UNSWAP_RCTL_RGUI, + CG_SWAP = MAGIC_SWAP_CTL_GUI, + CG_NORM = MAGIC_UNSWAP_CTL_GUI, + CG_TOGG = MAGIC_TOGGLE_CTL_GUI, + EH_LEFT = MAGIC_EE_HANDS_LEFT, + EH_RGHT = MAGIC_EE_HANDS_RIGHT, + EC_SWAP = MAGIC_SWAP_ESCAPE_CAPSLOCK, + EC_NORM = MAGIC_UNSWAP_ESCAPE_CAPSLOCK, + EC_TOGG = MAGIC_TOGGLE_ESCAPE_CAPSLOCK, + MI_Db = MI_Cs, + MI_Eb = MI_Ds, + MI_Gb = MI_Fs, + MI_Ab = MI_Gs, + MI_Bb = MI_As, + MI_Db_1 = MI_Cs_1, + MI_Eb_1 = MI_Ds_1, + MI_Gb_1 = MI_Fs_1, + MI_Ab_1 = MI_Gs_1, + MI_Bb_1 = MI_As_1, + MI_Db_2 = MI_Cs_2, + MI_Eb_2 = MI_Ds_2, + MI_Gb_2 = MI_Fs_2, + MI_Ab_2 = MI_Gs_2, + MI_Bb_2 = MI_As_2, + MI_Db_3 = MI_Cs_3, + MI_Eb_3 = MI_Ds_3, + MI_Gb_3 = MI_Fs_3, + MI_Ab_3 = MI_Gs_3, + MI_Bb_3 = MI_As_3, + MI_Db_4 = MI_Cs_4, + MI_Eb_4 = MI_Ds_4, + MI_Gb_4 = MI_Fs_4, + MI_Ab_4 = MI_Gs_4, + MI_Bb_4 = MI_As_4, + MI_Db_5 = MI_Cs_5, + MI_Eb_5 = MI_Ds_5, + MI_Gb_5 = MI_Fs_5, + MI_Ab_5 = MI_Gs_5, + MI_Bb_5 = MI_As_5, + JS_0 = QK_JOYSTICK_BUTTON_0, + JS_1 = QK_JOYSTICK_BUTTON_1, + JS_2 = QK_JOYSTICK_BUTTON_2, + JS_3 = QK_JOYSTICK_BUTTON_3, + JS_4 = QK_JOYSTICK_BUTTON_4, + JS_5 = QK_JOYSTICK_BUTTON_5, + JS_6 = QK_JOYSTICK_BUTTON_6, + JS_7 = QK_JOYSTICK_BUTTON_7, + JS_8 = QK_JOYSTICK_BUTTON_8, + JS_9 = QK_JOYSTICK_BUTTON_9, + JS_10 = QK_JOYSTICK_BUTTON_10, + JS_11 = QK_JOYSTICK_BUTTON_11, + JS_12 = QK_JOYSTICK_BUTTON_12, + JS_13 = QK_JOYSTICK_BUTTON_13, + JS_14 = QK_JOYSTICK_BUTTON_14, + JS_15 = QK_JOYSTICK_BUTTON_15, + JS_16 = QK_JOYSTICK_BUTTON_16, + JS_17 = QK_JOYSTICK_BUTTON_17, + JS_18 = QK_JOYSTICK_BUTTON_18, + JS_19 = QK_JOYSTICK_BUTTON_19, + JS_20 = QK_JOYSTICK_BUTTON_20, + JS_21 = QK_JOYSTICK_BUTTON_21, + JS_22 = QK_JOYSTICK_BUTTON_22, + JS_23 = QK_JOYSTICK_BUTTON_23, + JS_24 = QK_JOYSTICK_BUTTON_24, + JS_25 = QK_JOYSTICK_BUTTON_25, + JS_26 = QK_JOYSTICK_BUTTON_26, + JS_27 = QK_JOYSTICK_BUTTON_27, + JS_28 = QK_JOYSTICK_BUTTON_28, + JS_29 = QK_JOYSTICK_BUTTON_29, + JS_30 = QK_JOYSTICK_BUTTON_30, + JS_31 = QK_JOYSTICK_BUTTON_31, + PB_1 = QK_PROGRAMMABLE_BUTTON_1, + PB_2 = QK_PROGRAMMABLE_BUTTON_2, + PB_3 = QK_PROGRAMMABLE_BUTTON_3, + PB_4 = QK_PROGRAMMABLE_BUTTON_4, + PB_5 = QK_PROGRAMMABLE_BUTTON_5, + PB_6 = QK_PROGRAMMABLE_BUTTON_6, + PB_7 = QK_PROGRAMMABLE_BUTTON_7, + PB_8 = QK_PROGRAMMABLE_BUTTON_8, + PB_9 = QK_PROGRAMMABLE_BUTTON_9, + PB_10 = QK_PROGRAMMABLE_BUTTON_10, + PB_11 = QK_PROGRAMMABLE_BUTTON_11, + PB_12 = QK_PROGRAMMABLE_BUTTON_12, + PB_13 = QK_PROGRAMMABLE_BUTTON_13, + PB_14 = QK_PROGRAMMABLE_BUTTON_14, + PB_15 = QK_PROGRAMMABLE_BUTTON_15, + PB_16 = QK_PROGRAMMABLE_BUTTON_16, + PB_17 = QK_PROGRAMMABLE_BUTTON_17, + PB_18 = QK_PROGRAMMABLE_BUTTON_18, + PB_19 = QK_PROGRAMMABLE_BUTTON_19, + PB_20 = QK_PROGRAMMABLE_BUTTON_20, + PB_21 = QK_PROGRAMMABLE_BUTTON_21, + PB_22 = QK_PROGRAMMABLE_BUTTON_22, + PB_23 = QK_PROGRAMMABLE_BUTTON_23, + PB_24 = QK_PROGRAMMABLE_BUTTON_24, + PB_25 = QK_PROGRAMMABLE_BUTTON_25, + PB_26 = QK_PROGRAMMABLE_BUTTON_26, + PB_27 = QK_PROGRAMMABLE_BUTTON_27, + PB_28 = QK_PROGRAMMABLE_BUTTON_28, + PB_29 = QK_PROGRAMMABLE_BUTTON_29, + PB_30 = QK_PROGRAMMABLE_BUTTON_30, + PB_31 = QK_PROGRAMMABLE_BUTTON_31, + PB_32 = QK_PROGRAMMABLE_BUTTON_32, + CK_TOGG = CLICKY_TOGGLE, + CK_ON = CLICKY_ENABLE, + CK_OFF = CLICKY_DISABLE, + CK_UP = CLICKY_UP, + CK_DOWN = CLICKY_DOWN, + CK_RST = CLICKY_RESET, + RGB_MOD = RGB_MODE_FORWARD, + RGB_RMOD = RGB_MODE_REVERSE, + RGB_M_P = RGB_MODE_PLAIN, + RGB_M_B = RGB_MODE_BREATHE, + RGB_M_R = RGB_MODE_RAINBOW, + RGB_M_SW = RGB_MODE_SWIRL, + RGB_M_SN = RGB_MODE_SNAKE, + RGB_M_K = RGB_MODE_KNIGHT, + RGB_M_X = RGB_MODE_XMAS, + RGB_M_G = RGB_MODE_GRADIENT, + RGB_M_T = RGB_MODE_RGBTEST, + RGB_M_TW = RGB_MODE_TWINKLE, + QK_BOOT = QK_BOOTLOADER, + QK_RBT = QK_REBOOT, + DB_TOGG = QK_DEBUG_TOGGLE, + EE_CLR = QK_CLEAR_EEPROM, + AS_DOWN = QK_AUTO_SHIFT_DOWN, + AS_UP = QK_AUTO_SHIFT_UP, + AS_RPT = QK_AUTO_SHIFT_REPORT, + AS_ON = QK_AUTO_SHIFT_ON, + AS_OFF = QK_AUTO_SHIFT_OFF, + AS_TOGG = QK_AUTO_SHIFT_TOGGLE, + QK_GESC = QK_GRAVE_ESCAPE, + VK_TOGG = QK_VELOCIKEY_TOGGLE, + SC_LCPO = QK_SPACE_CADET_LEFT_CTRL_PARENTHESIS_OPEN, + SC_RCPC = QK_SPACE_CADET_RIGHT_CTRL_PARENTHESIS_CLOSE, + SC_LSPO = QK_SPACE_CADET_LEFT_SHIFT_PARENTHESIS_OPEN, + SC_RSPC = QK_SPACE_CADET_RIGHT_SHIFT_PARENTHESIS_CLOSE, + SC_LAPO = QK_SPACE_CADET_LEFT_ALT_PARENTHESIS_OPEN, + SC_RAPC = QK_SPACE_CADET_RIGHT_ALT_PARENTHESIS_CLOSE, + SC_SENT = QK_SPACE_CADET_RIGHT_SHIFT_ENTER, + UC_NEXT = QK_UNICODE_MODE_NEXT, + UC_PREV = QK_UNICODE_MODE_PREVIOUS, + UC_MAC = QK_UNICODE_MODE_MACOS, + UC_LINX = QK_UNICODE_MODE_LINUX, + UC_WIN = QK_UNICODE_MODE_WINDOWS, + UC_BSD = QK_UNICODE_MODE_BSD, + UC_WINC = QK_UNICODE_MODE_WINCOMPOSE, + UC_EMAC = QK_UNICODE_MODE_EMACS, + CM_ON = QK_COMBO_ON, + CM_OFF = QK_COMBO_OFF, + CM_TOGG = QK_COMBO_TOGGLE, + DM_REC1 = QK_DYNAMIC_MACRO_RECORD_START_1, + DM_REC2 = QK_DYNAMIC_MACRO_RECORD_START_2, + DM_RSTP = QK_DYNAMIC_MACRO_RECORD_STOP, + DM_PLY1 = QK_DYNAMIC_MACRO_PLAY_1, + DM_PLY2 = QK_DYNAMIC_MACRO_PLAY_2, + QK_LEAD = QK_LEADER, + OS_ON = QK_ONE_SHOT_ON, + OS_OFF = QK_ONE_SHOT_OFF, + OS_TOGG = QK_ONE_SHOT_TOGGLE, + KO_TOGG = QK_KEY_OVERRIDE_TOGGLE, + KO_ON = QK_KEY_OVERRIDE_ON, + KO_OFF = QK_KEY_OVERRIDE_OFF, + SE_LOCK = QK_SECURE_LOCK, + SE_UNLK = QK_SECURE_UNLOCK, + SE_TOGG = QK_SECURE_TOGGLE, + SE_REQ = QK_SECURE_REQUEST, + CW_TOGG = QK_CAPS_WORD_TOGGLE, + AC_ON = QK_AUTOCORRECT_ON, + AC_OFF = QK_AUTOCORRECT_OFF, + AC_TOGG = QK_AUTOCORRECT_TOGGLE, +}; + +// Range Helpers +#define IS_QK_BASIC(code) ((code) >= QK_BASIC && (code) <= QK_BASIC_MAX) +#define IS_QK_MODS(code) ((code) >= QK_MODS && (code) <= QK_MODS_MAX) +#define IS_QK_MOD_TAP(code) ((code) >= QK_MOD_TAP && (code) <= QK_MOD_TAP_MAX) +#define IS_QK_LAYER_TAP(code) ((code) >= QK_LAYER_TAP && (code) <= QK_LAYER_TAP_MAX) +#define IS_QK_LAYER_MOD(code) ((code) >= QK_LAYER_MOD && (code) <= QK_LAYER_MOD_MAX) +#define IS_QK_TO(code) ((code) >= QK_TO && (code) <= QK_TO_MAX) +#define IS_QK_MOMENTARY(code) ((code) >= QK_MOMENTARY && (code) <= QK_MOMENTARY_MAX) +#define IS_QK_DEF_LAYER(code) ((code) >= QK_DEF_LAYER && (code) <= QK_DEF_LAYER_MAX) +#define IS_QK_TOGGLE_LAYER(code) ((code) >= QK_TOGGLE_LAYER && (code) <= QK_TOGGLE_LAYER_MAX) +#define IS_QK_ONE_SHOT_LAYER(code) ((code) >= QK_ONE_SHOT_LAYER && (code) <= QK_ONE_SHOT_LAYER_MAX) +#define IS_QK_ONE_SHOT_MOD(code) ((code) >= QK_ONE_SHOT_MOD && (code) <= QK_ONE_SHOT_MOD_MAX) +#define IS_QK_LAYER_TAP_TOGGLE(code) ((code) >= QK_LAYER_TAP_TOGGLE && (code) <= QK_LAYER_TAP_TOGGLE_MAX) +#define IS_QK_SWAP_HANDS(code) ((code) >= QK_SWAP_HANDS && (code) <= QK_SWAP_HANDS_MAX) +#define IS_QK_TAP_DANCE(code) ((code) >= QK_TAP_DANCE && (code) <= QK_TAP_DANCE_MAX) +#define IS_QK_MAGIC(code) ((code) >= QK_MAGIC && (code) <= QK_MAGIC_MAX) +#define IS_QK_MIDI(code) ((code) >= QK_MIDI && (code) <= QK_MIDI_MAX) +#define IS_QK_SEQUENCER(code) ((code) >= QK_SEQUENCER && (code) <= QK_SEQUENCER_MAX) +#define IS_QK_JOYSTICK(code) ((code) >= QK_JOYSTICK && (code) <= QK_JOYSTICK_MAX) +#define IS_QK_PROGRAMMABLE_BUTTON(code) ((code) >= QK_PROGRAMMABLE_BUTTON && (code) <= QK_PROGRAMMABLE_BUTTON_MAX) +#define IS_QK_AUDIO(code) ((code) >= QK_AUDIO && (code) <= QK_AUDIO_MAX) +#define IS_QK_STENO(code) ((code) >= QK_STENO && (code) <= QK_STENO_MAX) +#define IS_QK_MACRO(code) ((code) >= QK_MACRO && (code) <= QK_MACRO_MAX) +#define IS_QK_LIGHTING(code) ((code) >= QK_LIGHTING && (code) <= QK_LIGHTING_MAX) +#define IS_QK_QUANTUM(code) ((code) >= QK_QUANTUM && (code) <= QK_QUANTUM_MAX) +#define IS_QK_KB(code) ((code) >= QK_KB && (code) <= QK_KB_MAX) +#define IS_QK_USER(code) ((code) >= QK_USER && (code) <= QK_USER_MAX) +#define IS_QK_UNICODE(code) ((code) >= QK_UNICODE && (code) <= QK_UNICODE_MAX) + +// Group Helpers +#define IS_INTERNAL_KEYCODE(code) ((code) >= KC_NO && (code) <= KC_TRANSPARENT) +#define IS_BASIC_KEYCODE(code) ((code) >= KC_A && (code) <= KC_EXSEL) +#define IS_SYSTEM_KEYCODE(code) ((code) >= KC_SYSTEM_POWER && (code) <= KC_SYSTEM_WAKE) +#define IS_MEDIA_KEYCODE(code) ((code) >= KC_AUDIO_MUTE && (code) <= KC_ASSISTANT) +#define IS_MOUSE_KEYCODE(code) ((code) >= KC_MS_UP && (code) <= KC_MS_ACCEL2) +#define IS_MODIFIERS_KEYCODE(code) ((code) >= KC_LEFT_CTRL && (code) <= KC_RIGHT_GUI) +#define IS_SWAP_HANDS_KEYCODE(code) ((code) >= SH_TG && (code) <= SH_OS) +#define IS_MAGIC_KEYCODE(code) ((code) >= MAGIC_SWAP_CONTROL_CAPSLOCK && (code) <= MAGIC_TOGGLE_ESCAPE_CAPSLOCK) +#define IS_MIDI_KEYCODE(code) ((code) >= MI_ON && (code) <= MI_BENDU) +#define IS_SEQUENCER_KEYCODE(code) ((code) >= SQ_ON && (code) <= SQ_SCLR) +#define IS_JOYSTICK_KEYCODE(code) ((code) >= QK_JOYSTICK_BUTTON_0 && (code) <= QK_JOYSTICK_BUTTON_31) +#define IS_PROGRAMMABLE_BUTTON_KEYCODE(code) ((code) >= QK_PROGRAMMABLE_BUTTON_1 && (code) <= QK_PROGRAMMABLE_BUTTON_32) +#define IS_AUDIO_KEYCODE(code) ((code) >= AU_ON && (code) <= MUV_DE) +#define IS_STENO_KEYCODE(code) ((code) >= QK_STENO_BOLT && (code) <= QK_STENO_COMB_MAX) +#define IS_MACRO_KEYCODE(code) ((code) >= MACRO_0 && (code) <= MACRO_31) +#define IS_BACKLIGHT_KEYCODE(code) ((code) >= BL_ON && (code) <= BL_BRTG) +#define IS_RGB_KEYCODE(code) ((code) >= RGB_TOG && (code) <= RGB_MODE_TWINKLE) +#define IS_QUANTUM_KEYCODE(code) ((code) >= QK_BOOTLOADER && (code) <= QK_AUTOCORRECT_TOGGLE) + diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 50e581cd87..a5997711f2 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -109,7 +109,7 @@ action_t action_for_keycode(uint16_t keycode) { break; case QK_ONE_SHOT_MOD ... QK_ONE_SHOT_MOD_MAX:; // OSM(mod) - One-shot mod - mod = mod_config(keycode & 0xFF); + mod = mod_config(keycode & 0x1F); action.code = ACTION_MODS_ONESHOT(mod); break; #endif @@ -118,8 +118,8 @@ action_t action_for_keycode(uint16_t keycode) { action.code = ACTION_LAYER_TAP_TOGGLE(keycode & 0xFF); break; case QK_LAYER_MOD ... QK_LAYER_MOD_MAX: - mod = mod_config(keycode & 0xF); - action_layer = (keycode >> 4) & 0xF; + mod = mod_config(keycode & 0x1F); + action_layer = (keycode >> 5) & 0xF; action.code = ACTION_LAYER_MODS(action_layer, mod); break; #endif diff --git a/quantum/process_keycode/process_joystick.c b/quantum/process_keycode/process_joystick.c index c4c6fb59a8..43067b81db 100644 --- a/quantum/process_keycode/process_joystick.c +++ b/quantum/process_keycode/process_joystick.c @@ -19,11 +19,11 @@ bool process_joystick(uint16_t keycode, keyrecord_t *record) { switch (keycode) { - case QK_JOYSTICK_BUTTON_MIN ... QK_JOYSTICK_BUTTON_MAX: + case QK_JOYSTICK ... QK_JOYSTICK_MAX: if (record->event.pressed) { - register_joystick_button(keycode - QK_JOYSTICK_BUTTON_MIN); + register_joystick_button(keycode - QK_JOYSTICK); } else { - unregister_joystick_button(keycode - QK_JOYSTICK_BUTTON_MIN); + unregister_joystick_button(keycode - QK_JOYSTICK); } return false; } diff --git a/quantum/process_keycode/process_magic.c b/quantum/process_keycode/process_magic.c index 50816c5261..72332b20d7 100644 --- a/quantum/process_keycode/process_magic.c +++ b/quantum/process_keycode/process_magic.c @@ -40,158 +40,152 @@ float cg_swap_song[][2] = CG_SWAP_SONG; bool process_magic(uint16_t keycode, keyrecord_t *record) { // skip anything that isn't a keyup if (record->event.pressed) { - switch (keycode) { - case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_ALT_GUI: - case MAGIC_SWAP_LCTL_LGUI ... MAGIC_EE_HANDS_RIGHT: - case MAGIC_TOGGLE_GUI: - case MAGIC_TOGGLE_CONTROL_CAPSLOCK: - case MAGIC_TOGGLE_BACKSLASH_BACKSPACE: - case MAGIC_SWAP_ESCAPE_CAPSLOCK ... MAGIC_TOGGLE_ESCAPE_CAPSLOCK: - /* keymap config */ - keymap_config.raw = eeconfig_read_keymap(); - switch (keycode) { - case MAGIC_SWAP_CONTROL_CAPSLOCK: - keymap_config.swap_control_capslock = true; - break; - case MAGIC_SWAP_ESCAPE_CAPSLOCK: - keymap_config.swap_escape_capslock = true; - break; - case MAGIC_CAPSLOCK_TO_CONTROL: - keymap_config.capslock_to_control = true; - break; - case MAGIC_SWAP_LALT_LGUI: - keymap_config.swap_lalt_lgui = true; - break; - case MAGIC_SWAP_RALT_RGUI: - keymap_config.swap_ralt_rgui = true; - break; - case MAGIC_SWAP_LCTL_LGUI: - keymap_config.swap_lctl_lgui = true; - break; - case MAGIC_SWAP_RCTL_RGUI: - keymap_config.swap_rctl_rgui = true; - break; - case MAGIC_NO_GUI: - keymap_config.no_gui = true; - break; - case MAGIC_SWAP_GRAVE_ESC: - keymap_config.swap_grave_esc = true; - break; - case MAGIC_SWAP_BACKSLASH_BACKSPACE: - keymap_config.swap_backslash_backspace = true; - break; - case MAGIC_HOST_NKRO: - clear_keyboard(); // clear first buffer to prevent stuck keys - keymap_config.nkro = true; - break; - case MAGIC_SWAP_ALT_GUI: - keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = true; + if (IS_MAGIC_KEYCODE(keycode)) { + /* keymap config */ + keymap_config.raw = eeconfig_read_keymap(); + switch (keycode) { + case MAGIC_SWAP_CONTROL_CAPSLOCK: + keymap_config.swap_control_capslock = true; + break; + case MAGIC_SWAP_ESCAPE_CAPSLOCK: + keymap_config.swap_escape_capslock = true; + break; + case MAGIC_CAPSLOCK_TO_CONTROL: + keymap_config.capslock_to_control = true; + break; + case MAGIC_SWAP_LALT_LGUI: + keymap_config.swap_lalt_lgui = true; + break; + case MAGIC_SWAP_RALT_RGUI: + keymap_config.swap_ralt_rgui = true; + break; + case MAGIC_SWAP_LCTL_LGUI: + keymap_config.swap_lctl_lgui = true; + break; + case MAGIC_SWAP_RCTL_RGUI: + keymap_config.swap_rctl_rgui = true; + break; + case MAGIC_NO_GUI: + keymap_config.no_gui = true; + break; + case MAGIC_SWAP_GRAVE_ESC: + keymap_config.swap_grave_esc = true; + break; + case MAGIC_SWAP_BACKSLASH_BACKSPACE: + keymap_config.swap_backslash_backspace = true; + break; + case MAGIC_HOST_NKRO: + clear_keyboard(); // clear first buffer to prevent stuck keys + keymap_config.nkro = true; + break; + case MAGIC_SWAP_ALT_GUI: + keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = true; #ifdef AUDIO_ENABLE - PLAY_SONG(ag_swap_song); + PLAY_SONG(ag_swap_song); #endif - break; - case MAGIC_SWAP_CTL_GUI: - keymap_config.swap_lctl_lgui = keymap_config.swap_rctl_rgui = true; + break; + case MAGIC_SWAP_CTL_GUI: + keymap_config.swap_lctl_lgui = keymap_config.swap_rctl_rgui = true; #ifdef AUDIO_ENABLE - PLAY_SONG(cg_swap_song); + PLAY_SONG(cg_swap_song); #endif - break; - case MAGIC_UNSWAP_CONTROL_CAPSLOCK: - keymap_config.swap_control_capslock = false; - break; - case MAGIC_UNSWAP_ESCAPE_CAPSLOCK: - keymap_config.swap_escape_capslock = false; - break; - case MAGIC_UNCAPSLOCK_TO_CONTROL: - keymap_config.capslock_to_control = false; - break; - case MAGIC_UNSWAP_LALT_LGUI: - keymap_config.swap_lalt_lgui = false; - break; - case MAGIC_UNSWAP_RALT_RGUI: - keymap_config.swap_ralt_rgui = false; - break; - case MAGIC_UNSWAP_LCTL_LGUI: - keymap_config.swap_lctl_lgui = false; - break; - case MAGIC_UNSWAP_RCTL_RGUI: - keymap_config.swap_rctl_rgui = false; - break; - case MAGIC_UNNO_GUI: - keymap_config.no_gui = false; - break; - case MAGIC_UNSWAP_GRAVE_ESC: - keymap_config.swap_grave_esc = false; - break; - case MAGIC_UNSWAP_BACKSLASH_BACKSPACE: - keymap_config.swap_backslash_backspace = false; - break; - case MAGIC_UNHOST_NKRO: - clear_keyboard(); // clear first buffer to prevent stuck keys - keymap_config.nkro = false; - break; - case MAGIC_UNSWAP_ALT_GUI: - keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = false; + break; + case MAGIC_UNSWAP_CONTROL_CAPSLOCK: + keymap_config.swap_control_capslock = false; + break; + case MAGIC_UNSWAP_ESCAPE_CAPSLOCK: + keymap_config.swap_escape_capslock = false; + break; + case MAGIC_UNCAPSLOCK_TO_CONTROL: + keymap_config.capslock_to_control = false; + break; + case MAGIC_UNSWAP_LALT_LGUI: + keymap_config.swap_lalt_lgui = false; + break; + case MAGIC_UNSWAP_RALT_RGUI: + keymap_config.swap_ralt_rgui = false; + break; + case MAGIC_UNSWAP_LCTL_LGUI: + keymap_config.swap_lctl_lgui = false; + break; + case MAGIC_UNSWAP_RCTL_RGUI: + keymap_config.swap_rctl_rgui = false; + break; + case MAGIC_UNNO_GUI: + keymap_config.no_gui = false; + break; + case MAGIC_UNSWAP_GRAVE_ESC: + keymap_config.swap_grave_esc = false; + break; + case MAGIC_UNSWAP_BACKSLASH_BACKSPACE: + keymap_config.swap_backslash_backspace = false; + break; + case MAGIC_UNHOST_NKRO: + clear_keyboard(); // clear first buffer to prevent stuck keys + keymap_config.nkro = false; + break; + case MAGIC_UNSWAP_ALT_GUI: + keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = false; #ifdef AUDIO_ENABLE - PLAY_SONG(ag_norm_song); + PLAY_SONG(ag_norm_song); #endif - break; - case MAGIC_UNSWAP_CTL_GUI: - keymap_config.swap_lctl_lgui = keymap_config.swap_rctl_rgui = false; + break; + case MAGIC_UNSWAP_CTL_GUI: + keymap_config.swap_lctl_lgui = keymap_config.swap_rctl_rgui = false; #ifdef AUDIO_ENABLE - PLAY_SONG(cg_norm_song); + PLAY_SONG(cg_norm_song); #endif - break; - case MAGIC_TOGGLE_ALT_GUI: - keymap_config.swap_lalt_lgui = !keymap_config.swap_lalt_lgui; - keymap_config.swap_ralt_rgui = keymap_config.swap_lalt_lgui; + break; + case MAGIC_TOGGLE_ALT_GUI: + keymap_config.swap_lalt_lgui = !keymap_config.swap_lalt_lgui; + keymap_config.swap_ralt_rgui = keymap_config.swap_lalt_lgui; #ifdef AUDIO_ENABLE - if (keymap_config.swap_ralt_rgui) { - PLAY_SONG(ag_swap_song); - } else { - PLAY_SONG(ag_norm_song); - } + if (keymap_config.swap_ralt_rgui) { + PLAY_SONG(ag_swap_song); + } else { + PLAY_SONG(ag_norm_song); + } #endif - break; - case MAGIC_TOGGLE_CTL_GUI: - keymap_config.swap_lctl_lgui = !keymap_config.swap_lctl_lgui; - keymap_config.swap_rctl_rgui = keymap_config.swap_lctl_lgui; + break; + case MAGIC_TOGGLE_CTL_GUI: + keymap_config.swap_lctl_lgui = !keymap_config.swap_lctl_lgui; + keymap_config.swap_rctl_rgui = keymap_config.swap_lctl_lgui; #ifdef AUDIO_ENABLE - if (keymap_config.swap_rctl_rgui) { - PLAY_SONG(cg_swap_song); - } else { - PLAY_SONG(cg_norm_song); - } + if (keymap_config.swap_rctl_rgui) { + PLAY_SONG(cg_swap_song); + } else { + PLAY_SONG(cg_norm_song); + } #endif - break; - case MAGIC_TOGGLE_BACKSLASH_BACKSPACE: - keymap_config.swap_backslash_backspace = !keymap_config.swap_backslash_backspace; - break; - case MAGIC_TOGGLE_NKRO: - clear_keyboard(); // clear first buffer to prevent stuck keys - keymap_config.nkro = !keymap_config.nkro; - break; - case MAGIC_EE_HANDS_LEFT: - eeconfig_update_handedness(true); - break; - case MAGIC_EE_HANDS_RIGHT: - eeconfig_update_handedness(false); - break; - case MAGIC_TOGGLE_GUI: - keymap_config.no_gui = !keymap_config.no_gui; - break; - case MAGIC_TOGGLE_CONTROL_CAPSLOCK: - keymap_config.swap_control_capslock = !keymap_config.swap_control_capslock; - break; - case MAGIC_TOGGLE_ESCAPE_CAPSLOCK: - keymap_config.swap_escape_capslock = !keymap_config.swap_escape_capslock; - break; - } + break; + case MAGIC_TOGGLE_BACKSLASH_BACKSPACE: + keymap_config.swap_backslash_backspace = !keymap_config.swap_backslash_backspace; + break; + case MAGIC_TOGGLE_NKRO: + clear_keyboard(); // clear first buffer to prevent stuck keys + keymap_config.nkro = !keymap_config.nkro; + break; + case MAGIC_EE_HANDS_LEFT: + eeconfig_update_handedness(true); + break; + case MAGIC_EE_HANDS_RIGHT: + eeconfig_update_handedness(false); + break; + case MAGIC_TOGGLE_GUI: + keymap_config.no_gui = !keymap_config.no_gui; + break; + case MAGIC_TOGGLE_CONTROL_CAPSLOCK: + keymap_config.swap_control_capslock = !keymap_config.swap_control_capslock; + break; + case MAGIC_TOGGLE_ESCAPE_CAPSLOCK: + keymap_config.swap_escape_capslock = !keymap_config.swap_escape_capslock; + break; + } - eeconfig_update_keymap(keymap_config.raw); - clear_keyboard(); // clear to prevent stuck keys + eeconfig_update_keymap(keymap_config.raw); + clear_keyboard(); // clear to prevent stuck keys - return false; + return false; } } diff --git a/quantum/process_keycode/process_programmable_button.c b/quantum/process_keycode/process_programmable_button.c index d6a14e120c..03034edb61 100644 --- a/quantum/process_keycode/process_programmable_button.c +++ b/quantum/process_keycode/process_programmable_button.c @@ -19,8 +19,8 @@ along with this program. If not, see . #include "programmable_button.h" bool process_programmable_button(uint16_t keycode, keyrecord_t *record) { - if (keycode >= QK_PROGRAMMABLE_BUTTON_MIN && keycode <= QK_PROGRAMMABLE_BUTTON_MAX) { - uint8_t button = keycode - QK_PROGRAMMABLE_BUTTON_MIN + 1; + if (IS_QK_PROGRAMMABLE_BUTTON(keycode)) { + uint8_t button = keycode - QK_PROGRAMMABLE_BUTTON + 1; if (record->event.pressed) { programmable_button_register(button); } else { diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 2df733fe1f..ec69fadbab 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -16,610 +16,28 @@ #pragma once -#include "sequencer.h" - -// Fillers to make layering more clear -#define _______ KC_TRANSPARENT -#define XXXXXXX KC_NO - -enum quantum_keycodes { - // Ranges used in shortcuts - not to be used directly - QK_BASIC = 0x0000, - QK_BASIC_MAX = 0x00FF, - QK_MODS = 0x0100, - QK_LCTL = 0x0100, - QK_LSFT = 0x0200, - QK_LALT = 0x0400, - QK_LGUI = 0x0800, - QK_RMODS_MIN = 0x1000, - QK_RCTL = 0x1100, - QK_RSFT = 0x1200, - QK_RALT = 0x1400, - QK_RGUI = 0x1800, - QK_MODS_MAX = 0x1FFF, - QK_LAYER_TAP = 0x4000, - QK_LAYER_TAP_MAX = 0x4FFF, - QK_TO = 0x5000, - QK_TO_MAX = 0x50FF, - QK_MOMENTARY = 0x5100, - QK_MOMENTARY_MAX = 0x51FF, - QK_DEF_LAYER = 0x5200, - QK_DEF_LAYER_MAX = 0x52FF, - QK_TOGGLE_LAYER = 0x5300, - QK_TOGGLE_LAYER_MAX = 0x53FF, - QK_ONE_SHOT_LAYER = 0x5400, - QK_ONE_SHOT_LAYER_MAX = 0x54FF, - QK_ONE_SHOT_MOD = 0x5500, - QK_ONE_SHOT_MOD_MAX = 0x55FF, - QK_SWAP_HANDS = 0x5600, - QK_SWAP_HANDS_MAX = 0x56FF, - QK_TAP_DANCE = 0x5700, - QK_TAP_DANCE_MAX = 0x57FF, - QK_LAYER_TAP_TOGGLE = 0x5800, - QK_LAYER_TAP_TOGGLE_MAX = 0x58FF, - QK_LAYER_MOD = 0x5900, - QK_LAYER_MOD_MAX = 0x59FF, - QK_STENO = 0x5A00, - QK_STENO_BOLT = 0x5A30, - QK_STENO_GEMINI = 0x5A31, - QK_STENO_COMB = 0x5A32, - QK_STENO_COMB_MAX = 0x5A3C, - QK_STENO_MAX = 0x5A3F, - // 0x5C00 - 0x5FFF are reserved, see below - QK_MOD_TAP = 0x6000, - QK_MOD_TAP_MAX = 0x7FFF, - QK_UNICODE = 0x8000, - QK_UNICODE_MAX = 0xFFFF, - QK_UNICODEMAP = 0x8000, - QK_UNICODEMAP_MAX = 0xBFFF, - QK_UNICODEMAP_PAIR = 0xC000, - QK_UNICODEMAP_PAIR_MAX = 0xFFFF, - - // Loose keycodes - to be used directly - QK_BOOTLOADER = 0x5C00, - QK_DEBUG_TOGGLE, // 5C01 - - // Magic - MAGIC_SWAP_CONTROL_CAPSLOCK, // 5C02 - MAGIC_CAPSLOCK_TO_CONTROL, // 5C03 - MAGIC_SWAP_LALT_LGUI, // 5C04 - MAGIC_SWAP_RALT_RGUI, // 5C05 - MAGIC_NO_GUI, // 5C06 - MAGIC_SWAP_GRAVE_ESC, // 5C07 - MAGIC_SWAP_BACKSLASH_BACKSPACE, // 5C08 - MAGIC_HOST_NKRO, // 5C09 - MAGIC_SWAP_ALT_GUI, // 5C0A - MAGIC_UNSWAP_CONTROL_CAPSLOCK, // 5C0B - MAGIC_UNCAPSLOCK_TO_CONTROL, // 5C0C - MAGIC_UNSWAP_LALT_LGUI, // 5C0D - MAGIC_UNSWAP_RALT_RGUI, // 5C0E - MAGIC_UNNO_GUI, // 5C0F - MAGIC_UNSWAP_GRAVE_ESC, // 5C10 - MAGIC_UNSWAP_BACKSLASH_BACKSPACE, // 5C11 - MAGIC_UNHOST_NKRO, // 5C12 - MAGIC_UNSWAP_ALT_GUI, // 5C13 - MAGIC_TOGGLE_NKRO, // 5C14 - MAGIC_TOGGLE_ALT_GUI, // 5C15 - - // Grave Escape - QK_GRAVE_ESCAPE, // 5C16 - - // Auto Shift - QK_AUTO_SHIFT_UP, // 5C17 - QK_AUTO_SHIFT_DOWN, // 5C18 - QK_AUTO_SHIFT_REPORT, // 5C19 - QK_AUTO_SHIFT_TOGGLE, // 5C1A - QK_AUTO_SHIFT_ON, // 5C1B - QK_AUTO_SHIFT_OFF, // 5C1C - - // Audio - AU_ON, // 5C1D - AU_OFF, // 5C1E - AU_TOG, // 5C1F - - // Audio Clicky - CLICKY_TOGGLE, // 5C20 - CLICKY_ENABLE, // 5C21 - CLICKY_DISABLE, // 5C22 - CLICKY_UP, // 5C23 - CLICKY_DOWN, // 5C24 - CLICKY_RESET, // 5C25 - - // Music mode - MU_ON, // 5C26 - MU_OFF, // 5C27 - MU_TOG, // 5C28 - MU_MOD, // 5C29 - MUV_IN, // 5C2A - MUV_DE, // 5C2B - - // MIDI - MI_ON, // 5C2C - MI_OFF, // 5C2D - MI_TOG, // 5C2E - - MI_C, // 5C2F - MI_Cs, // 5C30 - MI_Db = MI_Cs, - MI_D, // 5C31 - MI_Ds, // 5C32 - MI_Eb = MI_Ds, - MI_E, // 5C33 - MI_F, // 5C34 - MI_Fs, // 5C35 - MI_Gb = MI_Fs, - MI_G, // 5C36 - MI_Gs, // 5C37 - MI_Ab = MI_Gs, - MI_A, // 5C38 - MI_As, // 5C39 - MI_Bb = MI_As, - MI_B, // 5C3A - - MI_C_1, // 5C3B - MI_Cs_1, // 5C3C - MI_Db_1 = MI_Cs_1, - MI_D_1, // 5C3D - MI_Ds_1, // 5C3E - MI_Eb_1 = MI_Ds_1, - MI_E_1, // 5C3F - MI_F_1, // 5C40 - MI_Fs_1, // 5C41 - MI_Gb_1 = MI_Fs_1, - MI_G_1, // 5C42 - MI_Gs_1, // 5C43 - MI_Ab_1 = MI_Gs_1, - MI_A_1, // 5C44 - MI_As_1, // 5C45 - MI_Bb_1 = MI_As_1, - MI_B_1, // 5C46 - - MI_C_2, // 5C47 - MI_Cs_2, // 5C48 - MI_Db_2 = MI_Cs_2, - MI_D_2, // 5C49 - MI_Ds_2, // 5C4A - MI_Eb_2 = MI_Ds_2, - MI_E_2, // 5C4B - MI_F_2, // 5C4C - MI_Fs_2, // 5C4D - MI_Gb_2 = MI_Fs_2, - MI_G_2, // 5C4E - MI_Gs_2, // 5C4F - MI_Ab_2 = MI_Gs_2, - MI_A_2, // 5C50 - MI_As_2, // 5C51 - MI_Bb_2 = MI_As_2, - MI_B_2, // 5C52 - - MI_C_3, // 5C53 - MI_Cs_3, // 5C54 - MI_Db_3 = MI_Cs_3, - MI_D_3, // 5C55 - MI_Ds_3, // 5C56 - MI_Eb_3 = MI_Ds_3, - MI_E_3, // 5C57 - MI_F_3, // 5C58 - MI_Fs_3, // 5C59 - MI_Gb_3 = MI_Fs_3, - MI_G_3, // 5C5A - MI_Gs_3, // 5C5B - MI_Ab_3 = MI_Gs_3, - MI_A_3, // 5C5C - MI_As_3, // 5C5D - MI_Bb_3 = MI_As_3, - MI_B_3, // 5C5E - - MI_C_4, // 5C5F - MI_Cs_4, // 5C60 - MI_Db_4 = MI_Cs_4, - MI_D_4, // 5C61 - MI_Ds_4, // 5C62 - MI_Eb_4 = MI_Ds_4, - MI_E_4, // 5C63 - MI_F_4, // 5C64 - MI_Fs_4, // 5C65 - MI_Gb_4 = MI_Fs_4, - MI_G_4, // 5C66 - MI_Gs_4, // 5C67 - MI_Ab_4 = MI_Gs_4, - MI_A_4, // 5C68 - MI_As_4, // 5C69 - MI_Bb_4 = MI_As_4, - MI_B_4, // 5C6A - - MI_C_5, // 5C6B - MI_Cs_5, // 5C6C - MI_Db_5 = MI_Cs_5, - MI_D_5, // 5C6D - MI_Ds_5, // 5C6E - MI_Eb_5 = MI_Ds_5, - MI_E_5, // 5C6F - MI_F_5, // 5C70 - MI_Fs_5, // 5C71 - MI_Gb_5 = MI_Fs_5, - MI_G_5, // 5C72 - MI_Gs_5, // 5C73 - MI_Ab_5 = MI_Gs_5, - MI_A_5, // 5C74 - MI_As_5, // 5C75 - MI_Bb_5 = MI_As_5, - MI_B_5, // 5C76 - - MI_OCT_N2, // 5C77 - MI_OCT_N1, // 5C78 - MI_OCT_0, // 5C79 - MI_OCT_1, // 5C7A - MI_OCT_2, // 5C7B - MI_OCT_3, // 5C7C - MI_OCT_4, // 5C7D - MI_OCT_5, // 5C7E - MI_OCT_6, // 5C7F - MI_OCT_7, // 5C80 - MI_OCTD, // 5C81 - MI_OCTU, // 5C82 - - MI_TRNS_N6, // 5C83 - MI_TRNS_N5, // 5C84 - MI_TRNS_N4, // 5C85 - MI_TRNS_N3, // 5C86 - MI_TRNS_N2, // 5C87 - MI_TRNS_N1, // 5C88 - MI_TRNS_0, // 5C89 - MI_TRNS_1, // 5C8A - MI_TRNS_2, // 5C8B - MI_TRNS_3, // 5C8C - MI_TRNS_4, // 5C8D - MI_TRNS_5, // 5C8E - MI_TRNS_6, // 5C8F - MI_TRNSD, // 5C90 - MI_TRNSU, // 5C91 - - MI_VEL_0, // 5C92 -#ifdef VIA_ENABLE - MI_VEL_1 = MI_VEL_0, -#else - MI_VEL_1, // 5C93 -#endif - MI_VEL_2, // 5C94 - MI_VEL_3, // 5C95 - MI_VEL_4, // 5C96 - MI_VEL_5, // 5C97 - MI_VEL_6, // 5C98 - MI_VEL_7, // 5C99 - MI_VEL_8, // 5C9A - MI_VEL_9, // 5C9B - MI_VEL_10, // 5C9C - MI_VELD, // 5C9D - MI_VELU, // 5C9E - - MI_CH1, // 5C9F - MI_CH2, // 5CA0 - MI_CH3, // 5CA1 - MI_CH4, // 5CA2 - MI_CH5, // 5CA3 - MI_CH6, // 5CA4 - MI_CH7, // 5CA5 - MI_CH8, // 5CA6 - MI_CH9, // 5CA7 - MI_CH10, // 5CA8 - MI_CH11, // 5CA9 - MI_CH12, // 5CAA - MI_CH13, // 5CAB - MI_CH14, // 5CAC - MI_CH15, // 5CAD - MI_CH16, // 5CAE - MI_CHD, // 5CAF - MI_CHU, // 5CB0 - - MI_ALLOFF, // 5CB1 - - MI_SUS, // 5CB2 - MI_PORT, // 5CB3 - MI_SOST, // 5CB4 - MI_SOFT, // 5CB5 - MI_LEG, // 5CB6 - - MI_MOD, // 5CB7 - MI_MODSD, // 5CB8 - MI_MODSU, // 5CB9 - - MI_BENDD, // 5CBA - MI_BENDU, // 5CBB - - // Backlight - BL_ON, // 5CBC - BL_OFF, // 5CBD - BL_DEC, // 5CBE - BL_INC, // 5CBF - BL_TOGG, // 5CC0 - BL_STEP, // 5CC1 - BL_BRTG, // 5CC2 - - // RGB underglow/matrix - RGB_TOG, // 5CC3 - RGB_MODE_FORWARD, // 5CC4 - RGB_MODE_REVERSE, // 5CC5 - RGB_HUI, // 5CC6 - RGB_HUD, // 5CC7 - RGB_SAI, // 5CC8 - RGB_SAD, // 5CC9 - RGB_VAI, // 5CCA - RGB_VAD, // 5CCB - RGB_SPI, // 5CCC - RGB_SPD, // 5CCD - RGB_MODE_PLAIN, // 5CCE - RGB_MODE_BREATHE, // 5CCF - RGB_MODE_RAINBOW, // 5CD0 - RGB_MODE_SWIRL, // 5CD1 - RGB_MODE_SNAKE, // 5CD2 - RGB_MODE_KNIGHT, // 5CD3 - RGB_MODE_XMAS, // 5CD4 - RGB_MODE_GRADIENT, // 5CD5 - RGB_MODE_RGBTEST, // 5CD6 - - // Velocikey - QK_VELOCIKEY_TOGGLE, // 5CD7 - - // Space Cadet - QK_SPACE_CADET_LEFT_SHIFT_PARENTHESIS_OPEN, // 5CD8 - QK_SPACE_CADET_RIGHT_SHIFT_PARENTHESIS_CLOSE, // 5CD9 - QK_SPACE_CADET_RIGHT_SHIFT_ENTER, // 5CDA - - // Thermal Printer - PRINT_ON, // 5CDB - PRINT_OFF, // 5CDC - - // Bluetooth: output selection - OUT_AUTO, // 5CDD - OUT_USB, // 5CDE - - // Clear EEPROM - QK_CLEAR_EEPROM, // 5CDF - - // Unicode - QK_UNICODE_MODE_NEXT, // 5CE0 - QK_UNICODE_MODE_PREVIOUS, // 5CE1 - QK_UNICODE_MODE_MACOS, // 5CE2 - QK_UNICODE_MODE_LINUX, // 5CE3 - QK_UNICODE_MODE_WINDOWS, // 5CE4 - QK_UNICODE_MODE_BSD, // 5CE5 - QK_UNICODE_MODE_WINCOMPOSE, // 5CE6 - - // Haptic - HPT_ON, // 5CE7 - HPT_OFF, // 5CE8 - HPT_TOG, // 5CE9 - HPT_RST, // 5CEA - HPT_FBK, // 5CEB - HPT_BUZ, // 5CEC - HPT_MODI, // 5CED - HPT_MODD, // 5CEE - HPT_CONT, // 5CEF - HPT_CONI, // 5CF0 - HPT_COND, // 5CF1 - HPT_DWLI, // 5CF2 - HPT_DWLD, // 5CF3 - - // Space Cadet (continued) - QK_SPACE_CADET_LEFT_CTRL_PARENTHESIS_OPEN, // 5CF4 - QK_SPACE_CADET_RIGHT_CTRL_PARENTHESIS_CLOSE, // 5CF5 - QK_SPACE_CADET_LEFT_ALT_PARENTHESIS_OPEN, // 5CF6 - QK_SPACE_CADET_RIGHT_ALT_PARENTHESIS_CLOSE, // 5CF7 - - // Combos - QK_COMBO_ON, // 5CF8 - QK_COMBO_OFF, // 5CF9 - QK_COMBO_TOGGLE, // 5CFA - - // Magic (continued) - MAGIC_SWAP_LCTL_LGUI, // 5CFB - MAGIC_SWAP_RCTL_RGUI, // 5CFC - MAGIC_UNSWAP_LCTL_LGUI, // 5CFD - MAGIC_UNSWAP_RCTL_RGUI, // 5CFE - MAGIC_SWAP_CTL_GUI, // 5CFF - MAGIC_UNSWAP_CTL_GUI, // 5D00 - MAGIC_TOGGLE_CTL_GUI, // 5D01 - MAGIC_EE_HANDS_LEFT, // 5D02 - MAGIC_EE_HANDS_RIGHT, // 5D03 - - // Dynamic Macros - QK_DYNAMIC_MACRO_RECORD_START_1, // 5D04 - QK_DYNAMIC_MACRO_RECORD_START_2, // 5D05 - QK_DYNAMIC_MACRO_RECORD_STOP, // 5D06 - QK_DYNAMIC_MACRO_PLAY_1, // 5D07 - QK_DYNAMIC_MACRO_PLAY_2, // 5D08 - - // Joystick - QK_JOYSTICK_BUTTON_0, // 5D09 - QK_JOYSTICK_BUTTON_1, // 5D0A - QK_JOYSTICK_BUTTON_2, // 5D0B - QK_JOYSTICK_BUTTON_3, // 5D0C - QK_JOYSTICK_BUTTON_4, // 5D0D - QK_JOYSTICK_BUTTON_5, // 5D0E - QK_JOYSTICK_BUTTON_6, // 5D0F - QK_JOYSTICK_BUTTON_7, // 5D10 - QK_JOYSTICK_BUTTON_8, // 5D11 - QK_JOYSTICK_BUTTON_9, // 5D12 - QK_JOYSTICK_BUTTON_10, // 5D13 - QK_JOYSTICK_BUTTON_11, // 5D14 - QK_JOYSTICK_BUTTON_12, // 5D15 - QK_JOYSTICK_BUTTON_13, // 5D16 - QK_JOYSTICK_BUTTON_14, // 5D17 - QK_JOYSTICK_BUTTON_15, // 5D18 - QK_JOYSTICK_BUTTON_16, // 5D19 - QK_JOYSTICK_BUTTON_17, // 5D1A - QK_JOYSTICK_BUTTON_18, // 5D1B - QK_JOYSTICK_BUTTON_19, // 5D1C - QK_JOYSTICK_BUTTON_20, // 5D1D - QK_JOYSTICK_BUTTON_21, // 5D1E - QK_JOYSTICK_BUTTON_22, // 5D1F - QK_JOYSTICK_BUTTON_23, // 5D20 - QK_JOYSTICK_BUTTON_24, // 5D21 - QK_JOYSTICK_BUTTON_25, // 5D22 - QK_JOYSTICK_BUTTON_26, // 5D23 - QK_JOYSTICK_BUTTON_27, // 5D24 - QK_JOYSTICK_BUTTON_28, // 5D25 - QK_JOYSTICK_BUTTON_29, // 5D26 - QK_JOYSTICK_BUTTON_30, // 5D27 - QK_JOYSTICK_BUTTON_31, // 5D28 - - // Leader Key - QK_LEADER, // 5D29 - - // Bluetooth: output selection (continued) - OUT_BT, // 5D2A - - // Lock Key - QK_LOCK, // 5D2B - - // Unused slots - UNUSED_000, // 5D2C - UNUSED_001, // 5D2D - - // Sequencer - SQ_ON, // 5D2E - SQ_OFF, // 5D2F - SQ_TOG, // 5D30 - - SQ_TMPD, // 5D31 - SQ_TMPU, // 5D32 - - SQ_RESD, // 5D33 - SQ_RESU, // 5D34 - - SQ_SALL, // 5D35 - SQ_SCLR, // 5D36 - - SEQUENCER_STEP_MIN, // 5D37 - SEQUENCER_STEP_MAX = SEQUENCER_STEP_MIN + SEQUENCER_STEPS, - - SEQUENCER_RESOLUTION_MIN, - SEQUENCER_RESOLUTION_MAX = SEQUENCER_RESOLUTION_MIN + SEQUENCER_RESOLUTIONS, - - SEQUENCER_TRACK_MIN, - SEQUENCER_TRACK_MAX = SEQUENCER_TRACK_MIN + SEQUENCER_TRACKS, +// Pull in dd keycodes to maintain header compatibility +#include "keycodes.h" -#define SQ_S(n) (n < SEQUENCER_STEPS ? SEQUENCER_STEP_MIN + n : KC_NO) -#define SQ_R(n) (n < SEQUENCER_RESOLUTIONS ? SEQUENCER_RESOLUTION_MIN + n : KC_NO) -#define SQ_T(n) (n < SEQUENCER_TRACKS ? SEQUENCER_TRACK_MIN + n : KC_NO) +// US ANSI shifted keycode aliases +#include "keymap_us.h" - // One Shot - QK_ONE_SHOT_ON, - QK_ONE_SHOT_OFF, - QK_ONE_SHOT_TOGGLE, - - // RGB underglow/matrix (continued) - RGB_MODE_TWINKLE, - - // Key Overrides - QK_KEY_OVERRIDE_TOGGLE, - QK_KEY_OVERRIDE_ON, - QK_KEY_OVERRIDE_OFF, - - // Additional magic key - MAGIC_TOGGLE_GUI, - - // Adjust tapping term on the fly - DT_PRNT, - DT_UP, - DT_DOWN, - - // Programmable Button - QK_PROGRAMMABLE_BUTTON_1, - QK_PROGRAMMABLE_BUTTON_2, - QK_PROGRAMMABLE_BUTTON_3, - QK_PROGRAMMABLE_BUTTON_4, - QK_PROGRAMMABLE_BUTTON_5, - QK_PROGRAMMABLE_BUTTON_6, - QK_PROGRAMMABLE_BUTTON_7, - QK_PROGRAMMABLE_BUTTON_8, - QK_PROGRAMMABLE_BUTTON_9, - QK_PROGRAMMABLE_BUTTON_10, - QK_PROGRAMMABLE_BUTTON_11, - QK_PROGRAMMABLE_BUTTON_12, - QK_PROGRAMMABLE_BUTTON_13, - QK_PROGRAMMABLE_BUTTON_14, - QK_PROGRAMMABLE_BUTTON_15, - QK_PROGRAMMABLE_BUTTON_16, - QK_PROGRAMMABLE_BUTTON_17, - QK_PROGRAMMABLE_BUTTON_18, - QK_PROGRAMMABLE_BUTTON_19, - QK_PROGRAMMABLE_BUTTON_20, - QK_PROGRAMMABLE_BUTTON_21, - QK_PROGRAMMABLE_BUTTON_22, - QK_PROGRAMMABLE_BUTTON_23, - QK_PROGRAMMABLE_BUTTON_24, - QK_PROGRAMMABLE_BUTTON_25, - QK_PROGRAMMABLE_BUTTON_26, - QK_PROGRAMMABLE_BUTTON_27, - QK_PROGRAMMABLE_BUTTON_28, - QK_PROGRAMMABLE_BUTTON_29, - QK_PROGRAMMABLE_BUTTON_30, - QK_PROGRAMMABLE_BUTTON_31, - QK_PROGRAMMABLE_BUTTON_32, - - // Dedicated macro keys for Configurator and VIA - MACRO_0, - MACRO_1, - MACRO_2, - MACRO_3, - MACRO_4, - MACRO_5, - MACRO_6, - MACRO_7, - MACRO_8, - MACRO_9, - MACRO_10, - MACRO_11, - MACRO_12, - MACRO_13, - MACRO_14, - MACRO_15, - MACRO_16, - MACRO_17, - MACRO_18, - MACRO_19, - MACRO_20, - MACRO_21, - MACRO_22, - MACRO_23, - MACRO_24, - MACRO_25, - MACRO_26, - MACRO_27, - MACRO_28, - MACRO_29, - MACRO_30, - MACRO_31, - - MAGIC_TOGGLE_CONTROL_CAPSLOCK, - - QK_MAKE, - QK_REBOOT, - - QK_SECURE_LOCK, - QK_SECURE_UNLOCK, - QK_SECURE_TOGGLE, - QK_SECURE_REQUEST, - - QK_CAPS_WORD_TOGGLE, - - MAGIC_SWAP_ESCAPE_CAPSLOCK, - MAGIC_UNSWAP_ESCAPE_CAPSLOCK, - MAGIC_TOGGLE_ESCAPE_CAPSLOCK, - - QK_UNICODE_MODE_EMACS, - - QK_AUTOCORRECT_ON, - QK_AUTOCORRECT_OFF, - QK_AUTOCORRECT_TOGGLE, - - MAGIC_TOGGLE_BACKSLASH_BACKSPACE, - - // Start of custom keycode range for keyboards and keymaps - always leave at the end - SAFE_RANGE -}; +// TODO: sub-ranges? +// clang-format off +#define QK_LCTL 0x0100 +#define QK_LSFT 0x0200 +#define QK_LALT 0x0400 +#define QK_LGUI 0x0800 +#define QK_RMODS_MIN 0x1000 +#define QK_RCTL 0x1100 +#define QK_RSFT 0x1200 +#define QK_RALT 0x1400 +#define QK_RGUI 0x1800 +#define QK_UNICODEMAP 0x8000 +#define QK_UNICODEMAP_MAX 0xBFFF +#define QK_UNICODEMAP_PAIR 0xC000 +#define QK_UNICODEMAP_PAIR_MAX 0xFFFF +// clang-format on // Keycode modifiers & aliases #define LCTL(kc) (QK_LCTL | (kc)) @@ -654,122 +72,35 @@ enum quantum_keycodes { #define RCS(kc) (QK_RCTL | QK_RSFT | (kc)) #define SAGR(kc) RSA(kc) -#define MOD_HYPR 0xF -#define MOD_MEH 0x7 - -// US ANSI shifted keycode aliases -#include "keymap_us.h" - // Modified keycode aliases #define C(kc) LCTL(kc) #define S(kc) LSFT(kc) #define A(kc) LALT(kc) #define G(kc) LGUI(kc) -#define QK_GESC QK_GRAVE_ESCAPE - -#define QK_BOOT QK_BOOTLOADER -#define DB_TOGG QK_DEBUG_TOGGLE -#define EE_CLR QK_CLEAR_EEPROM -#define QK_RBT QK_REBOOT - -// Audio Clicky aliases -#define CK_TOGG CLICKY_TOGGLE -#define CK_RST CLICKY_RESET -#define CK_UP CLICKY_UP -#define CK_DOWN CLICKY_DOWN -#define CK_ON CLICKY_ENABLE -#define CK_OFF CLICKY_DISABLE - -// RGB aliases -#define RGB_MOD RGB_MODE_FORWARD -#define RGB_RMOD RGB_MODE_REVERSE -#define RGB_M_P RGB_MODE_PLAIN -#define RGB_M_B RGB_MODE_BREATHE -#define RGB_M_R RGB_MODE_RAINBOW -#define RGB_M_SW RGB_MODE_SWIRL -#define RGB_M_SN RGB_MODE_SNAKE -#define RGB_M_K RGB_MODE_KNIGHT -#define RGB_M_X RGB_MODE_XMAS -#define RGB_M_G RGB_MODE_GRADIENT -#define RGB_M_T RGB_MODE_RGBTEST -#define RGB_M_TW RGB_MODE_TWINKLE - -// Magic aliases -#define CL_SWAP MAGIC_SWAP_CONTROL_CAPSLOCK -#define CL_NORM MAGIC_UNSWAP_CONTROL_CAPSLOCK -#define CL_CTRL MAGIC_CAPSLOCK_TO_CONTROL -#define CL_CAPS MAGIC_UNCAPSLOCK_TO_CONTROL -#define CL_TOGG MAGIC_TOGGLE_CONTROL_CAPSLOCK - -#define EC_SWAP MAGIC_SWAP_ESCAPE_CAPSLOCK -#define EC_NORM MAGIC_UNSWAP_ESCAPE_CAPSLOCK -#define EC_TOGG MAGIC_TOGGLE_ESCAPE_CAPSLOCK - -#define LCG_SWP MAGIC_SWAP_LCTL_LGUI -#define LCG_NRM MAGIC_UNSWAP_LCTL_LGUI -#define RCG_SWP MAGIC_SWAP_RCTL_RGUI -#define RCG_NRM MAGIC_UNSWAP_RCTL_RGUI -#define CG_SWAP MAGIC_SWAP_CTL_GUI -#define CG_NORM MAGIC_UNSWAP_CTL_GUI -#define CG_TOGG MAGIC_TOGGLE_CTL_GUI - -#define LAG_SWP MAGIC_SWAP_LALT_LGUI -#define LAG_NRM MAGIC_UNSWAP_LALT_LGUI -#define RAG_SWP MAGIC_SWAP_RALT_RGUI -#define RAG_NRM MAGIC_UNSWAP_RALT_RGUI -#define AG_SWAP MAGIC_SWAP_ALT_GUI -#define AG_NORM MAGIC_UNSWAP_ALT_GUI -#define AG_TOGG MAGIC_TOGGLE_ALT_GUI - -#define GUI_OFF MAGIC_NO_GUI -#define GUI_ON MAGIC_UNNO_GUI -#define GUI_TOG MAGIC_TOGGLE_GUI - -#define GE_SWAP MAGIC_SWAP_GRAVE_ESC -#define GE_NORM MAGIC_UNSWAP_GRAVE_ESC - -#define BS_SWAP MAGIC_SWAP_BACKSLASH_BACKSPACE -#define BS_NORM MAGIC_UNSWAP_BACKSLASH_BACKSPACE -#define BS_TOGG MAGIC_TOGGLE_BACKSLASH_BACKSPACE - -#define NK_ON MAGIC_HOST_NKRO -#define NK_OFF MAGIC_UNHOST_NKRO -#define NK_TOGG MAGIC_TOGGLE_NKRO - -#define EH_LEFT MAGIC_EE_HANDS_LEFT -#define EH_RGHT MAGIC_EE_HANDS_RIGHT - -#define AC_ON QK_AUTOCORRECT_ON -#define AC_OFF QK_AUTOCORRECT_OFF -#define AC_TOGG QK_AUTOCORRECT_TOGGLE - -// Velocikey -#define VK_TOGG QK_VELOCIKEY_TOGGLE - -// GOTO layer - 256 layer max -#define TO(layer) (QK_TO | ((layer)&0xFF)) - -// Momentary switch layer - 256 layer max -#define MO(layer) (QK_MOMENTARY | ((layer)&0xFF)) - -// Set default layer - 256 layer max -#define DF(layer) (QK_DEF_LAYER | ((layer)&0xFF)) - -// Toggle to layer - 256 layer max -#define TG(layer) (QK_TOGGLE_LAYER | ((layer)&0xFF)) - -// One-shot layer - 256 layer max -#define OSL(layer) (QK_ONE_SHOT_LAYER | ((layer)&0xFF)) - -// L-ayer M-od: Momentary switch layer with modifiers active - 16 layer max, left mods only -#define LM(layer, mod) (QK_LAYER_MOD | (((layer)&0xF) << 4) | ((mod)&0xF)) +// GOTO layer - 32 layer max +#define TO(layer) (QK_TO | ((layer)&0x1F)) + +// Momentary switch layer - 32 layer max +#define MO(layer) (QK_MOMENTARY | ((layer)&0x1F)) + +// Set default layer - 32 layer max +#define DF(layer) (QK_DEF_LAYER | ((layer)&0x1F)) + +// Toggle to layer - 32 layer max +#define TG(layer) (QK_TOGGLE_LAYER | ((layer)&0x1F)) + +// One-shot layer - 32 layer max +#define OSL(layer) (QK_ONE_SHOT_LAYER | ((layer)&0x1F)) + +// L-ayer M-od: Momentary switch layer with modifiers active - 16 layer max +#define LM(layer, mod) (QK_LAYER_MOD | (((layer)&0xF) << 5) | ((mod)&0x1F)) // One-shot mod -#define OSM(mod) (QK_ONE_SHOT_MOD | ((mod)&0xFF)) +#define OSM(mod) (QK_ONE_SHOT_MOD | ((mod)&0x1F)) -// Layer tap-toggle -#define TT(layer) (QK_LAYER_TAP_TOGGLE | ((layer)&0xFF)) +// Layer tap-toggle - 32 layer max +#define TT(layer) (QK_LAYER_TAP_TOGGLE | ((layer)&0x1F)) // L-ayer, T-ap - 256 keycode max, 16 layer max #define LT(layer, kc) (QK_LAYER_TAP | (((layer)&0xF) << 8) | ((kc)&0xFF)) @@ -834,64 +165,8 @@ enum quantum_keycodes { #define X(i) (QK_UNICODEMAP | (i)) #define XP(i, j) (QK_UNICODEMAP_PAIR | ((i)&0x7F) | (((j)&0x7F) << 7)) // 127 max i and j -#define UC_NEXT QK_UNICODE_MODE_NEXT -#define UC_PREV QK_UNICODE_MODE_PREVIOUS - -#define UC_MAC QK_UNICODE_MODE_MACOS -#define UC_LINX QK_UNICODE_MODE_LINUX -#define UC_WIN QK_UNICODE_MODE_WINDOWS -#define UC_BSD QK_UNICODE_MODE_BSD -#define UC_WINC QK_UNICODE_MODE_WINCOMPOSE -#define UC_EMAC QK_UNICODE_MODE_EMACS - -// Auto Shift -#define AS_UP QK_AUTO_SHIFT_UP -#define AS_DOWN QK_AUTO_SHIFT_DOWN -#define AS_RPT QK_AUTO_SHIFT_REPORT -#define AS_TOGG QK_AUTO_SHIFT_TOGGLE -#define AS_ON QK_AUTO_SHIFT_ON -#define AS_OFF QK_AUTO_SHIFT_OFF - -// Leader key -#define QK_LEAD QK_LEADER - -// Caps Word -#define CW_TOGG QK_CAPS_WORD_TOGGLE - -// Key Overrides -#define KO_TOGG QK_KEY_OVERRIDE_TOGGLE -#define KO_ON QK_KEY_OVERRIDE_ON -#define KO_OFF QK_KEY_OVERRIDE_OFF - -// Secure -#define SE_LOCK QK_SECURE_LOCK -#define SE_UNLK QK_SECURE_UNLOCK -#define SE_TOGG QK_SECURE_TOGGLE -#define SE_REQ QK_SECURE_REQUEST - -// Space Cadet -#define SC_LSPO QK_SPACE_CADET_LEFT_SHIFT_PARENTHESIS_OPEN -#define SC_RSPC QK_SPACE_CADET_RIGHT_SHIFT_PARENTHESIS_CLOSE -#define SC_LCPO QK_SPACE_CADET_LEFT_CTRL_PARENTHESIS_OPEN -#define SC_RCPC QK_SPACE_CADET_RIGHT_CTRL_PARENTHESIS_CLOSE -#define SC_LAPO QK_SPACE_CADET_LEFT_ALT_PARENTHESIS_OPEN -#define SC_RAPC QK_SPACE_CADET_RIGHT_ALT_PARENTHESIS_CLOSE -#define SC_SENT QK_SPACE_CADET_RIGHT_SHIFT_ENTER - -// Combos -#define CM_ON QK_COMBO_ON -#define CM_OFF QK_COMBO_OFF -#define CM_TOGG QK_COMBO_TOGGLE - // Swap Hands #define SH_T(kc) (QK_SWAP_HANDS | (kc)) -#define SH_TG (QK_SWAP_HANDS | OP_SH_TOGGLE) -#define SH_TT (QK_SWAP_HANDS | OP_SH_TAP_TOGGLE) -#define SH_OS (QK_SWAP_HANDS | OP_SH_ONESHOT) -#define SH_MON (QK_SWAP_HANDS | OP_SH_ON_OFF) -#define SH_MOFF (QK_SWAP_HANDS | OP_SH_OFF_ON) -#define SH_ON (QK_SWAP_HANDS | OP_SH_ON) -#define SH_OFF (QK_SWAP_HANDS | OP_SH_OFF) // MIDI aliases #define MIDI_TONE_MIN MI_C @@ -905,88 +180,20 @@ enum quantum_keycodes { #define MIDI_CHANNEL_MIN MI_CH1 #define MIDI_CHANNEL_MAX MI_CH16 -// Dynamic Macros aliases -#define DM_REC1 QK_DYNAMIC_MACRO_RECORD_START_1 -#define DM_REC2 QK_DYNAMIC_MACRO_RECORD_START_2 -#define DM_RSTP QK_DYNAMIC_MACRO_RECORD_STOP -#define DM_PLY1 QK_DYNAMIC_MACRO_PLAY_1 -#define DM_PLY2 QK_DYNAMIC_MACRO_PLAY_2 - -// Joystick aliases -#define JS_0 QK_JOYSTICK_BUTTON_0 -#define JS_1 QK_JOYSTICK_BUTTON_1 -#define JS_2 QK_JOYSTICK_BUTTON_2 -#define JS_3 QK_JOYSTICK_BUTTON_3 -#define JS_4 QK_JOYSTICK_BUTTON_4 -#define JS_5 QK_JOYSTICK_BUTTON_5 -#define JS_6 QK_JOYSTICK_BUTTON_6 -#define JS_7 QK_JOYSTICK_BUTTON_7 -#define JS_8 QK_JOYSTICK_BUTTON_8 -#define JS_9 QK_JOYSTICK_BUTTON_9 -#define JS_10 QK_JOYSTICK_BUTTON_10 -#define JS_11 QK_JOYSTICK_BUTTON_11 -#define JS_12 QK_JOYSTICK_BUTTON_12 -#define JS_13 QK_JOYSTICK_BUTTON_13 -#define JS_14 QK_JOYSTICK_BUTTON_14 -#define JS_15 QK_JOYSTICK_BUTTON_15 -#define JS_16 QK_JOYSTICK_BUTTON_16 -#define JS_17 QK_JOYSTICK_BUTTON_17 -#define JS_18 QK_JOYSTICK_BUTTON_18 -#define JS_19 QK_JOYSTICK_BUTTON_19 -#define JS_20 QK_JOYSTICK_BUTTON_20 -#define JS_21 QK_JOYSTICK_BUTTON_21 -#define JS_22 QK_JOYSTICK_BUTTON_22 -#define JS_23 QK_JOYSTICK_BUTTON_23 -#define JS_24 QK_JOYSTICK_BUTTON_24 -#define JS_25 QK_JOYSTICK_BUTTON_25 -#define JS_26 QK_JOYSTICK_BUTTON_26 -#define JS_27 QK_JOYSTICK_BUTTON_27 -#define JS_28 QK_JOYSTICK_BUTTON_28 -#define JS_29 QK_JOYSTICK_BUTTON_29 -#define JS_30 QK_JOYSTICK_BUTTON_30 -#define JS_31 QK_JOYSTICK_BUTTON_31 -#define QK_JOYSTICK_BUTTON_MIN QK_JOYSTICK_BUTTON_0 -#define QK_JOYSTICK_BUTTON_MAX QK_JOYSTICK_BUTTON_31 - -// One Shot aliases -#define OS_TOGG QK_ONE_SHOT_TOGGLE -#define OS_ON QK_ONE_SHOT_ON -#define OS_OFF QK_ONE_SHOT_OFF - -// Programmable Button aliases -#define PB_1 QK_PROGRAMMABLE_BUTTON_1 -#define PB_2 QK_PROGRAMMABLE_BUTTON_2 -#define PB_3 QK_PROGRAMMABLE_BUTTON_3 -#define PB_4 QK_PROGRAMMABLE_BUTTON_4 -#define PB_5 QK_PROGRAMMABLE_BUTTON_5 -#define PB_6 QK_PROGRAMMABLE_BUTTON_6 -#define PB_7 QK_PROGRAMMABLE_BUTTON_7 -#define PB_8 QK_PROGRAMMABLE_BUTTON_8 -#define PB_9 QK_PROGRAMMABLE_BUTTON_9 -#define PB_10 QK_PROGRAMMABLE_BUTTON_10 -#define PB_11 QK_PROGRAMMABLE_BUTTON_11 -#define PB_12 QK_PROGRAMMABLE_BUTTON_12 -#define PB_13 QK_PROGRAMMABLE_BUTTON_13 -#define PB_14 QK_PROGRAMMABLE_BUTTON_14 -#define PB_15 QK_PROGRAMMABLE_BUTTON_15 -#define PB_16 QK_PROGRAMMABLE_BUTTON_16 -#define PB_17 QK_PROGRAMMABLE_BUTTON_17 -#define PB_18 QK_PROGRAMMABLE_BUTTON_18 -#define PB_19 QK_PROGRAMMABLE_BUTTON_19 -#define PB_20 QK_PROGRAMMABLE_BUTTON_20 -#define PB_21 QK_PROGRAMMABLE_BUTTON_21 -#define PB_22 QK_PROGRAMMABLE_BUTTON_22 -#define PB_23 QK_PROGRAMMABLE_BUTTON_23 -#define PB_24 QK_PROGRAMMABLE_BUTTON_24 -#define PB_25 QK_PROGRAMMABLE_BUTTON_25 -#define PB_26 QK_PROGRAMMABLE_BUTTON_26 -#define PB_27 QK_PROGRAMMABLE_BUTTON_27 -#define PB_28 QK_PROGRAMMABLE_BUTTON_28 -#define PB_29 QK_PROGRAMMABLE_BUTTON_29 -#define PB_30 QK_PROGRAMMABLE_BUTTON_30 -#define PB_31 QK_PROGRAMMABLE_BUTTON_31 -#define PB_32 QK_PROGRAMMABLE_BUTTON_32 -#define QK_PROGRAMMABLE_BUTTON_MIN QK_PROGRAMMABLE_BUTTON_1 -#define QK_PROGRAMMABLE_BUTTON_MAX QK_PROGRAMMABLE_BUTTON_32 +// TODO: somehow migrate sequencer to DD? +#include "sequencer.h" + +#define SEQUENCER_STEP_MIN (QK_SEQUENCER + 0xF) +#define SEQUENCER_STEP_MAX (SEQUENCER_STEP_MIN + SEQUENCER_STEPS) + +#define SEQUENCER_RESOLUTION_MIN (SEQUENCER_STEP_MAX + 1) +#define SEQUENCER_RESOLUTION_MAX (SEQUENCER_RESOLUTION_MIN + SEQUENCER_RESOLUTIONS) + +#define SEQUENCER_TRACK_MIN (SEQUENCER_RESOLUTION_MAX + 1) +#define SEQUENCER_TRACK_MAX (SEQUENCER_TRACK_MIN + SEQUENCER_TRACKS) + +#define SQ_S(n) (n < SEQUENCER_STEPS ? SEQUENCER_STEP_MIN + n : KC_NO) +#define SQ_R(n) (n < SEQUENCER_RESOLUTIONS ? SEQUENCER_RESOLUTION_MIN + n : KC_NO) +#define SQ_T(n) (n < SEQUENCER_TRACKS ? SEQUENCER_TRACK_MIN + n : KC_NO) #include "quantum_keycodes_legacy.h" diff --git a/quantum/send_string/send_string_keycodes.h b/quantum/send_string/send_string_keycodes.h index f9e1c101ff..54b8382053 100644 --- a/quantum/send_string/send_string_keycodes.h +++ b/quantum/send_string/send_string_keycodes.h @@ -389,48 +389,25 @@ #define X_ASSISTANT c0 /* Mouse Buttons (unallocated range in HID spec) */ -#ifdef VIA_ENABLE -#define X_MS_UP f0 -#define X_MS_DOWN f1 -#define X_MS_LEFT f2 -#define X_MS_RIGHT f3 -#define X_MS_BTN1 f4 -#define X_MS_BTN2 f5 -#define X_MS_BTN3 f6 -#define X_MS_BTN4 f7 -#define X_MS_BTN5 f8 -#define X_MS_BTN6 f8 -#define X_MS_BTN7 f8 -#define X_MS_BTN8 f8 -#define X_MS_WH_UP f9 -#define X_MS_WH_DOWN fa -#define X_MS_WH_LEFT fb -#define X_MS_WH_RIGHT fc -#define X_MS_ACCEL0 fd -#define X_MS_ACCEL1 fe -#define X_MS_ACCEL2 ff -#else -#define X_MS_UP cd -#define X_MS_DOWN ce -#define X_MS_LEFT cf -#define X_MS_RIGHT d0 -#define X_MS_BTN1 d1 -#define X_MS_BTN2 d2 -#define X_MS_BTN3 d3 -#define X_MS_BTN4 d4 -#define X_MS_BTN5 d5 -#define X_MS_BTN6 d6 -#define X_MS_BTN7 d7 -#define X_MS_BTN8 d8 -#define X_MS_WH_UP d9 -#define X_MS_WH_DOWN da -#define X_MS_WH_LEFT db -#define X_MS_WH_RIGHT dc -#define X_MS_ACCEL0 dd -#define X_MS_ACCEL1 de -#define X_MS_ACCEL2 df -#endif - +#define X_MS_UP cd +#define X_MS_DOWN ce +#define X_MS_LEFT cf +#define X_MS_RIGHT d0 +#define X_MS_BTN1 d1 +#define X_MS_BTN2 d2 +#define X_MS_BTN3 d3 +#define X_MS_BTN4 d4 +#define X_MS_BTN5 d5 +#define X_MS_BTN6 d6 +#define X_MS_BTN7 d7 +#define X_MS_BTN8 d8 +#define X_MS_WH_UP d9 +#define X_MS_WH_DOWN da +#define X_MS_WH_LEFT db +#define X_MS_WH_RIGHT dc +#define X_MS_ACCEL0 dd +#define X_MS_ACCEL1 de +#define X_MS_ACCEL2 df // Send string macros #define STRINGIZE(z) #z diff --git a/quantum/via.c b/quantum/via.c index 37e2046a10..5afbee5a30 100644 --- a/quantum/via.c +++ b/quantum/via.c @@ -50,7 +50,6 @@ #include "dynamic_keymap.h" #include "eeprom.h" #include "version.h" // for QMK_BUILDDATE used in EEPROM magic -#include "via_ensure_keycode.h" // Forward declare some helpers. #if defined(VIA_QMK_BACKLIGHT_ENABLE) diff --git a/quantum/via.h b/quantum/via.h index 558ae95de4..84b264903f 100644 --- a/quantum/via.h +++ b/quantum/via.h @@ -58,7 +58,7 @@ // This is changed only when the command IDs change, // so VIA Configurator can detect compatible firmware. -#define VIA_PROTOCOL_VERSION 0x000A +#define VIA_PROTOCOL_VERSION 0x000B enum via_command_id { id_get_protocol_version = 0x01, // always 0x01 @@ -103,13 +103,8 @@ enum via_lighting_value { id_qmk_rgblight_color = 0x83, }; -// Can't use SAFE_RANGE here, it might change if someone adds -// new values to enum quantum_keycodes. -// Need to keep checking 0x5F10 is still in the safe range. -// TODO: merge this into quantum_keycodes -// Backlight keycodes are in range 0x5F00-0x5F0F enum via_keycodes { - FN_MO13 = 0x5F10, + FN_MO13 = QK_MACRO, FN_MO23, MACRO00, MACRO01, @@ -130,7 +125,7 @@ enum via_keycodes { }; enum user_keycodes { - USER00 = 0x5F80, + USER00 = QK_USER, USER01, USER02, USER03, diff --git a/quantum/via_ensure_keycode.h b/quantum/via_ensure_keycode.h deleted file mode 100644 index 48e611d0fa..0000000000 --- a/quantum/via_ensure_keycode.h +++ /dev/null @@ -1,344 +0,0 @@ -#pragma once - -#include "quantum.h" -#include "via.h" - -#ifndef VIA_HAS_BROKEN_KEYCODES - -// clang-format off - -_Static_assert(KC_NO == 0x0000, ""); -_Static_assert(KC_TRANSPARENT == 0x0001, ""); - -_Static_assert(KC_A == 0x0004, ""); -_Static_assert(KC_B == 0x0005, ""); -_Static_assert(KC_C == 0x0006, ""); -_Static_assert(KC_D == 0x0007, ""); -_Static_assert(KC_E == 0x0008, ""); -_Static_assert(KC_F == 0x0009, ""); -_Static_assert(KC_G == 0x000A, ""); -_Static_assert(KC_H == 0x000B, ""); -_Static_assert(KC_I == 0x000C, ""); -_Static_assert(KC_J == 0x000D, ""); -_Static_assert(KC_K == 0x000E, ""); -_Static_assert(KC_L == 0x000F, ""); -_Static_assert(KC_M == 0x0010, ""); -_Static_assert(KC_N == 0x0011, ""); -_Static_assert(KC_O == 0x0012, ""); -_Static_assert(KC_P == 0x0013, ""); -_Static_assert(KC_Q == 0x0014, ""); -_Static_assert(KC_R == 0x0015, ""); -_Static_assert(KC_S == 0x0016, ""); -_Static_assert(KC_T == 0x0017, ""); -_Static_assert(KC_U == 0x0018, ""); -_Static_assert(KC_V == 0x0019, ""); -_Static_assert(KC_W == 0x001A, ""); -_Static_assert(KC_X == 0x001B, ""); -_Static_assert(KC_Y == 0x001C, ""); -_Static_assert(KC_Z == 0x001D, ""); -_Static_assert(KC_1 == 0x001E, ""); -_Static_assert(KC_2 == 0x001F, ""); -_Static_assert(KC_3 == 0x0020, ""); -_Static_assert(KC_4 == 0x0021, ""); -_Static_assert(KC_5 == 0x0022, ""); -_Static_assert(KC_6 == 0x0023, ""); -_Static_assert(KC_7 == 0x0024, ""); -_Static_assert(KC_8 == 0x0025, ""); -_Static_assert(KC_9 == 0x0026, ""); -_Static_assert(KC_0 == 0x0027, ""); -_Static_assert(KC_ENTER == 0x0028, ""); -_Static_assert(KC_ESCAPE == 0x0029, ""); -_Static_assert(KC_BACKSPACE == 0x002A, ""); -_Static_assert(KC_TAB == 0x002B, ""); -_Static_assert(KC_SPACE == 0x002C, ""); -_Static_assert(KC_MINUS == 0x002D, ""); -_Static_assert(KC_EQUAL == 0x002E, ""); -_Static_assert(KC_LEFT_BRACKET == 0x002F, ""); -_Static_assert(KC_RIGHT_BRACKET == 0x0030, ""); -_Static_assert(KC_BACKSLASH == 0x0031, ""); -_Static_assert(KC_NONUS_HASH == 0x0032, ""); -_Static_assert(KC_SEMICOLON == 0x0033, ""); -_Static_assert(KC_QUOTE == 0x0034, ""); -_Static_assert(KC_GRAVE == 0x0035, ""); -_Static_assert(KC_COMMA == 0x0036, ""); -_Static_assert(KC_DOT == 0x0037, ""); -_Static_assert(KC_SLASH == 0x0038, ""); -_Static_assert(KC_CAPS_LOCK == 0x0039, ""); -_Static_assert(KC_F1 == 0x003A, ""); -_Static_assert(KC_F2 == 0x003B, ""); -_Static_assert(KC_F3 == 0x003C, ""); -_Static_assert(KC_F4 == 0x003D, ""); -_Static_assert(KC_F5 == 0x003E, ""); -_Static_assert(KC_F6 == 0x003F, ""); -_Static_assert(KC_F7 == 0x0040, ""); -_Static_assert(KC_F8 == 0x0041, ""); -_Static_assert(KC_F9 == 0x0042, ""); -_Static_assert(KC_F10 == 0x0043, ""); -_Static_assert(KC_F11 == 0x0044, ""); -_Static_assert(KC_F12 == 0x0045, ""); -_Static_assert(KC_PRINT_SCREEN == 0x0046, ""); -_Static_assert(KC_SCROLL_LOCK == 0x0047, ""); -_Static_assert(KC_PAUSE == 0x0048, ""); -_Static_assert(KC_INSERT == 0x0049, ""); -_Static_assert(KC_HOME == 0x004A, ""); -_Static_assert(KC_PAGE_UP == 0x004B, ""); -_Static_assert(KC_DELETE == 0x004C, ""); -_Static_assert(KC_END == 0x004D, ""); -_Static_assert(KC_PAGE_DOWN == 0x004E, ""); -_Static_assert(KC_RIGHT == 0x004F, ""); -_Static_assert(KC_LEFT == 0x0050, ""); -_Static_assert(KC_DOWN == 0x0051, ""); -_Static_assert(KC_UP == 0x0052, ""); -_Static_assert(KC_NUM_LOCK == 0x0053, ""); -_Static_assert(KC_KP_SLASH == 0x0054, ""); -_Static_assert(KC_KP_ASTERISK == 0x0055, ""); -_Static_assert(KC_KP_MINUS == 0x0056, ""); -_Static_assert(KC_KP_PLUS == 0x0057, ""); -_Static_assert(KC_KP_ENTER == 0x0058, ""); -_Static_assert(KC_KP_1 == 0x0059, ""); -_Static_assert(KC_KP_2 == 0x005A, ""); -_Static_assert(KC_KP_3 == 0x005B, ""); -_Static_assert(KC_KP_4 == 0x005C, ""); -_Static_assert(KC_KP_5 == 0x005D, ""); -_Static_assert(KC_KP_6 == 0x005E, ""); -_Static_assert(KC_KP_7 == 0x005F, ""); -_Static_assert(KC_KP_8 == 0x0060, ""); -_Static_assert(KC_KP_9 == 0x0061, ""); -_Static_assert(KC_KP_0 == 0x0062, ""); -_Static_assert(KC_KP_DOT == 0x0063, ""); -_Static_assert(KC_NONUS_BACKSLASH == 0x0064, ""); -_Static_assert(KC_APPLICATION == 0x0065, ""); -_Static_assert(KC_KB_POWER == 0x0066, ""); -_Static_assert(KC_KP_EQUAL == 0x0067, ""); -_Static_assert(KC_F13 == 0x0068, ""); -_Static_assert(KC_F14 == 0x0069, ""); -_Static_assert(KC_F15 == 0x006A, ""); -_Static_assert(KC_F16 == 0x006B, ""); -_Static_assert(KC_F17 == 0x006C, ""); -_Static_assert(KC_F18 == 0x006D, ""); -_Static_assert(KC_F19 == 0x006E, ""); -_Static_assert(KC_F20 == 0x006F, ""); -_Static_assert(KC_F21 == 0x0070, ""); -_Static_assert(KC_F22 == 0x0071, ""); -_Static_assert(KC_F23 == 0x0072, ""); -_Static_assert(KC_F24 == 0x0073, ""); -_Static_assert(KC_EXECUTE == 0x0074, ""); -_Static_assert(KC_HELP == 0x0075, ""); -_Static_assert(KC_MENU == 0x0076, ""); -_Static_assert(KC_SELECT == 0x0077, ""); -_Static_assert(KC_STOP == 0x0078, ""); -_Static_assert(KC_AGAIN == 0x0079, ""); -_Static_assert(KC_UNDO == 0x007A, ""); -_Static_assert(KC_CUT == 0x007B, ""); -_Static_assert(KC_COPY == 0x007C, ""); -_Static_assert(KC_PASTE == 0x007D, ""); -_Static_assert(KC_FIND == 0x007E, ""); - -_Static_assert(KC_LOCKING_CAPS_LOCK == 0x0082, ""); -_Static_assert(KC_LOCKING_NUM_LOCK == 0x0083, ""); -_Static_assert(KC_LOCKING_SCROLL_LOCK == 0x0084, ""); -_Static_assert(KC_KP_COMMA == 0x0085, ""); -_Static_assert(KC_KP_EQUAL_AS400 == 0x0086, ""); -_Static_assert(KC_INTERNATIONAL_1 == 0x0087, ""); -_Static_assert(KC_INTERNATIONAL_2 == 0x0088, ""); -_Static_assert(KC_INTERNATIONAL_3 == 0x0089, ""); -_Static_assert(KC_INTERNATIONAL_4 == 0x008A, ""); -_Static_assert(KC_INTERNATIONAL_5 == 0x008B, ""); -_Static_assert(KC_INTERNATIONAL_6 == 0x008C, ""); -_Static_assert(KC_INTERNATIONAL_7 == 0x008D, ""); -_Static_assert(KC_INTERNATIONAL_8 == 0x008E, ""); -_Static_assert(KC_INTERNATIONAL_9 == 0x008F, ""); -_Static_assert(KC_LANGUAGE_1 == 0x0090, ""); -_Static_assert(KC_LANGUAGE_2 == 0x0091, ""); -_Static_assert(KC_LANGUAGE_3 == 0x0092, ""); -_Static_assert(KC_LANGUAGE_4 == 0x0093, ""); -_Static_assert(KC_LANGUAGE_5 == 0x0094, ""); -_Static_assert(KC_LANGUAGE_6 == 0x0095, ""); -_Static_assert(KC_LANGUAGE_7 == 0x0096, ""); -_Static_assert(KC_LANGUAGE_8 == 0x0097, ""); -_Static_assert(KC_LANGUAGE_9 == 0x0098, ""); -_Static_assert(KC_ALTERNATE_ERASE == 0x0099, ""); -_Static_assert(KC_SYSTEM_REQUEST == 0x009A, ""); -_Static_assert(KC_CANCEL == 0x009B, ""); -_Static_assert(KC_CLEAR == 0x009C, ""); -_Static_assert(KC_PRIOR == 0x009D, ""); - -_Static_assert(KC_OUT == 0x00A0, ""); -_Static_assert(KC_OPER == 0x00A1, ""); -_Static_assert(KC_CLEAR_AGAIN == 0x00A2, ""); -_Static_assert(KC_CRSEL == 0x00A3, ""); -_Static_assert(KC_EXSEL == 0x00A4, ""); - -_Static_assert(KC_PWR == 0x00A5, ""); -_Static_assert(KC_SLEP == 0x00A6, ""); -_Static_assert(KC_WAKE == 0x00A7, ""); -_Static_assert(KC_MUTE == 0x00A8, ""); -_Static_assert(KC_VOLU == 0x00A9, ""); -_Static_assert(KC_VOLD == 0x00AA, ""); -_Static_assert(KC_MNXT == 0x00AB, ""); -_Static_assert(KC_MPRV == 0x00AC, ""); -_Static_assert(KC_MSTP == 0x00AD, ""); -_Static_assert(KC_MPLY == 0x00AE, ""); -_Static_assert(KC_MSEL == 0x00AF, ""); -_Static_assert(KC_EJCT == 0x00B0, ""); -_Static_assert(KC_MAIL == 0x00B1, ""); -_Static_assert(KC_CALC == 0x00B2, ""); -_Static_assert(KC_MYCM == 0x00B3, ""); -_Static_assert(KC_WSCH == 0x00B4, ""); -_Static_assert(KC_WHOM == 0x00B5, ""); -_Static_assert(KC_WBAK == 0x00B6, ""); -_Static_assert(KC_WFWD == 0x00B7, ""); -_Static_assert(KC_WSTP == 0x00B8, ""); -_Static_assert(KC_WREF == 0x00B9, ""); -_Static_assert(KC_WFAV == 0x00BA, ""); -_Static_assert(KC_MFFD == 0x00BB, ""); -_Static_assert(KC_MRWD == 0x00BC, ""); -_Static_assert(KC_BRIU == 0x00BD, ""); -_Static_assert(KC_BRID == 0x00BE, ""); -_Static_assert(KC_CPNL == 0x00BF, ""); -_Static_assert(KC_ASST == 0x00C0, ""); - -_Static_assert(KC_LEFT_CTRL == 0x00E0, ""); -_Static_assert(KC_LEFT_SHIFT == 0x00E1, ""); -_Static_assert(KC_LEFT_ALT == 0x00E2, ""); -_Static_assert(KC_LEFT_GUI == 0x00E3, ""); -_Static_assert(KC_RIGHT_CTRL == 0x00E4, ""); -_Static_assert(KC_RIGHT_SHIFT == 0x00E5, ""); -_Static_assert(KC_RIGHT_ALT == 0x00E6, ""); -_Static_assert(KC_RIGHT_GUI == 0x00E7, ""); - -_Static_assert(KC_MS_U == 0x00F0, ""); -_Static_assert(KC_MS_D == 0x00F1, ""); -_Static_assert(KC_MS_L == 0x00F2, ""); -_Static_assert(KC_MS_R == 0x00F3, ""); -_Static_assert(KC_BTN1 == 0x00F4, ""); -_Static_assert(KC_BTN2 == 0x00F5, ""); -_Static_assert(KC_BTN3 == 0x00F6, ""); -_Static_assert(KC_BTN4 == 0x00F7, ""); -_Static_assert(KC_BTN5 == 0x00F8, ""); -_Static_assert(KC_WH_U == 0x00F9, ""); -_Static_assert(KC_WH_D == 0x00FA, ""); -_Static_assert(KC_WH_L == 0x00FB, ""); -_Static_assert(KC_WH_R == 0x00FC, ""); -_Static_assert(KC_ACL0 == 0x00FD, ""); -_Static_assert(KC_ACL1 == 0x00FE, ""); -_Static_assert(KC_ACL2 == 0x00FF, ""); - -_Static_assert(KC_EXLM == 0x021E, ""); -_Static_assert(KC_AT == 0x021F, ""); -_Static_assert(KC_HASH == 0x0220, ""); -_Static_assert(KC_DLR == 0x0221, ""); -_Static_assert(KC_PERC == 0x0222, ""); -_Static_assert(KC_CIRC == 0x0223, ""); -_Static_assert(KC_AMPR == 0x0224, ""); -_Static_assert(KC_ASTR == 0x0225, ""); -_Static_assert(KC_LPRN == 0x0226, ""); -_Static_assert(KC_RPRN == 0x0227, ""); -_Static_assert(KC_UNDS == 0x022D, ""); -_Static_assert(KC_PLUS == 0x022E, ""); -_Static_assert(KC_LCBR == 0x022F, ""); -_Static_assert(KC_RCBR == 0x0230, ""); -_Static_assert(KC_PIPE == 0x0231, ""); -_Static_assert(KC_COLN == 0x0233, ""); -_Static_assert(KC_DQUO == 0x0234, ""); -_Static_assert(KC_TILD == 0x0235, ""); -_Static_assert(KC_LT == 0x0236, ""); -_Static_assert(KC_GT == 0x0237, ""); -_Static_assert(KC_QUES == 0x0238, ""); - -_Static_assert(QK_BOOTLOADER == 0x5C00, ""); -_Static_assert(QK_DEBUG_TOGGLE == 0x5C01, ""); - -_Static_assert(MAGIC_TOGGLE_NKRO == 0x5C14, ""); - -_Static_assert(QK_GRAVE_ESCAPE == 0x5C16, ""); - -_Static_assert(AU_ON == 0x5C1D, ""); -_Static_assert(AU_OFF == 0x5C1E, ""); -_Static_assert(AU_TOG == 0x5C1F, ""); - -_Static_assert(CLICKY_TOGGLE == 0x5C20, ""); -_Static_assert(CLICKY_ENABLE == 0x5C21, ""); -_Static_assert(CLICKY_DISABLE == 0x5C22, ""); -_Static_assert(CLICKY_UP == 0x5C23, ""); -_Static_assert(CLICKY_DOWN == 0x5C24, ""); -_Static_assert(CLICKY_RESET == 0x5C25, ""); -_Static_assert(MU_ON == 0x5C26, ""); -_Static_assert(MU_OFF == 0x5C27, ""); -_Static_assert(MU_TOG == 0x5C28, ""); -_Static_assert(MU_MOD == 0x5C29, ""); - -_Static_assert(BL_ON == 0x5CBB, ""); -_Static_assert(BL_OFF == 0x5CBC, ""); -_Static_assert(BL_DEC == 0x5CBD, ""); -_Static_assert(BL_INC == 0x5CBE, ""); -_Static_assert(BL_TOGG == 0x5CBF, ""); -_Static_assert(BL_STEP == 0x5CC0, ""); -_Static_assert(BL_BRTG == 0x5CC1, ""); -_Static_assert(RGB_TOG == 0x5CC2, ""); -_Static_assert(RGB_MOD == 0x5CC3, ""); -_Static_assert(RGB_RMOD == 0x5CC4, ""); -_Static_assert(RGB_HUI == 0x5CC5, ""); -_Static_assert(RGB_HUD == 0x5CC6, ""); -_Static_assert(RGB_SAI == 0x5CC7, ""); -_Static_assert(RGB_SAD == 0x5CC8, ""); -_Static_assert(RGB_VAI == 0x5CC9, ""); -_Static_assert(RGB_VAD == 0x5CCA, ""); -_Static_assert(RGB_SPI == 0x5CCB, ""); -_Static_assert(RGB_SPD == 0x5CCC, ""); -_Static_assert(RGB_M_P == 0x5CCD, ""); -_Static_assert(RGB_M_B == 0x5CCE, ""); -_Static_assert(RGB_M_R == 0x5CCF, ""); -_Static_assert(RGB_M_SW == 0x5CD0, ""); -_Static_assert(RGB_M_SN == 0x5CD1, ""); -_Static_assert(RGB_M_K == 0x5CD2, ""); -_Static_assert(RGB_M_X == 0x5CD3, ""); -_Static_assert(RGB_M_G == 0x5CD4, ""); -_Static_assert(RGB_M_T == 0x5CD5, ""); - -_Static_assert(SC_LSPO == 0x5CD7, ""); -_Static_assert(SC_RSPC == 0x5CD8, ""); -_Static_assert(SC_SENT == 0x5CD9, ""); - -_Static_assert(SC_LCPO == 0x5CF3, ""); -_Static_assert(SC_RCPC == 0x5CF4, ""); -_Static_assert(SC_LAPO == 0x5CF5, ""); -_Static_assert(SC_RAPC == 0x5CF6, ""); - -_Static_assert(FN_MO13 == 0x5F10, ""); -_Static_assert(FN_MO23 == 0x5F11, ""); -_Static_assert(MACRO00 == 0x5F12, ""); -_Static_assert(MACRO01 == 0x5F13, ""); -_Static_assert(MACRO02 == 0x5F14, ""); -_Static_assert(MACRO03 == 0x5F15, ""); -_Static_assert(MACRO04 == 0x5F16, ""); -_Static_assert(MACRO05 == 0x5F17, ""); -_Static_assert(MACRO06 == 0x5F18, ""); -_Static_assert(MACRO07 == 0x5F19, ""); -_Static_assert(MACRO08 == 0x5F1A, ""); -_Static_assert(MACRO09 == 0x5F1B, ""); -_Static_assert(MACRO10 == 0x5F1C, ""); -_Static_assert(MACRO11 == 0x5F1D, ""); -_Static_assert(MACRO12 == 0x5F1E, ""); -_Static_assert(MACRO13 == 0x5F1F, ""); -_Static_assert(MACRO14 == 0x5F20, ""); -_Static_assert(MACRO15 == 0x5F21, ""); - -_Static_assert(USER00 == 0x5F80, ""); -_Static_assert(USER01 == 0x5F81, ""); -_Static_assert(USER02 == 0x5F82, ""); -_Static_assert(USER03 == 0x5F83, ""); -_Static_assert(USER04 == 0x5F84, ""); -_Static_assert(USER05 == 0x5F85, ""); -_Static_assert(USER06 == 0x5F86, ""); -_Static_assert(USER07 == 0x5F87, ""); -_Static_assert(USER08 == 0x5F88, ""); -_Static_assert(USER09 == 0x5F89, ""); -_Static_assert(USER10 == 0x5F8A, ""); -_Static_assert(USER11 == 0x5F8B, ""); -_Static_assert(USER12 == 0x5F8C, ""); -_Static_assert(USER13 == 0x5F8D, ""); -_Static_assert(USER14 == 0x5F8E, ""); -_Static_assert(USER15 == 0x5F8F, ""); - -#endif -- cgit v1.2.3 From fe00c8021192c43e27e5a91a5193d7fbe07b9fa8 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 5 Nov 2022 21:45:40 +1100 Subject: Reduce includes for send_string header (#18952) --- quantum/send_string/send_string.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'quantum') diff --git a/quantum/send_string/send_string.c b/quantum/send_string/send_string.c index 818a52f6dc..820fc25163 100644 --- a/quantum/send_string/send_string.c +++ b/quantum/send_string/send_string.c @@ -14,11 +14,15 @@ * along with this program. If not, see . */ -#include +#include "send_string.h" -#include "quantum.h" +#include +#include -#include "send_string.h" +#include "quantum_keycodes.h" +#include "keycode.h" +#include "action.h" +#include "wait.h" #if defined(AUDIO_ENABLE) && defined(SENDSTRING_BELL) # include "audio.h" -- cgit v1.2.3 From 4d33f356a62c195f5498ed2fe8dd3ea434d5a689 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Sat, 5 Nov 2022 23:22:11 +1100 Subject: Macro keycode name refactoring (#18958) --- quantum/keycodes.h | 99 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 65 insertions(+), 34 deletions(-) (limited to 'quantum') diff --git a/quantum/keycodes.h b/quantum/keycodes.h index 6772bb6a4a..e3c9321d16 100644 --- a/quantum/keycodes.h +++ b/quantum/keycodes.h @@ -582,38 +582,38 @@ enum qk_keycode_defines { QK_STENO_GEMINI = 0x74F1, QK_STENO_COMB = 0x74F2, QK_STENO_COMB_MAX = 0x74FC, - MACRO_0 = 0x7700, - MACRO_1 = 0x7701, - MACRO_2 = 0x7702, - MACRO_3 = 0x7703, - MACRO_4 = 0x7704, - MACRO_5 = 0x7705, - MACRO_6 = 0x7706, - MACRO_7 = 0x7707, - MACRO_8 = 0x7708, - MACRO_9 = 0x7709, - MACRO_10 = 0x770A, - MACRO_11 = 0x770B, - MACRO_12 = 0x770C, - MACRO_13 = 0x770D, - MACRO_14 = 0x770E, - MACRO_15 = 0x770F, - MACRO_16 = 0x7710, - MACRO_17 = 0x7711, - MACRO_18 = 0x7712, - MACRO_19 = 0x7713, - MACRO_20 = 0x7714, - MACRO_21 = 0x7715, - MACRO_22 = 0x7716, - MACRO_23 = 0x7717, - MACRO_24 = 0x7718, - MACRO_25 = 0x7719, - MACRO_26 = 0x771A, - MACRO_27 = 0x771B, - MACRO_28 = 0x771C, - MACRO_29 = 0x771D, - MACRO_30 = 0x771E, - MACRO_31 = 0x771F, + QK_MACRO_0 = 0x7700, + QK_MACRO_1 = 0x7701, + QK_MACRO_2 = 0x7702, + QK_MACRO_3 = 0x7703, + QK_MACRO_4 = 0x7704, + QK_MACRO_5 = 0x7705, + QK_MACRO_6 = 0x7706, + QK_MACRO_7 = 0x7707, + QK_MACRO_8 = 0x7708, + QK_MACRO_9 = 0x7709, + QK_MACRO_10 = 0x770A, + QK_MACRO_11 = 0x770B, + QK_MACRO_12 = 0x770C, + QK_MACRO_13 = 0x770D, + QK_MACRO_14 = 0x770E, + QK_MACRO_15 = 0x770F, + QK_MACRO_16 = 0x7710, + QK_MACRO_17 = 0x7711, + QK_MACRO_18 = 0x7712, + QK_MACRO_19 = 0x7713, + QK_MACRO_20 = 0x7714, + QK_MACRO_21 = 0x7715, + QK_MACRO_22 = 0x7716, + QK_MACRO_23 = 0x7717, + QK_MACRO_24 = 0x7718, + QK_MACRO_25 = 0x7719, + QK_MACRO_26 = 0x771A, + QK_MACRO_27 = 0x771B, + QK_MACRO_28 = 0x771C, + QK_MACRO_29 = 0x771D, + QK_MACRO_30 = 0x771E, + QK_MACRO_31 = 0x771F, BL_ON = 0x7800, BL_OFF = 0x7801, BL_DEC = 0x7802, @@ -1000,6 +1000,38 @@ enum qk_keycode_defines { CK_UP = CLICKY_UP, CK_DOWN = CLICKY_DOWN, CK_RST = CLICKY_RESET, + MC_0 = QK_MACRO_0, + MC_1 = QK_MACRO_1, + MC_2 = QK_MACRO_2, + MC_3 = QK_MACRO_3, + MC_4 = QK_MACRO_4, + MC_5 = QK_MACRO_5, + MC_6 = QK_MACRO_6, + MC_7 = QK_MACRO_7, + MC_8 = QK_MACRO_8, + MC_9 = QK_MACRO_9, + MC_10 = QK_MACRO_10, + MC_11 = QK_MACRO_11, + MC_12 = QK_MACRO_12, + MC_13 = QK_MACRO_13, + MC_14 = QK_MACRO_14, + MC_15 = QK_MACRO_15, + MC_16 = QK_MACRO_16, + MC_17 = QK_MACRO_17, + MC_18 = QK_MACRO_18, + MC_19 = QK_MACRO_19, + MC_20 = QK_MACRO_20, + MC_21 = QK_MACRO_21, + MC_22 = QK_MACRO_22, + MC_23 = QK_MACRO_23, + MC_24 = QK_MACRO_24, + MC_25 = QK_MACRO_25, + MC_26 = QK_MACRO_26, + MC_27 = QK_MACRO_27, + MC_28 = QK_MACRO_28, + MC_29 = QK_MACRO_29, + MC_30 = QK_MACRO_30, + MC_31 = QK_MACRO_31, RGB_MOD = RGB_MODE_FORWARD, RGB_RMOD = RGB_MODE_REVERSE, RGB_M_P = RGB_MODE_PLAIN, @@ -1108,8 +1140,7 @@ enum qk_keycode_defines { #define IS_PROGRAMMABLE_BUTTON_KEYCODE(code) ((code) >= QK_PROGRAMMABLE_BUTTON_1 && (code) <= QK_PROGRAMMABLE_BUTTON_32) #define IS_AUDIO_KEYCODE(code) ((code) >= AU_ON && (code) <= MUV_DE) #define IS_STENO_KEYCODE(code) ((code) >= QK_STENO_BOLT && (code) <= QK_STENO_COMB_MAX) -#define IS_MACRO_KEYCODE(code) ((code) >= MACRO_0 && (code) <= MACRO_31) +#define IS_MACRO_KEYCODE(code) ((code) >= QK_MACRO_0 && (code) <= QK_MACRO_31) #define IS_BACKLIGHT_KEYCODE(code) ((code) >= BL_ON && (code) <= BL_BRTG) #define IS_RGB_KEYCODE(code) ((code) >= RGB_TOG && (code) <= RGB_MODE_TWINKLE) #define IS_QUANTUM_KEYCODE(code) ((code) >= QK_BOOTLOADER && (code) <= QK_AUTOCORRECT_TOGGLE) - -- cgit v1.2.3 From 5233c69bc60aa612709e5d74a005431594612b6e Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Sun, 6 Nov 2022 00:15:55 +1100 Subject: Remove thermal printer. (#18959) --- quantum/keycodes.h | 10 +- quantum/process_keycode/process_printer.c | 269 -------------------------- quantum/process_keycode/process_printer.h | 21 --- quantum/process_keycode/process_printer_bb.c | 270 --------------------------- quantum/quantum.c | 3 - quantum/quantum.h | 4 - 6 files changed, 4 insertions(+), 573 deletions(-) delete mode 100644 quantum/process_keycode/process_printer.c delete mode 100644 quantum/process_keycode/process_printer.h delete mode 100644 quantum/process_keycode/process_printer_bb.c (limited to 'quantum') diff --git a/quantum/keycodes.h b/quantum/keycodes.h index e3c9321d16..c27a5a732c 100644 --- a/quantum/keycodes.h +++ b/quantum/keycodes.h @@ -709,12 +709,10 @@ enum qk_keycode_defines { DT_PRNT = 0x7C70, DT_UP = 0x7C71, DT_DOWN = 0x7C72, - PRINT_ON = 0x7C73, - PRINT_OFF = 0x7C74, - QK_CAPS_WORD_TOGGLE = 0x7C75, - QK_AUTOCORRECT_ON = 0x7C76, - QK_AUTOCORRECT_OFF = 0x7C77, - QK_AUTOCORRECT_TOGGLE = 0x7C78, + QK_CAPS_WORD_TOGGLE = 0x7C73, + QK_AUTOCORRECT_ON = 0x7C74, + QK_AUTOCORRECT_OFF = 0x7C75, + QK_AUTOCORRECT_TOGGLE = 0x7C76, SAFE_RANGE = 0x7E00, // Alias diff --git a/quantum/process_keycode/process_printer.c b/quantum/process_keycode/process_printer.c deleted file mode 100644 index 6dd1f28c9b..0000000000 --- a/quantum/process_keycode/process_printer.c +++ /dev/null @@ -1,269 +0,0 @@ -/* Copyright 2016 Jack Humbert - * - * 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 . - */ - -#include "process_printer.h" -#include "action_util.h" -#include "uart.h" - -bool printing_enabled = false; -uint8_t character_shift = 0; - -void enable_printing(void) { - printing_enabled = true; - uart_init(19200); -} - -void disable_printing(void) { - printing_enabled = false; -} - -uint8_t shifted_numbers[10] = {0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29}; - -// uint8_t keycode_to_ascii[0xFF][2]; - -// keycode_to_ascii[KC_MINUS] = {0x2D, 0x5F}; - -void print_char(char c) { - USB_Disable(); - uart_write(c); - USB_Init(); -} - -void print_string(char c[]) { - for (uint8_t i = 0; i < strlen(c); i++) - print_char(c[i]); -} - -void print_box_string(const char text[]) { - size_t len = strlen(text); - char out[len * 3 + 8]; - out[0] = 0xDA; - for (uint8_t i = 0; i < len; i++) { - out[i + 1] = 0xC4; - } - out[len + 1] = 0xBF; - out[len + 2] = '\n'; - - out[len + 3] = 0xB3; - for (uint8_t i = 0; i < len; i++) { - out[len + 4 + i] = text[i]; - } - out[len * 2 + 4] = 0xB3; - out[len * 2 + 5] = '\n'; - - out[len * 2 + 6] = 0xC0; - for (uint8_t i = 0; i < len; i++) { - out[len * 2 + 7 + i] = 0xC4; - } - out[len * 3 + 7] = 0xD9; - out[len * 3 + 8] = '\n'; - - print_string(out); -} - -bool process_printer(uint16_t keycode, keyrecord_t *record) { - if (keycode == PRINT_ON) { - enable_printing(); - return false; - } - if (keycode == PRINT_OFF) { - disable_printing(); - return false; - } - - if (printing_enabled) { - switch (keycode) { - case KC_EXLM ... KC_RPRN: - case KC_UNDS: - case KC_PLUS: - case KC_LCBR: - case KC_RCBR: - case KC_PIPE: - case KC_TILD: - keycode &= 0xFF; - case KC_LEFT_SHIFT: - case KC_RIGHT_SHIFT: - if (record->event.pressed) { - character_shift++; - } else { - character_shift--; - } - return false; - break; - } - - switch (keycode) { - case KC_F1: - if (record->event.pressed) { - print_box_string("This is a line of text!"); - } - return false; - case KC_ESCAPE: - if (record->event.pressed) { - print_char(0x1B); - } - return false; - break; - case KC_SPACE: - if (record->event.pressed) { - print_char(0x20); - } - return false; - break; - case KC_A ... KC_Z: - if (record->event.pressed) { - if (character_shift) { - print_char(0x41 + (keycode - KC_A)); - } else { - print_char(0x61 + (keycode - KC_A)); - } - } - return false; - break; - case KC_1 ... KC_0: - if (record->event.pressed) { - if (character_shift) { - print_char(shifted_numbers[keycode - KC_1]); - } else { - print_char(0x30 + ((keycode - KC_1 + 1) % 10)); - } - } - return false; - break; - case KC_ENTER: - if (record->event.pressed) { - if (character_shift) { - print_char(0x0C); - } else { - print_char(0x0A); - } - } - return false; - break; - case KC_BACKSPACE: - if (record->event.pressed) { - if (character_shift) { - print_char(0x18); - } else { - print_char(0x1A); - } - } - return false; - break; - case KC_DOT: - if (record->event.pressed) { - if (character_shift) { - print_char(0x3E); - } else { - print_char(0x2E); - } - } - return false; - break; - case KC_COMMA: - if (record->event.pressed) { - if (character_shift) { - print_char(0x3C); - } else { - print_char(0x2C); - } - } - return false; - break; - case KC_SLASH: - if (record->event.pressed) { - if (character_shift) { - print_char(0x3F); - } else { - print_char(0x2F); - } - } - return false; - break; - case KC_QUOTE: - if (record->event.pressed) { - if (character_shift) { - print_char(0x22); - } else { - print_char(0x27); - } - } - return false; - break; - case KC_GRAVE: - if (record->event.pressed) { - if (character_shift) { - print_char(0x7E); - } else { - print_char(0x60); - } - } - return false; - break; - case KC_MINUS: - if (record->event.pressed) { - if (character_shift) { - print_char(0x5F); - } else { - print_char(0x2D); - } - } - return false; - break; - case KC_EQUAL: - if (record->event.pressed) { - if (character_shift) { - print_char(0x2B); - } else { - print_char(0x3D); - } - } - return false; - break; - case KC_LEFT_BRACKET: - if (record->event.pressed) { - if (character_shift) { - print_char(0x7B); - } else { - print_char(0x5B); - } - } - return false; - break; - case KC_RIGHT_BRACKET: - if (record->event.pressed) { - if (character_shift) { - print_char(0x7D); - } else { - print_char(0x5D); - } - } - return false; - break; - case KC_BACKSLASH: - if (record->event.pressed) { - if (character_shift) { - print_char(0x7C); - } else { - print_char(0x5C); - } - } - return false; - break; - } - } - return true; -} diff --git a/quantum/process_keycode/process_printer.h b/quantum/process_keycode/process_printer.h deleted file mode 100644 index 6f4d09f333..0000000000 --- a/quantum/process_keycode/process_printer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright 2016 Jack Humbert - * - * 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 . - */ - -#pragma once - -#include "quantum.h" - -bool process_printer(uint16_t keycode, keyrecord_t *record); diff --git a/quantum/process_keycode/process_printer_bb.c b/quantum/process_keycode/process_printer_bb.c deleted file mode 100644 index 88a9f33994..0000000000 --- a/quantum/process_keycode/process_printer_bb.c +++ /dev/null @@ -1,270 +0,0 @@ -/* Copyright 2016 Jack Humbert - * - * 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 . - */ - -#include "process_printer.h" -#include "action_util.h" - -bool printing_enabled = false; -uint8_t character_shift = 0; - -#define SERIAL_PIN_DDR DDRD -#define SERIAL_PIN_PORT PORTD -#define SERIAL_PIN_MASK _BV(PD3) -#define SERIAL_DELAY 52 - -inline static void serial_delay(void) { - _delay_us(SERIAL_DELAY); -} - -inline static void serial_high(void) { - SERIAL_PIN_PORT |= SERIAL_PIN_MASK; -} - -inline static void serial_low(void) { - SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK; -} - -inline static void serial_output(void) { - SERIAL_PIN_DDR |= SERIAL_PIN_MASK; -} - -void enable_printing() { - printing_enabled = true; - serial_output(); - serial_high(); -} - -void disable_printing() { - printing_enabled = false; -} - -uint8_t shifted_numbers[10] = {0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29}; - -// uint8_t keycode_to_ascii[0xFF][2]; - -// keycode_to_ascii[KC_MINUS] = {0x2D, 0x5F}; - -void print_char(char c) { - uint8_t b = 8; - serial_output(); - while (b--) { - if (c & (1 << b)) { - serial_high(); - } else { - serial_low(); - } - serial_delay(); - } -} - -void print_string(char c[]) { - for (uint8_t i = 0; i < strlen(c); i++) - print_char(c[i]); -} - -bool process_printer(uint16_t keycode, keyrecord_t *record) { - if (keycode == PRINT_ON) { - enable_printing(); - return false; - } - if (keycode == PRINT_OFF) { - disable_printing(); - return false; - } - - if (printing_enabled) { - switch (keycode) { - case KC_EXLM ... KC_RPRN: - case KC_UNDS: - case KC_PLUS: - case KC_LCBR: - case KC_RCBR: - case KC_PIPE: - case KC_TILD: - keycode &= 0xFF; - case KC_LEFT_SHIFT: - case KC_RIGHT_SHIFT: - if (record->event.pressed) { - character_shift++; - } else { - character_shift--; - } - return false; - break; - } - - switch (keycode) { - case KC_F1: - if (record->event.pressed) { - print_string("This is a line of text!\n\n\n"); - } - return false; - case KC_ESCAPE: - if (record->event.pressed) { - print_char(0x1B); - } - return false; - break; - case KC_SPACE: - if (record->event.pressed) { - print_char(0x20); - } - return false; - break; - case KC_A ... KC_Z: - if (record->event.pressed) { - if (character_shift) { - print_char(0x41 + (keycode - KC_A)); - } else { - print_char(0x61 + (keycode - KC_A)); - } - } - return false; - break; - case KC_1 ... KC_0: - if (record->event.pressed) { - if (character_shift) { - print_char(shifted_numbers[keycode - KC_1]); - } else { - print_char(0x30 + ((keycode - KC_1 + 1) % 10)); - } - } - return false; - break; - case KC_ENTER: - if (record->event.pressed) { - if (character_shift) { - print_char(0x0C); - } else { - print_char(0x0A); - } - } - return false; - break; - case KC_BACKSPACE: - if (record->event.pressed) { - if (character_shift) { - print_char(0x18); - } else { - print_char(0x1A); - } - } - return false; - break; - case KC_DOT: - if (record->event.pressed) { - if (character_shift) { - print_char(0x3E); - } else { - print_char(0x2E); - } - } - return false; - break; - case KC_COMMA: - if (record->event.pressed) { - if (character_shift) { - print_char(0x3C); - } else { - print_char(0x2C); - } - } - return false; - break; - case KC_SLASH: - if (record->event.pressed) { - if (character_shift) { - print_char(0x3F); - } else { - print_char(0x2F); - } - } - return false; - break; - case KC_QUOTE: - if (record->event.pressed) { - if (character_shift) { - print_char(0x22); - } else { - print_char(0x27); - } - } - return false; - break; - case KC_GRAVE: - if (record->event.pressed) { - if (character_shift) { - print_char(0x7E); - } else { - print_char(0x60); - } - } - return false; - break; - case KC_MINUS: - if (record->event.pressed) { - if (character_shift) { - print_char(0x5F); - } else { - print_char(0x2D); - } - } - return false; - break; - case KC_EQUAL: - if (record->event.pressed) { - if (character_shift) { - print_char(0x2B); - } else { - print_char(0x3D); - } - } - return false; - break; - case KC_LEFT_BRACKET: - if (record->event.pressed) { - if (character_shift) { - print_char(0x7B); - } else { - print_char(0x5B); - } - } - return false; - break; - case KC_RIGHT_BRACKET: - if (record->event.pressed) { - if (character_shift) { - print_char(0x7D); - } else { - print_char(0x5D); - } - } - return false; - break; - case KC_BACKSLASH: - if (record->event.pressed) { - if (character_shift) { - print_char(0x7C); - } else { - print_char(0x5C); - } - } - return false; - break; - } - } - return true; -} diff --git a/quantum/quantum.c b/quantum/quantum.c index 2333357be1..c60ec22d8b 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -316,9 +316,6 @@ bool process_record_quantum(keyrecord_t *record) { #ifdef LEADER_ENABLE process_leader(keycode, record) && #endif -#ifdef PRINTING_ENABLE - process_printer(keycode, record) && -#endif #ifdef AUTO_SHIFT_ENABLE process_auto_shift(keycode, record) && #endif diff --git a/quantum/quantum.h b/quantum/quantum.h index 9c1b9952b8..4192b3fb16 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -121,10 +121,6 @@ extern layer_state_t layer_state; # include "process_tap_dance.h" #endif -#ifdef PRINTING_ENABLE -# include "process_printer.h" -#endif - #ifdef AUTO_SHIFT_ENABLE # include "process_auto_shift.h" #endif -- cgit v1.2.3 From fd4c3f46fb31c6b095607706808a58ba068536bf Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Sat, 5 Nov 2022 16:58:30 +0000 Subject: Align dynamic tapping term keycode names (#18963) * Align dynamic tapping term keycode names * regen header --- quantum/keycodes.h | 10 +++++++--- quantum/process_keycode/process_dynamic_tapping_term.c | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'quantum') diff --git a/quantum/keycodes.h b/quantum/keycodes.h index c27a5a732c..2ef94f5d3e 100644 --- a/quantum/keycodes.h +++ b/quantum/keycodes.h @@ -706,9 +706,9 @@ enum qk_keycode_defines { QK_SECURE_UNLOCK = 0x7C61, QK_SECURE_TOGGLE = 0x7C62, QK_SECURE_REQUEST = 0x7C63, - DT_PRNT = 0x7C70, - DT_UP = 0x7C71, - DT_DOWN = 0x7C72, + QK_DYNAMIC_TAPPING_TERM_PRINT = 0x7C70, + QK_DYNAMIC_TAPPING_TERM_UP = 0x7C71, + QK_DYNAMIC_TAPPING_TERM_DOWN = 0x7C72, QK_CAPS_WORD_TOGGLE = 0x7C73, QK_AUTOCORRECT_ON = 0x7C74, QK_AUTOCORRECT_OFF = 0x7C75, @@ -1088,6 +1088,9 @@ enum qk_keycode_defines { SE_UNLK = QK_SECURE_UNLOCK, SE_TOGG = QK_SECURE_TOGGLE, SE_REQ = QK_SECURE_REQUEST, + DT_PRNT = QK_DYNAMIC_TAPPING_TERM_PRINT, + DT_UP = QK_DYNAMIC_TAPPING_TERM_UP, + DT_DOWN = QK_DYNAMIC_TAPPING_TERM_DOWN, CW_TOGG = QK_CAPS_WORD_TOGGLE, AC_ON = QK_AUTOCORRECT_ON, AC_OFF = QK_AUTOCORRECT_OFF, @@ -1142,3 +1145,4 @@ enum qk_keycode_defines { #define IS_BACKLIGHT_KEYCODE(code) ((code) >= BL_ON && (code) <= BL_BRTG) #define IS_RGB_KEYCODE(code) ((code) >= RGB_TOG && (code) <= RGB_MODE_TWINKLE) #define IS_QUANTUM_KEYCODE(code) ((code) >= QK_BOOTLOADER && (code) <= QK_AUTOCORRECT_TOGGLE) + diff --git a/quantum/process_keycode/process_dynamic_tapping_term.c b/quantum/process_keycode/process_dynamic_tapping_term.c index b682f34da6..146b9fccd7 100644 --- a/quantum/process_keycode/process_dynamic_tapping_term.c +++ b/quantum/process_keycode/process_dynamic_tapping_term.c @@ -35,15 +35,15 @@ static void tapping_term_report(void) { bool process_dynamic_tapping_term(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { switch (keycode) { - case DT_PRNT: + case QK_DYNAMIC_TAPPING_TERM_PRINT: tapping_term_report(); return false; - case DT_UP: + case QK_DYNAMIC_TAPPING_TERM_UP: g_tapping_term += DYNAMIC_TAPPING_TERM_INCREMENT; return false; - case DT_DOWN: + case QK_DYNAMIC_TAPPING_TERM_DOWN: g_tapping_term -= DYNAMIC_TAPPING_TERM_INCREMENT; return false; } -- cgit v1.2.3 From 69fa02c37d296273c47a5cc0767ca9e6b7170a47 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Sat, 5 Nov 2022 17:05:19 +0000 Subject: Align audio keycode names (#18962) * Align audio keycode names * Update docs * Update quantum --- quantum/keycodes.h | 53 +++++++++++++++++++------------- quantum/process_keycode/process_audio.c | 10 +++--- quantum/process_keycode/process_clicky.c | 16 +++++----- quantum/process_keycode/process_music.c | 8 ++--- quantum/quantum_keycodes_legacy.h | 12 ++++++++ 5 files changed, 60 insertions(+), 39 deletions(-) (limited to 'quantum') diff --git a/quantum/keycodes.h b/quantum/keycodes.h index 2ef94f5d3e..ec07648ab5 100644 --- a/quantum/keycodes.h +++ b/quantum/keycodes.h @@ -563,21 +563,21 @@ enum qk_keycode_defines { QK_PROGRAMMABLE_BUTTON_30 = 0x745D, QK_PROGRAMMABLE_BUTTON_31 = 0x745E, QK_PROGRAMMABLE_BUTTON_32 = 0x745F, - AU_ON = 0x7480, - AU_OFF = 0x7481, - AU_TOG = 0x7482, - CLICKY_TOGGLE = 0x748A, - CLICKY_ENABLE = 0x748B, - CLICKY_DISABLE = 0x748C, - CLICKY_UP = 0x748D, - CLICKY_DOWN = 0x748E, - CLICKY_RESET = 0x748F, - MU_ON = 0x7490, - MU_OFF = 0x7491, - MU_TOG = 0x7492, - MU_MOD = 0x7493, - MUV_IN = 0x7494, - MUV_DE = 0x7495, + QK_AUDIO_ON = 0x7480, + QK_AUDIO_OFF = 0x7481, + QK_AUDIO_TOGGLE = 0x7482, + QK_AUDIO_CLICKY_TOGGLE = 0x748A, + QK_AUDIO_CLICKY_ON = 0x748B, + QK_AUDIO_CLICKY_OFF = 0x748C, + QK_AUDIO_CLICKY_UP = 0x748D, + QK_AUDIO_CLICKY_DOWN = 0x748E, + QK_AUDIO_CLICKY_RESET = 0x748F, + QK_MUSIC_ON = 0x7490, + QK_MUSIC_OFF = 0x7491, + QK_MUSIC_TOGGLE = 0x7492, + QK_MUSIC_MODE_NEXT = 0x7493, + QK_AUDIO_VOICE_NEXT = 0x7494, + QK_AUDIO_VOICE_PREVIOUS = 0x7495, QK_STENO_BOLT = 0x74F0, QK_STENO_GEMINI = 0x74F1, QK_STENO_COMB = 0x74F2, @@ -992,12 +992,21 @@ enum qk_keycode_defines { PB_30 = QK_PROGRAMMABLE_BUTTON_30, PB_31 = QK_PROGRAMMABLE_BUTTON_31, PB_32 = QK_PROGRAMMABLE_BUTTON_32, - CK_TOGG = CLICKY_TOGGLE, - CK_ON = CLICKY_ENABLE, - CK_OFF = CLICKY_DISABLE, - CK_UP = CLICKY_UP, - CK_DOWN = CLICKY_DOWN, - CK_RST = CLICKY_RESET, + AU_ON = QK_AUDIO_ON, + AU_OFF = QK_AUDIO_OFF, + AU_TOGG = QK_AUDIO_TOGGLE, + CK_TOGG = QK_AUDIO_CLICKY_TOGGLE, + CK_ON = QK_AUDIO_CLICKY_ON, + CK_OFF = QK_AUDIO_CLICKY_OFF, + CK_UP = QK_AUDIO_CLICKY_UP, + CK_DOWN = QK_AUDIO_CLICKY_DOWN, + CK_RST = QK_AUDIO_CLICKY_RESET, + MU_ON = QK_MUSIC_ON, + MU_OFF = QK_MUSIC_OFF, + MU_TOGG = QK_MUSIC_TOGGLE, + MU_NEXT = QK_MUSIC_MODE_NEXT, + AU_NEXT = QK_AUDIO_VOICE_NEXT, + AU_PREV = QK_AUDIO_VOICE_PREVIOUS, MC_0 = QK_MACRO_0, MC_1 = QK_MACRO_1, MC_2 = QK_MACRO_2, @@ -1139,7 +1148,7 @@ enum qk_keycode_defines { #define IS_SEQUENCER_KEYCODE(code) ((code) >= SQ_ON && (code) <= SQ_SCLR) #define IS_JOYSTICK_KEYCODE(code) ((code) >= QK_JOYSTICK_BUTTON_0 && (code) <= QK_JOYSTICK_BUTTON_31) #define IS_PROGRAMMABLE_BUTTON_KEYCODE(code) ((code) >= QK_PROGRAMMABLE_BUTTON_1 && (code) <= QK_PROGRAMMABLE_BUTTON_32) -#define IS_AUDIO_KEYCODE(code) ((code) >= AU_ON && (code) <= MUV_DE) +#define IS_AUDIO_KEYCODE(code) ((code) >= QK_AUDIO_ON && (code) <= QK_AUDIO_VOICE_PREVIOUS) #define IS_STENO_KEYCODE(code) ((code) >= QK_STENO_BOLT && (code) <= QK_STENO_COMB_MAX) #define IS_MACRO_KEYCODE(code) ((code) >= QK_MACRO_0 && (code) <= QK_MACRO_31) #define IS_BACKLIGHT_KEYCODE(code) ((code) >= BL_ON && (code) <= BL_BRTG) diff --git a/quantum/process_keycode/process_audio.c b/quantum/process_keycode/process_audio.c index e7fe453308..03b0af9277 100644 --- a/quantum/process_keycode/process_audio.c +++ b/quantum/process_keycode/process_audio.c @@ -16,17 +16,17 @@ float compute_freq_for_midi_note(uint8_t note) { } bool process_audio(uint16_t keycode, keyrecord_t *record) { - if (keycode == AU_ON && record->event.pressed) { + if (keycode == QK_AUDIO_ON && record->event.pressed) { audio_on(); return false; } - if (keycode == AU_OFF && record->event.pressed) { + if (keycode == QK_AUDIO_OFF && record->event.pressed) { audio_off(); return false; } - if (keycode == AU_TOG && record->event.pressed) { + if (keycode == QK_AUDIO_TOGGLE && record->event.pressed) { if (is_audio_on()) { audio_off(); } else { @@ -35,13 +35,13 @@ bool process_audio(uint16_t keycode, keyrecord_t *record) { return false; } - if (keycode == MUV_IN && record->event.pressed) { + if (keycode == QK_AUDIO_VOICE_NEXT && record->event.pressed) { voice_iterate(); PLAY_SONG(voice_change_song); return false; } - if (keycode == MUV_DE && record->event.pressed) { + if (keycode == QK_AUDIO_VOICE_PREVIOUS && record->event.pressed) { voice_deiterate(); PLAY_SONG(voice_change_song); return false; diff --git a/quantum/process_keycode/process_clicky.c b/quantum/process_keycode/process_clicky.c index 9795734984..b662a3f2f4 100644 --- a/quantum/process_keycode/process_clicky.c +++ b/quantum/process_keycode/process_clicky.c @@ -82,31 +82,31 @@ bool is_clicky_on(void) { } bool process_clicky(uint16_t keycode, keyrecord_t *record) { - if (keycode == CLICKY_TOGGLE && record->event.pressed) { + if (keycode == QK_AUDIO_CLICKY_TOGGLE && record->event.pressed) { clicky_toggle(); } - if (keycode == CLICKY_ENABLE && record->event.pressed) { + if (keycode == QK_AUDIO_CLICKY_ON && record->event.pressed) { clicky_on(); } - if (keycode == CLICKY_DISABLE && record->event.pressed) { + if (keycode == QK_AUDIO_CLICKY_OFF && record->event.pressed) { clicky_off(); } - if (keycode == CLICKY_RESET && record->event.pressed) { + if (keycode == QK_AUDIO_CLICKY_RESET && record->event.pressed) { clicky_freq_reset(); } - if (keycode == CLICKY_UP && record->event.pressed) { + if (keycode == QK_AUDIO_CLICKY_UP && record->event.pressed) { clicky_freq_up(); } - if (keycode == CLICKY_DOWN && record->event.pressed) { + if (keycode == QK_AUDIO_CLICKY_DOWN && record->event.pressed) { clicky_freq_down(); } if (audio_config.enable && audio_config.clicky_enable) { - if (record->event.pressed) { // Leave this separate so it's easier to add upstroke sound - if (keycode != AU_OFF && keycode != AU_TOG) { // DO NOT PLAY if audio will be disabled, and causes issuse on ARM + if (record->event.pressed) { // Leave this separate so it's easier to add upstroke sound + if (keycode != QK_AUDIO_ON && keycode != QK_AUDIO_OFF) { // DO NOT PLAY if audio will be disabled, and causes issuse on ARM clicky_play(); } } diff --git a/quantum/process_keycode/process_music.c b/quantum/process_keycode/process_music.c index eeec0c28a4..950aec22f9 100644 --- a/quantum/process_keycode/process_music.c +++ b/quantum/process_keycode/process_music.c @@ -101,17 +101,17 @@ void music_all_notes_off(void) { } bool process_music(uint16_t keycode, keyrecord_t *record) { - if (keycode == MU_ON && record->event.pressed) { + if (keycode == QK_MUSIC_ON && record->event.pressed) { music_on(); return false; } - if (keycode == MU_OFF && record->event.pressed) { + if (keycode == QK_MUSIC_OFF && record->event.pressed) { music_off(); return false; } - if (keycode == MU_TOG && record->event.pressed) { + if (keycode == QK_MUSIC_TOGGLE && record->event.pressed) { if (music_activated) { music_off(); } else { @@ -139,7 +139,7 @@ bool process_music(uint16_t keycode, keyrecord_t *record) { return false; } - if (keycode == MU_MOD && record->event.pressed) { + if (keycode == QK_MUSIC_MODE_NEXT && record->event.pressed) { music_mode_cycle(); return false; } diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h index 8f325251bc..44044ec625 100644 --- a/quantum/quantum_keycodes_legacy.h +++ b/quantum/quantum_keycodes_legacy.h @@ -123,6 +123,18 @@ #define KC_RAPC QK_SPACE_CADET_RIGHT_ALT_PARENTHESIS_CLOSE #define KC_SFTENT QK_SPACE_CADET_RIGHT_SHIFT_ENTER +#define AU_TOG QK_AUDIO_TOGGLE +#define CLICKY_TOGGLE QK_AUDIO_CLICKY_TOGGLE +#define CLICKY_ENABLE QK_AUDIO_CLICKY_ON +#define CLICKY_DISABLE QK_AUDIO_CLICKY_OFF +#define CLICKY_UP QK_AUDIO_CLICKY_UP +#define CLICKY_DOWN QK_AUDIO_CLICKY_DOWN +#define CLICKY_RESET QK_AUDIO_CLICKY_RESET +#define MU_TOG QK_MUSIC_TOGGLE +#define MU_MOD QK_MUSIC_MODE_NEXT +#define MUV_IN QK_AUDIO_VOICE_NEXT +#define MUV_DE QK_AUDIO_VOICE_PREVIOUS + #define TERM_ON _Static_assert(false, "The Terminal feature has been removed from QMK. Please remove use of TERM_ON/TERM_OFF from your keymap.") #define TERM_OFF _Static_assert(false, "The Terminal feature has been removed from QMK.. Please remove use of TERM_ON/TERM_OFF from your keymap.") // #define RESET _Static_assert(false, "The RESET keycode has been removed from QMK.. Please remove use from your keymap.") -- cgit v1.2.3 From 352beeac2f62edf1f3288a2a7aa0f1e3bafa7dfd Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Sat, 5 Nov 2022 12:05:01 -0700 Subject: [Bug] Fix compilation issue with WPM (#18965) --- quantum/wpm.c | 1 + 1 file changed, 1 insertion(+) (limited to 'quantum') diff --git a/quantum/wpm.c b/quantum/wpm.c index 6a4e39a8d6..9a125efba0 100644 --- a/quantum/wpm.c +++ b/quantum/wpm.c @@ -19,6 +19,7 @@ #include "timer.h" #include "keycode.h" #include "quantum_keycodes.h" +#include "action_util.h" #include // WPM Stuff -- cgit v1.2.3 From 219afaba42e6b4384f578977eadbb71a03383ecc Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Sun, 6 Nov 2022 08:11:59 +1100 Subject: Reworked backlight keycodes. (#18961) Co-authored-by: Ryan --- quantum/keycodes.h | 23 +++++++++++++++-------- quantum/process_keycode/process_backlight.c | 26 +++++++++++++------------- quantum/quantum_keycodes_legacy.h | 3 +++ 3 files changed, 31 insertions(+), 21 deletions(-) (limited to 'quantum') diff --git a/quantum/keycodes.h b/quantum/keycodes.h index ec07648ab5..db4d373234 100644 --- a/quantum/keycodes.h +++ b/quantum/keycodes.h @@ -614,13 +614,13 @@ enum qk_keycode_defines { QK_MACRO_29 = 0x771D, QK_MACRO_30 = 0x771E, QK_MACRO_31 = 0x771F, - BL_ON = 0x7800, - BL_OFF = 0x7801, - BL_DEC = 0x7802, - BL_INC = 0x7803, - BL_TOGG = 0x7804, - BL_STEP = 0x7805, - BL_BRTG = 0x7806, + QK_BACKLIGHT_ON = 0x7800, + QK_BACKLIGHT_OFF = 0x7801, + QK_BACKLIGHT_TOGGLE = 0x7802, + QK_BACKLIGHT_DOWN = 0x7803, + QK_BACKLIGHT_UP = 0x7804, + QK_BACKLIGHT_STEP = 0x7805, + QK_BACKLIGHT_TOGGLE_BREATHING = 0x7806, RGB_TOG = 0x7820, RGB_MODE_FORWARD = 0x7821, RGB_MODE_REVERSE = 0x7822, @@ -1039,6 +1039,13 @@ enum qk_keycode_defines { MC_29 = QK_MACRO_29, MC_30 = QK_MACRO_30, MC_31 = QK_MACRO_31, + BL_ON = QK_BACKLIGHT_ON, + BL_OFF = QK_BACKLIGHT_OFF, + BL_TOGG = QK_BACKLIGHT_TOGGLE, + BL_DOWN = QK_BACKLIGHT_DOWN, + BL_UP = QK_BACKLIGHT_UP, + BL_STEP = QK_BACKLIGHT_STEP, + BL_BRTG = QK_BACKLIGHT_TOGGLE_BREATHING, RGB_MOD = RGB_MODE_FORWARD, RGB_RMOD = RGB_MODE_REVERSE, RGB_M_P = RGB_MODE_PLAIN, @@ -1151,7 +1158,7 @@ enum qk_keycode_defines { #define IS_AUDIO_KEYCODE(code) ((code) >= QK_AUDIO_ON && (code) <= QK_AUDIO_VOICE_PREVIOUS) #define IS_STENO_KEYCODE(code) ((code) >= QK_STENO_BOLT && (code) <= QK_STENO_COMB_MAX) #define IS_MACRO_KEYCODE(code) ((code) >= QK_MACRO_0 && (code) <= QK_MACRO_31) -#define IS_BACKLIGHT_KEYCODE(code) ((code) >= BL_ON && (code) <= BL_BRTG) +#define IS_BACKLIGHT_KEYCODE(code) ((code) >= QK_BACKLIGHT_ON && (code) <= QK_BACKLIGHT_TOGGLE_BREATHING) #define IS_RGB_KEYCODE(code) ((code) >= RGB_TOG && (code) <= RGB_MODE_TWINKLE) #define IS_QUANTUM_KEYCODE(code) ((code) >= QK_BOOTLOADER && (code) <= QK_AUTOCORRECT_TOGGLE) diff --git a/quantum/process_keycode/process_backlight.c b/quantum/process_keycode/process_backlight.c index 8b70339a55..c1596ec07d 100644 --- a/quantum/process_keycode/process_backlight.c +++ b/quantum/process_keycode/process_backlight.c @@ -26,45 +26,45 @@ bool process_backlight(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { switch (keycode) { #ifdef LED_MATRIX_ENABLE - case BL_ON: + case QK_BACKLIGHT_ON: led_matrix_enable(); return false; - case BL_OFF: + case QK_BACKLIGHT_OFF: led_matrix_disable(); return false; - case BL_DEC: + case QK_BACKLIGHT_DOWN: led_matrix_decrease_val(); return false; - case BL_INC: + case QK_BACKLIGHT_UP: led_matrix_increase_val(); return false; - case BL_TOGG: + case QK_BACKLIGHT_TOGGLE: led_matrix_toggle(); return false; - case BL_STEP: + case QK_BACKLIGHT_STEP: led_matrix_step(); return false; #else - case BL_ON: + case QK_BACKLIGHT_ON: backlight_level(BACKLIGHT_LEVELS); return false; - case BL_OFF: + case QK_BACKLIGHT_OFF: backlight_level(0); return false; - case BL_DEC: + case QK_BACKLIGHT_DOWN: backlight_decrease(); return false; - case BL_INC: + case QK_BACKLIGHT_UP: backlight_increase(); return false; - case BL_TOGG: + case QK_BACKLIGHT_TOGGLE: backlight_toggle(); return false; - case BL_STEP: + case QK_BACKLIGHT_STEP: backlight_step(); return false; # ifdef BACKLIGHT_BREATHING - case BL_BRTG: + case QK_BACKLIGHT_TOGGLE_BREATHING: backlight_toggle_breathing(); return false; # endif diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h index 44044ec625..e2133513bd 100644 --- a/quantum/quantum_keycodes_legacy.h +++ b/quantum/quantum_keycodes_legacy.h @@ -123,6 +123,9 @@ #define KC_RAPC QK_SPACE_CADET_RIGHT_ALT_PARENTHESIS_CLOSE #define KC_SFTENT QK_SPACE_CADET_RIGHT_SHIFT_ENTER +#define BL_DEC QK_BACKLIGHT_DOWN +#define BL_INC QK_BACKLIGHT_UP + #define AU_TOG QK_AUDIO_TOGGLE #define CLICKY_TOGGLE QK_AUDIO_CLICKY_TOGGLE #define CLICKY_ENABLE QK_AUDIO_CLICKY_ON -- cgit v1.2.3 From a7b2f4233ca2062037303e783ced30d9376c9443 Mon Sep 17 00:00:00 2001 From: Sergey Vlasov Date: Mon, 7 Nov 2022 00:39:05 +0300 Subject: Fix keycode parameter extraction to match the new DD keycodes (#18977) * Add macros to extract parameters from keycode values Implement both encoding and decoding for keycodes like TO(layer) or LM(layer, mod) in one place, so that the decoding won't get out of sync with the encoding. While at it, fix some macros for creating keycode values that did not apply the appropriate masks to parameters (and therefore could allow the result to be out of range if a wrong parameter was passed). * keymap_common: Use extraction macros for keycodes * pointing_device_auto_mouse: Use extraction macros for keycodes Fixes #18970. * process_autocorrect: Use extraction macros for keycodes * process_caps_word: Use extraction macros for keycodes (Also fix a minor bug - SH_TG was not handled properly) * process_leader: Use extraction macros for keycodes (Technically the code is not 100% correct, because it always assumes that the LT() or MT() action was a tap, but it's a separate issue that already existed before the keycode changes.) * process_unicode: Use extraction macros for keycodes * process_unicodemap: Use extraction macros for keycodes --- quantum/keymap_common.c | 28 +++++++++++----------- .../pointing_device/pointing_device_auto_mouse.c | 16 ++++++++----- quantum/process_keycode/process_autocorrect.c | 17 +++++++++---- quantum/process_keycode/process_caps_word.c | 12 ++++++---- quantum/process_keycode/process_leader.c | 6 +++-- quantum/process_keycode/process_unicode.c | 2 +- quantum/process_keycode/process_unicodemap.c | 10 ++++---- quantum/quantum_keycodes.h | 28 ++++++++++++++++++++-- 8 files changed, 81 insertions(+), 38 deletions(-) (limited to 'quantum') diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index a5997711f2..c4336440f9 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -74,64 +74,64 @@ action_t action_for_keycode(uint16_t keycode) { case QK_MODS ... QK_MODS_MAX:; // Has a modifier // Split it up - action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF); // adds modifier to key + action.code = ACTION_MODS_KEY(QK_MODS_GET_MODS(keycode), QK_MODS_GET_BASIC_KEYCODE(keycode)); // adds modifier to key break; #ifndef NO_ACTION_LAYER case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: - action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); + action.code = ACTION_LAYER_TAP_KEY(QK_LAYER_TAP_GET_LAYER(keycode), QK_LAYER_TAP_GET_TAP_KEYCODE(keycode)); break; case QK_TO ... QK_TO_MAX:; // Layer set "GOTO" - action_layer = keycode & 0xFF; + action_layer = QK_TO_GET_LAYER(keycode); action.code = ACTION_LAYER_GOTO(action_layer); break; case QK_MOMENTARY ... QK_MOMENTARY_MAX:; // Momentary action_layer - action_layer = keycode & 0xFF; + action_layer = QK_MOMENTARY_GET_LAYER(keycode); action.code = ACTION_LAYER_MOMENTARY(action_layer); break; case QK_DEF_LAYER ... QK_DEF_LAYER_MAX:; // Set default action_layer - action_layer = keycode & 0xFF; + action_layer = QK_DEF_LAYER_GET_LAYER(keycode); action.code = ACTION_DEFAULT_LAYER_SET(action_layer); break; case QK_TOGGLE_LAYER ... QK_TOGGLE_LAYER_MAX:; // Set toggle - action_layer = keycode & 0xFF; + action_layer = QK_TOGGLE_LAYER_GET_LAYER(keycode); action.code = ACTION_LAYER_TOGGLE(action_layer); break; #endif #ifndef NO_ACTION_ONESHOT case QK_ONE_SHOT_LAYER ... QK_ONE_SHOT_LAYER_MAX:; // OSL(action_layer) - One-shot action_layer - action_layer = keycode & 0xFF; + action_layer = QK_ONE_SHOT_LAYER_GET_LAYER(keycode); action.code = ACTION_LAYER_ONESHOT(action_layer); break; case QK_ONE_SHOT_MOD ... QK_ONE_SHOT_MOD_MAX:; // OSM(mod) - One-shot mod - mod = mod_config(keycode & 0x1F); + mod = mod_config(QK_ONE_SHOT_MOD_GET_MODS(keycode)); action.code = ACTION_MODS_ONESHOT(mod); break; #endif #ifndef NO_ACTION_LAYER case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX: - action.code = ACTION_LAYER_TAP_TOGGLE(keycode & 0xFF); + action.code = ACTION_LAYER_TAP_TOGGLE(QK_LAYER_TAP_TOGGLE_GET_LAYER(keycode)); break; case QK_LAYER_MOD ... QK_LAYER_MOD_MAX: - mod = mod_config(keycode & 0x1F); - action_layer = (keycode >> 5) & 0xF; + mod = mod_config(QK_LAYER_MOD_GET_MODS(keycode)); + action_layer = QK_LAYER_MOD_GET_LAYER(keycode); action.code = ACTION_LAYER_MODS(action_layer, mod); break; #endif #ifndef NO_ACTION_TAPPING case QK_MOD_TAP ... QK_MOD_TAP_MAX: - mod = mod_config((keycode >> 0x8) & 0x1F); - action.code = ACTION_MODS_TAP_KEY(mod, keycode & 0xFF); + mod = mod_config(QK_MOD_TAP_GET_MODS(keycode)); + action.code = ACTION_MODS_TAP_KEY(mod, QK_MOD_TAP_GET_TAP_KEYCODE(keycode)); break; #endif #ifdef SWAP_HANDS_ENABLE case QK_SWAP_HANDS ... QK_SWAP_HANDS_MAX: - action.code = ACTION(ACT_SWAP_HANDS, keycode & 0xff); + action.code = ACTION(ACT_SWAP_HANDS, QK_SWAP_HANDS_GET_TAP_KEYCODE(keycode)); break; #endif diff --git a/quantum/pointing_device/pointing_device_auto_mouse.c b/quantum/pointing_device/pointing_device_auto_mouse.c index edffd44787..5e78817c7c 100644 --- a/quantum/pointing_device/pointing_device_auto_mouse.c +++ b/quantum/pointing_device/pointing_device_auto_mouse.c @@ -266,16 +266,20 @@ bool process_auto_mouse(uint16_t keycode, keyrecord_t* record) { case QK_MODS ... QK_MODS_MAX: break; // TO((AUTO_MOUSE_TARGET_LAYER))------------------------------------------------------------------------------- - case QK_TO ... QK_TO_MAX: // same proccessing as next + case QK_TO ... QK_TO_MAX: + if (QK_TO_GET_LAYER(keycode) == (AUTO_MOUSE_TARGET_LAYER)) { + if (!(record->event.pressed)) auto_mouse_toggle(); + } + break; // TG((AUTO_MOUSE_TARGET_LAYER))------------------------------------------------------------------------------- case QK_TOGGLE_LAYER ... QK_TOGGLE_LAYER_MAX: - if ((keycode & 0xff) == (AUTO_MOUSE_TARGET_LAYER)) { + if (QK_TOGGLE_LAYER_GET_LAYER(keycode) == (AUTO_MOUSE_TARGET_LAYER)) { if (!(record->event.pressed)) auto_mouse_toggle(); } break; // MO((AUTO_MOUSE_TARGET_LAYER))------------------------------------------------------------------------------- case QK_MOMENTARY ... QK_MOMENTARY_MAX: - if ((keycode & 0xff) == (AUTO_MOUSE_TARGET_LAYER)) { + if (QK_MOMENTARY_GET_LAYER(keycode) == (AUTO_MOUSE_TARGET_LAYER)) { auto_mouse_keyevent(record->event.pressed); } // DF --------------------------------------------------------------------------------------------------------- @@ -288,14 +292,14 @@ bool process_auto_mouse(uint16_t keycode, keyrecord_t* record) { break; // LM((AUTO_MOUSE_TARGET_LAYER), mod)-------------------------------------------------------------------------- case QK_LAYER_MOD ... QK_LAYER_MOD_MAX: - if (((keycode >> 8) & 0x0f) == (AUTO_MOUSE_TARGET_LAYER)) { + if (QK_LAYER_MOD_GET_LAYER(keycode) == (AUTO_MOUSE_TARGET_LAYER)) { auto_mouse_keyevent(record->event.pressed); } break; // TT((AUTO_MOUSE_TARGET_LAYER))--------------------------------------------------------------------------- # ifndef NO_ACTION_TAPPING case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX: - if ((keycode & 0xff) == (AUTO_MOUSE_TARGET_LAYER)) { + if (QK_LAYER_TAP_TOGGLE_GET_LAYER(keycode) == (AUTO_MOUSE_TARGET_LAYER)) { auto_mouse_keyevent(record->event.pressed); # if TAPPING_TOGGLE != 0 if (record->tap.count == TAPPING_TOGGLE) { @@ -312,7 +316,7 @@ bool process_auto_mouse(uint16_t keycode, keyrecord_t* record) { // LT((AUTO_MOUSE_TARGET_LAYER), kc)--------------------------------------------------------------------------- case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: if (!record->tap.count) { - if (((keycode >> 8) & 0x0f) == (AUTO_MOUSE_TARGET_LAYER)) { + if (QK_LAYER_TAP_GET_LAYER(keycode) == (AUTO_MOUSE_TARGET_LAYER)) { auto_mouse_keyevent(record->event.pressed); } break; diff --git a/quantum/process_keycode/process_autocorrect.c b/quantum/process_keycode/process_autocorrect.c index e3fcbc34ae..8aeebf0e06 100644 --- a/quantum/process_keycode/process_autocorrect.c +++ b/quantum/process_keycode/process_autocorrect.c @@ -91,7 +91,7 @@ __attribute__((weak)) bool process_autocorrect_user(uint16_t *keycode, keyrecord } else { *mods |= MOD_RSFT; } - *keycode &= 0xFF; // Get the basic keycode. + *keycode = QK_MODS_GET_BASIC_KEYCODE(*keycode); // Get the basic keycode. return true; #ifndef NO_ACTION_TAPPING // Exclude tap-hold keys when they are held down @@ -101,13 +101,20 @@ __attribute__((weak)) bool process_autocorrect_user(uint16_t *keycode, keyrecord // Exclude Layer Tap, if layers are disabled // but action tapping is still enabled. return false; +# else + // Exclude hold keycode + if (!record->tap.count) { + return false; + } + *keycode = QK_LAYER_TAP_GET_TAP_KEYCODE(*keycode); + break; # endif case QK_MOD_TAP ... QK_MOD_TAP_MAX: // Exclude hold keycode if (!record->tap.count) { return false; } - *keycode &= 0xFF; + *keycode = QK_MOD_TAP_GET_TAP_KEYCODE(*keycode); break; #else case QK_MOD_TAP ... QK_MOD_TAP_MAX: @@ -119,10 +126,12 @@ __attribute__((weak)) bool process_autocorrect_user(uint16_t *keycode, keyrecord // and mask for base keycode when they are tapped. case QK_SWAP_HANDS ... QK_SWAP_HANDS_MAX: #ifdef SWAP_HANDS_ENABLE - if (*keycode >= 0x56F0 || !record->tap.count) { + // Note: IS_SWAP_HANDS_KEYCODE() actually tests for the special action keycodes like SH_TG, SH_TT, ..., + // which currently overlap the SH_T(kc) range. + if (IS_SWAP_HANDS_KEYCODE(*keycode) || !record->tap.count) { return false; } - *keycode &= 0xFF; + *keycode = QK_SWAP_HANDS_GET_TAP_KEYCODE(*keycode); break; #else // Exclude if disabled diff --git a/quantum/process_keycode/process_caps_word.c b/quantum/process_keycode/process_caps_word.c index 7a83f7bf49..4c0217eba7 100644 --- a/quantum/process_keycode/process_caps_word.c +++ b/quantum/process_keycode/process_caps_word.c @@ -109,7 +109,7 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) { // * Otherwise stop Caps Word. case QK_MOD_TAP ... QK_MOD_TAP_MAX: if (record->tap.count == 0) { // Mod-tap key is held. - const uint8_t mods = (keycode >> 8) & 0x1f; + const uint8_t mods = QK_MOD_TAP_GET_MODS(keycode); switch (mods) { case MOD_LSFT: keycode = KC_LSFT; @@ -127,7 +127,7 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) { return true; } } else { - keycode &= 0xff; + keycode = QK_MOD_TAP_GET_TAP_KEYCODE(keycode); } break; @@ -137,16 +137,18 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) { if (record->tap.count == 0) { return true; } - keycode &= 0xff; + keycode = QK_LAYER_TAP_GET_TAP_KEYCODE(keycode); break; #endif // NO_ACTION_TAPPING #ifdef SWAP_HANDS_ENABLE case QK_SWAP_HANDS ... QK_SWAP_HANDS_MAX: - if (keycode > 0x56F0 || record->tap.count == 0) { + // Note: IS_SWAP_HANDS_KEYCODE() actually tests for the special action keycodes like SH_TG, SH_TT, ..., + // which currently overlap the SH_T(kc) range. + if (IS_SWAP_HANDS_KEYCODE(keycode) || record->tap.count == 0) { return true; } - keycode &= 0xff; + keycode = QK_SWAP_HANDS_GET_TAP_KEYCODE(keycode); break; #endif // SWAP_HANDS_ENABLE } diff --git a/quantum/process_keycode/process_leader.c b/quantum/process_keycode/process_leader.c index 7e6f3ad73c..b74b4927a8 100644 --- a/quantum/process_keycode/process_leader.c +++ b/quantum/process_keycode/process_leader.c @@ -54,8 +54,10 @@ bool process_leader(uint16_t keycode, keyrecord_t *record) { # endif // LEADER_NO_TIMEOUT { # ifndef LEADER_KEY_STRICT_KEY_PROCESSING - if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) { - keycode = keycode & 0xFF; + if (IS_QK_MOD_TAP(keycode)) { + keycode = QK_MOD_TAP_GET_TAP_KEYCODE(keycode); + } else if (IS_QK_LAYER_TAP(keycode)) { + keycode = QK_LAYER_TAP_GET_TAP_KEYCODE(keycode); } # endif // LEADER_KEY_STRICT_KEY_PROCESSING if (leader_sequence_size < ARRAY_SIZE(leader_sequence)) { diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c index 99cc2f5f26..1ec76245a3 100644 --- a/quantum/process_keycode/process_unicode.c +++ b/quantum/process_keycode/process_unicode.c @@ -21,7 +21,7 @@ bool process_unicode(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { if (keycode >= QK_UNICODE && keycode <= QK_UNICODE_MAX) { - register_unicode(keycode & 0x7FFF); + register_unicode(QK_UNICODE_GET_CODE_POINT(keycode)); } } return true; diff --git a/quantum/process_keycode/process_unicodemap.c b/quantum/process_keycode/process_unicodemap.c index 979d773b05..195c093e6e 100644 --- a/quantum/process_keycode/process_unicodemap.c +++ b/quantum/process_keycode/process_unicodemap.c @@ -24,7 +24,7 @@ __attribute__((weak)) uint16_t unicodemap_index(uint16_t keycode) { if (keycode >= QK_UNICODEMAP_PAIR) { // Keycode is a pair: extract index based on Shift / Caps Lock state - uint16_t index = keycode - QK_UNICODEMAP_PAIR; + uint16_t index; uint8_t mods = get_mods() | get_weak_mods(); #ifndef NO_ACTION_ONESHOT @@ -34,13 +34,15 @@ __attribute__((weak)) uint16_t unicodemap_index(uint16_t keycode) { bool shift = mods & MOD_MASK_SHIFT; bool caps = host_keyboard_led_state().caps_lock; if (shift ^ caps) { - index >>= 7; + index = QK_UNICODEMAP_PAIR_GET_SHIFTED_INDEX(keycode); + } else { + index = QK_UNICODEMAP_PAIR_GET_UNSHIFTED_INDEX(keycode); } - return index & 0x7F; + return index; } else { // Keycode is a regular index - return keycode - QK_UNICODEMAP; + return QK_UNICODEMAP_GET_INDEX(keycode); } } diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index ec69fadbab..6b0e890792 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -39,6 +39,10 @@ #define QK_UNICODEMAP_PAIR_MAX 0xFFFF // clang-format on +// Generic decoding for the whole QK_MODS range +#define QK_MODS_GET_MODS(kc) (((kc) >> 8) & 0x1F) +#define QK_MODS_GET_BASIC_KEYCODE(kc) ((kc)&0xFF) + // Keycode modifiers & aliases #define LCTL(kc) (QK_LCTL | (kc)) #define LSFT(kc) (QK_LSFT | (kc)) @@ -80,33 +84,46 @@ // GOTO layer - 32 layer max #define TO(layer) (QK_TO | ((layer)&0x1F)) +#define QK_TO_GET_LAYER(kc) ((kc)&0x1F) // Momentary switch layer - 32 layer max #define MO(layer) (QK_MOMENTARY | ((layer)&0x1F)) +#define QK_MOMENTARY_GET_LAYER(kc) ((kc)&0x1F) // Set default layer - 32 layer max #define DF(layer) (QK_DEF_LAYER | ((layer)&0x1F)) +#define QK_DEF_LAYER_GET_LAYER(kc) ((kc)&0x1F) // Toggle to layer - 32 layer max #define TG(layer) (QK_TOGGLE_LAYER | ((layer)&0x1F)) +#define QK_TOGGLE_LAYER_GET_LAYER(kc) ((kc)&0x1F) // One-shot layer - 32 layer max #define OSL(layer) (QK_ONE_SHOT_LAYER | ((layer)&0x1F)) +#define QK_ONE_SHOT_LAYER_GET_LAYER(kc) ((kc)&0x1F) // L-ayer M-od: Momentary switch layer with modifiers active - 16 layer max #define LM(layer, mod) (QK_LAYER_MOD | (((layer)&0xF) << 5) | ((mod)&0x1F)) +#define QK_LAYER_MOD_GET_LAYER(kc) (((kc) >> 5) & 0xF) +#define QK_LAYER_MOD_GET_MODS(kc) ((kc)&0x1F) // One-shot mod #define OSM(mod) (QK_ONE_SHOT_MOD | ((mod)&0x1F)) +#define QK_ONE_SHOT_MOD_GET_MODS(kc) ((kc)&0x1F) // Layer tap-toggle - 32 layer max #define TT(layer) (QK_LAYER_TAP_TOGGLE | ((layer)&0x1F)) +#define QK_LAYER_TAP_TOGGLE_GET_LAYER(kc) ((kc)&0x1F) // L-ayer, T-ap - 256 keycode max, 16 layer max #define LT(layer, kc) (QK_LAYER_TAP | (((layer)&0xF) << 8) | ((kc)&0xFF)) +#define QK_LAYER_TAP_GET_LAYER(kc) (((kc) >> 8) & 0xF) +#define QK_LAYER_TAP_GET_TAP_KEYCODE(kc) ((kc)&0xFF) // M-od, T-ap - 256 keycode max #define MT(mod, kc) (QK_MOD_TAP | (((mod)&0x1F) << 8) | ((kc)&0xFF)) +#define QK_MOD_TAP_GET_MODS(kc) (((kc) >> 8) & 0x1F) +#define QK_MOD_TAP_GET_TAP_KEYCODE(kc) ((kc)&0xFF) #define LCTL_T(kc) MT(MOD_LCTL, kc) #define RCTL_T(kc) MT(MOD_RCTL, kc) @@ -161,12 +178,19 @@ // Unicode aliases // UNICODE_ENABLE - Allows Unicode input up to 0x7FFF #define UC(c) (QK_UNICODE | (c)) +#define QK_UNICODE_GET_CODE_POINT(kc) ((kc)&0x7FFF) + // UNICODEMAP_ENABLE - Allows Unicode input up to 0x10FFFF, requires unicode_map -#define X(i) (QK_UNICODEMAP | (i)) +#define X(i) (QK_UNICODEMAP | ((i)&0x3FFF)) +#define QK_UNICODEMAP_GET_INDEX(kc) ((kc)&0x3FFF) + #define XP(i, j) (QK_UNICODEMAP_PAIR | ((i)&0x7F) | (((j)&0x7F) << 7)) // 127 max i and j +#define QK_UNICODEMAP_PAIR_GET_UNSHIFTED_INDEX(kc) ((kc)&0x7F) +#define QK_UNICODEMAP_PAIR_GET_SHIFTED_INDEX(kc) (((kc) >> 7) & 0x7F) // Swap Hands -#define SH_T(kc) (QK_SWAP_HANDS | (kc)) +#define SH_T(kc) (QK_SWAP_HANDS | ((kc)&0xFF)) +#define QK_SWAP_HANDS_GET_TAP_KEYCODE(kc) ((kc)&0xFF) // MIDI aliases #define MIDI_TONE_MIN MI_C -- cgit v1.2.3 From 8b658dcc9a826b03fedb1ef2bfcc692f3e25da1b Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 7 Nov 2022 13:26:15 +1100 Subject: Normalise MIDI keycodes (#18972) * `MI_ON`, `MI_OFF`, `MI_TOG` -> `MI_TOGG` * `MI_CH*`, `MI_CHU` -> `MI_CHNU`, `MI_CHD` -> `MI_CHND` * `MI_VEL_*` -> `MI_VL*`, `MI_VELU`, `MI_VELD` * `MI_TRNS_*` -> `MI_TR*`, `MI_TRNSU` -> `MI_TRSU`, `MI_TRNSD` -> `MI_TRSD` * `MI_OCT_*` -> `MI_OC*`, `MI_OCTU`, `MI_OCTD` * Misc controls * Note keycodes * Add legacy keycodes * Regenerate keycodes * Typo --- quantum/keycodes.h | 495 ++++++++++++++++++---------- quantum/process_keycode/process_midi.c | 48 +-- quantum/process_keycode/process_music.c | 6 +- quantum/quantum_keycodes.h | 20 +- quantum/quantum_keycodes_legacy.h | 130 ++++++++ quantum/sequencer/tests/sequencer_tests.cpp | 22 +- 6 files changed, 497 insertions(+), 224 deletions(-) (limited to 'quantum') diff --git a/quantum/keycodes.h b/quantum/keycodes.h index db4d373234..deb3565262 100644 --- a/quantum/keycodes.h +++ b/quantum/keycodes.h @@ -346,150 +346,150 @@ enum qk_keycode_defines { MAGIC_SWAP_ESCAPE_CAPSLOCK = 0x7020, MAGIC_UNSWAP_ESCAPE_CAPSLOCK = 0x7021, MAGIC_TOGGLE_ESCAPE_CAPSLOCK = 0x7022, - MI_ON = 0x7100, - MI_OFF = 0x7101, - MI_TOG = 0x7102, - MI_C = 0x7110, - MI_Cs = 0x7111, - MI_D = 0x7112, - MI_Ds = 0x7113, - MI_E = 0x7114, - MI_F = 0x7115, - MI_Fs = 0x7116, - MI_G = 0x7117, - MI_Gs = 0x7118, - MI_A = 0x7119, - MI_As = 0x711A, - MI_B = 0x711B, - MI_C_1 = 0x7120, - MI_Cs_1 = 0x7121, - MI_D_1 = 0x7122, - MI_Ds_1 = 0x7123, - MI_E_1 = 0x7124, - MI_F_1 = 0x7125, - MI_Fs_1 = 0x7126, - MI_G_1 = 0x7127, - MI_Gs_1 = 0x7128, - MI_A_1 = 0x7129, - MI_As_1 = 0x712A, - MI_B_1 = 0x712B, - MI_C_2 = 0x7130, - MI_Cs_2 = 0x7131, - MI_D_2 = 0x7132, - MI_Ds_2 = 0x7133, - MI_E_2 = 0x7134, - MI_F_2 = 0x7135, - MI_Fs_2 = 0x7136, - MI_G_2 = 0x7137, - MI_Gs_2 = 0x7138, - MI_A_2 = 0x7139, - MI_As_2 = 0x713A, - MI_B_2 = 0x713B, - MI_C_3 = 0x7140, - MI_Cs_3 = 0x7141, - MI_D_3 = 0x7142, - MI_Ds_3 = 0x7143, - MI_E_3 = 0x7144, - MI_F_3 = 0x7145, - MI_Fs_3 = 0x7146, - MI_G_3 = 0x7147, - MI_Gs_3 = 0x7148, - MI_A_3 = 0x7149, - MI_As_3 = 0x714A, - MI_B_3 = 0x714B, - MI_C_4 = 0x7150, - MI_Cs_4 = 0x7151, - MI_D_4 = 0x7152, - MI_Ds_4 = 0x7153, - MI_E_4 = 0x7154, - MI_F_4 = 0x7155, - MI_Fs_4 = 0x7156, - MI_G_4 = 0x7157, - MI_Gs_4 = 0x7158, - MI_A_4 = 0x7159, - MI_As_4 = 0x715A, - MI_B_4 = 0x715B, - MI_C_5 = 0x7160, - MI_Cs_5 = 0x7161, - MI_D_5 = 0x7162, - MI_Ds_5 = 0x7163, - MI_E_5 = 0x7164, - MI_F_5 = 0x7165, - MI_Fs_5 = 0x7166, - MI_G_5 = 0x7167, - MI_Gs_5 = 0x7168, - MI_A_5 = 0x7169, - MI_As_5 = 0x716A, - MI_B_5 = 0x716B, - MI_OCT_N2 = 0x7170, - MI_OCT_N1 = 0x7171, - MI_OCT_0 = 0x7172, - MI_OCT_1 = 0x7173, - MI_OCT_2 = 0x7174, - MI_OCT_3 = 0x7175, - MI_OCT_4 = 0x7176, - MI_OCT_5 = 0x7177, - MI_OCT_6 = 0x7178, - MI_OCT_7 = 0x7179, - MI_OCTD = 0x717A, - MI_OCTU = 0x717B, - MI_TRNS_N6 = 0x7180, - MI_TRNS_N5 = 0x7181, - MI_TRNS_N4 = 0x7182, - MI_TRNS_N3 = 0x7183, - MI_TRNS_N2 = 0x7184, - MI_TRNS_N1 = 0x7185, - MI_TRNS_0 = 0x7186, - MI_TRNS_1 = 0x7187, - MI_TRNS_2 = 0x7188, - MI_TRNS_3 = 0x7189, - MI_TRNS_4 = 0x718A, - MI_TRNS_5 = 0x718B, - MI_TRNS_6 = 0x718C, - MI_TRNSD = 0x718D, - MI_TRNSU = 0x718E, - MI_VEL_0 = 0x7190, - MI_VEL_1 = 0x7191, - MI_VEL_2 = 0x7192, - MI_VEL_3 = 0x7193, - MI_VEL_4 = 0x7194, - MI_VEL_5 = 0x7195, - MI_VEL_6 = 0x7196, - MI_VEL_7 = 0x7197, - MI_VEL_8 = 0x7198, - MI_VEL_9 = 0x7199, - MI_VEL_10 = 0x719A, - MI_VELD = 0x719B, - MI_VELU = 0x719C, - MI_CH1 = 0x71A0, - MI_CH2 = 0x71A1, - MI_CH3 = 0x71A2, - MI_CH4 = 0x71A3, - MI_CH5 = 0x71A4, - MI_CH6 = 0x71A5, - MI_CH7 = 0x71A6, - MI_CH8 = 0x71A7, - MI_CH9 = 0x71A8, - MI_CH10 = 0x71A9, - MI_CH11 = 0x71AA, - MI_CH12 = 0x71AB, - MI_CH13 = 0x71AC, - MI_CH14 = 0x71AD, - MI_CH15 = 0x71AE, - MI_CH16 = 0x71AF, - MI_CHD = 0x71B0, - MI_CHU = 0x71B1, - MI_ALLOFF = 0x71C0, - MI_SUS = 0x71C1, - MI_PORT = 0x71C2, - MI_SOST = 0x71C3, - MI_SOFT = 0x71C4, - MI_LEG = 0x71C5, - MI_MOD = 0x71C6, - MI_MODSD = 0x71C7, - MI_MODSU = 0x71C8, - MI_BENDD = 0x71C9, - MI_BENDU = 0x71CA, + QK_MIDI_ON = 0x7100, + QK_MIDI_OFF = 0x7101, + QK_MIDI_TOGGLE = 0x7102, + QK_MIDI_NOTE_C_0 = 0x7110, + QK_MIDI_NOTE_C_SHARP_0 = 0x7111, + QK_MIDI_NOTE_D_0 = 0x7112, + QK_MIDI_NOTE_D_SHARP_0 = 0x7113, + QK_MIDI_NOTE_E_0 = 0x7114, + QK_MIDI_NOTE_F_0 = 0x7115, + QK_MIDI_NOTE_F_SHARP_0 = 0x7116, + QK_MIDI_NOTE_G_0 = 0x7117, + QK_MIDI_NOTE_G_SHARP_0 = 0x7118, + QK_MIDI_NOTE_A_0 = 0x7119, + QK_MIDI_NOTE_A_SHARP_0 = 0x711A, + QK_MIDI_NOTE_B_0 = 0x711B, + QK_MIDI_NOTE_C_1 = 0x7120, + QK_MIDI_NOTE_C_SHARP_1 = 0x7121, + QK_MIDI_NOTE_D_1 = 0x7122, + QK_MIDI_NOTE_D_SHARP_1 = 0x7123, + QK_MIDI_NOTE_E_1 = 0x7124, + QK_MIDI_NOTE_F_1 = 0x7125, + QK_MIDI_NOTE_F_SHARP_1 = 0x7126, + QK_MIDI_NOTE_G_1 = 0x7127, + QK_MIDI_NOTE_G_SHARP_1 = 0x7128, + QK_MIDI_NOTE_A_1 = 0x7129, + QK_MIDI_NOTE_A_SHARP_1 = 0x712A, + QK_MIDI_NOTE_B_1 = 0x712B, + QK_MIDI_NOTE_C_2 = 0x7130, + QK_MIDI_NOTE_C_SHARP_2 = 0x7131, + QK_MIDI_NOTE_D_2 = 0x7132, + QK_MIDI_NOTE_D_SHARP_2 = 0x7133, + QK_MIDI_NOTE_E_2 = 0x7134, + QK_MIDI_NOTE_F_2 = 0x7135, + QK_MIDI_NOTE_F_SHARP_2 = 0x7136, + QK_MIDI_NOTE_G_2 = 0x7137, + QK_MIDI_NOTE_G_SHARP_2 = 0x7138, + QK_MIDI_NOTE_A_2 = 0x7139, + QK_MIDI_NOTE_A_SHARP_2 = 0x713A, + QK_MIDI_NOTE_B_2 = 0x713B, + QK_MIDI_NOTE_C_3 = 0x7140, + QK_MIDI_NOTE_C_SHARP_3 = 0x7141, + QK_MIDI_NOTE_D_3 = 0x7142, + QK_MIDI_NOTE_D_SHARP_3 = 0x7143, + QK_MIDI_NOTE_E_3 = 0x7144, + QK_MIDI_NOTE_F_3 = 0x7145, + QK_MIDI_NOTE_F_SHARP_3 = 0x7146, + QK_MIDI_NOTE_G_3 = 0x7147, + QK_MIDI_NOTE_G_SHARP_3 = 0x7148, + QK_MIDI_NOTE_A_3 = 0x7149, + QK_MIDI_NOTE_A_SHARP_3 = 0x714A, + QK_MIDI_NOTE_B_3 = 0x714B, + QK_MIDI_NOTE_C_4 = 0x7150, + QK_MIDI_NOTE_C_SHARP_4 = 0x7151, + QK_MIDI_NOTE_D_4 = 0x7152, + QK_MIDI_NOTE_D_SHARP_4 = 0x7153, + QK_MIDI_NOTE_E_4 = 0x7154, + QK_MIDI_NOTE_F_4 = 0x7155, + QK_MIDI_NOTE_F_SHARP_4 = 0x7156, + QK_MIDI_NOTE_G_4 = 0x7157, + QK_MIDI_NOTE_G_SHARP_4 = 0x7158, + QK_MIDI_NOTE_A_4 = 0x7159, + QK_MIDI_NOTE_A_SHARP_4 = 0x715A, + QK_MIDI_NOTE_B_4 = 0x715B, + QK_MIDI_NOTE_C_5 = 0x7160, + QK_MIDI_NOTE_C_SHARP_5 = 0x7161, + QK_MIDI_NOTE_D_5 = 0x7162, + QK_MIDI_NOTE_D_SHARP_5 = 0x7163, + QK_MIDI_NOTE_E_5 = 0x7164, + QK_MIDI_NOTE_F_5 = 0x7165, + QK_MIDI_NOTE_F_SHARP_5 = 0x7166, + QK_MIDI_NOTE_G_5 = 0x7167, + QK_MIDI_NOTE_G_SHARP_5 = 0x7168, + QK_MIDI_NOTE_A_5 = 0x7169, + QK_MIDI_NOTE_A_SHARP_5 = 0x716A, + QK_MIDI_NOTE_B_5 = 0x716B, + QK_MIDI_OCTAVE_N2 = 0x7170, + QK_MIDI_OCTAVE_N1 = 0x7171, + QK_MIDI_OCTAVE_0 = 0x7172, + QK_MIDI_OCTAVE_1 = 0x7173, + QK_MIDI_OCTAVE_2 = 0x7174, + QK_MIDI_OCTAVE_3 = 0x7175, + QK_MIDI_OCTAVE_4 = 0x7176, + QK_MIDI_OCTAVE_5 = 0x7177, + QK_MIDI_OCTAVE_6 = 0x7178, + QK_MIDI_OCTAVE_7 = 0x7179, + QK_MIDI_OCTAVE_DOWN = 0x717A, + QK_MIDI_OCTAVE_UP = 0x717B, + QK_MIDI_TRANSPOSE_N6 = 0x7180, + QK_MIDI_TRANSPOSE_N5 = 0x7181, + QK_MIDI_TRANSPOSE_N4 = 0x7182, + QK_MIDI_TRANSPOSE_N3 = 0x7183, + QK_MIDI_TRANSPOSE_N2 = 0x7184, + QK_MIDI_TRANSPOSE_N1 = 0x7185, + QK_MIDI_TRANSPOSE_0 = 0x7186, + QK_MIDI_TRANSPOSE_1 = 0x7187, + QK_MIDI_TRANSPOSE_2 = 0x7188, + QK_MIDI_TRANSPOSE_3 = 0x7189, + QK_MIDI_TRANSPOSE_4 = 0x718A, + QK_MIDI_TRANSPOSE_5 = 0x718B, + QK_MIDI_TRANSPOSE_6 = 0x718C, + QK_MIDI_TRANSPOSE_DOWN = 0x718D, + QK_MIDI_TRANSPOSE_UP = 0x718E, + QK_MIDI_VELOCITY_0 = 0x7190, + QK_MIDI_VELOCITY_1 = 0x7191, + QK_MIDI_VELOCITY_2 = 0x7192, + QK_MIDI_VELOCITY_3 = 0x7193, + QK_MIDI_VELOCITY_4 = 0x7194, + QK_MIDI_VELOCITY_5 = 0x7195, + QK_MIDI_VELOCITY_6 = 0x7196, + QK_MIDI_VELOCITY_7 = 0x7197, + QK_MIDI_VELOCITY_8 = 0x7198, + QK_MIDI_VELOCITY_9 = 0x7199, + QK_MIDI_VELOCITY_10 = 0x719A, + QK_MIDI_VELOCITY_DOWN = 0x719B, + QK_MIDI_VELOCITY_UP = 0x719C, + QK_MIDI_CHANNEL_1 = 0x71A0, + QK_MIDI_CHANNEL_2 = 0x71A1, + QK_MIDI_CHANNEL_3 = 0x71A2, + QK_MIDI_CHANNEL_4 = 0x71A3, + QK_MIDI_CHANNEL_5 = 0x71A4, + QK_MIDI_CHANNEL_6 = 0x71A5, + QK_MIDI_CHANNEL_7 = 0x71A6, + QK_MIDI_CHANNEL_8 = 0x71A7, + QK_MIDI_CHANNEL_9 = 0x71A8, + QK_MIDI_CHANNEL_10 = 0x71A9, + QK_MIDI_CHANNEL_11 = 0x71AA, + QK_MIDI_CHANNEL_12 = 0x71AB, + QK_MIDI_CHANNEL_13 = 0x71AC, + QK_MIDI_CHANNEL_14 = 0x71AD, + QK_MIDI_CHANNEL_15 = 0x71AE, + QK_MIDI_CHANNEL_16 = 0x71AF, + QK_MIDI_CHANNEL_DOWN = 0x71B0, + QK_MIDI_CHANNEL_UP = 0x71B1, + QK_MIDI_ALL_NOTES_OFF = 0x71C0, + QK_MIDI_SUSTAIN = 0x71C1, + QK_MIDI_PORTAMENTO = 0x71C2, + QK_MIDI_SOSTENUTO = 0x71C3, + QK_MIDI_SOFT = 0x71C4, + QK_MIDI_LEGATO = 0x71C5, + QK_MIDI_MODULATION = 0x71C6, + QK_MIDI_MODULATION_SPEED_DOWN = 0x71C7, + QK_MIDI_MODULATION_SPEED_UP = 0x71C8, + QK_MIDI_PITCH_BEND_DOWN = 0x71C9, + QK_MIDI_PITCH_BEND_UP = 0x71CA, SQ_ON = 0x7200, SQ_OFF = 0x7201, SQ_TOG = 0x7202, @@ -898,36 +898,180 @@ enum qk_keycode_defines { EC_SWAP = MAGIC_SWAP_ESCAPE_CAPSLOCK, EC_NORM = MAGIC_UNSWAP_ESCAPE_CAPSLOCK, EC_TOGG = MAGIC_TOGGLE_ESCAPE_CAPSLOCK, - MI_Db = MI_Cs, - MI_Eb = MI_Ds, - MI_Gb = MI_Fs, - MI_Ab = MI_Gs, - MI_Bb = MI_As, - MI_Db_1 = MI_Cs_1, - MI_Eb_1 = MI_Ds_1, - MI_Gb_1 = MI_Fs_1, - MI_Ab_1 = MI_Gs_1, - MI_Bb_1 = MI_As_1, - MI_Db_2 = MI_Cs_2, - MI_Eb_2 = MI_Ds_2, - MI_Gb_2 = MI_Fs_2, - MI_Ab_2 = MI_Gs_2, - MI_Bb_2 = MI_As_2, - MI_Db_3 = MI_Cs_3, - MI_Eb_3 = MI_Ds_3, - MI_Gb_3 = MI_Fs_3, - MI_Ab_3 = MI_Gs_3, - MI_Bb_3 = MI_As_3, - MI_Db_4 = MI_Cs_4, - MI_Eb_4 = MI_Ds_4, - MI_Gb_4 = MI_Fs_4, - MI_Ab_4 = MI_Gs_4, - MI_Bb_4 = MI_As_4, - MI_Db_5 = MI_Cs_5, - MI_Eb_5 = MI_Ds_5, - MI_Gb_5 = MI_Fs_5, - MI_Ab_5 = MI_Gs_5, - MI_Bb_5 = MI_As_5, + MI_ON = QK_MIDI_ON, + MI_OFF = QK_MIDI_OFF, + MI_TOGG = QK_MIDI_TOGGLE, + MI_C = QK_MIDI_NOTE_C_0, + MI_Cs = QK_MIDI_NOTE_C_SHARP_0, + MI_Db = QK_MIDI_NOTE_C_SHARP_0, + MI_D = QK_MIDI_NOTE_D_0, + MI_Ds = QK_MIDI_NOTE_D_SHARP_0, + MI_Eb = QK_MIDI_NOTE_D_SHARP_0, + MI_E = QK_MIDI_NOTE_E_0, + MI_F = QK_MIDI_NOTE_F_0, + MI_Fs = QK_MIDI_NOTE_F_SHARP_0, + MI_Gb = QK_MIDI_NOTE_F_SHARP_0, + MI_G = QK_MIDI_NOTE_G_0, + MI_Gs = QK_MIDI_NOTE_G_SHARP_0, + MI_Ab = QK_MIDI_NOTE_G_SHARP_0, + MI_A = QK_MIDI_NOTE_A_0, + MI_As = QK_MIDI_NOTE_A_SHARP_0, + MI_Bb = QK_MIDI_NOTE_A_SHARP_0, + MI_B = QK_MIDI_NOTE_B_0, + MI_C1 = QK_MIDI_NOTE_C_1, + MI_Cs1 = QK_MIDI_NOTE_C_SHARP_1, + MI_Db1 = QK_MIDI_NOTE_C_SHARP_1, + MI_D1 = QK_MIDI_NOTE_D_1, + MI_Ds1 = QK_MIDI_NOTE_D_SHARP_1, + MI_Eb1 = QK_MIDI_NOTE_D_SHARP_1, + MI_E1 = QK_MIDI_NOTE_E_1, + MI_F1 = QK_MIDI_NOTE_F_1, + MI_Fs1 = QK_MIDI_NOTE_F_SHARP_1, + MI_Gb1 = QK_MIDI_NOTE_F_SHARP_1, + MI_G1 = QK_MIDI_NOTE_G_1, + MI_Gs1 = QK_MIDI_NOTE_G_SHARP_1, + MI_Ab1 = QK_MIDI_NOTE_G_SHARP_1, + MI_A1 = QK_MIDI_NOTE_A_1, + MI_As1 = QK_MIDI_NOTE_A_SHARP_1, + MI_Bb1 = QK_MIDI_NOTE_A_SHARP_1, + MI_B1 = QK_MIDI_NOTE_B_1, + MI_C2 = QK_MIDI_NOTE_C_2, + MI_Cs2 = QK_MIDI_NOTE_C_SHARP_2, + MI_Db2 = QK_MIDI_NOTE_C_SHARP_2, + MI_D2 = QK_MIDI_NOTE_D_2, + MI_Ds2 = QK_MIDI_NOTE_D_SHARP_2, + MI_Eb2 = QK_MIDI_NOTE_D_SHARP_2, + MI_E2 = QK_MIDI_NOTE_E_2, + MI_F2 = QK_MIDI_NOTE_F_2, + MI_Fs2 = QK_MIDI_NOTE_F_SHARP_2, + MI_Gb2 = QK_MIDI_NOTE_F_SHARP_2, + MI_G2 = QK_MIDI_NOTE_G_2, + MI_Gs2 = QK_MIDI_NOTE_G_SHARP_2, + MI_Ab2 = QK_MIDI_NOTE_G_SHARP_2, + MI_A2 = QK_MIDI_NOTE_A_2, + MI_As2 = QK_MIDI_NOTE_A_SHARP_2, + MI_Bb2 = QK_MIDI_NOTE_A_SHARP_2, + MI_B2 = QK_MIDI_NOTE_B_2, + MI_C3 = QK_MIDI_NOTE_C_3, + MI_Cs3 = QK_MIDI_NOTE_C_SHARP_3, + MI_Db3 = QK_MIDI_NOTE_C_SHARP_3, + MI_D3 = QK_MIDI_NOTE_D_3, + MI_Ds3 = QK_MIDI_NOTE_D_SHARP_3, + MI_Eb3 = QK_MIDI_NOTE_D_SHARP_3, + MI_E3 = QK_MIDI_NOTE_E_3, + MI_F3 = QK_MIDI_NOTE_F_3, + MI_Fs3 = QK_MIDI_NOTE_F_SHARP_3, + MI_Gb3 = QK_MIDI_NOTE_F_SHARP_3, + MI_G3 = QK_MIDI_NOTE_G_3, + MI_Gs3 = QK_MIDI_NOTE_G_SHARP_3, + MI_Ab3 = QK_MIDI_NOTE_G_SHARP_3, + MI_A3 = QK_MIDI_NOTE_A_3, + MI_As3 = QK_MIDI_NOTE_A_SHARP_3, + MI_Bb3 = QK_MIDI_NOTE_A_SHARP_3, + MI_B3 = QK_MIDI_NOTE_B_3, + MI_C4 = QK_MIDI_NOTE_C_4, + MI_Cs4 = QK_MIDI_NOTE_C_SHARP_4, + MI_Db4 = QK_MIDI_NOTE_C_SHARP_4, + MI_D4 = QK_MIDI_NOTE_D_4, + MI_Ds4 = QK_MIDI_NOTE_D_SHARP_4, + MI_Eb4 = QK_MIDI_NOTE_D_SHARP_4, + MI_E4 = QK_MIDI_NOTE_E_4, + MI_F4 = QK_MIDI_NOTE_F_4, + MI_Fs4 = QK_MIDI_NOTE_F_SHARP_4, + MI_Gb4 = QK_MIDI_NOTE_F_SHARP_4, + MI_G4 = QK_MIDI_NOTE_G_4, + MI_Gs4 = QK_MIDI_NOTE_G_SHARP_4, + MI_Ab4 = QK_MIDI_NOTE_G_SHARP_4, + MI_A4 = QK_MIDI_NOTE_A_4, + MI_As4 = QK_MIDI_NOTE_A_SHARP_4, + MI_Bb4 = QK_MIDI_NOTE_A_SHARP_4, + MI_B4 = QK_MIDI_NOTE_B_4, + MI_C5 = QK_MIDI_NOTE_C_5, + MI_Cs5 = QK_MIDI_NOTE_C_SHARP_5, + MI_Db5 = QK_MIDI_NOTE_C_SHARP_5, + MI_D5 = QK_MIDI_NOTE_D_5, + MI_Ds5 = QK_MIDI_NOTE_D_SHARP_5, + MI_Eb5 = QK_MIDI_NOTE_D_SHARP_5, + MI_E5 = QK_MIDI_NOTE_E_5, + MI_F5 = QK_MIDI_NOTE_F_5, + MI_Fs5 = QK_MIDI_NOTE_F_SHARP_5, + MI_Gb5 = QK_MIDI_NOTE_F_SHARP_5, + MI_G5 = QK_MIDI_NOTE_G_5, + MI_Gs5 = QK_MIDI_NOTE_G_SHARP_5, + MI_Ab5 = QK_MIDI_NOTE_G_SHARP_5, + MI_A5 = QK_MIDI_NOTE_A_5, + MI_As5 = QK_MIDI_NOTE_A_SHARP_5, + MI_Bb5 = QK_MIDI_NOTE_A_SHARP_5, + MI_B5 = QK_MIDI_NOTE_B_5, + MI_OCN2 = QK_MIDI_OCTAVE_N2, + MI_OCN1 = QK_MIDI_OCTAVE_N1, + MI_OC0 = QK_MIDI_OCTAVE_0, + MI_OC1 = QK_MIDI_OCTAVE_1, + MI_OC2 = QK_MIDI_OCTAVE_2, + MI_OC3 = QK_MIDI_OCTAVE_3, + MI_OC4 = QK_MIDI_OCTAVE_4, + MI_OC5 = QK_MIDI_OCTAVE_5, + MI_OC6 = QK_MIDI_OCTAVE_6, + MI_OC7 = QK_MIDI_OCTAVE_7, + MI_OCTD = QK_MIDI_OCTAVE_DOWN, + MI_OCTU = QK_MIDI_OCTAVE_UP, + MI_TRN6 = QK_MIDI_TRANSPOSE_N6, + MI_TRN5 = QK_MIDI_TRANSPOSE_N5, + MI_TRN4 = QK_MIDI_TRANSPOSE_N4, + MI_TRN3 = QK_MIDI_TRANSPOSE_N3, + MI_TRN2 = QK_MIDI_TRANSPOSE_N2, + MI_TRN1 = QK_MIDI_TRANSPOSE_N1, + MI_TR0 = QK_MIDI_TRANSPOSE_0, + MI_TR1 = QK_MIDI_TRANSPOSE_1, + MI_TR2 = QK_MIDI_TRANSPOSE_2, + MI_TR3 = QK_MIDI_TRANSPOSE_3, + MI_TR4 = QK_MIDI_TRANSPOSE_4, + MI_TR5 = QK_MIDI_TRANSPOSE_5, + MI_TR6 = QK_MIDI_TRANSPOSE_6, + MI_TRSD = QK_MIDI_TRANSPOSE_DOWN, + MI_TRSU = QK_MIDI_TRANSPOSE_UP, + MI_VL0 = QK_MIDI_VELOCITY_0, + MI_VL1 = QK_MIDI_VELOCITY_1, + MI_VL2 = QK_MIDI_VELOCITY_2, + MI_VL3 = QK_MIDI_VELOCITY_3, + MI_VL4 = QK_MIDI_VELOCITY_4, + MI_VL5 = QK_MIDI_VELOCITY_5, + MI_VL6 = QK_MIDI_VELOCITY_6, + MI_VL7 = QK_MIDI_VELOCITY_7, + MI_VL8 = QK_MIDI_VELOCITY_8, + MI_VL9 = QK_MIDI_VELOCITY_9, + MI_VL10 = QK_MIDI_VELOCITY_10, + MI_VELD = QK_MIDI_VELOCITY_DOWN, + MI_VELU = QK_MIDI_VELOCITY_UP, + MI_CH1 = QK_MIDI_CHANNEL_1, + MI_CH2 = QK_MIDI_CHANNEL_2, + MI_CH3 = QK_MIDI_CHANNEL_3, + MI_CH4 = QK_MIDI_CHANNEL_4, + MI_CH5 = QK_MIDI_CHANNEL_5, + MI_CH6 = QK_MIDI_CHANNEL_6, + MI_CH7 = QK_MIDI_CHANNEL_7, + MI_CH8 = QK_MIDI_CHANNEL_8, + MI_CH9 = QK_MIDI_CHANNEL_9, + MI_CH10 = QK_MIDI_CHANNEL_10, + MI_CH11 = QK_MIDI_CHANNEL_11, + MI_CH12 = QK_MIDI_CHANNEL_12, + MI_CH13 = QK_MIDI_CHANNEL_13, + MI_CH14 = QK_MIDI_CHANNEL_14, + MI_CH15 = QK_MIDI_CHANNEL_15, + MI_CH16 = QK_MIDI_CHANNEL_16, + MI_CHND = QK_MIDI_CHANNEL_DOWN, + MI_CHNU = QK_MIDI_CHANNEL_UP, + MI_AOFF = QK_MIDI_ALL_NOTES_OFF, + MI_SUST = QK_MIDI_SUSTAIN, + MI_PORT = QK_MIDI_PORTAMENTO, + MI_SOST = QK_MIDI_SOSTENUTO, + MI_SOFT = QK_MIDI_SOFT, + MI_LEG = QK_MIDI_LEGATO, + MI_MOD = QK_MIDI_MODULATION, + MI_MODD = QK_MIDI_MODULATION_SPEED_DOWN, + MI_MODU = QK_MIDI_MODULATION_SPEED_UP, + MI_BNDD = QK_MIDI_PITCH_BEND_DOWN, + MI_BNDU = QK_MIDI_PITCH_BEND_UP, JS_0 = QK_JOYSTICK_BUTTON_0, JS_1 = QK_JOYSTICK_BUTTON_1, JS_2 = QK_JOYSTICK_BUTTON_2, @@ -1151,7 +1295,7 @@ enum qk_keycode_defines { #define IS_MODIFIERS_KEYCODE(code) ((code) >= KC_LEFT_CTRL && (code) <= KC_RIGHT_GUI) #define IS_SWAP_HANDS_KEYCODE(code) ((code) >= SH_TG && (code) <= SH_OS) #define IS_MAGIC_KEYCODE(code) ((code) >= MAGIC_SWAP_CONTROL_CAPSLOCK && (code) <= MAGIC_TOGGLE_ESCAPE_CAPSLOCK) -#define IS_MIDI_KEYCODE(code) ((code) >= MI_ON && (code) <= MI_BENDU) +#define IS_MIDI_KEYCODE(code) ((code) >= QK_MIDI_ON && (code) <= QK_MIDI_PITCH_BEND_UP) #define IS_SEQUENCER_KEYCODE(code) ((code) >= SQ_ON && (code) <= SQ_SCLR) #define IS_JOYSTICK_KEYCODE(code) ((code) >= QK_JOYSTICK_BUTTON_0 && (code) <= QK_JOYSTICK_BUTTON_31) #define IS_PROGRAMMABLE_BUTTON_KEYCODE(code) ((code) >= QK_PROGRAMMABLE_BUTTON_1 && (code) <= QK_PROGRAMMABLE_BUTTON_32) @@ -1161,4 +1305,3 @@ enum qk_keycode_defines { #define IS_BACKLIGHT_KEYCODE(code) ((code) >= QK_BACKLIGHT_ON && (code) <= QK_BACKLIGHT_TOGGLE_BREATHING) #define IS_RGB_KEYCODE(code) ((code) >= RGB_TOG && (code) <= RGB_MODE_TWINKLE) #define IS_QUANTUM_KEYCODE(code) ((code) >= QK_BOOTLOADER && (code) <= QK_AUTOCORRECT_TOGGLE) - diff --git a/quantum/process_keycode/process_midi.c b/quantum/process_keycode/process_midi.c index c49c31a525..ce62559849 100644 --- a/quantum/process_keycode/process_midi.c +++ b/quantum/process_keycode/process_midi.c @@ -52,7 +52,7 @@ inline uint8_t compute_velocity(uint8_t setting) { } void midi_init(void) { - midi_config.octave = MI_OCT_2 - MIDI_OCTAVE_MIN; + midi_config.octave = QK_MIDI_OCTAVE_2 - MIDI_OCTAVE_MIN; midi_config.transpose = 0; midi_config.velocity = 127; midi_config.channel = 0; @@ -103,13 +103,13 @@ bool process_midi(uint16_t keycode, keyrecord_t *record) { dprintf("midi octave %d\n", midi_config.octave); } return false; - case MI_OCTD: + case QK_MIDI_OCTAVE_DOWN: if (record->event.pressed && midi_config.octave > 0) { midi_config.octave--; dprintf("midi octave %d\n", midi_config.octave); } return false; - case MI_OCTU: + case QK_MIDI_OCTAVE_UP: if (record->event.pressed && midi_config.octave < (MIDI_OCTAVE_MAX - MIDI_OCTAVE_MIN)) { midi_config.octave++; dprintf("midi octave %d\n", midi_config.octave); @@ -117,18 +117,18 @@ bool process_midi(uint16_t keycode, keyrecord_t *record) { return false; case MIDI_TRANSPOSE_MIN ... MIDI_TRANSPOSE_MAX: if (record->event.pressed) { - midi_config.transpose = keycode - MI_TRNS_0; + midi_config.transpose = keycode - QK_MIDI_TRANSPOSE_0; dprintf("midi transpose %d\n", midi_config.transpose); } return false; - case MI_TRNSD: - if (record->event.pressed && midi_config.transpose > (MIDI_TRANSPOSE_MIN - MI_TRNS_0)) { + case QK_MIDI_TRANSPOSE_DOWN: + if (record->event.pressed && midi_config.transpose > (MIDI_TRANSPOSE_MIN - QK_MIDI_TRANSPOSE_0)) { midi_config.transpose--; dprintf("midi transpose %d\n", midi_config.transpose); } return false; - case MI_TRNSU: - if (record->event.pressed && midi_config.transpose < (MIDI_TRANSPOSE_MAX - MI_TRNS_0)) { + case QK_MIDI_TRANSPOSE_UP: + if (record->event.pressed && midi_config.transpose < (MIDI_TRANSPOSE_MAX - QK_MIDI_TRANSPOSE_0)) { const bool positive = midi_config.transpose > 0; midi_config.transpose++; if (positive && midi_config.transpose < 0) midi_config.transpose--; @@ -141,7 +141,7 @@ bool process_midi(uint16_t keycode, keyrecord_t *record) { dprintf("midi velocity %d\n", midi_config.velocity); } return false; - case MI_VELD: + case QK_MIDI_VELOCITY_DOWN: if (record->event.pressed && midi_config.velocity > 0) { if (midi_config.velocity == 127) { midi_config.velocity -= 10; @@ -154,7 +154,7 @@ bool process_midi(uint16_t keycode, keyrecord_t *record) { dprintf("midi velocity %d\n", midi_config.velocity); } return false; - case MI_VELU: + case QK_MIDI_VELOCITY_UP: if (record->event.pressed && midi_config.velocity < 127) { if (midi_config.velocity < 115) { midi_config.velocity += 13; @@ -170,48 +170,48 @@ bool process_midi(uint16_t keycode, keyrecord_t *record) { dprintf("midi channel %d\n", midi_config.channel); } return false; - case MI_CHD: + case QK_MIDI_CHANNEL_DOWN: if (record->event.pressed) { midi_config.channel--; dprintf("midi channel %d\n", midi_config.channel); } return false; - case MI_CHU: + case QK_MIDI_CHANNEL_UP: if (record->event.pressed) { midi_config.channel++; dprintf("midi channel %d\n", midi_config.channel); } return false; - case MI_ALLOFF: + case QK_MIDI_ALL_NOTES_OFF: if (record->event.pressed) { midi_send_cc(&midi_device, midi_config.channel, 0x7B, 0); dprintf("midi all notes off\n"); } return false; - case MI_SUS: + case QK_MIDI_SUSTAIN: midi_send_cc(&midi_device, midi_config.channel, 0x40, record->event.pressed ? 127 : 0); dprintf("midi sustain %d\n", record->event.pressed); return false; - case MI_PORT: + case QK_MIDI_PORTAMENTO: midi_send_cc(&midi_device, midi_config.channel, 0x41, record->event.pressed ? 127 : 0); dprintf("midi portamento %d\n", record->event.pressed); return false; - case MI_SOST: + case QK_MIDI_SOSTENUTO: midi_send_cc(&midi_device, midi_config.channel, 0x42, record->event.pressed ? 127 : 0); dprintf("midi sostenuto %d\n", record->event.pressed); return false; - case MI_SOFT: + case QK_MIDI_SOFT: midi_send_cc(&midi_device, midi_config.channel, 0x43, record->event.pressed ? 127 : 0); dprintf("midi soft %d\n", record->event.pressed); return false; - case MI_LEG: - midi_send_cc(&midi_device, midi_config.channel, 0x43, record->event.pressed ? 127 : 0); + case QK_MIDI_LEGATO: + midi_send_cc(&midi_device, midi_config.channel, 0x44, record->event.pressed ? 127 : 0); dprintf("midi legato %d\n", record->event.pressed); return false; - case MI_MOD: + case QK_MIDI_MODULATION: midi_modulation_step = record->event.pressed ? 1 : -1; return false; - case MI_MODSD: + case QK_MIDI_MODULATION_SPEED_DOWN: if (record->event.pressed) { midi_config.modulation_interval++; // prevent overflow @@ -219,13 +219,13 @@ bool process_midi(uint16_t keycode, keyrecord_t *record) { dprintf("midi modulation interval %d\n", midi_config.modulation_interval); } return false; - case MI_MODSU: + case QK_MIDI_MODULATION_SPEED_UP: if (record->event.pressed && midi_config.modulation_interval > 0) { midi_config.modulation_interval--; dprintf("midi modulation interval %d\n", midi_config.modulation_interval); } return false; - case MI_BENDD: + case QK_MIDI_PITCH_BEND_DOWN: if (record->event.pressed) { midi_send_pitchbend(&midi_device, midi_config.channel, -0x2000); dprintf("midi pitchbend channel:%d amount:%d\n", midi_config.channel, -0x2000); @@ -234,7 +234,7 @@ bool process_midi(uint16_t keycode, keyrecord_t *record) { dprintf("midi pitchbend channel:%d amount:%d\n", midi_config.channel, 0); } return false; - case MI_BENDU: + case QK_MIDI_PITCH_BEND_UP: if (record->event.pressed) { midi_send_pitchbend(&midi_device, midi_config.channel, 0x1fff); dprintf("midi pitchbend channel:%d amount:%d\n", midi_config.channel, 0x1fff); diff --git a/quantum/process_keycode/process_music.c b/quantum/process_keycode/process_music.c index 950aec22f9..ee697a0cc6 100644 --- a/quantum/process_keycode/process_music.c +++ b/quantum/process_keycode/process_music.c @@ -120,17 +120,17 @@ bool process_music(uint16_t keycode, keyrecord_t *record) { return false; } - if (keycode == MI_ON && record->event.pressed) { + if (keycode == QK_MIDI_ON && record->event.pressed) { midi_on(); return false; } - if (keycode == MI_OFF && record->event.pressed) { + if (keycode == QK_MIDI_OFF && record->event.pressed) { midi_off(); return false; } - if (keycode == MI_TOG && record->event.pressed) { + if (keycode == QK_MIDI_TOGGLE && record->event.pressed) { if (midi_activated) { midi_off(); } else { diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 6b0e890792..688fb892eb 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -193,16 +193,16 @@ #define QK_SWAP_HANDS_GET_TAP_KEYCODE(kc) ((kc)&0xFF) // MIDI aliases -#define MIDI_TONE_MIN MI_C -#define MIDI_TONE_MAX MI_B_5 -#define MIDI_OCTAVE_MIN MI_OCT_N2 -#define MIDI_OCTAVE_MAX MI_OCT_7 -#define MIDI_TRANSPOSE_MIN MI_TRNS_N6 -#define MIDI_TRANSPOSE_MAX MI_TRNS_6 -#define MIDI_VELOCITY_MIN MI_VEL_0 -#define MIDI_VELOCITY_MAX MI_VEL_10 -#define MIDI_CHANNEL_MIN MI_CH1 -#define MIDI_CHANNEL_MAX MI_CH16 +#define MIDI_TONE_MIN QK_MIDI_NOTE_C_0 +#define MIDI_TONE_MAX QK_MIDI_NOTE_B_5 +#define MIDI_OCTAVE_MIN QK_MIDI_OCTAVE_N2 +#define MIDI_OCTAVE_MAX QK_MIDI_OCTAVE_7 +#define MIDI_TRANSPOSE_MIN QK_MIDI_TRANSPOSE_N6 +#define MIDI_TRANSPOSE_MAX QK_MIDI_TRANSPOSE_6 +#define MIDI_VELOCITY_MIN QK_MIDI_VELOCITY_0 +#define MIDI_VELOCITY_MAX QK_MIDI_VELOCITY_10 +#define MIDI_CHANNEL_MIN QK_MIDI_CHANNEL_1 +#define MIDI_CHANNEL_MAX QK_MIDI_CHANNEL_16 // TODO: somehow migrate sequencer to DD? #include "sequencer.h" diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h index e2133513bd..04bf687561 100644 --- a/quantum/quantum_keycodes_legacy.h +++ b/quantum/quantum_keycodes_legacy.h @@ -138,6 +138,136 @@ #define MUV_IN QK_AUDIO_VOICE_NEXT #define MUV_DE QK_AUDIO_VOICE_PREVIOUS +#define MI_TOG QK_MIDI_TOGGLE +#define MI_C_1 QK_MIDI_NOTE_C_1 +#define MI_Cs_1 QK_MIDI_NOTE_C_SHARP_1 +#define MI_Db_1 QK_MIDI_NOTE_C_SHARP_1 +#define MI_D_1 QK_MIDI_NOTE_D_1 +#define MI_Ds_1 QK_MIDI_NOTE_D_SHARP_1 +#define MI_Eb_1 QK_MIDI_NOTE_D_SHARP_1 +#define MI_E_1 QK_MIDI_NOTE_E_1 +#define MI_F_1 QK_MIDI_NOTE_F_1 +#define MI_Fs_1 QK_MIDI_NOTE_F_SHARP_1 +#define MI_Gb_1 QK_MIDI_NOTE_F_SHARP_1 +#define MI_G_1 QK_MIDI_NOTE_G_1 +#define MI_Gs_1 QK_MIDI_NOTE_G_SHARP_1 +#define MI_Ab_1 QK_MIDI_NOTE_G_SHARP_1 +#define MI_A_1 QK_MIDI_NOTE_A_1 +#define MI_As_1 QK_MIDI_NOTE_A_SHARP_1 +#define MI_Bb_1 QK_MIDI_NOTE_A_SHARP_1 +#define MI_B_1 QK_MIDI_NOTE_B_1 +#define MI_C_2 QK_MIDI_NOTE_C_2 +#define MI_Cs_2 QK_MIDI_NOTE_C_SHARP_2 +#define MI_Db_2 QK_MIDI_NOTE_C_SHARP_2 +#define MI_D_2 QK_MIDI_NOTE_D_2 +#define MI_Ds_2 QK_MIDI_NOTE_D_SHARP_2 +#define MI_Eb_2 QK_MIDI_NOTE_D_SHARP_2 +#define MI_E_2 QK_MIDI_NOTE_E_2 +#define MI_F_2 QK_MIDI_NOTE_F_2 +#define MI_Fs_2 QK_MIDI_NOTE_F_SHARP_2 +#define MI_Gb_2 QK_MIDI_NOTE_F_SHARP_2 +#define MI_G_2 QK_MIDI_NOTE_G_2 +#define MI_Gs_2 QK_MIDI_NOTE_G_SHARP_2 +#define MI_Ab_2 QK_MIDI_NOTE_G_SHARP_2 +#define MI_A_2 QK_MIDI_NOTE_A_2 +#define MI_As_2 QK_MIDI_NOTE_A_SHARP_2 +#define MI_Bb_2 QK_MIDI_NOTE_A_SHARP_2 +#define MI_B_2 QK_MIDI_NOTE_B_2 +#define MI_C_3 QK_MIDI_NOTE_C_3 +#define MI_Cs_3 QK_MIDI_NOTE_C_SHARP_3 +#define MI_Db_3 QK_MIDI_NOTE_C_SHARP_3 +#define MI_D_3 QK_MIDI_NOTE_D_3 +#define MI_Ds_3 QK_MIDI_NOTE_D_SHARP_3 +#define MI_Eb_3 QK_MIDI_NOTE_D_SHARP_3 +#define MI_E_3 QK_MIDI_NOTE_E_3 +#define MI_F_3 QK_MIDI_NOTE_F_3 +#define MI_Fs_3 QK_MIDI_NOTE_F_SHARP_3 +#define MI_Gb_3 QK_MIDI_NOTE_F_SHARP_3 +#define MI_G_3 QK_MIDI_NOTE_G_3 +#define MI_Gs_3 QK_MIDI_NOTE_G_SHARP_3 +#define MI_Ab_3 QK_MIDI_NOTE_G_SHARP_3 +#define MI_A_3 QK_MIDI_NOTE_A_3 +#define MI_As_3 QK_MIDI_NOTE_A_SHARP_3 +#define MI_Bb_3 QK_MIDI_NOTE_A_SHARP_3 +#define MI_B_3 QK_MIDI_NOTE_B_3 +#define MI_C_4 QK_MIDI_NOTE_C_4 +#define MI_Cs_4 QK_MIDI_NOTE_C_SHARP_4 +#define MI_Db_4 QK_MIDI_NOTE_C_SHARP_4 +#define MI_D_4 QK_MIDI_NOTE_D_4 +#define MI_Ds_4 QK_MIDI_NOTE_D_SHARP_4 +#define MI_Eb_4 QK_MIDI_NOTE_D_SHARP_4 +#define MI_E_4 QK_MIDI_NOTE_E_4 +#define MI_F_4 QK_MIDI_NOTE_F_4 +#define MI_Fs_4 QK_MIDI_NOTE_F_SHARP_4 +#define MI_Gb_4 QK_MIDI_NOTE_F_SHARP_4 +#define MI_G_4 QK_MIDI_NOTE_G_4 +#define MI_Gs_4 QK_MIDI_NOTE_G_SHARP_4 +#define MI_Ab_4 QK_MIDI_NOTE_G_SHARP_4 +#define MI_A_4 QK_MIDI_NOTE_A_4 +#define MI_As_4 QK_MIDI_NOTE_A_SHARP_4 +#define MI_Bb_4 QK_MIDI_NOTE_A_SHARP_4 +#define MI_B_4 QK_MIDI_NOTE_B_4 +#define MI_C_5 QK_MIDI_NOTE_C_5 +#define MI_Cs_5 QK_MIDI_NOTE_C_SHARP_5 +#define MI_Db_5 QK_MIDI_NOTE_C_SHARP_5 +#define MI_D_5 QK_MIDI_NOTE_D_5 +#define MI_Ds_5 QK_MIDI_NOTE_D_SHARP_5 +#define MI_Eb_5 QK_MIDI_NOTE_D_SHARP_5 +#define MI_E_5 QK_MIDI_NOTE_E_5 +#define MI_F_5 QK_MIDI_NOTE_F_5 +#define MI_Fs_5 QK_MIDI_NOTE_F_SHARP_5 +#define MI_Gb_5 QK_MIDI_NOTE_F_SHARP_5 +#define MI_G_5 QK_MIDI_NOTE_G_5 +#define MI_Gs_5 QK_MIDI_NOTE_G_SHARP_5 +#define MI_Ab_5 QK_MIDI_NOTE_G_SHARP_5 +#define MI_A_5 QK_MIDI_NOTE_A_5 +#define MI_As_5 QK_MIDI_NOTE_A_SHARP_5 +#define MI_Bb_5 QK_MIDI_NOTE_A_SHARP_5 +#define MI_B_5 QK_MIDI_NOTE_B_5 +#define MI_OCT_N2 QK_MIDI_OCTAVE_N2 +#define MI_OCT_N1 QK_MIDI_OCTAVE_N1 +#define MI_OCT_0 QK_MIDI_OCTAVE_0 +#define MI_OCT_1 QK_MIDI_OCTAVE_1 +#define MI_OCT_2 QK_MIDI_OCTAVE_2 +#define MI_OCT_3 QK_MIDI_OCTAVE_3 +#define MI_OCT_4 QK_MIDI_OCTAVE_4 +#define MI_OCT_5 QK_MIDI_OCTAVE_5 +#define MI_OCT_6 QK_MIDI_OCTAVE_6 +#define MI_OCT_7 QK_MIDI_OCTAVE_7 +#define MI_TRNS_N6 QK_MIDI_TRANSPOSE_N6 +#define MI_TRNS_N5 QK_MIDI_TRANSPOSE_N5 +#define MI_TRNS_N4 QK_MIDI_TRANSPOSE_N4 +#define MI_TRNS_N3 QK_MIDI_TRANSPOSE_N3 +#define MI_TRNS_N2 QK_MIDI_TRANSPOSE_N2 +#define MI_TRNS_N1 QK_MIDI_TRANSPOSE_N1 +#define MI_TRNS_0 QK_MIDI_TRANSPOSE_0 +#define MI_TRNS_1 QK_MIDI_TRANSPOSE_1 +#define MI_TRNS_2 QK_MIDI_TRANSPOSE_2 +#define MI_TRNS_3 QK_MIDI_TRANSPOSE_3 +#define MI_TRNS_4 QK_MIDI_TRANSPOSE_4 +#define MI_TRNS_5 QK_MIDI_TRANSPOSE_5 +#define MI_TRNS_6 QK_MIDI_TRANSPOSE_6 +#define MI_TRNSD QK_MIDI_TRANSPOSE_DOWN +#define MI_TRNSU QK_MIDI_TRANSPOSE_UP +#define MI_VEL_0 QK_MIDI_VELOCITY_0 +#define MI_VEL_1 QK_MIDI_VELOCITY_1 +#define MI_VEL_2 QK_MIDI_VELOCITY_2 +#define MI_VEL_3 QK_MIDI_VELOCITY_3 +#define MI_VEL_4 QK_MIDI_VELOCITY_4 +#define MI_VEL_5 QK_MIDI_VELOCITY_5 +#define MI_VEL_6 QK_MIDI_VELOCITY_6 +#define MI_VEL_7 QK_MIDI_VELOCITY_7 +#define MI_VEL_8 QK_MIDI_VELOCITY_8 +#define MI_VEL_9 QK_MIDI_VELOCITY_9 +#define MI_VEL_10 QK_MIDI_VELOCITY_10 +#define MI_CHD QK_MIDI_CHANNEL_DOWN +#define MI_CHU QK_MIDI_CHANNEL_UP +#define MI_ALLOFF QK_MIDI_ALL_NOTES_OFF +#define MI_MODSD QK_MIDI_MODULATION_SPEED_DOWN +#define MI_MODSU QK_MIDI_MODULATION_SPEED_UP +#define MI_BENDD QK_MIDI_PITCH_BEND_DOWN +#define MI_BENDU QK_MIDI_PITCH_BEND_UP + #define TERM_ON _Static_assert(false, "The Terminal feature has been removed from QMK. Please remove use of TERM_ON/TERM_OFF from your keymap.") #define TERM_OFF _Static_assert(false, "The Terminal feature has been removed from QMK.. Please remove use of TERM_ON/TERM_OFF from your keymap.") // #define RESET _Static_assert(false, "The RESET keycode has been removed from QMK.. Please remove use from your keymap.") diff --git a/quantum/sequencer/tests/sequencer_tests.cpp b/quantum/sequencer/tests/sequencer_tests.cpp index 05e58e4111..79ec10cabf 100644 --- a/quantum/sequencer/tests/sequencer_tests.cpp +++ b/quantum/sequencer/tests/sequencer_tests.cpp @@ -371,14 +371,14 @@ void setUpMatrixScanSequencerTest(void) { sequencer_config.resolution = SQ_RES_16; // Configure the notes for each track - sequencer_config.track_notes[0] = MI_C; - sequencer_config.track_notes[1] = MI_D; - sequencer_config.track_notes[2] = MI_E; - sequencer_config.track_notes[3] = MI_F; - sequencer_config.track_notes[4] = MI_G; - sequencer_config.track_notes[5] = MI_A; - sequencer_config.track_notes[6] = MI_B; - sequencer_config.track_notes[7] = MI_C; + sequencer_config.track_notes[0] = QK_MIDI_NOTE_C_0; + sequencer_config.track_notes[1] = QK_MIDI_NOTE_D_0; + sequencer_config.track_notes[2] = QK_MIDI_NOTE_E_0; + sequencer_config.track_notes[3] = QK_MIDI_NOTE_F_0; + sequencer_config.track_notes[4] = QK_MIDI_NOTE_G_0; + sequencer_config.track_notes[5] = QK_MIDI_NOTE_A_0; + sequencer_config.track_notes[6] = QK_MIDI_NOTE_B_0; + sequencer_config.track_notes[7] = QK_MIDI_NOTE_C_0; // Turn on some steps sequencer_config.steps[0] = (1 << 0); @@ -389,7 +389,7 @@ TEST_F(SequencerTest, TestMatrixScanSequencerShouldAttackFirstTrackOfFirstStep) setUpMatrixScanSequencerTest(); sequencer_task(); - EXPECT_EQ(last_noteon, MI_C); + EXPECT_EQ(last_noteon, QK_MIDI_NOTE_C_0); EXPECT_EQ(last_noteoff, 0); } @@ -499,7 +499,7 @@ TEST_F(SequencerTest, TestMatrixScanSequencerShouldReleaseFirstTrackFirstStep) { sequencer_task(); EXPECT_EQ(last_noteon, 0); - EXPECT_EQ(last_noteoff, MI_C); + EXPECT_EQ(last_noteoff, QK_MIDI_NOTE_C_0); } TEST_F(SequencerTest, TestMatrixScanSequencerShouldEnterPausePhaseAfterRelease) { @@ -565,7 +565,7 @@ TEST_F(SequencerTest, TestMatrixScanSequencerShouldProcessSecondTrackOnTime) { advance_time(SEQUENCER_TRACK_THROTTLE); sequencer_task(); - EXPECT_EQ(last_noteon, MI_D); + EXPECT_EQ(last_noteon, QK_MIDI_NOTE_D_0); EXPECT_EQ(last_noteoff, 0); } -- cgit v1.2.3 From e4d2ba9a4d98a8ff7327156ff45cc6339cb40c95 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Mon, 7 Nov 2022 02:43:53 +0000 Subject: Align haptic feedback keycode names (#18964) --- quantum/keycodes.h | 39 +++++++++++++++++++++----------- quantum/process_keycode/process_haptic.c | 26 ++++++++++----------- quantum/quantum_keycodes_legacy.h | 14 ++++++++++++ 3 files changed, 53 insertions(+), 26 deletions(-) (limited to 'quantum') diff --git a/quantum/keycodes.h b/quantum/keycodes.h index deb3565262..2b81261519 100644 --- a/quantum/keycodes.h +++ b/quantum/keycodes.h @@ -673,19 +673,19 @@ enum qk_keycode_defines { QK_UNICODE_MODE_BSD = 0x7C35, QK_UNICODE_MODE_WINCOMPOSE = 0x7C36, QK_UNICODE_MODE_EMACS = 0x7C37, - HPT_ON = 0x7C40, - HPT_OFF = 0x7C41, - HPT_TOG = 0x7C42, - HPT_RST = 0x7C43, - HPT_FBK = 0x7C44, - HPT_BUZ = 0x7C45, - HPT_MODI = 0x7C46, - HPT_MODD = 0x7C47, - HPT_CONT = 0x7C48, - HPT_CONI = 0x7C49, - HPT_COND = 0x7C4A, - HPT_DWLI = 0x7C4B, - HPT_DWLD = 0x7C4C, + QK_HAPTIC_ON = 0x7C40, + QK_HAPTIC_OFF = 0x7C41, + QK_HAPTIC_TOGGLE = 0x7C42, + QK_HAPTIC_RESET = 0x7C43, + QK_HAPTIC_FEEDBACK_TOGGLE = 0x7C44, + QK_HAPTIC_BUZZ_TOGGLE = 0x7C45, + QK_HAPTIC_MODE_NEXT = 0x7C46, + QK_HAPTIC_MODE_PREVIOUS = 0x7C47, + QK_HAPTIC_CONTINUOUS_TOGGLE = 0x7C48, + QK_HAPTIC_CONTINUOUS_UP = 0x7C49, + QK_HAPTIC_CONTINUOUS_DOWN = 0x7C4A, + QK_HAPTIC_DWELL_UP = 0x7C4B, + QK_HAPTIC_DWELL_DOWN = 0x7C4C, QK_COMBO_ON = 0x7C50, QK_COMBO_OFF = 0x7C51, QK_COMBO_TOGGLE = 0x7C52, @@ -1229,6 +1229,19 @@ enum qk_keycode_defines { UC_BSD = QK_UNICODE_MODE_BSD, UC_WINC = QK_UNICODE_MODE_WINCOMPOSE, UC_EMAC = QK_UNICODE_MODE_EMACS, + HF_ON = QK_HAPTIC_ON, + HF_OFF = QK_HAPTIC_OFF, + HF_TOGG = QK_HAPTIC_TOGGLE, + HF_RST = QK_HAPTIC_RESET, + HF_FDBK = QK_HAPTIC_FEEDBACK_TOGGLE, + HF_BUZZ = QK_HAPTIC_BUZZ_TOGGLE, + HF_NEXT = QK_HAPTIC_MODE_NEXT, + HF_PREV = QK_HAPTIC_MODE_PREVIOUS, + HF_CONT = QK_HAPTIC_CONTINUOUS_TOGGLE, + HF_CONU = QK_HAPTIC_CONTINUOUS_UP, + HF_COND = QK_HAPTIC_CONTINUOUS_DOWN, + HF_DWLU = QK_HAPTIC_DWELL_UP, + HF_DWLD = QK_HAPTIC_DWELL_DOWN, CM_ON = QK_COMBO_ON, CM_OFF = QK_COMBO_OFF, CM_TOGG = QK_COMBO_TOGGLE, diff --git a/quantum/process_keycode/process_haptic.c b/quantum/process_keycode/process_haptic.c index 0f07f9ac75..21d4c5ce30 100644 --- a/quantum/process_keycode/process_haptic.c +++ b/quantum/process_keycode/process_haptic.c @@ -87,43 +87,43 @@ __attribute__((weak)) bool get_haptic_enabled_key(uint16_t keycode, keyrecord_t bool process_haptic(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { switch (keycode) { - case HPT_ON: + case QK_HAPTIC_ON: haptic_enable(); break; - case HPT_OFF: + case QK_HAPTIC_OFF: haptic_disable(); break; - case HPT_TOG: + case QK_HAPTIC_TOGGLE: haptic_toggle(); break; - case HPT_RST: + case QK_HAPTIC_RESET: haptic_reset(); break; - case HPT_FBK: + case QK_HAPTIC_FEEDBACK_TOGGLE: haptic_feedback_toggle(); break; - case HPT_BUZ: + case QK_HAPTIC_BUZZ_TOGGLE: haptic_buzz_toggle(); break; - case HPT_MODI: + case QK_HAPTIC_MODE_NEXT: haptic_mode_increase(); break; - case HPT_MODD: + case QK_HAPTIC_MODE_PREVIOUS: haptic_mode_decrease(); break; - case HPT_DWLI: + case QK_HAPTIC_DWELL_UP: haptic_dwell_increase(); break; - case HPT_DWLD: + case QK_HAPTIC_DWELL_DOWN: haptic_dwell_decrease(); break; - case HPT_CONT: + case QK_HAPTIC_CONTINUOUS_TOGGLE: haptic_toggle_continuous(); break; - case HPT_CONI: + case QK_HAPTIC_CONTINUOUS_UP: haptic_cont_increase(); break; - case HPT_COND: + case QK_HAPTIC_CONTINUOUS_DOWN: haptic_cont_decrease(); break; } diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h index 04bf687561..305b89a569 100644 --- a/quantum/quantum_keycodes_legacy.h +++ b/quantum/quantum_keycodes_legacy.h @@ -268,6 +268,20 @@ #define MI_BENDD QK_MIDI_PITCH_BEND_DOWN #define MI_BENDU QK_MIDI_PITCH_BEND_UP +#define HPT_ON QK_HAPTIC_ON +#define HPT_OFF QK_HAPTIC_OFF +#define HPT_TOG QK_HAPTIC_TOGGLE +#define HPT_RST QK_HAPTIC_RESET +#define HPT_FBK QK_HAPTIC_FEEDBACK_TOGGLE +#define HPT_BUZ QK_HAPTIC_BUZZ_TOGGLE +#define HPT_MODI QK_HAPTIC_MODE_NEXT +#define HPT_MODD QK_HAPTIC_MODE_PREVIOUS +#define HPT_CONT QK_HAPTIC_CONTINUOUS_TOGGLE +#define HPT_CONI QK_HAPTIC_CONTINUOUS_UP +#define HPT_COND QK_HAPTIC_CONTINUOUS_DOWN +#define HPT_DWLI QK_HAPTIC_DWELL_UP +#define HPT_DWLD QK_HAPTIC_DWELL_DOWN + #define TERM_ON _Static_assert(false, "The Terminal feature has been removed from QMK. Please remove use of TERM_ON/TERM_OFF from your keymap.") #define TERM_OFF _Static_assert(false, "The Terminal feature has been removed from QMK.. Please remove use of TERM_ON/TERM_OFF from your keymap.") // #define RESET _Static_assert(false, "The RESET keycode has been removed from QMK.. Please remove use from your keymap.") -- cgit v1.2.3 From d810878d5e36e032ec99fb309b66caf3ea57e4ba Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 9 Nov 2022 06:03:31 +1100 Subject: Normalise output selection (Bluetooth) keycodes (#19004) --- quantum/keycodes.h | 9 ++++++--- quantum/quantum.c | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'quantum') diff --git a/quantum/keycodes.h b/quantum/keycodes.h index 2b81261519..c013858e78 100644 --- a/quantum/keycodes.h +++ b/quantum/keycodes.h @@ -662,9 +662,9 @@ enum qk_keycode_defines { QK_SPACE_CADET_LEFT_ALT_PARENTHESIS_OPEN = 0x7C1C, QK_SPACE_CADET_RIGHT_ALT_PARENTHESIS_CLOSE = 0x7C1D, QK_SPACE_CADET_RIGHT_SHIFT_ENTER = 0x7C1E, - OUT_AUTO = 0x7C20, - OUT_USB = 0x7C21, - OUT_BT = 0x7C22, + QK_OUTPUT_AUTO = 0x7C20, + QK_OUTPUT_USB = 0x7C21, + QK_OUTPUT_BLUETOOTH = 0x7C22, QK_UNICODE_MODE_NEXT = 0x7C30, QK_UNICODE_MODE_PREVIOUS = 0x7C31, QK_UNICODE_MODE_MACOS = 0x7C32, @@ -1221,6 +1221,9 @@ enum qk_keycode_defines { SC_LAPO = QK_SPACE_CADET_LEFT_ALT_PARENTHESIS_OPEN, SC_RAPC = QK_SPACE_CADET_RIGHT_ALT_PARENTHESIS_CLOSE, SC_SENT = QK_SPACE_CADET_RIGHT_SHIFT_ENTER, + OU_AUTO = QK_OUTPUT_AUTO, + OU_USB = QK_OUTPUT_USB, + OU_BT = QK_OUTPUT_BLUETOOTH, UC_NEXT = QK_UNICODE_MODE_NEXT, UC_PREV = QK_UNICODE_MODE_PREVIOUS, UC_MAC = QK_UNICODE_MODE_MACOS, diff --git a/quantum/quantum.c b/quantum/quantum.c index c60ec22d8b..e7dc71e5d7 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -381,13 +381,13 @@ bool process_record_quantum(keyrecord_t *record) { return false; #endif #ifdef BLUETOOTH_ENABLE - case OUT_AUTO: + case QK_OUTPUT_AUTO: set_output(OUTPUT_AUTO); return false; - case OUT_USB: + case QK_OUTPUT_USB: set_output(OUTPUT_USB); return false; - case OUT_BT: + case QK_OUTPUT_BLUETOOTH: set_output(OUTPUT_BLUETOOTH); return false; #endif -- cgit v1.2.3 From af52a9f8add3c1cef1b71c96fb3ee8f73485a26d Mon Sep 17 00:00:00 2001 From: Christopher Hoage Date: Wed, 9 Nov 2022 09:48:46 -0800 Subject: Fix jump in report value when scale changes during cirque get report (#18992) Fixes undefined --- quantum/pointing_device/pointing_device_drivers.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'quantum') diff --git a/quantum/pointing_device/pointing_device_drivers.c b/quantum/pointing_device/pointing_device_drivers.c index 172c9f36d7..d6f29c062e 100644 --- a/quantum/pointing_device/pointing_device_drivers.c +++ b/quantum/pointing_device/pointing_device_drivers.c @@ -123,9 +123,11 @@ bool auto_mouse_activation(report_mouse_t mouse_report) { # endif report_mouse_t cirque_pinnacle_get_report(report_mouse_t mouse_report) { + uint16_t scale = cirque_pinnacle_get_scale(); pinnacle_data_t touchData = cirque_pinnacle_read_data(); mouse_xy_report_t report_x = 0, report_y = 0; - static uint16_t x = 0, y = 0; + static uint16_t x = 0, y = 0, last_scale = 0; + # if defined(CIRQUE_PINNACLE_TAP_ENABLE) mouse_report.buttons = pointing_device_handle_buttons(mouse_report.buttons, false, POINTING_DEVICE_BUTTON1); # endif @@ -157,15 +159,16 @@ report_mouse_t cirque_pinnacle_get_report(report_mouse_t mouse_report) { # endif // Scale coordinates to arbitrary X, Y resolution - cirque_pinnacle_scale_data(&touchData, cirque_pinnacle_get_scale(), cirque_pinnacle_get_scale()); + cirque_pinnacle_scale_data(&touchData, scale, scale); if (!cirque_pinnacle_gestures(&mouse_report, touchData)) { - if (x && y && touchData.xValue && touchData.yValue) { + if (last_scale && scale == last_scale && x && y && touchData.xValue && touchData.yValue) { report_x = CONSTRAIN_HID_XY((int16_t)(touchData.xValue - x)); report_y = CONSTRAIN_HID_XY((int16_t)(touchData.yValue - y)); } - x = touchData.xValue; - y = touchData.yValue; + x = touchData.xValue; + y = touchData.yValue; + last_scale = scale; # ifdef POINTING_DEVICE_GESTURES_CURSOR_GLIDE_ENABLE if (cursor_glide_enable) { -- cgit v1.2.3 From bc6f8dc8b0822e5e03893eacffa42a7badb4c2fa Mon Sep 17 00:00:00 2001 From: Wilba Date: Thu, 10 Nov 2022 07:46:44 +1100 Subject: VIA V3 - The Custom UI Update (#18222) --- quantum/dynamic_keymap.c | 56 ++++-- quantum/dynamic_keymap.h | 6 + quantum/via.c | 479 ++++++++++++++++++++++++++++++++--------------- quantum/via.h | 94 ++++++++-- 4 files changed, 452 insertions(+), 183 deletions(-) (limited to 'quantum') diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c index e9529ed14e..c406be4585 100644 --- a/quantum/dynamic_keymap.c +++ b/quantum/dynamic_keymap.c @@ -279,9 +279,8 @@ void dynamic_keymap_macro_send(uint8_t id) { p = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR); void *end = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE); while (id > 0) { - // If we are past the end of the buffer, then the buffer - // contents are garbage, i.e. there were not DYNAMIC_KEYMAP_MACRO_COUNT - // nulls in the buffer. + // If we are past the end of the buffer, then there is + // no Nth macro in the buffer. if (p == end) { return; } @@ -291,9 +290,8 @@ void dynamic_keymap_macro_send(uint8_t id) { ++p; } - // Send the macro string one or three chars at a time - // by making temporary 1 or 3 char strings - char data[4] = {0, 0, 0, 0}; + // Send the macro string by making a temporary string. + char data[8] = {0}; // We already checked there was a null at the end of // the buffer, so this cannot go past the end while (1) { @@ -303,14 +301,44 @@ void dynamic_keymap_macro_send(uint8_t id) { if (data[0] == 0) { break; } - // If the char is magic (tap, down, up), - // add the next char (key to use) and send a 3 char string. - if (data[0] == SS_TAP_CODE || data[0] == SS_DOWN_CODE || data[0] == SS_UP_CODE) { - data[1] = data[0]; - data[0] = SS_QMK_PREFIX; - data[2] = eeprom_read_byte(p++); - if (data[2] == 0) { - break; + if (data[0] == SS_QMK_PREFIX) { + // Get the code + data[1] = eeprom_read_byte(p++); + // Unexpected null, abort. + if (data[1] == 0) { + return; + } + if (data[1] == SS_TAP_CODE || data[1] == SS_DOWN_CODE || data[1] == SS_UP_CODE) { + // Get the keycode + data[2] = eeprom_read_byte(p++); + // Unexpected null, abort. + if (data[2] == 0) { + return; + } + // Null terminate + data[3] = 0; + } else if (data[1] == SS_DELAY_CODE) { + // Get the number and '|' + // At most this is 4 digits plus '|' + uint8_t i = 2; + while (1) { + data[i] = eeprom_read_byte(p++); + // Unexpected null, abort + if (data[i] == 0) { + return; + } + // Found '|', send it + if (data[i] == '|') { + data[i + 1] = 0; + break; + } + // If haven't found '|' by i==6 then + // number too big, abort + if (i == 6) { + return; + } + ++i; + } } } send_string_with_delay(data, DYNAMIC_KEYMAP_MACRO_DELAY); diff --git a/quantum/dynamic_keymap.h b/quantum/dynamic_keymap.h index 459b48d07a..806342efa3 100644 --- a/quantum/dynamic_keymap.h +++ b/quantum/dynamic_keymap.h @@ -54,6 +54,12 @@ void dynamic_keymap_set_buffer(uint16_t offset, uint16_t size, uint8_t *data); // strings, the last byte must be a null when at maximum capacity, // and it not being null means the buffer can be considered in an // invalid state. +// +// The buffer *may* contain less macro strings than the maximum. +// This allows a higher maximum number of macros without requiring that +// number of nulls to be in the buffer. +// Note: dynamic_keymap_macro_get_count() returns the maximum that *can* be +// stored, not the current count of macros in the buffer. uint8_t dynamic_keymap_macro_get_count(void); uint16_t dynamic_keymap_macro_get_buffer_size(void); diff --git a/quantum/via.c b/quantum/via.c index 5afbee5a30..12ef6c6b2f 100644 --- a/quantum/via.c +++ b/quantum/via.c @@ -22,26 +22,6 @@ # error "DYNAMIC_KEYMAP_ENABLE is not enabled" #endif -// If VIA_CUSTOM_LIGHTING_ENABLE is not defined, then VIA_QMK_BACKLIGHT_ENABLE is set -// if BACKLIGHT_ENABLE is set, so handling of QMK Backlight values happens here by default. -// if VIA_CUSTOM_LIGHTING_ENABLE is defined, then VIA_QMK_BACKLIGHT_ENABLE must be explicitly -// set in keyboard-level config.h, so handling of QMK Backlight values happens here -#if defined(BACKLIGHT_ENABLE) && !defined(VIA_CUSTOM_LIGHTING_ENABLE) -# define VIA_QMK_BACKLIGHT_ENABLE -#endif - -// If VIA_CUSTOM_LIGHTING_ENABLE is not defined, then VIA_QMK_RGBLIGHT_ENABLE is set -// if RGBLIGHT_ENABLE is set, so handling of QMK RGBLIGHT values happens here by default. -// If VIA_CUSTOM_LIGHTING_ENABLE is defined, then VIA_QMK_RGBLIGHT_ENABLE must be explicitly -// set in keyboard-level config.h, so handling of QMK RGBLIGHT values happens here -#if defined(RGBLIGHT_ENABLE) && !defined(VIA_CUSTOM_LIGHTING_ENABLE) -# define VIA_QMK_RGBLIGHT_ENABLE -#endif - -#if defined(RGB_MATRIX_ENABLE) && !defined(VIA_QMK_RGBLIGHT_ENABLE) && !defined(VIA_CUSTOM_LIGHTING_ENABLE) -# define VIA_QMK_RGB_MATRIX_ENABLE -#endif - #include "quantum.h" #include "via.h" @@ -51,22 +31,8 @@ #include "eeprom.h" #include "version.h" // for QMK_BUILDDATE used in EEPROM magic -// Forward declare some helpers. -#if defined(VIA_QMK_BACKLIGHT_ENABLE) -void via_qmk_backlight_set_value(uint8_t *data); -void via_qmk_backlight_get_value(uint8_t *data); -#endif - -#if defined(VIA_QMK_RGBLIGHT_ENABLE) -void via_qmk_rgblight_set_value(uint8_t *data); -void via_qmk_rgblight_get_value(uint8_t *data); -#endif - -#if defined(VIA_QMK_RGB_MATRIX_ENABLE) +#if defined(RGB_MATRIX_ENABLE) # include -void via_qmk_rgb_matrix_set_value(uint8_t *data); -void via_qmk_rgb_matrix_get_value(uint8_t *data); -void eeconfig_update_rgb_matrix(void); #endif // Can be called in an overriding via_init_kb() to test if keyboard level code usage of @@ -155,6 +121,34 @@ void via_set_layout_options(uint32_t value) { } } +#if defined(AUDIO_ENABLE) +float via_device_indication_song[][2] = SONG(STARTUP_SOUND); +#endif // AUDIO_ENABLE + +// Used by VIA to tell a device to flash LEDs (or do something else) when that +// device becomes the active device being configured, on startup or switching +// between devices. This function will be called six times, at 200ms interval, +// with an incrementing value starting at zero. Since this function is called +// an even number of times, it can call a toggle function and leave things in +// the original state. +__attribute__((weak)) void via_set_device_indication(uint8_t value) { +#if defined(BACKLIGHT_ENABLE) + backlight_toggle(); +#endif // BACKLIGHT_ENABLE +#if defined(RGBLIGHT_ENABLE) + rgblight_toggle_noeeprom(); +#endif // RGBLIGHT_ENABLE +#if defined(RGB_MATRIX_ENABLE) + rgb_matrix_toggle_noeeprom(); +#endif // RGB_MATRIX_ENABLE +#if defined(AUDIO_ENABLE) + if (value == 0) { + wait_ms(10); + PLAY_SONG(via_device_indication_song); + } +#endif // AUDIO_ENABLE +} + // Called by QMK core to process VIA-specific keycodes. bool process_record_via(uint16_t keycode, keyrecord_t *record) { // Handle macros @@ -194,24 +188,96 @@ bool process_record_via(uint16_t keycode, keyrecord_t *record) { return true; } -// Keyboard level code can override this to handle custom messages from VIA. -// See raw_hid_receive() implementation. +// +// via_custom_value_command() has the default handling of custom values for Core modules. +// If a keyboard is using the default Core modules, it does not need to be overridden, +// the VIA keyboard definition will have matching channel/IDs. +// +// If a keyboard has some extra custom values, then via_custom_value_command_kb() can be +// overridden to handle the extra custom values, leaving via_custom_value_command() to +// handle the custom values for Core modules. +// +// If a keyboard has custom values and code that are overlapping with Core modules, +// then via_custom_value_command() can be overridden and call the same functions +// as the default implementation, or do whatever else is required. +// // DO NOT call raw_hid_send() in the override function. -__attribute__((weak)) void raw_hid_receive_kb(uint8_t *data, uint8_t length) { +// + +// This is the default handler for "extra" custom values, i.e. keyboard-specific custom values +// that are not handled by via_custom_value_command(). +__attribute__((weak)) void via_custom_value_command_kb(uint8_t *data, uint8_t length) { + // data = [ command_id, channel_id, value_id, value_data ] uint8_t *command_id = &(data[0]); - *command_id = id_unhandled; + // Return the unhandled state + *command_id = id_unhandled; } -// VIA handles received HID messages first, and will route to -// raw_hid_receive_kb() for command IDs that are not handled here. -// This gives the keyboard code level the ability to handle the command -// specifically. +// This is the default handler for custom value commands. +// It routes commands with channel IDs to command handlers as such: // -// raw_hid_send() is called at the end, with the same buffer, which was -// possibly modified with returned values. +// id_qmk_backlight_channel -> via_qmk_backlight_command() +// id_qmk_rgblight_channel -> via_qmk_rgblight_command() +// id_qmk_rgb_matrix_channel -> via_qmk_rgb_matrix_command() +// id_qmk_audio_channel -> via_qmk_audio_command() +// +__attribute__((weak)) void via_custom_value_command(uint8_t *data, uint8_t length) { + // data = [ command_id, channel_id, value_id, value_data ] + uint8_t *channel_id = &(data[1]); + +#if defined(BACKLIGHT_ENABLE) + if (*channel_id == id_qmk_backlight_channel) { + via_qmk_backlight_command(data, length); + return; + } +#endif // BACKLIGHT_ENABLE + +#if defined(RGBLIGHT_ENABLE) + if (*channel_id == id_qmk_rgblight_channel) { + via_qmk_rgblight_command(data, length); + return; + } +#endif // RGBLIGHT_ENABLE + +#if defined(RGB_MATRIX_ENABLE) + if (*channel_id == id_qmk_rgb_matrix_channel) { + via_qmk_rgb_matrix_command(data, length); + return; + } +#endif // RGBLIGHT_ENABLE + +#if defined(AUDIO_ENABLE) + if (*channel_id == id_qmk_audio_channel) { + via_qmk_audio_command(data, length); + return; + } +#endif // AUDIO_ENABLE + + (void)channel_id; // force use of variable + + // If we haven't returned before here, then let the keyboard level code + // handle this, if it is overridden, otherwise by default, this will + // return the unhandled state. + via_custom_value_command_kb(data, length); +} + +// Keyboard level code can override this, but shouldn't need to. +// Controlling custom features should be done by overriding +// via_custom_value_command_kb() instead. +__attribute__((weak)) bool via_command_kb(uint8_t *data, uint8_t length) { + return false; +} + void raw_hid_receive(uint8_t *data, uint8_t length) { uint8_t *command_id = &(data[0]); uint8_t *command_data = &(data[1]); + + // If via_command_kb() returns true, the command was fully + // handled, including calling raw_hid_send() + if (via_command_kb(data, length)) { + return; + } + switch (*command_id) { case id_get_protocol_version: { command_data[0] = VIA_PROTOCOL_VERSION >> 8; @@ -237,7 +303,10 @@ void raw_hid_receive(uint8_t *data, uint8_t length) { break; } case id_switch_matrix_state: { -#if ((MATRIX_COLS / 8 + 1) * MATRIX_ROWS <= 28) +// Round up to the nearest number of bytes required to hold row state. +// Multiply by number of rows to get the required size in bytes. +// Guard against this being too big for the HID message. +#if (((MATRIX_COLS + 7) / 8) * MATRIX_ROWS <= 28) uint8_t i = 1; for (uint8_t row = 0; row < MATRIX_ROWS; row++) { matrix_row_t value = matrix_get_row(row); @@ -255,8 +324,18 @@ void raw_hid_receive(uint8_t *data, uint8_t length) { #endif break; } + case id_firmware_version: { + uint32_t value = VIA_FIRMWARE_VERSION; + command_data[1] = (value >> 24) & 0xFF; + command_data[2] = (value >> 16) & 0xFF; + command_data[3] = (value >> 8) & 0xFF; + command_data[4] = value & 0xFF; + break; + } default: { - raw_hid_receive_kb(data, length); + // The value ID is not known + // Return the unhandled state + *command_id = id_unhandled; break; } } @@ -269,8 +348,15 @@ void raw_hid_receive(uint8_t *data, uint8_t length) { via_set_layout_options(value); break; } + case id_device_indication: { + uint8_t value = command_data[1]; + via_set_device_indication(value); + break; + } default: { - raw_hid_receive_kb(data, length); + // The value ID is not known + // Return the unhandled state + *command_id = id_unhandled; break; } } @@ -290,61 +376,10 @@ void raw_hid_receive(uint8_t *data, uint8_t length) { dynamic_keymap_reset(); break; } - case id_lighting_set_value: { -#if defined(VIA_QMK_BACKLIGHT_ENABLE) - via_qmk_backlight_set_value(command_data); -#endif -#if defined(VIA_QMK_RGBLIGHT_ENABLE) - via_qmk_rgblight_set_value(command_data); -#endif -#if defined(VIA_QMK_RGB_MATRIX_ENABLE) - via_qmk_rgb_matrix_set_value(command_data); -#endif -#if defined(VIA_CUSTOM_LIGHTING_ENABLE) - raw_hid_receive_kb(data, length); -#endif -#if !defined(VIA_QMK_BACKLIGHT_ENABLE) && !defined(VIA_QMK_RGBLIGHT_ENABLE) && !defined(VIA_CUSTOM_LIGHTING_ENABLE) && !defined(VIA_QMK_RGB_MATRIX_ENABLE) - // Return the unhandled state - *command_id = id_unhandled; -#endif - break; - } - case id_lighting_get_value: { -#if defined(VIA_QMK_BACKLIGHT_ENABLE) - via_qmk_backlight_get_value(command_data); -#endif -#if defined(VIA_QMK_RGBLIGHT_ENABLE) - via_qmk_rgblight_get_value(command_data); -#endif -#if defined(VIA_QMK_RGB_MATRIX_ENABLE) - via_qmk_rgb_matrix_get_value(command_data); -#endif -#if defined(VIA_CUSTOM_LIGHTING_ENABLE) - raw_hid_receive_kb(data, length); -#endif -#if !defined(VIA_QMK_BACKLIGHT_ENABLE) && !defined(VIA_QMK_RGBLIGHT_ENABLE) && !defined(VIA_CUSTOM_LIGHTING_ENABLE) && !defined(VIA_QMK_RGB_MATRIX_ENABLE) - // Return the unhandled state - *command_id = id_unhandled; -#endif - break; - } - case id_lighting_save: { -#if defined(VIA_QMK_BACKLIGHT_ENABLE) - eeconfig_update_backlight_current(); -#endif -#if defined(VIA_QMK_RGBLIGHT_ENABLE) - eeconfig_update_rgblight_current(); -#endif -#if defined(VIA_QMK_RGB_MATRIX_ENABLE) - eeconfig_update_rgb_matrix(); -#endif -#if defined(VIA_CUSTOM_LIGHTING_ENABLE) - raw_hid_receive_kb(data, length); -#endif -#if !defined(VIA_QMK_BACKLIGHT_ENABLE) && !defined(VIA_QMK_RGBLIGHT_ENABLE) && !defined(VIA_CUSTOM_LIGHTING_ENABLE) && !defined(VIA_QMK_RGB_MATRIX_ENABLE) - // Return the unhandled state - *command_id = id_unhandled; -#endif + case id_custom_set_value: + case id_custom_get_value: + case id_custom_save: { + via_custom_value_command(data, length); break; } #ifdef VIA_EEPROM_ALLOW_RESET @@ -421,13 +456,39 @@ void raw_hid_receive(uint8_t *data, uint8_t length) { raw_hid_send(data, length); } -#if defined(VIA_QMK_BACKLIGHT_ENABLE) +#if defined(BACKLIGHT_ENABLE) + +void via_qmk_backlight_command(uint8_t *data, uint8_t length) { + // data = [ command_id, channel_id, value_id, value_data ] + uint8_t *command_id = &(data[0]); + uint8_t *value_id_and_data = &(data[2]); + + switch (*command_id) { + case id_custom_set_value: { + via_qmk_backlight_set_value(value_id_and_data); + break; + } + case id_custom_get_value: { + via_qmk_backlight_get_value(value_id_and_data); + break; + } + case id_custom_save: { + via_qmk_backlight_save(); + break; + } + default: { + *command_id = id_unhandled; + break; + } + } +} # if BACKLIGHT_LEVELS == 0 # error BACKLIGHT_LEVELS == 0 # endif void via_qmk_backlight_get_value(uint8_t *data) { + // data = [ value_id, value_data ] uint8_t *value_id = &(data[0]); uint8_t *value_data = &(data[1]); switch (*value_id) { @@ -448,6 +509,7 @@ void via_qmk_backlight_get_value(uint8_t *data) { } void via_qmk_backlight_set_value(uint8_t *data) { + // data = [ value_id, value_data ] uint8_t *value_id = &(data[0]); uint8_t *value_data = &(data[1]); switch (*value_id) { @@ -469,14 +531,44 @@ void via_qmk_backlight_set_value(uint8_t *data) { } } -#endif // #if defined(VIA_QMK_BACKLIGHT_ENABLE) +void via_qmk_backlight_save(void) { + eeconfig_update_backlight_current(); +} + +#endif // BACKLIGHT_ENABLE -#if defined(VIA_QMK_RGBLIGHT_ENABLE) +#if defined(RGBLIGHT_ENABLE) # ifndef RGBLIGHT_LIMIT_VAL # define RGBLIGHT_LIMIT_VAL 255 # endif +void via_qmk_rgblight_command(uint8_t *data, uint8_t length) { + // data = [ command_id, channel_id, value_id, value_data ] + uint8_t *command_id = &(data[0]); + uint8_t *value_id_and_data = &(data[2]); + + switch (*command_id) { + case id_custom_set_value: { + via_qmk_rgblight_set_value(value_id_and_data); + break; + } + case id_custom_get_value: { + via_qmk_rgblight_get_value(value_id_and_data); + break; + } + case id_custom_save: { + via_qmk_rgblight_save(); + break; + } + default: { + *command_id = id_unhandled; + break; + } + } +} + void via_qmk_rgblight_get_value(uint8_t *data) { + // data = [ value_id, value_data ] uint8_t *value_id = &(data[0]); uint8_t *value_data = &(data[1]); switch (*value_id) { @@ -485,7 +577,7 @@ void via_qmk_rgblight_get_value(uint8_t *data) { break; } case id_qmk_rgblight_effect: { - value_data[0] = rgblight_get_mode(); + value_data[0] = rgblight_is_enabled() ? rgblight_get_mode() : 0; break; } case id_qmk_rgblight_effect_speed: { @@ -501,6 +593,7 @@ void via_qmk_rgblight_get_value(uint8_t *data) { } void via_qmk_rgblight_set_value(uint8_t *data) { + // data = [ value_id, value_data ] uint8_t *value_id = &(data[0]); uint8_t *value_data = &(data[1]); switch (*value_id) { @@ -509,11 +602,11 @@ void via_qmk_rgblight_set_value(uint8_t *data) { break; } case id_qmk_rgblight_effect: { - rgblight_mode_noeeprom(value_data[0]); if (value_data[0] == 0) { rgblight_disable_noeeprom(); } else { rgblight_enable_noeeprom(); + rgblight_mode_noeeprom(value_data[0]); } break; } @@ -528,92 +621,168 @@ void via_qmk_rgblight_set_value(uint8_t *data) { } } -#endif // #if defined(VIA_QMK_RGBLIGHT_ENABLE) +void via_qmk_rgblight_save(void) { + eeconfig_update_rgblight_current(); +} + +#endif // QMK_RGBLIGHT_ENABLE -#if defined(VIA_QMK_RGB_MATRIX_ENABLE) +#if defined(RGB_MATRIX_ENABLE) # if !defined(RGB_MATRIX_MAXIMUM_BRIGHTNESS) || RGB_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX # undef RGB_MATRIX_MAXIMUM_BRIGHTNESS # define RGB_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX # endif -// VIA supports only 4 discrete values for effect speed; map these to some -// useful speed values for RGB Matrix. -enum speed_values { - RGBLIGHT_SPEED_0 = UINT8_MAX / 16, // not 0 to avoid really slow effects - RGBLIGHT_SPEED_1 = UINT8_MAX / 4, - RGBLIGHT_SPEED_2 = UINT8_MAX / 2, // matches the default value - RGBLIGHT_SPEED_3 = UINT8_MAX / 4 * 3, // UINT8_MAX is really fast -}; - -static uint8_t speed_from_rgblight(uint8_t rgblight_speed) { - switch (rgblight_speed) { - case 0: - return RGBLIGHT_SPEED_0; - case 1: - return RGBLIGHT_SPEED_1; - case 2: - default: - return RGBLIGHT_SPEED_2; - case 3: - return RGBLIGHT_SPEED_3; - } -} +void via_qmk_rgb_matrix_command(uint8_t *data, uint8_t length) { + // data = [ command_id, channel_id, value_id, value_data ] + uint8_t *command_id = &(data[0]); + uint8_t *value_id_and_data = &(data[2]); -static uint8_t speed_to_rgblight(uint8_t rgb_matrix_speed) { - if (rgb_matrix_speed < ((RGBLIGHT_SPEED_0 + RGBLIGHT_SPEED_1) / 2)) { - return 0; - } else if (rgb_matrix_speed < ((RGBLIGHT_SPEED_1 + RGBLIGHT_SPEED_2) / 2)) { - return 1; - } else if (rgb_matrix_speed < ((RGBLIGHT_SPEED_2 + RGBLIGHT_SPEED_3) / 2)) { - return 2; - } else { - return 3; + switch (*command_id) { + case id_custom_set_value: { + via_qmk_rgb_matrix_set_value(value_id_and_data); + break; + } + case id_custom_get_value: { + via_qmk_rgb_matrix_get_value(value_id_and_data); + break; + } + case id_custom_save: { + via_qmk_rgb_matrix_save(); + break; + } + default: { + *command_id = id_unhandled; + break; + } } } void via_qmk_rgb_matrix_get_value(uint8_t *data) { + // data = [ value_id, value_data ] uint8_t *value_id = &(data[0]); uint8_t *value_data = &(data[1]); + switch (*value_id) { - case id_qmk_rgblight_brightness: + case id_qmk_rgb_matrix_brightness: { value_data[0] = ((uint16_t)rgb_matrix_get_val() * UINT8_MAX) / RGB_MATRIX_MAXIMUM_BRIGHTNESS; break; - case id_qmk_rgblight_effect: - value_data[0] = rgb_matrix_get_mode(); + } + case id_qmk_rgb_matrix_effect: { + value_data[0] = rgb_matrix_is_enabled() ? rgb_matrix_get_mode() : 0; break; - case id_qmk_rgblight_effect_speed: - value_data[0] = speed_to_rgblight(rgb_matrix_get_speed()); + } + case id_qmk_rgb_matrix_effect_speed: { + value_data[0] = rgb_matrix_get_speed(); break; - case id_qmk_rgblight_color: + } + case id_qmk_rgb_matrix_color: { value_data[0] = rgb_matrix_get_hue(); value_data[1] = rgb_matrix_get_sat(); break; + } } } void via_qmk_rgb_matrix_set_value(uint8_t *data) { + // data = [ value_id, value_data ] uint8_t *value_id = &(data[0]); uint8_t *value_data = &(data[1]); switch (*value_id) { - case id_qmk_rgblight_brightness: + case id_qmk_rgb_matrix_brightness: { rgb_matrix_sethsv_noeeprom(rgb_matrix_get_hue(), rgb_matrix_get_sat(), scale8(value_data[0], RGB_MATRIX_MAXIMUM_BRIGHTNESS)); break; - case id_qmk_rgblight_effect: - rgb_matrix_mode_noeeprom(value_data[0]); + } + case id_qmk_rgb_matrix_effect: { if (value_data[0] == 0) { rgb_matrix_disable_noeeprom(); } else { rgb_matrix_enable_noeeprom(); + rgb_matrix_mode_noeeprom(value_data[0]); } break; - case id_qmk_rgblight_effect_speed: - rgb_matrix_set_speed_noeeprom(speed_from_rgblight(value_data[0])); + } + case id_qmk_rgb_matrix_effect_speed: { + rgblight_set_speed_noeeprom(value_data[0]); + break; + } + case id_qmk_rgb_matrix_color: { + rgblight_sethsv_noeeprom(value_data[0], value_data[1], rgb_matrix_get_val()); + break; + } + } +} + +void via_qmk_rgb_matrix_save(void) { + eeconfig_update_rgb_matrix(); +} + +#endif // RGB_MATRIX_ENABLE + +#if defined(AUDIO_ENABLE) + +extern audio_config_t audio_config; + +void via_qmk_audio_command(uint8_t *data, uint8_t length) { + // data = [ command_id, channel_id, value_id, value_data ] + uint8_t *command_id = &(data[0]); + uint8_t *value_id_and_data = &(data[2]); + + switch (*command_id) { + case id_custom_set_value: { + via_qmk_audio_set_value(value_id_and_data); + break; + } + case id_custom_get_value: { + via_qmk_audio_get_value(value_id_and_data); + break; + } + case id_custom_save: { + via_qmk_audio_save(); + break; + } + default: { + *command_id = id_unhandled; + break; + } + } +} + +void via_qmk_audio_get_value(uint8_t *data) { + // data = [ value_id, value_data ] + uint8_t *value_id = &(data[0]); + uint8_t *value_data = &(data[1]); + switch (*value_id) { + case id_qmk_audio_enable: { + value_data[0] = audio_config.enable ? 1 : 0; break; - case id_qmk_rgblight_color: - rgb_matrix_sethsv_noeeprom(value_data[0], value_data[1], rgb_matrix_get_val()); + } + case id_qmk_audio_clicky_enable: { + value_data[0] = audio_config.clicky_enable ? 1 : 0; break; + } } } -#endif // #if defined(VIA_QMK_RGB_MATRIX_ENABLE) +void via_qmk_audio_set_value(uint8_t *data) { + // data = [ value_id, value_data ] + uint8_t *value_id = &(data[0]); + uint8_t *value_data = &(data[1]); + switch (*value_id) { + case id_qmk_audio_enable: { + audio_config.enable = value_data[0] ? 1 : 0; + break; + } + case id_qmk_audio_clicky_enable: { + audio_config.clicky_enable = value_data[0] ? 1 : 0; + break; + } + } +} + +void via_qmk_audio_save(void) { + eeconfig_update_audio(audio_config.raw); +} + +#endif // QMK_AUDIO_ENABLE diff --git a/quantum/via.h b/quantum/via.h index 84b264903f..eca0733525 100644 --- a/quantum/via.h +++ b/quantum/via.h @@ -60,6 +60,16 @@ // so VIA Configurator can detect compatible firmware. #define VIA_PROTOCOL_VERSION 0x000B +// This is a version number for the firmware for the keyboard. +// It can be used to ensure the VIA keyboard definition and the firmware +// have the same version, especially if there are changes to custom values. +// Define this in config.h to override and bump this number. +// This is *not* required if the keyboard is only using basic functionality +// and not using custom values for lighting, rotary encoders, etc. +#ifndef VIA_FIRMWARE_VERSION +# define VIA_FIRMWARE_VERSION 0x00000000 +#endif + enum via_command_id { id_get_protocol_version = 0x01, // always 0x01 id_get_keyboard_value = 0x02, @@ -67,9 +77,9 @@ enum via_command_id { id_dynamic_keymap_get_keycode = 0x04, id_dynamic_keymap_set_keycode = 0x05, id_dynamic_keymap_reset = 0x06, - id_lighting_set_value = 0x07, - id_lighting_get_value = 0x08, - id_lighting_save = 0x09, + id_custom_set_value = 0x07, + id_custom_get_value = 0x08, + id_custom_save = 0x09, id_eeprom_reset = 0x0A, id_bootloader_jump = 0x0B, id_dynamic_keymap_macro_get_count = 0x0C, @@ -86,21 +96,43 @@ enum via_command_id { }; enum via_keyboard_value_id { - id_uptime = 0x01, // + id_uptime = 0x01, id_layout_options = 0x02, - id_switch_matrix_state = 0x03 + id_switch_matrix_state = 0x03, + id_firmware_version = 0x04, + id_device_indication = 0x05, }; -enum via_lighting_value { - // QMK BACKLIGHT - id_qmk_backlight_brightness = 0x09, - id_qmk_backlight_effect = 0x0A, +enum via_channel_id { + id_custom_channel = 0, + id_qmk_backlight_channel = 1, + id_qmk_rgblight_channel = 2, + id_qmk_rgb_matrix_channel = 3, + id_qmk_audio_channel = 4, +}; + +enum via_qmk_backlight_value { + id_qmk_backlight_brightness = 1, + id_qmk_backlight_effect = 2, +}; + +enum via_qmk_rgblight_value { + id_qmk_rgblight_brightness = 1, + id_qmk_rgblight_effect = 2, + id_qmk_rgblight_effect_speed = 3, + id_qmk_rgblight_color = 4, +}; + +enum via_qmk_rgb_matrix_value { + id_qmk_rgb_matrix_brightness = 1, + id_qmk_rgb_matrix_effect = 2, + id_qmk_rgb_matrix_effect_speed = 3, + id_qmk_rgb_matrix_color = 4, +}; - // QMK RGBLIGHT - id_qmk_rgblight_brightness = 0x80, - id_qmk_rgblight_effect = 0x81, - id_qmk_rgblight_effect_speed = 0x82, - id_qmk_rgblight_color = 0x83, +enum via_qmk_audio_value { + id_qmk_audio_enable = 1, + id_qmk_audio_clicky_enable = 2, }; enum via_keycodes { @@ -160,5 +192,39 @@ uint32_t via_get_layout_options(void); void via_set_layout_options(uint32_t value); void via_set_layout_options_kb(uint32_t value); +// Used by VIA to tell a device to flash LEDs (or do something else) when that +// device becomes the active device being configured, on startup or switching +// between devices. +void via_set_device_indication(uint8_t value); + // Called by QMK core to process VIA-specific keycodes. bool process_record_via(uint16_t keycode, keyrecord_t *record); + +// These are made external so that keyboard level custom value handlers can use them. +#if defined(BACKLIGHT_ENABLE) +void via_qmk_backlight_command(uint8_t *data, uint8_t length); +void via_qmk_backlight_set_value(uint8_t *data); +void via_qmk_backlight_get_value(uint8_t *data); +void via_qmk_backlight_save(void); +#endif + +#if defined(RGBLIGHT_ENABLE) +void via_qmk_rgblight_command(uint8_t *data, uint8_t length); +void via_qmk_rgblight_set_value(uint8_t *data); +void via_qmk_rgblight_get_value(uint8_t *data); +void via_qmk_rgblight_save(void); +#endif + +#if defined(RGB_MATRIX_ENABLE) +void via_qmk_rgb_matrix_command(uint8_t *data, uint8_t length); +void via_qmk_rgb_matrix_set_value(uint8_t *data); +void via_qmk_rgb_matrix_get_value(uint8_t *data); +void via_qmk_rgb_matrix_save(void); +#endif + +#if defined(AUDIO_ENABLE) +void via_qmk_audio_command(uint8_t *data, uint8_t length); +void via_qmk_audio_set_value(uint8_t *data); +void via_qmk_audio_get_value(uint8_t *data); +void via_qmk_audio_save(void); +#endif \ No newline at end of file -- cgit v1.2.3 From f6baf916a9ac14cd150f65054573cd1a0e732c5a Mon Sep 17 00:00:00 2001 From: Joshua Diamond Date: Thu, 10 Nov 2022 04:27:40 -0500 Subject: Avoid repeated calls to rgblight_set() in tight succession when setting lighting layers (#18338) Co-authored-by: Sergey Vlasov --- quantum/rgblight/rgblight.c | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) (limited to 'quantum') diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c index 37cd7a66ab..f832854c5f 100644 --- a/quantum/rgblight/rgblight.c +++ b/quantum/rgblight/rgblight.c @@ -127,6 +127,8 @@ LED_TYPE led[RGBLED_NUM]; #ifdef RGBLIGHT_LAYERS rgblight_segment_t const *const *rgblight_layers = NULL; + +static bool deferred_set_layer_state = false; #endif rgblight_ranges_t rgblight_ranges = {0, RGBLED_NUM, 0, RGBLED_NUM, RGBLED_NUM}; @@ -748,17 +750,13 @@ void rgblight_set_layer_state(uint8_t layer, bool enabled) { rgblight_status.enabled_layer_mask &= ~mask; } RGBLIGHT_SPLIT_SET_CHANGE_LAYERS; - // Static modes don't have a ticker running to update the LEDs - if (rgblight_status.timer_enabled == false) { - rgblight_mode_noeeprom(rgblight_config.mode); - } -# ifdef RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF - // If not enabled, then nothing else will actually set the LEDs... - if (!rgblight_config.enable) { - rgblight_set(); - } -# endif + // Calling rgblight_set() here (directly or indirectly) could + // potentially cause timing issues when there are multiple + // successive calls to rgblight_set_layer_state(). Instead, + // set a flag and do it the next time rgblight_task() runs. + + deferred_set_layer_state = true; } bool rgblight_get_layer_state(uint8_t layer) { @@ -1154,8 +1152,26 @@ void rgblight_task(void) { } } -# ifdef RGBLIGHT_LAYER_BLINK +# ifdef RGBLIGHT_LAYERS +# ifdef RGBLIGHT_LAYER_BLINK rgblight_blink_layer_repeat_helper(); +# endif + + if (deferred_set_layer_state) { + deferred_set_layer_state = false; + + // Static modes don't have a ticker running to update the LEDs + if (rgblight_status.timer_enabled == false) { + rgblight_mode_noeeprom(rgblight_config.mode); + } + +# ifdef RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF + // If not enabled, then nothing else will actually set the LEDs... + if (!rgblight_config.enable) { + rgblight_set(); + } +# endif + } # endif } -- cgit v1.2.3 From 1caedd10c45adef49724f5aa0967e23286f4dd38 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 11 Nov 2022 18:11:50 -0800 Subject: Don't clear keys on layer change unless STRICT_LAYER_RELEASE is enabled (#18577) * Don't clear mousekeys unless clearing keys * Revert "Don't clear mousekeys unless clearing keys" This reverts commit 29a0c06b547d72b80d416a8b6fab478c77fbd247. * Just don't clear anything on layer set * Fix lint * Enable test? --- quantum/action_layer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'quantum') diff --git a/quantum/action_layer.c b/quantum/action_layer.c index 8ef337a690..31cfdfe13a 100644 --- a/quantum/action_layer.c +++ b/quantum/action_layer.c @@ -45,9 +45,9 @@ static void default_layer_state_set(layer_state_t state) { default_layer_state = state; default_layer_debug(); debug("\n"); -#ifdef STRICT_LAYER_RELEASE +#if defined(STRICT_LAYER_RELEASE) clear_keyboard_but_mods(); // To avoid stuck keys -#else +#elif defined(SEMI_STRICT_LAYER_RELEASE) clear_keyboard_but_mods_and_keys(); // Don't reset held keys #endif } @@ -125,9 +125,9 @@ void layer_state_set(layer_state_t state) { layer_state = state; layer_debug(); dprintln(); -# ifdef STRICT_LAYER_RELEASE +# if defined(STRICT_LAYER_RELEASE) clear_keyboard_but_mods(); // To avoid stuck keys -# else +# elif defined(SEMI_STRICT_LAYER_RELEASE) clear_keyboard_but_mods_and_keys(); // Don't reset held keys # endif } -- cgit v1.2.3 From 6cc9513ab0cd5e21354c51ab83a89af9f2eb517e Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 13 Nov 2022 10:28:11 +1100 Subject: Digitizer feature improvements (#19034) --- quantum/digitizer.c | 64 +++++++++++++++++++++++++++++++++++++++----------- quantum/digitizer.h | 67 ++++++++++++++++++++++++++++++++++++++++++++--------- quantum/keyboard.c | 7 ------ quantum/quantum.h | 4 ++++ 4 files changed, 111 insertions(+), 31 deletions(-) (limited to 'quantum') diff --git a/quantum/digitizer.c b/quantum/digitizer.c index 7925129d0c..f1b926181e 100644 --- a/quantum/digitizer.c +++ b/quantum/digitizer.c @@ -13,26 +13,64 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + #include "digitizer.h" -digitizer_t digitizerReport = {.tipswitch = 0, .inrange = 0, .id = 0, .x = 0, .y = 0, .status = DZ_INITIALIZED}; +digitizer_t digitizer_state = { + .in_range = false, + .tip = false, + .barrel = false, + .x = 0, + .y = 0, + .dirty = false, +}; -__attribute__((weak)) void digitizer_send(void) { - if (digitizerReport.status & DZ_UPDATED) { - host_digitizer_send(&digitizerReport); - digitizerReport.status &= ~DZ_UPDATED; +void digitizer_flush(void) { + if (digitizer_state.dirty) { + host_digitizer_send(&digitizer_state); + digitizer_state.dirty = false; } } -__attribute__((weak)) void digitizer_task(void) { - digitizer_send(); +void digitizer_in_range_on(void) { + digitizer_state.in_range = true; + digitizer_state.dirty = true; + digitizer_flush(); +} + +void digitizer_in_range_off(void) { + digitizer_state.in_range = false; + digitizer_state.dirty = true; + digitizer_flush(); +} + +void digitizer_tip_switch_on(void) { + digitizer_state.tip = true; + digitizer_state.dirty = true; + digitizer_flush(); } -digitizer_t digitizer_get_report(void) { - return digitizerReport; +void digitizer_tip_switch_off(void) { + digitizer_state.tip = false; + digitizer_state.dirty = true; + digitizer_flush(); } -void digitizer_set_report(digitizer_t newDigitizerReport) { - digitizerReport = newDigitizerReport; - digitizerReport.status |= DZ_UPDATED; -} \ No newline at end of file +void digitizer_barrel_switch_on(void) { + digitizer_state.barrel = true; + digitizer_state.dirty = true; + digitizer_flush(); +} + +void digitizer_barrel_switch_off(void) { + digitizer_state.barrel = false; + digitizer_state.dirty = true; + digitizer_flush(); +} + +void digitizer_set_position(float x, float y) { + digitizer_state.x = x; + digitizer_state.y = y; + digitizer_state.dirty = true; + digitizer_flush(); +} diff --git a/quantum/digitizer.h b/quantum/digitizer.h index cef551567e..b826ba8ac8 100644 --- a/quantum/digitizer.h +++ b/quantum/digitizer.h @@ -17,25 +17,70 @@ #include "quantum.h" +#include #include -enum digitizer_status { DZ_INITIALIZED = 1, DZ_UPDATED = 2 }; +/** + * \defgroup digitizer + * + * HID Digitizer + * \{ + */ typedef struct { - int8_t tipswitch; - int8_t inrange; - uint8_t id; - float x; - float y; - uint8_t status : 2; + bool in_range : 1; + bool tip : 1; + bool barrel : 1; + float x; + float y; + bool dirty; } digitizer_t; -extern digitizer_t digitizer; +extern digitizer_t digitizer_state; -digitizer_t digitizer_get_report(void); +/** + * \brief Send the digitizer report to the host if it is marked as dirty. + */ +void digitizer_flush(void); -void digitizer_set_report(digitizer_t newDigitizerReport); +/** + * \brief Assert the "in range" indicator, and flush the report. + */ +void digitizer_in_range_on(void); -void digitizer_task(void); +/** + * \brief Deassert the "in range" indicator, and flush the report. + */ +void digitizer_in_range_off(void); + +/** + * \brief Assert the tip switch, and flush the report. + */ +void digitizer_tip_switch_on(void); + +/** + * \brief Deassert the tip switch, and flush the report. + */ +void digitizer_tip_switch_off(void); + +/** + * \brief Assert the barrel switch, and flush the report. + */ +void digitizer_barrel_switch_on(void); + +/** + * \brief Deassert the barrel switch, and flush the report. + */ +void digitizer_barrel_switch_off(void); + +/** + * \brief Set the absolute X and Y position of the digitizer contact, and flush the report. + * + * \param x The X value of the contact position, from 0 to 1. + * \param y The Y value of the contact position, from 0 to 1. + */ +void digitizer_set_position(float x, float y); void host_digitizer_send(digitizer_t *digitizer); + +/** \} */ diff --git a/quantum/keyboard.c b/quantum/keyboard.c index eb5e4b583a..83ade7829a 100644 --- a/quantum/keyboard.c +++ b/quantum/keyboard.c @@ -90,9 +90,6 @@ along with this program. If not, see . #if defined(CRC_ENABLE) # include "crc.h" #endif -#ifdef DIGITIZER_ENABLE -# include "digitizer.h" -#endif #ifdef VIRTSER_ENABLE # include "virtser.h" #endif @@ -662,10 +659,6 @@ void keyboard_task(void) { joystick_task(); #endif -#ifdef DIGITIZER_ENABLE - digitizer_task(); -#endif - #ifdef BLUETOOTH_ENABLE bluetooth_task(); #endif diff --git a/quantum/quantum.h b/quantum/quantum.h index 4192b3fb16..c8dfdeca75 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -207,6 +207,10 @@ extern layer_state_t layer_state; # include "joystick.h" #endif +#ifdef DIGITIZER_ENABLE +# include "digitizer.h" +#endif + #ifdef VIA_ENABLE # include "via.h" #endif -- cgit v1.2.3 From 8812872794b5fb09e6bbbe47a58cc7dbcaca18a7 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Sun, 13 Nov 2022 07:51:19 -0800 Subject: Only trigger encoder callbacks on primary side (#18467) Co-authored-by: zvecr --- quantum/encoder.c | 14 ++- quantum/encoder/tests/config_mock_split_role.h | 26 +++++ quantum/encoder/tests/encoder_tests_split_role.cpp | 122 +++++++++++++++++++++ quantum/encoder/tests/mock.c | 4 + quantum/encoder/tests/mock_split.c | 4 + quantum/encoder/tests/rules.mk | 10 ++ quantum/encoder/tests/testlist.mk | 3 +- 7 files changed, 180 insertions(+), 3 deletions(-) create mode 100644 quantum/encoder/tests/config_mock_split_role.h create mode 100644 quantum/encoder/tests/encoder_tests_split_role.cpp (limited to 'quantum') diff --git a/quantum/encoder.c b/quantum/encoder.c index 1393e34868..3aee340249 100644 --- a/quantum/encoder.c +++ b/quantum/encoder.c @@ -80,6 +80,10 @@ __attribute__((weak)) bool encoder_update_kb(uint8_t index, bool clockwise) { return encoder_update_user(index, clockwise); } +__attribute__((weak)) bool should_process_encoder(void) { + return is_keyboard_master(); +} + void encoder_init(void) { #ifdef SPLIT_KEYBOARD thisHand = isLeftHand ? 0 : NUM_ENCODERS_LEFT; @@ -179,8 +183,11 @@ static bool encoder_update(uint8_t index, uint8_t state) { encoder_value[index]++; changed = true; +#ifdef SPLIT_KEYBOARD + if (should_process_encoder()) +#endif // SPLIT_KEYBOARD #ifdef ENCODER_MAP_ENABLE - encoder_exec_mapping(index, ENCODER_COUNTER_CLOCKWISE); + encoder_exec_mapping(index, ENCODER_COUNTER_CLOCKWISE); #else // ENCODER_MAP_ENABLE encoder_update_kb(index, ENCODER_COUNTER_CLOCKWISE); #endif // ENCODER_MAP_ENABLE @@ -193,8 +200,11 @@ static bool encoder_update(uint8_t index, uint8_t state) { #endif encoder_value[index]--; changed = true; +#ifdef SPLIT_KEYBOARD + if (should_process_encoder()) +#endif // SPLIT_KEYBOARD #ifdef ENCODER_MAP_ENABLE - encoder_exec_mapping(index, ENCODER_CLOCKWISE); + encoder_exec_mapping(index, ENCODER_CLOCKWISE); #else // ENCODER_MAP_ENABLE encoder_update_kb(index, ENCODER_CLOCKWISE); #endif // ENCODER_MAP_ENABLE diff --git a/quantum/encoder/tests/config_mock_split_role.h b/quantum/encoder/tests/config_mock_split_role.h new file mode 100644 index 0000000000..c80ac4d519 --- /dev/null +++ b/quantum/encoder/tests/config_mock_split_role.h @@ -0,0 +1,26 @@ +// Copyright 2022 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +#define MATRIX_ROWS 1 +#define MATRIX_COLS 1 + +/* Here, "pins" from 0 to 31 are allowed. */ +#define ENCODERS_PAD_A \ + { 0, 2 } +#define ENCODERS_PAD_B \ + { 1, 3 } +#define ENCODERS_PAD_A_RIGHT \ + { 4, 6 } +#define ENCODERS_PAD_B_RIGHT \ + { 5, 7 } + +#ifdef __cplusplus +extern "C" { +#endif + +#include "mock_split.h" + +#ifdef __cplusplus +}; +#endif diff --git a/quantum/encoder/tests/encoder_tests_split_role.cpp b/quantum/encoder/tests/encoder_tests_split_role.cpp new file mode 100644 index 0000000000..02264067f4 --- /dev/null +++ b/quantum/encoder/tests/encoder_tests_split_role.cpp @@ -0,0 +1,122 @@ +/* Copyright 2021 Balz Guenat + * + * 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 . + */ + +#include "gtest/gtest.h" +#include "gmock/gmock.h" +#include +#include +#include + +extern "C" { +#include "encoder.h" +#include "encoder/tests/mock_split.h" +} + +struct update { + int8_t index; + bool clockwise; +}; + +uint8_t num_updates = 0; + +bool isMaster; +bool isLeftHand; + +bool is_keyboard_master(void) { + return isMaster; +} + +bool encoder_update_kb(uint8_t index, bool clockwise) { + if (!isMaster) { + ADD_FAILURE() << "We shouldn't get here."; + } + num_updates++; + return true; +} + +bool setAndRead(pin_t pin, bool val) { + setPin(pin, val); + return encoder_read(); +} + +class EncoderSplitTestRole : public ::testing::Test { + protected: + void SetUp() override { + num_updates = 0; + for (int i = 0; i < 32; i++) { + pinIsInputHigh[i] = 0; + pins[i] = 0; + } + } +}; + +TEST_F(EncoderSplitTestRole, TestPrimaryLeft) { + isMaster = true; + isLeftHand = true; + encoder_init(); + // send 4 pulses. with resolution 4, that's one step and we should get 1 update. + setAndRead(0, false); + setAndRead(1, false); + setAndRead(0, true); + setAndRead(1, true); + + EXPECT_EQ(num_updates, 1); // one update received +} + +TEST_F(EncoderSplitTestRole, TestPrimaryRight) { + isMaster = true; + isLeftHand = false; + encoder_init(); + // send 4 pulses. with resolution 4, that's one step and we should get 1 update. + setAndRead(6, false); + setAndRead(7, false); + setAndRead(6, true); + setAndRead(7, true); + + uint8_t slave_state[32] = {0}; + encoder_state_raw(slave_state); + + EXPECT_EQ(num_updates, 1); // one update received +} + +TEST_F(EncoderSplitTestRole, TestNotPrimaryLeft) { + isMaster = false; + isLeftHand = true; + encoder_init(); + // send 4 pulses. with resolution 4, that's one step and we should get 1 update. + setAndRead(0, false); + setAndRead(1, false); + setAndRead(0, true); + setAndRead(1, true); + + EXPECT_EQ(num_updates, 0); // zero updates received +} + +TEST_F(EncoderSplitTestRole, TestNotPrimaryRight) { + isMaster = false; + isLeftHand = false; + encoder_init(); + // send 4 pulses. with resolution 4, that's one step and we should get 1 update. + setAndRead(6, false); + setAndRead(7, false); + setAndRead(6, true); + setAndRead(7, true); + + uint8_t slave_state[32] = {0}; + encoder_state_raw(slave_state); + + EXPECT_EQ(num_updates, 0); // zero updates received +} diff --git a/quantum/encoder/tests/mock.c b/quantum/encoder/tests/mock.c index 10a00cb8f2..61f2f8294d 100644 --- a/quantum/encoder/tests/mock.c +++ b/quantum/encoder/tests/mock.c @@ -34,3 +34,7 @@ bool setPin(pin_t pin, bool val) { pins[pin] = val; return val; } + +__attribute__((weak)) bool is_keyboard_master(void) { + return true; +} diff --git a/quantum/encoder/tests/mock_split.c b/quantum/encoder/tests/mock_split.c index dd3c26d958..5cc6cd19e1 100644 --- a/quantum/encoder/tests/mock_split.c +++ b/quantum/encoder/tests/mock_split.c @@ -36,3 +36,7 @@ bool setPin(pin_t pin, bool val) { } void last_encoder_activity_trigger(void) {} + +__attribute__((weak)) bool is_keyboard_master(void) { + return true; +} diff --git a/quantum/encoder/tests/rules.mk b/quantum/encoder/tests/rules.mk index 6a2611952c..d01c1c66ee 100644 --- a/quantum/encoder/tests/rules.mk +++ b/quantum/encoder/tests/rules.mk @@ -56,3 +56,13 @@ encoder_split_no_right_SRC := \ $(QUANTUM_PATH)/encoder/tests/mock_split.c \ $(QUANTUM_PATH)/encoder/tests/encoder_tests_split_no_right.cpp \ $(QUANTUM_PATH)/encoder.c + +encoder_split_role_DEFS := -DENCODER_TESTS -DENCODER_ENABLE -DENCODER_MOCK_SPLIT +encoder_split_role_INC := $(QUANTUM_PATH)/split_common +encoder_split_role_CONFIG := $(QUANTUM_PATH)/encoder/tests/config_mock_split_role.h + +encoder_split_role_SRC := \ + platforms/test/timer.c \ + $(QUANTUM_PATH)/encoder/tests/mock_split.c \ + $(QUANTUM_PATH)/encoder/tests/encoder_tests_split_role.cpp \ + $(QUANTUM_PATH)/encoder.c diff --git a/quantum/encoder/tests/testlist.mk b/quantum/encoder/tests/testlist.mk index 6b2fd84d96..a407f1fadd 100644 --- a/quantum/encoder/tests/testlist.mk +++ b/quantum/encoder/tests/testlist.mk @@ -4,4 +4,5 @@ TEST_LIST += \ encoder_split_left_gt_right \ encoder_split_left_lt_right \ encoder_split_no_left \ - encoder_split_no_right + encoder_split_no_right \ + encoder_split_role \ -- cgit v1.2.3 From c1ef943ce0dccacd222b66cffaac43417c840373 Mon Sep 17 00:00:00 2001 From: nicknimchuk <32887909+nicknimchuk@users.noreply.github.com> Date: Sun, 13 Nov 2022 10:34:59 -0600 Subject: Add missing prototype for get_hold_on_other_key_press to resolve #18855 (#19056) Closes undefined --- quantum/action_tapping.h | 1 + 1 file changed, 1 insertion(+) (limited to 'quantum') diff --git a/quantum/action_tapping.h b/quantum/action_tapping.h index 9b64c93120..bcccc7ac45 100644 --- a/quantum/action_tapping.h +++ b/quantum/action_tapping.h @@ -40,6 +40,7 @@ bool get_permissive_hold(uint16_t keycode, keyrecord_t *record); bool get_ignore_mod_tap_interrupt(uint16_t keycode, keyrecord_t *record); bool get_tapping_force_hold(uint16_t keycode, keyrecord_t *record); bool get_retro_tapping(uint16_t keycode, keyrecord_t *record); +bool get_hold_on_other_key_press(uint16_t keycode, keyrecord_t *record); #ifdef DYNAMIC_TAPPING_TERM_ENABLE extern uint16_t g_tapping_term; -- cgit v1.2.3 From 57ac917b4366cbd25044ed59496e6b4f3bb9a17a Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Wed, 16 Nov 2022 07:06:49 +0000 Subject: Extend eeconfig kb/user datablock API (#19094) --- quantum/eeconfig.c | 42 ++++++++++++++++++++++++++++++++++-------- quantum/eeconfig.h | 4 ++++ 2 files changed, 38 insertions(+), 8 deletions(-) (limited to 'quantum') diff --git a/quantum/eeconfig.c b/quantum/eeconfig.c index 3b4d690e42..21bcce2654 100644 --- a/quantum/eeconfig.c +++ b/quantum/eeconfig.c @@ -71,15 +71,11 @@ void eeconfig_init_quantum(void) { #endif #if (EECONFIG_KB_DATA_SIZE) > 0 - eeprom_update_dword(EECONFIG_KEYBOARD, (EECONFIG_KB_DATA_VERSION)); - uint8_t dummy_kb[(EECONFIG_KB_DATA_SIZE)] = {0}; - eeprom_update_block(EECONFIG_KB_DATABLOCK, dummy_kb, (EECONFIG_KB_DATA_SIZE)); + eeconfig_init_kb_datablock(); #endif #if (EECONFIG_USER_DATA_SIZE) > 0 - eeprom_update_dword(EECONFIG_USER, (EECONFIG_USER_DATA_VERSION)); - uint8_t dummy_user[(EECONFIG_USER_DATA_SIZE)] = {0}; - eeprom_update_block(EECONFIG_USER_DATABLOCK, dummy_user, (EECONFIG_USER_DATA_SIZE)); + eeconfig_init_user_datablock(); #endif #if defined(VIA_ENABLE) @@ -273,12 +269,19 @@ void eeconfig_update_handedness(bool val) { } #if (EECONFIG_KB_DATA_SIZE) > 0 +/** \brief eeconfig assert keyboard data block version + * + * FIXME: needs doc + */ +bool eeconfig_is_kb_datablock_valid(void) { + return eeprom_read_dword(EECONFIG_KEYBOARD) == (EECONFIG_KB_DATA_VERSION); +} /** \brief eeconfig read keyboard data block * * FIXME: needs doc */ void eeconfig_read_kb_datablock(void *data) { - if (eeprom_read_dword(EECONFIG_KEYBOARD) == (EECONFIG_KB_DATA_VERSION)) { + if (eeconfig_is_kb_datablock_valid()) { eeprom_read_block(data, EECONFIG_KB_DATABLOCK, (EECONFIG_KB_DATA_SIZE)); } else { memset(data, 0, (EECONFIG_KB_DATA_SIZE)); @@ -292,15 +295,30 @@ void eeconfig_update_kb_datablock(const void *data) { eeprom_update_dword(EECONFIG_KEYBOARD, (EECONFIG_KB_DATA_VERSION)); eeprom_update_block(data, EECONFIG_KB_DATABLOCK, (EECONFIG_KB_DATA_SIZE)); } +/** \brief eeconfig init keyboard data block + * + * FIXME: needs doc + */ +__attribute__((weak)) void eeconfig_init_kb_datablock(void) { + uint8_t dummy_kb[(EECONFIG_KB_DATA_SIZE)] = {0}; + eeconfig_update_kb_datablock(dummy_kb); +} #endif // (EECONFIG_KB_DATA_SIZE) > 0 #if (EECONFIG_USER_DATA_SIZE) > 0 +/** \brief eeconfig assert user data block version + * + * FIXME: needs doc + */ +bool eeconfig_is_user_datablock_valid(void) { + return eeprom_read_dword(EECONFIG_USER) == (EECONFIG_USER_DATA_VERSION); +} /** \brief eeconfig read user data block * * FIXME: needs doc */ void eeconfig_read_user_datablock(void *data) { - if (eeprom_read_dword(EECONFIG_USER) == (EECONFIG_USER_DATA_VERSION)) { + if (eeconfig_is_user_datablock_valid()) { eeprom_read_block(data, EECONFIG_USER_DATABLOCK, (EECONFIG_USER_DATA_SIZE)); } else { memset(data, 0, (EECONFIG_USER_DATA_SIZE)); @@ -314,4 +332,12 @@ void eeconfig_update_user_datablock(const void *data) { eeprom_update_dword(EECONFIG_USER, (EECONFIG_USER_DATA_VERSION)); eeprom_update_block(data, EECONFIG_USER_DATABLOCK, (EECONFIG_USER_DATA_SIZE)); } +/** \brief eeconfig init user data block + * + * FIXME: needs doc + */ +__attribute__((weak)) void eeconfig_init_user_datablock(void) { + uint8_t dummy_user[(EECONFIG_USER_DATA_SIZE)] = {0}; + eeconfig_update_user_datablock(dummy_user); +} #endif // (EECONFIG_USER_DATA_SIZE) > 0 diff --git a/quantum/eeconfig.h b/quantum/eeconfig.h index 9fc563d09c..ee8e9add8b 100644 --- a/quantum/eeconfig.h +++ b/quantum/eeconfig.h @@ -134,13 +134,17 @@ bool eeconfig_read_handedness(void); void eeconfig_update_handedness(bool val); #if (EECONFIG_KB_DATA_SIZE) > 0 +bool eeconfig_is_kb_datablock_valid(void); void eeconfig_read_kb_datablock(void *data); void eeconfig_update_kb_datablock(const void *data); +void eeconfig_init_kb_datablock(void); #endif // (EECONFIG_KB_DATA_SIZE) > 0 #if (EECONFIG_USER_DATA_SIZE) > 0 +bool eeconfig_is_user_datablock_valid(void); void eeconfig_read_user_datablock(void *data); void eeconfig_update_user_datablock(const void *data); +void eeconfig_init_user_datablock(void); #endif // (EECONFIG_USER_DATA_SIZE) > 0 // Any "checked" debounce variant used requires implementation of: -- cgit v1.2.3 From 31fb55ae7b495508c2fd3d56616d11564a0c3f0c Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Wed, 16 Nov 2022 14:46:11 -0700 Subject: fixed MOUSEKEY_INERTIA on AVR (#19096) Co-authored-by: Selene ToyKeeper --- quantum/mousekey.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'quantum') diff --git a/quantum/mousekey.c b/quantum/mousekey.c index b91db80de6..703fb39fa6 100644 --- a/quantum/mousekey.c +++ b/quantum/mousekey.c @@ -129,7 +129,7 @@ static int8_t move_unit(uint8_t axis) { // x**2 acceleration (quadratic, more precise for short movements) int16_t percent = (inertia << 8) / mk_time_to_max; - percent = (percent * percent) >> 8; + percent = ((int32_t)percent * percent) >> 8; if (inertia < 0) percent = -percent; // unit = sign(inertia) + (percent of max speed) -- cgit v1.2.3 From a5a20cc792540c0de61f064bd8dafcdc5815d4cc Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 27 Nov 2022 03:14:35 +1100 Subject: Change `LED_MATRIX_STARTUP_*` defines to `LED_MATRIX_DEFAULT_*` (#19080) --- quantum/led_matrix/led_matrix.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'quantum') diff --git a/quantum/led_matrix/led_matrix.c b/quantum/led_matrix/led_matrix.c index e215c2c2c3..577331d916 100644 --- a/quantum/led_matrix/led_matrix.c +++ b/quantum/led_matrix/led_matrix.c @@ -71,16 +71,16 @@ const led_point_t k_led_matrix_center = LED_MATRIX_CENTER; # define LED_MATRIX_SPD_STEP 16 #endif -#if !defined(LED_MATRIX_STARTUP_MODE) -# define LED_MATRIX_STARTUP_MODE LED_MATRIX_SOLID +#if !defined(LED_MATRIX_DEFAULT_MODE) +# define LED_MATRIX_DEFAULT_MODE LED_MATRIX_SOLID #endif -#if !defined(LED_MATRIX_STARTUP_VAL) -# define LED_MATRIX_STARTUP_VAL LED_MATRIX_MAXIMUM_BRIGHTNESS +#if !defined(LED_MATRIX_DEFAULT_VAL) +# define LED_MATRIX_DEFAULT_VAL LED_MATRIX_MAXIMUM_BRIGHTNESS #endif -#if !defined(LED_MATRIX_STARTUP_SPD) -# define LED_MATRIX_STARTUP_SPD UINT8_MAX / 2 +#if !defined(LED_MATRIX_DEFAULT_SPD) +# define LED_MATRIX_DEFAULT_SPD UINT8_MAX / 2 #endif // globals @@ -123,9 +123,9 @@ void eeconfig_update_led_matrix(void) { void eeconfig_update_led_matrix_default(void) { dprintf("eeconfig_update_led_matrix_default\n"); led_matrix_eeconfig.enable = 1; - led_matrix_eeconfig.mode = LED_MATRIX_STARTUP_MODE; - led_matrix_eeconfig.val = LED_MATRIX_STARTUP_VAL; - led_matrix_eeconfig.speed = LED_MATRIX_STARTUP_SPD; + led_matrix_eeconfig.mode = LED_MATRIX_DEFAULT_MODE; + led_matrix_eeconfig.val = LED_MATRIX_DEFAULT_VAL; + led_matrix_eeconfig.speed = LED_MATRIX_DEFAULT_SPD; led_matrix_eeconfig.flags = LED_FLAG_ALL; eeconfig_flush_led_matrix(true); } -- cgit v1.2.3 From 1e95f7be8f214c544bf99f415916a4a5f07a1e9b Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 27 Nov 2022 03:14:45 +1100 Subject: Joystick feature improvements (#19052) --- quantum/joystick.c | 55 ++++++++++++++++++++------------------ quantum/joystick.h | 77 +++++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 86 insertions(+), 46 deletions(-) (limited to 'quantum') diff --git a/quantum/joystick.c b/quantum/joystick.c index d285dcdb5e..057a018dff 100644 --- a/quantum/joystick.c +++ b/quantum/joystick.c @@ -19,45 +19,48 @@ #include "analog.h" #include "wait.h" -// clang-format off -joystick_t joystick_status = { +joystick_t joystick_state = { .buttons = {0}, - .axes = { -#if JOYSTICK_AXES_COUNT > 0 - 0 + .axes = + { +#if JOYSTICK_AXIS_COUNT > 0 + 0 #endif - }, - .status = 0 + }, + .dirty = false, }; -// clang-format on // array defining the reading of analog values for each axis -__attribute__((weak)) joystick_config_t joystick_axes[JOYSTICK_AXES_COUNT] = {}; +__attribute__((weak)) joystick_config_t joystick_axes[JOYSTICK_AXIS_COUNT] = {}; __attribute__((weak)) void joystick_task(void) { joystick_read_axes(); } void joystick_flush(void) { - if ((joystick_status.status & JS_UPDATED) > 0) { - host_joystick_send(&joystick_status); - joystick_status.status &= ~JS_UPDATED; + if (joystick_state.dirty) { + host_joystick_send(&joystick_state); + joystick_state.dirty = false; } } void register_joystick_button(uint8_t button) { - joystick_status.buttons[button / 8] |= 1 << (button % 8); - joystick_status.status |= JS_UPDATED; + if (button >= JOYSTICK_BUTTON_COUNT) return; + joystick_state.buttons[button / 8] |= 1 << (button % 8); + joystick_state.dirty = true; joystick_flush(); } void unregister_joystick_button(uint8_t button) { - joystick_status.buttons[button / 8] &= ~(1 << (button % 8)); - joystick_status.status |= JS_UPDATED; + if (button >= JOYSTICK_BUTTON_COUNT) return; + joystick_state.buttons[button / 8] &= ~(1 << (button % 8)); + joystick_state.dirty = true; joystick_flush(); } int16_t joystick_read_axis(uint8_t axis) { + if (axis >= JOYSTICK_AXIS_COUNT) return 0; + // disable pull-up resistor writePinLow(joystick_axes[axis].input_pin); @@ -93,24 +96,24 @@ int16_t joystick_read_axis(uint8_t axis) { // test the converted value against the lower range int32_t ref = joystick_axes[axis].mid_digit; int32_t range = joystick_axes[axis].min_digit; - int32_t ranged_val = ((axis_val - ref) * -JOYSTICK_RESOLUTION) / (range - ref); + int32_t ranged_val = ((axis_val - ref) * -JOYSTICK_MAX_VALUE) / (range - ref); if (ranged_val > 0) { // the value is in the higher range range = joystick_axes[axis].max_digit; - ranged_val = ((axis_val - ref) * JOYSTICK_RESOLUTION) / (range - ref); + ranged_val = ((axis_val - ref) * JOYSTICK_MAX_VALUE) / (range - ref); } // clamp the result in the valid range - ranged_val = ranged_val < -JOYSTICK_RESOLUTION ? -JOYSTICK_RESOLUTION : ranged_val; - ranged_val = ranged_val > JOYSTICK_RESOLUTION ? JOYSTICK_RESOLUTION : ranged_val; + ranged_val = ranged_val < -JOYSTICK_MAX_VALUE ? -JOYSTICK_MAX_VALUE : ranged_val; + ranged_val = ranged_val > JOYSTICK_MAX_VALUE ? JOYSTICK_MAX_VALUE : ranged_val; return ranged_val; } void joystick_read_axes() { -#if JOYSTICK_AXES_COUNT > 0 - for (int i = 0; i < JOYSTICK_AXES_COUNT; ++i) { +#if JOYSTICK_AXIS_COUNT > 0 + for (int i = 0; i < JOYSTICK_AXIS_COUNT; ++i) { if (joystick_axes[i].input_pin == JS_VIRTUAL_AXIS) { continue; } @@ -123,8 +126,10 @@ void joystick_read_axes() { } void joystick_set_axis(uint8_t axis, int16_t value) { - if (value != joystick_status.axes[axis]) { - joystick_status.axes[axis] = value; - joystick_status.status |= JS_UPDATED; + if (axis >= JOYSTICK_AXIS_COUNT) return; + + if (value != joystick_state.axes[axis]) { + joystick_state.axes[axis] = value; + joystick_state.dirty = true; } } diff --git a/quantum/joystick.h b/quantum/joystick.h index ee966fdb1a..0ac99aa590 100644 --- a/quantum/joystick.h +++ b/quantum/joystick.h @@ -16,32 +16,41 @@ #pragma once +#include #include + #include "gpio.h" +/** + * \defgroup joystick + * + * HID Joystick + * \{ + */ + #ifndef JOYSTICK_BUTTON_COUNT # define JOYSTICK_BUTTON_COUNT 8 #elif JOYSTICK_BUTTON_COUNT > 32 # error Joystick feature only supports up to 32 buttons #endif -#ifndef JOYSTICK_AXES_COUNT -# define JOYSTICK_AXES_COUNT 4 -#elif JOYSTICK_AXES_COUNT > 6 +#ifndef JOYSTICK_AXIS_COUNT +# define JOYSTICK_AXIS_COUNT 2 +#elif JOYSTICK_AXIS_COUNT > 6 # error Joystick feature only supports up to 6 axes #endif -#if JOYSTICK_AXES_COUNT == 0 && JOYSTICK_BUTTON_COUNT == 0 +#if JOYSTICK_AXIS_COUNT == 0 && JOYSTICK_BUTTON_COUNT == 0 # error Joystick feature requires at least one axis or button #endif -#ifndef JOYSTICK_AXES_RESOLUTION -# define JOYSTICK_AXES_RESOLUTION 8 -#elif JOYSTICK_AXES_RESOLUTION < 8 || JOYSTICK_AXES_RESOLUTION > 16 -# error JOYSTICK_AXES_RESOLUTION must be between 8 and 16 +#ifndef JOYSTICK_AXIS_RESOLUTION +# define JOYSTICK_AXIS_RESOLUTION 8 +#elif JOYSTICK_AXIS_RESOLUTION < 8 || JOYSTICK_AXIS_RESOLUTION > 16 +# error JOYSTICK_AXIS_RESOLUTION must be between 8 and 16 #endif -#define JOYSTICK_RESOLUTION ((1L << (JOYSTICK_AXES_RESOLUTION - 1)) - 1) +#define JOYSTICK_MAX_VALUE ((1L << (JOYSTICK_AXIS_RESOLUTION - 1)) - 1) // configure on input_pin of the joystick_axes array entry to JS_VIRTUAL_AXIS // to prevent it from being read from the ADC. This allows outputing forged axis value. @@ -68,30 +77,56 @@ typedef struct { uint16_t max_digit; } joystick_config_t; -extern joystick_config_t joystick_axes[JOYSTICK_AXES_COUNT]; - -enum joystick_status { - JS_INITIALIZED = 1, - JS_UPDATED, -}; +extern joystick_config_t joystick_axes[JOYSTICK_AXIS_COUNT]; typedef struct { uint8_t buttons[(JOYSTICK_BUTTON_COUNT - 1) / 8 + 1]; - - int16_t axes[JOYSTICK_AXES_COUNT]; - uint8_t status : 2; + int16_t axes[JOYSTICK_AXIS_COUNT]; + bool dirty; } joystick_t; -extern joystick_t joystick_status; +extern joystick_t joystick_state; void joystick_task(void); + +/** + * \brief Send the joystick report to the host, if it has been marked as dirty. + */ void joystick_flush(void); +/** + * \brief Set the state of a button, and flush the report. + * + * \param button The index of the button to press, from 0 to 31. + */ void register_joystick_button(uint8_t button); + +/** + * \brief Reset the state of a button, and flush the report. + * + * \param button The index of the button to release, from 0 to 31. + */ void unregister_joystick_button(uint8_t button); +/** + * \brief Sample and process the analog value of the given axis. + * + * \param axis The axis to read. + * + * \return A signed 16-bit integer, where 0 is the resting or mid point. + */ int16_t joystick_read_axis(uint8_t axis); -void joystick_read_axes(void); -void joystick_set_axis(uint8_t axis, int16_t value); + +void joystick_read_axes(void); + +/** + * \brief Set the value of the given axis. + * + * \param axis The axis to set the value of. + * \param value The value to set. + */ +void joystick_set_axis(uint8_t axis, int16_t value); void host_joystick_send(joystick_t *joystick); + +/** \} */ -- cgit v1.2.3 From e12ca14af8fc1799357bbfffd156d53b4a51001c Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 27 Nov 2022 04:18:24 +1100 Subject: Change `RGB_MATRIX_STARTUP_*` defines to `RGB_MATRIX_DEFAULT_*` (#19079) --- quantum/rgb_matrix/rgb_matrix.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'quantum') diff --git a/quantum/rgb_matrix/rgb_matrix.c b/quantum/rgb_matrix/rgb_matrix.c index 539ca0e100..e7125bb87f 100644 --- a/quantum/rgb_matrix/rgb_matrix.c +++ b/quantum/rgb_matrix/rgb_matrix.c @@ -81,29 +81,29 @@ __attribute__((weak)) RGB rgb_matrix_hsv_to_rgb(HSV hsv) { # define RGB_MATRIX_SPD_STEP 16 #endif -#if !defined(RGB_MATRIX_STARTUP_MODE) +#if !defined(RGB_MATRIX_DEFAULT_MODE) # ifdef ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT -# define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_LEFT_RIGHT +# define RGB_MATRIX_DEFAULT_MODE RGB_MATRIX_CYCLE_LEFT_RIGHT # else // fallback to solid colors if RGB_MATRIX_CYCLE_LEFT_RIGHT is disabled in userspace -# define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_SOLID_COLOR +# define RGB_MATRIX_DEFAULT_MODE RGB_MATRIX_SOLID_COLOR # endif #endif -#if !defined(RGB_MATRIX_STARTUP_HUE) -# define RGB_MATRIX_STARTUP_HUE 0 +#if !defined(RGB_MATRIX_DEFAULT_HUE) +# define RGB_MATRIX_DEFAULT_HUE 0 #endif -#if !defined(RGB_MATRIX_STARTUP_SAT) -# define RGB_MATRIX_STARTUP_SAT UINT8_MAX +#if !defined(RGB_MATRIX_DEFAULT_SAT) +# define RGB_MATRIX_DEFAULT_SAT UINT8_MAX #endif -#if !defined(RGB_MATRIX_STARTUP_VAL) -# define RGB_MATRIX_STARTUP_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS +#if !defined(RGB_MATRIX_DEFAULT_VAL) +# define RGB_MATRIX_DEFAULT_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS #endif -#if !defined(RGB_MATRIX_STARTUP_SPD) -# define RGB_MATRIX_STARTUP_SPD UINT8_MAX / 2 +#if !defined(RGB_MATRIX_DEFAULT_SPD) +# define RGB_MATRIX_DEFAULT_SPD UINT8_MAX / 2 #endif // globals @@ -146,9 +146,9 @@ void eeconfig_update_rgb_matrix(void) { void eeconfig_update_rgb_matrix_default(void) { dprintf("eeconfig_update_rgb_matrix_default\n"); rgb_matrix_config.enable = 1; - rgb_matrix_config.mode = RGB_MATRIX_STARTUP_MODE; - rgb_matrix_config.hsv = (HSV){RGB_MATRIX_STARTUP_HUE, RGB_MATRIX_STARTUP_SAT, RGB_MATRIX_STARTUP_VAL}; - rgb_matrix_config.speed = RGB_MATRIX_STARTUP_SPD; + rgb_matrix_config.mode = RGB_MATRIX_DEFAULT_MODE; + rgb_matrix_config.hsv = (HSV){RGB_MATRIX_DEFAULT_HUE, RGB_MATRIX_DEFAULT_SAT, RGB_MATRIX_DEFAULT_VAL}; + rgb_matrix_config.speed = RGB_MATRIX_DEFAULT_SPD; rgb_matrix_config.flags = LED_FLAG_ALL; eeconfig_flush_rgb_matrix(true); } -- cgit v1.2.3 From 9b51f02f45f72758a61d761c2d8e1b1696cce6e8 Mon Sep 17 00:00:00 2001 From: Christopher Hoage Date: Sat, 26 Nov 2022 15:07:35 -0800 Subject: Fix encoder_init call order in keyboard_init (#19140) --- quantum/keyboard.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'quantum') diff --git a/quantum/keyboard.c b/quantum/keyboard.c index 83ade7829a..37675ded0b 100644 --- a/quantum/keyboard.c +++ b/quantum/keyboard.c @@ -353,6 +353,9 @@ void keyboard_init(void) { #endif #ifdef SPLIT_KEYBOARD split_pre_init(); +#endif +#ifdef ENCODER_ENABLE + encoder_init(); #endif matrix_init(); quantum_init(); @@ -374,9 +377,6 @@ void keyboard_init(void) { #ifdef RGBLIGHT_ENABLE rgblight_init(); #endif -#ifdef ENCODER_ENABLE - encoder_init(); -#endif #ifdef STENO_ENABLE_ALL steno_init(); #endif -- cgit v1.2.3