Direct Input Lost

Started by
4 comments, last by S1CA 16 years, 2 months ago
I'm using DInput. When I switch applications, DInput is lost and my App crashes. How Can I recover it? with D3D I just call Direct3DDevice->Reset() after releasing everything. How do I do it with DInput? (im using Version 8).
Advertisement
When a DirectInput device is lost, calls to get data will return DIERR_INPUTLOST.

When you get a DIERR_INPUTLOST error you need to attept to re-acquire the device again (IDirectInputDevice8::Acquire). Take a look at the "Acquiring Devices" section of the SDK documentation for more info.

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Your app shouldn't crash if the device is lost, because the pointer is still valid. Unless you're checking for FAILED() HRESULT codes and releasing the input device of course.
Also, I hope you're not using DirectInput for mouse or keyboard input...
Quote:Original post by Evil Steve
Also, I hope you're not using DirectInput for mouse or keyboard input...


Thanks for summing everything up in a single post regarding DirectInput and keyboard/mouse.

I have 2 follow-up questions on this:

1> Can you point to any VB.Net examples for doing the Raw input reading? (Or C# examples, which I'd be able to use for conversion to VB.Net?)

2> Is DirectInput still a good source for reading traditional ("pre-XBox compatible") joysticks/gamepads? Or are there newer/better methods for that now too? (btw, I'm working with DirectX9 through SlimDX)

Thanks for anything you can point me to!

-Matt
www.mwgames.com - my game projects websiteNimble2D Blog - Simple 2D Game Dev with VB.Net
Never mind my question #1 -- I'm getting that piece figured out.

However, I am still curious about insights on #2.

Thanks,
-Matt
www.mwgames.com - my game projects websiteNimble2D Blog - Simple 2D Game Dev with VB.Net
Quote:Original post by MattWorden
Never mind my question #1 -- I'm getting that piece figured out.

However, I am still curious about insights on #2.

Thanks,
-Matt


Yep, for joysticks/joypads that are not Xbox 360 compatible DirectInput is still the best way to go.

For Xbox 360 pads (aka "Microsoft Common Controller"), XInput is the way to go.

And as Steve mentioned, you shouldn't be using DirectInput for mouse or keyboard these days (back in the Windows 98 days maybe, but not now).

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

This topic is closed to new replies.

Advertisement