Jump to content
  • Advertisement
Sign in to follow this  
wonyee

help with DInput. strange problem

This topic is 3720 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

I'm using DInput8 in my game, flag DISCL_NONEXCLUSIVE | DISCL_FOREGROUND, at most time and on most machines, it works fine. but on some machines, the keyboard OR mouse will occasionally "lost response", especially when switching back from other apps or changing to full screen mode. When mouse or keyboard "lost response", I can still get the key press events using windows messages(WM_KEYDOWN,etc) or using GetAsyncKeyState, but pKeyboardDevice->GetDeviceState() or pMouseDevice->GetDeviceState() cannot detect keyboard/mouse actions. heres my GetDeviceState function:
	HRESULT hr;
	hr = device->GetDeviceState(s, data); // for keyboard, s = 256
	if(FAILED(hr))
	{
		if((hr == DIERR_INPUTLOST)||(hr == DIERR_NOTACQUIRED))
		{
			memset(data, 0, s);
			hr = device->Acquire();
			while( hr == DIERR_INPUTLOST ) 
				hr = device->Acquire();
			if(FAILED(hr))
			{
				return hr;
			}
			hr = device->GetDeviceState(s, data);
			if(FAILED(hr))
			{
				ErrorReport(hr);
			}
		}
		else
		{
			ErrorReport(hr);
		}
	}
	return hr;

When keyboard lost response, I hold down a key, and checked the data pKeyboardDevice->GetDeviceState() filled, and got all zeroes. I also checked the return value of Acquire() and GetDeviceState(), nothing is wrong. Everything seems to be fine, but the result is wrong... I've tried calling Unacquire() and then Acquire() and Poll() and GetDeviceState(), three returns DI_OK and Poll() returns DI_NOEFFECT. and still the result is WRONG. I found the only way to make it work again, is to release the DInput device and create and acquire again! Anyone have any ideas? Please help... Thanks a lot!

Share this post


Link to post
Share on other sites
Advertisement
Don't do that. Seriously. I don't understand what this sudden surge in DirectInput threads is all about...

DirectInput is a complete waste of time unless you're targeting Windows 98 (Good luck with that), you're reading multiple axis and button joysticks that aren't XBox 360 controllers, and the Win32 multimedia API isn't good enough for something, or you're doing force feedback.

And to the best of my knowlege there's no such thing as a force feedback keyboard or mouse, which makes it completely redundant, slower to use and harder to implement - As you're seeing here [smile]

Share this post


Link to post
Share on other sites
Now I have a better understanding of DInput...

I'm not targeting Windows 98, and I have no plan to support force feedback devices..
And I think it's time to give up DInput..

Thanks a lot.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!