Path: blob/trunk/cpp/iedriver/ActionSimulators/ActionSimulator.cpp
2868 views
// Licensed to the Software Freedom Conservancy (SFC) under one1// or more contributor license agreements. See the NOTICE file2// distributed with this work for additional information3// regarding copyright ownership. The SFC licenses this file4// to you under the Apache License, Version 2.0 (the "License");5// you may not use this file except in compliance with the License.6// You may obtain a copy of the License at7//8// http://www.apache.org/licenses/LICENSE-2.09//10// Unless required by applicable law or agreed to in writing, software11// distributed under the License is distributed on an "AS IS" BASIS,12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13// See the License for the specific language governing permissions and14// limitations under the License.1516#include "ActionSimulator.h"1718namespace webdriver {1920ActionSimulator::ActionSimulator() {21}2223ActionSimulator::~ActionSimulator() {24}252627void ActionSimulator::UpdateInputState(INPUT current_input,28InputState* input_state) {29if (current_input.type == INPUT_MOUSE) {30if (current_input.mi.dwFlags & MOUSEEVENTF_MOVE) {31input_state->mouse_x = current_input.mi.dx;32input_state->mouse_y = current_input.mi.dy;33} else if (current_input.mi.dwFlags & MOUSEEVENTF_LEFTDOWN) {34input_state->is_left_button_pressed = true;35} else if (current_input.mi.dwFlags & MOUSEEVENTF_LEFTUP) {36if (input_state->is_left_button_pressed &&37input_state->mouse_x == current_input.mi.dx &&38input_state->mouse_y == current_input.mi.dy) {39input_state->last_click_time = clock();40}41input_state->is_left_button_pressed = false;42} else if (current_input.mi.dwFlags & MOUSEEVENTF_RIGHTDOWN) {43input_state->is_right_button_pressed = true;44} else if (current_input.mi.dwFlags & MOUSEEVENTF_RIGHTUP) {45input_state->is_right_button_pressed = false;46}47} else if (current_input.type == INPUT_KEYBOARD) {48if (current_input.ki.dwFlags & KEYEVENTF_KEYUP) {49if (current_input.ki.wVk == VK_SHIFT) {50input_state->is_shift_pressed = false;51} else if (current_input.ki.wVk == VK_CONTROL) {52input_state->is_control_pressed = false;53} else if (current_input.ki.wVk == VK_MENU) {54input_state->is_alt_pressed = false;55}56} else {57if (current_input.ki.wVk == VK_SHIFT) {58input_state->is_shift_pressed = true;59} else if (current_input.ki.wVk == VK_CONTROL) {60input_state->is_control_pressed = true;61} else if (current_input.ki.wVk == VK_MENU) {62input_state->is_alt_pressed = true;63}64}65}66}6768}697071