From 88a783a8a769e604fa13947ee9c556f0dc1c95ad Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Wed, 18 Nov 2020 14:20:29 -0800 Subject: [PATCH] [Keyboard] PloopyCo update and fixes (#10936) This is based on feedback talking with crop_octagon about the device. Future trackballs will ship with ATMEL DFU for simplicity. This also includes some fixes and optimizations based on code review and tinkering on my own devices. --- keyboards/ploopyco/mouse/mouse.c | 25 +++------------- keyboards/ploopyco/mouse/readme.md | 2 +- keyboards/ploopyco/pmw3360.c | 2 +- keyboards/ploopyco/trackball/readme.md | 23 -------------- keyboards/ploopyco/trackball/rev1/readme.md | 30 +++++++++++++++++++ keyboards/ploopyco/trackball/rev1/rules.mk | 2 ++ .../ploopyco/trackball/rev1_005/readme.md | 3 ++ .../ploopyco/trackball/rev1_005/rules.mk | 2 ++ keyboards/ploopyco/trackball/rules.mk | 3 -- keyboards/ploopyco/trackball/trackball.c | 24 ++------------- 10 files changed, 46 insertions(+), 70 deletions(-) create mode 100644 keyboards/ploopyco/trackball/rev1/readme.md create mode 100644 keyboards/ploopyco/trackball/rev1_005/readme.md diff --git a/keyboards/ploopyco/mouse/mouse.c b/keyboards/ploopyco/mouse/mouse.c index 7e44feaf7..788a0a1f0 100644 --- a/keyboards/ploopyco/mouse/mouse.c +++ b/keyboards/ploopyco/mouse/mouse.c @@ -140,7 +140,7 @@ __attribute__((weak)) void process_mouse(report_mouse_t* mouse_report) { if (debug_mouse) dprintf("Cons] X: %d, Y: %d\n", data.dx, data.dy); // dprintf("Elapsed:%u, X: %f Y: %\n", i, pgm_read_byte(firmware_data+i)); - process_mouse_user(mouse_report, data.dx, -data.dy); + process_mouse_user(mouse_report, data.dx, data.dy); } } @@ -171,31 +171,14 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) { if (IS_MOUSEKEY_BUTTON(keycode)) { report_mouse_t currentReport = pointing_device_get_report(); if (record->event.pressed) { - if (keycode == KC_MS_BTN1) - currentReport.buttons |= MOUSE_BTN1; - else if (keycode == KC_MS_BTN2) - currentReport.buttons |= MOUSE_BTN2; - else if (keycode == KC_MS_BTN3) - currentReport.buttons |= MOUSE_BTN3; - else if (keycode == KC_MS_BTN4) - currentReport.buttons |= MOUSE_BTN4; - else if (keycode == KC_MS_BTN5) - currentReport.buttons |= MOUSE_BTN5; + currentReport.buttons |= 1 << (keycode - KC_MS_BTN1); } else { - if (keycode == KC_MS_BTN1) - currentReport.buttons &= ~MOUSE_BTN1; - else if (keycode == KC_MS_BTN2) - currentReport.buttons &= ~MOUSE_BTN2; - else if (keycode == KC_MS_BTN3) - currentReport.buttons &= ~MOUSE_BTN3; - else if (keycode == KC_MS_BTN4) - currentReport.buttons &= ~MOUSE_BTN4; - else if (keycode == KC_MS_BTN5) - currentReport.buttons &= ~MOUSE_BTN5; + currentReport.buttons &= ~(1 << (keycode - KC_MS_BTN1)); } pointing_device_set_report(currentReport); pointing_device_send(); } + #endif return true; diff --git a/keyboards/ploopyco/mouse/readme.md b/keyboards/ploopyco/mouse/readme.md index fd0f932c6..5532a1998 100644 --- a/keyboards/ploopyco/mouse/readme.md +++ b/keyboards/ploopyco/mouse/readme.md @@ -17,7 +17,7 @@ To jump to the bootloader, hold down "Button 4" (the "forward" button on the lef See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). -# Customzing your PloopyCo Trackball +# Customzing your PloopyCo Mouse While the defaults are designed so that it can be plugged in and used right away, there are a number of things that you may want to change. Such as adding DPI control, or to use the ball to scroll while holding a button. To allow for this sort of control, there is a callback for both the scroll wheel and the mouse censor. diff --git a/keyboards/ploopyco/pmw3360.c b/keyboards/ploopyco/pmw3360.c index 1bd03e8b9..8007fecef 100644 --- a/keyboards/ploopyco/pmw3360.c +++ b/keyboards/ploopyco/pmw3360.c @@ -213,7 +213,7 @@ report_pmw_t pmw_read_burst(void) { data.dx |= (data.mdx << 8); data.dx = data.dx * -1; data.dy |= (data.mdy << 8); - // data.dy = data.dy * -1; + data.dy = data.dy * -1; spi_stop(); diff --git a/keyboards/ploopyco/trackball/readme.md b/keyboards/ploopyco/trackball/readme.md index bd88d5c5a..714f61034 100644 --- a/keyboards/ploopyco/trackball/readme.md +++ b/keyboards/ploopyco/trackball/readme.md @@ -58,26 +58,3 @@ To configure/set your own array, there are two defines to use, `PLOOPY_DPI_OPTIO The `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. The `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. - -# Programming QMK-DFU onto the PloopyCo Trackball - -If you would rather have DFU on this board, you can use the QMK-DFU bootloader on the device. To do so, you want to run: - - make ploopyco/trackball:default:production - -Once you have that, you'll need to [ISP Flash](https://docs.qmk.fm/#/isp_flashing_guide) the chip with the new bootloader hex file created (or the production hex), and set the fuses: - - -| Fuse | Setting | -|----------|------------------| -| Low | `0xDF` | -| High | `0xD8` or `0x98` | -| Extended | `0xCB` | - -Original (Caterina) settings: - -| Fuse | Setting | -|----------|------------------| -| Low | `0xFF` | -| High | `0xD8` | -| Extended | `0xFE` | diff --git a/keyboards/ploopyco/trackball/rev1/readme.md b/keyboards/ploopyco/trackball/rev1/readme.md new file mode 100644 index 000000000..c0b022372 --- /dev/null +++ b/keyboards/ploopyco/trackball/rev1/readme.md @@ -0,0 +1,30 @@ +See the [main readme](../readme.md) for more details. + +This is just the rev 1.001-1.004 trackball + +# Programming QMK-DFU onto the PloopyCo Trackball (Advanced) + +If you would rather have DFU on this board, you can use the QMK-DFU bootloader on the device. To do so, you want to run: + + make ploopyco/trackball:default:production + +Once you have that, you'll need to [ISP Flash](https://docs.qmk.fm/#/isp_flashing_guide) the chip with the new "production" hex file created (or the production hex), and set the fuses: + + +| Fuse | Setting | +|----------|------------------| +| Low | `0xDF` | +| High | `0xD8` or `0x98` | +| Extended | `0xCB` | + +Original (Caterina) settings: + +| Fuse | Setting | +|----------|------------------| +| Low | `0xFF` | +| High | `0xD8` | +| Extended | `0xFE` | + +If you're using QMK DFU, you'll also need to add `BOOTLOADER=qmk-dfu` to your keymap's rules.mk file, to ensure that the reboot/reset works correctly. Otherwise, it will jump right back into the firmware, like nothing happened. + +Additionally, once you've flashed the qmk-dfu bootloader onto your device, you will no longer be able to use the Arduino IDE to flash the board. You'll need to use the command line or QMK Toolbox to flash it. diff --git a/keyboards/ploopyco/trackball/rev1/rules.mk b/keyboards/ploopyco/trackball/rev1/rules.mk index e69de29bb..6ded83e74 100644 --- a/keyboards/ploopyco/trackball/rev1/rules.mk +++ b/keyboards/ploopyco/trackball/rev1/rules.mk @@ -0,0 +1,2 @@ +# Bootloader selection +BOOTLOADER = caterina diff --git a/keyboards/ploopyco/trackball/rev1_005/readme.md b/keyboards/ploopyco/trackball/rev1_005/readme.md new file mode 100644 index 000000000..a923d1659 --- /dev/null +++ b/keyboards/ploopyco/trackball/rev1_005/readme.md @@ -0,0 +1,3 @@ +See the [main readme](../readme.md) for more details. + +This is just the rev 1.005+ trackball diff --git a/keyboards/ploopyco/trackball/rev1_005/rules.mk b/keyboards/ploopyco/trackball/rev1_005/rules.mk index e69de29bb..bddd4e389 100644 --- a/keyboards/ploopyco/trackball/rev1_005/rules.mk +++ b/keyboards/ploopyco/trackball/rev1_005/rules.mk @@ -0,0 +1,2 @@ +# Bootloader selection +BOOTLOADER = atmel-dfu diff --git a/keyboards/ploopyco/trackball/rules.mk b/keyboards/ploopyco/trackball/rules.mk index 9e252fbdd..4ec870e65 100644 --- a/keyboards/ploopyco/trackball/rules.mk +++ b/keyboards/ploopyco/trackball/rules.mk @@ -4,9 +4,6 @@ MCU = atmega32u4 # Processor frequency F_CPU = 8000000 -# Bootloader selection -BOOTLOADER = caterina - # Build Options # change yes to no to disable # diff --git a/keyboards/ploopyco/trackball/trackball.c b/keyboards/ploopyco/trackball/trackball.c index 7b7b68027..94f284346 100644 --- a/keyboards/ploopyco/trackball/trackball.c +++ b/keyboards/ploopyco/trackball/trackball.c @@ -140,7 +140,7 @@ __attribute__((weak)) void process_mouse(report_mouse_t* mouse_report) { if (debug_mouse) dprintf("Cons] X: %d, Y: %d\n", data.dx, data.dy); // dprintf("Elapsed:%u, X: %f Y: %\n", i, pgm_read_byte(firmware_data+i)); - process_mouse_user(mouse_report, data.dx, data.dy); + process_mouse_user(mouse_report, data.dx, -data.dy); } } @@ -172,27 +172,9 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) { if (IS_MOUSEKEY_BUTTON(keycode)) { report_mouse_t currentReport = pointing_device_get_report(); if (record->event.pressed) { - if (keycode == KC_MS_BTN1) - currentReport.buttons |= MOUSE_BTN1; - else if (keycode == KC_MS_BTN2) - currentReport.buttons |= MOUSE_BTN2; - else if (keycode == KC_MS_BTN3) - currentReport.buttons |= MOUSE_BTN3; - else if (keycode == KC_MS_BTN4) - currentReport.buttons |= MOUSE_BTN4; - else if (keycode == KC_MS_BTN5) - currentReport.buttons |= MOUSE_BTN5; + currentReport.buttons |= 1 << (keycode - KC_MS_BTN1); } else { - if (keycode == KC_MS_BTN1) - currentReport.buttons &= ~MOUSE_BTN1; - else if (keycode == KC_MS_BTN2) - currentReport.buttons &= ~MOUSE_BTN2; - else if (keycode == KC_MS_BTN3) - currentReport.buttons &= ~MOUSE_BTN3; - else if (keycode == KC_MS_BTN4) - currentReport.buttons &= ~MOUSE_BTN4; - else if (keycode == KC_MS_BTN5) - currentReport.buttons &= ~MOUSE_BTN5; + currentReport.buttons &= ~(1 << (keycode - KC_MS_BTN1)); } pointing_device_set_report(currentReport); pointing_device_send();