Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/cpp/iedriver/ActionSimulators/ActionSimulator.cpp
2868 views
1
// Licensed to the Software Freedom Conservancy (SFC) under one
2
// or more contributor license agreements. See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership. The SFC licenses this file
5
// to you under the Apache License, Version 2.0 (the "License");
6
// you may not use this file except in compliance with the License.
7
// You may obtain a copy of the License at
8
//
9
// http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing, software
12
// distributed under the License is distributed on an "AS IS" BASIS,
13
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
// See the License for the specific language governing permissions and
15
// limitations under the License.
16
17
#include "ActionSimulator.h"
18
19
namespace webdriver {
20
21
ActionSimulator::ActionSimulator() {
22
}
23
24
ActionSimulator::~ActionSimulator() {
25
}
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
}
70
71