Jump to content
  • Advertisement

Archived

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

Link

If i want handle the WM_KEYDOWN for two bottons...?

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

Ok if I push one botton WM_KEYDOWN event it start function(): LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CREATE: return 0; case WM_KEYDOWN: function() ; return 0; so in the function() i switch if it is button ''A'' or Space or ''S'' and so on.... (only one pressed botton) it is so: function(WPARAM wParam) { switch(wParam) { case VK_LEFT: HandleLeftArrow(); break; case VK_RIGHT: HandleRightArrow(); break; case ''Z'': HandleZ(); break; but if i want handle 2 pressed buttons how i can do?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
GetAsyncKeyState();

Share this post


Link to post
Share on other sites
What is GetAsyncKeyState(); ?? How do work it?

Can you give me some good tutorial or istructions abaut DirectInput?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
you are already handling two pressed buttons, aren''t you?

or do you mean to detect key combos?
keep an array keys[256] of all keys.. in WM_KEYDOWN, set corresponding entry to 1, and in WM_KEYUP, set it to 0. in WM_KEYDOWN, if you get a ''C'', check if keys[VK_CONTROL] == 1, if so you got a Ctrl-C.

Not the best way to do it but should work.

Share this post


Link to post
Share on other sites
yes but if i push A and X at the same time how i understand?
i sholud get ''A'' code and ''X'', but how?

Share this post


Link to post
Share on other sites
Well you could just make a variable like this:

keydown[256];

Check the WM_KEYDOWN, and for each case do keydown[key] = TRUE;

After this line do if (keydown[otherkey] = TRUE) do_stuff;

You get me? It''s pretty basic but it works. And about your questions about what is GetAsyncKeyState() and where to find good DirectInput tutorials, for info on certain functions or whatever browse to msdn.microsoft.com and search for the function with the search option. Succes guaranteed. For DirectInput tutorials, have a look at the DirectX SDK help files... As simple as that...

Share this post


Link to post
Share on other sites
The simplest way is to use lots of if statments rather than a case statment -

if (key1)
{}

if(key2)
{}

will ctach both whereas a case statment would only do one of them (the first one it came across)

Share this post


Link to post
Share on other sites
it should be:

if (key1) && (key2)
{
// If it is push key1 and in the same tile key2 so do this
}


Is it correct?

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.

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!