summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny <nooges@users.noreply.github.com>2019-08-16 19:46:41 -0400
committerDrashna Jaelre <drashna@live.com>2019-08-16 16:46:41 -0700
commit36dd261d06e86ed90997486776f06b286a163cd8 (patch)
tree96bf3d7419b66eb736cf1d1522f60fad298d9d64
parent61b5914a80a7945952dd259cbe70d1e6752259c2 (diff)
Add support for different encoder pinout for right half of split keyboard (#6521)0.6.451
* Add support for different encoder pinouts for split keyboard * Update documentation for new encoder pinout feature
-rw-r--r--docs/feature_encoders.md9
-rw-r--r--docs/feature_split_keyboard.md7
-rw-r--r--quantum/encoder.c14
3 files changed, 30 insertions, 0 deletions
diff --git a/docs/feature_encoders.md b/docs/feature_encoders.md
index bb2d538e7e..cbf72914e9 100644
--- a/docs/feature_encoders.md
+++ b/docs/feature_encoders.md
@@ -20,6 +20,15 @@ Additionally, the resolution can be specified in the same file (the default & su
#define ENCODER_RESOLUTION 4
+## Split Keyboards
+
+If you are using different pinouts for the encoders on each half of a split keyboard, you can define the pinout for the right half like this:
+
+```c
+#define ENCODERS_PAD_A_RIGHT { encoder1a, encoder2a }
+#define ENCODERS_PAD_B_RIGHT { encoder1b, encoder2b }
+```
+
## Callbacks
The callback functions can be inserted into your `<keyboard>.c`:
diff --git a/docs/feature_split_keyboard.md b/docs/feature_split_keyboard.md
index 4addb1bfd0..60e0d278c0 100644
--- a/docs/feature_split_keyboard.md
+++ b/docs/feature_split_keyboard.md
@@ -167,6 +167,13 @@ This allows you to specify a different set of pins for the matrix on the right s
This allows you to specify a different set of direct pins for the right side.
```c
+#define ENCODERS_PAD_A_RIGHT { encoder1a, encoder2a }
+#define ENCODERS_PAD_B_RIGHT { encoder1b, encoder2b }
+```
+
+This allows you to specify a different set of encoder pins for the right side.
+
+```c
#define RGBLIGHT_SPLIT
```
diff --git a/quantum/encoder.c b/quantum/encoder.c
index 31f00c346b..10d8cf7da0 100644
--- a/quantum/encoder.c
+++ b/quantum/encoder.c
@@ -16,6 +16,9 @@
*/
#include "encoder.h"
+#ifdef SPLIT_KEYBOARD
+ #include "split_util.h"
+#endif
// for memcpy
#include <string.h>
@@ -54,6 +57,17 @@ void encoder_update_kb(int8_t index, bool clockwise) {
}
void encoder_init(void) {
+#if defined(SPLIT_KEYBOARD) && defined(ENCODERS_PAD_A_RIGHT) && defined(ENCODERS_PAD_B_RIGHT)
+ if (!isLeftHand) {
+ const pin_t encoders_pad_a_right[] = ENCODERS_PAD_A_RIGHT;
+ const pin_t encoders_pad_b_right[] = ENCODERS_PAD_B_RIGHT;
+ for (uint8_t i = 0; i < NUMBER_OF_ENCODERS; i++) {
+ encoders_pad_a[i] = encoders_pad_a_right[i];
+ encoders_pad_b[i] = encoders_pad_b_right[i];
+ }
+ }
+#endif
+
for (int i = 0; i < NUMBER_OF_ENCODERS; i++) {
setPinInputHigh(encoders_pad_a[i]);
setPinInputHigh(encoders_pad_b[i]);