From ec8a779507546a2c217f1a7dc3d4679ae3934ce9 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 21 Aug 2024 23:50:48 -0700 Subject: [PATCH] Added editor connection single reset --- VortexEngine/src/Menus/MenuList/EditorConnection.cpp | 11 ++++++++++- VortexEngine/src/Menus/MenuList/EditorConnection.h | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/VortexEngine/src/Menus/MenuList/EditorConnection.cpp b/VortexEngine/src/Menus/MenuList/EditorConnection.cpp index b47b25146e..293fb77a48 100644 --- a/VortexEngine/src/Menus/MenuList/EditorConnection.cpp +++ b/VortexEngine/src/Menus/MenuList/EditorConnection.cpp @@ -16,7 +16,8 @@ EditorConnection::EditorConnection(const RGBColor &col, bool advanced) : Menu(col, advanced), - m_state(STATE_DISCONNECTED) + m_state(STATE_DISCONNECTED), + m_allowReset(true) { } @@ -57,6 +58,8 @@ bool EditorConnection::receiveMessage(const char *message) if (m_receiveBuffer.unserializerAtEnd()) { m_receiveBuffer.clear(); } + // we have now received at least one command, do not allow resetting + m_allowReset = false; return true; } @@ -202,10 +205,16 @@ void EditorConnection::sendCurModeVL() // handlers for clicks void EditorConnection::onShortClick() { + // if the device has received any commands do not reset! + if (!m_allowReset) { + return; + } // reset, this won't actually disconnect the com port m_state = STATE_DISCONNECTED; // clear the demo clearDemo(); + // sent a reset, do not allow another + m_allowReset = false; } void EditorConnection::onLongClick() diff --git a/VortexEngine/src/Menus/MenuList/EditorConnection.h b/VortexEngine/src/Menus/MenuList/EditorConnection.h index 56235ee432..18c1c57ff7 100644 --- a/VortexEngine/src/Menus/MenuList/EditorConnection.h +++ b/VortexEngine/src/Menus/MenuList/EditorConnection.h @@ -72,6 +72,8 @@ class EditorConnection : public Menu EditorConnectionState m_state; // the data that is received ByteStream m_receiveBuffer; + // Whether at least one command has been received yet + bool m_allowReset; }; #endif