I am having trouble resolving the absolute screen position of the cursor.
Here is my setup of the DirectInput mouse device...it is currently set up in relative mode (only because I'm not sure how to set it up in absolute mode):
if (lpdi->CreateDevice(GUID_SysMouse, &lpdimouse, NULL)!=DI_OK)
return(0);
// set cooperation level
if (lpdimouse->SetCooperativeLevel(main_window_handle,
DISCL_NONEXCLUSIVE | DISCL_BACKGROUND)!=DI_OK)
return(0);
// set data format
if (lpdimouse->SetDataFormat(&c_dfDIMouse)!=DI_OK)
return(0);
// acquire the mouse
if (lpdimouse->Acquire()!=DI_OK)
return(0);
Then in my main event loop I poll the mouse and try to convert the relative coordinates to absolute coordinates:
mouse_x += mouse_state.lX; //initialized to screen_width/2;
mouse_y += mouse_state.lY; //initialized to screen_height/2;
I thought that would give me absolute cordinates but the values do not seem to be correct. For example, if i drag the cursor to the corner of the screen the position doesnt appear as (0,0).
How can I easily obtain the absolute (x,y) position of the cursor?