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/libs/input/VelocityTracker.cpp b/libs/input/VelocityTracker.cpp
index d74c520..be1a33d 100644
--- a/libs/input/VelocityTracker.cpp
+++ b/libs/input/VelocityTracker.cpp
@@ -289,13 +289,12 @@
         pointerIndex[i] = idBits.getIndexOfBit(event->getPointerId(i));
     }
 
-    nsecs_t eventTime;
     std::vector<Position> positions;
     positions.resize(pointerCount);
 
     size_t historySize = event->getHistorySize();
-    for (size_t h = 0; h < historySize; h++) {
-        eventTime = event->getHistoricalEventTime(h);
+    for (size_t h = 0; h <= historySize; h++) {
+        nsecs_t eventTime = event->getHistoricalEventTime(h);
         for (size_t i = 0; i < pointerCount; i++) {
             uint32_t index = pointerIndex[i];
             positions[index].x = event->getHistoricalX(i, h);
@@ -303,14 +302,6 @@
         }
         addMovement(eventTime, idBits, positions);
     }
-
-    eventTime = event->getEventTime();
-    for (size_t i = 0; i < pointerCount; i++) {
-        uint32_t index = pointerIndex[i];
-        positions[index].x = event->getX(i);
-        positions[index].y = event->getY(i);
-    }
-    addMovement(eventTime, idBits, positions);
 }
 
 bool VelocityTracker::getVelocity(uint32_t id, float* outVx, float* outVy) const {