//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
@doc EX_TOUCH_DDI INTERNAL DRIVERS MDD TOUCH_PANEL
Module Name:
@module mdd.c
Abstract:
This module contains the DDI implementation and the supporting administriva.
if DBGCAL is defined, the results of the calibration calculations are
displayed following the setting of calibration data. <nl>
Functions:
TouchPanelpDetach
TouchPanelpAttach
TouchPanelpISR
TouchPanelGetDeviceCaps
TouchPanelSetMode
TouchPanelPowerHandler
TouchPanelEnable
TouchPanelDisable
TouchPanelReadCalibrationPoint
TouchPanelReadCalibrationAbort
Notes:
--*/
#include <windows.h>
#include <types.h>
#include <memory.h>
#include <nkintr.h>
#include <tchddi.h>
#include <tchddsi.h>
extern PFN_TOUCH_PANEL_CALLBACK v_pfnCgrPointCallback;
extern PFN_TOUCH_PANEL_CALLBACK v_pfnCgrCallback;
// To track if we are in OOM state.
BOOL _bTchThreadHighPriority = FALSE;
//
// Run at high priority so that we can service our interrupts quickly.
//
#define DEFAULT_THREAD_PRIORITY 109
#define DEFAULT_THREAD_HIGH_PRIORITY 109
#define CAL_DELTA_RESET 20
#define CAL_HOLD_STEADY_TIME 1500
// If we are a DLL, we can define our dpCurSettings
#ifdef DEBUG
DBGPARAM dpCurSettings = {
TEXT("Touch"), {
TEXT("Samples"),TEXT("Calibrate"),TEXT("Stats"),TEXT("Thread"),
TEXT("TipState"),TEXT("Init"),TEXT(""),TEXT(""),
TEXT(""),TEXT("Misc"),TEXT("Delays"),TEXT("Timing"),
TEXT("Alloc"),TEXT("Function"),TEXT("Warning"),TEXT("Error") },
0xC020 // warning, error, init
};
#endif
//
// Calibration State defintions
//
// @const LONG | CalibrationAvailable |
// Indicates that calibration is not in progress and is available for use.
//
// @const LONG | CalibrationActive |
// Indicates that calibration is active.
//
// @const LONG | CalibrationInactive |
// Indicates that calibration is inactive and waiting for completion.
//
// @const LONG | CalibrationAborted |
// Indicates that calibration is in the process of aborting via user request.
//
#define CalibrationInactive 0x00
#define CalibrationWaiting 0x01
#define CalibrationDown 0x02
#define CalibrationValid 0x03
#define CalibrationAborted 0x04
// Scale factor to support sub-pixel resolutions
#define X_SCALE_FACTOR 4
#define Y_SCALE_FACTOR 4
//
// Macro for absolute value.
//
#define ABS(x) ((x) >= 0 ? (x) : (-(x)))
//
// Internal Function Prototypes
//
static ULONG
TouchPanelpISR(
PVOID Reserved
);
ULONG culReferenceCount; //@globalvar ULONG | culReferenceCount | Count of attached threads
HANDLE hThread; //@globalvar HANDLE | hThread | Handle of attached thread
CRITICAL_SECTION csMutex; //@globalvar CRITICAL_SECTION | csMutex | Critical section
HANDLE hTouchPanelEvent; //@globalvar HANDLE | hTouchPanelEvent | Holds the event handle for
// touch panel event notification.
HANDLE hCalibrationSampleAvailable; //@globalvar HANDLE | hCalibrationSampleAvailable | Holds the event handle for
// notification that a calibration
// mapping point is available.
INT CalibrationState; //@globalvar INT | CalibrationState | Flag which indicates the
// state of calibration: Available,
// Active or Inactive.
static DWORD gThreadPriority; //@globalvar DWORD | gThreadPriority | Interrupt thread normal priority
static DWORD gThreadHighPriority; //@globalvar DWORD | gThreadHighPriority | Interrupt thread high priority
// The MIN_CAL_COUNT is defined in the PDD, since each touch panel
// has different characteristics. The value should be high enough
// to prevent spurious touches, but low enough that the user doesn't
// have to hold the pen on each crosshair too long.
extern int MIN_CAL_COUNT;
LONG lCalibrationXCoord; //@globalvar LONG | lCalibrationXCoord | Holds the X coordinate
// corresponding to the touch.
LONG lCalibrationYCoord; //@globalvar LONG | lCalibrationYCoord | Holds the Y coordinate
// corresponding to the touch.
INT32 DisplayWidth;
INT32 DisplayHeight;
DWORD gdwTouchIstTimeout = INFINITE; // hold csMutex when accessing this
//
//@globalvar PFN_TOUCH_PANEL_CALLBACK | v_pfnPointCallback |
// Pointer to the application supplied function for receiving points.
//
PFN_TOUCH_PANEL_CALLBACK v_pfnPointCallback;
//**********************************************************************
// The following routines are internal helpers, and are not visible to
// the DDI layer.
// @doc IN_TOUCH_DDI INTERNAL DRIVERS MDD TOUCH_PANEL
//**********************************************************************
/*++
Autodoc Information:
@func VOID | TouchPanelpDetach |
Performs cleanup and frees memory when owning process detaches.
@devnote
We let ExitProcess handle the shutting down of the ISR thread.
--*/
static VOID
TouchPanelpDetach(
VOID
)
{
}
/*++
Autodoc Information:
@func BOOL | TouchPanelpAttach |
This routine performs the initialization for the touch panel.
@rdesc
If the function succeeds the return value is TRUE, otherwise, it is FALSE.
--*/
static BOOL
TouchPanelpAttach(
VOID
)
{
//
// Create the event for touch panel events.
// If creation fails, return failure.
//
hTouchPanelEvent = CreateEvent( NULL,
FALSE, // Not manual reset
FALSE, // Not signalled
NULL
);
if ( !hTouchPanelEvent )
return ( FALSE );
//
// Create the event for signaling when a calibration sample has been sent.
//
hCalibrationSampleAvailable =
CreateEvent( NULL,
FALSE, // Not manual reset
FALSE, // Not signalled
NULL
);
if ( !hCalibrationSampleAvailable )
return ( FALSE );
DdsiTouchPanelDisable(); // Insure the device is disabled
//
// Initialize the critical section, flags, callbacks, reference count,
// sample rate.
//
InitializeCriticalSection( &csMutex );
CalibrationState = CalibrationInactive;
v_pfnPointCallback = NULL;
culReferenceCount = 0;
//
// Initialize calibration info used to convert uncalibrated to calibrated
// points so that function is a noop.
//
TouchPanelSetCalibration( 0, NULL, NULL, NULL, NULL );
return ( TRUE );
}
/*++
Autodoc Information:
@func ULONG | TouchPanelpISR |
This routine is the thread which handles touch panel events.
The event that this thread synchronizes on is signaled by the PDD based on
the sampling rate, typically 10ms.
@rdesc
Never returns.
--*/
static ULONG
TouchPanelpISR(
PVOID Reserved //@parm Reserved, not used.
)
{
TOUCH_PANEL_
WinCE下的触控屏驱动程序源代码
需积分: 9 139 浏览量
2008-10-31
12:50:44
上传
评论
收藏 32KB ZIP 举报
li_guotao
- 粉丝: 139
- 资源: 6
最新资源
- 论文(最终)_20240430235101.pdf
- 基于python编写的Keras深度学习框架开发,利用卷积神经网络CNN,快速识别图片并进行分类
- 最全空间计量实证方法(空间杜宾模型和检验以及结果解释文档).txt
- 5uonly.apk
- 蓝桥杯Python组的历年真题
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 前端开发技术实验报告:内含4四实验&实验报告
- Highlight Plus v20.0.1
- 林周瑜-论文.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