diff options
| author | Takeshi ISHII <2170248+mtei@users.noreply.github.com> | 2020-07-04 23:04:47 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-04 15:04:47 +0100 |
| commit | 5c8b23ccffa0083752044f0459e6ac3114ce6e52 (patch) | |
| tree | e73a2f8189905754ba71ede0d42f7a46221ce93a /quantum | |
| parent | 13a8d1681ca89b14931b0f9246dad4a4f60705fa (diff) | |
| download | qmk_firmware-5c8b23ccffa0083752044f0459e6ac3114ce6e52.tar.gz qmk_firmware-5c8b23ccffa0083752044f0459e6ac3114ce6e52.zip | |
add SPLIT_HAND_MATRIX_GRID support (#8685)
Co-authored-by: Danny <nooges@users.noreply.github.com>
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/split_common/split_util.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c index afcd9d2aa..90735eda4 100644 --- a/quantum/split_common/split_util.c +++ b/quantum/split_common/split_util.c | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include "timer.h" | 5 | #include "timer.h" |
| 6 | #include "transport.h" | 6 | #include "transport.h" |
| 7 | #include "quantum.h" | 7 | #include "quantum.h" |
| 8 | #include "wait.h" | ||
| 8 | 9 | ||
| 9 | #ifdef PROTOCOL_LUFA | 10 | #ifdef PROTOCOL_LUFA |
| 10 | # include <LUFA/Drivers/USB/USB.h> | 11 | # include <LUFA/Drivers/USB/USB.h> |
| @@ -82,11 +83,34 @@ static inline bool usbIsActive(void) { | |||
| 82 | static inline bool usbIsActive(void) { return true; } | 83 | static inline bool usbIsActive(void) { return true; } |
| 83 | #endif | 84 | #endif |
| 84 | 85 | ||
| 86 | #ifdef SPLIT_HAND_MATRIX_GRID | ||
| 87 | void matrix_io_delay(void); | ||
| 88 | |||
| 89 | static uint8_t peek_matrix_intersection(pin_t out_pin, pin_t in_pin) { | ||
| 90 | setPinInputHigh(in_pin); | ||
| 91 | setPinOutput(out_pin); | ||
| 92 | writePinLow(out_pin); | ||
| 93 | // It's almost unnecessary, but wait until it's down to low, just in case. | ||
| 94 | wait_us(1); | ||
| 95 | uint8_t pin_state = readPin(in_pin); | ||
| 96 | // Set out_pin to a setting that is less susceptible to noise. | ||
| 97 | setPinInputHigh(out_pin); | ||
| 98 | matrix_io_delay(); // Wait for the pull-up to go HIGH. | ||
| 99 | return pin_state; | ||
| 100 | } | ||
| 101 | #endif | ||
| 102 | |||
| 85 | __attribute__((weak)) bool is_keyboard_left(void) { | 103 | __attribute__((weak)) bool is_keyboard_left(void) { |
| 86 | #if defined(SPLIT_HAND_PIN) | 104 | #if defined(SPLIT_HAND_PIN) |
| 87 | // Test pin SPLIT_HAND_PIN for High/Low, if low it's right hand | 105 | // Test pin SPLIT_HAND_PIN for High/Low, if low it's right hand |
| 88 | setPinInput(SPLIT_HAND_PIN); | 106 | setPinInput(SPLIT_HAND_PIN); |
| 89 | return readPin(SPLIT_HAND_PIN); | 107 | return readPin(SPLIT_HAND_PIN); |
| 108 | #elif defined(SPLIT_HAND_MATRIX_GRID) | ||
| 109 | # ifdef SPLIT_HAND_MATRIX_GRID_LOW_IS_RIGHT | ||
| 110 | return peek_matrix_intersection(SPLIT_HAND_MATRIX_GRID); | ||
| 111 | # else | ||
| 112 | return !peek_matrix_intersection(SPLIT_HAND_MATRIX_GRID); | ||
| 113 | # endif | ||
| 90 | #elif defined(EE_HANDS) | 114 | #elif defined(EE_HANDS) |
| 91 | return eeconfig_read_handedness(); | 115 | return eeconfig_read_handedness(); |
| 92 | #elif defined(MASTER_RIGHT) | 116 | #elif defined(MASTER_RIGHT) |
