MPX 설치 완료 +_+

2009. 4. 29. 05:17 from 컴퓨터/Linux
멀티터치스크린 디바이스 드라이버 제작한다고 선언(?)한 후, 꼬박 한달여 기간이 지났다.

드라이버의 테스트를 위해선 X-window 내에서 두개의 포인터가 필요했다. 그래야 동시에 두좌표 이상이 되는지 확인할 수 있기 때문이다.;; 너무나 당연하다.

검색을 해보니, 새로운 윈도우 버전에서나 볼 수 있는 두개의 포인터 기술이 리눅스에선 이미 있었다.(역시!)
MPX(Multi-Pointer X server)라는 기술인데, Peter Hutterer라는 X input hacker가 개발한 것이 있었다.
그리고, 데모 동영상도 꽤 있었다. 하지만, 실제 구현하는 순서 같은 것은 거의 없었다 ㅡ.ㅡ^

최신 버전의 X-window를 설치하느라 꽤 삽질을 했었다. git, tar, jhbuild, deb 파일, apt-get, emerge 등....
결국은 jhbuild에서도 컴파일 에러를 수정해가면서 되게 했다.



위 동영상과 같이 두 개의 USB 마우스에서 두 개의 포인터는 나오게 했지만, 결국 두 개의 이벤트를 동시에 보여주는 프로그램이 없는 관계로 이정도로... 위 과정이 되기에도 꽤 많은 삽질이 있어서 아래에 기록해본다.

- http://www.x.org/wiki/JhBuildInstructions 페이지를 참고하여 jhbuild를 이용해서 빌드를 시작했다.
   # jhbuild -f modular-jhbuildrc build xserver xf86-video-nv xf86-input-keyboard
                                xf86-input-mouse
xorg-drivers xorg-libs xorg-apps

- 컴파일 과정에서 xf86Version.h 파일이 없다는 메시지가 자주 나와서, 그냥 /usr/include/xorg/xf86Version.h으로 지정해버렸다. 같은 디렉토리에 있는 어떤 파일들도 잘 참조가 되지 않아, 어찌어찌 통과하는 방향으로 했다. 중간에 asm/@!@!@.h 파일은 그냥 무시하고,..

- 기본 디렉토리(prefix)는 /root/xorg로 잡혀있으며, 해당 디렉토리/bin 에 startx 가 있는지 확인해야 하며, 없으면 다시 컴파일 시도한다.;;

- xorg.conf 파일의 작성... 여기서 실제로 많이 막혔다. 그래서 다시 컴파일하여 mouse와 keyboard 드라이버를 재로딩했다.

Section "ServerLayout"
        Identifier     "X.org Configured"
        Screen      0  "Screen0" 0 0
        #InputDevice    "Mouse0" "CorePointer"
        InputDevice    "Mouse0" "SendCoreEvents"
        InputDevice    "Mouse1" "SendCoreEvents"
        InputDevice    "Keyboard0" "CoreKeyboard"
        #InputDevice    "Keyboard0" "SendCoreEvents"
        Option         "AllowEmptyInput" "off"
        Option         "AutoAddDevices" "off"
EndSection

Section "Files"
        ModulePath   "/root/xorg/lib/xorg/modules"
        FontPath     "/usr/share/fonts/misc/"
        FontPath     "/usr/share/fonts/TTF/"
        FontPath     "/usr/share/fonts/OTF"
        FontPath     "/usr/share/fonts/Type1/"
        FontPath     "/usr/share/fonts/100dpi/"
        FontPath     "/usr/share/fonts/75dpi/"
EndSection

Section "Module"
        Load  "dbe"
        Load  "dri"
        Load  "record"
        Load  "extmod"
        Load  "xtrap"
        Load  "glx"
EndSection

Section "InputDevice"
        Identifier  "Keyboard0"
        Driver      "kbd"
        Option      "XkbRules" "xorg"
        Option      "XkbModel" "pc105"
        Option      "XkbLayout" "us"
EndSection

