diff options
author | bunnei <bunneidev@gmail.com> | 2018-12-23 20:35:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-23 20:35:13 +0100 |
commit | f95f6c7d86af9857cb737a741fc847bf2c5d8413 (patch) | |
tree | b5c02a35cdb18b78c648bc3a6f98b87e68d2e651 /src/core/hle/service/am/applets/profile_select.cpp | |
parent | Merge pull request #1780 from DarkLordZach/controller-profiles (diff) | |
parent | applets: Correct event ResetTypes from OneShot to Sticky (diff) | |
download | yuzu-f95f6c7d86af9857cb737a741fc847bf2c5d8413.tar yuzu-f95f6c7d86af9857cb737a741fc847bf2c5d8413.tar.gz yuzu-f95f6c7d86af9857cb737a741fc847bf2c5d8413.tar.bz2 yuzu-f95f6c7d86af9857cb737a741fc847bf2c5d8413.tar.lz yuzu-f95f6c7d86af9857cb737a741fc847bf2c5d8413.tar.xz yuzu-f95f6c7d86af9857cb737a741fc847bf2c5d8413.tar.zst yuzu-f95f6c7d86af9857cb737a741fc847bf2c5d8413.zip |
Diffstat (limited to 'src/core/hle/service/am/applets/profile_select.cpp')
-rw-r--r-- | src/core/hle/service/am/applets/profile_select.cpp | 77 |
1 files changed, 77 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..4c7b45454 --- /dev/null +++ b/src/core/hle/service/am/applets/profile_select.cpp @@ -0,0 +1,77 @@ +// Copyright 2018 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include <cstring> + +#include "common/assert.h" +#include "common/string_util.h" +#include "core/core.h" +#include "core/frontend/applets/software_keyboard.h" +#include "core/hle/service/am/am.h" +#include "core/hle/service/am/applets/profile_select.h" + +namespace Service::AM::Applets { + +constexpr ResultCode ERR_USER_CANCELLED_SELECTION{ErrorModule::Account, 1}; + +ProfileSelect::ProfileSelect() = default; +ProfileSelect::~ProfileSelect() = default; + +void ProfileSelect::Initialize() { + complete = false; + status = RESULT_SUCCESS; + final_data.clear(); + + Applet::Initialize(); + + const auto user_config_storage = broker.PopNormalDataToApplet(); + ASSERT(user_config_storage != nullptr); + const auto& user_config = user_config_storage->GetData(); + + ASSERT(user_config.size() >= sizeof(UserSelectionConfig)); + std::memcpy(&config, user_config.data(), sizeof(UserSelectionConfig)); +} + +bool ProfileSelect::TransactionComplete() const { + return complete; +} + +ResultCode ProfileSelect::GetStatus() const { + return status; +} + +void ProfileSelect::ExecuteInteractive() { + UNREACHABLE_MSG("Attempted to call interactive execution on non-interactive applet."); +} + +void ProfileSelect::Execute() { + if (complete) { + broker.PushNormalDataFromApplet(IStorage{final_data}); + return; + } + + const auto& frontend{Core::System::GetInstance().GetProfileSelector()}; + + frontend.SelectProfile([this](std::optional<Account::UUID> uuid) { SelectionComplete(uuid); }); +} + +void ProfileSelect::SelectionComplete(std::optional<Account::UUID> uuid) { + UserSelectionOutput output{}; + + if (uuid.has_value() && uuid->uuid != Account::INVALID_UUID) { + output.result = 0; + output.uuid_selected = uuid->uuid; + } else { + status = ERR_USER_CANCELLED_SELECTION; + output.result = ERR_USER_CANCELLED_SELECTION.raw; + output.uuid_selected = Account::INVALID_UUID; + } + + final_data = std::vector<u8>(sizeof(UserSelectionOutput)); + std::memcpy(final_data.data(), &output, final_data.size()); + broker.PushNormalDataFromApplet(IStorage{final_data}); + broker.SignalStateChanged(); +} + +} // namespace Service::AM::Applets |