Arduino Function: USBHost.Mouse.mouseReleased

Description

mouseReleased() is a function that is called whenever a button on a connected USB mouse is released.

Syntax

void mouseReleased(){
//statements
}

Examples

#include 

// 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();
}


Based on the reference originally written by Arduino Community,  wiring.org.co and  arduino.cc