View Single Post
Old 27-03-2011, 11:29 AM   #6
Kanalia
Newbie

 
Join Date: Mar 2011
Location: ,
Posts: 13
Default

Well, I think that going into SDL or any other external library just for this keyboard mapping functionality would be a kind of overkill.

IMHO it isn't possible to distinguish the RETURN (main keyboard) and ENTER (numpad) keys with GetAsyncKeyState(), precisely because both are mapped to the VK_RETURN virtual key. Same thing with other "duplicated" keys (such as +,-,*, etc.) IIRC.

I suggest that you handle the WM_KEYDOWN event message through WinAPI. With this approach you'll get both the virtual key code (stored in wParam), which is the same as what you're getting already through calling GetAsyncKeyState(), and the so called "keydata" (stored in lParam).
The 24th bit of the keydata parameter enables you to distinguish between the two ENTER keys (value 0 for RETURN, 1 for numpad ENTER).

More info: http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx

If you intend to use this approach I think you'd be better of with axing the GetAsyncKeyState() calls and just listen for the WM_KEYDOWN events.

I trust that you already know how to handle Windows messages inside a .NET application

Last edited by Kanalia; 27-03-2011 at 11:33 AM.
Kanalia is offline                         Send a private message to Kanalia
Reply With Quote