diff --git a/src/citron/bootmanager.cpp b/src/citron/bootmanager.cpp index c04f143aa..878da76ac 100644 --- a/src/citron/bootmanager.cpp +++ b/src/citron/bootmanager.cpp @@ -602,6 +602,10 @@ int GRenderWindow::QtModifierToSwitchModifier(Qt::KeyboardModifiers qt_modifiers } void GRenderWindow::keyPressEvent(QKeyEvent* event) { + if (!first_frame) { + event->ignore(); + return; + } if (event->isAutoRepeat()) { return; // Ignore auto-repeated key presses } @@ -621,6 +625,12 @@ void GRenderWindow::keyPressEvent(QKeyEvent* event) { return; // Stop processing } + if (key_sequence == hotkey_registry.GetKeySequence(main_window_id, "Toggle Framerate Limit")) { + emit UnlockFramerateHotkeyPressed(); // Signal the main window + event->accept(); // Consume the event + return; // Stop processing + } + // --- If not a critical hotkey, pass to game as normal --- const auto modifier = QtModifierToSwitchModifier(event->modifiers()); const auto key = QtKeyToSwitchKey(static_cast(event->key())); @@ -630,6 +640,10 @@ void GRenderWindow::keyPressEvent(QKeyEvent* event) { } void GRenderWindow::keyReleaseEvent(QKeyEvent* event) { + if (!first_frame) { + event->ignore(); + return; + } /** * This feature can be enhanced with the following functions, but they do not provide * cross-platform behavior. diff --git a/src/citron/bootmanager.h b/src/citron/bootmanager.h index dcdbbfe43..14696c3ee 100644 --- a/src/citron/bootmanager.h +++ b/src/citron/bootmanager.h @@ -232,6 +232,7 @@ signals: void TasPlaybackStateChanged(); void PanningToggleHotkeyPressed(); void FullscreenExitHotkeyPressed(); + void UnlockFramerateHotkeyPressed(); private slots: void HideMouseCursor(); diff --git a/src/citron/main.cpp b/src/citron/main.cpp index c1a1b9862..b96b1e109 100644 --- a/src/citron/main.cpp +++ b/src/citron/main.cpp @@ -1104,6 +1104,8 @@ void GMainWindow::InitializeWidgets() { if (emulation_running) { render_window->show(); render_window->setFocus(); + // The only safe time to enable screenshots: + ui->action_Capture_Screenshot->setEnabled(true); } }); @@ -1473,9 +1475,6 @@ void GMainWindow::InitializeHotkeys() { connect_shortcut(QStringLiteral("Audio Mute/Unmute"), &GMainWindow::OnMute); connect_shortcut(QStringLiteral("Audio Volume Down"), &GMainWindow::OnDecreaseVolume); connect_shortcut(QStringLiteral("Audio Volume Up"), &GMainWindow::OnIncreaseVolume); - connect_shortcut(QStringLiteral("Toggle Framerate Limit"), [] { - Settings::values.use_speed_limit.SetValue(!Settings::values.use_speed_limit.GetValue()); - }); connect_shortcut(QStringLiteral("Toggle Renderdoc Capture"), [this] { if (Settings::values.enable_renderdoc_hotkey) { system->GetRenderdocAPI().ToggleCapture(); @@ -1614,6 +1613,12 @@ void GMainWindow::ConnectWidgetEvents() { connect(this, &GMainWindow::EmulationStopping, render_window, &GRenderWindow::OnEmulationStopping); + connect(render_window, &GRenderWindow::UnlockFramerateHotkeyPressed, this, [this] { + if (system->IsPoweredOn()) { + Settings::values.use_speed_limit.SetValue(!Settings::values.use_speed_limit.GetValue()); + } + }); + // Software Keyboard Applet connect(this, &GMainWindow::EmulationStarting, this, &GMainWindow::SoftwareKeyboardExit); connect(this, &GMainWindow::EmulationStopping, this, &GMainWindow::SoftwareKeyboardExit); @@ -2059,6 +2064,8 @@ void GMainWindow::BootGame(const QString& filename, Service::AM::FrontendAppletP return; } + current_title_id = title_id; // Store ID safely + if (type == StartGameType::Normal) { // Load per game settings if it is a normal boot const auto file_path = @@ -5297,15 +5304,17 @@ void GMainWindow::OnOpenControllerMenu() { } void GMainWindow::OnCaptureScreenshot() { - if (emu_thread == nullptr || !emu_thread->IsRunning()) { + if (emu_thread == nullptr || !emu_thread->IsRunning() || !render_window->IsLoadingComplete()) { return; } - const u64 title_id = system->GetApplicationProcessProgramID(); + const u64 title_id = current_title_id; + const auto screenshot_path = QString::fromStdString(Common::FS::GetCitronPathString(Common::FS::CitronPath::ScreenshotsDir)); const auto date = QDateTime::currentDateTime().toString(QStringLiteral("yyyy-MM-dd_hh-mm-ss-zzz")); + QString filename = QStringLiteral("%1/%2_%3.png") .arg(screenshot_path) .arg(title_id, 16, 16, QLatin1Char{'0'}) @@ -5326,6 +5335,7 @@ void GMainWindow::OnCaptureScreenshot() { } } #endif + render_window->CaptureScreenshot(filename); }