diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/am/applets/general_backend.cpp (renamed from src/core/hle/service/am/applets/stub_applet.cpp) | 55 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/general_backend.h | 48 |
2 files changed, 102 insertions, 1 deletions
diff --git a/src/core/hle/service/am/applets/stub_applet.cpp b/src/core/hle/service/am/applets/general_backend.cpp index ed166b87d..18ab0718b 100644 --- a/src/core/hle/service/am/applets/stub_applet.cpp +++ b/src/core/hle/service/am/applets/general_backend.cpp | |||
| @@ -6,9 +6,12 @@ | |||
| 6 | 6 | ||
| 7 | #include "common/hex_util.h" | 7 | #include "common/hex_util.h" |
| 8 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| 9 | #include "core/core.h" | ||
| 10 | #include "core/frontend/applets/general_frontend.h" | ||
| 11 | #include "core/hle/kernel/process.h" | ||
| 9 | #include "core/hle/result.h" | 12 | #include "core/hle/result.h" |
| 10 | #include "core/hle/service/am/am.h" | 13 | #include "core/hle/service/am/am.h" |
| 11 | #include "core/hle/service/am/applets/stub_applet.h" | 14 | #include "core/hle/service/am/applets/general_backend.h" |
| 12 | 15 | ||
| 13 | namespace Service::AM::Applets { | 16 | namespace Service::AM::Applets { |
| 14 | 17 | ||
| @@ -30,6 +33,55 @@ static void LogCurrentStorage(AppletDataBroker& broker, std::string prefix) { | |||
| 30 | } | 33 | } |
| 31 | } | 34 | } |
| 32 | 35 | ||
| 36 | PhotoViewer::PhotoViewer(const Core::Frontend::PhotoViewerApplet& frontend) : frontend(frontend) {} | ||
| 37 | |||
| 38 | PhotoViewer::~PhotoViewer() = default; | ||
| 39 | |||
| 40 | void PhotoViewer::Initialize() { | ||
| 41 | Applet::Initialize(); | ||
| 42 | complete = false; | ||
| 43 | |||
| 44 | const auto storage = broker.PopNormalDataToApplet(); | ||
| 45 | ASSERT(storage != nullptr); | ||
| 46 | const auto data = storage->GetData(); | ||
| 47 | ASSERT(!data.empty()); | ||
| 48 | mode = static_cast<PhotoViewerAppletMode>(data[0]); | ||
| 49 | } | ||
| 50 | |||
| 51 | bool PhotoViewer::TransactionComplete() const { | ||
| 52 | return complete; | ||
| 53 | } | ||
| 54 | |||
| 55 | ResultCode PhotoViewer::GetStatus() const { | ||
| 56 | return RESULT_SUCCESS; | ||
| 57 | } | ||
| 58 | |||
| 59 | void PhotoViewer::ExecuteInteractive() { | ||
| 60 | UNREACHABLE_MSG("Unexpected interactive applet data."); | ||
| 61 | } | ||
| 62 | |||
| 63 | void PhotoViewer::Execute() { | ||
| 64 | if (complete) | ||
| 65 | return; | ||
| 66 | |||
| 67 | const auto callback = [this] { ViewFinished(); }; | ||
| 68 | switch (mode) { | ||
| 69 | case PhotoViewerAppletMode::CurrentApp: | ||
| 70 | frontend.ShowPhotosForApplication(Core::CurrentProcess()->GetTitleID(), callback); | ||
| 71 | break; | ||
| 72 | case PhotoViewerAppletMode::AllApps: | ||
| 73 | frontend.ShowAllPhotos(callback); | ||
| 74 | break; | ||
| 75 | default: | ||
| 76 | UNIMPLEMENTED_MSG("Unimplemented PhotoViewer applet mode={:02X}!", static_cast<u8>(mode)); | ||
| 77 | } | ||
| 78 | } | ||
| 79 | |||
| 80 | void PhotoViewer::ViewFinished() { | ||
| 81 | broker.PushNormalDataFromApplet(IStorage{{}}); | ||
| 82 | broker.SignalStateChanged(); | ||
| 83 | } | ||
| 84 | |||
| 33 | StubApplet::StubApplet() = default; | 85 | StubApplet::StubApplet() = default; |
| 34 | 86 | ||
| 35 | StubApplet::~StubApplet() = default; | 87 | StubApplet::~StubApplet() = default; |
| @@ -67,4 +119,5 @@ void StubApplet::Execute() { | |||
| 67 | broker.PushInteractiveDataFromApplet(IStorage{std::vector<u8>(0x1000)}); | 119 | broker.PushInteractiveDataFromApplet(IStorage{std::vector<u8>(0x1000)}); |
| 68 | broker.SignalStateChanged(); | 120 | broker.SignalStateChanged(); |
| 69 | } | 121 | } |
| 122 | |||
| 70 | } // namespace Service::AM::Applets | 123 | } // namespace Service::AM::Applets |
diff --git a/src/core/hle/service/am/applets/general_backend.h b/src/core/hle/service/am/applets/general_backend.h new file mode 100644 index 000000000..d7313e74a --- /dev/null +++ b/src/core/hle/service/am/applets/general_backend.h | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | // Copyright 2019 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "core/hle/service/am/applets/applets.h" | ||
| 8 | |||
| 9 | namespace Service::AM::Applets { | ||
| 10 | |||
| 11 | enum class PhotoViewerAppletMode : u8 { | ||
| 12 | CurrentApp = 0, | ||
| 13 | AllApps = 1, | ||
| 14 | }; | ||
| 15 | |||
| 16 | class PhotoViewer final : public Applet { | ||
| 17 | public: | ||
| 18 | PhotoViewer(const Core::Frontend::PhotoViewerApplet& frontend); | ||
| 19 | ~PhotoViewer() override; | ||
| 20 | |||
| 21 | void Initialize() override; | ||
| 22 | bool TransactionComplete() const override; | ||
| 23 | ResultCode GetStatus() const override; | ||
| 24 | void ExecuteInteractive() override; | ||
| 25 | void Execute() override; | ||
| 26 | |||
| 27 | void ViewFinished(); | ||
| 28 | |||
| 29 | private: | ||
| 30 | const Core::Frontend::PhotoViewerApplet& frontend; | ||
| 31 | bool complete; | ||
| 32 | PhotoViewerAppletMode mode; | ||
| 33 | }; | ||
| 34 | |||
| 35 | class StubApplet final : public Applet { | ||
| 36 | public: | ||
| 37 | StubApplet(); | ||
| 38 | ~StubApplet() override; | ||
| 39 | |||
| 40 | void Initialize() override; | ||
| 41 | |||
| 42 | bool TransactionComplete() const override; | ||
| 43 | ResultCode GetStatus() const override; | ||
| 44 | void ExecuteInteractive() override; | ||
| 45 | void Execute() override; | ||
| 46 | }; | ||
| 47 | |||
| 48 | } // namespace Service::AM::Applets | ||