| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2014 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 | #ifndef _INPUTFLINGER_POINTER_CONTROLLER_INTERFACE_H | 
|  | 18 | #define _INPUTFLINGER_POINTER_CONTROLLER_INTERFACE_H | 
|  | 19 |  | 
| Garfield Tan | 888a6a4 | 2020-01-09 11:39:16 -0800 | [diff] [blame] | 20 | #include <input/DisplayViewport.h> | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 21 | #include <input/Input.h> | 
|  | 22 | #include <utils/BitSet.h> | 
|  | 23 | #include <utils/RefBase.h> | 
|  | 24 |  | 
|  | 25 | namespace android { | 
|  | 26 |  | 
|  | 27 | /** | 
|  | 28 | * Interface for tracking a mouse / touch pad pointer and touch pad spots. | 
|  | 29 | * | 
|  | 30 | * The spots are sprites on screen that visually represent the positions of | 
|  | 31 | * fingers | 
|  | 32 | * | 
|  | 33 | * The pointer controller is responsible for providing synchronization and for tracking | 
|  | 34 | * display orientation changes if needed. | 
|  | 35 | */ | 
| Michael Wright | 17db18e | 2020-06-26 20:51:44 +0100 | [diff] [blame] | 36 | class PointerControllerInterface { | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 37 | protected: | 
|  | 38 | PointerControllerInterface() { } | 
|  | 39 | virtual ~PointerControllerInterface() { } | 
|  | 40 |  | 
|  | 41 | public: | 
|  | 42 | /* Gets the bounds of the region that the pointer can traverse. | 
|  | 43 | * Returns true if the bounds are available. */ | 
|  | 44 | virtual bool getBounds(float* outMinX, float* outMinY, | 
|  | 45 | float* outMaxX, float* outMaxY) const = 0; | 
|  | 46 |  | 
|  | 47 | /* Move the pointer. */ | 
|  | 48 | virtual void move(float deltaX, float deltaY) = 0; | 
|  | 49 |  | 
|  | 50 | /* Sets a mask that indicates which buttons are pressed. */ | 
|  | 51 | virtual void setButtonState(int32_t buttonState) = 0; | 
|  | 52 |  | 
|  | 53 | /* Gets a mask that indicates which buttons are pressed. */ | 
|  | 54 | virtual int32_t getButtonState() const = 0; | 
|  | 55 |  | 
|  | 56 | /* Sets the absolute location of the pointer. */ | 
|  | 57 | virtual void setPosition(float x, float y) = 0; | 
|  | 58 |  | 
|  | 59 | /* Gets the absolute location of the pointer. */ | 
|  | 60 | virtual void getPosition(float* outX, float* outY) const = 0; | 
|  | 61 |  | 
| Michael Wright | ca5bede | 2020-07-02 00:00:29 +0100 | [diff] [blame] | 62 | enum class Transition { | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 63 | // Fade/unfade immediately. | 
| Michael Wright | ca5bede | 2020-07-02 00:00:29 +0100 | [diff] [blame] | 64 | IMMEDIATE, | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 65 | // Fade/unfade gradually. | 
| Michael Wright | ca5bede | 2020-07-02 00:00:29 +0100 | [diff] [blame] | 66 | GRADUAL, | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 67 | }; | 
|  | 68 |  | 
|  | 69 | /* Fades the pointer out now. */ | 
|  | 70 | virtual void fade(Transition transition) = 0; | 
|  | 71 |  | 
|  | 72 | /* Makes the pointer visible if it has faded out. | 
|  | 73 | * The pointer never unfades itself automatically.  This method must be called | 
|  | 74 | * by the client whenever the pointer is moved or a button is pressed and it | 
|  | 75 | * wants to ensure that the pointer becomes visible again. */ | 
|  | 76 | virtual void unfade(Transition transition) = 0; | 
|  | 77 |  | 
| Michael Wright | ca5bede | 2020-07-02 00:00:29 +0100 | [diff] [blame] | 78 | enum class Presentation { | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 79 | // Show the mouse pointer. | 
| Michael Wright | ca5bede | 2020-07-02 00:00:29 +0100 | [diff] [blame] | 80 | POINTER, | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 81 | // Show spots and a spot anchor in place of the mouse pointer. | 
| Michael Wright | ca5bede | 2020-07-02 00:00:29 +0100 | [diff] [blame] | 82 | SPOT, | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 83 | }; | 
|  | 84 |  | 
|  | 85 | /* Sets the mode of the pointer controller. */ | 
|  | 86 | virtual void setPresentation(Presentation presentation) = 0; | 
|  | 87 |  | 
|  | 88 | /* Sets the spots for the current gesture. | 
|  | 89 | * The spots are not subject to the inactivity timeout like the pointer | 
|  | 90 | * itself it since they are expected to remain visible for so long as | 
|  | 91 | * the fingers are on the touch pad. | 
|  | 92 | * | 
|  | 93 | * The values of the AMOTION_EVENT_AXIS_PRESSURE axis is significant. | 
|  | 94 | * For spotCoords, pressure != 0 indicates that the spot's location is being | 
|  | 95 | * pressed (not hovering). | 
|  | 96 | */ | 
|  | 97 | virtual void setSpots(const PointerCoords* spotCoords, const uint32_t* spotIdToIndex, | 
| Arthur Hung | 7c64540 | 2019-01-25 17:45:42 +0800 | [diff] [blame] | 98 | BitSet32 spotIdBits, int32_t displayId) = 0; | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 99 |  | 
|  | 100 | /* Removes all spots. */ | 
|  | 101 | virtual void clearSpots() = 0; | 
| Arthur Hung | c7ad2d0 | 2018-12-18 17:41:29 +0800 | [diff] [blame] | 102 |  | 
|  | 103 | /* Gets the id of the display where the pointer should be shown. */ | 
|  | 104 | virtual int32_t getDisplayId() const = 0; | 
| Garfield Tan | 888a6a4 | 2020-01-09 11:39:16 -0800 | [diff] [blame] | 105 |  | 
|  | 106 | /* Sets the associated display of this pointer. Pointer should show on that display. */ | 
|  | 107 | virtual void setDisplayViewport(const DisplayViewport& displayViewport) = 0; | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 108 | }; | 
|  | 109 |  | 
|  | 110 | } // namespace android | 
|  | 111 |  | 
|  | 112 | #endif // _INPUTFLINGER_POINTER_CONTROLLER_INTERFACE_H |