1 /*
2 * Copyright (C) 2023 The Android Open Source Project
3 *
4 * Licensed 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 at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0f
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * 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 and
14 * limitations under the License.
15 */
16
17 #include "host/libs/confui/host_virtual_input.h"
18
19 #include <android-base/logging.h>
20
21 namespace cuttlefish {
22 namespace confui {
23
HostVirtualInput(HostServer & host_server,HostModeCtrl & host_mode_ctrl)24 HostVirtualInput::HostVirtualInput(HostServer& host_server,
25 HostModeCtrl& host_mode_ctrl)
26 : host_server_(host_server), host_mode_ctrl_(host_mode_ctrl) {}
27
TouchEvent(const int x,const int y,const bool is_down)28 void HostVirtualInput::TouchEvent(const int x, const int y,
29 const bool is_down) {
30 std::string mode("Android Mode");
31 if (IsConfUiActive()) {
32 mode = std::string("Confirmation UI Mode");
33 }
34 if (is_down) {
35 ConfUiLog(INFO) << "TouchEvent occurs in " << mode << " at [" << x << ", "
36 << y << "]";
37 }
38 host_server_.TouchEvent(x, y, is_down);
39 }
40
UserAbortEvent()41 void HostVirtualInput::UserAbortEvent() { host_server_.UserAbortEvent(); }
42
IsConfUiActive()43 bool HostVirtualInput::IsConfUiActive() {
44 return host_mode_ctrl_.IsConfirmatioUiMode();
45 }
46
47 } // namespace confui
48 } // namespace cuttlefish
49