Add support for encoder mapping. (#13286)
This commit is contained in:
parent
7121a228eb
commit
8d5eacb7dd
16 changed files with 279 additions and 53 deletions
|
@ -67,9 +67,30 @@ Additionally, if one side does not have an encoder, you can specify `{}` for the
|
|||
#define ENCODER_RESOLUTIONS_RIGHT { 4 }
|
||||
```
|
||||
|
||||
## Encoder map
|
||||
|
||||
Encoder mapping may be added to your `keymap.c`, which replicates the normal keyswitch layer handling functionality, but with encoders. Add this to your `rules.mk`:
|
||||
|
||||
```make
|
||||
ENCODER_MAP_ENABLE = yes
|
||||
```
|
||||
|
||||
Your `keymap.c` will then need an encoder mapping defined (for four layers and two encoders):
|
||||
|
||||
```c
|
||||
#if defined(ENCODER_MAP_ENABLE)
|
||||
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
|
||||
[_BASE] = { ENCODER_CCW_CW(KC_MS_WH_UP, KC_MS_WH_DOWN), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
|
||||
[_LOWER] = { ENCODER_CCW_CW(RGB_HUD, RGB_HUI), ENCODER_CCW_CW(RGB_SAD, RGB_SAI) },
|
||||
[_RAISE] = { ENCODER_CCW_CW(RGB_VAD, RGB_VAI), ENCODER_CCW_CW(RGB_SPD, RGB_SPI) },
|
||||
[_ADJUST] = { ENCODER_CCW_CW(RGB_RMOD, RGB_MOD), ENCODER_CCW_CW(KC_RIGHT, KC_LEFT) },
|
||||
};
|
||||
#endif
|
||||
```
|
||||
|
||||
## Callbacks
|
||||
|
||||
The callback functions can be inserted into your `<keyboard>.c`:
|
||||
When not using `ENCODER_MAP_ENABLE = yes`, the callback functions can be inserted into your `<keyboard>.c`:
|
||||
|
||||
```c
|
||||
bool encoder_update_kb(uint8_t index, bool clockwise) {
|
||||
|
|
|
@ -31,3 +31,16 @@ Note that the array indices are reversed same as the matrix and the values are o
|
|||
|`SH_OS` |One shot swap hands: toggles while pressed or until next key press. |
|
||||
|
||||
`SH_TT` swap-hands tap-toggle key is similar to [layer tap-toggle](feature_layers.md?id=switching-and-toggling-layers). Tapping repeatedly (5 taps by default) will toggle swap-hands on or off, like `SH_TG`. Tap-toggle count can be changed by defining a value for `TAPPING_TOGGLE`.
|
||||
|
||||
## Encoder Mapping
|
||||
|
||||
When using an encoder mapping, it's also able to handle swapping encoders between sides, too.
|
||||
|
||||
Encoder indexes are defined as left-to-right, and the extent of the array needs to match the number of encoders on the keyboard.
|
||||
|
||||
As an example, if a split keyboard has a single encoder per side, you can swap the order by using the following code in your keymap:
|
||||
```c
|
||||
#if defined(SWAP_HANDS_ENABLE) && defined(ENCODER_MAP_ENABLE)
|
||||
const uint8_t PROGMEM encoder_hand_swap_config[NUM_ENCODERS] = { 1, 0 };
|
||||
#endif
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue