Skip to content

Commit

Permalink
Merge pull request #826 from UltimateHackingKeyboard/preload_default_…
Browse files Browse the repository at this point in the history
…keycluster

Predictively load keycluster settings.
  • Loading branch information
mondalaci authored Dec 11, 2024
2 parents 52c4dec + 4a6cbb0 commit 0c1afcb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion device/src/state_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,10 @@ void receiveBacklight(sync_command_backlight_t *buffer) {
static void receiveModuleStateData(sync_command_module_state_t *buffer) {
uint8_t driverId = UhkModuleSlaveDriver_SlotIdToDriverId(buffer->slotId);
uhk_module_state_t *moduleState = &UhkModuleStates[driverId];
module_connection_state_t *moduleConnectionState = &ModuleConnectionStates[driverId];

// once we have multiple left modules, reload keymap here

module_connection_state_t *moduleConnectionState = &ModuleConnectionStates[driverId];
moduleConnectionState->moduleId = buffer->moduleId;
moduleState->moduleId = buffer->moduleId;
moduleState->moduleProtocolVersion = buffer->moduleProtocolVersion;
Expand Down
9 changes: 6 additions & 3 deletions right/src/config_parser/parse_keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,18 @@ static parser_error_t parseLayer(config_buffer_t *buffer, uint8_t layer, parse_m
}
}

// if current config doesn't configuration of the connected module, fill in hardwired values
// if current config doesn't contain configuration of the connected module, fill in hardwired values
bool rightUhkModuleUnmapped = moduleCount <= UhkModuleStates[UhkModuleSlaveDriver_SlotIdToDriverId(SlotId_RightModule)].moduleId;
bool touchpadUnmapped = moduleCount <= ModuleId_TouchpadRight && IsModuleAttached(ModuleId_TouchpadRight);
if (rightUhkModuleUnmapped || touchpadUnmapped) {
applyDefaultRightModuleActions(layer, parseMode);
}

// if current config doesn't configuration of the connected module, fill in hardwired values
if (moduleCount <= UhkModuleStates[UhkModuleSlaveDriver_SlotIdToDriverId(SlotId_LeftModule)].moduleId) {
// if current config doesn't contain configuration of the connected module, fill in hardwired values
uint8_t leftModuleId = UhkModuleStates[UhkModuleSlaveDriver_SlotIdToDriverId(SlotId_LeftModule)].moduleId;
bool leftUhkModuleUnmapped = moduleCount <= leftModuleId;
bool keyclusterUnmapped = moduleCount <= ModuleId_KeyClusterLeft;
if ((leftModuleId != 0 && leftUhkModuleUnmapped) || (leftModuleId == 0 && keyclusterUnmapped)) {
applyDefaultLeftModuleActions(layer, parseMode);
}

Expand Down

0 comments on commit 0c1afcb

Please sign in to comment.