diff options
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); |