am 089c7d43: Merge "Use touch position correction in the geometric input" into jb-mr1-dev

* commit '089c7d43c7a81dc862212c91b14bac7d2294da51':
  Use touch position correction in the geometric input
main
Satoshi Kataoka 2012-09-24 20:29:15 -07:00 committed by Android Git Automerger
commit fe46f57cff
3 changed files with 19 additions and 9 deletions

View File

@ -134,10 +134,22 @@ static inline float getNormalizedSquaredDistanceFloat(float x1, float y1, float
return (SQUARE_FLOAT(deltaX) + SQUARE_FLOAT(deltaY)) / SQUARE_FLOAT(scale);
}
float ProximityInfo::getNormalizedSquaredDistanceFromCenterFloat(
float ProximityInfo::getNormalizedSquaredDistanceFromCenterFloatG(
const int keyId, const int x, const int y) const {
const float centerX = static_cast<float>(getKeyCenterXOfKeyIdG(keyId));
const float centerY = static_cast<float>(getKeyCenterYOfKeyIdG(keyId));
const static float verticalSweetSpotScaleForGeometric = 1.1f;
const bool correctTouchPosition = hasTouchPositionCorrectionData();
const float centerX = static_cast<float>(correctTouchPosition
? getSweetSpotCenterXAt(keyId)
: getKeyCenterXOfKeyIdG(keyId));
const float visualKeyCenterY = static_cast<float>(getKeyCenterYOfKeyIdG(keyId));
float centerY;
if (correctTouchPosition) {
const float sweetSpotCenterY = static_cast<float>(getSweetSpotCenterYAt(keyId));
const float gapY = sweetSpotCenterY - visualKeyCenterY;
centerY = visualKeyCenterY + gapY * verticalSweetSpotScaleForGeometric;
} else {
centerY = visualKeyCenterY;
}
const float touchX = static_cast<float>(x);
const float touchY = static_cast<float>(y);
const float keyWidth = static_cast<float>(getMostCommonKeyWidth());

View File

@ -44,7 +44,7 @@ class ProximityInfo {
~ProximityInfo();
bool hasSpaceProximity(const int x, const int y) const;
int getNormalizedSquaredDistance(const int inputIndex, const int proximityIndex) const;
float getNormalizedSquaredDistanceFromCenterFloat(
float getNormalizedSquaredDistanceFromCenterFloatG(
const int keyId, const int x, const int y) const;
bool sameAsTyped(const unsigned short *word, int length) const;
int getKeyIndexOf(const int c) const;
@ -123,8 +123,6 @@ class ProximityInfo {
int getStartIndexFromCoordinates(const int x, const int y) const;
void initializeG();
float calculateNormalizedSquaredDistance(const int keyIndex, const int inputIndex) const;
float calculateSquaredDistanceFromSweetSpotCenter(
const int keyIndex, const int inputIndex) const;
bool hasInputCoordinates() const;
int squaredDistanceToEdge(const int keyId, const int x, const int y) const;
bool isOnKey(const int keyId, const int x, const int y) const {

View File

@ -202,7 +202,7 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi
const int x = mInputXs[i];
const int y = mInputYs[i];
const float normalizedSquaredDistance =
mProximityInfo->getNormalizedSquaredDistanceFromCenterFloat(k, x, y);
mProximityInfo->getNormalizedSquaredDistanceFromCenterFloatG(k, x, y);
mDistanceCache[index] = normalizedSquaredDistance;
if (normalizedSquaredDistance < NEAR_KEY_NORMALIZED_SQUARED_THRESHOLD) {
mNearKeysVector[i].set(k, 1);
@ -234,7 +234,7 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi
memset(mNormalizedSquaredDistances, NOT_A_DISTANCE, sizeof(mNormalizedSquaredDistances));
memset(mPrimaryInputWord, 0, sizeof(mPrimaryInputWord));
mTouchPositionCorrectionEnabled = mInputSize > 0 && mHasTouchPositionCorrectionData
&& xCoordinates && yCoordinates && !isGeometric;
&& xCoordinates && yCoordinates;
if (!isGeometric && pointerId == 0) {
for (int i = 0; i < inputSize; ++i) {
mPrimaryInputWord[i] = getPrimaryCharAt(i);
@ -298,7 +298,7 @@ float ProximityInfoState::updateNearKeysDistances(const int x, const int y,
const int keyCount = mProximityInfo->getKeyCount();
float nearestKeyDistance = mMaxPointToKeyLength;
for (int k = 0; k < keyCount; ++k) {
const float dist = mProximityInfo->getNormalizedSquaredDistanceFromCenterFloat(k, x, y);
const float dist = mProximityInfo->getNormalizedSquaredDistanceFromCenterFloatG(k, x, y);
if (dist < NEAR_KEY_THRESHOLD) {
currentNearKeysDistances->insert(std::pair<int, float>(k, dist));
}