Added releaseAll() for abs Mouse
This commit is contained in:
parent
b33ff31253
commit
7c269d9749
2 changed files with 9 additions and 4 deletions
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue