Arduino Due Mouse Controller

Hello,

I'm new to this. I am trying to read out the mouse position using Arduino Due.I am using a Logitech M100 mouse, and the code from here http://arduino.cc/en/Tutorial/MouseController . I am pasting it again for convenience.

*
 Mouse Controller Example

 Shows the output of a USB Mouse connected to 
 the Native USB port on an Arduino Due Board.

 created 8 Oct 2012
 by Cristian Maglie

 http://arduino.cc/en/Tutorial/MouseController

 This samlple code is part of the public domain.
 */

// Require mouse control library
#include <MouseController.h>

// Initialize USB Controller
USBHost usb;

// Attach mouse controller to USB
MouseController mouse(usb);

// variables for mouse button states
boolean leftButton = false;
boolean middleButton = false;
boolean rightButton = false;

// This function intercepts mouse movements
void mouseMoved() {
  Serial.print("Move: ");
  Serial.print(mouse.getXChange());
  Serial.print(", ");
  Serial.println(mouse.getYChange());
}

// This function intercepts mouse movements while a button is pressed
void mouseDragged() {
  Serial.print("DRAG: ");
  Serial.print(mouse.getXChange());
  Serial.print(", ");
  Serial.println(mouse.getYChange());
}

// This function intercepts mouse button press
void mousePressed() {
  Serial.print("Pressed: ");
  if (mouse.getButton(LEFT_BUTTON)){
    Serial.print("L");
    leftButton = true;
  }
  if (mouse.getButton(MIDDLE_BUTTON)){
    Serial.print("M");
    middleButton = true;
  }
  if (mouse.getButton(RIGHT_BUTTON)){
    Serial.print("R");
    Serial.println();
    rightButton = true;
  }
}

// This function intercepts mouse button release
void mouseReleased() {
  Serial.print("Released: ");
  if (!mouse.getButton(LEFT_BUTTON) && left==true) {
    Serial.print("L");
    leftButton = false;
  }
  if (!mouse.getButton(MIDDLE_BUTTON) && middle==true) {
    Serial.print("M");
    middleButton = false;
  }
  if (!mouse.getButton(RIGHT_BUTTON) && right==true) {
    Serial.print("R");
    rightButton = false;
  }
  Serial.println();
}

void setup()
{
  Serial.begin(9600);
  Serial.println("Program started");
  delay(200);
}

void loop()
{
  // Process USB tasks
  usb.Task();
}

I don't know how to find the header file mousecontroller.h which needs to be included. Moreover I get the following errors

sketch_jun02a:19: error: 'USBHost' does not name a type
sketch_jun02a:22: error: 'MouseController' does not name a type
sketch_jun02a.ino: In function 'void mouseMoved()':
sketch_jun02a:32: error: 'mouse' was not declared in this scope
sketch_jun02a.ino: In function 'void mouseDragged()':
sketch_jun02a:40: error: 'mouse' was not declared in this scope
sketch_jun02a.ino: In function 'void mousePressed()':
sketch_jun02a:48: error: 'mouse' was not declared in this scope
sketch_jun02a:48: error: 'LEFT_BUTTON' was not declared in this scope
sketch_jun02a:52: error: 'mouse' was not declared in this scope
sketch_jun02a:52: error: 'MIDDLE_BUTTON' was not declared in this scope
sketch_jun02a:56: error: 'mouse' was not declared in this scope
sketch_jun02a:56: error: 'RIGHT_BUTTON' was not declared in this scope
sketch_jun02a.ino: In function 'void mouseReleased()':
sketch_jun02a:66: error: 'mouse' was not declared in this scope
sketch_jun02a:66: error: 'LEFT_BUTTON' was not declared in this scope
sketch_jun02a:66: error: 'left' was not declared in this scope
sketch_jun02a:70: error: 'mouse' was not declared in this scope
sketch_jun02a:70: error: 'MIDDLE_BUTTON' was not declared in this scope
sketch_jun02a:70: error: 'middle' was not declared in this scope
sketch_jun02a:74: error: 'mouse' was not declared in this scope
sketch_jun02a:74: error: 'RIGHT_BUTTON' was not declared in this scope
sketch_jun02a:74: error: 'right' was not declared in this scope
sketch_jun02a.ino: In function 'void loop()':
sketch_jun02a:91: error: 'usb' was not declared in this scope
sketch_jun02a.ino: At global scope:
sketch_jun02a:94: error: expected declaration before '}' token

This is my first project with Arduino Due. Help will be so much appreciated! :slight_smile:

What version of the IDE are you using? Have you selected the correct board?

Do you have the correct libs downloaded?

Mark

I selected programming port Due. I am using 1.5.2.

I can't find this header file called MouseController.h
I went to the library, http://arduino.cc/en/Reference/MouseKeyboard. But I don't see the header file.

And, should i just save all these as pde files in the library? Any suggestions? Thanks so much.

And, should i just save all these as pde files in the library?

All these what? There are no pde files used in the edit/compile/link/upload process for a Due. Only ino, cpp, and h.