diff options
| author | 2018-11-22 21:02:36 -0500 | |
|---|---|---|
| committer | 2018-12-03 17:26:27 -0500 | |
| commit | 4fb59fdfe1e5fe2d0b9313c395e0d7c880e00c6f (patch) | |
| tree | f8ccb5bf5e31a915a0572e1789f8b08dd9796f27 /src/core | |
| parent | qt: Register to use Qt ProfileSelector instead of default (diff) | |
| download | yuzu-4fb59fdfe1e5fe2d0b9313c395e0d7c880e00c6f.tar.gz yuzu-4fb59fdfe1e5fe2d0b9313c395e0d7c880e00c6f.tar.xz yuzu-4fb59fdfe1e5fe2d0b9313c395e0d7c880e00c6f.zip | |
applets: Implement ProfileSelect applet
Allows the player to select an emulated profile.
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/hle/service/am/applets/profile_select.cpp | 76 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/profile_select.h | 54 |
2 files changed, 130 insertions, 0 deletions
diff --git a/src/core/hle/service/am/applets/profile_select.cpp b/src/core/hle/service/am/applets/profile_select.cpp new file mode 100644 index 000000000..750f0fdeb --- /dev/null +++ b/src/core/hle/service/am/applets/profile_select.cpp | |||
| @@ -0,0 +1,76 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <cstring> | ||
| 6 | #include "common/assert.h" | ||
| 7 | #include "common/string_util.h" | ||
| 8 | #include "core/core.h" | ||
| 9 | #include "core/frontend/applets/software_keyboard.h" | ||
| 10 | #include "core/hle/service/am/am.h" | ||
| 11 | #include "core/hle/service/am/applets/profile_select.h" | ||
| 12 | |||
| 13 | namespace Service::AM::Applets { | ||
| 14 | |||
| 15 | constexpr ResultCode ERR_USER_CANCELLED_SELECTION{ErrorModule::Account, 1}; | ||
| 16 | |||
| 17 | ProfileSelect::ProfileSelect() = default; | ||
| 18 | ProfileSelect::~ProfileSelect() = default; | ||
| 19 | |||
| 20 | void ProfileSelect::Initialize() { | ||
| 21 | complete = false; | ||
| 22 | status = RESULT_SUCCESS; | ||
| 23 | final_data.clear(); | ||
| 24 | |||
| 25 | Applet::Initialize(); | ||
| 26 | |||
| 27 | const auto user_config_storage = broker.PopNormalDataToApplet(); | ||
| 28 | ASSERT(user_config_storage != nullptr); | ||
| 29 | const auto& user_config = user_config_storage->GetData(); | ||
| 30 | |||
| 31 | ASSERT(user_config.size() >= sizeof(UserSelectionConfig)); | ||
| 32 | std::memcpy(&config, user_config.data(), sizeof(UserSelectionConfig)); | ||
| 33 | } | ||
| 34 | |||
| 35 | bool ProfileSelect::TransactionComplete() const { | ||
| 36 | return complete; | ||
| 37 | } | ||
| 38 | |||
| 39 | ResultCode ProfileSelect::GetStatus() const { | ||
| 40 | return status; | ||
| 41 | } | ||
| 42 | |||
| 43 | void ProfileSelect::ExecuteInteractive() { | ||
| 44 | UNREACHABLE_MSG("Attempted to call interactive execution on non-interactive applet."); | ||
| 45 | } | ||
| 46 | |||
| 47 | void ProfileSelect::Execute() { | ||
| 48 | if (complete) { | ||
| 49 | broker.PushNormalDataFromApplet(IStorage{final_data}); | ||
| 50 | return; | ||
| 51 | } | ||
| 52 | |||
| 53 | const auto& frontend{Core::System::GetInstance().GetProfileSelector()}; | ||
| 54 | |||
| 55 | frontend.SelectProfile([this](std::optional<Account::UUID> uuid) { SelectionComplete(uuid); }); | ||
| 56 | } | ||
| 57 | |||
| 58 | void ProfileSelect::SelectionComplete(std::optional<Account::UUID> uuid) { | ||
| 59 | UserSelectionOutput output{}; | ||
| 60 | |||
| 61 | if (uuid.has_value() && uuid->uuid != Account::INVALID_UUID) { | ||
| 62 | output.result = 0; | ||
| 63 | output.uuid_selected = uuid->uuid; | ||
| 64 | } else { | ||
| 65 | status = ERR_USER_CANCELLED_SELECTION; | ||
| 66 | output.result = ERR_USER_CANCELLED_SELECTION.raw; | ||
| 67 | output.uuid_selected = Account::INVALID_UUID; | ||
| 68 | } | ||
| 69 | |||
| 70 | final_data = std::vector<u8>(sizeof(UserSelectionOutput)); | ||
| 71 | std::memcpy(final_data.data(), &output, final_data.size()); | ||
| 72 | broker.PushNormalDataFromApplet(IStorage{final_data}); | ||
| 73 | broker.SignalStateChanged(); | ||
| 74 | } | ||
| 75 | |||
| 76 | } // namespace Service::AM::Applets | ||
diff --git a/src/core/hle/service/am/applets/profile_select.h b/src/core/hle/service/am/applets/profile_select.h new file mode 100644 index 000000000..c383527f4 --- /dev/null +++ b/src/core/hle/service/am/applets/profile_select.h | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | // Copyright 2018 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 <array> | ||
| 8 | #include <string> | ||
| 9 | #include <vector> | ||
| 10 | |||
| 11 | #include "common/common_funcs.h" | ||
| 12 | #include "common/swap.h" | ||
| 13 | #include "core/hle/service/acc/profile_manager.h" | ||
| 14 | #include "core/hle/service/am/am.h" | ||
| 15 | #include "core/hle/service/am/applets/applets.h" | ||
| 16 | |||
| 17 | namespace Service::AM::Applets { | ||
| 18 | |||
| 19 | struct UserSelectionConfig { | ||
| 20 | // TODO(DarkLordZach): RE this structure | ||
| 21 | // It seems to be flags and the like that determine the UI of the applet on the switch... from | ||
| 22 | // my research this is safe to ignore for now. | ||
| 23 | INSERT_PADDING_BYTES(0xA0); | ||
| 24 | }; | ||
| 25 | static_assert(sizeof(UserSelectionConfig) == 0xA0, "UserSelectionConfig has incorrect size."); | ||
| 26 | |||
| 27 | struct UserSelectionOutput { | ||
| 28 | u64 result; | ||
| 29 | u128 uuid_selected; | ||
| 30 | }; | ||
| 31 | static_assert(sizeof(UserSelectionOutput) == 0x18, "UserSelectionOutput has incorrect size."); | ||
| 32 | |||
| 33 | class ProfileSelect final : public Applet { | ||
| 34 | public: | ||
| 35 | ProfileSelect(); | ||
| 36 | ~ProfileSelect() override; | ||
| 37 | |||
| 38 | void Initialize() override; | ||
| 39 | |||
| 40 | bool TransactionComplete() const override; | ||
| 41 | ResultCode GetStatus() const override; | ||
| 42 | void ExecuteInteractive() override; | ||
| 43 | void Execute() override; | ||
| 44 | |||
| 45 | void SelectionComplete(std::optional<Account::UUID> uuid); | ||
| 46 | |||
| 47 | private: | ||
| 48 | UserSelectionConfig config; | ||
| 49 | bool complete = false; | ||
| 50 | ResultCode status = RESULT_SUCCESS; | ||
| 51 | std::vector<u8> final_data; | ||
| 52 | }; | ||
| 53 | |||
| 54 | } // namespace Service::AM::Applets | ||