转自:http://www.cnblogs.com/sky1991/archive/2013/06/03/3114702.html

http://www.ptrackapp.com/apclassys-notes/embedded-linux-multitouch/

Embedded Linux Multitouch with Qt, TUIO, and TSLIB

This tutorial describes how to set up multi-touch and single-touch touchscreen input
for Qt for embedded Linux. I assume that you received a driver from your touchscreen
manufacturer or there is an existing one you can use in the Kernel source.

First things first, locate your driver ( usually /drivers/input/touchscreen/* ), and 
ensure that you have every event type being defined that is required by tslib. So, 
specifically you need EV_SYN, EV_ABS, and EV_KEY. My driver did not define EV_KEY, 
and even though it does not report that event type, I still had to define it in the 
driver source for tslib to work with the input from the driver.

set_bit(EV_SYN, aura.input_dev->evbit);
set_bit(EV_ABS, aura.input_dev->evbit);
set_bit(EV_KEY, aura.input_dev->evbit); # I had to add this line so that tslib was happy

Now build the Kernel with your driver ( either as module or driver ) and fire up your
board.

My input device is called 'touchscreen'. Yours will probably be event1 or event0 depending
on serveral possible reasons.

See what the device is with:

# ls -rlt /dev/input/touchscreen 
lrwxrwxrwx    1 root     root             6 Jan 17 21:06 /dev/input/touchscreen -> event1
# chmod 777 /dev/input/touchscreen 
# chmod 777 /dev/input/event1 

You can see more information with:

# cat /sys/devices/virtual/input/input1/uevent 
PRODUCT=0/0/0/0
NAME="aura-touchscreen"
PROP=0
EV=9
ABS=650000 0
MODALIAS=input:b0000v0000p0000e0000-e0,3,kra30,32,35,36,mlsfw

To ensure that your driver is working do the following command and 
then move your finger around the screen. You should see output here
when you finger is touching the screen.
# cat /dev/input/touchscreen  | hexdump
0000000 9011 3883 565f 0001 0003 0030 0001 0000
0000010 9011 3883 565f 0001 0003 0032 0001 0000
0000020 9011 3883 565f 0001 0003 0035 04c9 0000
0000030 9011 3883 565f 0001 0003 0036 0c3f 0000
0000040 9011 3883 565f 0001 0000 0002 0000 0000
0000050 9011 3883 565f 0001 0000 0000 0000 0000
0000060 9011 3883 90a9 0001 0003 0030 0001 0000
0000070 9011 3883 90a9 0001 0003 0032 0001 0000

Go back to your host machine and download the tslib src from here 
--> https://github.com/kergoth/tslib.

Enter the tslib source directory ( cd tslib/plugins ) and edit the input-raw.c file.
Replace any occurences of ABS_X / Y with ABS_MT_POSITION_X / Y. These are the names
of the multi-touch event type variables produces by a multitouch driver.

Now that everything is in order, build tslib and deploy using the following commands
to your exported nfs ( root file system ) for the board:
sudo ./autogen-clean.sh
sudo ./autogen.sh
sudo export ac_cv_func_malloc_0_nonnull=yes
sudo export PATH=`pwd`:$PATH
sudo ./configure CC=/home/user/toolchain/linaro/bin/arm-linux-gnueabi-gcc
CXX=/home/user/toolchain/linaro/bin/arm-linux-gnueabi-g++
--host=arm-linux
--prefix=/usr/local/tslib
--enable-shared=yes
--enable-static=yes
sudo make
sudo make install
sudo cp /usr/local/tslib/bin/* /home/user/exported-nfs/usr/bin/
sudo cp /usr/local/tslib/etc/ts.conf /home/user/exported-nfs/etc/
sudo cp -r /usr/local/tslib/lib/ts /home/user/exported-nfs/usr/lib
sudo cp /usr/local/tslib/lib/* /home/user/exported-nfs/lib/
sudo vim /home/user/exported-nfs/etc/ts.conf

When ts.conf opens for editing, uncomment the 'input raw' line ( the very first 
commented out module ).

Now log back into your embedded machine and export the following environment
variables:

export TSLIB_TSEVENTTYPE=INPUT
export TSLIB_TSDEVICE=/dev/input/touchscreen
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONFFILE=/etc/ts.conf
export TSLIB_PLUGINDIR=/usr/lib/ts
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_CONSOLEDEVICE=none
export TSTS_INFO_FILE=/sys/devices/virtual/input/input1/uevent
export QWS_MOUSE_PROTO=tslib:/dev/input/touchscreen
export PATH=$PATH:/usr/bin

Now we are ready to calibrate. Go to /usr/bin and launch the calibration
utility. You should now see a calibration image on the screen requesting
you to touch a few crosshairs. Go ahead and do that until it stops. Then
your screen is calibrated! The calibration parameters are stored in the
/etc/pointercal file. (you may have to first increase the brightness
of your screen with --> echo 127 > /sys/class/backlight/generic-bl/brightness)

# ts_calibrate 
xres = 640, yres = 480
Took 5 samples...
Top left : X = 3817 Y = 3912
Took 6 samples...
Top right : X =  269 Y = 3822
Took 5 samples...
Bot right : X =  356 Y =  550
Took 5 samples...
Bot left : X = 3732 Y =  614
Took 6 samples...
Center : X = 2202 Y = 2216
643.068298 -0.155621 -0.000056
491.792572 0.002567 -0.115674
Calibration constants: 42144124 -10198 -3 32230118 168 -7580 65536 

You can also test the touchscreen mouse input by running:

ts_test

Great! Now you have single mouse input with tslib ready to go!

Now let's move on to multi-touch.

Download the following packages to enable multitouch events with Qt.

https://github.com/x29a/qTUIO 
https://github.com/olivopaolo/mtdev2tuio 
http://bitmath.org/code/mtdev/ 
http://liblo.sourceforge.net/

Export your cross-compiler and toolchain:

export CC=/home/user/toolchain/linaro/bin/arm-linux-gnueabi-gcc
export CXX=/home/user/toolchain/linaro/bin/arm-linux-gnueabi-g++

Enter the liblo source code directory and build and deploy with:

cd /home/user/Desktop/QTUIO/liblo-0.26
export SKIP_RMDIR_CHECK=yes
./configure --prefix=/usr/local/lib/liblo --host=arm
make clean
make
sudo make install
cd /usr/local/lib/liblo
sudo cp bin/* /home/user/exported-nfs/usr/bin/
sudo cp lib/liblo.a /home/user/exported-nfs/usr/bin/
sudo cp lib/liblo.la /home/user/exported-nfs/usr/bin/

Enter the mtdev source code directory and build and deploy with:

cd /home/user/Desktop/QTUIO/mtdev-1.1.2
./autogen.sh
./configure --prefix=/usr/local/lib/mtdev --host=arm
make clean
make
sudo make install
cd /usr/local/lib/mtdev
sudo cp bin/* /home/user/exported-nfs/usr/bin/
sudo cp lib/libmtdev.a /home/user/exported-nfs/usr/bin/
sudo cp lib/libmtdev.la /home/user/exported-nfs/usr/bin/

Enter the mtdev2tuio bridge source code directory and build and deploy with:

cd /home/user/Desktop/QTUIO/mtdev2tuio
make clean
make
sudo cp mtdev2tuio /home/user/exported-nfs/usr/bin/

Enter the qTUIO source directory and build and deploy with:

cd /home/user/Desktop/QTUIO/qTUIO
sudo rm -rf /home/user/Desktop/QTUIO/qTUIO/lib/*
cd src/
/home/user/output/buildroot/host/usr/bin/qmake
make clean
make
cd ../lib
mv libqTUIO_d.so.1.0.0 libqTUIO.so.1.0.0
sudo rm -rf *libqT*_d*so*
sudo ln -sf libqTUIO.so.1.0.0 libqTUIO.so.1.0
sudo ln -sf libqTUIO.so.1.0.0 libqTUIO.so.1
sudo ln -sf libqTUIO.so.1.0.0 libqTUIO.so
sudo mkdir -p /usr/local/lib/qTUIO
sudo cp -r ../lib/* /usr/local/lib/qTUIO
sudo cp -r /usr/local/lib/qTUIO/* /home/user/exported-nfs/usr/lib/

Now kick off the server that will take multi-touch events input from
mtdev and feed that as TUIO packets to Qt:

# ./mtdev2tuio /dev/input/touchscreen osc.udp://127.0.0.1:3333/
Sending OSC/TUIO packets to osc.udp://127.0.0.1:3333/

Also, ensure that you exported your Qt mouse pointer input environment
variable as follows:

export QWS_MOUSE_PROTO=tslib:/dev/input/touchscreen

Now use Qt Creator or some other IDE to build and deploy the pinchzoom
example found in the qTUIO examples directory to the board.

On the board ( or from Qt Creator ) run the application like:

cd /home/test ; export QWS_MOUSE_PROTO=Tslib:/dev/input/touchscreen  ; ./pinchzoom -qws

Output should look like:

Connecting to device...
Killing remote process(es)...
Starting remote process ...
Remote process started.
graphicsview initialized 
listening to TUIO messages on UDP port 3333

The application will launch on your screen and you should be able to use your finger
as a mouse but also pinch and zoom ( gestures ) at the same time!

Happy coding :)

Feel free to leave feedback - happy coding

ARM QT实现多点触摸【转】相关推荐

  1. android怎么监听多点触摸_什么是多点触控技术,有哪些用途

    自从乔布斯将触控技术用于苹果手机上,很多的手机厂商纷纷效仿,触控技术几乎成为手机的"标配".其实,触控技术早就存在,只是一直未能大面积用于各种设备中,本文将带您认识神奇的触控技术. ...

  2. VS 2010中对WPF4有哪些多点触摸支持?

    随着多点触摸输入和操作处理支持的引进, WPF 4提供了一个极棒的方式,可在Windows 7中使你的客户端应用大放光彩,新的特性包括: UIElement上的多点触摸操作.惯性(漫游(Pan).缩放 ...

  3. Android多点触摸交互处理,放大缩小图片

    多点触摸(MultiTouch),指的是允许计算机用户同时通过多个手指来控制图形界面的一种技术.与多点触摸技术相对应的就是单点触摸,单点触摸的设备已经有很多年了,小尺寸的有触摸式的手机,大尺寸的最常见 ...

  4. android怎么监听多点触摸_大尺寸触摸屏厂家定制多点触摸框

    深圳融创方圆是订做红外大尺寸触摸屏生产厂家,弧形/直角/异形/U型大尺寸红外多点触摸框定做15寸-1000寸超大尺寸红外触控屏可以用于配合液晶拼接屏,DLP拼接屏,无缝拼接屏,小间距LED.互动投影. ...

  5. 基于Visual C++2010与windows SDK fo windows7开发Windows 7的多点触摸特性应用程序(1)

    2008年5月28日,微软即将退休的精神领袖比尔·盖茨和首席执行官史蒂夫·鲍尔默共同在北圣地亚哥四季艾维亚拉洲际度假村举办的2008 D6 All Things数字化大会上向到场的嘉宾展示了windo ...

  6. WP7开发—Silverlight多点触摸事件详解【含Demo代码】

    最近在学习WP7的Silverlight编程,就把学习到知识点整理为日志,方便自己理解深刻点,也作为笔记和备忘,如有不合理或者错误之处,还恳请指正. WP7的支持多点触摸,有两种不同的编程模式: 1. ...

  7. Windows Phone 7 多点触摸编程

    一.基本的程序结构 一个需要响应多点触控的 Silverlight 应用程序必须将一个处理程序连接到静态 Touch.FrameReported 事件: Touch.FrameReported += ...

  8. Linux/Android多点触摸协议

    链接点击打开链接 关于Linux多点触摸协议大家可以参考kernel中的文档:https://www.kernel.org/doc/Documentation/input/multi-touch-pr ...

  9. Linux Android 多点触摸协议 原文出自【比特网】,转载请保留原文链接:http://soft.chinabyte.com/os/71/12306571.shtml

    为了使用功能强大的多点触控设备,就需要一种方案去上报用户层所需的详细的手指触摸数据.这个文档所描述的多点触控协议可以让内核驱动程序向用户层上报任意多指的数据信息. 使用说明 单点触摸信息是以ABS承载 ...

最新文章

  1. 剑指offer:面试题32 - I. 从上到下打印二叉树
  2. windows下如何正确使用Jconsole远程连接linux主机上的JVM
  3. windows下安装pygtk报g_assertion_message无法定位libglib-2.0-0.dll错误解决
  4. Oracle 原理: PL/SQL基础
  5. 漫画:35岁的IT会不会失业?
  6. linux top功能,[每日一题]说说Linux top命令的功能和用法
  7. string能存多大数据_信息技术助力精准教学:大数据到底有多好用?
  8. 用python实现分段函数_在Python中绘制分段函数
  9. .com才是顶级域名,baidu.com是二级域名
  10. 安装32位linux系统安装教程,Ubuntu16.04安装32位支持库
  11. React Native之原理浅析, iOS原理分析与实践解析、Android原理分析与实践解析
  12. python可视化拖拽编程平台_PythonEditor可视化拼插编辑器:编程不用写代码,拖拖拽拽就可以!...
  13. 苹果平板可以用html么,如何将ipad苹果平板电脑中的safari浏览器禁用
  14. 夜神模拟器adb找不到
  15. 对话海尔CEO张瑞敏
  16. js如何获取中午12点的时间
  17. 之和质数c语言题判断,C语言经典例题100例——C语言练习实例33解答(质数判断)...
  18. 滴滴快车奖励政策,高峰奖励,翻倍奖励,按成交率,指派单数分级(10月17日~10月23日)...
  19. 博客实名与一年前的预言
  20. linux下生成dump文件方法及设置

热门文章

  1. 做一个略调皮的个人主页--相册与随笔篇
  2. 体绘制(Volume Rendering)概述介绍
  3. web压力测试工具ab安装及使用
  4. 极米亮相CES展 首推3000元内1080p无屏电视
  5. 中国铁建内网漫游沦陷多个重要部门泄漏大量信息(redis+ssh-keygen免认证登录案例)...
  6. Oracle 11g dataguard主库坏块修复
  7. BeanShell 跟jdk js引擎使用记录
  8. WM OS手机跳过调整屏幕的终极办法
  9. Android开发之动态库调用
  10. CGI,FastCGI与PHP