diff options
Diffstat (limited to 'native/src/proximity_info.h')
-rw-r--r-- | native/src/proximity_info.h | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/native/src/proximity_info.h b/native/src/proximity_info.h index 3425efe4e..35e354c6e 100644 --- a/native/src/proximity_info.h +++ b/native/src/proximity_info.h @@ -28,6 +28,8 @@ class Correction; class ProximityInfo { public: static const int NORMALIZED_SQUARED_DISTANCE_SCALING_FACTOR_LOG_2 = 10; + static const int NORMALIZED_SQUARED_DISTANCE_SCALING_FACTOR = + 1 << NORMALIZED_SQUARED_DISTANCE_SCALING_FACTOR_LOG_2; // Used as a return value for character comparison typedef enum { @@ -53,19 +55,20 @@ public: unsigned short getPrimaryCharAt(const int index) const; bool existsCharInProximityAt(const int index, const int c) const; bool existsAdjacentProximityChars(const int index) const; - ProximityType getMatchedProximityId( - const int index, const unsigned short c, const bool checkProximityChars) const; - int getNormalizedSquaredDistance(int index) const { - return mNormalizedSquaredDistance[index]; + ProximityType getMatchedProximityId(const int index, const unsigned short c, + const bool checkProximityChars, int *proximityIndex = NULL) const; + int getNormalizedSquaredDistance(const int inputIndex, const int proximityIndex) const { + return mNormalizedSquaredDistances[inputIndex * MAX_PROXIMITY_CHARS_SIZE + proximityIndex]; } bool sameAsTyped(const unsigned short *word, int length) const; const unsigned short* getPrimaryInputWord() const { return mPrimaryInputWord; } + bool touchPositionCorrectionEnabled() const { + return mTouchPositionCorrectionEnabled; + } private: - static const int NORMALIZED_SQUARED_DISTANCE_SCALING_FACTOR = - 1 << NORMALIZED_SQUARED_DISTANCE_SCALING_FACTOR_LOG_2; // The max number of the keys in one keyboard layout static const int MAX_KEY_COUNT_IN_A_KEYBOARD = 64; // The upper limit of the char code in mCodeToKeyIndex @@ -73,8 +76,15 @@ private: int getStartIndexFromCoordinates(const int x, const int y) const; void initializeCodeToKeyIndex(); - float calculateNormalizedSquaredDistance(int index) const; - float calculateSquaredDistanceFromSweetSpotCenter(int keyIndex, int inputIndex) const; + float calculateNormalizedSquaredDistance(const int keyIndex, const int inputIndex) const; + float calculateSquaredDistanceFromSweetSpotCenter( + const int keyIndex, const int inputIndex) const; + int getKeyIndex(const int c) const; + bool hasSweetSpotData(const int keyIndex) const { + // When there are no calibration data for a key, + // the radius of the key is assigned to zero. + return mSweetSpotRadii[keyIndex] > 0.0; + } const int MAX_PROXIMITY_CHARS_SIZE; const int KEYBOARD_WIDTH; @@ -84,10 +94,13 @@ private: const int CELL_WIDTH; const int CELL_HEIGHT; const int KEY_COUNT; + const bool HAS_TOUCH_POSITION_CORRECTION_DATA; const int *mInputCodes; const int *mInputXCoordinates; const int *mInputYCoordinates; + bool mTouchPositionCorrectionEnabled; uint32_t *mProximityCharsArray; + int *mNormalizedSquaredDistances; int32_t mKeyXCoordinates[MAX_KEY_COUNT_IN_A_KEYBOARD]; int32_t mKeyYCoordinates[MAX_KEY_COUNT_IN_A_KEYBOARD]; int32_t mKeyWidths[MAX_KEY_COUNT_IN_A_KEYBOARD]; @@ -96,7 +109,6 @@ private: float mSweetSpotCenterXs[MAX_KEY_COUNT_IN_A_KEYBOARD]; float mSweetSpotCenterYs[MAX_KEY_COUNT_IN_A_KEYBOARD]; float mSweetSpotRadii[MAX_KEY_COUNT_IN_A_KEYBOARD]; - int mNormalizedSquaredDistance[MAX_WORD_LENGTH_INTERNAL]; int mInputLength; unsigned short mPrimaryInputWord[MAX_WORD_LENGTH_INTERNAL]; int mCodeToKeyIndex[MAX_CHAR_CODE + 1]; |