觸摸屏驅動正常工作時,當用戶用觸摸行爲時需要提供該觸摸點.當觸摸結束時驅動必須提交至少一個事件以通知系統觸摸筆已移除.
開發人員可以使用以下步驟來進行對觸摸屏進行採樣和校準:
(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.