Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

MancubuS

Mouse stuff

This topic is 6476 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

Does anybody know how I can read the RELATIVE Mouse movement without using Direct Input(there has to be a Win32 function that does that???) --Mancubus

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by NuffSaid

Handle the WM_MOUSEMOVE ?


It returns only the ABSOLUTE coordinates, not the realitives.

The relatives are the mouse position change since the last read of its state. That''s what I need.

Q2 uses it(I''m sure that it uses it cause I haven''t DirectInput on my PC and it runs pretty good.), so there HAS to be a way....



Share this post


Link to post
Share on other sites
Call

BOOL GetCursorPos(
LPPOINT lpPoint // address of structure for cursor position
);

And store the previous value to get the relative.

Share this post


Link to post
Share on other sites
quote:
Original post by Backman

Call

BOOL GetCursorPos(
LPPOINT lpPoint // address of structure for cursor position
);

And store the previous value to get the relative.


Thanx!!!

Share this post


Link to post
Share on other sites
That works fine until the mouse cursor hits the edge of the screen.

At each tick, test where the mouse cursor is relative to the center of the screen, then restore the cursor to the center of the screen.

Share this post


Link to post
Share on other sites
quote:
Original post by Beer Hunter

That works fine until the mouse cursor hits the edge of the screen.

At each tick, test where the mouse cursor is relative to the center of the screen, then restore the cursor to the center of the screen.


Yes that''s right. There has to be a function SetCursorPos. It''s easier to set the cursor position to 0,0 and then to read the pos. I''ll get directly the relative coordinates then...

Share this post


Link to post
Share on other sites
No, being lazy here won''t work. If you put it at [0,0], you won''t get any movement if the user tries to move the cursor up or left. So, put it at center screen, and do the extra math...

junk = GetCursorPos(vPos)
OffSetX = vPos.X - (ScreenWidth/2)
OffSetY = vPos.Y - (ScreenHeight/2)
vPos.X = (ScreenWidth/2)
vPos.Y = (ScreenHeight/2)
junk = SetCursorPos(vPos)

That will work. (ScreenWidth/2) and (ScreenHeight/2) should be either constants, or pre-calculated.

Share this post


Link to post
Share on other sites
quote:
Original post by Wyrframe

No, being lazy here won''t work. If you put it at [0,0], you won''t get any movement if the user tries to move the cursor up or left. So, put it at center screen, and do the extra math...

junk = GetCursorPos(vPos)
OffSetX = vPos.X - (ScreenWidth/2)
OffSetY = vPos.Y - (ScreenHeight/2)
vPos.X = (ScreenWidth/2)
vPos.Y = (ScreenHeight/2)
junk = SetCursorPos(vPos)

That will work. (ScreenWidth/2) and (ScreenHeight/2) should be either constants, or pre-calculated.



Oh yeah.... you''re right. Thanx!!!

Share this post


Link to post
Share on other sites
i''ve found SetCursorPos to be very slow... anybody know why? or anybody have any other ways around using it?...



Thank you for your bandwidth.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~Succinct Demos Online~


"<DiLLiGaS> I''m suprised nobody takes M$ to court for rape... The OS keeps going down on you w/o your permission."

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!