Make the primary character stable

Bug: 4343280
Change-Id: I3e6eaa3803dc32a837825f3a64403430721b6192
This commit is contained in:
satok 2012-03-19 12:00:00 +09:00
parent 660776e09b
commit d6d0f6976c

View file

@ -265,9 +265,9 @@ public class KeyDetector {
for (final Key key: mKeyboard.getNearestKeys(touchX, touchY)) { for (final Key key: mKeyboard.getNearestKeys(touchX, touchY)) {
final boolean isOnKey = key.isOnKey(touchX, touchY); final boolean isOnKey = key.isOnKey(touchX, touchY);
final int distance = key.squaredDistanceToEdge(touchX, touchY); final int distance = key.squaredDistanceToEdge(touchX, touchY);
// TODO: need to take care of hitbox overlaps // To take care of hitbox overlaps, we compare mCode here too.
if (primaryKey == null || distance < minDistance if (primaryKey == null || distance < minDistance
|| (distance == minDistance && isOnKey)) { || (distance == minDistance && isOnKey && key.mCode > primaryKey.mCode)) {
minDistance = distance; minDistance = distance;
primaryKey = key; primaryKey = key;
} }