blob: 8d95f6589683e145a3d528515b6024a7d5ad6f87 [file] [log] [blame]
Harry Cuttsb57f1702022-11-28 15:34:22 +00001/*
2 * Copyright 2022 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.0
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#pragma once
18
19#include <PointerControllerInterface.h>
Harry Cuttsb57f1702022-11-28 15:34:22 +000020#include <input/DisplayViewport.h>
21#include <input/Input.h>
22#include <utils/BitSet.h>
Arpit Singh4b6ad2d2024-04-04 11:54:20 +000023#include <unordered_set>
Harry Cuttsb57f1702022-11-28 15:34:22 +000024
25namespace android {
26
Byoungho Jung99326452023-11-03 20:19:17 +090027struct SpriteIcon {
28 PointerIconStyle style;
29};
30
Harry Cuttsb57f1702022-11-28 15:34:22 +000031class FakePointerController : public PointerControllerInterface {
32public:
Harry Cutts3beea7d2024-02-21 15:52:35 +000033 FakePointerController() : FakePointerController(/*enabled=*/true) {}
34 FakePointerController(bool enabled) : mEnabled(enabled) {}
35
Harry Cuttsb57f1702022-11-28 15:34:22 +000036 virtual ~FakePointerController() {}
37
38 void setBounds(float minX, float minY, float maxX, float maxY);
Harry Cutts7ecbb992023-12-18 14:45:09 +000039 void clearBounds();
Linnan Li13bf76a2024-05-05 19:18:02 +080040 const std::map<ui::LogicalDisplayId, std::vector<int32_t>>& getSpots();
Harry Cuttsb57f1702022-11-28 15:34:22 +000041
42 void setPosition(float x, float y) override;
Prabir Pradhan2719e822023-02-28 17:39:36 +000043 FloatPoint getPosition() const override;
Linnan Li13bf76a2024-05-05 19:18:02 +080044 ui::LogicalDisplayId getDisplayId() const override;
Harry Cuttsb57f1702022-11-28 15:34:22 +000045 void setDisplayViewport(const DisplayViewport& viewport) override;
Byoungho Jung99326452023-11-03 20:19:17 +090046 void updatePointerIcon(PointerIconStyle iconId) override;
47 void setCustomPointerIcon(const SpriteIcon& icon) override;
Arpit Singh420d0742024-04-04 11:54:20 +000048 void setSkipScreenshotFlagForDisplay(ui::LogicalDisplayId displayId) override;
49 void clearSkipScreenshotFlags() override;
Prabir Pradhan6506f6f2023-12-11 20:48:39 +000050 void fade(Transition) override;
Harry Cuttsb57f1702022-11-28 15:34:22 +000051
Linnan Li13bf76a2024-05-05 19:18:02 +080052 void assertViewportSet(ui::LogicalDisplayId displayId);
Byoungho Jungee6268f2023-10-30 17:27:26 +090053 void assertViewportNotSet();
Harry Cuttsce86cc32022-12-14 20:36:33 +000054 void assertPosition(float x, float y);
Linnan Li13bf76a2024-05-05 19:18:02 +080055 void assertSpotCount(ui::LogicalDisplayId displayId, int32_t count);
Byoungho Jung99326452023-11-03 20:19:17 +090056 void assertPointerIconSet(PointerIconStyle iconId);
57 void assertPointerIconNotSet();
58 void assertCustomPointerIconSet(PointerIconStyle iconId);
59 void assertCustomPointerIconNotSet();
Linnan Li13bf76a2024-05-05 19:18:02 +080060 void assertIsHiddenOnMirroredDisplays(ui::LogicalDisplayId displayId, bool isHidden);
Seunghwan Choi356026c2023-02-01 14:37:25 +090061 bool isPointerShown();
Harry Cuttsce86cc32022-12-14 20:36:33 +000062
Harry Cuttsb57f1702022-11-28 15:34:22 +000063private:
Byoungho Jungda10dd32023-10-06 17:03:45 +090064 std::string dump() override { return ""; }
Prabir Pradhan2719e822023-02-28 17:39:36 +000065 std::optional<FloatRect> getBounds() const override;
Harry Cuttsb57f1702022-11-28 15:34:22 +000066 void move(float deltaX, float deltaY) override;
Seunghwan Choi356026c2023-02-01 14:37:25 +090067 void unfade(Transition) override;
Harry Cuttsb57f1702022-11-28 15:34:22 +000068 void setPresentation(Presentation) override {}
69 void setSpots(const PointerCoords*, const uint32_t*, BitSet32 spotIdBits,
Linnan Li13bf76a2024-05-05 19:18:02 +080070 ui::LogicalDisplayId displayId) override;
Harry Cuttsb57f1702022-11-28 15:34:22 +000071 void clearSpots() override;
72
Harry Cutts3beea7d2024-02-21 15:52:35 +000073 const bool mEnabled;
Harry Cuttsb57f1702022-11-28 15:34:22 +000074 bool mHaveBounds{false};
75 float mMinX{0}, mMinY{0}, mMaxX{0}, mMaxY{0};
76 float mX{0}, mY{0};
Linnan Li13bf76a2024-05-05 19:18:02 +080077 std::optional<ui::LogicalDisplayId> mDisplayId;
Seunghwan Choi356026c2023-02-01 14:37:25 +090078 bool mIsPointerShown{false};
Byoungho Jung99326452023-11-03 20:19:17 +090079 std::optional<PointerIconStyle> mIconStyle;
80 std::optional<PointerIconStyle> mCustomIconStyle;
Harry Cuttsb57f1702022-11-28 15:34:22 +000081
Linnan Li13bf76a2024-05-05 19:18:02 +080082 std::map<ui::LogicalDisplayId, std::vector<int32_t>> mSpotsByDisplay;
83 std::unordered_set<ui::LogicalDisplayId> mDisplaysToSkipScreenshot;
Harry Cuttsb57f1702022-11-28 15:34:22 +000084};
85
86} // namespace android