static void Run(JNIEnv* env, const std::vector<std::string>& paths, bool first_open, std::optional<std::string> savestate_path = {}, bool delete_savestate = false) { ASSERT(!paths.empty()); __android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Running : %s", paths[0].c_str()); RegisterMsgAlertHandler(&MsgAlert); Common::AndroidSetReportHandler(&ReportSend); DolphinAnalytics::AndroidSetGetValFunc(&GetAnalyticValue); std::unique_lock<std::mutex> guard(s_host_identity_lock); UICommon::Init(); if (first_open) { DolphinAnalytics::Instance()->ReportDolphinStart(GetAnalyticValue("DEVICE_TYPE")); } WiimoteReal::InitAdapterClass(); // No use running the loop when booting fails s_have_wm_user_stop = false; std::unique_ptr<BootParameters> boot = BootParameters::GenerateFromFile(paths, savestate_path); boot->delete_savestate = delete_savestate; WindowSystemInfo wsi(WindowSystemType::Android, nullptr, s_surf); wsi.render_surface_scale = GetRenderSurfaceScale(env); if (BootManager::BootCore(std::move(boot), wsi)) { ButtonManager::Init(SConfig::GetInstance().GetGameID()); static constexpr int TIMEOUT = 10000; static constexpr int WAIT_STEP = 25; int time_waited = 0; // A Core::CORE_ERROR state would be helpful here. while (!Core::IsRunning() && time_waited < TIMEOUT && !s_have_wm_user_stop) { std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_STEP)); time_waited += WAIT_STEP; } while (Core::IsRunning()) { guard.unlock(); s_update_main_frame_event.Wait(); guard.lock(); Core::HostDispatchJobs(); } } Core::Shutdown(); ButtonManager::Shutdown(); UICommon::Shutdown(); guard.unlock(); if (s_surf) { ANativeWindow_release(s_surf); s_surf = nullptr; } }
bool DolphinApp::OnInit() { std::lock_guard<std::mutex> lk(s_init_mutex); if (!wxApp::OnInit()) return false; Bind(wxEVT_QUERY_END_SESSION, &DolphinApp::OnEndSession, this); Bind(wxEVT_END_SESSION, &DolphinApp::OnEndSession, this); Bind(wxEVT_IDLE, &DolphinApp::OnIdle, this); Bind(wxEVT_ACTIVATE_APP, &DolphinApp::OnActivate, this); // Register message box and translation handlers RegisterMsgAlertHandler(&wxMsgAlert); RegisterStringTranslator(&wxStringTranslator); #if wxUSE_ON_FATAL_EXCEPTION wxHandleFatalExceptions(true); #endif UICommon::SetUserDirectory(m_user_path.ToStdString()); UICommon::CreateDirectories(); InitLanguageSupport(); // The language setting is loaded from the user directory UICommon::Init(); if (m_select_video_backend && !m_video_backend_name.empty()) SConfig::GetInstance().m_strVideoBackend = WxStrToStr(m_video_backend_name); if (m_select_audio_emulation) SConfig::GetInstance().bDSPHLE = (m_audio_emulation_name.Upper() == "HLE"); VideoBackendBase::ActivateBackend(SConfig::GetInstance().m_strVideoBackend); DolphinAnalytics::Instance()->ReportDolphinStart("wx"); wxToolTip::Enable(!SConfig::GetInstance().m_DisableTooltips); // Enable the PNG image handler for screenshots wxImage::AddHandler(new wxPNGHandler); // We have to copy the size and position out of SConfig now because CFrame's OnMove // handler will corrupt them during window creation (various APIs like SetMenuBar cause // event dispatch including WM_MOVE/WM_SIZE) wxRect window_geometry(SConfig::GetInstance().iPosX, SConfig::GetInstance().iPosY, SConfig::GetInstance().iWidth, SConfig::GetInstance().iHeight); main_frame = new CFrame(nullptr, wxID_ANY, StrToWxStr(scm_rev_str), window_geometry, m_use_debugger, m_batch_mode, m_use_logger); SetTopWindow(main_frame); AfterInit(); return true; }
bool DolphinApp::OnInit() { Bind(wxEVT_QUERY_END_SESSION, &DolphinApp::OnEndSession, this); Bind(wxEVT_END_SESSION, &DolphinApp::OnEndSession, this); // Declarations and definitions bool UseDebugger = false; bool UseLogger = false; bool selectVideoBackend = false; bool selectAudioEmulation = false; bool selectPerfDir = false; wxString videoBackendName; wxString audioEmulationName; wxString userPath; wxString perfDir; #if wxUSE_CMDLINE_PARSER // Parse command lines wxCmdLineEntryDesc cmdLineDesc[] = { { wxCMD_LINE_SWITCH, "h", "help", "Show this help message", wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, { wxCMD_LINE_SWITCH, "d", "debugger", "Opens the debugger", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_SWITCH, "l", "logger", "Opens the logger", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, "e", "exec", "Loads the specified file (ELF, DOL, GCM, ISO, WBFS, CISO, GCZ, WAD)", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_SWITCH, "b", "batch", "Exit Dolphin with emulator", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, "V", "video_backend", "Specify a video backend", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, "A", "audio_emulation", "Low level (LLE) or high level (HLE) audio", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, "m", "movie", "Play a movie file", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, "U", "user", "User folder path", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, "P", "perf_dir", "Directory for Linux perf perf-$pid.map file", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_NONE, nullptr, nullptr, nullptr, wxCMD_LINE_VAL_NONE, 0 } }; // Gets the command line parameters wxCmdLineParser parser(cmdLineDesc, argc, argv); LoadFile = false; if (argc == 2 && File::Exists(argv[1].ToUTF8().data())) { LoadFile = true; FileToLoad = argv[1]; } else if (parser.Parse() != 0) { return false; } UseDebugger = parser.Found("debugger"); UseLogger = parser.Found("logger"); if (!LoadFile) LoadFile = parser.Found("exec", &FileToLoad); BatchMode = parser.Found("batch"); selectVideoBackend = parser.Found("video_backend", &videoBackendName); selectAudioEmulation = parser.Found("audio_emulation", &audioEmulationName); selectPerfDir = parser.Found("perf_dir", &perfDir); playMovie = parser.Found("movie", &movieFile); parser.Found("user", &userPath); #endif // wxUSE_CMDLINE_PARSER // Register message box and translation handlers RegisterMsgAlertHandler(&wxMsgAlert); RegisterStringTranslator(&wxStringTranslator); #if wxUSE_ON_FATAL_EXCEPTION wxHandleFatalExceptions(true); #endif UICommon::SetUserDirectory(userPath.ToStdString()); UICommon::CreateDirectories(); InitLanguageSupport(); // The language setting is loaded from the user directory UICommon::Init(); if (selectPerfDir) { SConfig::GetInstance().m_LocalCoreStartupParameter.m_perfDir = WxStrToStr(perfDir); } if (selectVideoBackend && videoBackendName != wxEmptyString) SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend = WxStrToStr(videoBackendName); if (selectAudioEmulation) { if (audioEmulationName == "HLE") SConfig::GetInstance().m_LocalCoreStartupParameter.bDSPHLE = true; else if (audioEmulationName == "LLE") SConfig::GetInstance().m_LocalCoreStartupParameter.bDSPHLE = false; } VideoBackend::ActivateBackend(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend); // Enable the PNG image handler for screenshots wxImage::AddHandler(new wxPNGHandler); int x = SConfig::GetInstance().m_LocalCoreStartupParameter.iPosX; int y = SConfig::GetInstance().m_LocalCoreStartupParameter.iPosY; int w = SConfig::GetInstance().m_LocalCoreStartupParameter.iWidth; int h = SConfig::GetInstance().m_LocalCoreStartupParameter.iHeight; if (File::Exists("www.dolphin-emulator.com.txt")) { File::Delete("www.dolphin-emulator.com.txt"); wxMessageDialog dlg(nullptr, _( "This version of Dolphin was downloaded from a website stealing money from developers of the emulator. Please " "download Dolphin from the official website instead: https://dolphin-emu.org/"), _("Unofficial version detected"), wxOK | wxICON_WARNING); dlg.ShowModal(); wxLaunchDefaultBrowser("https://dolphin-emu.org/?ref=badver"); exit(0); } // The following is not needed with X11, where window managers // do not allow windows to be created off the desktop. #ifdef _WIN32 // Out of desktop check int leftPos = GetSystemMetrics(SM_XVIRTUALSCREEN); int topPos = GetSystemMetrics(SM_YVIRTUALSCREEN); int width = GetSystemMetrics(SM_CXVIRTUALSCREEN); int height = GetSystemMetrics(SM_CYVIRTUALSCREEN); if ((leftPos + width) < (x + w) || leftPos > x || (topPos + height) < (y + h) || topPos > y) x = y = wxDefaultCoord; #elif defined __APPLE__ if (y < 1) y = wxDefaultCoord; #endif main_frame = new CFrame(nullptr, wxID_ANY, StrToWxStr(scm_rev_str), wxPoint(x, y), wxSize(w, h), UseDebugger, BatchMode, UseLogger); SetTopWindow(main_frame); main_frame->SetMinSize(wxSize(400, 300)); AfterInit(); return true; }
bool DolphinApp::OnInit() { InitLanguageSupport(); // Declarations and definitions bool UseDebugger = false; bool UseLogger = false; bool selectVideoBackend = false; bool selectAudioEmulation = false; wxString videoBackendName; wxString audioEmulationName; #if wxUSE_CMDLINE_PARSER // Parse command lines wxCmdLineEntryDesc cmdLineDesc[] = { { wxCMD_LINE_SWITCH, wxS("h"), wxS("help"), _("Show this help message"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, { wxCMD_LINE_SWITCH, wxS("d"), wxS("debugger"), _("Opens the debugger"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_SWITCH, wxS("l"), wxS("logger"), _("Opens the logger"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, wxS("e"), wxS("exec"), _("Loads the specified file (DOL,ELF,GCM,ISO,WAD)"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_SWITCH, wxS("b"), wxS("batch"), _("Exit Dolphin with emulator"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, wxS("V"), wxS("video_backend"), _("Specify a video backend"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, wxS("A"), wxS("audio_emulation"), _("Low level (LLE) or high level (HLE) audio"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_NONE, NULL, NULL, NULL, wxCMD_LINE_VAL_NONE, 0 } }; // Gets the command line parameters wxCmdLineParser parser(cmdLineDesc, argc, argv); if (parser.Parse() != 0) { return false; } UseDebugger = parser.Found(wxT("debugger")); UseLogger = parser.Found(wxT("logger")); LoadFile = parser.Found(wxT("exec"), &FileToLoad); BatchMode = parser.Found(wxT("batch")); selectVideoBackend = parser.Found(wxT("video_backend"), &videoBackendName); // TODO: This currently has no effect. Implement or delete. selectAudioEmulation = parser.Found(wxT("audio_emulation"), &audioEmulationName); #endif // wxUSE_CMDLINE_PARSER #if defined _DEBUG && defined _WIN32 int tmpflag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); tmpflag |= _CRTDBG_DELAY_FREE_MEM_DF; _CrtSetDbgFlag(tmpflag); #endif // Register message box and translation handlers RegisterMsgAlertHandler(&wxMsgAlert); RegisterStringTranslator(&wxStringTranslator); // "ExtendedTrace" looks freakin dangerous!!! #ifdef _WIN32 EXTENDEDTRACEINITIALIZE("."); SetUnhandledExceptionFilter(&MyUnhandledExceptionFilter); #elif wxUSE_ON_FATAL_EXCEPTION wxHandleFatalExceptions(true); #endif // TODO: if First Boot if (!cpu_info.bSSE2) { PanicAlertT("Hi,\n\nDolphin requires that your CPU has support for SSE2 extensions.\n" "Unfortunately your CPU does not support them, so Dolphin will not run.\n\n" "Sayonara!\n"); return false; } #ifdef _WIN32 if (!wxSetWorkingDirectory(wxString(File::GetExeDirectory().c_str(), *wxConvCurrent))) { INFO_LOG(CONSOLE, "set working directory failed"); } #else //create all necessary directories in user directory //TODO : detect the revision and upgrade where necessary File::CopyDir(std::string(SHARED_USER_DIR GAMECONFIG_DIR DIR_SEP), File::GetUserPath(D_GAMECONFIG_IDX)); File::CopyDir(std::string(SHARED_USER_DIR MAPS_DIR DIR_SEP), File::GetUserPath(D_MAPS_IDX)); File::CopyDir(std::string(SHARED_USER_DIR SHADERS_DIR DIR_SEP), File::GetUserPath(D_SHADERS_IDX)); File::CopyDir(std::string(SHARED_USER_DIR WII_USER_DIR DIR_SEP), File::GetUserPath(D_WIIUSER_IDX)); File::CopyDir(std::string(SHARED_USER_DIR OPENCL_DIR DIR_SEP), File::GetUserPath(D_OPENCL_IDX)); if (!File::Exists(File::GetUserPath(D_CONFIG_IDX))) File::CreateFullPath(File::GetUserPath(D_CONFIG_IDX)); if (!File::Exists(File::GetUserPath(D_GCUSER_IDX))) File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX)); if (!File::Exists(File::GetUserPath(D_CACHE_IDX))) File::CreateFullPath(File::GetUserPath(D_CACHE_IDX)); if (!File::Exists(File::GetUserPath(D_DUMPDSP_IDX))) File::CreateFullPath(File::GetUserPath(D_DUMPDSP_IDX)); if (!File::Exists(File::GetUserPath(D_DUMPTEXTURES_IDX))) File::CreateFullPath(File::GetUserPath(D_DUMPTEXTURES_IDX)); if (!File::Exists(File::GetUserPath(D_HIRESTEXTURES_IDX))) File::CreateFullPath(File::GetUserPath(D_HIRESTEXTURES_IDX)); if (!File::Exists(File::GetUserPath(D_SCREENSHOTS_IDX))) File::CreateFullPath(File::GetUserPath(D_SCREENSHOTS_IDX)); if (!File::Exists(File::GetUserPath(D_STATESAVES_IDX))) File::CreateFullPath(File::GetUserPath(D_STATESAVES_IDX)); if (!File::Exists(File::GetUserPath(D_MAILLOGS_IDX))) File::CreateFullPath(File::GetUserPath(D_MAILLOGS_IDX)); #endif LogManager::Init(); SConfig::Init(); VideoBackend::PopulateList(); WiimoteReal::LoadSettings(); if (selectVideoBackend && videoBackendName != wxEmptyString) SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend = std::string(videoBackendName.mb_str()); VideoBackend::ActivateBackend(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend); // Enable the PNG image handler for screenshots wxImage::AddHandler(new wxPNGHandler); SetEnableAlert(SConfig::GetInstance().m_LocalCoreStartupParameter.bUsePanicHandlers); int x = SConfig::GetInstance().m_LocalCoreStartupParameter.iPosX; int y = SConfig::GetInstance().m_LocalCoreStartupParameter.iPosY; int w = SConfig::GetInstance().m_LocalCoreStartupParameter.iWidth; int h = SConfig::GetInstance().m_LocalCoreStartupParameter.iHeight; // The following is not needed with X11, where window managers // do not allow windows to be created off the desktop. #ifdef _WIN32 // Out of desktop check HWND hDesktop = GetDesktopWindow(); RECT rc; GetWindowRect(hDesktop, &rc); if (rc.right < x + w || rc.bottom < y + h) x = y = wxDefaultCoord; #elif defined __APPLE__ if (y < 1) y = wxDefaultCoord; #endif main_frame = new CFrame((wxFrame*)NULL, wxID_ANY, wxString::FromAscii(svn_rev_str), wxPoint(x, y), wxSize(w, h), UseDebugger, BatchMode, UseLogger); SetTopWindow(main_frame); main_frame->SetMinSize(wxSize(400, 300)); // Postpone final actions until event handler is running. // Updating the game list makes use of wxProgressDialog which may // only be run after OnInit() when the event handler is running. m_afterinit = new wxTimer(this, wxID_ANY); m_afterinit->Start(1, wxTIMER_ONE_SHOT); return true; }
bool DolphinApp::OnInit() { if (!wxApp::OnInit()) return false; Bind(wxEVT_QUERY_END_SESSION, &DolphinApp::OnEndSession, this); Bind(wxEVT_END_SESSION, &DolphinApp::OnEndSession, this); // Register message box and translation handlers RegisterMsgAlertHandler(&wxMsgAlert); RegisterStringTranslator(&wxStringTranslator); #if wxUSE_ON_FATAL_EXCEPTION wxHandleFatalExceptions(true); #endif UICommon::SetUserDirectory(m_user_path.ToStdString()); UICommon::CreateDirectories(); InitLanguageSupport(); // The language setting is loaded from the user directory UICommon::Init(); if (m_select_video_backend && !m_video_backend_name.empty()) SConfig::GetInstance().m_strVideoBackend = WxStrToStr(m_video_backend_name); if (m_select_audio_emulation) SConfig::GetInstance().bDSPHLE = (m_audio_emulation_name.Upper() == "HLE"); VideoBackend::ActivateBackend(SConfig::GetInstance().m_strVideoBackend); // Enable the PNG image handler for screenshots wxImage::AddHandler(new wxPNGHandler); int x = SConfig::GetInstance().iPosX; int y = SConfig::GetInstance().iPosY; int w = SConfig::GetInstance().iWidth; int h = SConfig::GetInstance().iHeight; // The following is not needed with X11, where window managers // do not allow windows to be created off the desktop. #ifdef _WIN32 // Out of desktop check int leftPos = GetSystemMetrics(SM_XVIRTUALSCREEN); int topPos = GetSystemMetrics(SM_YVIRTUALSCREEN); int width = GetSystemMetrics(SM_CXVIRTUALSCREEN); int height = GetSystemMetrics(SM_CYVIRTUALSCREEN); if ((leftPos + width) < (x + w) || leftPos > x || (topPos + height) < (y + h) || topPos > y) x = y = wxDefaultCoord; #elif defined __APPLE__ if (y < 1) y = wxDefaultCoord; #endif main_frame = new CFrame(nullptr, wxID_ANY, StrToWxStr(scm_rev_str), wxPoint(x, y), wxSize(w, h), m_use_debugger, m_batch_mode, m_use_logger); SetTopWindow(main_frame); main_frame->SetMinSize(wxSize(400, 300)); AfterInit(); return true; }
bool DolphinApp::OnInit() { InitLanguageSupport(); // Declarations and definitions bool UseDebugger = false; bool UseLogger = false; bool selectVideoBackend = false; bool selectAudioEmulation = false; wxString videoBackendName; wxString audioEmulationName; wxString userPath; #if wxUSE_CMDLINE_PARSER // Parse command lines wxCmdLineEntryDesc cmdLineDesc[] = { { wxCMD_LINE_SWITCH, "h", "help", "Show this help message", wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, { wxCMD_LINE_SWITCH, "d", "debugger", "Opens the debugger", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_SWITCH, "l", "logger", "Opens the logger", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, "e", "exec", "Loads the specified file (DOL,ELF,GCM,ISO,WAD)", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_SWITCH, "b", "batch", "Exit Dolphin with emulator", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, "V", "video_backend", "Specify a video backend", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, "A", "audio_emulation", "Low level (LLE) or high level (HLE) audio", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, "m", "movie", "Play a movie file", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, "U", "user", "User folder path", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_NONE, nullptr, nullptr, nullptr, wxCMD_LINE_VAL_NONE, 0 } }; // Gets the command line parameters wxCmdLineParser parser(cmdLineDesc, argc, argv); if (parser.Parse() != 0) { return false; } UseDebugger = parser.Found("debugger"); UseLogger = parser.Found("logger"); LoadFile = parser.Found("exec", &FileToLoad); BatchMode = parser.Found("batch"); selectVideoBackend = parser.Found("video_backend", &videoBackendName); selectAudioEmulation = parser.Found("audio_emulation", &audioEmulationName); playMovie = parser.Found("movie", &movieFile); if (parser.Found("user", &userPath)) { File::CreateFullPath(WxStrToStr(userPath) + DIR_SEP); File::GetUserPath(D_USER_IDX, userPath.ToStdString() + DIR_SEP); } #endif // wxUSE_CMDLINE_PARSER // Register message box and translation handlers RegisterMsgAlertHandler(&wxMsgAlert); RegisterStringTranslator(&wxStringTranslator); // "ExtendedTrace" looks freakin' dangerous!!! #ifdef _WIN32 EXTENDEDTRACEINITIALIZE("."); SetUnhandledExceptionFilter(&MyUnhandledExceptionFilter); #elif wxUSE_ON_FATAL_EXCEPTION wxHandleFatalExceptions(true); #endif #ifndef _M_ARM // TODO: if First Boot if (!cpu_info.bSSE2) { PanicAlertT("Hi,\n\nDolphin requires that your CPU has support for SSE2 extensions.\n" "Unfortunately your CPU does not support them, so Dolphin will not run.\n\n" "Sayonara!\n"); return false; } #endif #ifdef __APPLE__ if (floor(NSAppKitVersionNumber) < NSAppKitVersionNumber10_7) { PanicAlertT("Hi,\n\nDolphin requires Mac OS X 10.7 or greater.\n" "Unfortunately you're running an old version of OS X.\n" "The last Dolphin version to support OS X 10.6 is Dolphin 3.5\n" "Please upgrade to 10.7 or greater to use the newest Dolphin version.\n\n" "Sayonara!\n"); return false; } #endif // Copy initial Wii NAND data from Sys to User. File::CopyDir(File::GetSysDirectory() + WII_USER_DIR DIR_SEP, File::GetUserPath(D_WIIUSER_IDX)); File::CreateFullPath(File::GetUserPath(D_USER_IDX)); File::CreateFullPath(File::GetUserPath(D_CACHE_IDX)); File::CreateFullPath(File::GetUserPath(D_CONFIG_IDX)); File::CreateFullPath(File::GetUserPath(D_DUMPDSP_IDX)); File::CreateFullPath(File::GetUserPath(D_DUMPTEXTURES_IDX)); File::CreateFullPath(File::GetUserPath(D_GAMESETTINGS_IDX)); File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX)); File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + USA_DIR DIR_SEP); File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + EUR_DIR DIR_SEP); File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + JAP_DIR DIR_SEP); File::CreateFullPath(File::GetUserPath(D_HIRESTEXTURES_IDX)); File::CreateFullPath(File::GetUserPath(D_MAILLOGS_IDX)); File::CreateFullPath(File::GetUserPath(D_MAPS_IDX)); File::CreateFullPath(File::GetUserPath(D_SCREENSHOTS_IDX)); File::CreateFullPath(File::GetUserPath(D_SHADERS_IDX)); File::CreateFullPath(File::GetUserPath(D_STATESAVES_IDX)); File::CreateFullPath(File::GetUserPath(D_THEMES_IDX)); LogManager::Init(); SConfig::Init(); VideoBackend::PopulateList(); WiimoteReal::LoadSettings(); if (selectVideoBackend && videoBackendName != wxEmptyString) SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend = WxStrToStr(videoBackendName); if (selectAudioEmulation) { if (audioEmulationName == "HLE") SConfig::GetInstance().m_LocalCoreStartupParameter.bDSPHLE = true; else if (audioEmulationName == "LLE") SConfig::GetInstance().m_LocalCoreStartupParameter.bDSPHLE = false; } VideoBackend::ActivateBackend(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend); // Enable the PNG image handler for screenshots wxImage::AddHandler(new wxPNGHandler); SetEnableAlert(SConfig::GetInstance().m_LocalCoreStartupParameter.bUsePanicHandlers); int x = SConfig::GetInstance().m_LocalCoreStartupParameter.iPosX; int y = SConfig::GetInstance().m_LocalCoreStartupParameter.iPosY; int w = SConfig::GetInstance().m_LocalCoreStartupParameter.iWidth; int h = SConfig::GetInstance().m_LocalCoreStartupParameter.iHeight; #ifdef _WIN32 if (File::Exists("www.dolphin-emulator.com.txt")) { File::Delete("www.dolphin-emulator.com.txt"); MessageBox(nullptr, L"This version of Dolphin was downloaded from a website stealing money from developers of the emulator. Please " L"download Dolphin from the official website instead: http://dolphin-emu.org/", L"Unofficial version detected", MB_OK | MB_ICONWARNING); ShellExecute(nullptr, L"open", L"http://dolphin-emu.org/?ref=badver", nullptr, nullptr, SW_SHOWDEFAULT); exit(0); } #endif // The following is not needed with X11, where window managers // do not allow windows to be created off the desktop. #ifdef _WIN32 // Out of desktop check int leftPos = GetSystemMetrics(SM_XVIRTUALSCREEN); int topPos = GetSystemMetrics(SM_YVIRTUALSCREEN); int width = GetSystemMetrics(SM_CXVIRTUALSCREEN); int height = GetSystemMetrics(SM_CYVIRTUALSCREEN); if ((leftPos + width) < (x + w) || leftPos > x || (topPos + height) < (y + h) || topPos > y) x = y = wxDefaultCoord; #elif defined __APPLE__ if (y < 1) y = wxDefaultCoord; #endif main_frame = new CFrame((wxFrame*)nullptr, wxID_ANY, StrToWxStr(scm_rev_str), wxPoint(x, y), wxSize(w, h), UseDebugger, BatchMode, UseLogger); SetTopWindow(main_frame); main_frame->SetMinSize(wxSize(400, 300)); // Postpone final actions until event handler is running. // Updating the game list makes use of wxProgressDialog which may // only be run after OnInit() when the event handler is running. m_afterinit = new wxTimer(this, wxID_ANY); m_afterinit->Start(1, wxTIMER_ONE_SHOT); return true; }
// N.B. On Windows, this should be called from WinMain. Link against qtmain and specify // /SubSystem:Windows int main(int argc, char* argv[]) { #ifdef _WIN32 const bool console_attached = AttachConsole(ATTACH_PARENT_PROCESS) != FALSE; HANDLE stdout_handle = ::GetStdHandle(STD_OUTPUT_HANDLE); if (console_attached && stdout_handle) { freopen("CONOUT$", "w", stdout); freopen("CONOUT$", "w", stderr); } #endif QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QCoreApplication::setOrganizationName(QStringLiteral("Dolphin Emulator")); QCoreApplication::setOrganizationDomain(QStringLiteral("dolphin-emu.org")); QCoreApplication::setApplicationName(QStringLiteral("dolphin-emu")); QApplication app(argc, argv); #ifdef _WIN32 // Get the default system font because Qt's way of obtaining it is outdated NONCLIENTMETRICS metrics = {}; LOGFONT& logfont = metrics.lfMenuFont; metrics.cbSize = sizeof(NONCLIENTMETRICS); if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(metrics), &metrics, 0)) { // Sadly Qt 5 doesn't support turning a native font handle into a QFont so this is the next best // thing QFont font = QApplication::font(); font.setFamily(QString::fromStdString(UTF16ToUTF8(logfont.lfFaceName))); font.setItalic(logfont.lfItalic); font.setStrikeOut(logfont.lfStrikeOut); font.setUnderline(logfont.lfUnderline); // The default font size is a bit too small font.setPointSize(QFontInfo(font).pointSize() * 1.2); QApplication::setFont(font); } #endif auto parser = CommandLineParse::CreateParser(CommandLineParse::ParserOptions::IncludeGUIOptions); const optparse::Values& options = CommandLineParse::ParseArguments(parser.get(), argc, argv); const std::vector<std::string> args = parser->args(); #ifdef _WIN32 FreeConsole(); #endif UICommon::SetUserDirectory(static_cast<const char*>(options.get("user"))); UICommon::CreateDirectories(); UICommon::Init(); Resources::Init(); Settings::Instance().SetBatchModeEnabled(options.is_set("batch")); // Hook up alerts from core RegisterMsgAlertHandler(QtMsgAlertHandler); // Hook up translations Translation::Initialize(); // Whenever the event loop is about to go to sleep, dispatch the jobs // queued in the Core first. QObject::connect(QAbstractEventDispatcher::instance(), &QAbstractEventDispatcher::aboutToBlock, &app, &Core::HostDispatchJobs); std::unique_ptr<BootParameters> boot; if (options.is_set("exec")) { const std::list<std::string> paths_list = options.all("exec"); const std::vector<std::string> paths{std::make_move_iterator(std::begin(paths_list)), std::make_move_iterator(std::end(paths_list))}; boot = BootParameters::GenerateFromFile(paths); } else if (options.is_set("nand_title")) { const std::string hex_string = static_cast<const char*>(options.get("nand_title")); if (hex_string.length() == 16) { const u64 title_id = std::stoull(hex_string, nullptr, 16); boot = std::make_unique<BootParameters>(BootParameters::NANDTitle{title_id}); } else { QMessageBox::critical(nullptr, QObject::tr("Error"), QObject::tr("Invalid title ID.")); } } else if (!args.empty()) { boot = BootParameters::GenerateFromFile(args.front()); } int retval; { DolphinAnalytics::Instance()->ReportDolphinStart("qt"); MainWindow win{std::move(boot)}; if (options.is_set("debugger")) Settings::Instance().SetDebugModeEnabled(true); win.Show(); #if defined(USE_ANALYTICS) && USE_ANALYTICS if (!SConfig::GetInstance().m_analytics_permission_asked) { QMessageBox analytics_prompt(&win); analytics_prompt.setIcon(QMessageBox::Question); analytics_prompt.setStandardButtons(QMessageBox::Yes | QMessageBox::No); analytics_prompt.setWindowTitle(QObject::tr("Allow Usage Statistics Reporting")); analytics_prompt.setText( QObject::tr("Do you authorize Dolphin to report information to Dolphin's developers?")); analytics_prompt.setInformativeText( QObject::tr("If authorized, Dolphin can collect data on its performance, " "feature usage, and configuration, as well as data on your system's " "hardware and operating system.\n\n" "No private data is ever collected. This data helps us understand " "how people and emulated games use Dolphin and prioritize our " "efforts. It also helps us identify rare configurations that are " "causing bugs, performance and stability issues.\n" "This authorization can be revoked at any time through Dolphin's " "settings.")); const int answer = analytics_prompt.exec(); SConfig::GetInstance().m_analytics_permission_asked = true; Settings::Instance().SetAnalyticsEnabled(answer == QMessageBox::Yes); DolphinAnalytics::Instance()->ReloadConfig(); } #endif auto* updater = new Updater(&win); updater->start(); retval = app.exec(); } Core::Shutdown(); UICommon::Shutdown(); Host::GetInstance()->deleteLater(); return retval; }