diff options
-rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic_64.cpp | 20 | ||||
-rw-r--r-- | src/core/frontend/framebuffer_layout.cpp | 7 | ||||
-rw-r--r-- | src/core/frontend/framebuffer_layout.h | 11 | ||||
-rw-r--r-- | src/core/hle/kernel/kernel.cpp | 22 | ||||
-rw-r--r-- | src/core/hle/service/pm/pm.cpp | 47 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/blit_image.cpp | 38 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/blit_image.h | 3 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/vk_texture_cache.cpp | 6 | ||||
-rw-r--r-- | src/video_core/video_core.cpp | 6 | ||||
-rw-r--r-- | src/video_core/video_core.h | 2 | ||||
-rw-r--r-- | src/yuzu/bootmanager.cpp | 11 | ||||
-rw-r--r-- | src/yuzu/bootmanager.h | 6 | ||||
-rw-r--r-- | src/yuzu/main.cpp | 99 | ||||
-rw-r--r-- | src/yuzu/main.h | 5 | ||||
-rw-r--r-- | src/yuzu/main.ui | 90 |
15 files changed, 248 insertions, 125 deletions
diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.cpp b/src/core/arm/dynarmic/arm_dynarmic_64.cpp index 4e73cc03a..56836bd05 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_64.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_64.cpp @@ -86,6 +86,26 @@ public: num_instructions, MemoryReadCode(pc)); } + void InstructionCacheOperationRaised(Dynarmic::A64::InstructionCacheOperation op, + VAddr value) override { + switch (op) { + case Dynarmic::A64::InstructionCacheOperation::InvalidateByVAToPoU: { + static constexpr u64 ICACHE_LINE_SIZE = 64; + + const u64 cache_line_start = value & ~(ICACHE_LINE_SIZE - 1); + parent.InvalidateCacheRange(cache_line_start, ICACHE_LINE_SIZE); + break; + } + case Dynarmic::A64::InstructionCacheOperation::InvalidateAllToPoU: + parent.ClearInstructionCache(); + break; + case Dynarmic::A64::InstructionCacheOperation::InvalidateAllToPoUInnerSharable: + default: + LOG_DEBUG(Core_ARM, "Unprocesseed instruction cache operation: {}", op); + break; + } + } + void ExceptionRaised(u64 pc, Dynarmic::A64::Exception exception) override { switch (exception) { case Dynarmic::A64::Exception::WaitForInterrupt: diff --git a/src/core/frontend/framebuffer_layout.cpp b/src/core/frontend/framebuffer_layout.cpp index 4b58b672a..26a5b12aa 100644 --- a/src/core/frontend/framebuffer_layout.cpp +++ b/src/core/frontend/framebuffer_layout.cpp @@ -25,7 +25,12 @@ FramebufferLayout DefaultFrameLayout(u32 width, u32 height) { ASSERT(height > 0); // The drawing code needs at least somewhat valid values for both screens // so just calculate them both even if the other isn't showing. - FramebufferLayout res{width, height, false, {}}; + FramebufferLayout res{ + .width = width, + .height = height, + .screen = {}, + .is_srgb = false, + }; const float window_aspect_ratio = static_cast<float>(height) / static_cast<float>(width); const float emulation_aspect_ratio = EmulationAspectRatio( diff --git a/src/core/frontend/framebuffer_layout.h b/src/core/frontend/framebuffer_layout.h index 2e36c0163..8e341e4e2 100644 --- a/src/core/frontend/framebuffer_layout.h +++ b/src/core/frontend/framebuffer_layout.h @@ -35,17 +35,8 @@ enum class AspectRatio { struct FramebufferLayout { u32 width{ScreenUndocked::Width}; u32 height{ScreenUndocked::Height}; - bool is_srgb{}; - Common::Rectangle<u32> screen; - - /** - * Returns the ration of pixel size of the screen, compared to the native size of the undocked - * Switch screen. - */ - float GetScalingRatio() const { - return static_cast<float>(screen.GetWidth()) / ScreenUndocked::Width; - } + bool is_srgb{}; }; /** diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index e42a6d36f..45e86a677 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -300,15 +300,16 @@ struct KernelCore::Impl { // Gets the dummy KThread for the caller, allocating a new one if this is the first time KThread* GetHostDummyThread() { auto make_thread = [this]() { - std::unique_ptr<KThread> thread = std::make_unique<KThread>(system.Kernel()); + std::lock_guard lk(dummy_thread_lock); + auto& thread = dummy_threads.emplace_back(std::make_unique<KThread>(system.Kernel())); KAutoObject::Create(thread.get()); ASSERT(KThread::InitializeDummyThread(thread.get()).IsSuccess()); thread->SetName(fmt::format("DummyThread:{}", GetHostThreadId())); - return thread; + return thread.get(); }; - thread_local auto thread = make_thread(); - return thread.get(); + thread_local KThread* saved_thread = make_thread(); + return saved_thread; } /// Registers a CPU core thread by allocating a host thread ID for it @@ -695,6 +696,12 @@ struct KernelCore::Impl { return port; } + std::mutex server_ports_lock; + std::mutex server_sessions_lock; + std::mutex registered_objects_lock; + std::mutex registered_in_use_objects_lock; + std::mutex dummy_thread_lock; + std::atomic<u32> next_object_id{0}; std::atomic<u64> next_kernel_process_id{KProcess::InitialKIPIDMin}; std::atomic<u64> next_user_process_id{KProcess::ProcessIDMin}; @@ -725,10 +732,6 @@ struct KernelCore::Impl { std::unordered_set<KServerSession*> server_sessions; std::unordered_set<KAutoObject*> registered_objects; std::unordered_set<KAutoObject*> registered_in_use_objects; - std::mutex server_ports_lock; - std::mutex server_sessions_lock; - std::mutex registered_objects_lock; - std::mutex registered_in_use_objects_lock; std::unique_ptr<Core::ExclusiveMonitor> exclusive_monitor; std::vector<Kernel::PhysicalCore> cores; @@ -753,6 +756,9 @@ struct KernelCore::Impl { std::array<Core::CPUInterruptHandler, Core::Hardware::NUM_CPU_CORES> interrupts{}; std::array<std::unique_ptr<Kernel::KScheduler>, Core::Hardware::NUM_CPU_CORES> schedulers{}; + // Specifically tracked to be automatically destroyed with kernel + std::vector<std::unique_ptr<KThread>> dummy_threads; + bool is_multicore{}; bool is_phantom_mode_for_singlecore{}; u32 single_core_thread_id{}; diff --git a/src/core/hle/service/pm/pm.cpp b/src/core/hle/service/pm/pm.cpp index 88fc5b5cc..277abc17a 100644 --- a/src/core/hle/service/pm/pm.cpp +++ b/src/core/hle/service/pm/pm.cpp @@ -13,7 +13,12 @@ namespace Service::PM { namespace { -constexpr ResultCode ERROR_PROCESS_NOT_FOUND{ErrorModule::PM, 1}; +constexpr ResultCode ResultProcessNotFound{ErrorModule::PM, 1}; +[[maybe_unused]] constexpr ResultCode ResultAlreadyStarted{ErrorModule::PM, 2}; +[[maybe_unused]] constexpr ResultCode ResultNotTerminated{ErrorModule::PM, 3}; +[[maybe_unused]] constexpr ResultCode ResultDebugHookInUse{ErrorModule::PM, 4}; +[[maybe_unused]] constexpr ResultCode ResultApplicationRunning{ErrorModule::PM, 5}; +[[maybe_unused]] constexpr ResultCode ResultInvalidSize{ErrorModule::PM, 6}; constexpr u64 NO_PROCESS_FOUND_PID{0}; @@ -95,18 +100,18 @@ public: private: void GetProcessId(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; - const auto title_id = rp.PopRaw<u64>(); + const auto program_id = rp.PopRaw<u64>(); - LOG_DEBUG(Service_PM, "called, title_id={:016X}", title_id); + LOG_DEBUG(Service_PM, "called, program_id={:016X}", program_id); const auto process = - SearchProcessList(kernel.GetProcessList(), [title_id](const auto& proc) { - return proc->GetProgramID() == title_id; + SearchProcessList(kernel.GetProcessList(), [program_id](const auto& proc) { + return proc->GetProgramID() == program_id; }); if (!process.has_value()) { IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERROR_PROCESS_NOT_FOUND); + rb.Push(ResultProcessNotFound); return; } @@ -128,13 +133,16 @@ public: explicit Info(Core::System& system_, const std::vector<Kernel::KProcess*>& process_list_) : ServiceFramework{system_, "pm:info"}, process_list{process_list_} { static const FunctionInfo functions[] = { - {0, &Info::GetTitleId, "GetTitleId"}, + {0, &Info::GetProgramId, "GetProgramId"}, + {65000, &Info::AtmosphereGetProcessId, "AtmosphereGetProcessId"}, + {65001, nullptr, "AtmosphereHasLaunchedProgram"}, + {65002, nullptr, "AtmosphereGetProcessInfo"}, }; RegisterHandlers(functions); } private: - void GetTitleId(Kernel::HLERequestContext& ctx) { + void GetProgramId(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto process_id = rp.PopRaw<u64>(); @@ -146,7 +154,7 @@ private: if (!process.has_value()) { IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERROR_PROCESS_NOT_FOUND); + rb.Push(ResultProcessNotFound); return; } @@ -155,6 +163,27 @@ private: rb.Push((*process)->GetProgramID()); } + void AtmosphereGetProcessId(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + const auto program_id = rp.PopRaw<u64>(); + + LOG_DEBUG(Service_PM, "called, program_id={:016X}", program_id); + + const auto process = SearchProcessList(process_list, [program_id](const auto& proc) { + return proc->GetProgramID() == program_id; + }); + + if (!process.has_value()) { + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultProcessNotFound); + return; + } + + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(ResultSuccess); + rb.Push((*process)->GetProcessID()); + } + const std::vector<Kernel::KProcess*>& process_list; }; diff --git a/src/video_core/renderer_vulkan/blit_image.cpp b/src/video_core/renderer_vulkan/blit_image.cpp index 28b631f73..a63d4d222 100644 --- a/src/video_core/renderer_vulkan/blit_image.cpp +++ b/src/video_core/renderer_vulkan/blit_image.cpp @@ -749,8 +749,9 @@ void BlitImageHelper::ConvertColorToDepthPipeline(vk::Pipeline& pipeline, VkRend }); } -void BlitImageHelper::ConvertPipelineColorTargetEx(vk::Pipeline& pipeline, VkRenderPass renderpass, - vk::ShaderModule& module, bool single_texture) { +void BlitImageHelper::ConvertPipelineEx(vk::Pipeline& pipeline, VkRenderPass renderpass, + vk::ShaderModule& module, bool is_target_depth, + bool single_texture) { if (pipeline) { return; } @@ -767,7 +768,7 @@ void BlitImageHelper::ConvertPipelineColorTargetEx(vk::Pipeline& pipeline, VkRen .pViewportState = &PIPELINE_VIEWPORT_STATE_CREATE_INFO, .pRasterizationState = &PIPELINE_RASTERIZATION_STATE_CREATE_INFO, .pMultisampleState = &PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, - .pDepthStencilState = nullptr, + .pDepthStencilState = is_target_depth ? &PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO : nullptr, .pColorBlendState = &PIPELINE_COLOR_BLEND_STATE_GENERIC_CREATE_INFO, .pDynamicState = &PIPELINE_DYNAMIC_STATE_CREATE_INFO, .layout = single_texture ? *one_texture_pipeline_layout : *two_textures_pipeline_layout, @@ -778,33 +779,14 @@ void BlitImageHelper::ConvertPipelineColorTargetEx(vk::Pipeline& pipeline, VkRen }); } +void BlitImageHelper::ConvertPipelineColorTargetEx(vk::Pipeline& pipeline, VkRenderPass renderpass, + vk::ShaderModule& module, bool single_texture) { + ConvertPipelineEx(pipeline, renderpass, module, false, single_texture); +} + void BlitImageHelper::ConvertPipelineDepthTargetEx(vk::Pipeline& pipeline, VkRenderPass renderpass, vk::ShaderModule& module, bool single_texture) { - if (pipeline) { - return; - } - const std::array stages = MakeStages(*full_screen_vert, *module); - pipeline = device.GetLogical().CreateGraphicsPipeline({ - .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, - .pNext = nullptr, - .flags = 0, - .stageCount = static_cast<u32>(stages.size()), - .pStages = stages.data(), - .pVertexInputState = &PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, - .pInputAssemblyState = &PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, - .pTessellationState = nullptr, - .pViewportState = &PIPELINE_VIEWPORT_STATE_CREATE_INFO, - .pRasterizationState = &PIPELINE_RASTERIZATION_STATE_CREATE_INFO, - .pMultisampleState = &PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, - .pDepthStencilState = &PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, - .pColorBlendState = &PIPELINE_COLOR_BLEND_STATE_EMPTY_CREATE_INFO, - .pDynamicState = &PIPELINE_DYNAMIC_STATE_CREATE_INFO, - .layout = single_texture ? *one_texture_pipeline_layout : *two_textures_pipeline_layout, - .renderPass = renderpass, - .subpass = 0, - .basePipelineHandle = VK_NULL_HANDLE, - .basePipelineIndex = 0, - }); + ConvertPipelineEx(pipeline, renderpass, module, true, single_texture); } } // namespace Vulkan diff --git a/src/video_core/renderer_vulkan/blit_image.h b/src/video_core/renderer_vulkan/blit_image.h index cec095341..3455c75f4 100644 --- a/src/video_core/renderer_vulkan/blit_image.h +++ b/src/video_core/renderer_vulkan/blit_image.h @@ -89,6 +89,9 @@ private: void ConvertColorToDepthPipeline(vk::Pipeline& pipeline, VkRenderPass renderpass); + void ConvertPipelineEx(vk::Pipeline& pipeline, VkRenderPass renderpass, + vk::ShaderModule& module, bool is_target_depth, bool single_texture); + void ConvertPipelineColorTargetEx(vk::Pipeline& pipeline, VkRenderPass renderpass, vk::ShaderModule& module, bool single_texture); diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 3964424af..c72f0c897 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp @@ -787,9 +787,9 @@ VkBuffer TextureCacheRuntime::GetTemporaryBuffer(size_t needed_size) { return *buffers[level]; } const auto new_size = Common::NextPow2(needed_size); - VkBufferUsageFlags flags = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | - VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT | - VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT; + static constexpr VkBufferUsageFlags flags = + VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | + VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT; buffers[level] = device.GetLogical().CreateBuffer({ .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, .pNext = nullptr, diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp index e852c817e..329bf4def 100644 --- a/src/video_core/video_core.cpp +++ b/src/video_core/video_core.cpp @@ -55,10 +55,4 @@ std::unique_ptr<Tegra::GPU> CreateGPU(Core::Frontend::EmuWindow& emu_window, Cor } } -float GetResolutionScaleFactor(const RendererBase& renderer) { - return Settings::values.resolution_info.active - ? Settings::values.resolution_info.up_factor - : renderer.GetRenderWindow().GetFramebufferLayout().GetScalingRatio(); -} - } // namespace VideoCore diff --git a/src/video_core/video_core.h b/src/video_core/video_core.h index f86877e86..084df641f 100644 --- a/src/video_core/video_core.h +++ b/src/video_core/video_core.h @@ -25,6 +25,4 @@ class RendererBase; /// Creates an emulated GPU instance using the given system context. std::unique_ptr<Tegra::GPU> CreateGPU(Core::Frontend::EmuWindow& emu_window, Core::System& system); -float GetResolutionScaleFactor(const RendererBase& renderer); - } // namespace VideoCore diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 976acd176..fd0a130a3 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -303,6 +303,7 @@ GRenderWindow::GRenderWindow(GMainWindow* parent, EmuThread* emu_thread_, connect(this, &GRenderWindow::ExecuteProgramSignal, parent, &GMainWindow::OnExecuteProgram, Qt::QueuedConnection); connect(this, &GRenderWindow::ExitSignal, parent, &GMainWindow::OnExit, Qt::QueuedConnection); + connect(this, &GRenderWindow::TasPlaybackStateChanged, parent, &GMainWindow::OnTasStateChanged); } void GRenderWindow::ExecuteProgram(std::size_t program_index) { @@ -319,10 +320,18 @@ GRenderWindow::~GRenderWindow() { void GRenderWindow::OnFrameDisplayed() { input_subsystem->GetTas()->UpdateThread(); + const TasInput::TasState new_tas_state = std::get<0>(input_subsystem->GetTas()->GetStatus()); + if (!first_frame) { + last_tas_state = new_tas_state; first_frame = true; emit FirstFrameDisplayed(); } + + if (new_tas_state != last_tas_state) { + last_tas_state = new_tas_state; + emit TasPlaybackStateChanged(); + } } bool GRenderWindow::IsShown() const { @@ -630,7 +639,7 @@ void GRenderWindow::ReleaseRenderTarget() { void GRenderWindow::CaptureScreenshot(const QString& screenshot_path) { auto& renderer = system.Renderer(); - const f32 res_scale = VideoCore::GetResolutionScaleFactor(renderer); + const f32 res_scale = Settings::values.resolution_info.up_factor; const Layout::FramebufferLayout layout{Layout::FrameLayoutFromResolutionScale(res_scale)}; screenshot_image = QImage(QSize(layout.width, layout.height), QImage::Format_RGB32); diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h index 40fd4a9d6..061e3605f 100644 --- a/src/yuzu/bootmanager.h +++ b/src/yuzu/bootmanager.h @@ -41,6 +41,10 @@ enum class LoadCallbackStage; class RendererBase; } // namespace VideoCore +namespace TasInput { +enum class TasState; +} + class EmuThread final : public QThread { Q_OBJECT @@ -203,6 +207,7 @@ signals: void ExecuteProgramSignal(std::size_t program_index); void ExitSignal(); void MouseActivity(); + void TasPlaybackStateChanged(); private: void TouchBeginEvent(const QTouchEvent* event); @@ -236,6 +241,7 @@ private: QWidget* child_widget = nullptr; bool first_frame = false; + TasInput::TasState last_tas_state; std::array<std::size_t, 16> touch_ids{}; diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index c4c76b094..5058c3e4e 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -965,6 +965,9 @@ void GMainWindow::InitializeHotkeys() { const QString toggle_status_bar = QStringLiteral("Toggle Status Bar"); const QString fullscreen = QStringLiteral("Fullscreen"); const QString capture_screenshot = QStringLiteral("Capture Screenshot"); + const QString tas_start_stop = QStringLiteral("TAS Start/Stop"); + const QString tas_record = QStringLiteral("TAS Record"); + const QString tas_reset = QStringLiteral("TAS Reset"); ui->action_Load_File->setShortcut(hotkey_registry.GetKeySequence(main_window, load_file)); ui->action_Load_File->setShortcutContext( @@ -1005,6 +1008,18 @@ void GMainWindow::InitializeHotkeys() { ui->action_Fullscreen->setShortcutContext( hotkey_registry.GetShortcutContext(main_window, fullscreen)); + ui->action_TAS_Start->setShortcut(hotkey_registry.GetKeySequence(main_window, tas_start_stop)); + ui->action_TAS_Start->setShortcutContext( + hotkey_registry.GetShortcutContext(main_window, tas_start_stop)); + + ui->action_TAS_Record->setShortcut(hotkey_registry.GetKeySequence(main_window, tas_record)); + ui->action_TAS_Record->setShortcutContext( + hotkey_registry.GetShortcutContext(main_window, tas_record)); + + ui->action_TAS_Reset->setShortcut(hotkey_registry.GetKeySequence(main_window, tas_reset)); + ui->action_TAS_Reset->setShortcutContext( + hotkey_registry.GetShortcutContext(main_window, tas_reset)); + connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Load File"), this), &QShortcut::activated, this, &GMainWindow::OnMenuLoadFile); connect( @@ -1095,28 +1110,6 @@ void GMainWindow::InitializeHotkeys() { render_window->setAttribute(Qt::WA_Hover, true); } }); - connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("TAS Start/Stop"), this), - &QShortcut::activated, this, [&] { - if (!emulation_running) { - return; - } - input_subsystem->GetTas()->StartStop(); - }); - connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("TAS Reset"), this), - &QShortcut::activated, this, [&] { input_subsystem->GetTas()->Reset(); }); - connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("TAS Record"), this), - &QShortcut::activated, this, [&] { - if (!emulation_running) { - return; - } - bool is_recording = input_subsystem->GetTas()->Record(); - if (!is_recording) { - const auto res = QMessageBox::question(this, tr("TAS Recording"), - tr("Overwrite file of player 1?"), - QMessageBox::Yes | QMessageBox::No); - input_subsystem->GetTas()->SaveRecording(res == QMessageBox::Yes); - } - }); } void GMainWindow::SetDefaultUIGeometry() { @@ -1236,11 +1229,11 @@ void GMainWindow::ConnectMenuEvents() { connect(ui->action_Restart, &QAction::triggered, this, [this] { BootGame(QString(game_path)); }); connect(ui->action_Configure, &QAction::triggered, this, &GMainWindow::OnConfigure); - connect(ui->action_Configure_Tas, &QAction::triggered, this, &GMainWindow::OnConfigureTas); connect(ui->action_Configure_Current_Game, &QAction::triggered, this, &GMainWindow::OnConfigurePerGame); // View + connect(ui->action_Fullscreen, &QAction::triggered, this, &GMainWindow::ToggleFullscreen); connect(ui->action_Single_Window_Mode, &QAction::triggered, this, &GMainWindow::ToggleWindowMode); connect(ui->action_Display_Dock_Widget_Headers, &QAction::triggered, this, @@ -1258,17 +1251,20 @@ void GMainWindow::ConnectMenuEvents() { ui->menu_Reset_Window_Size->addAction(ui->action_Reset_Window_Size_900); ui->menu_Reset_Window_Size->addAction(ui->action_Reset_Window_Size_1080); - // Fullscreen - connect(ui->action_Fullscreen, &QAction::triggered, this, &GMainWindow::ToggleFullscreen); - - // Movie + // Tools + connect(ui->action_Rederive, &QAction::triggered, this, + std::bind(&GMainWindow::OnReinitializeKeys, this, ReinitializeKeyBehavior::Warning)); connect(ui->action_Capture_Screenshot, &QAction::triggered, this, &GMainWindow::OnCaptureScreenshot); + // TAS + connect(ui->action_TAS_Start, &QAction::triggered, this, &GMainWindow::OnTasStartStop); + connect(ui->action_TAS_Record, &QAction::triggered, this, &GMainWindow::OnTasRecord); + connect(ui->action_TAS_Reset, &QAction::triggered, this, &GMainWindow::OnTasReset); + connect(ui->action_Configure_Tas, &QAction::triggered, this, &GMainWindow::OnConfigureTas); + // Help connect(ui->action_Open_yuzu_Folder, &QAction::triggered, this, &GMainWindow::OnOpenYuzuFolder); - connect(ui->action_Rederive, &QAction::triggered, this, - std::bind(&GMainWindow::OnReinitializeKeys, this, ReinitializeKeyBehavior::Warning)); connect(ui->action_About, &QAction::triggered, this, &GMainWindow::OnAbout); } @@ -1582,6 +1578,7 @@ void GMainWindow::ShutdownGame() { game_list->SetFilterFocus(); tas_label->clear(); input_subsystem->GetTas()->Stop(); + OnTasStateChanged(); render_window->removeEventFilter(render_window); render_window->setAttribute(Qt::WA_Hover, false); @@ -2509,6 +2506,7 @@ void GMainWindow::OnStartGame() { ui->action_Restart->setEnabled(true); ui->action_Configure_Current_Game->setEnabled(true); ui->action_Report_Compatibility->setEnabled(true); + OnTasStateChanged(); discord_rpc->Update(); ui->action_Load_Amiibo->setEnabled(true); @@ -2821,6 +2819,32 @@ void GMainWindow::OnConfigureTas() { } } +void GMainWindow::OnTasStartStop() { + if (!emulation_running) { + return; + } + input_subsystem->GetTas()->StartStop(); + OnTasStateChanged(); +} + +void GMainWindow::OnTasRecord() { + if (!emulation_running) { + return; + } + const bool is_recording = input_subsystem->GetTas()->Record(); + if (!is_recording) { + const auto res = + QMessageBox::question(this, tr("TAS Recording"), tr("Overwrite file of player 1?"), + QMessageBox::Yes | QMessageBox::No); + input_subsystem->GetTas()->SaveRecording(res == QMessageBox::Yes); + } + OnTasStateChanged(); +} + +void GMainWindow::OnTasReset() { + input_subsystem->GetTas()->Reset(); +} + void GMainWindow::OnConfigurePerGame() { const u64 title_id = system->GetCurrentProcessProgramID(); OpenPerGameConfiguration(title_id, game_path.toStdString()); @@ -3014,6 +3038,23 @@ QString GMainWindow::GetTasStateDescription() const { } } +void GMainWindow::OnTasStateChanged() { + bool is_running = false; + bool is_recording = false; + if (emulation_running) { + const TasInput::TasState tas_status = std::get<0>(input_subsystem->GetTas()->GetStatus()); + is_running = tas_status == TasInput::TasState::Running; + is_recording = tas_status == TasInput::TasState::Recording; + } + + ui->action_TAS_Start->setText(is_running ? tr("&Stop Running") : tr("&Start")); + ui->action_TAS_Record->setText(is_recording ? tr("Stop R&ecording") : tr("R&ecord")); + + ui->action_TAS_Start->setEnabled(emulation_running); + ui->action_TAS_Record->setEnabled(emulation_running); + ui->action_TAS_Reset->setEnabled(emulation_running); +} + void GMainWindow::UpdateStatusBar() { if (emu_thread == nullptr) { status_bar_update_timer.stop(); diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 24633ff2d..556cbbaf7 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h @@ -177,6 +177,7 @@ public slots: void WebBrowserOpenWebPage(const std::string& main_url, const std::string& additional_args, bool is_local); void OnAppFocusStateChanged(Qt::ApplicationState state); + void OnTasStateChanged(); private: void RegisterMetaTypes(); @@ -268,6 +269,9 @@ private slots: void OnMenuRecentFile(); void OnConfigure(); void OnConfigureTas(); + void OnTasStartStop(); + void OnTasRecord(); + void OnTasReset(); void OnConfigurePerGame(); void OnLoadAmiibo(); void OnOpenYuzuFolder(); @@ -313,6 +317,7 @@ private: void OpenURL(const QUrl& url); void LoadTranslation(); void OpenPerGameConfiguration(u64 title_id, const std::string& file_name); + QString GetTasStateDescription() const; std::unique_ptr<Ui::MainWindow> ui; diff --git a/src/yuzu/main.ui b/src/yuzu/main.ui index a62e39a06..c58aa2866 100644 --- a/src/yuzu/main.ui +++ b/src/yuzu/main.ui @@ -79,39 +79,39 @@ <string>&View</string> </property> <widget class="QMenu" name="menu_Reset_Window_Size"> - <property name="title"> - <string>&Reset Window Size</string> - </property> + <property name="title"> + <string>&Reset Window Size</string> + </property> + </widget> + <widget class="QMenu" name="menu_View_Debugging"> + <property name="title"> + <string>&Debugging</string> + </property> </widget> <action name="action_Reset_Window_Size_720"> - <property name="text"> - <string>Reset Window Size to &720p</string> - </property> - <property name="iconText"> - <string>Reset Window Size to 720p</string> - </property> + <property name="text"> + <string>Reset Window Size to &720p</string> + </property> + <property name="iconText"> + <string>Reset Window Size to 720p</string> + </property> </action> <action name="action_Reset_Window_Size_900"> - <property name="text"> - <string>Reset Window Size to &900p</string> - </property> - <property name="iconText"> - <string>Reset Window Size to 900p</string> - </property> + <property name="text"> + <string>Reset Window Size to &900p</string> + </property> + <property name="iconText"> + <string>Reset Window Size to 900p</string> + </property> </action> <action name="action_Reset_Window_Size_1080"> - <property name="text"> - <string>Reset Window Size to &1080p</string> - </property> - <property name="iconText"> - <string>Reset Window Size to 1080p</string> - </property> - </action> - <widget class="QMenu" name="menu_View_Debugging"> - <property name="title"> - <string>&Debugging</string> + <property name="text"> + <string>Reset Window Size to &1080p</string> </property> - </widget> + <property name="iconText"> + <string>Reset Window Size to 1080p</string> + </property> + </action> <addaction name="action_Fullscreen"/> <addaction name="action_Single_Window_Mode"/> <addaction name="action_Display_Dock_Widget_Headers"/> @@ -125,10 +125,20 @@ <property name="title"> <string>&Tools</string> </property> + <widget class="QMenu" name="menuTAS"> + <property name="title"> + <string>&TAS</string> + </property> + <addaction name="action_TAS_Start"/> + <addaction name="action_TAS_Record"/> + <addaction name="action_TAS_Reset"/> + <addaction name="separator"/> + <addaction name="action_Configure_Tas"/> + </widget> <addaction name="action_Rederive"/> <addaction name="separator"/> <addaction name="action_Capture_Screenshot"/> - <addaction name="action_Configure_Tas"/> + <addaction name="menuTAS"/> </widget> <widget class="QMenu" name="menu_Help"> <property name="title"> @@ -309,7 +319,7 @@ </action> <action name="action_Configure_Tas"> <property name="text"> - <string>Configure &TAS...</string> + <string>&Configure TAS...</string> </property> </action> <action name="action_Configure_Current_Game"> @@ -320,6 +330,30 @@ <string>Configure C&urrent Game...</string> </property> </action> + <action name="action_TAS_Start"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>&Start</string> + </property> + </action> + <action name="action_TAS_Reset"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>&Reset</string> + </property> + </action> + <action name="action_TAS_Record"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>R&ecord</string> + </property> + </action> </widget> <resources> <include location="yuzu.qrc"/> |