From 7c269d9749222983e21a82aff841538111e9998f Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sat, 5 Mar 2016 18:02:50 +0100 Subject: [PATCH] Added releaseAll() for abs Mouse --- src/HID-APIs/AbsoluteMouseAPI.h | 4 ++-- src/HID-APIs/AbsoluteMouseAPI.hpp | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/HID-APIs/AbsoluteMouseAPI.h b/src/HID-APIs/AbsoluteMouseAPI.h index 37a6ee8..6f117e6 100644 --- a/src/HID-APIs/AbsoluteMouseAPI.h +++ b/src/HID-APIs/AbsoluteMouseAPI.h @@ -71,12 +71,12 @@ public: inline void move(int x, int y, signed char wheel = 0); inline void press(uint8_t b = MOUSE_LEFT); inline void release(uint8_t b = MOUSE_LEFT); + inline void releaseAll(void); inline bool isPressed(uint8_t b = MOUSE_LEFT); - + // Sending is public in the base class for advanced users. virtual void SendReport(void* data, int length) = 0; }; // Implementation is inline #include "AbsoluteMouseAPI.hpp" - diff --git a/src/HID-APIs/AbsoluteMouseAPI.hpp b/src/HID-APIs/AbsoluteMouseAPI.hpp index 23f736e..a561d19 100644 --- a/src/HID-APIs/AbsoluteMouseAPI.hpp +++ b/src/HID-APIs/AbsoluteMouseAPI.hpp @@ -32,7 +32,7 @@ void AbsoluteMouseAPI::buttons(uint8_t b){ } int16_t AbsoluteMouseAPI::qadd16(int16_t base, int16_t increment) { - // Separate between subtracting and adding + // Separate between subtracting and adding if (increment < 0) { // Subtracting more would cause an undefined overflow if ((int16_t)0x8000 - increment > base) @@ -50,7 +50,7 @@ int16_t AbsoluteMouseAPI::qadd16(int16_t base, int16_t increment) { return base; } -AbsoluteMouseAPI::AbsoluteMouseAPI(void): +AbsoluteMouseAPI::AbsoluteMouseAPI(void): xAxis(0), yAxis(0), _buttons(0) { // Empty @@ -98,6 +98,11 @@ void AbsoluteMouseAPI::release(uint8_t b){ buttons(_buttons & ~b); } +void AbsoluteMouseAPI::releaseAll(void){ + _buttons = 0; + moveTo(xAxis, yAxis, 0); +} + bool AbsoluteMouseAPI::isPressed(uint8_t b){ // check LEFT by default if ((b & _buttons) > 0)