Jump to content
  • Advertisement

Archived

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

TheHermit

Direct Input ->Acquire()

This topic is 6016 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 am using buffered, exclusive mode Direct input 8, and am curios to know if i have to acquire the keyboard each time i loop the program or if one aquire in my initialisation is enough. The SDK does not specify very clearly for me, and the only way my prog works is if i reaquire each time.

Share this post


Link to post
Share on other sites
Advertisement
You should do it once during initialization, but you also have to be prepared to re-Acquire() if the device is lost. This usually happens when your app window loses focus. For example, if you pop up a MessageBox() your window will lose focus and the device will go into the unacquired state.

--
Eric

Share this post


Link to post
Share on other sites
so something at the beginning of my key capture like this

hr = m_lpDIDevice->GetDeviceData(...,...,...,...);

while (hr == DIERR_NOTACQUIRED)
{
m_lpDIDevice->Acquire();
hr = m_lpDIDevice->GetDeviceData(...,...,...,...);
}

if (FAILED(hr))
//other errors


//and so on..



should be appropriate. Also, this should ensure that when the program loses focus that the game will pause. Right or wrong?

Share this post


Link to post
Share on other sites
You should check for DIERR_INPUTLOST, not DIERR_NOTACQUIRED. The docs warn you that you might/will get an infinite loop if you execute your code. If input is lost, hr will be set to DIERR_INPUTLOST, so you will never reacquire the device this way.

I call (Un)Acquire explicitly during initialization, in my WM_ACTIVATE handler, and when the user tells me to. Since my program can "unacquire" input if the user wants mouse cursor back, auto-acquiring doesn''t work for me.

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!