Get real world coords with DirectInput

Started by
1 comment, last by Garra 13 years, 6 months ago
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);	//========================================================================
Advertisement
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.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

thanks, i ended up taking your advice and just using WM_MOUSEMOVE to handle my coordinates.

This topic is closed to new replies.

Advertisement