I think there might be something I don't understand in the logic of the windows message flags we use in IsDown / WasDown, and since it came up on last night's stream (and I guess we will continue using it on tonight's) I am trying to see if somebody will clear it out for me.
What is the logic by which the previous key-state flag and the transition-state flag seem to be inversed? As a reminder, these are the 30th and 31st bits on the lParam in the WM_KEYDOWN, WM_SYSKEYDOWN, WM_KEYUP and WM_SYSKEYUP messages. The 30th bit flags the "previous key state" as in was it down before the message was sent or not. The 31st bit is the "transition-state flag" , which we are pretty much using as a "is the button down or not" flag.
However, the bit values seem reversed: on the previous state bit a 1 means the key was DOWN, 0 if the key was UP. On the transition 1 means the key is UP and 0 DOWN. My guess is the we are simplifying the meaning of the 31st bit flag, but in the MSDN documentation all I found is that it flags "whether pressing a key or releasing a key generated the keystroke message" ... which didn't really clear it for me. This discrepancy creates these weird (to me) looking bool assignments:
| bool32 WasDown = ((Message.lParam & (1 << 30)) != 0);
bool32 IsDown = ((Message.lParam & (1 << 31)) == 0);
|
Can anybody enlighten me or am I forever doomed be bothered by this strange looking "isEqual/isNotEqual even though we are both checking if a key is down" thing?