am c7401068: am 0a4692ef: Merge "Step 39-A Cleanup proximity_info_state" into jb-mr1-dev
* commit 'c740106854e5d688d8238fb8464e4a3c4ce89567': Step 39-A Cleanup proximity_info_statemain
commit
c2fa66ba40
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
void ProximityInfoState::initInputParams(const int pointerId, const float maxPointToKeyLength,
|
void ProximityInfoState::initInputParams(const int pointerId, const float maxPointToKeyLength,
|
||||||
const ProximityInfo *proximityInfo, const int32_t *inputCodes, const int inputSize,
|
const ProximityInfo *proximityInfo, const int32_t *const inputCodes, const int inputSize,
|
||||||
const int *const xCoordinates, const int *const yCoordinates, const int *const times,
|
const int *const xCoordinates, const int *const yCoordinates, const int *const times,
|
||||||
const int *const pointerIds, const bool isGeometric) {
|
const int *const pointerIds, const bool isGeometric) {
|
||||||
mProximityInfo = proximityInfo;
|
mProximityInfo = proximityInfo;
|
||||||
|
@ -38,39 +38,39 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi
|
||||||
mCellWidth = proximityInfo->getCellWidth();
|
mCellWidth = proximityInfo->getCellWidth();
|
||||||
mGridHeight = proximityInfo->getGridWidth();
|
mGridHeight = proximityInfo->getGridWidth();
|
||||||
mGridWidth = proximityInfo->getGridHeight();
|
mGridWidth = proximityInfo->getGridHeight();
|
||||||
const int normalizedSquaredDistancesLength =
|
|
||||||
MAX_PROXIMITY_CHARS_SIZE_INTERNAL * MAX_WORD_LENGTH_INTERNAL;
|
|
||||||
for (int i = 0; i < normalizedSquaredDistancesLength; ++i) {
|
|
||||||
mNormalizedSquaredDistances[i] = NOT_A_DISTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(mInputCodes, 0,
|
memset(mInputCodes, 0, sizeof(mInputCodes));
|
||||||
MAX_WORD_LENGTH_INTERNAL * MAX_PROXIMITY_CHARS_SIZE_INTERNAL * sizeof(mInputCodes[0]));
|
|
||||||
|
|
||||||
for (int i = 0; i < inputSize; ++i) {
|
if (!isGeometric && pointerId == 0) {
|
||||||
const int32_t primaryKey = inputCodes[i];
|
// Initialize
|
||||||
const int x = xCoordinates[i];
|
// - mInputCodes
|
||||||
const int y = yCoordinates[i];
|
// - mNormalizedSquaredDistances
|
||||||
int *proximities = &mInputCodes[i * MAX_PROXIMITY_CHARS_SIZE_INTERNAL];
|
// TODO: Merge
|
||||||
mProximityInfo->calculateNearbyKeyCodes(x, y, primaryKey, proximities);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DEBUG_PROXIMITY_CHARS) {
|
|
||||||
for (int i = 0; i < inputSize; ++i) {
|
for (int i = 0; i < inputSize; ++i) {
|
||||||
AKLOGI("---");
|
const int32_t primaryKey = inputCodes[i];
|
||||||
for (int j = 0; j < MAX_PROXIMITY_CHARS_SIZE_INTERNAL; ++j) {
|
const int x = xCoordinates[i];
|
||||||
int icc = mInputCodes[i * MAX_PROXIMITY_CHARS_SIZE_INTERNAL + j];
|
const int y = yCoordinates[i];
|
||||||
int icfjc = inputCodes[i * MAX_PROXIMITY_CHARS_SIZE_INTERNAL + j];
|
int *proximities = &mInputCodes[i * MAX_PROXIMITY_CHARS_SIZE_INTERNAL];
|
||||||
icc += 0;
|
mProximityInfo->calculateNearbyKeyCodes(x, y, primaryKey, proximities);
|
||||||
icfjc += 0;
|
}
|
||||||
AKLOGI("--- (%d)%c,%c", i, icc, icfjc); AKLOGI("--- A<%d>,B<%d>", icc, icfjc);
|
|
||||||
|
if (DEBUG_PROXIMITY_CHARS) {
|
||||||
|
for (int i = 0; i < inputSize; ++i) {
|
||||||
|
AKLOGI("---");
|
||||||
|
for (int j = 0; j < MAX_PROXIMITY_CHARS_SIZE_INTERNAL; ++j) {
|
||||||
|
int icc = mInputCodes[i * MAX_PROXIMITY_CHARS_SIZE_INTERNAL + j];
|
||||||
|
int icfjc = inputCodes[i * MAX_PROXIMITY_CHARS_SIZE_INTERNAL + j];
|
||||||
|
icc += 0;
|
||||||
|
icfjc += 0;
|
||||||
|
AKLOGI("--- (%d)%c,%c", i, icc, icfjc); AKLOGI("--- A<%d>,B<%d>", icc, icfjc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mMaxPointToKeyLength = maxPointToKeyLength;
|
|
||||||
///////////////////////
|
///////////////////////
|
||||||
// Setup touch points
|
// Setup touch points
|
||||||
|
mMaxPointToKeyLength = maxPointToKeyLength;
|
||||||
mInputXs.clear();
|
mInputXs.clear();
|
||||||
mInputYs.clear();
|
mInputYs.clear();
|
||||||
mTimes.clear();
|
mTimes.clear();
|
||||||
|
@ -81,10 +81,10 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi
|
||||||
if (xCoordinates && yCoordinates) {
|
if (xCoordinates && yCoordinates) {
|
||||||
const bool proximityOnly = !isGeometric && (xCoordinates[0] < 0 || yCoordinates[0] < 0);
|
const bool proximityOnly = !isGeometric && (xCoordinates[0] < 0 || yCoordinates[0] < 0);
|
||||||
for (int i = 0; i < inputSize; ++i) {
|
for (int i = 0; i < inputSize; ++i) {
|
||||||
++mInputSize;
|
|
||||||
// Assuming pointerId == 0 if pointerIds is null.
|
// Assuming pointerId == 0 if pointerIds is null.
|
||||||
const int pid = pointerIds ? pointerIds[i] : 0;
|
const int pid = pointerIds ? pointerIds[i] : 0;
|
||||||
if (pointerId == pid) {
|
if (pointerId == pid) {
|
||||||
|
++mInputSize;
|
||||||
const int c = isGeometric ? NOT_A_COORDINATE : getPrimaryCharAt(i);
|
const int c = isGeometric ? NOT_A_COORDINATE : getPrimaryCharAt(i);
|
||||||
const int x = proximityOnly ? NOT_A_COORDINATE : xCoordinates[i];
|
const int x = proximityOnly ? NOT_A_COORDINATE : xCoordinates[i];
|
||||||
const int y = proximityOnly ? NOT_A_COORDINATE : yCoordinates[i];
|
const int y = proximityOnly ? NOT_A_COORDINATE : yCoordinates[i];
|
||||||
|
@ -107,42 +107,46 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// end
|
// end
|
||||||
///////////////////////
|
///////////////////////
|
||||||
|
|
||||||
for (int i = 0; i < inputSize; ++i) {
|
memset(mNormalizedSquaredDistances, NOT_A_DISTANCE, sizeof(mNormalizedSquaredDistances));
|
||||||
mPrimaryInputWord[i] = getPrimaryCharAt(i);
|
memset(mPrimaryInputWord, 0, sizeof(mPrimaryInputWord));
|
||||||
}
|
|
||||||
mPrimaryInputWord[inputSize] = 0;
|
|
||||||
|
|
||||||
mTouchPositionCorrectionEnabled = mInputSize > 0 && mHasTouchPositionCorrectionData
|
mTouchPositionCorrectionEnabled = mInputSize > 0 && mHasTouchPositionCorrectionData
|
||||||
&& xCoordinates && yCoordinates && !isGeometric;
|
&& xCoordinates && yCoordinates && !isGeometric;
|
||||||
for (int i = 0; i < mInputSize && mTouchPositionCorrectionEnabled; ++i) {
|
if (!isGeometric && pointerId == 0) {
|
||||||
const int *proximityChars = getProximityCharsAt(i);
|
for (int i = 0; i < inputSize; ++i) {
|
||||||
const int primaryKey = proximityChars[0];
|
mPrimaryInputWord[i] = getPrimaryCharAt(i);
|
||||||
const int x = xCoordinates[i];
|
|
||||||
const int y = yCoordinates[i];
|
|
||||||
if (DEBUG_PROXIMITY_CHARS) {
|
|
||||||
int a = x + y + primaryKey;
|
|
||||||
a += 0;
|
|
||||||
AKLOGI("--- Primary = %c, x = %d, y = %d", primaryKey, x, y);
|
|
||||||
}
|
}
|
||||||
for (int j = 0; j < MAX_PROXIMITY_CHARS_SIZE_INTERNAL && proximityChars[j] > 0; ++j) {
|
|
||||||
const int currentChar = proximityChars[j];
|
for (int i = 0; i < mInputSize && mTouchPositionCorrectionEnabled; ++i) {
|
||||||
const float squaredDistance =
|
const int *proximityChars = getProximityCharsAt(i);
|
||||||
hasInputCoordinates() ? calculateNormalizedSquaredDistance(
|
const int primaryKey = proximityChars[0];
|
||||||
mProximityInfo->getKeyIndex(currentChar), i) :
|
const int x = xCoordinates[i];
|
||||||
NOT_A_DISTANCE_FLOAT;
|
const int y = yCoordinates[i];
|
||||||
if (squaredDistance >= 0.0f) {
|
|
||||||
mNormalizedSquaredDistances[i * MAX_PROXIMITY_CHARS_SIZE_INTERNAL + j] =
|
|
||||||
(int) (squaredDistance * NORMALIZED_SQUARED_DISTANCE_SCALING_FACTOR);
|
|
||||||
} else {
|
|
||||||
mNormalizedSquaredDistances[i * MAX_PROXIMITY_CHARS_SIZE_INTERNAL + j] =
|
|
||||||
(j == 0) ? EQUIVALENT_CHAR_WITHOUT_DISTANCE_INFO :
|
|
||||||
PROXIMITY_CHAR_WITHOUT_DISTANCE_INFO;
|
|
||||||
}
|
|
||||||
if (DEBUG_PROXIMITY_CHARS) {
|
if (DEBUG_PROXIMITY_CHARS) {
|
||||||
AKLOGI("--- Proximity (%d) = %c", j, currentChar);
|
int a = x + y + primaryKey;
|
||||||
|
a += 0;
|
||||||
|
AKLOGI("--- Primary = %c, x = %d, y = %d", primaryKey, x, y);
|
||||||
|
}
|
||||||
|
for (int j = 0; j < MAX_PROXIMITY_CHARS_SIZE_INTERNAL && proximityChars[j] > 0; ++j) {
|
||||||
|
const int currentChar = proximityChars[j];
|
||||||
|
const float squaredDistance =
|
||||||
|
hasInputCoordinates() ? calculateNormalizedSquaredDistance(
|
||||||
|
mProximityInfo->getKeyIndex(currentChar), i) :
|
||||||
|
NOT_A_DISTANCE_FLOAT;
|
||||||
|
if (squaredDistance >= 0.0f) {
|
||||||
|
mNormalizedSquaredDistances[i * MAX_PROXIMITY_CHARS_SIZE_INTERNAL + j] =
|
||||||
|
(int) (squaredDistance * NORMALIZED_SQUARED_DISTANCE_SCALING_FACTOR);
|
||||||
|
} else {
|
||||||
|
mNormalizedSquaredDistances[i * MAX_PROXIMITY_CHARS_SIZE_INTERNAL + j] =
|
||||||
|
(j == 0) ? EQUIVALENT_CHAR_WITHOUT_DISTANCE_INFO :
|
||||||
|
PROXIMITY_CHAR_WITHOUT_DISTANCE_INFO;
|
||||||
|
}
|
||||||
|
if (DEBUG_PROXIMITY_CHARS) {
|
||||||
|
AKLOGI("--- Proximity (%d) = %c", j, currentChar);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,9 +42,9 @@ class ProximityInfoState {
|
||||||
// Defined in proximity_info_state.cpp //
|
// Defined in proximity_info_state.cpp //
|
||||||
/////////////////////////////////////////
|
/////////////////////////////////////////
|
||||||
void initInputParams(const int pointerId, const float maxPointToKeyLength,
|
void initInputParams(const int pointerId, const float maxPointToKeyLength,
|
||||||
const ProximityInfo *proximityInfo, const int32_t *inputCodes, const int inputSize,
|
const ProximityInfo *proximityInfo, const int32_t *const inputCodes,
|
||||||
const int *xCoordinates, const int *yCoordinates, const int *const times,
|
const int inputSize, const int *xCoordinates, const int *yCoordinates,
|
||||||
const int *const pointerIds, const bool isGeometric);
|
const int *const times, const int *const pointerIds, const bool isGeometric);
|
||||||
|
|
||||||
/////////////////////////////////////////
|
/////////////////////////////////////////
|
||||||
// Defined here //
|
// Defined here //
|
||||||
|
|
Loading…
Reference in New Issue