Added releaseAll() for Mouse API
This commit is contained in:
parent
3a71aaeb72
commit
d3147adbfd
2 changed files with 14 additions and 8 deletions
|
|
@ -70,14 +70,15 @@ public:
|
||||||
inline void begin(void);
|
inline void begin(void);
|
||||||
inline void end(void);
|
inline void end(void);
|
||||||
inline void click(uint8_t b = MOUSE_LEFT);
|
inline void click(uint8_t b = MOUSE_LEFT);
|
||||||
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.
|
||||||
virtual void SendReport(void* data, int length) = 0;
|
virtual void SendReport(void* data, int length) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint8_t _buttons;
|
uint8_t _buttons;
|
||||||
inline void buttons(uint8_t b);
|
inline void buttons(uint8_t b);
|
||||||
|
|
|
||||||
|
|
@ -29,12 +29,12 @@ MouseAPI::MouseAPI(void) : _buttons(0)
|
||||||
// Empty
|
// Empty
|
||||||
}
|
}
|
||||||
|
|
||||||
void MouseAPI::begin(void)
|
void MouseAPI::begin(void)
|
||||||
{
|
{
|
||||||
end();
|
end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MouseAPI::end(void)
|
void MouseAPI::end(void)
|
||||||
{
|
{
|
||||||
_buttons = 0;
|
_buttons = 0;
|
||||||
move(0, 0, 0);
|
move(0, 0, 0);
|
||||||
|
|
@ -67,7 +67,7 @@ void MouseAPI::buttons(uint8_t b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MouseAPI::press(uint8_t b)
|
void MouseAPI::press(uint8_t b)
|
||||||
{
|
{
|
||||||
buttons(_buttons | b);
|
buttons(_buttons | b);
|
||||||
}
|
}
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue