1
0
Fork 0

Convert Dip Switch callbacks to boolean functions (#13399)

This commit is contained in:
Drashna Jael're 2021-07-01 08:22:21 -07:00 committed by GitHub
parent 8f78be076d
commit 0bde920817
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 117 additions and 75 deletions

View file

@ -23,8 +23,9 @@ or
The callback functions can be inserted into your `<keyboard>.c`:
```c
void dip_switch_update_kb(uint8_t index, bool active) {
dip_switch_update_user(index, active);
bool dip_switch_update_kb(uint8_t index, bool active) {
if !(dip_switch_update_user(index, active)) { return false; }
return true;
}
```
@ -32,7 +33,7 @@ void dip_switch_update_kb(uint8_t index, bool active) {
or `keymap.c`:
```c
void dip_switch_update_user(uint8_t index, bool active) {
bool dip_switch_update_user(uint8_t index, bool active) {
switch (index) {
case 0:
if(active) { audio_on(); } else { audio_off(); }
@ -57,6 +58,7 @@ void dip_switch_update_user(uint8_t index, bool active) {
}
break;
}
return true;
}
```
@ -64,8 +66,9 @@ Additionally, we support bit mask functions which allow for more complex handlin
```c
void dip_switch_update_mask_kb(uint32_t state) {
dip_switch_update_mask_user(state);
bool dip_switch_update_mask_kb(uint32_t state) {
if (!dip_switch_update_mask_user(state)) { return false; }
return true;
}
```
@ -73,7 +76,7 @@ void dip_switch_update_mask_kb(uint32_t state) {
or `keymap.c`:
```c
void dip_switch_update_mask_user(uint32_t state) {
bool dip_switch_update_mask_user(uint32_t state) {
if (state & (1UL<<0) && state & (1UL<<1)) {
layer_on(_ADJUST); // C on esc
} else {
@ -89,6 +92,7 @@ void dip_switch_update_mask_user(uint32_t state) {
} else {
layer_off(_TEST_B);
}
return true;
}
```

View file

@ -28,8 +28,9 @@ DIP スイッチは、以下を `rules.mk` に追加することでサポート
コールバック関数を `<keyboard>.c` に記述することができます:
```c
void dip_switch_update_kb(uint8_t index, bool active) {
dip_switch_update_user(index, active);
bool dip_switch_update_kb(uint8_t index, bool active) {
if !(dip_switch_update_user(index, active)) { return false; }
return true;
}
```
@ -37,7 +38,7 @@ void dip_switch_update_kb(uint8_t index, bool active) {
あるいは `keymap.c` に記述することもできます:
```c
void dip_switch_update_user(uint8_t index, bool active) {
bool dip_switch_update_user(uint8_t index, bool active) {
switch (index) {
case 0:
if(active) { audio_on(); } else { audio_off(); }
@ -62,6 +63,7 @@ void dip_switch_update_user(uint8_t index, bool active) {
}
break;
}
return true;
}
```
@ -69,8 +71,9 @@ void dip_switch_update_user(uint8_t index, bool active) {
```c
void dip_switch_update_mask_kb(uint32_t state) {
dip_switch_update_mask_user(state);
bool dip_switch_update_mask_kb(uint32_t state) {
if (!dip_switch_update_mask_user(state)) { return false; }
return true;
}
```
@ -78,7 +81,7 @@ void dip_switch_update_mask_kb(uint32_t state) {
あるいは `keymap.c` に記述することもできます:
```c
void dip_switch_update_mask_user(uint32_t state) {
bool dip_switch_update_mask_user(uint32_t state) {
if (state & (1UL<<0) && state & (1UL<<1)) {
layer_on(_ADJUST); // C on esc
} else {
@ -94,6 +97,7 @@ void dip_switch_update_mask_user(uint32_t state) {
} else {
layer_off(_TEST_B);
}
return true;
}
```