diff options
author | Ryan <fauxpark@gmail.com> | 2022-11-13 10:28:11 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-12 23:28:11 +0000 |
commit | 6cc9513ab0cd5e21354c51ab83a89af9f2eb517e (patch) | |
tree | f997df9ea4a7e066b049c2e906ccb2529db6b5b7 /quantum/digitizer.c | |
parent | 8cecf7fad8614de2defd43f225250186cc517f38 (diff) |
Digitizer feature improvements (#19034)
Diffstat (limited to 'quantum/digitizer.c')
-rw-r--r-- | quantum/digitizer.c | 64 |
1 files changed, 51 insertions, 13 deletions
diff --git a/quantum/digitizer.c b/quantum/digitizer.c index 7925129d0c..f1b926181e 100644 --- a/quantum/digitizer.c +++ b/quantum/digitizer.c @@ -13,26 +13,64 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ + #include "digitizer.h" -digitizer_t digitizerReport = {.tipswitch = 0, .inrange = 0, .id = 0, .x = 0, .y = 0, .status = DZ_INITIALIZED}; +digitizer_t digitizer_state = { + .in_range = false, + .tip = false, + .barrel = false, + .x = 0, + .y = 0, + .dirty = false, +}; -__attribute__((weak)) void digitizer_send(void) { - if (digitizerReport.status & DZ_UPDATED) { - host_digitizer_send(&digitizerReport); - digitizerReport.status &= ~DZ_UPDATED; +void digitizer_flush(void) { + if (digitizer_state.dirty) { + host_digitizer_send(&digitizer_state); + digitizer_state.dirty = false; } } -__attribute__((weak)) void digitizer_task(void) { - digitizer_send(); +void digitizer_in_range_on(void) { + digitizer_state.in_range = true; + digitizer_state.dirty = true; + digitizer_flush(); +} + +void digitizer_in_range_off(void) { + digitizer_state.in_range = false; + digitizer_state.dirty = true; + digitizer_flush(); +} + +void digitizer_tip_switch_on(void) { + digitizer_state.tip = true; + digitizer_state.dirty = true; + digitizer_flush(); } -digitizer_t digitizer_get_report(void) { - return digitizerReport; +void digitizer_tip_switch_off(void) { + digitizer_state.tip = false; + digitizer_state.dirty = true; + digitizer_flush(); } -void digitizer_set_report(digitizer_t newDigitizerReport) { - digitizerReport = newDigitizerReport; - digitizerReport.status |= DZ_UPDATED; -}
\ No newline at end of file +void digitizer_barrel_switch_on(void) { + digitizer_state.barrel = true; + digitizer_state.dirty = true; + digitizer_flush(); +} + +void digitizer_barrel_switch_off(void) { + digitizer_state.barrel = false; + digitizer_state.dirty = true; + digitizer_flush(); +} + +void digitizer_set_position(float x, float y) { + digitizer_state.x = x; + digitizer_state.y = y; + digitizer_state.dirty = true; + digitizer_flush(); +} |