bool DxMouse::Update()
{
assert( m_Initialised && "DxMouse not initialised!" );
HRESULT hResult = m_pMouse->GetDeviceState( sizeof(DIMOUSESTATE2),
(LPVOID)&m_MouseState );
if( FAILED( hResult ) )
{
hResult = m_pMouse->Acquire();
while( hResult == DIERR_INPUTLOST )
hResult = m_pMouse->Acquire();
return false;
}
m_Dx = m_MouseState.lX;
m_Dy = m_MouseState.lY;
m_X += m_Dx + m_WindowRECT.left;
if( m_YDown )
m_Y -= m_Dy - m_WindowRECT.top;
else
m_Y += m_Dy + m_WindowRECT.top;
if( m_X < 0.0f )
m_X = 0.0f;
if( m_Y < 0.0f )
m_Y = 0.0f;
return true;
}
More DX Mouse problems...
Hey!
I'm messing about with DX input using the mouse...I'm moving a QUAD via the mouse position on the screen for testing purposes...the problem is the QUAD overtakes the mouse position the more I move it i.e. It seems that it is accumalting more than it should with adding the dx and dy mouse position per frame to the mouse x and y position, here is my mouse update function:
Can anybody see something obvious that I'm doing wrong? I did try storing the dx and dy of the mouse position from the previous frame and then subtract that from the new mouse dx and dy, that ended up with flickering of the QUAD and drawing two of them :S
Thanks!
The m_WindowRECT.left and m_WindowRECT.top are not needed, they just increase your deltas which result in exactly the effect you describe.
Since the mouse movement is given relative the windows position has no relation to it.
Since the mouse movement is given relative the windows position has no relation to it.
Hi DrukenBrit,
The general concensus for handling keyboard/mouse input seems to favour standard Windows messages now, rather than DX Input.
I do use DX Input occasionally now, but generally only for joystick input.
Either way, I guess the problem may be a difference between mouse coordinates and your viewport coodinates.
I guess the problem may be of your mapping of mouse coordinates to viewport coordinates.
Sorry, I can't be more specific, but I would look for something along those lines.
Could you show your code where you map the mouse coordinates to your quads position (in the viewport)?
HTH,
Cambo_frog
The general concensus for handling keyboard/mouse input seems to favour standard Windows messages now, rather than DX Input.
I do use DX Input occasionally now, but generally only for joystick input.
Either way, I guess the problem may be a difference between mouse coordinates and your viewport coodinates.
I guess the problem may be of your mapping of mouse coordinates to viewport coordinates.
Sorry, I can't be more specific, but I would look for something along those lines.
Could you show your code where you map the mouse coordinates to your quads position (in the viewport)?
HTH,
Cambo_frog
Hi Cambo_frog,
Thank for your reply. My viewport is:
I have also tried to use GetMousePos() and I get the same results with that...
Thanks mate!
Thank for your reply. My viewport is:
glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D( 0.0, (double)g_ScreenWidth, 0.0, (double)g_ScreenHeight ); glMatrixMode(GL_MODELVIEW); glViewport( 0, 0, g_ScreenWidth, g_ScreenHeight ); // Below is my main render loop:void Display(){ glClear( GL_COLOR_BUFFER_BIT ); glClearColor( 0, 0, 0, 0 ); DxMouse::Get().Update(); f32 x = DxMouse::Get().GetMouseX(); f32 y = DxMouse::Get().GetMouseY(); glPushMatrix(); glTranslatef( x, y, 0.0f ); test.Render(); glPopMatrix(); glutSwapBuffers(); }
I have also tried to use GetMousePos() and I get the same results with that...
Thanks mate!
Hi DrukenBrit,
That looks like OGL code rather than DX code!
Or is it a mix of both?
Sorry, but I am not familiar with OGL coordinate systems.
TIA,
Cambo_frog
That looks like OGL code rather than DX code!
Or is it a mix of both?
Sorry, but I am not familiar with OGL coordinate systems.
TIA,
Cambo_frog
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement