mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-12-07 03:53:31 +08:00
Add core handling for pointing device failures. (#25315)
This commit is contained in:
@@ -80,8 +80,10 @@ uint16_t pointing_device_get_shared_cpi(void) {
|
||||
|
||||
#endif // defined(SPLIT_POINTING_ENABLE)
|
||||
|
||||
static report_mouse_t local_mouse_report = {};
|
||||
static bool pointing_device_force_send = false;
|
||||
static report_mouse_t local_mouse_report = {};
|
||||
static bool pointing_device_force_send = false;
|
||||
static pointing_device_status_t pointing_device_status = POINTING_DEVICE_STATUS_UNKNOWN;
|
||||
|
||||
#ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE
|
||||
static uint16_t hires_scroll_resolution;
|
||||
#endif
|
||||
@@ -90,7 +92,9 @@ static uint16_t hires_scroll_resolution;
|
||||
#define POINTING_DEVICE_DRIVER(name) POINTING_DEVICE_DRIVER_CONCAT(name)
|
||||
|
||||
#ifdef POINTING_DEVICE_DRIVER_custom
|
||||
__attribute__((weak)) void pointing_device_driver_init(void) {}
|
||||
__attribute__((weak)) bool pointing_device_driver_init(void) {
|
||||
return false;
|
||||
}
|
||||
__attribute__((weak)) report_mouse_t pointing_device_driver_get_report(report_mouse_t mouse_report) {
|
||||
return mouse_report;
|
||||
}
|
||||
@@ -179,7 +183,11 @@ __attribute__((weak)) void pointing_device_init(void) {
|
||||
if ((POINTING_DEVICE_THIS_SIDE))
|
||||
#endif
|
||||
{
|
||||
pointing_device_driver->init();
|
||||
if (pointing_device_driver->init()) {
|
||||
pointing_device_status = POINTING_DEVICE_STATUS_SUCCESS;
|
||||
} else {
|
||||
pointing_device_status = POINTING_DEVICE_STATUS_INIT_FAILED;
|
||||
}
|
||||
#ifdef POINTING_DEVICE_MOTION_PIN
|
||||
# ifdef POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW
|
||||
gpio_set_pin_input_high(POINTING_DEVICE_MOTION_PIN);
|
||||
@@ -200,6 +208,28 @@ __attribute__((weak)) void pointing_device_init(void) {
|
||||
pointing_device_init_user();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets status of pointing device
|
||||
*
|
||||
* Returns current pointing device status
|
||||
* @return pointing_device_status_t
|
||||
*/
|
||||
__attribute__((weak)) pointing_device_status_t pointing_device_get_status(void) {
|
||||
#ifdef SPLIT_POINTING_ENABLE
|
||||
// Assume target side is always good, split transaction checksum should stop additional reports being generated.
|
||||
return POINTING_DEVICE_THIS_SIDE ? pointing_device_status : POINTING_DEVICE_STATUS_SUCCESS;
|
||||
#else
|
||||
return pointing_device_status;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets status of pointing device
|
||||
*/
|
||||
void pointing_device_set_status(pointing_device_status_t status) {
|
||||
pointing_device_status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sends processed mouse report to host
|
||||
*
|
||||
@@ -281,6 +311,10 @@ __attribute__((weak)) bool pointing_device_task(void) {
|
||||
last_exec = timer_read32();
|
||||
#endif
|
||||
|
||||
if (pointing_device_get_status() != POINTING_DEVICE_STATUS_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Gather report info
|
||||
#ifdef POINTING_DEVICE_MOTION_PIN
|
||||
# if defined(SPLIT_POINTING_ENABLE)
|
||||
|
||||
@@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include "report.h"
|
||||
|
||||
typedef struct {
|
||||
void (*init)(void);
|
||||
bool (*init)(void);
|
||||
report_mouse_t (*get_report)(report_mouse_t mouse_report);
|
||||
void (*set_cpi)(uint16_t);
|
||||
uint16_t (*get_cpi)(void);
|
||||
@@ -75,7 +75,7 @@ typedef struct {
|
||||
# include "drivers/sensors/pmw33xx_common.h"
|
||||
# define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW
|
||||
#else
|
||||
void pointing_device_driver_init(void);
|
||||
bool pointing_device_driver_init(void);
|
||||
report_mouse_t pointing_device_driver_get_report(report_mouse_t mouse_report);
|
||||
uint16_t pointing_device_driver_get_cpi(void);
|
||||
void pointing_device_driver_set_cpi(uint16_t cpi);
|
||||
@@ -92,6 +92,13 @@ typedef enum {
|
||||
POINTING_DEVICE_BUTTON8,
|
||||
} pointing_device_buttons_t;
|
||||
|
||||
typedef enum {
|
||||
POINTING_DEVICE_STATUS_UNKNOWN,
|
||||
POINTING_DEVICE_STATUS_INIT_FAILED,
|
||||
POINTING_DEVICE_STATUS_FAILED,
|
||||
POINTING_DEVICE_STATUS_SUCCESS,
|
||||
} pointing_device_status_t;
|
||||
|
||||
#ifdef MOUSE_EXTENDED_REPORT
|
||||
typedef int32_t xy_clamp_range_t;
|
||||
#else
|
||||
@@ -107,13 +114,15 @@ typedef int16_t hv_clamp_range_t;
|
||||
#define CONSTRAIN_HID(amt) ((amt) < INT8_MIN ? INT8_MIN : ((amt) > INT8_MAX ? INT8_MAX : (amt)))
|
||||
#define CONSTRAIN_HID_XY(amt) ((amt) < MOUSE_REPORT_XY_MIN ? MOUSE_REPORT_XY_MIN : ((amt) > MOUSE_REPORT_XY_MAX ? MOUSE_REPORT_XY_MAX : (amt)))
|
||||
|
||||
void pointing_device_init(void);
|
||||
bool pointing_device_task(void);
|
||||
bool pointing_device_send(void);
|
||||
report_mouse_t pointing_device_get_report(void);
|
||||
void pointing_device_set_report(report_mouse_t mouse_report);
|
||||
uint16_t pointing_device_get_cpi(void);
|
||||
void pointing_device_set_cpi(uint16_t cpi);
|
||||
void pointing_device_init(void);
|
||||
bool pointing_device_task(void);
|
||||
bool pointing_device_send(void);
|
||||
report_mouse_t pointing_device_get_report(void);
|
||||
void pointing_device_set_report(report_mouse_t mouse_report);
|
||||
uint16_t pointing_device_get_cpi(void);
|
||||
void pointing_device_set_cpi(uint16_t cpi);
|
||||
pointing_device_status_t pointing_device_get_status(void);
|
||||
void pointing_device_set_status(pointing_device_status_t status);
|
||||
|
||||
void pointing_device_init_kb(void);
|
||||
void pointing_device_init_user(void);
|
||||
|
||||
Reference in New Issue
Block a user