aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/feature_dip_switch.md16
-rw-r--r--docs/ja/feature_dip_switch.md16
2 files changed, 20 insertions, 12 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
23The callback functions can be inserted into your `<keyboard>.c`: 23The callback functions can be inserted into your `<keyboard>.c`:
24 24
25```c 25```c
26void dip_switch_update_kb(uint8_t index, bool active) { 26bool 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) {
32or `keymap.c`: 33or `keymap.c`:
33 34
34```c 35```c
35void dip_switch_update_user(uint8_t index, bool active) { 36bool 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
67void dip_switch_update_mask_kb(uint32_t state) { 69bool 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) {
73or `keymap.c`: 76or `keymap.c`:
74 77
75```c 78```c
76void dip_switch_update_mask_user(uint32_t state) { 79bool 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
diff --git a/docs/ja/feature_dip_switch.md b/docs/ja/feature_dip_switch.md
index a0f6aeb00..a5436779f 100644
--- a/docs/ja/feature_dip_switch.md
+++ b/docs/ja/feature_dip_switch.md
@@ -28,8 +28,9 @@ DIP スイッチは、以下を `rules.mk` に追加することでサポート
28コールバック関数を `<keyboard>.c` に記述することができます: 28コールバック関数を `<keyboard>.c` に記述することができます:
29 29
30```c 30```c
31void dip_switch_update_kb(uint8_t index, bool active) { 31bool dip_switch_update_kb(uint8_t index, bool active) {
32 dip_switch_update_user(index, active); 32 if !(dip_switch_update_user(index, active)) { return false; }
33 return true;
33} 34}
34``` 35```
35 36
@@ -37,7 +38,7 @@ void dip_switch_update_kb(uint8_t index, bool active) {
37あるいは `keymap.c` に記述することもできます: 38あるいは `keymap.c` に記述することもできます:
38 39
39```c 40```c
40void dip_switch_update_user(uint8_t index, bool active) { 41bool dip_switch_update_user(uint8_t index, bool active) {
41 switch (index) { 42 switch (index) {
42 case 0: 43 case 0:
43 if(active) { audio_on(); } else { audio_off(); } 44 if(active) { audio_on(); } else { audio_off(); }
@@ -62,6 +63,7 @@ void dip_switch_update_user(uint8_t index, bool active) {
62 } 63 }
63 break; 64 break;
64 } 65 }
66 return true;
65} 67}
66``` 68```
67 69
@@ -69,8 +71,9 @@ void dip_switch_update_user(uint8_t index, bool active) {
69 71
70 72
71```c 73```c
72void dip_switch_update_mask_kb(uint32_t state) { 74bool dip_switch_update_mask_kb(uint32_t state) {
73 dip_switch_update_mask_user(state); 75 if (!dip_switch_update_mask_user(state)) { return false; }
76 return true;
74} 77}
75``` 78```
76 79
@@ -78,7 +81,7 @@ void dip_switch_update_mask_kb(uint32_t state) {
78あるいは `keymap.c` に記述することもできます: 81あるいは `keymap.c` に記述することもできます:
79 82
80```c 83```c
81void dip_switch_update_mask_user(uint32_t state) { 84bool dip_switch_update_mask_user(uint32_t state) {
82 if (state & (1UL<<0) && state & (1UL<<1)) { 85 if (state & (1UL<<0) && state & (1UL<<1)) {
83 layer_on(_ADJUST); // C on esc 86 layer_on(_ADJUST); // C on esc
84 } else { 87 } else {
@@ -94,6 +97,7 @@ void dip_switch_update_mask_user(uint32_t state) {
94 } else { 97 } else {
95 layer_off(_TEST_B); 98 layer_off(_TEST_B);
96 } 99 }
100 return true;
97} 101}
98``` 102```
99 103