·您现在的位置: 云翼网络 >> 文章中心 >> 网站建设 >> app软件开发 >> Android开发 >> android4.0与2.3版本的TP代码区别解析

android4.0与2.3版本的TP代码区别解析

作者:佚名      Android开发编辑:admin      更新时间:2022-07-23

通常来说在android2.3上调试TP时,只需要把linux驱动调通,android就可以正常使用了。但是到了android4.0上又有些不同了,针对linux驱动,需添加如下一些内容:

1、在手指按下时需调用如下函数上报Key Down:

input_report_key(struct input_dev *input, BTN_TOUCH, 1);

2、在手指释放时需调用如下函数上报Key Up:

input_report_key(struct input_dev *input, BTN_TOUCH, 0);

这样通过的话,可以在android4.0上看到有鼠标指针(圆圈)可以移动,把触摸屏做成了笔记本电脑上的鼠标触摸屏了,后来再查了下,原来需要添加一个idc文件,具体识别优先级参考:http://source.android.com/tech/input/input-device-configuration-files.html这篇文档,会按下面的顺序识别配置文件:

/system/usr/idc/Vendor_XXXX_Product_XXXX_Version_XXXX.idc
/system/usr/idc/Vendor_XXXX_Product_XXXX.idc
/system/usr/idc/DEVICE_NAME.idc
/data/system/devices/idc/Vendor_XXXX_Product_XXXX_Version_XXXX.idc
/data/system/devices/idc/Vendor_XXXX_Product_XXXX.idc
/data/system/devices/idc/DEVICE_NAME.idc

为了方便,我直接创建一个“设备名.idc”的文件,直接放到/system/usr/idc/目录下,相应的内容参考如下:

# Basic Parameters
touch.deviceType = touchScreen
touch.orientationAware = 1

# Size
touch.size.calibration = diameter
touch.size.scale = 10
touch.size.bias = 0
touch.size.isSummed = 0

# Pressure
# Driver reports signal strength as pressure.
#
# A normal thumb touch typically registers about 200 signal strength
# units although we don't expect these values to be accurate.
touch.pressure.calibration = amplitude
touch.pressure.scale = 0.005

# Orientation
touch.orientation.calibration = none

这样配置好后,在android4.0上的TP就可以正常使用了,而不会成为滑鼠触屏了。