Jump to content
  • Advertisement
Sign in to follow this  
tom_mai78101

Using a simple scan for inputs: Mixing GetAsyncKeyState() and msg,wParam

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

Here's the code:

[source lang="cpp"]
//Straight up and integrated into System.console main()...

#include <window.h>

//...

void KeyStateLoop(int vk_Code)
{
switch(vk_Code)
{
case VK_ESCAPE:
PostMessage(global_hWnd, WM_DESTROY, 0, 0);
break;
}
return;
}


//And here's where it goes in

while (msg.message != WM_QUIT)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
Core::KeyStateLoop(GetAsyncKeyState(msg.wParam));
}

[/source]

All the rest of the codes are RegisterClassEx(), int WinMain(), WindowProc() with WM_DESTROY, WM_QUIT, etc., and normal stuffs. The codes I posted are the only differences from a simple Win32 program of "Hello World!".

How do you scan all of the key presses correctly, then pick out VK_ESCAPE key, so that I can exit out of my program? Would like a tip or two. Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
#1: GetAsyncKeyState() doesn't return a Virtual Key code: GetAsyncKeyState
#2: msg.wParam isn't what you'd expect, it can mean different things depending on the message.

Share this post


Link to post
Share on other sites

#1: GetAsyncKeyState() doesn't return a Virtual Key code: GetAsyncKeyState
#2: msg.wParam isn't what you'd expect, it can mean different things depending on the message.



Then what is the better solution? I'm all ears.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!