Loading include/input/InputDevice.h +17 −1 Original line number Diff line number Diff line Loading @@ -75,6 +75,17 @@ struct InputDeviceIdentifier { bool operator!=(const InputDeviceIdentifier&) const = default; }; /** * Holds View related behaviors for an InputDevice. */ struct InputDeviceViewBehavior { /** * The smooth scroll behavior that applies for all source/axis, if defined by the device. * Empty optional if the device has not specified the default smooth scroll behavior. */ std::optional<bool> shouldSmoothScroll; }; /* Types of input device sensors. Keep sync with core/java/android/hardware/Sensor.java */ enum class InputDeviceSensorType : int32_t { ACCELEROMETER = ASENSOR_TYPE_ACCELEROMETER, Loading Loading @@ -266,7 +277,8 @@ public: void initialize(int32_t id, int32_t generation, int32_t controllerNumber, const InputDeviceIdentifier& identifier, const std::string& alias, bool isExternal, bool hasMic, int32_t associatedDisplayId); bool isExternal, bool hasMic, int32_t associatedDisplayId, InputDeviceViewBehavior viewBehavior = {{}}); inline int32_t getId() const { return mId; } inline int32_t getControllerNumber() const { return mControllerNumber; } Loading Loading @@ -298,6 +310,8 @@ public: return mKeyboardLayoutInfo; } inline const InputDeviceViewBehavior& getViewBehavior() const { return mViewBehavior; } inline void setKeyCharacterMap(const std::shared_ptr<KeyCharacterMap> value) { mKeyCharacterMap = value; } Loading Loading @@ -359,6 +373,8 @@ private: std::unordered_map<int32_t, InputDeviceLightInfo> mLights; /* Map from battery ID to battery info */ std::unordered_map<int32_t, InputDeviceBatteryInfo> mBatteries; /** The View related behaviors for the device. */ InputDeviceViewBehavior mViewBehavior; }; /* Types of input device configuration files. */ Loading libs/input/InputDevice.cpp +5 −2 Original line number Diff line number Diff line Loading @@ -190,14 +190,16 @@ InputDeviceInfo::InputDeviceInfo(const InputDeviceInfo& other) mHasSensor(other.mHasSensor), mMotionRanges(other.mMotionRanges), mSensors(other.mSensors), mLights(other.mLights) {} mLights(other.mLights), mViewBehavior(other.mViewBehavior) {} InputDeviceInfo::~InputDeviceInfo() { } void InputDeviceInfo::initialize(int32_t id, int32_t generation, int32_t controllerNumber, const InputDeviceIdentifier& identifier, const std::string& alias, bool isExternal, bool hasMic, int32_t associatedDisplayId) { bool isExternal, bool hasMic, int32_t associatedDisplayId, InputDeviceViewBehavior viewBehavior) { mId = id; mGeneration = generation; mControllerNumber = controllerNumber; Loading @@ -212,6 +214,7 @@ void InputDeviceInfo::initialize(int32_t id, int32_t generation, int32_t control mHasBattery = false; mHasButtonUnderPad = false; mHasSensor = false; mViewBehavior = viewBehavior; mUsiVersion.reset(); mMotionRanges.clear(); mSensors.clear(); Loading libs/input/input_flags.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -111,3 +111,10 @@ flag { description: "Move user-activity poke rate-limiting from PowerManagerService to InputDispatcher." bug: "320499729" } flag { name: "input_device_view_behavior_api" namespace: "input" description: "Controls the API to provide InputDevice view behavior." bug: "246946631" } services/inputflinger/reader/InputDevice.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -251,6 +251,7 @@ std::list<NotifyArgs> InputDevice::configureInternal(nsecs_t when, mAssociatedDeviceType = getValueByKey(readerConfig.deviceTypeAssociations, mIdentifier.location); mIsWaking = mConfiguration.getBool("device.wake").value_or(false); mShouldSmoothScroll = mConfiguration.getBool("device.viewBehavior_smoothScroll"); } if (!changes.any() || changes.test(Change::DEVICE_ALIAS)) { Loading Loading @@ -401,7 +402,8 @@ std::list<NotifyArgs> InputDevice::updateExternalStylusState(const StylusState& InputDeviceInfo InputDevice::getDeviceInfo() { InputDeviceInfo outDeviceInfo; outDeviceInfo.initialize(mId, mGeneration, mControllerNumber, mIdentifier, mAlias, mIsExternal, mHasMic, getAssociatedDisplayId().value_or(ADISPLAY_ID_NONE)); mHasMic, getAssociatedDisplayId().value_or(ADISPLAY_ID_NONE), {mShouldSmoothScroll}); for_each_mapper( [&outDeviceInfo](InputMapper& mapper) { mapper.populateDeviceInfo(outDeviceInfo); }); Loading services/inputflinger/reader/include/InputDevice.h +1 −0 Original line number Diff line number Diff line Loading @@ -199,6 +199,7 @@ private: std::optional<DisplayViewport> mAssociatedViewport; bool mHasMic; bool mDropUntilNextSync; std::optional<bool> mShouldSmoothScroll; typedef int32_t (InputMapper::*GetStateFunc)(uint32_t sourceMask, int32_t code); int32_t getState(uint32_t sourceMask, int32_t code, GetStateFunc getStateFunc); Loading Loading
include/input/InputDevice.h +17 −1 Original line number Diff line number Diff line Loading @@ -75,6 +75,17 @@ struct InputDeviceIdentifier { bool operator!=(const InputDeviceIdentifier&) const = default; }; /** * Holds View related behaviors for an InputDevice. */ struct InputDeviceViewBehavior { /** * The smooth scroll behavior that applies for all source/axis, if defined by the device. * Empty optional if the device has not specified the default smooth scroll behavior. */ std::optional<bool> shouldSmoothScroll; }; /* Types of input device sensors. Keep sync with core/java/android/hardware/Sensor.java */ enum class InputDeviceSensorType : int32_t { ACCELEROMETER = ASENSOR_TYPE_ACCELEROMETER, Loading Loading @@ -266,7 +277,8 @@ public: void initialize(int32_t id, int32_t generation, int32_t controllerNumber, const InputDeviceIdentifier& identifier, const std::string& alias, bool isExternal, bool hasMic, int32_t associatedDisplayId); bool isExternal, bool hasMic, int32_t associatedDisplayId, InputDeviceViewBehavior viewBehavior = {{}}); inline int32_t getId() const { return mId; } inline int32_t getControllerNumber() const { return mControllerNumber; } Loading Loading @@ -298,6 +310,8 @@ public: return mKeyboardLayoutInfo; } inline const InputDeviceViewBehavior& getViewBehavior() const { return mViewBehavior; } inline void setKeyCharacterMap(const std::shared_ptr<KeyCharacterMap> value) { mKeyCharacterMap = value; } Loading Loading @@ -359,6 +373,8 @@ private: std::unordered_map<int32_t, InputDeviceLightInfo> mLights; /* Map from battery ID to battery info */ std::unordered_map<int32_t, InputDeviceBatteryInfo> mBatteries; /** The View related behaviors for the device. */ InputDeviceViewBehavior mViewBehavior; }; /* Types of input device configuration files. */ Loading
libs/input/InputDevice.cpp +5 −2 Original line number Diff line number Diff line Loading @@ -190,14 +190,16 @@ InputDeviceInfo::InputDeviceInfo(const InputDeviceInfo& other) mHasSensor(other.mHasSensor), mMotionRanges(other.mMotionRanges), mSensors(other.mSensors), mLights(other.mLights) {} mLights(other.mLights), mViewBehavior(other.mViewBehavior) {} InputDeviceInfo::~InputDeviceInfo() { } void InputDeviceInfo::initialize(int32_t id, int32_t generation, int32_t controllerNumber, const InputDeviceIdentifier& identifier, const std::string& alias, bool isExternal, bool hasMic, int32_t associatedDisplayId) { bool isExternal, bool hasMic, int32_t associatedDisplayId, InputDeviceViewBehavior viewBehavior) { mId = id; mGeneration = generation; mControllerNumber = controllerNumber; Loading @@ -212,6 +214,7 @@ void InputDeviceInfo::initialize(int32_t id, int32_t generation, int32_t control mHasBattery = false; mHasButtonUnderPad = false; mHasSensor = false; mViewBehavior = viewBehavior; mUsiVersion.reset(); mMotionRanges.clear(); mSensors.clear(); Loading
libs/input/input_flags.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -111,3 +111,10 @@ flag { description: "Move user-activity poke rate-limiting from PowerManagerService to InputDispatcher." bug: "320499729" } flag { name: "input_device_view_behavior_api" namespace: "input" description: "Controls the API to provide InputDevice view behavior." bug: "246946631" }
services/inputflinger/reader/InputDevice.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -251,6 +251,7 @@ std::list<NotifyArgs> InputDevice::configureInternal(nsecs_t when, mAssociatedDeviceType = getValueByKey(readerConfig.deviceTypeAssociations, mIdentifier.location); mIsWaking = mConfiguration.getBool("device.wake").value_or(false); mShouldSmoothScroll = mConfiguration.getBool("device.viewBehavior_smoothScroll"); } if (!changes.any() || changes.test(Change::DEVICE_ALIAS)) { Loading Loading @@ -401,7 +402,8 @@ std::list<NotifyArgs> InputDevice::updateExternalStylusState(const StylusState& InputDeviceInfo InputDevice::getDeviceInfo() { InputDeviceInfo outDeviceInfo; outDeviceInfo.initialize(mId, mGeneration, mControllerNumber, mIdentifier, mAlias, mIsExternal, mHasMic, getAssociatedDisplayId().value_or(ADISPLAY_ID_NONE)); mHasMic, getAssociatedDisplayId().value_or(ADISPLAY_ID_NONE), {mShouldSmoothScroll}); for_each_mapper( [&outDeviceInfo](InputMapper& mapper) { mapper.populateDeviceInfo(outDeviceInfo); }); Loading
services/inputflinger/reader/include/InputDevice.h +1 −0 Original line number Diff line number Diff line Loading @@ -199,6 +199,7 @@ private: std::optional<DisplayViewport> mAssociatedViewport; bool mHasMic; bool mDropUntilNextSync; std::optional<bool> mShouldSmoothScroll; typedef int32_t (InputMapper::*GetStateFunc)(uint32_t sourceMask, int32_t code); int32_t getState(uint32_t sourceMask, int32_t code, GetStateFunc getStateFunc); Loading