Add the parser for the top-level configuration
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
// Includes:
|
||||
|
||||
#include <stdint.h>
|
||||
#include "fsl_common.h"
|
||||
|
||||
// Macros:
|
||||
@@ -16,16 +17,6 @@
|
||||
uint16_t offset;
|
||||
} serialized_buffer_t;
|
||||
|
||||
typedef enum {
|
||||
ParserError_Success,
|
||||
ParserError_InvalidSerializedKeystrokeType,
|
||||
ParserError_InvalidSerializedMouseAction,
|
||||
ParserError_InvalidSerializedKeyActionType,
|
||||
ParserError_InvalidLayerCount,
|
||||
ParserError_InvalidModuleCount,
|
||||
ParserError_InvalidActionCount,
|
||||
} parser_error_t;
|
||||
|
||||
// Variables:
|
||||
|
||||
extern serialized_buffer_t ConfigBuffer;
|
||||
|
||||
46
right/src/config/parse_config.c
Normal file
46
right/src/config/parse_config.c
Normal file
@@ -0,0 +1,46 @@
|
||||
#include "parse_config.h"
|
||||
#include "parse_keymap.h"
|
||||
|
||||
static parser_error_t parseModuleConfiguration(serialized_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(serialized_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 (uint8_t moduleConfigurationIdx = 0; moduleConfigurationIdx < moduleConfigurationCount; moduleConfigurationIdx++) {
|
||||
errorCode = parseModuleConfiguration(buffer);
|
||||
if (errorCode != ParserError_Success) {
|
||||
return errorCode;
|
||||
}
|
||||
}
|
||||
macroCount = readCompactLength(buffer);
|
||||
for (uint8_t macroIdx = 0; macroIdx < macroCount; macroIdx++) {
|
||||
// errorCode = ParseMacro(buffer);
|
||||
// if (errorCode != ParserError_Success) {
|
||||
// return errorCode;
|
||||
// }
|
||||
}
|
||||
keymapCount = readCompactLength(buffer);
|
||||
for (uint8_t keymapIdx = 0; keymapIdx < keymapCount; keymapIdx++) {
|
||||
errorCode = ParseKeymap(buffer);
|
||||
if (errorCode != ParserError_Success) {
|
||||
return errorCode;
|
||||
}
|
||||
}
|
||||
return ParserError_Success;
|
||||
}
|
||||
24
right/src/config/parse_config.h
Normal file
24
right/src/config/parse_config.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#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,
|
||||
} parser_error_t;
|
||||
|
||||
// Functions:
|
||||
|
||||
parser_error_t ParseConfig(serialized_buffer_t *buffer);
|
||||
|
||||
#endif
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "config_state.h"
|
||||
#include "parse_config.h"
|
||||
|
||||
// Macros:
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "i2c_addresses.h"
|
||||
#include "led_driver.h"
|
||||
#include "peripherals/merge_sensor.h"
|
||||
#include "config/parse_keymap.h"
|
||||
#include "config/parse_config.h"
|
||||
#include "config/config_state.h"
|
||||
#include "led_pwm.h"
|
||||
#include "slave_scheduler.h"
|
||||
@@ -194,7 +194,7 @@ void uploadConfig()
|
||||
void applyConfig()
|
||||
{
|
||||
ConfigBuffer.offset = 0;
|
||||
GenericHidOutBuffer[0] = ParseKeymap(&ConfigBuffer);
|
||||
GenericHidOutBuffer[0] = ParseConfig(&ConfigBuffer);
|
||||
GenericHidOutBuffer[1] = ConfigBuffer.offset;
|
||||
GenericHidOutBuffer[2] = ConfigBuffer.offset >> 8;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user