Systemd

更改給定設備的密鑰程式碼

  • March 2, 2021

我剛得到一個羅技 Spotlight Presenter,它有兩個按鈕,其鍵碼與我的展示文稿 (revealjs) 不兼容。 NextandPrevious綁定為Rightand Left,而我想將它們更改為nand p。我正在使用 Ubuntu 18.04 和 ArchLinux。

設備參數:

$ lsusb -d 046d:c53e -v

Bus 001 Device 012: ID 046d:c53e Logitech, Inc.
Couldn't open device, some information will be missing
Device Descriptor:
 bLength                18
 bDescriptorType         1
 bcdUSB               2.00
 bDeviceClass            0 (Defined at Interface level)
 bDeviceSubClass         0
 bDeviceProtocol         0
 bMaxPacketSize0        32
 idVendor           0x046d Logitech, Inc.
 idProduct          0xc53e
 bcdDevice           41.00
 iManufacturer           1
 iProduct                2
 iSerial                 0
 bNumConfigurations      1
 Configuration Descriptor:
   bLength                 9
   bDescriptorType         2
   wTotalLength           84
   bNumInterfaces          3
   bConfigurationValue     1
   iConfiguration          4
   bmAttributes         0xa0
     (Bus Powered)
     Remote Wakeup
   MaxPower               98mA
   Interface Descriptor:
     bLength                 9
     bDescriptorType         4
     bInterfaceNumber        0
     bAlternateSetting       0
     bNumEndpoints           1
     bInterfaceClass         3 Human Interface Device
     bInterfaceSubClass      1 Boot Interface Subclass
     bInterfaceProtocol      1 Keyboard
     iInterface              0
       HID Device Descriptor:
         bLength                 9
         bDescriptorType        33
         bcdHID               1.11
         bCountryCode            0 Not supported
         bNumDescriptors         1
         bDescriptorType        34 Report
         wDescriptorLength      59
        Report Descriptors:
          ** UNAVAILABLE **
     Endpoint Descriptor:
       bLength                 7
       bDescriptorType         5
       bEndpointAddress     0x81  EP 1 IN
       bmAttributes            3
         Transfer Type            Interrupt
         Synch Type               None
         Usage Type               Data
       wMaxPacketSize     0x0008  1x 8 bytes
       bInterval               8
   Interface Descriptor:
     bLength                 9
     bDescriptorType         4
     bInterfaceNumber        1
     bAlternateSetting       0
     bNumEndpoints           1
     bInterfaceClass         3 Human Interface Device
     bInterfaceSubClass      1 Boot Interface Subclass
     bInterfaceProtocol      2 Mouse
     iInterface              0
       HID Device Descriptor:
         bLength                 9
         bDescriptorType        33
         bcdHID               1.11
         bCountryCode            0 Not supported
         bNumDescriptors         1
         bDescriptorType        34 Report
         wDescriptorLength     148
        Report Descriptors:
          ** UNAVAILABLE **
     Endpoint Descriptor:
       bLength                 7
       bDescriptorType         5
       bEndpointAddress     0x82  EP 2 IN
       bmAttributes            3
         Transfer Type            Interrupt
         Synch Type               None
         Usage Type               Data
       wMaxPacketSize     0x0008  1x 8 bytes
       bInterval               2
   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.11
         bCountryCode            0 Not supported
         bNumDescriptors         1
         bDescriptorType        34 Report
         wDescriptorLength      98
        Report Descriptors:
          ** UNAVAILABLE **
     Endpoint Descriptor:
       bLength                 7
       bDescriptorType         5
       bEndpointAddress     0x83  EP 3 IN
       bmAttributes            3
         Transfer Type            Interrupt
         Synch Type               None
         Usage Type               Data
       wMaxPacketSize     0x0020  1x 32 bytes
       bInterval               2

以下是目前的顯示鍵:

# showkeys --scancodes
0xe0 0x4d 0xe0 0xcd
0xe0 0x4b 0xe0 0xcb

# showkeys --keycodes
keycode 106 release
keycode 105 release

這是根據我的鍵盤的顯示鍵:

# showkeys --scancodes
0x31 0xb1
p0x19 0x99

# showkeys --keycodes
keycode  49 release
keycode  25 release

我已經推斷出以下內容/lib/udev/hwdb.d/61-logitech-spotlight-presenter-revealjs.hwdb

# This file has been created to improve Logitech Spotlight Presenter in revealjs
evdev:input:b*v046dpc53e*
KEYBOARD_KEY_69=p
KEYBOARD_KEY_6a=n

然後我嘗試了以下

$ sudo systemd-hwdb update
$ udevadm trigger
$ sudo udevadm control --reload-rules && udevadm trigger

但是我的遙控器仍然會觸發Right/ Left

開源軟體Projecteur允許您映射羅技 Spotlight 的按鈕(並具有可自定義的桌麵點)

項目首頁:https ://github.com/jahnf/Projecteur

也可以使用 arch 的包: https ://aur.archlinux.org/packages/projecteur

對於 Ubuntu,可以在項目的 github 頁面以及 Ubuntu 儲存庫 20.10 及更高版本中獲得軟體包。

免責聲明:我是Projecteur的作者

引用自:https://unix.stackexchange.com/questions/542299