diff --git a/builddefs/xap.mk b/builddefs/xap.mk
index a0c0dc38ed0..14c3ada9f4b 100644
--- a/builddefs/xap.mk
+++ b/builddefs/xap.mk
@@ -21,9 +21,9 @@ ifneq ("$(wildcard $(KEYMAP_PATH)/xap.hjson)","")
XAP_FILES += $(KEYMAP_PATH)/xap.hjson
endif
-$(KEYMAP_OUTPUT)/src/info_json_gz.h: $(INFO_JSON_FILES)
+$(KEYMAP_OUTPUT)/src/config_blob_gz.h: $(INFO_JSON_FILES)
@$(SILENT) || printf "$(MSG_GENERATING) $@" | $(AWK_CMD)
- $(eval CMD=$(QMK_BIN) xap-generate-info-h -o "$(KEYMAP_OUTPUT)/src/info_json_gz.h" -kb $(KEYBOARD) -km $(KEYMAP))
+ $(eval CMD=$(QMK_BIN) xap-generate-qmk-blob-h -o "$(KEYMAP_OUTPUT)/src/config_blob_gz.h" -kb $(KEYBOARD) -km $(KEYMAP))
@$(BUILD_CMD)
$(KEYMAP_OUTPUT)/src/xap_generated.inl: $(XAP_FILES)
@@ -36,6 +36,6 @@ $(KEYMAP_OUTPUT)/src/xap_generated.h: $(XAP_FILES)
$(eval CMD=$(QMK_BIN) xap-generate-qmk-h -o "$(KEYMAP_OUTPUT)/src/xap_generated.h" -kb $(KEYBOARD) -km $(KEYMAP))
@$(BUILD_CMD)
-generated-files: $(KEYMAP_OUTPUT)/src/info_json_gz.h $(KEYMAP_OUTPUT)/src/xap_generated.inl $(KEYMAP_OUTPUT)/src/xap_generated.h
+generated-files: $(KEYMAP_OUTPUT)/src/config_blob_gz.h $(KEYMAP_OUTPUT)/src/xap_generated.inl $(KEYMAP_OUTPUT)/src/xap_generated.h
VPATH += $(KEYMAP_OUTPUT)/src
diff --git a/data/xap/xap_0.1.0.hjson b/data/xap/xap_0.1.0.hjson
index 361a37461e1..8965f2b5136 100755
--- a/data/xap/xap_0.1.0.hjson
+++ b/data/xap/xap_0.1.0.hjson
@@ -296,21 +296,21 @@
}
0x05: {
type: command
- name: info.json length
- define: INFO_LEN_QUERY
- description: Retrieves the length of info.json
+ name: Config Blob Length
+ define: CONFIG_BLOB_LEN
+ description: Retrieves the length of the configuration data bundled within the firmware
return_type: u32
- return_constant: INFO_JSON_GZ_LEN
+ return_constant: CONFIG_BLOB_GZ_LEN
}
0x06: {
type: command
- name: info.json
- define: INFO_QUERY
- description: Retrieves a chunk of info.json
+ name: Config Blob Chunk
+ define: CONFIG_BLOB_CHUNK
+ description: Retrieves a chunk of the configuration data bundled within the firmware
request_type: u16
request_purpose: offset
return_type: u8[32]
- return_execute: get_info_json_chunk
+ return_execute: get_config_blob_chunk
}
0x07: {
type: command
@@ -332,7 +332,7 @@
}
0x08: {
type: command
- name: info.json
+ name: Unique Identifier
define: HARDWARE_ID
description: Retrieves a unique identifier for the board.
return_type: u32[4]
diff --git a/data/xap/xap_0.2.0.hjson b/data/xap/xap_0.2.0.hjson
index 6c791ffd429..20118d93f41 100755
--- a/data/xap/xap_0.2.0.hjson
+++ b/data/xap/xap_0.2.0.hjson
@@ -4,33 +4,24 @@
routes: {
0x04: {
type: router
- name: Dynamic Keymap
- define: DYNAMIC_KEYMAP
+ name: Keymap
+ define: KEYMAP
description:
'''
- This subsystem allows for live modifications of the keymap, allowing keys to be reassigned without rebuilding the firmware.
+ This subsystem allows for query of currently configured keycodes.
'''
- enable_if_preprocessor: defined(DYNAMIC_KEYMAP_ENABLE)
routes: {
- 0x00: {
+ 0x01: {
type: command
name: Capabilities Query
define: CAPABILITIES_QUERY
description:
'''
- Dynamic Keymap subsystem capabilities query. Each bit should be considered as a "usable" route within this subsystem.
+ Keymap subsystem capabilities query. Each bit should be considered as a "usable" route within this subsystem.
'''
return_type: u32
return_purpose: capabilities
- return_constant: XAP_ROUTE_DYNAMIC_KEYMAP_CAPABILITIES
- }
- 0x01: {
- 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_constant: DYNAMIC_KEYMAP_LAYER_COUNT
+ return_constant: XAP_ROUTE_KEYMAP_CAPABILITIES
}
0x02: {
type: command
@@ -54,9 +45,59 @@
}
]
return_type: u16
- return_execute: dynamic_keymap_get_keycode
+ return_execute: get_keymap_keycode
}
0x03: {
+ type: command
+ name: Get Encoder Keycode
+ define: GET_ENCODER_KEYCODE
+ description: Query the Keycode at the requested location.
+ enable_if_preprocessor: defined(ENCODER_MAP_ENABLE)
+ request_type: struct
+ request_struct_length: 3
+ request_struct_members: [
+ {
+ type: u8
+ name: Layer
+ },
+ {
+ type: u8
+ name: Encoder
+ },
+ {
+ type: u8
+ name: Clockwise
+ }
+ ]
+ return_type: u16
+ return_execute: get_encoder_keycode
+ }
+ }
+ }
+
+ 0x05: {
+ type: router
+ name: Remapping
+ define: REMAPPING
+ description:
+ '''
+ This subsystem allows for live reassignment of keycodes without rebuilding the firmware.
+ '''
+ enable_if_preprocessor: defined(DYNAMIC_KEYMAP_ENABLE)
+ routes: {
+ 0x01: {
+ type: command
+ name: Capabilities Query
+ define: CAPABILITIES_QUERY
+ description:
+ '''
+ Remapping subsystem capabilities query. Each bit should be considered as a "usable" route within this subsystem.
+ '''
+ return_type: u32
+ return_purpose: capabilities
+ return_constant: XAP_ROUTE_REMAPPING_CAPABILITIES
+ }
+ 0x02: {
type: command
name: Set Keycode
define: SET_KEYMAP_KEYCODE
@@ -84,61 +125,13 @@
]
return_execute: dynamic_keymap_set_keycode
}
- }
- }
-
- 0x05: {
- type: router
- name: Dynamic Encoders
- define: DYNAMIC_ENCODER
- description:
- '''
- This subsystem allows for live modifications of the keymap, allowing encoder functionality to be reassigned without rebuilding the firmware.
- '''
- enable_if_preprocessor: defined(DYNAMIC_KEYMAP_ENABLE) && defined(ENCODER_MAP_ENABLE)
- routes: {
- 0x00: {
- type: command
- name: Capabilities Query
- define: CAPABILITIES_QUERY
- description:
- '''
- Dynamic Encoders subsystem capabilities query. Each bit should be considered as a "usable" route within this subsystem.
- '''
- return_type: u32
- return_purpose: capabilities
- return_constant: XAP_ROUTE_DYNAMIC_ENCODER_CAPABILITIES
- }
- 0x02: {
- type: command
- name: Get Keycode
- define: GET_ENCODER_KEYCODE
- description: Query the Keycode at the requested location.
- request_type: struct
- request_struct_length: 3
- request_struct_members: [
- {
- type: u8
- name: Layer
- },
- {
- type: u8
- name: Encoder
- },
- {
- type: u8
- name: Clockwise
- }
- ]
- return_type: u16
- return_execute: dynamic_encoder_get_keycode
- }
0x03: {
type: command
- name: Set Keycode
+ name: Set Encoder Keycode
define: SET_ENCODER_KEYCODE
permissions: secure
description: Modify the Keycode at the requested location.
+ enable_if_preprocessor: defined(ENCODER_MAP_ENABLE)
request_type: struct
request_struct_length: 5
request_struct_members: [
@@ -174,7 +167,7 @@
'''
enable_if_preprocessor: defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
routes: {
- 0x00: {
+ 0x01: {
type: command
name: Capabilities Query
define: CAPABILITIES_QUERY
diff --git a/docs/xap_0.1.0.md b/docs/xap_0.1.0.md
index cd9036cff1e..8c54aff882c 100644
--- a/docs/xap_0.1.0.md
+++ b/docs/xap_0.1.0.md
@@ -108,10 +108,10 @@ This subsystem is always present, and provides the ability to address QMK-specif
| Board identifiers | `0x01 0x02` | |
__Response:__
* Vendor ID: `u16`
* Product ID: `u16`
* Product Version: `u16`
* QMK Unique Identifier: `u32`| Retrieves the set of identifying information for the board.|
| Board Manufacturer | `0x01 0x03` | |
__Response:__ `string`| Retrieves the name of the manufacturer|
| Product Name | `0x01 0x04` | |
__Response:__ `string`| Retrieves the product name|
-| info.json length | `0x01 0x05` | |
__Response:__ `u32`| Retrieves the length of info.json|
-| info.json | `0x01 0x06` | |
__Request:__ `u16`
__Response:__ `u8[32]`| Retrieves a chunk of info.json|
+| Config Blob Length | `0x01 0x05` | |
__Response:__ `u32`| Retrieves the length of the configuration data bundled within the firmware|
+| Config Blob Chunk | `0x01 0x06` | |
__Request:__ `u16`
__Response:__ `u8[32]`| Retrieves a chunk of the configuration data bundled within the firmware|
| Jump to bootloader | `0x01 0x07` | __Secure__ |
__Response:__ `u8`| Jump to bootloader
May not be present – if QMK capabilities query returns “true”, then jump to bootloader is supported
* 0 means secure routes are disabled, and should be considered as a failure
* 1 means successful, board will jump to bootloader|
-| info.json | `0x01 0x08` | |
__Response:__ `u32[4]`| Retrieves a unique identifier for the board.|
+| Unique Identifier | `0x01 0x08` | |
__Response:__ `u32[4]`| Retrieves a unique identifier for the board.|
### Keyboard - `0x02`
This subsystem is always present, and reserved for user-specific functionality. No routes are defined by XAP.
diff --git a/docs/xap_0.2.0.md b/docs/xap_0.2.0.md
index ed2130e34fd..e1d1a0882b2 100644
--- a/docs/xap_0.2.0.md
+++ b/docs/xap_0.2.0.md
@@ -108,10 +108,10 @@ This subsystem is always present, and provides the ability to address QMK-specif
| Board identifiers | `0x01 0x02` | |
__Response:__
* Vendor ID: `u16`
* Product ID: `u16`
* Product Version: `u16`
* QMK Unique Identifier: `u32`| Retrieves the set of identifying information for the board.|
| Board Manufacturer | `0x01 0x03` | |
__Response:__ `string`| Retrieves the name of the manufacturer|
| Product Name | `0x01 0x04` | |
__Response:__ `string`| Retrieves the product name|
-| info.json length | `0x01 0x05` | |
__Response:__ `u32`| Retrieves the length of info.json|
-| info.json | `0x01 0x06` | |
__Request:__ `u16`
__Response:__ `u8[32]`| Retrieves a chunk of info.json|
+| Config Blob Length | `0x01 0x05` | |
__Response:__ `u32`| Retrieves the length of the configuration data bundled within the firmware|
+| Config Blob Chunk | `0x01 0x06` | |
__Request:__ `u16`
__Response:__ `u8[32]`| Retrieves a chunk of the configuration data bundled within the firmware|
| Jump to bootloader | `0x01 0x07` | __Secure__ |
__Response:__ `u8`| Jump to bootloader
May not be present – if QMK capabilities query returns “true”, then jump to bootloader is supported
* 0 means secure routes are disabled, and should be considered as a failure
* 1 means successful, board will jump to bootloader|
-| info.json | `0x01 0x08` | |
__Response:__ `u32[4]`| Retrieves a unique identifier for the board.|
+| Unique Identifier | `0x01 0x08` | |
__Response:__ `u32[4]`| Retrieves a unique identifier for the board.|
### Keyboard - `0x02`
This subsystem is always present, and reserved for user-specific functionality. No routes are defined by XAP.
@@ -121,26 +121,25 @@ This subsystem is always present, and reserved for user-specific functionality.
This subsystem is always present, and reserved for user-specific functionality. No routes are defined by XAP.
-### Dynamic Keymap - `0x04`
-This subsystem allows for live modifications of the keymap, allowing keys to be reassigned without rebuilding the firmware.
+### Keymap - `0x04`
+This subsystem allows for query of currently configured keycodes.
| Name | Route | Tags | Payloads | Description |
| -- | -- | -- | -- | -- |
-| Capabilities Query | `0x04 0x00` | |
__Response:__ `u32`| Dynamic Keymap subsystem capabilities query. Each bit should be considered as a "usable" route within this subsystem.|
-| Get Layer Count | `0x04 0x01` | |
__Response:__ `u8`| Query maximum number of layers that can be addressed within the keymap.|
+| 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.|
-| Set Keycode | `0x04 0x03` | __Secure__ |
__Request:__
* Layer: `u8`
* Row: `u8`
* Column: `u8`
* Keycode: `u16`| Modify 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.|
-### Dynamic Encoders - `0x05`
-This subsystem allows for live modifications of the keymap, allowing encoder functionality to be reassigned without rebuilding the firmware.
+### Remapping - `0x05`
+This subsystem allows for live reassignment of keycodes without rebuilding the firmware.
| Name | Route | Tags | Payloads | Description |
| -- | -- | -- | -- | -- |
-| Capabilities Query | `0x05 0x00` | |
__Response:__ `u32`| Dynamic Encoders subsystem capabilities query. Each bit should be considered as a "usable" route within this subsystem.|
-| Get Keycode | `0x05 0x02` | |
__Request:__
* Layer: `u8`
* Encoder: `u8`
* Clockwise: `u8`
__Response:__ `u16`| Query the Keycode at the requested location.|
-| Set Keycode | `0x05 0x03` | __Secure__ |
__Request:__
* Layer: `u8`
* Encoder: `u8`
* Clockwise: `u8`
* Keycode: `u16`| Modify the Keycode at the requested location.|
+| 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.|
### Lighting - `0x06`
This subsystem allows for control over the lighting subsystem.
@@ -148,7 +147,7 @@ This subsystem allows for control over the lighting subsystem.
| Name | Route | Tags | Payloads | Description |
| -- | -- | -- | -- | -- |
-| Capabilities Query | `0x06 0x00` | |
__Response:__ `u32`| Lighting subsystem capabilities query. Each bit should be considered as a "usable" route within this subsystem.|
+| Capabilities Query | `0x06 0x01` | |
__Response:__ `u32`| Lighting subsystem capabilities query. Each bit should be considered as a "usable" route within this subsystem.|
## Broadcast messages
diff --git a/lib/python/qmk/cli/xap/generate_qmk.py b/lib/python/qmk/cli/xap/generate_qmk.py
index d4ebb7e9dbd..5144d5fd722 100755
--- a/lib/python/qmk/cli/xap/generate_qmk.py
+++ b/lib/python/qmk/cli/xap/generate_qmk.py
@@ -4,7 +4,7 @@ from milc import cli
from qmk.path import normpath
from qmk.keyboard import keyboard_completer, keyboard_folder
-from qmk.xap.gen_firmware.info_generator import generate_info
+from qmk.xap.gen_firmware.blob_generator import generate_blob
from qmk.xap.gen_firmware.inline_generator import generate_inline
from qmk.xap.gen_firmware.header_generator import generate_header
@@ -52,9 +52,9 @@ def xap_generate_qmk_h(cli):
@cli.argument('-o', '--output', type=normpath, help='File to write to')
@cli.argument('-kb', '--keyboard', type=keyboard_folder, completer=keyboard_completer, help='Name of the keyboard')
@cli.argument('-km', '--keymap', help='The keymap\'s name')
-@cli.subcommand('Generates the XAP info.json payload include.', hidden=False if cli.config.user.developer else True)
-def xap_generate_info_h(cli):
- """Generates the XAP info.json payload header file, generated during normal build.
+@cli.subcommand('Generates the XAP config payload include.', hidden=False if cli.config.user.developer else True)
+def xap_generate_qmk_blob_h(cli):
+ """Generates the XAP config payload header file, generated during normal build.
"""
# Determine our keyboard/keymap
if not cli.args.keyboard:
@@ -66,4 +66,4 @@ def xap_generate_info_h(cli):
cli.subcommands['xap-generate-info-h'].print_help()
return False
- generate_info(cli.args.output, cli.args.keyboard, cli.args.keymap)
+ generate_blob(cli.args.output, cli.args.keyboard, cli.args.keymap)
diff --git a/lib/python/qmk/cli/xap/xap.py b/lib/python/qmk/cli/xap/xap.py
index 8de1b568082..272f667a120 100644
--- a/lib/python/qmk/cli/xap/xap.py
+++ b/lib/python/qmk/cli/xap/xap.py
@@ -163,23 +163,23 @@ def _list_devices():
print_dotted_output(data)
-def xap_dummy(device):
- # get layer count
- layers = _xap_transaction(device, 0x04, 0x01)
- layers = int.from_bytes(layers, "little")
- print(f'layers:{layers}')
+# def xap_dummy(device):
+# # get layer count
+# layers = _xap_transaction(device, 0x04, 0x00)
+# 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")
+# # get keycode [layer:0, row:0, col:0]
+# # keycode = _xap_transaction(device, 0x04, 0x02, b"\x00\x00\x00")
- # get encoder [layer:0, index:0, clockwise:0]
- keycode = _xap_transaction(device, 0x05, 0x02, b"\x00\x00\x00")
+# # get encoder [layer:0, index:0, clockwise:0]
+# keycode = _xap_transaction(device, 0x04, 0x03, b"\x00\x00\x00")
- keycode = int.from_bytes(keycode, "little")
- print(f'keycode:{KEYCODE_MAP.get(keycode, "unknown")}[{keycode}]')
+# 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")
+# # set encoder [layer:0, index:0, clockwise:0, keycode:KC_A]
+# _xap_transaction(device, 0x05, 0x03, b"\x00\x00\x00\x04\00")
def xap_broadcast_listen(device):
diff --git a/lib/python/qmk/xap/gen_firmware/info_generator.py b/lib/python/qmk/xap/gen_firmware/blob_generator.py
similarity index 84%
rename from lib/python/qmk/xap/gen_firmware/info_generator.py
rename to lib/python/qmk/xap/gen_firmware/blob_generator.py
index a1a6f1b40c6..13e19688dfa 100644
--- a/lib/python/qmk/xap/gen_firmware/info_generator.py
+++ b/lib/python/qmk/xap/gen_firmware/blob_generator.py
@@ -9,7 +9,7 @@ from qmk.commands import get_chunks, dump_lines
from qmk.constants import GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE
-def generate_info(output_file, keyboard, keymap):
+def generate_blob(output_file, keyboard, keymap):
# Build the info.json file
km_info_json = keymap_json(keyboard, keymap)
@@ -33,9 +33,9 @@ def generate_info(output_file, keyboard, keymap):
lines = [GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE, '#pragma once', '']
# Gen output file
- lines.append('static const unsigned char info_json_gz[] PROGMEM = {')
+ lines.append('static const unsigned char config_blob_gz[] PROGMEM = {')
lines.append(data)
lines.append('};')
- lines.append(f'#define INFO_JSON_GZ_LEN {data_len}')
+ lines.append(f'#define CONFIG_BLOB_GZ_LEN {data_len}')
dump_lines(output_file, lines)
diff --git a/quantum/xap/xap.c b/quantum/xap/xap.c
index 52030639edd..83bdbe13f39 100644
--- a/quantum/xap/xap.c
+++ b/quantum/xap/xap.c
@@ -18,13 +18,13 @@
#include
#include "secure.h"
-#include "info_json_gz.h"
-bool get_info_json_chunk(uint16_t offset, uint8_t *data, uint8_t data_len) {
- if (offset + data_len > INFO_JSON_GZ_LEN) {
- data_len = INFO_JSON_GZ_LEN - offset;
+#include "config_blob_gz.h"
+bool get_config_blob_chunk(uint16_t offset, uint8_t *data, uint8_t data_len) {
+ if (offset + data_len > CONFIG_BLOB_GZ_LEN) {
+ data_len = CONFIG_BLOB_GZ_LEN - offset;
}
- memcpy_P(data, &info_json_gz[offset], data_len);
+ memcpy_P(data, &config_blob_gz[offset], data_len);
return true;
}
diff --git a/quantum/xap/xap_handlers.c b/quantum/xap/xap_handlers.c
index a104c5c65bb..bd9cda148be 100644
--- a/quantum/xap/xap_handlers.c
+++ b/quantum/xap/xap_handlers.c
@@ -53,16 +53,17 @@ uint32_t xap_route_qmk_ffffffffffffffff_getter(void) {
return 0x12345678;
}
-bool xap_respond_get_info_json_chunk(xap_token_t token, const void *data, size_t length) {
+bool xap_respond_get_config_blob_chunk(xap_token_t token, const void *data, size_t length) {
if (length != sizeof(uint16_t)) {
return false;
}
- uint16_t offset = *((uint16_t *)data);
- xap_route_qmk_info_query_t ret = {0};
+ uint16_t offset = *((uint16_t *)data);
- bool get_info_json_chunk(uint16_t offset, uint8_t * data, uint8_t data_len);
- get_info_json_chunk(offset, (uint8_t *)&ret, sizeof(ret));
+ xap_route_qmk_config_blob_chunk_t ret = {0};
+
+ bool get_config_blob_chunk(uint16_t offset, uint8_t * data, uint8_t data_len);
+ get_config_blob_chunk(offset, (uint8_t *)&ret, sizeof(ret));
return xap_respond_data(token, &ret, sizeof(ret));
}
@@ -89,7 +90,7 @@ bool xap_respond_secure_lock(xap_token_t token, const void *data, size_t length)
#ifdef BOOTLOADER_JUMP_SUPPORTED
bool xap_respond_request_bootloader_jump(xap_token_t token, const void *data, size_t length) {
- uint8_t ret = secure_is_unlocked();
+ uint8_t ret = secure_is_unlocked();
// TODO: post to deferred queue so this request can return?
bool res = xap_respond_data(token, &ret, sizeof(ret));
@@ -103,24 +104,41 @@ bool xap_respond_get_hardware_id(xap_token_t token, const void *data, size_t len
return xap_respond_data(token, &ret, sizeof(ret));
}
-#if ((defined(DYNAMIC_KEYMAP_ENABLE)))
-bool xap_respond_dynamic_keymap_get_keycode(xap_token_t token, const void *data, size_t length) {
- if (length != sizeof(xap_route_dynamic_keymap_get_keymap_keycode_arg_t)) {
+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;
}
- xap_route_dynamic_keymap_get_keymap_keycode_arg_t *arg = (xap_route_dynamic_keymap_get_keymap_keycode_arg_t *)data;
+ xap_route_keymap_get_keymap_keycode_arg_t *arg = (xap_route_keymap_get_keymap_keycode_arg_t *)data;
- uint16_t keycode = dynamic_keymap_get_keycode(arg->layer, arg->row, arg->column);
+ keypos_t pos = MAKE_KEYPOS(arg->row, arg->column);
+
+ uint16_t keycode = keymap_key_to_keycode(arg->layer, pos);
return xap_respond_data(token, &keycode, sizeof(keycode));
}
-bool xap_respond_dynamic_keymap_set_keycode(xap_token_t token, const void *data, size_t length) {
- if (length != sizeof(xap_route_dynamic_keymap_set_keymap_keycode_arg_t)) {
+#if ((defined(ENCODER_MAP_ENABLE)))
+bool xap_respond_get_encoder_keycode(xap_token_t token, const void *data, size_t length) {
+ if (length != sizeof(xap_route_keymap_get_encoder_keycode_arg_t)) {
return false;
}
- xap_route_dynamic_keymap_set_keymap_keycode_arg_t *arg = (xap_route_dynamic_keymap_set_keymap_keycode_arg_t *)data;
+ xap_route_keymap_get_encoder_keycode_arg_t *arg = (xap_route_keymap_get_encoder_keycode_arg_t *)data;
+
+ keypos_t pos = MAKE_KEYPOS(arg->clockwise ? KEYLOC_ENCODER_CW : KEYLOC_ENCODER_CCW, arg->encoder);
+
+ uint16_t keycode = keymap_key_to_keycode(arg->layer, pos);
+ return xap_respond_data(token, &keycode, sizeof(keycode));
+}
+#endif
+
+#if ((defined(DYNAMIC_KEYMAP_ENABLE)))
+bool xap_respond_dynamic_keymap_set_keycode(xap_token_t token, const void *data, size_t length) {
+ if (length != sizeof(xap_route_remapping_set_keymap_keycode_arg_t)) {
+ return false;
+ }
+
+ xap_route_remapping_set_keymap_keycode_arg_t *arg = (xap_route_remapping_set_keymap_keycode_arg_t *)data;
dynamic_keymap_set_keycode(arg->layer, arg->row, arg->column, arg->keycode);
xap_respond_success(token);
@@ -128,27 +146,16 @@ bool xap_respond_dynamic_keymap_set_keycode(xap_token_t token, const void *data,
}
#endif
-#if ((defined(ENCODER_MAP_ENABLE)))
-bool xap_respond_dynamic_encoder_get_keycode(xap_token_t token, const void *data, size_t length) {
- if (length != sizeof(xap_route_dynamic_encoder_get_encoder_keycode_arg_t)) {
- return false;
- }
-
- xap_route_dynamic_encoder_get_encoder_keycode_arg_t *arg = (xap_route_dynamic_encoder_get_encoder_keycode_arg_t *)data;
-
- uint16_t keycode = dynamic_keymap_get_encoder(arg->layer, arg->encoder, arg->clockwise);
- return xap_respond_data(token, &keycode, sizeof(keycode));
-}
-
+#if ((defined(DYNAMIC_KEYMAP_ENABLE) && defined(ENCODER_MAP_ENABLE)))
bool xap_respond_dynamic_encoder_set_keycode(xap_token_t token, const void *data, size_t length) {
- if (length != sizeof(xap_route_dynamic_encoder_set_encoder_keycode_arg_t)) {
+ if (length != sizeof(xap_route_remapping_set_encoder_keycode_arg_t)) {
return false;
}
- xap_route_dynamic_encoder_set_encoder_keycode_arg_t *arg = (xap_route_dynamic_encoder_set_encoder_keycode_arg_t *)data;
+ xap_route_remapping_set_encoder_keycode_arg_t *arg = (xap_route_remapping_set_encoder_keycode_arg_t *)data;
dynamic_keymap_set_encoder(arg->layer, arg->encoder, arg->clockwise, arg->keycode);
xap_respond_success(token);
return true;
}
-#endif
\ No newline at end of file
+#endif