Re-map scancode - código de teclado integrado do MacBook Pro

4

Objeto

Eu leio este artigo do Wiki do Arch para tentar remapear o & scancode & keycode no meu Chakra 201710 + MacBook Pro 2015 (sem touchbar e USB-C):

  1. Reimprima o teclado incorporado da seguinte forma:

    | ORIGINAL || capslock | control | option(alt) | command(meta?) |
    | MAP TO   || ctrl     | ctrl    | super       | alt            |
    
  2. Não remapeie outro teclado USB externo. (nunca uso um teclado externo da Apple).

O que tentei (mas falhei, não funciona)

1. Encontre o ID do fornecedor / ID do produto / versão do teclado integrado

link

#  - Generic input devices match:
#      evdev:input:bZZZZvYYYYpXXXXeWWWW-VVVV
#    This matches on the kernel modalias of the input-device, mainly:
#    ZZZZ is the bus-id (see /usr/include/linux/input.h BUS_*), YYYY, XXXX and
#    WWW are the 4-digit hex uppercase vendor, product and version ID and VVVV
#    is an arbitrary length input-modalias describing the device capabilities.
#    The vendor, product and version ID for a device node "eventX" is listed
# in /sys/class/input/eventX/device/id.

Comando:

less /proc/bus/input/devices

Entendi:

I: Bus=0003 Vendor=05ac Product=0274 Version=0110
N: Name="Apple Inc. Apple Internal Keyboard / Trackpad"
P: Phys=usb-0000:00:14.0-12/input1
S: Sysfs=/devices/pci0000:00/0000:00:14.0/usb1/1-12/1-12:1.1/0003:05AC:0274.0004/input/input7
U: Uniq=D3H624316K1FTV4A63PS
H: Handlers=sysrq kbd leds event7
B: PROP=0
B: EV=120013
B: KEY=10000 0 0 0 1007b00011007 ff9f217ac14057ff ffbeffdfffefffff fffffffffffffffe
B: MSC=10
B: LED=1f

Portanto, o teclado integrado da Apple é evdev:input:b0003v05acp0274e0110*

2. Obter scancodes

Eu usei showkey --scancodes em TTY para obter um mapa padrão como este:

|           | scancode (hex) | keycode |
|-----------+----------------+---------|
| capslock  | 3a ba          |      58 |
|-----------+----------------+---------|
| fn        | -- --          |     464 |
| leftctrl  | 1d 9d          |      29 |
| leftalt   | 38 b8          |      56 |
| leftmeta  | e0 5b e0 db    |     125 |
|-----------+----------------+---------|
| rightctrl | e0 5c e0 dc    |     126 |
| rightalt  | e0 38 e0 b8    |     100 |

I don't know why the scancode of all keys mentioned above are large than 1 byte...

3. Criar arquivo de configuração em /etc/udev/hwdb.d/

Crie o arquivo /etc/udev/hwdb.d/10-apple-kb.hwdb com o seguinte conteúdo:

evdev:input:b0003v05acp0274e0110*
  KEYBOARD_KEY_3aba=leftctrl
  KEYBOARD_KEY_1d9d=leftctrl
  KEYBOARD_KEY_38b8=leftmeta
  KEYBOARD_KEY_e05be0db=leftalt
  KEYBOARD_KEY_e05ce0dc=rightctrl
  KEYBOARD_KEY_e038e0b8=rightalt

Em seguida, reinicie, não funcione ...

Update: use evtest to capture scancode.

Take Caps Lock for example:

 Event: time 1514827961.426158, -------------- SYN_REPORT ------------
 Event: time 1514827961.538086, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70039
 Event: time 1514827961.538086, type 1 (EV_KEY), code 58 (KEY_CAPSLOCK), value 0
 Event: time 1514827961.538086, -------------- SYN_REPORT ------------

So /etc/udev/hwdb.d/10-apple-kb.hwdb looks like this now:

evdev:input:b0003v05acp0274e0110*
  KEYBOARD_KEY_70039=leftctrl
  KEYBOARD_KEY_700e0=leftctrl
  KEYBOARD_KEY_700e2=leftmeta
  KEYBOARD_KEY_700e3=leftalt
  KEYBOARD_KEY_700e7=rightctrl
  KEYBOARD_KEY_700e6=rightalt

Unfortunately, not work either...

Tente também usar setkeycodes como este, ele disse que o erro:

$ sudo setkeycodes 3aba 29
setkeycodes: failed to set scancode 3aba to keycode 29: ioctl KDSETKEYCODE: Invalid argument
    
por kuanyui 31.12.2017 / 06:50

0 respostas