src/taesooLib/MainLib/OgreFltk/Joystick.cpp
HRESULT Joystick::UpdateInputState() 
{
    HRESULT     hr;


    if( NULL == g_pJoystick ) 
        return S_OK;

    // Poll the device to read the current state
    hr = g_pJoystick->Poll(); 
    if( FAILED(hr) )  
    {
        // DInput is telling us that the input stream has been
        // interrupted. We aren't tracking any state between polls, so
        // we don't have any special reset that needs to be done. We
        // just re-acquire and try again.
        hr = g_pJoystick->Acquire();
        while( hr == DIERR_INPUTLOST ) 
            hr = g_pJoystick->Acquire();

        // hr may be DIERR_OTHERAPPHASPRIO or other errors.  This
        // may occur when the app is minimized or in the process of 
        // switching, so just try again later 
        return S_OK; 
    }

    // Get the input's device state
	
	DIJOYSTATE2 js;
    if( FAILED( hr = g_pJoystick->GetDeviceState( sizeof(DIJOYSTATE2), &js) ) )
        return hr; // The device should have been acquired during the Poll()

	// thread safe
    m_js =js;
    return S_OK;
}
//-----------------------------------------------------------------------------
// Name: UpdateInputState()
// Desc: Get the input device's state and display it.
//-----------------------------------------------------------------------------
UpdateInputState()
Desc: Get the input device's state and display it.
UpdateInputState () Desc : Get the input device ' s state and display it .
HRESULT Joystick::UpdateInputState() 
{
    HRESULT     hr;
    if( NULL == g_pJoystick ) 
        return S_OK;
    hr = g_pJoystick->Poll(); 
    if( FAILED(hr) )  
    {
        hr = g_pJoystick->Acquire();
        while( hr == DIERR_INPUTLOST ) 
            hr = g_pJoystick->Acquire();
        return S_OK; 
    }
	DIJOYSTATE2 js;
    if( FAILED( hr = g_pJoystick->GetDeviceState( sizeof(DIJOYSTATE2), &js) ) )
        return hr; 
    m_js =js;
    return S_OK;
}
HRESULT Joystick :: UpdateInputState ( ) { HRESULT hr ; if ( NULL == g_pJoystick ) return S_OK ; hr = g_pJoystick -> Poll ( ) ; if ( FAILED ( hr ) ) { hr = g_pJoystick -> Acquire ( ) ; while ( hr == DIERR_INPUTLOST ) hr = g_pJoystick -> Acquire ( ) ; return S_OK ; } DIJOYSTATE2 js ; if ( FAILED ( hr = g_pJoystick -> GetDeviceState ( sizeof ( DIJOYSTATE2 ) , & js ) ) ) return hr ; m_js = js ; return S_OK ; }
Name: UpdateInputState()
Desc: Get the input device's state and display it.
Name : UpdateInputState () Desc : Get the input device ' s state and display it .
// Poll the device to read the current state // DInput is telling us that the input stream has been // interrupted. We aren't tracking any state between polls, so // we don't have any special reset that needs to be done. We // just re-acquire and try again. // hr may be DIERR_OTHERAPPHASPRIO or other errors.  This // may occur when the app is minimized or in the process of  // switching, so just try again later  // Get the input's device state // The device should have been acquired during the Poll() // thread safe