summaryrefslogtreecommitdiffstats
path: root/src/core/hle
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/service/caps/caps_a.cpp156
-rw-r--r--src/core/hle/service/caps/caps_a.h34
-rw-r--r--src/core/hle/service/caps/caps_c.cpp16
-rw-r--r--src/core/hle/service/caps/caps_c.h5
-rw-r--r--src/core/hle/service/caps/caps_manager.cpp61
-rw-r--r--src/core/hle/service/caps/caps_manager.h16
-rw-r--r--src/core/hle/service/caps/caps_ss.cpp82
-rw-r--r--src/core/hle/service/caps/caps_ss.h18
-rw-r--r--src/core/hle/service/caps/caps_su.cpp87
-rw-r--r--src/core/hle/service/caps/caps_su.h18
-rw-r--r--src/core/hle/service/caps/caps_types.h32
-rw-r--r--src/core/hle/service/caps/caps_u.cpp110
-rw-r--r--src/core/hle/service/caps/caps_u.h16
-rw-r--r--src/core/hle/service/hid/hid.cpp5
-rw-r--r--src/core/hle/service/hid/hid_debug_server.cpp196
-rw-r--r--src/core/hle/service/hid/hid_debug_server.h15
-rw-r--r--src/core/hle/service/hid/hid_server.cpp24
-rw-r--r--src/core/hle/service/hid/hid_system_server.cpp64
-rw-r--r--src/core/hle/service/hid/hid_system_server.h3
-rw-r--r--src/core/hle/service/set/setting_formats/system_settings.h4
-rw-r--r--src/core/hle/service/set/system_settings_server.cpp37
-rw-r--r--src/core/hle/service/set/system_settings_server.h4
22 files changed, 581 insertions, 422 deletions
diff --git a/src/core/hle/service/caps/caps_a.cpp b/src/core/hle/service/caps/caps_a.cpp
index 69acb3a8b..47ff072c5 100644
--- a/src/core/hle/service/caps/caps_a.cpp
+++ b/src/core/hle/service/caps/caps_a.cpp
@@ -5,7 +5,7 @@
#include "core/hle/service/caps/caps_a.h"
#include "core/hle/service/caps/caps_manager.h"
#include "core/hle/service/caps/caps_result.h"
-#include "core/hle/service/caps/caps_types.h"
+#include "core/hle/service/cmif_serialization.h"
#include "core/hle/service/ipc_helpers.h"
namespace Service::Capture {
@@ -18,9 +18,9 @@ IAlbumAccessorService::IAlbumAccessorService(Core::System& system_,
{0, nullptr, "GetAlbumFileCount"},
{1, nullptr, "GetAlbumFileList"},
{2, nullptr, "LoadAlbumFile"},
- {3, &IAlbumAccessorService::DeleteAlbumFile, "DeleteAlbumFile"},
+ {3, C<&IAlbumAccessorService::DeleteAlbumFile>, "DeleteAlbumFile"},
{4, nullptr, "StorageCopyAlbumFile"},
- {5, &IAlbumAccessorService::IsAlbumMounted, "IsAlbumMounted"},
+ {5, C<&IAlbumAccessorService::IsAlbumMounted>, "IsAlbumMounted"},
{6, nullptr, "GetAlbumUsage"},
{7, nullptr, "GetAlbumFileSize"},
{8, nullptr, "LoadAlbumFileThumbnail"},
@@ -33,18 +33,18 @@ IAlbumAccessorService::IAlbumAccessorService(Core::System& system_,
{15, nullptr, "GetAlbumUsage3"},
{16, nullptr, "GetAlbumMountResult"},
{17, nullptr, "GetAlbumUsage16"},
- {18, &IAlbumAccessorService::Unknown18, "Unknown18"},
+ {18, C<&IAlbumAccessorService::Unknown18>, "Unknown18"},
{19, nullptr, "Unknown19"},
{100, nullptr, "GetAlbumFileCountEx0"},
- {101, &IAlbumAccessorService::GetAlbumFileListEx0, "GetAlbumFileListEx0"},
+ {101, C<&IAlbumAccessorService::GetAlbumFileListEx0>, "GetAlbumFileListEx0"},
{202, nullptr, "SaveEditedScreenShot"},
{301, nullptr, "GetLastThumbnail"},
{302, nullptr, "GetLastOverlayMovieThumbnail"},
- {401, &IAlbumAccessorService::GetAutoSavingStorage, "GetAutoSavingStorage"},
+ {401, C<&IAlbumAccessorService::GetAutoSavingStorage>, "GetAutoSavingStorage"},
{501, nullptr, "GetRequiredStorageSpaceSizeToCopyAll"},
{1001, nullptr, "LoadAlbumScreenShotThumbnailImageEx0"},
- {1002, &IAlbumAccessorService::LoadAlbumScreenShotImageEx1, "LoadAlbumScreenShotImageEx1"},
- {1003, &IAlbumAccessorService::LoadAlbumScreenShotThumbnailImageEx1, "LoadAlbumScreenShotThumbnailImageEx1"},
+ {1002, C<&IAlbumAccessorService::LoadAlbumScreenShotImageEx1>, "LoadAlbumScreenShotImageEx1"},
+ {1003, C<&IAlbumAccessorService::LoadAlbumScreenShotThumbnailImageEx1>, "LoadAlbumScreenShotThumbnailImageEx1"},
{8001, nullptr, "ForceAlbumUnmounted"},
{8002, nullptr, "ResetAlbumMountStatus"},
{8011, nullptr, "RefreshAlbumCache"},
@@ -62,138 +62,70 @@ IAlbumAccessorService::IAlbumAccessorService(Core::System& system_,
IAlbumAccessorService::~IAlbumAccessorService() = default;
-void IAlbumAccessorService::DeleteAlbumFile(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto file_id{rp.PopRaw<AlbumFileId>()};
-
+Result IAlbumAccessorService::DeleteAlbumFile(AlbumFileId file_id) {
LOG_INFO(Service_Capture, "called, application_id=0x{:0x}, storage={}, type={}",
file_id.application_id, file_id.storage, file_id.type);
- Result result = manager->DeleteAlbumFile(file_id);
- result = TranslateResult(result);
-
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(result);
+ const Result result = manager->DeleteAlbumFile(file_id);
+ R_RETURN(TranslateResult(result));
}
-void IAlbumAccessorService::IsAlbumMounted(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto storage{rp.PopEnum<AlbumStorage>()};
-
+Result IAlbumAccessorService::IsAlbumMounted(Out<bool> out_is_mounted, AlbumStorage storage) {
LOG_INFO(Service_Capture, "called, storage={}", storage);
- Result result = manager->IsAlbumMounted(storage);
- const bool is_mounted = result.IsSuccess();
- result = TranslateResult(result);
-
- IPC::ResponseBuilder rb{ctx, 3};
- rb.Push(result);
- rb.Push<u8>(is_mounted);
+ const Result result = manager->IsAlbumMounted(storage);
+ *out_is_mounted = result.IsSuccess();
+ R_RETURN(TranslateResult(result));
}
-void IAlbumAccessorService::Unknown18(HLERequestContext& ctx) {
- struct UnknownBuffer {
- INSERT_PADDING_BYTES(0x10);
- };
- static_assert(sizeof(UnknownBuffer) == 0x10, "UnknownBuffer is an invalid size");
-
+Result IAlbumAccessorService::Unknown18(
+ Out<u32> out_buffer_size,
+ OutArray<u8, BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure> out_buffer) {
LOG_WARNING(Service_Capture, "(STUBBED) called");
-
- std::vector<UnknownBuffer> buffer{};
-
- if (!buffer.empty()) {
- ctx.WriteBuffer(buffer);
- }
-
- IPC::ResponseBuilder rb{ctx, 3};
- rb.Push(ResultSuccess);
- rb.Push(static_cast<u32>(buffer.size()));
+ *out_buffer_size = 0;
+ R_SUCCEED();
}
-void IAlbumAccessorService::GetAlbumFileListEx0(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto storage{rp.PopEnum<AlbumStorage>()};
- const auto flags{rp.Pop<u8>()};
- const auto album_entry_size{ctx.GetWriteBufferNumElements<AlbumEntry>()};
-
+Result IAlbumAccessorService::GetAlbumFileListEx0(
+ Out<u64> out_entries_size, AlbumStorage storage, u8 flags,
+ OutArray<AlbumEntry, BufferAttr_HipcMapAlias> out_entries) {
LOG_INFO(Service_Capture, "called, storage={}, flags={}", storage, flags);
- std::vector<AlbumEntry> entries;
- Result result = manager->GetAlbumFileList(entries, storage, flags);
- result = TranslateResult(result);
-
- entries.resize(std::min(album_entry_size, entries.size()));
-
- if (!entries.empty()) {
- ctx.WriteBuffer(entries);
- }
-
- IPC::ResponseBuilder rb{ctx, 4};
- rb.Push(result);
- rb.Push<u64>(entries.size());
+ const Result result = manager->GetAlbumFileList(out_entries, *out_entries_size, storage, flags);
+ R_RETURN(TranslateResult(result));
}
-void IAlbumAccessorService::GetAutoSavingStorage(HLERequestContext& ctx) {
+Result IAlbumAccessorService::GetAutoSavingStorage(Out<bool> out_is_autosaving) {
LOG_WARNING(Service_Capture, "(STUBBED) called");
- bool is_autosaving{};
- Result result = manager->GetAutoSavingStorage(is_autosaving);
- result = TranslateResult(result);
-
- IPC::ResponseBuilder rb{ctx, 3};
- rb.Push(result);
- rb.Push<u8>(is_autosaving);
+ const Result result = manager->GetAutoSavingStorage(*out_is_autosaving);
+ R_RETURN(TranslateResult(result));
}
-void IAlbumAccessorService::LoadAlbumScreenShotImageEx1(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto file_id{rp.PopRaw<AlbumFileId>()};
- const auto decoder_options{rp.PopRaw<ScreenShotDecodeOption>()};
- const auto image_buffer_size{ctx.GetWriteBufferSize(1)};
-
+Result IAlbumAccessorService::LoadAlbumScreenShotImageEx1(
+ const AlbumFileId& file_id, const ScreenShotDecodeOption& decoder_options,
+ OutLargeData<LoadAlbumScreenShotImageOutput, BufferAttr_HipcMapAlias> out_image_output,
+ OutArray<u8, BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure> out_image,
+ OutArray<u8, BufferAttr_HipcMapAlias> out_buffer) {
LOG_INFO(Service_Capture, "called, application_id=0x{:0x}, storage={}, type={}, flags={}",
file_id.application_id, file_id.storage, file_id.type, decoder_options.flags);
- std::vector<u8> image;
- LoadAlbumScreenShotImageOutput image_output;
- Result result =
- manager->LoadAlbumScreenShotImage(image_output, image, file_id, decoder_options);
- result = TranslateResult(result);
-
- if (image.size() > image_buffer_size) {
- result = ResultWorkMemoryError;
- }
-
- if (result.IsSuccess()) {
- ctx.WriteBuffer(image_output, 0);
- ctx.WriteBuffer(image, 1);
- }
-
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(result);
+ const Result result =
+ manager->LoadAlbumScreenShotImage(*out_image_output, out_image, file_id, decoder_options);
+ R_RETURN(TranslateResult(result));
}
-void IAlbumAccessorService::LoadAlbumScreenShotThumbnailImageEx1(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto file_id{rp.PopRaw<AlbumFileId>()};
- const auto decoder_options{rp.PopRaw<ScreenShotDecodeOption>()};
-
+Result IAlbumAccessorService::LoadAlbumScreenShotThumbnailImageEx1(
+ const AlbumFileId& file_id, const ScreenShotDecodeOption& decoder_options,
+ OutLargeData<LoadAlbumScreenShotImageOutput, BufferAttr_HipcMapAlias> out_image_output,
+ OutArray<u8, BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure> out_image,
+ OutArray<u8, BufferAttr_HipcMapAlias> out_buffer) {
LOG_INFO(Service_Capture, "called, application_id=0x{:0x}, storage={}, type={}, flags={}",
file_id.application_id, file_id.storage, file_id.type, decoder_options.flags);
- std::vector<u8> image(ctx.GetWriteBufferSize(1));
- LoadAlbumScreenShotImageOutput image_output;
- Result result =
- manager->LoadAlbumScreenShotThumbnail(image_output, image, file_id, decoder_options);
- result = TranslateResult(result);
-
- if (result.IsSuccess()) {
- ctx.WriteBuffer(image_output, 0);
- ctx.WriteBuffer(image, 1);
- }
-
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(result);
+ const Result result = manager->LoadAlbumScreenShotThumbnail(*out_image_output, out_image,
+ file_id, decoder_options);
+ R_RETURN(TranslateResult(result));
}
Result IAlbumAccessorService::TranslateResult(Result in_result) {
diff --git a/src/core/hle/service/caps/caps_a.h b/src/core/hle/service/caps/caps_a.h
index c90cff71e..2cb9b4547 100644
--- a/src/core/hle/service/caps/caps_a.h
+++ b/src/core/hle/service/caps/caps_a.h
@@ -3,6 +3,8 @@
#pragma once
+#include "core/hle/service/caps/caps_types.h"
+#include "core/hle/service/cmif_types.h"
#include "core/hle/service/service.h"
namespace Core {
@@ -19,13 +21,31 @@ public:
~IAlbumAccessorService() override;
private:
- void DeleteAlbumFile(HLERequestContext& ctx);
- void IsAlbumMounted(HLERequestContext& ctx);
- void Unknown18(HLERequestContext& ctx);
- void GetAlbumFileListEx0(HLERequestContext& ctx);
- void GetAutoSavingStorage(HLERequestContext& ctx);
- void LoadAlbumScreenShotImageEx1(HLERequestContext& ctx);
- void LoadAlbumScreenShotThumbnailImageEx1(HLERequestContext& ctx);
+ Result DeleteAlbumFile(AlbumFileId file_id);
+
+ Result IsAlbumMounted(Out<bool> out_is_mounted, AlbumStorage storage);
+
+ Result Unknown18(
+ Out<u32> out_buffer_size,
+ OutArray<u8, BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure>
+ out_buffer);
+
+ Result GetAlbumFileListEx0(Out<u64> out_entries_size, AlbumStorage storage, u8 flags,
+ OutArray<AlbumEntry, BufferAttr_HipcMapAlias> out_entries);
+
+ Result GetAutoSavingStorage(Out<bool> out_is_autosaving);
+
+ Result LoadAlbumScreenShotImageEx1(
+ const AlbumFileId& file_id, const ScreenShotDecodeOption& decoder_options,
+ OutLargeData<LoadAlbumScreenShotImageOutput, BufferAttr_HipcMapAlias> out_image_output,
+ OutArray<u8, BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure> out_image,
+ OutArray<u8, BufferAttr_HipcMapAlias> out_buffer);
+
+ Result LoadAlbumScreenShotThumbnailImageEx1(
+ const AlbumFileId& file_id, const ScreenShotDecodeOption& decoder_options,
+ OutLargeData<LoadAlbumScreenShotImageOutput, BufferAttr_HipcMapAlias> out_image_output,
+ OutArray<u8, BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure> out_image,
+ OutArray<u8, BufferAttr_HipcMapAlias> out_buffer);
Result TranslateResult(Result in_result);
diff --git a/src/core/hle/service/caps/caps_c.cpp b/src/core/hle/service/caps/caps_c.cpp
index 1e7fe6474..6993c04c2 100644
--- a/src/core/hle/service/caps/caps_c.cpp
+++ b/src/core/hle/service/caps/caps_c.cpp
@@ -6,6 +6,7 @@
#include "core/hle/service/caps/caps_manager.h"
#include "core/hle/service/caps/caps_result.h"
#include "core/hle/service/caps/caps_types.h"
+#include "core/hle/service/cmif_serialization.h"
#include "core/hle/service/ipc_helpers.h"
namespace Service::Capture {
@@ -17,7 +18,7 @@ IAlbumControlService::IAlbumControlService(Core::System& system_,
static const FunctionInfo functions[] = {
{1, nullptr, "CaptureRawImage"},
{2, nullptr, "CaptureRawImageWithTimeout"},
- {33, &IAlbumControlService::SetShimLibraryVersion, "SetShimLibraryVersion"},
+ {33, C<&IAlbumControlService::SetShimLibraryVersion>, "SetShimLibraryVersion"},
{1001, nullptr, "RequestTakingScreenShot"},
{1002, nullptr, "RequestTakingScreenShotWithTimeout"},
{1011, nullptr, "NotifyTakingScreenShotRefused"},
@@ -42,16 +43,11 @@ IAlbumControlService::IAlbumControlService(Core::System& system_,
IAlbumControlService::~IAlbumControlService() = default;
-void IAlbumControlService::SetShimLibraryVersion(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto library_version{rp.Pop<u64>()};
- const auto applet_resource_user_id{rp.Pop<u64>()};
-
+Result IAlbumControlService::SetShimLibraryVersion(ShimLibraryVersion library_version,
+ ClientAppletResourceUserId aruid) {
LOG_WARNING(Service_Capture, "(STUBBED) called. library_version={}, applet_resource_user_id={}",
- library_version, applet_resource_user_id);
-
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultSuccess);
+ library_version, aruid.pid);
+ R_SUCCEED();
}
} // namespace Service::Capture
diff --git a/src/core/hle/service/caps/caps_c.h b/src/core/hle/service/caps/caps_c.h
index 92ba242db..0ecdfa114 100644
--- a/src/core/hle/service/caps/caps_c.h
+++ b/src/core/hle/service/caps/caps_c.h
@@ -3,6 +3,7 @@
#pragma once
+#include "core/hle/service/cmif_types.h"
#include "core/hle/service/service.h"
namespace Core {
@@ -11,6 +12,7 @@ class System;
namespace Service::Capture {
class AlbumManager;
+enum class ShimLibraryVersion : u64;
class IAlbumControlService final : public ServiceFramework<IAlbumControlService> {
public:
@@ -19,7 +21,8 @@ public:
~IAlbumControlService() override;
private:
- void SetShimLibraryVersion(HLERequestContext& ctx);
+ Result SetShimLibraryVersion(ShimLibraryVersion library_version,
+ ClientAppletResourceUserId aruid);
std::shared_ptr<AlbumManager> manager = nullptr;
};
diff --git a/src/core/hle/service/caps/caps_manager.cpp b/src/core/hle/service/caps/caps_manager.cpp
index 3a22b135f..7f0bc127f 100644
--- a/src/core/hle/service/caps/caps_manager.cpp
+++ b/src/core/hle/service/caps/caps_manager.cpp
@@ -58,8 +58,8 @@ Result AlbumManager::IsAlbumMounted(AlbumStorage storage) {
return is_mounted ? ResultSuccess : ResultIsNotMounted;
}
-Result AlbumManager::GetAlbumFileList(std::vector<AlbumEntry>& out_entries, AlbumStorage storage,
- u8 flags) const {
+Result AlbumManager::GetAlbumFileList(std::span<AlbumEntry> out_entries, u64& out_entries_count,
+ AlbumStorage storage, u8 flags) const {
if (storage > AlbumStorage::Sd) {
return ResultInvalidStorage;
}
@@ -72,51 +72,55 @@ Result AlbumManager::GetAlbumFileList(std::vector<AlbumEntry>& out_entries, Albu
if (file_id.storage != storage) {
continue;
}
- if (out_entries.size() >= SdAlbumFileLimit) {
+ if (out_entries_count >= SdAlbumFileLimit) {
+ break;
+ }
+ if (out_entries_count >= out_entries.size()) {
break;
}
const auto entry_size = Common::FS::GetSize(path);
- out_entries.push_back({
+ out_entries[out_entries_count++] = {
.entry_size = entry_size,
.file_id = file_id,
- });
+ };
}
return ResultSuccess;
}
-Result AlbumManager::GetAlbumFileList(std::vector<ApplicationAlbumFileEntry>& out_entries,
- ContentType content_type, s64 start_posix_time,
- s64 end_posix_time, u64 aruid) const {
+Result AlbumManager::GetAlbumFileList(std::span<ApplicationAlbumFileEntry> out_entries,
+ u64& out_entries_count, ContentType content_type,
+ s64 start_posix_time, s64 end_posix_time, u64 aruid) const {
if (!is_mounted) {
return ResultIsNotMounted;
}
- std::vector<ApplicationAlbumEntry> album_entries;
+ std::vector<ApplicationAlbumEntry> album_entries(out_entries.size());
const auto start_date = ConvertToAlbumDateTime(start_posix_time);
const auto end_date = ConvertToAlbumDateTime(end_posix_time);
- const auto result = GetAlbumFileList(album_entries, content_type, start_date, end_date, aruid);
+ const auto result = GetAlbumFileList(album_entries, out_entries_count, content_type, start_date,
+ end_date, aruid);
if (result.IsError()) {
return result;
}
- for (const auto& album_entry : album_entries) {
- ApplicationAlbumFileEntry entry{
- .entry = album_entry,
- .datetime = album_entry.datetime,
+ for (std::size_t i = 0; i < out_entries_count; i++) {
+ out_entries[i] = {
+ .entry = album_entries[i],
+ .datetime = album_entries[i].datetime,
.unknown = {},
};
- out_entries.push_back(entry);
}
return ResultSuccess;
}
-Result AlbumManager::GetAlbumFileList(std::vector<ApplicationAlbumEntry>& out_entries,
- ContentType content_type, AlbumFileDateTime start_date,
- AlbumFileDateTime end_date, u64 aruid) const {
+Result AlbumManager::GetAlbumFileList(std::span<ApplicationAlbumEntry> out_entries,
+ u64& out_entries_count, ContentType content_type,
+ AlbumFileDateTime start_date, AlbumFileDateTime end_date,
+ u64 aruid) const {
if (!is_mounted) {
return ResultIsNotMounted;
}
@@ -131,12 +135,15 @@ Result AlbumManager::GetAlbumFileList(std::vector<ApplicationAlbumEntry>& out_en
if (file_id.date < end_date) {
continue;
}
- if (out_entries.size() >= SdAlbumFileLimit) {
+ if (out_entries_count >= SdAlbumFileLimit) {
+ break;
+ }
+ if (out_entries_count >= out_entries.size()) {
break;
}
const auto entry_size = Common::FS::GetSize(path);
- ApplicationAlbumEntry entry{
+ out_entries[out_entries_count++] = {
.size = entry_size,
.hash{},
.datetime = file_id.date,
@@ -144,7 +151,6 @@ Result AlbumManager::GetAlbumFileList(std::vector<ApplicationAlbumEntry>& out_en
.content = content_type,
.unknown = 1,
};
- out_entries.push_back(entry);
}
return ResultSuccess;
@@ -156,8 +162,7 @@ Result AlbumManager::GetAutoSavingStorage(bool& out_is_autosaving) const {
}
Result AlbumManager::LoadAlbumScreenShotImage(LoadAlbumScreenShotImageOutput& out_image_output,
- std::vector<u8>& out_image,
- const AlbumFileId& file_id,
+ std::span<u8> out_image, const AlbumFileId& file_id,
const ScreenShotDecodeOption& decoder_options) const {
if (file_id.storage > AlbumStorage::Sd) {
return ResultInvalidStorage;
@@ -176,7 +181,9 @@ Result AlbumManager::LoadAlbumScreenShotImage(LoadAlbumScreenShotImageOutput& ou
.orientation = AlbumImageOrientation::None,
.unknown_1{},
.unknown_2{},
+ .pad163{},
},
+ .pad179{},
};
std::filesystem::path path;
@@ -186,14 +193,12 @@ Result AlbumManager::LoadAlbumScreenShotImage(LoadAlbumScreenShotImageOutput& ou
return result;
}
- out_image.resize(out_image_output.height * out_image_output.width * STBI_rgb_alpha);
-
return LoadImage(out_image, path, static_cast<int>(out_image_output.width),
+static_cast<int>(out_image_output.height), decoder_options.flags);
}
Result AlbumManager::LoadAlbumScreenShotThumbnail(
- LoadAlbumScreenShotImageOutput& out_image_output, std::vector<u8>& out_image,
+ LoadAlbumScreenShotImageOutput& out_image_output, std::span<u8> out_image,
const AlbumFileId& file_id, const ScreenShotDecodeOption& decoder_options) const {
if (file_id.storage > AlbumStorage::Sd) {
return ResultInvalidStorage;
@@ -212,7 +217,9 @@ Result AlbumManager::LoadAlbumScreenShotThumbnail(
.orientation = AlbumImageOrientation::None,
.unknown_1{},
.unknown_2{},
+ .pad163{},
},
+ .pad179{},
};
std::filesystem::path path;
@@ -222,8 +229,6 @@ Result AlbumManager::LoadAlbumScreenShotThumbnail(
return result;
}
- out_image.resize(out_image_output.height * out_image_output.width * STBI_rgb_alpha);
-
return LoadImage(out_image, path, static_cast<int>(out_image_output.width),
+static_cast<int>(out_image_output.height), decoder_options.flags);
}
diff --git a/src/core/hle/service/caps/caps_manager.h b/src/core/hle/service/caps/caps_manager.h
index 6fd34f589..893a9075a 100644
--- a/src/core/hle/service/caps/caps_manager.h
+++ b/src/core/hle/service/caps/caps_manager.h
@@ -42,20 +42,20 @@ public:
Result DeleteAlbumFile(const AlbumFileId& file_id);
Result IsAlbumMounted(AlbumStorage storage);
- Result GetAlbumFileList(std::vector<AlbumEntry>& out_entries, AlbumStorage storage,
- u8 flags) const;
- Result GetAlbumFileList(std::vector<ApplicationAlbumFileEntry>& out_entries,
- ContentType content_type, s64 start_posix_time, s64 end_posix_time,
- u64 aruid) const;
- Result GetAlbumFileList(std::vector<ApplicationAlbumEntry>& out_entries,
+ Result GetAlbumFileList(std::span<AlbumEntry> out_entries, u64& out_entries_count,
+ AlbumStorage storage, u8 flags) const;
+ Result GetAlbumFileList(std::span<ApplicationAlbumFileEntry> out_entries,
+ u64& out_entries_count, ContentType content_type, s64 start_posix_time,
+ s64 end_posix_time, u64 aruid) const;
+ Result GetAlbumFileList(std::span<ApplicationAlbumEntry> out_entries, u64& out_entries_count,
ContentType content_type, AlbumFileDateTime start_date,
AlbumFileDateTime end_date, u64 aruid) const;
Result GetAutoSavingStorage(bool& out_is_autosaving) const;
Result LoadAlbumScreenShotImage(LoadAlbumScreenShotImageOutput& out_image_output,
- std::vector<u8>& out_image, const AlbumFileId& file_id,
+ std::span<u8> out_image, const AlbumFileId& file_id,
const ScreenShotDecodeOption& decoder_options) const;
Result LoadAlbumScreenShotThumbnail(LoadAlbumScreenShotImageOutput& out_image_output,
- std::vector<u8>& out_image, const AlbumFileId& file_id,
+ std::span<u8> out_image, const AlbumFileId& file_id,
const ScreenShotDecodeOption& decoder_options) const;
Result SaveScreenShot(ApplicationAlbumEntry& out_entry, const ScreenShotAttribute& attribute,
diff --git a/src/core/hle/service/caps/caps_ss.cpp b/src/core/hle/service/caps/caps_ss.cpp
index eab023568..dfa7f1a84 100644
--- a/src/core/hle/service/caps/caps_ss.cpp
+++ b/src/core/hle/service/caps/caps_ss.cpp
@@ -3,10 +3,9 @@
#include "common/logging/log.h"
#include "core/hle/service/caps/caps_manager.h"
-#include "core/hle/service/caps/caps_types.h"
-#include "core/hle/service/ipc_helpers.h"
-
#include "core/hle/service/caps/caps_ss.h"
+#include "core/hle/service/cmif_serialization.h"
+#include "core/hle/service/ipc_helpers.h"
namespace Service::Capture {
@@ -17,9 +16,9 @@ IScreenShotService::IScreenShotService(Core::System& system_,
static const FunctionInfo functions[] = {
{201, nullptr, "SaveScreenShot"},
{202, nullptr, "SaveEditedScreenShot"},
- {203, &IScreenShotService::SaveScreenShotEx0, "SaveScreenShotEx0"},
+ {203, C<&IScreenShotService::SaveScreenShotEx0>, "SaveScreenShotEx0"},
{204, nullptr, "SaveEditedScreenShotEx0"},
- {206, &IScreenShotService::SaveEditedScreenShotEx1, "SaveEditedScreenShotEx1"},
+ {206, C<&IScreenShotService::SaveEditedScreenShotEx1>, "SaveEditedScreenShotEx1"},
{208, nullptr, "SaveScreenShotOfMovieEx1"},
{1000, nullptr, "Unknown1000"},
};
@@ -30,69 +29,38 @@ IScreenShotService::IScreenShotService(Core::System& system_,
IScreenShotService::~IScreenShotService() = default;
-void IScreenShotService::SaveScreenShotEx0(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- struct Parameters {
- ScreenShotAttribute attribute{};
- AlbumReportOption report_option{};
- INSERT_PADDING_BYTES(0x4);
- u64 applet_resource_user_id{};
- };
- static_assert(sizeof(Parameters) == 0x50, "Parameters has incorrect size.");
-
- const auto parameters{rp.PopRaw<Parameters>()};
- const auto image_data_buffer = ctx.ReadBuffer();
-
+Result IScreenShotService::SaveScreenShotEx0(
+ Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute,
+ AlbumReportOption report_option, ClientAppletResourceUserId aruid,
+ InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
+ image_data_buffer) {
LOG_INFO(Service_Capture,
"called, report_option={}, image_data_buffer_size={}, applet_resource_user_id={}",
- parameters.report_option, image_data_buffer.size(),
- parameters.applet_resource_user_id);
+ report_option, image_data_buffer.size(), aruid.pid);
- ApplicationAlbumEntry entry{};
manager->FlipVerticallyOnWrite(false);
- const auto result =
- manager->SaveScreenShot(entry, parameters.attribute, parameters.report_option,
- image_data_buffer, parameters.applet_resource_user_id);
-
- IPC::ResponseBuilder rb{ctx, 10};
- rb.Push(result);
- rb.PushRaw(entry);
+ R_RETURN(manager->SaveScreenShot(*out_entry, attribute, report_option, image_data_buffer,
+ aruid.pid));
}
-void IScreenShotService::SaveEditedScreenShotEx1(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- struct Parameters {
- ScreenShotAttribute attribute;
- u64 width;
- u64 height;
- u64 thumbnail_width;
- u64 thumbnail_height;
- AlbumFileId file_id;
- };
- static_assert(sizeof(Parameters) == 0x78, "Parameters has incorrect size.");
-
- const auto parameters{rp.PopRaw<Parameters>()};
- const auto application_data_buffer = ctx.ReadBuffer(0);
- const auto image_data_buffer = ctx.ReadBuffer(1);
- const auto thumbnail_image_data_buffer = ctx.ReadBuffer(2);
-
+Result IScreenShotService::SaveEditedScreenShotEx1(
+ Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute, u64 width,
+ u64 height, u64 thumbnail_width, u64 thumbnail_height, const AlbumFileId& file_id,
+ const InLargeData<std::array<u8, 0x400>, BufferAttr_HipcMapAlias> application_data_buffer,
+ const InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
+ image_data_buffer,
+ const InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
+ thumbnail_image_data_buffer) {
LOG_INFO(Service_Capture,
"called, width={}, height={}, thumbnail_width={}, thumbnail_height={}, "
- "application_id={:016x}, storage={}, type={}, app_data_buffer_size={}, "
+ "application_id={:016x}, storage={}, type={}, "
"image_data_buffer_size={}, thumbnail_image_buffer_size={}",
- parameters.width, parameters.height, parameters.thumbnail_width,
- parameters.thumbnail_height, parameters.file_id.application_id,
- parameters.file_id.storage, parameters.file_id.type, application_data_buffer.size(),
- image_data_buffer.size(), thumbnail_image_data_buffer.size());
+ width, height, thumbnail_width, thumbnail_height, file_id.application_id,
+ file_id.storage, file_id.type, image_data_buffer.size(),
+ thumbnail_image_data_buffer.size());
- ApplicationAlbumEntry entry{};
manager->FlipVerticallyOnWrite(false);
- const auto result = manager->SaveEditedScreenShot(entry, parameters.attribute,
- parameters.file_id, image_data_buffer);
-
- IPC::ResponseBuilder rb{ctx, 10};
- rb.Push(result);
- rb.PushRaw(entry);
+ R_RETURN(manager->SaveEditedScreenShot(*out_entry, attribute, file_id, image_data_buffer));
}
} // namespace Service::Capture
diff --git a/src/core/hle/service/caps/caps_ss.h b/src/core/hle/service/caps/caps_ss.h
index a7e9972ab..da4b4cc5f 100644
--- a/src/core/hle/service/caps/caps_ss.h
+++ b/src/core/hle/service/caps/caps_ss.h
@@ -3,6 +3,8 @@
#pragma once
+#include "core/hle/service/caps/caps_types.h"
+#include "core/hle/service/cmif_types.h"
#include "core/hle/service/service.h"
namespace Core {
@@ -17,8 +19,20 @@ public:
~IScreenShotService() override;
private:
- void SaveScreenShotEx0(HLERequestContext& ctx);
- void SaveEditedScreenShotEx1(HLERequestContext& ctx);
+ Result SaveScreenShotEx0(
+ Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute,
+ AlbumReportOption report_option, ClientAppletResourceUserId aruid,
+ InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
+ image_data_buffer);
+
+ Result SaveEditedScreenShotEx1(
+ Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute, u64 width,
+ u64 height, u64 thumbnail_width, u64 thumbnail_height, const AlbumFileId& file_id,
+ const InLargeData<std::array<u8, 0x400>, BufferAttr_HipcMapAlias> application_data_buffer,
+ const InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
+ image_data_buffer,
+ const InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
+ thumbnail_image_data_buffer);
std::shared_ptr<AlbumManager> manager;
};
diff --git a/src/core/hle/service/caps/caps_su.cpp b/src/core/hle/service/caps/caps_su.cpp
index 296b07b00..528f364f5 100644
--- a/src/core/hle/service/caps/caps_su.cpp
+++ b/src/core/hle/service/caps/caps_su.cpp
@@ -6,6 +6,7 @@
#include "core/hle/service/caps/caps_manager.h"
#include "core/hle/service/caps/caps_su.h"
#include "core/hle/service/caps/caps_types.h"
+#include "core/hle/service/cmif_serialization.h"
#include "core/hle/service/ipc_helpers.h"
#include "video_core/renderer_base.h"
@@ -16,10 +17,10 @@ IScreenShotApplicationService::IScreenShotApplicationService(
: ServiceFramework{system_, "caps:su"}, manager{album_manager} {
// clang-format off
static const FunctionInfo functions[] = {
- {32, &IScreenShotApplicationService::SetShimLibraryVersion, "SetShimLibraryVersion"},
+ {32, C<&IScreenShotApplicationService::SetShimLibraryVersion>, "SetShimLibraryVersion"},
{201, nullptr, "SaveScreenShot"},
- {203, &IScreenShotApplicationService::SaveScreenShotEx0, "SaveScreenShotEx0"},
- {205, &IScreenShotApplicationService::SaveScreenShotEx1, "SaveScreenShotEx1"},
+ {203, C<&IScreenShotApplicationService::SaveScreenShotEx0>, "SaveScreenShotEx0"},
+ {205, C<&IScreenShotApplicationService::SaveScreenShotEx1>, "SaveScreenShotEx1"},
{210, nullptr, "SaveScreenShotEx2"},
};
// clang-format on
@@ -29,77 +30,40 @@ IScreenShotApplicationService::IScreenShotApplicationService(
IScreenShotApplicationService::~IScreenShotApplicationService() = default;
-void IScreenShotApplicationService::SetShimLibraryVersion(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto library_version{rp.Pop<u64>()};
- const auto applet_resource_user_id{rp.Pop<u64>()};
-
+Result IScreenShotApplicationService::SetShimLibraryVersion(ShimLibraryVersion library_version,
+ ClientAppletResourceUserId aruid) {
LOG_WARNING(Service_Capture, "(STUBBED) called. library_version={}, applet_resource_user_id={}",
- library_version, applet_resource_user_id);
-
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultSuccess);
+ library_version, aruid.pid);
+ R_SUCCEED();
}
-void IScreenShotApplicationService::SaveScreenShotEx0(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- struct Parameters {
- ScreenShotAttribute attribute{};
- AlbumReportOption report_option{};
- INSERT_PADDING_BYTES(0x4);
- u64 applet_resource_user_id{};
- };
- static_assert(sizeof(Parameters) == 0x50, "Parameters has incorrect size.");
-
- const auto parameters{rp.PopRaw<Parameters>()};
- const auto image_data_buffer = ctx.ReadBuffer();
-
+Result IScreenShotApplicationService::SaveScreenShotEx0(
+ Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute,
+ AlbumReportOption report_option, ClientAppletResourceUserId aruid,
+ InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
+ image_data_buffer) {
LOG_INFO(Service_Capture,
"called, report_option={}, image_data_buffer_size={}, applet_resource_user_id={}",
- parameters.report_option, image_data_buffer.size(),
- parameters.applet_resource_user_id);
+ report_option, image_data_buffer.size(), aruid.pid);
- ApplicationAlbumEntry entry{};
manager->FlipVerticallyOnWrite(false);
- const auto result =
- manager->SaveScreenShot(entry, parameters.attribute, parameters.report_option,
- image_data_buffer, parameters.applet_resource_user_id);
-
- IPC::ResponseBuilder rb{ctx, 10};
- rb.Push(result);
- rb.PushRaw(entry);
+ R_RETURN(manager->SaveScreenShot(*out_entry, attribute, report_option, image_data_buffer,
+ aruid.pid));
}
-void IScreenShotApplicationService::SaveScreenShotEx1(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- struct Parameters {
- ScreenShotAttribute attribute{};
- AlbumReportOption report_option{};
- INSERT_PADDING_BYTES(0x4);
- u64 applet_resource_user_id{};
- };
- static_assert(sizeof(Parameters) == 0x50, "Parameters has incorrect size.");
-
- const auto parameters{rp.PopRaw<Parameters>()};
- const auto app_data_buffer = ctx.ReadBuffer(0);
- const auto image_data_buffer = ctx.ReadBuffer(1);
-
+Result IScreenShotApplicationService::SaveScreenShotEx1(
+ Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute,
+ AlbumReportOption report_option, ClientAppletResourceUserId aruid,
+ const InLargeData<ApplicationData, BufferAttr_HipcMapAlias> app_data_buffer,
+ const InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
+ image_data_buffer) {
LOG_INFO(Service_Capture,
"called, report_option={}, image_data_buffer_size={}, applet_resource_user_id={}",
- parameters.report_option, image_data_buffer.size(),
- parameters.applet_resource_user_id);
+ report_option, image_data_buffer.size(), aruid.pid);
- ApplicationAlbumEntry entry{};
- ApplicationData app_data{};
- std::memcpy(&app_data, app_data_buffer.data(), sizeof(ApplicationData));
manager->FlipVerticallyOnWrite(false);
- const auto result =
- manager->SaveScreenShot(entry, parameters.attribute, parameters.report_option, app_data,
- image_data_buffer, parameters.applet_resource_user_id);
-
- IPC::ResponseBuilder rb{ctx, 10};
- rb.Push(result);
- rb.PushRaw(entry);
+ R_RETURN(manager->SaveScreenShot(*out_entry, attribute, report_option, *app_data_buffer,
+ image_data_buffer, aruid.pid));
}
void IScreenShotApplicationService::CaptureAndSaveScreenshot(AlbumReportOption report_option) {
@@ -112,6 +76,7 @@ void IScreenShotApplicationService::CaptureAndSaveScreenshot(AlbumReportOption r
.orientation = Capture::AlbumImageOrientation::None,
.unknown_1{},
.unknown_2{},
+ .pad163{},
};
renderer.RequestScreenshot(
diff --git a/src/core/hle/service/caps/caps_su.h b/src/core/hle/service/caps/caps_su.h
index 21912e95f..4b4cbd09e 100644
--- a/src/core/hle/service/caps/caps_su.h
+++ b/src/core/hle/service/caps/caps_su.h
@@ -3,6 +3,8 @@
#pragma once
+#include "core/hle/service/caps/caps_types.h"
+#include "core/hle/service/cmif_types.h"
#include "core/hle/service/service.h"
namespace Core {
@@ -26,9 +28,19 @@ private:
static constexpr std::size_t screenshot_height = 720;
static constexpr std::size_t bytes_per_pixel = 4;
- void SetShimLibraryVersion(HLERequestContext& ctx);
- void SaveScreenShotEx0(HLERequestContext& ctx);
- void SaveScreenShotEx1(HLERequestContext& ctx);
+ Result SetShimLibraryVersion(ShimLibraryVersion library_version,
+ ClientAppletResourceUserId aruid);
+ Result SaveScreenShotEx0(
+ Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute,
+ AlbumReportOption report_option, ClientAppletResourceUserId aruid,
+ InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
+ image_data_buffer);
+ Result SaveScreenShotEx1(
+ Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute,
+ AlbumReportOption report_option, ClientAppletResourceUserId aruid,
+ const InLargeData<ApplicationData, BufferAttr_HipcMapAlias> app_data_buffer,
+ const InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
+ image_data_buffer);
std::array<u8, screenshot_width * screenshot_height * bytes_per_pixel> image_data;
diff --git a/src/core/hle/service/caps/caps_types.h b/src/core/hle/service/caps/caps_types.h
index 589ac28d3..3deaaad5b 100644
--- a/src/core/hle/service/caps/caps_types.h
+++ b/src/core/hle/service/caps/caps_types.h
@@ -41,6 +41,10 @@ enum class ScreenShotDecoderFlag : u64 {
EnableBlockSmoothing = 1 << 1,
};
+enum class ShimLibraryVersion : u64 {
+ Version1 = 1,
+};
+
// This is nn::capsrv::AlbumFileDateTime
struct AlbumFileDateTime {
s16 year{};
@@ -144,19 +148,23 @@ static_assert(sizeof(ApplicationAlbumFileEntry) == 0x30,
"ApplicationAlbumFileEntry has incorrect size.");
struct ApplicationData {
- std::array<u8, 0x400> data{};
- u32 data_size{};
+ std::array<u8, 0x400> data;
+ u32 data_size;
};
static_assert(sizeof(ApplicationData) == 0x404, "ApplicationData is an invalid size");
+static_assert(std::is_trivial_v<ApplicationData>,
+ "ApplicationData type must be trivially copyable.");
struct ScreenShotAttribute {
- u32 unknown_0{};
- AlbumImageOrientation orientation{};
- u32 unknown_1{};
- u32 unknown_2{};
- INSERT_PADDING_BYTES(0x30);
+ u32 unknown_0;
+ AlbumImageOrientation orientation;
+ u32 unknown_1;
+ u32 unknown_2;
+ INSERT_PADDING_BYTES_NOINIT(0x30);
};
static_assert(sizeof(ScreenShotAttribute) == 0x40, "ScreenShotAttribute is an invalid size");
+static_assert(std::is_trivial_v<ScreenShotAttribute>,
+ "ScreenShotAttribute type must be trivially copyable.");
struct ScreenShotDecodeOption {
ScreenShotDecoderFlag flags{};
@@ -165,13 +173,15 @@ struct ScreenShotDecodeOption {
static_assert(sizeof(ScreenShotDecodeOption) == 0x20, "ScreenShotDecodeOption is an invalid size");
struct LoadAlbumScreenShotImageOutput {
- s64 width{};
- s64 height{};
- ScreenShotAttribute attribute{};
- INSERT_PADDING_BYTES(0x400);
+ s64 width;
+ s64 height;
+ ScreenShotAttribute attribute;
+ INSERT_PADDING_BYTES_NOINIT(0x400);
};
static_assert(sizeof(LoadAlbumScreenShotImageOutput) == 0x450,
"LoadAlbumScreenShotImageOutput is an invalid size");
+static_assert(std::is_trivial_v<LoadAlbumScreenShotImageOutput>,
+ "LoadAlbumScreenShotImageOutput type must be trivially copyable.");
struct LoadAlbumScreenShotImageOutputForApplication {
s64 width{};
diff --git a/src/core/hle/service/caps/caps_u.cpp b/src/core/hle/service/caps/caps_u.cpp
index b6b33fb2f..40d4d05fe 100644
--- a/src/core/hle/service/caps/caps_u.cpp
+++ b/src/core/hle/service/caps/caps_u.cpp
@@ -5,6 +5,7 @@
#include "core/hle/service/caps/caps_manager.h"
#include "core/hle/service/caps/caps_types.h"
#include "core/hle/service/caps/caps_u.h"
+#include "core/hle/service/cmif_serialization.h"
#include "core/hle/service/ipc_helpers.h"
namespace Service::Capture {
@@ -14,8 +15,8 @@ IAlbumApplicationService::IAlbumApplicationService(Core::System& system_,
: ServiceFramework{system_, "caps:u"}, manager{album_manager} {
// clang-format off
static const FunctionInfo functions[] = {
- {32, &IAlbumApplicationService::SetShimLibraryVersion, "SetShimLibraryVersion"},
- {102, &IAlbumApplicationService::GetAlbumFileList0AafeAruidDeprecated, "GetAlbumFileList0AafeAruidDeprecated"},
+ {32, C<&IAlbumApplicationService::SetShimLibraryVersion>, "SetShimLibraryVersion"},
+ {102, C<&IAlbumApplicationService::GetAlbumFileList0AafeAruidDeprecated>, "GetAlbumFileList0AafeAruidDeprecated"},
{103, nullptr, "DeleteAlbumFileByAruid"},
{104, nullptr, "GetAlbumFileSizeByAruid"},
{105, nullptr, "DeleteAlbumFileByAruidForDebug"},
@@ -24,7 +25,7 @@ IAlbumApplicationService::IAlbumApplicationService(Core::System& system_,
{130, nullptr, "PrecheckToCreateContentsByAruid"},
{140, nullptr, "GetAlbumFileList1AafeAruidDeprecated"},
{141, nullptr, "GetAlbumFileList2AafeUidAruidDeprecated"},
- {142, &IAlbumApplicationService::GetAlbumFileList3AaeAruid, "GetAlbumFileList3AaeAruid"},
+ {142, C<&IAlbumApplicationService::GetAlbumFileList3AaeAruid>, "GetAlbumFileList3AaeAruid"},
{143, nullptr, "GetAlbumFileList4AaeUidAruid"},
{144, nullptr, "GetAllAlbumFileList3AaeAruid"},
{60002, nullptr, "OpenAccessorSessionForApplication"},
@@ -36,101 +37,40 @@ IAlbumApplicationService::IAlbumApplicationService(Core::System& system_,
IAlbumApplicationService::~IAlbumApplicationService() = default;
-void IAlbumApplicationService::SetShimLibraryVersion(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto library_version{rp.Pop<u64>()};
- const auto applet_resource_user_id{rp.Pop<u64>()};
-
+Result IAlbumApplicationService::SetShimLibraryVersion(ShimLibraryVersion library_version,
+ ClientAppletResourceUserId aruid) {
LOG_WARNING(Service_Capture, "(STUBBED) called. library_version={}, applet_resource_user_id={}",
- library_version, applet_resource_user_id);
-
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultSuccess);
+ library_version, aruid.pid);
+ R_SUCCEED();
}
-void IAlbumApplicationService::GetAlbumFileList0AafeAruidDeprecated(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- struct Parameters {
- ContentType content_type;
- INSERT_PADDING_BYTES(7);
- s64 start_posix_time;
- s64 end_posix_time;
- u64 applet_resource_user_id;
- };
- static_assert(sizeof(Parameters) == 0x20, "Parameters has incorrect size.");
-
- const auto parameters{rp.PopRaw<Parameters>()};
-
+Result IAlbumApplicationService::GetAlbumFileList0AafeAruidDeprecated(
+ Out<u64> out_entries_count, ContentType content_type, s64 start_posix_time, s64 end_posix_time,
+ ClientAppletResourceUserId aruid,
+ OutArray<ApplicationAlbumFileEntry, BufferAttr_HipcMapAlias> out_entries) {
LOG_WARNING(Service_Capture,
"(STUBBED) called. content_type={}, start_posix_time={}, end_posix_time={}, "
"applet_resource_user_id={}",
- parameters.content_type, parameters.start_posix_time, parameters.end_posix_time,
- parameters.applet_resource_user_id);
-
- Result result = ResultSuccess;
-
- if (result.IsSuccess()) {
- result = manager->IsAlbumMounted(AlbumStorage::Sd);
- }
-
- std::vector<ApplicationAlbumFileEntry> entries;
- if (result.IsSuccess()) {
- result = manager->GetAlbumFileList(entries, parameters.content_type,
- parameters.start_posix_time, parameters.end_posix_time,
- parameters.applet_resource_user_id);
- }
+ content_type, start_posix_time, end_posix_time, aruid.pid);
- if (!entries.empty()) {
- ctx.WriteBuffer(entries);
- }
-
- IPC::ResponseBuilder rb{ctx, 4};
- rb.Push(result);
- rb.Push<u64>(entries.size());
+ R_TRY(manager->IsAlbumMounted(AlbumStorage::Sd));
+ R_RETURN(manager->GetAlbumFileList(out_entries, *out_entries_count, content_type,
+ start_posix_time, end_posix_time, aruid.pid));
}
-void IAlbumApplicationService::GetAlbumFileList3AaeAruid(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- struct Parameters {
- ContentType content_type;
- INSERT_PADDING_BYTES(1);
- AlbumFileDateTime start_date_time;
- AlbumFileDateTime end_date_time;
- INSERT_PADDING_BYTES(6);
- u64 applet_resource_user_id;
- };
- static_assert(sizeof(Parameters) == 0x20, "Parameters has incorrect size.");
-
- const auto parameters{rp.PopRaw<Parameters>()};
-
+Result IAlbumApplicationService::GetAlbumFileList3AaeAruid(
+ Out<u64> out_entries_count, ContentType content_type, AlbumFileDateTime start_date_time,
+ AlbumFileDateTime end_date_time, ClientAppletResourceUserId aruid,
+ OutArray<ApplicationAlbumEntry, BufferAttr_HipcMapAlias> out_entries) {
LOG_WARNING(Service_Capture,
"(STUBBED) called. content_type={}, start_date={}/{}/{}, "
"end_date={}/{}/{}, applet_resource_user_id={}",
- parameters.content_type, parameters.start_date_time.year,
- parameters.start_date_time.month, parameters.start_date_time.day,
- parameters.end_date_time.year, parameters.end_date_time.month,
- parameters.end_date_time.day, parameters.applet_resource_user_id);
-
- Result result = ResultSuccess;
-
- if (result.IsSuccess()) {
- result = manager->IsAlbumMounted(AlbumStorage::Sd);
- }
-
- std::vector<ApplicationAlbumEntry> entries;
- if (result.IsSuccess()) {
- result =
- manager->GetAlbumFileList(entries, parameters.content_type, parameters.start_date_time,
- parameters.end_date_time, parameters.applet_resource_user_id);
- }
-
- if (!entries.empty()) {
- ctx.WriteBuffer(entries);
- }
+ content_type, start_date_time.year, start_date_time.month, start_date_time.day,
+ end_date_time.year, end_date_time.month, end_date_time.day, aruid.pid);
- IPC::ResponseBuilder rb{ctx, 4};
- rb.Push(result);
- rb.Push<u64>(entries.size());
+ R_TRY(manager->IsAlbumMounted(AlbumStorage::Sd));
+ R_RETURN(manager->GetAlbumFileList(out_entries, *out_entries_count, content_type,
+ start_date_time, end_date_time, aruid.pid));
}
} // namespace Service::Capture
diff --git a/src/core/hle/service/caps/caps_u.h b/src/core/hle/service/caps/caps_u.h
index 9458c128e..023ee1fe7 100644
--- a/src/core/hle/service/caps/caps_u.h
+++ b/src/core/hle/service/caps/caps_u.h
@@ -3,6 +3,7 @@
#pragma once
+#include "core/hle/service/cmif_types.h"
#include "core/hle/service/service.h"
namespace Core {
@@ -19,9 +20,18 @@ public:
~IAlbumApplicationService() override;
private:
- void SetShimLibraryVersion(HLERequestContext& ctx);
- void GetAlbumFileList0AafeAruidDeprecated(HLERequestContext& ctx);
- void GetAlbumFileList3AaeAruid(HLERequestContext& ctx);
+ Result SetShimLibraryVersion(ShimLibraryVersion library_version,
+ ClientAppletResourceUserId aruid);
+
+ Result GetAlbumFileList0AafeAruidDeprecated(
+ Out<u64> out_entries_count, ContentType content_type, s64 start_posix_time,
+ s64 end_posix_time, ClientAppletResourceUserId aruid,
+ OutArray<ApplicationAlbumFileEntry, BufferAttr_HipcMapAlias> out_entries);
+
+ Result GetAlbumFileList3AaeAruid(
+ Out<u64> out_entries_count, ContentType content_type, AlbumFileDateTime start_date_time,
+ AlbumFileDateTime end_date_time, ClientAppletResourceUserId aruid,
+ OutArray<ApplicationAlbumEntry, BufferAttr_HipcMapAlias> out_entries);
std::shared_ptr<AlbumManager> manager = nullptr;
};
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index 5b28be577..b60fb9139 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -18,9 +18,10 @@ namespace Service::HID {
void LoopProcess(Core::System& system) {
auto server_manager = std::make_unique<ServerManager>(system);
- std::shared_ptr<ResourceManager> resource_manager = std::make_shared<ResourceManager>(system);
std::shared_ptr<HidFirmwareSettings> firmware_settings =
std::make_shared<HidFirmwareSettings>(system);
+ std::shared_ptr<ResourceManager> resource_manager =
+ std::make_shared<ResourceManager>(system, firmware_settings);
// TODO: Remove this hack when am is emulated properly.
resource_manager->Initialize();
@@ -31,7 +32,7 @@ void LoopProcess(Core::System& system) {
server_manager->RegisterNamedService(
"hid", std::make_shared<IHidServer>(system, resource_manager, firmware_settings));
server_manager->RegisterNamedService(
- "hid:dbg", std::make_shared<IHidDebugServer>(system, resource_manager));
+ "hid:dbg", std::make_shared<IHidDebugServer>(system, resource_manager, firmware_settings));
server_manager->RegisterNamedService(
"hid:sys", std::make_shared<IHidSystemServer>(system, resource_manager, firmware_settings));
diff --git a/src/core/hle/service/hid/hid_debug_server.cpp b/src/core/hle/service/hid/hid_debug_server.cpp
index f2a767d37..610af34dd 100644
--- a/src/core/hle/service/hid/hid_debug_server.cpp
+++ b/src/core/hle/service/hid/hid_debug_server.cpp
@@ -1,27 +1,37 @@
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
+#include <algorithm>
+
#include "core/hle/service/hid/hid_debug_server.h"
#include "core/hle/service/ipc_helpers.h"
+#include "hid_core/hid_types.h"
#include "hid_core/resource_manager.h"
+#include "hid_core/resources/hid_firmware_settings.h"
+
+#include "hid_core/resources/touch_screen/gesture.h"
+#include "hid_core/resources/touch_screen/touch_screen.h"
+#include "hid_core/resources/touch_screen/touch_types.h"
namespace Service::HID {
-IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptr<ResourceManager> resource)
- : ServiceFramework{system_, "hid:dbg"}, resource_manager{resource} {
+IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptr<ResourceManager> resource,
+ std::shared_ptr<HidFirmwareSettings> settings)
+ : ServiceFramework{system_, "hid:dbg"}, resource_manager{resource}, firmware_settings{
+ settings} {
// clang-format off
static const FunctionInfo functions[] = {
{0, nullptr, "DeactivateDebugPad"},
{1, nullptr, "SetDebugPadAutoPilotState"},
{2, nullptr, "UnsetDebugPadAutoPilotState"},
- {10, nullptr, "DeactivateTouchScreen"},
- {11, nullptr, "SetTouchScreenAutoPilotState"},
- {12, nullptr, "UnsetTouchScreenAutoPilotState"},
- {13, nullptr, "GetTouchScreenConfiguration"},
- {14, nullptr, "ProcessTouchScreenAutoTune"},
- {15, nullptr, "ForceStopTouchScreenManagement"},
- {16, nullptr, "ForceRestartTouchScreenManagement"},
- {17, nullptr, "IsTouchScreenManaged"},
+ {10, &IHidDebugServer::DeactivateTouchScreen, "DeactivateTouchScreen"},
+ {11, &IHidDebugServer::SetTouchScreenAutoPilotState, "SetTouchScreenAutoPilotState"},
+ {12, &IHidDebugServer::UnsetTouchScreenAutoPilotState, "UnsetTouchScreenAutoPilotState"},
+ {13, &IHidDebugServer::GetTouchScreenConfiguration, "GetTouchScreenConfiguration"},
+ {14, &IHidDebugServer::ProcessTouchScreenAutoTune, "ProcessTouchScreenAutoTune"},
+ {15, &IHidDebugServer::ForceStopTouchScreenManagement, "ForceStopTouchScreenManagement"},
+ {16, &IHidDebugServer::ForceRestartTouchScreenManagement, "ForceRestartTouchScreenManagement"},
+ {17, &IHidDebugServer::IsTouchScreenManaged, "IsTouchScreenManaged"},
{20, nullptr, "DeactivateMouse"},
{21, nullptr, "SetMouseAutoPilotState"},
{22, nullptr, "UnsetMouseAutoPilotState"},
@@ -37,7 +47,7 @@ IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptr<Resource
{60, nullptr, "ClearNpadSystemCommonPolicy"},
{61, nullptr, "DeactivateNpad"},
{62, nullptr, "ForceDisconnectNpad"},
- {91, nullptr, "DeactivateGesture"},
+ {91, &IHidDebugServer::DeactivateGesture, "DeactivateGesture"},
{110, nullptr, "DeactivateHomeButton"},
{111, nullptr, "SetHomeButtonAutoPilotState"},
{112, nullptr, "UnsetHomeButtonAutoPilotState"},
@@ -150,6 +160,170 @@ IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptr<Resource
}
IHidDebugServer::~IHidDebugServer() = default;
+void IHidDebugServer::DeactivateTouchScreen(HLERequestContext& ctx) {
+ LOG_INFO(Service_HID, "called");
+
+ Result result = ResultSuccess;
+
+ if (!firmware_settings->IsDeviceManaged()) {
+ result = GetResourceManager()->GetTouchScreen()->Deactivate();
+ }
+
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(result);
+}
+
+void IHidDebugServer::SetTouchScreenAutoPilotState(HLERequestContext& ctx) {
+ AutoPilotState auto_pilot{};
+ auto_pilot.count = ctx.GetReadBufferNumElements<TouchState>();
+ const auto buffer = ctx.ReadBuffer();
+
+ auto_pilot.count = std::min(auto_pilot.count, static_cast<u64>(auto_pilot.state.size()));
+ memcpy(auto_pilot.state.data(), buffer.data(), auto_pilot.count * sizeof(TouchState));
+
+ LOG_INFO(Service_HID, "called, auto_pilot_count={}", auto_pilot.count);
+
+ const Result result =
+ GetResourceManager()->GetTouchScreen()->SetTouchScreenAutoPilotState(auto_pilot);
+
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(result);
+}
+
+void IHidDebugServer::UnsetTouchScreenAutoPilotState(HLERequestContext& ctx) {
+ LOG_INFO(Service_HID, "called");
+
+ const Result result = GetResourceManager()->GetTouchScreen()->UnsetTouchScreenAutoPilotState();
+
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(result);
+}
+
+void IHidDebugServer::GetTouchScreenConfiguration(HLERequestContext& ctx) {
+ IPC::RequestParser rp{ctx};
+ const auto applet_resource_user_id{rp.Pop<u64>()};
+
+ LOG_INFO(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
+
+ Core::HID::TouchScreenConfigurationForNx touchscreen_config{};
+ const Result result = GetResourceManager()->GetTouchScreen()->GetTouchScreenConfiguration(
+ touchscreen_config, applet_resource_user_id);
+
+ if (touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Heat2 &&
+ touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Finger) {
+ touchscreen_config.mode = Core::HID::TouchScreenModeForNx::UseSystemSetting;
+ }
+
+ IPC::ResponseBuilder rb{ctx, 6};
+ rb.Push(result);
+ rb.PushRaw(touchscreen_config);
+}
+
+void IHidDebugServer::ProcessTouchScreenAutoTune(HLERequestContext& ctx) {
+ LOG_INFO(Service_HID, "called");
+
+ Result result = GetResourceManager()->GetTouchScreen()->ProcessTouchScreenAutoTune();
+
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(result);
+}
+
+void IHidDebugServer::ForceStopTouchScreenManagement(HLERequestContext& ctx) {
+ LOG_INFO(Service_HID, "called");
+
+ if (!firmware_settings->IsDeviceManaged()) {
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(ResultSuccess);
+ return;
+ }
+
+ Result result = ResultSuccess;
+ bool is_touch_active{};
+ bool is_gesture_active{};
+ auto touch_screen = GetResourceManager()->GetTouchScreen();
+ auto gesture = GetResourceManager()->GetGesture();
+
+ if (firmware_settings->IsTouchI2cManaged()) {
+ result = touch_screen->IsActive(is_touch_active);
+ if (result.IsSuccess()) {
+ result = gesture->IsActive(is_gesture_active);
+ }
+ if (result.IsSuccess() && is_touch_active) {
+ result = touch_screen->Deactivate();
+ }
+ if (result.IsSuccess() && is_gesture_active) {
+ result = gesture->Deactivate();
+ }
+ }
+
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(result);
+}
+
+void IHidDebugServer::ForceRestartTouchScreenManagement(HLERequestContext& ctx) {
+ IPC::RequestParser rp{ctx};
+ struct Parameters {
+ u32 basic_gesture_id;
+ INSERT_PADDING_WORDS_NOINIT(1);
+ u64 applet_resource_user_id;
+ };
+ static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
+
+ const auto parameters{rp.PopRaw<Parameters>()};
+
+ LOG_INFO(Service_HID, "called, basic_gesture_id={}, applet_resource_user_id={}",
+ parameters.basic_gesture_id, parameters.applet_resource_user_id);
+
+ Result result = ResultSuccess;
+ auto touch_screen = GetResourceManager()->GetTouchScreen();
+ auto gesture = GetResourceManager()->GetGesture();
+
+ if (firmware_settings->IsDeviceManaged() && firmware_settings->IsTouchI2cManaged()) {
+ result = gesture->Activate();
+ if (result.IsSuccess()) {
+ result =
+ gesture->Activate(parameters.applet_resource_user_id, parameters.basic_gesture_id);
+ }
+ if (result.IsSuccess()) {
+ result = touch_screen->Activate();
+ }
+ if (result.IsSuccess()) {
+ result = touch_screen->Activate(parameters.applet_resource_user_id);
+ }
+ }
+
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(result);
+}
+
+void IHidDebugServer::IsTouchScreenManaged(HLERequestContext& ctx) {
+ LOG_INFO(Service_HID, "called");
+
+ bool is_touch_active{};
+ bool is_gesture_active{};
+
+ Result result = GetResourceManager()->GetTouchScreen()->IsActive(is_touch_active);
+ if (result.IsSuccess()) {
+ result = GetResourceManager()->GetGesture()->IsActive(is_gesture_active);
+ }
+
+ IPC::ResponseBuilder rb{ctx, 3};
+ rb.Push(result);
+ rb.Push(is_touch_active | is_gesture_active);
+}
+
+void IHidDebugServer::DeactivateGesture(HLERequestContext& ctx) {
+ LOG_INFO(Service_HID, "called");
+
+ Result result = ResultSuccess;
+
+ if (!firmware_settings->IsDeviceManaged()) {
+ result = GetResourceManager()->GetGesture()->Deactivate();
+ }
+
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(result);
+}
std::shared_ptr<ResourceManager> IHidDebugServer::GetResourceManager() {
resource_manager->Initialize();
diff --git a/src/core/hle/service/hid/hid_debug_server.h b/src/core/hle/service/hid/hid_debug_server.h
index 406db2211..7d5b082b3 100644
--- a/src/core/hle/service/hid/hid_debug_server.h
+++ b/src/core/hle/service/hid/hid_debug_server.h
@@ -11,16 +11,29 @@ class System;
namespace Service::HID {
class ResourceManager;
+class HidFirmwareSettings;
class IHidDebugServer final : public ServiceFramework<IHidDebugServer> {
public:
- explicit IHidDebugServer(Core::System& system_, std::shared_ptr<ResourceManager> resource);
+ explicit IHidDebugServer(Core::System& system_, std::shared_ptr<ResourceManager> resource,
+ std::shared_ptr<HidFirmwareSettings> settings);
~IHidDebugServer() override;
private:
+ void DeactivateTouchScreen(HLERequestContext& ctx);
+ void SetTouchScreenAutoPilotState(HLERequestContext& ctx);
+ void UnsetTouchScreenAutoPilotState(HLERequestContext& ctx);
+ void GetTouchScreenConfiguration(HLERequestContext& ctx);
+ void ProcessTouchScreenAutoTune(HLERequestContext& ctx);
+ void ForceStopTouchScreenManagement(HLERequestContext& ctx);
+ void ForceRestartTouchScreenManagement(HLERequestContext& ctx);
+ void IsTouchScreenManaged(HLERequestContext& ctx);
+ void DeactivateGesture(HLERequestContext& ctx);
+
std::shared_ptr<ResourceManager> GetResourceManager();
std::shared_ptr<ResourceManager> resource_manager;
+ std::shared_ptr<HidFirmwareSettings> firmware_settings;
};
} // namespace Service::HID
diff --git a/src/core/hle/service/hid/hid_server.cpp b/src/core/hle/service/hid/hid_server.cpp
index 938b93451..3603d8ccf 100644
--- a/src/core/hle/service/hid/hid_server.cpp
+++ b/src/core/hle/service/hid/hid_server.cpp
@@ -990,8 +990,7 @@ void IHidServer::ActivateGesture(HLERequestContext& ctx) {
}
if (result.IsSuccess()) {
- // TODO: Use gesture id here
- result = gesture->Activate(parameters.applet_resource_user_id);
+ result = gesture->Activate(parameters.applet_resource_user_id, parameters.basic_gesture_id);
}
IPC::ResponseBuilder rb{ctx, 2};
@@ -2470,14 +2469,22 @@ void IHidServer::GetNpadCommunicationMode(HLERequestContext& ctx) {
void IHidServer::SetTouchScreenConfiguration(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
- const auto touchscreen_mode{rp.PopRaw<Core::HID::TouchScreenConfigurationForNx>()};
+ auto touchscreen_config{rp.PopRaw<Core::HID::TouchScreenConfigurationForNx>()};
const auto applet_resource_user_id{rp.Pop<u64>()};
- LOG_WARNING(Service_HID, "(STUBBED) called, touchscreen_mode={}, applet_resource_user_id={}",
- touchscreen_mode.mode, applet_resource_user_id);
+ LOG_INFO(Service_HID, "called, touchscreen_config={}, applet_resource_user_id={}",
+ touchscreen_config.mode, applet_resource_user_id);
+
+ if (touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Heat2 &&
+ touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Finger) {
+ touchscreen_config.mode = Core::HID::TouchScreenModeForNx::UseSystemSetting;
+ }
+
+ const Result result = GetResourceManager()->GetTouchScreen()->SetTouchScreenConfiguration(
+ touchscreen_config, applet_resource_user_id);
IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultSuccess);
+ rb.Push(result);
}
void IHidServer::IsFirmwareUpdateNeededForNotification(HLERequestContext& ctx) {
@@ -2505,11 +2512,12 @@ void IHidServer::SetTouchScreenResolution(HLERequestContext& ctx) {
const auto height{rp.Pop<u32>()};
const auto applet_resource_user_id{rp.Pop<u64>()};
- GetResourceManager()->GetTouchScreen()->SetTouchscreenDimensions(width, height);
-
LOG_INFO(Service_HID, "called, width={}, height={}, applet_resource_user_id={}", width, height,
applet_resource_user_id);
+ GetResourceManager()->GetTouchScreen()->SetTouchScreenResolution(width, height,
+ applet_resource_user_id);
+
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
diff --git a/src/core/hle/service/hid/hid_system_server.cpp b/src/core/hle/service/hid/hid_system_server.cpp
index d1ec42edc..22471e9e2 100644
--- a/src/core/hle/service/hid/hid_system_server.cpp
+++ b/src/core/hle/service/hid/hid_system_server.cpp
@@ -155,9 +155,9 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
{1133, nullptr, "StartUsbFirmwareUpdate"},
{1134, nullptr, "GetUsbFirmwareUpdateState"},
{1135, &IHidSystemServer::InitializeUsbFirmwareUpdateWithoutMemory, "InitializeUsbFirmwareUpdateWithoutMemory"},
- {1150, nullptr, "SetTouchScreenMagnification"},
- {1151, nullptr, "GetTouchScreenFirmwareVersion"},
- {1152, nullptr, "SetTouchScreenDefaultConfiguration"},
+ {1150, &IHidSystemServer::SetTouchScreenMagnification, "SetTouchScreenMagnification"},
+ {1151, &IHidSystemServer::GetTouchScreenFirmwareVersion, "GetTouchScreenFirmwareVersion"},
+ {1152, &IHidSystemServer::SetTouchScreenDefaultConfiguration, "SetTouchScreenDefaultConfiguration"},
{1153, &IHidSystemServer::GetTouchScreenDefaultConfiguration, "GetTouchScreenDefaultConfiguration"},
{1154, nullptr, "IsFirmwareAvailableForNotification"},
{1155, &IHidSystemServer::SetForceHandheldStyleVibration, "SetForceHandheldStyleVibration"},
@@ -845,12 +845,60 @@ void IHidSystemServer::InitializeUsbFirmwareUpdateWithoutMemory(HLERequestContex
rb.Push(ResultSuccess);
}
+void IHidSystemServer::SetTouchScreenMagnification(HLERequestContext& ctx) {
+ IPC::RequestParser rp{ctx};
+ const auto point1x{rp.Pop<f32>()};
+ const auto point1y{rp.Pop<f32>()};
+ const auto point2x{rp.Pop<f32>()};
+ const auto point2y{rp.Pop<f32>()};
+
+ LOG_INFO(Service_HID, "called, point1=-({},{}), point2=({},{})", point1x, point1y, point2x,
+ point2y);
+
+ const Result result = GetResourceManager()->GetTouchScreen()->SetTouchScreenMagnification(
+ point1x, point1y, point2x, point2y);
+
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(result);
+}
+
+void IHidSystemServer::GetTouchScreenFirmwareVersion(HLERequestContext& ctx) {
+ LOG_INFO(Service_HID, "called");
+
+ Core::HID::FirmwareVersion firmware{};
+ const auto result = GetResourceManager()->GetTouchScreenFirmwareVersion(firmware);
+
+ IPC::ResponseBuilder rb{ctx, 6};
+ rb.Push(result);
+ rb.PushRaw(firmware);
+}
+
+void IHidSystemServer::SetTouchScreenDefaultConfiguration(HLERequestContext& ctx) {
+ IPC::RequestParser rp{ctx};
+ auto touchscreen_config{rp.PopRaw<Core::HID::TouchScreenConfigurationForNx>()};
+
+ LOG_INFO(Service_HID, "called, touchscreen_config={}", touchscreen_config.mode);
+
+ if (touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Heat2 &&
+ touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Finger) {
+ touchscreen_config.mode = Core::HID::TouchScreenModeForNx::UseSystemSetting;
+ }
+
+ const Result result =
+ GetResourceManager()->GetTouchScreen()->SetTouchScreenDefaultConfiguration(
+ touchscreen_config);
+
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(result);
+}
+
void IHidSystemServer::GetTouchScreenDefaultConfiguration(HLERequestContext& ctx) {
- LOG_WARNING(Service_HID, "(STUBBED) called");
+ LOG_INFO(Service_HID, "called");
- Core::HID::TouchScreenConfigurationForNx touchscreen_config{
- .mode = Core::HID::TouchScreenModeForNx::Finger,
- };
+ Core::HID::TouchScreenConfigurationForNx touchscreen_config{};
+ const Result result =
+ GetResourceManager()->GetTouchScreen()->GetTouchScreenDefaultConfiguration(
+ touchscreen_config);
if (touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Heat2 &&
touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Finger) {
@@ -858,7 +906,7 @@ void IHidSystemServer::GetTouchScreenDefaultConfiguration(HLERequestContext& ctx
}
IPC::ResponseBuilder rb{ctx, 6};
- rb.Push(ResultSuccess);
+ rb.Push(result);
rb.PushRaw(touchscreen_config);
}
diff --git a/src/core/hle/service/hid/hid_system_server.h b/src/core/hle/service/hid/hid_system_server.h
index 4ab4d3931..738313e08 100644
--- a/src/core/hle/service/hid/hid_system_server.h
+++ b/src/core/hle/service/hid/hid_system_server.h
@@ -71,6 +71,9 @@ private:
void FinalizeUsbFirmwareUpdate(HLERequestContext& ctx);
void CheckUsbFirmwareUpdateRequired(HLERequestContext& ctx);
void InitializeUsbFirmwareUpdateWithoutMemory(HLERequestContext& ctx);
+ void SetTouchScreenMagnification(HLERequestContext& ctx);
+ void GetTouchScreenFirmwareVersion(HLERequestContext& ctx);
+ void SetTouchScreenDefaultConfiguration(HLERequestContext& ctx);
void GetTouchScreenDefaultConfiguration(HLERequestContext& ctx);
void SetForceHandheldStyleVibration(HLERequestContext& ctx);
void IsUsingCustomButtonConfig(HLERequestContext& ctx);
diff --git a/src/core/hle/service/set/setting_formats/system_settings.h b/src/core/hle/service/set/setting_formats/system_settings.h
index ebc373da5..40230182a 100644
--- a/src/core/hle/service/set/setting_formats/system_settings.h
+++ b/src/core/hle/service/set/setting_formats/system_settings.h
@@ -12,6 +12,7 @@
#include "common/vector_math.h"
#include "core/hle/service/set/setting_formats/private_settings.h"
#include "core/hle/service/set/settings_types.h"
+#include "hid_core/resources/touch_screen/touch_types.h"
namespace Service::Set {
@@ -257,8 +258,7 @@ struct SystemSettings {
std::array<u8, 0x10> analog_stick_user_calibration_left;
std::array<u8, 0x10> analog_stick_user_calibration_right;
- // nn::settings::system::TouchScreenMode
- s32 touch_screen_mode;
+ TouchScreenMode touch_screen_mode;
INSERT_PADDING_BYTES(0x14); // Reserved
TvSettings tv_settings;
diff --git a/src/core/hle/service/set/system_settings_server.cpp b/src/core/hle/service/set/system_settings_server.cpp
index d3d0fb112..7ef4a0ded 100644
--- a/src/core/hle/service/set/system_settings_server.cpp
+++ b/src/core/hle/service/set/system_settings_server.cpp
@@ -275,8 +275,8 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_)
{184, nullptr, "SetPlatformRegion"},
{185, &ISystemSettingsServer::GetHomeMenuSchemeModel, "GetHomeMenuSchemeModel"},
{186, nullptr, "GetMemoryUsageRateFlag"},
- {187, nullptr, "GetTouchScreenMode"},
- {188, nullptr, "SetTouchScreenMode"},
+ {187, &ISystemSettingsServer::GetTouchScreenMode, "GetTouchScreenMode"},
+ {188, &ISystemSettingsServer::SetTouchScreenMode, "SetTouchScreenMode"},
{189, nullptr, "GetButtonConfigSettingsFull"},
{190, nullptr, "SetButtonConfigSettingsFull"},
{191, nullptr, "GetButtonConfigSettingsEmbedded"},
@@ -1395,6 +1395,28 @@ void ISystemSettingsServer::GetHomeMenuSchemeModel(HLERequestContext& ctx) {
rb.Push(0);
}
+void ISystemSettingsServer::GetTouchScreenMode(HLERequestContext& ctx) {
+ TouchScreenMode touch_screen_mode{};
+ auto res = GetTouchScreenMode(touch_screen_mode);
+
+ LOG_INFO(Service_SET, "called, touch_screen_mode={}", touch_screen_mode);
+
+ IPC::ResponseBuilder rb{ctx, 3};
+ rb.Push(res);
+ rb.PushEnum(touch_screen_mode);
+}
+
+void ISystemSettingsServer::SetTouchScreenMode(HLERequestContext& ctx) {
+ IPC::RequestParser rp{ctx};
+ const auto touch_screen_mode = rp.PopEnum<TouchScreenMode>();
+ auto res = SetTouchScreenMode(touch_screen_mode);
+
+ LOG_INFO(Service_SET, "called, touch_screen_mode={}", touch_screen_mode);
+
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(res);
+}
+
void ISystemSettingsServer::GetFieldTestingFlag(HLERequestContext& ctx) {
LOG_INFO(Service_SET, "called, field_testing_flag={}", m_system_settings.field_testing_flag);
@@ -1670,4 +1692,15 @@ Result ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionUpdatedTime(
R_SUCCEED();
}
+Result ISystemSettingsServer::GetTouchScreenMode(TouchScreenMode& touch_screen_mode) const {
+ touch_screen_mode = m_system_settings.touch_screen_mode;
+ R_SUCCEED();
+}
+
+Result ISystemSettingsServer::SetTouchScreenMode(TouchScreenMode touch_screen_mode) {
+ m_system_settings.touch_screen_mode = touch_screen_mode;
+ SetSaveNeeded();
+ R_SUCCEED();
+}
+
} // namespace Service::Set
diff --git a/src/core/hle/service/set/system_settings_server.h b/src/core/hle/service/set/system_settings_server.h
index 1982b9723..9a3b36f0c 100644
--- a/src/core/hle/service/set/system_settings_server.h
+++ b/src/core/hle/service/set/system_settings_server.h
@@ -74,6 +74,8 @@ public:
Service::PSC::Time::SteadyClockTimePoint& out_time_point) const;
Result SetUserSystemClockAutomaticCorrectionUpdatedTime(
const Service::PSC::Time::SteadyClockTimePoint& time_point);
+ Result GetTouchScreenMode(TouchScreenMode& touch_screen_mode) const;
+ Result SetTouchScreenMode(TouchScreenMode touch_screen_mode);
private:
void SetLanguageCode(HLERequestContext& ctx);
@@ -154,6 +156,8 @@ private:
void GetChineseTraditionalInputMethod(HLERequestContext& ctx);
void GetHomeMenuScheme(HLERequestContext& ctx);
void GetHomeMenuSchemeModel(HLERequestContext& ctx);
+ void GetTouchScreenMode(HLERequestContext& ctx);
+ void SetTouchScreenMode(HLERequestContext& ctx);
void GetFieldTestingFlag(HLERequestContext& ctx);
void GetPanelCrcMode(HLERequestContext& ctx);
void SetPanelCrcMode(HLERequestContext& ctx);