summaryrefslogtreecommitdiffstats
path: root/keyboards/ploopyco/mouse
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/ploopyco/mouse')
-rw-r--r--keyboards/ploopyco/mouse/mouse.c25
-rw-r--r--keyboards/ploopyco/mouse/mouse.h13
-rw-r--r--keyboards/ploopyco/mouse/rules.mk3
3 files changed, 32 insertions, 9 deletions
diff --git a/keyboards/ploopyco/mouse/mouse.c b/keyboards/ploopyco/mouse/mouse.c
index 1b00ef3b71..25ebd1ee2d 100644
--- a/keyboards/ploopyco/mouse/mouse.c
+++ b/keyboards/ploopyco/mouse/mouse.c
@@ -66,7 +66,24 @@ uint8_t OptLowPin = OPT_ENC1;
bool debug_encoder = false;
bool is_drag_scroll = false;
-void process_wheel(report_mouse_t* mouse_report) {
+__attribute__((weak)) bool encoder_update_user(uint8_t index, bool clockwise) { return true; }
+
+bool encoder_update_kb(uint8_t index, bool clockwise) {
+ if (!encoder_update_user(index, clockwise)) {
+ return false;
+ }
+#ifdef MOUSEKEY_ENABLE
+ tap_code(clockwise ? KC_WH_U : KC_WH_D);
+#else
+ mouse_report_t mouse_report = pointing_device_get_report();
+ mouse_report.v = clockwise ? 1 : -1;
+ pointing_device_set_report(mouse_report);
+ pointing_device_send();
+#endif
+ return true;
+}
+
+void process_wheel(void) {
// Lovingly ripped from the Ploopy Source
// If the mouse wheel was just released, do not scroll.
@@ -94,11 +111,11 @@ void process_wheel(report_mouse_t* mouse_report) {
int dir = opt_encoder_handler(p1, p2);
if (dir == 0) return;
- mouse_report->v = (int8_t)(dir * OPT_SCALE);
+ encoder_update_kb(0, dir == 1);
}
-__attribute__((weak)) report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) {
- process_wheel(&mouse_report);
+report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) {
+ process_wheel();
if (is_drag_scroll) {
mouse_report.h = mouse_report.x;
diff --git a/keyboards/ploopyco/mouse/mouse.h b/keyboards/ploopyco/mouse/mouse.h
index ee59827139..8383049aa5 100644
--- a/keyboards/ploopyco/mouse/mouse.h
+++ b/keyboards/ploopyco/mouse/mouse.h
@@ -28,16 +28,16 @@
#define OPT_ENC1_MUX 0
#define OPT_ENC2_MUX 4
-void process_wheel(report_mouse_t* mouse_report);
+void process_wheel(void);
#define LAYOUT(BLL, BL, BM, BR, BRR, BF, BB, BDPI) \
{ {BL, BM, BR, BF, BB, BRR, BLL, BDPI}, }
typedef union {
- uint32_t raw;
- struct {
- uint8_t dpi_config;
- };
+ uint32_t raw;
+ struct {
+ uint8_t dpi_config;
+ };
} keyboard_config_t;
extern keyboard_config_t keyboard_config;
@@ -56,3 +56,6 @@ enum ploopy_keycodes {
PLOOPY_SAFE_RANGE,
#endif
};
+
+bool encoder_update_user(uint8_t index, bool clockwise);
+bool encoder_update_kb(uint8_t index, bool clockwise);
diff --git a/keyboards/ploopyco/mouse/rules.mk b/keyboards/ploopyco/mouse/rules.mk
index 45cb38901a..fd2989be08 100644
--- a/keyboards/ploopyco/mouse/rules.mk
+++ b/keyboards/ploopyco/mouse/rules.mk
@@ -25,5 +25,8 @@ POINTING_DEVICE_ENABLE = yes
POINTING_DEVICE_DRIVER = pmw3360
MOUSEKEY_ENABLE = yes # Mouse keys
+ENCODER_ENABLE := no
+OPTS_DEF += -DENCODER_ENABLE
+
QUANTUM_LIB_SRC += analog.c
SRC += opt_encoder.c