Browse Source

Refactor core use of deprecated `isLeftHand` (#25888)

Joel Challis 7 months ago
parent
commit
c1161a7a32

+ 4 - 6
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++) {

+ 2 - 1
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];

+ 4 - 0
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

+ 4 - 0
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

+ 4 - 0
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

+ 4 - 0
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

+ 4 - 0
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

+ 4 - 0
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.";

+ 2 - 2
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
 

+ 1 - 1
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