Xorg 1.5 XInput Hotplug

之前寫過 Xorg 1.4 XInput Hotplug,提到 xorg, evdev 可以利用 hal 自動偵測硬體載入 driver 與設定參數,而即將 release 的 Xorg 1.5 又新增了一些可以在 hal policy 裡設定的參數:

  • input.x11_driver 可以設定這個 device 要使用的 driver,對應到 xorg.conf 的 Driver 選項
  • input.x11_options.<option name> 則可以設定任意可以用 xorg.conf 裡的 Option 設定的選項 (除了 Option Device,因為 hal 已經知道是甚麼 device)

如今我的 /etc/hal/fdi/policy/10-x11-input.fdi 長這樣:

<?#63a35c;">xml #795da3;">version="1.0" #795da3;">encoding="ISO-8859-1"?>
<#63a35c;">deviceinfo #795da3;">version="0.2">
    <#63a35c;">device>
        <#63a35c;">match #795da3;">key="info.capabilities" #795da3;">contains="input.mouse">
            <#63a35c;">merge #795da3;">key="input.x11_driver" #795da3;">type="string">mouse</#63a35c;">merge>
            <#63a35c;">match #795da3;">key="/org/freedesktop/Hal/devices/computer:system.kernel.name"
                #795da3;">string="Linux">
                <#63a35c;">merge #795da3;">key="input.x11_driver" #795da3;">type="string">evdev</#63a35c;">merge>
            </#63a35c;">match>
        </#63a35c;">match>
    
    <#63a35c;">match #795da3;">key="info.capabilities" #795da3;">contains="input.keys">
        <#63a35c;">merge #795da3;">key="input.x11_options.XkbRules" #795da3;">type="string">base</#63a35c;">merge>
        <!-- If we're using Linux, we use evdev by default (falling back to
        keyboard otherwise). -->
        <#63a35c;">merge #795da3;">key="input.x11_driver" #795da3;">type="string">keyboard</#63a35c;">merge>
        <#63a35c;">merge #795da3;">key="input.x11_options.XkbModel" #795da3;">type="string">pc105</#63a35c;">merge>
        <#63a35c;">match #795da3;">key="/org/freedesktop/Hal/devices/computer:system.kernel.name"
            #795da3;">string="Linux">
            <#63a35c;">merge #795da3;">key="input.x11_driver" #795da3;">type="string">evdev</#63a35c;">merge>
            <#63a35c;">merge #795da3;">key="input.x11_options.XkbModel" #795da3;">type="string">evdev</#63a35c;">merge>
        </#63a35c;">match>
        <#63a35c;">merge #795da3;">key="input.x11_options.XkbVariant" #795da3;">type="string" />
        <#63a35c;">merge #795da3;">key="input.x11_options.XkbLayout" #795da3;">type="string">dvorak</#63a35c;">merge>
        <#63a35c;">merge #795da3;">key="input.x11_options.XkbOptions" #795da3;">type="string">ctrl:nocaps</#63a35c;">merge>
    </#63a35c;">match>
    <#63a35c;">match #795da3;">key="info.capabilities" #795da3;">contains="input.touchpad">
        <#63a35c;">merge #795da3;">key="input.x11_driver" #795da3;">type="string">synaptics</#63a35c;">merge>
        <#63a35c;">merge #795da3;">key="input.x11_options.Protocol" #795da3;">type="string">auto-dev</#63a35c;">merge>
        <#63a35c;">merge #795da3;">key="input.x11_options.SHMConfig" #795da3;">type="string">on</#63a35c;">merge>
        <#63a35c;">merge #795da3;">key="input.x11_options.LeftEdge" #795da3;">type="string">1100</#63a35c;">merge>
        <#63a35c;">merge #795da3;">key="input.x11_options.RightEdge" #795da3;">type="string">5800</#63a35c;">merge>
        <#63a35c;">merge #795da3;">key="input.x11_options.TopEdge" #795da3;">type="string">1600</#63a35c;">merge>
        <#63a35c;">merge #795da3;">key="input.x11_options.BottomEdge" #795da3;">type="string">4200</#63a35c;">merge>
        <#63a35c;">merge #795da3;">key="input.x11_options.HorizEdgeScroll" #795da3;">type="string">on</#63a35c;">merge>
    </#63a35c;">match>
    </#63a35c;">device>
</#63a35c;">deviceinfo>

我的 /etc/X11/xorg.conf 只剩下必要的:

Section "Device"
    Identifier  "i915gm"
    Driver      "intel"
EndSection
    
Section "Screen"
    Identifier  "Default Screen"
    Device      "i915gm"
    DefaultDepth    24
    SubSection "Display"
        Modes       "1280x768"
        Virtual     1280 1792
    EndSubSection
EndSection

X 啟動的 log 如下:

(II) config/hal: Adding input device SynPS/2 Synaptics TouchPad
(II) LoadModule: "synaptics"
    
(II) Loading /usr/lib/xorg/modules/input//synaptics_drv.so
(II) Module synaptics: vendor="X.Org Foundation"
        compiled for 1.4.99.906, module version = 0.15.0
        Module class: X.Org XInput Driver
        ABI class: X.Org XInput driver, version 2.1
(II) Synaptics touchpad driver version 0.15.0
(**) Option "Device" "/dev/input/event8"
(**) Option "SHMConfig" "on"
(**) Option "LeftEdge" "1100"
(**) Option "RightEdge" "5800"
(**) Option "TopEdge" "1600"
(**) Option "BottomEdge" "4200"
(**) Option "HorizEdgeScroll" "on"
(--) SynPS/2 Synaptics TouchPad touchpad found
(**) SynPS/2 Synaptics TouchPad: always reports core events
(II) XINPUT: Adding extended input device "SynPS/2 Synaptics TouchPad" (type: MOUSE)
(--) SynPS/2 Synaptics TouchPad touchpad found

未來各 distro 可以提供預設的 fdi 檔,常見的 input device 都可以隨插即用 🙂


已發佈

分類:

,

作者:

標籤: