diff --git a/sdk/Windows/SMXPanelAnimation.cpp b/sdk/Windows/SMXPanelAnimation.cpp index fa3f725..3ee4a07 100644 --- a/sdk/Windows/SMXPanelAnimation.cpp +++ b/sdk/Windows/SMXPanelAnimation.cpp @@ -412,20 +412,20 @@ private: } // Return lights for the given pad and pad state, using the loaded panel animations. - void GetCurrentLights(string &asLightsDataOut, int pad, int iPadState) + bool GetCurrentLights(string &asLightsDataOut, int pad, int iPadState) { m_Lock.AssertLockedByCurrentThread(); // Get this pad's configuration. SMXConfig config; if(!SMXManager::g_pSMX->GetDevice(pad)->GetConfig(config)) - return; + return false; // If this controller handles animation itself, don't handle it here too. It can // lead to confusing situations if SMXConfig's animations don't match the ones stored // on the pad. if(config.masterVersion >= 4) - return; + return false; AnimationStateForPad &pad_state = pad_states[pad]; @@ -453,20 +453,24 @@ private: for(auto &animation_state: pad_state.animations[panel]) animation_state.Update(); } + return true; } // Run a single light animation update. void UpdateLights() { string asLightsData[2]; + bool bHaveLights = false; for(int pad = 0; pad < 2; pad++) { int iPadState = SMXManager::g_pSMX->GetDevice(pad)->GetInputState(); - GetCurrentLights(asLightsData[pad], pad, iPadState); + if(GetCurrentLights(asLightsData[pad], pad, iPadState)) + bHaveLights = true; } // Update lights. - SMXManager::g_pSMX->SetLights(asLightsData); + if(bHaveLights) + SMXManager::g_pSMX->SetLights(asLightsData); } }; diff --git a/smx-config/Helpers.cs b/smx-config/Helpers.cs index 8454458..bfe0f9f 100644 --- a/smx-config/Helpers.cs +++ b/smx-config/Helpers.cs @@ -500,7 +500,12 @@ namespace smx_config { LightsTimer.Stop(); - // Turn lighting control back on. + // Reenable pad auto-lighting. If we're running animations in SMXPanelAnimation, + // this will be overridden by it once it sends lights. + SMX.SMX.ReenableAutoLights(); + + // Turn lighting control back on. This will only do anything on pads without + // support for animations. SMX.SMX.LightsAnimation_SetAuto(true); } diff --git a/smx-config/SMX.cs b/smx-config/SMX.cs index 1fd8e4f..639890c 100644 --- a/smx-config/SMX.cs +++ b/smx-config/SMX.cs @@ -297,6 +297,8 @@ namespace SMX private static extern bool SMX_GetTestData(int pad, out SMXSensorTestModeData data); [DllImport("SMX.dll", CallingConvention = CallingConvention.Cdecl)] private static extern bool SMX_SetLights2(byte[] buf, int lightDataSize); + [DllImport("SMX.dll", CallingConvention = CallingConvention.Cdecl)] + private static extern bool SMX_ReenableAutoLights(); [DllImport("SMX.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] private static extern IntPtr SMX_Version(); @@ -471,6 +473,13 @@ namespace SMX SMX_SetLights2(buf, buf.Length); } + public static void ReenableAutoLights() + { + if(!DLLAvailable()) return; + + SMX_ReenableAutoLights(); + } + // SMXPanelAnimation [DllImport("SMX.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return:MarshalAs(UnmanagedType.I1)]