Skip to content

Commit 0acf66d

Browse files
committed
Restore previous swipe sensibility
The distance at which a swipe was considered successful was reduced in 188c682 to allow making circle gestures on a key that also had a slider. It was also useful in reducing accidental sliding. This is impractical for normal typing so it is reverted. The reduced range continues to be used for sliders.
1 parent 85c73d9 commit 0acf66d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

srcs/juloo.keyboard2/Pointers.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public void onTouchDown(float x, float y, int pointerId, KeyboardData.Key key)
219219
* [direction] is an int between [0] and [15] that represent 16 sections of a
220220
* circle, clockwise, starting at the top.
221221
*/
222-
KeyValue getKeyAtDirection(KeyboardData.Key k, int direction)
222+
static KeyValue getKeyAtDirection(KeyboardData.Key k, int direction)
223223
{
224224
return k.keys[DIRECTION_TO_INDEX[direction]];
225225
}
@@ -234,16 +234,24 @@ KeyValue getKeyAtDirection(KeyboardData.Key k, int direction)
234234
private KeyValue getNearestKeyAtDirection(Pointer ptr, int direction)
235235
{
236236
KeyValue k;
237-
// [i] is [0, -1, 1, -2, 2], scanning a 1/4 of the circle's area, centered
238-
// on the initial direction.
239-
for (int i = 0; i > -2; i = (~i>>31) - i)
237+
// [i] is [0, -1, +1, ..., -3, +3], scanning 43% of the circle's area,
238+
// centered on the initial swipe direction.
239+
for (int i = 0; i > -4; i = (~i>>31) - i)
240240
{
241241
int d = (direction + i + 16) % 16;
242242
// Don't make the difference between a key that doesn't exist and a key
243243
// that is removed by [_handler]. Triggers side effects.
244244
k = _handler.modifyKey(getKeyAtDirection(ptr.key, d), ptr.modifiers);
245245
if (k != null)
246+
{
247+
// When the nearest key is a slider, it is only selected if it's placed
248+
// within 18% of the original swipe direction.
249+
// This reduces accidental swipes on the slider and allow typing circle
250+
// gestures without being interrupted by the slider.
251+
if (k.getKind() == KeyValue.Kind.Slider && Math.abs(i) >= 2)
252+
continue;
246253
return k;
254+
}
247255
}
248256
return null;
249257
}

0 commit comments

Comments
 (0)