Sign in to follow this  
Martaver

[.net] Problems with DirectInput Device - setting CooperativeLevels

Recommended Posts

Hi guys, I've been busting my brain over an error I've been getting for days now, and I simply have no idea what's causing it. I hope some of you have ideas on what's going on. I'm writing a simple rendering engine in C# & Managed DX9.0b: - I have a RenderState, which is a singleton class that all modules in my engine manipulate. It contains the Direct3D device & the module which draws to the device etc. - I have a 'Render-to' Control which also exists exclusively in the RenderState, along with the stuff that draws to it. - I also have an interface for dynamically loaded DLLs to interact with the system as 'plugins'. So far, all of this stuff works fine - I can render stuff from my plugins, the control works - it's all dandy. My problem comes when I try to initialize a 'camera' plugin that would control my view in the engine. I create a new DirectInput device like so: device = new Device(SystemGuid.Keyboard); device.SetCooperativeLevel( RenderState.Display, CooperativeLevelFlags.Background | //Can be used at all times. CooperativeLevelFlags.NonExclusive); //Other applications may use this device. RenderState.Display being the Control associated with the RenderState that I described above. At this point, the app dies - throwing an 'InputException', which I would have to say is the least descriptive exception I've ever seen. If I do: device.SetCooperativeLevel( new Form(), CooperativeLevelFlags.Background | //Can be used at all times. CooperativeLevelFlags.NonExclusive); //Other applications may use this device. I get 'UnsupportedException' - whose MSDN description is something like 'function is not available at this time'. Anyone have any ideas?

Share this post


Link to post
Share on other sites
Since you seem to be just setting the coop levels to their default, try not making the SetCooperativeLevel call at all.

I have seen this same thing a number of times on these forums, but I do not recall what the solution was (if there was a solution) -- it may be worth doing a search. Not much really going on in these lines, seems like the error must be coming from elsewhere.

Share this post


Link to post
Share on other sites

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