aboutsummaryrefslogtreecommitdiffstats
path: root/native/src/proximity_info.h
diff options
context:
space:
mode:
authorYusuke Nojima <nojima@google.com>2011-10-05 06:37:34 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2011-10-05 06:37:34 -0700
commit5e458b8e74bbc789b80b4fc567f426cfa5c63426 (patch)
tree4b8de4b71acbda214a89afe5e7f12dc6354e8f00 /native/src/proximity_info.h
parent30d24d8d40cef27240152dfbdea801b2a28552d8 (diff)
parente4ba822cc6959490868fd8868ffad1c4e9b23992 (diff)
downloadlatinime-5e458b8e74bbc789b80b4fc567f426cfa5c63426.tar.gz
latinime-5e458b8e74bbc789b80b4fc567f426cfa5c63426.tar.xz
latinime-5e458b8e74bbc789b80b4fc567f426cfa5c63426.zip
am e4ba822c: Promote touches in hit box according to the distance from sweet spot
* commit 'e4ba822cc6959490868fd8868ffad1c4e9b23992': Promote touches in hit box according to the distance from sweet spot
Diffstat (limited to 'native/src/proximity_info.h')
-rw-r--r--native/src/proximity_info.h30
1 files changed, 11 insertions, 19 deletions
diff --git a/native/src/proximity_info.h b/native/src/proximity_info.h
index 421ca0ef6..3425efe4e 100644
--- a/native/src/proximity_info.h
+++ b/native/src/proximity_info.h
@@ -27,14 +27,12 @@ class Correction;
class ProximityInfo {
public:
+ static const int NORMALIZED_SQUARED_DISTANCE_SCALING_FACTOR_LOG_2 = 10;
+
// Used as a return value for character comparison
typedef enum {
- // Same char, possibly with different case or accent, and in the sweet spot of the char
- EQUIVALENT_CHAR_STRONG,
- // Same char, possibly with different case or accent, and in the outer sweet spot
- EQUIVALENT_CHAR_NORMAL,
- // Same char, possibly with different case or accent, and in the hit box of the char
- EQUIVALENT_CHAR_WEAK,
+ // Same char, possibly with different case or accent
+ EQUIVALENT_CHAR,
// It is a char located nearby on the keyboard
NEAR_PROXIMITY_CHAR,
// It is an unrelated char
@@ -57,31 +55,25 @@ public:
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];
+ }
bool sameAsTyped(const unsigned short *word, int length) const;
const unsigned short* getPrimaryInputWord() const {
return mPrimaryInputWord;
}
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
static const int MAX_CHAR_CODE = 127;
- typedef enum {
- // cannot figure out the sweet spot type
- UNKNOWN,
- // touch position is out of neutral area of the given char
- OUT_OF_NEUTRAL_AREA,
- // touch position is in the neutral area of the given char
- IN_NEUTRAL_AREA,
- // touch position is in the sweet spot of the given char
- IN_SWEET_SPOT
- } SweetSpotType;
-
int getStartIndexFromCoordinates(const int x, const int y) const;
void initializeCodeToKeyIndex();
- SweetSpotType calculateSweetSpotType(int index) const;
+ float calculateNormalizedSquaredDistance(int index) const;
float calculateSquaredDistanceFromSweetSpotCenter(int keyIndex, int inputIndex) const;
const int MAX_PROXIMITY_CHARS_SIZE;
@@ -104,7 +96,7 @@ 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];
- SweetSpotType mSweetSpotTypes[MAX_WORD_LENGTH_INTERNAL];
+ int mNormalizedSquaredDistance[MAX_WORD_LENGTH_INTERNAL];
int mInputLength;
unsigned short mPrimaryInputWord[MAX_WORD_LENGTH_INTERNAL];
int mCodeToKeyIndex[MAX_CHAR_CODE + 1];