Skip to content

Commit d532d85

Browse files
committed
added Mouse.isPressed() method
1 parent 00c3631 commit d532d85

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

hardware/arduino/cores/arduino/HID.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,13 @@ void Mouse_::release(uint8_t b)
243243
buttons(_buttons & ~b);
244244
}
245245

246+
bool Mouse_::isPressed(uint8_t b)
247+
{
248+
if (b & _buttons > 0)
249+
return true;
250+
return false;
251+
}
252+
246253
//================================================================================
247254
//================================================================================
248255
// Keyboard

hardware/arduino/cores/arduino/USBAPI.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ extern Serial_ Serial;
4646
#define MOUSE_LEFT 1
4747
#define MOUSE_RIGHT 2
4848
#define MOUSE_MIDDLE 4
49+
#define MOUSE_ALL (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE)
4950

5051
class Mouse_
5152
{
@@ -58,6 +59,7 @@ class Mouse_
5859
void move(signed char x, signed char y, signed char wheel = 0);
5960
void press(uint8_t b = MOUSE_LEFT); // press LEFT by default
6061
void release(uint8_t b = MOUSE_LEFT); // release LEFT by default
62+
bool isPressed(uint8_t b = MOUSE_ALL); // check all buttons by default
6163
};
6264
extern Mouse_ Mouse;
6365

0 commit comments

Comments
 (0)