ARM QT实现多点触摸【转】
转自: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实现多点触摸【转】的更多相关文章
- 【转】基于Qt, TUIO和TSLIB的嵌入式Linux下的多点触摸设计
这个教程描述了在嵌入式linux下使用Qt如何设置一个支持多点触摸和单点触摸的输入系统.这里假定你已经有了对应的驱动程序,驱动可以从触摸屏的厂商那里获得或者使用一个linux 内核源码中已经存在的驱动 ...
- 基于Qt QGraphicsView的多点触摸绘图
本应用于基于QGraphicsView框架,实现多点触摸. 工程仅仅演示了多点触摸绘图,源自我前段时间一款基于Qt的绘图软件. 工程结构: kmp.h 定义了枚举 slide.h/cpp 定义了派生于 ...
- 10.14 android输入系统_多点触摸驱动测试及Reader线程、InputStage分析
21. 多点触摸_电容屏驱动程序_实践_tiny4412 tiny4412触摸屏: 分辨率为800 x 480http://wiki.friendlyarm.com/wiki/index.php/LC ...
- 多点触摸(MT)协议(翻译)
参考: http://www.kernel.org/doc/Documentation/input/multi-touch-protocol.txt 转自:http://www.arm9home.ne ...
- 移动web开发,12个触摸及多点触摸事件常用Js插件
如今移动互联网已经占据了主流地位,越来越多的开发者开始从桌面转向移动平台.与桌面开发不同的是,在移动领域中,不同的操作系统.大量不同屏幕尺寸的移动设备.触摸手势操作等,这都给开发者带来了一定的难度和挑 ...
- 毫无保留开源我写的:IOS Android Ipad 多点触摸通用js 库
毫无保留开源我写的:IOS Android Ipad 多点触摸通用js 库 在线演示地址: http://m.yunxunmi.com/ 支持 IOS Android Ipad 等不同操作系统的手持或 ...
- 多点触摸画板(MultiTouchCanvas)
这是个简单的支持多点触摸的画板控件, 绘制功能基于WPF InkCanvas,也是我drawTool系列文章的开篇. 阅读该文章后可能产生一些问题: 1. 如果对生成的笔迹对象进行控制 如果要对生成的 ...
- Android 中多点触摸协议
http://blog.csdn.net/zuosifengli/article/details/7398661 Android 中多点触摸协议: 参考: http://www.kernel.org/ ...
- Android 手势滑动,多点触摸放大缩小图片
效果展示: 基本思路: <1>首先写一个图片控制类ImageControl,实现对图片控制的的基本操作,我们的图片控制类ImageControl是继承自ImageView自定义的视图: & ...
随机推荐
- 【JAVA】mac配置java环境变量
如果用bash,修改~/.bash_profile 或 ~/.profile: 如果用zsh,修改-/.zshrc 修改这些文件之后,重修打开terminal,配置不会丢 首先确保已经安装了jdk: ...
- Python 正则表达式 匹配次数
管道可以匹配多个正则表达式中的一个 >>> >>> m=re.search(r'Batman|Tina Fey','Batman and Tina Fey')> ...
- 使用jieba和wordcloud进行中文分词并生成《悲伤逆流成河》词云
因为词云有利于体现文本信息,所以我就将那天无聊时爬取的<悲伤逆流成河>的评论处理了一下,生成了词云. 关于爬取影评的爬虫大概长这个样子(实际上是没有爬完的): #!/usr/bin/env ...
- js中基础数据类型
变量声明 undefined //未定义只声明 var age; alert(name);function fc(a1,a2,a3) { //alert(a1); //alert(a2); //a ...
- Python框架之Django学习笔记(三)
开始一个项目 第一次使用 Django,必须进行一些初始化设置工作. 新建一个工作目录,例如 D:\tool\python\Python27\workspace\djcode,然后进入该目录. 转到创 ...
- LR11生成图表后修正Analysis中显示请求的地址长度过短50个字符的问题
在LR11的安装目录下找到LRAnalysis80.ini文件,在其中的[WPB]下添加SURLSize=255内容. 其次还需要修改LR目录下loader2.mdb文件,将其中的Breakdown_ ...
- Leetcode 648.单词替换
单词替换 在英语中,我们有一个叫做 词根(root)的概念,它可以跟着其他一些词组成另一个较长的单词--我们称这个词为 继承词(successor).例如,词根an,跟随着单词 other(其他),可 ...
- 团队Alpha版本冲刺(三)
目录 组员情况 组员1(组长):胡绪佩 组员2:胡青元 组员3:庄卉 组员4:家灿 组员5:凯琳 组员6:丹丹 组员7:家伟 组员8:政演 组员9:鸿杰 组员10:刘一好 组员11:何宇恒 展示组内最 ...
- ECNU 3263 丽娃河的狼人传说(差分约束)
丽娃河的狼人传说 Time limit per test: 1.0 seconds Memory limit: 256 megabytes 丽娃河是华师大著名的风景线.但由于学校财政紧缺,丽娃河边的路 ...
- POJ 2686 Traveling by Stagecoach(状压二维SPFA)
Traveling by Stagecoach Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 3407 Accepted ...