DirectInput client cursor co-ords
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.
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
Hope it helped
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.
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.
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
Popular Topics
Advertisement