Added releaseAll() for Mouse API

This commit is contained in:
NicoHood 2016-03-05 17:58:16 +01:00
parent 3a71aaeb72
commit d3147adbfd
2 changed files with 14 additions and 8 deletions

View file

@ -73,6 +73,7 @@ public:
inline void move(signed char x, signed char y, signed char wheel = 0); inline void move(signed char x, signed char y, signed char wheel = 0);
inline void press(uint8_t b = MOUSE_LEFT); // press LEFT by default inline void press(uint8_t b = MOUSE_LEFT); // press LEFT by default
inline void release(uint8_t b = MOUSE_LEFT); // release LEFT by default inline void release(uint8_t b = MOUSE_LEFT); // release LEFT by default
inline void releaseAll(void);
inline bool isPressed(uint8_t b = MOUSE_LEFT); // check LEFT by default inline bool isPressed(uint8_t b = MOUSE_LEFT); // check LEFT by default
// Sending is public in the base class for advanced users. // Sending is public in the base class for advanced users.

View file

@ -77,10 +77,15 @@ void MouseAPI::release(uint8_t b)
buttons(_buttons & ~b); buttons(_buttons & ~b);
} }
void MouseAPI::releaseAll(void)
{
_buttons = 0;
move(0,0,0);
}
bool MouseAPI::isPressed(uint8_t b) bool MouseAPI::isPressed(uint8_t b)
{ {
if ((b & _buttons) > 0) if ((b & _buttons) > 0)
return true; return true;
return false; return false;
} }