Reduce amount of empty space in which keypresses are detected

Bug: 6942329
Change-Id: Ie92ccf43f307b8ceb9a311c30390d0cb2abf2cd7
main
Tadashi G. Takaoka 2012-09-04 14:50:56 +09:00
parent 2c0c1cc677
commit 3f00c6151f
10 changed files with 51 additions and 13 deletions

View File

@ -41,6 +41,8 @@
latin:moreKeys="!text/more_keys_for_tablet_double_quote" /> latin:moreKeys="!text/more_keys_for_tablet_double_quote" />
<Key <Key
latin:keyLabel="_" /> latin:keyLabel="_" />
<!-- Here is empty space. --> <!-- Note: This Spacer prevents the above key from being marked as a right edge key. -->
<Spacer
latin:keyWidth="fillRight" />
</Row> </Row>
</merge> </merge>

View File

@ -33,6 +33,8 @@
latin:keyXPos="28.0%p" latin:keyXPos="28.0%p"
latin:keyboardLayout="@xml/key_space" latin:keyboardLayout="@xml/key_space"
latin:backgroundType="normal" /> latin:backgroundType="normal" />
<!-- Here is empty space. --> <!-- Note: This Spacer prevents the above key from being marked as a right edge key. -->
<Spacer
latin:keyWidth="fillRight" />
</Row> </Row>
</merge> </merge>

View File

@ -153,5 +153,8 @@
<Key <Key
latin:keyLabel="#" latin:keyLabel="#"
latin:keyStyle="numKeyStyle" /> latin:keyStyle="numKeyStyle" />
<!-- Note: This Spacer prevents the above key from being marked as a right edge key. -->
<Spacer
latin:keyWidth="fillRight" />
</Row> </Row>
</merge> </merge>

View File

@ -25,8 +25,10 @@
latin:keyWidth="8.047%p" latin:keyWidth="8.047%p"
latin:backgroundType="functional" latin:backgroundType="functional"
> >
<!-- Note: This Spacer prevents the below key from being marked as a left edge key. -->
<Spacer
latin:keyWidth="5.782%p" />
<include <include
latin:keyXPos="5.782%p"
latin:keyboardLayout="@xml/key_settings" /> latin:keyboardLayout="@xml/key_settings" />
<include <include
latin:keyboardLayout="@xml/key_shortcut" /> latin:keyboardLayout="@xml/key_shortcut" />
@ -42,5 +44,8 @@
latin:keyboardLayout="@xml/key_dash" /> latin:keyboardLayout="@xml/key_dash" />
<include <include
latin:keyboardLayout="@xml/key_f2" /> latin:keyboardLayout="@xml/key_f2" />
<!-- Note: This Spacer prevents the above key from being marked as a right edge key. -->
<Spacer
latin:keyWidth="fillRight" />
</Row> </Row>
</merge> </merge>

View File

@ -25,8 +25,10 @@
latin:keyWidth="8.047%p" latin:keyWidth="8.047%p"
latin:backgroundType="functional" latin:backgroundType="functional"
> >
<!-- Note: This Spacer prevents the below key from being marked as a left edge key. -->
<Spacer
latin:keyWidth="5.782%p" />
<include <include
latin:keyXPos="5.782%p"
latin:keyboardLayout="@xml/key_settings" /> latin:keyboardLayout="@xml/key_settings" />
<include <include
latin:keyboardLayout="@xml/key_shortcut" /> latin:keyboardLayout="@xml/key_shortcut" />
@ -40,5 +42,8 @@
latin:keyboardLayout="@xml/keys_comma_period" /> latin:keyboardLayout="@xml/keys_comma_period" />
<include <include
latin:keyboardLayout="@xml/key_f2" /> latin:keyboardLayout="@xml/key_f2" />
<!-- Note: This Spacer prevents the above key from being marked as a right edge key. -->
<Spacer
latin:keyWidth="fillRight" />
</Row> </Row>
</merge> </merge>

View File

