Loading services/inputflinger/InputReaderBase.cpp +11 −1 Original line number Diff line number Diff line Loading @@ -125,6 +125,16 @@ std::optional<DisplayViewport> InputReaderConfiguration::getDisplayViewportByPor return std::nullopt; } std::optional<DisplayViewport> InputReaderConfiguration::getDisplayViewportById( int32_t displayId) const { for (const DisplayViewport& currentViewport : mDisplays) { if (currentViewport.displayId == displayId) { return std::make_optional(currentViewport); } } return std::nullopt; } void InputReaderConfiguration::setDisplayViewports(const std::vector<DisplayViewport>& viewports) { mDisplays = viewports; } Loading services/inputflinger/include/InputReaderBase.h +5 −1 Original line number Diff line number Diff line Loading @@ -169,6 +169,9 @@ struct InputReaderConfiguration { // Used to determine which DisplayViewport should be tied to which InputDevice. std::unordered_map<std::string, uint8_t> portAssociations; // The suggested display ID to show the cursor. int32_t defaultPointerDisplayId; // Velocity control parameters for mouse pointer movements. VelocityControlParameters pointerVelocityControlParameters; Loading Loading @@ -273,6 +276,7 @@ struct InputReaderConfiguration { std::optional<DisplayViewport> getDisplayViewportByUniqueId(const std::string& uniqueDisplayId) const; std::optional<DisplayViewport> getDisplayViewportByPort(uint8_t physicalPort) const; std::optional<DisplayViewport> getDisplayViewportById(int32_t displayId) const; void setDisplayViewports(const std::vector<DisplayViewport>& viewports); Loading services/inputflinger/include/PointerControllerInterface.h +4 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #ifndef _INPUTFLINGER_POINTER_CONTROLLER_INTERFACE_H #define _INPUTFLINGER_POINTER_CONTROLLER_INTERFACE_H #include <input/DisplayViewport.h> #include <input/Input.h> #include <utils/BitSet.h> #include <utils/RefBase.h> Loading Loading @@ -101,6 +102,9 @@ public: /* Gets the id of the display where the pointer should be shown. */ virtual int32_t getDisplayId() const = 0; /* Sets the associated display of this pointer. Pointer should show on that display. */ virtual void setDisplayViewport(const DisplayViewport& displayViewport) = 0; }; } // namespace android Loading services/inputflinger/reader/mapper/CursorInputMapper.cpp +21 −1 Original line number Diff line number Diff line Loading @@ -189,12 +189,32 @@ void CursorInputMapper::configure(nsecs_t when, const InputReaderConfiguration* // Update the PointerController if viewports changed. if (mParameters.mode == Parameters::MODE_POINTER) { getPolicy()->obtainPointerController(getDeviceId()); updatePointerControllerDisplayViewport(*config); } bumpGeneration(); } } void CursorInputMapper::updatePointerControllerDisplayViewport( const InputReaderConfiguration& config) { std::optional<DisplayViewport> viewport = config.getDisplayViewportById(config.defaultPointerDisplayId); if (!viewport) { ALOGW("Can't find the designated viewport with ID %" PRId32 " to update cursor input " "mapper. Fall back to default display", config.defaultPointerDisplayId); viewport = config.getDisplayViewportById(ADISPLAY_ID_DEFAULT); } if (!viewport) { ALOGE("Still can't find a viable viewport to update cursor input mapper. Skip setting it to" " PointerController."); return; } mPointerController->setDisplayViewport(*viewport); } void CursorInputMapper::configureParameters() { mParameters.mode = Parameters::MODE_POINTER; String8 cursorModeString; Loading services/inputflinger/reader/mapper/CursorInputMapper.h +2 −1 Original line number Diff line number Diff line Loading @@ -117,6 +117,7 @@ private: void dumpParameters(std::string& dump); void sync(nsecs_t when); void updatePointerControllerDisplayViewport(const InputReaderConfiguration& config); }; } // namespace android Loading Loading
services/inputflinger/InputReaderBase.cpp +11 −1 Original line number Diff line number Diff line Loading @@ -125,6 +125,16 @@ std::optional<DisplayViewport> InputReaderConfiguration::getDisplayViewportByPor return std::nullopt; } std::optional<DisplayViewport> InputReaderConfiguration::getDisplayViewportById( int32_t displayId) const { for (const DisplayViewport& currentViewport : mDisplays) { if (currentViewport.displayId == displayId) { return std::make_optional(currentViewport); } } return std::nullopt; } void InputReaderConfiguration::setDisplayViewports(const std::vector<DisplayViewport>& viewports) { mDisplays = viewports; } Loading
services/inputflinger/include/InputReaderBase.h +5 −1 Original line number Diff line number Diff line Loading @@ -169,6 +169,9 @@ struct InputReaderConfiguration { // Used to determine which DisplayViewport should be tied to which InputDevice. std::unordered_map<std::string, uint8_t> portAssociations; // The suggested display ID to show the cursor. int32_t defaultPointerDisplayId; // Velocity control parameters for mouse pointer movements. VelocityControlParameters pointerVelocityControlParameters; Loading Loading @@ -273,6 +276,7 @@ struct InputReaderConfiguration { std::optional<DisplayViewport> getDisplayViewportByUniqueId(const std::string& uniqueDisplayId) const; std::optional<DisplayViewport> getDisplayViewportByPort(uint8_t physicalPort) const; std::optional<DisplayViewport> getDisplayViewportById(int32_t displayId) const; void setDisplayViewports(const std::vector<DisplayViewport>& viewports); Loading
services/inputflinger/include/PointerControllerInterface.h +4 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #ifndef _INPUTFLINGER_POINTER_CONTROLLER_INTERFACE_H #define _INPUTFLINGER_POINTER_CONTROLLER_INTERFACE_H #include <input/DisplayViewport.h> #include <input/Input.h> #include <utils/BitSet.h> #include <utils/RefBase.h> Loading Loading @@ -101,6 +102,9 @@ public: /* Gets the id of the display where the pointer should be shown. */ virtual int32_t getDisplayId() const = 0; /* Sets the associated display of this pointer. Pointer should show on that display. */ virtual void setDisplayViewport(const DisplayViewport& displayViewport) = 0; }; } // namespace android Loading
services/inputflinger/reader/mapper/CursorInputMapper.cpp +21 −1 Original line number Diff line number Diff line Loading @@ -189,12 +189,32 @@ void CursorInputMapper::configure(nsecs_t when, const InputReaderConfiguration* // Update the PointerController if viewports changed. if (mParameters.mode == Parameters::MODE_POINTER) { getPolicy()->obtainPointerController(getDeviceId()); updatePointerControllerDisplayViewport(*config); } bumpGeneration(); } } void CursorInputMapper::updatePointerControllerDisplayViewport( const InputReaderConfiguration& config) { std::optional<DisplayViewport> viewport = config.getDisplayViewportById(config.defaultPointerDisplayId); if (!viewport) { ALOGW("Can't find the designated viewport with ID %" PRId32 " to update cursor input " "mapper. Fall back to default display", config.defaultPointerDisplayId); viewport = config.getDisplayViewportById(ADISPLAY_ID_DEFAULT); } if (!viewport) { ALOGE("Still can't find a viable viewport to update cursor input mapper. Skip setting it to" " PointerController."); return; } mPointerController->setDisplayViewport(*viewport); } void CursorInputMapper::configureParameters() { mParameters.mode = Parameters::MODE_POINTER; String8 cursorModeString; Loading
services/inputflinger/reader/mapper/CursorInputMapper.h +2 −1 Original line number Diff line number Diff line Loading @@ -117,6 +117,7 @@ private: void dumpParameters(std::string& dump); void sync(nsecs_t when); void updatePointerControllerDisplayViewport(const InputReaderConfiguration& config); }; } // namespace android Loading