summaryrefslogtreecommitdiffstats
path: root/users/mtei/encoder_update_user.c
diff options
context:
space:
mode:
Diffstat (limited to 'users/mtei/encoder_update_user.c')
-rw-r--r--users/mtei/encoder_update_user.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/users/mtei/encoder_update_user.c b/users/mtei/encoder_update_user.c
new file mode 100644
index 0000000000..67585e0345
--- /dev/null
+++ b/users/mtei/encoder_update_user.c
@@ -0,0 +1,33 @@
+// Copyright (c) 2022 Takeshi Ishii (mtei@github)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include QMK_KEYBOARD_H
+
+/* weak reference */ __attribute__((weak))
+int get_encoder_over_count(void);
+
+bool encoder_update_user(uint8_t index, bool clockwise) {
+#ifndef ENCODER_DETECT_OVER_SPEED
+ switch (index) {
+ /* Left side encoder */
+ case 0: tap_code(clockwise ? KC_LEFT : KC_RGHT); break;
+ /* Right side encoder */
+ case 1: tap_code(clockwise ? KC_DOWN : KC_UP); break;
+ }
+#else
+ // Is there a get_encoder_over_count() in quantum/encoder.c
+ if (get_encoder_over_count != NULL) {
+ int enc_over = get_encoder_over_count();
+ for (; enc_over > 0; enc_over--) {
+ tap_code(KC_MINUS);
+ }
+ }
+ switch (index) {
+ case 0: tap_code(clockwise ? KC_A : KC_B); break;
+ case 1: tap_code(clockwise ? KC_C : KC_D); break;
+ case 2: tap_code(clockwise ? KC_E : KC_F); break;
+ case 3: tap_code(clockwise ? KC_G : KC_H); break;
+ }
+#endif
+ return true;
+}