Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[kle2json] [WIP] populate rotation in info.json #8980

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions lib/python/kle2xy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,20 @@ def __init__(self, layout=None, name='', invert_y=True):
self.name = name
self.invert_y = invert_y
self.key_width = Decimal('19.05')
self.key_skel = {'decal': False, 'border_color': 'none', 'keycap_profile': '', 'keycap_color': 'grey', 'label_color': 'black', 'label_size': 3, 'label_style': 4, 'width': Decimal('1'), 'height': Decimal('1')}
self.key_skel = {
'decal': False,
'border_color': 'none',
'keycap_profile': '',
'keycap_color': 'grey',
'label_color': 'black',
'label_size': 3,
'label_style': 4,
'width': Decimal('1'),
'height': Decimal('1'),
'r': Decimal('0'),
'rx': Decimal('0'),
'ry': Decimal('0')
}
self.rows = Decimal(0)
self.columns = Decimal(0)

Expand Down Expand Up @@ -88,6 +101,12 @@ def parse_layout(self, layout): # noqa FIXME(skullydazed): flake8 says this ha
if key['t'] == "0":
key['t'] = "#000000"
current_key['label_color'] = self.key_skel['label_color'] = key['t']
if 'r' in key:
current_key['r'] = self.key_skel['r'] = Decimal(key['r'])
if 'rx' in key:
current_col = current_key['rx'] = self.key_skel['rx'] = Decimal(key['rx'])
if 'ry' in key:
current_row = current_key['ry'] = self.key_skel['ry'] = Decimal(key['ry'])
if 'x' in key:
current_col += Decimal(key['x'])
if 'y' in key:
Expand All @@ -97,8 +116,8 @@ def parse_layout(self, layout): # noqa FIXME(skullydazed): flake8 says this ha

else:
current_key['name'] = key
current_key['row'] = round(current_row, 2)
current_key['column'] = round(current_col, 2)
current_key['row'] = round(current_row, 3)
current_key['column'] = round(current_col, 3)

# x,y (units mm) is the center of the key
x_center = current_col + current_key['width'] / 2
Expand All @@ -120,7 +139,7 @@ def parse_layout(self, layout): # noqa FIXME(skullydazed): flake8 says this ha
current_key = self.key_skel.copy()

# Move to the next row
current_col = Decimal(0)
current_col = self.key_skel['ry']
current_row += Decimal(1)
if current_row > self.rows:
self.rows = Decimal(current_row)
4 changes: 4 additions & 0 deletions lib/python/qmk/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ def kle2qmk(kle):
qmk_key['w'] = key['width']
if key['height'] != 1:
qmk_key['h'] = key['height']
if 'r' in key and key['r'] != 0:
qmk_key['r'] = key['r'];
qmk_key['rx'] = key.get('rx', 0);
qmk_key['ry'] = key.get('ry', 0);
if 'name' in key and key['name']:
qmk_key['label'] = key['name'].split('\n', 1)[0]
else:
Expand Down