Sign in to follow this  

Trying to Unaquire DI properly to return devices to Windows

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

This topic is 3338 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this