2008年9月26日 星期五

PenmountLPC + udev + Xorg.conf

FlyBook惡搞日誌 009

PenmountLPC是德國工程師用反向工程寫出驅動程式的。現在還提供deb安裝套件包喔~

問題是,隨著你開機的配備不同,比如說多隻滑鼠之類,它的設備檔就會跑掉,這樣X啟動時就不會對應到正確的dev。因此就需要udev

遙想起咖啡店還在4GB硬碟快爆炸的年代,站長們對於安裝新硬碟要MAKEDEV都心存忌憚,深怕一個不小心就會因為弄丟資料而遭到眾人唾棄,這樣大學剩下的三年會很難過。

udev系統的誕生除了有裝置配合自動產生,其中一個功能就是可以依據關鍵字來自動為設備檔產生連結。

這個penmountlpc.ko可以放進/etc/modules下來自行載入

[   35.212000] input: PenmountLPC TouchScreen as /class/input/input4
[   35.212000] penmountlpc.c: init finished

但是每次產生的可能是input3,有外接滑鼠可能是input4,非開機載入還有可能是78,偏偏xorg.conf裡面一定要描寫到這段,不然就會沒作用。還好ubuntu用udev有個功能可以用hotplug製造symlink。

原理很複雜,方法卻很簡單,首先確認

udevinfo -a -p /sys/class/input/event4

Udevinfo starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/class/input/input4/event4':
    KERNEL=="event4"
    SUBSYSTEM=="input"
    DRIVER==""
    ATTR{dev}=="13:68"

  looking at parent device '/class/input/input4':
    KERNELS=="input4"
    SUBSYSTEMS=="input"
    DRIVERS==""
    ATTRS{modalias}=="input:b0010v0000p0000e0000-e0,1,3,k110,ra0,1,mlsfw"
    ATTRS{uniq}==""
    ATTRS{phys}==""
   ATTRS{name}=="PenmountLPC TouchScreen"

選定關鍵字後,我是直接修改/etc/udev/rules.d/65-persistent-input.rules

因為這檔裡面開頭說input?都要跳到最後一行,所以我直接多加一行

KERNEL=="event?", SUBSYSTEMS=="input", ATTR{dev}=="13:6?", ATTRS{name}=="PenmountLPC TouchScreen", SYMLINK+="input/penmountlpc"

然後對應的xorg.conf改為

Section "InputDevice"
    Identifier "touchscreen"
    Driver "evtouch"
    Option "Device" "/dev/input/penmountlpc"
    Option "DeviceName" "touchscreen"
        Option        "MinX"        "42"
        Option        "MinY"        "48"
        Option        "MaxX"        "988"
        Option        "MaxY"        "992"
        Option        "x0"        "-31"
        Option        "y0"        "-1"
        Option        "x1"        "-22"
        Option        "y1"        "-3"
        Option        "x2"        "-1"
        Option        "y2"        "-5"
        Option        "x3"        "-43"
        Option        "y3"        "0"
        Option        "x4"        "-15"
        Option        "y4"        "0"
        Option        "x5"        "1"
        Option        "y5"        "-1"
        Option        "x6"        "-3"
        Option        "y6"        "1"
        Option        "x7"        "-5"
        Option        "y7"        "2"
        Option        "x8"        "2"
        Option        "y8"        "2"
#       Option "Calibrate" "1"
    Option "ReportingMode" "Raw"
    option  "TapTimer" "500"
    option  "LongTouchTimer" "800"
    option  "MoveLimit" "30"
    Option  "maybetapped_action" "click"
    Option  "maybetapped_button" "1"
    option  "longtouch_action" "click"
    option  "longtouch_button" "3"
    option  "oneandhalftap_action" "click"
    option  "oneandhalftap_button" "2" 
       Option "Emulate3Buttons"
        Option "Emulate3Timeout" "50"
        Option "SendCoreEvents" "On"
EndSection

Section "InputDevice"
    Identifier "dummy"
    Driver "void"
    Option "Device" "/dev/input/mice"
EndSection

這樣每次x都會自動抓到正確的裝置,而不需要手動修改xorg.conf。

沒有留言: