Jump to content
  • Advertisement


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


win32 Direct input clash

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

hello, i tend to generally be a quiet one but i have ancountered a problem that i just dont seem to be able to find away around. the application im working on uses direct input to handle the mouse control. i''m trying to use the windows message handler to handle hot keys to start, pause, open settings dialogs etc. initially i set it up such that all keyboard entries are handled by the winproc function exe WM_COMMAND, WM_CHAR etc. the keyboard is not needed to control any of the gameplay, just the functions i mentioned above. this brings me to the problem. whenever a hotkey is pressed it seems that teh message (whether it be WM_COMMAND, WM_KEWDOWN, WM_CHAR, etc) isnt bumped off of the message cue propery and messages get sent twice. for instance, if you press "p" to unpaus e the game, it unpauses it and then imediately pauses it again. i tried to combat this by using wm_KEYUP messages instead of WM_COMMAND but it seems to happen regardless. below is the code from my message loop in winmain. // main message loop while (!isDone) { PeekMessage(&msg, G->hWnd, NULL, NULL, PM_REMOVE); if (msg.message == WM_QUIT) isDone = TRUE; else { G->myEngine->SendMessage(PN_RENDER_SCENE, (WPARAM) G->hDC, NULL); TranslateMessage(&msg); DispatchMessage(&msg); } } return msg.wParam; on another note, i decided to try using direct input fo rthe keyboard as well, (using the prima openGL book as reference) and i keep getting stack overflows in the acquire loop. any help would be greatly appreciated. thanx akyro

Share this post

Link to post
Share on other sites

Iv''e got a good idea as to what your problem is, as i had a similar prob in game i wrote quite a while back.

It turns out (At least in my case anyway) that my main loop and code speed was too fast, what was happening was the messages where coming back to my loop so fast that i got 2 in a row before i had chance to take my finger off the key.

My solution, or more to the point how i figured out what the problem was, involved me inserting a delay in my main loop so that i locked the frame rate to a fixed FPS, can''t quite remember how i did it but if you want to email me (shawty_ds@yahoo.com) i''ll see if i can dig the code out of my archives for you.

Also you might want to check your using the correct flags in the peekmessage call, peekmessage by default doesn''t remove the message from the cue unless you tell it to, in contrast to this getmessage does, but it also waits for a message to appear if the cue is empty, this is the reason why we always use peekmessage in our loops as it returns straight away message or not.

Hope this is of some help.

Shawty/Digital Solutions UK

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!