• Advertisement

Archived

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

DInput8 Relative Coordinates Problem

This topic is 5091 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);
 
	HRESULT		hr;
	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;
	GetCursorPos(&pt);
	if(lpmEngine->bWindowed)
		ScreenToClient(lpmEngine->hWnd,&pt);
	MouseX = pt.x;
	MouseY = pt.y;
 
That's the Init Code. Then, every frame:
	DIMOUSESTATE2 MouseState;
	relMouseX = 0;
	relMouseY = 0;

	// Eingabedaten von der Maus holen

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

		if(lpMouse->Acquire()==DI_OK)
			lpMouse->GetDeviceState(sizeof(DIMOUSESTATE2), &MouseState);
	}

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

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

	POINT pt = {MouseX,MouseY};

	if(lpmEngine->bWindowed)
		ClientToScreen(lpmEngine->hWnd,&pt);

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

	if(lpmEngine->bWindowed)
		ScreenToClient(lpmEngine->hWnd,&pt);

	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
Advertisement
No one here who can answer me ?
Would you recommend to use GetCursorPos() every frame instead of DInput ?

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.
PLEASE HELP ME!!!!

Share this post


Link to post
Share on other sites

  • Advertisement