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

📄 tchpdd.cpp

📁 WM9713 audio codec driver for WinCE 5.0
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    {
        /*
         * Nothing responding on I2S secondary - try AC'97 instead...
         */
        status = WMOpenTouchDevice( WM_DEV_AC97_PRIMARY, &hTouchDevice );
        if ( WM_SUCCESS( status ) )
        {
            DEBUGMSG( ZONE_INIT, ( TEXT( "DdsiTouchPanelEnable - primary AC'97 device\r\n" ) ) );
        }
    }
    if ( WMS_CODEC_NOT_READY == status || WMS_NO_SUPPORTED_DEVICE == status )
    {
        /*
         * Nothing responding on AC'97 primary - try secondary instead...
         */
        status = WMOpenTouchDevice( WM_DEV_AC97_SECONDARY, &hTouchDevice );
        if ( WM_SUCCESS( status ) )
        {
            DEBUGMSG( ZONE_INIT, ( TEXT( "DdsiTouchPanelEnable - secondary AC'97 device\r\n" ) ) );
        }
    }
#endif /* WM_AC97 */

    if ( WM_ERROR( status ) )
    {
        /*
         * Nothing responding on AC'97 or I2S, or something really went wrong
         * - nothing much we can do except tell the user...
         */
        RETAILMSG( ZONE_ALWAYS,
                   ( TEXT("DdsiTouchPanelEnable - WMOpenTouchDevice failed: %hs\r\n"), 
                     WMStatusText( status ) ) );
        goto error0;
    }

	DEBUGMSG(ZONE_INIT, (TEXT( " AC Link is initialised sucessfully \r\n" ) ) );
 
    //
    // And start touch interrupts.
    //
    WMEnablePenInterrupt( hTouchDevice );

    //
    // We're done.
    //    
	DEBUGMSG(ZONE_FUNCTION, (TEXT( "DdsiTouchPanelEnable-\r\n")));
    return TRUE;     

error0:
    return FALSE;
}

//-----------------------------------------------------------------------------------------
// @doc EX_TOUCH_DDSI EXTERNAL DRIVERS DDSI TOUCH_PANEL
//
// @func ULONG | DdsiTouchPanelDisable |
// Powers down the touch panel device.
//
// @comm
// Implemented in the PDD.
//------------------------------------------------------------------------------------------
VOID DdsiTouchPanelDisable(void)
{
    if ( hTouchDevice )
    {
        WMDisablePenInterrupt( hTouchDevice );
        WMTouchShutdown( hTouchDevice );
    }
    hTouchDevice = NULL;
}

//------------------------------------------------------------------------------------------
// @doc EX_TOUCH_DDSI EXTERNAL DRIVERS DDSI TOUCH_PANEL
//
// @func LONG | DdsiTouchPanelAttach |
// This routine no longer does anything.  All functionallity has been moved
// from here into DdsiTouchPanelEnable to allow this code to be statically
// linked with GWE rather than existing as a DLL.  Technically, when built
// as a DLL we should keep an attach count and only allow touh.dll to be
// loaded once.  But, since we are loaded at boot time by GWE, there is
// no real concern about multiple loads (unless gwe has a bug!).
//
// @rdesc
// Always returns 0
//
// @comm
// Implemented in the PDD.
//------------------------------------------------------------------------------------------
LONG DdsiTouchPanelAttach()
{
    return(1); 
}

//------------------------------------------------------------------------------------------
// @doc EX_TOUCH_DDSI EXTERNAL DRIVERS DDSI TOUCH_PANEL
//
// @func LONG | DdsiTouchPanelDetach |
// See the descrition for attach.  All functionallity has been moved into
// DdsiTouchPanelDisable.
//
// @rdesc
// The updated global counter.  If the initializations failed, the returned
// count is 0.
//
// @comm
// Implemented in the PDD.
//------------------------------------------------------------------------------------------
LONG DdsiTouchPanelDetach()
{
    return(0);
}

