#### Archived

This topic is now archived and is closed to further replies.

# direct input

This topic is 5375 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Isn´t it even showing the message box you placed inside the case statement??

##### Share on other sites
quote:
Original post by J_Vitel
Isn´t it even showing the message box you placed inside the case statement??

ha, nope. I don''t get it...

##### Share on other sites
mmmm, so where are you calling your WinProc function? are the other events being called properly??

##### Share on other sites
The way I''ve done it is I have a boolean variable for the key state (such as bSKeyDown).

On the KEYDOWN message, I set bSKeyDown to true and process a keystroke for the S key. But I only process it the first time; if another KEYDOWN comes but the bSKeyDown is already true, I don''t process the keystroke.

On the KEYUP message, I set bSKeyDown to false. Then when another KEYDOWN message comes, I can process the keystroke again.

##### Share on other sites
quote:
Original post by J_Vitel
mmmm, so where are you calling your WinProc function? are the other events being called properly??

There is no explicit call to MainWndProc, when the winow is made it is set to use MainWndProc. The other functions I have for menu items etc.. and the WM_DESTROY is being called and thats in there as well.

Is this what you mean?

##### Share on other sites
As others have said, you problem is most likely from the bool value rapidly toggling between true/false every time you press the key due to high frame rates. What you need to do is:

//once only initialisation (do not put this in your loop)bool keydown = false;bool keypressed = false;(loop)keydown = KEYDOWN();if(keydown && !keypressed){   keypressed = true;   playsound != playsound;}else if(!keydown){   keypressed = false;}

##### Share on other sites
The real question is, Are you still using DirectInput? If you are, is your cooperative level exclusive? AFAIK, DirectInput can not share the keyboard with the Windows message queue within the same application - it''s a one or the other situation. Of course, I could be wrong...

The cooperative level dictates whether DirectInput relinquishes control when its window is not the foreground or focus window. That''s to allow it share access with other applications.

If you''re still using DirectInput for other purposes, you''ll simply have to design a more robust capture mechanism.

##### Share on other sites
well I found that it was the cooperation level of the keyboard. It was DISCL_EXCLUSIVE | DISCL_FOREGROUND, and this told me that it was so greedy that it did not even let WIN32 messages come through. So I changed it to NONEXCLUSIVE instead, and then the WIN32 messages started to work. Now everyone is playing nice and sharing.

thanks all for the help! much appreciative

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 16
• 13
• 13
• ### Forum Statistics

• Total Topics
634453
• Total Posts
3017551
×