summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2021-12-27 10:16:53 +0000
committerQMK Bot <hello@qmk.fm>2021-12-27 10:16:53 +0000
commitc929b7aadf7f9df056b3e0b2464f23757575f507 (patch)
treea2bb0f68497a523e89a6d13079404dd08ee49d4c /docs
parent6f81880f17f94cb9a2e7a09f2f028c83e5d8b1db (diff)
parent067d94f0b6c957c4e1c0ae1d680b420651fb3766 (diff)
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'docs')
-rw-r--r--docs/feature_encoders.md37
1 files changed, 37 insertions, 0 deletions
diff --git a/docs/feature_encoders.md b/docs/feature_encoders.md
index 8e854c1e58..8ab5ca9c46 100644
--- a/docs/feature_encoders.md
+++ b/docs/feature_encoders.md
@@ -87,6 +87,43 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
!> If you return `true`, this will allow the keyboard level code to run, as well. Returning `false` will override the keyboard level code. Depending on how the keyboard level function is set up.
+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);
+ }
+ } else if (index == 1) {
+ if (clockwise) {
+ tap_code(KC_VOLU);
+ } else {
+ tap_code(KC_VOLD);
+ }
+ }
+ } else { /* Layer 0 */
+ if (index == 0) {
+ if (clockwise) {
+ tap_code(KC_PGDN);
+ } else {
+ tap_code(KC_PGUP);
+ }
+ } else if (index == 1) {
+ if (clockwise) {
+ tap_code(KC_DOWN);
+ } else {
+ tap_code(KC_UP);
+ }
+ }
+ }
+ return false;
+}
+```
+
## Hardware
The A an B lines of the encoders should be wired directly to the MCU, and the C/common lines should be wired to ground.