[sim] Automatically turn off GUI DS when real DS connected

This commit is contained in:
Peter Johnson
2020-09-02 20:51:43 -07:00
parent 1b18560e90
commit 8f87c56312
4 changed files with 48 additions and 13 deletions

View File

@@ -5,7 +5,9 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include <hal/Extensions.h>
#include <hal/Main.h>
#include <wpi/StringRef.h>
#include <wpi/raw_ostream.h>
#include "AccelerometerGui.h"
@@ -61,6 +63,12 @@ __declspec(dllexport)
wpi::outs() << "Simulator GUI Initializing.\n";
if (!HALSimGui::Initialize()) return 0;
HAL_RegisterExtensionListener(
nullptr, [](void*, const char* name, void* data) {
if (wpi::StringRef{name} == "ds_socket") {
DriverStationGui::SetDSSocketExtension(data);
}
});
HAL_SetMain(nullptr, HALSimGui::Main, HALSimGui::Exit);
wpi::outs() << "Simulator GUI Initialized!\n";