mirror of
https://github.com/qmk/qmk_firmware.git
synced 2024-11-26 21:26:46 +00:00
Refactor based on recent discussion - Add back 'Layer Count'
This commit is contained in:
parent
d467ac8427
commit
dab3a4fde0
@ -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
|
||||
|
@ -128,8 +128,9 @@ This subsystem allows for query of currently configured keycodes.
|
||||
| Name | Route | Tags | Payloads | Description |
|
||||
| -- | -- | -- | -- | -- |
|
||||
| Capabilities Query | `0x04 0x01` | |<br>__Response:__ `u32`| Keymap subsystem capabilities query. Each bit should be considered as a "usable" route within this subsystem.|
|
||||
| Get Keycode | `0x04 0x02` | |<br>__Request:__<br> * Layer: `u8`<br> * Row: `u8`<br> * Column: `u8`<br>__Response:__ `u16`| Query the Keycode at the requested location.|
|
||||
| Get Encoder Keycode | `0x04 0x03` | |<br>__Request:__<br> * Layer: `u8`<br> * Encoder: `u8`<br> * Clockwise: `u8`<br>__Response:__ `u16`| Query the Keycode at the requested location.|
|
||||
| Get Layer Count | `0x04 0x02` | |<br>__Response:__ `u8`| Query maximum number of layers that can be addressed within the keymap.|
|
||||
| Get Keycode | `0x04 0x03` | |<br>__Request:__<br> * Layer: `u8`<br> * Row: `u8`<br> * Column: `u8`<br>__Response:__ `u16`| Query the Keycode at the requested location.|
|
||||
| Get Encoder Keycode | `0x04 0x04` | |<br>__Request:__<br> * Layer: `u8`<br> * Encoder: `u8`<br> * Clockwise: `u8`<br>__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` | |<br>__Response:__ `u32`| Remapping subsystem capabilities query. Each bit should be considered as a "usable" route within this subsystem.|
|
||||
| Set Keycode | `0x05 0x02` | __Secure__ |<br>__Request:__<br> * Layer: `u8`<br> * Row: `u8`<br> * Column: `u8`<br> * Keycode: `u16`| Modify the Keycode at the requested location.|
|
||||
| Set Encoder Keycode | `0x05 0x03` | __Secure__ |<br>__Request:__<br> * Layer: `u8`<br> * Encoder: `u8`<br> * Clockwise: `u8`<br> * Keycode: `u16`| Modify the Keycode at the requested location.|
|
||||
| Get Layer Count | `0x05 0x02` | |<br>__Response:__ `u8`| Query maximum number of layers that can be addressed within the keymap.|
|
||||
| Set Keycode | `0x05 0x03` | __Secure__ |<br>__Request:__<br> * Layer: `u8`<br> * Row: `u8`<br> * Column: `u8`<br> * Keycode: `u16`| Modify the Keycode at the requested location.|
|
||||
| Set Encoder Keycode | `0x05 0x04` | __Secure__ |<br>__Request:__<br> * Layer: `u8`<br> * Encoder: `u8`<br> * Clockwise: `u8`<br> * Keycode: `u16`| Modify the Keycode at the requested location.|
|
||||
|
||||
### Lighting - `0x06`
|
||||
This subsystem allows for control over the lighting subsystem.
|
||||
|
@ -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, "???"))
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user