main.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <thread>
  5. #include <QDesktopWidget>
  6. #include <QtGui>
  7. #include <QFileDialog>
  8. #include <QMessageBox>
  9. #include "qhexedit.h"
  10. #include "citra_qt/bootmanager.h"
  11. #include "citra_qt/config.h"
  12. #include "citra_qt/game_list.h"
  13. #include "citra_qt/hotkeys.h"
  14. #include "citra_qt/main.h"
  15. // Debugger
  16. #include "citra_qt/debugger/callstack.h"
  17. #include "citra_qt/debugger/disassembler.h"
  18. #include "citra_qt/debugger/graphics.h"
  19. #include "citra_qt/debugger/graphics_breakpoints.h"
  20. #include "citra_qt/debugger/graphics_cmdlists.h"
  21. #include "citra_qt/debugger/graphics_framebuffer.h"
  22. #include "citra_qt/debugger/graphics_tracing.h"
  23. #include "citra_qt/debugger/graphics_vertex_shader.h"
  24. #include "citra_qt/debugger/profiler.h"
  25. #include "citra_qt/debugger/ramview.h"
  26. #include "citra_qt/debugger/registers.h"
  27. #include "common/make_unique.h"
  28. #include "common/microprofile.h"
  29. #include "common/platform.h"
  30. #include "common/scm_rev.h"
  31. #include "common/scope_exit.h"
  32. #include "common/string_util.h"
  33. #include "common/logging/backend.h"
  34. #include "common/logging/filter.h"
  35. #include "common/logging/log.h"
  36. #include "common/logging/text_formatter.h"
  37. #include "core/core.h"
  38. #include "core/settings.h"
  39. #include "core/system.h"
  40. #include "core/arm/disassembler/load_symbol_map.h"
  41. #include "core/gdbstub/gdbstub.h"
  42. #include "core/loader/loader.h"
  43. #include "video_core/video_core.h"
  44. GMainWindow::GMainWindow() : emu_thread(nullptr)
  45. {
  46. Pica::g_debug_context = Pica::DebugContext::Construct();
  47. Config config;
  48. ui.setupUi(this);
  49. statusBar()->hide();
  50. render_window = new GRenderWindow(this, emu_thread.get());
  51. render_window->hide();
  52. game_list = new GameList();
  53. ui.horizontalLayout->addWidget(game_list);
  54. profilerWidget = new ProfilerWidget(this);
  55. addDockWidget(Qt::BottomDockWidgetArea, profilerWidget);
  56. profilerWidget->hide();
  57. microProfileDialog = new MicroProfileDialog(this);
  58. microProfileDialog->hide();
  59. disasmWidget = new DisassemblerWidget(this, emu_thread.get());
  60. addDockWidget(Qt::BottomDockWidgetArea, disasmWidget);
  61. disasmWidget->hide();
  62. registersWidget = new RegistersWidget(this);
  63. addDockWidget(Qt::RightDockWidgetArea, registersWidget);
  64. registersWidget->hide();
  65. callstackWidget = new CallstackWidget(this);
  66. addDockWidget(Qt::RightDockWidgetArea, callstackWidget);
  67. callstackWidget->hide();
  68. graphicsWidget = new GPUCommandStreamWidget(this);
  69. addDockWidget(Qt::RightDockWidgetArea, graphicsWidget);
  70. graphicsWidget ->hide();
  71. graphicsCommandsWidget = new GPUCommandListWidget(this);
  72. addDockWidget(Qt::RightDockWidgetArea, graphicsCommandsWidget);
  73. graphicsCommandsWidget->hide();
  74. auto graphicsBreakpointsWidget = new GraphicsBreakPointsWidget(Pica::g_debug_context, this);
  75. addDockWidget(Qt::RightDockWidgetArea, graphicsBreakpointsWidget);
  76. graphicsBreakpointsWidget->hide();
  77. auto graphicsFramebufferWidget = new GraphicsFramebufferWidget(Pica::g_debug_context, this);
  78. addDockWidget(Qt::RightDockWidgetArea, graphicsFramebufferWidget);
  79. graphicsFramebufferWidget->hide();
  80. auto graphicsVertexShaderWidget = new GraphicsVertexShaderWidget(Pica::g_debug_context, this);
  81. addDockWidget(Qt::RightDockWidgetArea, graphicsVertexShaderWidget);
  82. graphicsVertexShaderWidget->hide();
  83. auto graphicsTracingWidget = new GraphicsTracingWidget(Pica::g_debug_context, this);
  84. addDockWidget(Qt::RightDockWidgetArea, graphicsTracingWidget);
  85. graphicsTracingWidget->hide();
  86. QMenu* debug_menu = ui.menu_View->addMenu(tr("Debugging"));
  87. debug_menu->addAction(profilerWidget->toggleViewAction());
  88. debug_menu->addAction(microProfileDialog->toggleViewAction());
  89. debug_menu->addAction(disasmWidget->toggleViewAction());
  90. debug_menu->addAction(registersWidget->toggleViewAction());
  91. debug_menu->addAction(callstackWidget->toggleViewAction());
  92. debug_menu->addAction(graphicsWidget->toggleViewAction());
  93. debug_menu->addAction(graphicsCommandsWidget->toggleViewAction());
  94. debug_menu->addAction(graphicsBreakpointsWidget->toggleViewAction());
  95. debug_menu->addAction(graphicsFramebufferWidget->toggleViewAction());
  96. debug_menu->addAction(graphicsVertexShaderWidget->toggleViewAction());
  97. debug_menu->addAction(graphicsTracingWidget->toggleViewAction());
  98. // Set default UI state
  99. // geometry: 55% of the window contents are in the upper screen half, 45% in the lower half
  100. QDesktopWidget* desktop = ((QApplication*)QApplication::instance())->desktop();
  101. QRect screenRect = desktop->screenGeometry(this);
  102. int x, y, w, h;
  103. w = screenRect.width() * 2 / 3;
  104. h = screenRect.height() / 2;
  105. x = (screenRect.x() + screenRect.width()) / 2 - w / 2;
  106. y = (screenRect.y() + screenRect.height()) / 2 - h * 55 / 100;
  107. setGeometry(x, y, w, h);
  108. // Restore UI state
  109. QSettings settings;
  110. settings.beginGroup("UILayout");
  111. restoreGeometry(settings.value("geometry").toByteArray());
  112. restoreState(settings.value("state").toByteArray());
  113. render_window->restoreGeometry(settings.value("geometryRenderWindow").toByteArray());
  114. microProfileDialog->restoreGeometry(settings.value("microProfileDialogGeometry").toByteArray());
  115. microProfileDialog->setVisible(settings.value("microProfileDialogVisible").toBool());
  116. settings.endGroup();
  117. game_list->LoadInterfaceLayout(settings);
  118. ui.action_Use_Gdbstub->setChecked(Settings::values.use_gdbstub);
  119. SetGdbstubEnabled(ui.action_Use_Gdbstub->isChecked());
  120. GDBStub::SetServerPort(static_cast<u32>(Settings::values.gdbstub_port));
  121. ui.action_Use_Hardware_Renderer->setChecked(Settings::values.use_hw_renderer);
  122. SetHardwareRendererEnabled(ui.action_Use_Hardware_Renderer->isChecked());
  123. ui.action_Use_Shader_JIT->setChecked(Settings::values.use_shader_jit);
  124. SetShaderJITEnabled(ui.action_Use_Shader_JIT->isChecked());
  125. ui.action_Single_Window_Mode->setChecked(settings.value("singleWindowMode", true).toBool());
  126. ToggleWindowMode();
  127. ui.actionDisplay_widget_title_bars->setChecked(settings.value("displayTitleBars", true).toBool());
  128. OnDisplayTitleBars(ui.actionDisplay_widget_title_bars->isChecked());
  129. // Prepare actions for recent files
  130. for (int i = 0; i < max_recent_files_item; ++i) {
  131. actions_recent_files[i] = new QAction(this);
  132. actions_recent_files[i]->setVisible(false);
  133. connect(actions_recent_files[i], SIGNAL(triggered()), this, SLOT(OnMenuRecentFile()));
  134. ui.menu_recent_files->addAction(actions_recent_files[i]);
  135. }
  136. UpdateRecentFiles();
  137. // Setup connections
  138. connect(game_list, SIGNAL(GameChosen(QString)), this, SLOT(OnGameListLoadFile(QString)));
  139. connect(ui.action_Load_File, SIGNAL(triggered()), this, SLOT(OnMenuLoadFile()));
  140. connect(ui.action_Load_Symbol_Map, SIGNAL(triggered()), this, SLOT(OnMenuLoadSymbolMap()));
  141. connect(ui.action_Select_Game_List_Root, SIGNAL(triggered()), this, SLOT(OnMenuSelectGameListRoot()));
  142. connect(ui.action_Start, SIGNAL(triggered()), this, SLOT(OnStartGame()));
  143. connect(ui.action_Pause, SIGNAL(triggered()), this, SLOT(OnPauseGame()));
  144. connect(ui.action_Stop, SIGNAL(triggered()), this, SLOT(OnStopGame()));
  145. connect(ui.action_Use_Hardware_Renderer, SIGNAL(triggered(bool)), this, SLOT(SetHardwareRendererEnabled(bool)));
  146. connect(ui.action_Use_Shader_JIT, SIGNAL(triggered(bool)), this, SLOT(SetShaderJITEnabled(bool)));
  147. connect(ui.action_Use_Gdbstub, SIGNAL(triggered(bool)), this, SLOT(SetGdbstubEnabled(bool)));
  148. connect(ui.action_Single_Window_Mode, SIGNAL(triggered(bool)), this, SLOT(ToggleWindowMode()));
  149. connect(ui.action_Hotkeys, SIGNAL(triggered()), this, SLOT(OnOpenHotkeysDialog()));
  150. connect(this, SIGNAL(EmulationStarting(EmuThread*)), disasmWidget, SLOT(OnEmulationStarting(EmuThread*)));
  151. connect(this, SIGNAL(EmulationStopping()), disasmWidget, SLOT(OnEmulationStopping()));
  152. connect(this, SIGNAL(EmulationStarting(EmuThread*)), registersWidget, SLOT(OnEmulationStarting(EmuThread*)));
  153. connect(this, SIGNAL(EmulationStopping()), registersWidget, SLOT(OnEmulationStopping()));
  154. connect(this, SIGNAL(EmulationStarting(EmuThread*)), render_window, SLOT(OnEmulationStarting(EmuThread*)));
  155. connect(this, SIGNAL(EmulationStopping()), render_window, SLOT(OnEmulationStopping()));
  156. connect(this, SIGNAL(EmulationStarting(EmuThread*)), graphicsTracingWidget, SLOT(OnEmulationStarting(EmuThread*)));
  157. connect(this, SIGNAL(EmulationStopping()), graphicsTracingWidget, SLOT(OnEmulationStopping()));
  158. // Setup hotkeys
  159. RegisterHotkey("Main Window", "Load File", QKeySequence::Open);
  160. RegisterHotkey("Main Window", "Start Emulation");
  161. LoadHotkeys(settings);
  162. connect(GetHotkey("Main Window", "Load File", this), SIGNAL(activated()), this, SLOT(OnMenuLoadFile()));
  163. connect(GetHotkey("Main Window", "Start Emulation", this), SIGNAL(activated()), this, SLOT(OnStartGame()));
  164. std::string window_title = Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc);
  165. setWindowTitle(window_title.c_str());
  166. show();
  167. game_list->PopulateAsync(settings.value("gameListRootDir").toString(), settings.value("gameListDeepScan").toBool());
  168. QStringList args = QApplication::arguments();
  169. if (args.length() >= 2) {
  170. BootGame(args[1].toStdString());
  171. }
  172. }
  173. GMainWindow::~GMainWindow()
  174. {
  175. // will get automatically deleted otherwise
  176. if (render_window->parent() == nullptr)
  177. delete render_window;
  178. Pica::g_debug_context.reset();
  179. }
  180. void GMainWindow::OnDisplayTitleBars(bool show)
  181. {
  182. QList<QDockWidget*> widgets = findChildren<QDockWidget*>();
  183. if (show) {
  184. for (QDockWidget* widget: widgets) {
  185. QWidget* old = widget->titleBarWidget();
  186. widget->setTitleBarWidget(nullptr);
  187. if (old != nullptr)
  188. delete old;
  189. }
  190. } else {
  191. for (QDockWidget* widget: widgets) {
  192. QWidget* old = widget->titleBarWidget();
  193. widget->setTitleBarWidget(new QWidget());
  194. if (old != nullptr)
  195. delete old;
  196. }
  197. }
  198. }
  199. void GMainWindow::BootGame(const std::string& filename) {
  200. LOG_INFO(Frontend, "Citra starting...");
  201. // Shutdown previous session if the emu thread is still active...
  202. if (emu_thread != nullptr)
  203. ShutdownGame();
  204. // Initialize the core emulation
  205. System::Init(render_window);
  206. // Load the game
  207. if (Loader::ResultStatus::Success != Loader::LoadFile(filename)) {
  208. LOG_CRITICAL(Frontend, "Failed to load ROM!");
  209. System::Shutdown();
  210. return;
  211. }
  212. // Create and start the emulation thread
  213. emu_thread = Common::make_unique<EmuThread>(render_window);
  214. emit EmulationStarting(emu_thread.get());
  215. render_window->moveContext();
  216. emu_thread->start();
  217. connect(render_window, SIGNAL(Closed()), this, SLOT(OnStopGame()));
  218. // BlockingQueuedConnection is important here, it makes sure we've finished refreshing our views before the CPU continues
  219. connect(emu_thread.get(), SIGNAL(DebugModeEntered()), disasmWidget, SLOT(OnDebugModeEntered()), Qt::BlockingQueuedConnection);
  220. connect(emu_thread.get(), SIGNAL(DebugModeEntered()), registersWidget, SLOT(OnDebugModeEntered()), Qt::BlockingQueuedConnection);
  221. connect(emu_thread.get(), SIGNAL(DebugModeEntered()), callstackWidget, SLOT(OnDebugModeEntered()), Qt::BlockingQueuedConnection);
  222. connect(emu_thread.get(), SIGNAL(DebugModeLeft()), disasmWidget, SLOT(OnDebugModeLeft()), Qt::BlockingQueuedConnection);
  223. connect(emu_thread.get(), SIGNAL(DebugModeLeft()), registersWidget, SLOT(OnDebugModeLeft()), Qt::BlockingQueuedConnection);
  224. connect(emu_thread.get(), SIGNAL(DebugModeLeft()), callstackWidget, SLOT(OnDebugModeLeft()), Qt::BlockingQueuedConnection);
  225. // Update the GUI
  226. registersWidget->OnDebugModeEntered();
  227. callstackWidget->OnDebugModeEntered();
  228. if (ui.action_Single_Window_Mode->isChecked()) {
  229. game_list->hide();
  230. }
  231. render_window->show();
  232. emulation_running = true;
  233. OnStartGame();
  234. }
  235. void GMainWindow::ShutdownGame() {
  236. emu_thread->RequestStop();
  237. // Release emu threads from any breakpoints
  238. // This belongs after RequestStop() and before wait() because if emulation stops on a GPU
  239. // breakpoint after (or before) RequestStop() is called, the emulation would never be able
  240. // to continue out to the main loop and terminate. Thus wait() would hang forever.
  241. // TODO(bunnei): This function is not thread safe, but it's being used as if it were
  242. Pica::g_debug_context->ClearBreakpoints();
  243. emit EmulationStopping();
  244. // Wait for emulation thread to complete and delete it
  245. emu_thread->wait();
  246. emu_thread = nullptr;
  247. // The emulation is stopped, so closing the window or not does not matter anymore
  248. disconnect(render_window, SIGNAL(Closed()), this, SLOT(OnStopGame()));
  249. // Update the GUI
  250. ui.action_Start->setEnabled(false);
  251. ui.action_Start->setText(tr("Start"));
  252. ui.action_Pause->setEnabled(false);
  253. ui.action_Stop->setEnabled(false);
  254. render_window->hide();
  255. game_list->show();
  256. emulation_running = false;
  257. }
  258. void GMainWindow::StoreRecentFile(const QString& filename)
  259. {
  260. QSettings settings;
  261. QStringList recent_files = settings.value("recentFiles").toStringList();
  262. recent_files.prepend(filename);
  263. recent_files.removeDuplicates();
  264. while (recent_files.size() > max_recent_files_item) {
  265. recent_files.removeLast();
  266. }
  267. settings.setValue("recentFiles", recent_files);
  268. UpdateRecentFiles();
  269. }
  270. void GMainWindow::UpdateRecentFiles() {
  271. QSettings settings;
  272. QStringList recent_files = settings.value("recentFiles").toStringList();
  273. unsigned int num_recent_files = std::min(recent_files.size(), static_cast<int>(max_recent_files_item));
  274. for (unsigned int i = 0; i < num_recent_files; i++) {
  275. QString text = QString("&%1. %2").arg(i + 1).arg(QFileInfo(recent_files[i]).fileName());
  276. actions_recent_files[i]->setText(text);
  277. actions_recent_files[i]->setData(recent_files[i]);
  278. actions_recent_files[i]->setToolTip(recent_files[i]);
  279. actions_recent_files[i]->setVisible(true);
  280. }
  281. for (int j = num_recent_files; j < max_recent_files_item; ++j) {
  282. actions_recent_files[j]->setVisible(false);
  283. }
  284. // Grey out the recent files menu if the list is empty
  285. if (num_recent_files == 0) {
  286. ui.menu_recent_files->setEnabled(false);
  287. } else {
  288. ui.menu_recent_files->setEnabled(true);
  289. }
  290. }
  291. void GMainWindow::OnGameListLoadFile(QString game_path) {
  292. BootGame(game_path.toLocal8Bit().data());
  293. }
  294. void GMainWindow::OnMenuLoadFile() {
  295. QSettings settings;
  296. QString rom_path = settings.value("romsPath", QString()).toString();
  297. QString filename = QFileDialog::getOpenFileName(this, tr("Load File"), rom_path, tr("3DS executable (*.3ds *.3dsx *.elf *.axf *.cci *.cxi)"));
  298. if (!filename.isEmpty()) {
  299. settings.setValue("romsPath", QFileInfo(filename).path());
  300. StoreRecentFile(filename);
  301. BootGame(filename.toLocal8Bit().data());
  302. }
  303. }
  304. void GMainWindow::OnMenuLoadSymbolMap() {
  305. QSettings settings;
  306. QString symbol_path = settings.value("symbolsPath", QString()).toString();
  307. QString filename = QFileDialog::getOpenFileName(this, tr("Load Symbol Map"), symbol_path, tr("Symbol map (*)"));
  308. if (!filename.isEmpty()) {
  309. settings.setValue("symbolsPath", QFileInfo(filename).path());
  310. LoadSymbolMap(filename.toLocal8Bit().data());
  311. }
  312. }
  313. void GMainWindow::OnMenuSelectGameListRoot() {
  314. QSettings settings;
  315. QString dir_path = QFileDialog::getExistingDirectory(this, tr("Select Directory"));
  316. if (!dir_path.isEmpty()) {
  317. settings.setValue("gameListRootDir", dir_path);
  318. game_list->PopulateAsync(dir_path, settings.value("gameListDeepScan").toBool());
  319. }
  320. }
  321. void GMainWindow::OnMenuRecentFile() {
  322. QAction* action = qobject_cast<QAction*>(sender());
  323. assert(action);
  324. QString filename = action->data().toString();
  325. QFileInfo file_info(filename);
  326. if (file_info.exists()) {
  327. BootGame(filename.toLocal8Bit().data());
  328. StoreRecentFile(filename); // Put the filename on top of the list
  329. } else {
  330. // Display an error message and remove the file from the list.
  331. QMessageBox::information(this, tr("File not found"), tr("File \"%1\" not found").arg(filename));
  332. QSettings settings;
  333. QStringList recent_files = settings.value("recentFiles").toStringList();
  334. recent_files.removeOne(filename);
  335. settings.setValue("recentFiles", recent_files);
  336. UpdateRecentFiles();
  337. }
  338. }
  339. void GMainWindow::OnStartGame() {
  340. emu_thread->SetRunning(true);
  341. ui.action_Start->setEnabled(false);
  342. ui.action_Start->setText(tr("Continue"));
  343. ui.action_Pause->setEnabled(true);
  344. ui.action_Stop->setEnabled(true);
  345. }
  346. void GMainWindow::OnPauseGame() {
  347. emu_thread->SetRunning(false);
  348. ui.action_Start->setEnabled(true);
  349. ui.action_Pause->setEnabled(false);
  350. ui.action_Stop->setEnabled(true);
  351. }
  352. void GMainWindow::OnStopGame() {
  353. ShutdownGame();
  354. }
  355. void GMainWindow::OnOpenHotkeysDialog() {
  356. GHotkeysDialog dialog(this);
  357. dialog.exec();
  358. }
  359. void GMainWindow::SetHardwareRendererEnabled(bool enabled) {
  360. VideoCore::g_hw_renderer_enabled = enabled;
  361. Config config;
  362. Settings::values.use_hw_renderer = enabled;
  363. config.Save();
  364. }
  365. void GMainWindow::SetGdbstubEnabled(bool enabled) {
  366. GDBStub::ToggleServer(enabled);
  367. }
  368. void GMainWindow::SetShaderJITEnabled(bool enabled) {
  369. VideoCore::g_shader_jit_enabled = enabled;
  370. Config config;
  371. Settings::values.use_shader_jit = enabled;
  372. config.Save();
  373. }
  374. void GMainWindow::ToggleWindowMode() {
  375. if (ui.action_Single_Window_Mode->isChecked()) {
  376. // Render in the main window...
  377. render_window->BackupGeometry();
  378. ui.horizontalLayout->addWidget(render_window);
  379. render_window->setFocusPolicy(Qt::ClickFocus);
  380. if (emulation_running) {
  381. render_window->setVisible(true);
  382. render_window->setFocus();
  383. game_list->hide();
  384. }
  385. } else {
  386. // Render in a separate window...
  387. ui.horizontalLayout->removeWidget(render_window);
  388. render_window->setParent(nullptr);
  389. render_window->setFocusPolicy(Qt::NoFocus);
  390. if (emulation_running) {
  391. render_window->setVisible(true);
  392. render_window->RestoreGeometry();
  393. game_list->show();
  394. }
  395. }
  396. }
  397. void GMainWindow::OnConfigure() {
  398. //GControllerConfigDialog* dialog = new GControllerConfigDialog(controller_ports, this);
  399. }
  400. void GMainWindow::closeEvent(QCloseEvent* event) {
  401. // Save window layout
  402. QSettings settings(QSettings::IniFormat, QSettings::UserScope, "Citra team", "Citra");
  403. settings.beginGroup("UILayout");
  404. settings.setValue("geometry", saveGeometry());
  405. settings.setValue("state", saveState());
  406. settings.setValue("geometryRenderWindow", render_window->saveGeometry());
  407. settings.setValue("microProfileDialogGeometry", microProfileDialog->saveGeometry());
  408. settings.setValue("microProfileDialogVisible", microProfileDialog->isVisible());
  409. settings.endGroup();
  410. settings.setValue("singleWindowMode", ui.action_Single_Window_Mode->isChecked());
  411. settings.setValue("displayTitleBars", ui.actionDisplay_widget_title_bars->isChecked());
  412. settings.setValue("firstStart", false);
  413. game_list->SaveInterfaceLayout(settings);
  414. SaveHotkeys(settings);
  415. // Shutdown session if the emu thread is active...
  416. if (emu_thread != nullptr)
  417. ShutdownGame();
  418. render_window->close();
  419. QWidget::closeEvent(event);
  420. }
  421. #ifdef main
  422. #undef main
  423. #endif
  424. int main(int argc, char* argv[]) {
  425. Log::Filter log_filter(Log::Level::Info);
  426. Log::SetFilter(&log_filter);
  427. MicroProfileOnThreadCreate("Frontend");
  428. SCOPE_EXIT({
  429. MicroProfileShutdown();
  430. });
  431. // Init settings params
  432. QSettings::setDefaultFormat(QSettings::IniFormat);
  433. QCoreApplication::setOrganizationName("Citra team");
  434. QCoreApplication::setApplicationName("Citra");
  435. QApplication::setAttribute(Qt::AA_X11InitThreads);
  436. QApplication app(argc, argv);
  437. GMainWindow main_window;
  438. // After settings have been loaded by GMainWindow, apply the filter
  439. log_filter.ParseFilterString(Settings::values.log_filter);
  440. main_window.show();
  441. return app.exec();
  442. }