====== Ubuntu - Mouse - Determine the Mouse ======
===== Determine the Mouse to use =====
xinput --list --short
returns:
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ Corsair CORSAIR K70 RGB MK.2 Mechanical Gaming Keyboard Consumer Control id=11 [slave pointer (2)]
⎜ ↳ Corsair CORSAIR K70 RGB MK.2 Mechanical Gaming Keyboard Mouse id=12 [slave pointer (2)]
⎜ ↳ Razer Razer DeathAdder V2 id=8 [slave pointer (2)]
⎜ ↳ Razer Razer DeathAdder V2 Consumer Control id=9 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Power Button id=7 [slave keyboard (3)]
↳ Corsair CORSAIR K70 RGB MK.2 Mechanical Gaming Keyboard id=10 [slave keyboard (3)]
↳ Corsair CORSAIR K70 RGB MK.2 Mechanical Gaming Keyboard Consumer Control id=13 [slave keyboard (3)]
↳ Razer Razer DeathAdder V2 Consumer Control id=14 [slave keyboard (3)]
↳ Razer Razer DeathAdder V2 Keyboard id=15 [slave keyboard (3)]
↳ Razer Razer DeathAdder V2 System Control id=16 [slave keyboard (3)]
↳ Razer Razer DeathAdder V2 id=17 [slave keyboard (3)]
**NOTE:** In this case, the "Razer Razer DeathAdder V2" is the mouse.
* As there are multiple entries, the name "Razer Razer DeathAdder V2" cannot be used as it is not unique.
* Instead, use the **id**.
* How to know which of the **id** to use.
----
===== Which id to use =====
In the above results, the **Razer DeathAdder** is shown multiple times.
* Only the salient id is needed.
xinput | grep -m 1 "DeathAdder"
returns:
⎜ ↳ Razer Razer DeathAdder V2 id=8 [slave pointer (2)]
**NOTE:** Many mouse show as as both Mouse and Keyboard.
* The Keyboard entries can usually be ignore.
* **-m 1** in the **grep** returns only the first line.
* This shows that **id=8** is the relevant line.
* This id may change upon system reboot, so for any future scripts using the id, it is best this is calculated beforehand:
xinput | grep -m 1 "DeathAdder" | sed 's/^.*id=\([0-9]*\)[ \t].*$/\1/'
* returns:
8
----
===== Determine Other Device Idenfiers =====
==== Device Product Name (Model) ====
The Product Name (or model):
xinput --list --short
returns:
...
Razer Razer DeathAdder V2
...
**NOTE:** This is the same as above.
----
==== Determine the Device Node ====
xinput list-props 8 | grep 'Device Node'
returns:
Device Node (279): "/dev/input/event7"
----
==== Device Vendor Name (Manufacturer) ====
The manufacturer or vendor name:
udevadm info --query=property --name=/dev/input/event7 | grep 'VENDOR='
returns:
ID_VENDOR=Razer
**NOTE:** This is the same as above.
----
udevadm info --query=all --path=$(udevadm info --query=path --name=$(xinput list-props `xinput | grep -m 1 "DeathAdder" | sed 's/^.*id=\([0-9]*\)[ \t].*$/\1/'` | grep 'Device Node'| awk '{ print $4; }' | sed 's/\"//g'))
or
udevadm info --query=all --path=$(udevadm info --query=path --name=/dev/input/event7)
returns:
P: /devices/pci0000:00/0000:00:08.1/0000:0b:00.3/usb5/5-1/5-1:1.0/0003:1532:0084.0006/input/input25/event7
N: input/event7
L: 0
S: input/by-id/usb-Razer_Razer_DeathAdder_V2-event-mouse
S: input/by-path/pci-0000:0b:00.3-usb-0:1:1.0-event-mouse
E: DEVPATH=/devices/pci0000:00/0000:00:08.1/0000:0b:00.3/usb5/5-1/5-1:1.0/0003:1532:0084.0006/input/input25/event7
E: DEVNAME=/dev/input/event7
E: MAJOR=13
E: MINOR=71
E: SUBSYSTEM=input
E: USEC_INITIALIZED=2059106657497
E: ID_INPUT=1
E: ID_INPUT_MOUSE=1
E: ID_VENDOR=Razer
E: ID_VENDOR_ENC=Razer
E: ID_VENDOR_ID=1532
E: ID_MODEL=Razer_DeathAdder_V2
E: ID_MODEL_ENC=Razer\x20DeathAdder\x20V2
E: ID_MODEL_ID=0084
E: ID_REVISION=0200
E: ID_SERIAL=Razer_Razer_DeathAdder_V2
E: ID_TYPE=hid
E: ID_BUS=usb
E: ID_USB_INTERFACES=:030102:030001:030101:030002:
E: ID_USB_INTERFACE_NUM=00
E: ID_USB_DRIVER=usbhid
E: ID_PATH=pci-0000:0b:00.3-usb-0:1:1.0
E: ID_PATH_TAG=pci-0000_0b_00_3-usb-0_1_1_0
E: LIBINPUT_DEVICE_GROUP=3/1532/84:usb-0000:0b:00.3-1
E: DEVLINKS=/dev/input/by-id/usb-Razer_Razer_DeathAdder_V2-event-mouse /dev/input/by-path/pci-0000:0b:00.3-usb-0:1:1.0-event-mouse
----
==== Other way to obtain information ====
For USB devices:
lsusb -v | grep -e idProduct -e idVendor
**NOTE:** lsusb uses /var/lib/usbutils/usb.ids to translate ids to names.
----
For the IDs only:
grep . /sys/bus/usb/devices/*/id*
----
==== XOrg Configuration ====
Putting it all together, a new XOrg configuration **InputClass** Section would look like:
Section "InputClass"
Identifier "Razer Deathadder v2"
MatchDevicePath "/dev/input/event*"
MatchProduct "Razer Razer DeathAdder V2"
MatchVendor "Razer"
EndSection
**NOTE:** See [[Ubuntu:Mouse:Change Mouse Properties|Change Mouse Properties]].