diff options
| author | XScorpion2 <rcalt2vt@gmail.com> | 2021-08-19 12:39:15 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-19 18:39:15 +0100 |
| commit | 9d1c98c891bb8e1e98dc618e0693a7efff23a22e (patch) | |
| tree | b3ceeb02861a2e94c248c1e538e9b8db456ffa47 /quantum/dip_switch.c | |
| parent | af3673a5b6985f4364210c3656f323624c2e1962 (diff) | |
| download | qmk_firmware-9d1c98c891bb8e1e98dc618e0693a7efff23a22e.tar.gz qmk_firmware-9d1c98c891bb8e1e98dc618e0693a7efff23a22e.zip | |
Added right vs left specific pin assignments for dip switch (#13074)
* Added right vs left specific pin assignments for dip switch
* Update feature_dip_switch.md
* Ran formatting tools
Diffstat (limited to 'quantum/dip_switch.c')
| -rw-r--r-- | quantum/dip_switch.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/quantum/dip_switch.c b/quantum/dip_switch.c index 72789ca8e..2608cae59 100644 --- a/quantum/dip_switch.c +++ b/quantum/dip_switch.c | |||
| @@ -17,6 +17,9 @@ | |||
| 17 | */ | 17 | */ |
| 18 | 18 | ||
| 19 | #include "dip_switch.h" | 19 | #include "dip_switch.h" |
| 20 | #ifdef SPLIT_KEYBOARD | ||
| 21 | # include "split_common/split_util.h" | ||
| 22 | #endif | ||
| 20 | 23 | ||
| 21 | // for memcpy | 24 | // for memcpy |
| 22 | #include <string.h> | 25 | #include <string.h> |
| @@ -32,6 +35,9 @@ | |||
| 32 | #ifdef DIP_SWITCH_PINS | 35 | #ifdef DIP_SWITCH_PINS |
| 33 | # define NUMBER_OF_DIP_SWITCHES (sizeof(dip_switch_pad) / sizeof(pin_t)) | 36 | # define NUMBER_OF_DIP_SWITCHES (sizeof(dip_switch_pad) / sizeof(pin_t)) |
| 34 | static pin_t dip_switch_pad[] = DIP_SWITCH_PINS; | 37 | static pin_t dip_switch_pad[] = DIP_SWITCH_PINS; |
| 38 | # if defined(SPLIT_KEYBOARD) && defined(DIP_SWITCH_PINS_RIGHT) | ||
| 39 | static pin_t dip_switch_pad_right[] = DIP_SWITCH_PINS_RIGHT; | ||
| 40 | # endif | ||
| 35 | #endif | 41 | #endif |
| 36 | 42 | ||
| 37 | #ifdef DIP_SWITCH_MATRIX_GRID | 43 | #ifdef DIP_SWITCH_MATRIX_GRID |
| @@ -60,7 +66,15 @@ __attribute__((weak)) bool dip_switch_update_mask_kb(uint32_t state) { return di | |||
| 60 | void dip_switch_init(void) { | 66 | void dip_switch_init(void) { |
| 61 | #ifdef DIP_SWITCH_PINS | 67 | #ifdef DIP_SWITCH_PINS |
| 62 | for (uint8_t i = 0; i < NUMBER_OF_DIP_SWITCHES; i++) { | 68 | for (uint8_t i = 0; i < NUMBER_OF_DIP_SWITCHES; i++) { |
| 63 | setPinInputHigh(dip_switch_pad[i]); | 69 | # if defined(SPLIT_KEYBOARD) && defined(DIP_SWITCH_PINS_RIGHT) |
| 70 | if (isLeftHand) { | ||
| 71 | # endif | ||
| 72 | setPinInputHigh(dip_switch_pad[i]); | ||
| 73 | # if defined(SPLIT_KEYBOARD) && defined(DIP_SWITCH_PINS_RIGHT) | ||
| 74 | } else { | ||
| 75 | setPinInputHigh(dip_switch_pad_right[i]); | ||
| 76 | } | ||
| 77 | # endif | ||
| 64 | } | 78 | } |
| 65 | dip_switch_read(true); | 79 | dip_switch_read(true); |
| 66 | #endif | 80 | #endif |
| @@ -89,7 +103,15 @@ void dip_switch_read(bool forced) { | |||
| 89 | 103 | ||
| 90 | for (uint8_t i = 0; i < NUMBER_OF_DIP_SWITCHES; i++) { | 104 | for (uint8_t i = 0; i < NUMBER_OF_DIP_SWITCHES; i++) { |
| 91 | #ifdef DIP_SWITCH_PINS | 105 | #ifdef DIP_SWITCH_PINS |
| 92 | dip_switch_state[i] = !readPin(dip_switch_pad[i]); | 106 | # if defined(SPLIT_KEYBOARD) && defined(DIP_SWITCH_PINS_RIGHT) |
| 107 | if (isLeftHand) { | ||
| 108 | # endif | ||
| 109 | dip_switch_state[i] = !readPin(dip_switch_pad[i]); | ||
| 110 | # if defined(SPLIT_KEYBOARD) && defined(DIP_SWITCH_PINS_RIGHT) | ||
| 111 | } else { | ||
| 112 | dip_switch_state[i] = !readPin(dip_switch_pad_right[i]); | ||
| 113 | } | ||
| 114 | # endif | ||
| 93 | #endif | 115 | #endif |
| 94 | #ifdef DIP_SWITCH_MATRIX_GRID | 116 | #ifdef DIP_SWITCH_MATRIX_GRID |
| 95 | dip_switch_state[i] = peek_matrix(dip_switch_pad[i].row, dip_switch_pad[i].col, read_raw); | 117 | dip_switch_state[i] = peek_matrix(dip_switch_pad[i].row, dip_switch_pad[i].col, read_raw); |
