[gnoduino: 141/237] added Mouse.isPressed() method
- From: Lucian Langa <lucilanga src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnoduino: 141/237] added Mouse.isPressed() method
- Date: Sat, 31 Mar 2012 20:26:41 +0000 (UTC)
commit 59c1dd2154e384a57777efe6188847d67b2a5df1
Author: Zach Eveland <zeveland blacklabel-development com>
Date: Fri Sep 16 16:59:14 2011 -0400
added Mouse.isPressed() method
arduino/cores/arduino/HID.cpp | 7 +++++++
arduino/cores/arduino/USBAPI.h | 2 ++
2 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/arduino/cores/arduino/HID.cpp b/arduino/cores/arduino/HID.cpp
index 16d0448..8ed1566 100644
--- a/arduino/cores/arduino/HID.cpp
+++ b/arduino/cores/arduino/HID.cpp
@@ -243,6 +243,13 @@ void Mouse_::release(uint8_t b)
buttons(_buttons & ~b);
}
+bool Mouse_::isPressed(uint8_t b)
+{
+ if (b & _buttons > 0)
+ return true;
+ return false;
+}
+
//================================================================================
//================================================================================
// Keyboard
diff --git a/arduino/cores/arduino/USBAPI.h b/arduino/cores/arduino/USBAPI.h
index 759079b..26a2032 100644
--- a/arduino/cores/arduino/USBAPI.h
+++ b/arduino/cores/arduino/USBAPI.h
@@ -46,6 +46,7 @@ extern Serial_ Serial;
#define MOUSE_LEFT 1
#define MOUSE_RIGHT 2
#define MOUSE_MIDDLE 4
+#define MOUSE_ALL (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE)
class Mouse_
{
@@ -58,6 +59,7 @@ public:
void move(signed char x, signed char y, signed char wheel = 0);
void press(uint8_t b = MOUSE_LEFT); // press LEFT by default
void release(uint8_t b = MOUSE_LEFT); // release LEFT by default
+ bool isPressed(uint8_t b = MOUSE_ALL); // check all buttons by default
};
extern Mouse_ Mouse;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]