Uppercamelcase read*() config parser functions since they're not local.
This commit is contained in:
@@ -1,40 +1,40 @@
|
||||
#include "basic_types.h"
|
||||
|
||||
uint8_t readUInt8(config_buffer_t *buffer)
|
||||
uint8_t ReadUInt8(config_buffer_t *buffer)
|
||||
{
|
||||
return buffer->buffer[buffer->offset++];
|
||||
}
|
||||
|
||||
uint16_t readUInt16(config_buffer_t *buffer)
|
||||
uint16_t ReadUInt16(config_buffer_t *buffer)
|
||||
{
|
||||
uint16_t uInt16 = readUInt8(buffer);
|
||||
uint16_t uInt16 = ReadUInt8(buffer);
|
||||
|
||||
uInt16 |= readUInt8(buffer) << 8;
|
||||
uInt16 |= ReadUInt8(buffer) << 8;
|
||||
return uInt16;
|
||||
}
|
||||
|
||||
int16_t readInt16(config_buffer_t *buffer)
|
||||
int16_t ReadInt16(config_buffer_t *buffer)
|
||||
{
|
||||
return readUInt16(buffer);
|
||||
return ReadUInt16(buffer);
|
||||
}
|
||||
|
||||
bool readBool(config_buffer_t *buffer)
|
||||
bool ReadBool(config_buffer_t *buffer)
|
||||
{
|
||||
return readUInt8(buffer);
|
||||
return ReadUInt8(buffer);
|
||||
}
|
||||
|
||||
uint16_t readCompactLength(config_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(config_buffer_t *buffer, uint16_t *len)
|
||||
const char *ReadString(config_buffer_t *buffer, uint16_t *len)
|
||||
{
|
||||
const char *string;
|
||||
|
||||
*len = readCompactLength(buffer);
|
||||
*len = ReadCompactLength(buffer);
|
||||
string = (const char *)(buffer->buffer + buffer->offset);
|
||||
buffer->offset += *len;
|
||||
return string;
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
|
||||
// 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);
|
||||
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
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
|
||||
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);
|
||||
uint8_t id = ReadUInt8(buffer);
|
||||
uint8_t initialPointerSpeed = ReadUInt8(buffer);
|
||||
uint8_t pointerAcceleration = ReadUInt8(buffer);
|
||||
uint8_t maxPointerSpeed = ReadUInt8(buffer);
|
||||
|
||||
(void)id;
|
||||
(void)initialPointerSpeed;
|
||||
@@ -26,11 +26,11 @@ parser_error_t ParseConfig(config_buffer_t *buffer)
|
||||
uint16_t keymapCount;
|
||||
parser_error_t errorCode;
|
||||
|
||||
uint16_t dataModelVersion = readUInt16(buffer);
|
||||
uint16_t userConfigLength = readUInt16(buffer);
|
||||
uint16_t dataModelVersion = ReadUInt16(buffer);
|
||||
uint16_t userConfigLength = ReadUInt16(buffer);
|
||||
(void)userConfigLength;
|
||||
readString(buffer, &len); // Ignore device name
|
||||
uint16_t moduleConfigurationCount = readCompactLength(buffer);
|
||||
ReadString(buffer, &len); // Ignore device name
|
||||
uint16_t moduleConfigurationCount = ReadCompactLength(buffer);
|
||||
|
||||
(void)dataModelVersion;
|
||||
|
||||
@@ -45,7 +45,7 @@ parser_error_t ParseConfig(config_buffer_t *buffer)
|
||||
}
|
||||
}
|
||||
|
||||
macroCount = readCompactLength(buffer);
|
||||
macroCount = ReadCompactLength(buffer);
|
||||
if (macroCount > MAX_MACRO_NUM) {
|
||||
return ParserError_InvalidMacroCount;
|
||||
}
|
||||
@@ -57,7 +57,7 @@ parser_error_t ParseConfig(config_buffer_t *buffer)
|
||||
}
|
||||
}
|
||||
|
||||
keymapCount = readCompactLength(buffer);
|
||||
keymapCount = ReadCompactLength(buffer);
|
||||
if (keymapCount == 0 || keymapCount > MAX_KEYMAP_NUM) {
|
||||
return ParserError_InvalidKeymapCount;
|
||||
}
|
||||
|
||||
@@ -34,21 +34,21 @@ static parser_error_t parseKeyStrokeAction(key_action_t *keyAction, uint8_t keyS
|
||||
return ParserError_InvalidSerializedKeystrokeType;
|
||||
}
|
||||
keyAction->keystroke.scancode = keyStrokeAction & SERIALIZED_KEYSTROKE_TYPE_MASK_HAS_SCANCODE
|
||||
? keystrokeType == SerializedKeystrokeType_LongMedia ? readUInt16(buffer) : readUInt8(buffer)
|
||||
? keystrokeType == SerializedKeystrokeType_LongMedia ? ReadUInt16(buffer) : ReadUInt8(buffer)
|
||||
: 0;
|
||||
keyAction->keystroke.modifiers = keyStrokeAction & SERIALIZED_KEYSTROKE_TYPE_MASK_HAS_MODIFIERS
|
||||
? readUInt8(buffer)
|
||||
? ReadUInt8(buffer)
|
||||
: 0;
|
||||
keyAction->keystroke.secondaryRole = keyStrokeAction & SERIALIZED_KEYSTROKE_TYPE_MASK_HAS_LONGPRESS
|
||||
? readUInt8(buffer) + 1
|
||||
? ReadUInt8(buffer) + 1
|
||||
: 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);
|
||||
uint8_t layer = ReadUInt8(buffer) + 1;
|
||||
bool isToggle = ReadBool(buffer);
|
||||
|
||||
KeyAction->type = KeyActionType_SwitchLayer;
|
||||
KeyAction->switchLayer.layer = layer;
|
||||
@@ -58,7 +58,7 @@ static parser_error_t parseSwitchLayerAction(key_action_t *KeyAction, config_buf
|
||||
|
||||
static parser_error_t parseSwitchKeymapAction(key_action_t *keyAction, config_buffer_t *buffer)
|
||||
{
|
||||
uint8_t keymapIndex = readUInt8(buffer);
|
||||
uint8_t keymapIndex = ReadUInt8(buffer);
|
||||
|
||||
if (keymapIndex >= tempKeymapCount) {
|
||||
return ParserError_InvalidSerializedSwitchKeymapAction;
|
||||
@@ -70,7 +70,7 @@ static parser_error_t parseSwitchKeymapAction(key_action_t *keyAction, config_bu
|
||||
|
||||
static parser_error_t parsePlayMacroAction(key_action_t *keyAction, config_buffer_t *buffer)
|
||||
{
|
||||
uint8_t macroIndex = readUInt8(buffer);
|
||||
uint8_t macroIndex = ReadUInt8(buffer);
|
||||
|
||||
if (macroIndex >= tempMacroCount) {
|
||||
return ParserError_InvalidSerializedPlayMacroAction;
|
||||
@@ -82,7 +82,7 @@ static parser_error_t parsePlayMacroAction(key_action_t *keyAction, config_buffe
|
||||
|
||||
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;
|
||||
memset(&keyAction->mouse, 0, sizeof keyAction->mouse);
|
||||
@@ -134,7 +134,7 @@ static parser_error_t parseMouseAction(key_action_t *keyAction, config_buffer_t
|
||||
|
||||
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) {
|
||||
case SerializedKeyActionType_None:
|
||||
@@ -156,7 +156,7 @@ static parser_error_t parseKeyAction(key_action_t *keyAction, config_buffer_t *b
|
||||
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);
|
||||
uint16_t actionCount = ReadCompactLength(buffer);
|
||||
key_action_t dummyKeyAction;
|
||||
|
||||
if (actionCount > MAX_KEY_COUNT_PER_MODULE) {
|
||||
@@ -173,8 +173,8 @@ static parser_error_t parseKeyActions(uint8_t targetLayer, config_buffer_t *buff
|
||||
|
||||
static parser_error_t parseModule(config_buffer_t *buffer, uint8_t layer)
|
||||
{
|
||||
uint8_t moduleId = readUInt8(buffer);
|
||||
uint8_t pointerRole = readUInt8(buffer);
|
||||
uint8_t moduleId = ReadUInt8(buffer);
|
||||
uint8_t pointerRole = ReadUInt8(buffer);
|
||||
|
||||
return parseKeyActions(layer, buffer, moduleId, pointerRole);
|
||||
}
|
||||
@@ -182,7 +182,7 @@ static parser_error_t parseModule(config_buffer_t *buffer, uint8_t layer)
|
||||
static parser_error_t parseLayer(config_buffer_t *buffer, uint8_t layer)
|
||||
{
|
||||
parser_error_t errorCode;
|
||||
uint16_t moduleCount = readCompactLength(buffer);
|
||||
uint16_t moduleCount = ReadCompactLength(buffer);
|
||||
|
||||
if (moduleCount > SLOT_COUNT) {
|
||||
return ParserError_InvalidModuleCount;
|
||||
@@ -203,11 +203,11 @@ parser_error_t ParseKeymap(config_buffer_t *buffer, uint8_t keymapIdx, uint8_t k
|
||||
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);
|
||||
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;
|
||||
|
||||
@@ -13,8 +13,8 @@ parser_error_t parseKeyMacroAction(config_buffer_t *buffer, macro_action_t *macr
|
||||
keyMacroType >>= 2;
|
||||
type = keyMacroType & 0b11;
|
||||
keyMacroType >>= 2;
|
||||
scancode = keyMacroType & 0b10 ? readUInt8(buffer) : 0;
|
||||
modifierMask = keyMacroType & 0b01 ? readUInt8(buffer) : 0;
|
||||
scancode = keyMacroType & 0b10 ? ReadUInt8(buffer) : 0;
|
||||
modifierMask = keyMacroType & 0b01 ? ReadUInt8(buffer) : 0;
|
||||
macroAction->type = MacroActionType_Key;
|
||||
macroAction->key.action = action;
|
||||
macroAction->key.type = type;
|
||||
@@ -26,7 +26,7 @@ parser_error_t parseKeyMacroAction(config_buffer_t *buffer, macro_action_t *macr
|
||||
parser_error_t parseMouseButtonMacroAction(config_buffer_t *buffer, macro_action_t *macroAction, serialized_macro_action_type_t macroActionType)
|
||||
{
|
||||
uint8_t action = macroActionType - SerializedMacroActionType_MouseButtonMacroAction;
|
||||
uint8_t mouseButtonsMask = readUInt8(buffer);
|
||||
uint8_t mouseButtonsMask = ReadUInt8(buffer);
|
||||
|
||||
macroAction->type = MacroActionType_MouseButton;
|
||||
macroAction->mouseButton.action = action;
|
||||
@@ -36,8 +36,8 @@ parser_error_t parseMouseButtonMacroAction(config_buffer_t *buffer, macro_action
|
||||
|
||||
parser_error_t parseMoveMouseMacroAction(config_buffer_t *buffer, macro_action_t *macroAction)
|
||||
{
|
||||
int16_t x = readInt16(buffer);
|
||||
int16_t y = readInt16(buffer);
|
||||
int16_t x = ReadInt16(buffer);
|
||||
int16_t y = ReadInt16(buffer);
|
||||
|
||||
macroAction->type = MacroActionType_MoveMouse;
|
||||
macroAction->moveMouse.x = x;
|
||||
@@ -47,8 +47,8 @@ parser_error_t parseMoveMouseMacroAction(config_buffer_t *buffer, macro_action_t
|
||||
|
||||
parser_error_t parseScrollMouseMacroAction(config_buffer_t *buffer, macro_action_t *macroAction)
|
||||
{
|
||||
int16_t x = readInt16(buffer);
|
||||
int16_t y = readInt16(buffer);
|
||||
int16_t x = ReadInt16(buffer);
|
||||
int16_t y = ReadInt16(buffer);
|
||||
|
||||
macroAction->type = MacroActionType_ScrollMouse;
|
||||
macroAction->scrollMouse.x = x;
|
||||
@@ -58,7 +58,7 @@ parser_error_t parseScrollMouseMacroAction(config_buffer_t *buffer, macro_action
|
||||
|
||||
parser_error_t parseDelayMacroAction(config_buffer_t *buffer, macro_action_t *macroAction)
|
||||
{
|
||||
int16_t delay = readInt16(buffer);
|
||||
int16_t delay = ReadInt16(buffer);
|
||||
|
||||
macroAction->type = MacroActionType_Delay;
|
||||
macroAction->delay.delay = delay;
|
||||
@@ -68,7 +68,7 @@ parser_error_t parseDelayMacroAction(config_buffer_t *buffer, macro_action_t *ma
|
||||
parser_error_t parseTextMacroAction(config_buffer_t *buffer, macro_action_t *macroAction)
|
||||
{
|
||||
uint16_t textLen;
|
||||
const char *text = readString(buffer, &textLen);
|
||||
const char *text = ReadString(buffer, &textLen);
|
||||
|
||||
macroAction->type = MacroActionType_Text;
|
||||
macroAction->text.text = text;
|
||||
@@ -78,7 +78,7 @@ parser_error_t parseTextMacroAction(config_buffer_t *buffer, macro_action_t *mac
|
||||
|
||||
parser_error_t ParseMacroAction(config_buffer_t *buffer, macro_action_t *macroAction)
|
||||
{
|
||||
uint8_t macroActionType = readUInt8(buffer);
|
||||
uint8_t macroActionType = ReadUInt8(buffer);
|
||||
|
||||
switch (macroActionType) {
|
||||
case SerializedMacroActionType_KeyMacroAction ... SerializedMacroActionType_LastKeyMacroAction:
|
||||
@@ -101,10 +101,10 @@ parser_error_t ParseMacro(config_buffer_t *buffer, uint8_t macroIdx)
|
||||
{
|
||||
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);
|
||||
bool isLooped = ReadBool(buffer);
|
||||
bool isPrivate = ReadBool(buffer);
|
||||
const char *name = ReadString(buffer, &nameLen);
|
||||
uint16_t macroActionsCount = ReadCompactLength(buffer);
|
||||
uint16_t firstMacroActionOffset = buffer->offset;
|
||||
macro_action_t dummyMacroAction;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user