diff options
author | Drashna Jaelre <drashna@live.com> | 2021-07-01 08:22:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-01 08:22:21 -0700 |
commit | 0bde920817ef458f2ad61a66ce76a2535bbc261b (patch) | |
tree | 9c7078bd67547fc44085cec1fbfbc82a47047161 /docs/feature_dip_switch.md | |
parent | 8f78be076debfc073741f1bc1ba424f1271191d9 (diff) | |
download | qmk_firmware-0bde920817ef458f2ad61a66ce76a2535bbc261b.tar.gz qmk_firmware-0bde920817ef458f2ad61a66ce76a2535bbc261b.zip |
Convert Dip Switch callbacks to boolean functions (#13399)
Diffstat (limited to 'docs/feature_dip_switch.md')
-rw-r--r-- | docs/feature_dip_switch.md | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/docs/feature_dip_switch.md b/docs/feature_dip_switch.md index 15e449c4c..5e8c19bfa 100644 --- a/docs/feature_dip_switch.md +++ b/docs/feature_dip_switch.md | |||
@@ -23,8 +23,9 @@ or | |||
23 | The callback functions can be inserted into your `<keyboard>.c`: | 23 | The callback functions can be inserted into your `<keyboard>.c`: |
24 | 24 | ||
25 | ```c | 25 | ```c |
26 | void dip_switch_update_kb(uint8_t index, bool active) { | 26 | bool dip_switch_update_kb(uint8_t index, bool active) { |
27 | dip_switch_update_user(index, active); | 27 | if !(dip_switch_update_user(index, active)) { return false; } |
28 | return true; | ||
28 | } | 29 | } |
29 | ``` | 30 | ``` |
30 | 31 | ||
@@ -32,7 +33,7 @@ void dip_switch_update_kb(uint8_t index, bool active) { | |||
32 | or `keymap.c`: | 33 | or `keymap.c`: |
33 | 34 | ||
34 | ```c | 35 | ```c |
35 | void dip_switch_update_user(uint8_t index, bool active) { | 36 | bool dip_switch_update_user(uint8_t index, bool active) { |
36 | switch (index) { | 37 | switch (index) { |
37 | case 0: | 38 | case 0: |
38 | if(active) { audio_on(); } else { audio_off(); } | 39 | if(active) { audio_on(); } else { audio_off(); } |
@@ -57,6 +58,7 @@ void dip_switch_update_user(uint8_t index, bool active) { | |||
57 | } | 58 | } |
58 | break; | 59 | break; |
59 | } | 60 | } |
61 | return true; | ||
60 | } | 62 | } |
61 | ``` | 63 | ``` |
62 | 64 | ||
@@ -64,8 +66,9 @@ Additionally, we support bit mask functions which allow for more complex handlin | |||
64 | 66 | ||
65 | 67 | ||
66 | ```c | 68 | ```c |
67 | void dip_switch_update_mask_kb(uint32_t state) { | 69 | bool dip_switch_update_mask_kb(uint32_t state) { |
68 | dip_switch_update_mask_user(state); | 70 | if (!dip_switch_update_mask_user(state)) { return false; } |
71 | return true; | ||
69 | } | 72 | } |
70 | ``` | 73 | ``` |
71 | 74 | ||
@@ -73,7 +76,7 @@ void dip_switch_update_mask_kb(uint32_t state) { | |||
73 | or `keymap.c`: | 76 | or `keymap.c`: |
74 | 77 | ||
75 | ```c | 78 | ```c |
76 | void dip_switch_update_mask_user(uint32_t state) { | 79 | bool dip_switch_update_mask_user(uint32_t state) { |
77 | if (state & (1UL<<0) && state & (1UL<<1)) { | 80 | if (state & (1UL<<0) && state & (1UL<<1)) { |
78 | layer_on(_ADJUST); // C on esc | 81 | layer_on(_ADJUST); // C on esc |
79 | } else { | 82 | } else { |
@@ -89,6 +92,7 @@ void dip_switch_update_mask_user(uint32_t state) { | |||
89 | } else { | 92 | } else { |
90 | layer_off(_TEST_B); | 93 | layer_off(_TEST_B); |
91 | } | 94 | } |
95 | return true; | ||
92 | } | 96 | } |
93 | ``` | 97 | ``` |
94 | 98 | ||