Jump to content
  • Advertisement
Sign in to follow this  
Endemoniada

Mouse Info Without DirectInput ?

This topic is 2163 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, I don't want to use DirectInput in my game. Is this the best way to get the mouse delta:


// called every frame

void heartbeat()
{
GetCursorPos(&point);
SetCursorPos(screenWidth/2,screenHeight/2);

delta.x=point.x-lastPoint.x;
delta.y=point.y-lastPoint.y;

lastPoint.x=point.x;
lastPoint.y=point.y;
}


I also want to determine if the mouse buttons are depressed. I was thinking of something simple like this:


// gets called when a WM_LBUTTONDOWN message comes in
void OnLButtonDown()
{
leftButton=TRUE;
}

// gets called when a WM_LBUTTONUP message comes in
void OnLButtonUp()
{
leftButton=FALSE;
}

// then in heartbeat() I can just do:

if(leftButton)
...


Does all that look right ? Maybe there is a better way ? Thank you.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!