Make the parser parse mouse properties, LED brightness values, and double tap switch layer timeout. Rename pointer config properties.
This commit is contained in:
@@ -8,7 +8,6 @@ uint8_t ReadUInt8(config_buffer_t *buffer)
|
|||||||
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;
|
return uInt16;
|
||||||
}
|
}
|
||||||
@@ -26,14 +25,12 @@ bool ReadBool(config_buffer_t *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;
|
const char *string;
|
||||||
|
|
||||||
*len = ReadCompactLength(buffer);
|
*len = ReadCompactLength(buffer);
|
||||||
string = (const char *)(buffer->buffer + buffer->offset);
|
string = (const char *)(buffer->buffer + buffer->offset);
|
||||||
buffer->offset += *len;
|
buffer->offset += *len;
|
||||||
|
|||||||
@@ -4,35 +4,84 @@
|
|||||||
#include "keymap.h"
|
#include "keymap.h"
|
||||||
#include "config_globals.h"
|
#include "config_globals.h"
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
|
#include "usb_report_updater.h"
|
||||||
|
|
||||||
static parser_error_t parseModuleConfiguration(config_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 deceleratedPointerSpeedMultiplier = ReadUInt8(buffer);
|
||||||
uint8_t pointerAcceleration = ReadUInt8(buffer);
|
uint8_t basePointerSpeedMultiplier = ReadUInt8(buffer);
|
||||||
uint8_t maxPointerSpeed = ReadUInt8(buffer);
|
uint8_t acceleratedPointerSpeed = ReadUInt8(buffer);
|
||||||
|
|
||||||
(void)id;
|
(void)id;
|
||||||
(void)initialPointerSpeed;
|
(void)deceleratedPointerSpeedMultiplier;
|
||||||
(void)pointerAcceleration;
|
(void)basePointerSpeedMultiplier;
|
||||||
(void)maxPointerSpeed;
|
(void)acceleratedPointerSpeed;
|
||||||
return ParserError_Success;
|
return ParserError_Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
parser_error_t ParseConfig(config_buffer_t *buffer)
|
parser_error_t ParseConfig(config_buffer_t *buffer)
|
||||||
{
|
{
|
||||||
|
// Miscellaneous properties
|
||||||
|
|
||||||
uint16_t len;
|
uint16_t len;
|
||||||
uint16_t macroCount;
|
uint16_t macroCount;
|
||||||
uint16_t keymapCount;
|
uint16_t keymapCount;
|
||||||
parser_error_t errorCode;
|
parser_error_t errorCode;
|
||||||
|
|
||||||
uint16_t dataModelVersion = ReadUInt16(buffer);
|
uint16_t dataModelMajorVersion = ReadUInt16(buffer);
|
||||||
|
uint16_t dataModelMinorVersion = ReadUInt16(buffer);
|
||||||
|
uint16_t dataModelPatchVersion = ReadUInt16(buffer);
|
||||||
uint16_t userConfigLength = ReadUInt16(buffer);
|
uint16_t userConfigLength = ReadUInt16(buffer);
|
||||||
(void)userConfigLength;
|
const char *deviceName = ReadString(buffer, &len);
|
||||||
ReadString(buffer, &len); // Ignore device name
|
uint16_t doubleTapSwitchLayerTimeout = ReadUInt16(buffer);
|
||||||
uint16_t moduleConfigurationCount = ReadCompactLength(buffer);
|
|
||||||
|
|
||||||
(void)dataModelVersion;
|
(void)userConfigLength;
|
||||||
|
(void)dataModelMajorVersion;
|
||||||
|
(void)dataModelMinorVersion;
|
||||||
|
(void)dataModelPatchVersion;
|
||||||
|
(void)deviceName;
|
||||||
|
|
||||||
|
// LED brightness
|
||||||
|
|
||||||
|
uint8_t iconsAndLayerTextsBrightness = ReadUInt8(buffer);
|
||||||
|
uint8_t alphanumericSegmentsBrightness = ReadUInt8(buffer);
|
||||||
|
uint8_t keyBacklightBrightness = ReadUInt8(buffer);
|
||||||
|
|
||||||
|
(void)iconsAndLayerTextsBrightness;
|
||||||
|
(void)alphanumericSegmentsBrightness;
|
||||||
|
(void)keyBacklightBrightness;
|
||||||
|
|
||||||
|
// Mouse kinetic properties
|
||||||
|
|
||||||
|
uint8_t mouseMoveInitialSpeed = ReadUInt8(buffer);
|
||||||
|
uint8_t mouseMoveAcceleration = ReadUInt8(buffer);
|
||||||
|
uint8_t mouseMoveDeceleratedSpeed = ReadUInt8(buffer);
|
||||||
|
uint8_t mouseMoveBaseSpeed = ReadUInt8(buffer);
|
||||||
|
uint8_t mouseMoveAcceleratedSpeed = ReadUInt8(buffer);
|
||||||
|
uint8_t mouseScrollInitialSpeed = ReadUInt8(buffer);
|
||||||
|
uint8_t mouseScrollAcceleration = ReadUInt8(buffer);
|
||||||
|
uint8_t mouseScrollDeceleratedSpeed = ReadUInt8(buffer);
|
||||||
|
uint8_t mouseScrollBaseSpeed = ReadUInt8(buffer);
|
||||||
|
uint8_t mouseScrollAcceleratedSpeed = ReadUInt8(buffer);
|
||||||
|
|
||||||
|
if (mouseMoveInitialSpeed == 0 ||
|
||||||
|
mouseMoveAcceleration == 0 ||
|
||||||
|
mouseMoveDeceleratedSpeed == 0 ||
|
||||||
|
mouseMoveBaseSpeed == 0 ||
|
||||||
|
mouseMoveAcceleratedSpeed == 0 ||
|
||||||
|
mouseScrollInitialSpeed == 0 ||
|
||||||
|
mouseScrollAcceleration == 0 ||
|
||||||
|
mouseScrollDeceleratedSpeed == 0 ||
|
||||||
|
mouseScrollBaseSpeed == 0 ||
|
||||||
|
mouseScrollAcceleratedSpeed == 0)
|
||||||
|
{
|
||||||
|
return ParserError_InvalidMouseKineticProperty;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Module configurations
|
||||||
|
|
||||||
|
uint16_t moduleConfigurationCount = ReadCompactLength(buffer);
|
||||||
|
|
||||||
if (moduleConfigurationCount > 255) {
|
if (moduleConfigurationCount > 255) {
|
||||||
return ParserError_InvalidModuleConfigurationCount;
|
return ParserError_InvalidModuleConfigurationCount;
|
||||||
@@ -45,6 +94,8 @@ parser_error_t ParseConfig(config_buffer_t *buffer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Macros
|
||||||
|
|
||||||
macroCount = ReadCompactLength(buffer);
|
macroCount = ReadCompactLength(buffer);
|
||||||
if (macroCount > MAX_MACRO_NUM) {
|
if (macroCount > MAX_MACRO_NUM) {
|
||||||
return ParserError_InvalidMacroCount;
|
return ParserError_InvalidMacroCount;
|
||||||
@@ -57,6 +108,8 @@ parser_error_t ParseConfig(config_buffer_t *buffer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Keymaps
|
||||||
|
|
||||||
keymapCount = ReadCompactLength(buffer);
|
keymapCount = ReadCompactLength(buffer);
|
||||||
if (keymapCount == 0 || keymapCount > MAX_KEYMAP_NUM) {
|
if (keymapCount == 0 || keymapCount > MAX_KEYMAP_NUM) {
|
||||||
return ParserError_InvalidKeymapCount;
|
return ParserError_InvalidKeymapCount;
|
||||||
@@ -69,7 +122,23 @@ parser_error_t ParseConfig(config_buffer_t *buffer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If parsing succeeded then apply the parsed values.
|
||||||
|
|
||||||
if (!ParserRunDry) {
|
if (!ParserRunDry) {
|
||||||
|
DoubleTapSwitchLayerTimeout = doubleTapSwitchLayerTimeout;
|
||||||
|
|
||||||
|
MouseMoveState.initialSpeed = mouseMoveInitialSpeed;
|
||||||
|
MouseMoveState.acceleration = mouseMoveAcceleration;
|
||||||
|
MouseMoveState.deceleratedSpeed = mouseMoveDeceleratedSpeed;
|
||||||
|
MouseMoveState.baseSpeed = mouseMoveBaseSpeed;
|
||||||
|
MouseMoveState.acceleratedSpeed = mouseMoveAcceleratedSpeed;
|
||||||
|
|
||||||
|
MouseScrollState.initialSpeed = mouseScrollInitialSpeed;
|
||||||
|
MouseScrollState.acceleration = mouseScrollAcceleration;
|
||||||
|
MouseScrollState.deceleratedSpeed = mouseScrollDeceleratedSpeed;
|
||||||
|
MouseScrollState.baseSpeed = mouseScrollBaseSpeed;
|
||||||
|
MouseScrollState.acceleratedSpeed = mouseScrollAcceleratedSpeed;
|
||||||
|
|
||||||
AllKeymapsCount = keymapCount;
|
AllKeymapsCount = keymapCount;
|
||||||
AllMacrosCount = macroCount;
|
AllMacrosCount = macroCount;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,20 +8,21 @@
|
|||||||
// Typedefs:
|
// Typedefs:
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ParserError_Success,
|
ParserError_Success = 0,
|
||||||
ParserError_InvalidSerializedKeystrokeType,
|
ParserError_InvalidSerializedKeystrokeType = 1,
|
||||||
ParserError_InvalidSerializedMouseAction,
|
ParserError_InvalidSerializedMouseAction = 2,
|
||||||
ParserError_InvalidSerializedKeyActionType,
|
ParserError_InvalidSerializedKeyActionType = 3,
|
||||||
ParserError_InvalidLayerCount,
|
ParserError_InvalidLayerCount = 4,
|
||||||
ParserError_InvalidModuleCount,
|
ParserError_InvalidModuleCount = 5,
|
||||||
ParserError_InvalidActionCount,
|
ParserError_InvalidActionCount = 6,
|
||||||
ParserError_InvalidSerializedMacroActionType,
|
ParserError_InvalidSerializedMacroActionType = 7,
|
||||||
ParserError_InvalidSerializedSwitchKeymapAction,
|
ParserError_InvalidSerializedSwitchKeymapAction = 8,
|
||||||
ParserError_InvalidModuleConfigurationCount,
|
ParserError_InvalidModuleConfigurationCount = 9,
|
||||||
ParserError_InvalidKeymapCount,
|
ParserError_InvalidKeymapCount = 10,
|
||||||
ParserError_InvalidAbbreviationLen,
|
ParserError_InvalidAbbreviationLen = 11,
|
||||||
ParserError_InvalidMacroCount,
|
ParserError_InvalidMacroCount = 12,
|
||||||
ParserError_InvalidSerializedPlayMacroAction,
|
ParserError_InvalidSerializedPlayMacroAction = 13,
|
||||||
|
ParserError_InvalidMouseKineticProperty = 14,
|
||||||
} parser_error_t;
|
} parser_error_t;
|
||||||
|
|
||||||
// Functions:
|
// Functions:
|
||||||
|
|||||||
@@ -20,11 +20,11 @@
|
|||||||
uint32_t UsbReportUpdateTime = 0;
|
uint32_t UsbReportUpdateTime = 0;
|
||||||
static uint32_t elapsedTime;
|
static uint32_t elapsedTime;
|
||||||
|
|
||||||
static uint16_t doubleTapSwitchLayerTimeout = 300;
|
uint16_t DoubleTapSwitchLayerTimeout = 250;
|
||||||
|
|
||||||
static bool activeMouseStates[ACTIVE_MOUSE_STATES_COUNT];
|
static bool activeMouseStates[ACTIVE_MOUSE_STATES_COUNT];
|
||||||
|
|
||||||
static mouse_kinetic_state_t mouseMoveState = {
|
mouse_kinetic_state_t MouseMoveState = {
|
||||||
.upState = SerializedMouseAction_MoveUp,
|
.upState = SerializedMouseAction_MoveUp,
|
||||||
.downState = SerializedMouseAction_MoveDown,
|
.downState = SerializedMouseAction_MoveDown,
|
||||||
.leftState = SerializedMouseAction_MoveLeft,
|
.leftState = SerializedMouseAction_MoveLeft,
|
||||||
@@ -37,7 +37,7 @@ static mouse_kinetic_state_t mouseMoveState = {
|
|||||||
.acceleratedSpeed = 80,
|
.acceleratedSpeed = 80,
|
||||||
};
|
};
|
||||||
|
|
||||||
static mouse_kinetic_state_t mouseScrollState = {
|
mouse_kinetic_state_t MouseScrollState = {
|
||||||
.upState = SerializedMouseAction_ScrollDown,
|
.upState = SerializedMouseAction_ScrollDown,
|
||||||
.downState = SerializedMouseAction_ScrollUp,
|
.downState = SerializedMouseAction_ScrollUp,
|
||||||
.leftState = SerializedMouseAction_ScrollLeft,
|
.leftState = SerializedMouseAction_ScrollLeft,
|
||||||
@@ -47,7 +47,7 @@ static mouse_kinetic_state_t mouseScrollState = {
|
|||||||
.acceleration = 20,
|
.acceleration = 20,
|
||||||
.deceleratedSpeed = 10,
|
.deceleratedSpeed = 10,
|
||||||
.baseSpeed = 20,
|
.baseSpeed = 20,
|
||||||
.acceleratedSpeed = 40,
|
.acceleratedSpeed = 50,
|
||||||
};
|
};
|
||||||
|
|
||||||
void processMouseKineticState(mouse_kinetic_state_t *kineticState)
|
void processMouseKineticState(mouse_kinetic_state_t *kineticState)
|
||||||
@@ -128,17 +128,17 @@ void processMouseKineticState(mouse_kinetic_state_t *kineticState)
|
|||||||
|
|
||||||
void processMouseActions()
|
void processMouseActions()
|
||||||
{
|
{
|
||||||
processMouseKineticState(&mouseMoveState);
|
processMouseKineticState(&MouseMoveState);
|
||||||
ActiveUsbMouseReport->x = mouseMoveState.xOut;
|
ActiveUsbMouseReport->x = MouseMoveState.xOut;
|
||||||
ActiveUsbMouseReport->y = mouseMoveState.yOut;
|
ActiveUsbMouseReport->y = MouseMoveState.yOut;
|
||||||
mouseMoveState.xOut = 0;
|
MouseMoveState.xOut = 0;
|
||||||
mouseMoveState.yOut = 0;
|
MouseMoveState.yOut = 0;
|
||||||
|
|
||||||
processMouseKineticState(&mouseScrollState);
|
processMouseKineticState(&MouseScrollState);
|
||||||
ActiveUsbMouseReport->wheelX = mouseScrollState.xOut;
|
ActiveUsbMouseReport->wheelX = MouseScrollState.xOut;
|
||||||
ActiveUsbMouseReport->wheelY = mouseScrollState.yOut;
|
ActiveUsbMouseReport->wheelY = MouseScrollState.yOut;
|
||||||
mouseScrollState.xOut = 0;
|
MouseScrollState.xOut = 0;
|
||||||
mouseScrollState.yOut = 0;
|
MouseScrollState.yOut = 0;
|
||||||
|
|
||||||
// The following line makes the firmware crash for some reason:
|
// The following line makes the firmware crash for some reason:
|
||||||
// SetDebugBufferFloat(60, mouseScrollState.currentSpeed);
|
// SetDebugBufferFloat(60, mouseScrollState.currentSpeed);
|
||||||
@@ -207,7 +207,7 @@ void applyKeyAction(key_state_t *keyState, key_action_t *action)
|
|||||||
case KeyActionType_SwitchLayer:
|
case KeyActionType_SwitchLayer:
|
||||||
if (!keyState->previous && previousLayer == LayerId_Base && action->switchLayer.mode == SwitchLayerMode_HoldAndDoubleTapToggle) {
|
if (!keyState->previous && previousLayer == LayerId_Base && action->switchLayer.mode == SwitchLayerMode_HoldAndDoubleTapToggle) {
|
||||||
if (doubleTapSwitchLayerKey) {
|
if (doubleTapSwitchLayerKey) {
|
||||||
if (Timer_GetElapsedTime(&doubleTapSwitchLayerStartTime) < doubleTapSwitchLayerTimeout) {
|
if (Timer_GetElapsedTime(&doubleTapSwitchLayerStartTime) < DoubleTapSwitchLayerTimeout) {
|
||||||
ToggledLayer = action->switchLayer.layer;
|
ToggledLayer = action->switchLayer.layer;
|
||||||
}
|
}
|
||||||
doubleTapSwitchLayerKey = NULL;
|
doubleTapSwitchLayerKey = NULL;
|
||||||
|
|||||||
@@ -63,6 +63,12 @@
|
|||||||
int16_t yOut;
|
int16_t yOut;
|
||||||
} mouse_kinetic_state_t;
|
} mouse_kinetic_state_t;
|
||||||
|
|
||||||
|
// Variables:
|
||||||
|
|
||||||
|
extern uint16_t DoubleTapSwitchLayerTimeout;
|
||||||
|
extern mouse_kinetic_state_t MouseMoveState;
|
||||||
|
extern mouse_kinetic_state_t MouseScrollState;
|
||||||
|
|
||||||
// Functions:
|
// Functions:
|
||||||
|
|
||||||
void UpdateUsbReports(void);
|
void UpdateUsbReports(void);
|
||||||
|
|||||||
Reference in New Issue
Block a user