//------------------------------------------------------------------------------------------ 
// @doc EX_TOUCH_DDSI EXTERNAL DRIVERS DDSI TOUCH_PANEL
//
// @func void | DdsiTouchPanelGetPoint |
// Returns the most recently acquired point and its associated tip state
// information.
//
// @parm PDDSI_TOUCHPANEL_TIPSTATE | pTipState |
// Pointer to where the tip state information will be returned.
// @parm PLONG | pUnCalX |
// Pointer to where the x coordinate will be returned.
// @parm PLONG | pUnCalY |
// Pointer to where the y coordinate will be returned.
//
// @comm
// Implemented in the PDD.
//
// Currently the scenario is that we configure the TSPX interrupt for a pen down. On a 
// pen down interrupt we start a timer which will interrupt the driver almost 150 times 
// a second. At the end of servicing each interrupt we query the status of the pen and 
// change the state accordingly. The driver assumes that every pen down event can be a 
// potential pen draw event. So if the driver gets a pen down it disables the 1400 intr and 
// starts a timer till it gets a pen up status. it learns of the pen up status by polling 
// the 1400 every timer interrupt. if it learns of a pen up then it sets the 1400 for a  
// pen down and disables the timer intr.
//------------------------------------------------------------------------------------------
VOID DdsiTouchPanelGetPoint(TOUCH_PANEL_SAMPLE_FLAGS *pTipStateFlags,INT *pUncalX,INT *pUncalY)
{
    WMSTATUS        status;
    static BOOL     penWasDown = FALSE;
    BOOL            penDown = penWasDown;
    static unsigned interruptType = SYSINTR_TOUCH;
    WM_REGVAL       xCoord, yCoord;
#ifdef DEBUG
    unsigned int    debugState;
    const TCHAR     *szInt;
    const TCHAR     *szWMInt;
    const TCHAR     *szMatches;
    BOOL            wmPenDown;
#endif
    
    DEBUGMSG(ZONE_FUNCTION,(TEXT("+DdsiTouchPanelGetPoint\r\n")));
	ASSERT( pTipStateFlags != NULL && pUncalX != NULL && pUncalY != NULL );

    //
    // Get the Wolfson API to handle the interrupt.
    //
    *pTipStateFlags = TouchSampleDownFlag;
    status = WMGetSmoothedTouchCoordinates( hTouchDevice, &xCoord, &yCoord );
    if ( WM_SUCCESS( status ) )
    {
        *pUncalX = xCoord;
        *pUncalY = yCoord;
        *pTipStateFlags |= TouchSampleValidFlag;
        penDown = TRUE;
    }
    else
    {
        if ( WMS_NO_PEN_DOWN == status )
        {
            penDown = FALSE;
            if ( penWasDown )
                *pTipStateFlags = TouchSampleValidFlag;     // send pen up to mdd
        }
        else
        {
            DEBUGMSG(ZONE_TIPSTATE,(TEXT("DdsiTouchPanelGetPoint: received error %hs\r\n"),
                WMStatusText( status ) ) );
            penDown = WMIsPenDown( hTouchDevice );
		    *pTipStateFlags |= TouchSampleIgnore;
        }
    }

#ifdef DEBUG
    if ( penDown != penWasDown )
    {
        if ( penDown )
            DEBUGMSG(ZONE_TIPSTATE,(TEXT("DdsiTouchPanelGetPoint: Pen down\r\n")));
        else
            DEBUGMSG(ZONE_TIPSTATE,(TEXT("DdsiTouchPanelGetPoint: Pen up\r\n")));
    }
#endif

	//
	// Request the next interrupt. If the pen is down this should be a timer,
    // otherwise it should be pen down.
	//
    if ( penDown )
    {
        if ( penDown != penWasDown )
        {
            //
    		// Mask the pen down signal.
            //
            WMMaskPenInterrupt( hTouchDevice, TRUE );
        }

        WMCancelTimerInterrupt( hTouchDevice );
        WMRequestTimerInterrupt( hTouchDevice );

#ifdef DEBUG
        szInt = TEXT("T: ");
#endif
    }
    else
    {
        //
        // Unmask pen down and cancel the timer.
        //
        WMMaskPenInterrupt( hTouchDevice, FALSE );
        WMCancelTimerInterrupt( hTouchDevice );

#ifdef DEBUG
        szInt = TEXT("I: ");
#endif
    }
        	
#ifdef DEBUG
    debugState = WMTouchDebugState( hTouchDevice );
    if ( debugState & WM_TOUCH_DEBUG_PEN_DOWN )
    {
        szWMInt = TEXT("V");
        wmPenDown = TRUE;
    }
    else
    {
        if ( debugState & WM_TOUCH_DEBUG_PEN_DEBOUNCING )
        {
            szWMInt = TEXT("=");
            wmPenDown = TRUE;
        }
        else
        {
            szWMInt = TEXT("^");
            wmPenDown = FALSE;
        }
    }
    if ( penDown == wmPenDown )
    {
        szMatches = _T("  ");
    }
    else
    {
        szMatches = _T("**");
    }
#endif // DEBUG

    //
    // Now acknowledge it as appropriate for what we want re-enabled
    // - if the pen is down we want the timer, otherwise we want
    // the pen detect interrupt.
    //
    // SYSINTR_TOUCH = pen detect.
    // SYSINTR_TOUCH_CHANGED = timer.
    //
    if ( penDown )
    {
        DEBUGMSG(ZONE_SAMPLES,(TEXT("%s %s %s (%x, %x) %hs\r\n"), szMatches,
                            szWMInt, szInt, *pUncalX, *pUncalY, WMStatusText( status ) ));
        InterruptDone( SYSINTR_TOUCH_CHANGED );
    }
    else
    {
        DEBUGMSG(ZONE_SAMPLES,(TEXT("%s %s %s pen up %hs\r\n"), szMatches,
                            szWMInt, szInt, WMStatusText( status ) ) );
        InterruptDone( SYSINTR_TOUCH );
    }        

    penWasDown = penDown;

    DEBUGMSG(ZONE_FUNCTION,(TEXT("-DdsiTouchPanelGetPoint\r\n")));
}  

