⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tchpdd.cpp

📁 ARM9基于WINDOWSCE的BSP源代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    {

            *pUncalY = (ULONG)( ( ( rgPointSamples[ 0 ].YSample + rgPointSamples[ 2 ].YSample ) >> 1 ) );
    }
    else
    {

            *pUncalY = (ULONG)( ( ( rgPointSamples[ 1 ].YSample + rgPointSamples[ 2 ].YSample ) >> 1 ) );
    }

    //
    // Validate the coordinates and set the tip state accordingly.
    //

    if ( dlXDiff0 > DELTA_X_COORD_VARIANCE ||
         dlXDiff1 > DELTA_X_COORD_VARIANCE ||
         dlXDiff2 > DELTA_X_COORD_VARIANCE ||
         dlYDiff0 > DELTA_Y_COORD_VARIANCE ||
         dlYDiff1 > DELTA_Y_COORD_VARIANCE ||
         dlYDiff2 > DELTA_Y_COORD_VARIANCE )
    {

#ifdef DBGPOINTS1
        DEBUGMSG( 1, (TEXT("Sample 0: X 0x%x Y 0x%x\r\n"),
               rgPointSamples[ 0 ].XSample, rgPointSamples[ 0 ].YSample) );
        DEBUGMSG( 1, (TEXT("Sample 1: X 0x%x Y 0x%x\r\n"),
               rgPointSamples[ 1 ].XSample, rgPointSamples[ 1 ].YSample) );
        DEBUGMSG( 1, (TEXT("Sample 2: X 0x%x Y 0x%x\r\n"),
               rgPointSamples[ 2 ].XSample, rgPointSamples[ 2 ].YSample) );


        if ( dlXDiff0 > DELTA_X_COORD_VARIANCE )
            DEBUGMSG( 1, (TEXT("XDiff0 too large 0x%x\r\n"), dlXDiff0) );
        if ( dlXDiff1 > DELTA_X_COORD_VARIANCE )
            DEBUGMSG( 1, (TEXT("XDiff1 too large 0x%x\r\n"), dlXDiff1) );
        if ( dlXDiff2 > DELTA_X_COORD_VARIANCE )
            DEBUGMSG( 1, (TEXT("XDiff2 too large 0x%x\r\n"), dlXDiff2) );

        if ( dlYDiff0 > DELTA_Y_COORD_VARIANCE )
            DEBUGMSG( 1, (TEXT("YDiff0 too large 0x%x\r\n"), dlYDiff0) );
        if ( dlYDiff1 > DELTA_Y_COORD_VARIANCE )
            DEBUGMSG( 1, (TEXT("YDiff1 too large 0x%x\r\n"), dlYDiff1) );
        if ( dlYDiff2 > DELTA_Y_COORD_VARIANCE )
            DEBUGMSG( 1, (TEXT("YDiff2 too large 0x%x\r\n"), dlYDiff2) );

#endif // DBGPOINTS1

    }
    else
    {
        //
        // Sample is valid. Set tip state accordingly.
        //
        *pSampleFlags = TouchSampleValidFlag | TouchSampleDownFlag;

    }

// add by zsc
	*pUncalX = 0xFF - *pUncalX;
	

    DEBUGMSG( 1, (TEXT("Filtered - SampleFlags: 0x%x X: %4d Y: %4d\r\n"),
           *pSampleFlags, *pUncalX, *pUncalY) );

#if 0
	DEBUGMSG( 1, (TEXT("Filtered - Sample X: %4d Y: %4d\r\n"),
           *pUncalX, *pUncalY) );
#endif

}

//
// PddpSetupPenDownIntr()
//
BOOL
PddpSetupPenDownIntr(BOOL EnableIntr)
{
	DEBUGMSG(1, (TEXT("Touchscreen: PddpSetupPenDownIntr\r\n")));

/*
	OEM_IOCTL_GPIO gpio;
	int value;
	
	gpio.num = 6;	gpio.pin = 7;	gpio.code = GPIO_IntType;
	value = 0x02;	gpio.value = &value;
	KernelIoControl(HAL_IOCTL_GPIO , &gpio , sizeof(OEM_IOCTL_GPIO) , 0 , 0 , 0 );
	
	gpio.num = 6;	gpio.pin = 7;	gpio.code = GPIO_IntEnable;
	value = EnableIntr?1:0;		gpio.value = &value;
	KernelIoControl(HAL_IOCTL_GPIO , &gpio , sizeof(OEM_IOCTL_GPIO) , 0 , 0 , 0 );

	if (EnableIntr)
	{
		unsigned long   iDump;
		WCHAR   reg = INT_REQUEST;
		WriteFile(gSsp, &reg, sizeof(reg), &iDump, NULL); // Write Query then
	}
*/


	pGpioHead->dwGPIOIS &= ~0x80;
	pGpioHead->dwGPIOIBE &= ~0x80;
	pGpioHead->dwGPIOIEV &= ~0x80;	
	if (EnableIntr)
	{
		pGpioHead->dwGPIOIC |= 0x80;
		pGpioHead->dwGPIOIE |= 0x80;
	}
	else
	{
		pGpioHead->dwGPIOIE &= ~0x80;
		pGpioHead->dwGPIOIC &= ~0x80;
	}

    return TRUE;
}

