Reidjako
Posts: 4
Joined: Mon Mar 12, 2018 11:05 pm

Emulating mouse inputs

Mon Mar 12, 2018 11:09 pm

So I have a bunch of sensors and a range of other things occurring, the raspberry pi then receives these processes them.

Now my issue is, how do I send an out put from the raspberry pi to another computers USB port so that the computer thinks that the raspberry pi is a mouse and is moving the cursor.

My thoughts were to get a 5 pin to USB adapter or just do some soldering to make it, however from that point I am lost on what the best way to emulate mouse movement. Does anyone know of any libraries or places I can go to work this out. Even better if their is a shield or what not for this!!

Thanks for the help guys!

User avatar
rpdom
Posts: 12497
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK

Re: Emulating mouse inputs

Tue Mar 13, 2018 7:20 am

This is relatively easy on a Pi Zero, but really difficult on any other ordinary Pi. (Can be done with some fiddling on an A or A+). Basically USB is Master->Slave. The Pi is a Master. The PC is a Master. The Zero has USB-OTG which means it can switch between being a Master and a Slave (but you have to load some drivers to tell it what sort of device it will pretend to be).

PiGraham
Posts: 3212
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Emulating mouse inputs

Tue Mar 13, 2018 7:38 am

Reidjako wrote:
Mon Mar 12, 2018 11:09 pm
So I have a bunch of sensors and a range of other things occurring, the raspberry pi then receives these processes them.

Now my issue is, how do I send an out put from the raspberry pi to another computers USB port so that the computer thinks that the raspberry pi is a mouse and is moving the cursor.

My thoughts were to get a 5 pin to USB adapter or just do some soldering to make it, however from that point I am lost on what the best way to emulate mouse movement. Does anyone know of any libraries or places I can go to work this out. Even better if their is a shield or what not for this!!

Thanks for the help guys!
You can make a PiZero act as a USB mouse or keyboard but thi may not be a good way to send information to another computer.
Some earcode readers do this, acting as "keyboard wedge" to inject the number of teh barcoe into any edit control. The user must be careful to select the edit control before activating the reader. It's a legacy technique that allowed new readers to work with old systems designed to have a user type a value.
Keyboards and mice are input devices only. They don't know where the mouse cursor is on screen or what control has input focus. Your data input process is therefpre blind.

It is usually better to use some structured communications where a client can communicate both ways with a server to get the right data to the right place.

What data do you want to send to what ?

Reidjako
Posts: 4
Joined: Mon Mar 12, 2018 11:05 pm

Re: Emulating mouse inputs

Tue Mar 13, 2018 11:53 pm

Thank you for the replies I appreciate it.

My goal is to essentially pass on from the pi mouse movement aka, move left by x or move right by x, left click, right click just like a normal mouse based on information obtained. https://www.mwave.com.au/product/starte ... PlEALw_wcB Using something like this on the raspberry pi pins to send the inputs.

From the sounds of it, I should use a raspberry piZero, send from the PI movement commands via the pins, then allow the piZero to act as the mouse. (https://raspberrypi.stackexchange.com/q ... hrough-usb) how to use a raspberry pi zero as a mouse.

I am only interested in one way communication and don't want the computer recieving the input to communicate with the PI what so ever, as it will defeat the purpose of my task, which is to have an AI being able to communicate with the computer just as a human would (the software for communication is good, it is just a matter of mouse movement).

Return to “Automation, sensing and robotics”

Who is online

Users browsing this forum: straggler1 and 7 guests