Archived

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

red_sodium

DirectInput client cursor co-ords

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