Rename deserialize_Layer() to parseLayer() and process* functions to parse*

This commit is contained in:
László Monda
2017-06-15 18:13:42 +02:00
parent 972febf360
commit bdaef763a4
3 changed files with 19 additions and 19 deletions

View File

@@ -68,11 +68,11 @@ static const char *readString(serialized_buffer_t *buffer, uint16_t *len) {
// ---------------- // ----------------
static void processNoneAction(key_action_t *action, serialized_buffer_t *buffer) { static void parseNoneAction(key_action_t *action, serialized_buffer_t *buffer) {
action->type = KEY_ACTION_NONE; action->type = KEY_ACTION_NONE;
} }
static void processKeyStrokeAction(key_action_t *action, uint8_t actionType, serialized_buffer_t *buffer) { static void parseKeyStrokeAction(key_action_t *action, uint8_t actionType, serialized_buffer_t *buffer) {
uint8_t flags = actionType - 1; uint8_t flags = actionType - 1;
action->type = KEY_ACTION_KEYSTROKE; action->type = KEY_ACTION_KEYSTROKE;
@@ -101,7 +101,7 @@ static void processKeyStrokeAction(key_action_t *action, uint8_t actionType, ser
} }
} }
static void processSwitchLayerAction(key_action_t *action, serialized_buffer_t *buffer) { static void parseSwitchLayerAction(key_action_t *action, serialized_buffer_t *buffer) {
uint8_t layer = readUInt8(buffer) + 1; uint8_t layer = readUInt8(buffer) + 1;
bool isToggle = readBool(buffer); bool isToggle = readBool(buffer);
@@ -110,7 +110,7 @@ static void processSwitchLayerAction(key_action_t *action, serialized_buffer_t *
action->switchLayer.isToggle = isToggle; action->switchLayer.isToggle = isToggle;
} }
static void processSwitchKeymapAction(key_action_t *action, serialized_buffer_t *buffer) { static void parseSwitchKeymapAction(key_action_t *action, serialized_buffer_t *buffer) {
// uint16_t len; // uint16_t len;
// const char *keymap = readString(buffer, &len); // const char *keymap = readString(buffer, &len);
@@ -119,7 +119,7 @@ static void processSwitchKeymapAction(key_action_t *action, serialized_buffer_t
// TODO: Implement this // TODO: Implement this
} }
static void processMouseAction(key_action_t *action, serialized_buffer_t *buffer) { static void parseMouseAction(key_action_t *action, serialized_buffer_t *buffer) {
uint8_t mouseAction = readUInt8(buffer); uint8_t mouseAction = readUInt8(buffer);
action->type = KEY_ACTION_MOUSE; action->type = KEY_ACTION_MOUSE;
@@ -166,42 +166,42 @@ static void processMouseAction(key_action_t *action, serialized_buffer_t *buffer
} }
} }
static void processKeyAction(key_action_t *action, serialized_buffer_t *buffer) { static void parseKeyAction(key_action_t *action, serialized_buffer_t *buffer) {
uint8_t actionType = readUInt8(buffer); uint8_t actionType = readUInt8(buffer);
switch (actionType) { switch (actionType) {
case NoneAction: case NoneAction:
return processNoneAction(action, buffer); return parseNoneAction(action, buffer);
case KeyStrokeAction ... LastKeyStrokeAction: case KeyStrokeAction ... LastKeyStrokeAction:
return processKeyStrokeAction(action, actionType, buffer); return parseKeyStrokeAction(action, actionType, buffer);
case SwitchLayerAction: case SwitchLayerAction:
return processSwitchLayerAction(action, buffer); return parseSwitchLayerAction(action, buffer);
case SwitchKeymapAction: case SwitchKeymapAction:
return processSwitchKeymapAction(action, buffer); return parseSwitchKeymapAction(action, buffer);
case MouseAction: case MouseAction:
return processMouseAction(action, buffer); return parseMouseAction(action, buffer);
default: default:
// TODO: Handle the case where the actionType is unknown // TODO: Handle the case where the actionType is unknown
break; break;
} }
} }
static void processKeyActions(uint8_t targetLayer, serialized_buffer_t *buffer, uint8_t moduleID, uint8_t pointerRole) { static void parseKeyActions(uint8_t targetLayer, serialized_buffer_t *buffer, uint8_t moduleID, uint8_t pointerRole) {
uint8_t actionCount = readCompactLength(buffer); uint8_t actionCount = readCompactLength(buffer);
for (uint8_t actionIdx = 0; actionIdx < actionCount; actionIdx++) { for (uint8_t actionIdx = 0; actionIdx < actionCount; actionIdx++) {
key_action_t *action = &(CurrentKeymap[targetLayer][moduleID][actionIdx]); key_action_t *action = &(CurrentKeymap[targetLayer][moduleID][actionIdx]);
processKeyAction(action, buffer); parseKeyAction(action, buffer);
} }
} }
static void processModule(serialized_buffer_t *buffer, uint8_t targetLayer) { static void parseModule(serialized_buffer_t *buffer, uint8_t targetLayer) {
uint8_t moduleID, pointerRole; uint8_t moduleID, pointerRole;
moduleID = readUInt8(buffer); moduleID = readUInt8(buffer);
pointerRole = readUInt8(buffer); pointerRole = readUInt8(buffer);
processKeyActions(targetLayer, buffer, moduleID, pointerRole); parseKeyActions(targetLayer, buffer, moduleID, pointerRole);
} }
static void clearModule(uint8_t targetLayer, uint8_t moduleID) { static void clearModule(uint8_t targetLayer, uint8_t moduleID) {
@@ -210,7 +210,7 @@ static void clearModule(uint8_t targetLayer, uint8_t moduleID) {
// ---------- // ----------
void deserialize_Layer (const uint8_t *data, uint8_t targetLayer) { void ParseLayer(const uint8_t *data, uint8_t targetLayer) {
serialized_buffer_t buffer; serialized_buffer_t buffer;
buffer.buffer = data; buffer.buffer = data;
@@ -220,6 +220,6 @@ void deserialize_Layer (const uint8_t *data, uint8_t targetLayer) {
for (uint8_t modIdx = 0; modIdx < moduleCount; modIdx++) { for (uint8_t modIdx = 0; modIdx < moduleCount; modIdx++) {
clearModule(targetLayer, modIdx); clearModule(targetLayer, modIdx);
processModule(&buffer, targetLayer); parseModule(&buffer, targetLayer);
} }
} }

View File

@@ -3,6 +3,6 @@
#include <stdint.h> #include <stdint.h>
void deserialize_Layer(const uint8_t *data, uint8_t targetLayer); void ParseLayer(const uint8_t *data, uint8_t targetLayer);
#endif #endif

View File

@@ -193,7 +193,7 @@ void uploadConfig()
void applyConfig() void applyConfig()
{ {
deserialize_Layer(ConfigBuffer, 0); ParseLayer(ConfigBuffer, 0);
} }
void setLedPwm() void setLedPwm()