https://wiki.archlinux.org/api.php?action=feedcontributions&user=Shua&feedformat=atomArchWiki - User contributions [en]2024-03-29T10:25:21ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Multitouch_displays&diff=294413Multitouch displays2014-01-25T23:35:44Z<p>Shua: fixed script to take -i option correctly</p>
<hr />
<div>[[Category:Other hardware]]<br />
{{Stub}}<br />
Since Linux Kernel 3.2, multitouch devices are handled by the {{ic|hid-multitouch}} module, see [[Kernel Modules]]. <br />
<br />
==Configuration (USB devices) ==<br />
Find the vendor ID (VID) and product ID (PID) for your touchscreen using {{ic|lsusb}}:<br />
{{hc|$ lsusb|<br />
...<br />
Bus 004 Device 002: ID 0eef:725e D-WAV Scientific Co., Ltd <br />
...<br />
}}<br />
Here, VID=0eef (eGalax) and PID=725e. Now, get the MT_CLASS_* definitions from [http://lxr.free-electrons.com/source/drivers/hid/hid-multitouch.c]. Currently vendor specific classes are available for 3M Cypress and eGalax. If none of this matches your device, you can try to experiment with the other MT_CLS_*. In this example<br />
#define MT_CLS_EGALAX 0x0103<br />
You need to convert MT_CLS_* to decimal (In this case, 0x0103 is 259 in decimal).<br />
<br />
After loading the {{ic|hid-multitouch}}, see [[Kernel Modules]], you need to pass the devices' options with<br />
# echo BUS VID PID MT_CLASS_* > /sys/module/hid_multitouch/drivers/hid\:hid-multitouch/new_id<br />
In this example, the touchscreen is an USB device, so BUS=3 and the previous command looks like this:<br />
# echo 3 0eef 725e 259 > /sys/module/hid_multitouch/drivers/hid\:hid-multitouch/new_id<br />
Reboot. If the touchscreen is detected you should submit your devices' details (relevant {{ic|lsusb}} line) to the [http://vger.kernel.org/vger-lists.html#linux-input linux-input mailing list].<br />
<br />
If the touchscreen is not working properly, you may need to install a specific driver for your touchscreen, see [[#Drivers]].<br />
<br />
== Rotating the touch screen ==<br />
Store and mark the following script executable (call the script to see its input options):<br />
{{bc|<nowiki><br />
#!/bin/bash<br />
<br />
## script to rotate touch screens<br />
## will include support for rotating specific monitors<br />
<br />
###############################################<br />
# #<br />
# Touch_rotate for Asus T101mt #<br />
# written by Mark Lee #<br />
# #<br />
###############################################<br />
<br />
function main () { ## main insertion function<br />
args=("$@"); ## store the arguments in an array<br />
check-arg; ## read and check the arguments<br />
resolve-rotate; ## resolve the rotation<br />
rotate-screen; ## rotate the screen<br />
}<br />
<br />
function help-man () { ## print the help manual<br />
echo "<br />
where options are:<br />
[usage]: touch_rotate [options]<br />
<br />
-r or -rotate | rotate the screen; ex. -r right<br />
| <left,right,normal,upside-down><br />
-c or -counter-clockwise | rotate the screen counter clockwise<br />
-m or -monitor | set the monitor to rotate; ex. -m native<br />
| <primary,external><br />
-i or -id | set the id of the touch screen device<br />
--help | print this help screen<br />
<br />
Examples:<br />
touch_rotate -m native -r right<br />
<br />
Press "Ctrl-C" to exit any time<br />
"<br />
}<br />
<br />
function check-arg () { ## read and check console arguments<br />
for ((i = 0; i <= ${#args}; i++)); do ## loop for all arguments passed<br />
case ${args[$i]} in ## parse each argument<br />
-c|-C|-counter-clockwise)<br />
counter="yes"; ## toggle to rotate counter clockwise<br />
;; <br />
-r|-R|-rotate|-Rotate)<br />
rot="${args[$[i + 1]]}"; ## set the new rotation<br />
;;<br />
-m|-M|-monitor|-Monitor)<br />
mon="${args[$[i + 1]]}"; ## set the monitor to control<br />
;;<br />
-i|-I|-id)<br />
id="${args[$[i + 1]]}"; ## set the id of the device<br />
;;<br />
-help|--help|/?) ## help menu<br />
help-man; ## print the help menu<br />
exit; ## exit the script<br />
;;<br />
-*) ## for all other options<br />
echo "Unrecognized option: ${args[$i]}"<br />
help-man; ## print the help menu<br />
;;<br />
esac;<br />
done;<br />
if [ -z "$mon" ]; then ## check if monitor was specified<br />
mon="primary"; ## set the monitor to be the primary monitor<br />
fi;<br />
if [ "$mon" == "primary" ]; then<br />
mon="$(xrandr | awk '$2~/^connected/ {print $1}')"; ## set the monitor to be the connected monitor<br />
fi;<br />
if [ "$counter" == "yes" ]; then ## if user wants to rotate counter clockwise<br />
rot=$(xrandr -q --verbose | awk "/$mon/ {print \$5}"); ## capture the current rotation<br />
resolve-rotate; ## convert the current rotation to an integer<br />
rot=$[$[int_rot + 1] % 4]; ## increment the rotation by one and divide by four<br />
fi;<br />
if [ -z "$rot" ]; then ## check if a rotation was specified<br />
echo "Which orientation do you want your display to be?";<br />
select rot in normal left upside-down right; do ## print menu of possible rotations<br />
break; ## break the loop<br />
done;<br />
fi;<br />
if [ -z "$id" ]; then ## if the id of the device is not specified<br />
id=$(xinput -list | awk '/MultiTouch/ {print $6}' | awk -F'=' '{print $2}'); ## get the id of the touch screen<br />
fi;<br />
}<br />
<br />
function resolve-rotate () { ## resolve the touch screen matrix<br />
case $rot in<br />
normal|0)<br />
int_rot=0;<br />
rot_mat="1 0 0 0 1 0"<br />
;;<br />
left|1)<br />
int_rot=1;<br />
rot_mat="0 -1 1 1 0 0"<br />
;;<br />
inverted|upside-down|2)<br />
int_rot=2;<br />
rot_mat="-1 0 1 0 -1 1"<br />
;;<br />
right|3)<br />
int_rot=3;<br />
rot_mat="0 1 0 -1 0 1"<br />
;;<br />
esac;<br />
}<br />
<br />
<br />
## touch cursor jumps around when in any other orientation than normal<br />
function rotate-screen () { ## rotate the touch screen<br />
xrandr -o $int_rot; ## rotate the display screen<br />
xinput set-float-prop $id "Coordinate Transformation Matrix" $rot_mat 0 0 1; ## rotate the touch screen<br />
}<br />
<br />
main $@; ## call the main function and pass console arguments<br />
</nowiki>}}<br />
<br />
==Drivers==<br />
<br />
{{Expansion}}<br />
<br />
===eGalax===<br />
<br />
The driver for eGalax tocushcreens is available from the [http://home.eeti.com.tw/web20/eGalaxTouchDriver/linuxDriver.htm eGalax website]. Also, it is availbale as {{AUR|xf86-input-egalax}} from the [[Arch User Repository]].<br />
<br />
====Invert Y-axis====<br />
If after installing the eGalax driver the Y-axis of the touchscreen is inverted, edit the file {{ic|/etc/eGTouchd.ini}} an change the value of {{ic|Direction}} from 0 to 2:<br />
{{hc|/etc/eGtouchd.ini|...<br />
DetectRotation 0<br />
'''Direction 2'''<br />
Orientation 0<br />
...}}<br />
<br />
==Gestures==<br />
<br />
If you want gestures in your window manager, install {{AUR|touchegg}} from the [[Arch User Repository]] and read its [https://code.google.com/p/touchegg/wiki/Main docs].</div>Shua