My goal is to produce a mouse with inbuilt macros. So my idea is mouse -> arduino usb hub (or raspberry pi) -> usb out -> computer. Where the arduino will process the input and will complete some aditional task based on the mouse input, then send it back to the computer. I don't want to rely on mouse to arduino then plug the arduino in. I want the arduino to produce the 4 pin signal to the computer.

Any suggestions as far as hardware is concerned for the best way to go about this!

Thanks alot guys.


closed as off-topic by Nick Alexeev Mar 12 '18 at 15:53

  • This question does not appear to be about electronics design within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • \$\begingroup\$ This seems like a complex way to do it. Why not build the processor into the mouse casing, with direct connection to the buttons etc? This way you avoid having to decode the USB string of data, and there's only one comms port to worry about. \$\endgroup\$ – henros Mar 12 '18 at 9:14

You want one of the arduinos with USB device ports on the processors, including the ATMEGA32U4 and ARM based arduinos (like the Leonardo, Micro, Due, Zero, M0 and M0 Pro among others. There are sample sketches for USB keyboard and mouse. If you also want to connect a mouse, you can use a PS2 mouse on any of these boards, I could be wrong but I don't think any of the current arduinos can be both a USB HID host and device (on two ports) at the same time. There are other processors (STM32/etc) that can be programmed with the MBED online IDE that have multiple USB ports and support for device and host mode.


There can be various ways of doing it. You can use leonardo. It has internal USB interface. The various libraries and community support will make it easy for you.

Another way to do it is stated by the other answer. I would just add that you can use LUFA library. Its tutorials and demos can guide you.

If you want to do it the hard way, learn how a mouse driver works and particularly, how it feeds the events into windows. Microsoft website is a good place to learn about windows internals.


Not the answer you're looking for? Browse other questions tagged or ask your own question.