abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/KeyModifier.java
diff options
context:
space:
mode:
authorJules Aguillon2024-05-25 21:19:44 +0200
committerGitHub2024-05-25 21:19:44 +0200
commit4906f8105f9f831b5977d4935f90ef26b8afdafd (patch)
treefbcc7e4aef2493dbe892f134c8b3bd7124ad2880 /srcs/juloo.keyboard2/KeyModifier.java
parent96fc4003f1f1705473398880f2bc2e5c2757c471 (diff)
downloadunexpected-keyboard-4906f8105f9f831b5977d4935f90ef26b8afdafd.tar.gz
unexpected-keyboard-4906f8105f9f831b5977d4935f90ef26b8afdafd.zip
Circle and round trip gestures (#640)
This implements clockwise/anticlockwise circle and round trip gestures inspired by Messagease. The circle gestures start after a small threshold to avoid making the regular swipe too hard to aim. The gestures do: - circle: The center symbol with Shift applied, with a fallback on Fn - round trip: Same as the circle gesture but applied to a side symbol - anticlockwise circle: Nothing currently. It is intended to be made configurable per-layout in the future. The new Gesture class keeps track of what the pointer is doing while it moves on a key. It replaces the 'selected_direction' integer.
Diffstat (limited to 'srcs/juloo.keyboard2/KeyModifier.java')
-rw-r--r--srcs/juloo.keyboard2/KeyModifier.java18
1 files changed, 13 insertions, 5 deletions
diff --git a/srcs/juloo.keyboard2/KeyModifier.java b/srcs/juloo.keyboard2/KeyModifier.java
index f358e97..a320ec5 100644
--- a/srcs/juloo.keyboard2/KeyModifier.java
+++ b/srcs/juloo.keyboard2/KeyModifier.java
@@ -33,7 +33,6 @@ public final class KeyModifier
if (r == null)
{
r = k;
- /* Order: Fn, Shift, accents */
for (int i = 0; i < n_mods; i++)
r = modify(r, mods.get(i));
ks.put(mods, r);
@@ -70,6 +69,7 @@ public final class KeyModifier
case ALT:
case META: return turn_into_keyevent(k);
case FN: return apply_fn(k);
+ case GESTURE: return apply_gesture(k);
case SHIFT: return apply_shift(k);
case GRAVE: return apply_map_char(k, map_char_grave);
case AIGU: return apply_map_char(k, map_char_aigu);
@@ -139,11 +139,10 @@ public final class KeyModifier
case Char:
char kc = k.getChar();
String modified = map.apply(kc);
- if (modified == null)
- return k;
- return KeyValue.makeStringKey(modified, k.getFlags());
- default: return k;
+ if (modified != null)
+ return KeyValue.makeStringKey(modified, k.getFlags());
}
+ return k;
}
private static KeyValue apply_shift(KeyValue k)
@@ -482,6 +481,15 @@ public final class KeyModifier
return k.withKeyevent(e);
}
+ /** Modify a key affected by a round-trip or a clockwise circle gesture. */
+ private static KeyValue apply_gesture(KeyValue k)
+ {
+ KeyValue shifted = apply_shift(k);
+ if (shifted == null || shifted.equals(k))
+ return apply_fn(k);
+ return shifted;
+ }
+
/* Lookup the cache entry for a key. Create it needed. */
private static HashMap<Pointers.Modifiers, KeyValue> cacheEntry(KeyValue k)
{