3

The goal is to connect a mouse to my raspberry Pi, and have it connected to a computer (both linux and windows will be used). I want to have a LED light up whenever I use a right mouse click. So the input would be mouse -> raspberry -> computer. Where I want the raspberry to have a led light up on certain actions.

Ideally I'd be able to configure this for not only certain mouse actions, but also keyboard.

Thing is, I have no idea where to start. Or if it is even remotely possible at all. Most challenging thing I can imagine is connecting the pi as a input peripheral. So any advice is greatly appriciated.

EDIT: Ideally the Pi would be connected as an actual USB device with a USB cable. This is to best imitate a mouse/keyboard and it's latencies.

Downquark
  • 31
  • 1
  • 3
  • 2
    Why are you trying to do this? Why spend $35 to emulate a $5 mouse? – Steve Robillard Mar 08 '16 at 12:23
  • Goal is to have a visual LED indicator for certain actions. With this and a high speed camera I want to do some testing on latencies. So I want to measure the time between the LED lighting up, and an action happening on screen. Also why use an overly expencive pi 2? becouse I have one laying around, and as a microprocessor board with output pins it seemed like it could do the job. – Downquark Mar 08 '16 at 12:33
  • It would also be a great surveillance device like the FBI used on that mobster when they couldn't crack his PGP. – SDsolar May 19 '17 at 09:26

3 Answers3

1

Following the approach given in the question mouse -> raspberry -> computer, one solution could be to emulate an HID (Human Interface Device) with the Pi when connecting to the computer. So the Pi picks up all input coming from the mouse/keyboard, gets the info it needs (the certain action you intend to act upon), and relays all the input to the other computer faking to be a HID using it's GPIO ports.

See here (to not repeat what's written there):

Ghanima
  • 15,855
  • 15
  • 61
  • 119
0

You cannot do this directly because the Pi's USB port was occupied.

However you can use Arduino Leonardo with some SPI-to-USB-Host chip here.

Maxthon Chan
  • 1,051
  • 7
  • 14
-2

Here is what you need USB over IP. Your RPi will run Linux and do the thing =)

Alexey Vesnin
  • 926
  • 9
  • 16
  • Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Steve Robillard Mar 08 '16 at 13:13
  • @SteveRobillard a link is provided. I know and I've been reading the fine manual, but this question is literally has a one-line answer. Why don;t you take a look at the official website of the project I've recommended? – Alexey Vesnin Mar 08 '16 at 14:27
  • This looks indeed very promising, and like a good solution. I am slightly worried about network latency though. Initially my idea was to use the RPi as an actual USB, so with a cable, to best imitate an actual mouse. although I notice I did not explicitly mention this in my question, for which my apologies. I edited my question to include this. I will go with this if no USB sollution arises though. – Downquark Mar 08 '16 at 14:55
  • 1
    The issue is that without including the pertinent details here your answer is only good as long as that link is functional. – Steve Robillard Mar 08 '16 at 15:08
  • @SteveRobillard the issue is, that if a whole project I'm referring to will go down with their website, then an answer will be useless, indeed. But it's not a reason to include the whole source code, right? – Alexey Vesnin Mar 08 '16 at 17:26
  • @Downquark no problem! take a look at theese modules - it will make your USB-plugged RPi have an ethernet-via-usb =) And the setup scheme will be the same, but the latency will be different. – Alexey Vesnin Mar 08 '16 at 17:28
  • @AlexeyVesnin Correct me if I'm wrong, but does the guide apply to only Raspberry Pi Zero (and model A and A+)? The story being that the Pi 2 does not support USB OTG? After all if it did you could somehow use it as slave, so like a mouse as I intend in the first place? – Downquark Mar 08 '16 at 20:23
  • @Downquark it is for a models yo've specified. If you need a USB OTG/slavemode for other versions - then you'll need a bridge on a separate chip. My good advice to you : make it work via network, then adjust your hardware profile if needed. – Alexey Vesnin Mar 08 '16 at 20:28