Sign in to follow this  

SetCooperativeLevel() Succeeds Then Causes Lock Up ?

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

Hi guys, My mouse and keyboard work perfectly under DirectInput and I seem to be able to setup my joystick as well. But when my program closes it locks up, and it's caused by SetCooperativeLevel() for the joystick (when I comment it out all is well). The thing is, the program runs fine until I exit, then it breaks right after DestroyWindow(). What's going on ?

Share this post


Link to post
Share on other sites
It doesn't crash when I exit now, all I have to do is clean up DirectInput *before* I clean up Direct3D, I tried that for the hell of it thinking it wouldn't matter but it did.

What should I use for keyboard/mouse, the regular message loop ? That's all I'm familiar with (besides DI) but maybe there is a better way ?

Thanks a lot.

Share this post


Link to post
Share on other sites
Quote:
Original post by Endemoniada
It doesn't crash when I exit now, all I have to do is clean up DirectInput *before* I clean up Direct3D, I tried that for the hell of it thinking it wouldn't matter but it did.
D3D subclasses the window you pass to it, and I imagine DirectInput does as well. Because of that, you'll probably need to make sure that you destroy DI and D3D in the reverse order you created them in; in your case I bet you init D3D before DirectInput, so you should clean up DI then D3D.
I suspect that you were getting a crash inside DirectInput because it was trying to restore the original window proc to how it was before DI hooked it; which is a thunk to D3D's subclasses window proc - which has been deleted by now, so you'd get "weird stuff" happening.

Quote:
Original post by Endemoniada
What should I use for keyboard/mouse, the regular message loop ? That's all I'm familiar with (besides DI) but maybe there is a better way ?
Yup, plain old windows messages. The only reason you'd want to use something other is if you want high-DPI mouse input (For a FPS camera that you think needs more precision than you can get with window messages), and then you'd want to use raw input rather than DirectInput.

Share this post


Link to post
Share on other sites

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