Jump to content
  • Advertisement
Sign in to follow this  
zyrolasting

Trying to Unaquire DI properly to return devices to Windows

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

When I ALT-TAB or minimize out of my application, code I set in the program is still running SetCursorPos to the center of the window and ShowCursor() is set to false. I figured my solution was WM_ACTIVATE APP, and I wrote a function called ShareDevices() which does nothing more than call UnAquire() on both my keyboard and mouse objects. The cursor is visible again, but I think the DirectX app retains it's grip since I still can't move it. How do I ensure that the keyboard and mouse remain in the app's control only when's it active? What am I missing/forgetting?
case WM_ACTIVATEAPP:
            {
                if(wParam)
                    ResetDevice();
				else
				{
					ShareDevices();
					ShowCursor(true);
				}
                return 0;
            } break;

Share this post


Link to post
Share on other sites
Advertisement
SetCursorPos and ShowCursor are not part of DirectInput. If you use them, you have to do any "releasing" yourself.

You're good with WM_ACTIVATEAPP already. Store a bool holding the last activation state. If you're not active do not call SetCursorPos.

A good idea would be to go into pause mode if your window looses the active state.

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!