Sign in to follow this  

Help! DirectInput won't acquire in debug!

This topic is 4838 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 debug, my engine gets stuck in a rut trying to Acquire() the keyboard. It keeps returning DIERR_DEVICELOST and trying again. I guess I must have set the cooperative level wrong, but I don't know what it should be! Can anyone help? It's currently set to (DISCL_FOREGROUND | DISCL_NONEXCLUSIVE) I had a search, but the only guy who seems to have had this problem fixed it himself and didn't tell us how! :o TIA Al

Share this post


Link to post
Share on other sites
Actually I just realised I've been a complete four asterisks.

I wrote the code half asleep (excuses, excuses!) but it turned out I'd done

while(res = DIERR_INPUTLOST) res = keyboard->Acquire();

Anyone awake can see what's wrong with that!

Hehe. Oops.

Share this post


Link to post
Share on other sites
ok, im not sure if you figured out the problem or not. so i will explain the solution.

you try and get your data from dinput, if and only if it returns DIERR_INPUTLOST, do you try and reacquire your input device.

do not enter a loop for this either, simply call acquire once, if it cant be reacquired this frame, skip over processing input and try again next frame.

Also as the Scrawl sample shows in the DXSDK, when your window recieves a WM_ACTIVATE message, if the lparam is WA_INACTIVE (or whatever it is) then that means your window is losing focus, and you unacquire all your devices. if lparam != WA_INACTIVE then you try and reacquire them. make sure your pointers are valid when you do this, b/c you typically get a wm_activate message before you create your direct input devices, meaning assertion errors!

your cooperative level is fine as it, for a nonfullscreen application. right now its set to only accept input while its in focus, and to allow other programs to read input in the background (including windows), which is what you want.

if its fullscreen you want, foreground and exclusive. this is faster because windows doesnt get the input and generate any input messages for other programs and stuff, which is faster. but you cant have it for windowed mode b/c with say your mouse it would hide the cursor, since it stops windows from processing the input, except for special ones like alt-ctrl-del ect.

the one catch with exclusive input, is you need to giveup your device manually when nessicary, which is what the code in the WM_ACTIVATE message will do.

ok thats a half decent explanation i think, hopefully...good luck

Share this post


Link to post
Share on other sites

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