Rename the config directory to config_parser.
This commit is contained in:
41
right/src/config_parser/config_state.c
Normal file
41
right/src/config_parser/config_state.c
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "config_state.h"
|
||||
|
||||
static uint8_t hardwareConfig[HARDWARE_CONFIG_SIZE];
|
||||
config_buffer_t HardwareConfigBuffer = {hardwareConfig};
|
||||
|
||||
static uint8_t userConfig[USER_CONFIG_SIZE];
|
||||
config_buffer_t UserConfigBuffer = {userConfig};
|
||||
|
||||
uint8_t readUInt8(config_buffer_t *buffer) {
|
||||
return buffer->buffer[buffer->offset++];
|
||||
}
|
||||
|
||||
uint16_t readUInt16(config_buffer_t *buffer) {
|
||||
uint16_t uInt16 = readUInt8(buffer);
|
||||
|
||||
uInt16 |= readUInt8(buffer) << 8;
|
||||
return uInt16;
|
||||
}
|
||||
|
||||
int16_t readInt16(config_buffer_t *buffer) {
|
||||
return readUInt16(buffer);
|
||||
}
|
||||
|
||||
bool readBool(config_buffer_t *buffer) {
|
||||
return readUInt8(buffer);
|
||||
}
|
||||
|
||||
uint16_t readCompactLength(config_buffer_t *buffer) {
|
||||
uint16_t compactLength = readUInt8(buffer);
|
||||
|
||||
return compactLength == 0xFF ? readUInt16(buffer) : compactLength;
|
||||
}
|
||||
|
||||
const char *readString(config_buffer_t *buffer, uint16_t *len) {
|
||||
const char *string;
|
||||
|
||||
*len = readCompactLength(buffer);
|
||||
string = (const char *)(buffer->buffer + buffer->offset);
|
||||
buffer->offset += *len;
|
||||
return string;
|
||||
}
|
||||
36
right/src/config_parser/config_state.h
Normal file
36
right/src/config_parser/config_state.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef __CONFIG_STATE_H__
|
||||
#define __CONFIG_STATE_H__
|
||||
|
||||
// Includes:
|
||||
|
||||
#include <stdint.h>
|
||||
#include "fsl_common.h"
|
||||
|
||||
// Macros:
|
||||
|
||||
#define EEPROM_SIZE (32*1024)
|
||||
#define HARDWARE_CONFIG_SIZE 64
|
||||
#define USER_CONFIG_SIZE (EEPROM_SIZE - HARDWARE_CONFIG_SIZE)
|
||||
|
||||
// Typedefs:
|
||||
|
||||
typedef struct {
|
||||
uint8_t *buffer;
|
||||
uint16_t offset;
|
||||
} config_buffer_t;
|
||||
|
||||
// Variables:
|
||||
|
||||
extern config_buffer_t HardwareConfigBuffer;
|
||||
extern config_buffer_t UserConfigBuffer;
|
||||
|
||||
// Functions:
|
||||
|
||||
uint8_t readUInt8(config_buffer_t *buffer);
|
||||
uint16_t readUInt16(config_buffer_t *buffer);
|
||||
int16_t readInt16(config_buffer_t *buffer);
|
||||
bool readBool(config_buffer_t *buffer);
|
||||
uint16_t readCompactLength(config_buffer_t *buffer);
|
||||
const char *readString(config_buffer_t *buffer, uint16_t *len);
|
||||
|
||||
#endif
|
||||
47
right/src/config_parser/parse_config.c
Normal file
47
right/src/config_parser/parse_config.c
Normal file
@@ -0,0 +1,47 @@
|
||||
#include "parse_config.h"
|
||||
#include "parse_keymap.h"
|
||||
#include "parse_macro.h"
|
||||
|
||||
static parser_error_t parseModuleConfiguration(config_buffer_t *buffer) {
|
||||
uint8_t id = readUInt8(buffer);
|
||||
uint8_t initialPointerSpeed = readUInt8(buffer);
|
||||
uint8_t pointerAcceleration = readUInt8(buffer);
|
||||
uint8_t maxPointerSpeed = readUInt8(buffer);
|
||||
|
||||
(void)id;
|
||||
(void)initialPointerSpeed;
|
||||
(void)pointerAcceleration;
|
||||
(void)maxPointerSpeed;
|
||||
return ParserError_Success;
|
||||
}
|
||||
|
||||
parser_error_t ParseConfig(config_buffer_t *buffer) {
|
||||
uint16_t dataModelVersion = readUInt16(buffer);
|
||||
parser_error_t errorCode;
|
||||
uint16_t moduleConfigurationCount = readCompactLength(buffer);
|
||||
uint16_t macroCount;
|
||||
uint16_t keymapCount;
|
||||
|
||||
(void)dataModelVersion;
|
||||
for (uint16_t moduleConfigurationIdx = 0; moduleConfigurationIdx < moduleConfigurationCount; moduleConfigurationIdx++) {
|
||||
errorCode = parseModuleConfiguration(buffer);
|
||||
if (errorCode != ParserError_Success) {
|
||||
return errorCode;
|
||||
}
|
||||
}
|
||||
macroCount = readCompactLength(buffer);
|
||||
for (uint16_t macroIdx = 0; macroIdx < macroCount; macroIdx++) {
|
||||
errorCode = ParseMacro(buffer);
|
||||
if (errorCode != ParserError_Success) {
|
||||
return errorCode;
|
||||
}
|
||||
}
|
||||
keymapCount = readCompactLength(buffer);
|
||||
for (uint16_t keymapIdx = 0; keymapIdx < keymapCount; keymapIdx++) {
|
||||
errorCode = ParseKeymap(buffer);
|
||||
if (errorCode != ParserError_Success) {
|
||||
return errorCode;
|
||||
}
|
||||
}
|
||||
return ParserError_Success;
|
||||
}
|
||||
25
right/src/config_parser/parse_config.h
Normal file
25
right/src/config_parser/parse_config.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef __PARSE_CONFIG_H__
|
||||
#define __PARSE_CONFIG_H__
|
||||
|
||||
// Includes:
|
||||
|
||||
#include "config_state.h"
|
||||
|
||||
// Typedefs:
|
||||
|
||||
typedef enum {
|
||||
ParserError_Success,
|
||||
ParserError_InvalidSerializedKeystrokeType,
|
||||
ParserError_InvalidSerializedMouseAction,
|
||||
ParserError_InvalidSerializedKeyActionType,
|
||||
ParserError_InvalidLayerCount,
|
||||
ParserError_InvalidModuleCount,
|
||||
ParserError_InvalidActionCount,
|
||||
ParserError_InvalidSerializedMacroActionType,
|
||||
} parser_error_t;
|
||||
|
||||
// Functions:
|
||||
|
||||
parser_error_t ParseConfig(config_buffer_t *buffer);
|
||||
|
||||
#endif
|
||||
208
right/src/config_parser/parse_keymap.c
Normal file
208
right/src/config_parser/parse_keymap.c
Normal file
@@ -0,0 +1,208 @@
|
||||
#include "config_parser/parse_keymap.h"
|
||||
#include "key_action.h"
|
||||
#include "current_keymap.h"
|
||||
#include "led_display.h"
|
||||
|
||||
static bool isDryRun;
|
||||
|
||||
static parser_error_t parseNoneAction(key_action_t *keyAction, config_buffer_t *buffer) {
|
||||
keyAction->type = KeyActionType_None;
|
||||
return ParserError_Success;
|
||||
}
|
||||
|
||||
static parser_error_t parseKeyStrokeAction(key_action_t *keyAction, uint8_t keyStrokeAction, config_buffer_t *buffer) {
|
||||
uint8_t keystrokeType = (SERIALIZED_KEYSTROKE_TYPE_MASK_KEYSTROKE_TYPE & keyStrokeAction) >> SERIALIZED_KEYSTROKE_TYPE_OFFSET_KEYSTROKE_TYPE;
|
||||
|
||||
keyAction->type = KeyActionType_Keystroke;
|
||||
switch (keystrokeType) {
|
||||
case SerializedKeystrokeType_Basic:
|
||||
keyAction->keystroke.keystrokeType = KeystrokeType_Basic;
|
||||
break;
|
||||
case SerializedKeystrokeType_ShortMedia:
|
||||
case SerializedKeystrokeType_LongMedia:
|
||||
keyAction->keystroke.keystrokeType = KeystrokeType_Media;
|
||||
break;
|
||||
case SerializedKeystrokeType_System:
|
||||
keyAction->keystroke.keystrokeType = KeystrokeType_System;
|
||||
break;
|
||||
default:
|
||||
return ParserError_InvalidSerializedKeystrokeType;
|
||||
}
|
||||
keyAction->keystroke.scancode = keyStrokeAction & SERIALIZED_KEYSTROKE_TYPE_MASK_HAS_SCANCODE
|
||||
? keystrokeType == SerializedKeystrokeType_LongMedia ? readUInt16(buffer) : readUInt8(buffer)
|
||||
: 0;
|
||||
keyAction->keystroke.modifiers = keyStrokeAction & SERIALIZED_KEYSTROKE_TYPE_MASK_HAS_MODIFIERS
|
||||
? readUInt8(buffer)
|
||||
: 0;
|
||||
keyAction->keystroke.longPressAction = keyStrokeAction & SERIALIZED_KEYSTROKE_TYPE_MASK_HAS_LONGPRESS
|
||||
? readUInt8(buffer)
|
||||
: 0;
|
||||
return ParserError_Success;
|
||||
}
|
||||
|
||||
static parser_error_t parseSwitchLayerAction(key_action_t *KeyAction, config_buffer_t *buffer) {
|
||||
uint8_t layer = readUInt8(buffer) + 1;
|
||||
bool isToggle = readBool(buffer);
|
||||
|
||||
KeyAction->type = KeyActionType_SwitchLayer;
|
||||
KeyAction->switchLayer.layer = layer;
|
||||
KeyAction->switchLayer.isToggle = isToggle;
|
||||
return ParserError_Success;
|
||||
}
|
||||
|
||||
static parser_error_t parseSwitchKeymapAction(key_action_t *keyAction, config_buffer_t *buffer) {
|
||||
uint8_t keymapIndex = readUInt8(buffer);
|
||||
|
||||
(void)keymapIndex;
|
||||
keyAction->type = KeyActionType_SwitchKeymap;
|
||||
// TODO: Implement this
|
||||
return ParserError_Success;
|
||||
}
|
||||
|
||||
static parser_error_t parsePlayMacroAction(key_action_t *keyAction, config_buffer_t *buffer) {
|
||||
uint8_t macroIndex = readUInt8(buffer);
|
||||
|
||||
(void)macroIndex;
|
||||
return ParserError_Success;
|
||||
}
|
||||
|
||||
static parser_error_t parseMouseAction(key_action_t *keyAction, config_buffer_t *buffer) {
|
||||
uint8_t mouseAction = readUInt8(buffer);
|
||||
|
||||
keyAction->type = KeyActionType_Mouse;
|
||||
memset(&keyAction->mouse, 0, sizeof keyAction->mouse);
|
||||
switch (mouseAction) {
|
||||
case SerializedMouseAction_LeftClick:
|
||||
keyAction->mouse.buttonActions = MouseButton_Left;
|
||||
break;
|
||||
case SerializedMouseAction_MiddleClick:
|
||||
keyAction->mouse.buttonActions = MouseButton_Middle;
|
||||
break;
|
||||
case SerializedMouseAction_RightClick:
|
||||
keyAction->mouse.buttonActions = MouseButton_Right;
|
||||
break;
|
||||
case SerializedMouseAction_MoveUp:
|
||||
keyAction->mouse.moveActions = MouseMove_Up;
|
||||
break;
|
||||
case SerializedMouseAction_MoveDown:
|
||||
keyAction->mouse.moveActions = MouseMove_Down;
|
||||
break;
|
||||
case SerializedMouseAction_MoveLeft:
|
||||
keyAction->mouse.moveActions = MouseMove_Left;
|
||||
break;
|
||||
case SerializedMouseAction_MoveRight:
|
||||
keyAction->mouse.moveActions = MouseMove_Right;
|
||||
break;
|
||||
case SerializedMouseAction_ScrollUp:
|
||||
keyAction->mouse.scrollActions = MouseScroll_Up;
|
||||
break;
|
||||
case SerializedMouseAction_ScrollDown:
|
||||
keyAction->mouse.scrollActions = MouseScroll_Down;
|
||||
break;
|
||||
case SerializedMouseAction_ScrollLeft:
|
||||
keyAction->mouse.scrollActions = MouseScroll_Left;
|
||||
break;
|
||||
case SerializedMouseAction_ScrollRight:
|
||||
keyAction->mouse.scrollActions = MouseScroll_Right;
|
||||
break;
|
||||
case SerializedMouseAction_Accelerate:
|
||||
keyAction->mouse.moveActions = MouseMove_Accelerate;
|
||||
break;
|
||||
case SerializedMouseAction_Decelerate:
|
||||
keyAction->mouse.moveActions = MouseMove_Decelerate;
|
||||
break;
|
||||
default:
|
||||
return ParserError_InvalidSerializedMouseAction;
|
||||
}
|
||||
return ParserError_Success;
|
||||
}
|
||||
|
||||
static parser_error_t parseKeyAction(key_action_t *keyAction, config_buffer_t *buffer) {
|
||||
uint8_t keyActionType = readUInt8(buffer);
|
||||
|
||||
switch (keyActionType) {
|
||||
case SerializedKeyActionType_None:
|
||||
return parseNoneAction(keyAction, buffer);
|
||||
case SerializedKeyActionType_KeyStroke ... SerializedKeyActionType_LastKeyStroke:
|
||||
return parseKeyStrokeAction(keyAction, keyActionType, buffer);
|
||||
case SerializedKeyActionType_SwitchLayer:
|
||||
return parseSwitchLayerAction(keyAction, buffer);
|
||||
case SerializedKeyActionType_SwitchKeymap:
|
||||
return parseSwitchKeymapAction(keyAction, buffer);
|
||||
case SerializedKeyActionType_Mouse:
|
||||
return parseMouseAction(keyAction, buffer);
|
||||
case SerializedKeyActionType_PlayMacro:
|
||||
return parsePlayMacroAction(keyAction, buffer);
|
||||
}
|
||||
return ParserError_InvalidSerializedKeyActionType;
|
||||
}
|
||||
|
||||
static parser_error_t parseKeyActions(uint8_t targetLayer, config_buffer_t *buffer, uint8_t moduleId, uint8_t pointerRole) {
|
||||
parser_error_t errorCode;
|
||||
uint16_t actionCount = readCompactLength(buffer);
|
||||
key_action_t dummyKeyAction;
|
||||
|
||||
if (actionCount > MAX_KEY_COUNT_PER_MODULE) {
|
||||
return ParserError_InvalidActionCount;
|
||||
}
|
||||
for (uint16_t actionIdx = 0; actionIdx < actionCount; actionIdx++) {
|
||||
errorCode = parseKeyAction(isDryRun ? &dummyKeyAction : &CurrentKeymap[targetLayer][moduleId][actionIdx], buffer);
|
||||
if (errorCode != ParserError_Success) {
|
||||
return errorCode;
|
||||
}
|
||||
}
|
||||
return ParserError_Success;
|
||||
}
|
||||
|
||||
static parser_error_t parseModule(config_buffer_t *buffer, uint8_t layer) {
|
||||
uint8_t moduleId = readUInt8(buffer);
|
||||
uint8_t pointerRole = readUInt8(buffer);
|
||||
|
||||
return parseKeyActions(layer, buffer, moduleId, pointerRole);
|
||||
}
|
||||
|
||||
static parser_error_t parseLayer(config_buffer_t *buffer, uint8_t layer) {
|
||||
parser_error_t errorCode;
|
||||
uint16_t moduleCount = readCompactLength(buffer);
|
||||
|
||||
if (moduleCount > SLOT_COUNT) {
|
||||
return ParserError_InvalidModuleCount;
|
||||
}
|
||||
for (uint16_t moduleIdx = 0; moduleIdx < moduleCount; moduleIdx++) {
|
||||
errorCode = parseModule(buffer, layer);
|
||||
if (errorCode != ParserError_Success) {
|
||||
return errorCode;
|
||||
}
|
||||
}
|
||||
return ParserError_Success;
|
||||
}
|
||||
|
||||
parser_error_t ParseKeymap(config_buffer_t *buffer) {;
|
||||
parser_error_t errorCode;
|
||||
uint16_t abbreviationLen;
|
||||
uint16_t nameLen;
|
||||
uint16_t descriptionLen;
|
||||
const char *abbreviation = readString(buffer, &abbreviationLen);
|
||||
bool isDefault = readBool(buffer);
|
||||
const char *name = readString(buffer, &nameLen);
|
||||
const char *description = readString(buffer, &descriptionLen);
|
||||
uint16_t layerCount = readCompactLength(buffer);
|
||||
|
||||
(void)name;
|
||||
(void)description;
|
||||
if (layerCount != LAYER_COUNT) {
|
||||
return ParserError_InvalidLayerCount;
|
||||
}
|
||||
isDryRun = !isDefault;
|
||||
if (!isDryRun) {
|
||||
LedDisplay_SetText(abbreviationLen, abbreviation);
|
||||
}
|
||||
for (uint16_t layerIdx = 0; layerIdx < layerCount; layerIdx++) {
|
||||
errorCode = parseLayer(buffer, layerIdx);
|
||||
if (errorCode != ParserError_Success) {
|
||||
return errorCode;
|
||||
}
|
||||
}
|
||||
return ParserError_Success;
|
||||
}
|
||||
|
||||
57
right/src/config_parser/parse_keymap.h
Normal file
57
right/src/config_parser/parse_keymap.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#ifndef __PARSE_KEYMAP_H__
|
||||
#define __PARSE_KEYMAP_H__
|
||||
|
||||
// Includes:
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "parse_config.h"
|
||||
|
||||
// Macros:
|
||||
|
||||
#define SERIALIZED_KEYSTROKE_TYPE_MASK_HAS_SCANCODE 0b00001
|
||||
#define SERIALIZED_KEYSTROKE_TYPE_MASK_HAS_MODIFIERS 0b00010
|
||||
#define SERIALIZED_KEYSTROKE_TYPE_MASK_HAS_LONGPRESS 0b00100
|
||||
#define SERIALIZED_KEYSTROKE_TYPE_MASK_KEYSTROKE_TYPE 0b11000
|
||||
#define SERIALIZED_KEYSTROKE_TYPE_OFFSET_KEYSTROKE_TYPE 3
|
||||
|
||||
// Typedefs:
|
||||
|
||||
typedef enum {
|
||||
SerializedKeyActionType_None = 0,
|
||||
SerializedKeyActionType_KeyStroke = 1,
|
||||
SerializedKeyActionType_LastKeyStroke = 31,
|
||||
SerializedKeyActionType_SwitchLayer,
|
||||
SerializedKeyActionType_SwitchKeymap,
|
||||
SerializedKeyActionType_Mouse,
|
||||
SerializedKeyActionType_PlayMacro
|
||||
} serialized_key_action_type_t;
|
||||
|
||||
typedef enum {
|
||||
SerializedKeystrokeType_Basic,
|
||||
SerializedKeystrokeType_ShortMedia,
|
||||
SerializedKeystrokeType_LongMedia,
|
||||
SerializedKeystrokeType_System,
|
||||
} serialized_keystroke_type_t;
|
||||
|
||||
typedef enum {
|
||||
SerializedMouseAction_LeftClick,
|
||||
SerializedMouseAction_MiddleClick,
|
||||
SerializedMouseAction_RightClick,
|
||||
SerializedMouseAction_MoveUp,
|
||||
SerializedMouseAction_MoveDown,
|
||||
SerializedMouseAction_MoveLeft,
|
||||
SerializedMouseAction_MoveRight,
|
||||
SerializedMouseAction_ScrollUp,
|
||||
SerializedMouseAction_ScrollDown,
|
||||
SerializedMouseAction_ScrollLeft,
|
||||
SerializedMouseAction_ScrollRight,
|
||||
SerializedMouseAction_Accelerate,
|
||||
SerializedMouseAction_Decelerate,
|
||||
} serialized_mouse_action_t;
|
||||
|
||||
// Functions:
|
||||
|
||||
parser_error_t ParseKeymap(config_buffer_t *buffer);
|
||||
|
||||
#endif
|
||||
106
right/src/config_parser/parse_macro.c
Normal file
106
right/src/config_parser/parse_macro.c
Normal file
@@ -0,0 +1,106 @@
|
||||
#include "parse_macro.h"
|
||||
|
||||
parser_error_t parseKeyMacroAction(config_buffer_t *buffer, serialized_macro_action_type_t macroActionType) {
|
||||
uint8_t keyMacroType = macroActionType - SerializedMacroActionType_KeyMacroAction;
|
||||
uint8_t action = keyMacroType & 0b11;
|
||||
uint8_t type;
|
||||
uint8_t scancode;
|
||||
uint8_t modifierMask;
|
||||
|
||||
keyMacroType >>= 2;
|
||||
type = keyMacroType & 0b11;
|
||||
keyMacroType >>= 2;
|
||||
if (keyMacroType & 0b10) {
|
||||
scancode = readUInt8(buffer);
|
||||
}
|
||||
if (keyMacroType & 0b01) {
|
||||
modifierMask = readUInt8(buffer);
|
||||
}
|
||||
(void)action;
|
||||
(void)type;
|
||||
(void)scancode;
|
||||
(void)modifierMask;
|
||||
return ParserError_Success;
|
||||
}
|
||||
|
||||
parser_error_t parseMouseButtonMacroAction(config_buffer_t *buffer, serialized_macro_action_type_t macroActionType) {
|
||||
uint8_t action = macroActionType - SerializedMacroActionType_MouseButtonMacroAction;
|
||||
uint8_t mouseButtonsMask = readUInt8(buffer);
|
||||
|
||||
(void)action;
|
||||
(void)mouseButtonsMask;
|
||||
return ParserError_Success;
|
||||
}
|
||||
|
||||
parser_error_t parseMoveMouseMacroAction(config_buffer_t *buffer) {
|
||||
int16_t x = readInt16(buffer);
|
||||
int16_t y = readInt16(buffer);
|
||||
|
||||
(void)x;
|
||||
(void)y;
|
||||
return ParserError_Success;
|
||||
}
|
||||
|
||||
parser_error_t parseScrollMouseMacroAction(config_buffer_t *buffer) {
|
||||
int16_t x = readInt16(buffer);
|
||||
int16_t y = readInt16(buffer);
|
||||
|
||||
(void)x;
|
||||
(void)y;
|
||||
return ParserError_Success;
|
||||
}
|
||||
|
||||
parser_error_t parseDelayMacroAction(config_buffer_t *buffer) {
|
||||
int16_t delay = readInt16(buffer);
|
||||
|
||||
(void)delay;
|
||||
return ParserError_Success;
|
||||
}
|
||||
|
||||
parser_error_t parseTextMacroAction(config_buffer_t *buffer) {
|
||||
uint16_t textLen;
|
||||
const char *text = readString(buffer, &textLen);
|
||||
|
||||
(void)text;
|
||||
return ParserError_Success;
|
||||
}
|
||||
|
||||
parser_error_t parseMacroAction(config_buffer_t *buffer) {
|
||||
uint8_t macroActionType = readUInt8(buffer);
|
||||
|
||||
switch (macroActionType) {
|
||||
case SerializedMacroActionType_KeyMacroAction ... SerializedMacroActionType_LastKeyMacroAction:
|
||||
return parseKeyMacroAction(buffer, macroActionType);
|
||||
case SerializedMacroActionType_MouseButtonMacroAction ... SerializedMacroActionType_LastMouseButtonMacroAction:
|
||||
return parseMouseButtonMacroAction(buffer, macroActionType);
|
||||
case SerializedMacroActionType_MoveMouseMacroAction:
|
||||
return parseMoveMouseMacroAction(buffer);
|
||||
case SerializedMacroActionType_ScrollMouseMacroAction:
|
||||
return parseScrollMouseMacroAction(buffer);
|
||||
case SerializedMacroActionType_DelayMacroAction:
|
||||
return parseDelayMacroAction(buffer);
|
||||
case SerializedMacroActionType_TextMacroAction:
|
||||
return parseTextMacroAction(buffer);
|
||||
}
|
||||
return ParserError_InvalidSerializedMacroActionType;
|
||||
}
|
||||
|
||||
parser_error_t ParseMacro(config_buffer_t *buffer) {
|
||||
parser_error_t errorCode;
|
||||
uint16_t nameLen;
|
||||
bool isLooped = readBool(buffer);
|
||||
bool isPrivate = readBool(buffer);
|
||||
const char *name = readString(buffer, &nameLen);
|
||||
uint16_t macroActionsCount = readCompactLength(buffer);
|
||||
|
||||
(void)isLooped;
|
||||
(void)isPrivate;
|
||||
(void)name;
|
||||
for (uint16_t i = 0; i < macroActionsCount; i++) {
|
||||
errorCode = parseMacroAction(buffer);
|
||||
if (errorCode != ParserError_Success) {
|
||||
return errorCode;
|
||||
}
|
||||
}
|
||||
return ParserError_Success;
|
||||
}
|
||||
25
right/src/config_parser/parse_macro.h
Normal file
25
right/src/config_parser/parse_macro.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef __PARSE_MACRO_H__
|
||||
#define __PARSE_MACRO_H__
|
||||
|
||||
// Includes:
|
||||
|
||||
#include "parse_config.h"
|
||||
|
||||
// Typedefs:
|
||||
|
||||
typedef enum {
|
||||
SerializedMacroActionType_KeyMacroAction = 0,
|
||||
SerializedMacroActionType_LastKeyMacroAction = 63,
|
||||
SerializedMacroActionType_MouseButtonMacroAction,
|
||||
SerializedMacroActionType_LastMouseButtonMacroAction = 66,
|
||||
SerializedMacroActionType_MoveMouseMacroAction,
|
||||
SerializedMacroActionType_ScrollMouseMacroAction,
|
||||
SerializedMacroActionType_DelayMacroAction,
|
||||
SerializedMacroActionType_TextMacroAction
|
||||
} serialized_macro_action_type_t;
|
||||
|
||||
// Functions:
|
||||
|
||||
parser_error_t ParseMacro(config_buffer_t *buffer);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user