'마우스'에 해당되는 글 2건

  1. 2009.05.18 리눅스와 윈도우에서 키보드 마우스 공유하기
  2. 2009.04.29 MPX 설치 완료 +_+

현재 사용하고 있는 상태는 리눅스 데스크탑 1대, 윈도우 XP 데스크탑 1대 그리고 윈도우 XP 노트북 1대.
하지만, 이리저리 옮겨가며 키보드, 마우스를 사용하긴 여긴 힘든게 아니다 ㅡ.ㅜ
또한, 데스크탑 2대는 키보드, 마우스, 모니터 각 1대로 그냥 여기 꼽았다, 뺐다 쓰고 있는 상황이다.
이전에는 키보드,마우스,모니터 공유기(?)가 있어서 사용가능했었는데, 필요 없어서 누구 줘버렸었다 ㅡ.ㅜ;

윈도우 XP 두대는 Synergy(http://synergy.sf.net 에서 Open Source로 진행 중인 프로젝트이다, http://synergy2.sourceforge.net 인 것 같다.)를 이용해서 공유는 해봤었다.
어느 날인가 이 Synergy가 리눅스에서도 지원되는지는 잘 몰랐었는데, 소스포지닷넷(sf.net)에서 지원하는 것보면 거의 리눅스용인데... 생각하면서 살펴보니, 리눅스에서도 지원한 걸 봤던 기억이 난다.

리눅스는 아직 해보지 않았었다. 하지만, 생각보다 간단했다 ㅎㅎ

일단은 리눅스가 어떤 리눅스인지에 따라 설치 방법이 달라지겠지만, Synergy 리눅스용 프로그램을 어떻게 구해보면 금방 가능해진다.
원래는 위 사이트에서 다운로드가 되어야하는데, 어찌된 영문인지 다운로드 페이지가 뜨질 않았다. ㅡ.ㅜ
하는 수 없이.. 젠투(Gentoo) 리눅스를 사용하고 있는 상황이라 emerge 패키지 시스템을 사용해서 설치하는 수 밖에..

# emerge -s synergy
Searching...
[ Results for search key : synergy ]
[ Applications found : 1 ]

*  x11-misc/synergy
      Latest version available: 1.3.1
      Latest version installed: 1.3.1
      Size of files: 774 kB
      Homepage:      http://synergy2.sourceforge.net/
      Description:   Lets you easily share a single mouse and keyboard between multiple computers.
      License:       GPL-2

패키지가 있어서 다행이다. 설치는 아주 간단하다.

# emerge synergy

그러면 /usr/bin 폴더에 synergyc와 synergys 파일이 생성되게 되는데, 이 파일이 각각 클라이언트와 서버 역할을 할 수 있도록 한다.
일단, 도움말을 보고..

# synergyc --help
Usage: synergyc [--daemon|--no-daemon] [--debug <level>] [--display <display>] [--name <screen-name>] [--restart|--no-restart] <server-address>

Start the synergy mouse/keyboard sharing server.

  -d, --debug <level>      filter out log messages with priorty below level.
                           level may be: FATAL, ERROR, WARNING, NOTE, INFO,
                           DEBUG, DEBUG1, DEBUG2.
      --display <display>  connect to the X server at <display>
  -f, --no-daemon          run the client in the foreground.
*     --daemon             run the client as a daemon.
  -n, --name <screen-name> use screen-name instead the hostname to identify
                           ourself to the server.
  -1, --no-restart         do not try to restart the client if it fails for
                           some reason.
*     --restart            restart the client automatically if it fails.
  -h, --help               display this help and exit.
      --version            display version information and exit.

* marks defaults.

The server address is of the form: [<hostname>][:<port>].  The hostname
must be the address or hostname of the server.  The port overrides the
default port, 24800.

Where log messages go depends on the platform and whether or not the
client is running as a daemon.

이미 노트북을 서버로 사용해서 키보드, 마우스를 사용하고 있으니, 리눅스에선 클라이언트로 해서 노트북에 접속하면 된다.

# synergyc --no-daemon --display localhost:1 --name desktop-linux 서버IP주소
INFO: synergyc.cpp,716: Synergy client 1.3.1 on Linux 2.6.27-gentoo-r10 #1 SMP Fri Apr 17 12:14:01 KST 2009 i686
DEBUG: CXWindowsScreen.cpp,841: XOpenDisplay("localhost:1")
DEBUG: CXWindowsScreenSaver.cpp,339: xscreensaver window: 0x00000000
DEBUG: CXWindowsScreen.cpp,111: screen shape: 0,0 1280x1024
DEBUG: CXWindowsScreen.cpp,112: window is 0x00600004
DEBUG: CScreen.cpp,38: opened display
NOTE: synergyc.cpp,330: started client
DEBUG: CXWindowsClipboard.cpp,313: open clipboard 0
DEBUG: CXWindowsClipboard.cpp,266: empty clipboard 0
DEBUG: CXWindowsClipboard.cpp,289: grabbed clipboard 0
DEBUG: CXWindowsClipboard.cpp,348: close clipboard 0
DEBUG: CXWindowsClipboard.cpp,313: open clipboard 1
DEBUG: CXWindowsClipboard.cpp,266: empty clipboard 1
DEBUG: CXWindowsClipboard.cpp,289: grabbed clipboard 1
DEBUG: CXWindowsClipboard.cpp,348: close clipboard 1
NOTE: synergyc.cpp,247: connected to server
INFO: CScreen.cpp,98: entering screen
DEBUG: CServerProxy.cpp,523: recv clipboard 0 size=1328
DEBUG: CXWindowsClipboard.cpp,313: open clipboard 0
DEBUG: CXWindowsClipboard.cpp,266: empty clipboard 0
DEBUG: CXWindowsClipboard.cpp,289: grabbed clipboard 0
DEBUG: CXWindowsClipboard.cpp,300: add 1316 bytes to clipboard 0 format: 0
DEBUG: CXWindowsClipboard.cpp,348: close clipboard 0
DEBUG: CServerProxy.cpp,523: recv clipboard 1 size=1328
DEBUG: CXWindowsClipboard.cpp,313: open clipboard 1
DEBUG: CXWindowsClipboard.cpp,266: empty clipboard 1
DEBUG: CXWindowsClipboard.cpp,289: grabbed clipboard 1
DEBUG: CXWindowsClipboard.cpp,300: add 1316 bytes to clipboard 1 format: 0
DEBUG: CXWindowsClipboard.cpp,348: close clipboard 1
INFO: CScreen.cpp,116: leaving screen

간단히 synergy 서버 역할을 하고 있는 노트북에선 아래와 같은 설정만 해놓으면 된다.
나 같은 경우에는 노트북이 오른쪽에 있고, 리눅스 데스크탑이 왼쪽에 있는 상황. 그리고 XP 데스크탑이 위쪽에 있는 것으로 설정하였다.
즉, 리눅스 데스크탑에서 화면 오른쪽으로 이동하면, 노트북 화면으로 이동되는 것이다.
 - desktop : 윈도우 XP 데스크탑 (시너지 클라이언트)
 - desktop-linux : Gentoo Linux 데스크탑 (시너지 클라이언트)
 - notebook : 윈도우 XP 노트북로 여기에 연결되어 있는 키보드와 마우스 사용함 (시너지 서버)


이렇게 서버에서 설정된 상황에서 리눅스에서 시너지 클라이언트(synergyc)로 접속하면 된다.

리눅스 상에선 X 윈도 화면이 나오는 디스플레이 번호를 잘 부여해야 한다.

나의 경우에는 ./start_xserver 실행하여 Xserver를 실행하고, 다른 ssh 화면에서 ./start_xclient 실행하여 Xclient를 실행하고, 또 다른 ssh 화면에서 ./start_mpwm 실행하여 mpwm(윈도우 매니저)를 실행한다. 그리고 또 다른 ssh 화면에서 디스플레이 화면을 1번으로 설정하고, xterm을 띄운다. 이러면, 리눅스 상에 있는 모니터엔 디스플레이 화면 1을 사용하는 Xwindow가 띄워진 상태가 된다. 이 상태에서 위에서 적힌 synergyc를 실행해야 해당 디스플레이 화면에 마우스 포인터가 나오게 되는 것이다.

참고를 위해 바로 위에서 사용한 쉘 스크립트를 적어본다.

# vim start_xserver.sh

#!/bin/bash

export LD_LIBRARY_PATH=/root/xorg/lib
/root/xorg/bin/xinit -- /root/xorg/bin/Xorg -verbose 6 -config mpx.xorg.conf



# vim start_xclient.sh

#!/bin/bash

export LD_LIBRARY_PATH=/root/xorg/lib
/root/xorg/bin/Xorg -ac -config mpx.xorg.conf :1



# vim start_mpwm.sh

#!/bin/bash

export LD_LIBRARY_PATH=/root/xorg/lib
export DISPLAY=localhost:1
/root/xorg/bin/mpwm



# vim c.sh

#!/bin/bash

export PATH=/root/xorg/bin:$PATH
export LD_LIBRARY_PATH=/root/xorg/lib
export DISPLAY=localhost:1



위에 있는 c.sh를 이용해 source c.sh로 실행하여, 현재 쉘 환경에 적용한 후, xerm을 실행하면 된다.

Posted by wbhacker :

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 :