• Advertisement
Sign in to follow this  

LPDIRECTINPUTDEVICE8::Acquire() error

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

Advertisement
How about you run a search in the SDK documentation and read what it says about DIERR_OTHERAPPHASPRIO?

Share this post


Link to post
Share on other sites
This could happen when your program is running on the background while it only has foreground acces. Do a loop until you can acquire.

I captured data from the device this way:
hr = mlpDIKeyboard->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), didod, &dwElements, 0 );
if( FAILED(hr) )
{
// Error
hr = mlpDIKeyboard->Acquire();
while( hr == DIERR_INPUTLOST )
hr = mlpDIKeyboard->Acquire();

// hr may be DIERR_OTHERAPPHASPRIO or other errors. This
// may occur when the app is minimized or in the process of
// switching, so just try again later
return !FAILED(hr);
}


You can see that I keep acquiring until it works. But when I receive your error message it just doesn't do anything.

This message can occure when you application is trying to access the device, when it is in the background, but you only have foreground access. You can avoid that by using other creation flags.

GBS

Share this post


Link to post
Share on other sites
Can you tell me excactly when you receive the error, is your window selected? Is it foreground or background? And with what flags did you create the device?

GBS

Share this post


Link to post
Share on other sites
	
// keyboard
hr = IO_Object->CreateDevice(GUID_SysKeyboard, &IO_KeyboardDevice, NULL);
if(FAILED(hr)){
e2::Error("Error(1):", ERR_LEVEL0);
return -1;
}

hr=IO_KeyboardDevice->SetDataFormat( &c_dfDIKeyboard );
if(FAILED(hr)){
e2::Error("Error(2):", ERR_LEVEL0);
return -1;
}

hr = IO_KeyboardDevice->SetCooperativeLevel(MainWindowHandle, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE);
if(FAILED(hr)){
e2::Error("Error(3):", ERR_LEVEL0);
return -1;
}


IO_KeyboardDevice->Acquire(); // ***

Share this post


Link to post
Share on other sites
Thank you for the information.

Here again a piece of code straight out of my engine:


// Blabla initialization of the keyboard device, setting buffer size etc.

// Try to aqcuire
hr = mlpDIKeyboard->Acquire();
if (FAILED(hr) && hr != DIERR_OTHERAPPHASPRIO)
{
// Error here (not shown)
}




As you can see here I dont care if this error pops up straight after initialization. This is because it's possible that when you create the device your window is still in the background. (Very likely in your case)

It doesnt matter that you receive the DIERR_OTHERAPPHASPRIO error. You can just ignore it. As long as you acquire it on a latter time.

Hope this helps,

GBS

Share this post


Link to post
Share on other sites
As GraphicsBas said, you can;t acquire your device immediately after creating the window, because it isn't properly constructed yet. You need to wait till you've processed a few window message first, or request background access instead of foreground.

Share this post


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

  • Advertisement