From 73b7ff4ac7790bf44ed52f8c0bb32ac067418d66 Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Thu, 2 Feb 2023 19:41:44 -0800 Subject: [PATCH 01/13] Add Tri-Layer keycodes to core Co-Authored-By: wilba --- builddefs/generic_features.mk | 2 + builddefs/show_options.mk | 3 +- .../keycodes/keycodes_0.0.2_quantum.hjson | 18 +++++ quantum/keycodes.h | 6 +- quantum/process_keycode/process_tri_layer.c | 43 +++++++++++ quantum/process_keycode/process_tri_layer.h | 9 +++ quantum/quantum.c | 3 + quantum/quantum.h | 4 + tests/basic/test_action_layer.cpp | 77 +++++++++++++++++++ tests/test_common/keycode_table.cpp | 2 + 10 files changed, 165 insertions(+), 2 deletions(-) create mode 100644 data/constants/keycodes/keycodes_0.0.2_quantum.hjson create mode 100644 quantum/process_keycode/process_tri_layer.c create mode 100644 quantum/process_keycode/process_tri_layer.h diff --git a/builddefs/generic_features.mk b/builddefs/generic_features.mk index 0d897bc1c828..240c52e042f7 100644 --- a/builddefs/generic_features.mk +++ b/builddefs/generic_features.mk @@ -15,6 +15,7 @@ SPACE_CADET_ENABLE ?= yes GRAVE_ESC_ENABLE ?= yes +TRI_LAYER_ENABLE ?= yes GENERIC_FEATURES = \ AUTOCORRECT \ @@ -39,6 +40,7 @@ GENERIC_FEATURES = \ VELOCIKEY \ WPM \ DYNAMIC_TAPPING_TERM \ + TRI_LAYER define HANDLE_GENERIC_FEATURE # $$(info "Processing: $1_ENABLE $2.c") diff --git a/builddefs/show_options.mk b/builddefs/show_options.mk index e9f7e7d0471f..9723b45438a8 100644 --- a/builddefs/show_options.mk +++ b/builddefs/show_options.mk @@ -84,7 +84,8 @@ OTHER_OPTION_NAMES = \ PROGRAMMABLE_BUTTON_ENABLE \ SECURE_ENABLE \ CAPS_WORD_ENABLE \ - AUTOCORRECT_ENABLE + AUTOCORRECT_ENABLE \ + TRI_LAYER_ENABLE define NAME_ECHO @printf " %-30s = %-16s # %s\\n" "$1" "$($1)" "$(origin $1)" diff --git a/data/constants/keycodes/keycodes_0.0.2_quantum.hjson b/data/constants/keycodes/keycodes_0.0.2_quantum.hjson new file mode 100644 index 000000000000..32095ff60b56 --- /dev/null +++ b/data/constants/keycodes/keycodes_0.0.2_quantum.hjson @@ -0,0 +1,18 @@ +{ + "keycodes": { + "0x7C77": { + "group": "quantum", + "key": "QK_TRI_LAYER_LOWER", + "aliases": [ + "FN_MO13" + ] + }, + "0x7C78": { + "group": "quantum", + "key": "QK_TRI_LAYER_RAISE", + "aliases": [ + "FN_MO23" + ] + } + } +} diff --git a/quantum/keycodes.h b/quantum/keycodes.h index eafa9eb1b635..681165e3c58d 100644 --- a/quantum/keycodes.h +++ b/quantum/keycodes.h @@ -713,6 +713,8 @@ enum qk_keycode_defines { QK_AUTOCORRECT_ON = 0x7C74, QK_AUTOCORRECT_OFF = 0x7C75, QK_AUTOCORRECT_TOGGLE = 0x7C76, + QK_TRI_LAYER_LOWER = 0x7C77, + QK_TRI_LAYER_RAISE = 0x7C78, SAFE_RANGE = 0x7E00, // Alias @@ -1278,6 +1280,8 @@ enum qk_keycode_defines { AC_ON = QK_AUTOCORRECT_ON, AC_OFF = QK_AUTOCORRECT_OFF, AC_TOGG = QK_AUTOCORRECT_TOGGLE, + FN_MO13 = QK_TRI_LAYER_LOWER, + FN_MO23 = QK_TRI_LAYER_RAISE, }; // Range Helpers @@ -1327,4 +1331,4 @@ enum qk_keycode_defines { #define IS_MACRO_KEYCODE(code) ((code) >= QK_MACRO_0 && (code) <= QK_MACRO_31) #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) +#define IS_QUANTUM_KEYCODE(code) ((code) >= QK_BOOTLOADER && (code) <= QK_TRI_LAYER_RAISE) diff --git a/quantum/process_keycode/process_tri_layer.c b/quantum/process_keycode/process_tri_layer.c new file mode 100644 index 000000000000..39a94a77314b --- /dev/null +++ b/quantum/process_keycode/process_tri_layer.c @@ -0,0 +1,43 @@ +// Copyright 2023 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "process_tri_layer.h" +#include "action_layer.h" + +void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3); + +#ifndef TRI_LAYER_LOWER_LAYER +# define TRI_LAYER_LOWER_LAYER 1 +#endif +#ifndef TRI_LAYER_RAISE_LAYER +# define TRI_LAYER_RAISE_LAYER 2 +#endif +#ifndef TRI_LAYER_ADJUST_LAYER +# define TRI_LAYER_ADJUST_LAYER 3 +#endif + +bool process_tri_layer(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case QK_TRI_LAYER_LOWER: + if (record->event.pressed) { + layer_on(TRI_LAYER_LOWER_LAYER); + update_tri_layer(TRI_LAYER_LOWER_LAYER, TRI_LAYER_RAISE_LAYER, TRI_LAYER_ADJUST_LAYER); + } else { + layer_off(TRI_LAYER_LOWER_LAYER); + update_tri_layer(TRI_LAYER_LOWER_LAYER, TRI_LAYER_RAISE_LAYER, TRI_LAYER_ADJUST_LAYER); + } + return false; + break; + case QK_TRI_LAYER_RAISE: + if (record->event.pressed) { + layer_on(TRI_LAYER_RAISE_LAYER); + update_tri_layer(TRI_LAYER_LOWER_LAYER, TRI_LAYER_RAISE_LAYER, TRI_LAYER_ADJUST_LAYER); + } else { + layer_off(TRI_LAYER_RAISE_LAYER); + update_tri_layer(TRI_LAYER_LOWER_LAYER, TRI_LAYER_RAISE_LAYER, TRI_LAYER_ADJUST_LAYER); + } + return false; + break; + } + return true; +} diff --git a/quantum/process_keycode/process_tri_layer.h b/quantum/process_keycode/process_tri_layer.h new file mode 100644 index 000000000000..579a395e3218 --- /dev/null +++ b/quantum/process_keycode/process_tri_layer.h @@ -0,0 +1,9 @@ +// Copyright 2023 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include +#include "action.h" + +bool process_tri_layer(uint16_t keycode, keyrecord_t *record); diff --git a/quantum/quantum.c b/quantum/quantum.c index 0e69246f41f1..4b764d0c55b5 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -342,6 +342,9 @@ bool process_record_quantum(keyrecord_t *record) { #endif #ifdef AUTOCORRECT_ENABLE process_autocorrect(keycode, record) && +#endif +#ifdef TRI_LAYER_ENABLE + process_tri_layer(keycode, record) && #endif true)) { return false; diff --git a/quantum/quantum.h b/quantum/quantum.h index 615ec2382c50..705336f8daea 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -240,6 +240,10 @@ extern layer_state_t layer_state; # include "process_autocorrect.h" #endif +#ifdef TRI_LAYER_ENABLE +# include "process_tri_layer.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/tests/basic/test_action_layer.cpp b/tests/basic/test_action_layer.cpp index 883d99b4040b..7ac98ecf35f6 100644 --- a/tests/basic/test_action_layer.cpp +++ b/tests/basic/test_action_layer.cpp @@ -399,3 +399,80 @@ TEST_F(ActionLayer, LayerTapReleasedBeforeKeypressReleaseWithModifiers) { EXPECT_TRUE(layer_state_is(0)); VERIFY_AND_CLEAR(driver); } + +TEST_F(ActionLayer, TriLayerStateTest) { + TestDriver driver; + KeymapKey lower_layer_key = KeymapKey{0, 0, 0, QK_TRI_LAYER_LOWER}; + KeymapKey raise_layer_key = KeymapKey{0, 1, 0, QK_TRI_LAYER_RAISE}; + + set_keymap({raise_layer_key, lower_layer_key, \ + KeymapKey{1, 0, 0, KC_TRNS}, KeymapKey{1, 1, 0, KC_TRNS}, \ + KeymapKey{2, 0, 0, KC_TRNS}, KeymapKey{2, 1, 0, KC_TRNS}, \ + KeymapKey{3, 0, 0, KC_TRNS}, KeymapKey{3, 1, 0, KC_TRNS}, \ + }); + + /* Press Lower. */ + EXPECT_NO_REPORT(driver); + lower_layer_key.press(); + run_one_scan_loop(); + EXPECT_TRUE(layer_state_is(1)); + EXPECT_FALSE(layer_state_is(2)); + EXPECT_FALSE(layer_state_is(3)); + VERIFY_AND_CLEAR(driver); + + /* Release Lower. */ + EXPECT_NO_REPORT(driver); + lower_layer_key.release(); + run_one_scan_loop(); + EXPECT_FALSE(layer_state_is(1)); + EXPECT_FALSE(layer_state_is(2)); + EXPECT_FALSE(layer_state_is(3)); + VERIFY_AND_CLEAR(driver); + + /* Press Raise. */ + EXPECT_NO_REPORT(driver); + raise_layer_key.press(); + run_one_scan_loop(); + EXPECT_FALSE(layer_state_is(1)); + EXPECT_TRUE(layer_state_is(2)); + EXPECT_FALSE(layer_state_is(3)); + VERIFY_AND_CLEAR(driver); + + /* Release Raise. */ + EXPECT_NO_REPORT(driver); + raise_layer_key.release(); + run_one_scan_loop(); + EXPECT_FALSE(layer_state_is(1)); + EXPECT_FALSE(layer_state_is(2)); + EXPECT_FALSE(layer_state_is(3)); + VERIFY_AND_CLEAR(driver); + + + /* Press Lower, then raise, and release raise and then lower. */ + EXPECT_NO_REPORT(driver); + lower_layer_key.press(); + run_one_scan_loop(); + EXPECT_TRUE(layer_state_is(1)); + EXPECT_FALSE(layer_state_is(2)); + EXPECT_FALSE(layer_state_is(3)); + + raise_layer_key.press(); + run_one_scan_loop(); + EXPECT_TRUE(layer_state_is(1)); + EXPECT_TRUE(layer_state_is(2)); + EXPECT_TRUE(layer_state_is(3)); + + raise_layer_key.release(); + run_one_scan_loop(); + EXPECT_TRUE(layer_state_is(1)); + EXPECT_FALSE(layer_state_is(2)); + EXPECT_FALSE(layer_state_is(3)); + + lower_layer_key.release(); + run_one_scan_loop(); + EXPECT_FALSE(layer_state_is(1)); + EXPECT_FALSE(layer_state_is(2)); + EXPECT_FALSE(layer_state_is(3)); + VERIFY_AND_CLEAR(driver); + +} diff --git a/tests/test_common/keycode_table.cpp b/tests/test_common/keycode_table.cpp index ab9c292e95db..a01326343726 100644 --- a/tests/test_common/keycode_table.cpp +++ b/tests/test_common/keycode_table.cpp @@ -659,5 +659,7 @@ std::map KEYCODE_ID_TABLE = { {QK_AUTOCORRECT_ON, "QK_AUTOCORRECT_ON"}, {QK_AUTOCORRECT_OFF, "QK_AUTOCORRECT_OFF"}, {QK_AUTOCORRECT_TOGGLE, "QK_AUTOCORRECT_TOGGLE"}, + {QK_TRI_LAYER_LOWER, "QK_TRI_LAYER_LOWER"}, + {QK_TRI_LAYER_RAISE, "QK_TRI_LAYER_RAISE"}, {SAFE_RANGE, "SAFE_RANGE"}, }; From 8fa226cf01fedc87d6b950c950e7c7082f187424 Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Thu, 2 Feb 2023 23:05:15 -0800 Subject: [PATCH 02/13] Move tri layer state to action_layer.[ch] --- quantum/action_layer.c | 10 ++++++++++ quantum/action_layer.h | 21 +++++++++++++++++++++ quantum/process_keycode/process_tri_layer.h | 8 ++++++++ quantum/quantum.c | 10 ---------- quantum/quantum.h | 4 ---- 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/quantum/action_layer.c b/quantum/action_layer.c index 74e813792078..35f494df8f16 100644 --- a/quantum/action_layer.c +++ b/quantum/action_layer.c @@ -349,3 +349,13 @@ uint8_t layer_switch_get_layer(keypos_t key) { action_t layer_switch_get_action(keypos_t key) { return action_for_key(layer_switch_get_layer(key), key); } + +layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_t layer2, uint8_t layer3) { + layer_state_t mask12 = ((layer_state_t)1 << layer1) | ((layer_state_t)1 << layer2); + layer_state_t mask3 = (layer_state_t)1 << layer3; + return (state & mask12) == mask12 ? (state | mask3) : (state & ~mask3); +} + +void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) { + layer_state_set(update_tri_layer_state(layer_state, layer1, layer2, layer3)); +} diff --git a/quantum/action_layer.h b/quantum/action_layer.h index 3fe272652999..ff783bb3e7fc 100644 --- a/quantum/action_layer.h +++ b/quantum/action_layer.h @@ -113,6 +113,25 @@ void layer_and(layer_state_t state); void layer_xor(layer_state_t state); layer_state_t layer_state_set_user(layer_state_t state); layer_state_t layer_state_set_kb(layer_state_t state); + +/** + * @brief Applies the tri layer to global layer state. Not be used in layer_state_set_(kb|user) functions. + * + * @param layer1 First layer to check for tri layer + * @param layer2 Second layer to check for tri layer + * @param layer3 Layer to activate if both other layers are enabled + */ +void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3); +/** + * @brief Applies the tri layer behavior to supplied layer bitmask, without using layer functions. + * + * @param state Original layer bitmask to check and modify + * @param layer1 First layer to check for tri layer + * @param layer2 Second layer to check for tri layer + * @param layer3 Layer to activate if both other layers are enabled + * @return layer_state_t returns a modified layer bitmask with tri layer modifications applied + */ +layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_t layer2, uint8_t layer3); #else # define layer_state 0 @@ -131,6 +150,8 @@ layer_state_t layer_state_set_kb(layer_state_t state); # define layer_xor(state) (void)state # define layer_state_set_kb(state) (void)state # define layer_state_set_user(state) (void)state +# define update_tri_layer(layer1, layer2, layer3) +# define update_tri_layer_state(state, layer1, layer2, layer3) (void)state #endif /* pressed actions cache */ diff --git a/quantum/process_keycode/process_tri_layer.h b/quantum/process_keycode/process_tri_layer.h index 579a395e3218..dd8412ae2d17 100644 --- a/quantum/process_keycode/process_tri_layer.h +++ b/quantum/process_keycode/process_tri_layer.h @@ -6,4 +6,12 @@ #include #include "action.h" +/** + * @brief Handles tri layer behavior + * + * @param keycode the keycode + * @param record the key record structure + * @return true continue handling keycodes + * @return false stop handling keycodes + */ bool process_tri_layer(uint16_t keycode, keyrecord_t *record); diff --git a/quantum/quantum.c b/quantum/quantum.c index 4b764d0c55b5..0d88b122c093 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -446,16 +446,6 @@ void set_single_persistent_default_layer(uint8_t default_layer) { default_layer_set((layer_state_t)1 << default_layer); } -layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_t layer2, uint8_t layer3) { - layer_state_t mask12 = ((layer_state_t)1 << layer1) | ((layer_state_t)1 << layer2); - layer_state_t mask3 = (layer_state_t)1 << layer3; - return (state & mask12) == mask12 ? (state | mask3) : (state & ~mask3); -} - -void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) { - layer_state_set(update_tri_layer_state(layer_state, layer1, layer2, layer3)); -} - // TODO: remove legacy api void matrix_init_quantum(void) { matrix_init_kb(); diff --git a/quantum/quantum.h b/quantum/quantum.h index 705336f8daea..5f90c6d4d64c 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -244,10 +244,6 @@ extern layer_state_t layer_state; # include "process_tri_layer.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); - void set_single_persistent_default_layer(uint8_t default_layer); #define IS_LAYER_ON(layer) layer_state_is(layer) From 08214d88d41781ebb628fe17cb93d90ebb378ce7 Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Fri, 3 Feb 2023 15:42:06 -0800 Subject: [PATCH 03/13] Make tri layer configurable --- quantum/process_keycode/process_tri_layer.c | 30 ++++------- quantum/process_keycode/process_tri_layer.h | 1 - quantum/quantum.h | 1 + quantum/tri_layer.c | 39 ++++++++++++++ quantum/tri_layer.h | 59 +++++++++++++++++++++ tests/basic/test_action_layer.cpp | 48 ++++++++--------- 6 files changed, 134 insertions(+), 44 deletions(-) create mode 100644 quantum/tri_layer.c create mode 100644 quantum/tri_layer.h diff --git a/quantum/process_keycode/process_tri_layer.c b/quantum/process_keycode/process_tri_layer.c index 39a94a77314b..f135c732dc68 100644 --- a/quantum/process_keycode/process_tri_layer.c +++ b/quantum/process_keycode/process_tri_layer.c @@ -4,37 +4,29 @@ #include "process_tri_layer.h" #include "action_layer.h" -void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3); - -#ifndef TRI_LAYER_LOWER_LAYER -# define TRI_LAYER_LOWER_LAYER 1 -#endif -#ifndef TRI_LAYER_RAISE_LAYER -# define TRI_LAYER_RAISE_LAYER 2 -#endif -#ifndef TRI_LAYER_ADJUST_LAYER -# define TRI_LAYER_ADJUST_LAYER 3 -#endif +extern uint8_t tri_layer_lower_layer; +extern uint8_t tri_layer_raise_layer; +extern uint8_t tri_layer_adjust_layer; bool process_tri_layer(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case QK_TRI_LAYER_LOWER: if (record->event.pressed) { - layer_on(TRI_LAYER_LOWER_LAYER); - update_tri_layer(TRI_LAYER_LOWER_LAYER, TRI_LAYER_RAISE_LAYER, TRI_LAYER_ADJUST_LAYER); + layer_on(tri_layer_lower_layer); + update_tri_layer(tri_layer_lower_layer, tri_layer_raise_layer, tri_layer_adjust_layer); } else { - layer_off(TRI_LAYER_LOWER_LAYER); - update_tri_layer(TRI_LAYER_LOWER_LAYER, TRI_LAYER_RAISE_LAYER, TRI_LAYER_ADJUST_LAYER); + layer_off(tri_layer_lower_layer); + update_tri_layer(tri_layer_lower_layer, tri_layer_raise_layer, tri_layer_adjust_layer); } return false; break; case QK_TRI_LAYER_RAISE: if (record->event.pressed) { - layer_on(TRI_LAYER_RAISE_LAYER); - update_tri_layer(TRI_LAYER_LOWER_LAYER, TRI_LAYER_RAISE_LAYER, TRI_LAYER_ADJUST_LAYER); + layer_on(tri_layer_raise_layer); + update_tri_layer(tri_layer_lower_layer, tri_layer_raise_layer, tri_layer_adjust_layer); } else { - layer_off(TRI_LAYER_RAISE_LAYER); - update_tri_layer(TRI_LAYER_LOWER_LAYER, TRI_LAYER_RAISE_LAYER, TRI_LAYER_ADJUST_LAYER); + layer_off(tri_layer_raise_layer); + update_tri_layer(tri_layer_lower_layer, tri_layer_raise_layer, tri_layer_adjust_layer); } return false; break; diff --git a/quantum/process_keycode/process_tri_layer.h b/quantum/process_keycode/process_tri_layer.h index dd8412ae2d17..9c4e3df1c2f4 100644 --- a/quantum/process_keycode/process_tri_layer.h +++ b/quantum/process_keycode/process_tri_layer.h @@ -3,7 +3,6 @@ #pragma once -#include #include "action.h" /** diff --git a/quantum/quantum.h b/quantum/quantum.h index 5f90c6d4d64c..708d325a3219 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -241,6 +241,7 @@ extern layer_state_t layer_state; #endif #ifdef TRI_LAYER_ENABLE +# include "tri_layer.h" # include "process_tri_layer.h" #endif diff --git a/quantum/tri_layer.c b/quantum/tri_layer.c new file mode 100644 index 000000000000..f8833adc1589 --- /dev/null +++ b/quantum/tri_layer.c @@ -0,0 +1,39 @@ +// Copyright 2023 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "tri_layer.h" +#include + +uint8_t tri_layer_lower_layer = TRI_LAYER_LOWER_LAYER; +uint8_t tri_layer_raise_layer = TRI_LAYER_RAISE_LAYER; +uint8_t tri_layer_adjust_layer = TRI_LAYER_ADJUST_LAYER; + +void set_tri_layer_lower_layer(uint8_t layer) { + tri_layer_lower_layer = layer; +} + +void set_tri_layer_raise_layer(uint8_t layer) { + tri_layer_raise_layer = layer; +} + +void set_tri_layer_adjust_layer(uint8_t layer) { + tri_layer_adjust_layer = layer; +} + +void set_tri_layer_layers(uint8_t lower, uint8_t raise, uint8_t adjust) { + tri_layer_lower_layer = lower; + tri_layer_raise_layer = raise; + tri_layer_adjust_layer = adjust; +} + +uint8_t get_tri_layer_lower_layer(void) { + return tri_layer_lower_layer; +} + +uint8_t get_tri_layer_raise_layer(void) { + return tri_layer_raise_layer; +} + +uint8_t get_tri_layer_adjust_layer(void) { + return tri_layer_adjust_layer; +} diff --git a/quantum/tri_layer.h b/quantum/tri_layer.h new file mode 100644 index 000000000000..bd7f8d5cf9e5 --- /dev/null +++ b/quantum/tri_layer.h @@ -0,0 +1,59 @@ +// Copyright 2023 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#include + +#ifndef TRI_LAYER_LOWER_LAYER +# define TRI_LAYER_LOWER_LAYER 1 +#endif +#ifndef TRI_LAYER_RAISE_LAYER +# define TRI_LAYER_RAISE_LAYER 2 +#endif +#ifndef TRI_LAYER_ADJUST_LAYER +# define TRI_LAYER_ADJUST_LAYER 3 +#endif + +/** + * @brief Set the tri layer lower layer layer value + * + * @param layer + */ +void set_tri_layer_lower_layer(uint8_t layer); +/** + * @brief Set the tri layer raise layer layer value + * + * @param layer + */ +void set_tri_layer_raise_layer(uint8_t layer); +/** + * @brief Set the tri layer adjust layer object + * + * @param layer + */ +void set_tri_layer_adjust_layer(uint8_t layer); +/** + * @brief Set the tri layer layers object + * + * @param lower + * @param raise + * @param adjust + */ +void set_tri_layer_layers(uint8_t lower, uint8_t raise, uint8_t adjust); +/** + * @brief Get the tri layer lower layer object + * + * @return uint8_t + */ +uint8_t get_tri_layer_lower_layer(void); +/** + * @brief Get the tri layer raise layer object + * + * @return uint8_t + */ +uint8_t get_tri_layer_raise_layer(void); +/** + * @brief Get the tri layer adjust layer object + * + * @return uint8_t + */ +uint8_t get_tri_layer_adjust_layer(void); diff --git a/tests/basic/test_action_layer.cpp b/tests/basic/test_action_layer.cpp index 7ac98ecf35f6..eba12c85a481 100644 --- a/tests/basic/test_action_layer.cpp +++ b/tests/basic/test_action_layer.cpp @@ -415,36 +415,36 @@ TEST_F(ActionLayer, TriLayerStateTest) { EXPECT_NO_REPORT(driver); lower_layer_key.press(); run_one_scan_loop(); - EXPECT_TRUE(layer_state_is(1)); - EXPECT_FALSE(layer_state_is(2)); - EXPECT_FALSE(layer_state_is(3)); + EXPECT_TRUE(layer_state_is(get_tri_layer_lower_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_raise_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); VERIFY_AND_CLEAR(driver); /* Release Lower. */ EXPECT_NO_REPORT(driver); lower_layer_key.release(); run_one_scan_loop(); - EXPECT_FALSE(layer_state_is(1)); - EXPECT_FALSE(layer_state_is(2)); - EXPECT_FALSE(layer_state_is(3)); + EXPECT_FALSE(layer_state_is(get_tri_layer_lower_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_raise_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); VERIFY_AND_CLEAR(driver); /* Press Raise. */ EXPECT_NO_REPORT(driver); raise_layer_key.press(); run_one_scan_loop(); - EXPECT_FALSE(layer_state_is(1)); - EXPECT_TRUE(layer_state_is(2)); - EXPECT_FALSE(layer_state_is(3)); + EXPECT_FALSE(layer_state_is(get_tri_layer_lower_layer())); + EXPECT_TRUE(layer_state_is(get_tri_layer_raise_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); VERIFY_AND_CLEAR(driver); /* Release Raise. */ EXPECT_NO_REPORT(driver); raise_layer_key.release(); run_one_scan_loop(); - EXPECT_FALSE(layer_state_is(1)); - EXPECT_FALSE(layer_state_is(2)); - EXPECT_FALSE(layer_state_is(3)); + EXPECT_FALSE(layer_state_is(get_tri_layer_lower_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_raise_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); VERIFY_AND_CLEAR(driver); @@ -452,27 +452,27 @@ TEST_F(ActionLayer, TriLayerStateTest) { EXPECT_NO_REPORT(driver); lower_layer_key.press(); run_one_scan_loop(); - EXPECT_TRUE(layer_state_is(1)); - EXPECT_FALSE(layer_state_is(2)); - EXPECT_FALSE(layer_state_is(3)); + EXPECT_TRUE(layer_state_is(get_tri_layer_lower_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_raise_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); raise_layer_key.press(); run_one_scan_loop(); - EXPECT_TRUE(layer_state_is(1)); - EXPECT_TRUE(layer_state_is(2)); - EXPECT_TRUE(layer_state_is(3)); + EXPECT_TRUE(layer_state_is(get_tri_layer_lower_layer())); + EXPECT_TRUE(layer_state_is(get_tri_layer_raise_layer())); + EXPECT_TRUE(layer_state_is(get_tri_layer_adjust_layer())); raise_layer_key.release(); run_one_scan_loop(); - EXPECT_TRUE(layer_state_is(1)); - EXPECT_FALSE(layer_state_is(2)); - EXPECT_FALSE(layer_state_is(3)); + EXPECT_TRUE(layer_state_is(get_tri_layer_lower_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_raise_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); lower_layer_key.release(); run_one_scan_loop(); - EXPECT_FALSE(layer_state_is(1)); - EXPECT_FALSE(layer_state_is(2)); - EXPECT_FALSE(layer_state_is(3)); + EXPECT_FALSE(layer_state_is(get_tri_layer_lower_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_raise_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); VERIFY_AND_CLEAR(driver); } From be1ea3ee4b258b5a10f02e153617b228228dc7f1 Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Fri, 3 Feb 2023 17:31:20 -0800 Subject: [PATCH 04/13] pull out variables in favor of functions --- quantum/process_keycode/process_tri_layer.c | 21 +++++++++------------ quantum/tri_layer.c | 6 +++--- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/quantum/process_keycode/process_tri_layer.c b/quantum/process_keycode/process_tri_layer.c index f135c732dc68..e6726d181ee3 100644 --- a/quantum/process_keycode/process_tri_layer.c +++ b/quantum/process_keycode/process_tri_layer.c @@ -2,31 +2,28 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "process_tri_layer.h" +#include "tri_layer.h" #include "action_layer.h" -extern uint8_t tri_layer_lower_layer; -extern uint8_t tri_layer_raise_layer; -extern uint8_t tri_layer_adjust_layer; - bool process_tri_layer(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case QK_TRI_LAYER_LOWER: if (record->event.pressed) { - layer_on(tri_layer_lower_layer); - update_tri_layer(tri_layer_lower_layer, tri_layer_raise_layer, tri_layer_adjust_layer); + layer_on(get_tri_layer_lower_layer()); + update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_raise_layer(), get_tri_layer_adjust_layer()); } else { - layer_off(tri_layer_lower_layer); - update_tri_layer(tri_layer_lower_layer, tri_layer_raise_layer, tri_layer_adjust_layer); + layer_off(get_tri_layer_lower_layer()); + update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_raise_layer(), get_tri_layer_adjust_layer()); } return false; break; case QK_TRI_LAYER_RAISE: if (record->event.pressed) { - layer_on(tri_layer_raise_layer); - update_tri_layer(tri_layer_lower_layer, tri_layer_raise_layer, tri_layer_adjust_layer); + layer_on(get_tri_layer_raise_layer()); + update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_raise_layer(), get_tri_layer_adjust_layer()); } else { - layer_off(tri_layer_raise_layer); - update_tri_layer(tri_layer_lower_layer, tri_layer_raise_layer, tri_layer_adjust_layer); + layer_off(get_tri_layer_raise_layer()); + update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_raise_layer(), get_tri_layer_adjust_layer()); } return false; break; diff --git a/quantum/tri_layer.c b/quantum/tri_layer.c index f8833adc1589..8084c5345011 100644 --- a/quantum/tri_layer.c +++ b/quantum/tri_layer.c @@ -4,9 +4,9 @@ #include "tri_layer.h" #include -uint8_t tri_layer_lower_layer = TRI_LAYER_LOWER_LAYER; -uint8_t tri_layer_raise_layer = TRI_LAYER_RAISE_LAYER; -uint8_t tri_layer_adjust_layer = TRI_LAYER_ADJUST_LAYER; +static uint8_t tri_layer_lower_layer = TRI_LAYER_LOWER_LAYER; +static uint8_t tri_layer_raise_layer = TRI_LAYER_RAISE_LAYER; +static uint8_t tri_layer_adjust_layer = TRI_LAYER_ADJUST_LAYER; void set_tri_layer_lower_layer(uint8_t layer) { tri_layer_lower_layer = layer; From 6e7386c410ea00e4bd8b3d7c2d118724582844ed Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Fri, 3 Feb 2023 18:47:45 -0800 Subject: [PATCH 05/13] Don't enable by default --- builddefs/generic_features.mk | 1 - tests/basic/test_action_layer.cpp | 77 -------------------------- tests/tri_layer/config.h | 6 +++ tests/tri_layer/test.mk | 8 +++ tests/tri_layer/test_tri_layer.cpp | 87 ++++++++++++++++++++++++++++++ 5 files changed, 101 insertions(+), 78 deletions(-) create mode 100644 tests/tri_layer/config.h create mode 100644 tests/tri_layer/test.mk create mode 100644 tests/tri_layer/test_tri_layer.cpp diff --git a/builddefs/generic_features.mk b/builddefs/generic_features.mk index 240c52e042f7..5a1ef5c6f0a5 100644 --- a/builddefs/generic_features.mk +++ b/builddefs/generic_features.mk @@ -15,7 +15,6 @@ SPACE_CADET_ENABLE ?= yes GRAVE_ESC_ENABLE ?= yes -TRI_LAYER_ENABLE ?= yes GENERIC_FEATURES = \ AUTOCORRECT \ diff --git a/tests/basic/test_action_layer.cpp b/tests/basic/test_action_layer.cpp index eba12c85a481..883d99b4040b 100644 --- a/tests/basic/test_action_layer.cpp +++ b/tests/basic/test_action_layer.cpp @@ -399,80 +399,3 @@ TEST_F(ActionLayer, LayerTapReleasedBeforeKeypressReleaseWithModifiers) { EXPECT_TRUE(layer_state_is(0)); VERIFY_AND_CLEAR(driver); } - -TEST_F(ActionLayer, TriLayerStateTest) { - TestDriver driver; - KeymapKey lower_layer_key = KeymapKey{0, 0, 0, QK_TRI_LAYER_LOWER}; - KeymapKey raise_layer_key = KeymapKey{0, 1, 0, QK_TRI_LAYER_RAISE}; - - set_keymap({raise_layer_key, lower_layer_key, \ - KeymapKey{1, 0, 0, KC_TRNS}, KeymapKey{1, 1, 0, KC_TRNS}, \ - KeymapKey{2, 0, 0, KC_TRNS}, KeymapKey{2, 1, 0, KC_TRNS}, \ - KeymapKey{3, 0, 0, KC_TRNS}, KeymapKey{3, 1, 0, KC_TRNS}, \ - }); - - /* Press Lower. */ - EXPECT_NO_REPORT(driver); - lower_layer_key.press(); - run_one_scan_loop(); - EXPECT_TRUE(layer_state_is(get_tri_layer_lower_layer())); - EXPECT_FALSE(layer_state_is(get_tri_layer_raise_layer())); - EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); - VERIFY_AND_CLEAR(driver); - - /* Release Lower. */ - EXPECT_NO_REPORT(driver); - lower_layer_key.release(); - run_one_scan_loop(); - EXPECT_FALSE(layer_state_is(get_tri_layer_lower_layer())); - EXPECT_FALSE(layer_state_is(get_tri_layer_raise_layer())); - EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); - VERIFY_AND_CLEAR(driver); - - /* Press Raise. */ - EXPECT_NO_REPORT(driver); - raise_layer_key.press(); - run_one_scan_loop(); - EXPECT_FALSE(layer_state_is(get_tri_layer_lower_layer())); - EXPECT_TRUE(layer_state_is(get_tri_layer_raise_layer())); - EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); - VERIFY_AND_CLEAR(driver); - - /* Release Raise. */ - EXPECT_NO_REPORT(driver); - raise_layer_key.release(); - run_one_scan_loop(); - EXPECT_FALSE(layer_state_is(get_tri_layer_lower_layer())); - EXPECT_FALSE(layer_state_is(get_tri_layer_raise_layer())); - EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); - VERIFY_AND_CLEAR(driver); - - - /* Press Lower, then raise, and release raise and then lower. */ - EXPECT_NO_REPORT(driver); - lower_layer_key.press(); - run_one_scan_loop(); - EXPECT_TRUE(layer_state_is(get_tri_layer_lower_layer())); - EXPECT_FALSE(layer_state_is(get_tri_layer_raise_layer())); - EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); - - raise_layer_key.press(); - run_one_scan_loop(); - EXPECT_TRUE(layer_state_is(get_tri_layer_lower_layer())); - EXPECT_TRUE(layer_state_is(get_tri_layer_raise_layer())); - EXPECT_TRUE(layer_state_is(get_tri_layer_adjust_layer())); - - raise_layer_key.release(); - run_one_scan_loop(); - EXPECT_TRUE(layer_state_is(get_tri_layer_lower_layer())); - EXPECT_FALSE(layer_state_is(get_tri_layer_raise_layer())); - EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); - - lower_layer_key.release(); - run_one_scan_loop(); - EXPECT_FALSE(layer_state_is(get_tri_layer_lower_layer())); - EXPECT_FALSE(layer_state_is(get_tri_layer_raise_layer())); - EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); - VERIFY_AND_CLEAR(driver); - -} diff --git a/tests/tri_layer/config.h b/tests/tri_layer/config.h new file mode 100644 index 000000000000..b68bf0c2d5aa --- /dev/null +++ b/tests/tri_layer/config.h @@ -0,0 +1,6 @@ +// Copyright 2021 Christopher Courtney, aka Drashna Jael're (@drashna) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "test_common.h" diff --git a/tests/tri_layer/test.mk b/tests/tri_layer/test.mk new file mode 100644 index 000000000000..50548c3e1c0e --- /dev/null +++ b/tests/tri_layer/test.mk @@ -0,0 +1,8 @@ +# Copyright 2021 Christopher Courtney, aka Drashna Jael're (@drashna) +# SPDX-License-Identifier: GPL-2.0-or-later + +# -------------------------------------------------------------------------------- +# Keep this file, even if it is empty, as a marker that this folder contains tests +# -------------------------------------------------------------------------------- + +TRI_LAYER_ENABLE = yes diff --git a/tests/tri_layer/test_tri_layer.cpp b/tests/tri_layer/test_tri_layer.cpp new file mode 100644 index 000000000000..7c33e916f29b --- /dev/null +++ b/tests/tri_layer/test_tri_layer.cpp @@ -0,0 +1,87 @@ +// Copyright 2021 Christopher Courtney, aka Drashna Jael're (@drashna) +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "test_common.hpp" + + +using testing::_; +using testing::InSequence; + +class ActionLayer : public TestFixture {}; + +TEST_F(ActionLayer, TriLayerStateTest) { + TestDriver driver; + KeymapKey lower_layer_key = KeymapKey{0, 0, 0, QK_TRI_LAYER_LOWER}; + KeymapKey raise_layer_key = KeymapKey{0, 1, 0, QK_TRI_LAYER_RAISE}; + + set_keymap({raise_layer_key, lower_layer_key, \ + KeymapKey{1, 0, 0, KC_TRNS}, KeymapKey{1, 1, 0, KC_TRNS}, \ + KeymapKey{2, 0, 0, KC_TRNS}, KeymapKey{2, 1, 0, KC_TRNS}, \ + KeymapKey{3, 0, 0, KC_TRNS}, KeymapKey{3, 1, 0, KC_TRNS}, \ + }); + + /* Press Lower. */ + EXPECT_NO_REPORT(driver); + lower_layer_key.press(); + run_one_scan_loop(); + EXPECT_TRUE(layer_state_is(get_tri_layer_lower_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_raise_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); + VERIFY_AND_CLEAR(driver); + + /* Release Lower. */ + EXPECT_NO_REPORT(driver); + lower_layer_key.release(); + run_one_scan_loop(); + EXPECT_FALSE(layer_state_is(get_tri_layer_lower_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_raise_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); + VERIFY_AND_CLEAR(driver); + + /* Press Raise. */ + EXPECT_NO_REPORT(driver); + raise_layer_key.press(); + run_one_scan_loop(); + EXPECT_FALSE(layer_state_is(get_tri_layer_lower_layer())); + EXPECT_TRUE(layer_state_is(get_tri_layer_raise_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); + VERIFY_AND_CLEAR(driver); + + /* Release Raise. */ + EXPECT_NO_REPORT(driver); + raise_layer_key.release(); + run_one_scan_loop(); + EXPECT_FALSE(layer_state_is(get_tri_layer_lower_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_raise_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); + VERIFY_AND_CLEAR(driver); + + + /* Press Lower, then raise, and release raise and then lower. */ + EXPECT_NO_REPORT(driver); + lower_layer_key.press(); + run_one_scan_loop(); + EXPECT_TRUE(layer_state_is(get_tri_layer_lower_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_raise_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); + + raise_layer_key.press(); + run_one_scan_loop(); + EXPECT_TRUE(layer_state_is(get_tri_layer_lower_layer())); + EXPECT_TRUE(layer_state_is(get_tri_layer_raise_layer())); + EXPECT_TRUE(layer_state_is(get_tri_layer_adjust_layer())); + + raise_layer_key.release(); + run_one_scan_loop(); + EXPECT_TRUE(layer_state_is(get_tri_layer_lower_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_raise_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); + + lower_layer_key.release(); + run_one_scan_loop(); + EXPECT_FALSE(layer_state_is(get_tri_layer_lower_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_raise_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); + VERIFY_AND_CLEAR(driver); + +} From fb2f237288bf043eaf6becdc5838024a178f1583 Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Fri, 3 Feb 2023 19:02:40 -0800 Subject: [PATCH 06/13] Rename functions --- .../keycodes/keycodes_0.0.2_quantum.hjson | 6 +- quantum/keycodes.h | 8 +-- quantum/process_keycode/process_tri_layer.c | 14 ++-- quantum/tri_layer.c | 12 ++-- quantum/tri_layer.h | 16 ++--- tests/test_common/keycode_table.cpp | 2 +- tests/tri_layer/test_tri_layer.cpp | 70 ++++++++++++------- 7 files changed, 72 insertions(+), 56 deletions(-) diff --git a/data/constants/keycodes/keycodes_0.0.2_quantum.hjson b/data/constants/keycodes/keycodes_0.0.2_quantum.hjson index 32095ff60b56..960afa4e5152 100644 --- a/data/constants/keycodes/keycodes_0.0.2_quantum.hjson +++ b/data/constants/keycodes/keycodes_0.0.2_quantum.hjson @@ -4,14 +4,14 @@ "group": "quantum", "key": "QK_TRI_LAYER_LOWER", "aliases": [ - "FN_MO13" + "TL_LOWR" ] }, "0x7C78": { "group": "quantum", - "key": "QK_TRI_LAYER_RAISE", + "key": "QK_TRI_LAYER_UPPER", "aliases": [ - "FN_MO23" + "TL_UPPR" ] } } diff --git a/quantum/keycodes.h b/quantum/keycodes.h index 681165e3c58d..ca8dd7a24bb8 100644 --- a/quantum/keycodes.h +++ b/quantum/keycodes.h @@ -714,7 +714,7 @@ enum qk_keycode_defines { QK_AUTOCORRECT_OFF = 0x7C75, QK_AUTOCORRECT_TOGGLE = 0x7C76, QK_TRI_LAYER_LOWER = 0x7C77, - QK_TRI_LAYER_RAISE = 0x7C78, + QK_TRI_LAYER_UPPER = 0x7C78, SAFE_RANGE = 0x7E00, // Alias @@ -1280,8 +1280,8 @@ enum qk_keycode_defines { AC_ON = QK_AUTOCORRECT_ON, AC_OFF = QK_AUTOCORRECT_OFF, AC_TOGG = QK_AUTOCORRECT_TOGGLE, - FN_MO13 = QK_TRI_LAYER_LOWER, - FN_MO23 = QK_TRI_LAYER_RAISE, + TL_LOWR = QK_TRI_LAYER_LOWER, + TL_UPPR = QK_TRI_LAYER_UPPER, }; // Range Helpers @@ -1331,4 +1331,4 @@ enum qk_keycode_defines { #define IS_MACRO_KEYCODE(code) ((code) >= QK_MACRO_0 && (code) <= QK_MACRO_31) #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_TRI_LAYER_RAISE) +#define IS_QUANTUM_KEYCODE(code) ((code) >= QK_BOOTLOADER && (code) <= QK_TRI_LAYER_UPPER) diff --git a/quantum/process_keycode/process_tri_layer.c b/quantum/process_keycode/process_tri_layer.c index e6726d181ee3..83465cd4c928 100644 --- a/quantum/process_keycode/process_tri_layer.c +++ b/quantum/process_keycode/process_tri_layer.c @@ -10,20 +10,20 @@ bool process_tri_layer(uint16_t keycode, keyrecord_t *record) { case QK_TRI_LAYER_LOWER: if (record->event.pressed) { layer_on(get_tri_layer_lower_layer()); - update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_raise_layer(), get_tri_layer_adjust_layer()); + update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_upper_layer(), get_tri_layer_adjust_layer()); } else { layer_off(get_tri_layer_lower_layer()); - update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_raise_layer(), get_tri_layer_adjust_layer()); + update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_upper_layer(), get_tri_layer_adjust_layer()); } return false; break; - case QK_TRI_LAYER_RAISE: + case QK_TRI_LAYER_UPPER: if (record->event.pressed) { - layer_on(get_tri_layer_raise_layer()); - update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_raise_layer(), get_tri_layer_adjust_layer()); + layer_on(get_tri_layer_upper_layer()); + update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_upper_layer(), get_tri_layer_adjust_layer()); } else { - layer_off(get_tri_layer_raise_layer()); - update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_raise_layer(), get_tri_layer_adjust_layer()); + layer_off(get_tri_layer_upper_layer()); + update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_upper_layer(), get_tri_layer_adjust_layer()); } return false; break; diff --git a/quantum/tri_layer.c b/quantum/tri_layer.c index 8084c5345011..701852faa1ac 100644 --- a/quantum/tri_layer.c +++ b/quantum/tri_layer.c @@ -5,15 +5,15 @@ #include static uint8_t tri_layer_lower_layer = TRI_LAYER_LOWER_LAYER; -static uint8_t tri_layer_raise_layer = TRI_LAYER_RAISE_LAYER; +static uint8_t tri_layer_upper_layer = TRI_LAYER_UPPER_LAYER; static uint8_t tri_layer_adjust_layer = TRI_LAYER_ADJUST_LAYER; void set_tri_layer_lower_layer(uint8_t layer) { tri_layer_lower_layer = layer; } -void set_tri_layer_raise_layer(uint8_t layer) { - tri_layer_raise_layer = layer; +void set_tri_layer_upper_layer(uint8_t layer) { + tri_layer_upper_layer = layer; } void set_tri_layer_adjust_layer(uint8_t layer) { @@ -22,7 +22,7 @@ void set_tri_layer_adjust_layer(uint8_t layer) { void set_tri_layer_layers(uint8_t lower, uint8_t raise, uint8_t adjust) { tri_layer_lower_layer = lower; - tri_layer_raise_layer = raise; + tri_layer_upper_layer = raise; tri_layer_adjust_layer = adjust; } @@ -30,8 +30,8 @@ uint8_t get_tri_layer_lower_layer(void) { return tri_layer_lower_layer; } -uint8_t get_tri_layer_raise_layer(void) { - return tri_layer_raise_layer; +uint8_t get_tri_layer_upper_layer(void) { + return tri_layer_upper_layer; } uint8_t get_tri_layer_adjust_layer(void) { diff --git a/quantum/tri_layer.h b/quantum/tri_layer.h index bd7f8d5cf9e5..82d0502bd4ed 100644 --- a/quantum/tri_layer.h +++ b/quantum/tri_layer.h @@ -6,8 +6,8 @@ #ifndef TRI_LAYER_LOWER_LAYER # define TRI_LAYER_LOWER_LAYER 1 #endif -#ifndef TRI_LAYER_RAISE_LAYER -# define TRI_LAYER_RAISE_LAYER 2 +#ifndef TRI_LAYER_UPPER_LAYER +# define TRI_LAYER_UPPER_LAYER 2 #endif #ifndef TRI_LAYER_ADJUST_LAYER # define TRI_LAYER_ADJUST_LAYER 3 @@ -20,11 +20,11 @@ */ void set_tri_layer_lower_layer(uint8_t layer); /** - * @brief Set the tri layer raise layer layer value + * @brief Set the tri layer upper layer layer value * * @param layer */ -void set_tri_layer_raise_layer(uint8_t layer); +void set_tri_layer_upper_layer(uint8_t layer); /** * @brief Set the tri layer adjust layer object * @@ -35,10 +35,10 @@ void set_tri_layer_adjust_layer(uint8_t layer); * @brief Set the tri layer layers object * * @param lower - * @param raise + * @param upper * @param adjust */ -void set_tri_layer_layers(uint8_t lower, uint8_t raise, uint8_t adjust); +void set_tri_layer_layers(uint8_t lower, uint8_t upper, uint8_t adjust); /** * @brief Get the tri layer lower layer object * @@ -46,11 +46,11 @@ void set_tri_layer_layers(uint8_t lower, uint8_t raise, uint8_t adjust); */ uint8_t get_tri_layer_lower_layer(void); /** - * @brief Get the tri layer raise layer object + * @brief Get the tri layer upper layer object * * @return uint8_t */ -uint8_t get_tri_layer_raise_layer(void); +uint8_t get_tri_layer_upper_layer(void); /** * @brief Get the tri layer adjust layer object * diff --git a/tests/test_common/keycode_table.cpp b/tests/test_common/keycode_table.cpp index a01326343726..337bc8fb5f5c 100644 --- a/tests/test_common/keycode_table.cpp +++ b/tests/test_common/keycode_table.cpp @@ -660,6 +660,6 @@ std::map KEYCODE_ID_TABLE = { {QK_AUTOCORRECT_OFF, "QK_AUTOCORRECT_OFF"}, {QK_AUTOCORRECT_TOGGLE, "QK_AUTOCORRECT_TOGGLE"}, {QK_TRI_LAYER_LOWER, "QK_TRI_LAYER_LOWER"}, - {QK_TRI_LAYER_RAISE, "QK_TRI_LAYER_RAISE"}, + {QK_TRI_LAYER_UPPER, "QK_TRI_LAYER_UPPER"}, {SAFE_RANGE, "SAFE_RANGE"}, }; diff --git a/tests/tri_layer/test_tri_layer.cpp b/tests/tri_layer/test_tri_layer.cpp index 7c33e916f29b..fffc124f4c6a 100644 --- a/tests/tri_layer/test_tri_layer.cpp +++ b/tests/tri_layer/test_tri_layer.cpp @@ -3,29 +3,23 @@ #include "test_common.hpp" - using testing::_; using testing::InSequence; -class ActionLayer : public TestFixture {}; +class TriLayer : public TestFixture {}; -TEST_F(ActionLayer, TriLayerStateTest) { +TEST_F(TriLayer, TriLayerLowerTest) { TestDriver driver; - KeymapKey lower_layer_key = KeymapKey{0, 0, 0, QK_TRI_LAYER_LOWER}; - KeymapKey raise_layer_key = KeymapKey{0, 1, 0, QK_TRI_LAYER_RAISE}; + KeymapKey lower_layer_key = KeymapKey{0, 0, 0, QK_TRI_LAYER_LOWER}; - set_keymap({raise_layer_key, lower_layer_key, \ - KeymapKey{1, 0, 0, KC_TRNS}, KeymapKey{1, 1, 0, KC_TRNS}, \ - KeymapKey{2, 0, 0, KC_TRNS}, KeymapKey{2, 1, 0, KC_TRNS}, \ - KeymapKey{3, 0, 0, KC_TRNS}, KeymapKey{3, 1, 0, KC_TRNS}, \ - }); + set_keymap({lower_layer_key, KeymapKey{1, 0, 0, KC_TRNS}}); /* Press Lower. */ EXPECT_NO_REPORT(driver); lower_layer_key.press(); run_one_scan_loop(); EXPECT_TRUE(layer_state_is(get_tri_layer_lower_layer())); - EXPECT_FALSE(layer_state_is(get_tri_layer_raise_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_upper_layer())); EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); VERIFY_AND_CLEAR(driver); @@ -34,54 +28,76 @@ TEST_F(ActionLayer, TriLayerStateTest) { lower_layer_key.release(); run_one_scan_loop(); EXPECT_FALSE(layer_state_is(get_tri_layer_lower_layer())); - EXPECT_FALSE(layer_state_is(get_tri_layer_raise_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_upper_layer())); EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); VERIFY_AND_CLEAR(driver); +} + +TEST_F(TriLayer, TriLayerUpperTest) { + TestDriver driver; + KeymapKey upper_layer_key = KeymapKey{0, 0, 0, QK_TRI_LAYER_UPPER}; + + set_keymap({upper_layer_key, KeymapKey{2, 0, 0, KC_TRNS}}); /* Press Raise. */ EXPECT_NO_REPORT(driver); - raise_layer_key.press(); + upper_layer_key.press(); run_one_scan_loop(); EXPECT_FALSE(layer_state_is(get_tri_layer_lower_layer())); - EXPECT_TRUE(layer_state_is(get_tri_layer_raise_layer())); + EXPECT_TRUE(layer_state_is(get_tri_layer_upper_layer())); EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); VERIFY_AND_CLEAR(driver); /* Release Raise. */ EXPECT_NO_REPORT(driver); - raise_layer_key.release(); + upper_layer_key.release(); run_one_scan_loop(); EXPECT_FALSE(layer_state_is(get_tri_layer_lower_layer())); - EXPECT_FALSE(layer_state_is(get_tri_layer_raise_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_upper_layer())); EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); VERIFY_AND_CLEAR(driver); +} - - /* Press Lower, then raise, and release raise and then lower. */ +TEST_F(TriLayer, TriLayerAdjustTest) { + TestDriver driver; + KeymapKey lower_layer_key = KeymapKey{0, 0, 0, QK_TRI_LAYER_LOWER}; + KeymapKey upper_layer_key = KeymapKey{0, 1, 0, QK_TRI_LAYER_UPPER}; + + set_keymap({ + upper_layer_key, + lower_layer_key, + KeymapKey{1, 0, 0, KC_TRNS}, + KeymapKey{1, 1, 0, KC_TRNS}, + KeymapKey{2, 0, 0, KC_TRNS}, + KeymapKey{2, 1, 0, KC_TRNS}, + KeymapKey{3, 0, 0, KC_TRNS}, + KeymapKey{3, 1, 0, KC_TRNS}, + }); + + /* Press Lower, then upper, and release upper and then lower. */ EXPECT_NO_REPORT(driver); lower_layer_key.press(); run_one_scan_loop(); EXPECT_TRUE(layer_state_is(get_tri_layer_lower_layer())); - EXPECT_FALSE(layer_state_is(get_tri_layer_raise_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_upper_layer())); EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); - raise_layer_key.press(); + upper_layer_key.press(); run_one_scan_loop(); EXPECT_TRUE(layer_state_is(get_tri_layer_lower_layer())); - EXPECT_TRUE(layer_state_is(get_tri_layer_raise_layer())); + EXPECT_TRUE(layer_state_is(get_tri_layer_upper_layer())); EXPECT_TRUE(layer_state_is(get_tri_layer_adjust_layer())); - raise_layer_key.release(); + lower_layer_key.release(); run_one_scan_loop(); - EXPECT_TRUE(layer_state_is(get_tri_layer_lower_layer())); - EXPECT_FALSE(layer_state_is(get_tri_layer_raise_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_lower_layer())); + EXPECT_TRUE(layer_state_is(get_tri_layer_upper_layer())); EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); - lower_layer_key.release(); + upper_layer_key.release(); run_one_scan_loop(); EXPECT_FALSE(layer_state_is(get_tri_layer_lower_layer())); - EXPECT_FALSE(layer_state_is(get_tri_layer_raise_layer())); + EXPECT_FALSE(layer_state_is(get_tri_layer_upper_layer())); EXPECT_FALSE(layer_state_is(get_tri_layer_adjust_layer())); VERIFY_AND_CLEAR(driver); - } From 10d431b140cd4a66745fbe9d8e55c2bc70a20cab Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Fri, 3 Feb 2023 19:03:12 -0800 Subject: [PATCH 07/13] force enable for via --- builddefs/common_features.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/builddefs/common_features.mk b/builddefs/common_features.mk index 4e032f9dcfaf..0880934e9579 100644 --- a/builddefs/common_features.mk +++ b/builddefs/common_features.mk @@ -620,6 +620,7 @@ ifeq ($(strip $(VIA_ENABLE)), yes) DYNAMIC_KEYMAP_ENABLE := yes RAW_ENABLE := yes BOOTMAGIC_ENABLE := yes + TRI_LAYER_ENABLE := yes SRC += $(QUANTUM_DIR)/via.c OPT_DEFS += -DVIA_ENABLE endif From ea6d719b83c76f705009f709eb5a6073f9e381c0 Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Sun, 5 Feb 2023 18:36:47 -0800 Subject: [PATCH 08/13] Add docs --- docs/_summary.md | 1 + docs/feature_tri_layer.md | 48 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 docs/feature_tri_layer.md diff --git a/docs/_summary.md b/docs/_summary.md index d2d4bb9b326a..b038f08a4dcb 100644 --- a/docs/_summary.md +++ b/docs/_summary.md @@ -93,6 +93,7 @@ * [Swap Hands](feature_swap_hands.md) * [Tap Dance](feature_tap_dance.md) * [Tap-Hold Configuration](tap_hold.md) + * [Tri Layer](feature_tri_layer.md) * [Unicode](feature_unicode.md) * [Userspace](feature_userspace.md) * [WPM Calculation](feature_wpm.md) diff --git a/docs/feature_tri_layer.md b/docs/feature_tri_layer.md new file mode 100644 index 000000000000..e25b3a51a0af --- /dev/null +++ b/docs/feature_tri_layer.md @@ -0,0 +1,48 @@ +# Tri Layers :id=tri-layers + +This enables support for the OLKB style "Tri Layer" keycodes. These function similar to the `MO` (momentary) function key, but if both the "Lower" and "Upper" keys are pressed, it activates a third "Adjust" layer. To enable this functionality, add this line to your `rules.mk`: + +```make +TRI_LAYER_ENABLE = yes +``` + +Note that the "upper", "lower" and "adjust" names don't have a particular significance. They are just used to identify and clarify the behavior, and the layers don't have to be in any particular order. However, layers are processed from highest numeric value to lowest. + +For a detailed explanation of how the layer stack works, checkout [Keymap Overview](keymap.md#keymap-and-layers). + +## Keycodes :id=keycodes + +| Keycode | Alias | Description | +|----------------------|-----------|---------------------------------------------------------------------------------------------------------| +| `QK_TRI_LAYER_LOWER` | `TL_LOWR` | Momentraily enables the "lower" layer. Enables the "adjust" layer if the "upper" layer is also enabled" | +| `QK_TRI_LAYER_UPPER` | `TL_UPPR` | Momentraily enables the "upper" layer. Enables the "adjust" layer if the "lower" layer is also enabled" | + +## Configuration + +To change the default values for the layers, you can change these defines, in your `config.h` + +| Config name | Default | Description | +|--------------------------|---------|------------------------------------------| +| `TRI_LAYER_LOWER_LAYER` | `1` | Sets the default for the "lower" layer. | +| `TRI_LAYER_LOWER_UPPER` | `2` | Sets the default for the "upper" layer. | +| `TRI_LAYER_LOWER_ADJUST` | `3` | Sets the default for the "adjust" layer. | + +Eg, if you wanted to set the "Adjust" layer to be layer 5, you'd add this to your `config.h`: + +```c +#define TRI_LAYER_LOWER_ADJUST 5 +``` + +## Functions + +| Function name | Description | +|----------------------------------------------|-------------------------------------------------| +| `set_tri_layer_lower_layer(layer)` | Changes the "lower" layer*. | +| `set_tri_layer_upper_layer(layer)` | Changes the "upper" layer*. | +| `set_tri_layer_adjust_layer(layer)` | Changes the "adjust" layer*. | +| `set_tri_layer_layers(lower, upper, adjust)` | Stes the "lower", "upper" and "adjust" layers*. | +| `get_tri_layer_lower_layer()` | Gets the current "lower" layer. | +| `get_tri_layer_upper_layer()` | Gets the current "upper" layer. | +| `get_tri_layer_adjust_layer()` | Gets the current "adjust" layer. | + +!> Note: these settings are not persisent, and will be reset to the default on power loss or power cycling of the controller. From 31c2ccc26894abbdc1d691c0bd61e5b75961e648 Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Thu, 9 Feb 2023 15:05:35 -0800 Subject: [PATCH 09/13] Fix linting issues --- quantum/tri_layer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quantum/tri_layer.c b/quantum/tri_layer.c index 701852faa1ac..a5e3f8cb477f 100644 --- a/quantum/tri_layer.c +++ b/quantum/tri_layer.c @@ -21,8 +21,8 @@ void set_tri_layer_adjust_layer(uint8_t layer) { } void set_tri_layer_layers(uint8_t lower, uint8_t raise, uint8_t adjust) { - tri_layer_lower_layer = lower; - tri_layer_upper_layer = raise; + tri_layer_lower_layer = lower; + tri_layer_upper_layer = raise; tri_layer_adjust_layer = adjust; } From 39ebc172e10ea0713edb0cc37b13528bb0c18db9 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Thu, 9 Feb 2023 15:30:42 -0800 Subject: [PATCH 10/13] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Pablo Martínez <58857054+elpekenin@users.noreply.github.com> --- docs/feature_tri_layer.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/feature_tri_layer.md b/docs/feature_tri_layer.md index e25b3a51a0af..a0680eaf144e 100644 --- a/docs/feature_tri_layer.md +++ b/docs/feature_tri_layer.md @@ -24,13 +24,13 @@ To change the default values for the layers, you can change these defines, in yo | Config name | Default | Description | |--------------------------|---------|------------------------------------------| | `TRI_LAYER_LOWER_LAYER` | `1` | Sets the default for the "lower" layer. | -| `TRI_LAYER_LOWER_UPPER` | `2` | Sets the default for the "upper" layer. | -| `TRI_LAYER_LOWER_ADJUST` | `3` | Sets the default for the "adjust" layer. | +| `TRI_LAYER_UPPER_LAYER` | `2` | Sets the default for the "upper" layer. | +| `TRI_LAYER_ADJUST_LAYER` | `3` | Sets the default for the "adjust" layer. | Eg, if you wanted to set the "Adjust" layer to be layer 5, you'd add this to your `config.h`: ```c -#define TRI_LAYER_LOWER_ADJUST 5 +#define TRI_LAYER_ADJUST_LAYER 5 ``` ## Functions From ca36eab932b5cd732f45f33e1bde81b8fee32925 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Thu, 9 Feb 2023 15:47:09 -0800 Subject: [PATCH 11/13] fix momentarily spelling problems --- docs/feature_tri_layer.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/feature_tri_layer.md b/docs/feature_tri_layer.md index a0680eaf144e..2ef190eb2cf8 100644 --- a/docs/feature_tri_layer.md +++ b/docs/feature_tri_layer.md @@ -14,8 +14,8 @@ For a detailed explanation of how the layer stack works, checkout [Keymap Overvi | Keycode | Alias | Description | |----------------------|-----------|---------------------------------------------------------------------------------------------------------| -| `QK_TRI_LAYER_LOWER` | `TL_LOWR` | Momentraily enables the "lower" layer. Enables the "adjust" layer if the "upper" layer is also enabled" | -| `QK_TRI_LAYER_UPPER` | `TL_UPPR` | Momentraily enables the "upper" layer. Enables the "adjust" layer if the "lower" layer is also enabled" | +| `QK_TRI_LAYER_LOWER` | `TL_LOWR` | Momentarily enables the "lower" layer. Enables the "adjust" layer if the "upper" layer is also enabled" | +| `QK_TRI_LAYER_UPPER` | `TL_UPPR` | Momentarily enables the "upper" layer. Enables the "adjust" layer if the "lower" layer is also enabled" | ## Configuration From 9010d2906e3ea6d7098ae5c422e5cdc226c2c4d9 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 10 Feb 2023 10:03:03 -0800 Subject: [PATCH 12/13] Apply suggestions from code review Co-authored-by: Joel Challis --- docs/feature_tri_layer.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/feature_tri_layer.md b/docs/feature_tri_layer.md index 2ef190eb2cf8..aa6c87719ca6 100644 --- a/docs/feature_tri_layer.md +++ b/docs/feature_tri_layer.md @@ -6,9 +6,9 @@ This enables support for the OLKB style "Tri Layer" keycodes. These function si TRI_LAYER_ENABLE = yes ``` -Note that the "upper", "lower" and "adjust" names don't have a particular significance. They are just used to identify and clarify the behavior, and the layers don't have to be in any particular order. However, layers are processed from highest numeric value to lowest. +Note that the "upper", "lower" and "adjust" names don't have a particular significance, they are just used to identify and clarify the behavior. Layers are processed from highest numeric value to lowest, however the values are not required to be consecutive. -For a detailed explanation of how the layer stack works, checkout [Keymap Overview](keymap.md#keymap-and-layers). +For a detailed explanation of how the layer stack works, check out [Keymap Overview](keymap.md#keymap-and-layers). ## Keycodes :id=keycodes From c9812cdb6557074b9c47088f0bbbc71b8c3ae3f8 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Sat, 11 Feb 2023 08:39:50 -0800 Subject: [PATCH 13/13] Apply suggestions from code review Co-authored-by: Nick Brassel --- quantum/process_keycode/process_tri_layer.c | 2 -- quantum/tri_layer.h | 14 +++++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/quantum/process_keycode/process_tri_layer.c b/quantum/process_keycode/process_tri_layer.c index 83465cd4c928..1e681b9a1c2e 100644 --- a/quantum/process_keycode/process_tri_layer.c +++ b/quantum/process_keycode/process_tri_layer.c @@ -16,7 +16,6 @@ bool process_tri_layer(uint16_t keycode, keyrecord_t *record) { update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_upper_layer(), get_tri_layer_adjust_layer()); } return false; - break; case QK_TRI_LAYER_UPPER: if (record->event.pressed) { layer_on(get_tri_layer_upper_layer()); @@ -26,7 +25,6 @@ bool process_tri_layer(uint16_t keycode, keyrecord_t *record) { update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_upper_layer(), get_tri_layer_adjust_layer()); } return false; - break; } return true; } diff --git a/quantum/tri_layer.h b/quantum/tri_layer.h index 82d0502bd4ed..3341ebffb288 100644 --- a/quantum/tri_layer.h +++ b/quantum/tri_layer.h @@ -14,25 +14,25 @@ #endif /** - * @brief Set the tri layer lower layer layer value + * @brief Set the tri layer lower layer index * * @param layer */ void set_tri_layer_lower_layer(uint8_t layer); /** - * @brief Set the tri layer upper layer layer value + * @brief Set the tri layer upper layer index * * @param layer */ void set_tri_layer_upper_layer(uint8_t layer); /** - * @brief Set the tri layer adjust layer object + * @brief Set the tri layer adjust layer index * * @param layer */ void set_tri_layer_adjust_layer(uint8_t layer); /** - * @brief Set the tri layer layers object + * @brief Set the tri layer indices * * @param lower * @param upper @@ -40,19 +40,19 @@ void set_tri_layer_adjust_layer(uint8_t layer); */ void set_tri_layer_layers(uint8_t lower, uint8_t upper, uint8_t adjust); /** - * @brief Get the tri layer lower layer object + * @brief Get the tri layer lower layer index * * @return uint8_t */ uint8_t get_tri_layer_lower_layer(void); /** - * @brief Get the tri layer upper layer object + * @brief Get the tri layer upper layer index * * @return uint8_t */ uint8_t get_tri_layer_upper_layer(void); /** - * @brief Get the tri layer adjust layer object + * @brief Get the tri layer adjust layer index * * @return uint8_t */