1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-04 15:24:12 +01:00
Arduino/hardware/arduino/sam/libraries/USBHost/examples/MouseController/MouseController.ino

52 lines
964 B
Arduino
Raw Normal View History

2012-09-21 17:24:48 +02:00
// Require mouse control library
#include <MouseController.h>
// Initialize USB Controller
USBHost usb;
// Attach mouse controller to USB
MouseController mouse(usb);
// This function intercepts mouse movements
void mouseMoved() {
Serial1.print("Moving mouse: ");
Serial1.print(mouseX);
Serial1.print(", ");
Serial1.println(mouseY);
}
// This function intercepts mouse movements when a button is pressed
void mouseDragged() {
Serial1.print("DRAG: ");
Serial1.print(mouseX);
Serial1.print(", ");
Serial1.println(mouseY);
}
// This function intercepts mouse button press
void mousePressed() {
Serial1.print("Pressed: ");
Serial1.println(mouseButton);
}
// This function intercepts mouse button release
void mouseReleased() {
Serial1.print("Released: ");
Serial1.println(mouseButton);
}
void setup()
{
Serial1.begin(115200);
Serial1.println("Program started");
delay(200);
}
void loop()
{
// Process USB tasks
usb.Task();
}