diff --git a/data/xap/xap_0.2.0.hjson b/data/xap/xap_0.2.0.hjson index 20118d93f4..245fa3e4ed 100755 --- a/data/xap/xap_0.2.0.hjson +++ b/data/xap/xap_0.2.0.hjson @@ -24,6 +24,14 @@ return_constant: XAP_ROUTE_KEYMAP_CAPABILITIES } 0x02: { + type: command + name: Get Layer Count + define: GET_LAYER_COUNT + description: Query maximum number of layers that can be addressed within the keymap. + return_type: u8 + return_execute: keymap_get_layer_count + } + 0x03: { type: command name: Get Keycode define: GET_KEYMAP_KEYCODE @@ -47,7 +55,7 @@ return_type: u16 return_execute: get_keymap_keycode } - 0x03: { + 0x04: { type: command name: Get Encoder Keycode define: GET_ENCODER_KEYCODE @@ -98,6 +106,14 @@ return_constant: XAP_ROUTE_REMAPPING_CAPABILITIES } 0x02: { + type: command + name: Get Layer Count + define: GET_DYNAMIC_LAYER_COUNT + description: Query maximum number of layers that can be addressed within the keymap. + return_type: u8 + return_constant: DYNAMIC_KEYMAP_LAYER_COUNT + } + 0x03: { type: command name: Set Keycode define: SET_KEYMAP_KEYCODE @@ -125,7 +141,7 @@ ] return_execute: dynamic_keymap_set_keycode } - 0x03: { + 0x04: { type: command name: Set Encoder Keycode define: SET_ENCODER_KEYCODE diff --git a/docs/xap_0.2.0.md b/docs/xap_0.2.0.md index e1d1a0882b..30f51dd863 100644 --- a/docs/xap_0.2.0.md +++ b/docs/xap_0.2.0.md @@ -128,8 +128,9 @@ This subsystem allows for query of currently configured keycodes. | Name | Route | Tags | Payloads | Description | | -- | -- | -- | -- | -- | | Capabilities Query | `0x04 0x01` | |
__Response:__ `u32`| Keymap subsystem capabilities query. Each bit should be considered as a "usable" route within this subsystem.| -| Get Keycode | `0x04 0x02` | |
__Request:__
    * Layer: `u8`
    * Row: `u8`
    * Column: `u8`
__Response:__ `u16`| Query the Keycode at the requested location.| -| Get Encoder Keycode | `0x04 0x03` | |
__Request:__
    * Layer: `u8`
    * Encoder: `u8`
    * Clockwise: `u8`
__Response:__ `u16`| Query the Keycode at the requested location.| +| Get Layer Count | `0x04 0x02` | |
__Response:__ `u8`| Query maximum number of layers that can be addressed within the keymap.| +| Get Keycode | `0x04 0x03` | |
__Request:__
    * Layer: `u8`
    * Row: `u8`
    * Column: `u8`
__Response:__ `u16`| Query the Keycode at the requested location.| +| Get Encoder Keycode | `0x04 0x04` | |
__Request:__
    * Layer: `u8`
    * Encoder: `u8`
    * Clockwise: `u8`
__Response:__ `u16`| Query the Keycode at the requested location.| ### Remapping - `0x05` This subsystem allows for live reassignment of keycodes without rebuilding the firmware. @@ -138,8 +139,9 @@ This subsystem allows for live reassignment of keycodes without rebuilding the f | Name | Route | Tags | Payloads | Description | | -- | -- | -- | -- | -- | | Capabilities Query | `0x05 0x01` | |
__Response:__ `u32`| Remapping subsystem capabilities query. Each bit should be considered as a "usable" route within this subsystem.| -| Set Keycode | `0x05 0x02` | __Secure__ |
__Request:__
    * Layer: `u8`
    * Row: `u8`
    * Column: `u8`
    * Keycode: `u16`| Modify the Keycode at the requested location.| -| Set Encoder Keycode | `0x05 0x03` | __Secure__ |
__Request:__
    * Layer: `u8`
    * Encoder: `u8`
    * Clockwise: `u8`
    * Keycode: `u16`| Modify the Keycode at the requested location.| +| Get Layer Count | `0x05 0x02` | |
__Response:__ `u8`| Query maximum number of layers that can be addressed within the keymap.| +| Set Keycode | `0x05 0x03` | __Secure__ |
__Request:__
    * Layer: `u8`
    * Row: `u8`
    * Column: `u8`
    * Keycode: `u16`| Modify the Keycode at the requested location.| +| Set Encoder Keycode | `0x05 0x04` | __Secure__ |
__Request:__
    * Layer: `u8`
    * Encoder: `u8`
    * Clockwise: `u8`
    * Keycode: `u16`| Modify the Keycode at the requested location.| ### Lighting - `0x06` This subsystem allows for control over the lighting subsystem. diff --git a/lib/python/qmk/cli/xap/xap.py b/lib/python/qmk/cli/xap/xap.py index 272f667a12..2de6663684 100644 --- a/lib/python/qmk/cli/xap/xap.py +++ b/lib/python/qmk/cli/xap/xap.py @@ -165,21 +165,21 @@ def _list_devices(): # def xap_dummy(device): # # get layer count -# layers = _xap_transaction(device, 0x04, 0x00) +# layers = _xap_transaction(device, 0x04, 0x02) # layers = int.from_bytes(layers, "little") # print(f'layers:{layers}') # # get keycode [layer:0, row:0, col:0] -# # keycode = _xap_transaction(device, 0x04, 0x02, b"\x00\x00\x00") +# # keycode = _xap_transaction(device, 0x04, 0x03, b"\x00\x00\x00") # # get encoder [layer:0, index:0, clockwise:0] -# keycode = _xap_transaction(device, 0x04, 0x03, b"\x00\x00\x00") +# keycode = _xap_transaction(device, 0x04, 0x04, b"\x00\x00\x00") # keycode = int.from_bytes(keycode, "little") # print(f'keycode:{KEYCODE_MAP.get(keycode, "unknown")}[{keycode}]') # # set encoder [layer:0, index:0, clockwise:0, keycode:KC_A] -# _xap_transaction(device, 0x05, 0x03, b"\x00\x00\x00\x04\00") +# _xap_transaction(device, 0x05, 0x04, b"\x00\x00\x00\x04\00") def xap_broadcast_listen(device): @@ -235,7 +235,7 @@ class XAPShell(cmd.Cmd): cli.log.error("Invalid args") return - keycode = _xap_transaction(self.device, 0x04, 0x02, data) + keycode = _xap_transaction(self.device, 0x04, 0x03, data) keycode = int.from_bytes(keycode, "little") print(f'keycode:{self.keycodes.get(keycode, "unknown")}[{keycode}]') @@ -254,7 +254,7 @@ class XAPShell(cmd.Cmd): for r in range(rows): for c in range(cols): q = data + r.to_bytes(1, byteorder='little') + c.to_bytes(1, byteorder='little') - keycode = _xap_transaction(self.device, 0x04, 0x02, q) + keycode = _xap_transaction(self.device, 0x04, 0x03, q) keycode = int.from_bytes(keycode, "little") print(f'| {self.keycodes.get(keycode, "unknown").ljust(7)} ', end='', flush=True) print('|') @@ -276,7 +276,7 @@ class XAPShell(cmd.Cmd): keycodes = [] for item in layout: q = data + bytes(item['matrix']) - keycode = _xap_transaction(self.device, 0x04, 0x02, q) + keycode = _xap_transaction(self.device, 0x04, 0x03, q) keycode = int.from_bytes(keycode, "little") keycodes.append(self.keycodes.get(keycode, "???")) diff --git a/quantum/xap/xap_handlers.c b/quantum/xap/xap_handlers.c index bd9cda148b..8ae9bcedf5 100644 --- a/quantum/xap/xap_handlers.c +++ b/quantum/xap/xap_handlers.c @@ -104,6 +104,11 @@ bool xap_respond_get_hardware_id(xap_token_t token, const void *data, size_t len return xap_respond_data(token, &ret, sizeof(ret)); } +bool xap_respond_keymap_get_layer_count(xap_token_t token, const void *data, size_t length) { + uint8_t ret = keymap_layer_count(); + return xap_respond_data(token, &ret, sizeof(ret)); +} + bool xap_respond_get_keymap_keycode(xap_token_t token, const void *data, size_t length) { if (length != sizeof(xap_route_keymap_get_keymap_keycode_arg_t)) { return false;