Mouse stuff
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
________________HASTE - still recruiting
Handle the WM_MOUSEMOVE ?
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
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....
________________HASTE - still recruiting
Call
BOOL GetCursorPos(
LPPOINT lpPoint // address of structure for cursor position
);
And store the previous value to get the relative.
BOOL GetCursorPos(
LPPOINT lpPoint // address of structure for cursor position
);
And store the previous value to get the relative.
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!!!
________________HASTE - still recruiting
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.
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.
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...
________________HASTE - still recruiting
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.
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.
RIP GameDev.net: launched 2 unusably-broken forum engines in as many years, and now has ceased operating as a forum at all, happy to remain naught but an advertising platform with an attached social media presense, headed by a staff who by their own admission have no idea what their userbase wants or expects.Here's to the good times; shame they exist in the past.
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!!!
________________HASTE - still recruiting
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."
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."
-- Succinct(Don't listen to me)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement