Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


DInput8 Relative Coordinates Problem

This topic is 5364 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, I searched on this forum for posts concerning my problem but I didn't find any so I' opening a new thread. First of all a little bit code.
 // Create the DI object

	DirectInput8Create(lpmEngine->hInstance, DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&lpDI, NULL);
	hr = lpDI->CreateDevice(GUID_SysMouse,&lpMouse,NULL);
	hr = lpMouse->SetDataFormat(&c_dfDIMouse2);
	hr = lpMouse->SetCooperativeLevel(lpmEngine->hWnd, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE);
	hr = lpMouse->Acquire();

	// Mouse Pos

	POINT pt;
	MouseX = pt.x;
	MouseY = pt.y;
That's the Init Code. Then, every frame:
	relMouseX = 0;
	relMouseY = 0;

	// Eingabedaten von der Maus holen

	if(lpMouse->GetDeviceState(sizeof(DIMOUSESTATE2), &MouseState) == DIERR_INPUTLOST)
		// Maus neu reservieren und nochmal versuchen

			lpMouse->GetDeviceState(sizeof(DIMOUSESTATE2), &MouseState);

	MouseX +=MouseState.lX;
	relMouseX = MouseState.lX;

	MouseY +=MouseState.lY;
	relMouseY = MouseState.lY;

	POINT pt = {MouseX,MouseY};


		pt.x = 0;
	else if(pt.x > lpmEngine->ScreenWidth)
		pt.x = lpmEngine->ScreenWidth;
		pt.y = 0;		
	else if(pt.y > lpmEngine->ScreenHeight)
		pt.y = lpmEngine->ScreenHeight;


	MouseX = pt.x;
	MouseY = pt.y;

That's the whole code infecting the mouse coordinates. It works great on my computer (WIN XP, DX 9.0b, MS Intelli Explorer 3.0 ) I'm using Visual Studio .net to compile the code. I have two friend and I gave them my app to test. The first one has a Win98 system, the second one a WIN XP system. When I point to the ClientPixelOrigin, the X and Y coordinates are 0. But on my friend's computer they are different every time. When they move their mouse fast over the whole screen and point to the same point, the coordinate is different. I tried it already with buffered data -> same thing. I would be really content if someone can help me! Thanks verTex [edited by - ver_T_ex on March 7, 2004 2:14:54 PM]

Share this post

Link to post
Share on other sites
Does anyone see a mistake in my code that would infect my described problem.
I my current code I use GetCursorPos every Frame and it works for everyone but I don''t like it because it''s not exact.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!