Merge pull request #9505 from liamwhite/request-exit
applets: implement RequestExit
This commit is contained in:
commit
8bdc51b620
48 changed files with 312 additions and 61 deletions
14
src/core/frontend/applets/applet.h
Normal file
14
src/core/frontend/applets/applet.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Core::Frontend {
|
||||
|
||||
class Applet {
|
||||
public:
|
||||
virtual ~Applet() = default;
|
||||
virtual void Close() const = 0;
|
||||
};
|
||||
|
||||
} // namespace Core::Frontend
|
|
@ -10,6 +10,8 @@ namespace Core::Frontend {
|
|||
|
||||
CabinetApplet::~CabinetApplet() = default;
|
||||
|
||||
void DefaultCabinetApplet::Close() const {}
|
||||
|
||||
void DefaultCabinetApplet::ShowCabinetApplet(
|
||||
const CabinetCallback& callback, const CabinetParameters& parameters,
|
||||
std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include "core/frontend/applets/applet.h"
|
||||
#include "core/hle/service/nfp/nfp_types.h"
|
||||
|
||||
namespace Service::NFP {
|
||||
|
@ -20,7 +21,7 @@ struct CabinetParameters {
|
|||
|
||||
using CabinetCallback = std::function<void(bool, const std::string&)>;
|
||||
|
||||
class CabinetApplet {
|
||||
class CabinetApplet : public Applet {
|
||||
public:
|
||||
virtual ~CabinetApplet();
|
||||
virtual void ShowCabinetApplet(const CabinetCallback& callback,
|
||||
|
@ -30,6 +31,7 @@ public:
|
|||
|
||||
class DefaultCabinetApplet final : public CabinetApplet {
|
||||
public:
|
||||
void Close() const override;
|
||||
void ShowCabinetApplet(const CabinetCallback& callback, const CabinetParameters& parameters,
|
||||
std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const override;
|
||||
};
|
||||
|
|
|
@ -16,6 +16,8 @@ DefaultControllerApplet::DefaultControllerApplet(HID::HIDCore& hid_core_) : hid_
|
|||
|
||||
DefaultControllerApplet::~DefaultControllerApplet() = default;
|
||||
|
||||
void DefaultControllerApplet::Close() const {}
|
||||
|
||||
void DefaultControllerApplet::ReconfigureControllers(ReconfigureCallback callback,
|
||||
const ControllerParameters& parameters) const {
|
||||
LOG_INFO(Service_HID, "called, deducing the best configuration based on the given parameters!");
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "core/frontend/applets/applet.h"
|
||||
|
||||
namespace Core::HID {
|
||||
class HIDCore;
|
||||
|
@ -34,7 +35,7 @@ struct ControllerParameters {
|
|||
bool allow_gamecube_controller{};
|
||||
};
|
||||
|
||||
class ControllerApplet {
|
||||
class ControllerApplet : public Applet {
|
||||
public:
|
||||
using ReconfigureCallback = std::function<void()>;
|
||||
|
||||
|
@ -49,6 +50,7 @@ public:
|
|||
explicit DefaultControllerApplet(HID::HIDCore& hid_core_);
|
||||
~DefaultControllerApplet() override;
|
||||
|
||||
void Close() const override;
|
||||
void ReconfigureControllers(ReconfigureCallback callback,
|
||||
const ControllerParameters& parameters) const override;
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@ namespace Core::Frontend {
|
|||
|
||||
ErrorApplet::~ErrorApplet() = default;
|
||||
|
||||
void DefaultErrorApplet::Close() const {}
|
||||
|
||||
void DefaultErrorApplet::ShowError(Result error, FinishedCallback finished) const {
|
||||
LOG_CRITICAL(Service_Fatal, "Application requested error display: {:04}-{:04} (raw={:08X})",
|
||||
error.module.Value(), error.description.Value(), error.raw);
|
||||
|
|
|
@ -6,11 +6,12 @@
|
|||
#include <chrono>
|
||||
#include <functional>
|
||||
|
||||
#include "core/frontend/applets/applet.h"
|
||||
#include "core/hle/result.h"
|
||||
|
||||
namespace Core::Frontend {
|
||||
|
||||
class ErrorApplet {
|
||||
class ErrorApplet : public Applet {
|
||||
public:
|
||||
using FinishedCallback = std::function<void()>;
|
||||
|
||||
|
@ -28,6 +29,7 @@ public:
|
|||
|
||||
class DefaultErrorApplet final : public ErrorApplet {
|
||||
public:
|
||||
void Close() const override;
|
||||
void ShowError(Result error, FinishedCallback finished) const override;
|
||||
void ShowErrorWithTimestamp(Result error, std::chrono::seconds time,
|
||||
FinishedCallback finished) const override;
|
||||
|
|
|
@ -10,6 +10,8 @@ ParentalControlsApplet::~ParentalControlsApplet() = default;
|
|||
|
||||
DefaultParentalControlsApplet::~DefaultParentalControlsApplet() = default;
|
||||
|
||||
void DefaultParentalControlsApplet::Close() const {}
|
||||
|
||||
void DefaultParentalControlsApplet::VerifyPIN(std::function<void(bool)> finished,
|
||||
bool suspend_future_verification_temporarily) {
|
||||
LOG_INFO(Service_AM,
|
||||
|
@ -39,6 +41,8 @@ PhotoViewerApplet::~PhotoViewerApplet() = default;
|
|||
|
||||
DefaultPhotoViewerApplet::~DefaultPhotoViewerApplet() = default;
|
||||
|
||||
void DefaultPhotoViewerApplet::Close() const {}
|
||||
|
||||
void DefaultPhotoViewerApplet::ShowPhotosForApplication(u64 title_id,
|
||||
std::function<void()> finished) const {
|
||||
LOG_INFO(Service_AM,
|
||||
|
|
|
@ -6,9 +6,11 @@
|
|||
#include <functional>
|
||||
#include "common/common_types.h"
|
||||
|
||||
#include "core/frontend/applets/applet.h"
|
||||
|
||||
namespace Core::Frontend {
|
||||
|
||||
class ParentalControlsApplet {
|
||||
class ParentalControlsApplet : public Applet {
|
||||
public:
|
||||
virtual ~ParentalControlsApplet();
|
||||
|
||||
|
@ -33,6 +35,7 @@ class DefaultParentalControlsApplet final : public ParentalControlsApplet {
|
|||
public:
|
||||
~DefaultParentalControlsApplet() override;
|
||||
|
||||
void Close() const override;
|
||||
void VerifyPIN(std::function<void(bool)> finished,
|
||||
bool suspend_future_verification_temporarily) override;
|
||||
void VerifyPINForSettings(std::function<void(bool)> finished) override;
|
||||
|
@ -40,7 +43,7 @@ public:
|
|||
void ChangePIN(std::function<void()> finished) override;
|
||||
};
|
||||
|
||||
class PhotoViewerApplet {
|
||||
class PhotoViewerApplet : public Applet {
|
||||
public:
|
||||
virtual ~PhotoViewerApplet();
|
||||
|
||||
|
@ -52,6 +55,7 @@ class DefaultPhotoViewerApplet final : public PhotoViewerApplet {
|
|||
public:
|
||||
~DefaultPhotoViewerApplet() override;
|
||||
|
||||
void Close() const override;
|
||||
void ShowPhotosForApplication(u64 title_id, std::function<void()> finished) const override;
|
||||
void ShowAllPhotos(std::function<void()> finished) const override;
|
||||
};
|
||||
|
|
|
@ -8,6 +8,8 @@ namespace Core::Frontend {
|
|||
|
||||
MiiEditApplet::~MiiEditApplet() = default;
|
||||
|
||||
void DefaultMiiEditApplet::Close() const {}
|
||||
|
||||
void DefaultMiiEditApplet::ShowMiiEdit(const MiiEditCallback& callback) const {
|
||||
LOG_WARNING(Service_AM, "(STUBBED) called");
|
||||
|
||||
|
|
|
@ -5,9 +5,11 @@
|
|||
|
||||
#include <functional>
|
||||
|
||||
#include "core/frontend/applets/applet.h"
|
||||
|
||||
namespace Core::Frontend {
|
||||
|
||||
class MiiEditApplet {
|
||||
class MiiEditApplet : public Applet {
|
||||
public:
|
||||
using MiiEditCallback = std::function<void()>;
|
||||
|
||||
|
@ -18,6 +20,7 @@ public:
|
|||
|
||||
class DefaultMiiEditApplet final : public MiiEditApplet {
|
||||
public:
|
||||
void Close() const override;
|
||||
void ShowMiiEdit(const MiiEditCallback& callback) const override;
|
||||
};
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ namespace Core::Frontend {
|
|||
|
||||
ProfileSelectApplet::~ProfileSelectApplet() = default;
|
||||
|
||||
void DefaultProfileSelectApplet::Close() const {}
|
||||
|
||||
void DefaultProfileSelectApplet::SelectProfile(SelectProfileCallback callback) const {
|
||||
Service::Account::ProfileManager manager;
|
||||
callback(manager.GetUser(Settings::values.current_user.GetValue()).value_or(Common::UUID{}));
|
||||
|
|
|
@ -7,9 +7,11 @@
|
|||
#include <optional>
|
||||
#include "common/uuid.h"
|
||||
|
||||
#include "core/frontend/applets/applet.h"
|
||||
|
||||
namespace Core::Frontend {
|
||||
|
||||
class ProfileSelectApplet {
|
||||
class ProfileSelectApplet : public Applet {
|
||||
public:
|
||||
using SelectProfileCallback = std::function<void(std::optional<Common::UUID>)>;
|
||||
|
||||
|
@ -20,6 +22,7 @@ public:
|
|||
|
||||
class DefaultProfileSelectApplet final : public ProfileSelectApplet {
|
||||
public:
|
||||
void Close() const override;
|
||||
void SelectProfile(SelectProfileCallback callback) const override;
|
||||
};
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@ SoftwareKeyboardApplet::~SoftwareKeyboardApplet() = default;
|
|||
|
||||
DefaultSoftwareKeyboardApplet::~DefaultSoftwareKeyboardApplet() = default;
|
||||
|
||||
void DefaultSoftwareKeyboardApplet::Close() const {}
|
||||
|
||||
void DefaultSoftwareKeyboardApplet::InitializeKeyboard(
|
||||
bool is_inline, KeyboardInitializeParameters initialize_parameters,
|
||||
SubmitNormalCallback submit_normal_callback_, SubmitInlineCallback submit_inline_callback_) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "common/common_types.h"
|
||||
|
||||
#include "core/frontend/applets/applet.h"
|
||||
#include "core/hle/service/am/applets/applet_software_keyboard_types.h"
|
||||
|
||||
namespace Core::Frontend {
|
||||
|
@ -52,7 +53,7 @@ struct InlineTextParameters {
|
|||
s32 cursor_position;
|
||||
};
|
||||
|
||||
class SoftwareKeyboardApplet {
|
||||
class SoftwareKeyboardApplet : public Applet {
|
||||
public:
|
||||
using SubmitInlineCallback =
|
||||
std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)>;
|
||||
|
@ -84,6 +85,8 @@ class DefaultSoftwareKeyboardApplet final : public SoftwareKeyboardApplet {
|
|||
public:
|
||||
~DefaultSoftwareKeyboardApplet() override;
|
||||
|
||||
void Close() const override;
|
||||
|
||||
void InitializeKeyboard(bool is_inline, KeyboardInitializeParameters initialize_parameters,
|
||||
SubmitNormalCallback submit_normal_callback_,
|
||||
SubmitInlineCallback submit_inline_callback_) override;
|
||||
|
|
|
@ -10,6 +10,8 @@ WebBrowserApplet::~WebBrowserApplet() = default;
|
|||
|
||||
DefaultWebBrowserApplet::~DefaultWebBrowserApplet() = default;
|
||||
|
||||
void DefaultWebBrowserApplet::Close() const {}
|
||||
|
||||
void DefaultWebBrowserApplet::OpenLocalWebPage(const std::string& local_url,
|
||||
ExtractROMFSCallback extract_romfs_callback,
|
||||
OpenWebPageCallback callback) const {
|
||||
|
|
|
@ -5,11 +5,12 @@
|
|||
|
||||
#include <functional>
|
||||
|
||||
#include "core/frontend/applets/applet.h"
|
||||
#include "core/hle/service/am/applets/applet_web_browser_types.h"
|
||||
|
||||
namespace Core::Frontend {
|
||||
|
||||
class WebBrowserApplet {
|
||||
class WebBrowserApplet : public Applet {
|
||||
public:
|
||||
using ExtractROMFSCallback = std::function<void()>;
|
||||
using OpenWebPageCallback =
|
||||
|
@ -29,6 +30,8 @@ class DefaultWebBrowserApplet final : public WebBrowserApplet {
|
|||
public:
|
||||
~DefaultWebBrowserApplet() override;
|
||||
|
||||
void Close() const override;
|
||||
|
||||
void OpenLocalWebPage(const std::string& local_url, ExtractROMFSCallback extract_romfs_callback,
|
||||
OpenWebPageCallback callback) const override;
|
||||
|
||||
|
|
|
@ -945,7 +945,7 @@ public:
|
|||
{0, &ILibraryAppletAccessor::GetAppletStateChangedEvent, "GetAppletStateChangedEvent"},
|
||||
{1, &ILibraryAppletAccessor::IsCompleted, "IsCompleted"},
|
||||
{10, &ILibraryAppletAccessor::Start, "Start"},
|
||||
{20, nullptr, "RequestExit"},
|
||||
{20, &ILibraryAppletAccessor::RequestExit, "RequestExit"},
|
||||
{25, nullptr, "Terminate"},
|
||||
{30, &ILibraryAppletAccessor::GetResult, "GetResult"},
|
||||
{50, nullptr, "SetOutOfFocusApplicationSuspendingEnabled"},
|
||||
|
@ -1010,6 +1010,15 @@ private:
|
|||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void RequestExit(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_AM, "called");
|
||||
|
||||
ASSERT(applet != nullptr);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(applet->RequestExit());
|
||||
}
|
||||
|
||||
void PushInData(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_AM, "called");
|
||||
|
||||
|
|
|
@ -174,4 +174,9 @@ void Cabinet::Cancel() {
|
|||
broker.SignalStateChanged();
|
||||
}
|
||||
|
||||
Result Cabinet::RequestExit() {
|
||||
frontend.Close();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
} // namespace Service::AM::Applets
|
||||
|
|
|
@ -89,6 +89,7 @@ public:
|
|||
void Execute() override;
|
||||
void DisplayCompleted(bool apply_changes, std::string_view amiibo_name);
|
||||
void Cancel();
|
||||
Result RequestExit() override;
|
||||
|
||||
private:
|
||||
const Core::Frontend::CabinetApplet& frontend;
|
||||
|
|
|
@ -262,4 +262,9 @@ void Controller::ConfigurationComplete() {
|
|||
broker.SignalStateChanged();
|
||||
}
|
||||
|
||||
Result Controller::RequestExit() {
|
||||
frontend.Close();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
} // namespace Service::AM::Applets
|
||||
|
|
|
@ -129,6 +129,7 @@ public:
|
|||
Result GetStatus() const override;
|
||||
void ExecuteInteractive() override;
|
||||
void Execute() override;
|
||||
Result RequestExit() override;
|
||||
|
||||
void ConfigurationComplete();
|
||||
|
||||
|
|
|
@ -209,4 +209,9 @@ void Error::DisplayCompleted() {
|
|||
broker.SignalStateChanged();
|
||||
}
|
||||
|
||||
Result Error::RequestExit() {
|
||||
frontend.Close();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
} // namespace Service::AM::Applets
|
||||
|
|
|
@ -34,6 +34,7 @@ public:
|
|||
Result GetStatus() const override;
|
||||
void ExecuteInteractive() override;
|
||||
void Execute() override;
|
||||
Result RequestExit() override;
|
||||
|
||||
void DisplayCompleted();
|
||||
|
||||
|
|
|
@ -150,6 +150,11 @@ void Auth::AuthFinished(bool is_successful) {
|
|||
broker.SignalStateChanged();
|
||||
}
|
||||
|
||||
Result Auth::RequestExit() {
|
||||
frontend.Close();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
PhotoViewer::PhotoViewer(Core::System& system_, LibraryAppletMode applet_mode_,
|
||||
const Core::Frontend::PhotoViewerApplet& frontend_)
|
||||
: Applet{system_, applet_mode_}, frontend{frontend_}, system{system_} {}
|
||||
|
@ -202,6 +207,11 @@ void PhotoViewer::ViewFinished() {
|
|||
broker.SignalStateChanged();
|
||||
}
|
||||
|
||||
Result PhotoViewer::RequestExit() {
|
||||
frontend.Close();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
StubApplet::StubApplet(Core::System& system_, AppletId id_, LibraryAppletMode applet_mode_)
|
||||
: Applet{system_, applet_mode_}, id{id_}, system{system_} {}
|
||||
|
||||
|
@ -250,4 +260,9 @@ void StubApplet::Execute() {
|
|||
broker.SignalStateChanged();
|
||||
}
|
||||
|
||||
Result StubApplet::RequestExit() {
|
||||
// Nothing to do.
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
} // namespace Service::AM::Applets
|
||||
|
|
|
@ -28,6 +28,7 @@ public:
|
|||
Result GetStatus() const override;
|
||||
void ExecuteInteractive() override;
|
||||
void Execute() override;
|
||||
Result RequestExit() override;
|
||||
|
||||
void AuthFinished(bool is_successful = true);
|
||||
|
||||
|
@ -59,6 +60,7 @@ public:
|
|||
Result GetStatus() const override;
|
||||
void ExecuteInteractive() override;
|
||||
void Execute() override;
|
||||
Result RequestExit() override;
|
||||
|
||||
void ViewFinished();
|
||||
|
||||
|
@ -80,6 +82,7 @@ public:
|
|||
Result GetStatus() const override;
|
||||
void ExecuteInteractive() override;
|
||||
void Execute() override;
|
||||
Result RequestExit() override;
|
||||
|
||||
private:
|
||||
AppletId id;
|
||||
|
|
|
@ -135,4 +135,9 @@ void MiiEdit::MiiEditOutputForCharInfoEditing(MiiEditResult result,
|
|||
broker.SignalStateChanged();
|
||||
}
|
||||
|
||||
Result MiiEdit::RequestExit() {
|
||||
frontend.Close();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
} // namespace Service::AM::Applets
|
||||
|
|
|
@ -25,6 +25,7 @@ public:
|
|||
Result GetStatus() const override;
|
||||
void ExecuteInteractive() override;
|
||||
void Execute() override;
|
||||
Result RequestExit() override;
|
||||
|
||||
void MiiEditOutput(MiiEditResult result, s32 index);
|
||||
|
||||
|
|
|
@ -73,4 +73,9 @@ void ProfileSelect::SelectionComplete(std::optional<Common::UUID> uuid) {
|
|||
broker.SignalStateChanged();
|
||||
}
|
||||
|
||||
Result ProfileSelect::RequestExit() {
|
||||
frontend.Close();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
} // namespace Service::AM::Applets
|
||||
|
|
|
@ -42,6 +42,7 @@ public:
|
|||
Result GetStatus() const override;
|
||||
void ExecuteInteractive() override;
|
||||
void Execute() override;
|
||||
Result RequestExit() override;
|
||||
|
||||
void SelectionComplete(std::optional<Common::UUID> uuid);
|
||||
|
||||
|
|
|
@ -770,6 +770,11 @@ void SoftwareKeyboard::ExitKeyboard() {
|
|||
broker.SignalStateChanged();
|
||||
}
|
||||
|
||||
Result SoftwareKeyboard::RequestExit() {
|
||||
frontend.Close();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
// Inline Software Keyboard Requests
|
||||
|
||||
void SoftwareKeyboard::RequestFinalize(const std::vector<u8>& request_data) {
|
||||
|
|
|
@ -31,6 +31,7 @@ public:
|
|||
Result GetStatus() const override;
|
||||
void ExecuteInteractive() override;
|
||||
void Execute() override;
|
||||
Result RequestExit() override;
|
||||
|
||||
/**
|
||||
* Submits the input text to the application.
|
||||
|
|
|
@ -363,6 +363,11 @@ void WebBrowser::WebBrowserExit(WebExitReason exit_reason, std::string last_url)
|
|||
broker.SignalStateChanged();
|
||||
}
|
||||
|
||||
Result WebBrowser::RequestExit() {
|
||||
frontend.Close();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
bool WebBrowser::InputTLVExistsInMap(WebArgInputTLVType input_tlv_type) const {
|
||||
return web_arg_input_tlv_map.find(input_tlv_type) != web_arg_input_tlv_map.end();
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ public:
|
|||
Result GetStatus() const override;
|
||||
void ExecuteInteractive() override;
|
||||
void Execute() override;
|
||||
Result RequestExit() override;
|
||||
|
||||
void ExtractOfflineRomFS();
|
||||
|
||||
|
|
|
@ -142,6 +142,7 @@ public:
|
|||
virtual Result GetStatus() const = 0;
|
||||
virtual void ExecuteInteractive() = 0;
|
||||
virtual void Execute() = 0;
|
||||
virtual Result RequestExit() = 0;
|
||||
|
||||
AppletDataBroker& GetBroker() {
|
||||
return broker;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue