blob: 061ae62b57f35e355ada72baefa0fd9627335a29 [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>
20#include <gui/constants.h>
21#include <input/DisplayViewport.h>
22#include <input/Input.h>
23#include <utils/BitSet.h>
24
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:
33 virtual ~FakePointerController() {}
34
35 void setBounds(float minX, float minY, float maxX, float maxY);
Harry Cutts7ecbb992023-12-18 14:45:09 +000036 void clearBounds();
Harry Cuttsb57f1702022-11-28 15:34:22 +000037 const std::map<int32_t, std::vector<int32_t>>& getSpots();
38
39 void setPosition(float x, float y) override;
Prabir Pradhan2719e822023-02-28 17:39:36 +000040 FloatPoint getPosition() const override;
Harry Cuttsb57f1702022-11-28 15:34:22 +000041 int32_t getDisplayId() const override;
42 void setDisplayViewport(const DisplayViewport& viewport) override;
Byoungho Jung99326452023-11-03 20:19:17 +090043 void updatePointerIcon(PointerIconStyle iconId) override;
44 void setCustomPointerIcon(const SpriteIcon& icon) override;
Prabir Pradhan6506f6f2023-12-11 20:48:39 +000045 void fade(Transition) override;
Harry Cuttsb57f1702022-11-28 15:34:22 +000046
Byoungho Jungee6268f2023-10-30 17:27:26 +090047 void assertViewportSet(int32_t displayId);
48 void assertViewportNotSet();
Harry Cuttsce86cc32022-12-14 20:36:33 +000049 void assertPosition(float x, float y);
Prabir Pradhan16788792023-11-08 21:07:21 +000050 void assertSpotCount(int32_t displayId, int32_t count);
Byoungho Jung99326452023-11-03 20:19:17 +090051 void assertPointerIconSet(PointerIconStyle iconId);
52 void assertPointerIconNotSet();
53 void assertCustomPointerIconSet(PointerIconStyle iconId);
54 void assertCustomPointerIconNotSet();
Seunghwan Choi356026c2023-02-01 14:37:25 +090055 bool isPointerShown();
Harry Cuttsce86cc32022-12-14 20:36:33 +000056
Harry Cuttsb57f1702022-11-28 15:34:22 +000057private:
Byoungho Jungda10dd32023-10-06 17:03:45 +090058 std::string dump() override { return ""; }
Prabir Pradhan2719e822023-02-28 17:39:36 +000059 std::optional<FloatRect> getBounds() const override;
Harry Cuttsb57f1702022-11-28 15:34:22 +000060 void move(float deltaX, float deltaY) override;
Seunghwan Choi356026c2023-02-01 14:37:25 +090061 void unfade(Transition) override;
Harry Cuttsb57f1702022-11-28 15:34:22 +000062 void setPresentation(Presentation) override {}
63 void setSpots(const PointerCoords*, const uint32_t*, BitSet32 spotIdBits,
64 int32_t displayId) override;
65 void clearSpots() override;
66
67 bool mHaveBounds{false};
68 float mMinX{0}, mMinY{0}, mMaxX{0}, mMaxY{0};
69 float mX{0}, mY{0};
Byoungho Jungee6268f2023-10-30 17:27:26 +090070 std::optional<int32_t> mDisplayId;
Seunghwan Choi356026c2023-02-01 14:37:25 +090071 bool mIsPointerShown{false};
Byoungho Jung99326452023-11-03 20:19:17 +090072 std::optional<PointerIconStyle> mIconStyle;
73 std::optional<PointerIconStyle> mCustomIconStyle;
Harry Cuttsb57f1702022-11-28 15:34:22 +000074
75 std::map<int32_t, std::vector<int32_t>> mSpotsByDisplay;
76};
77
78} // namespace android