이 장은 주 입력장치(core pointer)를 변경하는 방법과 버튼 맵핑하는 방법을 설명한다.
다음과 같이 XF86Config의 Xinput Section에 AlwaysCore을 설정하지 않았다면 현재 상태에서는 마우스만 사용할 수 있을 것이다. 그렇다면 타블렛을 사용하기 위해서는 X-window을 재실행해야 하나? 그렇지는 않다.
Section "Xinput"
SubSection "WacomStylus"
Port "/dev/ttyS0"
DeviceName "Wacom"
Mode Absolute
Suppress 6
EndSubSection
SubSection "WacomEraser"
Port "/dev/ttyS0"
Mode Absolute
EndSubSection
...
EndSection
xsetpointer는 주 입력 장치를 바꿔주는 프로그램이다.
xsetpointer < 장치명 > xsetpointer -l
먼저 사용 가능한 장치 목록을 보자.
xsetpointer -l
"pointer" [XPointer]
"keyboard" [XKeyboard]
"SWITCH" [XExtensionDevice]
"Wacom" [XExtensionDevice]
"ERASER" [XExtensionDevice]
"CURSOR" [XExtensionDevice]
pointer는 마우스, keyboard는 키보드, 나머지는 타블렛 장치들이다. 주 입력 장치를 타블렛으로 바꿔보자. 타블렛을 주 입력 장치로 바꾸면 마우스는 사용할 수 없게 된다.
truefeel: # xsetpointer wacom
모드를 전환하는 xsetmode은 사용이 간단하므로 특별히 설명할 것이 없다.
xsetmode <장치명> (ABSOLUTE|RELATIVE)
xsetmode wacom absolute
xmodmap은 키보드 및 포인터(마우스, 타블렛 등) 버튼 맵핑에 사용하는 유틸리티 이다. 키보드의 키 맵핑을 확인하거나 변경하는데 한 번씩은 사용해 봤을 것이다. 키맵핑은 이글의 주제와 어울리지 않으므로 포인터의 버튼 맵핑에 대해서만 설명한다.
xmodmap -pp xmodmap -e "pointer = 논리버튼1 논리버튼2 논리버튼3 ..."
xmodmap은 주 입력 장치(core pointer)로 지정된 장치의 버튼을 맵핑하므로 설정 전에 반드시 주 입력 장치를 테블렛 장치로 빠꿔야 한다. 버튼 맵핑을 확인해 보자. 물리적 버튼과 논리적 버튼이 같음을 알 수 있다.
truefeel:~# xsetpointer wacom
truefeel:~# xmodmap -pp
There are 4 pointer buttons defined.
Physical Button
Button Code
1 1
2 2
3 3
4 4
물리적 버튼 1은 논리적 버튼 2로, 물리적 버튼 2는 논리적 버튼 1로, 물리적 버튼 3은 논리적 버튼 3으로, 물리적 버튼 4은 논리적 버튼 4로 바꿔보자.
xmodmap -e "pointer = 2 1 3 4"
Frederic Lepied가 만든 xinput은 Wacom 타블렛과 같은 XInput 장치를 테스트하고 설정하는 유틸리티다. xinput 유틸리티는 앞에서 설명한 xsetpointer, xsetmode, xmodmap의 기능을 모두 가지고 있다.
xinput은 ftp://ftp.x.org/contrib/utilities/xinput-1.2.tar.gz 에서 구할 수 있다. 설치는 우선 tar로 푼 다음 Imakefile -> Makefile 생성(xmkmf)하고 2번의 make 과정을 거치면 된다.
truefeel:~# tar xvfz xinput-1.2.tar.gz
xinput-1.2/
xinput-1.2/xinput.man
xinput-1.2/Imakefile
xinput-1.2/README
xinput-1.2/ChangeLog
xinput-1.2/COPYRIGHT
...
truefeel:~# cd xinput-1.2
truefeel:~/xinput-1.2# xmkmf -a
truefeel:~/xinput-1.2# make install
truefeel:~/xinput-1.2# make install.man
만들어진 xinput과 xinput 맨페이지는 각각 /usr/X11R6/bin, /usr/X11R6/man/man1에 설치된다.
xinput 사용할 때 주의할 것은 장치명의 대소문자를 구분 한다는 것이다. 장치명은 XF86Config의 XInput 섹션에서 DeviceName 옵션으로 지정한다.
SubSection "WacomStylus"
Port "/dev/ttyS0"
DeviceName "Wacom"
EndSubSection
이제 xinput 기능을 상세하게 알아보자.
지정한 입력장치에 대한 상세한 정보를 보여준다. 장치명을 지정하지 않으면 모든 입력장치에 대한 정보를 출력한다. 상당히 자세한 정보를 보여주므로 가능하면 장치명을 지정하기 바란다.
truefeel:~# xinput list Wacom "Wacom" id=3 [XExtensionDevice] Num_keys is 32 Min_keycode is 8 Max_keycode is 39 Num_buttons is 4 Num_axes is 5 Mode is Absolute Motion_buffer is 0 Axis 0 : Min_value is 0 Max_value is 10240 Resolution is 499999 Axis 1 : Min_value is 0 Max_value is 7680 Resolution is 499999 ...
단순히 입력 장치의 목록만을 확인하고 싶다면 앞서 배운 xsetpointer -l을 이용하거나 xinput 을 다음과 같이 이용해도 된다.
xinput list|grep '^"'
주 입력장치를 변경한다. xsetpointer < 장치명 > 과 같은 기능을 한다.
지정한 입력장치의 모드를 절대 또는 상대 모드로 바꾼다. xsetmode < 장치명 > ABSOLUTE|RELATIVE 과 같은 기능을 한다.
입력장치의 물리버튼을 지정한 순서대로 논리버튼으로 매핑시킨다.
xinput set-button-map Wacom 2 1 3 4
입력장치의 상태를 확인한다.
truefeel:~# xinput query-state Wacom 3 classes : KeyClass key[0]=up key[1]=up ... key[31]=up ButtonClass button[1]=up button[2]=up button[3]=up button[4]=up ValuatorClass Mode=Absolute Proximity=In valuator[0]=4389 valuator[1]=5728 valuator[2]=-128 valuator[3]=30 valuator[4]=-9
위의 실행 결과는 키 코드 상태(KeyClass), 버튼 상태(ButtonClass), 축 상태(ValuatorClass) 등 3가지 상태를 제공한다. 32개의 키, 4개의 버튼이 동작하고 있으며 모드는 절대 모드(Mode=Absolute), 펜 또는 에어브러쉬가 입력받을 수 있는 거리(Proximity=In)에 있음을 알 수 있다. 축 상태가 나타내는 값의 의미는 다음과 같다.
입력장치를 테스트하는 기능으로 장치를 통해 입력되는 모든 이벤트를 연속적으로 보여준다. 테스트를 끝내려면 Ctrl+C를 누른다.
-proximity : 접근성까지 표시해준다. proximity in / proximity out
truefeel:~# xinput test -proximity Wacom ... motion a[0]=4572 a[1]=5142 a[2]=-128 a[3]=30 a[4]=-12 motion a[0]=4563 a[1]=5200 a[2]=-128 a[3]=30 a[4]=-12 motion a[0]=4553 a[1]=5261 a[2]=-128 a[3]=30 a[4]=-14 button release 2 a[0]=4553 a[1]=5261 a[2]=0 a[3]=30 a[4]=-13 proximity out a[0]=4553 a[1]=5261 a[2]=-128 a[3]=30 a[4]=-14 motion a[0]=4571 a[1]=5259 a[2]=-128 a[3]=27 a[4]=-10 proximity out a[0]=4606 a[1]=5208 a[2]=-128 a[3]=29 a[4]=-11 proximity in a[0]=4606 a[1]=5208 a[2]=-128 a[3]=29 a[4]=-11 motion a[0]=6031 a[1]=4948 a[2]=-128 a[3]=-14 a[4]=13 motion a[0]=6085 a[1]=4996 a[2]=-128 a[3]=-15 a[4]=14 ...