summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/input/PointerController.cpp41
-rw-r--r--libs/input/PointerController.h70
-rw-r--r--services/core/jni/com_android_server_input_InputManagerService.cpp10
3 files changed, 118 insertions, 3 deletions
diff --git a/libs/input/PointerController.cpp b/libs/input/PointerController.cpp
index 576ebc1579ef..65e16056c106 100644
--- a/libs/input/PointerController.cpp
+++ b/libs/input/PointerController.cpp
@@ -74,6 +74,14 @@ std::shared_ptr<PointerController> PointerController::create(
controller = std::shared_ptr<PointerController>(
new MousePointerController(policy, looper, spriteController, enabled));
break;
+ case ControllerType::TOUCH:
+ controller = std::shared_ptr<PointerController>(
+ new TouchPointerController(policy, looper, spriteController, enabled));
+ break;
+ case ControllerType::STYLUS:
+ controller = std::shared_ptr<PointerController>(
+ new StylusPointerController(policy, looper, spriteController, enabled));
+ break;
case ControllerType::LEGACY:
default:
controller = std::shared_ptr<PointerController>(
@@ -167,8 +175,7 @@ void PointerController::setPosition(float x, float y) {
FloatPoint PointerController::getPosition() const {
if (!mEnabled) {
- return FloatPoint{AMOTION_EVENT_INVALID_CURSOR_POSITION,
- AMOTION_EVENT_INVALID_CURSOR_POSITION};
+ return FloatPoint{0, 0};
}
const int32_t displayId = mCursorController.getDisplayId();
@@ -397,4 +404,34 @@ MousePointerController::MousePointerController(const sp<PointerControllerPolicyI
PointerController::setPresentation(Presentation::POINTER);
}
+MousePointerController::~MousePointerController() {
+ MousePointerController::fade(Transition::IMMEDIATE);
+}
+
+// --- TouchPointerController ---
+
+TouchPointerController::TouchPointerController(const sp<PointerControllerPolicyInterface>& policy,
+ const sp<Looper>& looper,
+ SpriteController& spriteController, bool enabled)
+ : PointerController(policy, looper, spriteController, enabled) {
+ PointerController::setPresentation(Presentation::SPOT);
+}
+
+TouchPointerController::~TouchPointerController() {
+ TouchPointerController::clearSpots();
+}
+
+// --- StylusPointerController ---
+
+StylusPointerController::StylusPointerController(const sp<PointerControllerPolicyInterface>& policy,
+ const sp<Looper>& looper,
+ SpriteController& spriteController, bool enabled)
+ : PointerController(policy, looper, spriteController, enabled) {
+ PointerController::setPresentation(Presentation::STYLUS_HOVER);
+}
+
+StylusPointerController::~StylusPointerController() {
+ StylusPointerController::fade(Transition::IMMEDIATE);
+}
+
} // namespace android
diff --git a/libs/input/PointerController.h b/libs/input/PointerController.h
index 08e19a096d87..fa07c3989720 100644
--- a/libs/input/PointerController.h
+++ b/libs/input/PointerController.h
@@ -68,7 +68,7 @@ public:
void updatePointerIcon(PointerIconStyle iconId);
void setCustomPointerIcon(const SpriteIcon& icon);
- void setInactivityTimeout(InactivityTimeout inactivityTimeout);
+ virtual void setInactivityTimeout(InactivityTimeout inactivityTimeout);
void doInactivityTimeout();
void reloadPointerResources();
void onDisplayViewportsUpdated(const std::vector<DisplayViewport>& viewports);
@@ -143,6 +143,74 @@ public:
const sp<Looper>& looper, SpriteController& spriteController,
bool enabled);
+ ~MousePointerController() override;
+
+ void setPresentation(Presentation) override {
+ LOG_ALWAYS_FATAL("Should not be called");
+ }
+ void setSpots(const PointerCoords*, const uint32_t*, BitSet32, int32_t) override {
+ LOG_ALWAYS_FATAL("Should not be called");
+ }
+ void clearSpots() override {
+ LOG_ALWAYS_FATAL("Should not be called");
+ }
+};
+
+class TouchPointerController : public PointerController {
+public:
+ /** A version of PointerController that controls touch spots. */
+ TouchPointerController(const sp<PointerControllerPolicyInterface>& policy,
+ const sp<Looper>& looper, SpriteController& spriteController,
+ bool enabled);
+
+ ~TouchPointerController() override;
+
+ std::optional<FloatRect> getBounds() const override {
+ LOG_ALWAYS_FATAL("Should not be called");
+ }
+ void move(float, float) override {
+ LOG_ALWAYS_FATAL("Should not be called");
+ }
+ void setPosition(float, float) override {
+ LOG_ALWAYS_FATAL("Should not be called");
+ }
+ FloatPoint getPosition() const override {
+ LOG_ALWAYS_FATAL("Should not be called");
+ }
+ int32_t getDisplayId() const override {
+ LOG_ALWAYS_FATAL("Should not be called");
+ }
+ void fade(Transition) override {
+ LOG_ALWAYS_FATAL("Should not be called");
+ }
+ void unfade(Transition) override {
+ LOG_ALWAYS_FATAL("Should not be called");
+ }
+ void setDisplayViewport(const DisplayViewport&) override {
+ LOG_ALWAYS_FATAL("Should not be called");
+ }
+ void setPresentation(Presentation) override {
+ LOG_ALWAYS_FATAL("Should not be called");
+ }
+ void updatePointerIcon(PointerIconStyle) {
+ LOG_ALWAYS_FATAL("Should not be called");
+ }
+ void setCustomPointerIcon(const SpriteIcon&) {
+ LOG_ALWAYS_FATAL("Should not be called");
+ }
+ // fade() should not be called by inactivity timeout. Do nothing.
+ void setInactivityTimeout(InactivityTimeout) override {}
+};
+
+class StylusPointerController : public PointerController {
+public:
+ /** A version of PointerController that controls one stylus pointer. */
+ StylusPointerController(const sp<PointerControllerPolicyInterface>& policy,
+ const sp<Looper>& looper, SpriteController& spriteController,
+ bool enabled);
+
+ ~StylusPointerController() override;
+
void setPresentation(Presentation) override {
LOG_ALWAYS_FATAL("Should not be called");
}
diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp
index a7d77304d046..21820939ba03 100644
--- a/services/core/jni/com_android_server_input_InputManagerService.cpp
+++ b/services/core/jni/com_android_server_input_InputManagerService.cpp
@@ -1293,6 +1293,11 @@ void NativeInputManager::setInputDeviceEnabled(uint32_t deviceId, bool enabled)
}
void NativeInputManager::setShowTouches(bool enabled) {
+ if (ENABLE_POINTER_CHOREOGRAPHER) {
+ mInputManager->getChoreographer().setShowTouchesEnabled(enabled);
+ return;
+ }
+
{ // acquire lock
std::scoped_lock _l(mLock);
@@ -1744,6 +1749,11 @@ FloatPoint NativeInputManager::getMouseCursorPosition() {
}
void NativeInputManager::setStylusPointerIconEnabled(bool enabled) {
+ if (ENABLE_POINTER_CHOREOGRAPHER) {
+ mInputManager->getChoreographer().setStylusPointerIconEnabled(enabled);
+ return;
+ }
+
{ // acquire lock
std::scoped_lock _l(mLock);