Does this code already exist?

I am just wondering if I wanted to plug in a USB mouse into a Arduino and then emulate the mouses movements to the computer does anyone know if there is already an existing code?

Mouse --> Arduino ----> Computer

I doubt it does exist but I have found other projects where the movement of a mouse powers a little mechanical arm or another type of robot and I am simply looking for something that will allow me to basically have it like the Arduino isn't even in the middle of the mouse and the computer. My purpose for this is that I am trying to intercept a mouse button press on the mouse while it is connected to the PC. I believe that this is the easiest option of them all but if anyone has any better ideas feel free to lmk!

Thanks!

David1937:
I am just wondering if I wanted to plug in a USB mouse into a Arduino

The Arduino and a mouse are both (I probably almost certainly have the terminology wrong here) "slaves" of the PC "host", as far as I know. So a slave plugged into a slave doesn't make sense (to me). Isn't that why the Arduino USB cable is a square type-B on the Arduino end, and the flat type-A on the PC end, same as a mouse's USB?

The Leonardo can act as a HID. So you could use a USB host shield to put the mouse to the Leonardo and then send whatever you read to the computer from Leonardo. I'm not sure what the code would have to look like, but that seems possible.

I have the Due which as I am aware had the USB host built in. That gives me acess to the mouse controller class. My question is does a code which I described already exist on here? That way I dont have to waste my time

David1937:
That way I dont have to waste my time

Or anyone else's by not saying you had a Due in the opening post.

Maybe edit your first post:

I wanted to plug in a USB mouse into a Arduino Due and then emulate .....