Close

Got mouse.

A project log for ReTest-yg

YG's own version of Mateng's ReTest, but with different features and a palindromic project number!

yann-guidon-ygdesYann Guidon / YGDES 11/11/2018 at 07:070 Comments

The new ReTest uses a mouse.

A nicely hacked mouse because I only need one input bit. Apparently this one can provide 3 so I could test 3 relays at the same time :-P


I found a used USB mouse with its wires and it perfectly fits my needs.

I only have to replace the buttons with the relay contacts :-) I leave the casing/wiring work for later...


Software is a different matter though, but not as difficult as it could have been. That's why using a mouse (a very common and mundane peripheral) is a great solution : cheap, widely used and very well documented.

First I had to disable it in Xorg : it's a matter of 1) finding the right peripheral 2) writing the right file at the right place. 1) is solved easily with dmesg, xinput, cat /proc/bus/input/devices ...

$ xinput list
⎡ Virtual core pointer              id=2   [master pointer  (3)]
⎜   ↳ PS/2 Generic Mouse            id=12  [slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad    id=13  [slave  pointer  (2)]
⎜   ↳ Logitech USB Optical Mouse    id=17  [slave  pointer  (2)]
...

$ dmesg
[1015128.994372] usb 2-1.3: new low-speed USB device number 86 using ehci-pci
[1015129.078062] usb 2-1.3: New USB device found, idVendor=046d, idProduct=c077
[1015129.078069] usb 2-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[1015129.078073] usb 2-1.3: Product: USB Optical Mouse
[1015129.078077] usb 2-1.3: Manufacturer: Logitech
[1015129.083902] input: Logitech USB Optical Mouse as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/0003:046D:C077.0007/input/input62
[1015129.084707] hid-generic 0003:046D:C077.0007: input,hidraw1: USB HID v1.11 Mouse [Logitech USB Optical Mouse] on usb-0000:00:1d.0-1.3/input0

$ cat /proc/bus/input/devices | grep "Name\|Handlers"
...
N: Name="Logitech USB Optical Mouse"
...
$ less /proc/bus/input/devices
...
I: Bus=0003 Vendor=046d Product=c077 Version=0111
N: Name="Logitech USB Optical Mouse"
P: Phys=usb-0000:00:1d.0-1.3/input0
S: Sysfs=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/0003:046D:C077.0006/input/input61
U: Uniq=
H: Handlers=mouse3 event17
...

The last command shows that the device is handled by /dev/input/mouse3 and /dev/input/event17. This is easily verified.

2) the right file is a new file in /etc/X11/xorg.conf.d/01-no_optical_mouse.conf

Section "InputClass"
   Identifier     "Desactive souris Logitech"
   MatchIsPointer "on"
   Driver         "evdev"
   MatchProduct   "USB Optical Mouse"
   MatchVendor    "Logitech"
   Option         "Ignore" "true"
EndSection

 After I restarted the X server, the mouse is now mute and deaf, but I still can read data from it !

sudo od -An -v -w1 -t x1 /dev/input/mouse3
 09
 00
 00
 08
 00
 00

 that's the binary dump when I press and release the left button.

The binary protocol is really straight-forward so now I focus on the PSU...


Update : 20181118 see log 10.Mouse button handling in C

Discussions