aboutsummaryrefslogtreecommitdiff
path: root/keyboards/ploopyco
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/ploopyco')
-rw-r--r--keyboards/ploopyco/mouse/config.h12
-rw-r--r--keyboards/ploopyco/mouse/info.json3
-rw-r--r--keyboards/ploopyco/mouse/keymaps/default/keymap.c4
-rw-r--r--keyboards/ploopyco/mouse/keymaps/default/readme.md2
-rw-r--r--keyboards/ploopyco/mouse/keymaps/drag_scroll/keymap.c62
-rw-r--r--keyboards/ploopyco/mouse/keymaps/drag_scroll/readme.md3
-rw-r--r--keyboards/ploopyco/mouse/keymaps/via/config.h21
-rw-r--r--keyboards/ploopyco/mouse/keymaps/via/keymap.c7
-rw-r--r--keyboards/ploopyco/mouse/mouse.c57
-rw-r--r--keyboards/ploopyco/mouse/mouse.h16
-rw-r--r--keyboards/ploopyco/mouse/readme.md17
-rw-r--r--keyboards/ploopyco/mouse/rules.mk4
-rw-r--r--keyboards/ploopyco/pmw3360.c (renamed from keyboards/ploopyco/pmw3600.c)13
-rw-r--r--keyboards/ploopyco/pmw3360.h (renamed from keyboards/ploopyco/pmw3600.h)0
-rw-r--r--keyboards/ploopyco/pmw3360_firmware.h (renamed from keyboards/ploopyco/pmw3600_firmware.h)0
-rw-r--r--keyboards/ploopyco/trackball/config.h27
-rw-r--r--keyboards/ploopyco/trackball/info.json3
-rw-r--r--keyboards/ploopyco/trackball/keymaps/default/keymap.c1
-rw-r--r--keyboards/ploopyco/trackball/keymaps/drag_scroll/keymap.c66
-rw-r--r--keyboards/ploopyco/trackball/keymaps/drag_scroll/readme.md3
-rw-r--r--keyboards/ploopyco/trackball/keymaps/via/config.h21
-rw-r--r--keyboards/ploopyco/trackball/keymaps/via/keymap.c12
-rw-r--r--keyboards/ploopyco/trackball/readme.md23
-rw-r--r--keyboards/ploopyco/trackball/rev1/config.h42
-rw-r--r--keyboards/ploopyco/trackball/rev1/rev1.h21
-rw-r--r--keyboards/ploopyco/trackball/rev1/rules.mk0
-rw-r--r--keyboards/ploopyco/trackball/rev1_005/config.h47
-rw-r--r--keyboards/ploopyco/trackball/rev1_005/rev1_005.h21
-rw-r--r--keyboards/ploopyco/trackball/rev1_005/rules.mk0
-rw-r--r--keyboards/ploopyco/trackball/rules.mk4
-rw-r--r--keyboards/ploopyco/trackball/trackball.c64
-rw-r--r--keyboards/ploopyco/trackball/trackball.h21
32 files changed, 536 insertions, 61 deletions
diff --git a/keyboards/ploopyco/mouse/config.h b/keyboards/ploopyco/mouse/config.h
index 787eb9a85..db1c7d002 100644
--- a/keyboards/ploopyco/mouse/config.h
+++ b/keyboards/ploopyco/mouse/config.h
@@ -24,7 +24,7 @@
24#define VENDOR_ID 0x5043 24#define VENDOR_ID 0x5043
25#define PRODUCT_ID 0x4D6F 25#define PRODUCT_ID 0x4D6F
26#define DEVICE_VER 0x0001 26#define DEVICE_VER 0x0001
27#define MANUFACTURER Ploopyco 27#define MANUFACTURER PloopyCo
28#define PRODUCT Mouse 28#define PRODUCT Mouse
29 29
30/* key matrix size */ 30/* key matrix size */
@@ -57,6 +57,7 @@
57/* Much more so than a keyboard, speed matters for a mouse. So we'll go for as high 57/* Much more so than a keyboard, speed matters for a mouse. So we'll go for as high
58 a polling rate as possible. */ 58 a polling rate as possible. */
59#define USB_POLLING_INTERVAL_MS 1 59#define USB_POLLING_INTERVAL_MS 1
60#define USB_MAX_POWER_CONSUMPTION 100
60 61
61/* define if matrix has ghost (lacks anti-ghosting diodes) */ 62/* define if matrix has ghost (lacks anti-ghosting diodes) */
62//#define MATRIX_HAS_GHOST 63//#define MATRIX_HAS_GHOST
@@ -71,3 +72,12 @@
71/* Bootmagic Lite key configuration */ 72/* Bootmagic Lite key configuration */
72#define BOOTMAGIC_LITE_ROW 0 73#define BOOTMAGIC_LITE_ROW 0
73#define BOOTMAGIC_LITE_COLUMN 3 74#define BOOTMAGIC_LITE_COLUMN 3
75
76#define RGB_DI_PIN B5
77#define RGBLED_NUM 4
78#define RGBLIGHT_LIMIT_VAL 40
79#define RGBLIGHT_EFFECT_BREATHING
80#define RGBLIGHT_EFFECT_RAINBOW_MOOD
81#define RGBLIGHT_EFFECT_RAINBOW_SWIRL
82
83// #define DEBUG_LED_PIN F7
diff --git a/keyboards/ploopyco/mouse/info.json b/keyboards/ploopyco/mouse/info.json
index 6763838dc..142bf2bef 100644
--- a/keyboards/ploopyco/mouse/info.json
+++ b/keyboards/ploopyco/mouse/info.json
@@ -1,7 +1,8 @@
1{ 1{
2 "keyboard_name": "PloopyCo Mouse", 2 "keyboard_name": "PloopyCo Mouse",
3 "url": "", 3 "url": "www.ploopy.co",
4 "maintainer": "drashna", 4 "maintainer": "drashna",
5 "manufacturer": "Ploopy Corporation",
5 "width": 8, 6 "width": 8,
6 "height": 3, 7 "height": 3,
7 "layouts": { 8 "layouts": {
diff --git a/keyboards/ploopyco/mouse/keymaps/default/keymap.c b/keyboards/ploopyco/mouse/keymaps/default/keymap.c
index c02d23d2a..8145ffb1c 100644
--- a/keyboards/ploopyco/mouse/keymaps/default/keymap.c
+++ b/keyboards/ploopyco/mouse/keymaps/default/keymap.c
@@ -17,7 +17,9 @@
17 */ 17 */
18#include QMK_KEYBOARD_H 18#include QMK_KEYBOARD_H
19 19
20// safe range starts at `PLOOPY_SAFE_RANGE` instead.
21
20const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 22const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
21 [0] = LAYOUT(/* Base */ 23 [0] = LAYOUT(/* Base */
22 C(KC_C), KC_BTN1, KC_BTN3, KC_BTN2, C(KC_C), KC_BTN4, KC_BTN5, C(KC_Z)), 24 C(KC_C), KC_BTN1, KC_BTN3, KC_BTN2, C(KC_V), KC_BTN4, KC_BTN5, DPI_CONFIG)
23}; 25};
diff --git a/keyboards/ploopyco/mouse/keymaps/default/readme.md b/keyboards/ploopyco/mouse/keymaps/default/readme.md
index f965ef3c3..4618c83c0 100644
--- a/keyboards/ploopyco/mouse/keymaps/default/readme.md
+++ b/keyboards/ploopyco/mouse/keymaps/default/readme.md
@@ -1 +1 @@
# The default keymap for Ploopyco Trackball # The default keymap for PloopyCo Mouse
diff --git a/keyboards/ploopyco/mouse/keymaps/drag_scroll/keymap.c b/keyboards/ploopyco/mouse/keymaps/drag_scroll/keymap.c
new file mode 100644
index 000000000..438e2406f
--- /dev/null
+++ b/keyboards/ploopyco/mouse/keymaps/drag_scroll/keymap.c
@@ -0,0 +1,62 @@
1/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
2 * Copyright 2019 Sunjun Kim
3 * Copyright 2020 Ploopy Corporation
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18#include QMK_KEYBOARD_H
19
20// used for tracking the state
21bool is_drag_scroll = false;
22
23enum custom_keycodes {
24 DRAG_SCROLL = PLOOPY_SAFE_RANGE,
25};
26
27
28const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
29 [0] = LAYOUT(/* Base */
30 C(KC_C), KC_BTN1, KC_BTN3, KC_BTN2, C(KC_V), KC_BTN4, KC_BTN5, DPI_CONFIG)
31};
32
33
34bool process_record_user(uint16_t keycode, keyrecord_t *record) {
35 switch (keycode) {
36 case DRAG_SCROLL:
37 if (record->event.pressed) {
38 // this toggles the state each time you tap it
39 is_drag_scroll ^= 1;
40 }
41 break;
42 }
43 return true;
44}
45
46// The real magic is here.
47// This function is called to translate the processed sensor movement
48// from the mouse sensor and translates it into x and y movement for
49// the mouse report. Normally. So if "drag scroll" is toggled on,
50// moving the ball scrolls instead. You could remove the x or y here
51// to only scroll in one direction, if you wanted, as well. In fact,
52// there is no reason that you need to send this to the mouse report.
53// You could have it register a key, instead.
54void process_mouse_user(report_mouse_t* mouse_report, int16_t x, int16_t y) {
55 if (is_drag_scroll) {
56 mouse_report->h = x;
57 mouse_report->v = y;
58 } else {
59 mouse_report->x = x;
60 mouse_report->y = y;
61 }
62}
diff --git a/keyboards/ploopyco/mouse/keymaps/drag_scroll/readme.md b/keyboards/ploopyco/mouse/keymaps/drag_scroll/readme.md
new file mode 100644
index 000000000..ddf5eb708
--- /dev/null
+++ b/keyboards/ploopyco/mouse/keymaps/drag_scroll/readme.md
@@ -0,0 +1,3 @@
1# The Drag Scroll keymap for PloopyCo Mouse
2
3This is a sample keymap showing off what you can do with the custom callback drivers.
diff --git a/keyboards/ploopyco/mouse/keymaps/via/config.h b/keyboards/ploopyco/mouse/keymaps/via/config.h
new file mode 100644
index 000000000..0ba4c7e0c
--- /dev/null
+++ b/keyboards/ploopyco/mouse/keymaps/via/config.h
@@ -0,0 +1,21 @@
1/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
2 * Copyright 2019 Sunjun Kim
3 * Copyright 2020 Ploopy Corporation
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#pragma once
20
21#define DYNAMIC_KEYMAP_LAYER_COUNT 8
diff --git a/keyboards/ploopyco/mouse/keymaps/via/keymap.c b/keyboards/ploopyco/mouse/keymaps/via/keymap.c
index 27a038438..cd8b7f6c6 100644
--- a/keyboards/ploopyco/mouse/keymaps/via/keymap.c
+++ b/keyboards/ploopyco/mouse/keymaps/via/keymap.c
@@ -18,9 +18,12 @@
18#include QMK_KEYBOARD_H 18#include QMK_KEYBOARD_H
19 19
20const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 20const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
21 [0] = LAYOUT(/* Base */ 21 [0] = LAYOUT(C(KC_C), KC_BTN1, KC_BTN3, KC_BTN2, C(KC_V), KC_BTN4, KC_BTN5, C(KC_Z)),
22 C(KC_C), KC_BTN1, KC_BTN3, KC_BTN2, C(KC_C), KC_BTN4, KC_BTN5, C(KC_Z)),
23 [1] = LAYOUT(_______, _______, _______, _______, _______, _______, _______, _______), 22 [1] = LAYOUT(_______, _______, _______, _______, _______, _______, _______, _______),
24 [2] = LAYOUT(_______, _______, _______, _______, _______, _______, _______, _______), 23 [2] = LAYOUT(_______, _______, _______, _______, _______, _______, _______, _______),
25 [3] = LAYOUT(_______, _______, _______, _______, _______, _______, _______, _______), 24 [3] = LAYOUT(_______, _______, _______, _______, _______, _______, _______, _______),
25 [4] = LAYOUT(_______, _______, _______, _______, _______, _______, _______, _______),
26 [5] = LAYOUT(_______, _______, _______, _______, _______, _______, _______, _______),
27 [6] = LAYOUT(_______, _______, _______, _______, _______, _______, _______, _______),
28 [7] = LAYOUT(_______, _______, _______, _______, _______, _______, _______, _______)
26}; 29};
diff --git a/keyboards/ploopyco/mouse/mouse.c b/keyboards/ploopyco/mouse/mouse.c
index 6a9bffbff..fad4807c7 100644
--- a/keyboards/ploopyco/mouse/mouse.c
+++ b/keyboards/ploopyco/mouse/mouse.c
@@ -30,6 +30,19 @@
30#ifndef OPT_SCALE 30#ifndef OPT_SCALE
31# define OPT_SCALE 1 // Multiplier for wheel 31# define OPT_SCALE 1 // Multiplier for wheel
32#endif 32#endif
33#ifndef PLOOPY_DPI_OPTIONS
34# define PLOOPY_DPI_OPTIONS { 1200, 1600, 2400 }
35# ifndef PLOOPY_DPI_DEFAULT
36# define PLOOPY_DPI_DEFAULT 1
37# endif
38#endif
39#ifndef PLOOPY_DPI_DEFAULT
40# define PLOOPY_DPI_DEFAULT 0
41#endif
42
43keyboard_config_t keyboard_config;
44uint16_t dpi_array[] = PLOOPY_DPI_OPTIONS;
45#define DPI_OPTION_SIZE (sizeof(dpi_array) / sizeof(uint16_t))
33 46
34// TODO: Implement libinput profiles 47// TODO: Implement libinput profiles
35// https://wayland.freedesktop.org/libinput/doc/latest/pointer-acceleration.html 48// https://wayland.freedesktop.org/libinput/doc/latest/pointer-acceleration.html
@@ -137,11 +150,18 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
137 } 150 }
138 151
139 // Update Timer to prevent accidental scrolls 152 // Update Timer to prevent accidental scrolls
140 if ((record->event.key.col == 2) && (record->event.key.row == 0)) { 153 if ((record->event.key.col == 1) && (record->event.key.row == 0)) {
141 lastMidClick = timer_read(); 154 lastMidClick = timer_read();
142 is_scroll_clicked = record->event.pressed; 155 is_scroll_clicked = record->event.pressed;
143 } 156 }
144 157
158 if (!process_record_user(keycode, record)) { return false; }
159
160 if (keycode == DPI_CONFIG && record->event.pressed) {
161 keyboard_config.dpi_config = (keyboard_config.dpi_config + 1) % DPI_OPTION_SIZE;
162 eeconfig_update_kb(keyboard_config.raw);
163 pmw_set_cpi(dpi_array[keyboard_config.dpi_config]);
164 }
145/* If Mousekeys is disabled, then use handle the mouse button 165/* If Mousekeys is disabled, then use handle the mouse button
146 * keycodes. This makes things simpler, and allows usage of 166 * keycodes. This makes things simpler, and allows usage of
147 * the keycodes in a consistent manner. But only do this if 167 * 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) {
174 currentReport.buttons &= ~MOUSE_BTN5; 194 currentReport.buttons &= ~MOUSE_BTN5;
175 } 195 }
176 pointing_device_set_report(currentReport); 196 pointing_device_set_report(currentReport);
197 pointing_device_send();
177 } 198 }
178#endif 199#endif
179 200
180 return process_record_user(keycode, record); 201 return true;
181} 202}
182 203
183// Hardware Setup 204// Hardware Setup
@@ -190,10 +211,6 @@ void keyboard_pre_init_kb(void) {
190 setPinInput(OPT_ENC1); 211 setPinInput(OPT_ENC1);
191 setPinInput(OPT_ENC2); 212 setPinInput(OPT_ENC2);
192 213
193 // This is the debug LED.
194 setPinOutput(F7);
195 writePin(F7, debug_enable);
196
197 /* Ground all output pins connected to ground. This provides additional 214 /* Ground all output pins connected to ground. This provides additional
198 * pathways to ground. If you're messing with this, know this: driving ANY 215 * pathways to ground. If you're messing with this, know this: driving ANY
199 * of these pins high will cause a short. On the MCU. Ka-blooey. 216 * of these pins high will cause a short. On the MCU. Ka-blooey.
@@ -206,6 +223,13 @@ void keyboard_pre_init_kb(void) {
206 writePinLow(unused_pins[i]); 223 writePinLow(unused_pins[i]);
207 } 224 }
208#endif 225#endif
226
227 // This is the debug LED.
228#if defined(DEBUG_LED_PIN)
229 setPinOutput(DEBUG_LED_PIN);
230 writePin(DEBUG_LED_PIN, debug_enable);
231#endif
232
209 keyboard_pre_init_user(); 233 keyboard_pre_init_user();
210} 234}
211 235
@@ -235,3 +259,24 @@ void pointing_device_task(void) {
235 pointing_device_send(); 259 pointing_device_send();
236 } 260 }
237} 261}
262
263void eeconfig_init_kb(void) {
264 keyboard_config.dpi_config = PLOOPY_DPI_DEFAULT;
265 eeconfig_update_kb(keyboard_config.raw);
266}
267
268void matrix_init_kb(void) {
269 // is safe to just read DPI setting since matrix init
270 // comes before pointing device init.
271 keyboard_config.raw = eeconfig_read_kb();
272 if (keyboard_config.dpi_config > DPI_OPTION_SIZE) {
273 eeconfig_init_kb();
274 }
275 matrix_init_user();
276}
277
278void keyboard_post_init_kb(void) {
279 pmw_set_cpi(dpi_array[keyboard_config.dpi_config]);
280
281 keyboard_post_init_user();
282}
diff --git a/keyboards/ploopyco/mouse/mouse.h b/keyboards/ploopyco/mouse/mouse.h
index 3c89d64d8..f80449c18 100644
--- a/keyboards/ploopyco/mouse/mouse.h
+++ b/keyboards/ploopyco/mouse/mouse.h
@@ -20,7 +20,7 @@
20 20
21#include "quantum.h" 21#include "quantum.h"
22#include "spi_master.h" 22#include "spi_master.h"
23#include "pmw3600.h" 23#include "pmw3360.h"
24#include "analog.h" 24#include "analog.h"
25#include "opt_encoder.h" 25#include "opt_encoder.h"
26#include "pointing_device.h" 26#include "pointing_device.h"
@@ -38,3 +38,17 @@ void process_wheel_user(report_mouse_t* mouse_report, int16_t h, int16_t v);
38 38
39#define LAYOUT(BLL, BL, BM, BR, BRR, BF, BB, BDPI) \ 39#define LAYOUT(BLL, BL, BM, BR, BRR, BF, BB, BDPI) \
40 { {BL, BM, BR, BF, BB, BRR, BLL, BDPI}, } 40 { {BL, BM, BR, BF, BB, BRR, BLL, BDPI}, }
41
42typedef union {
43 uint32_t raw;
44 struct {
45 uint8_t dpi_config;
46 };
47} keyboard_config_t;
48
49extern keyboard_config_t keyboard_config;
50
51enum ploopy_keycodes {
52 DPI_CONFIG = SAFE_RANGE,
53 PLOOPY_SAFE_RANGE,
54};
diff --git a/keyboards/ploopyco/mouse/readme.md b/keyboards/ploopyco/mouse/readme.md
index abfa643a4..a9b4b581a 100644
--- a/keyboards/ploopyco/mouse/readme.md
+++ b/keyboards/ploopyco/mouse/readme.md
@@ -1,6 +1,6 @@
1# Ploopyco Mouse 1# Ploopyco Mouse
2 2
3![Ploopyco Mouse](https://i.redd.it/bf7bkzqzeti51.jpg) 3![Ploopyco Mouse](https://www.ploopy.co/uploads/1/2/7/6/127652558/s905404500980887952_p10_i19_w1414.jpeg)
4 4
5It's a DIY, QMK Powered Trackball!!!! 5It's a DIY, QMK Powered Trackball!!!!
6 6
@@ -14,7 +14,7 @@ Make example for this keyboard (after setting up your build environment):
14 14
15 make ploopyco/mouse:default:flash 15 make ploopyco/mouse:default:flash
16 16
17To jump to the bootloader, hold down "Button 4" (immediate right of the Mouse) 17To jump to the bootloader, hold down "Button 4" (the "forward" button on the left side)
18 18
19See 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). 19See 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).
20 20
@@ -40,9 +40,18 @@ This should allow you to more heavily customize the behavior.
40 40
41Alternatively, the `process_wheel` and `process_mouse` functions can both be replaced too, to allow for even more functionality. 41Alternatively, the `process_wheel` and `process_mouse` functions can both be replaced too, to allow for even more functionality.
42 42
43Additionally, 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: 43Additionally, you can change the DPI/CPI or speed of the krackball by calling `pmw_set_cpi` at any time. Additionally, there is a `DPI_CONFIG` macro that will cycle through an array of options for the DPI. This is set to 1200, 1600, and 2400, but can be changed. 1600 is also set to the default.
44
45To configure/set your own array, there are two defines to use, `PLOOPY_DPI_OPTIONS` to set the array, and `PLOOPY_DPI_DEFAULT`.
46
47```c
48#define PLOOPY_DPI_OPTIONS { 1200, 1600, 2400 }
49#define PLOOPY_DPI_DEFAULT 1
50```
51The `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.
52
53The `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.
44 54
45 #define PMW_CPI 1600
46 55
47# Programming QMK-DFU onto the PloopyCo Mouse 56# Programming QMK-DFU onto the PloopyCo Mouse
48 57
diff --git a/keyboards/ploopyco/mouse/rules.mk b/keyboards/ploopyco/mouse/rules.mk
index d77431b67..db72641d0 100644
--- a/keyboards/ploopyco/mouse/rules.mk
+++ b/keyboards/ploopyco/mouse/rules.mk
@@ -5,7 +5,7 @@ MCU = atmega32u4
5F_CPU = 8000000 5F_CPU = 8000000
6 6
7# Bootloader selection 7# Bootloader selection
8BOOTLOADER = caterina 8BOOTLOADER = qmk-dfu
9 9
10# Build Options 10# Build Options
11# change yes to no to disable 11# change yes to no to disable
@@ -27,4 +27,4 @@ POINTING_DEVICE_ENABLE = yes
27MOUSEKEY_ENABLE = no # Mouse keys 27MOUSEKEY_ENABLE = no # Mouse keys
28 28
29QUANTUM_LIB_SRC += analog.c spi_master.c 29QUANTUM_LIB_SRC += analog.c spi_master.c
30SRC += pmw3600.c opt_encoder.c 30SRC += pmw3360.c opt_encoder.c
diff --git a/keyboards/ploopyco/pmw3600.c b/keyboards/ploopyco/pmw3360.c
index 93b47078a..1bd03e8b9 100644
--- a/keyboards/ploopyco/pmw3600.c
+++ b/keyboards/ploopyco/pmw3360.c
@@ -17,8 +17,9 @@
17 */ 17 */
18 18
19 19
20#include "pmw3600.h" 20#include "pmw3360.h"
21#include "pmw3600_firmware.h" 21#include "pmw3360_firmware.h"
22
22#ifdef CONSOLE_ENABLE 23#ifdef CONSOLE_ENABLE
23# include "print.h" 24# include "print.h"
24#endif 25#endif
@@ -30,8 +31,9 @@ bool _inBurst = false;
30#ifndef SPI_DIVISOR 31#ifndef SPI_DIVISOR
31# define SPI_DIVISOR 2 32# define SPI_DIVISOR 2
32#endif 33#endif
33 34#ifndef ROTATIONAL_TRANSFORM_ANGLE
34static const int8_t ROTATIONAL_TRANSFORM_ANGLE = 20; 35# define ROTATIONAL_TRANSFORM_ANGLE 0x00
36#endif
35 37
36#ifdef CONSOLE_ENABLE 38#ifdef CONSOLE_ENABLE
37void 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')); } 39void 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')); }
@@ -120,7 +122,6 @@ bool pmw_spi_init(void) {
120 122
121 pmw_upload_firmware(); 123 pmw_upload_firmware();
122 124
123 spi_write_adv(REG_Angle_Tune, constrain(ROTATIONAL_TRANSFORM_ANGLE, -30, 30));
124 spi_stop_adv(); 125 spi_stop_adv();
125 126
126 wait_ms(10); 127 wait_ms(10);
@@ -134,6 +135,8 @@ bool pmw_spi_init(void) {
134void pmw_upload_firmware(void) { 135void pmw_upload_firmware(void) {
135 spi_write_adv(REG_Config2, 0x00); 136 spi_write_adv(REG_Config2, 0x00);
136 137
138 spi_write_adv(REG_Angle_Tune, constrain(ROTATIONAL_TRANSFORM_ANGLE, -30, 30));
139
137 spi_write_adv(REG_SROM_Enable, 0x1d); 140 spi_write_adv(REG_SROM_Enable, 0x1d);
138 141
139 wait_ms(10); 142 wait_ms(10);
diff --git a/keyboards/ploopyco/pmw3600.h b/keyboards/ploopyco/pmw3360.h
index c1d5e3bad..c1d5e3bad 100644
--- a/keyboards/ploopyco/pmw3600.h
+++ b/keyboards/ploopyco/pmw3360.h
diff --git a/keyboards/ploopyco/pmw3600_firmware.h b/keyboards/ploopyco/pmw3360_firmware.h
index cca5a6a4d..cca5a6a4d 100644
--- a/keyboards/ploopyco/pmw3600_firmware.h
+++ b/keyboards/ploopyco/pmw3360_firmware.h
diff --git a/keyboards/ploopyco/trackball/config.h b/keyboards/ploopyco/trackball/config.h
index 57113d965..66189c33e 100644
--- a/keyboards/ploopyco/trackball/config.h
+++ b/keyboards/ploopyco/trackball/config.h
@@ -23,29 +23,14 @@
23/* USB Device descriptor parameter */ 23/* USB Device descriptor parameter */
24#define VENDOR_ID 0x5043 24#define VENDOR_ID 0x5043
25#define PRODUCT_ID 0x5442 25#define PRODUCT_ID 0x5442
26#define DEVICE_VER 0x0001 26#define DEVICE_VER 0x0001
27#define MANUFACTURER Ploopyco 27#define MANUFACTURER PloopyCo
28#define PRODUCT Trackball 28#define PRODUCT Trackball
29 29
30/* key matrix size */ 30/* key matrix size */
31#define MATRIX_ROWS 1 31#define MATRIX_ROWS 1
32#define MATRIX_COLS 5 32#define MATRIX_COLS 5
33 33
34/*
35 * Keyboard Matrix Assignments
36 *
37 * Change this to how you wired your keyboard
38 * COLS: AVR pins used for columns, left to right
39 * ROWS: AVR pins used for rows, top to bottom
40 * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode)
41 * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
42 *
43 */
44#define DIRECT_PINS { { D4, D2, E6, B5, D7 } }
45
46// These pins are not broken out, and cannot be used normally.
47// They are set as output and pulled high, by default
48#define UNUSED_PINS { D1, D3, B4, B6, B7, D6, C7, F6, F5, F3 }
49 34
50/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ 35/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
51#define DEBOUNCE 5 36#define DEBOUNCE 5
@@ -63,7 +48,13 @@
63/* Much more so than a keyboard, speed matters for a mouse. So we'll go for as high 48/* Much more so than a keyboard, speed matters for a mouse. So we'll go for as high
64 a polling rate as possible. */ 49 a polling rate as possible. */
65#define USB_POLLING_INTERVAL_MS 1 50#define USB_POLLING_INTERVAL_MS 1
51#define USB_MAX_POWER_CONSUMPTION 100
66 52
67/* Bootmagic Lite key configuration */ 53/* Bootmagic Lite key configuration */
68#define BOOTMAGIC_LITE_ROW 0 54#define BOOTMAGIC_LITE_ROW 0
69#define BOOTMAGIC_LITE_COLUMN 3 55#define BOOTMAGIC_LITE_COLUMN 3
56
57#define ROTATIONAL_TRANSFORM_ANGLE 20
58
59// If board has a debug LED, you can enable it by defining this
60// #define DEBUG_LED_PIN F7
diff --git a/keyboards/ploopyco/trackball/info.json b/keyboards/ploopyco/trackball/info.json
index 84d512d8d..c5e4527d8 100644
--- a/keyboards/ploopyco/trackball/info.json
+++ b/keyboards/ploopyco/trackball/info.json
@@ -1,7 +1,8 @@
1{ 1{
2 "keyboard_name": "PloopyCo Trackball", 2 "keyboard_name": "PloopyCo Trackball",
3 "url": "", 3 "url": "www.ploopy.co",
4 "maintainer": "drashna", 4 "maintainer": "drashna",
5 "manufacturer": "Ploopy Corporation",
5 "width": 8, 6 "width": 8,
6 "height": 3, 7 "height": 3,
7 "layouts": { 8 "layouts": {
diff --git a/keyboards/ploopyco/trackball/keymaps/default/keymap.c b/keyboards/ploopyco/trackball/keymaps/default/keymap.c
index dc1ad1439..40f70ab99 100644
--- a/keyboards/ploopyco/trackball/keymaps/default/keymap.c
+++ b/keyboards/ploopyco/trackball/keymaps/default/keymap.c
@@ -17,6 +17,7 @@
17 */ 17 */
18#include QMK_KEYBOARD_H 18#include QMK_KEYBOARD_H
19 19
20// safe range starts at `PLOOPY_SAFE_RANGE` instead.
20 21
21const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 22const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
22 [0] = LAYOUT( /* Base */ 23 [0] = LAYOUT( /* Base */
diff --git a/keyboards/ploopyco/trackball/keymaps/drag_scroll/keymap.c b/keyboards/ploopyco/trackball/keymaps/drag_scroll/keymap.c
new file mode 100644
index 000000000..7784bc855
--- /dev/null
+++ b/keyboards/ploopyco/trackball/keymaps/drag_scroll/keymap.c
@@ -0,0 +1,66 @@
1/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
2 * Copyright 2019 Sunjun Kim
3 * Copyright 2020 Ploopy Corporation
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18#include QMK_KEYBOARD_H
19
20// used for tracking the state
21bool is_drag_scroll = false;
22
23enum custom_keycodes {
24 DRAG_SCROLL = PLOOPY_SAFE_RANGE,
25};
26
27bool process_record_user(uint16_t keycode, keyrecord_t *record) {
28 switch (keycode) {
29 case DRAG_SCROLL:
30 if (record->event.pressed) {
31 // this toggles the state each time you tap it
32 is_drag_scroll ^= 1;
33 }
34 break;
35 }
36 return true;
37}
38
39// The real magic is here.
40// This function is called to translate the processed sensor movement
41// from the mouse sensor and translates it into x and y movement for
42// the mouse report. Normally. So if "drag scroll" is toggled on,
43// moving the ball scrolls instead. You could remove the x or y here
44// to only scroll in one direction, if you wanted, as well. In fact,
45// there is no reason that you need to send this to the mouse report.
46// You could have it register a key, instead.
47void process_mouse_user(report_mouse_t* mouse_report, int16_t x, int16_t y) {
48 if (is_drag_scroll) {
49 mouse_report->h = x;
50 mouse_report->v = y;
51 } else {
52 mouse_report->x = x;
53 mouse_report->y = y;
54 }
55}
56
57const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
58 [0] = LAYOUT( /* Base */
59 KC_BTN1, KC_BTN3, KC_BTN2,
60 KC_BTN4, LT(1, KC_BTN5)
61 ),
62 [1] = LAYOUT(
63 DRAG_SCROLL, _______, _______,
64 _______, _______
65 )
66};
diff --git a/keyboards/ploopyco/trackball/keymaps/drag_scroll/readme.md b/keyboards/ploopyco/trackball/keymaps/drag_scroll/readme.md
new file mode 100644
index 000000000..cafa11bfc
--- /dev/null
+++ b/keyboards/ploopyco/trackball/keymaps/drag_scroll/readme.md
@@ -0,0 +1,3 @@
1# The Drag Scroll keymap for Ploopyco Trackball
2
3This is a sample keymap showing off what you can do with the custom callback drivers.
diff --git a/keyboards/ploopyco/trackball/keymaps/via/config.h b/keyboards/ploopyco/trackball/keymaps/via/config.h
new file mode 100644
index 000000000..0ba4c7e0c
--- /dev/null
+++ b/keyboards/ploopyco/trackball/keymaps/via/config.h
@@ -0,0 +1,21 @@
1/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
2 * Copyright 2019 Sunjun Kim
3 * Copyright 2020 Ploopy Corporation
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#pragma once
20
21#define DYNAMIC_KEYMAP_LAYER_COUNT 8
diff --git a/keyboards/ploopyco/trackball/keymaps/via/keymap.c b/keyboards/ploopyco/trackball/keymaps/via/keymap.c
index dc1ad1439..31539be2e 100644
--- a/keyboards/ploopyco/trackball/keymaps/via/keymap.c
+++ b/keyboards/ploopyco/trackball/keymaps/via/keymap.c
@@ -19,8 +19,12 @@
19 19
20 20
21const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 21const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
22 [0] = LAYOUT( /* Base */ 22 [0] = LAYOUT( KC_BTN1, KC_BTN3, KC_BTN2, KC_BTN4, KC_BTN5 ),
23 KC_BTN1, KC_BTN3, KC_BTN2, 23 [1] = LAYOUT( _______, _______, _______, _______, _______ ),
24 KC_BTN4, KC_BTN5 24 [2] = LAYOUT( _______, _______, _______, _______, _______ ),
25 ), 25 [3] = LAYOUT( _______, _______, _______, _______, _______ ),
26 [4] = LAYOUT( _______, _______, _______, _______, _______ ),
27 [5] = LAYOUT( _______, _______, _______, _______, _______ ),
28 [6] = LAYOUT( _______, _______, _______, _______, _______ ),
29 [7] = LAYOUT( _______, _______, _______, _______, _______ )
26}; 30};
diff --git a/keyboards/ploopyco/trackball/readme.md b/keyboards/ploopyco/trackball/readme.md
index 76b9d6a76..a38fec21a 100644
--- a/keyboards/ploopyco/trackball/readme.md
+++ b/keyboards/ploopyco/trackball/readme.md
@@ -12,12 +12,21 @@ Everything works. However the scroll wheel has some issues and acts very odd.
12 12
13Make example for this keyboard (after setting up your build environment): 13Make example for this keyboard (after setting up your build environment):
14 14
15 make ploopyco/trackball:default:flash 15 make ploopyco/trackball/rev1:default:flash
16 make ploopyco/trackball/rev1_005:default:flash
16 17
17To jump to the bootloader, hold down "Button 4" (immediate right of the trackball) 18To jump to the bootloader, hold down "Button 4" (immediate right of the trackball)
18 19
19See 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). 20See 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).
20 21
22## Revisions
23
24There are two main revisions for the PloopyCo Tracball, everything up to 1.004, and 1.005.
25
26In the 1.005 revision, button for was changed from pin B5 to B6, and the debug LED pin was changed from F7 to B5.
27
28The PCB should indicate which revision this is.
29
21# Customzing your PloopyCo Trackball 30# Customzing your PloopyCo Trackball
22 31
23While 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. 32While 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.
@@ -40,9 +49,17 @@ This should allow you to more heavily customize the behavior.
40 49
41Alternatively, the `process_wheel` and `process_mouse` functions can both be replaced too, to allow for even more functionality. 50Alternatively, the `process_wheel` and `process_mouse` functions can both be replaced too, to allow for even more functionality.
42 51
43Additionally, 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: 52Additionally, you can change the DPI/CPI or speed of the trackball by calling `pmw_set_cpi` at any time. Additionally, there is a `DPI_CONFIG` macro that will cycle through an array of options for the DPI. This is set to 1200, 1600, and 2400, but can be changed. 1600 is also set to the default.
53
54To configure/set your own array, there are two defines to use, `PLOOPY_DPI_OPTIONS` to set the array, and `PLOOPY_DPI_DEFAULT`.
55
56```c
57#define PLOOPY_DPI_OPTIONS { 1200, 1600, 2400 }
58#define PLOOPY_DPI_DEFAULT 1
59```
60The `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.
44 61
45 #define PMW_CPI 1600 62The `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.
46 63
47# Programming QMK-DFU onto the PloopyCo Trackball 64# Programming QMK-DFU onto the PloopyCo Trackball
48 65
diff --git a/keyboards/ploopyco/trackball/rev1/config.h b/keyboards/ploopyco/trackball/rev1/config.h
new file mode 100644
index 000000000..2908f0960
--- /dev/null
+++ b/keyboards/ploopyco/trackball/rev1/config.h
@@ -0,0 +1,42 @@
1/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
2 * Copyright 2019 Sunjun Kim
3 * Copyright 2020 Ploopy Corporation
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#pragma once
20
21/*
22 * Keyboard Matrix Assignments
23 *
24 * Change this to how you wired your keyboard
25 * COLS: AVR pins used for columns, left to right
26 * ROWS: AVR pins used for rows, top to bottom
27 * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode)
28 * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
29 *
30 */
31#define DIRECT_PINS \
32 { \
33 { D4, D2, E6, B5, D7 } \
34 }
35
36// These pins are not broken out, and cannot be used normally.
37// They are set as output and pulled high, by default
38#define UNUSED_PINS \
39 { D1, D3, B4, B6, B7, D6, C7, F6, F5, F3, F7 }
40
41// If board has a debug LED, you can enable it by defining this
42#define DEBUG_LED_PIN F7
diff --git a/keyboards/ploopyco/trackball/rev1/rev1.h b/keyboards/ploopyco/trackball/rev1/rev1.h
new file mode 100644
index 000000000..a82c20a11
--- /dev/null
+++ b/keyboards/ploopyco/trackball/rev1/rev1.h
@@ -0,0 +1,21 @@
1/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
2 * Copyright 2019 Sunjun Kim
3 * Copyright 2020 Ploopy Corporation
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#pragma once
20
21#include "trackball.h"
diff --git a/keyboards/ploopyco/trackball/rev1/rules.mk b/keyboards/ploopyco/trackball/rev1/rules.mk
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/keyboards/ploopyco/trackball/rev1/rules.mk
diff --git a/keyboards/ploopyco/trackball/rev1_005/config.h b/keyboards/ploopyco/trackball/rev1_005/config.h
new file mode 100644
index 000000000..83e70181d
--- /dev/null
+++ b/keyboards/ploopyco/trackball/rev1_005/config.h
@@ -0,0 +1,47 @@
1/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
2 * Copyright 2019 Sunjun Kim
3 * Copyright 2020 Ploopy Corporation
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#pragma once
20
21/*
22 * Keyboard Matrix Assignments
23 *
24 * Change this to how you wired your keyboard
25 * COLS: AVR pins used for columns, left to right
26 * ROWS: AVR pins used for rows, top to bottom
27 * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode)
28 * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
29 *
30 */
31#define DIRECT_PINS \
32 { \
33 { D4, D2, E6, B6, D7 } \
34 }
35
36// These pins are not broken out, and cannot be used normally.
37// They are set as output and pulled high, by default
38#define UNUSED_PINS \
39 { D1, D3, B4, B7, D6, C7, F6, F5, F3, F7 }
40
41// If board has a debug LED, you can enable it by defining this
42#define RGB_DI_PIN B5
43#define RGBLED_NUM 3
44#define RGBLIGHT_LIMIT_VAL 40
45#define RGBLIGHT_EFFECT_BREATHING
46#define RGBLIGHT_EFFECT_RAINBOW_MOOD
47#define RGBLIGHT_EFFECT_RAINBOW_SWIRL
diff --git a/keyboards/ploopyco/trackball/rev1_005/rev1_005.h b/keyboards/ploopyco/trackball/rev1_005/rev1_005.h
new file mode 100644
index 000000000..a82c20a11
--- /dev/null
+++ b/keyboards/ploopyco/trackball/rev1_005/rev1_005.h
@@ -0,0 +1,21 @@
1/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
2 * Copyright 2019 Sunjun Kim
3 * Copyright 2020 Ploopy Corporation
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#pragma once
20
21#include "trackball.h"
diff --git a/keyboards/ploopyco/trackball/rev1_005/rules.mk b/keyboards/ploopyco/trackball/rev1_005/rules.mk
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/keyboards/ploopyco/trackball/rev1_005/rules.mk
diff --git a/keyboards/ploopyco/trackball/rules.mk b/keyboards/ploopyco/trackball/rules.mk
index d77431b67..9e252fbdd 100644
--- a/keyboards/ploopyco/trackball/rules.mk
+++ b/keyboards/ploopyco/trackball/rules.mk
@@ -27,4 +27,6 @@ POINTING_DEVICE_ENABLE = yes
27MOUSEKEY_ENABLE = no # Mouse keys 27MOUSEKEY_ENABLE = no # Mouse keys
28 28
29QUANTUM_LIB_SRC += analog.c spi_master.c 29QUANTUM_LIB_SRC += analog.c spi_master.c
30SRC += pmw3600.c opt_encoder.c 30SRC += pmw3360.c opt_encoder.c
31
32DEFAULT_FOLDER = ploopyco/trackball/rev1_005
diff --git a/keyboards/ploopyco/trackball/trackball.c b/keyboards/ploopyco/trackball/trackball.c
index 6a9bffbff..7b7b68027 100644
--- a/keyboards/ploopyco/trackball/trackball.c
+++ b/keyboards/ploopyco/trackball/trackball.c
@@ -16,7 +16,7 @@
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 17 */
18 18
19#include QMK_KEYBOARD_H 19#include "trackball.h"
20 20
21#ifndef OPT_DEBOUNCE 21#ifndef OPT_DEBOUNCE
22# define OPT_DEBOUNCE 5 // (ms) Time between scroll events 22# define OPT_DEBOUNCE 5 // (ms) Time between scroll events
@@ -30,6 +30,19 @@
30#ifndef OPT_SCALE 30#ifndef OPT_SCALE
31# define OPT_SCALE 1 // Multiplier for wheel 31# define OPT_SCALE 1 // Multiplier for wheel
32#endif 32#endif
33#ifndef PLOOPY_DPI_OPTIONS
34# define PLOOPY_DPI_OPTIONS { 1200, 1600, 2400 }
35# ifndef PLOOPY_DPI_DEFAULT
36# define PLOOPY_DPI_DEFAULT 1
37# endif
38#endif
39#ifndef PLOOPY_DPI_DEFAULT
40# define PLOOPY_DPI_DEFAULT 0
41#endif
42
43keyboard_config_t keyboard_config;
44uint16_t dpi_array[] = PLOOPY_DPI_OPTIONS;
45#define DPI_OPTION_SIZE (sizeof(dpi_array) / sizeof(uint16_t))
33 46
34// TODO: Implement libinput profiles 47// TODO: Implement libinput profiles
35// https://wayland.freedesktop.org/libinput/doc/latest/pointer-acceleration.html 48// https://wayland.freedesktop.org/libinput/doc/latest/pointer-acceleration.html
@@ -132,16 +145,24 @@ __attribute__((weak)) void process_mouse(report_mouse_t* mouse_report) {
132} 145}
133 146
134bool process_record_kb(uint16_t keycode, keyrecord_t* record) { 147bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
135 if (debug_mouse) { 148 if (true) {
136 dprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed); 149 xprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed);
137 } 150 }
138 151
139 // Update Timer to prevent accidental scrolls 152 // Update Timer to prevent accidental scrolls
140 if ((record->event.key.col == 2) && (record->event.key.row == 0)) { 153 if ((record->event.key.col == 1) && (record->event.key.row == 0)) {
141 lastMidClick = timer_read(); 154 lastMidClick = timer_read();
142 is_scroll_clicked = record->event.pressed; 155 is_scroll_clicked = record->event.pressed;
143 } 156 }
144 157
158 if (!process_record_user(keycode, record)) { return false; }
159
160 if (keycode == DPI_CONFIG && record->event.pressed) {
161 keyboard_config.dpi_config = (keyboard_config.dpi_config + 1) % DPI_OPTION_SIZE;
162 eeconfig_update_kb(keyboard_config.raw);
163 pmw_set_cpi(dpi_array[keyboard_config.dpi_config]);
164 }
165
145/* If Mousekeys is disabled, then use handle the mouse button 166/* If Mousekeys is disabled, then use handle the mouse button
146 * keycodes. This makes things simpler, and allows usage of 167 * keycodes. This makes things simpler, and allows usage of
147 * the keycodes in a consistent manner. But only do this if 168 * the keycodes in a consistent manner. But only do this if
@@ -174,10 +195,11 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
174 currentReport.buttons &= ~MOUSE_BTN5; 195 currentReport.buttons &= ~MOUSE_BTN5;
175 } 196 }
176 pointing_device_set_report(currentReport); 197 pointing_device_set_report(currentReport);
198 pointing_device_send();
177 } 199 }
178#endif 200#endif
179 201
180 return process_record_user(keycode, record); 202 return true;
181} 203}
182 204
183// Hardware Setup 205// Hardware Setup
@@ -190,10 +212,6 @@ void keyboard_pre_init_kb(void) {
190 setPinInput(OPT_ENC1); 212 setPinInput(OPT_ENC1);
191 setPinInput(OPT_ENC2); 213 setPinInput(OPT_ENC2);
192 214
193 // This is the debug LED.
194 setPinOutput(F7);
195 writePin(F7, debug_enable);
196
197 /* Ground all output pins connected to ground. This provides additional 215 /* Ground all output pins connected to ground. This provides additional
198 * pathways to ground. If you're messing with this, know this: driving ANY 216 * pathways to ground. If you're messing with this, know this: driving ANY
199 * of these pins high will cause a short. On the MCU. Ka-blooey. 217 * of these pins high will cause a short. On the MCU. Ka-blooey.
@@ -206,6 +224,13 @@ void keyboard_pre_init_kb(void) {
206 writePinLow(unused_pins[i]); 224 writePinLow(unused_pins[i]);
207 } 225 }
208#endif 226#endif
227
228 // This is the debug LED.
229#if defined(DEBUG_LED_PIN)
230 setPinOutput(DEBUG_LED_PIN);
231 writePin(DEBUG_LED_PIN, debug_enable);
232#endif
233
209 keyboard_pre_init_user(); 234 keyboard_pre_init_user();
210} 235}
211 236
@@ -235,3 +260,24 @@ void pointing_device_task(void) {
235 pointing_device_send(); 260 pointing_device_send();
236 } 261 }
237} 262}
263
264void eeconfig_init_kb(void) {
265 keyboard_config.dpi_config = PLOOPY_DPI_DEFAULT;
266 eeconfig_update_kb(keyboard_config.raw);
267}
268
269void matrix_init_kb(void) {
270 // is safe to just read DPI setting since matrix init
271 // comes before pointing device init.
272 keyboard_config.raw = eeconfig_read_kb();
273 if (keyboard_config.dpi_config > DPI_OPTION_SIZE) {
274 eeconfig_init_kb();
275 }
276 matrix_init_user();
277}
278
279void keyboard_post_init_kb(void) {
280 pmw_set_cpi(dpi_array[keyboard_config.dpi_config]);
281
282 keyboard_post_init_user();
283}
diff --git a/keyboards/ploopyco/trackball/trackball.h b/keyboards/ploopyco/trackball/trackball.h
index 959305a07..c58be6c84 100644
--- a/keyboards/ploopyco/trackball/trackball.h
+++ b/keyboards/ploopyco/trackball/trackball.h
@@ -20,10 +20,15 @@
20 20
21#include "quantum.h" 21#include "quantum.h"
22#include "spi_master.h" 22#include "spi_master.h"
23#include "pmw3600.h" 23#include "pmw3360.h"
24#include "analog.h" 24#include "analog.h"
25#include "opt_encoder.h" 25#include "opt_encoder.h"
26#include "pointing_device.h" 26#include "pointing_device.h"
27#if defined(KEYBOARD_ploopyco_trackball_rev1)
28# include "rev1.h"
29#elif defined(KEYBOARD_ploopyco_trackball_rev1_005)
30# include "rev1_005.h"
31#endif
27 32
28// Sensor defs 33// Sensor defs
29#define OPT_ENC1 F0 34#define OPT_ENC1 F0
@@ -38,3 +43,17 @@ void process_wheel_user(report_mouse_t* mouse_report, int16_t h, int16_t v);
38 43
39#define LAYOUT(BL, BM, BR, BF, BB) \ 44#define LAYOUT(BL, BM, BR, BF, BB) \
40 { {BL, BM, BR, BF, BB}, } 45 { {BL, BM, BR, BF, BB}, }
46
47typedef union {
48 uint32_t raw;
49 struct {
50 uint8_t dpi_config;
51 };
52} keyboard_config_t;
53
54extern keyboard_config_t keyboard_config;
55
56enum ploopy_keycodes {
57 DPI_CONFIG = SAFE_RANGE,
58 PLOOPY_SAFE_RANGE,
59};