Harry Cutts | b57f170 | 2022-11-28 15:34:22 +0000 | [diff] [blame] | 1 | /* |
| 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 Cutts | b57f170 | 2022-11-28 15:34:22 +0000 | [diff] [blame] | 20 | #include <input/DisplayViewport.h> |
| 21 | #include <input/Input.h> |
| 22 | #include <utils/BitSet.h> |
Arpit Singh | 4b6ad2d | 2024-04-04 11:54:20 +0000 | [diff] [blame] | 23 | #include <unordered_set> |
Harry Cutts | b57f170 | 2022-11-28 15:34:22 +0000 | [diff] [blame] | 24 | |
| 25 | namespace android { |
| 26 | |
Byoungho Jung | 9932645 | 2023-11-03 20:19:17 +0900 | [diff] [blame] | 27 | struct SpriteIcon { |
| 28 | PointerIconStyle style; |
| 29 | }; |
| 30 | |
Harry Cutts | b57f170 | 2022-11-28 15:34:22 +0000 | [diff] [blame] | 31 | class FakePointerController : public PointerControllerInterface { |
| 32 | public: |
Harry Cutts | 3beea7d | 2024-02-21 15:52:35 +0000 | [diff] [blame] | 33 | FakePointerController() : FakePointerController(/*enabled=*/true) {} |
| 34 | FakePointerController(bool enabled) : mEnabled(enabled) {} |
| 35 | |
Harry Cutts | b57f170 | 2022-11-28 15:34:22 +0000 | [diff] [blame] | 36 | virtual ~FakePointerController() {} |
| 37 | |
| 38 | void setBounds(float minX, float minY, float maxX, float maxY); |
Harry Cutts | 7ecbb99 | 2023-12-18 14:45:09 +0000 | [diff] [blame] | 39 | void clearBounds(); |
Linnan Li | 13bf76a | 2024-05-05 19:18:02 +0800 | [diff] [blame] | 40 | const std::map<ui::LogicalDisplayId, std::vector<int32_t>>& getSpots(); |
Harry Cutts | b57f170 | 2022-11-28 15:34:22 +0000 | [diff] [blame] | 41 | |
| 42 | void setPosition(float x, float y) override; |
Prabir Pradhan | 2719e82 | 2023-02-28 17:39:36 +0000 | [diff] [blame] | 43 | FloatPoint getPosition() const override; |
Linnan Li | 13bf76a | 2024-05-05 19:18:02 +0800 | [diff] [blame] | 44 | ui::LogicalDisplayId getDisplayId() const override; |
Harry Cutts | b57f170 | 2022-11-28 15:34:22 +0000 | [diff] [blame] | 45 | void setDisplayViewport(const DisplayViewport& viewport) override; |
Byoungho Jung | 9932645 | 2023-11-03 20:19:17 +0900 | [diff] [blame] | 46 | void updatePointerIcon(PointerIconStyle iconId) override; |
| 47 | void setCustomPointerIcon(const SpriteIcon& icon) override; |
Arpit Singh | 420d074 | 2024-04-04 11:54:20 +0000 | [diff] [blame^] | 48 | void setSkipScreenshotFlagForDisplay(ui::LogicalDisplayId displayId) override; |
| 49 | void clearSkipScreenshotFlags() override; |
Prabir Pradhan | 6506f6f | 2023-12-11 20:48:39 +0000 | [diff] [blame] | 50 | void fade(Transition) override; |
Harry Cutts | b57f170 | 2022-11-28 15:34:22 +0000 | [diff] [blame] | 51 | |
Linnan Li | 13bf76a | 2024-05-05 19:18:02 +0800 | [diff] [blame] | 52 | void assertViewportSet(ui::LogicalDisplayId displayId); |
Byoungho Jung | ee6268f | 2023-10-30 17:27:26 +0900 | [diff] [blame] | 53 | void assertViewportNotSet(); |
Harry Cutts | ce86cc3 | 2022-12-14 20:36:33 +0000 | [diff] [blame] | 54 | void assertPosition(float x, float y); |
Linnan Li | 13bf76a | 2024-05-05 19:18:02 +0800 | [diff] [blame] | 55 | void assertSpotCount(ui::LogicalDisplayId displayId, int32_t count); |
Byoungho Jung | 9932645 | 2023-11-03 20:19:17 +0900 | [diff] [blame] | 56 | void assertPointerIconSet(PointerIconStyle iconId); |
| 57 | void assertPointerIconNotSet(); |
| 58 | void assertCustomPointerIconSet(PointerIconStyle iconId); |
| 59 | void assertCustomPointerIconNotSet(); |
Linnan Li | 13bf76a | 2024-05-05 19:18:02 +0800 | [diff] [blame] | 60 | void assertIsHiddenOnMirroredDisplays(ui::LogicalDisplayId displayId, bool isHidden); |
Seunghwan Choi | 356026c | 2023-02-01 14:37:25 +0900 | [diff] [blame] | 61 | bool isPointerShown(); |
Harry Cutts | ce86cc3 | 2022-12-14 20:36:33 +0000 | [diff] [blame] | 62 | |
Harry Cutts | b57f170 | 2022-11-28 15:34:22 +0000 | [diff] [blame] | 63 | private: |
Byoungho Jung | da10dd3 | 2023-10-06 17:03:45 +0900 | [diff] [blame] | 64 | std::string dump() override { return ""; } |
Prabir Pradhan | 2719e82 | 2023-02-28 17:39:36 +0000 | [diff] [blame] | 65 | std::optional<FloatRect> getBounds() const override; |
Harry Cutts | b57f170 | 2022-11-28 15:34:22 +0000 | [diff] [blame] | 66 | void move(float deltaX, float deltaY) override; |
Seunghwan Choi | 356026c | 2023-02-01 14:37:25 +0900 | [diff] [blame] | 67 | void unfade(Transition) override; |
Harry Cutts | b57f170 | 2022-11-28 15:34:22 +0000 | [diff] [blame] | 68 | void setPresentation(Presentation) override {} |
| 69 | void setSpots(const PointerCoords*, const uint32_t*, BitSet32 spotIdBits, |
Linnan Li | 13bf76a | 2024-05-05 19:18:02 +0800 | [diff] [blame] | 70 | ui::LogicalDisplayId displayId) override; |
Harry Cutts | b57f170 | 2022-11-28 15:34:22 +0000 | [diff] [blame] | 71 | void clearSpots() override; |
| 72 | |
Harry Cutts | 3beea7d | 2024-02-21 15:52:35 +0000 | [diff] [blame] | 73 | const bool mEnabled; |
Harry Cutts | b57f170 | 2022-11-28 15:34:22 +0000 | [diff] [blame] | 74 | bool mHaveBounds{false}; |
| 75 | float mMinX{0}, mMinY{0}, mMaxX{0}, mMaxY{0}; |
| 76 | float mX{0}, mY{0}; |
Linnan Li | 13bf76a | 2024-05-05 19:18:02 +0800 | [diff] [blame] | 77 | std::optional<ui::LogicalDisplayId> mDisplayId; |
Seunghwan Choi | 356026c | 2023-02-01 14:37:25 +0900 | [diff] [blame] | 78 | bool mIsPointerShown{false}; |
Byoungho Jung | 9932645 | 2023-11-03 20:19:17 +0900 | [diff] [blame] | 79 | std::optional<PointerIconStyle> mIconStyle; |
| 80 | std::optional<PointerIconStyle> mCustomIconStyle; |
Harry Cutts | b57f170 | 2022-11-28 15:34:22 +0000 | [diff] [blame] | 81 | |
Linnan Li | 13bf76a | 2024-05-05 19:18:02 +0800 | [diff] [blame] | 82 | std::map<ui::LogicalDisplayId, std::vector<int32_t>> mSpotsByDisplay; |
| 83 | std::unordered_set<ui::LogicalDisplayId> mDisplaysToSkipScreenshot; |
Harry Cutts | b57f170 | 2022-11-28 15:34:22 +0000 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | } // namespace android |