Jump to content
  • Advertisement

Archived

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

peter86

DirectInputDevice8::Acquire returns E_ACCESSDENIED

This topic is 5738 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 set the cooperative level like below Acquire() returns E_ACCESSDENIED, but if I skip the cooperative level, it works fine. What´s wrong?
  
if( FAILED( hr = g_pKeyboard->SetCooperativeLevel( hWnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE ) ) )
{
	return hr;
}

if( FAILED( hr = g_pKeyboard->Acquire() ) )
{
	return hr;
}
  
____________________________________________________________ Nothing dosen´t exist. Does it?

Share this post


Link to post
Share on other sites
Advertisement
It works fine with DISCL_BACKGROUND, so why not DISCL_FOREGROUND?

[edited by - peter86 on December 3, 2002 2:17:20 PM]

Share this post


Link to post
Share on other sites
maybe your application is in the background when you try to acquire the device so it'll fail, because it cant acquire the device util your app is in focus. I dunno for sure, could you maybe post some code, initialization caode that is.

On another note why dont you just get rid of the if(FAILED( checking on the Acquire method. That way when you use the function GetDeviceState(...) and that fails, then you can enter a loop until the device is acquired or something


::: Al:::
[Triple Buffer V2.0] - Resource leak imminent. Memory status: Fragile

[edited by - alfmga on December 3, 2002 2:33:56 PM]

Share this post


Link to post
Share on other sites
It''s very annoying, as I''m experiencing the same thing now!

Input code which USED to work just fine, now suddenly doesn''t.

I''ve rebooted the machine, I''ve tried to use SetFocus to force the window to the foreground.

Nada.

Share this post


Link to post
Share on other sites
quote:
Original post by wazoo69
It''s very annoying, as I''m experiencing the same thing now!

Input code which USED to work just fine, now suddenly doesn''t.

I''ve rebooted the machine, I''ve tried to use SetFocus to force the window to the foreground.

Nada.


Just acquire when GetDeviceState returns DIERR_INPUTLOST or DIERR_NOTACQUIRED and you´ll get rid of the annoying problem .

Share this post


Link to post
Share on other sites
This could happen if your creating direct input before the window is set to visible. (ie before the ShowWindow() call) I''m not sure if the application is in the foreground until it is visible but others here might be able to clarify this if it isn''t the case.

Do you have anything running in the taskbar that would cause your application to move to the background? Are you running a profiler that could cause this? Virus scanner? IM application?

In anycase, as long as all that is an error is that your not getting the keyboard acquired, you can handle that during GetDeviceState or GetDeviceData as mentioned above. You should handle it here regardless as that is good practice.

I went ahead and changed the (FAILED()) checks in my code. Every DirectInput call now passes the result to ''hr'' and I test all of the known return values according to MSDN function specs and record specifics to log files. It helps to have this information when DirectInput begins to fail.

Kressilac
ps Side note. Use GetDeviceData instead of GetDeviceState if absolutely every keypress must be captured. GetDeviceState stands a good chance of missing keys.

Share this post


Link to post
Share on other sites
Hmm I wonder if that''s it?

In my old codebase, one of the window creation parameters was set to WS_VISIBLE (and the input worked)

Yet now, I removed that, and am just calling ShowWindow after the device initialization..

Share this post


Link to post
Share on other sites
My code uses DISCL_FOREGROUND with DISCL_NONEXCLUSIVE, but before calling Acquire() it calls SetDataFormat(&c_dfDIKeyboard). You need to do that. c_dfDIKeyboard is defined by DirectX so just type that verbatim ("g_pKeyboard->SetDataFormat( &c_dfDIKeyboard )") and it should work. The call goes inbetween SetCooperativeLevel and Acquire.

~CGameProgrammer( );

[edited by - CGameProgrammer on December 5, 2002 1:53:10 AM]

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!