abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Pointers.java
diff options
context:
space:
mode:
authorRodrigo Batista de Moraes2022-05-06 13:38:43 -0300
committerJules Aguillon2022-05-08 16:55:03 +0200
commita27c64479f158e840c717e81d2345b2eaca23e47 (patch)
tree8fa1f44e966f8ee2b6ff5557242109729f9d82cf /srcs/juloo.keyboard2/Pointers.java
parent7da7a5082dc28a434776bb7f127b00955d7098f0 (diff)
downloadunexpected-keyboard-a27c64479f158e840c717e81d2345b2eaca23e47.tar.gz
unexpected-keyboard-a27c64479f158e840c717e81d2345b2eaca23e47.zip
use the closest swipe key on swipe
fix a direction
Diffstat (limited to 'srcs/juloo.keyboard2/Pointers.java')
-rw-r--r--srcs/juloo.keyboard2/Pointers.java29
1 files changed, 16 insertions, 13 deletions
diff --git a/srcs/juloo.keyboard2/Pointers.java b/srcs/juloo.keyboard2/Pointers.java
index cdc254d..774ecf6 100644
--- a/srcs/juloo.keyboard2/Pointers.java
+++ b/srcs/juloo.keyboard2/Pointers.java
@@ -146,6 +146,11 @@ public final class Pointers implements Handler.Callback
Pointer ptr = getPtr(pointerId);
if (ptr == null)
return;
+
+ // The position in a IME windows is clampled to view.
+ // For a better up swipe behaviour, set the y position to a negative value when clamped.
+ if (y == 0.0) y = -400;
+
float dx = x - ptr.downX;
float dy = y - ptr.downY;
float dist = Math.abs(dx) + Math.abs(dy);
@@ -155,19 +160,17 @@ public final class Pointers implements Handler.Callback
{
newIndex = 0;
}
- else if (ptr.key.edgekeys)
- {
- if (Math.abs(dy) > Math.abs(dx)) // vertical swipe
- newIndex = (dy < 0) ? 1 : 4;
- else // horizontal swipe
- newIndex = (dx < 0) ? 3 : 2;
- }
- else
- {
- if (dx < 0) // left side
- newIndex = (dy < 0) ? 1 : 3;
- else // right side
- newIndex = (dy < 0) ? 2 : 4;
+ else {
+ // One of the 8 directions:
+ // |\2|3/|
+ // |1\|/4|
+ // |-----|
+ // |5/|\8|
+ // |/6|7\|
+ newIndex = 1;
+ if (dy > 0) newIndex += 4;
+ if (dx > 0) newIndex += 2;
+ if (dx > Math.abs(dy) || (dx < 0 && dx > -Math.abs(dy))) newIndex += 1;
}
if (newIndex != ptr.value_index)
{