summaryrefslogtreecommitdiff
path: root/quantum/encoder.h
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2022-05-29 07:57:11 +1000
committerNick Brassel <nick@tzarc.org>2022-05-29 07:57:11 +1000
commitb835171008eaeaa992a1b8e390af8bce6f5f0b8f (patch)
treede22c239cc47556f8be7538f95f48ad75b86d110 /quantum/encoder.h
parentf5d091a9d58c8349437e9d52de87294258cbd256 (diff)
parent0c8f78020d01ee5c45481d7d93b9b0d9f7b95103 (diff)
Merge branch 'develop' -- breaking changes 2022-05-28.
Diffstat (limited to 'quantum/encoder.h')
-rw-r--r--quantum/encoder.h34
1 files changed, 33 insertions, 1 deletions
diff --git a/quantum/encoder.h b/quantum/encoder.h
index 25dc77721d..82f95b4931 100644
--- a/quantum/encoder.h
+++ b/quantum/encoder.h
@@ -18,6 +18,7 @@
#pragma once
#include "quantum.h"
+#include "util.h"
void encoder_init(void);
bool encoder_read(void);
@@ -26,6 +27,37 @@ bool encoder_update_kb(uint8_t index, bool clockwise);
bool encoder_update_user(uint8_t index, bool clockwise);
#ifdef SPLIT_KEYBOARD
+
void encoder_state_raw(uint8_t* slave_state);
void encoder_update_raw(uint8_t* slave_state);
-#endif
+
+# if defined(ENCODERS_PAD_A_RIGHT)
+# define NUM_ENCODERS_LEFT (sizeof(((pin_t[])ENCODERS_PAD_A)) / sizeof(pin_t))
+# define NUM_ENCODERS_RIGHT (sizeof(((pin_t[])ENCODERS_PAD_A_RIGHT)) / sizeof(pin_t))
+# else
+# define NUM_ENCODERS_LEFT (sizeof(((pin_t[])ENCODERS_PAD_A)) / sizeof(pin_t))
+# define NUM_ENCODERS_RIGHT NUM_ENCODERS_LEFT
+# endif
+# define NUM_ENCODERS (NUM_ENCODERS_LEFT + NUM_ENCODERS_RIGHT)
+
+#else // SPLIT_KEYBOARD
+
+# define NUM_ENCODERS (sizeof(((pin_t[])ENCODERS_PAD_A)) / sizeof(pin_t))
+# define NUM_ENCODERS_LEFT NUM_ENCODERS
+# define NUM_ENCODERS_RIGHT 0
+
+#endif // SPLIT_KEYBOARD
+
+#ifndef NUM_ENCODERS
+# define NUM_ENCODERS 0
+# define NUM_ENCODERS_LEFT 0
+# define NUM_ENCODERS_RIGHT 0
+#endif // NUM_ENCODERS
+
+#define NUM_ENCODERS_MAX_PER_SIDE MAX(NUM_ENCODERS_LEFT, NUM_ENCODERS_RIGHT)
+
+#ifdef ENCODER_MAP_ENABLE
+# define ENCODER_CCW_CW(ccw, cw) \
+ { (cw), (ccw) }
+extern const uint16_t encoder_map[][NUM_ENCODERS][2];
+#endif // ENCODER_MAP_ENABLE