diff options
Diffstat (limited to 'keyboards/ploopyco/mouse')
-rw-r--r-- | keyboards/ploopyco/mouse/config.h | 73 | ||||
-rw-r--r-- | keyboards/ploopyco/mouse/info.json | 21 | ||||
-rw-r--r-- | keyboards/ploopyco/mouse/keymaps/default/keymap.c | 23 | ||||
-rw-r--r-- | keyboards/ploopyco/mouse/keymaps/default/readme.md | 1 | ||||
-rw-r--r-- | keyboards/ploopyco/mouse/keymaps/via/keymap.c | 26 | ||||
-rw-r--r-- | keyboards/ploopyco/mouse/keymaps/via/rules.mk | 1 | ||||
-rw-r--r-- | keyboards/ploopyco/mouse/mouse.c | 237 | ||||
-rw-r--r-- | keyboards/ploopyco/mouse/mouse.h | 40 | ||||
-rw-r--r-- | keyboards/ploopyco/mouse/readme.md | 68 | ||||
-rw-r--r-- | keyboards/ploopyco/mouse/rules.mk | 30 |
10 files changed, 520 insertions, 0 deletions
diff --git a/keyboards/ploopyco/mouse/config.h b/keyboards/ploopyco/mouse/config.h new file mode 100644 index 000000000..787eb9a85 --- /dev/null +++ b/keyboards/ploopyco/mouse/config.h | |||
@@ -0,0 +1,73 @@ | |||
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 "config_common.h" | ||
22 | |||
23 | /* USB Device descriptor parameter */ | ||
24 | #define VENDOR_ID 0x5043 | ||
25 | #define PRODUCT_ID 0x4D6F | ||
26 | #define DEVICE_VER 0x0001 | ||
27 | #define MANUFACTURER Ploopyco | ||
28 | #define PRODUCT Mouse | ||
29 | |||
30 | /* key matrix size */ | ||
31 | #define MATRIX_ROWS 1 | ||
32 | #define MATRIX_COLS 8 | ||
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 \ | ||
45 | { \ | ||
46 | { D4, D2, E6, B6, D7, C6, C7, B7 } \ | ||
47 | } | ||
48 | |||
49 | // These pins are not broken out, and cannot be used normally. | ||
50 | // They are set as output and pulled high, by default | ||
51 | #define UNUSED_PINS \ | ||
52 | { B4, D6, F1, F5, F6, F7 } | ||
53 | |||
54 | /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ | ||
55 | #define DEBOUNCE 5 | ||
56 | |||
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. */ | ||
59 | #define USB_POLLING_INTERVAL_MS 1 | ||
60 | |||
61 | /* define if matrix has ghost (lacks anti-ghosting diodes) */ | ||
62 | //#define MATRIX_HAS_GHOST | ||
63 | |||
64 | /* disable action features */ | ||
65 | //#define NO_ACTION_LAYER | ||
66 | //#define NO_ACTION_TAPPING | ||
67 | //#define NO_ACTION_ONESHOT | ||
68 | #define NO_ACTION_MACRO | ||
69 | #define NO_ACTION_FUNCTION | ||
70 | |||
71 | /* Bootmagic Lite key configuration */ | ||
72 | #define BOOTMAGIC_LITE_ROW 0 | ||
73 | #define BOOTMAGIC_LITE_COLUMN 3 | ||
diff --git a/keyboards/ploopyco/mouse/info.json b/keyboards/ploopyco/mouse/info.json new file mode 100644 index 000000000..6763838dc --- /dev/null +++ b/keyboards/ploopyco/mouse/info.json | |||
@@ -0,0 +1,21 @@ | |||
1 | { | ||
2 | "keyboard_name": "PloopyCo Mouse", | ||
3 | "url": "", | ||
4 | "maintainer": "drashna", | ||
5 | "width": 8, | ||
6 | "height": 3, | ||
7 | "layouts": { | ||
8 | "LAYOUT": { | ||
9 | "layout": [ | ||
10 | {"x":1, "y":0, "h":2}, | ||
11 | {"x":2, "y":0, "h":2}, | ||
12 | {"x":3, "y":0.25, "h":1.25}, | ||
13 | {"x":4, "y":0, "h":2}, | ||
14 | {"x":5, "y":0, "h":2}, | ||
15 | {"x":0, "y":0}, | ||
16 | {"x":0, "y":1}, | ||
17 | {"x":3, "y":1.5} | ||
18 | ] | ||
19 | } | ||
20 | } | ||
21 | } | ||
diff --git a/keyboards/ploopyco/mouse/keymaps/default/keymap.c b/keyboards/ploopyco/mouse/keymaps/default/keymap.c new file mode 100644 index 000000000..c02d23d2a --- /dev/null +++ b/keyboards/ploopyco/mouse/keymaps/default/keymap.c | |||
@@ -0,0 +1,23 @@ | |||
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 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
21 | [0] = LAYOUT(/* Base */ | ||
22 | C(KC_C), KC_BTN1, KC_BTN3, KC_BTN2, C(KC_C), KC_BTN4, KC_BTN5, C(KC_Z)), | ||
23 | }; | ||
diff --git a/keyboards/ploopyco/mouse/keymaps/default/readme.md b/keyboards/ploopyco/mouse/keymaps/default/readme.md new file mode 100644 index 000000000..f965ef3c3 --- /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 000000000..27a038438 --- /dev/null +++ b/keyboards/ploopyco/mouse/keymaps/via/keymap.c | |||
@@ -0,0 +1,26 @@ | |||
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 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
21 | [0] = LAYOUT(/* Base */ | ||
22 | C(KC_C), KC_BTN1, KC_BTN3, KC_BTN2, C(KC_C), KC_BTN4, KC_BTN5, C(KC_Z)), | ||
23 | [1] = LAYOUT(_______, _______, _______, _______, _______, _______, _______, _______), | ||
24 | [2] = LAYOUT(_______, _______, _______, _______, _______, _______, _______, _______), | ||
25 | [3] = LAYOUT(_______, _______, _______, _______, _______, _______, _______, _______), | ||
26 | }; | ||
diff --git a/keyboards/ploopyco/mouse/keymaps/via/rules.mk b/keyboards/ploopyco/mouse/keymaps/via/rules.mk new file mode 100644 index 000000000..1e5b99807 --- /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 000000000..6a9bffbff --- /dev/null +++ b/keyboards/ploopyco/mouse/mouse.c | |||
@@ -0,0 +1,237 @@ | |||
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 | #include QMK_KEYBOARD_H | ||
20 | |||
21 | #ifndef OPT_DEBOUNCE | ||
22 | # define OPT_DEBOUNCE 5 // (ms) Time between scroll events | ||
23 | #endif | ||
24 | #ifndef SCROLL_BUTT_DEBOUNCE | ||
25 | # define SCROLL_BUTT_DEBOUNCE 100 // (ms) Time between scroll events | ||
26 | #endif | ||
27 | #ifndef OPT_THRES | ||
28 | # define OPT_THRES 150 // (0-1024) Threshold for actication | ||
29 | #endif | ||
30 | #ifndef OPT_SCALE | ||
31 | # define OPT_SCALE 1 // Multiplier for wheel | ||
32 | #endif | ||
33 | |||
34 | // TODO: Implement libinput profiles | ||
35 | // https://wayland.freedesktop.org/libinput/doc/latest/pointer-acceleration.html | ||
36 | // Compile time accel selection | ||
37 | // Valid options are ACC_NONE, ACC_LINEAR, ACC_CUSTOM, ACC_QUADRATIC | ||
38 | |||
39 | // Trackball State | ||
40 | bool is_scroll_clicked = false; | ||
41 | bool BurstState = false; // init burst state for Trackball module | ||
42 | uint16_t MotionStart = 0; // Timer for accel, 0 is resting state | ||
43 | uint16_t lastScroll = 0; // Previous confirmed wheel event | ||
44 | uint16_t lastMidClick = 0; // Stops scrollwheel from being read if it was pressed | ||
45 | uint8_t OptLowPin = OPT_ENC1; | ||
46 | bool debug_encoder = false; | ||
47 | |||
48 | __attribute__((weak)) void process_wheel_user(report_mouse_t* mouse_report, int16_t h, int16_t v) { | ||
49 | mouse_report->h = h; | ||
50 | mouse_report->v = v; | ||
51 | } | ||
52 | |||
53 | __attribute__((weak)) void process_wheel(report_mouse_t* mouse_report) { | ||
54 | // TODO: Replace this with interrupt driven code, polling is S L O W | ||
55 | // Lovingly ripped from the Ploopy Source | ||
56 | |||
57 | // If the mouse wheel was just released, do not scroll. | ||
58 | if (timer_elapsed(lastMidClick) < SCROLL_BUTT_DEBOUNCE) { | ||
59 | return; | ||
60 | } | ||
61 | |||
62 | // Limit the number of scrolls per unit time. | ||
63 | if (timer_elapsed(lastScroll) < OPT_DEBOUNCE) { | ||
64 | return; | ||
65 | } | ||
66 | |||
67 | // Don't scroll if the middle button is depressed. | ||
68 | if (is_scroll_clicked) { | ||
69 | #ifndef IGNORE_SCROLL_CLICK | ||
70 | return; | ||
71 | #endif | ||
72 | } | ||
73 | |||
74 | lastScroll = timer_read(); | ||
75 | uint16_t p1 = adc_read(OPT_ENC1_MUX); | ||
76 | uint16_t p2 = adc_read(OPT_ENC2_MUX); | ||
77 | if (debug_encoder) dprintf("OPT1: %d, OPT2: %d\n", p1, p2); | ||
78 | |||
79 | uint8_t dir = opt_encoder_handler(p1, p2); | ||
80 | |||
81 | if (dir == 0) return; | ||
82 | process_wheel_user(mouse_report, mouse_report->h, (int)(mouse_report->v + (dir * OPT_SCALE))); | ||
83 | } | ||
84 | |||
85 | __attribute__((weak)) void process_mouse_user(report_mouse_t* mouse_report, int16_t x, int16_t y) { | ||
86 | mouse_report->x = x; | ||
87 | mouse_report->y = y; | ||
88 | } | ||
89 | |||
90 | __attribute__((weak)) void process_mouse(report_mouse_t* mouse_report) { | ||
91 | report_pmw_t data = pmw_read_burst(); | ||
92 | if (data.isOnSurface && data.isMotion) { | ||
93 | // Reset timer if stopped moving | ||
94 | if (!data.isMotion) { | ||
95 | if (MotionStart != 0) MotionStart = 0; | ||
96 | return; | ||
97 | } | ||
98 | |||
99 | // Set timer if new motion | ||
100 | if ((MotionStart == 0) && data.isMotion) { | ||
101 | if (debug_mouse) dprintf("Starting motion.\n"); | ||
102 | MotionStart = timer_read(); | ||
103 | } | ||
104 | |||
105 | if (debug_mouse) { | ||
106 | dprintf("Delt] d: %d t: %u\n", abs(data.dx) + abs(data.dy), MotionStart); | ||
107 | } | ||
108 | if (debug_mouse) { | ||
109 | dprintf("Pre ] X: %d, Y: %d\n", data.dx, data.dy); | ||
110 | } | ||
111 | #if defined(PROFILE_LINEAR) | ||
112 | float scale = float(timer_elaspsed(MotionStart)) / 1000.0; | ||
113 | data.dx *= scale; | ||
114 | data.dy *= scale; | ||
115 | #elif defined(PROFILE_INVERSE) | ||
116 | // TODO | ||
117 | #else | ||
118 | // no post processing | ||
119 | #endif | ||
120 | // apply multiplier | ||
121 | // data.dx *= mouse_multiplier; | ||
122 | // data.dy *= mouse_multiplier; | ||
123 | |||
124 | // Wrap to HID size | ||
125 | data.dx = constrain(data.dx, -127, 127); | ||
126 | data.dy = constrain(data.dy, -127, 127); | ||
127 | if (debug_mouse) dprintf("Cons] X: %d, Y: %d\n", data.dx, data.dy); | ||
128 | // dprintf("Elapsed:%u, X: %f Y: %\n", i, pgm_read_byte(firmware_data+i)); | ||
129 | |||
130 | process_mouse_user(mouse_report, data.dx, data.dy); | ||
131 | } | ||
132 | } | ||
133 | |||
134 | bool process_record_kb(uint16_t keycode, keyrecord_t* record) { | ||
135 | if (debug_mouse) { | ||
136 | dprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed); | ||
137 | } | ||
138 | |||
139 | // Update Timer to prevent accidental scrolls | ||
140 | if ((record->event.key.col == 2) && (record->event.key.row == 0)) { | ||
141 | lastMidClick = timer_read(); | ||
142 | is_scroll_clicked = record->event.pressed; | ||
143 | } | ||
144 | |||
145 | /* If Mousekeys is disabled, then use handle the mouse button | ||
146 | * keycodes. This makes things simpler, and allows usage of | ||
147 | * the keycodes in a consistent manner. But only do this if | ||
148 | * Mousekeys is not enable, so it's not handled twice. | ||
149 | */ | ||
150 | #ifndef MOUSEKEY_ENABLE | ||
151 | if (IS_MOUSEKEY_BUTTON(keycode)) { | ||
152 | report_mouse_t currentReport = pointing_device_get_report(); | ||
153 | if (record->event.pressed) { | ||
154 | if (keycode == KC_MS_BTN1) | ||
155 | currentReport.buttons |= MOUSE_BTN1; | ||
156 | else if (keycode == KC_MS_BTN2) | ||
157 | currentReport.buttons |= MOUSE_BTN2; | ||
158 | else if (keycode == KC_MS_BTN3) | ||
159 | currentReport.buttons |= MOUSE_BTN3; | ||
160 | else if (keycode == KC_MS_BTN4) | ||
161 | currentReport.buttons |= MOUSE_BTN4; | ||
162 | else if (keycode == KC_MS_BTN5) | ||
163 | currentReport.buttons |= MOUSE_BTN5; | ||
164 | } else { | ||
165 | if (keycode == KC_MS_BTN1) | ||
166 | currentReport.buttons &= ~MOUSE_BTN1; | ||
167 | else if (keycode == KC_MS_BTN2) | ||
168 | currentReport.buttons &= ~MOUSE_BTN2; | ||
169 | else if (keycode == KC_MS_BTN3) | ||
170 | currentReport.buttons &= ~MOUSE_BTN3; | ||
171 | else if (keycode == KC_MS_BTN4) | ||
172 | currentReport.buttons &= ~MOUSE_BTN4; | ||
173 | else if (keycode == KC_MS_BTN5) | ||
174 | currentReport.buttons &= ~MOUSE_BTN5; | ||
175 | } | ||
176 | pointing_device_set_report(currentReport); | ||
177 | } | ||
178 | #endif | ||
179 | |||
180 | return process_record_user(keycode, record); | ||
181 | } | ||
182 | |||
183 | // Hardware Setup | ||
184 | void keyboard_pre_init_kb(void) { | ||
185 | // debug_enable = true; | ||
186 | // debug_matrix = true; | ||
187 | // debug_mouse = true; | ||
188 | // debug_encoder = true; | ||
189 | |||
190 | setPinInput(OPT_ENC1); | ||
191 | setPinInput(OPT_ENC2); | ||
192 | |||
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 | ||
198 | * 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. | ||
200 | */ | ||
201 | #ifdef UNUSED_PINS | ||
202 | const pin_t unused_pins[] = UNUSED_PINS; | ||
203 | |||
204 | for (uint8_t i = 0; i < (sizeof(unused_pins) / sizeof(pin_t)); i++) { | ||
205 | setPinOutput(unused_pins[i]); | ||
206 | writePinLow(unused_pins[i]); | ||
207 | } | ||
208 | #endif | ||
209 | keyboard_pre_init_user(); | ||
210 | } | ||
211 | |||
212 | void pointing_device_init(void) { | ||
213 | // initialize ball sensor | ||
214 | pmw_spi_init(); | ||
215 | // initialize the scroll wheel's optical encoder | ||
216 | opt_encoder_init(); | ||
217 | } | ||
218 | |||
219 | bool has_report_changed (report_mouse_t first, report_mouse_t second) { | ||
220 | return !( | ||
221 | (!first.buttons && first.buttons == second.buttons) && | ||
222 | (!first.x && first.x == second.x) && | ||
223 | (!first.y && first.y == second.y) && | ||
224 | (!first.h && first.h == second.h) && | ||
225 | (!first.v && first.v == second.v) ); | ||
226 | } | ||
227 | |||
228 | void pointing_device_task(void) { | ||
229 | report_mouse_t mouse_report = pointing_device_get_report(); | ||
230 | process_wheel(&mouse_report); | ||
231 | process_mouse(&mouse_report); | ||
232 | |||
233 | pointing_device_set_report(mouse_report); | ||
234 | if (has_report_changed(mouse_report, pointing_device_get_report())) { | ||
235 | pointing_device_send(); | ||
236 | } | ||
237 | } | ||
diff --git a/keyboards/ploopyco/mouse/mouse.h b/keyboards/ploopyco/mouse/mouse.h new file mode 100644 index 000000000..3c89d64d8 --- /dev/null +++ b/keyboards/ploopyco/mouse/mouse.h | |||
@@ -0,0 +1,40 @@ | |||
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 "quantum.h" | ||
22 | #include "spi_master.h" | ||
23 | #include "pmw3600.h" | ||
24 | #include "analog.h" | ||
25 | #include "opt_encoder.h" | ||
26 | #include "pointing_device.h" | ||
27 | |||
28 | // Sensor defs | ||
29 | #define OPT_ENC1 F0 | ||
30 | #define OPT_ENC2 F4 | ||
31 | #define OPT_ENC1_MUX 0 | ||
32 | #define OPT_ENC2_MUX 4 | ||
33 | |||
34 | void process_mouse(report_mouse_t* mouse_report); | ||
35 | void process_mouse_user(report_mouse_t* mouse_report, int16_t x, int16_t y); | ||
36 | void process_wheel(report_mouse_t* mouse_report); | ||
37 | void process_wheel_user(report_mouse_t* mouse_report, int16_t h, int16_t v); | ||
38 | |||
39 | #define LAYOUT(BLL, BL, BM, BR, BRR, BF, BB, BDPI) \ | ||
40 | { {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 000000000..abfa643a4 --- /dev/null +++ b/keyboards/ploopyco/mouse/readme.md | |||
@@ -0,0 +1,68 @@ | |||
1 | # Ploopyco Mouse | ||
2 | |||
3 |  | ||
4 | |||
5 | It's a DIY, QMK Powered Trackball!!!! | ||
6 | |||
7 | Everything works. However the scroll wheel has some issues and acts very odd. | ||
8 | |||
9 | * Keyboard Maintainer: [PloopyCo](https://github.com/ploopyco), [Drashna Jael're](https://github.com/drashna/), [Germ](https://github.com/germ/) | ||
10 | * Hardware Supported: ATMega32u4 8MHz(3.3v) | ||
11 | * Hardware Availability: [Store](https://ploopy.co), [GitHub](https://github.com/ploopyco) | ||
12 | |||
13 | Make example for this keyboard (after setting up your build environment): | ||
14 | |||
15 | make ploopyco/mouse:default:flash | ||
16 | |||
17 | To jump to the bootloader, hold down "Button 4" (immediate right of the Mouse) | ||
18 | |||
19 | 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). | ||
20 | |||
21 | # Customzing your PloopyCo Trackball | ||
22 | |||
23 | 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. | ||
24 | |||
25 | The default behavior for this is: | ||
26 | |||
27 | ```c | ||
28 | void process_wheel_user(report_mouse_t* mouse_report, int16_t h, int16_t v) { | ||
29 | mouse_report->h = h; | ||
30 | mouse_report->v = v; | ||
31 | } | ||
32 | |||
33 | void process_mouse_user(report_mouse_t* mouse_report, int16_t x, int16_t y) { | ||
34 | mouse_report->x = x; | ||
35 | mouse_report->y = y; | ||
36 | } | ||
37 | ``` | ||
38 | |||
39 | This should allow you to more heavily customize the behavior. | ||
40 | |||
41 | Alternatively, the `process_wheel` and `process_mouse` functions can both be replaced too, to allow for even more functionality. | ||
42 | |||
43 | 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: | ||
44 | |||
45 | #define PMW_CPI 1600 | ||
46 | |||
47 | # Programming QMK-DFU onto the PloopyCo Mouse | ||
48 | |||
49 | 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: | ||
50 | |||
51 | make ploopyco/trackball:default:production | ||
52 | |||
53 | 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: | ||
54 | |||
55 | |||
56 | | Fuse | Setting | | ||
57 | |----------|------------------| | ||
58 | | Low | `0xDF` | | ||
59 | | High | `0xD8` or `0x98` | | ||
60 | | Extended | `0xCB` | | ||
61 | |||
62 | Original (Caterina) settings: | ||
63 | |||
64 | | Fuse | Setting | | ||
65 | |----------|------------------| | ||
66 | | Low | `0xFF` | | ||
67 | | High | `0xD8` | | ||
68 | | Extended | `0xFE` | | ||
diff --git a/keyboards/ploopyco/mouse/rules.mk b/keyboards/ploopyco/mouse/rules.mk new file mode 100644 index 000000000..d77431b67 --- /dev/null +++ b/keyboards/ploopyco/mouse/rules.mk | |||
@@ -0,0 +1,30 @@ | |||
1 | # MCU name | ||
2 | MCU = atmega32u4 | ||
3 | |||
4 | # Processor frequency | ||
5 | F_CPU = 8000000 | ||
6 | |||
7 | # Bootloader selection | ||
8 | BOOTLOADER = caterina | ||
9 | |||
10 | # Build Options | ||
11 | # change yes to no to disable | ||
12 | # | ||
13 | BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration | ||
14 | EXTRAKEY_ENABLE = yes # Audio control and System control | ||
15 | CONSOLE_ENABLE = yes # Console for debug | ||
16 | COMMAND_ENABLE = no # Commands for debug and configuration | ||
17 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | ||
18 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | ||
19 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | ||
20 | NKRO_ENABLE = no # USB Nkey Rollover | ||
21 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality | ||
22 | RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow | ||
23 | UNICODE_ENABLE = no # Unicode | ||
24 | BLUETOOTH_ENABLE = no # Enable Bluetooth | ||
25 | AUDIO_ENABLE = no # Audio output | ||
26 | POINTING_DEVICE_ENABLE = yes | ||
27 | MOUSEKEY_ENABLE = no # Mouse keys | ||
28 | |||
29 | QUANTUM_LIB_SRC += analog.c spi_master.c | ||
30 | SRC += pmw3600.c opt_encoder.c | ||