Jump to content
  • Advertisement
Sign in to follow this  
JasonBaldwin

Getting input without using a wndproc

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

Is there a way on windows to get keyboard input without using a wndproc? Basically im creating a UI library and want my UI library to do its own input so the user doesnt have to give the library input. Thanks

Share this post


Link to post
Share on other sites
Advertisement
You can use GetAsyncKeyState(), but it's pretty horrible and won't handle e.g. upper and lower case translation.

Getting the application to pass in input seems reasonable to me?

Share this post


Link to post
Share on other sites
You can use some of the functions listed here, but without using a wndproc function, you won't know the order at which the keys were pressed (I think).

Share this post


Link to post
Share on other sites
Thanks a lot for the ideas. I looked at all those functions and don't really like them. I've decided to listen to Evil Steve and let the user pass on input

Share this post


Link to post
Share on other sites
Quote:
Original post by JasonBaldwin
Is there a way on windows to get keyboard input without using a wndproc? Basically im creating a UI library and want my UI library to do its own input so the user doesnt have to give the library input.

Thanks


In order to open a window on win32 platform, you need a winproc. So you don't earn a lot if you start reading input with lower level functions. You will just repeat the work that win32 already is doing for you. Instead of redoing the work of reading input, which is quite ugly to do, just "abstract" winproc away. For ex. get input in WM_INPUT as raw input, and then pass it to your own input routine, which is the only one that UI will ever see. That way (by just passing raw input to your own code), WinProc is hidden in your "platform" code and is never seen or known by any user code. That is the way I have seen it mplemented in many GUI or game windowing libraries. If you don't want to redo the work of formatting the input (checking if the user holds for example shift while he is pressing 'a' to get an 'A' and similar) you might rather register for some other messages then wm_input and then pass the input from those to your input routine.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!