summaryrefslogtreecommitdiffstats
path: root/keyboards/ploopyco/mouse/mouse.c
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2020-10-26 23:09:11 -0700
committerGitHub <noreply@github.com>2020-10-27 17:09:11 +1100
commit33074bcbadbafa3a359efda5a45a9412e4eca7d2 (patch)
tree5682dd93d88aa91a91b2e111f1b2a1e5604d7633 /keyboards/ploopyco/mouse/mouse.c
parent555b1640b26fa09ea5f6b5bc7ea07dc654a326f9 (diff)
[Keyboard] Bug fixes and improvements to PloopyCo devices (#10573)
Co-authored-by: Ryan <fauxpark@gmail.com>
Diffstat (limited to 'keyboards/ploopyco/mouse/mouse.c')
-rw-r--r--keyboards/ploopyco/mouse/mouse.c57
1 files changed, 51 insertions, 6 deletions
diff --git a/keyboards/ploopyco/mouse/mouse.c b/keyboards/ploopyco/mouse/mouse.c
index 6a9bffbffe..fad4807c78 100644
--- a/keyboards/ploopyco/mouse/mouse.c
+++ b/keyboards/ploopyco/mouse/mouse.c
@@ -30,6 +30,19 @@
#ifndef OPT_SCALE
# define OPT_SCALE 1 // Multiplier for wheel
#endif
+#ifndef PLOOPY_DPI_OPTIONS
+# define PLOOPY_DPI_OPTIONS { 1200, 1600, 2400 }
+# ifndef PLOOPY_DPI_DEFAULT
+# define PLOOPY_DPI_DEFAULT 1
+# endif
+#endif
+#ifndef PLOOPY_DPI_DEFAULT
+# define PLOOPY_DPI_DEFAULT 0
+#endif
+
+keyboard_config_t keyboard_config;
+uint16_t dpi_array[] = PLOOPY_DPI_OPTIONS;
+#define DPI_OPTION_SIZE (sizeof(dpi_array) / sizeof(uint16_t))
// TODO: Implement libinput profiles
// https://wayland.freedesktop.org/libinput/doc/latest/pointer-acceleration.html
@@ -137,11 +150,18 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
}
// Update Timer to prevent accidental scrolls
- if ((record->event.key.col == 2) && (record->event.key.row == 0)) {
+ if ((record->event.key.col == 1) && (record->event.key.row == 0)) {
lastMidClick = timer_read();
is_scroll_clicked = record->event.pressed;
}
+ if (!process_record_user(keycode, record)) { return false; }
+
+ if (keycode == DPI_CONFIG && record->event.pressed) {
+ keyboard_config.dpi_config = (keyboard_config.dpi_config + 1) % DPI_OPTION_SIZE;
+ eeconfig_update_kb(keyboard_config.raw);
+ pmw_set_cpi(dpi_array[keyboard_config.dpi_config]);
+ }
/* If Mousekeys is disabled, then use handle the mouse button
* keycodes. This makes things simpler, and allows usage of
* the keycodes in a consistent manner. But only do this if
@@ -174,10 +194,11 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
currentReport.buttons &= ~MOUSE_BTN5;
}
pointing_device_set_report(currentReport);
+ pointing_device_send();
}
#endif
- return process_record_user(keycode, record);
+ return true;
}
// Hardware Setup
@@ -190,10 +211,6 @@ void keyboard_pre_init_kb(void) {
setPinInput(OPT_ENC1);
setPinInput(OPT_ENC2);
- // This is the debug LED.
- setPinOutput(F7);
- writePin(F7, debug_enable);
-
/* Ground all output pins connected to ground. This provides additional
* pathways to ground. If you're messing with this, know this: driving ANY
* of these pins high will cause a short. On the MCU. Ka-blooey.
@@ -206,6 +223,13 @@ void keyboard_pre_init_kb(void) {
writePinLow(unused_pins[i]);
}
#endif
+
+ // This is the debug LED.
+#if defined(DEBUG_LED_PIN)
+ setPinOutput(DEBUG_LED_PIN);
+ writePin(DEBUG_LED_PIN, debug_enable);
+#endif
+
keyboard_pre_init_user();
}
@@ -235,3 +259,24 @@ void pointing_device_task(void) {
pointing_device_send();
}
}
+
+void eeconfig_init_kb(void) {
+ keyboard_config.dpi_config = PLOOPY_DPI_DEFAULT;
+ eeconfig_update_kb(keyboard_config.raw);
+}
+
+void matrix_init_kb(void) {
+ // is safe to just read DPI setting since matrix init
+ // comes before pointing device init.
+ keyboard_config.raw = eeconfig_read_kb();
+ if (keyboard_config.dpi_config > DPI_OPTION_SIZE) {
+ eeconfig_init_kb();
+ }
+ matrix_init_user();
+}
+
+void keyboard_post_init_kb(void) {
+ pmw_set_cpi(dpi_array[keyboard_config.dpi_config]);
+
+ keyboard_post_init_user();
+}