I've got a few questions about windows keyboard messages.
What I want to do is use the keys WASD to scroll.
W for up, D for right, S for down, A for left.
I also want to be able to press up/down and left/right keys at the sametime for diagonal scrolling.
I thought this could be implemented roughly like this:
case IS_D: // d is pressed
while(KEY_D_STILL_DOWN()) // d is still down
x += 4; // move 4 pixels right
if(KEY_W_DOWN()) // w is down as well
y -= 4; // move 4 pixels up
else if(KEY_S_DOWN()) // or s is down as well
y += 4; // move 4 pixels down
// the routine I call in WM_PAINT, uses x and y to paint the correct region
I could of course call TranslateMessage() instead and handle WM_CHAR, but I don't like that since by the time I handle the WM_CHAR message, KEY_D_STILL_DOWN() might return true and nothing will happen. I'm open to suggestions though.
The part I don't know how to do is KEY_D_STILL_DOWN() and KEY_W_DOWN(). I also have no idea how to test IS_D, since the WM_KEYDOWN message returns a virtual keycode.
How could I do this?