Comment 11 for bug 939868

Revision history for this message
Thomas B Homburg (thomasbhomburg) wrote :

Hello

The file /usr/share/doc/udev/README.keymap.txt.gz describe steps to find the udev key mapping for your device. And if you find the correct keymap, the file also details how you can submit your keymap to the udev developers and fix the keyboard for all matching laptops in the future.

I don't have the exact same Sony VPC model (VPCCB4C5E) as the others mentioned in this bug.

Steps to fix keymap (that I used)

1. Find keyboard input device:
  $ /lib/udev/findkeyboards
  ----
    AT keyboard: input/event2
    module: input/event3
  ----

  The keys you are fixing might be from either of the devices, so you should do the following steps for each device.

2. Find scan codes:
  $ /lib/udev/keymap -i input/event3 # And press the key(-combo) you are fixing, I pressed fn+f1
  ---
    Press ESC to finish, or Control-C if this device is not your primary keyboard
    scan code: 0x0C key code: f21
  ---

  The scan code here (0x0C) is wrong! (At least on my system). You have to substract 7 from the code
  to get the usable value (for the keymap): 0x0C - 7 = 0x05

3. Find the key code:
  /usr/include/linux/input.h
  Search for the constants: "KEY_" and convert the rest to lowercase:
    KEY_F21 > f21
    KEY_BRIGHTNESSDOWN > brightnessdown
  Touchpad toggle: Do not use the KEY_touchpad_toggle. Instead use the f21 for toggling touchpad.
  This took me a long time to figure out.

4. Construct the keymap: /etc/udev/keymaps/module-sony-vpc
  Look at /lib/udev/keymaps/module-sony-vgn (or the attached module-sony-vpc) as an example.
  The format is:

    <scan code> <key code>

   eg.
   0x05 f21
   0x0A brightnessdown

5. Build the udev rule. The udev rule matches the laptop and execute the keymap on boot. My attached rule: sony-vpc.conf
    should match all Sony VPC laptops: The "VPC*" pattern should match /sys/devices/virtual/dmi/id/product_name

6. The result should be:
  /etc/udev/keymaps/module-sony-vpc
  /etc/udev/rules.d/sony-vpc.rules