From 6cc9513ab0cd5e21354c51ab83a89af9f2eb517e Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 13 Nov 2022 10:28:11 +1100 Subject: Digitizer feature improvements (#19034) --- quantum/digitizer.h | 67 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 11 deletions(-) (limited to 'quantum/digitizer.h') diff --git a/quantum/digitizer.h b/quantum/digitizer.h index cef551567e..b826ba8ac8 100644 --- a/quantum/digitizer.h +++ b/quantum/digitizer.h @@ -17,25 +17,70 @@ #include "quantum.h" +#include #include -enum digitizer_status { DZ_INITIALIZED = 1, DZ_UPDATED = 2 }; +/** + * \defgroup digitizer + * + * HID Digitizer + * \{ + */ typedef struct { - int8_t tipswitch; - int8_t inrange; - uint8_t id; - float x; - float y; - uint8_t status : 2; + bool in_range : 1; + bool tip : 1; + bool barrel : 1; + float x; + float y; + bool dirty; } digitizer_t; -extern digitizer_t digitizer; +extern digitizer_t digitizer_state; -digitizer_t digitizer_get_report(void); +/** + * \brief Send the digitizer report to the host if it is marked as dirty. + */ +void digitizer_flush(void); -void digitizer_set_report(digitizer_t newDigitizerReport); +/** + * \brief Assert the "in range" indicator, and flush the report. + */ +void digitizer_in_range_on(void); -void digitizer_task(void); +/** + * \brief Deassert the "in range" indicator, and flush the report. + */ +void digitizer_in_range_off(void); + +/** + * \brief Assert the tip switch, and flush the report. + */ +void digitizer_tip_switch_on(void); + +/** + * \brief Deassert the tip switch, and flush the report. + */ +void digitizer_tip_switch_off(void); + +/** + * \brief Assert the barrel switch, and flush the report. + */ +void digitizer_barrel_switch_on(void); + +/** + * \brief Deassert the barrel switch, and flush the report. + */ +void digitizer_barrel_switch_off(void); + +/** + * \brief Set the absolute X and Y position of the digitizer contact, and flush the report. + * + * \param x The X value of the contact position, from 0 to 1. + * \param y The Y value of the contact position, from 0 to 1. + */ +void digitizer_set_position(float x, float y); void host_digitizer_send(digitizer_t *digitizer); + +/** \} */ -- cgit v1.2.3