Loading include/android/configuration.h +4 −0 Original line number Diff line number Diff line Loading @@ -133,10 +133,14 @@ enum { * resource qualifier. */ ACONFIGURATION_DENSITY_XXXHIGH = 640, // If adding additional special density values, also update ACONFIGURATION_MAX_SUPPORTED_DENSITY // in CursorInputMapper. // LINT.IfChange /** Density: any density. */ ACONFIGURATION_DENSITY_ANY = 0xfffe, /** Density: no density specified. */ ACONFIGURATION_DENSITY_NONE = 0xffff, // LINT.ThenChange(/services/inputflinger/reader/mapper/CursorInputMapper.cpp) /** Keyboard: not specified. */ ACONFIGURATION_KEYBOARD_ANY = 0x0000, Loading include/input/DisplayViewport.h +8 −4 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #pragma once #include <android-base/stringprintf.h> #include <android/configuration.h> #include <ftl/enum.h> #include <ftl/string.h> #include <input/Input.h> Loading Loading @@ -64,6 +65,7 @@ struct DisplayViewport { // Not all viewports will have this specified. std::optional<uint8_t> physicalPort; ViewportType type; int32_t densityDpi; DisplayViewport() : displayId(ui::LogicalDisplayId::INVALID), Loading @@ -81,7 +83,8 @@ struct DisplayViewport { isActive(false), uniqueId(), physicalPort(std::nullopt), type(ViewportType::INTERNAL) {} type(ViewportType::INTERNAL), densityDpi(ACONFIGURATION_DENSITY_NONE) {} bool operator==(const DisplayViewport& other) const { return displayId == other.displayId && orientation == other.orientation && Loading Loading @@ -121,6 +124,7 @@ struct DisplayViewport { std::string toString() const { return StringPrintf("Viewport %s: displayId=%s, uniqueId=%s, port=%s, orientation=%d, " "densityDpi=%d " "logicalFrame=[%d, %d, %d, %d], " "physicalFrame=[%d, %d, %d, %d], " "deviceSize=[%d, %d], " Loading @@ -128,9 +132,9 @@ struct DisplayViewport { ftl::enum_string(type).c_str(), displayId.toString().c_str(), uniqueId.c_str(), physicalPort ? ftl::to_string(*physicalPort).c_str() : "<none>", static_cast<int>(orientation), logicalLeft, logicalTop, logicalRight, logicalBottom, physicalLeft, physicalTop, physicalRight, physicalBottom, deviceWidth, deviceHeight, isActive); static_cast<int>(orientation), densityDpi, logicalLeft, logicalTop, logicalRight, logicalBottom, physicalLeft, physicalTop, physicalRight, physicalBottom, deviceWidth, deviceHeight, isActive); } }; Loading include/input/InputFlags.h +9 −0 Original line number Diff line number Diff line Loading @@ -42,8 +42,17 @@ public: /** * Check if both connectedDisplaysCursor and associatedDisplayCursorBugfix is enabled. * This setting can be overridden with the dev option similar to the * connectedDisplaysCursorEnabled flag. */ static bool connectedDisplaysCursorAndAssociatedDisplayCursorBugfixEnabled(); /** * Check if display density based cursor scaling is enabled. * This setting can be overridden with the dev option similar to the * connectedDisplaysCursorEnabled flag. */ static bool scaleCursorSpeedWithDisplayDensity(); }; } // namespace android libs/input/InputFlags.cpp +23 −3 Original line number Diff line number Diff line Loading @@ -25,9 +25,13 @@ namespace android { bool InputFlags::connectedDisplaysCursorEnabled() { namespace { // Returns the cached dev option value if available. // This check is only required for connected-displays related features. std::optional<bool> getConnectedDisplaysDevOptionValue() { if (!com::android::window::flags::enable_desktop_mode_through_dev_option()) { return com::android::input::flags::connected_displays_cursor(); return std::nullopt; } static std::optional<bool> cachedDevOption; if (!cachedDevOption.has_value()) { Loading @@ -37,15 +41,31 @@ bool InputFlags::connectedDisplaysCursorEnabled() { property_get(sysprop_name, value, nullptr) > 0 ? std::atoi(value) : 0; cachedDevOption = devOptionEnabled == 1; } if (cachedDevOption.value_or(false)) { return cachedDevOption; } } // namespace bool InputFlags::connectedDisplaysCursorEnabled() { if (getConnectedDisplaysDevOptionValue().value_or(false)) { return true; } return com::android::input::flags::connected_displays_cursor(); } bool InputFlags::connectedDisplaysCursorAndAssociatedDisplayCursorBugfixEnabled() { if (getConnectedDisplaysDevOptionValue().value_or(false)) { return true; } return connectedDisplaysCursorEnabled() && com::android::input::flags::connected_displays_associated_display_cursor_bugfix(); } bool InputFlags::scaleCursorSpeedWithDisplayDensity() { if (getConnectedDisplaysDevOptionValue().value_or(false)) { return true; } return com::android::input::flags::scale_cursor_speed_with_dpi(); } } // namespace android No newline at end of file services/inputflinger/reader/mapper/CursorInputMapper.cpp +32 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include <com_android_input_flags.h> #include <ftl/enum.h> #include <input/AccelerationCurve.h> #include <input/InputFlags.h> #include "CursorButtonAccumulator.h" #include "CursorScrollAccumulator.h" Loading @@ -35,6 +36,24 @@ namespace android { namespace { /** Max density value supported by input. */ const int32_t ACONFIGURATION_MAX_SUPPORTED_DENSITY = ACONFIGURATION_DENSITY_ANY; // Density values in range (0, ACONFIGURATION_MAX_SUPPORTED_DENSITY] are supported for cursor // moves scaling. Other density values e.g. ACONFIGURATION_DENSITY_DEFAULT, // ACONFIGURATION_DENSITY_NONE etc. are ignored. inline bool isDensityValueSupportedForScaling(int32_t density) { if (density > 0 && density <= ACONFIGURATION_MAX_SUPPORTED_DENSITY) { return true; } ALOGE("Unexpected display density value %d, cursor move scaling will be disabled.", density); return false; } } // namespace // The default velocity control parameters that has no effect. static const VelocityControlParameters FLAT_VELOCITY_CONTROL_PARAMS{}; Loading Loading @@ -129,6 +148,7 @@ void CursorInputMapper::dump(std::string& dump) { dump += StringPrintf(INDENT3 "DisplayId: %s\n", toString(mDisplayId, streamableToString).c_str()); dump += StringPrintf(INDENT3 "Orientation: %s\n", ftl::enum_string(mOrientation).c_str()); dump += StringPrintf(INDENT3 "ViewportDensityDpi: %d\n", mViewportDensityDpi); dump += StringPrintf(INDENT3 "ButtonState: 0x%08x\n", mButtonState); dump += StringPrintf(INDENT3 "Down: %s\n", toString(isPointerDown(mButtonState))); dump += StringPrintf(INDENT3 "DownTime: %" PRId64 "\n", mDownTime); Loading Loading @@ -496,6 +516,15 @@ void CursorInputMapper::configureOnChangePointerSpeed(const InputReaderConfigura bool disableAllScaling = config.displaysWithMouseScalingDisabled.count( mDisplayId.value_or(ui::LogicalDisplayId::INVALID)) != 0; if (InputFlags::scaleCursorSpeedWithDisplayDensity() && mParameters.mode == Parameters::Mode::POINTER && !disableAllScaling) { // TODO(b/408170793): We use ACONFIGURATION_DENSITY_XHIGH as baseline for scale due to // legacy reasons, this need to be tuned with further UX testing. mXScale = mYScale = isDensityValueSupportedForScaling(mViewportDensityDpi) ? static_cast<float>(mViewportDensityDpi) / static_cast<float>(ACONFIGURATION_DENSITY_XHIGH) : 1.0; } mPointerVelocityControl.setAccelerationEnabled(!disableAllScaling); mPointerVelocityControl.setCurve( Loading Loading @@ -538,6 +567,9 @@ void CursorInputMapper::configureOnChangeDisplayInfo(const InputReaderConfigurat static_cast<float>(resolvedViewport->logicalBottom - 1)} : FloatRect{0, 0, 0, 0}; mViewportDensityDpi = resolvedViewport ? resolvedViewport->densityDpi : ACONFIGURATION_DENSITY_MEDIUM; bumpGeneration(); } Loading Loading
include/android/configuration.h +4 −0 Original line number Diff line number Diff line Loading @@ -133,10 +133,14 @@ enum { * resource qualifier. */ ACONFIGURATION_DENSITY_XXXHIGH = 640, // If adding additional special density values, also update ACONFIGURATION_MAX_SUPPORTED_DENSITY // in CursorInputMapper. // LINT.IfChange /** Density: any density. */ ACONFIGURATION_DENSITY_ANY = 0xfffe, /** Density: no density specified. */ ACONFIGURATION_DENSITY_NONE = 0xffff, // LINT.ThenChange(/services/inputflinger/reader/mapper/CursorInputMapper.cpp) /** Keyboard: not specified. */ ACONFIGURATION_KEYBOARD_ANY = 0x0000, Loading
include/input/DisplayViewport.h +8 −4 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #pragma once #include <android-base/stringprintf.h> #include <android/configuration.h> #include <ftl/enum.h> #include <ftl/string.h> #include <input/Input.h> Loading Loading @@ -64,6 +65,7 @@ struct DisplayViewport { // Not all viewports will have this specified. std::optional<uint8_t> physicalPort; ViewportType type; int32_t densityDpi; DisplayViewport() : displayId(ui::LogicalDisplayId::INVALID), Loading @@ -81,7 +83,8 @@ struct DisplayViewport { isActive(false), uniqueId(), physicalPort(std::nullopt), type(ViewportType::INTERNAL) {} type(ViewportType::INTERNAL), densityDpi(ACONFIGURATION_DENSITY_NONE) {} bool operator==(const DisplayViewport& other) const { return displayId == other.displayId && orientation == other.orientation && Loading Loading @@ -121,6 +124,7 @@ struct DisplayViewport { std::string toString() const { return StringPrintf("Viewport %s: displayId=%s, uniqueId=%s, port=%s, orientation=%d, " "densityDpi=%d " "logicalFrame=[%d, %d, %d, %d], " "physicalFrame=[%d, %d, %d, %d], " "deviceSize=[%d, %d], " Loading @@ -128,9 +132,9 @@ struct DisplayViewport { ftl::enum_string(type).c_str(), displayId.toString().c_str(), uniqueId.c_str(), physicalPort ? ftl::to_string(*physicalPort).c_str() : "<none>", static_cast<int>(orientation), logicalLeft, logicalTop, logicalRight, logicalBottom, physicalLeft, physicalTop, physicalRight, physicalBottom, deviceWidth, deviceHeight, isActive); static_cast<int>(orientation), densityDpi, logicalLeft, logicalTop, logicalRight, logicalBottom, physicalLeft, physicalTop, physicalRight, physicalBottom, deviceWidth, deviceHeight, isActive); } }; Loading
include/input/InputFlags.h +9 −0 Original line number Diff line number Diff line Loading @@ -42,8 +42,17 @@ public: /** * Check if both connectedDisplaysCursor and associatedDisplayCursorBugfix is enabled. * This setting can be overridden with the dev option similar to the * connectedDisplaysCursorEnabled flag. */ static bool connectedDisplaysCursorAndAssociatedDisplayCursorBugfixEnabled(); /** * Check if display density based cursor scaling is enabled. * This setting can be overridden with the dev option similar to the * connectedDisplaysCursorEnabled flag. */ static bool scaleCursorSpeedWithDisplayDensity(); }; } // namespace android
libs/input/InputFlags.cpp +23 −3 Original line number Diff line number Diff line Loading @@ -25,9 +25,13 @@ namespace android { bool InputFlags::connectedDisplaysCursorEnabled() { namespace { // Returns the cached dev option value if available. // This check is only required for connected-displays related features. std::optional<bool> getConnectedDisplaysDevOptionValue() { if (!com::android::window::flags::enable_desktop_mode_through_dev_option()) { return com::android::input::flags::connected_displays_cursor(); return std::nullopt; } static std::optional<bool> cachedDevOption; if (!cachedDevOption.has_value()) { Loading @@ -37,15 +41,31 @@ bool InputFlags::connectedDisplaysCursorEnabled() { property_get(sysprop_name, value, nullptr) > 0 ? std::atoi(value) : 0; cachedDevOption = devOptionEnabled == 1; } if (cachedDevOption.value_or(false)) { return cachedDevOption; } } // namespace bool InputFlags::connectedDisplaysCursorEnabled() { if (getConnectedDisplaysDevOptionValue().value_or(false)) { return true; } return com::android::input::flags::connected_displays_cursor(); } bool InputFlags::connectedDisplaysCursorAndAssociatedDisplayCursorBugfixEnabled() { if (getConnectedDisplaysDevOptionValue().value_or(false)) { return true; } return connectedDisplaysCursorEnabled() && com::android::input::flags::connected_displays_associated_display_cursor_bugfix(); } bool InputFlags::scaleCursorSpeedWithDisplayDensity() { if (getConnectedDisplaysDevOptionValue().value_or(false)) { return true; } return com::android::input::flags::scale_cursor_speed_with_dpi(); } } // namespace android No newline at end of file
services/inputflinger/reader/mapper/CursorInputMapper.cpp +32 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include <com_android_input_flags.h> #include <ftl/enum.h> #include <input/AccelerationCurve.h> #include <input/InputFlags.h> #include "CursorButtonAccumulator.h" #include "CursorScrollAccumulator.h" Loading @@ -35,6 +36,24 @@ namespace android { namespace { /** Max density value supported by input. */ const int32_t ACONFIGURATION_MAX_SUPPORTED_DENSITY = ACONFIGURATION_DENSITY_ANY; // Density values in range (0, ACONFIGURATION_MAX_SUPPORTED_DENSITY] are supported for cursor // moves scaling. Other density values e.g. ACONFIGURATION_DENSITY_DEFAULT, // ACONFIGURATION_DENSITY_NONE etc. are ignored. inline bool isDensityValueSupportedForScaling(int32_t density) { if (density > 0 && density <= ACONFIGURATION_MAX_SUPPORTED_DENSITY) { return true; } ALOGE("Unexpected display density value %d, cursor move scaling will be disabled.", density); return false; } } // namespace // The default velocity control parameters that has no effect. static const VelocityControlParameters FLAT_VELOCITY_CONTROL_PARAMS{}; Loading Loading @@ -129,6 +148,7 @@ void CursorInputMapper::dump(std::string& dump) { dump += StringPrintf(INDENT3 "DisplayId: %s\n", toString(mDisplayId, streamableToString).c_str()); dump += StringPrintf(INDENT3 "Orientation: %s\n", ftl::enum_string(mOrientation).c_str()); dump += StringPrintf(INDENT3 "ViewportDensityDpi: %d\n", mViewportDensityDpi); dump += StringPrintf(INDENT3 "ButtonState: 0x%08x\n", mButtonState); dump += StringPrintf(INDENT3 "Down: %s\n", toString(isPointerDown(mButtonState))); dump += StringPrintf(INDENT3 "DownTime: %" PRId64 "\n", mDownTime); Loading Loading @@ -496,6 +516,15 @@ void CursorInputMapper::configureOnChangePointerSpeed(const InputReaderConfigura bool disableAllScaling = config.displaysWithMouseScalingDisabled.count( mDisplayId.value_or(ui::LogicalDisplayId::INVALID)) != 0; if (InputFlags::scaleCursorSpeedWithDisplayDensity() && mParameters.mode == Parameters::Mode::POINTER && !disableAllScaling) { // TODO(b/408170793): We use ACONFIGURATION_DENSITY_XHIGH as baseline for scale due to // legacy reasons, this need to be tuned with further UX testing. mXScale = mYScale = isDensityValueSupportedForScaling(mViewportDensityDpi) ? static_cast<float>(mViewportDensityDpi) / static_cast<float>(ACONFIGURATION_DENSITY_XHIGH) : 1.0; } mPointerVelocityControl.setAccelerationEnabled(!disableAllScaling); mPointerVelocityControl.setCurve( Loading Loading @@ -538,6 +567,9 @@ void CursorInputMapper::configureOnChangeDisplayInfo(const InputReaderConfigurat static_cast<float>(resolvedViewport->logicalBottom - 1)} : FloatRect{0, 0, 0, 0}; mViewportDensityDpi = resolvedViewport ? resolvedViewport->densityDpi : ACONFIGURATION_DENSITY_MEDIUM; bumpGeneration(); } Loading