diff --git a/CHANGES b/CHANGES index 69160760c..74f434bb2 100644 --- a/CHANGES +++ b/CHANGES @@ -32,6 +32,7 @@ Misc: - Qt: Only set default controller bindings if loading fails (fixes mgba.io/i/799) - Qt: Save converter now supports importing GameShark Advance saves - Qt: Save positions of multiplayer windows (closes mgba.io/i/2128) + - Windows: Attach to console if present 0.9.3: (2021-12-17) Emulation fixes: diff --git a/src/platform/qt/main.cpp b/src/platform/qt/main.cpp index 21570c0b8..38a3df725 100644 --- a/src/platform/qt/main.cpp +++ b/src/platform/qt/main.cpp @@ -41,6 +41,7 @@ Q_IMPORT_PLUGIN(AVFServicePlugin); #ifdef Q_OS_WIN #include +#include #else #include #endif @@ -48,6 +49,9 @@ Q_IMPORT_PLUGIN(AVFServicePlugin); using namespace QGBA; int main(int argc, char* argv[]) { +#ifdef Q_OS_WIN + AttachConsole(ATTACH_PARENT_PROCESS); +#endif #ifdef BUILD_SDL #if SDL_VERSION_ATLEAST(2, 0, 0) // CPP does not shortcut function lookup SDL_SetMainReady(); @@ -154,6 +158,7 @@ int wmain(int argc, wchar_t* argv[]) { for (int i = 0; i < argc; ++i) { argv8.push_back(utf16to8(reinterpret_cast(argv[i]), wcslen(argv[i]) * 2)); } + __argv = argv8.data(); int ret = main(argc, argv8.data()); for (char* ptr : argv8) { free(ptr); diff --git a/src/platform/sdl/main.c b/src/platform/sdl/main.c index 2e3b18514..5025e7b6c 100644 --- a/src/platform/sdl/main.c +++ b/src/platform/sdl/main.c @@ -59,6 +59,9 @@ static void _loadState(struct mCoreThread* thread) { } int main(int argc, char** argv) { +#ifdef _WIN32 + AttachConsole(ATTACH_PARENT_PROCESS); +#endif struct mSDLRenderer renderer = {0}; struct mCoreOptions opts = { @@ -213,6 +216,7 @@ int wmain(int argc, wchar_t** argv) { for (i = 0; i < argc; ++i) { argv8[i] = utf16to8((uint16_t*) argv[i], wcslen(argv[i]) * 2); } + __argv = argv8; int ret = main(argc, argv8); for (i = 0; i < argc; ++i) { free(argv8[i]);