diff --git a/CMakeLists.txt b/CMakeLists.txt index 197709f7..7443075b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,6 +90,7 @@ endif() set(SOURCE_FILES src/main.cpp src/emulator.cpp src/io_file.cpp src/gl_state.cpp src/config.cpp src/core/CPU/cpu_dynarmic.cpp src/core/CPU/dynarmic_cycles.cpp src/core/memory.cpp + src/httpserver.cpp ) set(CRYPTO_SOURCE_FILES src/core/crypto/aes_engine.cpp) set(KERNEL_SOURCE_FILES src/core/kernel/kernel.cpp src/core/kernel/resource_limits.cpp @@ -145,7 +146,7 @@ set(HEADER_FILES include/emulator.hpp include/helpers.hpp include/opengl.hpp inc include/result/result_common.hpp include/result/result_fs.hpp include/result/result_fnd.hpp include/result/result_gsp.hpp include/result/result_kernel.hpp include/result/result_os.hpp include/crypto/aes_engine.hpp include/metaprogramming.hpp include/PICA/pica_vertex.hpp include/gl_state.hpp - include/config.hpp include/services/ir_user.hpp + include/config.hpp include/services/ir_user.hpp include/httpserver.hpp ) set(THIRD_PARTY_SOURCE_FILES third_party/imgui/imgui.cpp @@ -158,10 +159,6 @@ set(THIRD_PARTY_SOURCE_FILES third_party/imgui/imgui.cpp third_party/xxhash/xxhash.c ) -if (ENABLE_HTTP_SERVER) - set(HTTPSERVER_SOURCE_FILES src/httpserver.cpp) -endif() - source_group("Header Files\\Core" FILES ${HEADER_FILES}) source_group("Source Files\\Core" FILES ${SOURCE_FILES}) source_group("Source Files\\Core\\Crypto" FILES ${CRYPTO_SOURCE_FILES}) diff --git a/include/httpserver.hpp b/include/httpserver.hpp index 2f342920..0526045a 100644 --- a/include/httpserver.hpp +++ b/include/httpserver.hpp @@ -1,19 +1,22 @@ +#ifdef PANDA3DS_ENABLE_HTTP_SERVER #pragma once #include #include + #include "helpers.hpp" enum class HttpAction { None, Screenshot, PressKey, ReleaseKey }; -constexpr const char* httpServerScreenshotPath = "screenshot.png"; +struct HttpServer { + static constexpr const char* httpServerScreenshotPath = "screenshot.png"; -struct HttpServer -{ - std::atomic_bool pendingAction = false; + std::atomic_bool pendingAction = false; HttpAction action = HttpAction::None; std::mutex actionMutex = {}; u32 pendingKey = 0; void startHttpServer(); -}; \ No newline at end of file +}; + +#endif // PANDA3DS_ENABLE_HTTP_SERVER \ No newline at end of file diff --git a/src/emulator.cpp b/src/emulator.cpp index 3ffe2829..ef30088f 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -429,7 +429,7 @@ void Emulator::pollHttpServer() { if (httpServer.pendingAction) { switch (httpServer.action) { case HttpAction::Screenshot: { - screenshot(httpServerScreenshotPath); + screenshot(HttpServer::httpServerScreenshotPath); break; } case HttpAction::PressKey: { diff --git a/src/httpserver.cpp b/src/httpserver.cpp index f5b1d0f6..570a3987 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -1,3 +1,4 @@ +#ifdef PANDA3DS_ENABLE_HTTP_SERVER #include "httpserver.hpp" #include @@ -97,4 +98,6 @@ void HttpServer::startHttpServer() { server.listen("localhost", 1234); }); http_thread.detach(); -} \ No newline at end of file +} + +#endif // PANDA3DS_ENABLE_HTTP_SERVER \ No newline at end of file