Fix config updates when updating quickly.

This fixes the pad flickering when dragging the color slider, because it
could briefly use an out-of-date configuration (only really visible when
going between red and white on the left).
master
Glenn Maynard 6 years ago
parent f4e60ef2e0
commit 5e1068d565
  1. 14
      sdk/Windows/SMXDevice.cpp
  2. 1
      sdk/Windows/SMXDevice.h

@ -297,6 +297,11 @@ void SMX::SMXDevice::SendConfig()
if(!m_bHaveConfig)
return;
// If we're still waiting for a previous configuration to read back, don't send
// another yet.
if(m_bWaitingForConfigResponse)
return;
// Write configuration command:
string sData = ssprintf("w");
int8_t iSize = sizeof(SMXConfig);
@ -316,9 +321,16 @@ void SMX::SMXDevice::SendConfig()
// command below completes.
config = wanted_config;
// Don't send another configuration packet until we receive the response to the above
// command. If we're sending updates quickly (eg. dragging the color slider), we can
// send multiple updates before we get a response.
m_bWaitingForConfigResponse = true;
// After we write the configuration, read back the updated configuration to
// verify it.
SendCommandLocked("g\n");
SendCommandLocked("g\n", [this]() {
m_bWaitingForConfigResponse = false;
});
}
void SMX::SMXDevice::Update(wstring &sError)

@ -110,6 +110,7 @@ private:
SMXConfig wanted_config;
bool m_bSendConfig = false;
bool m_bSendingConfig = false;
bool m_bWaitingForConfigResponse = false;
void CallUpdateCallback(SMXUpdateCallbackReason reason);
void HandlePackets();

Loading…
Cancel
Save