Optical mouse as encoder

I recently discovered the beauty of an optical mouse as an incremental encoder.

An optical mouse typically contains one component in which the camera is connected to an image processor connected to a USB interface. Resolution depends on the resolution of the camera. On the Internet it is easy to find data tables of this type of component, which also describe how to read / write with them.

My problem, which I must first solve, is to make sure that the laptop-encoder does not see the laptop / computer as a pointing device without disconnecting the USB port to which it is connected. I need to use 2 encoders, so this means that on my PC I need to use 3 USB ports (running Windows XP), one for the mouse as a pointing device and two for the mouse as an encoder.

The second question is how to read / write instructions / data from / to the mouse encoder via the USB port? Can someone send me a link to a tutorial / example in C ++?

Thank you very much in advance,

Stephen

+6
source share
2 answers

The USB mouse microcontroller is probably hard-coded to send USB frames that identify themselves as HID devices. In this case, there is little hope that Windows will be able to use Windows as a mouse. After all this a mouse.

If you are in DIY, you can try to hack the mouse board by unpacking the component / wires and directly control the encoders using your arduino. Thus, the Arduino can read data from the encoder and send it to a PC using its own USB serial port.

See an example:

http://www.martijnthe.nl/2009/07/interfacing-an-optical-mouse-sensor-to-your-arduino/

More information about the HID device: http://en.wikipedia.org/wiki/USB_human_interface_device_class Excerpt: "There are two levels of USB HID-related APIs: the USB level and the operating system level. At the USB level, there is a protocol for devices to announce its capabilities and the operating system for analyzing the data it receives.then offers a higher level presentation for applications that do not need to include support for individual devices, but for device classes.This level of abstraction allows the game to work with any control USB lehr, for example, even with established after the game. "

+4
source

Take a look at the Raw Input API to see if you can pick up events this way and block Windows from acting on them.

+2
source

Source: https://habr.com/ru/post/914809/


All Articles