summaryrefslogtreecommitdiffstats
path: root/docs/feature_encoders.md
diff options
context:
space:
mode:
authorAlbert Y <76888457+filterpaper@users.noreply.github.com>2022-08-13 08:27:24 +0800
committerGitHub <noreply@github.com>2022-08-12 17:27:24 -0700
commit70c6b183dfa9f08b8bf0d11be2cd5036ebed9ff4 (patch)
tree77e499bdf7f9133819ded5ceea53b1a07e215301 /docs/feature_encoders.md
parent1a4a2782519a94a5c418ab7e8800c45b3e4d60cf (diff)
[Docs] Refactor code examples (#18003)
Diffstat (limited to 'docs/feature_encoders.md')
-rw-r--r--docs/feature_encoders.md55
1 files changed, 29 insertions, 26 deletions
diff --git a/docs/feature_encoders.md b/docs/feature_encoders.md
index ad6ed2bece..fdde03ac23 100644
--- a/docs/feature_encoders.md
+++ b/docs/feature_encoders.md
@@ -125,34 +125,37 @@ Layer conditions can also be used with the callback function like the following:
```c
bool encoder_update_user(uint8_t index, bool clockwise) {
- if (get_highest_layer(layer_state|default_layer_state) > 0) {
- if (index == 0) {
- if (clockwise) {
- tap_code(KC_WH_D);
- } else {
- tap_code(KC_WH_U);
+ switch(get_highest_layer(layer_state|default_layer_state)) {
+ case 0:
+ if (index == 0) {
+ if (clockwise) {
+ tap_code(KC_PGDN);
+ } else {
+ tap_code(KC_PGUP);
+ }
+ } else if (index == 1) {
+ if (clockwise) {
+ rgb_matrix_increase_speed();
+ } else {
+ rgb_matrix_decrease_speed();
+ }
}
- } else if (index == 1) {
- if (clockwise) {
- tap_code_delay(KC_VOLU, 10);
- } else {
- tap_code_delay(KC_VOLD, 10);
+ break;
+ case 1:
+ if (index == 0) {
+ if (clockwise) {
+ tap_code(KC_WH_D);
+ } else {
+ tap_code(KC_WH_U);
+ }
+ } else if (index == 1) {
+ if (clockwise) {
+ tap_code_delay(KC_VOLU, 10);
+ } else {
+ tap_code_delay(KC_VOLD, 10);
+ }
}
- }
- } else { /* Layer 0 */
- if (index == 0) {
- if (clockwise) {
- tap_code(KC_PGDN);
- } else {
- tap_code(KC_PGUP);
- }
- } else if (index == 1) {
- if (clockwise) {
- rgb_matrix_increase_speed();
- } else {
- rgb_matrix_decrease_speed();
- }
- }
+ break;
}
return false;
}