📄 touchpdd.cpp
字号:
//------------------------------------------------------------------------------
//
// 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.
//
//------------------------------------------------------------------------------
//
// Copyright (C) 2004, Motorola Inc. All Rights Reserved
//
//------------------------------------------------------------------------------
//
// Copyright (C) 2004, Freescale Semiconductor, Inc. All Rights Reserved
// THIS SOURCE CODE IS CONFIDENTIAL AND PROPRIETARY AND MAY NOT
// BE USED OR DISTRIBUTED WITHOUT THE WRITTEN PERMISSION OF
// FREESCALE SEMICONDUCTOR, INC.
//
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//
// File: touchpdd.cpp
//
// Provides the PDD code for the DDSI touch driver routines.
//
//-----------------------------------------------------------------------------
#include <windows.h>
#include <nkintr.h>
#include <tchddsi.h>
#include "touchpdd.h"
#include "mxarm11.h"
//-----------------------------------------------------------------------------
// External Functions
extern BOOL BSPTouchInit(DWORD dwIntervalMsec);
extern void BSPTouchDeinit(void);
extern TOUCH_PANEL_SAMPLE_FLAGS BSPTouchGetSample(INT *x, INT *y);
extern void BSPTouchSetSampleRate(DWORD dwIntervalMsec);
extern void BSPTouchPowerHandler(BOOL boff);
extern void BSPTouchTimerEnable(void);
extern void BSPTouchTimerDisable(void);
extern BOOL BSPTouchTimerIrqQuery(void);
//-----------------------------------------------------------------------------
// External Variables
//-----------------------------------------------------------------------------
// Defines
//-----------------------------------------------------------------------------
// Types
//-----------------------------------------------------------------------------
// Global Variables
DWORD gIntrTouch = SYSINTR_UNDEFINED;
DWORD gIntrTouchChanged = SYSINTR_NOP;
INT gCurSampleRateSetting = 1; // High sample rate setting
//-----------------------------------------------------------------------------
// Local Variables
static DWORD gCurSampleRate = TOUCH_SAMPLE_RATE_HIGH;
static DWORD gTouchPowerStatus = TouchPowerOff;
//-----------------------------------------------------------------------------
// Local Functions
static BOOL TouchDriverCalibrationPointGet(TPDC_CALIBRATION_POINT *lpOutput);
//-----------------------------------------------------------------------------
//
// Function: DdsiTouchPanelAttach
//
// This function executes when the MDD's DLL entry point gets a
// DLL_PROCESS_ATTACH message.
//
// Parameters:
// None.
//
// Returns:
// Returns zero (0).
//
//-----------------------------------------------------------------------------
LONG DdsiTouchPanelAttach(void)
{
DEBUGMSG(ZONE_FUNCTION, (_T("DdsiTouchPanelAttach+\r\n")));
return 0;
}
//-----------------------------------------------------------------------------
//
// Function: DdsiTouchPanelDetach
//
// This function executes when the MDD's DLL entry point gets a
// DLL_PROCESS_DETACH message.
//
// Parameters:
// None.
//
// Returns:
// Returns zero (0).
//
//-----------------------------------------------------------------------------
LONG DdsiTouchPanelDetach(void)
{
DEBUGMSG(ZONE_FUNCTION, (_T("DdsiTouchPanelDetach+\r\n")));
return 0;
}
//-----------------------------------------------------------------------------
//
// Function: DdsiTouchPanelEnable
//
// This function applies power to the touch screen device and initializes
// it for operation.
//
// Parameters:
// None.
//
// Returns:
// TRUE indicates success. FALSE indicates failure.
//
//-----------------------------------------------------------------------------
BOOL DdsiTouchPanelEnable(void)
{
BOOL rc = TRUE;
DEBUGMSG(ZONE_FUNCTION, (_T("DdsiTouchPanelEnable+\r\n")));
// if we are already powered on, just return
if (gTouchPowerStatus == TouchPowerOn)
{
goto cleanUp;
}
// Initialize BSP-specific settings
if (!BSPTouchInit(1000/gCurSampleRate))
{
DEBUGMSG(ZONE_ERROR,
(_T("DdsiTouchPanelEnable: BSPTouchInit failed!\r\n")));
rc = FALSE;
goto cleanUp;
}
// Power on the touch device
DdsiTouchPanelPowerHandler(FALSE);
cleanUp:
if (!rc) BSPTouchDeinit();
DEBUGMSG(ZONE_FUNCTION, (_T("DdsiTouchPanelEnable-\r\n")));
return rc;
}
//-----------------------------------------------------------------------------
//
// Function: DdsiTouchPanelDisable
//
// This function disables the touch screen device. Disabling a touch
// screen prevents generation of any subsequent touch samples, and
// removes power from the screen's hardware. The exact steps necessary
// depend on the specific characteristics of the touch screen hardware.
//
// Parameters:
// None.
//
// Returns:
// None.
//
//-----------------------------------------------------------------------------
void DdsiTouchPanelDisable(void)
{
DEBUGMSG(ZONE_FUNCTION, (_T("DdsiTouchPanelDisable+\r\n")));
// If we are already off, just return
if (gTouchPowerStatus == TouchPowerOff)
return;
// Power off
DdsiTouchPanelPowerHandler(TRUE);
// Deinitialize BSP-specific settings
BSPTouchDeinit();
DEBUGMSG(ZONE_FUNCTION, (_T("DdsiTouchPanelDisable-\r\n")));
return;
}
//-----------------------------------------------------------------------------
//
// Function: DdsiTouchPanelGetDeviceCaps
//
// This function queries capabilities of the touch screen device.
//
// Parameters:
// iIndex
// [in] Capability to query. The following capabilities can
// be specifed:
//
// TPDC_SAMPLE_RATE_ID - Returns the sample rate.
//
// TPDC_CALIBRATION_POINT_ID - Returns the x and y
// coordinates of the required calibration point. The index
// of the calibration point is set in the PointNumber member
// of lpOutput.
//
// TPDC_CALIBRATION_POINT_COUNT_ID Returns the number of
// calibration points used to calibrate the touch screen.
//
// lpOutput
// [out] Pointer to one or more memory locations to place the
// queried information. The format of the memory referenced
// depends on the setting of iIndex.
//
// Returns:
// TRUE if successful, FALSE otherwise.
//
//-----------------------------------------------------------------------------
BOOL DdsiTouchPanelGetDeviceCaps(INT iIndex, LPVOID lpOutput)
{
TPDC_SAMPLE_RATE *ptrSR;
TPDC_CALIBRATION_POINT *ptrCP;
TPDC_CALIBRATION_POINT_COUNT *ptrCPC;
DEBUGMSG(ZONE_FUNCTION, (_T("DdsiTouchPanelGetDeviceCaps+\r\n")));
// Check for invalid parameter
if (lpOutput == NULL)
return FALSE;
switch (iIndex)
{
// Get the sample rate
case TPDC_SAMPLE_RATE_ID:
ptrSR = (TPDC_SAMPLE_RATE*)lpOutput;
ptrSR->SamplesPerSecondLow = TOUCH_SAMPLE_RATE_LOW;
ptrSR->SamplesPerSecondHigh = TOUCH_SAMPLE_RATE_HIGH;
ptrSR->CurrentSampleRateSetting = gCurSampleRateSetting;
break;
// Get the x and y coordinates of the required calibration point.
case TPDC_CALIBRATION_POINT_ID:
ptrCP = (TPDC_CALIBRATION_POINT*)lpOutput;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -