DirectInput client cursor co-ords

Started by
3 comments, last by red_sodium 20 years ago
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.
"Learn as though you would never be able to master it,
hold it as though you would be in fear of losing it" - Confucius
Advertisement
After about a week, I still have this problem. Does anyone know of a solution?
"Learn as though you would never be able to master it,
hold it as though you would be in fear of losing it" - Confucius
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

@mikaelbauer

Super Sportmatchen - A retro multiplayer competitive sports game project!

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.
_______________________________________________________________________Hoo-rah.
you make your own mousex, mousey, do collision detection for it on the screen, and + the mouse movements to the x,y

This topic is closed to new replies.

Advertisement