| 26 | |
| 27 | |
| 28 | void ActionSimulator::UpdateInputState(INPUT current_input, |
| 29 | InputState* input_state) { |
| 30 | if (current_input.type == INPUT_MOUSE) { |
| 31 | if (current_input.mi.dwFlags & MOUSEEVENTF_MOVE) { |
| 32 | input_state->mouse_x = current_input.mi.dx; |
| 33 | input_state->mouse_y = current_input.mi.dy; |
| 34 | } else if (current_input.mi.dwFlags & MOUSEEVENTF_LEFTDOWN) { |
| 35 | input_state->is_left_button_pressed = true; |
| 36 | } else if (current_input.mi.dwFlags & MOUSEEVENTF_LEFTUP) { |
| 37 | if (input_state->is_left_button_pressed && |
| 38 | input_state->mouse_x == current_input.mi.dx && |
| 39 | input_state->mouse_y == current_input.mi.dy) { |
| 40 | input_state->last_click_time = clock(); |
| 41 | } |
| 42 | input_state->is_left_button_pressed = false; |
| 43 | } else if (current_input.mi.dwFlags & MOUSEEVENTF_RIGHTDOWN) { |
| 44 | input_state->is_right_button_pressed = true; |
| 45 | } else if (current_input.mi.dwFlags & MOUSEEVENTF_RIGHTUP) { |
| 46 | input_state->is_right_button_pressed = false; |
| 47 | } |
| 48 | } else if (current_input.type == INPUT_KEYBOARD) { |
| 49 | if (current_input.ki.dwFlags & KEYEVENTF_KEYUP) { |
| 50 | if (current_input.ki.wVk == VK_SHIFT) { |
| 51 | input_state->is_shift_pressed = false; |
| 52 | } else if (current_input.ki.wVk == VK_CONTROL) { |
| 53 | input_state->is_control_pressed = false; |
| 54 | } else if (current_input.ki.wVk == VK_MENU) { |
| 55 | input_state->is_alt_pressed = false; |
| 56 | } |
| 57 | } else { |
| 58 | if (current_input.ki.wVk == VK_SHIFT) { |
| 59 | input_state->is_shift_pressed = true; |
| 60 | } else if (current_input.ki.wVk == VK_CONTROL) { |
| 61 | input_state->is_control_pressed = true; |
| 62 | } else if (current_input.ki.wVk == VK_MENU) { |
| 63 | input_state->is_alt_pressed = true; |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | } |
no outgoing calls
no test coverage detected