Original Post
🔒 Locked
directinput -- mouse position?
Advertisement
It depends whether you use your own mouse pointer or whether you use the Windows one. If you use the Windows one you simply call an appropiate API function (though I'm too lazy to help you with that I'm sure someone else can). If you have your own mouse pointer you should store its position in vector screen coordinates, and then update it every frame by adding the movement vector from Direct Input (preferably you first multiply it by some user-definable scalar to allow the user to set the mouse sensitivity).
[edited by - Unwise owl on June 10, 2004 9:55:39 AM]
[edited by - Unwise owl on June 10, 2004 9:55:39 AM]
You can do it multiple ways:
(1) Check for the WM_MOUSEMOVE windows message. It will give you the mouse coordinates in lparam. This would be good because you only have to update when the user moves their mouse.
(2) Use GetMouseMovePointsEx() to get the last whatever number of points the mouse was at
(3) Simply track the position with DirectInput by adding the position every frame
Method #1 is probably the easiest way to go.
![]()
Dustin Franklin
Mircrosoft DirectX MVP
(1) Check for the WM_MOUSEMOVE windows message. It will give you the mouse coordinates in lparam. This would be good because you only have to update when the user moves their mouse.
(2) Use GetMouseMovePointsEx() to get the last whatever number of points the mouse was at
(3) Simply track the position with DirectInput by adding the position every frame
Method #1 is probably the easiest way to go.
Dustin Franklin
Mircrosoft DirectX MVP
That is pretty simple:
Direct Input tell''s you the "Delta" move. So if dxinput returns (0,0), your mouse has not moved, if it says (-5,0) your mouse moved 5 pixels to the left, if it says (0,7) it went 7 pixels down and so on. What you have to do is:
int iMouseX = ScreenWidth/2, iMouseY = ScreenHeight / 2;
... Get your dx info and then:
iMouseX += dx;
iMoyseY += dy;
if you have a 640x480 screen your mouse will start at 320x240. When you move it 5 pixels to the left, the dx will be -5, and dy = 0:
iMouseX += dx -> 320 += -5 ->315
So it goes.
Direct Input tell''s you the "Delta" move. So if dxinput returns (0,0), your mouse has not moved, if it says (-5,0) your mouse moved 5 pixels to the left, if it says (0,7) it went 7 pixels down and so on. What you have to do is:
int iMouseX = ScreenWidth/2, iMouseY = ScreenHeight / 2;
... Get your dx info and then:
iMouseX += dx;
iMoyseY += dy;
if you have a 640x480 screen your mouse will start at 320x240. When you move it 5 pixels to the left, the dx will be -5, and dy = 0:
iMouseX += dx -> 320 += -5 ->315
So it goes.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement