From ccec4867c80d25548871e2534d2ca6205891824a Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Tue, 9 Jan 2024 11:24:53 +0000 Subject: [PATCH] Align `SPLIT_HAND_MATRIX_GRID` left/right logic with `SPLIT_HAND_PIN` (#22775) --- docs/config_options.md | 2 +- docs/feature_split_keyboard.md | 6 +++--- docs/ja/config_options.md | 2 +- docs/ja/feature_split_keyboard.md | 4 ++-- keyboards/bandominedoni/bandominedoni.c | 6 +++--- keyboards/bandominedoni/config.h | 1 + keyboards/helix/rev3_4rows/config.h | 1 - keyboards/helix/rev3_5rows/config.h | 1 - keyboards/hillside/46/0_1/config.h | 1 + keyboards/hillside/52/0_1/config.h | 1 + keyboards/keychron/q11/config.h | 1 - keyboards/pisces/config.h | 2 ++ keyboards/rate/pistachio/rev2/config.h | 1 + keyboards/splitkb/kyria/rev2/config.h | 1 - quantum/split_common/split_util.c | 6 +++--- 15 files changed, 19 insertions(+), 17 deletions(-) diff --git a/docs/config_options.md b/docs/config_options.md index bc28f603fa..045d9c0747 100644 --- a/docs/config_options.md +++ b/docs/config_options.md @@ -275,7 +275,7 @@ There are a few different ways to set handedness for split keyboards (listed in * For using high/low pin to determine handedness, low = right hand, high = left hand. Replace `B7` with the pin you are using. This is optional, and if you leave `SPLIT_HAND_PIN` undefined, then you can still use the EE_HANDS method or MASTER_LEFT / MASTER_RIGHT defines like the stock Let's Split uses. * `#define SPLIT_HAND_MATRIX_GRID ,` - * The handedness is determined by using the intersection of the keyswitches in the key matrix, which does not exist. Normally, when this intersection is shorted (level low), it is considered left. If you define `#define SPLIT_HAND_MATRIX_GRID_LOW_IS_RIGHT`, it is determined to be right when the level is low. + * The handedness is determined by using the intersection of the keyswitches in the key matrix, which does not exist. Normally, when this intersection is shorted (level low), it is considered right. If you define `#define SPLIT_HAND_MATRIX_GRID_LOW_IS_LEFT`, it is determined to be left when the level is low. * `#define EE_HANDS` (only works if `SPLIT_HAND_PIN` and `SPLIT_HAND_MATRIX_GRID` are not defined) * Reads the handedness value stored in the EEPROM after `eeprom-lefthand.eep`/`eeprom-righthand.eep` has been flashed to their respective halves. diff --git a/docs/feature_split_keyboard.md b/docs/feature_split_keyboard.md index 8f695a2b7c..59159cb3fa 100644 --- a/docs/feature_split_keyboard.md +++ b/docs/feature_split_keyboard.md @@ -119,12 +119,12 @@ You can configure the firmware to read key matrix pins on the controller to dete The first pin is the output pin and the second is the input pin. -Some keyboards have unused intersections in the key matrix. This setting uses one of these unused intersections to determine the handness. +Some keyboards have unused intersections in the key matrix. This setting uses one of these unused intersections to determine the handedness. -Normally, when a diode is connected to an intersection, it is judged to be left. If you add the following definition, it will be judged to be right. +Normally, when a diode is connected to an intersection, it is judged to be right. If you add the following definition, it will be judged to be left. ```c -#define SPLIT_HAND_MATRIX_GRID_LOW_IS_RIGHT +#define SPLIT_HAND_MATRIX_GRID_LOW_IS_LEFT ``` Note that adding a diode at a previously unused intersection will effectively tell the firmware that there is a key held down at that point. You can instruct qmk to ignore that intersection by defining `MATRIX_MASKED` and then defining a `matrix_row_t matrix_mask[MATRIX_ROWS]` array in your keyboard config. Each bit of a single value (starting form the least-significant bit) is used to tell qmk whether or not to pay attention to key presses at that intersection. diff --git a/docs/ja/config_options.md b/docs/ja/config_options.md index 5e98da5eee..a349081d6a 100644 --- a/docs/ja/config_options.md +++ b/docs/ja/config_options.md @@ -248,7 +248,7 @@ QMK での全ての利用可能な設定にはデフォルトがあります。 * high/low ピンを使って左右を決定します。low = 右手、high = 左手。`B7` を使っているピンに置き換えます。これはオプションで、`SPLIT_HAND_PIN` が未定義のままである場合、EE_HANDS メソッドまたは標準の Let's Splitが使っている MASTER_LEFT / MASTER_RIGHT 定義をまだ使うことができます。 * `#define SPLIT_HAND_MATRIX_GRID ,` - * 左右はキーマトリックスのキースイッチが存在しない交点を使って決定されます。通常、この交点が短絡している(ローレベル)のときに左側と見なされます。もし `#define SPLIT_HAND_MATRIX_GRID_LOW_IS_RIGHT` が定義されている場合は、ローレベルの時に右側と決定されます。 + * 左右はキーマトリックスのキースイッチが存在しない交点を使って決定されます。通常、この交点が短絡している(ローレベル)のときに右側と見なされます。もし `#define SPLIT_HAND_MATRIX_GRID_LOW_IS_LEFT` が定義されている場合は、ローレベルの時に左側と決定されます。 * `#define EE_HANDS` (`SPLIT_HAND_PIN` と `SPLIT_HAND_MATRIX_GRID` が定義されていない場合のみ動作します) * `eeprom-lefthand.eep`/`eeprom-righthand.eep` がそれぞれの半分に書き込まれた後で、EEPROM 内に格納されている左右の設定の値を読み込みます。 diff --git a/docs/ja/feature_split_keyboard.md b/docs/ja/feature_split_keyboard.md index 3bdf96d1c7..c84b782d87 100644 --- a/docs/ja/feature_split_keyboard.md +++ b/docs/ja/feature_split_keyboard.md @@ -108,10 +108,10 @@ SPLIT_TRANSPORT = custom キーマトリックスに未使用の交点があるキーボードがあります。この設定は、左右の決定にこれらの未使用の交点の1つを使用します。 -通常、ダイオードが交点に接続されている場合、左側と判断されます。次の定義を追加すると、右側と判断されます。 +通常、ダイオードが交点に接続されている場合、右側と判断されます。次の定義を追加すると、左側と判断されます。 ```c -#define SPLIT_HAND_MATRIX_GRID_LOW_IS_RIGHT +#define SPLIT_HAND_MATRIX_GRID_LOW_IS_LEFT ``` #### EEPROM による左右の設定 diff --git a/keyboards/bandominedoni/bandominedoni.c b/keyboards/bandominedoni/bandominedoni.c index 47be95a62b..2884e41c9c 100644 --- a/keyboards/bandominedoni/bandominedoni.c +++ b/keyboards/bandominedoni/bandominedoni.c @@ -97,11 +97,11 @@ static enum { UNKNOWN, LEFT, RIGHT } hand_side = UNKNOWN; hand_side = readPin(SPLIT_HAND_PIN) ? LEFT : RIGHT; return (hand_side == LEFT); #elif defined(SPLIT_HAND_MATRIX_GRID) -# ifdef SPLIT_HAND_MATRIX_GRID_LOW_IS_RIGHT - hand_side = peek_matrix_intersection(SPLIT_HAND_MATRIX_GRID) ? LEFT : RIGHT; +# ifdef SPLIT_HAND_MATRIX_GRID_LOW_IS_LEFT + hand_side = peek_matrix_intersection(SPLIT_HAND_MATRIX_GRID) ? RIGHT : LEFT; return (hand_side == LEFT); # else - hand_side = peek_matrix_intersection(SPLIT_HAND_MATRIX_GRID) ? RIGHT : LEFT; + hand_side = peek_matrix_intersection(SPLIT_HAND_MATRIX_GRID) ? LEFT : RIGHT; return (hand_side == LEFT); # endif #elif defined(EE_HANDS) diff --git a/keyboards/bandominedoni/config.h b/keyboards/bandominedoni/config.h index 1d317a945b..ecab8fc61f 100644 --- a/keyboards/bandominedoni/config.h +++ b/keyboards/bandominedoni/config.h @@ -19,6 +19,7 @@ #ifndef MASTER_RIGHT // SPLIT_HAND_MATRIX_GRID was initially designed to use with left hand side diode D35 mounted and not pressing K7 on the right hand side during boot. However when a USB cable is reconnected immediately, it fails. Decided to use "MASTER_RIGHT" to make it more reliable. # define SPLIT_HAND_MATRIX_GRID B5, D0 +# define SPLIT_HAND_MATRIX_GRID_LOW_IS_LEFT #endif #define SPLIT_USB_DETECT diff --git a/keyboards/helix/rev3_4rows/config.h b/keyboards/helix/rev3_4rows/config.h index 000a09d1ab..cc1a925295 100644 --- a/keyboards/helix/rev3_4rows/config.h +++ b/keyboards/helix/rev3_4rows/config.h @@ -39,7 +39,6 @@ along with this program. If not, see . /* Split hand configration */ #define SPLIT_HAND_MATRIX_GRID D7,B2 -#define SPLIT_HAND_MATRIX_GRID_LOW_IS_RIGHT /* Custom font */ #define OLED_FONT_H "keyboards/helix/common/glcdfont.c" diff --git a/keyboards/helix/rev3_5rows/config.h b/keyboards/helix/rev3_5rows/config.h index 79162a097c..733f8b5a55 100644 --- a/keyboards/helix/rev3_5rows/config.h +++ b/keyboards/helix/rev3_5rows/config.h @@ -39,7 +39,6 @@ along with this program. If not, see . /* Split hand configration */ #define SPLIT_HAND_MATRIX_GRID D7,B2 -#define SPLIT_HAND_MATRIX_GRID_LOW_IS_RIGHT /* Custom font */ #define OLED_FONT_H "keyboards/helix/common/glcdfont.c" diff --git a/keyboards/hillside/46/0_1/config.h b/keyboards/hillside/46/0_1/config.h index 20c4deca40..136be2f581 100644 --- a/keyboards/hillside/46/0_1/config.h +++ b/keyboards/hillside/46/0_1/config.h @@ -6,6 +6,7 @@ /* Split */ #define SPLIT_HAND_MATRIX_GRID B5, F6 +#define SPLIT_HAND_MATRIX_GRID_LOW_IS_LEFT #define MATRIX_MASKED /* Haptic hardware */ diff --git a/keyboards/hillside/52/0_1/config.h b/keyboards/hillside/52/0_1/config.h index 20c4deca40..136be2f581 100644 --- a/keyboards/hillside/52/0_1/config.h +++ b/keyboards/hillside/52/0_1/config.h @@ -6,6 +6,7 @@ /* Split */ #define SPLIT_HAND_MATRIX_GRID B5, F6 +#define SPLIT_HAND_MATRIX_GRID_LOW_IS_LEFT #define MATRIX_MASKED /* Haptic hardware */ diff --git a/keyboards/keychron/q11/config.h b/keyboards/keychron/q11/config.h index 146e42d68c..949e5cf1da 100755 --- a/keyboards/keychron/q11/config.h +++ b/keyboards/keychron/q11/config.h @@ -22,7 +22,6 @@ /* handedness */ #define SPLIT_HAND_MATRIX_GRID A2, A15 -#define SPLIT_HAND_MATRIX_GRID_LOW_IS_RIGHT #define MATRIX_MASKED // actual mask is defined by `matrix_mask` in `q11.c` diff --git a/keyboards/pisces/config.h b/keyboards/pisces/config.h index 4cb5aaf54e..cbdce6f83e 100644 --- a/keyboards/pisces/config.h +++ b/keyboards/pisces/config.h @@ -18,6 +18,8 @@ /* Select hand configuration */ #define SPLIT_HAND_MATRIX_GRID B0,B7 +#define SPLIT_HAND_MATRIX_GRID_LOW_IS_LEFT + #define MATRIX_MASKED #define SPLIT_USB_DETECT diff --git a/keyboards/rate/pistachio/rev2/config.h b/keyboards/rate/pistachio/rev2/config.h index 8b5dcbc9f4..8a12d3d9ee 100644 --- a/keyboards/rate/pistachio/rev2/config.h +++ b/keyboards/rate/pistachio/rev2/config.h @@ -21,6 +21,7 @@ along with this program. If not, see . /* Split hand configration */ #define SPLIT_HAND_MATRIX_GRID D4,D3 +#define SPLIT_HAND_MATRIX_GRID_LOW_IS_LEFT #define RGBLIGHT_LAYERS diff --git a/keyboards/splitkb/kyria/rev2/config.h b/keyboards/splitkb/kyria/rev2/config.h index d39b8eca88..5aa142f90b 100644 --- a/keyboards/splitkb/kyria/rev2/config.h +++ b/keyboards/splitkb/kyria/rev2/config.h @@ -20,7 +20,6 @@ along with this program. If not, see . // Side detection // col 4 row 3 on right-hand-side #define SPLIT_HAND_MATRIX_GRID E6, B3 // row first because the board is col2row -#define SPLIT_HAND_MATRIX_GRID_LOW_IS_RIGHT #define MATRIX_MASKED // actual mask is defined by `matrix_mask` in `rev2.c` /* diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c index 874339361d..2f592bd4cf 100644 --- a/quantum/split_common/split_util.c +++ b/quantum/split_common/split_util.c @@ -147,10 +147,10 @@ __attribute__((weak)) bool is_keyboard_left_impl(void) { return readPin(SPLIT_HAND_PIN); # endif #elif defined(SPLIT_HAND_MATRIX_GRID) -# ifdef SPLIT_HAND_MATRIX_GRID_LOW_IS_RIGHT - return peek_matrix_intersection(SPLIT_HAND_MATRIX_GRID); -# else +# ifdef SPLIT_HAND_MATRIX_GRID_LOW_IS_LEFT return !peek_matrix_intersection(SPLIT_HAND_MATRIX_GRID); +# else + return peek_matrix_intersection(SPLIT_HAND_MATRIX_GRID); # endif #elif defined(EE_HANDS) if (!eeconfig_is_enabled()) {