Merge remote-tracking branch 'origin/master' into firmware24

This commit is contained in:
Drashna Jael're
2025-03-27 20:38:06 -07:00
780 changed files with 14658 additions and 81334 deletions

View File

@@ -98,6 +98,7 @@ bool process_autocorrect_default_handler(uint16_t *keycode, keyrecord_t *record,
case QK_TO ... QK_TO_MAX:
case QK_MOMENTARY ... QK_MOMENTARY_MAX:
case QK_DEF_LAYER ... QK_DEF_LAYER_MAX:
case QK_PERSISTENT_DEF_LAYER ... QK_PERSISTENT_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:

View File

@@ -36,19 +36,19 @@ __attribute__((weak)) uint8_t combo_ref_from_layer(uint8_t layer) {
#endif
#ifdef COMBO_MUST_HOLD_PER_COMBO
__attribute__((weak)) bool get_combo_must_hold(uint16_t index, combo_t *combo) {
__attribute__((weak)) bool get_combo_must_hold(uint16_t combo_index, combo_t *combo) {
return false;
}
#endif
#ifdef COMBO_MUST_TAP_PER_COMBO
__attribute__((weak)) bool get_combo_must_tap(uint16_t index, combo_t *combo) {
__attribute__((weak)) bool get_combo_must_tap(uint16_t combo_index, combo_t *combo) {
return false;
}
#endif
#ifdef COMBO_TERM_PER_COMBO
__attribute__((weak)) uint16_t get_combo_term(uint16_t index, combo_t *combo) {
__attribute__((weak)) uint16_t get_combo_term(uint16_t combo_index, combo_t *combo) {
return COMBO_TERM;
}
#endif
@@ -65,12 +65,20 @@ __attribute__((weak)) bool process_combo_key_release(uint16_t combo_index, combo
}
#endif
#ifdef COMBO_PROCESS_KEY_REPRESS
__attribute__((weak)) bool process_combo_key_repress(uint16_t combo_index, combo_t *combo, uint8_t key_index, uint16_t keycode) {
return false;
}
#endif
#ifdef COMBO_SHOULD_TRIGGER
__attribute__((weak)) bool combo_should_trigger(uint16_t combo_index, combo_t *combo, uint16_t keycode, keyrecord_t *record) {
return true;
}
#endif
typedef enum { COMBO_KEY_NOT_PRESSED, COMBO_KEY_PRESSED, COMBO_KEY_REPRESSED } combo_key_action_t;
#ifndef COMBO_NO_TIMER
static uint16_t timer = 0;
#endif
@@ -414,14 +422,14 @@ static bool keys_pressed_in_order(uint16_t combo_index, combo_t *combo, uint16_t
}
#endif
static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *record, uint16_t combo_index) {
static combo_key_action_t process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *record, uint16_t combo_index) {
uint8_t key_count = 0;
uint16_t key_index = -1;
_find_key_index_and_count(combo->keys, keycode, &key_index, &key_count);
/* Continue processing if key isn't part of current combo. */
if (-1 == (int16_t)key_index) {
return false;
return COMBO_KEY_NOT_PRESSED;
}
bool key_is_part_of_combo = (!COMBO_DISABLED(combo) && is_combo_enabled()
@@ -449,7 +457,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
/* Don't buffer this combo if its combo term has passed. */
if (timer && timer_elapsed(timer) > time) {
DISABLE_COMBO(combo);
return true;
return COMBO_KEY_PRESSED;
} else
#endif
{
@@ -485,6 +493,15 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
}
} // if timer elapsed end
}
#ifdef COMBO_PROCESS_KEY_REPRESS
} else if (record->event.pressed) {
if (COMBO_ACTIVE(combo)) {
if (process_combo_key_repress(combo_index, combo, key_index, keycode)) {
KEY_STATE_DOWN(combo->state, key_index);
return COMBO_KEY_REPRESSED;
}
}
#endif
} else {
// chord releases
if (!COMBO_ACTIVE(combo) && ALL_COMBO_KEYS_ARE_DOWN(COMBO_STATE(combo), key_count)) {
@@ -531,12 +548,12 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
KEY_STATE_UP(combo->state, key_index);
}
return key_is_part_of_combo;
return key_is_part_of_combo ? COMBO_KEY_PRESSED : COMBO_KEY_NOT_PRESSED;
}
bool process_combo(uint16_t keycode, keyrecord_t *record) {
bool is_combo_key = false;
bool no_combo_keys_pressed = true;
uint8_t is_combo_key = COMBO_KEY_NOT_PRESSED;
bool no_combo_keys_pressed = true;
if (keycode == QK_COMBO_ON && record->event.pressed) {
combo_enable();
@@ -582,12 +599,17 @@ bool process_combo(uint16_t keycode, keyrecord_t *record) {
# endif
#endif
if (key_buffer_size < COMBO_KEY_BUFFER_LENGTH) {
key_buffer[key_buffer_size++] = (queued_record_t){
.record = *record,
.keycode = keycode,
.combo_index = -1, // this will be set when applying combos
};
#ifdef COMBO_PROCESS_KEY_REPRESS
if (is_combo_key == COMBO_KEY_PRESSED)
#endif
{
if (key_buffer_size < COMBO_KEY_BUFFER_LENGTH) {
key_buffer[key_buffer_size++] = (queued_record_t){
.record = *record,
.keycode = keycode,
.combo_index = -1, // this will be set when applying combos
};
}
}
} else {
if (combo_buffer_read != combo_buffer_write) {

View File

@@ -0,0 +1,36 @@
// Copyright 2024 Nick Brassel (@tzarc)
// SPDX-License-Identifier: GPL-2.0-or-later
#include "outputselect.h"
#include "process_connection.h"
bool process_connection(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
switch (keycode) {
case QK_OUTPUT_NEXT:
set_output(OUTPUT_AUTO); // This should cycle through the outputs going forward. Ensure `docs/keycodes.md`, `docs/features/bluetooth.md` are updated when it does.
return false;
case QK_OUTPUT_USB:
set_output(OUTPUT_USB);
return false;
case QK_OUTPUT_BLUETOOTH:
set_output(OUTPUT_BLUETOOTH);
return false;
case QK_OUTPUT_PREV:
case QK_OUTPUT_NONE:
case QK_OUTPUT_2P4GHZ:
case QK_BLUETOOTH_PROFILE_NEXT:
case QK_BLUETOOTH_PROFILE_PREV:
case QK_BLUETOOTH_UNPAIR:
case QK_BLUETOOTH_PROFILE1:
case QK_BLUETOOTH_PROFILE2:
case QK_BLUETOOTH_PROFILE3:
case QK_BLUETOOTH_PROFILE4:
case QK_BLUETOOTH_PROFILE5:
// As-yet unimplemented.
// When implementation is done, ensure `docs/keycodes.md`, `docs/features/bluetooth.md` are updated accordingly.
return false;
}
}
return true;
}

View File

@@ -0,0 +1,9 @@
// Copyright 2024 Nick Brassel (@tzarc)
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include "action.h"
bool process_connection(uint16_t keycode, keyrecord_t *record);

View File

@@ -0,0 +1,32 @@
/* Copyright 2023 Nebuleon
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "process_default_layer.h"
#include "quantum.h"
#include "quantum_keycodes.h"
#if !defined(NO_ACTION_LAYER)
bool process_default_layer(uint16_t keycode, keyrecord_t *record) {
if (IS_QK_PERSISTENT_DEF_LAYER(keycode) && !record->event.pressed) {
uint8_t layer = QK_PERSISTENT_DEF_LAYER_GET_LAYER(keycode);
set_single_persistent_default_layer(layer);
return false;
}
return true;
}
#endif // !defined(NO_ACTION_LAYER)

View File

@@ -1,4 +1,4 @@
/* Copyright 2019
/* Copyright 2023 Nebuleon
*
* 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
@@ -13,10 +13,15 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include "action.h"
bool process_rgb(const uint16_t keycode, const keyrecord_t *record);
#if !defined(NO_ACTION_LAYER)
bool process_default_layer(uint16_t keycode, keyrecord_t *record);
#endif // !defined(NO_ACTION_LAYER)

View File

@@ -38,20 +38,44 @@ void dynamic_macro_led_blink(void) {
/* User hooks for Dynamic Macros */
__attribute__((weak)) void dynamic_macro_record_start_user(int8_t direction) {
dynamic_macro_led_blink();
__attribute__((weak)) bool dynamic_macro_record_start_kb(int8_t direction) {
return dynamic_macro_record_start_user(direction);
}
__attribute__((weak)) void dynamic_macro_play_user(int8_t direction) {
__attribute__((weak)) bool dynamic_macro_record_start_user(int8_t direction) {
dynamic_macro_led_blink();
return true;
}
__attribute__((weak)) void dynamic_macro_record_key_user(int8_t direction, keyrecord_t *record) {
dynamic_macro_led_blink();
__attribute__((weak)) bool dynamic_macro_play_kb(int8_t direction) {
return dynamic_macro_play_user(direction);
}
__attribute__((weak)) void dynamic_macro_record_end_user(int8_t direction) {
__attribute__((weak)) bool dynamic_macro_play_user(int8_t direction) {
dynamic_macro_led_blink();
return true;
}
__attribute__((weak)) bool dynamic_macro_record_key_kb(int8_t direction, keyrecord_t *record) {
return dynamic_macro_record_key_user(direction, record);
}
__attribute__((weak)) bool dynamic_macro_record_key_user(int8_t direction, keyrecord_t *record) {
dynamic_macro_led_blink();
return true;
}
__attribute__((weak)) bool dynamic_macro_record_end_kb(int8_t direction) {
return dynamic_macro_record_end_user(direction);
}
__attribute__((weak)) bool dynamic_macro_record_end_user(int8_t direction) {
dynamic_macro_led_blink();
return true;
}
__attribute__((weak)) bool dynamic_macro_valid_key_kb(uint16_t keycode, keyrecord_t *record) {
return dynamic_macro_valid_key_user(keycode, record);
}
__attribute__((weak)) bool dynamic_macro_valid_key_user(uint16_t keycode, keyrecord_t *record) {
@@ -74,7 +98,7 @@ __attribute__((weak)) bool dynamic_macro_valid_key_user(uint16_t keycode, keyrec
void dynamic_macro_record_start(keyrecord_t **macro_pointer, keyrecord_t *macro_buffer, int8_t direction) {
dprintln("dynamic macro recording: started");
dynamic_macro_record_start_user(direction);
dynamic_macro_record_start_kb(direction);
clear_keyboard();
layer_clear();
@@ -108,7 +132,7 @@ void dynamic_macro_play(keyrecord_t *macro_buffer, keyrecord_t *macro_end, int8_
layer_state_set(saved_layer_state);
dynamic_macro_play_user(direction);
dynamic_macro_play_kb(direction);
}
/**
@@ -134,7 +158,7 @@ void dynamic_macro_record_key(keyrecord_t *macro_buffer, keyrecord_t **macro_poi
**macro_pointer = *record;
*macro_pointer += direction;
}
dynamic_macro_record_key_user(direction, record);
dynamic_macro_record_key_kb(direction, record);
dprintf("dynamic macro: slot %d length: %d/%d\n", DYNAMIC_MACRO_CURRENT_SLOT(), DYNAMIC_MACRO_CURRENT_LENGTH(macro_buffer, *macro_pointer), DYNAMIC_MACRO_CURRENT_CAPACITY(macro_buffer, macro2_end));
}
@@ -144,7 +168,7 @@ void dynamic_macro_record_key(keyrecord_t *macro_buffer, keyrecord_t **macro_poi
* pointer to the end of the macro.
*/
void dynamic_macro_record_end(keyrecord_t *macro_buffer, keyrecord_t *macro_pointer, int8_t direction, keyrecord_t **macro_end) {
dynamic_macro_record_end_user(direction);
dynamic_macro_record_end_kb(direction);
/* Do not save the keys being held when stopping the recording,
* i.e. the keys used to access the layer DM_RSTP is on.
@@ -220,15 +244,7 @@ void dynamic_macro_stop_recording(void) {
macro_id = 0;
}
/* Handle the key events related to the dynamic macros. Should be
* called from process_record_user() like this:
*
* bool process_record_user(uint16_t keycode, keyrecord_t *record) {
* if (!process_record_dynamic_macro(keycode, record)) {
* return false;
* }
* <...THE REST OF THE FUNCTION...>
* }
/* Handle the key events related to the dynamic macros.
*/
bool process_dynamic_macro(uint16_t keycode, keyrecord_t *record) {
if (macro_id == 0) {
@@ -271,7 +287,7 @@ bool process_dynamic_macro(uint16_t keycode, keyrecord_t *record) {
return false;
#endif
default:
if (dynamic_macro_valid_key_user(keycode, record)) {
if (dynamic_macro_valid_key_kb(keycode, record)) {
/* Store the key in the macro buffer and process it normally. */
switch (macro_id) {
case 1:

View File

@@ -37,8 +37,14 @@
void dynamic_macro_led_blink(void);
bool process_dynamic_macro(uint16_t keycode, keyrecord_t *record);
void dynamic_macro_record_start_user(int8_t direction);
void dynamic_macro_play_user(int8_t direction);
void dynamic_macro_record_key_user(int8_t direction, keyrecord_t *record);
void dynamic_macro_record_end_user(int8_t direction);
bool dynamic_macro_record_start_kb(int8_t direction);
bool dynamic_macro_record_start_user(int8_t direction);
bool dynamic_macro_play_kb(int8_t direction);
bool dynamic_macro_play_user(int8_t direction);
bool dynamic_macro_record_key_kb(int8_t direction, keyrecord_t *record);
bool dynamic_macro_record_key_user(int8_t direction, keyrecord_t *record);
bool dynamic_macro_record_end_kb(int8_t direction);
bool dynamic_macro_record_end_user(int8_t direction);
bool dynamic_macro_valid_key_kb(uint16_t keycode, keyrecord_t *record);
bool dynamic_macro_valid_key_user(uint16_t keycode, keyrecord_t *record);
void dynamic_macro_stop_recording(void);

View File

@@ -129,7 +129,7 @@ bool process_haptic(uint16_t keycode, keyrecord_t *record) {
}
}
if (haptic_get_enable() && ((!HAPTIC_OFF_IN_LOW_POWER) || (usb_device_state == USB_DEVICE_STATE_CONFIGURED))) {
if (haptic_get_enable() && ((!HAPTIC_OFF_IN_LOW_POWER) || (usb_device_state_get_configure_state() == USB_DEVICE_STATE_CONFIGURED))) {
if (record->event.pressed) {
// keypress
if (haptic_get_feedback() < 2 && get_haptic_enabled_key(keycode, record)) {

View File

@@ -23,6 +23,7 @@
#include "action_util.h"
#include "quantum.h"
#include "quantum_keycodes.h"
#include "keymap_introspection.h"
#ifndef KEY_OVERRIDE_REPEAT_DELAY
# define KEY_OVERRIDE_REPEAT_DELAY 500
@@ -83,9 +84,6 @@ static uint16_t deferred_register = 0;
// TODO: in future maybe save in EEPROM?
static bool enabled = true;
// Public variables
__attribute__((weak)) const key_override_t **key_overrides = NULL;
// Forward decls
static const key_override_t *clear_active_override(const bool allow_reregister);
@@ -247,12 +245,12 @@ static bool check_activation_event(const key_override_t *override, const bool ke
/** Iterates through the list of key overrides and tries activating each, until it finds one that activates or reaches the end of overrides. Returns true if the key action for `keycode` should be sent */
static bool try_activating_override(const uint16_t keycode, const uint8_t layer, const bool key_down, const bool is_mod, const uint8_t active_mods, bool *activated) {
if (key_overrides == NULL) {
if (key_override_count() == 0) {
return true;
}
for (uint8_t i = 0;; i++) {
const key_override_t *const override = key_overrides[i];
for (uint8_t i = 0; i < key_override_count(); i++) {
const key_override_t *const override = key_override_get(i);
// End of array
if (override == NULL) {

View File

@@ -55,7 +55,7 @@ typedef enum {
} ko_option_t;
/** Defines a single key override */
typedef struct {
typedef struct key_override_t {
// The non-modifier keycode that triggers the override. This keycode, and the necessary modifiers (trigger_mods) must be pressed to activate this override. Set this to the keycode of the key that should activate the override. Set to KC_NO to require only the necessary modifiers to be pressed and no non-modifier.
uint16_t trigger;
@@ -87,9 +87,6 @@ typedef struct {
bool *enabled;
} key_override_t;
/** Define this as a null-terminated array of pointers to key overrides. These key overrides will be used by qmk. */
extern const key_override_t **key_overrides;
/** Turns key overrides on */
void key_override_on(void);

View File

@@ -12,14 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @file layer_lock.c
* @brief Layer Lock implementation
*
* For full documentation, see
* <https://getreuer.info/posts/keyboards/layer-lock>
*/
#include "layer_lock.h"
#include "process_layer_lock.h"
#include "quantum_keycodes.h"
@@ -27,12 +19,9 @@
// The current lock state. The kth bit is on if layer k is locked.
extern layer_state_t locked_layers;
#if defined(LAYER_LOCK_IDLE_TIMEOUT) && LAYER_LOCK_IDLE_TIMEOUT > 0
extern uint32_t layer_lock_timer;
#endif
// Handles an event on an `MO` or `TT` layer switch key.
static bool handle_mo_or_tt(uint8_t layer, keyrecord_t* record) {
static inline bool handle_mo_or_tt(uint8_t layer, keyrecord_t* record) {
if (is_layer_locked(layer)) {
if (record->event.pressed) { // On press, unlock the layer.
layer_lock_invert(layer);
@@ -44,9 +33,7 @@ static bool handle_mo_or_tt(uint8_t layer, keyrecord_t* record) {
bool process_layer_lock(uint16_t keycode, keyrecord_t* record) {
#ifndef NO_ACTION_LAYER
# if defined(LAYER_LOCK_IDLE_TIMEOUT) && LAYER_LOCK_IDLE_TIMEOUT > 0
layer_lock_timer = timer_read32();
# endif // LAYER_LOCK_IDLE_TIMEOUT > 0
layer_lock_activity_trigger();
// The intention is that locked layers remain on. If something outside of
// this feature turned any locked layers off, unlock them.

View File

@@ -12,53 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @file layer_lock.h
* @brief Layer Lock, a key to stay in the current layer.
*
* Overview
* --------
*
* Layers are often accessed by holding a button, e.g. with a momentary layer
* switch `MO(layer)` or layer tap `LT(layer, key)` key. But you may sometimes
* want to "lock" or "toggle" the layer so that it stays on without having to
* hold down a button. One way to do that is with a tap-toggle `TT` layer key,
* but here is an alternative.
*
* This library implements a "Layer Lock key". When tapped, it "locks" the
* highest layer to stay active, assuming the layer was activated by one of the
* following keys:
*
* * `MO(layer)` momentary layer switch
* * `LT(layer, key)` layer tap
* * `OSL(layer)` one-shot layer
* * `TT(layer)` layer tap toggle
* * `LM(layer, mod)` layer-mod key (the layer is locked, but not the mods)
*
* Tapping the Layer Lock key again unlocks and turns off the layer.
*
* @note When a layer is "locked", other layer keys such as `TO(layer)` or
* manually calling `layer_off(layer)` will override and unlock the layer.
*
* Configuration
* -------------
*
* Optionally, a timeout may be defined so that Layer Lock disables
* automatically if not keys are pressed for `LAYER_LOCK_IDLE_TIMEOUT`
* milliseconds. Define `LAYER_LOCK_IDLE_TIMEOUT` in your config.h, for instance
*
* #define LAYER_LOCK_IDLE_TIMEOUT 60000 // Turn off after 60 seconds.
*
* and call `layer_lock_task()` from your `matrix_scan_user()` in keymap.c:
*
* void matrix_scan_user(void) {
* layer_lock_task();
* // Other tasks...
* }
*
* For full documentation, see
* <https://getreuer.info/posts/keyboards/layer-lock>
*/
#pragma once

View File

@@ -1,226 +0,0 @@
/* Copyright 2019
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "process_rgb.h"
#include "action_util.h"
#ifdef RGB_MATRIX_ENABLE
# include "rgb_matrix.h"
#endif
#ifdef RGBLIGHT_ENABLE
# include "rgblight.h"
#endif
typedef void (*rgb_func_pointer)(void);
/**
* Wrapper for inc/dec rgb keycode
*
* noinline to optimise for firmware size not speed (not in hot path)
*/
#if (defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)) || (defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES))
static void __attribute__((noinline)) handleKeycodeRGB(const uint8_t is_shifted, const rgb_func_pointer inc_func, const rgb_func_pointer dec_func) {
if (is_shifted) {
dec_func();
} else {
inc_func();
}
}
#endif
/**
* Wrapper for animation mode
* - if not in animation family -> jump to that animation
* - otherwise -> wrap round animation speed
*
* noinline to optimise for firmware size not speed (not in hot path)
*/
static void __attribute__((noinline, unused)) handleKeycodeRGBMode(const uint8_t start, const uint8_t end) {
if ((start <= rgblight_get_mode()) && (rgblight_get_mode() < end)) {
rgblight_step();
} else {
rgblight_mode(start);
}
}
/**
* Handle keycodes for both rgblight and rgbmatrix
*/
bool process_rgb(const uint16_t keycode, const keyrecord_t *record) {
// need to trigger on key-up for edge-case issue
#ifndef RGB_TRIGGER_ON_KEYDOWN
if (!record->event.pressed) {
#else
if (record->event.pressed) {
#endif
#if (defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)) || (defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES))
uint8_t shifted = get_mods() & MOD_MASK_SHIFT;
#endif
switch (keycode) {
case QK_UNDERGLOW_TOGGLE:
#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_toggle();
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_toggle();
#endif
return false;
case QK_UNDERGLOW_MODE_NEXT:
#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
handleKeycodeRGB(shifted, rgblight_step, rgblight_step_reverse);
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
handleKeycodeRGB(shifted, rgb_matrix_step, rgb_matrix_step_reverse);
#endif
return false;
case QK_UNDERGLOW_MODE_PREVIOUS:
#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
handleKeycodeRGB(shifted, rgblight_step_reverse, rgblight_step);
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
handleKeycodeRGB(shifted, rgb_matrix_step_reverse, rgb_matrix_step);
#endif
return false;
case QK_UNDERGLOW_HUE_UP:
#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
handleKeycodeRGB(shifted, rgblight_increase_hue, rgblight_decrease_hue);
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
handleKeycodeRGB(shifted, rgb_matrix_increase_hue, rgb_matrix_decrease_hue);
#endif
return false;
case QK_UNDERGLOW_HUE_DOWN:
#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
handleKeycodeRGB(shifted, rgblight_decrease_hue, rgblight_increase_hue);
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
handleKeycodeRGB(shifted, rgb_matrix_decrease_hue, rgb_matrix_increase_hue);
#endif
return false;
case QK_UNDERGLOW_SATURATION_UP:
#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
handleKeycodeRGB(shifted, rgblight_increase_sat, rgblight_decrease_sat);
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
handleKeycodeRGB(shifted, rgb_matrix_increase_sat, rgb_matrix_decrease_sat);
#endif
return false;
case QK_UNDERGLOW_SATURATION_DOWN:
#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
handleKeycodeRGB(shifted, rgblight_decrease_sat, rgblight_increase_sat);
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
handleKeycodeRGB(shifted, rgb_matrix_decrease_sat, rgb_matrix_increase_sat);
#endif
return false;
case QK_UNDERGLOW_VALUE_UP:
#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
handleKeycodeRGB(shifted, rgblight_increase_val, rgblight_decrease_val);
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
handleKeycodeRGB(shifted, rgb_matrix_increase_val, rgb_matrix_decrease_val);
#endif
return false;
case QK_UNDERGLOW_VALUE_DOWN:
#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
handleKeycodeRGB(shifted, rgblight_decrease_val, rgblight_increase_val);
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
handleKeycodeRGB(shifted, rgb_matrix_decrease_val, rgb_matrix_increase_val);
#endif
return false;
case QK_UNDERGLOW_SPEED_UP:
#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
handleKeycodeRGB(shifted, rgblight_increase_speed, rgblight_decrease_speed);
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
handleKeycodeRGB(shifted, rgb_matrix_increase_speed, rgb_matrix_decrease_speed);
#endif
return false;
case QK_UNDERGLOW_SPEED_DOWN:
#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
handleKeycodeRGB(shifted, rgblight_decrease_speed, rgblight_increase_speed);
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
handleKeycodeRGB(shifted, rgb_matrix_decrease_speed, rgb_matrix_increase_speed);
#endif
return false;
case RGB_MODE_PLAIN:
#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT);
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_mode(RGB_MATRIX_SOLID_COLOR);
#endif
return false;
case RGB_MODE_BREATHE:
#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_BREATHING)
handleKeycodeRGBMode(RGBLIGHT_MODE_BREATHING, RGBLIGHT_MODE_BREATHING_end);
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) && defined(ENABLE_RGB_MATRIX_BREATHING)
rgb_matrix_mode(RGB_MATRIX_BREATHING);
#endif
return false;
case RGB_MODE_RAINBOW:
#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_RAINBOW_MOOD)
handleKeycodeRGBMode(RGBLIGHT_MODE_RAINBOW_MOOD, RGBLIGHT_MODE_RAINBOW_MOOD_end);
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) && defined(ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT)
rgb_matrix_mode(RGB_MATRIX_CYCLE_LEFT_RIGHT);
#endif
return false;
case RGB_MODE_SWIRL:
#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_RAINBOW_SWIRL)
handleKeycodeRGBMode(RGBLIGHT_MODE_RAINBOW_SWIRL, RGBLIGHT_MODE_RAINBOW_SWIRL_end);
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) && defined(ENABLE_RGB_MATRIX_CYCLE_PINWHEEL)
rgb_matrix_mode(RGB_MATRIX_CYCLE_PINWHEEL);
#endif
return false;
case RGB_MODE_SNAKE:
#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_SNAKE)
handleKeycodeRGBMode(RGBLIGHT_MODE_SNAKE, RGBLIGHT_MODE_SNAKE_end);
#endif
return false;
case RGB_MODE_KNIGHT:
#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_KNIGHT)
handleKeycodeRGBMode(RGBLIGHT_MODE_KNIGHT, RGBLIGHT_MODE_KNIGHT_end);
#endif
return false;
case RGB_MODE_XMAS:
#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_CHRISTMAS)
rgblight_mode(RGBLIGHT_MODE_CHRISTMAS);
#endif
return false;
case RGB_MODE_GRADIENT:
#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_STATIC_GRADIENT)
handleKeycodeRGBMode(RGBLIGHT_MODE_STATIC_GRADIENT, RGBLIGHT_MODE_STATIC_GRADIENT_end);
#endif
return false;
case RGB_MODE_RGBTEST:
#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_RGB_TEST)
rgblight_mode(RGBLIGHT_MODE_RGB_TEST);
#endif
return false;
case RGB_MODE_TWINKLE:
#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_TWINKLE)
handleKeycodeRGBMode(RGBLIGHT_MODE_TWINKLE, RGBLIGHT_MODE_TWINKLE_end);
#endif
return false;
}
}
return true;
}

View File

@@ -0,0 +1,101 @@
// Copyright 2024 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
#include "process_rgb_matrix.h"
#include "rgb_matrix.h"
#include "action_util.h"
#include "keycodes.h"
#include "modifiers.h"
bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
#ifdef RGB_TRIGGER_ON_KEYDOWN
if (record->event.pressed) {
#else
if (!record->event.pressed) {
#endif
bool shifted = get_mods() & MOD_MASK_SHIFT;
switch (keycode) {
case QK_RGB_MATRIX_ON:
rgb_matrix_enable();
return false;
case QK_RGB_MATRIX_OFF:
rgb_matrix_disable();
return false;
case QK_RGB_MATRIX_TOGGLE:
rgb_matrix_toggle();
return false;
case QK_RGB_MATRIX_MODE_NEXT:
if (shifted) {
rgb_matrix_step_reverse();
} else {
rgb_matrix_step();
}
return false;
case QK_RGB_MATRIX_MODE_PREVIOUS:
if (shifted) {
rgb_matrix_step();
} else {
rgb_matrix_step_reverse();
}
return false;
case QK_RGB_MATRIX_HUE_UP:
if (shifted) {
rgb_matrix_decrease_hue();
} else {
rgb_matrix_increase_hue();
}
return false;
case QK_RGB_MATRIX_HUE_DOWN:
if (shifted) {
rgb_matrix_increase_hue();
} else {
rgb_matrix_decrease_hue();
}
return false;
case QK_RGB_MATRIX_SATURATION_UP:
if (shifted) {
rgb_matrix_decrease_sat();
} else {
rgb_matrix_increase_sat();
}
return false;
case QK_RGB_MATRIX_SATURATION_DOWN:
if (shifted) {
rgb_matrix_increase_sat();
} else {
rgb_matrix_decrease_sat();
}
return false;
case QK_RGB_MATRIX_VALUE_UP:
if (shifted) {
rgb_matrix_decrease_val();
} else {
rgb_matrix_increase_val();
}
return false;
case QK_RGB_MATRIX_VALUE_DOWN:
if (shifted) {
rgb_matrix_increase_val();
} else {
rgb_matrix_decrease_val();
}
return false;
case QK_RGB_MATRIX_SPEED_UP:
if (shifted) {
rgb_matrix_decrease_speed();
} else {
rgb_matrix_increase_speed();
}
return false;
case QK_RGB_MATRIX_SPEED_DOWN:
if (shifted) {
rgb_matrix_increase_speed();
} else {
rgb_matrix_decrease_speed();
}
return false;
}
}
return true;
}

View File

@@ -0,0 +1,10 @@
// Copyright 2024 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include "action.h"
bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record);

View File

@@ -21,6 +21,7 @@
#include "action_util.h"
#include "timer.h"
#include "wait.h"
#include "keymap_introspection.h"
static uint16_t active_td;
static uint16_t last_tap_time;
@@ -133,7 +134,7 @@ bool preprocess_tap_dance(uint16_t keycode, keyrecord_t *record) {
if (!active_td || keycode == active_td) return false;
action = &tap_dance_actions[QK_TAP_DANCE_GET_INDEX(active_td)];
action = tap_dance_get(QK_TAP_DANCE_GET_INDEX(active_td));
action->state.interrupted = true;
action->state.interrupting_keycode = keycode;
process_tap_dance_action_on_dance_finished(action);
@@ -150,11 +151,16 @@ bool preprocess_tap_dance(uint16_t keycode, keyrecord_t *record) {
}
bool process_tap_dance(uint16_t keycode, keyrecord_t *record) {
int td_index;
tap_dance_action_t *action;
switch (keycode) {
case QK_TAP_DANCE ... QK_TAP_DANCE_MAX:
action = &tap_dance_actions[QK_TAP_DANCE_GET_INDEX(keycode)];
td_index = QK_TAP_DANCE_GET_INDEX(keycode);
if (td_index >= tap_dance_count()) {
return false;
}
action = tap_dance_get(td_index);
action->state.pressed = record->event.pressed;
if (record->event.pressed) {
@@ -182,7 +188,7 @@ void tap_dance_task(void) {
if (!active_td || timer_elapsed(last_tap_time) <= GET_TAPPING_TERM(active_td, &(keyrecord_t){})) return;
action = &tap_dance_actions[QK_TAP_DANCE_GET_INDEX(active_td)];
action = tap_dance_get(QK_TAP_DANCE_GET_INDEX(active_td));
if (!action->state.interrupted) {
process_tap_dance_action_on_dance_finished(action);
}

View File

@@ -35,7 +35,7 @@ typedef struct {
typedef void (*tap_dance_user_fn_t)(tap_dance_state_t *state, void *user_data);
typedef struct {
typedef struct tap_dance_action_t {
tap_dance_state_t state;
struct {
tap_dance_user_fn_t on_each_tap;
@@ -78,8 +78,6 @@ typedef struct {
#define TD_INDEX(code) QK_TAP_DANCE_GET_INDEX(code)
#define TAP_DANCE_KEYCODE(state) TD(((tap_dance_action_t *)state) - tap_dance_actions)
extern tap_dance_action_t tap_dance_actions[];
void reset_tap_dance(tap_dance_state_t *state);
/* To be used internally */

View File

@@ -0,0 +1,207 @@
// Copyright 2024 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
#include "process_underglow.h"
#if defined(RGBLIGHT_ENABLE)
# include "rgblight.h"
#endif
#include "action_util.h"
#include "keycodes.h"
#include "modifiers.h"
// TODO: Remove this
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES)
# include "rgb_matrix.h"
#endif
bool process_underglow(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
#if defined(RGBLIGHT_ENABLE) || (defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES))
const uint8_t shifted = get_mods() & MOD_MASK_SHIFT;
#endif
switch (keycode) {
case QK_UNDERGLOW_TOGGLE:
#if defined(RGBLIGHT_ENABLE)
rgblight_toggle();
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES)
rgb_matrix_toggle();
#endif
return false;
case QK_UNDERGLOW_MODE_NEXT:
#if defined(RGBLIGHT_ENABLE)
if (shifted) {
rgblight_step_reverse();
} else {
rgblight_step();
}
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES)
if (shifted) {
rgb_matrix_step_reverse();
} else {
rgb_matrix_step();
}
#endif
return false;
case QK_UNDERGLOW_MODE_PREVIOUS:
#if defined(RGBLIGHT_ENABLE)
if (shifted) {
rgblight_step();
} else {
rgblight_step_reverse();
}
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES)
if (shifted) {
rgb_matrix_step();
} else {
rgb_matrix_step_reverse();
}
#endif
return false;
case QK_UNDERGLOW_HUE_UP:
#if defined(RGBLIGHT_ENABLE)
if (shifted) {
rgblight_decrease_hue();
} else {
rgblight_increase_hue();
}
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES)
if (shifted) {
rgb_matrix_decrease_hue();
} else {
rgb_matrix_increase_hue();
}
#endif
return false;
case QK_UNDERGLOW_HUE_DOWN:
#if defined(RGBLIGHT_ENABLE)
if (shifted) {
rgblight_increase_hue();
} else {
rgblight_decrease_hue();
}
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES)
if (shifted) {
rgb_matrix_increase_hue();
} else {
rgb_matrix_decrease_hue();
}
#endif
return false;
case QK_UNDERGLOW_SATURATION_UP:
#if defined(RGBLIGHT_ENABLE)
if (shifted) {
rgblight_decrease_sat();
} else {
rgblight_increase_sat();
}
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES)
if (shifted) {
rgb_matrix_decrease_sat();
} else {
rgb_matrix_increase_sat();
}
#endif
return false;
case QK_UNDERGLOW_SATURATION_DOWN:
#if defined(RGBLIGHT_ENABLE)
if (shifted) {
rgblight_increase_sat();
} else {
rgblight_decrease_sat();
}
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES)
if (shifted) {
rgb_matrix_increase_sat();
} else {
rgb_matrix_decrease_sat();
}
#endif
return false;
case QK_UNDERGLOW_VALUE_UP:
#if defined(RGBLIGHT_ENABLE)
if (shifted) {
rgblight_decrease_val();
} else {
rgblight_increase_val();
}
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES)
if (shifted) {
rgb_matrix_decrease_val();
} else {
rgb_matrix_increase_val();
}
#endif
return false;
case QK_UNDERGLOW_VALUE_DOWN:
#if defined(RGBLIGHT_ENABLE)
if (shifted) {
rgblight_increase_val();
} else {
rgblight_decrease_val();
}
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES)
if (shifted) {
rgb_matrix_increase_val();
} else {
rgb_matrix_decrease_val();
}
#endif
return false;
case QK_UNDERGLOW_SPEED_UP:
#if defined(RGBLIGHT_ENABLE)
if (shifted) {
rgblight_decrease_speed();
} else {
rgblight_increase_speed();
}
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES)
if (shifted) {
rgb_matrix_decrease_speed();
} else {
rgb_matrix_increase_speed();
}
#endif
return false;
case QK_UNDERGLOW_SPEED_DOWN:
#if defined(RGBLIGHT_ENABLE)
if (shifted) {
rgblight_increase_speed();
} else {
rgblight_decrease_speed();
}
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES)
if (shifted) {
rgb_matrix_increase_speed();
} else {
rgb_matrix_decrease_speed();
}
#endif
return false;
}
}
return true;
}

View File

@@ -0,0 +1,10 @@
// Copyright 2024 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include "action.h"
bool process_underglow(uint16_t keycode, keyrecord_t *record);