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