diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | src/core/core.cpp | 11 | ||||
| -rw-r--r-- | src/core/core.h | 5 | ||||
| -rw-r--r-- | src/core/frontend/applets/profile_select.cpp | 19 | ||||
| -rw-r--r-- | src/core/frontend/applets/profile_select.h | 27 | ||||
| -rw-r--r-- | src/core/hle/service/am/am.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/profile_select.cpp | 77 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/profile_select.h | 50 |
8 files changed, 197 insertions, 0 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 882c9ab59..93f5ba3fe 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -83,6 +83,8 @@ add_library(core STATIC | |||
| 83 | file_sys/vfs_vector.h | 83 | file_sys/vfs_vector.h |
| 84 | file_sys/xts_archive.cpp | 84 | file_sys/xts_archive.cpp |
| 85 | file_sys/xts_archive.h | 85 | file_sys/xts_archive.h |
| 86 | frontend/applets/profile_select.cpp | ||
| 87 | frontend/applets/profile_select.h | ||
| 86 | frontend/applets/software_keyboard.cpp | 88 | frontend/applets/software_keyboard.cpp |
| 87 | frontend/applets/software_keyboard.h | 89 | frontend/applets/software_keyboard.h |
| 88 | frontend/emu_window.cpp | 90 | frontend/emu_window.cpp |
| @@ -162,6 +164,8 @@ add_library(core STATIC | |||
| 162 | hle/service/am/applet_oe.h | 164 | hle/service/am/applet_oe.h |
| 163 | hle/service/am/applets/applets.cpp | 165 | hle/service/am/applets/applets.cpp |
| 164 | hle/service/am/applets/applets.h | 166 | hle/service/am/applets/applets.h |
| 167 | hle/service/am/applets/profile_select.cpp | ||
| 168 | hle/service/am/applets/profile_select.h | ||
| 165 | hle/service/am/applets/software_keyboard.cpp | 169 | hle/service/am/applets/software_keyboard.cpp |
| 166 | hle/service/am/applets/software_keyboard.h | 170 | hle/service/am/applets/software_keyboard.h |
| 167 | hle/service/am/applets/stub_applet.cpp | 171 | hle/service/am/applets/stub_applet.cpp |
diff --git a/src/core/core.cpp b/src/core/core.cpp index ce7851538..fd10199ec 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -99,6 +99,8 @@ struct System::Impl { | |||
| 99 | virtual_filesystem = std::make_shared<FileSys::RealVfsFilesystem>(); | 99 | virtual_filesystem = std::make_shared<FileSys::RealVfsFilesystem>(); |
| 100 | 100 | ||
| 101 | /// Create default implementations of applets if one is not provided. | 101 | /// Create default implementations of applets if one is not provided. |
| 102 | if (profile_selector == nullptr) | ||
| 103 | profile_selector = std::make_unique<Core::Frontend::DefaultProfileSelectApplet>(); | ||
| 102 | if (software_keyboard == nullptr) | 104 | if (software_keyboard == nullptr) |
| 103 | software_keyboard = std::make_unique<Core::Frontend::DefaultSoftwareKeyboardApplet>(); | 105 | software_keyboard = std::make_unique<Core::Frontend::DefaultSoftwareKeyboardApplet>(); |
| 104 | 106 | ||
| @@ -229,6 +231,7 @@ struct System::Impl { | |||
| 229 | bool is_powered_on = false; | 231 | bool is_powered_on = false; |
| 230 | 232 | ||
| 231 | /// Frontend applets | 233 | /// Frontend applets |
| 234 | std::unique_ptr<Core::Frontend::ProfileSelectApplet> profile_selector; | ||
| 232 | std::unique_ptr<Core::Frontend::SoftwareKeyboardApplet> software_keyboard; | 235 | std::unique_ptr<Core::Frontend::SoftwareKeyboardApplet> software_keyboard; |
| 233 | 236 | ||
| 234 | /// Service manager | 237 | /// Service manager |
| @@ -424,6 +427,14 @@ std::shared_ptr<FileSys::VfsFilesystem> System::GetFilesystem() const { | |||
| 424 | return impl->virtual_filesystem; | 427 | return impl->virtual_filesystem; |
| 425 | } | 428 | } |
| 426 | 429 | ||
| 430 | void System::SetProfileSelector(std::unique_ptr<Core::Frontend::ProfileSelectApplet> applet) { | ||
| 431 | impl->profile_selector = std::move(applet); | ||
| 432 | } | ||
| 433 | |||
| 434 | const Core::Frontend::ProfileSelectApplet& System::GetProfileSelector() const { | ||
| 435 | return *impl->profile_selector; | ||
| 436 | } | ||
| 437 | |||
| 427 | void System::SetSoftwareKeyboard(std::unique_ptr<Core::Frontend::SoftwareKeyboardApplet> applet) { | 438 | void System::SetSoftwareKeyboard(std::unique_ptr<Core::Frontend::SoftwareKeyboardApplet> applet) { |
| 428 | impl->software_keyboard = std::move(applet); | 439 | impl->software_keyboard = std::move(applet); |
| 429 | } | 440 | } |
diff --git a/src/core/core.h b/src/core/core.h index 71031dfcf..869921493 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "core/file_sys/vfs_types.h" | 12 | #include "core/file_sys/vfs_types.h" |
| 13 | #include "core/hle/kernel/object.h" | 13 | #include "core/hle/kernel/object.h" |
| 14 | #include "frontend/applets/profile_select.h" | ||
| 14 | 15 | ||
| 15 | namespace Core::Frontend { | 16 | namespace Core::Frontend { |
| 16 | class EmuWindow; | 17 | class EmuWindow; |
| @@ -241,6 +242,10 @@ public: | |||
| 241 | 242 | ||
| 242 | std::shared_ptr<FileSys::VfsFilesystem> GetFilesystem() const; | 243 | std::shared_ptr<FileSys::VfsFilesystem> GetFilesystem() const; |
| 243 | 244 | ||
| 245 | void SetProfileSelector(std::unique_ptr<Core::Frontend::ProfileSelectApplet> applet); | ||
| 246 | |||
| 247 | const Core::Frontend::ProfileSelectApplet& GetProfileSelector() const; | ||
| 248 | |||
| 244 | void SetSoftwareKeyboard(std::unique_ptr<Core::Frontend::SoftwareKeyboardApplet> applet); | 249 | void SetSoftwareKeyboard(std::unique_ptr<Core::Frontend::SoftwareKeyboardApplet> applet); |
| 245 | 250 | ||
| 246 | const Core::Frontend::SoftwareKeyboardApplet& GetSoftwareKeyboard() const; | 251 | const Core::Frontend::SoftwareKeyboardApplet& GetSoftwareKeyboard() const; |
diff --git a/src/core/frontend/applets/profile_select.cpp b/src/core/frontend/applets/profile_select.cpp new file mode 100644 index 000000000..fbf5f2a9e --- /dev/null +++ b/src/core/frontend/applets/profile_select.cpp | |||
| @@ -0,0 +1,19 @@ | |||
| 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 "core/frontend/applets/profile_select.h" | ||
| 6 | #include "core/settings.h" | ||
| 7 | |||
| 8 | namespace Core::Frontend { | ||
| 9 | |||
| 10 | ProfileSelectApplet::~ProfileSelectApplet() = default; | ||
| 11 | |||
| 12 | void DefaultProfileSelectApplet::SelectProfile( | ||
| 13 | std::function<void(std::optional<Service::Account::UUID>)> callback) const { | ||
| 14 | Service::Account::ProfileManager manager; | ||
| 15 | callback(manager.GetUser(Settings::values.current_user).value_or(Service::Account::UUID{})); | ||
| 16 | LOG_INFO(Service_ACC, "called, selecting current user instead of prompting..."); | ||
| 17 | } | ||
| 18 | |||
| 19 | } // namespace Core::Frontend | ||
diff --git a/src/core/frontend/applets/profile_select.h b/src/core/frontend/applets/profile_select.h new file mode 100644 index 000000000..fc8f7ae94 --- /dev/null +++ b/src/core/frontend/applets/profile_select.h | |||
| @@ -0,0 +1,27 @@ | |||
| 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 <functional> | ||
| 8 | #include <optional> | ||
| 9 | #include "core/hle/service/acc/profile_manager.h" | ||
| 10 | |||
| 11 | namespace Core::Frontend { | ||
| 12 | |||
| 13 | class ProfileSelectApplet { | ||
| 14 | public: | ||
| 15 | virtual ~ProfileSelectApplet(); | ||
| 16 | |||
| 17 | virtual void SelectProfile( | ||
| 18 | std::function<void(std::optional<Service::Account::UUID>)> callback) const = 0; | ||
| 19 | }; | ||
| 20 | |||
| 21 | class DefaultProfileSelectApplet final : public ProfileSelectApplet { | ||
| 22 | public: | ||
| 23 | void SelectProfile( | ||
| 24 | std::function<void(std::optional<Service::Account::UUID>)> callback) const override; | ||
| 25 | }; | ||
| 26 | |||
| 27 | } // namespace Core::Frontend | ||
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 27c31aad2..5fc02a521 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include "core/hle/service/am/applet_ae.h" | 19 | #include "core/hle/service/am/applet_ae.h" |
| 20 | #include "core/hle/service/am/applet_oe.h" | 20 | #include "core/hle/service/am/applet_oe.h" |
| 21 | #include "core/hle/service/am/applets/applets.h" | 21 | #include "core/hle/service/am/applets/applets.h" |
| 22 | #include "core/hle/service/am/applets/profile_select.h" | ||
| 22 | #include "core/hle/service/am/applets/software_keyboard.h" | 23 | #include "core/hle/service/am/applets/software_keyboard.h" |
| 23 | #include "core/hle/service/am/applets/stub_applet.h" | 24 | #include "core/hle/service/am/applets/stub_applet.h" |
| 24 | #include "core/hle/service/am/idle.h" | 25 | #include "core/hle/service/am/idle.h" |
| @@ -39,6 +40,7 @@ constexpr ResultCode ERR_NO_DATA_IN_CHANNEL{ErrorModule::AM, 0x2}; | |||
| 39 | constexpr ResultCode ERR_SIZE_OUT_OF_BOUNDS{ErrorModule::AM, 0x1F7}; | 40 | constexpr ResultCode ERR_SIZE_OUT_OF_BOUNDS{ErrorModule::AM, 0x1F7}; |
| 40 | 41 | ||
| 41 | enum class AppletId : u32 { | 42 | enum class AppletId : u32 { |
| 43 | ProfileSelect = 0x10, | ||
| 42 | SoftwareKeyboard = 0x11, | 44 | SoftwareKeyboard = 0x11, |
| 43 | }; | 45 | }; |
| 44 | 46 | ||
| @@ -775,6 +777,8 @@ ILibraryAppletCreator::~ILibraryAppletCreator() = default; | |||
| 775 | 777 | ||
| 776 | static std::shared_ptr<Applets::Applet> GetAppletFromId(AppletId id) { | 778 | static std::shared_ptr<Applets::Applet> GetAppletFromId(AppletId id) { |
| 777 | switch (id) { | 779 | switch (id) { |
| 780 | case AppletId::ProfileSelect: | ||
| 781 | return std::make_shared<Applets::ProfileSelect>(); | ||
| 778 | case AppletId::SoftwareKeyboard: | 782 | case AppletId::SoftwareKeyboard: |
| 779 | return std::make_shared<Applets::SoftwareKeyboard>(); | 783 | return std::make_shared<Applets::SoftwareKeyboard>(); |
| 780 | default: | 784 | default: |
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 @@ | |||
| 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 | |||
| 7 | #include "common/assert.h" | ||
| 8 | #include "common/string_util.h" | ||
| 9 | #include "core/core.h" | ||
| 10 | #include "core/frontend/applets/software_keyboard.h" | ||
| 11 | #include "core/hle/service/am/am.h" | ||
| 12 | #include "core/hle/service/am/applets/profile_select.h" | ||
| 13 | |||
| 14 | namespace Service::AM::Applets { | ||
| 15 | |||
| 16 | constexpr ResultCode ERR_USER_CANCELLED_SELECTION{ErrorModule::Account, 1}; | ||
| 17 | |||
| 18 | ProfileSelect::ProfileSelect() = default; | ||
| 19 | ProfileSelect::~ProfileSelect() = default; | ||
| 20 | |||
| 21 | void ProfileSelect::Initialize() { | ||
| 22 | complete = false; | ||
| 23 | status = RESULT_SUCCESS; | ||
| 24 | final_data.clear(); | ||
| 25 | |||
| 26 | Applet::Initialize(); | ||
| 27 | |||
| 28 | const auto user_config_storage = broker.PopNormalDataToApplet(); | ||
| 29 | ASSERT(user_config_storage != nullptr); | ||
| 30 | const auto& user_config = user_config_storage->GetData(); | ||
| 31 | |||
| 32 | ASSERT(user_config.size() >= sizeof(UserSelectionConfig)); | ||
| 33 | std::memcpy(&config, user_config.data(), sizeof(UserSelectionConfig)); | ||
| 34 | } | ||
| 35 | |||
| 36 | bool ProfileSelect::TransactionComplete() const { | ||
| 37 | return complete; | ||
| 38 | } | ||
| 39 | |||
| 40 | ResultCode ProfileSelect::GetStatus() const { | ||
| 41 | return status; | ||
| 42 | } | ||
| 43 | |||
| 44 | void ProfileSelect::ExecuteInteractive() { | ||
| 45 | UNREACHABLE_MSG("Attempted to call interactive execution on non-interactive applet."); | ||
| 46 | } | ||
| 47 | |||
| 48 | void ProfileSelect::Execute() { | ||
| 49 | if (complete) { | ||
| 50 | broker.PushNormalDataFromApplet(IStorage{final_data}); | ||
| 51 | return; | ||
| 52 | } | ||
| 53 | |||
| 54 | const auto& frontend{Core::System::GetInstance().GetProfileSelector()}; | ||
| 55 | |||
| 56 | frontend.SelectProfile([this](std::optional<Account::UUID> uuid) { SelectionComplete(uuid); }); | ||
| 57 | } | ||
| 58 | |||
| 59 | void ProfileSelect::SelectionComplete(std::optional<Account::UUID> uuid) { | ||
| 60 | UserSelectionOutput output{}; | ||
| 61 | |||
| 62 | if (uuid.has_value() && uuid->uuid != Account::INVALID_UUID) { | ||
| 63 | output.result = 0; | ||
| 64 | output.uuid_selected = uuid->uuid; | ||
| 65 | } else { | ||
| 66 | status = ERR_USER_CANCELLED_SELECTION; | ||
| 67 | output.result = ERR_USER_CANCELLED_SELECTION.raw; | ||
| 68 | output.uuid_selected = Account::INVALID_UUID; | ||
| 69 | } | ||
| 70 | |||
| 71 | final_data = std::vector<u8>(sizeof(UserSelectionOutput)); | ||
| 72 | std::memcpy(final_data.data(), &output, final_data.size()); | ||
| 73 | broker.PushNormalDataFromApplet(IStorage{final_data}); | ||
| 74 | broker.SignalStateChanged(); | ||
| 75 | } | ||
| 76 | |||
| 77 | } // 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..787485f22 --- /dev/null +++ b/src/core/hle/service/am/applets/profile_select.h | |||
| @@ -0,0 +1,50 @@ | |||
| 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 <vector> | ||
| 8 | |||
| 9 | #include "common/common_funcs.h" | ||
| 10 | #include "core/hle/service/acc/profile_manager.h" | ||
| 11 | #include "core/hle/service/am/applets/applets.h" | ||
| 12 | |||
| 13 | namespace Service::AM::Applets { | ||
| 14 | |||
| 15 | struct UserSelectionConfig { | ||
| 16 | // TODO(DarkLordZach): RE this structure | ||
| 17 | // It seems to be flags and the like that determine the UI of the applet on the switch... from | ||
| 18 | // my research this is safe to ignore for now. | ||
| 19 | INSERT_PADDING_BYTES(0xA0); | ||
| 20 | }; | ||
| 21 | static_assert(sizeof(UserSelectionConfig) == 0xA0, "UserSelectionConfig has incorrect size."); | ||
| 22 | |||
| 23 | struct UserSelectionOutput { | ||
| 24 | u64 result; | ||
| 25 | u128 uuid_selected; | ||
| 26 | }; | ||
| 27 | static_assert(sizeof(UserSelectionOutput) == 0x18, "UserSelectionOutput has incorrect size."); | ||
| 28 | |||
| 29 | class ProfileSelect final : public Applet { | ||
| 30 | public: | ||
| 31 | ProfileSelect(); | ||
| 32 | ~ProfileSelect() override; | ||
| 33 | |||
| 34 | void Initialize() override; | ||
| 35 | |||
| 36 | bool TransactionComplete() const override; | ||
| 37 | ResultCode GetStatus() const override; | ||
| 38 | void ExecuteInteractive() override; | ||
| 39 | void Execute() override; | ||
| 40 | |||
| 41 | void SelectionComplete(std::optional<Account::UUID> uuid); | ||
| 42 | |||
| 43 | private: | ||
| 44 | UserSelectionConfig config; | ||
| 45 | bool complete = false; | ||
| 46 | ResultCode status = RESULT_SUCCESS; | ||
| 47 | std::vector<u8> final_data; | ||
| 48 | }; | ||
| 49 | |||
| 50 | } // namespace Service::AM::Applets | ||