zyrolasting
2008-09-23 21:26:10 UTC
DirectX9.0c August
Visual Studio 2008
Windows Vista
I am using a DirectInput framework that I downloaded to study.
Everything in it works correctly except for the following function.
POINT DirectInput::DIMouseHandler(void)
{
POINT p;
HRESULT hr;
//Clear out the mouse structure
memset(&m_diMouseState, 0, sizeof(m_diMouseState));
//Get the scoop from the mouse
if(FAILED(hr = m_diMouse->GetDeviceState(sizeof(m_diMouseState),(LPVOID)
&m_diMouseState)))
{
//Maintain control of mouse
if(hr == DIERR_INPUTLOST)
m_diMouse->Acquire();
}
p.x = m_diMouseState.lX;
p.y = m_diMouseState.lY;
return p;
}
Everything runs fine to it's call, and the compiler never complains.
However, when I start the app Vista immediately tells me the program hit a
fatal error.
This is how I try to use it.
POINT mousePos = g_pDI->DIMouseHandler();
OR
POINT mousePos = (g_pDI->DIMouseHandler());
//Attempt to use mousePos.x and mousPos.y
Commenting that call makes the program run smoothly again, (minus the mouse
of course)
I'm a novice, so I'm out of ideas. What did I miss?
Visual Studio 2008
Windows Vista
I am using a DirectInput framework that I downloaded to study.
Everything in it works correctly except for the following function.
POINT DirectInput::DIMouseHandler(void)
{
POINT p;
HRESULT hr;
//Clear out the mouse structure
memset(&m_diMouseState, 0, sizeof(m_diMouseState));
//Get the scoop from the mouse
if(FAILED(hr = m_diMouse->GetDeviceState(sizeof(m_diMouseState),(LPVOID)
&m_diMouseState)))
{
//Maintain control of mouse
if(hr == DIERR_INPUTLOST)
m_diMouse->Acquire();
}
p.x = m_diMouseState.lX;
p.y = m_diMouseState.lY;
return p;
}
Everything runs fine to it's call, and the compiler never complains.
However, when I start the app Vista immediately tells me the program hit a
fatal error.
This is how I try to use it.
POINT mousePos = g_pDI->DIMouseHandler();
OR
POINT mousePos = (g_pDI->DIMouseHandler());
//Attempt to use mousePos.x and mousPos.y
Commenting that call makes the program run smoothly again, (minus the mouse
of course)
I'm a novice, so I'm out of ideas. What did I miss?