diff --git a/ion/src/simulator/Makefile b/ion/src/simulator/Makefile index fec9da40c..228a23764 100644 --- a/ion/src/simulator/Makefile +++ b/ion/src/simulator/Makefile @@ -21,6 +21,7 @@ ion_src += $(addprefix ion/src/simulator/shared/, \ keyboard_dummy.cpp:+headless \ keyboard_sdl.cpp:-headless \ layout.cpp:-headless \ + main.cpp \ power.cpp \ random.cpp \ timing.cpp \ diff --git a/ion/src/simulator/shared/main.cpp b/ion/src/simulator/shared/main.cpp new file mode 100644 index 000000000..ebb823209 --- /dev/null +++ b/ion/src/simulator/shared/main.cpp @@ -0,0 +1,30 @@ +#include "haptics.h" +#include "platform.h" +#include "telemetry.h" +#include "window.h" +#include +#include + +int main(int argc, char * argv[]) { + std::vector arguments(argv, argv + argc); + + char * language = IonSimulatorGetLanguageCode(); + if (language != nullptr) { + arguments.push_back("--language"); + arguments.push_back(language); + } + +#if EPSILON_TELEMETRY + Ion::Simulator::Telemetry::init(); +#endif + Ion::Simulator::Window::init(); + Ion::Simulator::Haptics::init(); + ion_main(arguments.size(), &arguments[0]); + Ion::Simulator::Haptics::shutdown(); + Ion::Simulator::Window::quit(); +#if EPSILON_TELEMETRY + Ion::Simulator::Telemetry::shutdown(); +#endif + + return 0; +} diff --git a/ion/src/simulator/shared/window_headless.cpp b/ion/src/simulator/shared/window_headless.cpp index a8debe061..600affa65 100644 --- a/ion/src/simulator/shared/window_headless.cpp +++ b/ion/src/simulator/shared/window_headless.cpp @@ -1,18 +1,14 @@ #include "window.h" #include "display.h" -#include "platform.h" #include "framebuffer.h" #include "events.h" -#include -#include #include #ifndef __WIN32__ #include #include #endif -constexpr int kHeapSize = 131072; #ifdef NDEBUG /* TODO : Reduce stack memory cost in prime factorization to allow running * tests with the actual stack size */ @@ -21,22 +17,21 @@ constexpr int kStackSize = 32768*10; constexpr int kStackSize = 32768*10; // In DEBUG mode, we increase the stack to be able to pass the tests #endif -char heap[kHeapSize]; -extern "C" { - char * _heap_start = (char *)heap; - char * _heap_end = _heap_start+kHeapSize; -} +namespace Ion { +namespace Simulator { +namespace Window { -int main(int argc, char * argv[]) { +void init() { Ion::Simulator::Framebuffer::setActive(false); - // Parse command-line arguments + // This feature is lost for now + /* Parse command-line arguments for (int i=1; i i+1) { Ion::Simulator::Framebuffer::setActive(true); Ion::Simulator::Events::logAfter(atoi(argv[i+1])); } } - + */ #ifndef __WIN32__ // Handle signals signal(SIGABRT, Ion::Simulator::Events::dumpEventCount); @@ -45,16 +40,9 @@ int main(int argc, char * argv[]) { struct rlimit stackLimits = {kStackSize, kStackSize}; setrlimit(RLIMIT_STACK, &stackLimits); #endif - - ion_main(argc, argv); - return 0; } -namespace Ion { -namespace Simulator { -namespace Window { - -void init() { +void quit() { } void setNeedsRefresh() { diff --git a/ion/src/simulator/shared/window_sdl.cpp b/ion/src/simulator/shared/window_sdl.cpp index 437aeb291..63004387c 100644 --- a/ion/src/simulator/shared/window_sdl.cpp +++ b/ion/src/simulator/shared/window_sdl.cpp @@ -1,44 +1,12 @@ #include "window.h" #include "display.h" -#include "haptics.h" #include "layout.h" #include "platform.h" -#include "telemetry.h" #include "random.h" #include #include -#include #include -#include - -int main(int argc, char * argv[]) { - std::vector arguments(argv, argv + argc); - - char * language = IonSimulatorGetLanguageCode(); - if (language != nullptr) { - arguments.push_back("--language"); - arguments.push_back(language); - } - - // Init -#if EPSILON_TELEMETRY - Ion::Simulator::Telemetry::init(); -#endif - Ion::Simulator::Window::init(); - Ion::Simulator::Haptics::init(); - - ion_main(arguments.size(), &arguments[0]); - - // Shutdown - Ion::Simulator::Haptics::shutdown(); - Ion::Simulator::Window::quit(); -#if EPSILON_TELEMETRY - Ion::Simulator::Telemetry::shutdown(); -#endif - - return 0; -} namespace Ion { namespace Simulator {