Extend the for loop to use all samples
Currently, the last sample is treated in a special manner (consistent
with the docs for MotionEvent).
However, the public api of MotionEvent also work fine if the element at
index [historySize] is accessed.
Therefore, calling event.getX() is the same as calling
event.getHistoricalX(historySize).
To simplify the code, remove the redundant code and instead extend the
loop by 1.
Bug: 167946721
Test: atest libinput_tests
Change-Id: Icc1fff1b0f16d63d7d0eb33e5977a3b3b440f562
diff --git a/include/input/Input.h b/include/input/Input.h
index 9feab7b..258adae 100644
--- a/include/input/Input.h
+++ b/include/input/Input.h
@@ -578,10 +578,18 @@
float getAxisValue(int32_t axis, size_t pointerIndex) const;
+ /**
+ * Get the X coordinate of the latest sample in this MotionEvent for pointer 'pointerIndex'.
+ * Identical to calling getHistoricalX(pointerIndex, getHistorySize()).
+ */
inline float getX(size_t pointerIndex) const {
return getAxisValue(AMOTION_EVENT_AXIS_X, pointerIndex);
}
+ /**
+ * Get the Y coordinate of the latest sample in this MotionEvent for pointer 'pointerIndex'.
+ * Identical to calling getHistoricalX(pointerIndex, getHistorySize()).
+ */
inline float getY(size_t pointerIndex) const {
return getAxisValue(AMOTION_EVENT_AXIS_Y, pointerIndex);
}