Skip to content

Commit

Permalink
allow for <fn ...> in <modmap> (#626)
Browse files Browse the repository at this point in the history
  • Loading branch information
alotbsol555 authored May 2, 2024
1 parent c7ed2bc commit 82e0840
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
6 changes: 6 additions & 0 deletions srcs/juloo.keyboard2/KeyModifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ private static KeyValue apply_shift(KeyValue k)

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())
{
Expand Down
25 changes: 21 additions & 4 deletions srcs/juloo.keyboard2/KeyboardData.java
Original file line number Diff line number Diff line change
Expand Up @@ -515,18 +515,35 @@ public Key apply(Key k)
public static class Modmap
{
public final Map<KeyValue, KeyValue> shift;
public final Map<KeyValue, KeyValue> fn;

public Modmap(Map<KeyValue, KeyValue> s)
public Modmap(Map<KeyValue, KeyValue> s, Map<KeyValue, KeyValue> f)
{
shift = s;
fn = f;
}

public static Modmap parse(XmlPullParser parser) throws Exception
{
HashMap<KeyValue, KeyValue> shift = new HashMap<KeyValue, KeyValue>();
while (expect_tag(parser, "shift"))
parse_mapping(parser, shift);
return new Modmap(shift);
HashMap<KeyValue, KeyValue> fn = new HashMap<KeyValue, KeyValue>();

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 <shift> or <fn>, got <" + parser.getName() + ">");
}
}

return new Modmap(shift, fn);
}

private static void parse_mapping(XmlPullParser parser, Map<KeyValue, KeyValue> dst) throws Exception
Expand Down

0 comments on commit 82e0840

Please sign in to comment.