Hi,
I'm detecting usb keyboards from shell using this simple script:
for i in /sys/class/input/input*; do
[ ! -f $i/device/bInterfaceClass -o ! -f $i/device/bInterfaceProtocol ] && continue
bInterfaceClass=$(cat $i/device/bInterfaceClass)
bInterfaceProtocol=$(cat $i/device/bInterfaceProtocol)
if [ "$bInterfaceClass" = "03" -a "$bInterfaceProtocol" = "01" ]; then
module=$(readlink $i/device/driver/module)
module=$(basename $module)
echo "found keyboard driven by $module"
fi
done
but for keyboards hidden behind logitech unifying receiver
there seem to be no such information in /sys.
Any ideas on how I can detect such keyboards via /sys or other
scriptable method?
(note that I'm interested only in "regular" keyboards, so single buttons
and some other devices are not interesting)
dmesg:
[130816.672862] usb 6-2: new full-speed USB device number 4 using uhci_hcd
[130816.856173] usb 6-2: New USB device found, idVendor=046d, idProduct=c52b
[130816.856183] usb 6-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[130816.856190] usb 6-2: Product: USB Receiver
[130816.856195] usb 6-2: Manufacturer: Logitech
[130816.868751] logitech-djreceiver 0003:046D:C52B.000F: hiddev0,hidraw2: USB HID v1.11 Device [Logitech USB Receiver] on usb-0000:00:1d.0-2/input2
[130816.878201] input: Logitech Unifying Device. Wireless PID:4004 as /devices/pci0000:00/0000:00:1d.0/usb6/6-2/6-2:1.2/0003:046D:C52B.000F/input/input14
[130816.878717] logitech-djdevice 0003:046D:C52B.0010: input,hidraw3: USB HID v1.11 Keyboard [Logitech Unifying Device. Wireless PID:4004] on usb-0000:00:1d.0-2:1
--
Arkadiusz Miśkiewicz PLD/Linux Team
arekm / maven.pl http://ftp.pld-linux.org/
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, 22 Mar 2012, Arkadiusz Miśkiewicz wrote:
Hi,
I'm detecting usb keyboards from shell using this simple script:
for i in /sys/class/input/input*; do
[ ! -f $i/device/bInterfaceClass -o ! -f $i/device/bInterfaceProtocol ] && continue
bInterfaceClass=$(cat $i/device/bInterfaceClass)
bInterfaceProtocol=$(cat $i/device/bInterfaceProtocol)
if [ "$bInterfaceClass" = "03" -a "$bInterfaceProtocol" = "01" ]; then
module=$(readlink $i/device/driver/module)
module=$(basename $module)
echo "found keyboard driven by $module"
fi
done
but for keyboards hidden behind logitech unifying receiver there seem to
be no such information in /sys.
Any ideas on how I can detect such keyboards via /sys or other
scriptable method?
(note that I'm interested only in "regular" keyboards, so single buttons
and some other devices are not interesting)
dmesg:
[130816.672862] usb 6-2: new full-speed USB device number 4 using uhci_hcd
[130816.856173] usb 6-2: New USB device found, idVendor=046d, idProduct=c52b
[130816.856183] usb 6-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[130816.856190] usb 6-2: Product: USB Receiver
[130816.856195] usb 6-2: Manufacturer: Logitech
[130816.868751] logitech-djreceiver 0003:046D:C52B.000F: hiddev0,hidraw2: USB HID v1.11 Device [Logitech USB Receiver] on usb-0000:00:1d.0-2/input2
[130816.878201] input: Logitech Unifying Device. Wireless PID:4004 as /devices/pci0000:00/0000:00:1d.0/usb6/6-2/6-2:1.2/0003:046D:C52B.000F/input/input14
[130816.878717] logitech-djdevice 0003:046D:C52B.0010: input,hidraw3: USB HID v1.11 Keyboard [Logitech Unifying Device. Wireless PID:4004] on usb-0000:00:1d.0-2:1
I suggest you inspect all available input devices using EVIOCGBIT ioctl()
instead, querying the device capabilities (and looking namely on the
EV_KEY capabilities).
Alternatively, you can find this information prepared for you in
/proc/bus/input/devices.
If you really want to restrict yourself to USB keyboards, you'll have to
inspect 'Phys' as well. This you can do via EVIOCGPHYS ioctl() or look
into procfs as well.
--
Jiri Kosina
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
On Friday 30 of March 2012, Jiri Kosina wrote:
On Thu, 22 Mar 2012, Arkadiusz Miśkiewicz wrote:
quoted
Hi,
I'm detecting usb keyboards from shell using this simple script:
for i in /sys/class/input/input*; do
[ ! -f $i/device/bInterfaceClass -o ! -f
$i/device/bInterfaceProtocol ] && continue
bInterfaceClass=$(cat $i/device/bInterfaceClass)
bInterfaceProtocol=$(cat $i/device/bInterfaceProtocol)
if [ "$bInterfaceClass" = "03" -a "$bInterfaceProtocol"
= "01" ]; then
module=$(readlink $i/device/driver/module)
module=$(basename $module)
echo "found keyboard driven by $module"
fi
done
but for keyboards hidden behind logitech unifying receiver there seem to
be no such information in /sys.
Any ideas on how I can detect such keyboards via /sys or other
scriptable method?
(note that I'm interested only in "regular" keyboards, so single buttons
and some other devices are not interesting)
dmesg:
[130816.672862] usb 6-2: new full-speed USB device number 4 using
uhci_hcd [130816.856173] usb 6-2: New USB device found, idVendor=046d,
idProduct=c52b [130816.856183] usb 6-2: New USB device strings: Mfr=1,
Product=2, SerialNumber=0 [130816.856190] usb 6-2: Product: USB Receiver
[130816.856195] usb 6-2: Manufacturer: Logitech
[130816.868751] logitech-djreceiver 0003:046D:C52B.000F: hiddev0,hidraw2:
USB HID v1.11 Device [Logitech USB Receiver] on
usb-0000:00:1d.0-2/input2 [130816.878201] input: Logitech Unifying
Device. Wireless PID:4004 as
/devices/pci0000:00/0000:00:1d.0/usb6/6-2/6-2:1.2/0003:046D:C52B.000F/in
put/input14 [130816.878717] logitech-djdevice 0003:046D:C52B.0010:
input,hidraw3: USB HID v1.11 Keyboard [Logitech Unifying Device.
Wireless PID:4004] on usb-0000:00:1d.0-2:1
I suggest you inspect all available input devices using EVIOCGBIT ioctl()
instead, querying the device capabilities (and looking namely on the
EV_KEY capabilities).
Alternatively, you can find this information prepared for you in
/proc/bus/input/devices.
If you really want to restrict yourself to USB keyboards, you'll have to
inspect 'Phys' as well. This you can do via EVIOCGPHYS ioctl() or look
into procfs as well.
Ok, thanks. Seems there is no good way to find out regular keyboards only
since many non keyboard devices have some keys.
--
Arkadiusz Miśkiewicz PLD/Linux Team
arekm / maven.pl http://ftp.pld-linux.org/
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html