Process EV_MSC MSC_TIMESTAMP in InputMapper
An evdev driver could report EV_MSC MSC_TIMESTAMP input event to relay
the number of microseconds since the last reset. This data could be
useful for keeping track of the specific kernel time of a particular
input_event. Propagate this data here to the InputDispatcher level,
but only for the MultiTouchInputMapper.
Bug: 62940136
Test: report MSC_TIMESTAMP in kernel driver on Pixel 2 XL device and
observe the data in the inputflinger layer using HeatMapDemo app.
Test: m -j inputflinger_tests_InputReader_test
inputflinger_tests_InputDispatcher_test && adb push
out/target/product/$TARGET_PRODUCT/data/nativetest64/*
/data/nativetest64/
then on device: /data/nativetest64/inputflinger_tests # ./InputReader_test
Change-Id: Id990ec46a380e7f367020863fd86e4bae6ce47e4
diff --git a/services/inputflinger/InputReader.h b/services/inputflinger/InputReader.h
index 4f48262..cef3212 100644
--- a/services/inputflinger/InputReader.h
+++ b/services/inputflinger/InputReader.h
@@ -947,6 +947,7 @@
inline size_t getSlotCount() const { return mSlotCount; }
inline const Slot* getSlot(size_t index) const { return &mSlots[index]; }
+ inline uint32_t getDeviceTimestamp() const { return mDeviceTimestamp; }
private:
int32_t mCurrentSlot;
@@ -954,6 +955,7 @@
size_t mSlotCount;
bool mUsingSlotsProtocol;
bool mHaveStylus;
+ uint32_t mDeviceTimestamp;
void clearSlots(int32_t initialSlot);
};
@@ -1396,6 +1398,7 @@
struct RawState {
nsecs_t when;
+ uint32_t deviceTimestamp;
// Raw pointer sample data.
RawPointerData rawPointerData;
@@ -1408,6 +1411,7 @@
void copyFrom(const RawState& other) {
when = other.when;
+ deviceTimestamp = other.deviceTimestamp;
rawPointerData.copyFrom(other.rawPointerData);
buttonState = other.buttonState;
rawVScroll = other.rawVScroll;
@@ -1416,6 +1420,7 @@
void clear() {
when = 0;
+ deviceTimestamp = 0;
rawPointerData.clear();
buttonState = 0;
rawVScroll = 0;
@@ -1424,6 +1429,7 @@
};
struct CookedState {
+ uint32_t deviceTimestamp;
// Cooked pointer sample data.
CookedPointerData cookedPointerData;
@@ -1435,6 +1441,7 @@
int32_t buttonState;
void copyFrom(const CookedState& other) {
+ deviceTimestamp = other.deviceTimestamp;
cookedPointerData.copyFrom(other.cookedPointerData);
fingerIdBits = other.fingerIdBits;
stylusIdBits = other.stylusIdBits;
@@ -1443,6 +1450,7 @@
}
void clear() {
+ deviceTimestamp = 0;
cookedPointerData.clear();
fingerIdBits.clear();
stylusIdBits.clear();
@@ -1837,6 +1845,7 @@
void dispatchMotion(nsecs_t when, uint32_t policyFlags, uint32_t source,
int32_t action, int32_t actionButton,
int32_t flags, int32_t metaState, int32_t buttonState, int32_t edgeFlags,
+ uint32_t deviceTimestamp,
const PointerProperties* properties, const PointerCoords* coords,
const uint32_t* idToIndex, BitSet32 idBits,
int32_t changedId, float xPrecision, float yPrecision, nsecs_t downTime);