B
B
betrachtung2014-03-19 11:31:20
linux
betrachtung, 2014-03-19 11:31:20

How can I create a udev rule to turn off part of a composite USB device?

I have a device (Microsoft Sculpt Ergonomic Desktop keyboard and mouse set) part of which for some reason is recognized as a joystick /dev/input/js0. This greatly interferes in games, but I don’t want to use the rmmod joydev option, it’s too radical, I don’t want to ruin support for game controllers as such. Accordingly, I want to somehow get rid of this "joystick" so that nothing else is damaged.
It looks like this:

$ udevadm info /dev/input/js0 
P: /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.5/2-1.5:1.2/input/input21/js0
N: input/js0
S: input/by-id/usb-Microsoft_Microsoft®_2.4GHz_Transceiver_v9.0-if02-kbd
S: input/by-path/pci-0000:00:1d.0-usb-0:1.5:1.2-kbd
E: DEVLINKS=/dev/input/by-id/usb-Microsoft_Microsoft®_2.4GHz_Transceiver_v9.0-if02-kbd /dev/input/by-path/pci-0000:00:1d.0-usb-0:1.5:1.2-kbd
E: DEVNAME=/dev/input/js0
E: DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.5/2-1.5:1.2/input/input21/js0
E: ID_BUS=usb
E: ID_INPUT=1
E: ID_INPUT_KEY=1
E: ID_INPUT_KEYBOARD=1
E: ID_MODEL=Microsoft®_2.4GHz_Transceiver_v9.0
E: ID_MODEL_ENC=Microsoft®\x202.4GHz\x20Transceiver\x20v9.0
E: ID_MODEL_ID=07a5
E: ID_PATH=pci-0000:00:1d.0-usb-0:1.5:1.2
E: ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_5_1_2
E: ID_REVISION=0757
E: ID_SERIAL=Microsoft_Microsoft®_2.4GHz_Transceiver_v9.0
E: ID_TYPE=hid
E: ID_USB_DRIVER=usbhid
E: ID_USB_INTERFACES=:030101:030102:030000:
E: ID_USB_INTERFACE_NUM=02
E: ID_VENDOR=Microsoft
E: ID_VENDOR_ENC=Microsoft
E: ID_VENDOR_ID=045e
E: MAJOR=13
E: MINOR=0
E: SUBSYSTEM=input
E: USEC_INITIALIZED=907811523

$ udevadm info --attribute-walk /dev/input/js0 

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.5/2-1.5:1.2/input/input21/js0':
    KERNEL=="js0"
    SUBSYSTEM=="input"
    DRIVER==""

  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.5/2-1.5:1.2/input/input21':
    KERNELS=="input21"
    SUBSYSTEMS=="input"
    DRIVERS==""
    ATTRS{phys}=="usb-0000:00:1d.0-1.5/input2"
    ATTRS{uniq}==""
    ATTRS{properties}=="0"

  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.5/2-1.5:1.2':
    KERNELS=="2-1.5:1.2"
    SUBSYSTEMS=="usb"
    DRIVERS=="usbhid"
    ATTRS{bInterfaceClass}=="03"
    ATTRS{bInterfaceSubClass}=="00"
    ATTRS{bInterfaceProtocol}=="00"
    ATTRS{bNumEndpoints}=="01"
    ATTRS{supports_autosuspend}=="1"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bInterfaceNumber}=="02"

  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.5':
    KERNELS=="2-1.5"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{devpath}=="1.5"
    ATTRS{idVendor}=="045e"
    ATTRS{speed}=="12"
    ATTRS{bNumInterfaces}==" 3"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{busnum}=="2"
    ATTRS{devnum}=="6"
    ATTRS{configuration}==""
    ATTRS{bMaxPower}=="100mA"
    ATTRS{authorized}=="1"
    ATTRS{bmAttributes}=="a0"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{maxchild}=="0"
    ATTRS{bcdDevice}=="0757"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{version}==" 2.00"
    ATTRS{urbnum}=="26396"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="Microsoft"
    ATTRS{removable}=="removable"
    ATTRS{idProduct}=="07a5"
    ATTRS{bDeviceClass}=="00"

  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb2/2-1':
    KERNELS=="2-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{devpath}=="1"
    ATTRS{idVendor}=="8087"
    ATTRS{speed}=="480"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{busnum}=="2"
    ATTRS{devnum}=="2"
    ATTRS{configuration}==""
    ATTRS{bMaxPower}=="0mA"
    ATTRS{authorized}=="1"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{maxchild}=="8"
    ATTRS{bcdDevice}=="0000"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{version}==" 2.00"
    ATTRS{urbnum}=="116"
    ATTRS{ltm_capable}=="no"
    ATTRS{removable}=="fixed"
    ATTRS{idProduct}=="0024"
    ATTRS{bDeviceClass}=="09"

  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb2':
    KERNELS=="usb2"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{devpath}=="0"
    ATTRS{idVendor}=="1d6b"
    ATTRS{speed}=="480"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{authorized_default}=="1"
    ATTRS{busnum}=="2"
    ATTRS{devnum}=="1"
    ATTRS{configuration}==""
    ATTRS{bMaxPower}=="0mA"
    ATTRS{authorized}=="1"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{maxchild}=="2"
    ATTRS{bcdDevice}=="0313"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{serial}=="0000:00:1d.0"
    ATTRS{version}==" 2.00"
    ATTRS{urbnum}=="24"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="Linux 3.13.0-18-generic ehci_hcd"
    ATTRS{removable}=="unknown"
    ATTRS{idProduct}=="0002"
    ATTRS{bDeviceClass}=="09"
    ATTRS{product}=="EHCI Host Controller"

  looking at parent device '/devices/pci0000:00/0000:00:1d.0':
    KERNELS=="0000:00:1d.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="ehci-pci"
    ATTRS{irq}=="23"
    ATTRS{subsystem_vendor}=="0x1458"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0x0c0320"
    ATTRS{companion}==""
    ATTRS{enabled}=="1"
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{local_cpus}=="00000000,00000000,00000000,00000000,00000000,00000000,00000000,0000000f"
    ATTRS{device}=="0x1e26"
    ATTRS{uframe_periodic_max}=="100"
    ATTRS{msi_bus}==""
    ATTRS{local_cpulist}=="0-3"
    ATTRS{vendor}=="0x8086"
    ATTRS{subsystem_device}=="0x5006"
    ATTRS{numa_node}=="-1"
    ATTRS{d3cold_allowed}=="1"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

I tried to create a rule file like this:
SUBSYSTEM=="input", BUS="usb", ID_PATH="pci-0000:00:1d.0-usb-0:1.5:1.2" OPTIONS+="ignore_device"

I do sudo udevadm control --reload, disconnect and reconnect the transmitter of the kit - it does not help. Tell me what I'm doing wrong and how can I achieve the result?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Dolinin, 2014-03-22
@kostett

rmmod joydev will not remove joystick support, rm here does not mean removal from the file system, this command simply disconnects the given module from the kernel and unloads it from memory. If necessary, this module can be re-enabled with the modprobe joydev command.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question