+private:
+
+ // Struct to keep pairs of local and screen data together.
+ // TODO: This can encapsulate some functionality also.
+ typedef struct
+ {
+ Vector2 local;
+ Vector2 screen;
+ } RelativeVectors;
+
+ /**
+ * Houses new code to process input events and generate an output point.
+ *
+ * @param[in] lastVSyncTime The time of the last render (in milliseconds)
+ * @param[in] nextVSyncTime The estimated time of the next render (in milliseconds)
+ */
+ bool NewAlgorithm( unsigned int lastVSyncTime, unsigned int nextVSyncTime );
+
+ /**
+ * Gets the (absolute) time difference between two times.
+ * This is limited by minimumDelta, so it can be safe to use as a divisor.
+ * This function is wrapped so that the behviour can be overridden to return a "perfect" time difference (overrideDifference).
+ *
+ * @param[in] timeA The first time to calculate from
+ * @param[in] timeB The second time to calculate from
+ * @param[in] minimumDelta The smallest amount the difference can become
+ * @param[in] overrideDifference The time difference to return if using perfect times
+ */
+ inline float GetDivisibleTimeDifference( int timeA, int timeB, float minimumDelta, float overrideDifference );
+
+ /**
+ * This limits the change currentAcceleration can have over lastAcceleration by the specified changeLimit value.
+ *
+ * @param[in] currentAcceleration The acceleration to modify
+ * @param[in] lastAcceleration The acceleration to limit against
+ * @param[in] changeLimit The maximum change (in either direction)
+ */
+ void LimitAccelerationChange( RelativeVectors& currentAcceleration, RelativeVectors& lastAcceleration, float changeLimit );
+
+ /**
+ * Reads all events received this frame into a linear buffer.
+ * A lock is held while this is done.
+ */
+ unsigned int ReadFrameEvents();
+
+ /**
+ * Converts between input rate and internal rate (typically 60Hz internally).
+ * Also writes to the pan history container.
+ * TODO: Does not need to return the gesture if it is in the history also, but currently it's used.
+ * (if rate conversion does not generate a point there are points still in history, but this can been done with a bool property).
+ *
+ * @param[out] rateConvertedGesture Result gesture for this frame is writen here.
+ * @param[in] eventsThisFrame Number of events to convert
+ * @param[in] currentFrameTime Time of the frame we will render to
+ * @param[in] lastFrameTime Time of the last rendered frame
+ * @param[out] justStarted Set to true if we are now starting a new gesture
+ * @param[out] justFinished Set to true if we are now finishing a gesture
+ */
+ bool InputRateConversion( PanInfo& rateConvertedGesture, unsigned int eventsThisFrame,
+ unsigned int currentFrameTime, unsigned int lastFrameTime, bool& justStarted, bool& justFinished );
+
+ /**
+ * Generates an interpolated point at the specified point in time.
+ *
+ * @param[in] history of points to use
+ * @param[in] currentTime Time of the frame we will render to
+ * @param[in] targetTime Time of the point to generate
+ * @param[in] range Range of time (each side of target time) to use points from
+ * @param[out] outPoint Generated point
+ * @param[out] acceleration Generated acceleration
+ * @param[in] outputTimeGranularity Time difference between output point (typically 60Hz)
+ * @param[in] eraseUnused Set to true to clean up any history not used by the function
+ */
+ bool InterpolatePoint( PanInfoHistory& history, unsigned int currentTime, unsigned int targetTime, unsigned int range,
+ PanInfo& outPoint, RelativeVectors& acceleration, int outputTimeGranularity, bool eraseUnused );
+
+ /**
+ * Predicts a point in the future, based on the supplied point and acceleration.
+ * Other user configuration settings are considered.
+ *
+ * @param[in] startPoint Starting point to use. Position and velocity are taken from here.
+ * @param[in] accelerationToUse The acceleration to use.
+ * @param[out] predictedPoint Generated predicted point
+ * @param[in] currentFrameTime Time of the frame we will render to
+ * @param[in] previousFrameTime Time of the last rendered frame
+ * @param[in] noPreviousData Set to true if we are just starting a gesture
+ */
+ void PredictionMode2( PanInfo& startPoint, RelativeVectors& accelerationToUse,
+ PanInfo& predictedPoint, unsigned int currentFrameTime, unsigned int previousFrameTime, bool noPreviousData );
+
+private:
+