abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/KeyboardData.java
diff options
context:
space:
mode:
authorJules Aguillon2023-01-22 23:03:30 +0100
committerJules Aguillon2023-01-22 23:21:21 +0100
commit854eff211d62d566fdd3938a4bca1b0d63ad5958 (patch)
tree555a96911d7964fd35eb0abb112db74d96ef24be /srcs/juloo.keyboard2/KeyboardData.java
parentf4032e3be98b7e70fcd384537c3191cf7542c735 (diff)
downloadunexpected-keyboard-854eff211d62d566fdd3938a4bca1b0d63ad5958.tar.gz
unexpected-keyboard-854eff211d62d566fdd3938a4bca1b0d63ad5958.zip
Move cursor by sliding on the space bar
Send key events for the left or right arrow as the finger slides on the space bar. Can be used to select text by holding shift. Works under Termux. Events are sent linearly as the finger travels. The distance between each events is defined from the swiping distance divided by 4. 'slider="true"' can be set on a key that have 'edgekeys="true"'. 'key2' and 'key3' represent the right and left keys.
Diffstat (limited to 'srcs/juloo.keyboard2/KeyboardData.java')
-rw-r--r--srcs/juloo.keyboard2/KeyboardData.java20
1 files changed, 14 insertions, 6 deletions
diff --git a/srcs/juloo.keyboard2/KeyboardData.java b/srcs/juloo.keyboard2/KeyboardData.java
index 550af40..542c173 100644
--- a/srcs/juloo.keyboard2/KeyboardData.java
+++ b/srcs/juloo.keyboard2/KeyboardData.java
@@ -285,9 +285,13 @@ class KeyboardData
public final float shift;
/** Put keys 1 to 4 on the edges instead of the corners. */
public final boolean edgekeys;
+ /** Keys 2 and 3 are repeated as the finger moves laterally on the key.
+ Used for the left and right arrow keys on the space bar. */
+ public final boolean slider;
+ /** String printed on the keys. It has no other effect. */
public final String indication;
- protected Key(Corner k0, Corner k1, Corner k2, Corner k3, Corner k4, float w, float s, boolean e, String i)
+ protected Key(Corner k0, Corner k1, Corner k2, Corner k3, Corner k4, float w, float s, boolean e, boolean sl, String i)
{
key0 = k0;
key1 = k1;
@@ -297,6 +301,7 @@ class KeyboardData
width = w;
shift = s;
edgekeys = e;
+ slider = sl;
indication = i;
}
@@ -310,17 +315,18 @@ class KeyboardData
float width = attribute_float(parser, "width", 1f);
float shift = attribute_float(parser, "shift", 0.f);
boolean edgekeys = attribute_bool(parser, "edgekeys", false);
+ boolean slider = attribute_bool(parser, "slider", false);
String indication = parser.getAttributeValue(null, "indication");
while (parser.next() != XmlPullParser.END_TAG)
continue ;
- return new Key(k0, k1, k2, k3, k4, width, shift, edgekeys, indication);
+ return new Key(k0, k1, k2, k3, k4, width, shift, edgekeys, slider, indication);
}
/** New key with the width multiplied by 's'. */
public Key scaleWidth(float s)
{
return new Key(key0, key1, key2, key3, key4, width * s, shift, edgekeys,
- indication);
+ slider, indication);
}
public KeyValue getKeyValue(int i)
@@ -350,12 +356,14 @@ class KeyboardData
case 3: k3 = k; break;
case 4: k4 = k; break;
}
- return new Key(k0, k1, k2, k3, k4, width, shift, edgekeys, indication);
+ return new Key(k0, k1, k2, k3, k4, width, shift, edgekeys, slider,
+ indication);
}
public Key withShift(float s)
{
- return new Key(key0, key1, key2, key3, key4, width, s, edgekeys, indication);
+ return new Key(key0, key1, key2, key3, key4, width, s, edgekeys, slider,
+ indication);
}
/**
@@ -464,7 +472,7 @@ class KeyboardData
{
return new Key(apply_key0(k.key0), apply(k.key1), apply(k.key2),
apply(k.key3), apply(k.key4), k.width, k.shift, k.edgekeys,
- k.indication);
+ k.slider, k.indication);
}
protected Corner apply_key0(Corner c)