Sign in to follow this  
Garra

Get real world coords with DirectInput

Recommended Posts

Garra    103
i was wondering if there is a way to get the actual world coordinates of a DirectX window. Below was my original idea... but the coordinates will still start out where the mouse position originally started, and if you move out of the application window the coordinates still change. I wanted something more along the lines of how in GDI you can use WM_MOUSEMOVE to detect when the mouse is moving and then get the actual coords inside of the window, and output them to the screen.


//========================================================================
//get mouse coords to print to screen
//========================================================================
xcord += (float)mouse_state.lX;
ycord += (float)mouse_state.lY;

if (xcord < 0)
xcord = 0;
if (ycord < 0)
ycord = 0;

if (xcord > G_width)
xcord = G_width;
if (ycord > G_height)
ycord = G_height;

sprintf_s(xBuffer, 20, "X: %f", xcord);
sprintf_s(yBuffer, 20, "Y: %f", ycord);

D3DXCreateText(device, G_hdc, xBuffer, 300.0f, 0.004f, &Text_mesh, 0, 0);
D3DXCreateText(device, G_hdc, yBuffer, 300.0f, 0.004f, &Text_mesh2, 0, 0);
//========================================================================


Share this post


Link to post
Share on other sites
Endurion    5412
If you need sensual mouse coordinates don't use DirectInput. Seriously use WM_MOUSEMOVE. The window messages take all kind of user settings into account, while DirectInput does not.

Even if you keep your own set of current mouse position it will feel weird to the user, since all special behaviour is not active.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this