Render layers with 'qmk info' logic
This commit is contained in:
parent
87106e44c8
commit
68208278e0
2 changed files with 28 additions and 5 deletions
|
@ -210,7 +210,7 @@
|
|||
"0x0028": {
|
||||
"group": "basic",
|
||||
"key": "KC_ENTER",
|
||||
"label": "0",
|
||||
"label": "Enter",
|
||||
"aliases": [
|
||||
"KC_ENT"
|
||||
]
|
||||
|
@ -218,7 +218,7 @@
|
|||
"0x0029": {
|
||||
"group": "basic",
|
||||
"key": "KC_ESCAPE",
|
||||
"label": "0",
|
||||
"label": "Esc",
|
||||
"aliases": [
|
||||
"KC_ESC"
|
||||
]
|
||||
|
@ -226,7 +226,7 @@
|
|||
"0x002a": {
|
||||
"group": "basic",
|
||||
"key": "KC_BACKSPACE",
|
||||
"label": "0",
|
||||
"label": "Backspace",
|
||||
"aliases": [
|
||||
"KC_BSPC"
|
||||
]
|
||||
|
|
|
@ -8,6 +8,7 @@ from platform import platform
|
|||
|
||||
from milc import cli
|
||||
|
||||
from qmk.keyboard import render_layout
|
||||
from qmk.xap.common import get_xap_keycodes
|
||||
|
||||
KEYCODE_MAP = get_xap_keycodes('latest')
|
||||
|
@ -86,7 +87,7 @@ def _xap_transaction(device, sub, route, *args):
|
|||
device.write(buffer)
|
||||
|
||||
# get resp
|
||||
array_alpha = device.read(64, 100)
|
||||
array_alpha = device.read(64, 250)
|
||||
|
||||
# validate tok sent == resp
|
||||
if str(token) != str(array_alpha[:2]):
|
||||
|
@ -250,7 +251,6 @@ class XAPShell(cmd.Cmd):
|
|||
rows = info['matrix_size']['rows']
|
||||
cols = info['matrix_size']['cols']
|
||||
|
||||
# TODO: render like qmk info?
|
||||
for r in range(rows):
|
||||
for c in range(cols):
|
||||
q = data + r.to_bytes(1, byteorder='little') + c.to_bytes(1, byteorder='little')
|
||||
|
@ -259,6 +259,29 @@ class XAPShell(cmd.Cmd):
|
|||
print(f'| {self.keycodes.get(keycode, "unknown").ljust(7)} ', end='', flush=True)
|
||||
print('|')
|
||||
|
||||
def do_layer(self, arg):
|
||||
"""Renders keycode values of a certain layer
|
||||
"""
|
||||
data = bytes(map(int, arg.split()))
|
||||
if len(data) != 1:
|
||||
cli.log.error("Invalid args")
|
||||
return
|
||||
|
||||
info = _query_device_info(self.device)
|
||||
|
||||
# Assumptions on selected layout rather than prompt
|
||||
first_layout = next(iter(info['layouts']))
|
||||
layout = info['layouts'][first_layout]['layout']
|
||||
|
||||
keycodes = []
|
||||
for item in layout:
|
||||
q = data + bytes(item['matrix'])
|
||||
keycode = _xap_transaction(self.device, 0x04, 0x02, q)
|
||||
keycode = int.from_bytes(keycode, "little")
|
||||
keycodes.append(self.keycodes.get(keycode, "???"))
|
||||
|
||||
print(render_layout(layout, False, keycodes))
|
||||
|
||||
def do_exit(self, line):
|
||||
"""Quit shell
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue