aboutsummaryrefslogtreecommitdiff
path: root/keyboards/ploopyco
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2021-06-26 03:58:15 +0000
committerQMK Bot <hello@qmk.fm>2021-06-26 03:58:15 +0000
commite64705d2f40d209d4a52f1431c896cc3944757a1 (patch)
treec5a38d5b2f2991f48c69d2006e9d2f5cd28b6d32 /keyboards/ploopyco
parentd6592d898803f5f65cbbfe50ca3dab0685b2fd81 (diff)
parent79cc6ce2d0d860680834e9b0cadfbe42e789fa0c (diff)
downloadqmk_firmware-e64705d2f40d209d4a52f1431c896cc3944757a1.tar.gz
qmk_firmware-e64705d2f40d209d4a52f1431c896cc3944757a1.zip
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'keyboards/ploopyco')
-rw-r--r--keyboards/ploopyco/mouse/mouse.c25
-rw-r--r--keyboards/ploopyco/mouse/readme.md14
-rw-r--r--keyboards/ploopyco/trackball/readme.md14
-rw-r--r--keyboards/ploopyco/trackball/trackball.c20
-rw-r--r--keyboards/ploopyco/trackball_mini/readme.md11
-rw-r--r--keyboards/ploopyco/trackball_mini/trackball_mini.c31
-rw-r--r--keyboards/ploopyco/trackball_mini/trackball_mini.h9
-rw-r--r--keyboards/ploopyco/trackball_nano/config.h2
8 files changed, 87 insertions, 39 deletions
diff --git a/keyboards/ploopyco/mouse/mouse.c b/keyboards/ploopyco/mouse/mouse.c
index 1eb5e3ead..0bf96a20f 100644
--- a/keyboards/ploopyco/mouse/mouse.c
+++ b/keyboards/ploopyco/mouse/mouse.c
@@ -247,7 +247,6 @@ void pointing_device_init(void) {
247 opt_encoder_init(); 247 opt_encoder_init();
248} 248}
249 249
250bool has_report_changed(report_mouse_t new, report_mouse_t old) { return (new.buttons != old.buttons) || (new.x && new.x != old.x) || (new.y && new.y != old.y) || (new.h && new.h != old.h) || (new.v && new.v != old.v); }
251 250
252void pointing_device_task(void) { 251void pointing_device_task(void) {
253 report_mouse_t mouse_report = pointing_device_get_report(); 252 report_mouse_t mouse_report = pointing_device_get_report();
@@ -256,7 +255,12 @@ void pointing_device_task(void) {
256 255
257 if (is_drag_scroll) { 256 if (is_drag_scroll) {
258 mouse_report.h = mouse_report.x; 257 mouse_report.h = mouse_report.x;
258#ifdef PLOOPY_DRAGSCROLL_INVERT
259 // Invert vertical scroll direction
260 mouse_report.v = -mouse_report.y;
261#else
259 mouse_report.v = mouse_report.y; 262 mouse_report.v = mouse_report.y;
263#endif
260 mouse_report.x = 0; 264 mouse_report.x = 0;
261 mouse_report.y = 0; 265 mouse_report.y = 0;
262 } 266 }
@@ -265,27 +269,10 @@ void pointing_device_task(void) {
265 pointing_device_send(); 269 pointing_device_send();
266} 270}
267 271
268void pointing_device_send(void) {
269 static report_mouse_t old_report = {};
270 report_mouse_t mouseReport = pointing_device_get_report();
271
272 // If you need to do other things, like debugging, this is the place to do it.
273 if (has_report_changed(mouseReport, old_report)) {
274 host_mouse_send(&mouseReport);
275 }
276
277 // send it and 0 it out except for buttons, so those stay until they are explicity over-ridden using update_pointing_device
278 mouseReport.x = 0;
279 mouseReport.y = 0;
280 mouseReport.v = 0;
281 mouseReport.h = 0;
282 pointing_device_set_report(mouseReport);
283 old_report = mouseReport;
284}
285
286void eeconfig_init_kb(void) { 272void eeconfig_init_kb(void) {
287 keyboard_config.dpi_config = PLOOPY_DPI_DEFAULT; 273 keyboard_config.dpi_config = PLOOPY_DPI_DEFAULT;
288 eeconfig_update_kb(keyboard_config.raw); 274 eeconfig_update_kb(keyboard_config.raw);
275 eeconfig_init_user();
289} 276}
290 277
291void matrix_init_kb(void) { 278void matrix_init_kb(void) {
diff --git a/keyboards/ploopyco/mouse/readme.md b/keyboards/ploopyco/mouse/readme.md
index ff37a6b80..e9ad915a6 100644
--- a/keyboards/ploopyco/mouse/readme.md
+++ b/keyboards/ploopyco/mouse/readme.md
@@ -50,3 +50,17 @@ To configure/set your own array, there are two defines to use, `PLOOPY_DPI_OPTIO
50The `PLOOPY_DPI_OPTIONS` array sets the values that you want to be able to cycle through, and the order they are in. The "default" define lets the firmware know which of these options is the default and should be loaded by default. 50The `PLOOPY_DPI_OPTIONS` array sets the values that you want to be able to cycle through, and the order they are in. The "default" define lets the firmware know which of these options is the default and should be loaded by default.
51 51
52The `DPI_CONFIG` macro will cycle through the values in the array, each time you hit it. And it stores this value in persistent memory, so it will load it the next time the device powers up. 52The `DPI_CONFIG` macro will cycle through the values in the array, each time you hit it. And it stores this value in persistent memory, so it will load it the next time the device powers up.
53
54## Drag Scroll
55
56Drag Sroll is a custom keycode for the Ploopy devices that allow you to hold or tap a button and have the mouse movement translate into scrolling instead.
57
58Nothing needs to be enabled to use this functionality. Just add the `DRAG_SCROLL` to your keymap.
59
60### Drag Scroll Configuration
61
62* `#define PLOOPY_DRAGSCROLL_MOMENTARY` - Makes the key into a momentary key, rather than a toggle.
63* `#define PLOOPY_DRAGSCROLL_MULTIPLIER 0.75` - Sets the DPI multiplier to use when drag scroll is enabled.
64* `#define PLOOPY_DRAGSCROLL_FIXED` - Normally, when activating Drag Scroll, it uses a fraction of the current DPI. You can define this to use a specific, set DPI rather than a fraction of the current DPI.
65 * `#define PLOOPY_DRAGSCROLL_DPI 100` - When the fixed DPI option is enabled, this sets the DPI to be used for Drag Scroll.
66* `#define PLOOPY_DRAGSCROLL_INVERT` - This reverses the direction that the scroll is performed.
diff --git a/keyboards/ploopyco/trackball/readme.md b/keyboards/ploopyco/trackball/readme.md
index 7792c0cc5..cb5eaa53d 100644
--- a/keyboards/ploopyco/trackball/readme.md
+++ b/keyboards/ploopyco/trackball/readme.md
@@ -58,3 +58,17 @@ To configure/set your own array, there are two defines to use, `PLOOPY_DPI_OPTIO
58The `PLOOPY_DPI_OPTIONS` array sets the values that you want to be able to cycle through, and the order they are in. The "default" define lets the firmware know which of these options is the default and should be loaded by default. 58The `PLOOPY_DPI_OPTIONS` array sets the values that you want to be able to cycle through, and the order they are in. The "default" define lets the firmware know which of these options is the default and should be loaded by default.
59 59
60The `DPI_CONFIG` macro will cycle through the values in the array, each time you hit it. And it stores this value in persistent memory, so it will load it the next time the device powers up. 60The `DPI_CONFIG` macro will cycle through the values in the array, each time you hit it. And it stores this value in persistent memory, so it will load it the next time the device powers up.
61
62## Drag Scroll
63
64Drag Sroll is a custom keycode for the Ploopy devices that allow you to hold or tap a button and have the mouse movement translate into scrolling instead.
65
66Nothing needs to be enabled to use this functionality. Just add the `DRAG_SCROLL` to your keymap.
67
68### Drag Scroll Configuration
69
70* `#define PLOOPY_DRAGSCROLL_MOMENTARY` - Makes the key into a momentary key, rather than a toggle.
71* `#define PLOOPY_DRAGSCROLL_MULTIPLIER 0.75` - Sets the DPI multiplier to use when drag scroll is enabled.
72* `#define PLOOPY_DRAGSCROLL_FIXED` - Normally, when activating Drag Scroll, it uses a fraction of the current DPI. You can define this to use a specific, set DPI rather than a fraction of the current DPI.
73 * `#define PLOOPY_DRAGSCROLL_DPI 100` - When the fixed DPI option is enabled, this sets the DPI to be used for Drag Scroll.
74* `#define PLOOPY_DRAGSCROLL_INVERT` - This reverses the direction that the scroll is performed.
diff --git a/keyboards/ploopyco/trackball/trackball.c b/keyboards/ploopyco/trackball/trackball.c
index b9c29b54e..719020997 100644
--- a/keyboards/ploopyco/trackball/trackball.c
+++ b/keyboards/ploopyco/trackball/trackball.c
@@ -246,7 +246,6 @@ void pointing_device_init(void) {
246 opt_encoder_init(); 246 opt_encoder_init();
247} 247}
248 248
249bool has_report_changed(report_mouse_t new, report_mouse_t old) { return (new.buttons != old.buttons) || (new.x && new.x != old.x) || (new.y && new.y != old.y) || (new.h && new.h != old.h) || (new.v && new.v != old.v); }
250 249
251void pointing_device_task(void) { 250void pointing_device_task(void) {
252 report_mouse_t mouse_report = pointing_device_get_report(); 251 report_mouse_t mouse_report = pointing_device_get_report();
@@ -269,27 +268,10 @@ void pointing_device_task(void) {
269 pointing_device_send(); 268 pointing_device_send();
270} 269}
271 270
272void pointing_device_send(void) {
273 static report_mouse_t old_report = {};
274 report_mouse_t mouseReport = pointing_device_get_report();
275
276 // If you need to do other things, like debugging, this is the place to do it.
277 if (has_report_changed(mouseReport, old_report)) {
278 host_mouse_send(&mouseReport);
279 }
280
281 // send it and 0 it out except for buttons, so those stay until they are explicity over-ridden using update_pointing_device
282 mouseReport.x = 0;
283 mouseReport.y = 0;
284 mouseReport.v = 0;
285 mouseReport.h = 0;
286 pointing_device_set_report(mouseReport);
287 old_report = mouseReport;
288}
289
290void eeconfig_init_kb(void) { 271void eeconfig_init_kb(void) {
291 keyboard_config.dpi_config = PLOOPY_DPI_DEFAULT; 272 keyboard_config.dpi_config = PLOOPY_DPI_DEFAULT;
292 eeconfig_update_kb(keyboard_config.raw); 273 eeconfig_update_kb(keyboard_config.raw);
274 eeconfig_init_user();
293} 275}
294 276
295void matrix_init_kb(void) { 277void matrix_init_kb(void) {
diff --git a/keyboards/ploopyco/trackball_mini/readme.md b/keyboards/ploopyco/trackball_mini/readme.md
index 1858efb6e..3c21a57cf 100644
--- a/keyboards/ploopyco/trackball_mini/readme.md
+++ b/keyboards/ploopyco/trackball_mini/readme.md
@@ -64,6 +64,17 @@ The `PLOOPY_DPI_OPTIONS` array sets the values that you want to be able to cycle
64 64
65The `DPI_CONFIG` macro will cycle through the values in the array, each time you hit it. It stores this value in persistent memory, so it will load it the next time the device powers up. 65The `DPI_CONFIG` macro will cycle through the values in the array, each time you hit it. It stores this value in persistent memory, so it will load it the next time the device powers up.
66 66
67## Drag Scroll
68
69Drag Sroll is a custom keycode for the Ploopy devices that allow you to hold or tap a button and have the mouse movement translate into scrolling instead.
70
71Nothing needs to be enabled to use this functionality. Just add the `DRAG_SCROLL` to your keymap.
72
73### Drag Scroll Configuration
74
75* `#define PLOOPY_DRAGSCROLL_MOMENTARY` - Makes the key into a momentary key, rather than a toggle.
76* `#define PLOOPY_DRAGSCROLL_DPI CPI375` - When the fixed DPI option is enabled, this sets the DPI to be used for Drag Scroll.
77* `#define PLOOPY_DRAGSCROLL_INVERT` - This reverses the direction that the scroll is performed.
67## Fuse settings 78## Fuse settings
68 79
69When flashing the bootloader, use the following fuse settings: 80When flashing the bootloader, use the following fuse settings:
diff --git a/keyboards/ploopyco/trackball_mini/trackball_mini.c b/keyboards/ploopyco/trackball_mini/trackball_mini.c
index 996c00b22..b50850b54 100644
--- a/keyboards/ploopyco/trackball_mini/trackball_mini.c
+++ b/keyboards/ploopyco/trackball_mini/trackball_mini.c
@@ -40,6 +40,13 @@
40#define PLOOPY_DPI_OPTIONS { CPI375, CPI750, CPI1375 } 40#define PLOOPY_DPI_OPTIONS { CPI375, CPI750, CPI1375 }
41#define PLOOPY_DPI_DEFAULT 2 41#define PLOOPY_DPI_DEFAULT 2
42 42
43#ifndef PLOOPY_DRAGSCROLL_DPI
44# define PLOOPY_DRAGSCROLL_DPI CPI375 // Fixed-DPI Drag Scroll
45#endif
46#ifndef PLOOPY_DRAGSCROLL_MULTIPLIER
47# define PLOOPY_DRAGSCROLL_MULTIPLIER 0.75 // Variable-DPI Drag Scroll
48#endif
49
43// Transformation constants for delta-X and delta-Y 50// Transformation constants for delta-X and delta-Y
44const static float ADNS_X_TRANSFORM = -1.0; 51const static float ADNS_X_TRANSFORM = -1.0;
45const static float ADNS_Y_TRANSFORM = 1.0; 52const static float ADNS_Y_TRANSFORM = 1.0;
@@ -61,6 +68,7 @@ uint16_t lastScroll = 0; // Previous confirmed wheel event
61uint16_t lastMidClick = 0; // Stops scrollwheel from being read if it was pressed 68uint16_t lastMidClick = 0; // Stops scrollwheel from being read if it was pressed
62uint8_t OptLowPin = OPT_ENC1; 69uint8_t OptLowPin = OPT_ENC1;
63bool debug_encoder = false; 70bool debug_encoder = false;
71bool is_drag_scroll = false;
64 72
65__attribute__((weak)) void process_wheel_user(report_mouse_t* mouse_report, int16_t h, int16_t v) { 73__attribute__((weak)) void process_wheel_user(report_mouse_t* mouse_report, int16_t h, int16_t v) {
66 mouse_report->h = h; 74 mouse_report->h = h;
@@ -142,6 +150,16 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
142 adns_set_cpi(dpi_array[keyboard_config.dpi_config]); 150 adns_set_cpi(dpi_array[keyboard_config.dpi_config]);
143 } 151 }
144 152
153 if (keycode == DRAG_SCROLL) {
154#ifndef PLOOPY_DRAGSCROLL_MOMENTARY
155 if (record->event.pressed)
156#endif
157 {
158 is_drag_scroll ^= 1;
159 }
160 adns_set_cpi(is_drag_scroll ? PLOOPY_DRAGSCROLL_DPI : dpi_array[keyboard_config.dpi_config]);
161 }
162
145/* If Mousekeys is disabled, then use handle the mouse button 163/* If Mousekeys is disabled, then use handle the mouse button
146 * keycodes. This makes things simpler, and allows usage of 164 * keycodes. This makes things simpler, and allows usage of
147 * the keycodes in a consistent manner. But only do this if 165 * the keycodes in a consistent manner. But only do this if
@@ -214,6 +232,19 @@ void pointing_device_task(void) {
214 report_mouse_t mouse_report = pointing_device_get_report(); 232 report_mouse_t mouse_report = pointing_device_get_report();
215 process_wheel(&mouse_report); 233 process_wheel(&mouse_report);
216 process_mouse(&mouse_report); 234 process_mouse(&mouse_report);
235
236 if (is_drag_scroll) {
237 mouse_report.h = mouse_report.x;
238#ifdef PLOOPY_DRAGSCROLL_INVERT
239 // Invert vertical scroll direction
240 mouse_report.v = -mouse_report.y;
241#else
242 mouse_report.v = mouse_report.y;
243#endif
244 mouse_report.x = 0;
245 mouse_report.y = 0;
246 }
247
217 pointing_device_set_report(mouse_report); 248 pointing_device_set_report(mouse_report);
218 pointing_device_send(); 249 pointing_device_send();
219} 250}
diff --git a/keyboards/ploopyco/trackball_mini/trackball_mini.h b/keyboards/ploopyco/trackball_mini/trackball_mini.h
index da1b51b17..7bcb02a94 100644
--- a/keyboards/ploopyco/trackball_mini/trackball_mini.h
+++ b/keyboards/ploopyco/trackball_mini/trackball_mini.h
@@ -49,6 +49,15 @@ typedef union {
49extern keyboard_config_t keyboard_config; 49extern keyboard_config_t keyboard_config;
50 50
51enum ploopy_keycodes { 51enum ploopy_keycodes {
52#ifdef VIA_ENABLE
53 DPI_CONFIG = USER00,
54#else
52 DPI_CONFIG = SAFE_RANGE, 55 DPI_CONFIG = SAFE_RANGE,
56#endif
57 DRAG_SCROLL,
58#ifdef VIA_ENABLE
59 PLOOPY_SAFE_RANGE = SAFE_RANGE,
60#else
53 PLOOPY_SAFE_RANGE, 61 PLOOPY_SAFE_RANGE,
62#endif
54}; 63};
diff --git a/keyboards/ploopyco/trackball_nano/config.h b/keyboards/ploopyco/trackball_nano/config.h
index 6771506b2..7450f5574 100644
--- a/keyboards/ploopyco/trackball_nano/config.h
+++ b/keyboards/ploopyco/trackball_nano/config.h
@@ -23,7 +23,7 @@
23 23
24/* USB Device descriptor parameter */ 24/* USB Device descriptor parameter */
25#define VENDOR_ID 0x5043 25#define VENDOR_ID 0x5043
26#define PRODUCT_ID 0x1EAB 26#define PRODUCT_ID 0x54A3
27#define DEVICE_VER 0x0001 27#define DEVICE_VER 0x0001
28#define PRODUCT Trackball Nano 28#define PRODUCT Trackball Nano
29 29