@ -25,8 +25,10 @@
latin:keyWidth="8.047%p" latin:keyWidth="8.047%p"
latin:backgroundType="functional" latin:backgroundType="functional"
> >
<!-- Note: This Spacer prevents the below key from being marked as a left edge key. -->
<Spacer
latin:keyWidth="5.782%p" />
<include <include
latin:keyXPos="5.782%p"
latin:keyboardLayout="@xml/key_settings" /> latin:keyboardLayout="@xml/key_settings" />
<include <include
latin:keyboardLayout="@xml/key_shortcut" /> latin:keyboardLayout="@xml/key_shortcut" />
@ -42,5 +44,8 @@
latin:keyboardLayout="@xml/key_dash" /> latin:keyboardLayout="@xml/key_dash" />
<include <include
latin:keyboardLayout="@xml/key_f2" /> latin:keyboardLayout="@xml/key_f2" />
<!-- Note: This Spacer prevents the above key from being marked as a right edge key. -->
<Spacer
latin:keyWidth="fillRight" />
</Row> </Row>
</merge> </merge>

View File

@ -25,8 +25,10 @@
latin:keyWidth="8.047%p" latin:keyWidth="8.047%p"
latin:backgroundType="functional" latin:backgroundType="functional"
> >
<!-- Note: This Spacer prevents the below key from being marked as a left edge key. -->
<Spacer
latin:keyWidth="13.829%p" />
<Key <Key
latin:keyXPos="13.829%p"
latin:keyLabel="/" /> latin:keyLabel="/" />
<include <include
latin:keyboardLayout="@xml/key_f1" /> latin:keyboardLayout="@xml/key_f1" />
@ -39,6 +41,8 @@
latin:moreKeys="!text/more_keys_for_tablet_double_quote" /> latin:moreKeys="!text/more_keys_for_tablet_double_quote" />
<Key <Key
latin:keyLabel="_" /> latin:keyLabel="_" />
<!-- Here is empty space. --> <!-- Note: This Spacer prevents the above key from being marked as a right edge key. -->
<Spacer
latin:keyWidth="fillRight" />
</Row> </Row>
</merge> </merge>

View File

@ -25,11 +25,14 @@
latin:keyWidth="8.047%p" latin:keyWidth="8.047%p"
latin:backgroundType="functional" latin:backgroundType="functional"
> >
<!-- Here is empty space. --> <!-- Note: This Spacer prevents the below key from being marked as a left edge key. -->
<Spacer
latin:keyWidth="29.923%p" />
<include <include
latin:keyXPos="29.923%p"
latin:keyboardLayout="@xml/key_space" latin:keyboardLayout="@xml/key_space"
latin:backgroundType="normal" /> latin:backgroundType="normal" />
<!-- Here is empty space. --> <!-- Note: This Spacer prevents the above key from being marked as a right edge key. -->
<Spacer
latin:keyWidth="fillRight" />
</Row> </Row>
</merge> </merge>

View File

@ -168,5 +168,8 @@
<Key <Key
latin:keyLabel="#" latin:keyLabel="#"
latin:keyStyle="numKeyStyle" /> latin:keyStyle="numKeyStyle" />
<!-- Note: This Spacer prevents the above key from being marked as a right edge key. -->
<Spacer
latin:keyWidth="fillRight" />
</Row> </Row>
</merge> </merge>

View File

@ -83,11 +83,17 @@ public class KeyDetector {
int minDistance = Integer.MAX_VALUE; int minDistance = Integer.MAX_VALUE;
Key primaryKey = null; Key primaryKey = null;
for (final Key key: mKeyboard.getNearestKeys(touchX, touchY)) { for (final Key key: mKeyboard.getNearestKeys(touchX, touchY)) {
final boolean isOnKey = key.isOnKey(touchX, touchY); // An edge key always has its enlarged hitbox to respond to an event that occurred in
// the empty area around the key. (@see Key#markAsLeftEdge(KeyboardParams)} etc.)
if (!key.isOnKey(touchX, touchY)) {
continue;
}
final int distance = key.squaredDistanceToEdge(touchX, touchY); final int distance = key.squaredDistanceToEdge(touchX, touchY);
if (distance > minDistance) {
continue;
}
// To take care of hitbox overlaps, we compare mCode here too. // To take care of hitbox overlaps, we compare mCode here too.
if (primaryKey == null || distance < minDistance if (primaryKey == null || distance < minDistance || key.mCode > primaryKey.mCode) {
|| (distance == minDistance && isOnKey && key.mCode > primaryKey.mCode)) {
minDistance = distance; minDistance = distance;
primaryKey = key; primaryKey = key;
} }