summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keyboards/ploopyco/mouse/config.h73
-rw-r--r--keyboards/ploopyco/mouse/info.json21
-rw-r--r--keyboards/ploopyco/mouse/keymaps/default/keymap.c23
-rw-r--r--keyboards/ploopyco/mouse/keymaps/default/readme.md1
-rw-r--r--keyboards/ploopyco/mouse/keymaps/via/keymap.c26
-rw-r--r--keyboards/ploopyco/mouse/keymaps/via/rules.mk1
-rw-r--r--keyboards/ploopyco/mouse/mouse.c237
-rw-r--r--keyboards/ploopyco/mouse/mouse.h40
-rw-r--r--keyboards/ploopyco/mouse/readme.md68
-rw-r--r--keyboards/ploopyco/mouse/rules.mk30
-rw-r--r--keyboards/ploopyco/opt_encoder.c211
-rw-r--r--keyboards/ploopyco/opt_encoder.h66
-rw-r--r--keyboards/ploopyco/pmw3600.c222
-rw-r--r--keyboards/ploopyco/pmw3600.h103
-rw-r--r--keyboards/ploopyco/pmw3600_firmware.h300
-rw-r--r--keyboards/ploopyco/trackball/config.h69
-rw-r--r--keyboards/ploopyco/trackball/info.json18
-rw-r--r--keyboards/ploopyco/trackball/keymaps/default/keymap.c26
-rw-r--r--keyboards/ploopyco/trackball/keymaps/default/readme.md1
-rw-r--r--keyboards/ploopyco/trackball/keymaps/via/keymap.c26
-rw-r--r--keyboards/ploopyco/trackball/keymaps/via/rules.mk1
-rw-r--r--keyboards/ploopyco/trackball/readme.md68
-rw-r--r--keyboards/ploopyco/trackball/rules.mk30
-rw-r--r--keyboards/ploopyco/trackball/trackball.c237
-rw-r--r--keyboards/ploopyco/trackball/trackball.h40
25 files changed, 1938 insertions, 0 deletions
diff --git a/keyboards/ploopyco/mouse/config.h b/keyboards/ploopyco/mouse/config.h
new file mode 100644
index 0000000000..787eb9a85e
--- /dev/null
+++ b/keyboards/ploopyco/mouse/config.h
@@ -0,0 +1,73 @@
+/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ * Copyright 2019 Sunjun Kim
+ * Copyright 2020 Ploopy Corporation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include "config_common.h"
+
+/* USB Device descriptor parameter */
+#define VENDOR_ID 0x5043
+#define PRODUCT_ID 0x4D6F
+#define DEVICE_VER 0x0001
+#define MANUFACTURER Ploopyco
+#define PRODUCT Mouse
+
+/* key matrix size */
+#define MATRIX_ROWS 1
+#define MATRIX_COLS 8
+
+/*
+ * Keyboard Matrix Assignments
+ *
+ * Change this to how you wired your keyboard
+ * COLS: AVR pins used for columns, left to right
+ * ROWS: AVR pins used for rows, top to bottom
+ * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode)
+ * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
+ *
+ */
+#define DIRECT_PINS \
+ { \
+ { D4, D2, E6, B6, D7, C6, C7, B7 } \
+ }
+
+// These pins are not broken out, and cannot be used normally.
+// They are set as output and pulled high, by default
+#define UNUSED_PINS \
+ { B4, D6, F1, F5, F6, F7 }
+
+/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
+#define DEBOUNCE 5
+
+/* Much more so than a keyboard, speed matters for a mouse. So we'll go for as high
+ a polling rate as possible. */
+#define USB_POLLING_INTERVAL_MS 1
+
+/* define if matrix has ghost (lacks anti-ghosting diodes) */
+//#define MATRIX_HAS_GHOST
+
+/* disable action features */
+//#define NO_ACTION_LAYER
+//#define NO_ACTION_TAPPING
+//#define NO_ACTION_ONESHOT
+#define NO_ACTION_MACRO
+#define NO_ACTION_FUNCTION
+
+/* Bootmagic Lite key configuration */
+#define BOOTMAGIC_LITE_ROW 0
+#define BOOTMAGIC_LITE_COLUMN 3
diff --git a/keyboards/ploopyco/mouse/info.json b/keyboards/ploopyco/mouse/info.json
new file mode 100644
index 0000000000..6763838dcf
--- /dev/null
+++ b/keyboards/ploopyco/mouse/info.json
@@ -0,0 +1,21 @@
+{
+ "keyboard_name": "PloopyCo Mouse",
+ "url": "",
+ "maintainer": "drashna",
+ "width": 8,
+ "height": 3,
+ "layouts": {
+ "LAYOUT": {
+ "layout": [
+ {"x":1, "y":0, "h":2},
+ {"x":2, "y":0, "h":2},
+ {"x":3, "y":0.25, "h":1.25},
+ {"x":4, "y":0, "h":2},
+ {"x":5, "y":0, "h":2},
+ {"x":0, "y":0},
+ {"x":0, "y":1},
+ {"x":3, "y":1.5}
+ ]
+ }
+ }
+}
diff --git a/keyboards/ploopyco/mouse/keymaps/default/keymap.c b/keyboards/ploopyco/mouse/keymaps/default/keymap.c
new file mode 100644
index 0000000000..c02d23d2ab
--- /dev/null
+++ b/keyboards/ploopyco/mouse/keymaps/default/keymap.c
@@ -0,0 +1,23 @@
+/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ * Copyright 2019 Sunjun Kim
+ * Copyright 2020 Ploopy Corporation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include QMK_KEYBOARD_H
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ [0] = LAYOUT(/* Base */
+ C(KC_C), KC_BTN1, KC_BTN3, KC_BTN2, C(KC_C), KC_BTN4, KC_BTN5, C(KC_Z)),
+};
diff --git a/keyboards/ploopyco/mouse/keymaps/default/readme.md b/keyboards/ploopyco/mouse/keymaps/default/readme.md
new file mode 100644
index 0000000000..f965ef3c32
--- /dev/null
+++ b/keyboards/ploopyco/mouse/keymaps/default/readme.md
@@ -0,0 +1 @@
+# The default keymap for Ploopyco Trackball
diff --git a/keyboards/ploopyco/mouse/keymaps/via/keymap.c b/keyboards/ploopyco/mouse/keymaps/via/keymap.c
new file mode 100644
index 0000000000..27a0384381
--- /dev/null
+++ b/keyboards/ploopyco/mouse/keymaps/via/keymap.c
@@ -0,0 +1,26 @@
+/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ * Copyright 2019 Sunjun Kim
+ * Copyright 2020 Ploopy Corporation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include QMK_KEYBOARD_H
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ [0] = LAYOUT(/* Base */
+ C(KC_C), KC_BTN1, KC_BTN3, KC_BTN2, C(KC_C), KC_BTN4, KC_BTN5, C(KC_Z)),
+ [1] = LAYOUT(_______, _______, _______, _______, _______, _______, _______, _______),
+ [2] = LAYOUT(_______, _______, _______, _______, _______, _______, _______, _______),
+ [3] = LAYOUT(_______, _______, _______, _______, _______, _______, _______, _______),
+};
diff --git a/keyboards/ploopyco/mouse/keymaps/via/rules.mk b/keyboards/ploopyco/mouse/keymaps/via/rules.mk
new file mode 100644
index 0000000000..1e5b99807c
--- /dev/null
+++ b/keyboards/ploopyco/mouse/keymaps/via/rules.mk
@@ -0,0 +1 @@
+VIA_ENABLE = yes
diff --git a/keyboards/ploopyco/mouse/mouse.c b/keyboards/ploopyco/mouse/mouse.c
new file mode 100644
index 0000000000..6a9bffbffe
--- /dev/null
+++ b/keyboards/ploopyco/mouse/mouse.c
@@ -0,0 +1,237 @@
+/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ * Copyright 2019 Sunjun Kim
+ * Copyright 2020 Ploopy Corporation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include QMK_KEYBOARD_H
+
+#ifndef OPT_DEBOUNCE
+# define OPT_DEBOUNCE 5 // (ms) Time between scroll events
+#endif
+#ifndef SCROLL_BUTT_DEBOUNCE
+# define SCROLL_BUTT_DEBOUNCE 100 // (ms) Time between scroll events
+#endif
+#ifndef OPT_THRES
+# define OPT_THRES 150 // (0-1024) Threshold for actication
+#endif
+#ifndef OPT_SCALE
+# define OPT_SCALE 1 // Multiplier for wheel
+#endif
+
+// TODO: Implement libinput profiles
+// https://wayland.freedesktop.org/libinput/doc/latest/pointer-acceleration.html
+// Compile time accel selection
+// Valid options are ACC_NONE, ACC_LINEAR, ACC_CUSTOM, ACC_QUADRATIC
+
+// Trackball State
+bool is_scroll_clicked = false;
+bool BurstState = false; // init burst state for Trackball module
+uint16_t MotionStart = 0; // Timer for accel, 0 is resting state
+uint16_t lastScroll = 0; // Previous confirmed wheel event
+uint16_t lastMidClick = 0; // Stops scrollwheel from being read if it was pressed
+uint8_t OptLowPin = OPT_ENC1;
+bool debug_encoder = false;
+
+__attribute__((weak)) void process_wheel_user(report_mouse_t* mouse_report, int16_t h, int16_t v) {
+ mouse_report->h = h;
+ mouse_report->v = v;
+}
+
+__attribute__((weak)) void process_wheel(report_mouse_t* mouse_report) {
+ // TODO: Replace this with interrupt driven code, polling is S L O W
+ // Lovingly ripped from the Ploopy Source
+
+ // If the mouse wheel was just released, do not scroll.
+ if (timer_elapsed(lastMidClick) < SCROLL_BUTT_DEBOUNCE) {
+ return;
+ }
+
+ // Limit the number of scrolls per unit time.
+ if (timer_elapsed(lastScroll) < OPT_DEBOUNCE) {
+ return;
+ }
+
+ // Don't scroll if the middle button is depressed.
+ if (is_scroll_clicked) {
+#ifndef IGNORE_SCROLL_CLICK
+ return;
+#endif
+ }
+
+ lastScroll = timer_read();
+ uint16_t p1 = adc_read(OPT_ENC1_MUX);
+ uint16_t p2 = adc_read(OPT_ENC2_MUX);
+ if (debug_encoder) dprintf("OPT1: %d, OPT2: %d\n", p1, p2);
+
+ uint8_t dir = opt_encoder_handler(p1, p2);
+
+ if (dir == 0) return;
+ process_wheel_user(mouse_report, mouse_report->h, (int)(mouse_report->v + (dir * OPT_SCALE)));
+}
+
+__attribute__((weak)) void process_mouse_user(report_mouse_t* mouse_report, int16_t x, int16_t y) {
+ mouse_report->x = x;
+ mouse_report->y = y;
+}
+
+__attribute__((weak)) void process_mouse(report_mouse_t* mouse_report) {
+ report_pmw_t data = pmw_read_burst();
+ if (data.isOnSurface && data.isMotion) {
+ // Reset timer if stopped moving
+ if (!data.isMotion) {
+ if (MotionStart != 0) MotionStart = 0;
+ return;
+ }
+
+ // Set timer if new motion
+ if ((MotionStart == 0) && data.isMotion) {
+ if (debug_mouse) dprintf("Starting motion.\n");
+ MotionStart = timer_read();
+ }
+
+ if (debug_mouse) {
+ dprintf("Delt] d: %d t: %u\n", abs(data.dx) + abs(data.dy), MotionStart);
+ }
+ if (debug_mouse) {
+ dprintf("Pre ] X: %d, Y: %d\n", data.dx, data.dy);
+ }
+#if defined(PROFILE_LINEAR)
+ float scale = float(timer_elaspsed(MotionStart)) / 1000.0;
+ data.dx *= scale;
+ data.dy *= scale;
+#elif defined(PROFILE_INVERSE)
+ // TODO
+#else
+ // no post processing
+#endif
+ // apply multiplier
+ // data.dx *= mouse_multiplier;
+ // data.dy *= mouse_multiplier;
+
+ // Wrap to HID size
+ data.dx = constrain(data.dx, -127, 127);
+ data.dy = constrain(data.dy, -127, 127);
+ 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);
+ }
+}
+
+bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
+ if (debug_mouse) {
+ dprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed);
+ }
+
+ // Update Timer to prevent accidental scrolls
+ if ((record->event.key.col == 2) && (record->event.key.row == 0)) {
+ lastMidClick = timer_read();
+ is_scroll_clicked = record->event.pressed;
+ }
+
+/* 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
+ * Mousekeys is not enable, so it's not handled twice.
+ */
+#ifndef MOUSEKEY_ENABLE
+ 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;
+ } 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;
+ }
+ pointing_device_set_report(currentReport);
+ }
+#endif
+
+ return process_record_user(keycode, record);
+}
+
+// Hardware Setup
+void keyboard_pre_init_kb(void) {
+ // debug_enable = true;
+ // debug_matrix = true;
+ // debug_mouse = true;
+ // debug_encoder = true;
+
+ 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.
+ */
+#ifdef UNUSED_PINS
+ const pin_t unused_pins[] = UNUSED_PINS;
+
+ for (uint8_t i = 0; i < (sizeof(unused_pins) / sizeof(pin_t)); i++) {
+ setPinOutput(unused_pins[i]);
+ writePinLow(unused_pins[i]);
+ }
+#endif
+ keyboard_pre_init_user();
+}
+
+void pointing_device_init(void) {
+ // initialize ball sensor
+ pmw_spi_init();
+ // initialize the scroll wheel's optical encoder
+ opt_encoder_init();
+}
+
+bool has_report_changed (report_mouse_t first, report_mouse_t second) {
+ return !(
+ (!first.buttons && first.buttons == second.buttons) &&
+ (!first.x && first.x == second.x) &&
+ (!first.y && first.y == second.y) &&
+ (!first.h && first.h == second.h) &&
+ (!first.v && first.v == second.v) );
+}
+
+void pointing_device_task(void) {
+ report_mouse_t mouse_report = pointing_device_get_report();
+ process_wheel(&mouse_report);
+ process_mouse(&mouse_report);
+
+ pointing_device_set_report(mouse_report);
+ if (has_report_changed(mouse_report, pointing_device_get_report())) {
+ pointing_device_send();
+ }
+}
diff --git a/keyboards/ploopyco/mouse/mouse.h b/keyboards/ploopyco/mouse/mouse.h
new file mode 100644
index 0000000000..3c89d64d8c
--- /dev/null
+++ b/keyboards/ploopyco/mouse/mouse.h
@@ -0,0 +1,40 @@
+/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ * Copyright 2019 Sunjun Kim
+ * Copyright 2020 Ploopy Corporation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include "quantum.h"
+#include "spi_master.h"
+#include "pmw3600.h"
+#include "analog.h"
+#include "opt_encoder.h"
+#include "pointing_device.h"
+
+// Sensor defs
+#define OPT_ENC1 F0
+#define OPT_ENC2 F4
+#define OPT_ENC1_MUX 0
+#define OPT_ENC2_MUX 4
+
+void process_mouse(report_mouse_t* mouse_report);
+void process_mouse_user(report_mouse_t* mouse_report, int16_t x, int16_t y);
+void process_wheel(report_mouse_t* mouse_report);
+void process_wheel_user(report_mouse_t* mouse_report, int16_t h, int16_t v);
+
+#define LAYOUT(BLL, BL, BM, BR, BRR, BF, BB, BDPI) \
+ { {BL, BM, BR, BF, BB, BRR, BLL, BDPI}, }
diff --git a/keyboards/ploopyco/mouse/readme.md b/keyboards/ploopyco/mouse/readme.md
new file mode 100644
index 0000000000..abfa643a44
--- /dev/null
+++ b/keyboards/ploopyco/mouse/readme.md
@@ -0,0 +1,68 @@
+# Ploopyco Mouse
+
+![Ploopyco Mouse](https://i.redd.it/bf7bkzqzeti51.jpg)
+
+It's a DIY, QMK Powered Trackball!!!!
+
+Everything works. However the scroll wheel has some issues and acts very odd.
+
+* Keyboard Maintainer: [PloopyCo](https://github.com/ploopyco), [Drashna Jael're](https://github.com/drashna/), [Germ](https://github.com/germ/)
+* Hardware Supported: ATMega32u4 8MHz(3.3v)
+* Hardware Availability: [Store](https://ploopy.co), [GitHub](https://github.com/ploopyco)
+
+Make example for this keyboard (after setting up your build environment):
+
+ make ploopyco/mouse:default:flash
+
+To jump to the bootloader, hold down "Button 4" (immediate right of the Mouse)
+
+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
+
+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.
+
+The default behavior for this is:
+
+```c
+void process_wheel_user(report_mouse_t* mouse_report, int16_t h, int16_t v) {
+ mouse_report->h = h;
+ mouse_report->v = v;
+}
+
+void process_mouse_user(report_mouse_t* mouse_report, int16_t x, int16_t y) {
+ mouse_report->x = x;
+ mouse_report->y = y;
+}
+```
+
+This should allow you to more heavily customize the behavior.
+
+Alternatively, the `process_wheel` and `process_mouse` functions can both be replaced too, to allow for even more functionality.
+
+Additionally, you can change the DPI/CPI or speed of the Mouse by calling `pmw_set_cpi` at any time. And tThe default can be changed by adding a define to the keymap's `config.h` file:
+
+ #define PMW_CPI 1600
+
+# Programming QMK-DFU onto the PloopyCo Mouse
+
+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/mouse/rules.mk b/keyboards/ploopyco/mouse/rules.mk
new file mode 100644
index 0000000000..d77431b676
--- /dev/null
+++ b/keyboards/ploopyco/mouse/rules.mk
@@ -0,0 +1,30 @@
+# MCU name
+MCU = atmega32u4
+
+# Processor frequency
+F_CPU = 8000000
+
+# Bootloader selection
+BOOTLOADER = caterina
+
+# Build Options
+# change yes to no to disable
+#
+BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration
+EXTRAKEY_ENABLE = yes # Audio control and System control
+CONSOLE_ENABLE = yes # Console for debug
+COMMAND_ENABLE = no # Commands for debug and configuration
+# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
+SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
+# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
+NKRO_ENABLE = no # USB Nkey Rollover
+BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
+RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
+UNICODE_ENABLE = no # Unicode
+BLUETOOTH_ENABLE = no # Enable Bluetooth
+AUDIO_ENABLE = no # Audio output
+POINTING_DEVICE_ENABLE = yes
+MOUSEKEY_ENABLE = no # Mouse keys
+
+QUANTUM_LIB_SRC += analog.c spi_master.c
+SRC += pmw3600.c opt_encoder.c
diff --git a/keyboards/ploopyco/opt_encoder.c b/keyboards/ploopyco/opt_encoder.c
new file mode 100644
index 0000000000..44bcd5eb88
--- /dev/null
+++ b/keyboards/ploopyco/opt_encoder.c
@@ -0,0 +1,211 @@
+/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ * Copyright 2020 Ploopy Corporation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include "opt_encoder.h"
+
+/* Setup function for the scroll wheel. Initializes
+ the relevant variables. */
+void opt_encoder_init(void) {
+ state = HIHI;
+ lohif = false;
+ hilof = false;
+ lowA = 1023;
+ highA = 0;
+ cLowA = false;
+ cHighA = false;
+ lowIndexA = 0;
+ highIndexA = 0;
+ lowOverflowA = false;
+ highOverflowA = false;
+ lowB = 1023;
+ highB = 0;
+ cLowB = false;
+ cHighB = false;
+ lowIndexB = 0;
+ highIndexB = 0;
+ lowOverflowB = false;
+ highOverflowB = false;
+ scrollThresholdA = 0;
+ scrollThresholdB = 0;
+}
+
+int opt_encoder_handler(int curA, int curB) {
+ if (lowOverflowA == false || highOverflowA == false) calculateThresholdA(curA);
+ if (lowOverflowB == false || highOverflowB == false) calculateThresholdB(curB);
+
+ bool LO = false;
+ bool HI = true;
+ bool sA, sB;
+ int ret = 0;
+
+ if (curA < scrollThresholdA)
+ sA = LO;
+ else
+ sA = HI;
+
+ if (curB < scrollThresholdB)
+ sB = LO;
+ else
+ sB = HI;
+
+ if (state == HIHI) {
+ if (sA == LO && sB == HI) {
+ state = LOHI;
+ if (hilof) {
+ ret = 1;
+ hilof = false;
+ }
+ } else if (sA == HI && sB == LO) {
+ state = HILO;
+ if (lohif) {
+ ret = -1;
+ lohif = false;
+ }
+ }
+ }
+
+ else if (state == HILO) {
+ if (sA == HI && sB == HI) {
+ state = HIHI;
+ hilof = true;
+ lohif = false;
+ } else if (sA == LO && sB == LO) {
+ state = LOLO;
+ hilof = true;
+ lohif = false;
+ }
+ }
+
+ else if (state == LOLO) {
+ if (sA == HI && sB == LO) {
+ state = HILO;
+ if (lohif) {
+ ret = 1;
+ lohif = false;
+ }
+ } else if (sA == LO && sB == HI) {
+ state = LOHI;
+ if (hilof) {
+ ret = -1;
+ hilof = false;
+ }
+ }
+ }
+
+ else { // state must be LOHI
+ if (sA == HI && sB == HI) {
+ state = HIHI;
+ lohif = true;
+ hilof = false;
+ } else if (sA == LO && sB == LO) {
+ state = LOLO;
+ lohif = true;
+ hilof = false;
+ }
+ }
+
+ return ret;
+}
+
+void calculateThresholdA(int curA) { scrollThresholdA = calculateThreshold(curA, &lowA, &highA, &cLowA, &cHighA, arLowA, arHighA, &lowIndexA, &highIndexA, &lowOverflowA, &highOverflowA); }
+
+void calculateThresholdB(int curB) { scrollThresholdB = calculateThreshold(curB, &lowB, &highB, &cLowB, &cHighB, arLowB, arHighB, &lowIndexB, &highIndexB, &lowOverflowB, &highOverflowB); }
+
+int calculateThreshold(int cur, int* low, int* high, bool* cLow, bool* cHigh, int arLow[], int arHigh[], int* lowIndex, int* highIndex, bool* lowOverflow, bool* highOverflow) {
+ if (cur < *low) *low = cur;
+ if (cur > *high) *high = cur;
+
+ int curThresh = thresholdEquation(*low, *high);
+ int range = *high - *low;
+
+ // The range is enforced to be over a certain limit because noise
+ // can cause erroneous readings, making these calculations unstable.
+ if (range >= SCROLL_THRESH_RANGE_LIM) {
+ if (cur < curThresh) {
+ if (*cHigh == true) {
+ // We were just high, and now we crossed to low.
+ // high reflects a sample of a high reading.
+ arHigh[*highIndex] = *high;
+ incrementIndex(highIndex, highOverflow);
+ int midpoint = ((*high - *low) / 2) + *low;
+ *low = midpoint;
+ *high = midpoint;
+ *cLow = false;
+ *cHigh = false;
+ } else {
+ *cLow = true;
+ }
+ }
+ if (cur > curThresh) {
+ if (*cLow == true) {
+ // We were just low, and now we crossed to high.
+ // low reflects a sample of a low reading.
+ arLow[*lowIndex] = *low;
+ incrementIndex(lowIndex, lowOverflow);
+ int midpoint = ((*high - *low) / 2) + *low;
+ *low = midpoint;
+ *high = midpoint;
+ *cLow = false;
+ *cHigh = false;
+ } else {
+ *cHigh = true;
+ }
+ }
+ }
+
+ int calcHigh = 0;
+ if (*highOverflow == true) {
+ for (int i = 0; i < SCROLLER_AR_SIZE; i++) {
+ calcHigh += arHigh[i];
+ }
+ calcHigh = calcHigh / SCROLLER_AR_SIZE;
+ } else if (*highIndex != 0) {
+ for (int i = 0; i < *highIndex; i++) {
+ calcHigh += arHigh[i];
+ }
+ calcHigh = calcHigh / *highIndex;
+ } else {
+ calcHigh = *high;
+ }
+
+ int calcLow = 0;
+ if (*lowOverflow == true) {
+ for (int i = 0; i < SCROLLER_AR_SIZE; i++) {
+ calcLow += arLow[i];
+ }
+ calcLow = calcLow / SCROLLER_AR_SIZE;
+ } else if (*lowIndex != 0) {
+ for (int i = 0; i < *lowIndex; i++) {
+ calcLow += arLow[i];
+ }
+ calcLow = calcLow / *lowIndex;
+ } else {
+ calcLow = *low;
+ }
+
+ return thresholdEquation(calcLow, calcHigh);
+}
+
+int thresholdEquation(int lo, int hi) { return ((hi - lo) / 3) + lo; }
+
+void incrementIndex(int* index, bool* ovflw) {
+ if (*index < SCROLLER_AR_SIZE - 1)
+ (*index)++;
+ else {
+ *index = 0;
+ *ovflw = true;
+ }
+}
diff --git a/keyboards/ploopyco/opt_encoder.h b/keyboards/ploopyco/opt_encoder.h
new file mode 100644
index 0000000000..23a170d59f
--- /dev/null
+++ b/keyboards/ploopyco/opt_encoder.h
@@ -0,0 +1,66 @@
+/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ * Copyright 2020 Ploopy Corporation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#include <stdbool.h>
+
+#ifndef SCROLLER_AR_SIZE
+# define SCROLLER_AR_SIZE 31
+#endif
+
+#ifndef SCROLL_THRESH_RANGE_LIM
+# define SCROLL_THRESH_RANGE_LIM 10
+#endif
+
+enum State { HIHI, HILO, LOLO, LOHI };
+
+enum State state;
+
+/* Variables used for scroll wheel functionality. */
+bool lohif;
+bool hilof;
+int lowA;
+int highA;
+bool cLowA;
+bool cHighA;
+int lowIndexA;
+int highIndexA;
+bool lowOverflowA;
+bool highOverflowA;
+int lowB;
+int highB;
+bool cLowB;
+bool cHighB;
+int lowIndexB;
+int highIndexB;
+bool lowOverflowB;
+bool highOverflowB;
+int scrollThresholdA;
+int scrollThresholdB;
+int arLowA[SCROLLER_AR_SIZE];
+int arHighA[SCROLLER_AR_SIZE];
+int arLowB[SCROLLER_AR_SIZE];
+int arHighB[SCROLLER_AR_SIZE];
+
+void calculateThresholdA(int curA);
+void calculateThresholdB(int curB);
+int calculateThreshold(int cur, int* low, int* high, bool* cLow, bool* cHigh, int arLow[], int arHigh[], int* lowIndex, int* highIndex, bool* lowOverflow, bool* highOverflow);
+int thresholdEquation(int lo, int hi);
+void incrementIndex(int* index, bool* ovflw);
+
+void opt_encoder_init(void);
+int opt_encoder_handler(int curA, int curB);
diff --git a/keyboards/ploopyco/pmw3600.c b/keyboards/ploopyco/pmw3600.c
new file mode 100644
index 0000000000..93b47078ac
--- /dev/null
+++ b/keyboards/ploopyco/pmw3600.c
@@ -0,0 +1,222 @@
+/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ * Copyright 2019 Sunjun Kim
+ * Copyright 2020 Ploopy Corporation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "pmw3600.h"
+#include "pmw3600_firmware.h"
+#ifdef CONSOLE_ENABLE
+# include "print.h"
+#endif
+bool _inBurst = false;
+
+#ifndef PMW_CPI
+# define PMW_CPI 1600
+#endif
+#ifndef SPI_DIVISOR
+# define SPI_DIVISOR 2
+#endif
+
+static const int8_t ROTATIONAL_TRANSFORM_ANGLE = 20;
+
+#ifdef CONSOLE_ENABLE
+void print_byte(uint8_t byte) { dprintf("%c%c%c%c%c%c%c%c|", (byte & 0x80 ? '1' : '0'), (byte & 0x40 ? '1' : '0'), (byte & 0x20 ? '1' : '0'), (byte & 0x10 ? '1' : '0'), (byte & 0x08 ? '1' : '0'), (byte & 0x04 ? '1' : '0'), (byte & 0x02 ? '1' : '0'), (byte & 0x01 ? '1' : '0')); }
+#endif
+
+
+bool spi_start_adv(void) {
+ bool status = spi_start(SPI_SS_PIN, false, 3, SPI_DIVISOR);
+ wait_us(1);
+ return status;
+}
+
+void spi_stop_adv(void) {
+ wait_us(1);
+ spi_stop();
+}
+
+spi_status_t spi_write_adv(uint8_t reg_addr, uint8_t data) {
+ if (reg_addr != REG_Motion_Burst) {
+ _inBurst = false;
+ }
+
+ spi_start_adv();
+ // send address of the register, with MSBit = 1 to indicate it's a write
+ spi_status_t status = spi_write(reg_addr | 0x80);
+ status = spi_write(data);
+
+ // tSCLK-NCS for write operation
+ wait_us(20);
+
+ // tSWW/tSWR (=120us) minus tSCLK-NCS. Could be shortened, but is looks like a safe lower bound
+ wait_us(100);
+ spi_stop();
+ return status;
+}
+
+uint8_t spi_read_adv(uint8_t reg_addr) {
+ spi_start_adv();
+ // send adress of the register, with MSBit = 0 to indicate it's a read
+ spi_write(reg_addr & 0x7f);
+
+ uint8_t data = spi_read();
+
+ // tSCLK-NCS for read operation is 120ns
+ wait_us(1);
+
+ // tSRW/tSRR (=20us) minus tSCLK-NCS
+ wait_us(19);
+
+ spi_stop();
+ return data;
+}
+
+void pmw_set_cpi(uint16_t cpi) {
+ int cpival = constrain((cpi / 100) - 1, 0, 0x77); // limits to 0--119
+
+ spi_start_adv();
+ spi_write_adv(REG_Config1, cpival);
+ spi_stop();
+}
+
+bool pmw_spi_init(void) {
+ spi_init();
+ _inBurst = false;
+
+ spi_stop();
+ spi_start_adv();
+ spi_stop();
+
+ spi_write_adv(REG_Shutdown, 0xb6); // Shutdown first
+ wait_ms(300);
+
+ spi_start_adv();
+ wait_us(40);
+ spi_stop_adv();
+ wait_us(40);
+
+ spi_write_adv(REG_Power_Up_Reset, 0x5a);
+ wait_ms(50);
+
+ spi_read_adv(REG_Motion);
+ spi_read_adv(REG_Delta_X_L);
+ spi_read_adv(REG_Delta_X_H);
+ spi_read_adv(REG_Delta_Y_L);
+ spi_read_adv(REG_Delta_Y_H);
+
+ pmw_upload_firmware();
+
+ spi_write_adv(REG_Angle_Tune, constrain(ROTATIONAL_TRANSFORM_ANGLE, -30, 30));
+ spi_stop_adv();
+
+ wait_ms(10);
+ pmw_set_cpi(PMW_CPI);
+
+ wait_ms(1);
+
+ return pmw_check_signature();
+}
+
+void pmw_upload_firmware(void) {
+ spi_write_adv(REG_Config2, 0x00);
+
+ spi_write_adv(REG_SROM_Enable, 0x1d);
+
+ wait_ms(10);
+
+ spi_write_adv(REG_SROM_Enable, 0x18);
+
+ spi_start_adv();
+ spi_write(REG_SROM_Load_Burst | 0x80);
+ wait_us(15);
+
+ unsigned char c;
+ for (int i = 0; i < firmware_length; i++) {
+ c = (unsigned char)pgm_read_byte(firmware_data + i);
+ spi_write(c);
+ wait_us(15);
+ }
+ wait_us(200);
+
+ spi_read_adv(REG_SROM_ID);
+
+ spi_write_adv(REG_Config2, 0x00);
+
+ spi_stop();
+ wait_ms(10);
+}
+
+bool pmw_check_signature(void) {
+ uint8_t pid = spi_read_adv(REG_Product_ID);
+ uint8_t iv_pid = spi_read_adv(REG_Inverse_Product_ID);
+ uint8_t SROM_ver = spi_read_adv(REG_SROM_ID);
+ return (pid == 0x42 && iv_pid == 0xBD && SROM_ver == 0x04); // signature for SROM 0x04
+}
+
+report_pmw_t pmw_read_burst(void) {
+ if (!_inBurst) {
+#ifdef CONSOLE_ENABLE
+ dprintf("burst on");
+#endif
+ spi_write_adv(REG_Motion_Burst, 0x00);
+ _inBurst = true;
+ }
+
+ spi_start_adv();
+ spi_write(REG_Motion_Burst);
+ wait_us(35); // waits for tSRAD
+
+ report_pmw_t data;
+ data.motion = 0;
+ data.dx = 0;
+ data.mdx = 0;
+ data.dy = 0;
+ data.mdx = 0;
+
+ data.motion = spi_read();
+ spi_write(0x00); // skip Observation
+ data.dx = spi_read();
+ data.mdx = spi_read();
+ data.dy = spi_read();
+ data.mdy = spi_read();
+
+ spi_stop();
+
+#ifdef CONSOLE_ENABLE
+ print_byte(data.motion);
+ print_byte(data.dx);
+ print_byte(data.mdx);
+ print_byte(data.dy);
+ print_byte(data.mdy);
+ dprintf("\n");
+#endif
+
+ data.isMotion = (data.motion & 0x80) != 0;
+ data.isOnSurface = (data.motion & 0x08) == 0;
+ data.dx |= (data.mdx << 8);
+ data.dx = data.dx * -1;
+ data.dy |= (data.mdy << 8);
+ // data.dy = data.dy * -1;
+
+ spi_stop();
+
+ if (data.motion & 0b111) { // panic recovery, sometimes burst mode works weird.
+ _inBurst = false;
+ }
+
+ return data;
+}
diff --git a/keyboards/ploopyco/pmw3600.h b/keyboards/ploopyco/pmw3600.h
new file mode 100644
index 0000000000..c1d5e3badb
--- /dev/null
+++ b/keyboards/ploopyco/pmw3600.h
@@ -0,0 +1,103 @@
+/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ * Copyright 2019 Sunjun Kim
+ * Copyright 2020 Ploopy Corporation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include "spi_master.h"
+
+// Registers
+#define REG_Product_ID 0x00
+#define REG_Revision_ID 0x01
+#define REG_Motion 0x02
+#define REG_Delta_X_L 0x03
+#define REG_Delta_X_H 0x04
+#define REG_Delta_Y_L 0x05
+#define REG_Delta_Y_H 0x06
+#define REG_SQUAL 0x07
+#define REG_Raw_Data_Sum 0x08
+#define REG_Maximum_Raw_data 0x09
+#define REG_Minimum_Raw_data 0x0A
+#define REG_Shutter_Lower 0x0B
+#define REG_Shutter_Upper 0x0C
+#define REG_Control 0x0D
+#define REG_Config1 0x0F
+#define REG_Config2 0x10
+#define REG_Angle_Tune 0x11
+#define REG_Frame_Capture 0x12
+#define REG_SROM_Enable 0x13
+#define REG_Run_Downshift 0x14
+#define REG_Rest1_Rate_Lower 0x15
+#define REG_Rest1_Rate_Upper 0x16
+#define REG_Rest1_Downshift 0x17
+#define REG_Rest2_Rate_Lower 0x18
+#define REG_Rest2_Rate_Upper 0x19
+#define REG_Rest2_Downshift 0x1A
+#define REG_Rest3_Rate_Lower 0x1B
+#define REG_Rest3_Rate_Upper 0x1C
+#define REG_Observation 0x24
+#define REG_Data_Out_Lower 0x25
+#define REG_Data_Out_Upper 0x26
+#define REG_Raw_Data_Dump 0x29
+#define REG_SROM_ID 0x2A
+#define REG_Min_SQ_Run 0x2B
+#define REG_Raw_Data_Threshold 0x2C
+#define REG_Config5 0x2F
+#define REG_Power_Up_Reset 0x3A
+#define REG_Shutdown 0x3B
+#define REG_Inverse_Product_ID 0x3F
+#define REG_LiftCutoff_Tune3 0x41
+#define REG_Angle_Snap 0x42
+#define REG_LiftCutoff_Tune1 0x4A
+#define REG_Motion_Burst 0x50
+#define REG_LiftCutoff_Tune_Timeout 0x58
+#define REG_LiftCutoff_Tune_Min_Length 0x5A
+#define REG_SROM_Load_Burst 0x62
+#define REG_Lift_Config 0x63
+#define REG_Raw_Data_Burst 0x64
+#define REG_LiftCutoff_Tune2 0x65
+
+#ifdef CONSOLE_ENABLE
+void print_byte(uint8_t byte);
+#endif
+
+typedef struct {
+ int8_t motion;
+ bool isMotion; // True if a motion is detected.
+ bool isOnSurface; // True when a chip is on a surface
+ int16_t dx; // displacement on x directions. Unit: Count. (CPI * Count = Inch value)
+ int8_t mdx;
+ int16_t dy; // displacement on y directions.
+ int8_t mdy;
+} report_pmw_t;
+
+
+
+bool spi_start_adv(void);
+void spi_stop_adv(void);
+spi_status_t spi_write_adv(uint8_t reg_addr, uint8_t data);
+uint8_t spi_read_adv(uint8_t reg_addr);
+bool pmw_spi_init(void);
+void pmw_set_cpi(uint16_t cpi);
+void pmw_upload_firmware(void);
+bool pmw_check_signature(void);
+report_pmw_t pmw_read_burst(void);
+
+
+#define degToRad(angleInDegrees) ((angleInDegrees)*M_PI / 180.0)
+#define radToDeg(angleInRadians) ((angleInRadians)*180.0 / M_PI)
+#define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt)))
diff --git a/keyboards/ploopyco/pmw3600_firmware.h b/keyboards/ploopyco/pmw3600_firmware.h
new file mode 100644
index 0000000000..cca5a6a4d8
--- /dev/null
+++ b/keyboards/ploopyco/pmw3600_firmware.h
@@ -0,0 +1,300 @@
+/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ * Copyright 2019 Sunjun Kim
+ * Copyright 2020 Ploopy Corporation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+// clang-format off
+// Firmware Blob foor PMW3360
+const uint16_t firmware_length = 4094;
+// clang-format off
+const uint8_t firmware_data[] PROGMEM = { // SROM 0x04
+0x01, 0x04, 0x8e, 0x96, 0x6e, 0x77, 0x3e, 0xfe, 0x7e, 0x5f, 0x1d, 0xb8, 0xf2, 0x66, 0x4e,
+0xff, 0x5d, 0x19, 0xb0, 0xc2, 0x04, 0x69, 0x54, 0x2a, 0xd6, 0x2e, 0xbf, 0xdd, 0x19, 0xb0,
+0xc3, 0xe5, 0x29, 0xb1, 0xe0, 0x23, 0xa5, 0xa9, 0xb1, 0xc1, 0x00, 0x82, 0x67, 0x4c, 0x1a,
+0x97, 0x8d, 0x79, 0x51, 0x20, 0xc7, 0x06, 0x8e, 0x7c, 0x7c, 0x7a, 0x76, 0x4f, 0xfd, 0x59,
+0x30, 0xe2, 0x46, 0x0e, 0x9e, 0xbe, 0xdf, 0x1d, 0x99, 0x91, 0xa0, 0xa5, 0xa1, 0xa9, 0xd0,
+0x22, 0xc6, 0xef, 0x5c, 0x1b, 0x95, 0x89, 0x90, 0xa2, 0xa7, 0xcc, 0xfb, 0x55, 0x28, 0xb3,
+0xe4, 0x4a, 0xf7, 0x6c, 0x3b, 0xf4, 0x6a, 0x56, 0x2e, 0xde, 0x1f, 0x9d, 0xb8, 0xd3, 0x05,
+0x88, 0x92, 0xa6, 0xce, 0x1e, 0xbe, 0xdf, 0x1d, 0x99, 0xb0, 0xe2, 0x46, 0xef, 0x5c, 0x07,
+0x11, 0x5d, 0x98, 0x0b, 0x9d, 0x94, 0x97, 0xee, 0x4e, 0x45, 0x33, 0x6b, 0x44, 0xc7, 0x29,
+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0xfa, 0x57, 0x0d,
+0x79, 0x51, 0x01, 0x61, 0x21, 0xa1, 0xc0, 0xe3, 0x25, 0xa9, 0xb1, 0xc1, 0xe1, 0x40, 0x02,
+0x67, 0x4c, 0x1a, 0x97, 0x8d, 0x98, 0x93, 0xa4, 0xab, 0xd4, 0x2a, 0xd6, 0x0f, 0x9c, 0x9b,
+0xb4, 0xcb, 0x14, 0xaa, 0xb7, 0xcd, 0xf9, 0x51, 0x20, 0xa3, 0xc4, 0xeb, 0x35, 0xc9, 0xf1,
+0x60, 0x42, 0x06, 0x8e, 0x7f, 0x7c, 0x7a, 0x76, 0x6e, 0x3f, 0xfc, 0x7a, 0x76, 0x6e, 0x5e,
+0x3e, 0xfe, 0x7e, 0x5f, 0x3c, 0xdb, 0x15, 0x89, 0x71, 0x41, 0xe1, 0x21, 0xc0, 0xe3, 0x44,
+0xeb, 0x54, 0x2a, 0xb7, 0xcd, 0xf9, 0x70, 0x62, 0x27, 0xad, 0xd8, 0x32, 0xc7, 0x0c, 0x7b,
+0x74, 0x4b, 0x14, 0xaa, 0xb7, 0xec, 0x3b, 0xd5, 0x28, 0xd2, 0x07, 0x6d, 0x39, 0xd1, 0x20,
+0xc2, 0xe7, 0x4c, 0x1a, 0x97, 0x8d, 0x98, 0xb2, 0xc7, 0x0c, 0x59, 0x28, 0xf3, 0x9b };
+
+// clang-format off
diff --git a/keyboards/ploopyco/trackball/config.h b/keyboards/ploopyco/trackball/config.h
new file mode 100644
index 0000000000..57113d965b
--- /dev/null
+++ b/keyboards/ploopyco/trackball/config.h
@@ -0,0 +1,69 @@
+/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ * Copyright 2019 Sunjun Kim
+ * Copyright 2020 Ploopy Corporation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include "config_common.h"
+
+/* USB Device descriptor parameter */
+#define VENDOR_ID 0x5043
+#define PRODUCT_ID 0x5442
+#define DEVICE_VER 0x0001
+#define MANUFACTURER Ploopyco
+#define PRODUCT Trackball
+
+/* key matrix size */
+#define MATRIX_ROWS 1
+#define MATRIX_COLS 5
+
+/*
+ * Keyboard Matrix Assignments
+ *
+ * Change this to how you wired your keyboard
+ * COLS: AVR pins used for columns, left to right
+ * ROWS: AVR pins used for rows, top to bottom
+ * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode)
+ * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
+ *
+ */
+#define DIRECT_PINS { { D4, D2, E6, B5, D7 } }
+
+// These pins are not broken out, and cannot be used normally.
+// They are set as output and pulled high, by default
+#define UNUSED_PINS { D1, D3, B4, B6, B7, D6, C7, F6, F5, F3 }
+
+/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
+#define DEBOUNCE 5
+
+/* define if matrix has ghost (lacks anti-ghosting diodes) */
+//#define MATRIX_HAS_GHOST
+
+/* disable action features */
+//#define NO_ACTION_LAYER
+//#define NO_ACTION_TAPPING
+//#define NO_ACTION_ONESHOT
+#define NO_ACTION_MACRO
+#define NO_ACTION_FUNCTION
+
+/* Much more so than a keyboard, speed matters for a mouse. So we'll go for as high
+ a polling rate as possible. */
+#define USB_POLLING_INTERVAL_MS 1
+
+/* Bootmagic Lite key configuration */
+#define BOOTMAGIC_LITE_ROW 0
+#define BOOTMAGIC_LITE_COLUMN 3
diff --git a/keyboards/ploopyco/trackball/info.json b/keyboards/ploopyco/trackball/info.json
new file mode 100644
index 0000000000..84d512d8dd
--- /dev/null
+++ b/keyboards/ploopyco/trackball/info.json
@@ -0,0 +1,18 @@
+{
+ "keyboard_name": "PloopyCo Trackball",
+ "url": "",
+ "maintainer": "drashna",
+ "width": 8,
+ "height": 3,
+ "layouts": {
+ "LAYOUT": {
+ "layout": [
+ {"x":0, "y":0, "h":2},
+ {"x":1, "y":0.25, "h":1.5},
+ {"x":2, "y":0, "h":2},
+ {"x":3.5, "y":0, "h":2},
+ {"x":4.5, "y":0, "h":2}
+ ]
+ }
+ }
+}
diff --git a/keyboards/ploopyco/trackball/keymaps/default/keymap.c b/keyboards/ploopyco/trackball/keymaps/default/keymap.c
new file mode 100644
index 0000000000..dc1ad1439f
--- /dev/null
+++ b/keyboards/ploopyco/trackball/keymaps/default/keymap.c
@@ -0,0 +1,26 @@
+/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ * Copyright 2019 Sunjun Kim
+ * Copyright 2020 Ploopy Corporation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include QMK_KEYBOARD_H
+
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ [0] = LAYOUT( /* Base */
+ KC_BTN1, KC_BTN3, KC_BTN2,
+ KC_BTN4, KC_BTN5
+ ),
+};
diff --git a/keyboards/ploopyco/trackball/keymaps/default/readme.md b/keyboards/ploopyco/trackball/keymaps/default/readme.md
new file mode 100644
index 0000000000..f965ef3c32
--- /dev/null
+++ b/keyboards/ploopyco/trackball/keymaps/default/readme.md
@@ -0,0 +1 @@
+# The default keymap for Ploopyco Trackball
diff --git a/keyboards/ploopyco/trackball/keymaps/via/keymap.c b/keyboards/ploopyco/trackball/keymaps/via/keymap.c
new file mode 100644
index 0000000000..dc1ad1439f
--- /dev/null
+++ b/keyboards/ploopyco/trackball/keymaps/via/keymap.c
@@ -0,0 +1,26 @@
+/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ * Copyright 2019 Sunjun Kim
+ * Copyright 2020 Ploopy Corporation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include QMK_KEYBOARD_H
+
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ [0] = LAYOUT( /* Base */
+ KC_BTN1, KC_BTN3, KC_BTN2,
+ KC_BTN4, KC_BTN5
+ ),
+};
diff --git a/keyboards/ploopyco/trackball/keymaps/via/rules.mk b/keyboards/ploopyco/trackball/keymaps/via/rules.mk
new file mode 100644
index 0000000000..1e5b99807c
--- /dev/null
+++ b/keyboards/ploopyco/trackball/keymaps/via/rules.mk
@@ -0,0 +1 @@
+VIA_ENABLE = yes
diff --git a/keyboards/ploopyco/trackball/readme.md b/keyboards/ploopyco/trackball/readme.md
new file mode 100644
index 0000000000..76b9d6a762
--- /dev/null
+++ b/keyboards/ploopyco/trackball/readme.md
@@ -0,0 +1,68 @@
+# Ploopyco Trackball
+
+![Ploopyco Trackball](https://i.redd.it/j7z0y83txps31.jpg)
+
+It's a DIY, QMK Powered Trackball!!!!
+
+Everything works. However the scroll wheel has some issues and acts very odd.
+
+* Keyboard Maintainer: [PloopyCo](https://github.com/ploopyco), [Drashna Jael're](https://github.com/drashna/), [Germ](https://github.com/germ/)
+* Hardware Supported: ATMega32u4 8MHz(3.3v)
+* Hardware Availability: [Store](https://ploopy.co), [GitHub](https://github.com/ploopyco)
+
+Make example for this keyboard (after setting up your build environment):
+
+ make ploopyco/trackball:default:flash
+
+To jump to the bootloader, hold down "Button 4" (immediate right of the trackball)
+
+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
+
+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.
+
+The default behavior for this is:
+
+```c
+void process_wheel_user(report_mouse_t* mouse_report, int16_t h, int16_t v) {
+ mouse_report->h = h;
+ mouse_report->v = v;
+}
+
+void process_mouse_user(report_mouse_t* mouse_report, int16_t x, int16_t y) {
+ mouse_report->x = x;
+ mouse_report->y = y;
+}
+```
+
+This should allow you to more heavily customize the behavior.
+
+Alternatively, the `process_wheel` and `process_mouse` functions can both be replaced too, to allow for even more functionality.
+
+Additionally, you can change the DPI/CPI or speed of the trackball by calling `pmw_set_cpi` at any time. And tThe default can be changed by adding a define to the keymap's `config.h` file:
+
+ #define PMW_CPI 1600
+
+# 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/rules.mk b/keyboards/ploopyco/trackball/rules.mk
new file mode 100644
index 0000000000..d77431b676
--- /dev/null
+++ b/keyboards/ploopyco/trackball/rules.mk
@@ -0,0 +1,30 @@
+# MCU name
+MCU = atmega32u4
+
+# Processor frequency
+F_CPU = 8000000
+
+# Bootloader selection
+BOOTLOADER = caterina
+
+# Build Options
+# change yes to no to disable
+#
+BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration
+EXTRAKEY_ENABLE = yes # Audio control and System control
+CONSOLE_ENABLE = yes # Console for debug
+COMMAND_ENABLE = no # Commands for debug and configuration
+# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
+SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
+# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
+NKRO_ENABLE = no # USB Nkey Rollover
+BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
+RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
+UNICODE_ENABLE = no # Unicode
+BLUETOOTH_ENABLE = no # Enable Bluetooth
+AUDIO_ENABLE = no # Audio output
+POINTING_DEVICE_ENABLE = yes
+MOUSEKEY_ENABLE = no # Mouse keys
+
+QUANTUM_LIB_SRC += analog.c spi_master.c
+SRC += pmw3600.c opt_encoder.c
diff --git a/keyboards/ploopyco/trackball/trackball.c b/keyboards/ploopyco/trackball/trackball.c
new file mode 100644
index 0000000000..6a9bffbffe
--- /dev/null
+++ b/keyboards/ploopyco/trackball/trackball.c
@@ -0,0 +1,237 @@
+/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ * Copyright 2019 Sunjun Kim
+ * Copyright 2020 Ploopy Corporation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include QMK_KEYBOARD_H
+
+#ifndef OPT_DEBOUNCE
+# define OPT_DEBOUNCE 5 // (ms) Time between scroll events
+#endif
+#ifndef SCROLL_BUTT_DEBOUNCE
+# define SCROLL_BUTT_DEBOUNCE 100 // (ms) Time between scroll events
+#endif
+#ifndef OPT_THRES
+# define OPT_THRES 150 // (0-1024) Threshold for actication
+#endif
+#ifndef OPT_SCALE
+# define OPT_SCALE 1 // Multiplier for wheel
+#endif
+
+// TODO: Implement libinput profiles
+// https://wayland.freedesktop.org/libinput/doc/latest/pointer-acceleration.html
+// Compile time accel selection
+// Valid options are ACC_NONE, ACC_LINEAR, ACC_CUSTOM, ACC_QUADRATIC
+
+// Trackball State
+bool is_scroll_clicked = false;
+bool BurstState = false; // init burst state for Trackball module
+uint16_t MotionStart = 0; // Timer for accel, 0 is resting state
+uint16_t lastScroll = 0; // Previous confirmed wheel event
+uint16_t lastMidClick = 0; // Stops scrollwheel from being read if it was pressed
+uint8_t OptLowPin = OPT_ENC1;
+bool debug_encoder = false;
+
+__attribute__((weak)) void process_wheel_user(report_mouse_t* mouse_report, int16_t h, int16_t v) {
+ mouse_report->h = h;
+ mouse_report->v = v;
+}
+
+__attribute__((weak)) void process_wheel(report_mouse_t* mouse_report) {
+ // TODO: Replace this with interrupt driven code, polling is S L O W
+ // Lovingly ripped from the Ploopy Source
+
+ // If the mouse wheel was just released, do not scroll.
+ if (timer_elapsed(lastMidClick) < SCROLL_BUTT_DEBOUNCE) {
+ return;
+ }
+
+ // Limit the number of scrolls per unit time.
+ if (timer_elapsed(lastScroll) < OPT_DEBOUNCE) {
+ return;
+ }
+
+ // Don't scroll if the middle button is depressed.
+ if (is_scroll_clicked) {
+#ifndef IGNORE_SCROLL_CLICK
+ return;
+#endif
+ }
+
+ lastScroll = timer_read();
+ uint16_t p1 = adc_read(OPT_ENC1_MUX);
+ uint16_t p2 = adc_read(OPT_ENC2_MUX);
+ if (debug_encoder) dprintf("OPT1: %d, OPT2: %d\n", p1, p2);
+
+ uint8_t dir = opt_encoder_handler(p1, p2);
+
+ if (dir == 0) return;
+ process_wheel_user(mouse_report, mouse_report->h, (int)(mouse_report->v + (dir * OPT_SCALE)));
+}
+
+__attribute__((weak)) void process_mouse_user(report_mouse_t* mouse_report, int16_t x, int16_t y) {
+ mouse_report->x = x;
+ mouse_report->y = y;
+}
+
+__attribute__((weak)) void process_mouse(report_mouse_t* mouse_report) {
+ report_pmw_t data = pmw_read_burst();
+ if (data.isOnSurface && data.isMotion) {
+ // Reset timer if stopped moving
+ if (!data.isMotion) {
+ if (MotionStart != 0) MotionStart = 0;
+ return;
+ }
+
+ // Set timer if new motion
+ if ((MotionStart == 0) && data.isMotion) {
+ if (debug_mouse) dprintf("Starting motion.\n");
+ MotionStart = timer_read();
+ }
+
+ if (debug_mouse) {
+ dprintf("Delt] d: %d t: %u\n", abs(data.dx) + abs(data.dy), MotionStart);
+ }
+ if (debug_mouse) {
+ dprintf("Pre ] X: %d, Y: %d\n", data.dx, data.dy);
+ }
+#if defined(PROFILE_LINEAR)
+ float scale = float(timer_elaspsed(MotionStart)) / 1000.0;
+ data.dx *= scale;
+ data.dy *= scale;
+#elif defined(PROFILE_INVERSE)
+ // TODO
+#else
+ // no post processing
+#endif
+ // apply multiplier
+ // data.dx *= mouse_multiplier;
+ // data.dy *= mouse_multiplier;
+
+ // Wrap to HID size
+ data.dx = constrain(data.dx, -127, 127);
+ data.dy = constrain(data.dy, -127, 127);
+ 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);
+ }
+}
+
+bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
+ if (debug_mouse) {
+ dprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed);
+ }
+
+ // Update Timer to prevent accidental scrolls
+ if ((record->event.key.col == 2) && (record->event.key.row == 0)) {
+ lastMidClick = timer_read();
+ is_scroll_clicked = record->event.pressed;
+ }
+
+/* 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
+ * Mousekeys is not enable, so it's not handled twice.
+ */
+#ifndef MOUSEKEY_ENABLE
+ 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;
+ } 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;
+ }
+ pointing_device_set_report(currentReport);
+ }
+#endif
+
+ return process_record_user(keycode, record);
+}
+
+// Hardware Setup
+void keyboard_pre_init_kb(void) {
+ // debug_enable = true;
+ // debug_matrix = true;
+ // debug_mouse = true;
+ // debug_encoder = true;
+
+ 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.
+ */
+#ifdef UNUSED_PINS
+ const pin_t unused_pins[] = UNUSED_PINS;
+
+ for (uint8_t i = 0; i < (sizeof(unused_pins) / sizeof(pin_t)); i++) {
+ setPinOutput(unused_pins[i]);
+ writePinLow(unused_pins[i]);
+ }
+#endif
+ keyboard_pre_init_user();
+}
+
+void pointing_device_init(void) {
+ // initialize ball sensor
+ pmw_spi_init();
+ // initialize the scroll wheel's optical encoder
+ opt_encoder_init();
+}
+
+bool has_report_changed (report_mouse_t first, report_mouse_t second) {
+ return !(
+ (!first.buttons && first.buttons == second.buttons) &&
+ (!first.x && first.x == second.x) &&
+ (!first.y && first.y == second.y) &&
+ (!first.h && first.h == second.h) &&
+ (!first.v && first.v == second.v) );
+}
+
+void pointing_device_task(void) {
+ report_mouse_t mouse_report = pointing_device_get_report();
+ process_wheel(&mouse_report);
+ process_mouse(&mouse_report);
+
+ pointing_device_set_report(mouse_report);
+ if (has_report_changed(mouse_report, pointing_device_get_report())) {
+ pointing_device_send();
+ }
+}
diff --git a/keyboards/ploopyco/trackball/trackball.h b/keyboards/ploopyco/trackball/trackball.h
new file mode 100644
index 0000000000..959305a07e
--- /dev/null
+++ b/keyboards/ploopyco/trackball/trackball.h
@@ -0,0 +1,40 @@
+/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ * Copyright 2019 Sunjun Kim
+ * Copyright 2020 Ploopy Corporation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include "quantum.h"
+#include "spi_master.h"
+#include "pmw3600.h"
+#include "analog.h"
+#include "opt_encoder.h"
+#include "pointing_device.h"
+
+// Sensor defs
+#define OPT_ENC1 F0
+#define OPT_ENC2 F4
+#define OPT_ENC1_MUX 0
+#define OPT_ENC2_MUX 4
+
+void process_mouse(report_mouse_t* mouse_report);
+void process_mouse_user(report_mouse_t* mouse_report, int16_t x, int16_t y);
+void process_wheel(report_mouse_t* mouse_report);
+void process_wheel_user(report_mouse_t* mouse_report, int16_t h, int16_t v);
+
+#define LAYOUT(BL, BM, BR, BF, BB) \
+ { {BL, BM, BR, BF, BB}, }