Arduino DUE - receive, edit, send

Hey folks,
I am new to the ARDUINO community. I was able to gain some knowledge with an Adruino Micro, now that I am interested in editiing input device signals I ordered a DUE.
The DUE comes with in build host functinality and reading a connected Mouse for example was fun to watch and worked great.

Now I want to edit the received data and send it to the computer which gives me bit of a headache.
I googled quite a lot, tried different libiaries but I couldn't get anything to work.

What do I want to do?:
Basically I plug in my mouse into the default USB Port of the DUE, edit the input and send it to the computer via the programming port.

I tried to merge some examples from the Arduino website to get what I want, this is the code:

#include <Mouse.h>
#include <MouseController.h>

int move_X = 0;
int move_Y = 0;


// Initialize USB Controller
USBHost usb;

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

void setup(){
  Serial.begin(9600);
  Mouse.begin();
}

void loop(){
  usb.Task();
}

void mouseMoved() {


  Serial.print("Move: ");
  Serial.print(mouse.getXChange());
  move_X = mouse.getXChange();
  Serial.print(", ");
  Serial.println(mouse.getYChange());
  move_Y = mouse.getYChange();

 Mouse.move(move_X, move_Y, 0);
}

And this is the error that comes with it:
C:\Users\MSI\Documents\Arduino\libraries\USBHost-master\src/hid.h:156:15: note: no known conversion for argument 1 from 'HID*' to 'int*'

I did set the correct board and Port in IDE.

I moved the Mouse.h include after the MouseController.h include and it compiled for me. MouseController.h defines the HID class.

It then marks the last line "Mouse.move(move_X, move_Y, 0);" and says:
'Mouse' nicht gefunden. Beinhaltet Ihr Sketch die Zeile '#include <Mouse.h>'?
translated
'Mouse' could not be found. Are you including '#include <Mouse.h>'?

Yes. I just moved it.

That wasn't a question that was the error message :smiley:

The follwing code does still not work:

#include <MouseController.h>
#include <Mouse.h>


int move_X = 0;
int move_Y = 0;


// Initialize USB Controller
USBHost usb;

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

void setup(){
  Serial.begin(9600);
  Mouse.begin();
}

void loop(){
  usb.Task();
}

void mouseMoved() {


  Serial.print("Move: ");
  Serial.print(mouse.getXChange());
  move_X = mouse.getXChange();
  Serial.print(", ");
  Serial.println(mouse.getYChange());
  move_Y = mouse.getYChange();

 Mouse.move(move_X, move_Y, 0);
}

It tells me to include Mouse.h
Are you actually selecting Arduino DUE (programming Port) for your tests?

Anyone has another idea on this one? Sadly there are not examplkes doing exactly this.

Try this out:

#include <MouseController.h>

// Initialize USB Controller
USBHost usb;

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

void setup() {
  Serial.begin(250000);
}

void loop() {
  usb.Task();
}

void mouseMoved() {

  Serial.print("Move: ");
  Serial.print(mouse.getXChange());
  Serial.print(", ");
  Serial.println(mouse.getYChange());
}

I have not checked all the facts, but my suspicion is, what you are trying to do does not work. You only have one native USB port on the Arduino Due. You may think you have two but that is not true. The programming port is connected to another microcontroller.

You would need to change the firmware in the ATmega16U2 if you wanted it to act as a USB peripheral mouse device. Then you could talk to it with your own made-up serial protocol and make a USB mouse movement modifier.

The sketch from ard_newbie reply #7 should work as it only sends serial print information to the second microcontroller which is then send via USB to your PC using a virtual COM port.

Yes answer 7 does work, but it gives me no room for editing the mouse movement and forward it to the computer.
Are there ready to use firmware which does what I need? If not isn't it easier to buy another USB Shield and stick it on top?
I really thought the due is enough for my needs since it really sounded like it would in the description..

What you are trying to do has no application in the product world. As a product engineer you would just implement this into the USB device aka your mouse. On the other side if you had the skills, you could change the driver in the operating system (Windows or Linux) to modify the behavior towards the user application.

In USB most products are USB device, and they always connect to a USB host. Some products can be both aka smartphones but only one at a time. Host for a SD card reader and device when downloading data from a PC. The exception is USB Hubs, and they are single purpose chips not general-purpose microcontroller.

An Arduino with native USB may be a more flexible choice. You can connect them via Serial. It may not look as pretty as a shield.

Try Google. e.g., "ATmgea16U2 HID mouse" Remember that ATmega16U2 is used to program the SAM3X. If you modify it and something goes wrong, it may be a bit more difficult to get this back working.