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 move(int x, int y, signed char wheel = 0);
|
||||||
inline void press(uint8_t b = MOUSE_LEFT);
|
inline void press(uint8_t b = MOUSE_LEFT);
|
||||||
inline void release(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);
|
inline bool isPressed(uint8_t b = MOUSE_LEFT);
|
||||||
|
|
||||||
// Sending is public in the base class for advanced users.
|
// Sending is public in the base class for advanced users.
|
||||||
virtual void SendReport(void* data, int length) = 0;
|
virtual void SendReport(void* data, int length) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Implementation is inline
|
// Implementation is inline
|
||||||
#include "AbsoluteMouseAPI.hpp"
|
#include "AbsoluteMouseAPI.hpp"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ void AbsoluteMouseAPI::buttons(uint8_t b){
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t AbsoluteMouseAPI::qadd16(int16_t base, int16_t increment) {
|
int16_t AbsoluteMouseAPI::qadd16(int16_t base, int16_t increment) {
|
||||||
// Separate between subtracting and adding
|
// Separate between subtracting and adding
|
||||||
if (increment < 0) {
|
if (increment < 0) {
|
||||||
// Subtracting more would cause an undefined overflow
|
// Subtracting more would cause an undefined overflow
|
||||||
if ((int16_t)0x8000 - increment > base)
|
if ((int16_t)0x8000 - increment > base)
|
||||||
|
|
@ -50,7 +50,7 @@ int16_t AbsoluteMouseAPI::qadd16(int16_t base, int16_t increment) {
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
|
|
||||||
AbsoluteMouseAPI::AbsoluteMouseAPI(void):
|
AbsoluteMouseAPI::AbsoluteMouseAPI(void):
|
||||||
xAxis(0), yAxis(0), _buttons(0)
|
xAxis(0), yAxis(0), _buttons(0)
|
||||||
{
|
{
|
||||||
// Empty
|
// Empty
|
||||||
|
|
@ -98,6 +98,11 @@ void AbsoluteMouseAPI::release(uint8_t b){
|
||||||
buttons(_buttons & ~b);
|
buttons(_buttons & ~b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AbsoluteMouseAPI::releaseAll(void){
|
||||||
|
_buttons = 0;
|
||||||
|
moveTo(xAxis, yAxis, 0);
|
||||||
|
}
|
||||||
|
|
||||||
bool AbsoluteMouseAPI::isPressed(uint8_t b){
|
bool AbsoluteMouseAPI::isPressed(uint8_t b){
|
||||||
// check LEFT by default
|
// check LEFT by default
|
||||||
if ((b & _buttons) > 0)
|
if ((b & _buttons) > 0)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue