2

I want to write udev rule for a Logitec Bluetooth. My keyboard and mouse connect to PC as one Bluetooth device.

When I monitor udev, I see there are separate events for keyboard and mouse. I want to allow mouse usage but not keyboard. If I ignore the device, I can't use the mouse. How can I achieve this? Can I ignore the keyboard event?

Mouse event

UDEV  [325.554801] add      /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2:1.0/input/input15 (input)
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2:1.0/input/input15
EV=17
ID_BUS=usb
ID_INPUT=1
ID_INPUT_MOUSE=1
ID_MODEL=USB_Receiver
ID_MODEL_ENC=USB\x20Receiver
ID_MODEL_ID=c52f
ID_PATH=pci-0000:00:1d.0-usb-0:1.2:1.0
ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_2_1_0
ID_REVISION=3000
ID_SERIAL=Logitech_USB_Receiver
ID_TYPE=hid
ID_USB_DRIVER=usbhid
ID_USB_INTERFACES=:030102:030000:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=Logitech
ID_VENDOR_ENC=Logitech
ID_VENDOR_ID=046d
KEY=ffff0000 0 0 0 0
MODALIAS=input:b0003v046DpC52Fe0111-e0,1,2,4,k110,111,112,113,114,115,116,117,118,119,11A,11B,11C,11D,11E,11F,r0,1,6,8,am4,lsfw
MSC=10
NAME="Logitech USB Receiver"
PHYS="usb-0000:00:1d.0-1.2/input0"
PRODUCT=3/46d/c52f/111
PROP=0
REL=143
SEQNUM=1513
SUBSYSTEM=input
UDEV_LOG=3
UNIQ=""
USEC_INITIALIZED=325550123

Keyboard event

UDEV  [325.555963] add      /devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2:1.1/input/input16 (input)
ABS=100000000
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.2/4-1.2:1.1/input/input16
EV=1f
ID_BUS=usb
ID_INPUT=1
ID_INPUT_KEY=1
ID_MODEL=USB_Receiver
ID_MODEL_ENC=USB\x20Receiver
ID_MODEL_ID=c52f
ID_PATH=pci-0000:00:1d.0-usb-0:1.2:1.1
ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_2_1_1
ID_REVISION=3000
ID_SERIAL=Logitech_USB_Receiver
ID_TYPE=hid
ID_USB_DRIVER=usbhid
ID_USB_INTERFACES=:030102:030000:
ID_USB_INTERFACE_NUM=01
ID_VENDOR=Logitech
ID_VENDOR_ENC=Logitech
ID_VENDOR_ID=046d
KEY=4837fff072ff32d bf54444600000000 1 20f908b17c000 677bfad9415fed 9ed68000004400 10000002
MODALIAS=input:b0003v046DpC52Fe0111-e0,1,2,3,4,k71,72,73,74,77,80,82,83,85,86,87,88,89,8A,8B,8C,8E,90,96,98,9B,9C,9E,9F,A1,A3,A4,A5,A6,A7,A8,A9,AB,AC,AD,AE,B0,B1,B2,B5,B6,CE,CF,D0,D1,D2,D4,D8,D9,DB,DF,E4,E7,E8,E9,EA,EB,F1,100,161,162,166,16A,16E,172,174,176,178,179,17A,17B,17C,17D,17F,180,182,183,185,188,189,18C,18D,18E,18F,190,191,192,193,195,198,199,19A,1A0,1A1,1A2,1A3,1A4,1A5,1A6,1A7,1A8,1A9,1AA,1AB,1AC,1AD,1AE,1B0,1B1,1B7,1BA,r6,a20,m4,lsfw
MSC=10
NAME="Logitech USB Receiver"
PHYS="usb-0000:00:1d.0-1.2/input1"
PRODUCT=3/46d/c52f/111
PROP=0
REL=40
SEQNUM=1519
SUBSYSTEM=input
UDEV_LOG=3
UNIQ=""
USEC_INITIALIZED=325514060
0

So far what has worked for me is simply find the file /lib/udev/rules.d/97-hid2hci.rules.

Find this entry, and comment it out:

    # Logitech devices
    KERNEL=="hiddev*", ATTRS{idVendor}=="046d",
    ATTRS{idProduct}=="c70[345abce]|c71[3bc]", \
    RUN+="hid2hci --method=logitech-hid --devpath=%p"

It should look like this.

    # Logitech devices
    #KERNEL=="hiddev*", ATTRS{idVendor}=="046d", 
    ATTRS{idProduct}=="c70[345abce]|c71[3bc]", \
    #  RUN+="hid2hci --method=logitech-hid --devpath=%p

Save the file, unplug, and replug the receiver, it works fine.

The only problem I can see is that this may be overwritten on updates. I have yet to spot a better solution.

  • You're very close. Copy your modified /lib/udev/rules.d/97-hid2hci.rules file to /etc/udev/rules.d/97-hid2hci.rules: any rule files in /etc/udev/rules.d will override files with the same name in /lib/udev/rules.d. And the files in /etc/udev/rules.d won't be touched by updates, guaranteed. – telcoM Jun 14 '18 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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