Temat: Klawiatura HID USB
Chyba temat trochę na wyrost, ponieważ dotyczy kilku klawiszy a nie klawiatury, ale to chyba to samo.
Zainstalowałem mpd + mpc (Media Player) i kartę dźwiękową na USB (a dokładniej Logitech - Laptop Seaker Z205 http://oclab.pl/artykuly/audio/recenzja … tech-z205/). Wszytko do obsługi radia internetowego.
Logitech - Laptop Seaker Z205, to karta dźwiękowa ze wzmacniaczem, głośnikami stereo i 3 przyciskami na obudowie. Jeden to on/off wzmacniacza i dwa (oznaczone + i -) do regulacji wzmocnienia. Klawisze nie są obsługiwane bezpośrednio przez mpd ani mpc. Trzeba im troszkę pomóc.
A teraz trochę faktów:
root@OpenWrt:~# lsusb -d 046d: -v
Bus 001 Device 003: ID 046d:0a19 Logitech, Inc.
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x046d Logitech, Inc.
idProduct 0x0a19
bcdDevice 1.00
iManufacturer 1 Logitech
iProduct 2 Logitech Z205
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 48640
bNumInterfaces 3
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 500mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 1 Audio
bInterfaceSubClass 1 Control Device
bInterfaceProtocol 0
iInterface 0
AudioControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdADC 1.00
wTotalLength 40
bInCollection 1
baInterfaceNr( 0) 1
AudioControl Interface Descriptor:
bLength 12
bDescriptorType 36
bDescriptorSubtype 2 (INPUT_TERMINAL)
bTerminalID 1
wTerminalType 0x0101 USB Streaming
bAssocTerminal 0
bNrChannels 2
wChannelConfig 0x0003
Left Front (L)
Right Front (R)
iChannelNames 0
iTerminal 0
AudioControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 3 (OUTPUT_TERMINAL)
bTerminalID 2
wTerminalType 0x0301 Speaker
bAssocTerminal 0
bSourceID 3
iTerminal 0
AudioControl Interface Descriptor:
bLength 10
bDescriptorType 36
bDescriptorSubtype 6 (FEATURE_UNIT)
bUnitID 3
bSourceID 1
bControlSize 1
bmaControls( 0) 0x01
Mute
bmaControls( 1) 0x02
Volume
bmaControls( 2) 0x02
Volume
iFeature 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 1
bNumEndpoints 1
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 0
AudioStreaming Interface Descriptor:
bLength 7
bDescriptorType 36
bDescriptorSubtype 1 (AS_GENERAL)
bTerminalLink 1
bDelay 0 frames
wFormatTag 1 PCM
AudioStreaming Interface Descriptor:
bLength 17
bDescriptorType 36
bDescriptorSubtype 2 (FORMAT_TYPE)
bFormatType 1 (FORMAT_TYPE_I)
bNrChannels 2
bSubframeSize 2
bBitResolution 16
bSamFreqType 3 Discrete
tSamFreq[ 0] 32000
tSamFreq[ 1] 44100
tSamFreq[ 2] 48000
Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 9
Transfer Type Isochronous
Synch Type Adaptive
Usage Type Data
wMaxPacketSize 0xc000 1x 0 bytes
bInterval 1
bRefresh 0
bSynchAddress 0
AudioControl Endpoint Descriptor:
bLength 7
bDescriptorType 37
bDescriptorSubtype 1 (EP_GENERAL)
bmAttributes 0x00
bLockDelayUnits 2 Decoded PCM samples
wLockDelay 512 Decoded PCM samples
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 2
bNumEndpoints 1
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 0
AudioStreaming Interface Descriptor:
bLength 7
bDescriptorType 36
bDescriptorSubtype 1 (AS_GENERAL)
bTerminalLink 1
bDelay 0 frames
wFormatTag 1 PCM
AudioStreaming Interface Descriptor:
bLength 17
bDescriptorType 36
bDescriptorSubtype 2 (FORMAT_TYPE)
bFormatType 1 (FORMAT_TYPE_I)
bNrChannels 1
bSubframeSize 2
bBitResolution 16
bSamFreqType 3 Discrete
tSamFreq[ 0] 32000
tSamFreq[ 1] 44100
tSamFreq[ 2] 48000
Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 9
Transfer Type Isochronous
Synch Type Adaptive
Usage Type Data
wMaxPacketSize 0x6000 1x 0 bytes
bInterval 1
bRefresh 0
bSynchAddress 0
AudioControl Endpoint Descriptor:
bLength 7
bDescriptorType 37
bDescriptorSubtype 1 (EP_GENERAL)
bmAttributes 0x00
bLockDelayUnits 2 Decoded PCM samples
wLockDelay 512 Decoded PCM samples
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 2
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 0 No Subclass
bInterfaceProtocol 0 None
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.00
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 36
Report Descriptors:
** UNAVAILABLE **
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x85 EP 5 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0100 1x 256 bytes
bInterval 10
Device Status: 0x0000
(Bus Powered)Klawisze rozpoznawane są jako Human Interface Device (HID). Mam załadowane moduły: kmod-hid, kmod-usb-hid oraz kmod-input-core i kmod-input-evdev. Całość prawidłowo (chyba?) zgłosiła się w systemie:
root@OpenWrt:~# cat /proc/bus/input/devices
I: Bus=0019 Vendor=0001 Product=0001 Version=0100
N: Name="gpio-buttons"
P: Phys=gpio-buttons/input0
S: Sysfs=/devices/platform/gpio-buttons/input/input0
U: Uniq=
H: Handlers=button-hotplug event0
B: EV=3
B: KEY=3 0 0 0 0 0 0 0 0
I: Bus=0003 Vendor=046d Product=0a19 Version=0100
N: Name=" Logitech Logitech Z205 "
P: Phys=usb-ar71xx-ehci-1.1/input2
S: Sysfs=/devices/platform/ar71xx-ehci/usb1/1-1/1-1.1/1-1.1:1.2/input/input1
U: Uniq=
H: Handlers=event1
B: EV=13
B: KEY=78 0 e0000 0 0 0
B: MSC=10I jak widać w /dev/input zgłosiły się:
root@OpenWrt:~# ls /dev/input/
event0 event1/dev/input/event1 dotyczy zdarzeń przychodzących od klawiszy z karty Logitech Z205.
I tutaj mam problem. Jak obsłużyć te zdarzenia? Pewnie napisać jakiś skrypt, ale po 2 dniach szukania w necie nie mam żadnego pomysłu.
Jak się do tego zabrać?
pozdrawiam Jarek