Add level modifiers in JSON

This is needed because some layouts don't have an uppercase level.
That shouldn't make symbols the 2nd level.
This commit is contained in:
Alan 2017-08-02 15:26:32 +00:00 committed by Florian Müllner
parent 8b3be5e063
commit fe89f7c5ac
2 changed files with 11 additions and 9 deletions

View File

@ -97,19 +97,21 @@ def convert_xml(tree):
root["levels"] = []
# parse levels
for index, keymap in enumerate(tree.iter('keyMap')):
level = {}
root["levels"].append(level)
level["level"] = index + 1
# FIXME: heuristics here
modifiers = keymap.get('modifiers')
if not modifiers:
mode = 'default'
elif 'shift' in modifiers.split(' ') or 'lock' in modifiers.split(' '):
modifiers = ''
elif 'shift' in modifiers.split(' '):
mode = 'latched'
modifiers = 'shift'
else:
mode = 'locked'
level = {}
level["level"] = modifiers
level["mode"] = mode
level["rows"] = parse_rows(keymap)
root["levels"].append(level)
return root

View File

@ -1,7 +1,7 @@
{
"levels": [
{
"level": 1,
"level": "",
"mode": "default",
"rows": [
[
@ -163,7 +163,7 @@
]
},
{
"level": 2,
"level": "shift",
"mode": "latched",
"rows": [
[
@ -325,7 +325,7 @@
]
},
{
"level": 3,
"level": "opt",
"mode": "locked",
"rows": [
[
@ -478,7 +478,7 @@
]
},
{
"level": 4,
"level": "opt+shift",
"mode": "locked",
"rows": [
[