http://blog.csdn.net/eastmoon502136/article/details/7697434
记得应该是上上周了,终于毕业了,离开了学校,就得面对现实的社会,以前学校实验室里,老师给了钥匙,那电脑随便用,那元器件随便玩,什么51单片机啊,PIC单片机啊,FPGA啊,arm11啊什么的。想着做什么就直接万用版+电烙铁什么的一起搞定。调试,写程序,焊板子都是自己一手操办啊,多么自由啊。到了公司,可不依你,对于上市公司来说,管理什么的总归还是有些规范化的。
对于嵌入式,虽然早有所耳闻,大三也玩过arm7,编了几个基于GUI的贪吃蛇啊,黑白棋啊,连连看啊什么的。自己也买来arm11,烧写linux系统,搭建环境,最终也成功完成了hello world驱动模块。待以后有时间再好好整理整理。废话不多说了,既然是anrdroid下的touchscreen的配置,那就专心点,不东扯西扯了。
都说android4.0.3的touchscreen有了很大的变化,菜鸟也不知道这么庞大的代码,各个功能模块式干嘛的。只能找找资料,瞎折腾了。公司的任务,触摸屏得上了,android的东西,只用鼠标可不好玩啊。开始调试SPI模式的ads7846的电阻屏,板子没有SPI接口,于是就用GPIO模拟SPI的方式来实现SPI的功能,在此要说明下,这个嵌入式的板子就是和51,PIC的板子用起来不一样啊,什么工作队列,什么中断下半部分工作,什么总线啊,I2C啊,SPI啊,I2S啊,USB啊,都这么纠结,顿时觉得学得好少啊,自己又有点懒,什么都想学,至于什么也没学好。调试好驱动后,总算是完成了一半的工作,接着,是否要直接上android去跑呢?android里什么机制都不知道额,虽然一开始android中实现鼠标的时候小研究过android下的input那个框架,不过只是模模糊糊的概念,根本就没有弄清楚。看来得下点功夫啊,要不然怎么混啊。又偏题了,额,正题,正题。。
直接上android了,突然发现出现了一个小圈圈。向鼠标一样的。貌似触摸屏变成了鼠标了。觉得太怪了,怎么可以这样?肯定那里有问题的,找了好久的资料,终于找到了,原来是android4.0.3,他的touchscreen是需要配置文件的。只要直接创建一个“设备名.idc”的文件,直接放到/system/usr/idc/目录下,就可以了,设备名是驱动中定义的,在android中的Eventhub中也是可以加打印在logcat中看出来的。
[html] view
plaincopy
-
# 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
但是就知道了这个配置文件,具体那里实现的呢?怎么配置进去的呢?怎么看着你个是touch.deviceType = touchScreen这个决定的。不多说来代码
frameworks/base/services/input/InputReader.cpp
[html] view
plaincopy
-
void TouchInputMapper::configureParameters() {
-
// Use the pointer presentation mode for devices that do not support distinct
-
// multitouch. The spot-based presentation relies on being able to accurately
-
// locate two or more fingers on the touch pad.
-
mParameters.gestureMode = getEventHub()->hasInputProperty(getDeviceId(), INPUT_PROP_SEMI_MT)
-
? Parameters::GESTURE_MODE_POINTER : Parameters::GESTURE_MODE_SPOTS;
-
-
String8 gestureModeString;
-
if (getDevice()->getConfiguration().tryGetProperty(String8("touch.gestureMode"),
-
gestureModeString)) {
-
if (gestureModeString == "pointer") {
-
mParameters.gestureMode = Parameters::GESTURE_MODE_POINTER;
-
} else if (gestureModeString == "spots") {
-
mParameters.gestureMode = Parameters::GESTURE_MODE_SPOTS;
-
} else if (gestureModeString != "default") {
-
LOGW("Invalid value for touch.gestureMode: '%s'", gestureModeString.string());
-
}
-
}
-
-
if (getEventHub()->hasInputProperty(getDeviceId(), INPUT_PROP_DIRECT)) {
-
// The device is a touch screen.
-
mParameters.deviceType = Parameters::DEVICE_TYPE_TOUCH_SCREEN;
-
} else if (getEventHub()->hasInputProperty(getDeviceId(), INPUT_PROP_POINTER)) {
-
// The device is a pointing device like a track pad.
-
mParameters.deviceType = Parameters::DEVICE_TYPE_POINTER;
-
} else if (getEventHub()->hasRelativeAxis(getDeviceId(), REL_X)
-
|| getEventHub()->hasRelativeAxis(getDeviceId(), REL_Y)) {
-
// The device is a cursor device with a touch pad attached.
-
// By default don't use the touch pad to move the pointer.
-
mParameters.deviceType = Parameters::DEVICE_TYPE_TOUCH_PAD;
-
} else {
-
// The device is a touch pad of unknown purpose.
-
mParameters.deviceType = Parameters::DEVICE_TYPE_POINTER;
-
}
-
-
String8 deviceTypeString;
-
if (getDevice()->getConfiguration().tryGetProperty(String8("touch.deviceType"),
-
deviceTypeString)) {
-
if (deviceTypeString == "touchScreen") {
-
mParameters.deviceType = Parameters::DEVICE_TYPE_TOUCH_SCREEN;
-
} else if (deviceTypeString == "touchPad") {
-
mParameters.deviceType = Parameters::DEVICE_TYPE_TOUCH_PAD;
-
} else if (deviceTypeString == "pointer") {
-
mParameters.deviceType = Parameters::DEVICE_TYPE_POINTER;
-
} else if (deviceTypeString != "default") {
-
LOGW("Invalid value for touch.deviceType: '%s'", deviceTypeString.string());
-
}
-
}
-
-
mParameters.orientationAware = mParameters.deviceType == Parameters::DEVICE_TYPE_TOUCH_SCREEN;
-
getDevice()->getConfiguration().tryGetProperty(String8("touch.orientationAware"),
-
mParameters.orientationAware);
-
-
mParameters.associatedDisplayId = -1;
-
mParameters.associatedDisplayIsExternal = false;
-
if (mParameters.orientationAware
-
|| mParameters.deviceType == Parameters::DEVICE_TYPE_TOUCH_SCREEN
-
|| mParameters.deviceType == Parameters::DEVICE_TYPE_POINTER) {
-
mParameters.associatedDisplayIsExternal =
-
mParameters.deviceType == Parameters::DEVICE_TYPE_TOUCH_SCREEN
-
&& getDevice()->isExternal();
-
mParameters.associatedDisplayId = 0;
-
}
-
}
还是英文呢,看到第一行,如果没有配置的话,那就是pointer,pointer不就是鼠标吗?只有定义deviceType为touchScreen,那才是我们要的啊。看来英文真的好重要好重
要啊。那到底是那里去获取配置文件的呢?不是一般都是EventHub下打开什么文件吗?走,咱们去seesee。
frameworks/base/services/input/EventHub.cpp
[html] view
plaincopy
-
void EventHub::loadConfigurationLocked(Device* device) {
-
device->configurationFile = getInputDeviceConfigurationFilePathByDeviceIdentifier(
-
device->identifier, INPUT_DEVICE_CONFIGURATION_FILE_TYPE_CONFIGURATION);
-
if (device->configurationFile.isEmpty()) {
-
LOGD("No input device configuration file found for device '%s'.",
-
device->identifier.name.string());
-
} else {
-
status_t status = PropertyMap::load(device->configurationFile,
-
&