| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
#ifndef _UI_MOUSE_CURSOR_CONTROLLER_H |
| 18 |
#define _UI_MOUSE_CURSOR_CONTROLLER_H |
| 19 |
|
| 20 |
#include <gui/DisplayEventReceiver.h> |
| 21 |
#include <input/DisplayViewport.h> |
| 22 |
#include <input/Input.h> |
| 23 |
#include <utils/BitSet.h> |
| 24 |
#include <utils/Looper.h> |
| 25 |
#include <utils/RefBase.h> |
| 26 |
|
| 27 |
#include <functional> |
| 28 |
#include <map> |
| 29 |
#include <memory> |
| 30 |
#include <vector> |
| 31 |
|
| 32 |
#include "PointerControllerContext.h" |
| 33 |
#include "SpriteController.h" |
| 34 |
|
| 35 |
namespace android { |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
class MouseCursorController { |
| 42 |
public: |
| 43 |
MouseCursorController(PointerControllerContext& context); |
| 44 |
~MouseCursorController(); |
| 45 |
|
| 46 |
bool getBounds(float* outMinX, float* outMinY, float* outMaxX, float* outMaxY) const; |
| 47 |
void move(float deltaX, float deltaY); |
| 48 |
void setButtonState(int32_t buttonState); |
| 49 |
int32_t getButtonState() const; |
| 50 |
void setPosition(float x, float y); |
| 51 |
void getPosition(float* outX, float* outY) const; |
| 52 |
int32_t getDisplayId() const; |
| 53 |
void fade(PointerControllerInterface::Transition transition); |
| 54 |
void unfade(PointerControllerInterface::Transition transition); |
| 55 |
void setDisplayViewport(const DisplayViewport& viewport, bool getAdditionalMouseResources); |
| 56 |
|
| 57 |
void updatePointerIcon(int32_t iconId); |
| 58 |
void setCustomPointerIcon(const SpriteIcon& icon); |
| 59 |
void reloadPointerResources(bool getAdditionalMouseResources); |
| 60 |
|
| 61 |
void getAdditionalMouseResources(); |
| 62 |
bool isViewportValid(); |
| 63 |
|
| 64 |
bool doAnimations(nsecs_t timestamp); |
| 65 |
|
| 66 |
bool resourcesLoaded(); |
| 67 |
|
| 68 |
private: |
| 69 |
mutable std::mutex mLock; |
| 70 |
|
| 71 |
PointerResources mResources; |
| 72 |
|
| 73 |
PointerControllerContext& mContext; |
| 74 |
|
| 75 |
struct Locked { |
| 76 |
DisplayViewport viewport; |
| 77 |
|
| 78 |
size_t animationFrameIndex; |
| 79 |
nsecs_t lastFrameUpdatedTime; |
| 80 |
|
| 81 |
int32_t pointerFadeDirection; |
| 82 |
float pointerX; |
| 83 |
float pointerY; |
| 84 |
float pointerAlpha; |
| 85 |
sp<Sprite> pointerSprite; |
| 86 |
SpriteIcon pointerIcon; |
| 87 |
bool updatePointerIcon; |
| 88 |
|
| 89 |
bool resourcesLoaded; |
| 90 |
|
| 91 |
std::map<int32_t, SpriteIcon> additionalMouseResources; |
| 92 |
std::map<int32_t, PointerAnimation> animationResources; |
| 93 |
|
| 94 |
int32_t requestedPointerType; |
| 95 |
|
| 96 |
int32_t buttonState; |
| 97 |
|
| 98 |
bool animating{false}; |
| 99 |
|
| 100 |
} mLocked GUARDED_BY(mLock); |
| 101 |
|
| 102 |
bool getBoundsLocked(float* outMinX, float* outMinY, float* outMaxX, float* outMaxY) const; |
| 103 |
void setPositionLocked(float x, float y); |
| 104 |
|
| 105 |
void updatePointerLocked(); |
| 106 |
|
| 107 |
void loadResourcesLocked(bool getAdditionalMouseResources); |
| 108 |
|
| 109 |
bool doBitmapAnimationLocked(nsecs_t timestamp); |
| 110 |
bool doFadingAnimationLocked(nsecs_t timestamp); |
| 111 |
|
| 112 |
void startAnimationLocked(); |
| 113 |
}; |
| 114 |
|
| 115 |
} |
| 116 |
|
| 117 |
#endif |