# cd build
# ../4.7.0/configure -opensource -embedded arm -xplatform qws/linux-armv6-g++ -no-webkit -qt-libtiff -qt-libmng
-no-mouse-tslib -no-mouse-pc -no-mouse-linuxtp
-no-mouse-qvfb -no-mouse-qnx -no-neon -qt-gfx-linuxfb
-qt-gfx-transformed -nomake examples -nomake demos -qt-libjpeg -qt-libpng
-qt-mouse-linuxinput -prefix /opt/Qt4.7 -confirm-license
1.一定要使能
-qt-mouse-linuxinput,否则无法使用电容屏,同时
-no-mouse-tslib,-no-mouse-linuxtp,-no-mouse-pc,-no-mouse-qvfb,-no-mouse-qnx。
2.如果要使Qt程序可以旋转屏幕,那么还要使能
-qt-gfx-transformed。
启动时环境变量设置:
export QWS_MOUSE_PROTO="LinuxInput:/dev/input/event0"#
这个环境变量的得出是通过看源代码得出的,具体路径我忘记了
export HOME=/root
export QTDIR=/opt/Qt4.7
export QT_QWS_FONTDIR=$QTDIR/lib/fonts/
export QT_PLUGIN_PATH=$QTDIR/plugins
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
会有个"unkown mouse event type xxxx"的提示,解决方法:
由于驱动代码里面有一项:ABS_PRESSURE,这是android特有的,QtMouse不支持,因此修改qmouselinuxinput_qws.cpp文件,Line 163:
bool unknown = false;
if (data->type == EV_ABS) {
if (data->code == ABS_X) {
m_x = data->value;
} else if (data->code == ABS_Y){
m_y = data->value;
} else {
unknown= false;//modified by antony,because we have a data->type=ABS_PRESSURE
}
问题解决!
PS1:
提示:Could not read calibration: "/etc/pointercal"
还需要在/etc目录下面新建一个pointercal文件才能正常触摸,
pointercal内容如下:
0 65535 16 -65535 0 31457276 65536 800 480
这些数据得来比较曲折,方法就是利用tslib,然后认为输入一些ts_calibrate工具期望的坐标数据,最后生成的。
其实还有更好的方法:
int perform_calibration(calibration *cal)里面有以下代码:
// This code was here originally to just insert default values
for(j=0;j<7;j++) {
c->a[j]=0;
}
c->a[1] = c->a[5] = c->a[6] = 1;
return 1;
for(j=0;j<7;j++) {
c->a[j]=0;
}
c->a[1] = c->a[5] = c->a[6] = 1;
return 1;
可见,默认的方程的解应该是,0 1 0 0 0 1 1,
然后,main()函数里面:
len = sprintf(cal_buffer,"%d %d %d %d %d %d %d %d %d",
cal.a[1], cal.a[2], cal.a[0],
cal.a[4], cal.a[5], cal.a[3], cal.a[6],
xres, yres);
cal.a[1], cal.a[2], cal.a[0],
cal.a[4], cal.a[5], cal.a[3], cal.a[6],
xres, yres);
可见,pointercal文件里面的值就是方程的理想解,排列应该是:1 0 0 0 1 0 1
于是理想的pointercal文件如下:
1 0 0 0 1 0 1 800 480
如果你还想反向X轴,则:
1 0 0 0 -1 480 800 480
因为,在qt4.7.0/src/gui/embeded/qmouse_qws.cpp文件中,有如下转换函数:
QPoint QWSCalibratedMouseHandler::transform(const QPoint &position)
{
QPoint tp;
tp.setX((a * position.x() + b * position.y() + c) / s);
tp.setY((d * position.x() + e * position.y() + f) / s);
return tp;
}
如果你还想反向X轴,则:
1 0 0 0 -1 480 800 480
因为,在qt4.7.0/src/gui/embeded/qmouse_qws.cpp文件中,有如下转换函数:
QPoint QWSCalibratedMouseHandler::transform(const QPoint &position)
{
QPoint tp;
tp.setX((a * position.x() + b * position.y() + c) / s);
tp.setY((d * position.x() + e * position.y() + f) / s);
return tp;
}
PS2:
如果你用android内核修改,那么记得不要使用多点触摸来上报输入事件,因为QT无法识别,官方说可以,我不知道怎么弄,哪个晓得的告诉我一声啊!理由,看:
qmouse
linuxinput
_qws.cpp,里面读取的坐标数据都是ABS_X, ABS_Y没有带MT的。