问题描述
我需要获得触摸屏的绝对MAX轴值。我查看 xinput_calibrator 源,并执行以下功能:
void Xget_absoluteMax (XDeviceInfoPtr devInfo,int * absMAX)
{
XAnyClassptr any = (XAnyClassptr) (devInfo->inputclassinfo);
for (int j=0; j<devInfo->num_classes; j++)
{
if (any->class == ValuatorClass)
{
XValuatorInfoPtr V = (XValuatorInfoPtr) any;
XAxisInfoPtr ax = (XAxisInfoPtr) V->axes;
if (V->mode != Absolute) {
printf("DEBUG: Skipping device '%s' id=%i,does not report Absolute events.\n",devInfo->name,(int)devInfo->id);
} else if (V->num_axes < 2 ||
(ax[0].min_value == -1 && ax[0].max_value == -1) ||
(ax[1].min_value == -1 && ax[1].max_value == -1)) {
printf("DEBUG: Skipping device '%s' id=%i,does not have two calibratable axes.\n",(int)devInfo->id);
} else {
absMAX[ABS_MAX_X] = ax[0].max_value;
absMAX[ABS_MAX_Y] = ax[1].max_value;
printf("DEBUG: Setup ABS_MAX X Y: %d %d\r\n",ax[0].max_value,ax[1].max_value);
}
}
/*
* Increment 'any' to point to the next item in the linked
* list. The length is in bytes,so 'any' must be cast to
* a character pointer before being incremented.
*/
any = (XAnyClassptr) ((char *) any + any->length);
}
}
它可以在Ubuntu 16上很好地工作,给我2047x2047,这是真实值
但是在Ubuntu 20中,它给了我一些假值65535x65535
所以,我开始挖掘并发现一些东西...
在Ubuntu 20上, evtest 给我真正的价值
evtest /dev/input/event8
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0xeef product 0x1 version 0x100
Input device name: "egalax Inc."
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 330 (BTN_TOUCH)
Event type 3 (EV_ABS)
Event code 0 (ABS_X)
Value 0
Min 0
Max 2047
Event code 1 (ABS_Y)
Value 0
Min 0
Max 2047
Properties:
Testing ... (interrupt to exit)
然后我发现错误的价值观存在何处...
xinput list --long 9
egalax Inc. id=9 [slave pointer (2)]
Reporting 6 classes:
Class originated from: 9. Type: XIButtonClass
Buttons supported: 7
Button labels: "Button Left" "Button Middle" "Button Right" "Button Wheel Up" "Button Wheel Down" "Button Horiz Wheel Left" "Button Horiz Wheel Right"
Button state:
Class originated from: 9. Type: XIValuatorClass
Detail for Valuator 0:
Label: Abs MT Position X
Range: 0.000000 - 65535.000000
Resolution: 0 units/m
Mode: absolute
Current value: 0.000000
Class originated from: 9. Type: XIValuatorClass
Detail for Valuator 1:
Label: Abs MT Position Y
Range: 0.000000 - 65535.000000
Resolution: 0 units/m
Mode: absolute
Current value: 0.000000
Class originated from: 9. Type: XIValuatorClass
Detail for Valuator 2:
Label: Rel Horiz Scroll
Range: -1.000000 - -1.000000
Resolution: 0 units/m
Mode: relative
Class originated from: 9. Type: XIValuatorClass
Detail for Valuator 3:
Label: Rel Vert Scroll
Range: -1.000000 - -1.000000
Resolution: 0 units/m
Mode: relative
Class originated from: 9. Type: XITouchClass
Touch mode: direct
Max number of touches: 1
那么如何使用 Xorg 东西获得真实的范围值?
P.S。我已经有了计划B。使用 evtest 代码...但是它需要在/ dev / input / event *设备上打开和ioctl,这意味着我需要root权限。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)