DirectInput wont release [Solved]

Started by
11 comments, last by jflanglois 18 years, 5 months ago
I've been having a minor problem with my game, but recently it's been really annoying me. I'm only using DirectX for DirectInput and OpenGL for rendering which all works fine when everything works. The problem is when an assert fails or a message box pops up I cant use mouse or keyboard to click ok or on whatever buttons are available. I am using exclusive buffered mode for both keyboard and mouse, so I figure that might be where the problem is but I'm using my own asserts that both unaquire anf release the keyboard and mouse devices before I call the normal assert and it seems to have no effect. Anothing that really bothers me is that I can still drag around the message boxes and assert dialogs but I cant click on the X to close it. Does anyone have a clue as to what might be causing this? [Edited by - Skiller on November 22, 2005 10:31:25 AM]
-Skiller
Advertisement
Some questions to lessen problem scope:

Here we go:
Do you have the same problem in non-fullscreen?
Do you have the same problem with a nonexclusive device?
Do you have the same problem with all kind of dialogs? I.e. no just only MessageBox derived dialogs.
Do you have the same problem with all kinds of asserts or just some of them?

Would you mind posting some source? Especially the the DirectInput part or any other source you consider as suspicious.
[s]--------------------------------------------------------[/s]chromecode.com - software with source code
DEFINATALLY happens in windowed mode because I using windowed as default for easier Debugging. But I tested in fullscreen and same thing happens but more annoying since you have to CTRL-ALT-DEL to end the process. In windowed I just move mouse outside the window and click stop in VC++ (which is kind of wierd that it works).

Just tested with DISCL_NONEXCLUSIVE and it still happens. Probably should have tested that before posting as this make me think it migh not be DX.

I'm not sure what other dialogs there are, I only used MessageBox and assert. and neither of these work. Also with a message box the X on the main app window works but not the X on the actual message box window.

I'm only using the standard assert:
#include <assert.h>
assert(condition);
But I made my own assert fuction to release DirectInput to avoid this very problem:
void UtAssert(bool condition, char* warningMessage, bool critical) {	if (condition != true) {		char buffer[2048];		sprintf(buffer, "\n***** UtAssert Failure: %s *****\n\n", warningMessage);		OutputDebugString(buffer);		if (critical == true) {			Input::Release();			assert(condition);		}	}}


As for the source the problem should almost certainly be in the Input class so I'll upload the header/source for it, it's probably a bit big to post.
The header/source

Let me know if there's anything else you might need to know to help me with this prob. Thanks :D
-Skiller
I haven't encoured this problem before, but I'm keen on finding out why it behaves as it does.

I looked at the code, and it seems ok. I wonder though, why do you have the WndProc inside the Input class? Handling window messages has not much do with input IMHO. Well, it has some to do with it, but not enough to put the WndProc inside the Input class :)

Maybe it could have something to do with windows being unable to handle messages while the assert is shown. Maybe this has to do with putting the WndProc in the Input class. It should not matter, but maybe it does.

If I were you, I'd try to capture the code by working my way up from a very non complex app and up to what you have now.

I.e. first make a windows app (maybe even a consle app), where you just do an assert. If you are able to click this dialog, complicate the code a bit. For instance by implementing the game loop with just the input class initiated, and the make another assert call. If you are able to click this one, just add more and more complexity until you end up with the app you have now.

When you add code that suddenly makes the dialogs unclickable, investigate in that code.

This will take some work probably, and there's probalby some code guru who can tell you what's wrong immediatly. But I think it will be worth it.

Let me know when you've made some progress. Alternativly, you can mail me the source and I'll make a try. But that's just an emergency solution, since I've other things going on aswell :)

Happy hacking!
[s]--------------------------------------------------------[/s]chromecode.com - software with source code
Most of my code is pretty experimental at the moment, and I had originally been using input based off the way NeHe does it, which is why WndProc is in with the input.
There's probably too much source for in my game atm for it to be worth while sorting through, particularly since there are next to no comments in it :(, but I'll whip up a binary so that anyone willing to help can experience exactly what is wrong, because it's very confusing that half of it seems to work and half not :(.

[edit]
Here's the binary:
binary
It should pop up with a messagebox saying OMG or something like that, u cant click ok, but you can move it around, and you can click the X of the main window. Then it might show a loading screen and crash because it cant find data. You can click stuff in the crash report window thing that pops up.

[Edited by - Skiller on November 15, 2005 7:06:18 AM]
-Skiller
*bump*

Any body got any ideas what might be causing this?
-Skiller
You should have bumbed the thread with the edit, because then I would have knew there were new stuff in the thread immediatly :)

Anyway, I ran the binary and I get the same error. It seems like the mouse is disabled. Have you tried enabling the mouse in your homemade assert? It also seems that the app stops pumping messages, since you cant even focus on the omfg!-dialog, even with alt-tab. Would you mind sending me the source? That way I could more effectivly debug.
[s]--------------------------------------------------------[/s]chromecode.com - software with source code
There's too much code for me to upload unfortunatally, but i'll see if i can strip out some of the stuff over the weekend.
You think it might be that the proc function isn't working for the dialogs? I'll look into it more when stripping out stuff (I love having the safety of being able to load previous revisions in svn :D, just a pity I didn't start using svn till long after this problem showed up :( )
-Skiller
Ok here's the stripped down version of the code, still has the problem but has alot of stuff removed and now only relies on directx :) (used to need other middleware).
To get it to work you'll probably need to edit "Source\Resource Files\SearchPaths.txt" and "Source\Resource Files\Libraries.cpp" to point to where your directx sdk is. Also it was made in VC 2005, if you are using VC 2003 I think you can get it working by just editing the .vcproj in notepad and changing the version to 7 instead of 8.

THE FILE

Let me know if you have any probs, most of what you will want to look at will be in the display or input classes.

And thanks for helping me with this :D
-Skiller
*bump*

Anyone got any ideas, or are you all as stumped as me :(
-Skiller

This topic is closed to new replies.

Advertisement