basic info.json handling
This commit is contained in:
parent
1fbbd72c14
commit
ff1bb76537
7 changed files with 210 additions and 82 deletions
|
@ -14,6 +14,7 @@ def generate_info(output_file, keyboard, keymap):
|
|||
km_info_json = keymap_json(keyboard, keymap)
|
||||
|
||||
# TODO: Munge to XAP requirements
|
||||
del km_info_json['config_h_features']
|
||||
|
||||
# Minify
|
||||
str_data = json.dumps(km_info_json, separators=(',', ':'))
|
||||
|
@ -32,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('unsigned char info_json_gz[] = {')
|
||||
lines.append('static const unsigned char info_json_gz[] PROGMEM = {')
|
||||
lines.append(data)
|
||||
lines.append('};')
|
||||
lines.append(f'unsigned int info_json_gz_len = {data_len};')
|
||||
lines.append(f'static const unsigned int info_json_gz_len = {data_len};')
|
||||
|
||||
dump_lines(output_file, lines)
|
||||
|
|
|
@ -26,6 +26,8 @@ def _get_c_type(xap_type):
|
|||
def _get_route_type(container):
|
||||
if 'routes' in container:
|
||||
return 'XAP_ROUTE'
|
||||
elif 'return_execute' in container:
|
||||
return 'XAP_EXECUTE'
|
||||
elif 'return_constant' in container:
|
||||
if container['return_type'] == 'u32':
|
||||
return 'XAP_VALUE'
|
||||
|
@ -47,6 +49,11 @@ def _append_routing_table_declaration(lines, container, container_id, route_stac
|
|||
if 'routes' in container:
|
||||
pass
|
||||
|
||||
elif 'return_execute' in container:
|
||||
execute = container['return_execute']
|
||||
lines.append('')
|
||||
lines.append(f'bool xap_respond_{execute}(xap_token_t token, const uint8_t *data, size_t data_len);')
|
||||
|
||||
elif 'return_constant' in container:
|
||||
|
||||
if container['return_type'] == 'u32':
|
||||
|
@ -99,6 +106,11 @@ def _append_routing_table_entry_route(lines, container, container_id, route_stac
|
|||
lines.append(f' .child_routes_len = sizeof({route_name}_table)/sizeof(xap_route_t),')
|
||||
|
||||
|
||||
def _append_routing_table_entry_execute(lines, container, container_id, route_stack):
|
||||
value = container['return_execute']
|
||||
lines.append(f' .handler = xap_respond_{value},')
|
||||
|
||||
|
||||
def _append_routing_table_entry_u32value(lines, container, container_id, route_stack):
|
||||
value = container['return_constant']
|
||||
lines.append(f' .u32value = {value},')
|
||||
|
@ -134,6 +146,8 @@ def _append_routing_table_entry(lines, container, container_id, route_stack):
|
|||
_append_routing_table_entry_flags(lines, container, container_id, route_stack)
|
||||
if 'routes' in container:
|
||||
_append_routing_table_entry_route(lines, container, container_id, route_stack)
|
||||
elif 'return_execute' in container:
|
||||
_append_routing_table_entry_execute(lines, container, container_id, route_stack)
|
||||
elif 'return_constant' in container:
|
||||
if container['return_type'] == 'u32':
|
||||
_append_routing_table_entry_u32value(lines, container, container_id, route_stack)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue