Sign in to follow this  
123abcd1983

how to detect the coordinate of mouse cursor

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this