Xorg 1.4 XInput Hotplug

Xorg 1.4 開始支援 hal based 的 xinput hotplug,也就是說滑鼠跟鍵盤這些設備可以拔來拔去而不用在 xorg.conf 裡面設定,再加上越來越多 driver 可以 auto-configuration,xorg.conf 裡面的東西越來越少了。

xorg 的 evdev driver 是利用 linux kernel 的 evdev 支援,來使用滑鼠、鍵盤等多種設備,我的 Logitech V450 就一定要用 evdev 才能支援所有的按鍵。

無奈 Debian Sid 中的 Xorg 以及 evdev 都非常的新,但是一些升級的配套措施跟文件跟不上,導致最近發生許多問題,相關的 bug report 有 #443292#442316

今天終於把滑鼠鍵盤都設定好了,關鍵在於 hal 的設定跟 gnome 的設定。

首先是設定 hal,因為 hal 預設只設定了使用 evdev,但是沒有顧慮到非使用 us layout 的人,導致升級之後鍵盤 layout 大亂,目前暫時取消了這項設定,我們可以從 /usr/share/doc/hal/examples/10-x11-input.fdi 把設定撿回
/etc/hal/fdi/policy/,內容如下:

<?xml version="1.0" encoding="ISO-8859-1"?>
<deviceinfo version="0.2">
  <device>
    <!-- FIXME: Support tablets too. -->
    <match key="info.capabilities" contains="input.mouse">
      <merge key="input.x11_driver" type="string">mouse</merge>
      <match key="/org/freedesktop/Hal/devices/computer:system.kernel.name"
              string="Linux">
        <merge key="input.x11_driver" type="string">evdev</merge>
      </match>
    </match>
  
    <match key="info.capabilities" contains="input.keys">
      <!-- If we're using Linux, we use evdev by default (falling back to
            keyboard otherwise). -->
      <merge key="input.x11_driver" type="string">keyboard</merge>
      <match key="/org/freedesktop/Hal/devices/computer:system.kernel.name"
              string="Linux">
        <merge key="input.x11_driver" type="string">evdev</merge>
        <merge key="input.xkb.rules" type="string">xorg</merge>
        <merge key="input.xkb.model" type="string">evdev</merge>
        <merge key="input.xkb.layout" type="string">dvorak</merge>
      </match>
    </match>
  
  </device>
</deviceinfo>

其中關於鍵盤 layout、model、rules 的設定是我加上去的。滑鼠不需更動即可 hotplug 使用。

接下來關鍵的地方是,如果你使用 gnome 的話,記得把 keyboard model 改成 evdev,如圖:

gnome keyboard setting

最後,xorg.conf 就可以清乾淨了:

Section "Device"
        Identifier      "intel"
        Driver          "intel"
        Option          "AccelMethod"     "XAA"
        Option          "XAANoOffScreenPixmaps" "True"
EndSection
  
Section "InputDevice"
        Identifier      "Synaptics Touchpad"
        Driver          "synaptics"
        Option          "CorePointer"
        Option          "Device"                "/dev/input/event9"
        Option          "Protocol"              "auto-dev"
        Option          "SHMConfig"             "on"
        Option          "LeftEdge"              "1100"
        Option          "RightEdge"             "5800"
        Option          "TopEdge"               "1600"
        Option          "BottomEdge"    "4200"
        Option          "HorizEdgeScroll" "on"
EndSection
  
Section "Monitor"
        Identifier      "Configured Monitor"
        Option          "DPMS"
        DisplaySize     330 200
EndSection
  
Section "Screen"
        Identifier      "Default Screen"
        Monitor         "Configured Monitor"
        DefaultDepth    24
        SubSection "Display"
                Modes           "1280x768" "1024x768"
        EndSubSection
EndSection