diff --git a/Source/3rdParty/rt64/CMakeLists.txt b/Source/3rdParty/rt64/CMakeLists.txt index e7e362d9f..0935ed259 100644 --- a/Source/3rdParty/rt64/CMakeLists.txt +++ b/Source/3rdParty/rt64/CMakeLists.txt @@ -351,6 +351,7 @@ if (RT64_BUILD_PLUGIN) target_sources(rt64 PRIVATE "${PROJECT_SOURCE_DIR}/src/api/rt64_api_common.cpp" "${PROJECT_SOURCE_DIR}/src/api/rt64_api_plugin.cpp" + "${PROJECT_SOURCE_DIR}/src/contrib/imgui/backends/imgui_impl_sdl2.cpp" ) if (WIN32) target_sources(rt64 PRIVATE diff --git a/Source/3rdParty/rt64/src/api/rt64_api_common.cpp b/Source/3rdParty/rt64/src/api/rt64_api_common.cpp index 5583a3c0b..870f5c034 100644 --- a/Source/3rdParty/rt64/src/api/rt64_api_common.cpp +++ b/Source/3rdParty/rt64/src/api/rt64_api_common.cpp @@ -56,7 +56,7 @@ DLLEXPORT void CALL UpdateScreen(void) { DLLEXPORT void CALL ChangeWindow(void) { const bool isPJ64 = (RT64::API.apiType == RT64::APIType::Project64); - if (isPJ64) { + if (!isPJ64) { CoreVideo_ToggleFullScreen(); } else { RT64::ApplicationWindow *appWindow = RT64::API.app->appWindow.get(); diff --git a/Source/3rdParty/rt64/src/api/rt64_api_plugin.cpp b/Source/3rdParty/rt64/src/api/rt64_api_plugin.cpp index 927cd24a5..c5981ac4e 100644 --- a/Source/3rdParty/rt64/src/api/rt64_api_plugin.cpp +++ b/Source/3rdParty/rt64/src/api/rt64_api_plugin.cpp @@ -4,6 +4,9 @@ #include "rt64_api_common.h" +#include +#include "imgui/backends/imgui_impl_sdl2.h" + #define PLUGIN_NAME "RT64 Video Plugin" #define PLUGIN_VERSION 0x020509 #define VIDEO_PLUGIN_API_VERSION 0x020200 @@ -71,9 +74,7 @@ DLLEXPORT m64p_error CALL PluginGetVersion(m64p_plugin_type *PluginType, int *Pl *PluginNamePtr = PLUGIN_NAME; if (Capabilities != NULL) - { *Capabilities = 0; - } return M64ERR_SUCCESS; } @@ -151,7 +152,7 @@ int window_width = 640; int window_height = 480; DLLEXPORT void CALL ResizeVideoOutput(int width, int height) { - window_width = width; + window_width = width; window_height = height; } @@ -183,3 +184,79 @@ DLLEXPORT void CALL CaptureScreen(const char *Directory) { // Unused. } +// TODO: PR this to mupen64plus.... +DLLEXPORT void CALL SDL_KeyDown(int keymod, int keysym) +{ + SDL_Event event; + event.type = SDL_KEYDOWN; + event.key.keysym.mod = keymod; + event.key.keysym.sym = keysym; + if (RT64::API.app->presentQueue->inspector != nullptr) { + ImGui_ImplSDL2_ProcessEvent(&event); + } +} + +DLLEXPORT void CALL SDL_KeyUp(int keymod, int keysym) +{ + SDL_Event event; + event.type = SDL_KEYUP; + event.key.keysym.mod = SDL_SCANCODE_TO_KEYCODE(keymod); + event.key.keysym.sym = SDL_SCANCODE_TO_KEYCODE(keysym); + + if (keysym == SDL_SCANCODE_F10) + { + if (RT64::API.app->userConfig.developerMode) { + fprintf(stderr, "creating inspector...\n"); + const std::lock_guard lock(RT64::API.app->presentQueue->inspectorMutex); + if (RT64::API.app->presentQueue->inspector == nullptr) { + RT64::API.app->presentQueue->inspector = std::make_unique(RT64::API.app->device.get(), RT64::API.app->swapChain.get(), RT64::API.app->createdGraphicsAPI); + if (!RT64::API.app->userPaths.isEmpty()) { + RT64::API.app->presentQueue->inspector->setIniPath(RT64::API.app->userPaths.imguiPath); + } + + RT64::API.app->freeCamClearQueued = true; + ImGui_ImplSDL2_InitForVulkan(nullptr); // TODO: move this elsewhere... + //appWindow->blockSdlKeyboard(); + } + else if (RT64::API.app->presentQueue->inspector != nullptr) { + RT64::API.app->presentQueue->inspector.reset(nullptr); + //appWindow->unblockSdlKeyboard(); + } + } + else { + fprintf(stdout, "Inspector is not available: developer mode is not enabled in the configuration.\n"); + } + return; + } + + if (RT64::API.app->presentQueue->inspector != nullptr) { + ImGui_ImplSDL2_ProcessEvent(&event); + } +} + +DLLEXPORT void CALL MouseMove(int x, int y) +{ + SDL_Event event; + event.type = SDL_MOUSEMOTION; + event.motion.which = 1; + event.motion.x = x; + event.motion.y = y; + + if (RT64::API.app->presentQueue->inspector != nullptr) { + printf("MouseMove x = %i, y = %i\n", x,y); + ImGui_ImplSDL2_ProcessEvent(&event); + } +} + +DLLEXPORT void CALL MouseButton(int left, int right) +{ + if (RT64::API.app->presentQueue->inspector != nullptr) { + printf("MouseButton left = %i\n", left); + SDL_Event event; + event.type = left ? SDL_MOUSEBUTTONDOWN : SDL_MOUSEBUTTONUP; + event.button.button = SDL_BUTTON_LEFT; + ImGui_ImplSDL2_ProcessEvent(&event); + } +} + + diff --git a/Source/3rdParty/rt64/src/gui/rt64_inspector.cpp b/Source/3rdParty/rt64/src/gui/rt64_inspector.cpp index dee07adfd..6439001b8 100644 --- a/Source/3rdParty/rt64/src/gui/rt64_inspector.cpp +++ b/Source/3rdParty/rt64/src/gui/rt64_inspector.cpp @@ -22,6 +22,10 @@ # include "d3d12/rt64_d3d12.h" #endif +#if defined(RT64_BUILD_PLUGIN) +# include "api/rt64_api_common.h" +#endif + // Volk must be included before the ImGui Vulkan backend. #include "vulkan/rt64_vulkan.h" #include "imgui/backends/imgui_impl_vulkan.h" @@ -156,7 +160,8 @@ namespace RT64 { # ifdef _WIN32 ImGui_ImplWin32_Shutdown(); # else - assert(false && "Unimplemented."); + // if mupen64plus, dont assert... + //assert(false && "Unimplemented."); # endif ImPlot::DestroyContext(); @@ -177,7 +182,11 @@ namespace RT64 { # ifdef _WIN32 ImGui_ImplWin32_NewFrame(); # else - assert(false && "Unimplemented."); + // ???????? + // if mupen64plus == true, dont assert.... + ImGuiIO &io = ImGui::GetIO(); + io.DisplaySize = ImVec2((float)window_width, (float)window_height); + //assert(false && "Unimplemented."); # endif switch (graphicsAPI) { diff --git a/Source/3rdParty/rt64/src/hle/rt64_state.cpp b/Source/3rdParty/rt64/src/hle/rt64_state.cpp index 048a29ee0..ae5c75d40 100644 --- a/Source/3rdParty/rt64/src/hle/rt64_state.cpp +++ b/Source/3rdParty/rt64/src/hle/rt64_state.cpp @@ -1866,7 +1866,7 @@ namespace RT64 { // Check the debugger popup regardless of the active inspector mode. bool debuggerSelected = debuggerInspector.checkPopup(workload); - if (ImGui::Begin("Game editor")) { + if (ImGui::Begin("Game editor", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) { if (ImGui::BeginTabBar("##tabs", ImGuiTabBarFlags_None)) { if (ImGui::BeginTabItem("Configuration")) { // General configuration.