//-----------------------------------------------------------------------------------------
//
//  @func VOID | DdsiTouchPanelPowerHandler |
//  System power state notification.
//
//  @parm BOOL | bOff | TRUE, the system is powering off; FALSE, the system is powering up.
//
//  @comm
//  This routine is called in a kernel context and may not make any system
//  calls whatsoever.  It may read and write its own memory and that's about
//  it.  This routine is called by the MDD and also serves as an internal
//  helper routine for touch enable/disable.
//
//  @devnote This routine will run in kernel context, and may not make
//  any system calls.  If you call any subroutines inside here, make sure
//  that they also follow this restriction.
//
//----------------------------------------------------------------------------------------
void DdsiTouchPanelPowerHandler( BOOL bOff )
{
    WMSTATUS status;
    
    if ( ! hTouchDevice )
	{
		ASSERT(0);
        status = WMS_NO_SUPPORTED_DEVICE;
		goto error;
	}
    WMPreventSystemCalls( hTouchDevice, TRUE );
    
    if ( bOff )
    {
        status = WMEnterSleep( hTouchDevice );
        if ( WM_ERROR( status ) )
            goto error;
    }
    else
    {
        status = WMLeaveSleep( hTouchDevice );
        if ( WM_ERROR( status ) )
            goto error;
        status = WMTouchPowerUp( hTouchDevice, WM_POWER_PEN_DETECT );
        if ( WM_ERROR( status ) )
            goto error;
        WMEnablePenInterrupt( hTouchDevice );
    }

    WMPreventSystemCalls( hTouchDevice, FALSE );

    return;
    
error:
    WMPreventSystemCalls( hTouchDevice, FALSE );
    return;
}

//------------------------------------------------------------------------------------------------------------
// Function: TouchPanelInitializeCursor
// 
// Purpose:  currently does nothing.  
// Returns:  TRUE
//
//-------------------------------------------------------------------------------------------------------------
BOOL TouchPanelInitializeCursor()
{
	return TRUE;
}

//------------------------------- END OF FILE ----------------------------------

⌨️ 快捷键说明

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