//
// PddpDisableClearPenDownIntr(void)
//
inline BOOL
PddpDisableClearPenDownIntr(void)
{
	DEBUGMSG(1, (TEXT("Touchscreen: PddpDisableClearPenDownIntr\r\n")));
	pGpioHead->dwGPIOIC |= 0x80;

    // this function is unused as events are automatic
    return TRUE;
}

//
// DDSI Implementation
//


//  @DOC    EX_TOUCH_DDSI EXTERNAL DRIVERS TOUCH_DRIVER
/*  @FUNC   BOOL | TouchDriverCalibrationPointGet |

Gives a single calibration point.

    @XREF
        <l TouchPanelReadCalibrationPoint.TouchPanelReadCalibrationPoint>
        <l TouchPanelSetCalibration.TouchPanelSetCalibration>
        <l TouchPanelReadCalibrationAbort.TouchPanelReadCalibrationAbort>


    @COMM

This function is called to get a single calibration point, in screen
coordinates, when the input system is calibrating the touch driver.  The input system
will then draw a target on the screen for the user to press on.

The driver may use the cDisplayX and cDisplayY to compute a coordinate.
It does not need to remember this computed value internally since it will
be passed back when the input system has collected all of the points and
calls <l TouchPanelSetCalibration.TouchPanelSetCalibration>.

*/

extern "C"
BOOL
TouchDriverCalibrationPointGet(
    TPDC_CALIBRATION_POINT  *pTCP //@PARM pointer to returned calibration point
    )
{
	DEBUGMSG(1, (TEXT("Touchscreen: TouchDriverCalibrationPointGet(0x%x)\r\n"), pTCP -> PointNumber));
    INT32   cDisplayWidth = pTCP -> cDisplayWidth;
    INT32   cDisplayHeight = pTCP -> cDisplayHeight;

    int CalibrationRadiusX = cDisplayWidth/20;
    int CalibrationRadiusY = cDisplayHeight/20;

    switch (pTCP -> PointNumber)
        {
        case    0:
            pTCP -> CalibrationX = cDisplayWidth/2;
            pTCP -> CalibrationY = cDisplayHeight/2;
            break;

        case    1:
            pTCP -> CalibrationX = CalibrationRadiusX*2;
            pTCP -> CalibrationY = CalibrationRadiusY*2;
            break;

        case    2:
            pTCP -> CalibrationX = CalibrationRadiusX*2;
            pTCP -> CalibrationY = cDisplayHeight - CalibrationRadiusY*2;
            break;

        case    3:
            pTCP -> CalibrationX = cDisplayWidth - CalibrationRadiusX*2;
            pTCP -> CalibrationY = cDisplayHeight - CalibrationRadiusY*2;
            break;

        case    4:
            pTCP -> CalibrationX = cDisplayWidth - CalibrationRadiusX*2;
            pTCP -> CalibrationY = CalibrationRadiusY*2;
            break;

        default:
            pTCP -> CalibrationX = cDisplayWidth/2;
            pTCP -> CalibrationY = cDisplayHeight/2;
            SetLastError(ERROR_INVALID_PARAMETER);
            return FALSE;

        }
	DEBUGMSG(1,(TEXT("cDisplayWidth : %4X\r\n"),cDisplayWidth));
	DEBUGMSG(1,(TEXT("cDisplayHeight : %4X\r\n"),cDisplayHeight));
	DEBUGMSG(1,(TEXT("CalibrationRadiusX : %4d\r\n"),CalibrationRadiusX));
	DEBUGMSG(1,(TEXT("CalibrationRadiusY : %4d\r\n"),CalibrationRadiusY));
	DEBUGMSG(1,(TEXT("pTCP -> PointNumber : %4d\r\n"),pTCP -> PointNumber));
	DEBUGMSG(1,(TEXT("pTCP -> CalibrationX : %4d\r\n"),pTCP -> CalibrationX));
	DEBUGMSG(1,(TEXT("pTCP -> CalibrationY : %4d\r\n"),pTCP -> CalibrationY));

    return TRUE;
}




// @doc EX_TOUCH_DDSI EXTERNAL DRIVERS DDSI TOUCH_PANEL
//
// @func ULONG | DdsiTouchPanelGetDeviceCaps |
//
// Queries capabilities about the physical touch panel device.
//
// @parm ULONG | iIndex |
//
// Specifies the capability to query. They are one of the following:
//
// @flag TPDC_SAMPLERATE_ID |
// The sample rate.
// @flag TPDC_CALIBRATIONPOINTS_ID |
// The X and Y coordinates used for calibration.
// @flag TPDC_CALIBRATIONDATA_ID |
// The X and Y coordinates used for calibration mapping.
//
// @parm LPVOID | lpOutput |
// Points to the memory location(s) where the queried information
// will be placed. The format of the memory referenced depends on
// the setting of iIndex. If 0, returns the number of words
// required for the output data.
//
// @rdesc
// The return values is set to the amount of information supplied and depends
// on the setting of the iIndex argument.
//
// @comm
// Implemented in the PDD.
//

