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

* commit 'f1872aaf56e00fb2fb857b4d50f86d41df232959':
  Using relative speed instead of duration rate for gesture input distance calculation.
main
Keisuke Kuroyanagi 2012-09-24 09:36:39 -07:00 committed by Android Git Automerger
commit dba90e0e6e
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(); mLengthCache.clear();
mDistanceCache.clear(); mDistanceCache.clear();
mNearKeysVector.clear(); mNearKeysVector.clear();
mRelativeSpeeds.clear();
} }
if (DEBUG_GEO_FULL) { if (DEBUG_GEO_FULL) {
AKLOGI("Init ProximityInfoState: reused points = %d, last input size = %d", 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(); 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) { if (mInputSize > 0) {
const int keyCount = mProximityInfo->getKeyCount(); const int keyCount = mProximityInfo->getKeyCount();
mNearKeysVector.resize(mInputSize); mNearKeysVector.resize(mInputSize);
@ -464,7 +495,7 @@ float ProximityInfoState::calculateNormalizedSquaredDistance(
} }
int ProximityInfoState::getDuration(const int index) const { 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 mTimes[index + 1] - mTimes[index];
} }
return 0; return 0;
@ -524,13 +555,6 @@ int32_t ProximityInfoState::getAllPossibleChars(
return newFilterSize; 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() { void ProximityInfoState::popInputData() {
mInputXs.pop_back(); mInputXs.pop_back();
mInputYs.pop_back(); mInputYs.pop_back();

View File

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