diff options
| author | Drashna Jaelre <drashna@live.com> | 2021-05-21 23:17:32 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-21 23:17:32 -0700 |
| commit | a0fed0ea176d1c986e40fc4981b900509c90d66e (patch) | |
| tree | ee12f5943046015ea0dce8e2a30a68bc8eb99dbe /docs | |
| parent | 76c23b15abc824f867b48d8d5100dced2417d336 (diff) | |
| download | qmk_firmware-a0fed0ea176d1c986e40fc4981b900509c90d66e.tar.gz qmk_firmware-a0fed0ea176d1c986e40fc4981b900509c90d66e.zip | |
Convert Encoder callbacks to be boolean functions (#12805)
Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/feature_encoders.md | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/docs/feature_encoders.md b/docs/feature_encoders.md index 4338c85e8..a56f093a3 100644 --- a/docs/feature_encoders.md +++ b/docs/feature_encoders.md | |||
| @@ -53,15 +53,15 @@ If you are using different pinouts for the encoders on each half of a split keyb | |||
| 53 | The callback functions can be inserted into your `<keyboard>.c`: | 53 | The callback functions can be inserted into your `<keyboard>.c`: |
| 54 | 54 | ||
| 55 | ```c | 55 | ```c |
| 56 | void encoder_update_kb(uint8_t index, bool clockwise) { | 56 | bool encoder_update_kb(uint8_t index, bool clockwise) { |
| 57 | encoder_update_user(index, clockwise); | 57 | return encoder_update_user(index, clockwise); |
| 58 | } | 58 | } |
| 59 | ``` | 59 | ``` |
| 60 | 60 | ||
| 61 | or `keymap.c`: | 61 | or `keymap.c`: |
| 62 | 62 | ||
| 63 | ```c | 63 | ```c |
| 64 | void encoder_update_user(uint8_t index, bool clockwise) { | 64 | bool encoder_update_user(uint8_t index, bool clockwise) { |
| 65 | if (index == 0) { /* First encoder */ | 65 | if (index == 0) { /* First encoder */ |
| 66 | if (clockwise) { | 66 | if (clockwise) { |
| 67 | tap_code(KC_PGDN); | 67 | tap_code(KC_PGDN); |
| @@ -75,9 +75,12 @@ void encoder_update_user(uint8_t index, bool clockwise) { | |||
| 75 | tap_code(KC_UP); | 75 | tap_code(KC_UP); |
| 76 | } | 76 | } |
| 77 | } | 77 | } |
| 78 | return true; | ||
| 78 | } | 79 | } |
| 79 | ``` | 80 | ``` |
| 80 | 81 | ||
| 82 | !> 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. | ||
| 83 | |||
| 81 | ## Hardware | 84 | ## Hardware |
| 82 | 85 | ||
| 83 | 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. | 86 | 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. |
