Jump to content
  • Advertisement
Sign in to follow this  

DirectInput Aquire() Fails

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

If the window is not visible or the active window at the time I am initializing the Keyboard and Mouse as input devices in DirectInput, then Aquire() will fail when I call it on the mouse object. I don't know why this happens. It works perfectly fine otherwise. For example, if I step through the DirectInput initialization process via the Visual Studio debugger, it will fail because the window is not active/visible. The error return is DI_OK, but FAILED() says it failed. Below is my setup process, in case you're curious of my code:

        memset(m_KeyTap, 0, 256);

        CSAFECALL(DirectInput8Create(m_Window->GetInstance(), DIRECTINPUT_VERSION,
            IID_IDirectInput8, (void**)&m_Object, NULL));

        // Initialize Keyboard
        CSAFECALL(m_Object->CreateDevice(GUID_SysKeyboard, &m_Keyboard, NULL));
        CSAFECALL(m_Keyboard->SetCooperativeLevel(m_Window->GetWindowHandle(), DISCL_NONEXCLUSIVE | DISCL_BACKGROUND));

        // Initialize Mouse
        CSAFECALL(m_Object->CreateDevice(GUID_SysMouse, &m_Mouse, NULL));
        CSAFECALL(m_Mouse->SetCooperativeLevel(m_Window->GetWindowHandle(), DISCL_NONEXCLUSIVE | DISCL_BACKGROUND));

Share this post

Link to post
Share on other sites
I think that's just how things are. You can't acquire the device from a hidden window. Anyway, DI is going away soon, so it's recommended that you switch to standard Win32 API calls for keyboard and mouse, and only use DI for joysticks and controllers and stuff.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!