summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Kerkmann <karlk90@pm.me>2022-08-29 19:16:49 +0200
committerGitHub <noreply@github.com>2022-08-29 19:16:49 +0200
commite99ec28f5fffc41ce2662e883f7e9b56383d758b (patch)
tree121c7473da8a04ebffa8d848bdaca22b7b3ec5e6
parentd910e8df77150bab0b9cc2c3794554b4c8c81d71 (diff)
[Core] Introduce pointing device specific debug messages (#17663)
-rw-r--r--docs/feature_pointing_device.md10
-rw-r--r--drivers/sensors/cirque_pinnacle.c8
-rw-r--r--drivers/sensors/cirque_pinnacle.h1
-rw-r--r--drivers/sensors/cirque_pinnacle_i2c.c10
-rw-r--r--drivers/sensors/cirque_pinnacle_spi.c10
-rw-r--r--drivers/sensors/pimoroni_trackball.c21
-rw-r--r--drivers/sensors/pmw33xx_common.c13
-rw-r--r--quantum/pointing_device/pointing_device_drivers.c22
-rw-r--r--quantum/pointing_device_internal.h14
9 files changed, 50 insertions, 59 deletions
diff --git a/docs/feature_pointing_device.md b/docs/feature_pointing_device.md
index 999dd1272d..afc57ed493 100644
--- a/docs/feature_pointing_device.md
+++ b/docs/feature_pointing_device.md
@@ -487,3 +487,13 @@ report_mouse_t pointing_device_task_combined_user(report_mouse_t left_report, re
487 return pointing_device_combine_reports(left_report, right_report); 487 return pointing_device_combine_reports(left_report, right_report);
488} 488}
489``` 489```
490
491# Troubleshooting
492
493If you are having issues with pointing device drivers debug messages can be enabled that will give you insights in the inner workings. To enable these add to your keyboards `config.h` file:
494
495```c
496#define POINTING_DEVICE_DEBUG
497```
498
499?> The messages will be printed out to the `CONSOLE` output. For additional information, refer to [Debugging/Troubleshooting QMK](faq_debug.md).
diff --git a/drivers/sensors/cirque_pinnacle.c b/drivers/sensors/cirque_pinnacle.c
index 8bd4eb736e..4aed5fe67a 100644
--- a/drivers/sensors/cirque_pinnacle.c
+++ b/drivers/sensors/cirque_pinnacle.c
@@ -4,8 +4,6 @@
4// refer to documentation: Gen2 and Gen3 (Pinnacle ASIC) at https://www.cirque.com/documentation 4// refer to documentation: Gen2 and Gen3 (Pinnacle ASIC) at https://www.cirque.com/documentation
5 5
6#include "cirque_pinnacle.h" 6#include "cirque_pinnacle.h"
7#include "print.h"
8#include "debug.h"
9#include "wait.h" 7#include "wait.h"
10#include "timer.h" 8#include "timer.h"
11 9
@@ -27,12 +25,6 @@ void cirque_pinnacle_enable_feed(bool feedEnable);
27void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count); 25void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count);
28void RAP_Write(uint8_t address, uint8_t data); 26void RAP_Write(uint8_t address, uint8_t data);
29 27
30#ifdef CONSOLE_ENABLE
31void print_byte(uint8_t byte) {
32 xprintf("%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'));
33}
34#endif
35
36#if CIRQUE_PINNACLE_POSITION_MODE 28#if CIRQUE_PINNACLE_POSITION_MODE
37/* Logical Scaling Functions */ 29/* Logical Scaling Functions */
38// Clips raw coordinates to "reachable" window of sensor 30// Clips raw coordinates to "reachable" window of sensor
diff --git a/drivers/sensors/cirque_pinnacle.h b/drivers/sensors/cirque_pinnacle.h
index fa06e047f2..8717b32991 100644
--- a/drivers/sensors/cirque_pinnacle.h
+++ b/drivers/sensors/cirque_pinnacle.h
@@ -5,6 +5,7 @@
5#include "cirque_pinnacle_regdefs.h" 5#include "cirque_pinnacle_regdefs.h"
6#include <stdint.h> 6#include <stdint.h>
7#include <stdbool.h> 7#include <stdbool.h>
8#include "pointing_device_internal.h"
8 9
9#ifndef CIRQUE_PINNACLE_TIMEOUT 10#ifndef CIRQUE_PINNACLE_TIMEOUT
10# define CIRQUE_PINNACLE_TIMEOUT 20 // I2C timeout in milliseconds 11# define CIRQUE_PINNACLE_TIMEOUT 20 // I2C timeout in milliseconds
diff --git a/drivers/sensors/cirque_pinnacle_i2c.c b/drivers/sensors/cirque_pinnacle_i2c.c
index b328dd9a7a..3c11e5f079 100644
--- a/drivers/sensors/cirque_pinnacle_i2c.c
+++ b/drivers/sensors/cirque_pinnacle_i2c.c
@@ -1,8 +1,6 @@
1// Copyright (c) 2018 Cirque Corp. Restrictions apply. See: www.cirque.com/sw-license 1// Copyright (c) 2018 Cirque Corp. Restrictions apply. See: www.cirque.com/sw-license
2#include "cirque_pinnacle.h" 2#include "cirque_pinnacle.h"
3#include "i2c_master.h" 3#include "i2c_master.h"
4#include "print.h"
5#include "debug.h"
6#include "stdio.h" 4#include "stdio.h"
7 5
8// Masks for Cirque Register Access Protocol (RAP) 6// Masks for Cirque Register Access Protocol (RAP)
@@ -18,9 +16,7 @@ void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) {
18 if (touchpad_init) { 16 if (touchpad_init) {
19 i2c_writeReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, NULL, 0, CIRQUE_PINNACLE_TIMEOUT); 17 i2c_writeReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, NULL, 0, CIRQUE_PINNACLE_TIMEOUT);
20 if (i2c_readReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, data, count, CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) { 18 if (i2c_readReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, data, count, CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) {
21#ifdef CONSOLE_ENABLE 19 pd_dprintf("error cirque_pinnacle i2c_readReg\n");
22 dprintf("error cirque_pinnacle i2c_readReg\n");
23#endif
24 touchpad_init = false; 20 touchpad_init = false;
25 } 21 }
26 i2c_stop(); 22 i2c_stop();
@@ -33,9 +29,7 @@ void RAP_Write(uint8_t address, uint8_t data) {
33 29
34 if (touchpad_init) { 30 if (touchpad_init) {
35 if (i2c_writeReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, &data, sizeof(data), CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) { 31 if (i2c_writeReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, &data, sizeof(data), CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) {
36#ifdef CONSOLE_ENABLE 32 pd_dprintf("error cirque_pinnacle i2c_writeReg\n");
37 dprintf("error cirque_pinnacle i2c_writeReg\n");
38#endif
39 touchpad_init = false; 33 touchpad_init = false;
40 } 34 }
41 i2c_stop(); 35 i2c_stop();
diff --git a/drivers/sensors/cirque_pinnacle_spi.c b/drivers/sensors/cirque_pinnacle_spi.c
index bd980fc863..5cb39aebb0 100644
--- a/drivers/sensors/cirque_pinnacle_spi.c
+++ b/drivers/sensors/cirque_pinnacle_spi.c
@@ -1,8 +1,6 @@
1// Copyright (c) 2018 Cirque Corp. Restrictions apply. See: www.cirque.com/sw-license 1// Copyright (c) 2018 Cirque Corp. Restrictions apply. See: www.cirque.com/sw-license
2#include "cirque_pinnacle.h" 2#include "cirque_pinnacle.h"
3#include "spi_master.h" 3#include "spi_master.h"
4#include "print.h"
5#include "debug.h"
6 4
7// Masks for Cirque Register Access Protocol (RAP) 5// Masks for Cirque Register Access Protocol (RAP)
8#define WRITE_MASK 0x80 6#define WRITE_MASK 0x80
@@ -24,9 +22,7 @@ void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) {
24 data[i] = spi_write(FILLER_BYTE); // write filler, receive data on the third filler send 22 data[i] = spi_write(FILLER_BYTE); // write filler, receive data on the third filler send
25 } 23 }
26 } else { 24 } else {
27#ifdef CONSOLE_ENABLE 25 pd_dprintf("error cirque_pinnacle spi_start read\n");
28 dprintf("error cirque_pinnacle spi_start read\n");
29#endif
30 touchpad_init = false; 26 touchpad_init = false;
31 } 27 }
32 spi_stop(); 28 spi_stop();
@@ -42,9 +38,7 @@ void RAP_Write(uint8_t address, uint8_t data) {
42 spi_write(cmdByte); 38 spi_write(cmdByte);
43 spi_write(data); 39 spi_write(data);
44 } else { 40 } else {
45#ifdef CONSOLE_ENABLE 41 pd_dprintf("error cirque_pinnacle spi_start write\n");
46 dprintf("error cirque_pinnacle spi_start write\n");
47#endif
48 touchpad_init = false; 42 touchpad_init = false;
49 } 43 }
50 spi_stop(); 44 spi_stop();
diff --git a/drivers/sensors/pimoroni_trackball.c b/drivers/sensors/pimoroni_trackball.c
index 88a351316b..326e59744f 100644
--- a/drivers/sensors/pimoroni_trackball.c
+++ b/drivers/sensors/pimoroni_trackball.c
@@ -14,10 +14,10 @@
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17
18#include "pointing_device_internal.h"
17#include "pimoroni_trackball.h" 19#include "pimoroni_trackball.h"
18#include "i2c_master.h" 20#include "i2c_master.h"
19#include "print.h"
20#include "debug.h"
21#include "timer.h" 21#include "timer.h"
22 22
23// clang-format off 23// clang-format off
@@ -58,20 +58,17 @@ void pimoroni_trackball_set_rgbw(uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
58 uint8_t data[4] = {r, g, b, w}; 58 uint8_t data[4] = {r, g, b, w};
59 __attribute__((unused)) i2c_status_t status = i2c_writeReg(PIMORONI_TRACKBALL_ADDRESS << 1, PIMORONI_TRACKBALL_REG_LED_RED, data, sizeof(data), PIMORONI_TRACKBALL_TIMEOUT); 59 __attribute__((unused)) i2c_status_t status = i2c_writeReg(PIMORONI_TRACKBALL_ADDRESS << 1, PIMORONI_TRACKBALL_REG_LED_RED, data, sizeof(data), PIMORONI_TRACKBALL_TIMEOUT);
60 60
61#ifdef CONSOLE_ENABLE 61 pd_dprintf("Trackball RGBW i2c_status_t: %d\n", status);
62 if (debug_mouse) dprintf("Trackball RGBW i2c_status_t: %d\n", status);
63#endif
64} 62}
65 63
66i2c_status_t read_pimoroni_trackball(pimoroni_data_t* data) { 64i2c_status_t read_pimoroni_trackball(pimoroni_data_t* data) {
67 i2c_status_t status = i2c_readReg(PIMORONI_TRACKBALL_ADDRESS << 1, PIMORONI_TRACKBALL_REG_LEFT, (uint8_t*)data, sizeof(*data), PIMORONI_TRACKBALL_TIMEOUT); 65 i2c_status_t status = i2c_readReg(PIMORONI_TRACKBALL_ADDRESS << 1, PIMORONI_TRACKBALL_REG_LEFT, (uint8_t*)data, sizeof(*data), PIMORONI_TRACKBALL_TIMEOUT);
68#ifdef CONSOLE_ENABLE 66
69 if (debug_mouse) { 67#ifdef POINTING_DEVICE_DEBUG
70 static uint16_t d_timer; 68 static uint16_t d_timer;
71 if (timer_elapsed(d_timer) > PIMORONI_TRACKBALL_DEBUG_INTERVAL) { 69 if (timer_elapsed(d_timer) > PIMORONI_TRACKBALL_DEBUG_INTERVAL) {
72 dprintf("Trackball READ i2c_status_t: %d L: %d R: %d Up: %d D: %d SW: %d\n", status, data->left, data->right, data->up, data->down, data->click); 70 pd_dprintf("Trackball READ i2c_status_t: %d L: %d R: %d Up: %d D: %d SW: %d\n", status, data->left, data->right, data->up, data->down, data->click);
73 d_timer = timer_read(); 71 d_timer = timer_read();
74 }
75 } 72 }
76#endif 73#endif
77 74
diff --git a/drivers/sensors/pmw33xx_common.c b/drivers/sensors/pmw33xx_common.c
index 13164cb150..4993cc2d34 100644
--- a/drivers/sensors/pmw33xx_common.c
+++ b/drivers/sensors/pmw33xx_common.c
@@ -7,9 +7,8 @@
7// Copyright 2020 Ploopy Corporation 7// Copyright 2020 Ploopy Corporation
8// SPDX-License-Identifier: GPL-2.0-or-later 8// SPDX-License-Identifier: GPL-2.0-or-later
9 9
10#include "debug.h" 10#include "pointing_device_internal.h"
11#include "pmw33xx_common.h" 11#include "pmw33xx_common.h"
12#include "print.h"
13#include "string.h" 12#include "string.h"
14#include "wait.h" 13#include "wait.h"
15#include "spi_master.h" 14#include "spi_master.h"
@@ -154,7 +153,7 @@ bool pmw33xx_init(uint8_t sensor) {
154 pmw33xx_read(sensor, REG_Delta_Y_H); 153 pmw33xx_read(sensor, REG_Delta_Y_H);
155 154
156 if (!pmw33xx_upload_firmware(sensor)) { 155 if (!pmw33xx_upload_firmware(sensor)) {
157 dprintf("PMW33XX (%d): firmware upload failed!\n", sensor); 156 pd_dprintf("PMW33XX (%d): firmware upload failed!\n", sensor);
158 return false; 157 return false;
159 } 158 }
160 159
@@ -170,7 +169,7 @@ bool pmw33xx_init(uint8_t sensor) {
170 pmw33xx_write(sensor, REG_Lift_Config, PMW33XX_LIFTOFF_DISTANCE); 169 pmw33xx_write(sensor, REG_Lift_Config, PMW33XX_LIFTOFF_DISTANCE);
171 170
172 if (!pmw33xx_check_signature(sensor)) { 171 if (!pmw33xx_check_signature(sensor)) {
173 dprintf("PMW33XX (%d): firmware signature verification failed!\n", sensor); 172 pd_dprintf("PMW33XX (%d): firmware signature verification failed!\n", sensor);
174 return false; 173 return false;
175 } 174 }
176 175
@@ -185,7 +184,7 @@ pmw33xx_report_t pmw33xx_read_burst(uint8_t sensor) {
185 } 184 }
186 185
187 if (!in_burst[sensor]) { 186 if (!in_burst[sensor]) {
188 dprintf("PMW33XX (%d): burst\n", sensor); 187 pd_dprintf("PMW33XX (%d): burst\n", sensor);
189 if (!pmw33xx_write(sensor, REG_Motion_Burst, 0x00)) { 188 if (!pmw33xx_write(sensor, REG_Motion_Burst, 0x00)) {
190 return report; 189 return report;
191 } 190 }
@@ -208,9 +207,7 @@ pmw33xx_report_t pmw33xx_read_burst(uint8_t sensor) {
208 207
209 spi_stop(); 208 spi_stop();
210 209
211 if (debug_config.mouse) { 210 pd_dprintf("PMW33XX (%d): motion: 0x%x dx: %i dy: %i\n", sensor, report.motion.w, report.delta_x, report.delta_y);
212 dprintf("PMW33XX (%d): motion: 0x%x dx: %i dy: %i\n", sensor, report.motion.w, report.delta_x, report.delta_y);
213 }
214 211
215 report.delta_x *= -1; 212 report.delta_x *= -1;
216 report.delta_y *= -1; 213 report.delta_y *= -1;
diff --git a/quantum/pointing_device/pointing_device_drivers.c b/quantum/pointing_device/pointing_device_drivers.c
index b96f8ff4b3..096ad5d028 100644
--- a/quantum/pointing_device/pointing_device_drivers.c
+++ b/quantum/pointing_device/pointing_device_drivers.c
@@ -17,6 +17,7 @@
17 */ 17 */
18 18
19#include "pointing_device.h" 19#include "pointing_device.h"
20#include "pointing_device_internal.h"
20#include "debug.h" 21#include "debug.h"
21#include "wait.h" 22#include "wait.h"
22#include "timer.h" 23#include "timer.h"
@@ -32,10 +33,7 @@ report_mouse_t adns5050_get_report(report_mouse_t mouse_report) {
32 report_adns5050_t data = adns5050_read_burst(); 33 report_adns5050_t data = adns5050_read_burst();
33 34
34 if (data.dx != 0 || data.dy != 0) { 35 if (data.dx != 0 || data.dy != 0) {
35# ifdef CONSOLE_ENABLE 36 pd_dprintf("Raw ] X: %d, Y: %d\n", data.dx, data.dy);
36 if (debug_mouse) dprintf("Raw ] X: %d, Y: %d\n", data.dx, data.dy);
37# endif
38
39 mouse_report.x = (mouse_xy_report_t)data.dx; 37 mouse_report.x = (mouse_xy_report_t)data.dx;
40 mouse_report.y = (mouse_xy_report_t)data.dy; 38 mouse_report.y = (mouse_xy_report_t)data.dy;
41 } 39 }
@@ -76,9 +74,7 @@ const pointing_device_driver_t pointing_device_driver = {
76report_mouse_t analog_joystick_get_report(report_mouse_t mouse_report) { 74report_mouse_t analog_joystick_get_report(report_mouse_t mouse_report) {
77 report_analog_joystick_t data = analog_joystick_read(); 75 report_analog_joystick_t data = analog_joystick_read();
78 76
79# ifdef CONSOLE_ENABLE 77 pd_dprintf("Raw ] X: %d, Y: %d\n", data.x, data.y);
80 if (debug_mouse) dprintf("Raw ] X: %d, Y: %d\n", data.x, data.y);
81# endif
82 78
83 mouse_report.x = data.x; 79 mouse_report.x = data.x;
84 mouse_report.y = data.y; 80 mouse_report.y = data.y;
@@ -140,11 +136,9 @@ report_mouse_t cirque_pinnacle_get_report(report_mouse_t mouse_report) {
140 return mouse_report; 136 return mouse_report;
141 } 137 }
142 138
143# if CONSOLE_ENABLE 139 if (touchData.touchDown) {
144 if (debug_mouse && touchData.touchDown) { 140 pd_dprintf("cirque_pinnacle touchData x=%4d y=%4d z=%2d\n", touchData.xValue, touchData.yValue, touchData.zValue);
145 dprintf("cirque_pinnacle touchData x=%4d y=%4d z=%2d\n", touchData.xValue, touchData.yValue, touchData.zValue);
146 } 141 }
147# endif
148 142
149 // Scale coordinates to arbitrary X, Y resolution 143 // Scale coordinates to arbitrary X, Y resolution
150 cirque_pinnacle_scale_data(&touchData, cirque_pinnacle_get_scale(), cirque_pinnacle_get_scale()); 144 cirque_pinnacle_scale_data(&touchData, cirque_pinnacle_get_scale(), cirque_pinnacle_get_scale());
@@ -227,9 +221,7 @@ const pointing_device_driver_t pointing_device_driver = {
227report_mouse_t paw3204_get_report(report_mouse_t mouse_report) { 221report_mouse_t paw3204_get_report(report_mouse_t mouse_report) {
228 report_paw3204_t data = paw3204_read(); 222 report_paw3204_t data = paw3204_read();
229 if (data.isMotion) { 223 if (data.isMotion) {
230# ifdef CONSOLE_ENABLE 224 pd_dprintf("Raw ] X: %d, Y: %d\n", data.x, data.y);
231 dprintf("Raw ] X: %d, Y: %d\n", data.x, data.y);
232# endif
233 225
234 mouse_report.x = data.x; 226 mouse_report.x = data.x;
235 mouse_report.y = data.y; 227 mouse_report.y = data.y;
@@ -329,7 +321,7 @@ report_mouse_t pmw33xx_get_report(report_mouse_t mouse_report) {
329 321
330 if (!in_motion) { 322 if (!in_motion) {
331 in_motion = true; 323 in_motion = true;
332 dprintf("PWM3360 (0): starting motion\n"); 324 pd_dprintf("PWM3360 (0): starting motion\n");
333 } 325 }
334 326
335 mouse_report.x = CONSTRAIN_HID_XY(report.delta_x); 327 mouse_report.x = CONSTRAIN_HID_XY(report.delta_x);
diff --git a/quantum/pointing_device_internal.h b/quantum/pointing_device_internal.h
new file mode 100644
index 0000000000..ef649407ca
--- /dev/null
+++ b/quantum/pointing_device_internal.h
@@ -0,0 +1,14 @@
1// Copyright 2022 Stefan Kerkmann
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#ifdef POINTING_DEVICE_DEBUG
7# include "debug.h"
8# include "print.h"
9# define pd_dprintf(...) dprintf(__VA_ARGS__)
10#else
11# define pd_dprintf(...) \
12 do { \
13 } while (0)
14#endif