mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-03-01 02:33:53 +00:00
Stub out python client routes
This commit is contained in:
parent
2a1bfafa1a
commit
e4a41e8795
9
data/templates/xap/client/python/routes.py.j2
Normal file
9
data/templates/xap/client/python/routes.py.j2
Normal file
@ -0,0 +1,9 @@
|
||||
# TODO: assumption of only one level of children
|
||||
{%- for id, route in xap.routes | dictsort %}
|
||||
{%- if route.routes %}
|
||||
# {{route.define}}
|
||||
{%- for subid, subroute in route.routes | dictsort %}
|
||||
{{route.define}}_{{subroute.define}} = b'\x{{ '%02d' % id|int(base=16) }}\x{{ '%02d' % subid|int(base=16) }}'
|
||||
{%- endfor %}
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
@ -13,7 +13,7 @@ def xap_generate_python(cli):
|
||||
defs = latest_xap_defs()
|
||||
|
||||
parent = QMK_FIRMWARE / 'lib' / 'python' / 'xap_client'
|
||||
for name in ['types.py']:
|
||||
for name in ['types.py', 'routes.py']:
|
||||
lines = [GPL2_HEADER_SH_LIKE, GENERATED_HEADER_SH_LIKE]
|
||||
|
||||
output = render_xap_output('client/python', f'{name}.j2', defs)
|
||||
|
@ -2,8 +2,6 @@
|
||||
"""
|
||||
import hid
|
||||
|
||||
from .device import XAPDevice
|
||||
|
||||
|
||||
class XAPClient:
|
||||
@staticmethod
|
||||
@ -26,4 +24,6 @@ class XAPClient:
|
||||
def connect(self, dev):
|
||||
"""Connect to a given XAP device
|
||||
"""
|
||||
from .device import XAPDevice
|
||||
|
||||
return XAPDevice(dev)
|
||||
|
@ -11,6 +11,7 @@ from collections import namedtuple
|
||||
from platform import platform
|
||||
|
||||
from .types import XAPSecureStatus, XAPFlags, XAPRouteError
|
||||
from .routes import XAP_VERSION_QUERY
|
||||
|
||||
RequestPacket = namedtuple('RequestPacket', 'token length data')
|
||||
RequestStruct = Struct('<HB61s')
|
||||
@ -131,7 +132,7 @@ class XAPDevice:
|
||||
|
||||
@functools.lru_cache
|
||||
def version(self):
|
||||
ver = int.from_bytes(self._transaction(b'\x00\x00') or bytes(0), 'little')
|
||||
ver = int.from_bytes(self._transaction(XAP_VERSION_QUERY) or bytes(0), 'little')
|
||||
return {'xap': _u32toBCD(ver)}
|
||||
|
||||
def _ensure_route(self, route):
|
||||
|
58
lib/python/xap_client/routes.py
Normal file
58
lib/python/xap_client/routes.py
Normal file
@ -0,0 +1,58 @@
|
||||
# Copyright 2022 QMK
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# 88888888888 888 d8b .d888 d8b 888 d8b
|
||||
# 888 888 Y8P d88P" Y8P 888 Y8P
|
||||
# 888 888 888 888
|
||||
# 888 88888b. 888 .d8888b 888888 888 888 .d88b. 888 .d8888b
|
||||
# 888 888 "88b 888 88K 888 888 888 d8P Y8b 888 88K
|
||||
# 888 888 888 888 "Y8888b. 888 888 888 88888888 888 "Y8888b.
|
||||
# 888 888 888 888 X88 888 888 888 Y8b. 888 X88
|
||||
# 888 888 888 888 88888P' 888 888 888 "Y8888 888 88888P'
|
||||
#
|
||||
# 888 888
|
||||
# 888 888
|
||||
# 888 888
|
||||
# .d88b. .d88b. 88888b. .d88b. 888d888 8888b. 888888 .d88b. .d88888
|
||||
# d88P"88b d8P Y8b 888 "88b d8P Y8b 888P" "88b 888 d8P Y8b d88" 888
|
||||
# 888 888 88888888 888 888 88888888 888 .d888888 888 88888888 888 888
|
||||
# Y88b 888 Y8b. 888 888 Y8b. 888 888 888 Y88b. Y8b. Y88b 888
|
||||
# "Y88888 "Y8888 888 888 "Y8888 888 "Y888888 "Y888 "Y8888 "Y88888
|
||||
# 888
|
||||
# Y8b d88P
|
||||
# "Y88P"
|
||||
#
|
||||
################################################################################
|
||||
|
||||
# TODO: assumption of only one level of children
|
||||
# XAP
|
||||
XAP_VERSION_QUERY = b'\x00\x00'
|
||||
XAP_CAPABILITIES_QUERY = b'\x00\x01'
|
||||
XAP_SUBSYSTEM_QUERY = b'\x00\x02'
|
||||
XAP_SECURE_STATUS = b'\x00\x03'
|
||||
XAP_SECURE_UNLOCK = b'\x00\x04'
|
||||
XAP_SECURE_LOCK = b'\x00\x05'
|
||||
# QMK
|
||||
QMK_VERSION_QUERY = b'\x01\x00'
|
||||
QMK_CAPABILITIES_QUERY = b'\x01\x01'
|
||||
QMK_BOARD_IDENTIFIERS = b'\x01\x02'
|
||||
QMK_BOARD_MANUFACTURER = b'\x01\x03'
|
||||
QMK_PRODUCT_NAME = b'\x01\x04'
|
||||
QMK_CONFIG_BLOB_LEN = b'\x01\x05'
|
||||
QMK_CONFIG_BLOB_CHUNK = b'\x01\x06'
|
||||
QMK_BOOTLOADER_JUMP = b'\x01\x07'
|
||||
QMK_HARDWARE_ID = b'\x01\x08'
|
||||
# KEYMAP
|
||||
KEYMAP_CAPABILITIES_QUERY = b'\x04\x01'
|
||||
KEYMAP_GET_LAYER_COUNT = b'\x04\x02'
|
||||
KEYMAP_GET_KEYMAP_KEYCODE = b'\x04\x03'
|
||||
KEYMAP_GET_ENCODER_KEYCODE = b'\x04\x04'
|
||||
# REMAPPING
|
||||
REMAPPING_CAPABILITIES_QUERY = b'\x05\x01'
|
||||
REMAPPING_GET_DYNAMIC_LAYER_COUNT = b'\x05\x02'
|
||||
REMAPPING_SET_KEYMAP_KEYCODE = b'\x05\x03'
|
||||
REMAPPING_SET_ENCODER_KEYCODE = b'\x05\x04'
|
||||
# LIGHTING
|
||||
LIGHTING_CAPABILITIES_QUERY = b'\x06\x01'
|
Loading…
Reference in New Issue
Block a user