From b1b96db1eb56bd0df2bdf78d3922e10d65d08925 Mon Sep 17 00:00:00 2001 From: Yeabkal Wubshit Date: Wed, 24 Jan 2024 12:47:00 -0800 Subject: Support for InputDevice ViewBehavior This change creates a struct within InputDeviceInfo to hold View related behaviors of an input device. Currently, a single behavior is supported: device.viewBehavior_smoothScroll. This can be specified in an IDC file to hint clients of the InputDevice that they should animate scrolls for motion events generated by the InputDevice. Bug: 246946631 Test: add property in IDC, check API returns expected value Test: atest frameworks/native/services/inputflinger/tests/InputReader_test.cpp Change-Id: Ibe373cadc40d2a08116e787b744dd30812638edb --- include/input/InputDevice.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'include/input/InputDevice.h') diff --git a/include/input/InputDevice.h b/include/input/InputDevice.h index b7751f704a..57b659d9ee 100644 --- a/include/input/InputDevice.h +++ b/include/input/InputDevice.h @@ -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 shouldSmoothScroll; +}; + /* Types of input device sensors. Keep sync with core/java/android/hardware/Sensor.java */ enum class InputDeviceSensorType : int32_t { ACCELEROMETER = ASENSOR_TYPE_ACCELEROMETER, @@ -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; } @@ -298,6 +310,8 @@ public: return mKeyboardLayoutInfo; } + inline const InputDeviceViewBehavior& getViewBehavior() const { return mViewBehavior; } + inline void setKeyCharacterMap(const std::shared_ptr value) { mKeyCharacterMap = value; } @@ -359,6 +373,8 @@ private: std::unordered_map mLights; /* Map from battery ID to battery info */ std::unordered_map mBatteries; + /** The View related behaviors for the device. */ + InputDeviceViewBehavior mViewBehavior; }; /* Types of input device configuration files. */ -- cgit v1.2.3-59-g8ed1b