mirror of
https://github.com/Julow/Unexpected-Keyboard.git
synced 2024-11-25 00:33:24 +01:00
allow for <fn ...> in <modmap> (#626)
This commit is contained in:
parent
c7ed2bcae9
commit
82e0840568
@ -165,6 +165,12 @@ public final class KeyModifier
|
|||||||
|
|
||||||
private static KeyValue apply_fn(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;
|
String name = null;
|
||||||
switch (k.getKind())
|
switch (k.getKind())
|
||||||
{
|
{
|
||||||
|
@ -515,18 +515,35 @@ public final class KeyboardData
|
|||||||
public static class Modmap
|
public static class Modmap
|
||||||
{
|
{
|
||||||
public final Map<KeyValue, KeyValue> shift;
|
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;
|
shift = s;
|
||||||
|
fn = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Modmap parse(XmlPullParser parser) throws Exception
|
public static Modmap parse(XmlPullParser parser) throws Exception
|
||||||
{
|
{
|
||||||
HashMap<KeyValue, KeyValue> shift = new HashMap<KeyValue, KeyValue>();
|
HashMap<KeyValue, KeyValue> shift = new HashMap<KeyValue, KeyValue>();
|
||||||
while (expect_tag(parser, "shift"))
|
HashMap<KeyValue, KeyValue> fn = new HashMap<KeyValue, KeyValue>();
|
||||||
|
|
||||||
|
while (next_tag(parser))
|
||||||
|
{
|
||||||
|
switch (parser.getName())
|
||||||
|
{
|
||||||
|
case "shift":
|
||||||
parse_mapping(parser, shift);
|
parse_mapping(parser, shift);
|
||||||
return new Modmap(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
|
private static void parse_mapping(XmlPullParser parser, Map<KeyValue, KeyValue> dst) throws Exception
|
||||||
|
Loading…
Reference in New Issue
Block a user