Windows: Attach to console if present

This commit is contained in:
Vicki Pfau 2022-01-14 01:09:45 -08:00
parent 881dd11bf2
commit 76438391a1
3 changed files with 10 additions and 0 deletions

View File

@ -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:

View File

@ -41,6 +41,7 @@ Q_IMPORT_PLUGIN(AVFServicePlugin);
#ifdef Q_OS_WIN
#include <process.h>
#include <wincon.h>
#else
#include <unistd.h>
#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<uint16_t*>(argv[i]), wcslen(argv[i]) * 2));
}
__argv = argv8.data();
int ret = main(argc, argv8.data());
for (char* ptr : argv8) {
free(ptr);

View File

@ -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]);