blob: bbd3531317d7986410453be2605921a3d1b5222e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
"""Functions to convert to and from QMK formats
"""
from collections import OrderedDict
def kle2qmk(kle):
"""Convert a KLE layout to QMK's layout format.
"""
layout = []
for row in kle:
for key in row:
if key['decal']:
continue
qmk_key = OrderedDict(
label="",
x=key['column'],
y=key['row'],
)
if key['width'] != 1:
qmk_key['w'] = key['width']
if key['height'] != 1:
qmk_key['h'] = key['height']
if 'name' in key and key['name']:
qmk_key['label'] = key['name'].split('\n', 1)[0]
else:
del (qmk_key['label'])
layout.append(qmk_key)
return layout
|