Weblessons.org
Home Page | Language Reference| extended() | SD Reference | Libraries | Comparison | Changes
USBHost :
MouseController class
mouseReleased()
Description
mouseReleased() is a function that is called whenever a button on a connected USB mouse is released.
Syntax
void mouseReleased(
)
{
//statements
}
Example
#include <MouseController.h>
// Initialize USB Controller
USBHost usb;
// Attach mouse controller to USB
MouseController mouse(usb)
;
boolean left =
false
;
boolean middle =
false
;
boolean right =
false
;
void mousePressed(
)
{
if
(mouse.getButton
(LEFT_BUTTON)
)
left =
true
;
if
(mouse.getButton
(MIDDLE_BUTTON)
)
middle =
true
;
if
(mouse.getButton
(RIGHT_BUTTON)
)
right =
true
;
}
// This function intercepts mouse button release
void mouseReleased(
)
{
Serial.print
(
"Released: "
)
;
if
(
!mouse.getButton
(LEFT_BUTTON)
&& left==
true
)
{
Serial.print
(
"L"
)
;
left =
false
;
}
if
(
!mouse.getButton
(MIDDLE_BUTTON)
&& middle==
true
)
{
Serial.print
(
"M"
)
;
middle =
false
;
}
if
(
!mouse.getButton
(RIGHT_BUTTON)
&& right==
true
)
{
Serial.print
(
"R"
)
;
right =
false
;
}
Serial.println
(
)
;
}
void
setup
(
)
{
Serial.begin
(
9600
)
;
}
void
loop
(
)
{
usb.Task
(
)
;
}
See Also
Reference Home
The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.