From 82e0840568655c8d71f2ac0c0ac5b1c18ef17845 Mon Sep 17 00:00:00 2001 From: alotbsol555 <159767443+alotbsol555@users.noreply.github.com> Date: Thu, 2 May 2024 12:09:39 +0200 Subject: [PATCH] allow for in (#626) --- srcs/juloo.keyboard2/KeyModifier.java | 6 ++++++ srcs/juloo.keyboard2/KeyboardData.java | 25 +++++++++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/srcs/juloo.keyboard2/KeyModifier.java b/srcs/juloo.keyboard2/KeyModifier.java index 79531b2..3dc50a9 100644 --- a/srcs/juloo.keyboard2/KeyModifier.java +++ b/srcs/juloo.keyboard2/KeyModifier.java @@ -165,6 +165,12 @@ public final class KeyModifier private static KeyValue apply_fn(KeyValue k) { + if (_modmap != null) + { + KeyValue mapped = _modmap.fn.get(k); + if (mapped != null) + return mapped; + } String name = null; switch (k.getKind()) { diff --git a/srcs/juloo.keyboard2/KeyboardData.java b/srcs/juloo.keyboard2/KeyboardData.java index c8dcd13..25110ef 100644 --- a/srcs/juloo.keyboard2/KeyboardData.java +++ b/srcs/juloo.keyboard2/KeyboardData.java @@ -515,18 +515,35 @@ public final class KeyboardData public static class Modmap { public final Map shift; + public final Map fn; - public Modmap(Map s) + public Modmap(Map s, Map f) { shift = s; + fn = f; } public static Modmap parse(XmlPullParser parser) throws Exception { HashMap shift = new HashMap(); - while (expect_tag(parser, "shift")) - parse_mapping(parser, shift); - return new Modmap(shift); + HashMap fn = new HashMap(); + + while (next_tag(parser)) + { + switch (parser.getName()) + { + case "shift": + parse_mapping(parser, shift); + break; + case "fn": + parse_mapping(parser, fn); + break; + default: + throw error(parser, "Expecting tag or , got <" + parser.getName() + ">"); + } + } + + return new Modmap(shift, fn); } private static void parse_mapping(XmlPullParser parser, Map dst) throws Exception