Handling keyboard/mouse input

Started by
27 comments, last by Sneftel 13 years, 5 months ago
Tell me this, press and hold W, then press and hold A, then release W. What happens, do you get W up?
Advertisement
It will be able to detect that W was released, here is my log

Kbd: DOWN VK=0057 // Press and hold W
Kbd: DOWN VK=0057
Kbd: DOWN VK=0057
Kbd: DOWN VK=0057
Kbd: DOWN VK=0041 // Press A and hold A, while still holding W
Kbd: DOWN VK=0041
Kbd: DOWN VK=0041
Kbd: UP VK=0057 // Release W, while still holding A
Kbd: DOWN VK=0041
Kbd: DOWN VK=0041
Kbd: UP VK=0041 // Release A
Now store the state of that key, you know when it goes down, and you can assume its still down because you havent received an up message. Once youve stored it, it can be passed around to any place that needs to know if a keys down or up. This also allow for key combos to be checked for, because you have the state of all keys up to date at all times. Or you can use event handlers of some kind, and have the listeners, notifiers, observers, w/e, execute directly when down and up messages are received.

I could basically do the same thin with WM_KEYDOWN and WM_KEYUP, I don't see how using WM_INPUT adds an advantage ... how does it?
You could use WM_KEYDOWN, the main advantage of raw input is in mouse movement.
Is there a good way to tell buffered input?

What I am going to is have an array where a value gets set when a button is pressed, and another array that is for buffered input that will also get sets when the button is pressed. Then after the next time slice, it will clear the second array. So when I went to check to see if it is buffered input, I would check the value in both arrays, if it is not set in the second, then I could tell that it is not the first time the value is checked.
Quote:Original post by Hurp
I could basically do the same thin with WM_KEYDOWN and WM_KEYUP, I don't see how using WM_INPUT adds an advantage ... how does it?
It doesn't. WM_INPUT is used for raw input. For keyboard input, the only real advantage of raw input over, um, cooked input is that you can get notification of buffer overruns, but you don't want that.
Well I just got a system in place for handling keyboard input/keyboard buffered input, thank you Sneftel, NumberXaero and everyone else.

On the subject on WM_INPUT, is that still the recommended way to handle mouse input (such as cursor movement, scrolling and button pressing)?
Quote:Original post by Hurp
On the subject on WM_INPUT, is that still the recommended way to handle mouse input (such as cursor movement, scrolling and button pressing)?
Only if you need the features offered by raw input (sub-pixel accuracy), and don't care about the features not offered by raw input (cursor acceleration).

This topic is closed to new replies.

Advertisement