Jump to content
  • Advertisement

Archived

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

red_sodium

DirectInput client cursor co-ords

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

Hi, Upon recently using DI for the first time, I realise that you cannot get "cursor" co-ordinates, that is to say, the co-ordinates based upon the top-left of the window/screen. What''s the easiest way to get the client''s cursor co-ordinates (eg, top left of the window is (0,0) and not the whole screen)?Preferably by partly using DI if possible. I already have the mouse device set up and can obtain the mouse''s movements relative to its axes.

Share this post


Link to post
Share on other sites
Advertisement
Don''t know if this helps but here is a thought. Store the mouse coords in two variables, mousex and mousey for example. At the start of the program you set them to some value (0,0) or maybe (screenwidth/2, screenheight/2). Then every loop you add the delta mouse movement to those variables and you''ve got yourself a "virtual" mouse cursor. Then you can perform bound testing etc (i.e so that the cursor doesn''t leave the screen area ).

Hope it helped

Share this post


Link to post
Share on other sites
DirectX does not keep track of cursor position, as that''s windows'' job

try this. it works beautifully.

POINT mousepos;
GetCursorPos(&mousepos);
ScreenToClient(hWnd,&mousepos);

then mousepos.x and mousepos.y contain the mouse coords in the window. this works in fullscreen as well.

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!