it is for processing input messages
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; |
here we check isDown != wasDown. But probem what wasDown is doesn't work. it is always 0. Then I get assert message here:
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; } |
Maybe I misunderstand lParam bits or something else.
Other code
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; } |
Thanks for any help!!!!