From 925b017de95bedc1b055a17904228b28efaa8581 Mon Sep 17 00:00:00 2001 From: Karel Tucek Date: Thu, 26 Dec 2024 19:26:15 +0100 Subject: [PATCH] Always reload keymap on any module change. --- device/src/state_sync.c | 5 +++++ right/src/slave_drivers/uhk_module_driver.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/device/src/state_sync.c b/device/src/state_sync.c index 212218c4..5d7b3915 100644 --- a/device/src/state_sync.c +++ b/device/src/state_sync.c @@ -238,6 +238,7 @@ static void receiveModuleStateData(sync_command_module_state_t *buffer) { uhk_module_state_t *moduleState = &UhkModuleStates[driverId]; // once we have multiple left modules, reload keymap here + bool leftModuleChanged = buffer->slotId != SlotId_LeftKeyboardHalf && moduleState->moduleId != buffer->moduleId; module_connection_state_t *moduleConnectionState = &ModuleConnectionStates[driverId]; moduleConnectionState->moduleId = buffer->moduleId; @@ -249,6 +250,10 @@ static void receiveModuleStateData(sync_command_module_state_t *buffer) { Utils_SafeStrCopy(moduleState->gitRepo, buffer->gitRepo, MAX_STRING_PROPERTY_LENGTH); Utils_SafeStrCopy(moduleState->gitTag, buffer->gitTag, MAX_STRING_PROPERTY_LENGTH); memcpy(moduleState->firmwareChecksum, buffer->firmwareChecksum, MD5_CHECKSUM_LENGTH); + + if (DEVICE_IS_UHK80_RIGHT && leftModuleChanged) { + EventVector_Set(EventVector_KeymapReloadNeeded); + } } static void receiveProperty(device_id_t src, state_sync_prop_id_t propId, const uint8_t *data, uint8_t len) { diff --git a/right/src/slave_drivers/uhk_module_driver.c b/right/src/slave_drivers/uhk_module_driver.c index 82ce95ff..6d1b9bd4 100644 --- a/right/src/slave_drivers/uhk_module_driver.c +++ b/right/src/slave_drivers/uhk_module_driver.c @@ -9,7 +9,6 @@ #include "state_sync.h" #else #include "peripherals/test_led.h" -#include "test_switches.h" #include "device.h" #endif @@ -27,6 +26,7 @@ #include "macros/core.h" #include "versioning.h" #include "layouts/key_layout_60_to_universal.h" +#include "test_switches.h" uhk_module_state_t UhkModuleStates[UHK_MODULE_MAX_SLOT_COUNT]; module_connection_state_t ModuleConnectionStates[UHK_MODULE_MAX_SLOT_COUNT]; @@ -113,7 +113,7 @@ static void reloadKeymapIfNeeded() someoneElseWillDoTheJob |= uhkModuleState->moduleId == 0 && slave->isConnected; } #ifdef __ZEPHYR__ - if (DEVICE_ID == DeviceId_Uhk80_Right) { + if (DEVICE_ID == DeviceId_Uhk80_Right && !TestSwitches) { EventVector_Set(EventVector_KeymapReloadNeeded); EventVector_WakeMain(); }