• Advertisement
Sign in to follow this  

how to detect the coordinate of mouse cursor

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

How to detect the coordinate(x, y) of the mouse cursor. One of the example in DirectX Sample Browser "Cusstom Format" under DirectInput category got teach this, but the program got bug, I was point the cursor to a position, then i move the cursor around and point it back to same position, the coordinate will be different. I was tried to modify the program, and set the cursor to centre when the program run, but the coordinate still different when I move the cursor to same position. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Are you talking about where the mouse cursor is in 3d space translated to the 2d screen, or just the x and y position of the mouse on the screen?

Share this post


Link to post
Share on other sites
You shouldn't use DirectInput for absolute mouse input. If you are drawing your own mouse cursor, you may get away with it, but it won't be compatible with the Windows cursor, and will probably feel strange to the user. The reason for this is that Windows implements mouse acceleration, by default, so that the user can quickly traverse the screen without having to make wild hand movements. Since you are (presumably) using the DirectInput coordinates linearly, you will get dicrepancies unless the mouse moves at a constant speed.

Microsoft themselves recommend that you only use DirectInput for high DPI relative mouse input (for first-person games, in particular). If you want mouse input in screen coordinates, it is simpler, faster and more effective to use GetCursorPos (which is lightning fast anyway).

Regards
Admiral

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement