1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | case WM_SYSKEYDOWN:
case WM_KEYDOWN:
case WM_KEYUP:
{
bool isDown = (message.lParam & (1 << 31)) == 0;
bool wasDown = (message.lParam & (1 << 30)) != 0;
switch(message.wParam)
{
if(isDown != wasDown)
{
case 'W':
{
win32KeyboardProccessing(&keyboardController->buttonUp, isDown);
OutputDebugStringA("W\n");
}break;
case 'A':
{
win32KeyboardProccessing(&keyboardController->buttonLeft, isDown);
OutputDebugStringA("A\n");
}break;
case 'S':
{
win32KeyboardProccessing(&keyboardController->buttonDown, isDown);
OutputDebugStringA("S\n");
}break;
case 'D':
{
win32KeyboardProccessing(&keyboardController->buttonRight, isDown);
OutputDebugStringA("D\n");
}break;
|
1 2 3 4 5 6 7 | internal void win32KeyboardProccessing(game_button_state *newState, bool isDown)
{
assert(newState->endedDown != isDown);
newState->endedDown = isDown;
++newState->halfTransitionCount;
}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | game_input input[2] = {};
game_input *newInput = &input[0];
game_input *oldInput = &input[1];
while(gameIsRunning)
{
game_controller_input *oldKeyboardController = &oldInput->controllers[0];
game_controller_input *newKeyboardController = &newInput->controllers[0];
game_controller_input zeroController = {};
*newKeyboardController = zeroController;
for(s32 buttonIndex = 0; buttonIndex < 5; buttonIndex++)
{
newKeyboardController->buttons[buttonIndex].endedDown = oldKeyboardController->buttons[buttonIndex].endedDown;
}
win32KeyboardMessageProccessing(&winState,newKeyboardController);
game_input *temp = newInput;
newInput = oldInput;
oldInput = temp;
}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | b32 test = false; u32 a = 1; switch ( a ) { if ( test ) { case 1: { __debugbreak( ); } break; case 2: { __debugbreak( ); } break; } else { __debugbreak( ); } } |
1 2 3 | error C2220: warning treated as error - no 'object' file generated warning C4702: unreachable code warning C4702: unreachable code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | b32 test = false; u32 a = 1; if ( test ) { switch ( a ) { case 1: { __debugbreak( ); } break; case 2: { __debugbreak( ); } break; } } else { __debugbreak( ); } |