summaryrefslogtreecommitdiffstats
path: root/quantum/encoder.h
diff options
context:
space:
mode:
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