Sign in to follow this  
Endemoniada

Mouse Info Without DirectInput ?

Recommended Posts

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

[code]
// 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;
}
[/code]

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

[code]
// 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)
...
[/code]

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this