在嵌入式Qt项目上校准和配置evdevtouch [英] Calibrating and configuring evdevtouch on embedded qt project
问题描述
我有一个在Linux的icoremx6solo上运行的Qt项目。
我已经设置好图形并运行代码,但是我无法处理触摸输入。
使用$ p $
export QT_LOGGING_RULES = qt.qpa.input = true
$ b $启用输入日志记录b
我发现没有设置坐标ar,我认为这是主要的问题:
qt.qpa.input:evdevtouch:/ dev / input / event0:协议类型B(多)
qt.qpa.input:evdevtouch:/ dev / input / event0:最小X:0最大X:-1
qt.qpa.input:evdevtouch:/ dev / input / event0:最小Y:0最大Y:-1
qt.qpa.input:evdevtouch:/ dev / input / event0:最小压力:0最大压力:0
qt.qpa.input:evdevtouch:/ dev / input / event0:设备名称:EP0790M09
但我找不到校准该evdevtouch的方法。
我尝试用
那么,如何解决触摸屏正在运行的问题?
查看QT的来源(qevdevtouchhandler.cpp),可直接从设备ioctl获得校准值(最小,最大,压力…)。
在Qt中似乎没有办法更改这些值。
看我控制器的内核源代码(Atmel spi上的ADS7843),似乎没有办法从用户空间(/ proc,/ sys)中更改值)。
以下代码片段似乎可以完成工作–读取和写入校准值:
//检查参数计数
是否(argc!= 3&& argc!= 5){
puts(获取用法:evgetset device absnumber);
puts(设置用法:evgetset设备的absnumber值名);
返回(1);
}
//第一个参数是设备文件名
fd = open(argv [1],O_RDONLY);
if(fd< 0){
puts(无法打开设备文件-您是否以root用户身份运行);
返回(1);
}
//第二个参数是参数编号
absnumber = atoi(argv [2]);
if(absnumber< 0 || absnumber> ABS_MAX){
puts( absnumber超出范围);
返回(1);
}
//读取ioctl并显示当前值
ioctl(fd,EVIOCGABS(absnumber),& absval);
printf(%d\n的属性,绝对编号);
printf( Value:%d\n,absval.value);
printf( Minimum:%d\n,absval.minimum);
printf( Maximum:%d\n,absval.maximum);
printf( Fuzz:%d\n,absval.fuzz);
printf( Flat:%d\n,absval.flat);
// printf( Resolution:%d\n,absval.resolution);
//检查是否需要写-并进行
if(argc == 5){
valvalue = atoi(argv [4]);
if(!strcmp( Value,argv [3]))absval.value = valvalue;
if(!strcmp( Minimum,argv [3]))absval.minimum = valvalue;
if(!strcmp( Maximum,argv [3]))puts( Got Maximum);
if(!strcmp( Maximum,argv [3]))absval.maximum = valvalue;
if(!strcmp( Fuzz,argv [3]))absval.fuzz = valvalue;
if(!strcmp( Flat,argv [3]))absval.flat = valvalue;
// if(!strcmp( Resolution,argv [2])absval.resolution = valvalue;
ioctl(fd,EVIOCSABS(absnumber),& absval);
}
//全部完成
close(fd);
I have a Qt project running on a icoremx6solo with linux. I've setted up the graphics and run the code, but i can't handle touch inputs. Enabling the input logging with
export QT_LOGGING_RULES="qt.qpa.input=true"
i discovered that the coordinates ar not setted, i think that this is the main problem with that:
qt.qpa.input: evdevtouch: /dev/input/event0: Protocol type B (multi)
qt.qpa.input: evdevtouch: /dev/input/event0: min X: 0 max X: -1
qt.qpa.input: evdevtouch: /dev/input/event0: min Y: 0 max Y: -1
qt.qpa.input: evdevtouch: /dev/input/event0: min pressure: 0 max pressure: 0
qt.qpa.input: evdevtouch: /dev/input/event0: device name: EP0790M09
but i can't find a way to calibrate that evdevtouch.
I tried runnin the executable with -plugin tslib attribute after executing the ts_calibrate command but the output is the same.
so, how can i fix that having a running touchscreen?
Looking at QT's source (qevdevtouchhandler.cpp) the calibration values (min, max, pressure…) are obtained directly from the device ioctl.
There doesn't seem to be a way in Qt to change these values.
Looking at the kernel source for my controller (ADS7843 on Atmel spi) there doesn't seem to a way to change the values from user space (/proc, /sys).
The following snippet seems to do the job – reading and writing the calibration values:
// check the parameter count
if (argc != 3 && argc != 5) {
puts ("Get usage: evgetset device absnumber");
puts ("Set usage: evgetset device absnumber valname value");
return (1);
}
// the first parameter is the device file name
fd = open(argv[1], O_RDONLY);
if (fd < 0) {
puts ("Could not open device file - are you running as root");
return (1);
}
// the second parameter is the parameter number
absnumber = atoi (argv[2]);
if (absnumber < 0 || absnumber > ABS_MAX) {
puts ("absnumber out of range");
return (1);
}
// Read the ioctl and display the current values
ioctl(fd, EVIOCGABS(absnumber), &absval);
printf ("Properties for %d\n", absnumber);
printf ("Value : %d\n", absval.value);
printf ("Minimum : %d\n", absval.minimum);
printf ("Maximum : %d\n", absval.maximum);
printf ("Fuzz : %d\n", absval.fuzz);
printf ("Flat : %d\n", absval.flat);
// printf ("Resolution : %d\n", absval.resolution);
// check if a write is wanted - and do it
if (argc == 5) {
valvalue = atoi (argv[4]);
if (!strcmp ("Value", argv[3])) absval.value = valvalue;
if (!strcmp ("Minimum", argv[3])) absval.minimum = valvalue;
if (!strcmp ("Maximum", argv[3])) puts ("Got Maximum");
if (!strcmp ("Maximum", argv[3])) absval.maximum = valvalue;
if (!strcmp ("Fuzz", argv[3])) absval.fuzz = valvalue;
if (!strcmp ("Flat", argv[3])) absval.flat = valvalue;
// if (!strcmp ("Resolution", argv[2]) absval.resolution = valvalue;
ioctl(fd, EVIOCSABS(absnumber), &absval);
}
// all done
close(fd);
这篇关于在嵌入式Qt项目上校准和配置evdevtouch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!