Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Mouse Info Without DirectInput ?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Endemoniada   Members   -  Reputation: 174

Like
0Likes
Like

Posted 20 July 2012 - 10:44 AM

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.

Ad:

#2 ApochPiQ   Moderators   -  Reputation: 7533

Like
0Likes
Like

Posted 20 July 2012 - 10:59 AM

You might also want to look into Raw Input.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS