Rename serialized_buffer_t to config_buffer_t
This commit is contained in:
@@ -1,29 +1,29 @@
|
|||||||
#include "config_state.h"
|
#include "config_state.h"
|
||||||
|
|
||||||
serialized_buffer_t ConfigBuffer;
|
config_buffer_t ConfigBuffer;
|
||||||
|
|
||||||
uint8_t readUInt8(serialized_buffer_t *buffer) {
|
uint8_t readUInt8(config_buffer_t *buffer) {
|
||||||
return buffer->buffer[buffer->offset++];
|
return buffer->buffer[buffer->offset++];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t readUInt16(serialized_buffer_t *buffer) {
|
uint16_t readUInt16(config_buffer_t *buffer) {
|
||||||
uint16_t uInt16 = *(uint16_t *)(buffer->buffer + buffer->offset);
|
uint16_t uInt16 = *(uint16_t *)(buffer->buffer + buffer->offset);
|
||||||
|
|
||||||
buffer->offset += 2;
|
buffer->offset += 2;
|
||||||
return uInt16;
|
return uInt16;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool readBool(serialized_buffer_t *buffer) {
|
bool readBool(config_buffer_t *buffer) {
|
||||||
return readUInt8(buffer);
|
return readUInt8(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t readCompactLength(serialized_buffer_t *buffer) {
|
uint16_t readCompactLength(config_buffer_t *buffer) {
|
||||||
uint16_t compactLength = readUInt8(buffer);
|
uint16_t compactLength = readUInt8(buffer);
|
||||||
|
|
||||||
return compactLength == 0xFF ? readUInt16(buffer) : compactLength;
|
return compactLength == 0xFF ? readUInt16(buffer) : compactLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *readString(serialized_buffer_t *buffer, uint16_t *len) {
|
const char *readString(config_buffer_t *buffer, uint16_t *len) {
|
||||||
const char *string;
|
const char *string;
|
||||||
|
|
||||||
*len = readCompactLength(buffer);
|
*len = readCompactLength(buffer);
|
||||||
|
|||||||
@@ -15,18 +15,18 @@
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t const buffer[EEPROM_SIZE];
|
uint8_t const buffer[EEPROM_SIZE];
|
||||||
uint16_t offset;
|
uint16_t offset;
|
||||||
} serialized_buffer_t;
|
} config_buffer_t;
|
||||||
|
|
||||||
// Variables:
|
// Variables:
|
||||||
|
|
||||||
extern serialized_buffer_t ConfigBuffer;
|
extern config_buffer_t ConfigBuffer;
|
||||||
|
|
||||||
// Functions:
|
// Functions:
|
||||||
|
|
||||||
uint8_t readUInt8(serialized_buffer_t *buffer);
|
uint8_t readUInt8(config_buffer_t *buffer);
|
||||||
uint16_t readUInt16(serialized_buffer_t *buffer);
|
uint16_t readUInt16(config_buffer_t *buffer);
|
||||||
bool readBool(serialized_buffer_t *buffer);
|
bool readBool(config_buffer_t *buffer);
|
||||||
uint16_t readCompactLength(serialized_buffer_t *buffer);
|
uint16_t readCompactLength(config_buffer_t *buffer);
|
||||||
const char *readString(serialized_buffer_t *buffer, uint16_t *len);
|
const char *readString(config_buffer_t *buffer, uint16_t *len);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "parse_config.h"
|
#include "parse_config.h"
|
||||||
#include "parse_keymap.h"
|
#include "parse_keymap.h"
|
||||||
|
|
||||||
static parser_error_t parseModuleConfiguration(serialized_buffer_t *buffer) {
|
static parser_error_t parseModuleConfiguration(config_buffer_t *buffer) {
|
||||||
uint8_t id = readUInt8(buffer);
|
uint8_t id = readUInt8(buffer);
|
||||||
uint8_t initialPointerSpeed = readUInt8(buffer);
|
uint8_t initialPointerSpeed = readUInt8(buffer);
|
||||||
uint8_t pointerAcceleration = readUInt8(buffer);
|
uint8_t pointerAcceleration = readUInt8(buffer);
|
||||||
@@ -14,7 +14,7 @@ static parser_error_t parseModuleConfiguration(serialized_buffer_t *buffer) {
|
|||||||
return ParserError_Success;
|
return ParserError_Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
parser_error_t ParseConfig(serialized_buffer_t *buffer) {
|
parser_error_t ParseConfig(config_buffer_t *buffer) {
|
||||||
uint16_t dataModelVersion = readUInt16(buffer);
|
uint16_t dataModelVersion = readUInt16(buffer);
|
||||||
parser_error_t errorCode;
|
parser_error_t errorCode;
|
||||||
uint16_t moduleConfigurationCount = readCompactLength(buffer);
|
uint16_t moduleConfigurationCount = readCompactLength(buffer);
|
||||||
|
|||||||
@@ -19,6 +19,6 @@
|
|||||||
|
|
||||||
// Functions:
|
// Functions:
|
||||||
|
|
||||||
parser_error_t ParseConfig(serialized_buffer_t *buffer);
|
parser_error_t ParseConfig(config_buffer_t *buffer);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
|
|
||||||
static bool isDryRun;
|
static bool isDryRun;
|
||||||
|
|
||||||
static parser_error_t parseNoneAction(key_action_t *keyAction, serialized_buffer_t *buffer) {
|
static parser_error_t parseNoneAction(key_action_t *keyAction, config_buffer_t *buffer) {
|
||||||
keyAction->type = KeyActionType_None;
|
keyAction->type = KeyActionType_None;
|
||||||
return ParserError_Success;
|
return ParserError_Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
static parser_error_t parseKeyStrokeAction(key_action_t *keyAction, uint8_t keyStrokeAction, serialized_buffer_t *buffer) {
|
static parser_error_t parseKeyStrokeAction(key_action_t *keyAction, uint8_t keyStrokeAction, config_buffer_t *buffer) {
|
||||||
keyAction->type = KeyActionType_Keystroke;
|
keyAction->type = KeyActionType_Keystroke;
|
||||||
|
|
||||||
uint8_t keystrokeType = (SERIALIZED_KEYSTROKE_TYPE_MASK_KEYSTROKE_TYPE & keyStrokeAction) >> SERIALIZED_KEYSTROKE_TYPE_OFFSET_KEYSTROKE_TYPE;
|
uint8_t keystrokeType = (SERIALIZED_KEYSTROKE_TYPE_MASK_KEYSTROKE_TYPE & keyStrokeAction) >> SERIALIZED_KEYSTROKE_TYPE_OFFSET_KEYSTROKE_TYPE;
|
||||||
@@ -40,7 +40,7 @@ static parser_error_t parseKeyStrokeAction(key_action_t *keyAction, uint8_t keyS
|
|||||||
return ParserError_Success;
|
return ParserError_Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
static parser_error_t parseSwitchLayerAction(key_action_t *KeyAction, serialized_buffer_t *buffer) {
|
static parser_error_t parseSwitchLayerAction(key_action_t *KeyAction, config_buffer_t *buffer) {
|
||||||
uint8_t layer = readUInt8(buffer) + 1;
|
uint8_t layer = readUInt8(buffer) + 1;
|
||||||
bool isToggle = readBool(buffer);
|
bool isToggle = readBool(buffer);
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ static parser_error_t parseSwitchLayerAction(key_action_t *KeyAction, serialized
|
|||||||
return ParserError_Success;
|
return ParserError_Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
static parser_error_t parseSwitchKeymapAction(key_action_t *keyAction, serialized_buffer_t *buffer) {
|
static parser_error_t parseSwitchKeymapAction(key_action_t *keyAction, config_buffer_t *buffer) {
|
||||||
uint16_t keymapAbbreviationLen;
|
uint16_t keymapAbbreviationLen;
|
||||||
const char *keymapAbbreviation = readString(buffer, &keymapAbbreviationLen);
|
const char *keymapAbbreviation = readString(buffer, &keymapAbbreviationLen);
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ static parser_error_t parseSwitchKeymapAction(key_action_t *keyAction, serialize
|
|||||||
return ParserError_Success;
|
return ParserError_Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
static parser_error_t parseMouseAction(key_action_t *keyAction, serialized_buffer_t *buffer) {
|
static parser_error_t parseMouseAction(key_action_t *keyAction, config_buffer_t *buffer) {
|
||||||
uint8_t mouseAction = readUInt8(buffer);
|
uint8_t mouseAction = readUInt8(buffer);
|
||||||
|
|
||||||
keyAction->type = KeyActionType_Mouse;
|
keyAction->type = KeyActionType_Mouse;
|
||||||
@@ -111,7 +111,7 @@ static parser_error_t parseMouseAction(key_action_t *keyAction, serialized_buffe
|
|||||||
return ParserError_Success;
|
return ParserError_Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
static parser_error_t parseKeyAction(key_action_t *keyAction, serialized_buffer_t *buffer) {
|
static parser_error_t parseKeyAction(key_action_t *keyAction, config_buffer_t *buffer) {
|
||||||
uint8_t keyActionType = readUInt8(buffer);
|
uint8_t keyActionType = readUInt8(buffer);
|
||||||
|
|
||||||
switch (keyActionType) {
|
switch (keyActionType) {
|
||||||
@@ -131,7 +131,7 @@ static parser_error_t parseKeyAction(key_action_t *keyAction, serialized_buffer_
|
|||||||
return ParserError_Success;
|
return ParserError_Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
static parser_error_t parseKeyActions(uint8_t targetLayer, serialized_buffer_t *buffer, uint8_t moduleId, uint8_t pointerRole) {
|
static parser_error_t parseKeyActions(uint8_t targetLayer, config_buffer_t *buffer, uint8_t moduleId, uint8_t pointerRole) {
|
||||||
parser_error_t errorCode;
|
parser_error_t errorCode;
|
||||||
uint16_t actionCount = readCompactLength(buffer);
|
uint16_t actionCount = readCompactLength(buffer);
|
||||||
key_action_t dummyKeyAction;
|
key_action_t dummyKeyAction;
|
||||||
@@ -148,13 +148,13 @@ static parser_error_t parseKeyActions(uint8_t targetLayer, serialized_buffer_t *
|
|||||||
return ParserError_Success;
|
return ParserError_Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
static parser_error_t parseModule(serialized_buffer_t *buffer, uint8_t layer) {
|
static parser_error_t parseModule(config_buffer_t *buffer, uint8_t layer) {
|
||||||
uint8_t moduleId = readUInt8(buffer);
|
uint8_t moduleId = readUInt8(buffer);
|
||||||
uint8_t pointerRole = readUInt8(buffer);
|
uint8_t pointerRole = readUInt8(buffer);
|
||||||
return parseKeyActions(layer, buffer, moduleId, pointerRole);
|
return parseKeyActions(layer, buffer, moduleId, pointerRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
static parser_error_t parseLayer(serialized_buffer_t *buffer, uint8_t layer) {
|
static parser_error_t parseLayer(config_buffer_t *buffer, uint8_t layer) {
|
||||||
parser_error_t errorCode;
|
parser_error_t errorCode;
|
||||||
uint16_t moduleCount = readCompactLength(buffer);
|
uint16_t moduleCount = readCompactLength(buffer);
|
||||||
|
|
||||||
@@ -170,7 +170,7 @@ static parser_error_t parseLayer(serialized_buffer_t *buffer, uint8_t layer) {
|
|||||||
return ParserError_Success;
|
return ParserError_Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
parser_error_t ParseKeymap(serialized_buffer_t *buffer) {;
|
parser_error_t ParseKeymap(config_buffer_t *buffer) {;
|
||||||
parser_error_t errorCode;
|
parser_error_t errorCode;
|
||||||
uint16_t abbreviationLen;
|
uint16_t abbreviationLen;
|
||||||
uint16_t nameLen;
|
uint16_t nameLen;
|
||||||
|
|||||||
@@ -52,6 +52,6 @@
|
|||||||
|
|
||||||
// Functions:
|
// Functions:
|
||||||
|
|
||||||
parser_error_t ParseKeymap(serialized_buffer_t *buffer);
|
parser_error_t ParseKeymap(config_buffer_t *buffer);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user