I’ve always wondered what the LinuxCNC HAL pin names would be for an ordinary mouse, particularly nowadays when an Arduino Leonardo can become a USB HID gadget without much effort at all. If one had a Leonardo and l337 programming skillz, one might receive far more interesting data than just fast-twitch muscle movement…

So. We begin…
From less /proc/bus/input/devices:
... snippage ... I: Bus=0003 Vendor=046d Product=c077 Version=0111 N: Name="Logitech USB Optical Mouse" P: Phys=usb-0000:00:1d.0-1/input0 S: Sysfs=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1:1.0/input/input10 U: Uniq= H: Handlers=mouse3 event10 B: EV=17 B: KEY=ff0000 0 0 0 0 0 0 0 0 B: REL=143 B: MSC=10
From ll /dev/input:
... snippage ... crw-r----- 1 root root 13, 74 2013-02-23 07:46 event10 ... snippage ... crw-r----- 1 root root 13, 35 2013-02-23 07:46 mouse3
Manually beat the permissions into shape, because this is a one-off affair:
sudo chgrp users /dev/input/event10 sudo chgrp users /dev/input/mouse3 sudo chmod g+w /dev/input/event10 sudo chmod g+w /dev/input/mouse3
Find the USB address from lsusb:
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 004 Device 006: ID 06f2:0011 Emine Technology Co. KVM Switch Keyboard Bus 004 Device 005: ID 046d:c401 Logitech, Inc. TrackMan Marble Wheel Bus 004 Device 004: ID 04d9:1203 Holtek Semiconductor, Inc. MC Industries Keyboard Bus 004 Device 003: ID 046d:c216 Logitech, Inc. Dual Action Gamepad Bus 004 Device 002: ID 0451:2046 Texas Instruments, Inc. TUSB2046 Hub Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 002 Device 002: ID 046d:c077 Logitech, Inc. Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Query the attributes with udevadm:
udevadm info --query=all --attribute-walk --name=/dev/bus/usb/002/002
... snippage ...
looking at device '/devices/pci0000:00/0000:00:1d.0/usb2/2-1':
KERNEL=="2-1"
SUBSYSTEM=="usb"
DRIVER=="usb"
ATTR{configuration}==""
ATTR{bNumInterfaces}==" 1"
ATTR{bConfigurationValue}=="1"
ATTR{bmAttributes}=="a0"
ATTR{bMaxPower}==" 98mA"
ATTR{urbnum}=="13"
ATTR{idVendor}=="046d"
ATTR{idProduct}=="c077"
ATTR{bcdDevice}=="6700"
ATTR{bDeviceClass}=="00"
ATTR{bDeviceSubClass}=="00"
ATTR{bDeviceProtocol}=="00"
ATTR{bNumConfigurations}=="1"
ATTR{bMaxPacketSize0}=="8"
ATTR{speed}=="1.5"
ATTR{busnum}=="2"
ATTR{devnum}=="2"
ATTR{version}==" 2.00"
ATTR{maxchild}=="0"
ATTR{quirks}=="0x0"
ATTR{authorized}=="1"
ATTR{manufacturer}=="Logitech"
ATTR{product}=="USB Optical Mouse"
Fire up halrun, load hal_input, and dump the pins:
halrun
halcmd: loadusr -W hal_input -KRAL Optical
halcmd: show all
Loaded HAL Components:
ID Type Name PID State
5 User hal_input 1693 ready
3 User halcmd1692 1692 ready
Component Pins:
Owner Type Dir Value Name
5 bit OUT FALSE input.0.btn-back
5 bit OUT TRUE input.0.btn-back-not
5 bit OUT FALSE input.0.btn-extra
5 bit OUT TRUE input.0.btn-extra-not
5 bit OUT FALSE input.0.btn-forward
5 bit OUT TRUE input.0.btn-forward-not
5 bit OUT FALSE input.0.btn-middle
5 bit OUT TRUE input.0.btn-middle-not
5 bit OUT FALSE input.0.btn-mouse
5 bit OUT TRUE input.0.btn-mouse-not
5 bit OUT FALSE input.0.btn-right
5 bit OUT TRUE input.0.btn-right-not
5 bit OUT FALSE input.0.btn-side
5 bit OUT TRUE input.0.btn-side-not
5 bit OUT FALSE input.0.btn-task
5 bit OUT TRUE input.0.btn-task-not
5 s32 OUT 0 input.0.rel-hwheel-counts
5 float OUT 0 input.0.rel-hwheel-position
5 bit IN FALSE input.0.rel-hwheel-reset
5 float IN 1 input.0.rel-hwheel-scale
5 s32 OUT 0 input.0.rel-wheel-counts
5 float OUT 0 input.0.rel-wheel-position
5 bit IN FALSE input.0.rel-wheel-reset
5 float IN 1 input.0.rel-wheel-scale
5 s32 OUT 0 input.0.rel-x-counts
5 float OUT 0 input.0.rel-x-position
5 bit IN FALSE input.0.rel-x-reset
5 float IN 1 input.0.rel-x-scale
5 s32 OUT 0 input.0.rel-y-counts
5 float OUT 0 input.0.rel-y-position
5 bit IN FALSE input.0.rel-y-reset
5 float IN 1 input.0.rel-y-scale
... snippage ...
Hmmm, that was interesting…













