aboutsummaryrefslogtreecommitdiff
path: root/quantum/dip_switch.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/dip_switch.c')
-rw-r--r--quantum/dip_switch.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/quantum/dip_switch.c b/quantum/dip_switch.c
index cda69bd0e..133ec8502 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>
@@ -49,16 +52,24 @@ static uint16_t scan_count;
49static bool dip_switch_state[NUMBER_OF_DIP_SWITCHES] = {0}; 52static bool dip_switch_state[NUMBER_OF_DIP_SWITCHES] = {0};
50static bool last_dip_switch_state[NUMBER_OF_DIP_SWITCHES] = {0}; 53static bool last_dip_switch_state[NUMBER_OF_DIP_SWITCHES] = {0};
51 54
52__attribute__((weak)) void dip_switch_update_user(uint8_t index, bool active) {} 55__attribute__((weak)) bool dip_switch_update_user(uint8_t index, bool active) { return true; }
53 56
54__attribute__((weak)) void dip_switch_update_kb(uint8_t index, bool active) { dip_switch_update_user(index, active); } 57__attribute__((weak)) bool dip_switch_update_kb(uint8_t index, bool active) { return dip_switch_update_user(index, active); }
55 58
56__attribute__((weak)) void dip_switch_update_mask_user(uint32_t state) {} 59__attribute__((weak)) bool dip_switch_update_mask_user(uint32_t state) { return true; }
57 60
58__attribute__((weak)) void dip_switch_update_mask_kb(uint32_t state) { dip_switch_update_mask_user(state); } 61__attribute__((weak)) bool dip_switch_update_mask_kb(uint32_t state) { return dip_switch_update_mask_user(state); }
59 62
60void dip_switch_init(void) { 63void dip_switch_init(void) {
61#ifdef DIP_SWITCH_PINS 64#ifdef DIP_SWITCH_PINS
65# if defined(SPLIT_KEYBOARD) && defined(DIP_SWITCH_PINS_RIGHT)
66 if (!isLeftHand) {
67 const pin_t dip_switch_pad_right[] = DIP_SWITCH_PINS_RIGHT;
68 for (uint8_t i = 0; i < NUMBER_OF_DIP_SWITCHES; i++) {
69 dip_switch_pad[i] = dip_switch_pad_right[i];
70 }
71 }
72# endif
62 for (uint8_t i = 0; i < NUMBER_OF_DIP_SWITCHES; i++) { 73 for (uint8_t i = 0; i < NUMBER_OF_DIP_SWITCHES; i++) {
63 setPinInputHigh(dip_switch_pad[i]); 74 setPinInputHigh(dip_switch_pad[i]);
64 } 75 }