diff --git a/right/src/config_parser/parse_config.c b/right/src/config_parser/parse_config.c index df1f87c..c9f0a58 100644 --- a/right/src/config_parser/parse_config.c +++ b/right/src/config_parser/parse_config.c @@ -38,7 +38,7 @@ parser_error_t ParseConfig(config_buffer_t *buffer) } macroCount = readCompactLength(buffer); for (uint16_t macroIdx = 0; macroIdx < macroCount; macroIdx++) { - errorCode = ParseMacro(buffer); + errorCode = ParseMacro(buffer, macroIdx); if (errorCode != ParserError_Success) { return errorCode; } diff --git a/right/src/config_parser/parse_macro.c b/right/src/config_parser/parse_macro.c index 5a74a3d..5f8dcaf 100644 --- a/right/src/config_parser/parse_macro.c +++ b/right/src/config_parser/parse_macro.c @@ -1,4 +1,6 @@ #include "parse_macro.h" +#include "config_globals.h" +#include "macros.h" parser_error_t parseKeyMacroAction(config_buffer_t *buffer, serialized_macro_action_type_t macroActionType) { uint8_t keyMacroType = macroActionType - SerializedMacroActionType_KeyMacroAction; @@ -85,7 +87,8 @@ parser_error_t parseMacroAction(config_buffer_t *buffer) { return ParserError_InvalidSerializedMacroActionType; } -parser_error_t ParseMacro(config_buffer_t *buffer) { +parser_error_t ParseMacro(config_buffer_t *buffer, uint16_t macroIdx) { + uint16_t offset = buffer->offset; parser_error_t errorCode; uint16_t nameLen; bool isLooped = readBool(buffer); @@ -96,6 +99,10 @@ parser_error_t ParseMacro(config_buffer_t *buffer) { (void)isLooped; (void)isPrivate; (void)name; + if (!ParserRunDry) { + AllMacros[macroIdx].offset = offset; + AllMacros[macroIdx].macroActionsCount = macroActionsCount; + } for (uint16_t i = 0; i < macroActionsCount; i++) { errorCode = parseMacroAction(buffer); if (errorCode != ParserError_Success) { diff --git a/right/src/config_parser/parse_macro.h b/right/src/config_parser/parse_macro.h index 6791571..f2f504c 100644 --- a/right/src/config_parser/parse_macro.h +++ b/right/src/config_parser/parse_macro.h @@ -20,6 +20,6 @@ // Functions: - parser_error_t ParseMacro(config_buffer_t *buffer); + parser_error_t ParseMacro(config_buffer_t *buffer, uint16_t macroIdx); #endif diff --git a/right/src/macros.c b/right/src/macros.c new file mode 100644 index 0000000..cd17f7f --- /dev/null +++ b/right/src/macros.c @@ -0,0 +1,3 @@ +#include "macros.h" + +macro_reference_t AllMacros[MAX_MACRO_NUM]; diff --git a/right/src/macros.h b/right/src/macros.h new file mode 100644 index 0000000..652091d --- /dev/null +++ b/right/src/macros.h @@ -0,0 +1,23 @@ +#ifndef __MACROS_H__ +#define __MACROS_H__ + +// Includes: + + #include + +// Macros: + + #define MAX_MACRO_NUM 1024 + +// Typedefs: + + typedef struct { + uint16_t offset; + uint16_t macroActionsCount; + } macro_reference_t; + +// Variables: + + extern macro_reference_t AllMacros[MAX_MACRO_NUM]; + +#endif