Section "InputDevice"
        Identifier  "Mouse0"
        Driver      "mouse"
        #Option     "Protocol" "PS/2"
        Option      "Protocol" "auto"
        #Option     "Protocol" "ExplorerPS/2"
        #Option     "Protocol" "IMPS/2"
        Option      "Device" "/dev/input/mouse1"
        #Option     "Device" "/dev/input/mice"
        #Option      "Device" "/dev/input/by-path/pci-0000:00:1d.0-usb-0:1:1.0-e
vent-mouse"
        #Option      "Device" "/dev/input/event2"

        Option      "ZAxisMapping" "4 5"
        #Option     "ZAxisMapping" "4 5 6 7"
        #Option      "Emulate3Buttons" "no"
EndSection

Section "InputDevice"
        Identifier  "Mouse1"
        Driver      "mouse"
        Option      "Protocol" "auto"
        #Option     "Protocol" "ExplorerPS/2"
        Option      "Device" "/dev/input/mouse2"
        Option      "ZAxisMapping" "4 5"
EndSection

Section "Monitor"
        #DisplaySize      380   300     # mm
        Identifier   "Monitor0"
        VendorName   "SAM"
        ModelName    "SyncMaster"
        HorizSync    30.0 - 81.0
        VertRefresh  56.0 - 75.0
        Option      "DPMS"
EndSection

Section "Device"
        ### Available Driver options are:-
        ### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
        ### <string>: "String", <freq>: "<f> Hz/kHz/MHz"
        ### [arg]: arg optional
        #Option     "SWcursor"                  # [<bool>]
        #Option     "HWcursor"                  # [<bool>]
        #Option     "NoAccel"                   # [<bool>]
        #Option     "ShadowFB"                  # [<bool>]
        #Option     "UseFBDev"                  # [<bool>]
        #Option     "Rotate"                    # [<str>]
        #Option     "VideoKey"                  # <i>
        #Option     "FlatPanel"                 # [<bool>]
        #Option     "FPDither"                  # [<bool>]
        #Option     "CrtcNumber"                # <i>
        #Option     "FPScale"                   # [<bool>]
        #Option     "FPTweak"                   # <i>
        #Option     "DualHead"                  # [<bool>]
        #Option     "ShadowFB"                  # [<bool>]
        #Option     "UseFBDev"                  # [<bool>]
        #Option     "Rotate"                    # [<str>]
        #Option     "VideoKey"                  # <i>
        #Option     "FlatPanel"                 # [<bool>]
        #Option     "FPDither"                  # [<bool>]
        #Option     "CrtcNumber"                # <i>
        #Option     "FPScale"                   # [<bool>]
        #Option     "FPTweak"                   # <i>
        #Option     "DualHead"                  # [<bool>]
        Identifier  "Card0"
        Driver      "nv"
        VendorName  "nVidia Corporation"
        BoardName   "NV18 [GeForce4 MX 440 AGP 8x]"
        BusID       "PCI:1:0:0"
EndSection

Section "Screen"
        Identifier "Screen0"
        Device     "Card0"
        Monitor    "Monitor0"
        SubSection "Display"
                Viewport   0 0
                Depth     1
        EndSubSection
        SubSection "Display"
                Viewport   0 0
                Depth     4
        EndSubSection
        SubSection "Display"
                Viewport   0 0
                Depth     8
        EndSubSection
        SubSection "Display"
                Viewport   0 0
                Depth     15
        EndSubSection
        SubSection "Display"
                Viewport   0 0
                Depth     16
        EndSubSection
        SubSection "Display"
                Viewport   0 0
                Depth     24
        EndSubSection
EndSection


위에 살펴보면 알겠지만,
 1. Option "AllowEmptyInput" "off" 이 없으면 시작할 때 에러가 발생했다. (최신 버전에만 그러는 듯)
 2. ModulePath "/root/xorg/lib/xorg/modules" 도 꽤나 중요하다.
     나는 /root/xorg에 설치했기 때문에, 모든 모듈들이 해당 디렉토리 내에 존재했었다.
 3. InputDevice "Mouse0" "SendCoreEvents" 는 마우스 두개가 될 경우, 이벤트를 따로 발생하라는 의미이다.
     원래 하나의 포인터로 사용할 때에는 "CorePointer" 값이다.

- 위 설정대로 x-window가 실행되는지 해봐야 한다. (/root/xorg/bin 내에 있는 startx 나 xinit가 실행되도록 유도해야 한다.)
  # export PATH=/root/xorg/bin:$PATH
  # export LD_LIBRARY_PATH=/root/xorg/lib
  # startx -- -verbose 6

- 나오는 메시지를 잘 살펴보고, 에러가 있으면 나름대로 해결해야 한다. 나에게는 xcb 관련 에러가 발생했는데, 이미 gentoo 패키지 시스템인 emerge를 이용해서 x-window를 /usr에 설치된 상황이기 때문에 이곳에 있는 xcb 자료를 복사해서 사용했다.
  # cp -ap /usr/share/X11/xkb/* /root/xorg/share/X11/xkb/

- 마우스 관련 에러도 많이 나왔었다. 이것은 실제로 /dev/input/mouse1에 접근해보는 것으로 실제 동작하는 지 알 수 있다.
  # cat /dev/input/mouse1  (실행한 상태에서 마우스를 움직이거나 클릭해본 후, 이상한 쓰레기 값이 나오면 동작하는 것이다)
   물론, 두번째 마우스는 /dev/input/mouse2 가 될 것이다. 여기서 동작하는 값으로 xorg.conf 에 설정해주어야 하는 것은 당연하다.
   (원래 보통 /dev/input/mice로 되어 있을 것이다.)

- 이제 에러를 해결했으면, x-window가 정상적으로 뜰 것이다. 아직 포인터가 하나 뿐일 것이다.
   xinput를 통해 설정을 해주어야 하기 때문이다. (x-window 내 xterm이 띄워져 있을 것이다. 그 안에서 실행해야 한다.)
  # xinput --list --short
  "Virtual core pointer"  id=0    [XPointer]
  "Virtual core keyboard" id=1    [XKeyboard]
  "Virtual core Xtst pointer"     id=2    [XExtensionPointer]
  "Virtual core Xtst keyboard"    id=3    [XExtensionKeyboard]
  "Mouse0"        id=4    [XExtensionPointer]
  "Mouse1"        id=5    [XExtensionPointer]
  "Keyboard0"     id=6    [XExtensionKeyboard]
  "Mouse0"        id=7    [XExtensionPointer]
  # xinput --create-master "foobar"
  # xinput --reattach "Mouse1" "foobar pointer"
    (foobar pointer로 방향을 바꾸는 것으로 따로 동작이 가능해진다)

- 아래와 같이 포인터 두 개가 나오면 성공한 것이다.

포인터 두개 모습

I 포인터 두개의 모습



포인터 두개 모습

X 포인터 두개의 모습



동작이 제대로 되는지 확인하기 위해 나는 emerge gimp로 gimp를 설치하였다. 하지만, 아직, 한 쪽 마우스가 클릭한 상태에서 다른 마우스 클릭이 제대로 먹히지 않는데, 아마도 /dev/input/mice와 같이 중첩사용되는 장치 이벤트만 처리하나 보다. 아직 모르겠다.

- 마지막으로 이 xinput를 개발한 사람 블로그(?)에 샘플 소스가 있어서 컴파일을 해보았다.
  * 사이트 : http://wearables.unisa.edu.au/mpx/?q=xi2_sample
  # gcc -o xi2_sample xi2_sample.c `pkg-config --cflags --libs xi`
    -I/root/xorg/include -L/root/xorg/lib


참고 사이트 정보 :
1. http://live.gnome.org/Metacity/MpxHowto - How to install MPX and Metacity
2. http://wearables.unisa.edu.au/mpx/ - MPX 공식 홈페이지
3. http://www.x.org/wiki/JhBuildInstructions - JhBuildInstructions 설치방법

p.s. 이젠 멀티터치 디바이스 드라이버를 제작하기만 하면 된다 ㅡ.ㅜ
Posted by wbhacker :