mirror of
https://github.com/qmk/qmk_firmware.git
synced 2026-07-11 03:17:28 -04:00
stash
This commit is contained in:
@@ -7,7 +7,7 @@ from milc import cli
|
||||
from qmk.keyboard import render_layout
|
||||
from qmk.xap.common import get_xap_keycodes
|
||||
|
||||
from xap_client import XAPClient, XAPEventType, XAPSecureStatus
|
||||
from xap_client import XAPClient, XAPEventType, XAPSecureStatus, XAPConfigRgblight
|
||||
|
||||
KEYCODE_MAP = get_xap_keycodes('latest')
|
||||
|
||||
@@ -187,6 +187,14 @@ class XAPShell(cmd.Cmd):
|
||||
print('^C')
|
||||
return False
|
||||
|
||||
def do_dump(self, line):
|
||||
ret = self.device.transaction(b'\x06\x03\x03')
|
||||
ret = XAPConfigRgblight.from_bytes(ret)
|
||||
print(ret)
|
||||
|
||||
ret = self.device.int_transaction(b'\x06\x03\x02')
|
||||
print(f'XAPEffectRgblight(enabled={bin(ret)})')
|
||||
|
||||
|
||||
@cli.argument('-v', '--verbose', arg_only=True, action='store_true', help='Turns on verbose output.')
|
||||
@cli.argument('-d', '--device', help='device to select - uses format <pid>:<vid>.')
|
||||
|
||||
@@ -7,6 +7,7 @@ from pathlib import Path
|
||||
from typing import OrderedDict
|
||||
from jinja2 import Environment, FileSystemLoader, select_autoescape
|
||||
|
||||
from qmk.casing import to_snake
|
||||
from qmk.constants import QMK_FIRMWARE
|
||||
from qmk.json_schema import json_load, validate
|
||||
from qmk.decorators import lru_cache
|
||||
@@ -24,7 +25,7 @@ def _get_jinja2_env(data_templates_xap_subdir: str):
|
||||
|
||||
def render_xap_output(data_templates_xap_subdir, file_to_render, defs):
|
||||
j2 = _get_jinja2_env(data_templates_xap_subdir)
|
||||
return j2.get_template(file_to_render).render(xap=defs, xap_str=hjson.dumps(defs))
|
||||
return j2.get_template(file_to_render).render(xap=defs, xap_str=hjson.dumps(defs), to_snake=to_snake)
|
||||
|
||||
|
||||
def _find_kb_spec(kb):
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
from typing import List
|
||||
|
||||
|
||||
class XAPClient:
|
||||
"""XAP device discovery
|
||||
"""
|
||||
|
||||
@@ -61,3 +61,7 @@ class XAPRoutes():
|
||||
REMAPPING_SET_ENCODER_KEYCODE = b'\x05\x04'
|
||||
# LIGHTING
|
||||
LIGHTING_CAPABILITIES_QUERY = b'\x06\x01'
|
||||
LIGHTING_RGBLIGHT = b'\x06\x03'
|
||||
LIGHTING_RGBLIGHT_CAPABILITIES_QUERY = b'\x06\x03\x01'
|
||||
LIGHTING_RGBLIGHT_GET_ENABLED_EFFECTS = b'\x06\x03\x02'
|
||||
LIGHTING_RGBLIGHT_GET_CONFIG = b'\x06\x03\x03'
|
||||
|
||||
@@ -59,6 +59,29 @@ class XAPResponse(namedtuple('XAPResponse', 'token flags length data')):
|
||||
return self.fmt.pack(*list(self))
|
||||
|
||||
|
||||
class XAPConfigRgblight(namedtuple('XAPConfigRgblight', 'enable mode hue sat val speed')):
|
||||
fmt = Struct('<BBBBBB')
|
||||
|
||||
def __new__(cls, *args):
|
||||
return super().__new__(cls, *args)
|
||||
|
||||
@classmethod
|
||||
def from_bytes(cls, data):
|
||||
return cls._make(cls.fmt.unpack(data))
|
||||
|
||||
def to_bytes(self):
|
||||
return self.fmt.pack(*list(self))
|
||||
|
||||
|
||||
# Spec structs
|
||||
# TODO: gen outbound object for board_identifiers
|
||||
# TODO: gen inbound object for get_keymap_keycode
|
||||
# TODO: gen inbound object for get_encoder_keycode
|
||||
# TODO: gen inbound object for set_keymap_keycode
|
||||
# TODO: gen inbound object for set_encoder_keycode
|
||||
# TODO: gen outbound object for get_config
|
||||
|
||||
|
||||
class XAPSecureStatus(IntEnum):
|
||||
LOCKED = 0x00
|
||||
UNLOCKING = 0x01
|
||||
|
||||
Reference in New Issue
Block a user