EventHub: Track the global abs axis states for enabled devices
Similar to what we have done for the global switch and key states, we
track the state and value of all ABS axes for each fd so that we no
longer have to use ioctls to query the value when upper layers request it.
This will help ensure that the device state remains synchronized between
the kernel and userspace, as the axis info will only need to be queried
once for each axis when the fd is opened.
Bug: 290938220
Bug: 261025260
Test: Presubmit
Change-Id: I622a20f27341b694140bb454bb1c744272d73183
diff --git a/services/inputflinger/reader/include/EventHub.h b/services/inputflinger/reader/include/EventHub.h
index 6e647db..09c5e94 100644
--- a/services/inputflinger/reader/include/EventHub.h
+++ b/services/inputflinger/reader/include/EventHub.h
@@ -612,7 +612,6 @@
BitArray<KEY_MAX> keyBitmask;
BitArray<KEY_MAX> keyState;
- BitArray<ABS_MAX> absBitmask;
BitArray<REL_MAX> relBitmask;
BitArray<SW_MAX> swBitmask;
BitArray<SW_MAX> swState;
@@ -620,12 +619,17 @@
BitArray<FF_MAX> ffBitmask;
BitArray<INPUT_PROP_MAX> propBitmask;
BitArray<MSC_MAX> mscBitmask;
+ BitArray<ABS_MAX> absBitmask;
+ struct AxisState {
+ RawAbsoluteAxisInfo info;
+ int value;
+ };
+ std::unordered_map<int /*axis*/, AxisState> absState;
std::string configurationFile;
std::unique_ptr<PropertyMap> configuration;
std::unique_ptr<VirtualKeyMap> virtualKeyMap;
KeyMap keyMap;
- std::unordered_map<int /*axis*/, RawAbsoluteAxisInfo> rawAbsoluteAxisInfoCache;
bool ffEffectPlaying;
int16_t ffEffectId; // initially -1
@@ -654,6 +658,7 @@
status_t readDeviceBitMask(unsigned long ioctlCode, BitArray<N>& bitArray);
void configureFd();
+ void populateAbsoluteAxisStates();
bool hasKeycodeLocked(int keycode) const;
void loadConfigurationLocked();
bool loadVirtualKeyMapLocked();
@@ -732,13 +737,6 @@
void addDeviceInputInotify();
void addDeviceInotify();
- /**
- * AbsoluteAxisInfo remains unchanged for the lifetime of the device, hence
- * we can read and store it with device
- * @param device target device
- */
- static void populateDeviceAbsoluteAxisInfo(Device& device);
-
// Protect all internal state.
mutable std::mutex mLock;