Sign in to follow this  
JasonBaldwin

Getting input without using a wndproc

Recommended Posts

JasonBaldwin    126
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
Evil Steve    2017
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
Gage64    1235
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
joe_bubamara    100
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this