mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Use additional proximity chars in the native code
Bug: 4343280 Change-Id: Ida690fe246cea80a82fcdb3ad0c28e2907b882ac
This commit is contained in:
parent
552c3c27f0
commit
5eec574cf0
@ -47,7 +47,8 @@ static jlong latinime_Keyboard_setProximityInfo(JNIEnv *env, jobject object,
|
|||||||
jfloat *sweetSpotCenterXs = safeGetFloatArrayElements(env, sweetSpotCenterXArray);
|
jfloat *sweetSpotCenterXs = safeGetFloatArrayElements(env, sweetSpotCenterXArray);
|
||||||
jfloat *sweetSpotCenterYs = safeGetFloatArrayElements(env, sweetSpotCenterYArray);
|
jfloat *sweetSpotCenterYs = safeGetFloatArrayElements(env, sweetSpotCenterYArray);
|
||||||
jfloat *sweetSpotRadii = safeGetFloatArrayElements(env, sweetSpotRadiusArray);
|
jfloat *sweetSpotRadii = safeGetFloatArrayElements(env, sweetSpotRadiusArray);
|
||||||
ProximityInfo *proximityInfo = new ProximityInfo(localeStr, maxProximityCharsSize, displayWidth,
|
ProximityInfo *proximityInfo = new ProximityInfo(
|
||||||
|
localeStr, maxProximityCharsSize, displayWidth,
|
||||||
displayHeight, gridWidth, gridHeight, mostCommonkeyWidth,
|
displayHeight, gridWidth, gridHeight, mostCommonkeyWidth,
|
||||||
(const uint32_t*)proximityChars,
|
(const uint32_t*)proximityChars,
|
||||||
keyCount, (const int32_t*)keyXCoordinates, (const int32_t*)keyYCoordinates,
|
keyCount, (const int32_t*)keyXCoordinates, (const int32_t*)keyYCoordinates,
|
||||||
|
@ -19,23 +19,23 @@
|
|||||||
namespace latinime {
|
namespace latinime {
|
||||||
const std::string AdditionalProximityChars::LOCALE_EN_US("en");
|
const std::string AdditionalProximityChars::LOCALE_EN_US("en");
|
||||||
|
|
||||||
const uint16_t AdditionalProximityChars::EN_US_ADDITIONAL_A[EN_US_ADDITIONAL_A_SIZE] = {
|
const uint32_t AdditionalProximityChars::EN_US_ADDITIONAL_A[EN_US_ADDITIONAL_A_SIZE] = {
|
||||||
'e', 'i', 'o', 'u'
|
'e', 'i', 'o', 'u'
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint16_t AdditionalProximityChars::EN_US_ADDITIONAL_E[EN_US_ADDITIONAL_E_SIZE] = {
|
const uint32_t AdditionalProximityChars::EN_US_ADDITIONAL_E[EN_US_ADDITIONAL_E_SIZE] = {
|
||||||
'a', 'i', 'o', 'u'
|
'a', 'i', 'o', 'u'
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint16_t AdditionalProximityChars::EN_US_ADDITIONAL_I[EN_US_ADDITIONAL_I_SIZE] = {
|
const uint32_t AdditionalProximityChars::EN_US_ADDITIONAL_I[EN_US_ADDITIONAL_I_SIZE] = {
|
||||||
'a', 'e', 'o', 'u'
|
'a', 'e', 'o', 'u'
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint16_t AdditionalProximityChars::EN_US_ADDITIONAL_O[EN_US_ADDITIONAL_O_SIZE] = {
|
const uint32_t AdditionalProximityChars::EN_US_ADDITIONAL_O[EN_US_ADDITIONAL_O_SIZE] = {
|
||||||
'a', 'e', 'i', 'u'
|
'a', 'e', 'i', 'u'
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint16_t AdditionalProximityChars::EN_US_ADDITIONAL_U[EN_US_ADDITIONAL_U_SIZE] = {
|
const uint32_t AdditionalProximityChars::EN_US_ADDITIONAL_U[EN_US_ADDITIONAL_U_SIZE] = {
|
||||||
'a', 'e', 'i', 'o'
|
'a', 'e', 'i', 'o'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -26,23 +26,23 @@ class AdditionalProximityChars {
|
|||||||
private:
|
private:
|
||||||
static const std::string LOCALE_EN_US;
|
static const std::string LOCALE_EN_US;
|
||||||
static const int EN_US_ADDITIONAL_A_SIZE = 4;
|
static const int EN_US_ADDITIONAL_A_SIZE = 4;
|
||||||
static const uint16_t EN_US_ADDITIONAL_A[];
|
static const uint32_t EN_US_ADDITIONAL_A[];
|
||||||
static const int EN_US_ADDITIONAL_E_SIZE = 4;
|
static const int EN_US_ADDITIONAL_E_SIZE = 4;
|
||||||
static const uint16_t EN_US_ADDITIONAL_E[];
|
static const uint32_t EN_US_ADDITIONAL_E[];
|
||||||
static const int EN_US_ADDITIONAL_I_SIZE = 4;
|
static const int EN_US_ADDITIONAL_I_SIZE = 4;
|
||||||
static const uint16_t EN_US_ADDITIONAL_I[];
|
static const uint32_t EN_US_ADDITIONAL_I[];
|
||||||
static const int EN_US_ADDITIONAL_O_SIZE = 4;
|
static const int EN_US_ADDITIONAL_O_SIZE = 4;
|
||||||
static const uint16_t EN_US_ADDITIONAL_O[];
|
static const uint32_t EN_US_ADDITIONAL_O[];
|
||||||
static const int EN_US_ADDITIONAL_U_SIZE = 4;
|
static const int EN_US_ADDITIONAL_U_SIZE = 4;
|
||||||
static const uint16_t EN_US_ADDITIONAL_U[];
|
static const uint32_t EN_US_ADDITIONAL_U[];
|
||||||
|
|
||||||
static bool isEnLocale(std::string* locale_str) {
|
static bool isEnLocale(const std::string* locale_str) {
|
||||||
return locale_str && locale_str->size() >= LOCALE_EN_US.size()
|
return locale_str && locale_str->size() >= LOCALE_EN_US.size()
|
||||||
&& locale_str->compare(0, LOCALE_EN_US.size(), LOCALE_EN_US);
|
&& locale_str->compare(0, LOCALE_EN_US.size(), LOCALE_EN_US);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static int getAdditionalCharsSize(std::string* locale_str, uint16_t c) {
|
static int getAdditionalCharsSize(const std::string* locale_str, const uint16_t c) {
|
||||||
if (!isEnLocale(locale_str)) {
|
if (!isEnLocale(locale_str)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ class AdditionalProximityChars {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const uint16_t* getAdditionalChars(std::string* locale_str, uint16_t c) {
|
static const uint32_t* getAdditionalChars(const std::string* locale_str, const uint32_t c) {
|
||||||
if (!isEnLocale(locale_str)) {
|
if (!isEnLocale(locale_str)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ class AdditionalProximityChars {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool hasAdditionalChars(std::string* locale_str, uint16_t c) {
|
static bool hasAdditionalChars(const std::string* locale_str, const uint32_t c) {
|
||||||
return getAdditionalCharsSize(locale_str, c) > 0;
|
return getAdditionalCharsSize(locale_str, c) > 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -50,6 +50,7 @@ ProximityInfo::ProximityInfo(const std::string localeStr, const int maxProximity
|
|||||||
HAS_TOUCH_POSITION_CORRECTION_DATA(keyCount > 0 && keyXCoordinates && keyYCoordinates
|
HAS_TOUCH_POSITION_CORRECTION_DATA(keyCount > 0 && keyXCoordinates && keyYCoordinates
|
||||||
&& keyWidths && keyHeights && keyCharCodes && sweetSpotCenterXs
|
&& keyWidths && keyHeights && keyCharCodes && sweetSpotCenterXs
|
||||||
&& sweetSpotCenterYs && sweetSpotRadii),
|
&& sweetSpotCenterYs && sweetSpotRadii),
|
||||||
|
mLocaleStr(localeStr),
|
||||||
mInputXCoordinates(0), mInputYCoordinates(0),
|
mInputXCoordinates(0), mInputYCoordinates(0),
|
||||||
mTouchPositionCorrectionEnabled(false) {
|
mTouchPositionCorrectionEnabled(false) {
|
||||||
const int proximityGridLength = GRID_WIDTH * GRID_HEIGHT * MAX_PROXIMITY_CHARS_SIZE;
|
const int proximityGridLength = GRID_WIDTH * GRID_HEIGHT * MAX_PROXIMITY_CHARS_SIZE;
|
||||||
@ -164,6 +165,30 @@ void ProximityInfo::calculateNearbyKeyCodes(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const int existingProximitySize = insertPos;
|
||||||
|
for (int i = 0; i < existingProximitySize; ++i) {
|
||||||
|
const uint32_t c = inputCodes[i];
|
||||||
|
const int additionalProximitySize =
|
||||||
|
AdditionalProximityChars::hasAdditionalChars(&mLocaleStr, c);
|
||||||
|
if (additionalProximitySize <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const uint32_t* additionalProximityChars =
|
||||||
|
AdditionalProximityChars::getAdditionalChars(&mLocaleStr, c);
|
||||||
|
for (int j = 0; j < additionalProximitySize; ++j) {
|
||||||
|
const uint32_t ac = additionalProximityChars[j];
|
||||||
|
int k = 0;
|
||||||
|
for (; k < insertPos; ++k) {
|
||||||
|
if ((int)ac == inputCodes[k]) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (k < insertPos) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
inputCodes[insertPos++] = ac;
|
||||||
|
}
|
||||||
|
}
|
||||||
// TODO: calculate additional chars
|
// TODO: calculate additional chars
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +104,7 @@ class ProximityInfo {
|
|||||||
const int CELL_HEIGHT;
|
const int CELL_HEIGHT;
|
||||||
const int KEY_COUNT;
|
const int KEY_COUNT;
|
||||||
const bool HAS_TOUCH_POSITION_CORRECTION_DATA;
|
const bool HAS_TOUCH_POSITION_CORRECTION_DATA;
|
||||||
|
const std::string mLocaleStr;
|
||||||
const int *mInputCodes;
|
const int *mInputCodes;
|
||||||
const int *mInputXCoordinates;
|
const int *mInputXCoordinates;
|
||||||
const int *mInputYCoordinates;
|
const int *mInputYCoordinates;
|
||||||
|
Loading…
Reference in New Issue
Block a user