触摸屏驱动正常工作时,当用户用触摸行为时需要提供该触摸点.当触摸结束时驱动必须提交至少一个事件以通知系统触摸笔已移除.
开发人员可以使用以下步骤来进行对触摸屏进行采样和校准:
(1) 调用TouchPanelEnable开始屏幕采样
(2) 调用TouchPanelGetDeviceCaps来获取采样点数目
(3) 对于每个校准点,进行以下步骤
a. 调用TouchPanelGetDeviceCaps来获得一个校准坐标
b. 在返回坐标画一个交叉线
c. 调用TouchPanelReadCalibrationPoint来获得校准点数据
调用TouchPanelSetCalibration来计算校准系数.
当驱动执行完以上顺序后,任何采样数据被传递给TouchPanelEnable定义的回调函数.驱动可以传递校准好的坐标也可以传递未校准的坐标给回调函数.如果驱动有有效的校准算法,可以返回校准好的坐标.如果算法复杂,可以返回未校准坐标以避免在高优先级的驱动线程中进行计算,而是交由较低优先级的驱动回调函数来进行计算.
我们实际上是在应用程序中调用TouchCalibrate来完成触摸屏校准的.
source文件里引用了两个库tch_cal.lib和tchmdd.lib.
SOURCELIBS= /
$(_COMMONOAKROOT)/lib/$(_CPUINDPATH)/tch_cal.lib /
$(_COMMONOAKROOT)/lib/$(_CPUINDPATH)/tchmdd.lib /
tch_cal.lib(/WINCEROOT/PUBLIC/COMMON/OAK/DRIVERS/TOUCH/TCH_CAL)实现了触摸屏的校准算法.下表中的ErrorAnalysis,TouchPanelSetCalibration,TouchPanelCalibrateAPoint在此库中实现
tchmdd.lib(/WINCEROOT/PUBLIC/COMMON/OAK/DRIVERS/TOUCH/TCHMAIN/tchmain.c),实现了其他的touch screen driver functions.
这两个库实际上就是触摸屏的MDD层驱动.
Programming element
Description
ErrorAnalysis
This function provides information on the accuracy of the touch screen calibration.
TouchCalibrate
This function starts the touch screen calibration sequence.
TouchPanelCalibrateAPoint
This function converts noncalibrated points to calibrated points.
TouchPanelDisable
This function disables the touch screen.
TouchPanelEnable
This function enables and re-enables the touch screen.
TouchPanelGetDeviceCaps
This function returns information about the capabilities of the touch screen.
TouchPanelInitializeCursor
This function provides an opportunity for touch drivers to move the cursor at initialization time.
TouchPanelPowerHandler
This function handles power-state change notifications.
TouchPanelReadCalibrationAbort
This function aborts the currently active call to the TouchPanelCalibrateAPoint function.
TouchPanelReadCalibrationPoint
This function initiates the process of getting a calibration point.
TouchPanelSetCalibration
This function initializes calibration information in a global parameter vCalcParam, which you can use to convert noncalibrated points to calibrated points by the TouchPanelCalibrateAPoint function.
TouchPanelSetMode
This function sets mode information for a touch screen device.
而我们需要实现的PDD层驱动则是对应的以下DDSI函数,被对应的MDD层函数调用.
Programming element
Description
DdsiTouchPanelAttach
This function executes when the MDD's DLL entry point receives a DLL_PROCESS_ATTACH message.
DdsiTouchPanelDetach
This function executes when the MDD's DLL entry point receives a DLL_PROCESS_DETACH message.
DdsiTouchPanelDisable
This function disables the touch screen device.
DdsiTouchPanelEnable
This function applies power to the touch screen device and initializes it for operation.
DdsiTouchPanelGetDeviceCaps
This function queries capabilities of the touch screen device.
DdsiTouchPanelGetPoint
This function returns the most recently acquired point and its associated tip state information.
DdsiTouchPanelPowerHandler
This function indicates to the driver that the system is entering or leaving the suspend state.
DdsiTouchPanelSetMode
This function sets information about the touch screen device.