extern "C"
BOOL
DdsiTouchPanelGetDeviceCaps(
    INT     iIndex,
    LPVOID  lpOutput
    )
{
	DEBUGMSG(1, (TEXT("Touchscreen: DdsiTouchPanelGetDeviceCaps(0x%x)\r\n"), iIndex));

    if ( lpOutput == NULL )
        {
        ERRORMSG(1, (__TEXT("TouchPanelGetDeviceCaps: invalid parameter.\r\n")));
        SetLastError(ERROR_INVALID_PARAMETER);
        DebugBreak();
        return FALSE;
        }

    switch  ( iIndex )
        {
        case TPDC_SAMPLE_RATE_ID:
                {
                TPDC_SAMPLE_RATE    *pTSR = (TPDC_SAMPLE_RATE*)lpOutput;

                pTSR -> SamplesPerSecondLow = TOUCHPANEL_SAMPLE_RATE_LOW;
                pTSR -> SamplesPerSecondHigh = TOUCHPANEL_SAMPLE_RATE_HIGH;
                pTSR -> CurrentSampleRateSetting = CurrentSampleRateSetting;
                }
                break;

        case TPDC_CALIBRATION_POINT_COUNT_ID:
                {
                TPDC_CALIBRATION_POINT_COUNT *pTCPC = (TPDC_CALIBRATION_POINT_COUNT*)lpOutput;

                pTCPC -> flags = 0;
                pTCPC -> cCalibrationPoints = 5;
                }
                break;

        case TPDC_CALIBRATION_POINT_ID:
                return(TouchDriverCalibrationPointGet((TPDC_CALIBRATION_POINT*)lpOutput));

        default:
                ERRORMSG(1, (__TEXT("TouchPanelGetDeviceCaps: invalid parameter.\r\n")));
                SetLastError(ERROR_INVALID_PARAMETER);
                DebugBreak();
                return FALSE;

        }

    return TRUE;
}



//
// @doc EX_TOUCH_DDSI EXTERNAL DRIVERS DDSI TOUCH_PANEL
//
// @func BOOL | DdsiTouchPanelSetMode |
// Sets information about the physical touch panel device.
//
// @parm ULONG | iIndex |
// Specifies the mode to set. They are one of the following:
//
// @flag TPSM_SAMPLERATE_HIGH_ID |
// Sets the sample rate to the high rate.
// @flag TPSM_SAMPLERATE_LOW_ID |
// Sets the sample rate to the low rate.
//
// @parm LPVOID | lpInput |
// Points to the memory location(s) where the update information
// resides. The format of the memory referenced depends on the
// Points to the memory location(s) where the queried information
// will be placed.
//
// @rdesc
// If the function succeeds the return value is TRUE, otherwise, it is FALSE.
//
// @comm
// Implemented in the PDD.
//

BOOL
DdsiTouchPanelSetMode(
    INT     iIndex,
    LPVOID  lpInput
    )
{
	DEBUGMSG(1, (TEXT("Touchscreen: DdsiTouchPanelSetMode(0x%x)\r\n"), iIndex));

    BOOL  ReturnCode = FALSE;

    switch ( iIndex )
    {
        case TPSM_SAMPLERATE_LOW_ID:
        case TPSM_SAMPLERATE_HIGH_ID:
            SetLastError( ERROR_SUCCESS );
            ReturnCode = TRUE;
            break;

        default:
            SetLastError( ERROR_INVALID_PARAMETER );
            break;
    }


    return ( ReturnCode );
}

//
// @doc EX_TOUCH_DDSI EXTERNAL DRIVERS DDSI TOUCH_PANEL
//
// @func BOOL | DdsiTouchPanelEnable |
// Powers up and initializes the touch panel hardware for operation.
//
// @rdesc
// If the function succeeds, the return value is TRUE; otherwise, it is FALSE.
//
// @comm
// Implemented in the PDD.
//

BOOL
DdsiTouchPanelEnable(
    VOID
    )
{
    DEBUGMSG( TRUE, (TEXT("DdsiTouchPanelEnable\r\n")) );
    RETAILMSG( TRUE, (TEXT("MODULE NAME: %s\r\n"),part_name) );
    DEBUGMSG( TRUE, (TEXT("MODULE VERSION: %s\r\n"),part_num) );

    //
    // Mapping is required for Timer2
    //
    PHYSICAL_ADDRESS PhysicalAddress;
    PhysicalAddress.HighPart = 0;
    PhysicalAddress.LowPart = PHYS_CT2_BASE;
    pTimer= (pstDualTimerRegs)MmMapIoSpace(PhysicalAddress, (ULONG)sizeof(stDualTimerRegs),0);

    //
    // Setup global data
    //

    for ( unsigned long irg = 0; irg <= (NUMBER_SAMPLES_PER_POINT*REJECT_RATIO); irg+=1 )
    {
        gQuery[irg]                                             =X_REQUEST;
        gQuery[irg+ (NUMBER_SAMPLES_PER_POINT*REJECT_RATIO)]    =Y_REQUEST;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -