From c1161a7a322584be1f328e76dbbb68dbc1de333b Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Sun, 21 Dec 2025 20:52:55 +0000 Subject: [PATCH] Refactor core use of deprecated `isLeftHand` (#25888) --- drivers/encoder/encoder_quadrature.c | 10 ++++------ quantum/dip_switch.c | 3 ++- .../tests/encoder_tests_split_left_eq_right.cpp | 4 ++++ .../tests/encoder_tests_split_left_gt_right.cpp | 4 ++++ .../tests/encoder_tests_split_left_lt_right.cpp | 4 ++++ quantum/encoder/tests/encoder_tests_split_no_left.cpp | 4 ++++ quantum/encoder/tests/encoder_tests_split_no_right.cpp | 4 ++++ quantum/encoder/tests/encoder_tests_split_role.cpp | 4 ++++ quantum/matrix.c | 4 ++-- quantum/matrix_common.c | 2 +- 10 files changed, 33 insertions(+), 10 deletions(-) diff --git a/drivers/encoder/encoder_quadrature.c b/drivers/encoder/encoder_quadrature.c index 3dfdb27e8d0..b3aeb136b2f 100644 --- a/drivers/encoder/encoder_quadrature.c +++ b/drivers/encoder/encoder_quadrature.c @@ -27,8 +27,6 @@ # define ENCODER_DEFAULT_PIN_API_IMPL #endif -extern volatile bool isLeftHand; - __attribute__((weak)) void encoder_quadrature_init_pin(uint8_t index, bool pad_b); __attribute__((weak)) uint8_t encoder_quadrature_read_pin(uint8_t index, bool pad_b); @@ -108,10 +106,10 @@ void encoder_quadrature_post_init(void) { void encoder_driver_init(void) { #ifdef SPLIT_KEYBOARD - thisHand = isLeftHand ? 0 : NUM_ENCODERS_LEFT; + thisHand = is_keyboard_left() ? 0 : NUM_ENCODERS_LEFT; thatHand = NUM_ENCODERS_LEFT - thisHand; - thisCount = isLeftHand ? NUM_ENCODERS_LEFT : NUM_ENCODERS_RIGHT; - thatCount = isLeftHand ? NUM_ENCODERS_RIGHT : NUM_ENCODERS_LEFT; + thisCount = is_keyboard_left() ? NUM_ENCODERS_LEFT : NUM_ENCODERS_RIGHT; + thatCount = is_keyboard_left() ? NUM_ENCODERS_RIGHT : NUM_ENCODERS_LEFT; #else // SPLIT_KEYBOARD thisCount = NUM_ENCODERS; #endif @@ -133,7 +131,7 @@ void encoder_driver_init(void) { #if defined(SPLIT_KEYBOARD) && defined(ENCODER_A_PINS_RIGHT) && defined(ENCODER_B_PINS_RIGHT) // Re-initialise the pads if it's the right-hand side - if (!isLeftHand) { + if (!is_keyboard_left()) { const pin_t encoders_pad_a_right[] = ENCODER_A_PINS_RIGHT; const pin_t encoders_pad_b_right[] = ENCODER_B_PINS_RIGHT; for (uint8_t i = 0; i < thisCount; i++) { diff --git a/quantum/dip_switch.c b/quantum/dip_switch.c index 65ae21175b4..f662a0e7fc9 100644 --- a/quantum/dip_switch.c +++ b/quantum/dip_switch.c @@ -21,6 +21,7 @@ #include "dip_switch.h" #ifdef SPLIT_KEYBOARD +# include "keyboard.h" # include "split_common/split_util.h" #endif @@ -87,7 +88,7 @@ static void dip_switch_exec_mapping(uint8_t index, bool on) { void dip_switch_init(void) { #ifdef DIP_SWITCH_PINS # if defined(SPLIT_KEYBOARD) && defined(DIP_SWITCH_PINS_RIGHT) - if (!isLeftHand) { + if (!is_keyboard_left()) { const pin_t dip_switch_pad_right[] = DIP_SWITCH_PINS_RIGHT; for (uint8_t i = 0; i < NUM_DIP_SWITCHES; i++) { dip_switch_pad[i] = dip_switch_pad_right[i]; diff --git a/quantum/encoder/tests/encoder_tests_split_left_eq_right.cpp b/quantum/encoder/tests/encoder_tests_split_left_eq_right.cpp index 7d6b3e30e6b..590bd2e9f43 100644 --- a/quantum/encoder/tests/encoder_tests_split_left_eq_right.cpp +++ b/quantum/encoder/tests/encoder_tests_split_left_eq_right.cpp @@ -41,6 +41,10 @@ bool is_keyboard_master(void) { return isMaster; } +bool is_keyboard_left(void) { + return isLeftHand; +} + bool encoder_update_kb(uint8_t index, bool clockwise) { if (!is_keyboard_master()) { // this method has no effect on slave half diff --git a/quantum/encoder/tests/encoder_tests_split_left_gt_right.cpp b/quantum/encoder/tests/encoder_tests_split_left_gt_right.cpp index 2beb4e39720..e6f4db2636d 100644 --- a/quantum/encoder/tests/encoder_tests_split_left_gt_right.cpp +++ b/quantum/encoder/tests/encoder_tests_split_left_gt_right.cpp @@ -41,6 +41,10 @@ bool is_keyboard_master(void) { return isMaster; } +bool is_keyboard_left(void) { + return isLeftHand; +} + bool encoder_update_kb(uint8_t index, bool clockwise) { if (!is_keyboard_master()) { // this method has no effect on slave half diff --git a/quantum/encoder/tests/encoder_tests_split_left_lt_right.cpp b/quantum/encoder/tests/encoder_tests_split_left_lt_right.cpp index 5612f8b6589..c155f1269ab 100644 --- a/quantum/encoder/tests/encoder_tests_split_left_lt_right.cpp +++ b/quantum/encoder/tests/encoder_tests_split_left_lt_right.cpp @@ -41,6 +41,10 @@ bool is_keyboard_master(void) { return isMaster; } +bool is_keyboard_left(void) { + return isLeftHand; +} + bool encoder_update_kb(uint8_t index, bool clockwise) { if (!is_keyboard_master()) { // this method has no effect on slave half diff --git a/quantum/encoder/tests/encoder_tests_split_no_left.cpp b/quantum/encoder/tests/encoder_tests_split_no_left.cpp index 980e4074ffd..75244b94a27 100644 --- a/quantum/encoder/tests/encoder_tests_split_no_left.cpp +++ b/quantum/encoder/tests/encoder_tests_split_no_left.cpp @@ -41,6 +41,10 @@ bool is_keyboard_master(void) { return isMaster; } +bool is_keyboard_left(void) { + return isLeftHand; +} + bool encoder_update_kb(uint8_t index, bool clockwise) { if (!is_keyboard_master()) { // this method has no effect on slave half diff --git a/quantum/encoder/tests/encoder_tests_split_no_right.cpp b/quantum/encoder/tests/encoder_tests_split_no_right.cpp index d39659853b2..bde6e1c29dd 100644 --- a/quantum/encoder/tests/encoder_tests_split_no_right.cpp +++ b/quantum/encoder/tests/encoder_tests_split_no_right.cpp @@ -41,6 +41,10 @@ bool is_keyboard_master(void) { return isMaster; } +bool is_keyboard_left(void) { + return isLeftHand; +} + bool encoder_update_kb(uint8_t index, bool clockwise) { if (!is_keyboard_master()) { // this method has no effect on slave half diff --git a/quantum/encoder/tests/encoder_tests_split_role.cpp b/quantum/encoder/tests/encoder_tests_split_role.cpp index b588af8c70a..3da6fd6edbf 100644 --- a/quantum/encoder/tests/encoder_tests_split_role.cpp +++ b/quantum/encoder/tests/encoder_tests_split_role.cpp @@ -40,6 +40,10 @@ bool is_keyboard_master(void) { return isMaster; } +bool is_keyboard_left(void) { + return isLeftHand; +} + bool encoder_update_kb(uint8_t index, bool clockwise) { if (!isMaster) { ADD_FAILURE() << "We shouldn't get here."; diff --git a/quantum/matrix.c b/quantum/matrix.c index e99f7540657..ccedcc3f792 100644 --- a/quantum/matrix.c +++ b/quantum/matrix.c @@ -269,7 +269,7 @@ __attribute__((weak)) void matrix_read_rows_on_col(matrix_row_t current_matrix[] void matrix_init(void) { #ifdef SPLIT_KEYBOARD // Set pinout for right half if pinout for that half is defined - if (!isLeftHand) { + if (!is_keyboard_left()) { # ifdef DIRECT_PINS_RIGHT const pin_t direct_pins_right[MATRIX_ROWS_PER_HAND][MATRIX_COLS] = DIRECT_PINS_RIGHT; for (uint8_t i = 0; i < MATRIX_ROWS_PER_HAND; i++) { @@ -292,7 +292,7 @@ void matrix_init(void) { # endif } - thisHand = isLeftHand ? 0 : (MATRIX_ROWS_PER_HAND); + thisHand = is_keyboard_left() ? 0 : (MATRIX_ROWS_PER_HAND); thatHand = MATRIX_ROWS_PER_HAND - thisHand; #endif diff --git a/quantum/matrix_common.c b/quantum/matrix_common.c index 26589f29a64..47669cb6f2b 100644 --- a/quantum/matrix_common.c +++ b/quantum/matrix_common.c @@ -144,7 +144,7 @@ __attribute__((weak)) void matrix_slave_scan_user(void) {} __attribute__((weak)) void matrix_init(void) { #ifdef SPLIT_KEYBOARD - thisHand = isLeftHand ? 0 : (MATRIX_ROWS_PER_HAND); + thisHand = is_keyboard_left() ? 0 : (MATRIX_ROWS_PER_HAND); thatHand = MATRIX_ROWS_PER_HAND - thisHand; #endif