From d03afb6e8f391cb18aeadc6baaea520e8937f7ab Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sat, 25 May 2024 01:20:15 +0200 Subject: [PATCH] Apply Shift then fallback to Fn This changes both the round trip and the clockwise circle gestures to first apply Shift and if that didn't change the key, fallback to Fn. This allows to have letters in the corner of keys while being able to shift them. Clockwise circle modify keys the same way as round trip for the center key. The anti-clockwise gesture now do nothing. It's intended to make it configurable per-layout. --- srcs/juloo.keyboard2/Gesture.java | 7 ++++--- srcs/juloo.keyboard2/KeyModifier.java | 14 +++++--------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/srcs/juloo.keyboard2/Gesture.java b/srcs/juloo.keyboard2/Gesture.java index 1fbbb5f..073a6b5 100644 --- a/srcs/juloo.keyboard2/Gesture.java +++ b/srcs/juloo.keyboard2/Gesture.java @@ -43,13 +43,14 @@ public final class Gesture case Ended_swipe: return selected_val; case Ended_center: - return KeyModifier.modify_round_trip(selected_val); + return KeyModifier.modify_gesture(selected_val); case Rotating_clockwise: case Ended_clockwise: - return KeyModifier.modify_circle(key.keys[0], true); + return KeyModifier.modify_gesture(key.keys[0]); case Rotating_anticlockwise: case Ended_anticlockwise: - return KeyModifier.modify_circle(key.keys[0], false); + // Unimplemented for now. + return key.keys[0]; } return null; // Unreachable } diff --git a/srcs/juloo.keyboard2/KeyModifier.java b/srcs/juloo.keyboard2/KeyModifier.java index 8e6a983..e869e9f 100644 --- a/srcs/juloo.keyboard2/KeyModifier.java +++ b/srcs/juloo.keyboard2/KeyModifier.java @@ -117,17 +117,13 @@ public final class KeyModifier return k; } - public static KeyValue modify_round_trip(KeyValue k) + /** Modify a key affected by a round-trip or a clockwise circle gesture. */ + public static KeyValue modify_gesture(KeyValue k) { - return apply_fn(k); - } - - public static KeyValue modify_circle(KeyValue k, boolean clockwise) - { - if (clockwise) - return apply_shift(k); - else + KeyValue shifted = apply_shift(k); + if (shifted == null || shifted.equals(k)) return apply_fn(k); + return shifted; } public static Map_char modify_numpad_script(String numpad_script)