Move some code from parse_keymap.* to config_state.*

This commit is contained in:
Eric Tang
2017-07-07 14:54:39 -07:00
parent f4c5a7e969
commit 7a9659f7c0
4 changed files with 56 additions and 47 deletions
-32
View File
@@ -2,40 +2,8 @@
#include "key_action.h"
#include "current_keymap.h"
#define longCompactLengthPrefix 0xff
static bool isDryRun;
static uint8_t readUInt8(serialized_buffer_t *buffer) {
return buffer->buffer[buffer->offset++];
}
static uint16_t readUInt16(serialized_buffer_t *buffer) {
uint8_t firstByte = buffer->buffer[buffer->offset++];
return firstByte + (buffer->buffer[buffer->offset++] << 8);
}
static bool readBool(serialized_buffer_t *buffer) {
return buffer->buffer[buffer->offset++] == 1;
}
static uint16_t readCompactLength(serialized_buffer_t *buffer) {
uint16_t length = readUInt8(buffer);
if (length == longCompactLengthPrefix) {
length = readUInt16(buffer);
}
return length;
}
static const char *readString(serialized_buffer_t *buffer, uint16_t *len) {
const char *str = (const char *)&(buffer->buffer[buffer->offset]);
*len = readCompactLength(buffer);
buffer->offset += *len;
return str;
}
static parser_error_t parseNoneAction(key_action_t *keyAction, serialized_buffer_t *buffer) {
keyAction->type = KeyActionType_None;
return ParserError_Success;