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

* commit 'fe46f57cff6aafb88a65a210f31dc801925f49ba':
  Use touch position correction in the geometric input
main
Satoshi Kataoka 2012-09-24 20:30:54 -07:00 committed by Android Git Automerger
commit 9a565f5afd
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); 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 int keyId, const int x, const int y) const {
const float centerX = static_cast<float>(getKeyCenterXOfKeyIdG(keyId)); const static float verticalSweetSpotScaleForGeometric = 1.1f;
const float centerY = static_cast<float>(getKeyCenterYOfKeyIdG(keyId)); 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 touchX = static_cast<float>(x);
const float touchY = static_cast<float>(y); const float touchY = static_cast<float>(y);
const float keyWidth = static_cast<float>(getMostCommonKeyWidth()); const float keyWidth = static_cast<float>(getMostCommonKeyWidth());

View File

@ -44,7 +44,7 @@ class ProximityInfo {
~ProximityInfo(); ~ProximityInfo();
bool hasSpaceProximity(const int x, const int y) const; bool hasSpaceProximity(const int x, const int y) const;
int getNormalizedSquaredDistance(const int inputIndex, const int proximityIndex) const; int getNormalizedSquaredDistance(const int inputIndex, const int proximityIndex) const;
float getNormalizedSquaredDistanceFromCenterFloat( float getNormalizedSquaredDistanceFromCenterFloatG(
const int keyId, const int x, const int y) const; const int keyId, const int x, const int y) const;
bool sameAsTyped(const unsigned short *word, int length) const; bool sameAsTyped(const unsigned short *word, int length) const;
int getKeyIndexOf(const int c) const; int getKeyIndexOf(const int c) const;
@ -123,8 +123,6 @@ class ProximityInfo {
int getStartIndexFromCoordinates(const int x, const int y) const; int getStartIndexFromCoordinates(const int x, const int y) const;
void initializeG(); void initializeG();
float calculateNormalizedSquaredDistance(const int keyIndex, const int inputIndex) const; float calculateNormalizedSquaredDistance(const int keyIndex, const int inputIndex) const;
float calculateSquaredDistanceFromSweetSpotCenter(
const int keyIndex, const int inputIndex) const;
bool hasInputCoordinates() const; bool hasInputCoordinates() const;
int squaredDistanceToEdge(const int keyId, const int x, const int y) 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 { 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 x = mInputXs[i];
const int y = mInputYs[i]; const int y = mInputYs[i];
const float normalizedSquaredDistance = const float normalizedSquaredDistance =
mProximityInfo->getNormalizedSquaredDistanceFromCenterFloat(k, x, y); mProximityInfo->getNormalizedSquaredDistanceFromCenterFloatG(k, x, y);
mDistanceCache[index] = normalizedSquaredDistance; mDistanceCache[index] = normalizedSquaredDistance;
if (normalizedSquaredDistance < NEAR_KEY_NORMALIZED_SQUARED_THRESHOLD) { if (normalizedSquaredDistance < NEAR_KEY_NORMALIZED_SQUARED_THRESHOLD) {
mNearKeysVector[i].set(k, 1); 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(mNormalizedSquaredDistances, NOT_A_DISTANCE, sizeof(mNormalizedSquaredDistances));
memset(mPrimaryInputWord, 0, sizeof(mPrimaryInputWord)); memset(mPrimaryInputWord, 0, sizeof(mPrimaryInputWord));
mTouchPositionCorrectionEnabled = mInputSize > 0 && mHasTouchPositionCorrectionData mTouchPositionCorrectionEnabled = mInputSize > 0 && mHasTouchPositionCorrectionData
&& xCoordinates && yCoordinates && !isGeometric; && xCoordinates && yCoordinates;
if (!isGeometric && pointerId == 0) { if (!isGeometric && pointerId == 0) {
for (int i = 0; i < inputSize; ++i) { for (int i = 0; i < inputSize; ++i) {
mPrimaryInputWord[i] = getPrimaryCharAt(i); mPrimaryInputWord[i] = getPrimaryCharAt(i);
@ -298,7 +298,7 @@ float ProximityInfoState::updateNearKeysDistances(const int x, const int y,
const int keyCount = mProximityInfo->getKeyCount(); const int keyCount = mProximityInfo->getKeyCount();
float nearestKeyDistance = mMaxPointToKeyLength; float nearestKeyDistance = mMaxPointToKeyLength;
for (int k = 0; k < keyCount; ++k) { 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) { if (dist < NEAR_KEY_THRESHOLD) {
currentNearKeysDistances->insert(std::pair<int, float>(k, dist)); currentNearKeysDistances->insert(std::pair<int, float>(k, dist));
} }