am 28661069: Using relative speed instead of duration rate for gesture input distance calculation.

* commit '28661069591fd1d6a8e25981aaade2e5d8b20b9a':
  Using relative speed instead of duration rate for gesture input distance calculation.
main
Keisuke Kuroyanagi 2012-09-24 08:45:34 -07:00 committed by Android Git Automerger
commit ae096e803a
2 changed files with 37 additions and 10 deletions

View File

@ -104,6 +104,7 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi
mLengthCache.clear();
mDistanceCache.clear();
mNearKeysVector.clear();
mRelativeSpeeds.clear();
}
if (DEBUG_GEO_FULL) {
AKLOGI("Init ProximityInfoState: reused points = %d, last input size = %d",
@ -159,6 +160,36 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi
mInputSize = mInputXs.size();
}
if (mInputSize > 0 && isGeometric) {
int sumDuration = mTimes.back() - mTimes.front();
int sumLength = mLengthCache.back() - mLengthCache.front();
float averageSpeed = static_cast<float>(sumLength) / static_cast<float>(sumDuration);
mRelativeSpeeds.resize(mInputSize);
for (int i = lastSavedInputSize; i < mInputSize; ++i) {
const int index = mInputIndice[i];
int length = 0;
int duration = 0;
if (index == 0 && index < inputSize - 1) {
length = getDistanceInt(xCoordinates[index], yCoordinates[index],
xCoordinates[index + 1], yCoordinates[index + 1]);
duration = times[index + 1] - times[index];
} else if (index == inputSize - 1 && index > 0) {
length = getDistanceInt(xCoordinates[index - 1], yCoordinates[index - 1],
xCoordinates[index], yCoordinates[index]);
duration = times[index] - times[index - 1];
} else if (0 < index && index < inputSize - 1) {
length = getDistanceInt(xCoordinates[index - 1], yCoordinates[index - 1],
xCoordinates[index + 1], yCoordinates[index + 1]);
duration = times[index + 1] - times[index - 1];
} else {
length = 0;
duration = 1;
}
const float speed = static_cast<float>(length) / static_cast<float>(duration);
mRelativeSpeeds[i] = speed / averageSpeed;
}
}
if (mInputSize > 0) {
const int keyCount = mProximityInfo->getKeyCount();
mNearKeysVector.resize(mInputSize);
@ -464,7 +495,7 @@ float ProximityInfoState::calculateNormalizedSquaredDistance(
}
int ProximityInfoState::getDuration(const int index) const {
if (mInputSize > 0 && index >= 0 && index < mInputSize - 1) {
if (index >= 0 && index < mInputSize - 1) {
return mTimes[index + 1] - mTimes[index];
}
return 0;
@ -524,13 +555,6 @@ int32_t ProximityInfoState::getAllPossibleChars(
return newFilterSize;
}
float ProximityInfoState::getAveragePointDuration() const {
if (mInputSize == 0) {
return 0.0f;
}
return static_cast<float>(mTimes[mInputSize - 1] - mTimes[0]) / static_cast<float>(mInputSize);
}
void ProximityInfoState::popInputData() {
mInputXs.pop_back();
mInputYs.pop_back();

View File

@ -55,7 +55,7 @@ class ProximityInfoState {
mHasTouchPositionCorrectionData(false), mMostCommonKeyWidthSquare(0), mLocaleStr(),
mKeyCount(0), mCellHeight(0), mCellWidth(0), mGridHeight(0), mGridWidth(0),
mIsContinuationPossible(false), mInputXs(), mInputYs(), mTimes(), mInputIndice(),
mDistanceCache(), mLengthCache(), mNearKeysVector(),
mDistanceCache(), mLengthCache(), mRelativeSpeeds(), mNearKeysVector(),
mTouchPositionCorrectionEnabled(false), mInputSize(0) {
memset(mInputCodes, 0, sizeof(mInputCodes));
memset(mNormalizedSquaredDistances, 0, sizeof(mNormalizedSquaredDistances));
@ -220,7 +220,9 @@ class ProximityInfoState {
int32_t getAllPossibleChars(
const size_t startIndex, int32_t *const filter, const int32_t filterSize) const;
float getAveragePointDuration() const;
float getRelativeSpeed(const int index) const {
return mRelativeSpeeds[index];
}
private:
DISALLOW_COPY_AND_ASSIGN(ProximityInfoState);
typedef hash_map_compat<int, float> NearKeysDistanceMap;
@ -283,6 +285,7 @@ class ProximityInfoState {
std::vector<int> mInputIndice;
std::vector<float> mDistanceCache;
std::vector<int> mLengthCache;
std::vector<float> mRelativeSpeeds;
std::vector<NearKeycodesSet> mNearKeysVector;
bool mTouchPositionCorrectionEnabled;
int32_t mInputCodes[MAX_PROXIMITY_CHARS_SIZE_INTERNAL * MAX_WORD_LENGTH_INTERNAL];