Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LatinIME
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
keyboard
LatinIME
Commits
c25c7ccf
Commit
c25c7ccf
authored
13 years ago
by
Yusuke Nojima
Browse files
Options
Downloads
Patches
Plain Diff
Cache the sweet spot types
Change-Id: Ibaee062dc55c11892143d48b2d0959e78e52be83
parent
7afd9102
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
native/src/proximity_info.cpp
+29
-17
29 additions, 17 deletions
native/src/proximity_info.cpp
native/src/proximity_info.h
+4
-1
4 additions, 1 deletion
native/src/proximity_info.h
with
33 additions
and
18 deletions
native/src/proximity_info.cpp
+
29
−
17
View file @
c25c7ccf
...
...
@@ -114,40 +114,53 @@ void ProximityInfo::setInputParams(const int* inputCodes, const int inputLength,
mPrimaryInputWord
[
i
]
=
getPrimaryCharAt
(
i
);
}
mPrimaryInputWord
[
inputLength
]
=
0
;
for
(
int
i
=
0
;
i
<
mInputLength
;
++
i
)
{
mSweetSpotTypes
[
i
]
=
calculateSweetSpotType
(
i
);
}
}
inline
float
square
(
const
float
x
)
{
return
x
*
x
;
}
ProximityInfo
::
SweetSpotType
ProximityInfo
::
calculateSweetSpotType
(
int
index
,
unsigned
short
baseLowerC
)
const
{
if
(
KEY_COUNT
==
0
||
!
mInputXCoordinates
||
!
mInputYCoordinates
||
baseLowerC
>
MAX_CHAR_CODE
)
{
ProximityInfo
::
SweetSpotType
ProximityInfo
::
calculateSweetSpotType
(
int
index
)
const
{
if
(
KEY_COUNT
==
0
||
!
mInputXCoordinates
||
!
mInputYCoordinates
)
{
// We do not have the coordinate data
return
UNKNOWN
;
}
const
int
currentChar
=
getPrimaryCharAt
(
index
);
const
unsigned
short
baseLowerC
=
Dictionary
::
toBaseLowerCase
(
currentChar
);
if
(
baseLowerC
>
MAX_CHAR_CODE
)
{
return
UNKNOWN
;
}
const
int
keyIndex
=
mCodeToKeyIndex
[
baseLowerC
];
if
(
keyIndex
<
0
)
{
return
UNKNOWN
;
}
const
float
sweetSpotRadius
=
mSweetSpotRadii
[
keyIndex
];
if
(
sweetSpotRadius
<=
0.0
)
{
const
float
radius
=
mSweetSpotRadii
[
keyIndex
];
if
(
radius
<=
0.0
)
{
// When there are no calibration data for a key,
// the radius of the key is assigned to zero.
return
UNKNOWN
;
}
const
float
sweetSpotCenterX
=
mSweetSpotCenterXs
[
keyIndex
];
const
float
sweetSpotCenterY
=
mSweetSpotCenterYs
[
keyIndex
];
const
float
inputX
=
(
float
)
mInputXCoordinates
[
index
];
const
float
inputY
=
(
float
)
mInputYCoordinates
[
index
];
const
float
squaredDistance
=
square
(
inputX
-
sweetSpotCenterX
)
+
square
(
inputY
-
sweetSpotCenterY
);
const
float
squaredSweetSpotRadius
=
square
(
sweetSpotRadius
);
if
(
squaredDistance
<=
squaredSweetSpotRadius
)
{
const
float
squaredRadius
=
square
(
radius
);
const
float
squaredDistance
=
calculateSquaredDistanceFromSweetSpotCenter
(
keyIndex
,
index
);
if
(
squaredDistance
<=
squaredRadius
)
{
return
IN_SWEET_SPOT
;
}
if
(
squaredDistance
<=
square
(
NEUTRAL_AREA_RADIUS_RATIO
)
*
squared
SweetSpot
Radius
)
{
if
(
squaredDistance
<=
square
(
NEUTRAL_AREA_RADIUS_RATIO
)
*
squaredRadius
)
{
return
IN_NEUTRAL_AREA
;
}
return
OUT_OF_NEUTRAL_AREA
;
}
float
ProximityInfo
::
calculateSquaredDistanceFromSweetSpotCenter
(
int
keyIndex
,
int
inputIndex
)
const
{
const
float
sweetSpotCenterX
=
mSweetSpotCenterXs
[
keyIndex
];
const
float
sweetSpotCenterY
=
mSweetSpotCenterYs
[
keyIndex
];
const
float
inputX
=
(
float
)
mInputXCoordinates
[
inputIndex
];
const
float
inputY
=
(
float
)
mInputYCoordinates
[
inputIndex
];
return
square
(
inputX
-
sweetSpotCenterX
)
+
square
(
inputY
-
sweetSpotCenterY
);
}
inline
const
int
*
ProximityInfo
::
getProximityCharsAt
(
const
int
index
)
const
{
return
mInputCodes
+
(
index
*
MAX_PROXIMITY_CHARS_SIZE
);
}
...
...
@@ -201,8 +214,7 @@ ProximityInfo::ProximityType ProximityInfo::getMatchedProximityId(
// that means the user typed that same char for this pos.
if
(
firstChar
==
baseLowerC
||
firstChar
==
c
)
{
if
(
CALIBRATE_SCORE_BY_TOUCH_COORDINATES
)
{
const
SweetSpotType
result
=
calculateSweetSpotType
(
index
,
baseLowerC
);
switch
(
result
)
{
switch
(
mSweetSpotTypes
[
index
])
{
case
UNKNOWN
:
return
EQUIVALENT_CHAR_NORMAL
;
case
IN_SWEET_SPOT
:
...
...
This diff is collapsed.
Click to expand it.
native/src/proximity_info.h
+
4
−
1
View file @
c25c7ccf
...
...
@@ -81,7 +81,9 @@ private:
int
getStartIndexFromCoordinates
(
const
int
x
,
const
int
y
)
const
;
void
initializeCodeToKeyIndex
();
SweetSpotType
calculateSweetSpotType
(
int
index
,
unsigned
short
baseLowerC
)
const
;
SweetSpotType
calculateSweetSpotType
(
int
index
)
const
;
float
calculateSquaredDistanceFromSweetSpotCenter
(
int
keyIndex
,
int
inputIndex
)
const
;
const
int
MAX_PROXIMITY_CHARS_SIZE
;
const
int
KEYBOARD_WIDTH
;
const
int
KEYBOARD_HEIGHT
;
...
...
@@ -102,6 +104,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
mInputLength
;
unsigned
short
mPrimaryInputWord
[
MAX_WORD_LENGTH_INTERNAL
];
int
mCodeToKeyIndex
[
MAX_CHAR_CODE
+
1
];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment