Merge "Change native functions' interface for gesture"
This commit is contained in:
commit
1850551d6d
7 changed files with 34 additions and 3 deletions
|
@ -26,6 +26,8 @@ include $(CLEAR_VARS)
|
|||
LATIN_IME_SRC_DIR := src
|
||||
|
||||
LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR)
|
||||
LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR)/gesture
|
||||
LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR)/gesture/impl
|
||||
|
||||
LOCAL_CFLAGS += -Werror -Wall
|
||||
|
||||
|
|
|
@ -44,7 +44,8 @@ Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust,
|
|||
fullWordMultiplier, maxWordLength, maxWords, options);
|
||||
mBigramDictionary = new BigramDictionary(mDict + headerSize, maxWordLength);
|
||||
mGestureDecoder = new GestureDecoder(maxWordLength, maxWords);
|
||||
mGestureDecoder->setDict(mUnigramDictionary, mBigramDictionary);
|
||||
mGestureDecoder->setDict(mUnigramDictionary, mBigramDictionary,
|
||||
mDict + headerSize /* dict root */, 0 /* root pos */);
|
||||
}
|
||||
|
||||
Dictionary::~Dictionary() {
|
||||
|
|
|
@ -28,7 +28,8 @@ class IncrementalDecoderImpl : IncrementalDecoderInterface {
|
|||
|
||||
public:
|
||||
IncrementalDecoderImpl(int maxWordLength, int maxWords) { };
|
||||
void setDict(const UnigramDictionary *dict, const BigramDictionary *bigram) { };
|
||||
void setDict(const UnigramDictionary *dict, const BigramDictionary *bigram,
|
||||
const uint8_t *dictRoot, int rootPos) { };
|
||||
void setPrevWord(const int32_t *prevWord, int prevWordLength) { };
|
||||
void reset() { };
|
||||
|
|
@ -31,7 +31,8 @@ class IncrementalDecoderInterface {
|
|||
int *pointerIds, int *codes, int inputSize, int commitPoint, bool isMainDict,
|
||||
unsigned short *outWords, int *frequencies, int *outputIndices) = 0;
|
||||
virtual void reset() = 0;
|
||||
virtual void setDict(const UnigramDictionary *dict, const BigramDictionary *bigram) = 0;
|
||||
virtual void setDict(const UnigramDictionary *dict, const BigramDictionary *bigram,
|
||||
const uint8_t *dictRoot, int rootPos) = 0;
|
||||
virtual void setPrevWord(const int32_t *prevWord, int prevWordLength) = 0;
|
||||
virtual ~IncrementalDecoderInterface() { };
|
||||
};
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
|
@ -210,4 +211,25 @@ int ProximityInfo::getKeyIndex(const int c) const {
|
|||
}
|
||||
return mCodeToKeyIndex[baseLowerC];
|
||||
}
|
||||
|
||||
// TODO: [Staging] Optimize
|
||||
void ProximityInfo::getCenters(int *centerXs, int *centerYs, int *codeToKeyIndex,
|
||||
int *keyToCodeIndex, int *keyCount, int *keyWidth) const {
|
||||
*keyCount = KEY_COUNT;
|
||||
*keyWidth = sqrt((float)MOST_COMMON_KEY_WIDTH_SQUARE);
|
||||
|
||||
for (int i = 0; i < KEY_COUNT; ++i) {
|
||||
const int code = mKeyCharCodes[i];
|
||||
const int lowerCode = toBaseLowerCase(code);
|
||||
centerXs[i] = mKeyXCoordinates[i] + mKeyWidths[i] / 2;
|
||||
centerYs[i] = mKeyYCoordinates[i] + mKeyHeights[i] / 2;
|
||||
codeToKeyIndex[code] = i;
|
||||
if (code != lowerCode && lowerCode >= 0 && lowerCode <= MAX_CHAR_CODE) {
|
||||
codeToKeyIndex[lowerCode] = i;
|
||||
keyToCodeIndex[i] = lowerCode;
|
||||
} else {
|
||||
keyToCodeIndex[i] = code;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace latinime
|
||||
|
|
|
@ -98,6 +98,10 @@ class ProximityInfo {
|
|||
return GRID_HEIGHT;
|
||||
}
|
||||
|
||||
// Returns the keyboard key-center information.
|
||||
void getCenters(int *centersX, int *centersY, int *codeToKeyIndex, int *keyToCodeIndex,
|
||||
int *keyCount, int *keyWidth) const;
|
||||
|
||||
private:
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(ProximityInfo);
|
||||
// The max number of the keys in one keyboard layout
|
||||
|
|
Loading…
Reference in a new issue