diff options
48 files changed, 626 insertions, 350 deletions
diff --git a/src/audio_core/common.h b/src/audio_core/common.h index 1ab537588..e6b95769f 100644 --- a/src/audio_core/common.h +++ b/src/audio_core/common.h | |||
| @@ -15,7 +15,9 @@ constexpr ResultCode ERR_INVALID_PARAMETERS{ErrorModule::Audio, 41}; | |||
| 15 | constexpr ResultCode ERR_SPLITTER_SORT_FAILED{ErrorModule::Audio, 43}; | 15 | constexpr ResultCode ERR_SPLITTER_SORT_FAILED{ErrorModule::Audio, 43}; |
| 16 | } // namespace Audren | 16 | } // namespace Audren |
| 17 | 17 | ||
| 18 | constexpr u32_le CURRENT_PROCESS_REVISION = Common::MakeMagic('R', 'E', 'V', '9'); | 18 | constexpr u8 BASE_REVISION = '0'; |
| 19 | constexpr u32_le CURRENT_PROCESS_REVISION = | ||
| 20 | Common::MakeMagic('R', 'E', 'V', static_cast<u8>(BASE_REVISION + 0xA)); | ||
| 19 | constexpr std::size_t MAX_MIX_BUFFERS = 24; | 21 | constexpr std::size_t MAX_MIX_BUFFERS = 24; |
| 20 | constexpr std::size_t MAX_BIQUAD_FILTERS = 2; | 22 | constexpr std::size_t MAX_BIQUAD_FILTERS = 2; |
| 21 | constexpr std::size_t MAX_CHANNEL_COUNT = 6; | 23 | constexpr std::size_t MAX_CHANNEL_COUNT = 6; |
diff --git a/src/common/fs/fs_util.cpp b/src/common/fs/fs_util.cpp index 9f8671982..0068112e6 100644 --- a/src/common/fs/fs_util.cpp +++ b/src/common/fs/fs_util.cpp | |||
| @@ -16,6 +16,10 @@ std::u8string BufferToU8String(std::span<const u8> buffer) { | |||
| 16 | return std::u8string{buffer.begin(), std::ranges::find(buffer, u8{0})}; | 16 | return std::u8string{buffer.begin(), std::ranges::find(buffer, u8{0})}; |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | std::u8string_view BufferToU8StringView(std::span<const u8> buffer) { | ||
| 20 | return std::u8string_view{reinterpret_cast<const char8_t*>(buffer.data())}; | ||
| 21 | } | ||
| 22 | |||
| 19 | std::string ToUTF8String(std::u8string_view u8_string) { | 23 | std::string ToUTF8String(std::u8string_view u8_string) { |
| 20 | return std::string{u8_string.begin(), u8_string.end()}; | 24 | return std::string{u8_string.begin(), u8_string.end()}; |
| 21 | } | 25 | } |
| @@ -24,6 +28,10 @@ std::string BufferToUTF8String(std::span<const u8> buffer) { | |||
| 24 | return std::string{buffer.begin(), std::ranges::find(buffer, u8{0})}; | 28 | return std::string{buffer.begin(), std::ranges::find(buffer, u8{0})}; |
| 25 | } | 29 | } |
| 26 | 30 | ||
| 31 | std::string_view BufferToUTF8StringView(std::span<const u8> buffer) { | ||
| 32 | return std::string_view{reinterpret_cast<const char*>(buffer.data())}; | ||
| 33 | } | ||
| 34 | |||
| 27 | std::string PathToUTF8String(const std::filesystem::path& path) { | 35 | std::string PathToUTF8String(const std::filesystem::path& path) { |
| 28 | return ToUTF8String(path.u8string()); | 36 | return ToUTF8String(path.u8string()); |
| 29 | } | 37 | } |
diff --git a/src/common/fs/fs_util.h b/src/common/fs/fs_util.h index 1ec82eb35..1620d38c9 100644 --- a/src/common/fs/fs_util.h +++ b/src/common/fs/fs_util.h | |||
| @@ -38,6 +38,15 @@ concept IsChar = std::same_as<T, char>; | |||
| 38 | [[nodiscard]] std::u8string BufferToU8String(std::span<const u8> buffer); | 38 | [[nodiscard]] std::u8string BufferToU8String(std::span<const u8> buffer); |
| 39 | 39 | ||
| 40 | /** | 40 | /** |
| 41 | * Same as BufferToU8String, but returns a string view of the buffer. | ||
| 42 | * | ||
| 43 | * @param buffer Buffer of bytes | ||
| 44 | * | ||
| 45 | * @returns UTF-8 encoded std::u8string_view. | ||
| 46 | */ | ||
| 47 | [[nodiscard]] std::u8string_view BufferToU8StringView(std::span<const u8> buffer); | ||
| 48 | |||
| 49 | /** | ||
| 41 | * Converts a std::u8string or std::u8string_view to a UTF-8 encoded std::string. | 50 | * Converts a std::u8string or std::u8string_view to a UTF-8 encoded std::string. |
| 42 | * | 51 | * |
| 43 | * @param u8_string UTF-8 encoded u8string | 52 | * @param u8_string UTF-8 encoded u8string |
| @@ -58,6 +67,15 @@ concept IsChar = std::same_as<T, char>; | |||
| 58 | [[nodiscard]] std::string BufferToUTF8String(std::span<const u8> buffer); | 67 | [[nodiscard]] std::string BufferToUTF8String(std::span<const u8> buffer); |
| 59 | 68 | ||
| 60 | /** | 69 | /** |
| 70 | * Same as BufferToUTF8String, but returns a string view of the buffer. | ||
| 71 | * | ||
| 72 | * @param buffer Buffer of bytes | ||
| 73 | * | ||
| 74 | * @returns UTF-8 encoded std::string_view. | ||
| 75 | */ | ||
| 76 | [[nodiscard]] std::string_view BufferToUTF8StringView(std::span<const u8> buffer); | ||
| 77 | |||
| 78 | /** | ||
| 61 | * Converts a filesystem path to a UTF-8 encoded std::string. | 79 | * Converts a filesystem path to a UTF-8 encoded std::string. |
| 62 | * | 80 | * |
| 63 | * @param path Filesystem path | 81 | * @param path Filesystem path |
diff --git a/src/common/uuid.cpp b/src/common/uuid.cpp index d7435a6e9..2b6a530e3 100644 --- a/src/common/uuid.cpp +++ b/src/common/uuid.cpp | |||
| @@ -1,23 +1,25 @@ | |||
| 1 | // Copyright 2018 yuzu Emulator Project | 1 | // Copyright 2022 yuzu Emulator Project |
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <bit> | ||
| 6 | #include <optional> | ||
| 5 | #include <random> | 7 | #include <random> |
| 6 | 8 | ||
| 7 | #include <fmt/format.h> | 9 | #include <fmt/format.h> |
| 8 | 10 | ||
| 9 | #include "common/assert.h" | 11 | #include "common/assert.h" |
| 12 | #include "common/tiny_mt.h" | ||
| 10 | #include "common/uuid.h" | 13 | #include "common/uuid.h" |
| 11 | 14 | ||
| 12 | namespace Common { | 15 | namespace Common { |
| 13 | 16 | ||
| 14 | namespace { | 17 | namespace { |
| 15 | 18 | ||
| 16 | bool IsHexDigit(char c) { | 19 | constexpr size_t RawStringSize = sizeof(UUID) * 2; |
| 17 | return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); | 20 | constexpr size_t FormattedStringSize = RawStringSize + 4; |
| 18 | } | ||
| 19 | 21 | ||
| 20 | u8 HexCharToByte(char c) { | 22 | std::optional<u8> HexCharToByte(char c) { |
| 21 | if (c >= '0' && c <= '9') { | 23 | if (c >= '0' && c <= '9') { |
| 22 | return static_cast<u8>(c - '0'); | 24 | return static_cast<u8>(c - '0'); |
| 23 | } | 25 | } |
| @@ -28,60 +30,184 @@ u8 HexCharToByte(char c) { | |||
| 28 | return static_cast<u8>(c - 'A' + 10); | 30 | return static_cast<u8>(c - 'A' + 10); |
| 29 | } | 31 | } |
| 30 | ASSERT_MSG(false, "{} is not a hexadecimal digit!", c); | 32 | ASSERT_MSG(false, "{} is not a hexadecimal digit!", c); |
| 31 | return u8{0}; | 33 | return std::nullopt; |
| 32 | } | 34 | } |
| 33 | 35 | ||
| 34 | } // Anonymous namespace | 36 | std::array<u8, 0x10> ConstructFromRawString(std::string_view raw_string) { |
| 37 | std::array<u8, 0x10> uuid; | ||
| 38 | |||
| 39 | for (size_t i = 0; i < RawStringSize; i += 2) { | ||
| 40 | const auto upper = HexCharToByte(raw_string[i]); | ||
| 41 | const auto lower = HexCharToByte(raw_string[i + 1]); | ||
| 42 | if (!upper || !lower) { | ||
| 43 | return {}; | ||
| 44 | } | ||
| 45 | uuid[i / 2] = static_cast<u8>((*upper << 4) | *lower); | ||
| 46 | } | ||
| 47 | |||
| 48 | return uuid; | ||
| 49 | } | ||
| 35 | 50 | ||
| 36 | u128 HexStringToU128(std::string_view hex_string) { | 51 | std::array<u8, 0x10> ConstructFromFormattedString(std::string_view formatted_string) { |
| 37 | const size_t length = hex_string.length(); | 52 | std::array<u8, 0x10> uuid; |
| 38 | 53 | ||
| 39 | // Detect "0x" prefix. | 54 | size_t i = 0; |
| 40 | const bool has_0x_prefix = length > 2 && hex_string[0] == '0' && hex_string[1] == 'x'; | ||
| 41 | const size_t offset = has_0x_prefix ? 2 : 0; | ||
| 42 | 55 | ||
| 43 | // Check length. | 56 | // Process the first 8 characters. |
| 44 | if (length > 32 + offset) { | 57 | const auto* str = formatted_string.data(); |
| 45 | ASSERT_MSG(false, "hex_string has more than 32 hexadecimal characters!"); | 58 | |
| 46 | return INVALID_UUID; | 59 | for (; i < 4; ++i) { |
| 60 | const auto upper = HexCharToByte(*(str++)); | ||
| 61 | const auto lower = HexCharToByte(*(str++)); | ||
| 62 | if (!upper || !lower) { | ||
| 63 | return {}; | ||
| 64 | } | ||
| 65 | uuid[i] = static_cast<u8>((*upper << 4) | *lower); | ||
| 66 | } | ||
| 67 | |||
| 68 | // Process the next 4 characters. | ||
| 69 | ++str; | ||
| 70 | |||
| 71 | for (; i < 6; ++i) { | ||
| 72 | const auto upper = HexCharToByte(*(str++)); | ||
| 73 | const auto lower = HexCharToByte(*(str++)); | ||
| 74 | if (!upper || !lower) { | ||
| 75 | return {}; | ||
| 76 | } | ||
| 77 | uuid[i] = static_cast<u8>((*upper << 4) | *lower); | ||
| 47 | } | 78 | } |
| 48 | 79 | ||
| 49 | u64 lo = 0; | 80 | // Process the next 4 characters. |
| 50 | u64 hi = 0; | 81 | ++str; |
| 51 | for (size_t i = 0; i < length - offset; ++i) { | 82 | |
| 52 | const char c = hex_string[length - 1 - i]; | 83 | for (; i < 8; ++i) { |
| 53 | if (!IsHexDigit(c)) { | 84 | const auto upper = HexCharToByte(*(str++)); |
| 54 | ASSERT_MSG(false, "{} is not a hexadecimal digit!", c); | 85 | const auto lower = HexCharToByte(*(str++)); |
| 55 | return INVALID_UUID; | 86 | if (!upper || !lower) { |
| 87 | return {}; | ||
| 56 | } | 88 | } |
| 57 | if (i < 16) { | 89 | uuid[i] = static_cast<u8>((*upper << 4) | *lower); |
| 58 | lo |= u64{HexCharToByte(c)} << (i * 4); | 90 | } |
| 91 | |||
| 92 | // Process the next 4 characters. | ||
| 93 | ++str; | ||
| 94 | |||
| 95 | for (; i < 10; ++i) { | ||
| 96 | const auto upper = HexCharToByte(*(str++)); | ||
| 97 | const auto lower = HexCharToByte(*(str++)); | ||
| 98 | if (!upper || !lower) { | ||
| 99 | return {}; | ||
| 59 | } | 100 | } |
| 60 | if (i >= 16) { | 101 | uuid[i] = static_cast<u8>((*upper << 4) | *lower); |
| 61 | hi |= u64{HexCharToByte(c)} << ((i - 16) * 4); | 102 | } |
| 103 | |||
| 104 | // Process the last 12 characters. | ||
| 105 | ++str; | ||
| 106 | |||
| 107 | for (; i < 16; ++i) { | ||
| 108 | const auto upper = HexCharToByte(*(str++)); | ||
| 109 | const auto lower = HexCharToByte(*(str++)); | ||
| 110 | if (!upper || !lower) { | ||
| 111 | return {}; | ||
| 62 | } | 112 | } |
| 113 | uuid[i] = static_cast<u8>((*upper << 4) | *lower); | ||
| 114 | } | ||
| 115 | |||
| 116 | return uuid; | ||
| 117 | } | ||
| 118 | |||
| 119 | std::array<u8, 0x10> ConstructUUID(std::string_view uuid_string) { | ||
| 120 | const auto length = uuid_string.length(); | ||
| 121 | |||
| 122 | if (length == 0) { | ||
| 123 | return {}; | ||
| 124 | } | ||
| 125 | |||
| 126 | // Check if the input string contains 32 hexadecimal characters. | ||
| 127 | if (length == RawStringSize) { | ||
| 128 | return ConstructFromRawString(uuid_string); | ||
| 129 | } | ||
| 130 | |||
| 131 | // Check if the input string has the length of a RFC 4122 formatted UUID string. | ||
| 132 | if (length == FormattedStringSize) { | ||
| 133 | return ConstructFromFormattedString(uuid_string); | ||
| 63 | } | 134 | } |
| 64 | return u128{lo, hi}; | 135 | |
| 136 | ASSERT_MSG(false, "UUID string has an invalid length of {} characters!", length); | ||
| 137 | |||
| 138 | return {}; | ||
| 139 | } | ||
| 140 | |||
| 141 | } // Anonymous namespace | ||
| 142 | |||
| 143 | UUID::UUID(std::string_view uuid_string) : uuid{ConstructUUID(uuid_string)} {} | ||
| 144 | |||
| 145 | std::string UUID::RawString() const { | ||
| 146 | return fmt::format("{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}" | ||
| 147 | "{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}", | ||
| 148 | uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7], | ||
| 149 | uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], | ||
| 150 | uuid[15]); | ||
| 151 | } | ||
| 152 | |||
| 153 | std::string UUID::FormattedString() const { | ||
| 154 | return fmt::format("{:02x}{:02x}{:02x}{:02x}" | ||
| 155 | "-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-" | ||
| 156 | "{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}", | ||
| 157 | uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7], | ||
| 158 | uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], | ||
| 159 | uuid[15]); | ||
| 160 | } | ||
| 161 | |||
| 162 | size_t UUID::Hash() const noexcept { | ||
| 163 | u64 upper_hash; | ||
| 164 | u64 lower_hash; | ||
| 165 | |||
| 166 | std::memcpy(&upper_hash, uuid.data(), sizeof(u64)); | ||
| 167 | std::memcpy(&lower_hash, uuid.data() + sizeof(u64), sizeof(u64)); | ||
| 168 | |||
| 169 | return upper_hash ^ std::rotl(lower_hash, 1); | ||
| 65 | } | 170 | } |
| 66 | 171 | ||
| 67 | UUID UUID::Generate() { | 172 | u128 UUID::AsU128() const { |
| 173 | u128 uuid_old; | ||
| 174 | std::memcpy(&uuid_old, uuid.data(), sizeof(UUID)); | ||
| 175 | return uuid_old; | ||
| 176 | } | ||
| 177 | |||
| 178 | UUID UUID::MakeRandom() { | ||
| 68 | std::random_device device; | 179 | std::random_device device; |
| 69 | std::mt19937 gen(device()); | 180 | |
| 70 | std::uniform_int_distribution<u64> distribution(1, std::numeric_limits<u64>::max()); | 181 | return MakeRandomWithSeed(device()); |
| 71 | return UUID{distribution(gen), distribution(gen)}; | ||
| 72 | } | 182 | } |
| 73 | 183 | ||
| 74 | std::string UUID::Format() const { | 184 | UUID UUID::MakeRandomWithSeed(u32 seed) { |
| 75 | return fmt::format("{:016x}{:016x}", uuid[1], uuid[0]); | 185 | // Create and initialize our RNG. |
| 186 | TinyMT rng; | ||
| 187 | rng.Initialize(seed); | ||
| 188 | |||
| 189 | UUID uuid; | ||
| 190 | |||
| 191 | // Populate the UUID with random bytes. | ||
| 192 | rng.GenerateRandomBytes(uuid.uuid.data(), sizeof(UUID)); | ||
| 193 | |||
| 194 | return uuid; | ||
| 76 | } | 195 | } |
| 77 | 196 | ||
| 78 | std::string UUID::FormatSwitch() const { | 197 | UUID UUID::MakeRandomRFC4122V4() { |
| 79 | std::array<u8, 16> s{}; | 198 | auto uuid = MakeRandom(); |
| 80 | std::memcpy(s.data(), uuid.data(), sizeof(u128)); | 199 | |
| 81 | return fmt::format("{:02x}{:02x}{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{" | 200 | // According to Proposed Standard RFC 4122 Section 4.4, we must: |
| 82 | ":02x}{:02x}{:02x}{:02x}{:02x}", | 201 | |
| 83 | s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[8], s[9], s[10], s[11], | 202 | // 1. Set the two most significant bits (bits 6 and 7) of the |
| 84 | s[12], s[13], s[14], s[15]); | 203 | // clock_seq_hi_and_reserved to zero and one, respectively. |
| 204 | uuid.uuid[8] = 0x80 | (uuid.uuid[8] & 0x3F); | ||
| 205 | |||
| 206 | // 2. Set the four most significant bits (bits 12 through 15) of the | ||
| 207 | // time_hi_and_version field to the 4-bit version number from Section 4.1.3. | ||
| 208 | uuid.uuid[6] = 0x40 | (uuid.uuid[6] & 0xF); | ||
| 209 | |||
| 210 | return uuid; | ||
| 85 | } | 211 | } |
| 86 | 212 | ||
| 87 | } // namespace Common | 213 | } // namespace Common |
diff --git a/src/common/uuid.h b/src/common/uuid.h index 8ea01f8da..fe31e64e6 100644 --- a/src/common/uuid.h +++ b/src/common/uuid.h | |||
| @@ -1,9 +1,11 @@ | |||
| 1 | // Copyright 2018 yuzu Emulator Project | 1 | // Copyright 2022 yuzu Emulator Project |
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | ||
| 8 | #include <functional> | ||
| 7 | #include <string> | 9 | #include <string> |
| 8 | #include <string_view> | 10 | #include <string_view> |
| 9 | 11 | ||
| @@ -11,69 +13,119 @@ | |||
| 11 | 13 | ||
| 12 | namespace Common { | 14 | namespace Common { |
| 13 | 15 | ||
| 14 | constexpr u128 INVALID_UUID{{0, 0}}; | ||
| 15 | |||
| 16 | /** | ||
| 17 | * Converts a hex string to a 128-bit unsigned integer. | ||
| 18 | * | ||
| 19 | * The hex string can be formatted in lowercase or uppercase, with or without the "0x" prefix. | ||
| 20 | * | ||
| 21 | * This function will assert and return INVALID_UUID under the following conditions: | ||
| 22 | * - If the hex string is more than 32 characters long | ||
| 23 | * - If the hex string contains non-hexadecimal characters | ||
| 24 | * | ||
| 25 | * @param hex_string Hexadecimal string | ||
| 26 | * | ||
| 27 | * @returns A 128-bit unsigned integer if successfully converted, INVALID_UUID otherwise. | ||
| 28 | */ | ||
| 29 | [[nodiscard]] u128 HexStringToU128(std::string_view hex_string); | ||
| 30 | |||
| 31 | struct UUID { | 16 | struct UUID { |
| 32 | // UUIDs which are 0 are considered invalid! | 17 | std::array<u8, 0x10> uuid{}; |
| 33 | u128 uuid; | 18 | |
| 34 | UUID() = default; | 19 | /// Constructs an invalid UUID. |
| 35 | constexpr explicit UUID(const u128& id) : uuid{id} {} | 20 | constexpr UUID() = default; |
| 36 | constexpr explicit UUID(const u64 lo, const u64 hi) : uuid{{lo, hi}} {} | 21 | |
| 37 | explicit UUID(std::string_view hex_string) { | 22 | /// Constructs a UUID from a reference to a 128 bit array. |
| 38 | uuid = HexStringToU128(hex_string); | 23 | constexpr explicit UUID(const std::array<u8, 16>& uuid_) : uuid{uuid_} {} |
| 39 | } | 24 | |
| 40 | 25 | /** | |
| 41 | [[nodiscard]] constexpr explicit operator bool() const { | 26 | * Constructs a UUID from either: |
| 42 | return uuid != INVALID_UUID; | 27 | * 1. A 32 hexadecimal character string representing the bytes of the UUID |
| 43 | } | 28 | * 2. A RFC 4122 formatted UUID string, in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx |
| 44 | 29 | * | |
| 45 | [[nodiscard]] constexpr bool operator==(const UUID& rhs) const { | 30 | * The input string may contain uppercase or lowercase characters, but they must: |
| 46 | return uuid == rhs.uuid; | 31 | * 1. Contain valid hexadecimal characters (0-9, a-f, A-F) |
| 47 | } | 32 | * 2. Not contain the "0x" hexadecimal prefix |
| 48 | 33 | * | |
| 49 | [[nodiscard]] constexpr bool operator!=(const UUID& rhs) const { | 34 | * Should the input string not meet the above requirements, |
| 50 | return !operator==(rhs); | 35 | * an assert will be triggered and an invalid UUID is set instead. |
| 51 | } | 36 | */ |
| 52 | 37 | explicit UUID(std::string_view uuid_string); | |
| 53 | // TODO(ogniK): Properly generate uuids based on RFC-4122 | 38 | |
| 54 | [[nodiscard]] static UUID Generate(); | 39 | ~UUID() = default; |
| 55 | 40 | ||
| 56 | // Set the UUID to {0,0} to be considered an invalid user | 41 | constexpr UUID(const UUID&) noexcept = default; |
| 57 | constexpr void Invalidate() { | 42 | constexpr UUID(UUID&&) noexcept = default; |
| 58 | uuid = INVALID_UUID; | 43 | |
| 44 | constexpr UUID& operator=(const UUID&) noexcept = default; | ||
| 45 | constexpr UUID& operator=(UUID&&) noexcept = default; | ||
| 46 | |||
| 47 | /** | ||
| 48 | * Returns whether the stored UUID is valid or not. | ||
| 49 | * | ||
| 50 | * @returns True if the stored UUID is valid, false otherwise. | ||
| 51 | */ | ||
| 52 | constexpr bool IsValid() const { | ||
| 53 | return uuid != std::array<u8, 0x10>{}; | ||
| 59 | } | 54 | } |
| 60 | 55 | ||
| 61 | [[nodiscard]] constexpr bool IsInvalid() const { | 56 | /** |
| 62 | return uuid == INVALID_UUID; | 57 | * Returns whether the stored UUID is invalid or not. |
| 63 | } | 58 | * |
| 64 | [[nodiscard]] constexpr bool IsValid() const { | 59 | * @returns True if the stored UUID is invalid, false otherwise. |
| 65 | return !IsInvalid(); | 60 | */ |
| 61 | constexpr bool IsInvalid() const { | ||
| 62 | return !IsValid(); | ||
| 66 | } | 63 | } |
| 67 | 64 | ||
| 68 | // TODO(ogniK): Properly generate a Nintendo ID | 65 | /** |
| 69 | [[nodiscard]] constexpr u64 GetNintendoID() const { | 66 | * Returns a 32 hexadecimal character string representing the bytes of the UUID. |
| 70 | return uuid[0]; | 67 | * |
| 68 | * @returns A 32 hexadecimal character string of the UUID. | ||
| 69 | */ | ||
| 70 | std::string RawString() const; | ||
| 71 | |||
| 72 | /** | ||
| 73 | * Returns a RFC 4122 formatted UUID string in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. | ||
| 74 | * | ||
| 75 | * @returns A RFC 4122 formatted UUID string. | ||
| 76 | */ | ||
| 77 | std::string FormattedString() const; | ||
| 78 | |||
| 79 | /** | ||
| 80 | * Returns a 64-bit hash of the UUID for use in hash table data structures. | ||
| 81 | * | ||
| 82 | * @returns A 64-bit hash of the UUID. | ||
| 83 | */ | ||
| 84 | size_t Hash() const noexcept; | ||
| 85 | |||
| 86 | /// DO NOT USE. Copies the contents of the UUID into a u128. | ||
| 87 | u128 AsU128() const; | ||
| 88 | |||
| 89 | /** | ||
| 90 | * Creates a default UUID "yuzu Default UID". | ||
| 91 | * | ||
| 92 | * @returns A UUID with its bytes set to the ASCII values of "yuzu Default UID". | ||
| 93 | */ | ||
| 94 | static constexpr UUID MakeDefault() { | ||
| 95 | return UUID{ | ||
| 96 | {'y', 'u', 'z', 'u', ' ', 'D', 'e', 'f', 'a', 'u', 'l', 't', ' ', 'U', 'I', 'D'}, | ||
| 97 | }; | ||
| 71 | } | 98 | } |
| 72 | 99 | ||
| 73 | [[nodiscard]] std::string Format() const; | 100 | /** |
| 74 | [[nodiscard]] std::string FormatSwitch() const; | 101 | * Creates a random UUID. |
| 102 | * | ||
| 103 | * @returns A random UUID. | ||
| 104 | */ | ||
| 105 | static UUID MakeRandom(); | ||
| 106 | |||
| 107 | /** | ||
| 108 | * Creates a random UUID with a seed. | ||
| 109 | * | ||
| 110 | * @param seed A seed to initialize the Mersenne-Twister RNG | ||
| 111 | * | ||
| 112 | * @returns A random UUID. | ||
| 113 | */ | ||
| 114 | static UUID MakeRandomWithSeed(u32 seed); | ||
| 115 | |||
| 116 | /** | ||
| 117 | * Creates a random UUID. The generated UUID is RFC 4122 Version 4 compliant. | ||
| 118 | * | ||
| 119 | * @returns A random UUID that is RFC 4122 Version 4 compliant. | ||
| 120 | */ | ||
| 121 | static UUID MakeRandomRFC4122V4(); | ||
| 122 | |||
| 123 | friend constexpr bool operator==(const UUID& lhs, const UUID& rhs) = default; | ||
| 75 | }; | 124 | }; |
| 76 | static_assert(sizeof(UUID) == 16, "UUID is an invalid size!"); | 125 | static_assert(sizeof(UUID) == 0x10, "UUID has incorrect size."); |
| 126 | |||
| 127 | /// An invalid UUID. This UUID has all its bytes set to 0. | ||
| 128 | constexpr UUID InvalidUUID = {}; | ||
| 77 | 129 | ||
| 78 | } // namespace Common | 130 | } // namespace Common |
| 79 | 131 | ||
| @@ -82,7 +134,7 @@ namespace std { | |||
| 82 | template <> | 134 | template <> |
| 83 | struct hash<Common::UUID> { | 135 | struct hash<Common::UUID> { |
| 84 | size_t operator()(const Common::UUID& uuid) const noexcept { | 136 | size_t operator()(const Common::UUID& uuid) const noexcept { |
| 85 | return uuid.uuid[1] ^ uuid.uuid[0]; | 137 | return uuid.Hash(); |
| 86 | } | 138 | } |
| 87 | }; | 139 | }; |
| 88 | 140 | ||
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index 7c0950bb0..f19ac4607 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp | |||
| @@ -128,15 +128,6 @@ VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const { | |||
| 128 | if (exefs == nullptr) | 128 | if (exefs == nullptr) |
| 129 | return exefs; | 129 | return exefs; |
| 130 | 130 | ||
| 131 | if (Settings::values.dump_exefs) { | ||
| 132 | LOG_INFO(Loader, "Dumping ExeFS for title_id={:016X}", title_id); | ||
| 133 | const auto dump_dir = fs_controller.GetModificationDumpRoot(title_id); | ||
| 134 | if (dump_dir != nullptr) { | ||
| 135 | const auto exefs_dir = GetOrCreateDirectoryRelative(dump_dir, "/exefs"); | ||
| 136 | VfsRawCopyD(exefs, exefs_dir); | ||
| 137 | } | ||
| 138 | } | ||
| 139 | |||
| 140 | const auto& disabled = Settings::values.disabled_addons[title_id]; | 131 | const auto& disabled = Settings::values.disabled_addons[title_id]; |
| 141 | const auto update_disabled = | 132 | const auto update_disabled = |
| 142 | std::find(disabled.cbegin(), disabled.cend(), "Update") != disabled.cend(); | 133 | std::find(disabled.cbegin(), disabled.cend(), "Update") != disabled.cend(); |
| @@ -179,6 +170,15 @@ VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const { | |||
| 179 | } | 170 | } |
| 180 | } | 171 | } |
| 181 | 172 | ||
| 173 | if (Settings::values.dump_exefs) { | ||
| 174 | LOG_INFO(Loader, "Dumping ExeFS for title_id={:016X}", title_id); | ||
| 175 | const auto dump_dir = fs_controller.GetModificationDumpRoot(title_id); | ||
| 176 | if (dump_dir != nullptr) { | ||
| 177 | const auto exefs_dir = GetOrCreateDirectoryRelative(dump_dir, "/exefs"); | ||
| 178 | VfsRawCopyD(exefs, exefs_dir); | ||
| 179 | } | ||
| 180 | } | ||
| 181 | |||
| 182 | return exefs; | 182 | return exefs; |
| 183 | } | 183 | } |
| 184 | 184 | ||
diff --git a/src/core/frontend/applets/profile_select.cpp b/src/core/frontend/applets/profile_select.cpp index 3e4f90be2..4c58c310f 100644 --- a/src/core/frontend/applets/profile_select.cpp +++ b/src/core/frontend/applets/profile_select.cpp | |||
| @@ -13,8 +13,7 @@ ProfileSelectApplet::~ProfileSelectApplet() = default; | |||
| 13 | void DefaultProfileSelectApplet::SelectProfile( | 13 | void DefaultProfileSelectApplet::SelectProfile( |
| 14 | std::function<void(std::optional<Common::UUID>)> callback) const { | 14 | std::function<void(std::optional<Common::UUID>)> callback) const { |
| 15 | Service::Account::ProfileManager manager; | 15 | Service::Account::ProfileManager manager; |
| 16 | callback(manager.GetUser(Settings::values.current_user.GetValue()) | 16 | callback(manager.GetUser(Settings::values.current_user.GetValue()).value_or(Common::UUID{})); |
| 17 | .value_or(Common::UUID{Common::INVALID_UUID})); | ||
| 18 | LOG_INFO(Service_ACC, "called, selecting current user instead of prompting..."); | 17 | LOG_INFO(Service_ACC, "called, selecting current user instead of prompting..."); |
| 19 | } | 18 | } |
| 20 | 19 | ||
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index a7cdf45e6..2bee173b3 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp | |||
| @@ -269,7 +269,8 @@ void EmulatedController::ReloadInput() { | |||
| 269 | } | 269 | } |
| 270 | 270 | ||
| 271 | // Use a common UUID for TAS | 271 | // Use a common UUID for TAS |
| 272 | const auto tas_uuid = Common::UUID{0x0, 0x7A5}; | 272 | static constexpr Common::UUID TAS_UUID = Common::UUID{ |
| 273 | {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xA5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}; | ||
| 273 | 274 | ||
| 274 | // Register TAS devices. No need to force update | 275 | // Register TAS devices. No need to force update |
| 275 | for (std::size_t index = 0; index < tas_button_devices.size(); ++index) { | 276 | for (std::size_t index = 0; index < tas_button_devices.size(); ++index) { |
| @@ -278,8 +279,8 @@ void EmulatedController::ReloadInput() { | |||
| 278 | } | 279 | } |
| 279 | tas_button_devices[index]->SetCallback({ | 280 | tas_button_devices[index]->SetCallback({ |
| 280 | .on_change = | 281 | .on_change = |
| 281 | [this, index, tas_uuid](const Common::Input::CallbackStatus& callback) { | 282 | [this, index](const Common::Input::CallbackStatus& callback) { |
| 282 | SetButton(callback, index, tas_uuid); | 283 | SetButton(callback, index, TAS_UUID); |
| 283 | }, | 284 | }, |
| 284 | }); | 285 | }); |
| 285 | } | 286 | } |
| @@ -290,8 +291,8 @@ void EmulatedController::ReloadInput() { | |||
| 290 | } | 291 | } |
| 291 | tas_stick_devices[index]->SetCallback({ | 292 | tas_stick_devices[index]->SetCallback({ |
| 292 | .on_change = | 293 | .on_change = |
| 293 | [this, index, tas_uuid](const Common::Input::CallbackStatus& callback) { | 294 | [this, index](const Common::Input::CallbackStatus& callback) { |
| 294 | SetStick(callback, index, tas_uuid); | 295 | SetStick(callback, index, TAS_UUID); |
| 295 | }, | 296 | }, |
| 296 | }); | 297 | }); |
| 297 | } | 298 | } |
diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h index cf204f570..026257115 100644 --- a/src/core/hle/ipc_helpers.h +++ b/src/core/hle/ipc_helpers.h | |||
| @@ -404,6 +404,11 @@ inline s32 RequestParser::Pop() { | |||
| 404 | return static_cast<s32>(Pop<u32>()); | 404 | return static_cast<s32>(Pop<u32>()); |
| 405 | } | 405 | } |
| 406 | 406 | ||
| 407 | // Ignore the -Wclass-memaccess warning on memcpy for non-trivially default constructible objects. | ||
| 408 | #if defined(__GNUC__) | ||
| 409 | #pragma GCC diagnostic push | ||
| 410 | #pragma GCC diagnostic ignored "-Wclass-memaccess" | ||
| 411 | #endif | ||
| 407 | template <typename T> | 412 | template <typename T> |
| 408 | void RequestParser::PopRaw(T& value) { | 413 | void RequestParser::PopRaw(T& value) { |
| 409 | static_assert(std::is_trivially_copyable_v<T>, | 414 | static_assert(std::is_trivially_copyable_v<T>, |
| @@ -411,6 +416,9 @@ void RequestParser::PopRaw(T& value) { | |||
| 411 | std::memcpy(&value, cmdbuf + index, sizeof(T)); | 416 | std::memcpy(&value, cmdbuf + index, sizeof(T)); |
| 412 | index += (sizeof(T) + 3) / 4; // round up to word length | 417 | index += (sizeof(T) + 3) / 4; // round up to word length |
| 413 | } | 418 | } |
| 419 | #if defined(__GNUC__) | ||
| 420 | #pragma GCC diagnostic pop | ||
| 421 | #endif | ||
| 414 | 422 | ||
| 415 | template <typename T> | 423 | template <typename T> |
| 416 | T RequestParser::PopRaw() { | 424 | T RequestParser::PopRaw() { |
diff --git a/src/core/hle/kernel/k_code_memory.cpp b/src/core/hle/kernel/k_code_memory.cpp index d69f7ffb7..0b225e8e0 100644 --- a/src/core/hle/kernel/k_code_memory.cpp +++ b/src/core/hle/kernel/k_code_memory.cpp | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "common/alignment.h" | ||
| 5 | #include "common/common_types.h" | 6 | #include "common/common_types.h" |
| 6 | #include "core/device_memory.h" | 7 | #include "core/device_memory.h" |
| 7 | #include "core/hle/kernel/k_auto_object.h" | 8 | #include "core/hle/kernel/k_auto_object.h" |
| @@ -28,8 +29,7 @@ ResultCode KCodeMemory::Initialize(Core::DeviceMemory& device_memory, VAddr addr | |||
| 28 | auto& page_table = m_owner->PageTable(); | 29 | auto& page_table = m_owner->PageTable(); |
| 29 | 30 | ||
| 30 | // Construct the page group. | 31 | // Construct the page group. |
| 31 | KMemoryInfo kBlockInfo = page_table.QueryInfo(addr); | 32 | m_page_group = KPageLinkedList(addr, Common::DivideUp(size, PageSize)); |
| 32 | m_page_group = KPageLinkedList(kBlockInfo.GetAddress(), kBlockInfo.GetNumPages()); | ||
| 33 | 33 | ||
| 34 | // Lock the memory. | 34 | // Lock the memory. |
| 35 | R_TRY(page_table.LockForCodeMemory(addr, size)) | 35 | R_TRY(page_table.LockForCodeMemory(addr, size)) |
| @@ -143,4 +143,4 @@ ResultCode KCodeMemory::UnmapFromOwner(VAddr address, size_t size) { | |||
| 143 | return ResultSuccess; | 143 | return ResultSuccess; |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | } // namespace Kernel \ No newline at end of file | 146 | } // namespace Kernel |
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 9387373c1..3a2c9d18d 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -2559,9 +2559,9 @@ struct FunctionDef { | |||
| 2559 | } // namespace | 2559 | } // namespace |
| 2560 | 2560 | ||
| 2561 | static const FunctionDef SVC_Table_32[] = { | 2561 | static const FunctionDef SVC_Table_32[] = { |
| 2562 | {0x00, nullptr, "Unknown"}, | 2562 | {0x00, nullptr, "Unknown0"}, |
| 2563 | {0x01, SvcWrap32<SetHeapSize32>, "SetHeapSize32"}, | 2563 | {0x01, SvcWrap32<SetHeapSize32>, "SetHeapSize32"}, |
| 2564 | {0x02, nullptr, "Unknown"}, | 2564 | {0x02, nullptr, "SetMemoryPermission32"}, |
| 2565 | {0x03, SvcWrap32<SetMemoryAttribute32>, "SetMemoryAttribute32"}, | 2565 | {0x03, SvcWrap32<SetMemoryAttribute32>, "SetMemoryAttribute32"}, |
| 2566 | {0x04, SvcWrap32<MapMemory32>, "MapMemory32"}, | 2566 | {0x04, SvcWrap32<MapMemory32>, "MapMemory32"}, |
| 2567 | {0x05, SvcWrap32<UnmapMemory32>, "UnmapMemory32"}, | 2567 | {0x05, SvcWrap32<UnmapMemory32>, "UnmapMemory32"}, |
| @@ -2591,97 +2591,97 @@ static const FunctionDef SVC_Table_32[] = { | |||
| 2591 | {0x1d, SvcWrap32<SignalProcessWideKey32>, "SignalProcessWideKey32"}, | 2591 | {0x1d, SvcWrap32<SignalProcessWideKey32>, "SignalProcessWideKey32"}, |
| 2592 | {0x1e, SvcWrap32<GetSystemTick32>, "GetSystemTick32"}, | 2592 | {0x1e, SvcWrap32<GetSystemTick32>, "GetSystemTick32"}, |
| 2593 | {0x1f, SvcWrap32<ConnectToNamedPort32>, "ConnectToNamedPort32"}, | 2593 | {0x1f, SvcWrap32<ConnectToNamedPort32>, "ConnectToNamedPort32"}, |
| 2594 | {0x20, nullptr, "Unknown"}, | 2594 | {0x20, nullptr, "SendSyncRequestLight32"}, |
| 2595 | {0x21, SvcWrap32<SendSyncRequest32>, "SendSyncRequest32"}, | 2595 | {0x21, SvcWrap32<SendSyncRequest32>, "SendSyncRequest32"}, |
| 2596 | {0x22, nullptr, "SendSyncRequestWithUserBuffer32"}, | 2596 | {0x22, nullptr, "SendSyncRequestWithUserBuffer32"}, |
| 2597 | {0x23, nullptr, "Unknown"}, | 2597 | {0x23, nullptr, "SendAsyncRequestWithUserBuffer32"}, |
| 2598 | {0x24, SvcWrap32<GetProcessId32>, "GetProcessId32"}, | 2598 | {0x24, SvcWrap32<GetProcessId32>, "GetProcessId32"}, |
| 2599 | {0x25, SvcWrap32<GetThreadId32>, "GetThreadId32"}, | 2599 | {0x25, SvcWrap32<GetThreadId32>, "GetThreadId32"}, |
| 2600 | {0x26, SvcWrap32<Break32>, "Break32"}, | 2600 | {0x26, SvcWrap32<Break32>, "Break32"}, |
| 2601 | {0x27, nullptr, "OutputDebugString32"}, | 2601 | {0x27, nullptr, "OutputDebugString32"}, |
| 2602 | {0x28, nullptr, "Unknown"}, | 2602 | {0x28, nullptr, "ReturnFromException32"}, |
| 2603 | {0x29, SvcWrap32<GetInfo32>, "GetInfo32"}, | 2603 | {0x29, SvcWrap32<GetInfo32>, "GetInfo32"}, |
| 2604 | {0x2a, nullptr, "Unknown"}, | 2604 | {0x2a, nullptr, "FlushEntireDataCache32"}, |
| 2605 | {0x2b, nullptr, "Unknown"}, | 2605 | {0x2b, nullptr, "FlushDataCache32"}, |
| 2606 | {0x2c, SvcWrap32<MapPhysicalMemory32>, "MapPhysicalMemory32"}, | 2606 | {0x2c, SvcWrap32<MapPhysicalMemory32>, "MapPhysicalMemory32"}, |
| 2607 | {0x2d, SvcWrap32<UnmapPhysicalMemory32>, "UnmapPhysicalMemory32"}, | 2607 | {0x2d, SvcWrap32<UnmapPhysicalMemory32>, "UnmapPhysicalMemory32"}, |
| 2608 | {0x2e, nullptr, "Unknown"}, | 2608 | {0x2e, nullptr, "GetDebugFutureThreadInfo32"}, |
| 2609 | {0x2f, nullptr, "Unknown"}, | 2609 | {0x2f, nullptr, "GetLastThreadInfo32"}, |
| 2610 | {0x30, nullptr, "Unknown"}, | 2610 | {0x30, nullptr, "GetResourceLimitLimitValue32"}, |
| 2611 | {0x31, nullptr, "Unknown"}, | 2611 | {0x31, nullptr, "GetResourceLimitCurrentValue32"}, |
| 2612 | {0x32, SvcWrap32<SetThreadActivity32>, "SetThreadActivity32"}, | 2612 | {0x32, SvcWrap32<SetThreadActivity32>, "SetThreadActivity32"}, |
| 2613 | {0x33, SvcWrap32<GetThreadContext32>, "GetThreadContext32"}, | 2613 | {0x33, SvcWrap32<GetThreadContext32>, "GetThreadContext32"}, |
| 2614 | {0x34, SvcWrap32<WaitForAddress32>, "WaitForAddress32"}, | 2614 | {0x34, SvcWrap32<WaitForAddress32>, "WaitForAddress32"}, |
| 2615 | {0x35, SvcWrap32<SignalToAddress32>, "SignalToAddress32"}, | 2615 | {0x35, SvcWrap32<SignalToAddress32>, "SignalToAddress32"}, |
| 2616 | {0x36, SvcWrap32<SynchronizePreemptionState>, "SynchronizePreemptionState32"}, | 2616 | {0x36, SvcWrap32<SynchronizePreemptionState>, "SynchronizePreemptionState32"}, |
| 2617 | {0x37, nullptr, "Unknown"}, | 2617 | {0x37, nullptr, "GetResourceLimitPeakValue32"}, |
| 2618 | {0x38, nullptr, "Unknown"}, | 2618 | {0x38, nullptr, "Unknown38"}, |
| 2619 | {0x39, nullptr, "Unknown"}, | 2619 | {0x39, nullptr, "CreateIoPool32"}, |
| 2620 | {0x3a, nullptr, "Unknown"}, | 2620 | {0x3a, nullptr, "CreateIoRegion32"}, |
| 2621 | {0x3b, nullptr, "Unknown"}, | 2621 | {0x3b, nullptr, "Unknown3b"}, |
| 2622 | {0x3c, nullptr, "Unknown"}, | 2622 | {0x3c, nullptr, "KernelDebug32"}, |
| 2623 | {0x3d, nullptr, "Unknown"}, | 2623 | {0x3d, nullptr, "ChangeKernelTraceState32"}, |
| 2624 | {0x3e, nullptr, "Unknown"}, | 2624 | {0x3e, nullptr, "Unknown3e"}, |
| 2625 | {0x3f, nullptr, "Unknown"}, | 2625 | {0x3f, nullptr, "Unknown3f"}, |
| 2626 | {0x40, nullptr, "CreateSession32"}, | 2626 | {0x40, nullptr, "CreateSession32"}, |
| 2627 | {0x41, nullptr, "AcceptSession32"}, | 2627 | {0x41, nullptr, "AcceptSession32"}, |
| 2628 | {0x42, nullptr, "Unknown"}, | 2628 | {0x42, nullptr, "ReplyAndReceiveLight32"}, |
| 2629 | {0x43, nullptr, "ReplyAndReceive32"}, | 2629 | {0x43, nullptr, "ReplyAndReceive32"}, |
| 2630 | {0x44, nullptr, "Unknown"}, | 2630 | {0x44, nullptr, "ReplyAndReceiveWithUserBuffer32"}, |
| 2631 | {0x45, SvcWrap32<CreateEvent32>, "CreateEvent32"}, | 2631 | {0x45, SvcWrap32<CreateEvent32>, "CreateEvent32"}, |
| 2632 | {0x46, nullptr, "Unknown"}, | 2632 | {0x46, nullptr, "MapIoRegion32"}, |
| 2633 | {0x47, nullptr, "Unknown"}, | 2633 | {0x47, nullptr, "UnmapIoRegion32"}, |
| 2634 | {0x48, nullptr, "Unknown"}, | 2634 | {0x48, nullptr, "MapPhysicalMemoryUnsafe32"}, |
| 2635 | {0x49, nullptr, "Unknown"}, | 2635 | {0x49, nullptr, "UnmapPhysicalMemoryUnsafe32"}, |
| 2636 | {0x4a, nullptr, "Unknown"}, | 2636 | {0x4a, nullptr, "SetUnsafeLimit32"}, |
| 2637 | {0x4b, nullptr, "Unknown"}, | 2637 | {0x4b, nullptr, "CreateCodeMemory32"}, |
| 2638 | {0x4c, nullptr, "Unknown"}, | 2638 | {0x4c, nullptr, "ControlCodeMemory32"}, |
| 2639 | {0x4d, nullptr, "Unknown"}, | 2639 | {0x4d, nullptr, "SleepSystem32"}, |
| 2640 | {0x4e, nullptr, "Unknown"}, | 2640 | {0x4e, nullptr, "ReadWriteRegister32"}, |
| 2641 | {0x4f, nullptr, "Unknown"}, | 2641 | {0x4f, nullptr, "SetProcessActivity32"}, |
| 2642 | {0x50, nullptr, "Unknown"}, | 2642 | {0x50, nullptr, "CreateSharedMemory32"}, |
| 2643 | {0x51, nullptr, "Unknown"}, | 2643 | {0x51, nullptr, "MapTransferMemory32"}, |
| 2644 | {0x52, nullptr, "Unknown"}, | 2644 | {0x52, nullptr, "UnmapTransferMemory32"}, |
| 2645 | {0x53, nullptr, "Unknown"}, | 2645 | {0x53, nullptr, "CreateInterruptEvent32"}, |
| 2646 | {0x54, nullptr, "Unknown"}, | 2646 | {0x54, nullptr, "QueryPhysicalAddress32"}, |
| 2647 | {0x55, nullptr, "Unknown"}, | 2647 | {0x55, nullptr, "QueryIoMapping32"}, |
| 2648 | {0x56, nullptr, "Unknown"}, | 2648 | {0x56, nullptr, "CreateDeviceAddressSpace32"}, |
| 2649 | {0x57, nullptr, "Unknown"}, | 2649 | {0x57, nullptr, "AttachDeviceAddressSpace32"}, |
| 2650 | {0x58, nullptr, "Unknown"}, | 2650 | {0x58, nullptr, "DetachDeviceAddressSpace32"}, |
| 2651 | {0x59, nullptr, "Unknown"}, | 2651 | {0x59, nullptr, "MapDeviceAddressSpaceByForce32"}, |
| 2652 | {0x5a, nullptr, "Unknown"}, | 2652 | {0x5a, nullptr, "MapDeviceAddressSpaceAligned32"}, |
| 2653 | {0x5b, nullptr, "Unknown"}, | 2653 | {0x5b, nullptr, "MapDeviceAddressSpace32"}, |
| 2654 | {0x5c, nullptr, "Unknown"}, | 2654 | {0x5c, nullptr, "UnmapDeviceAddressSpace32"}, |
| 2655 | {0x5d, nullptr, "Unknown"}, | 2655 | {0x5d, nullptr, "InvalidateProcessDataCache32"}, |
| 2656 | {0x5e, nullptr, "Unknown"}, | 2656 | {0x5e, nullptr, "StoreProcessDataCache32"}, |
| 2657 | {0x5F, SvcWrap32<FlushProcessDataCache32>, "FlushProcessDataCache32"}, | 2657 | {0x5F, SvcWrap32<FlushProcessDataCache32>, "FlushProcessDataCache32"}, |
| 2658 | {0x60, nullptr, "Unknown"}, | 2658 | {0x60, nullptr, "StoreProcessDataCache32"}, |
| 2659 | {0x61, nullptr, "Unknown"}, | 2659 | {0x61, nullptr, "BreakDebugProcess32"}, |
| 2660 | {0x62, nullptr, "Unknown"}, | 2660 | {0x62, nullptr, "TerminateDebugProcess32"}, |
| 2661 | {0x63, nullptr, "Unknown"}, | 2661 | {0x63, nullptr, "GetDebugEvent32"}, |
| 2662 | {0x64, nullptr, "Unknown"}, | 2662 | {0x64, nullptr, "ContinueDebugEvent32"}, |
| 2663 | {0x65, nullptr, "GetProcessList32"}, | 2663 | {0x65, nullptr, "GetProcessList32"}, |
| 2664 | {0x66, nullptr, "Unknown"}, | 2664 | {0x66, nullptr, "GetThreadList"}, |
| 2665 | {0x67, nullptr, "Unknown"}, | 2665 | {0x67, nullptr, "GetDebugThreadContext32"}, |
| 2666 | {0x68, nullptr, "Unknown"}, | 2666 | {0x68, nullptr, "SetDebugThreadContext32"}, |
| 2667 | {0x69, nullptr, "Unknown"}, | 2667 | {0x69, nullptr, "QueryDebugProcessMemory32"}, |
| 2668 | {0x6A, nullptr, "Unknown"}, | 2668 | {0x6A, nullptr, "ReadDebugProcessMemory32"}, |
| 2669 | {0x6B, nullptr, "Unknown"}, | 2669 | {0x6B, nullptr, "WriteDebugProcessMemory32"}, |
| 2670 | {0x6C, nullptr, "Unknown"}, | 2670 | {0x6C, nullptr, "SetHardwareBreakPoint32"}, |
| 2671 | {0x6D, nullptr, "Unknown"}, | 2671 | {0x6D, nullptr, "GetDebugThreadParam32"}, |
| 2672 | {0x6E, nullptr, "Unknown"}, | 2672 | {0x6E, nullptr, "Unknown6E"}, |
| 2673 | {0x6f, nullptr, "GetSystemInfo32"}, | 2673 | {0x6f, nullptr, "GetSystemInfo32"}, |
| 2674 | {0x70, nullptr, "CreatePort32"}, | 2674 | {0x70, nullptr, "CreatePort32"}, |
| 2675 | {0x71, nullptr, "ManageNamedPort32"}, | 2675 | {0x71, nullptr, "ManageNamedPort32"}, |
| 2676 | {0x72, nullptr, "ConnectToPort32"}, | 2676 | {0x72, nullptr, "ConnectToPort32"}, |
| 2677 | {0x73, nullptr, "SetProcessMemoryPermission32"}, | 2677 | {0x73, nullptr, "SetProcessMemoryPermission32"}, |
| 2678 | {0x74, nullptr, "Unknown"}, | 2678 | {0x74, nullptr, "MapProcessMemory32"}, |
| 2679 | {0x75, nullptr, "Unknown"}, | 2679 | {0x75, nullptr, "UnmapProcessMemory32"}, |
| 2680 | {0x76, nullptr, "Unknown"}, | 2680 | {0x76, nullptr, "QueryProcessMemory32"}, |
| 2681 | {0x77, nullptr, "MapProcessCodeMemory32"}, | 2681 | {0x77, nullptr, "MapProcessCodeMemory32"}, |
| 2682 | {0x78, nullptr, "UnmapProcessCodeMemory32"}, | 2682 | {0x78, nullptr, "UnmapProcessCodeMemory32"}, |
| 2683 | {0x79, nullptr, "Unknown"}, | 2683 | {0x79, nullptr, "CreateProcess32"}, |
| 2684 | {0x7A, nullptr, "Unknown"}, | 2684 | {0x7A, nullptr, "StartProcess32"}, |
| 2685 | {0x7B, nullptr, "TerminateProcess32"}, | 2685 | {0x7B, nullptr, "TerminateProcess32"}, |
| 2686 | {0x7C, nullptr, "GetProcessInfo32"}, | 2686 | {0x7C, nullptr, "GetProcessInfo32"}, |
| 2687 | {0x7D, nullptr, "CreateResourceLimit32"}, | 2687 | {0x7D, nullptr, "CreateResourceLimit32"}, |
| @@ -2754,7 +2754,7 @@ static const FunctionDef SVC_Table_32[] = { | |||
| 2754 | }; | 2754 | }; |
| 2755 | 2755 | ||
| 2756 | static const FunctionDef SVC_Table_64[] = { | 2756 | static const FunctionDef SVC_Table_64[] = { |
| 2757 | {0x00, nullptr, "Unknown"}, | 2757 | {0x00, nullptr, "Unknown0"}, |
| 2758 | {0x01, SvcWrap64<SetHeapSize>, "SetHeapSize"}, | 2758 | {0x01, SvcWrap64<SetHeapSize>, "SetHeapSize"}, |
| 2759 | {0x02, SvcWrap64<SetMemoryPermission>, "SetMemoryPermission"}, | 2759 | {0x02, SvcWrap64<SetMemoryPermission>, "SetMemoryPermission"}, |
| 2760 | {0x03, SvcWrap64<SetMemoryAttribute>, "SetMemoryAttribute"}, | 2760 | {0x03, SvcWrap64<SetMemoryAttribute>, "SetMemoryAttribute"}, |
| @@ -2809,23 +2809,23 @@ static const FunctionDef SVC_Table_64[] = { | |||
| 2809 | {0x34, SvcWrap64<WaitForAddress>, "WaitForAddress"}, | 2809 | {0x34, SvcWrap64<WaitForAddress>, "WaitForAddress"}, |
| 2810 | {0x35, SvcWrap64<SignalToAddress>, "SignalToAddress"}, | 2810 | {0x35, SvcWrap64<SignalToAddress>, "SignalToAddress"}, |
| 2811 | {0x36, SvcWrap64<SynchronizePreemptionState>, "SynchronizePreemptionState"}, | 2811 | {0x36, SvcWrap64<SynchronizePreemptionState>, "SynchronizePreemptionState"}, |
| 2812 | {0x37, nullptr, "Unknown"}, | 2812 | {0x37, nullptr, "GetResourceLimitPeakValue"}, |
| 2813 | {0x38, nullptr, "Unknown"}, | 2813 | {0x38, nullptr, "Unknown38"}, |
| 2814 | {0x39, nullptr, "Unknown"}, | 2814 | {0x39, nullptr, "CreateIoPool"}, |
| 2815 | {0x3A, nullptr, "Unknown"}, | 2815 | {0x3A, nullptr, "CreateIoRegion"}, |
| 2816 | {0x3B, nullptr, "Unknown"}, | 2816 | {0x3B, nullptr, "Unknown3B"}, |
| 2817 | {0x3C, SvcWrap64<KernelDebug>, "KernelDebug"}, | 2817 | {0x3C, SvcWrap64<KernelDebug>, "KernelDebug"}, |
| 2818 | {0x3D, SvcWrap64<ChangeKernelTraceState>, "ChangeKernelTraceState"}, | 2818 | {0x3D, SvcWrap64<ChangeKernelTraceState>, "ChangeKernelTraceState"}, |
| 2819 | {0x3E, nullptr, "Unknown"}, | 2819 | {0x3E, nullptr, "Unknown3e"}, |
| 2820 | {0x3F, nullptr, "Unknown"}, | 2820 | {0x3F, nullptr, "Unknown3f"}, |
| 2821 | {0x40, nullptr, "CreateSession"}, | 2821 | {0x40, nullptr, "CreateSession"}, |
| 2822 | {0x41, nullptr, "AcceptSession"}, | 2822 | {0x41, nullptr, "AcceptSession"}, |
| 2823 | {0x42, nullptr, "ReplyAndReceiveLight"}, | 2823 | {0x42, nullptr, "ReplyAndReceiveLight"}, |
| 2824 | {0x43, nullptr, "ReplyAndReceive"}, | 2824 | {0x43, nullptr, "ReplyAndReceive"}, |
| 2825 | {0x44, nullptr, "ReplyAndReceiveWithUserBuffer"}, | 2825 | {0x44, nullptr, "ReplyAndReceiveWithUserBuffer"}, |
| 2826 | {0x45, SvcWrap64<CreateEvent>, "CreateEvent"}, | 2826 | {0x45, SvcWrap64<CreateEvent>, "CreateEvent"}, |
| 2827 | {0x46, nullptr, "Unknown"}, | 2827 | {0x46, nullptr, "MapIoRegion"}, |
| 2828 | {0x47, nullptr, "Unknown"}, | 2828 | {0x47, nullptr, "UnmapIoRegion"}, |
| 2829 | {0x48, nullptr, "MapPhysicalMemoryUnsafe"}, | 2829 | {0x48, nullptr, "MapPhysicalMemoryUnsafe"}, |
| 2830 | {0x49, nullptr, "UnmapPhysicalMemoryUnsafe"}, | 2830 | {0x49, nullptr, "UnmapPhysicalMemoryUnsafe"}, |
| 2831 | {0x4A, nullptr, "SetUnsafeLimit"}, | 2831 | {0x4A, nullptr, "SetUnsafeLimit"}, |
| @@ -2864,7 +2864,7 @@ static const FunctionDef SVC_Table_64[] = { | |||
| 2864 | {0x6B, nullptr, "WriteDebugProcessMemory"}, | 2864 | {0x6B, nullptr, "WriteDebugProcessMemory"}, |
| 2865 | {0x6C, nullptr, "SetHardwareBreakPoint"}, | 2865 | {0x6C, nullptr, "SetHardwareBreakPoint"}, |
| 2866 | {0x6D, nullptr, "GetDebugThreadParam"}, | 2866 | {0x6D, nullptr, "GetDebugThreadParam"}, |
| 2867 | {0x6E, nullptr, "Unknown"}, | 2867 | {0x6E, nullptr, "Unknown6E"}, |
| 2868 | {0x6F, nullptr, "GetSystemInfo"}, | 2868 | {0x6F, nullptr, "GetSystemInfo"}, |
| 2869 | {0x70, nullptr, "CreatePort"}, | 2869 | {0x70, nullptr, "CreatePort"}, |
| 2870 | {0x71, nullptr, "ManageNamedPort"}, | 2870 | {0x71, nullptr, "ManageNamedPort"}, |
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp index 6e63e057e..e34ef5a78 100644 --- a/src/core/hle/service/acc/acc.cpp +++ b/src/core/hle/service/acc/acc.cpp | |||
| @@ -39,9 +39,9 @@ constexpr ResultCode ERR_FAILED_SAVE_DATA{ErrorModule::Account, 100}; | |||
| 39 | // Thumbnails are hard coded to be at least this size | 39 | // Thumbnails are hard coded to be at least this size |
| 40 | constexpr std::size_t THUMBNAIL_SIZE = 0x24000; | 40 | constexpr std::size_t THUMBNAIL_SIZE = 0x24000; |
| 41 | 41 | ||
| 42 | static std::filesystem::path GetImagePath(Common::UUID uuid) { | 42 | static std::filesystem::path GetImagePath(const Common::UUID& uuid) { |
| 43 | return Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / | 43 | return Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / |
| 44 | fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormatSwitch()); | 44 | fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString()); |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | static constexpr u32 SanitizeJPEGSize(std::size_t size) { | 47 | static constexpr u32 SanitizeJPEGSize(std::size_t size) { |
| @@ -290,7 +290,7 @@ public: | |||
| 290 | 290 | ||
| 291 | protected: | 291 | protected: |
| 292 | void Get(Kernel::HLERequestContext& ctx) { | 292 | void Get(Kernel::HLERequestContext& ctx) { |
| 293 | LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.Format()); | 293 | LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.RawString()); |
| 294 | ProfileBase profile_base{}; | 294 | ProfileBase profile_base{}; |
| 295 | ProfileData data{}; | 295 | ProfileData data{}; |
| 296 | if (profile_manager.GetProfileBaseAndData(user_id, profile_base, data)) { | 296 | if (profile_manager.GetProfileBaseAndData(user_id, profile_base, data)) { |
| @@ -300,21 +300,21 @@ protected: | |||
| 300 | rb.PushRaw(profile_base); | 300 | rb.PushRaw(profile_base); |
| 301 | } else { | 301 | } else { |
| 302 | LOG_ERROR(Service_ACC, "Failed to get profile base and data for user=0x{}", | 302 | LOG_ERROR(Service_ACC, "Failed to get profile base and data for user=0x{}", |
| 303 | user_id.Format()); | 303 | user_id.RawString()); |
| 304 | IPC::ResponseBuilder rb{ctx, 2}; | 304 | IPC::ResponseBuilder rb{ctx, 2}; |
| 305 | rb.Push(ResultUnknown); // TODO(ogniK): Get actual error code | 305 | rb.Push(ResultUnknown); // TODO(ogniK): Get actual error code |
| 306 | } | 306 | } |
| 307 | } | 307 | } |
| 308 | 308 | ||
| 309 | void GetBase(Kernel::HLERequestContext& ctx) { | 309 | void GetBase(Kernel::HLERequestContext& ctx) { |
| 310 | LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.Format()); | 310 | LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.RawString()); |
| 311 | ProfileBase profile_base{}; | 311 | ProfileBase profile_base{}; |
| 312 | if (profile_manager.GetProfileBase(user_id, profile_base)) { | 312 | if (profile_manager.GetProfileBase(user_id, profile_base)) { |
| 313 | IPC::ResponseBuilder rb{ctx, 16}; | 313 | IPC::ResponseBuilder rb{ctx, 16}; |
| 314 | rb.Push(ResultSuccess); | 314 | rb.Push(ResultSuccess); |
| 315 | rb.PushRaw(profile_base); | 315 | rb.PushRaw(profile_base); |
| 316 | } else { | 316 | } else { |
| 317 | LOG_ERROR(Service_ACC, "Failed to get profile base for user=0x{}", user_id.Format()); | 317 | LOG_ERROR(Service_ACC, "Failed to get profile base for user=0x{}", user_id.RawString()); |
| 318 | IPC::ResponseBuilder rb{ctx, 2}; | 318 | IPC::ResponseBuilder rb{ctx, 2}; |
| 319 | rb.Push(ResultUnknown); // TODO(ogniK): Get actual error code | 319 | rb.Push(ResultUnknown); // TODO(ogniK): Get actual error code |
| 320 | } | 320 | } |
| @@ -373,7 +373,7 @@ protected: | |||
| 373 | LOG_DEBUG(Service_ACC, "called, username='{}', timestamp={:016X}, uuid=0x{}", | 373 | LOG_DEBUG(Service_ACC, "called, username='{}', timestamp={:016X}, uuid=0x{}", |
| 374 | Common::StringFromFixedZeroTerminatedBuffer( | 374 | Common::StringFromFixedZeroTerminatedBuffer( |
| 375 | reinterpret_cast<const char*>(base.username.data()), base.username.size()), | 375 | reinterpret_cast<const char*>(base.username.data()), base.username.size()), |
| 376 | base.timestamp, base.user_uuid.Format()); | 376 | base.timestamp, base.user_uuid.RawString()); |
| 377 | 377 | ||
| 378 | if (user_data.size() < sizeof(ProfileData)) { | 378 | if (user_data.size() < sizeof(ProfileData)) { |
| 379 | LOG_ERROR(Service_ACC, "ProfileData buffer too small!"); | 379 | LOG_ERROR(Service_ACC, "ProfileData buffer too small!"); |
| @@ -406,7 +406,7 @@ protected: | |||
| 406 | LOG_DEBUG(Service_ACC, "called, username='{}', timestamp={:016X}, uuid=0x{}", | 406 | LOG_DEBUG(Service_ACC, "called, username='{}', timestamp={:016X}, uuid=0x{}", |
| 407 | Common::StringFromFixedZeroTerminatedBuffer( | 407 | Common::StringFromFixedZeroTerminatedBuffer( |
| 408 | reinterpret_cast<const char*>(base.username.data()), base.username.size()), | 408 | reinterpret_cast<const char*>(base.username.data()), base.username.size()), |
| 409 | base.timestamp, base.user_uuid.Format()); | 409 | base.timestamp, base.user_uuid.RawString()); |
| 410 | 410 | ||
| 411 | if (user_data.size() < sizeof(ProfileData)) { | 411 | if (user_data.size() < sizeof(ProfileData)) { |
| 412 | LOG_ERROR(Service_ACC, "ProfileData buffer too small!"); | 412 | LOG_ERROR(Service_ACC, "ProfileData buffer too small!"); |
| @@ -435,7 +435,7 @@ protected: | |||
| 435 | } | 435 | } |
| 436 | 436 | ||
| 437 | ProfileManager& profile_manager; | 437 | ProfileManager& profile_manager; |
| 438 | Common::UUID user_id{Common::INVALID_UUID}; ///< The user id this profile refers to. | 438 | Common::UUID user_id{}; ///< The user id this profile refers to. |
| 439 | }; | 439 | }; |
| 440 | 440 | ||
| 441 | class IProfile final : public IProfileCommon { | 441 | class IProfile final : public IProfileCommon { |
| @@ -547,7 +547,7 @@ private: | |||
| 547 | 547 | ||
| 548 | IPC::ResponseBuilder rb{ctx, 4}; | 548 | IPC::ResponseBuilder rb{ctx, 4}; |
| 549 | rb.Push(ResultSuccess); | 549 | rb.Push(ResultSuccess); |
| 550 | rb.PushRaw<u64>(user_id.GetNintendoID()); | 550 | rb.PushRaw<u64>(user_id.Hash()); |
| 551 | } | 551 | } |
| 552 | 552 | ||
| 553 | void EnsureIdTokenCacheAsync(Kernel::HLERequestContext& ctx) { | 553 | void EnsureIdTokenCacheAsync(Kernel::HLERequestContext& ctx) { |
| @@ -577,7 +577,7 @@ private: | |||
| 577 | 577 | ||
| 578 | IPC::ResponseBuilder rb{ctx, 4}; | 578 | IPC::ResponseBuilder rb{ctx, 4}; |
| 579 | rb.Push(ResultSuccess); | 579 | rb.Push(ResultSuccess); |
| 580 | rb.PushRaw<u64>(user_id.GetNintendoID()); | 580 | rb.PushRaw<u64>(user_id.Hash()); |
| 581 | } | 581 | } |
| 582 | 582 | ||
| 583 | void StoreOpenContext(Kernel::HLERequestContext& ctx) { | 583 | void StoreOpenContext(Kernel::HLERequestContext& ctx) { |
| @@ -587,7 +587,7 @@ private: | |||
| 587 | } | 587 | } |
| 588 | 588 | ||
| 589 | std::shared_ptr<EnsureTokenIdCacheAsyncInterface> ensure_token_id{}; | 589 | std::shared_ptr<EnsureTokenIdCacheAsyncInterface> ensure_token_id{}; |
| 590 | Common::UUID user_id{Common::INVALID_UUID}; | 590 | Common::UUID user_id{}; |
| 591 | }; | 591 | }; |
| 592 | 592 | ||
| 593 | // 6.0.0+ | 593 | // 6.0.0+ |
| @@ -687,7 +687,7 @@ void Module::Interface::GetUserCount(Kernel::HLERequestContext& ctx) { | |||
| 687 | void Module::Interface::GetUserExistence(Kernel::HLERequestContext& ctx) { | 687 | void Module::Interface::GetUserExistence(Kernel::HLERequestContext& ctx) { |
| 688 | IPC::RequestParser rp{ctx}; | 688 | IPC::RequestParser rp{ctx}; |
| 689 | Common::UUID user_id = rp.PopRaw<Common::UUID>(); | 689 | Common::UUID user_id = rp.PopRaw<Common::UUID>(); |
| 690 | LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.Format()); | 690 | LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.RawString()); |
| 691 | 691 | ||
| 692 | IPC::ResponseBuilder rb{ctx, 3}; | 692 | IPC::ResponseBuilder rb{ctx, 3}; |
| 693 | rb.Push(ResultSuccess); | 693 | rb.Push(ResultSuccess); |
| @@ -718,7 +718,7 @@ void Module::Interface::GetLastOpenedUser(Kernel::HLERequestContext& ctx) { | |||
| 718 | void Module::Interface::GetProfile(Kernel::HLERequestContext& ctx) { | 718 | void Module::Interface::GetProfile(Kernel::HLERequestContext& ctx) { |
| 719 | IPC::RequestParser rp{ctx}; | 719 | IPC::RequestParser rp{ctx}; |
| 720 | Common::UUID user_id = rp.PopRaw<Common::UUID>(); | 720 | Common::UUID user_id = rp.PopRaw<Common::UUID>(); |
| 721 | LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.Format()); | 721 | LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.RawString()); |
| 722 | 722 | ||
| 723 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 723 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 724 | rb.Push(ResultSuccess); | 724 | rb.Push(ResultSuccess); |
| @@ -833,7 +833,7 @@ void Module::Interface::GetProfileEditor(Kernel::HLERequestContext& ctx) { | |||
| 833 | IPC::RequestParser rp{ctx}; | 833 | IPC::RequestParser rp{ctx}; |
| 834 | Common::UUID user_id = rp.PopRaw<Common::UUID>(); | 834 | Common::UUID user_id = rp.PopRaw<Common::UUID>(); |
| 835 | 835 | ||
| 836 | LOG_DEBUG(Service_ACC, "called, user_id=0x{}", user_id.Format()); | 836 | LOG_DEBUG(Service_ACC, "called, user_id=0x{}", user_id.RawString()); |
| 837 | 837 | ||
| 838 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 838 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 839 | rb.Push(ResultSuccess); | 839 | rb.Push(ResultSuccess); |
| @@ -875,7 +875,7 @@ void Module::Interface::StoreSaveDataThumbnailApplication(Kernel::HLERequestCont | |||
| 875 | IPC::RequestParser rp{ctx}; | 875 | IPC::RequestParser rp{ctx}; |
| 876 | const auto uuid = rp.PopRaw<Common::UUID>(); | 876 | const auto uuid = rp.PopRaw<Common::UUID>(); |
| 877 | 877 | ||
| 878 | LOG_WARNING(Service_ACC, "(STUBBED) called, uuid=0x{}", uuid.Format()); | 878 | LOG_WARNING(Service_ACC, "(STUBBED) called, uuid=0x{}", uuid.RawString()); |
| 879 | 879 | ||
| 880 | // TODO(ogniK): Check if application ID is zero on acc initialize. As we don't have a reliable | 880 | // TODO(ogniK): Check if application ID is zero on acc initialize. As we don't have a reliable |
| 881 | // way of confirming things like the TID, we're going to assume a non zero value for the time | 881 | // way of confirming things like the TID, we're going to assume a non zero value for the time |
| @@ -889,7 +889,7 @@ void Module::Interface::StoreSaveDataThumbnailSystem(Kernel::HLERequestContext& | |||
| 889 | const auto uuid = rp.PopRaw<Common::UUID>(); | 889 | const auto uuid = rp.PopRaw<Common::UUID>(); |
| 890 | const auto tid = rp.Pop<u64_le>(); | 890 | const auto tid = rp.Pop<u64_le>(); |
| 891 | 891 | ||
| 892 | LOG_WARNING(Service_ACC, "(STUBBED) called, uuid=0x{}, tid={:016X}", uuid.Format(), tid); | 892 | LOG_WARNING(Service_ACC, "(STUBBED) called, uuid=0x{}, tid={:016X}", uuid.RawString(), tid); |
| 893 | StoreSaveDataThumbnail(ctx, uuid, tid); | 893 | StoreSaveDataThumbnail(ctx, uuid, tid); |
| 894 | } | 894 | } |
| 895 | 895 | ||
| @@ -903,7 +903,7 @@ void Module::Interface::StoreSaveDataThumbnail(Kernel::HLERequestContext& ctx, | |||
| 903 | return; | 903 | return; |
| 904 | } | 904 | } |
| 905 | 905 | ||
| 906 | if (!uuid) { | 906 | if (uuid.IsInvalid()) { |
| 907 | LOG_ERROR(Service_ACC, "User ID is not valid!"); | 907 | LOG_ERROR(Service_ACC, "User ID is not valid!"); |
| 908 | rb.Push(ERR_INVALID_USER_ID); | 908 | rb.Push(ERR_INVALID_USER_ID); |
| 909 | return; | 909 | return; |
| @@ -927,20 +927,20 @@ void Module::Interface::TrySelectUserWithoutInteraction(Kernel::HLERequestContex | |||
| 927 | IPC::ResponseBuilder rb{ctx, 6}; | 927 | IPC::ResponseBuilder rb{ctx, 6}; |
| 928 | if (profile_manager->GetUserCount() != 1) { | 928 | if (profile_manager->GetUserCount() != 1) { |
| 929 | rb.Push(ResultSuccess); | 929 | rb.Push(ResultSuccess); |
| 930 | rb.PushRaw<u128>(Common::INVALID_UUID); | 930 | rb.PushRaw(Common::InvalidUUID); |
| 931 | return; | 931 | return; |
| 932 | } | 932 | } |
| 933 | 933 | ||
| 934 | const auto user_list = profile_manager->GetAllUsers(); | 934 | const auto user_list = profile_manager->GetAllUsers(); |
| 935 | if (std::ranges::all_of(user_list, [](const auto& user) { return user.IsInvalid(); })) { | 935 | if (std::ranges::all_of(user_list, [](const auto& user) { return user.IsInvalid(); })) { |
| 936 | rb.Push(ResultUnknown); // TODO(ogniK): Find the correct error code | 936 | rb.Push(ResultUnknown); // TODO(ogniK): Find the correct error code |
| 937 | rb.PushRaw<u128>(Common::INVALID_UUID); | 937 | rb.PushRaw(Common::InvalidUUID); |
| 938 | return; | 938 | return; |
| 939 | } | 939 | } |
| 940 | 940 | ||
| 941 | // Select the first user we have | 941 | // Select the first user we have |
| 942 | rb.Push(ResultSuccess); | 942 | rb.Push(ResultSuccess); |
| 943 | rb.PushRaw<u128>(profile_manager->GetUser(0)->uuid); | 943 | rb.PushRaw(profile_manager->GetUser(0)->uuid); |
| 944 | } | 944 | } |
| 945 | 945 | ||
| 946 | Module::Interface::Interface(std::shared_ptr<Module> module_, | 946 | Module::Interface::Interface(std::shared_ptr<Module> module_, |
diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp index 568303ced..fba847142 100644 --- a/src/core/hle/service/acc/profile_manager.cpp +++ b/src/core/hle/service/acc/profile_manager.cpp | |||
| @@ -19,8 +19,8 @@ namespace FS = Common::FS; | |||
| 19 | using Common::UUID; | 19 | using Common::UUID; |
| 20 | 20 | ||
| 21 | struct UserRaw { | 21 | struct UserRaw { |
| 22 | UUID uuid{Common::INVALID_UUID}; | 22 | UUID uuid{}; |
| 23 | UUID uuid2{Common::INVALID_UUID}; | 23 | UUID uuid2{}; |
| 24 | u64 timestamp{}; | 24 | u64 timestamp{}; |
| 25 | ProfileUsername username{}; | 25 | ProfileUsername username{}; |
| 26 | ProfileData extra_data{}; | 26 | ProfileData extra_data{}; |
| @@ -45,7 +45,7 @@ ProfileManager::ProfileManager() { | |||
| 45 | 45 | ||
| 46 | // Create an user if none are present | 46 | // Create an user if none are present |
| 47 | if (user_count == 0) { | 47 | if (user_count == 0) { |
| 48 | CreateNewUser(UUID::Generate(), "yuzu"); | 48 | CreateNewUser(UUID::MakeRandom(), "yuzu"); |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | auto current = | 51 | auto current = |
| @@ -101,7 +101,7 @@ ResultCode ProfileManager::CreateNewUser(UUID uuid, const ProfileUsername& usern | |||
| 101 | if (user_count == MAX_USERS) { | 101 | if (user_count == MAX_USERS) { |
| 102 | return ERROR_TOO_MANY_USERS; | 102 | return ERROR_TOO_MANY_USERS; |
| 103 | } | 103 | } |
| 104 | if (!uuid) { | 104 | if (uuid.IsInvalid()) { |
| 105 | return ERROR_ARGUMENT_IS_NULL; | 105 | return ERROR_ARGUMENT_IS_NULL; |
| 106 | } | 106 | } |
| 107 | if (username[0] == 0x0) { | 107 | if (username[0] == 0x0) { |
| @@ -145,7 +145,7 @@ std::optional<UUID> ProfileManager::GetUser(std::size_t index) const { | |||
| 145 | 145 | ||
| 146 | /// Returns a users profile index based on their user id. | 146 | /// Returns a users profile index based on their user id. |
| 147 | std::optional<std::size_t> ProfileManager::GetUserIndex(const UUID& uuid) const { | 147 | std::optional<std::size_t> ProfileManager::GetUserIndex(const UUID& uuid) const { |
| 148 | if (!uuid) { | 148 | if (uuid.IsInvalid()) { |
| 149 | return std::nullopt; | 149 | return std::nullopt; |
| 150 | } | 150 | } |
| 151 | 151 | ||
| @@ -250,9 +250,10 @@ UserIDArray ProfileManager::GetOpenUsers() const { | |||
| 250 | std::ranges::transform(profiles, output.begin(), [](const ProfileInfo& p) { | 250 | std::ranges::transform(profiles, output.begin(), [](const ProfileInfo& p) { |
| 251 | if (p.is_open) | 251 | if (p.is_open) |
| 252 | return p.user_uuid; | 252 | return p.user_uuid; |
| 253 | return UUID{Common::INVALID_UUID}; | 253 | return Common::InvalidUUID; |
| 254 | }); | 254 | }); |
| 255 | std::stable_partition(output.begin(), output.end(), [](const UUID& uuid) { return uuid; }); | 255 | std::stable_partition(output.begin(), output.end(), |
| 256 | [](const UUID& uuid) { return uuid.IsValid(); }); | ||
| 256 | return output; | 257 | return output; |
| 257 | } | 258 | } |
| 258 | 259 | ||
| @@ -299,7 +300,7 @@ bool ProfileManager::RemoveUser(UUID uuid) { | |||
| 299 | 300 | ||
| 300 | profiles[*index] = ProfileInfo{}; | 301 | profiles[*index] = ProfileInfo{}; |
| 301 | std::stable_partition(profiles.begin(), profiles.end(), | 302 | std::stable_partition(profiles.begin(), profiles.end(), |
| 302 | [](const ProfileInfo& profile) { return profile.user_uuid; }); | 303 | [](const ProfileInfo& profile) { return profile.user_uuid.IsValid(); }); |
| 303 | return true; | 304 | return true; |
| 304 | } | 305 | } |
| 305 | 306 | ||
| @@ -361,7 +362,7 @@ void ProfileManager::ParseUserSaveFile() { | |||
| 361 | } | 362 | } |
| 362 | 363 | ||
| 363 | std::stable_partition(profiles.begin(), profiles.end(), | 364 | std::stable_partition(profiles.begin(), profiles.end(), |
| 364 | [](const ProfileInfo& profile) { return profile.user_uuid; }); | 365 | [](const ProfileInfo& profile) { return profile.user_uuid.IsValid(); }); |
| 365 | } | 366 | } |
| 366 | 367 | ||
| 367 | void ProfileManager::WriteUserSaveFile() { | 368 | void ProfileManager::WriteUserSaveFile() { |
diff --git a/src/core/hle/service/acc/profile_manager.h b/src/core/hle/service/acc/profile_manager.h index 71b9d5518..17347f7ef 100644 --- a/src/core/hle/service/acc/profile_manager.h +++ b/src/core/hle/service/acc/profile_manager.h | |||
| @@ -35,7 +35,7 @@ static_assert(sizeof(ProfileData) == 0x80, "ProfileData structure has incorrect | |||
| 35 | /// This holds general information about a users profile. This is where we store all the information | 35 | /// This holds general information about a users profile. This is where we store all the information |
| 36 | /// based on a specific user | 36 | /// based on a specific user |
| 37 | struct ProfileInfo { | 37 | struct ProfileInfo { |
| 38 | Common::UUID user_uuid{Common::INVALID_UUID}; | 38 | Common::UUID user_uuid{}; |
| 39 | ProfileUsername username{}; | 39 | ProfileUsername username{}; |
| 40 | u64 creation_time{}; | 40 | u64 creation_time{}; |
| 41 | ProfileData data{}; // TODO(ognik): Work out what this is | 41 | ProfileData data{}; // TODO(ognik): Work out what this is |
| @@ -49,7 +49,7 @@ struct ProfileBase { | |||
| 49 | 49 | ||
| 50 | // Zero out all the fields to make the profile slot considered "Empty" | 50 | // Zero out all the fields to make the profile slot considered "Empty" |
| 51 | void Invalidate() { | 51 | void Invalidate() { |
| 52 | user_uuid.Invalidate(); | 52 | user_uuid = {}; |
| 53 | timestamp = 0; | 53 | timestamp = 0; |
| 54 | username.fill(0); | 54 | username.fill(0); |
| 55 | } | 55 | } |
| @@ -103,7 +103,7 @@ private: | |||
| 103 | 103 | ||
| 104 | std::array<ProfileInfo, MAX_USERS> profiles{}; | 104 | std::array<ProfileInfo, MAX_USERS> profiles{}; |
| 105 | std::size_t user_count{}; | 105 | std::size_t user_count{}; |
| 106 | Common::UUID last_opened_user{Common::INVALID_UUID}; | 106 | Common::UUID last_opened_user{}; |
| 107 | }; | 107 | }; |
| 108 | 108 | ||
| 109 | }; // namespace Service::Account | 109 | }; // namespace Service::Account |
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index e60661fe1..773dc9f29 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp | |||
| @@ -55,7 +55,7 @@ constexpr u32 LAUNCH_PARAMETER_ACCOUNT_PRESELECTED_USER_MAGIC = 0xC79497CA; | |||
| 55 | struct LaunchParameterAccountPreselectedUser { | 55 | struct LaunchParameterAccountPreselectedUser { |
| 56 | u32_le magic; | 56 | u32_le magic; |
| 57 | u32_le is_account_selected; | 57 | u32_le is_account_selected; |
| 58 | u128 current_user; | 58 | Common::UUID current_user; |
| 59 | INSERT_PADDING_BYTES(0x70); | 59 | INSERT_PADDING_BYTES(0x70); |
| 60 | }; | 60 | }; |
| 61 | static_assert(sizeof(LaunchParameterAccountPreselectedUser) == 0x88); | 61 | static_assert(sizeof(LaunchParameterAccountPreselectedUser) == 0x88); |
| @@ -1453,8 +1453,8 @@ void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) { | |||
| 1453 | 1453 | ||
| 1454 | Account::ProfileManager profile_manager{}; | 1454 | Account::ProfileManager profile_manager{}; |
| 1455 | const auto uuid = profile_manager.GetUser(static_cast<s32>(Settings::values.current_user)); | 1455 | const auto uuid = profile_manager.GetUser(static_cast<s32>(Settings::values.current_user)); |
| 1456 | ASSERT(uuid); | 1456 | ASSERT(uuid.has_value() && uuid->IsValid()); |
| 1457 | params.current_user = uuid->uuid; | 1457 | params.current_user = *uuid; |
| 1458 | 1458 | ||
| 1459 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 1459 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 1460 | 1460 | ||
diff --git a/src/core/hle/service/am/applets/applet_profile_select.cpp b/src/core/hle/service/am/applets/applet_profile_select.cpp index a6e891944..82500e121 100644 --- a/src/core/hle/service/am/applets/applet_profile_select.cpp +++ b/src/core/hle/service/am/applets/applet_profile_select.cpp | |||
| @@ -62,11 +62,11 @@ void ProfileSelect::SelectionComplete(std::optional<Common::UUID> uuid) { | |||
| 62 | 62 | ||
| 63 | if (uuid.has_value() && uuid->IsValid()) { | 63 | if (uuid.has_value() && uuid->IsValid()) { |
| 64 | output.result = 0; | 64 | output.result = 0; |
| 65 | output.uuid_selected = uuid->uuid; | 65 | output.uuid_selected = *uuid; |
| 66 | } else { | 66 | } else { |
| 67 | status = ERR_USER_CANCELLED_SELECTION; | 67 | status = ERR_USER_CANCELLED_SELECTION; |
| 68 | output.result = ERR_USER_CANCELLED_SELECTION.raw; | 68 | output.result = ERR_USER_CANCELLED_SELECTION.raw; |
| 69 | output.uuid_selected = Common::INVALID_UUID; | 69 | output.uuid_selected = Common::InvalidUUID; |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | final_data = std::vector<u8>(sizeof(UserSelectionOutput)); | 72 | final_data = std::vector<u8>(sizeof(UserSelectionOutput)); |
diff --git a/src/core/hle/service/am/applets/applet_profile_select.h b/src/core/hle/service/am/applets/applet_profile_select.h index 8fb76e6c4..852e1e0c0 100644 --- a/src/core/hle/service/am/applets/applet_profile_select.h +++ b/src/core/hle/service/am/applets/applet_profile_select.h | |||
| @@ -27,7 +27,7 @@ static_assert(sizeof(UserSelectionConfig) == 0xA0, "UserSelectionConfig has inco | |||
| 27 | 27 | ||
| 28 | struct UserSelectionOutput { | 28 | struct UserSelectionOutput { |
| 29 | u64 result; | 29 | u64 result; |
| 30 | u128 uuid_selected; | 30 | Common::UUID uuid_selected; |
| 31 | }; | 31 | }; |
| 32 | static_assert(sizeof(UserSelectionOutput) == 0x18, "UserSelectionOutput has incorrect size."); | 32 | static_assert(sizeof(UserSelectionOutput) == 0x18, "UserSelectionOutput has incorrect size."); |
| 33 | 33 | ||
diff --git a/src/core/hle/service/friend/friend.cpp b/src/core/hle/service/friend/friend.cpp index 9f9cea1e0..79cd3acbb 100644 --- a/src/core/hle/service/friend/friend.cpp +++ b/src/core/hle/service/friend/friend.cpp | |||
| @@ -173,7 +173,7 @@ private: | |||
| 173 | const auto uuid = rp.PopRaw<Common::UUID>(); | 173 | const auto uuid = rp.PopRaw<Common::UUID>(); |
| 174 | 174 | ||
| 175 | LOG_WARNING(Service_Friend, "(STUBBED) called, local_play={}, uuid=0x{}", local_play, | 175 | LOG_WARNING(Service_Friend, "(STUBBED) called, local_play={}, uuid=0x{}", local_play, |
| 176 | uuid.Format()); | 176 | uuid.RawString()); |
| 177 | 177 | ||
| 178 | IPC::ResponseBuilder rb{ctx, 2}; | 178 | IPC::ResponseBuilder rb{ctx, 2}; |
| 179 | rb.Push(ResultSuccess); | 179 | rb.Push(ResultSuccess); |
| @@ -186,7 +186,7 @@ private: | |||
| 186 | [[maybe_unused]] const auto filter = rp.PopRaw<SizedFriendFilter>(); | 186 | [[maybe_unused]] const auto filter = rp.PopRaw<SizedFriendFilter>(); |
| 187 | const auto pid = rp.Pop<u64>(); | 187 | const auto pid = rp.Pop<u64>(); |
| 188 | LOG_WARNING(Service_Friend, "(STUBBED) called, offset={}, uuid=0x{}, pid={}", friend_offset, | 188 | LOG_WARNING(Service_Friend, "(STUBBED) called, offset={}, uuid=0x{}, pid={}", friend_offset, |
| 189 | uuid.Format(), pid); | 189 | uuid.RawString(), pid); |
| 190 | 190 | ||
| 191 | IPC::ResponseBuilder rb{ctx, 3}; | 191 | IPC::ResponseBuilder rb{ctx, 3}; |
| 192 | rb.Push(ResultSuccess); | 192 | rb.Push(ResultSuccess); |
| @@ -312,7 +312,7 @@ void Module::Interface::CreateNotificationService(Kernel::HLERequestContext& ctx | |||
| 312 | IPC::RequestParser rp{ctx}; | 312 | IPC::RequestParser rp{ctx}; |
| 313 | auto uuid = rp.PopRaw<Common::UUID>(); | 313 | auto uuid = rp.PopRaw<Common::UUID>(); |
| 314 | 314 | ||
| 315 | LOG_DEBUG(Service_Friend, "called, uuid=0x{}", uuid.Format()); | 315 | LOG_DEBUG(Service_Friend, "called, uuid=0x{}", uuid.RawString()); |
| 316 | 316 | ||
| 317 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 317 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 318 | rb.Push(ResultSuccess); | 318 | rb.Push(ResultSuccess); |
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index a2bf7defb..d9202ea6c 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp | |||
| @@ -320,7 +320,7 @@ Hid::Hid(Core::System& system_) | |||
| 320 | {308, nullptr, "SetSevenSixAxisSensorFusionStrength"}, | 320 | {308, nullptr, "SetSevenSixAxisSensorFusionStrength"}, |
| 321 | {309, nullptr, "GetSevenSixAxisSensorFusionStrength"}, | 321 | {309, nullptr, "GetSevenSixAxisSensorFusionStrength"}, |
| 322 | {310, &Hid::ResetSevenSixAxisSensorTimestamp, "ResetSevenSixAxisSensorTimestamp"}, | 322 | {310, &Hid::ResetSevenSixAxisSensorTimestamp, "ResetSevenSixAxisSensorTimestamp"}, |
| 323 | {400, nullptr, "IsUsbFullKeyControllerEnabled"}, | 323 | {400, &Hid::IsUsbFullKeyControllerEnabled, "IsUsbFullKeyControllerEnabled"}, |
| 324 | {401, nullptr, "EnableUsbFullKeyController"}, | 324 | {401, nullptr, "EnableUsbFullKeyController"}, |
| 325 | {402, nullptr, "IsUsbFullKeyControllerConnected"}, | 325 | {402, nullptr, "IsUsbFullKeyControllerConnected"}, |
| 326 | {403, nullptr, "HasBattery"}, | 326 | {403, nullptr, "HasBattery"}, |
| @@ -1673,6 +1673,16 @@ void Hid::ResetSevenSixAxisSensorTimestamp(Kernel::HLERequestContext& ctx) { | |||
| 1673 | rb.Push(ResultSuccess); | 1673 | rb.Push(ResultSuccess); |
| 1674 | } | 1674 | } |
| 1675 | 1675 | ||
| 1676 | void Hid::IsUsbFullKeyControllerEnabled(Kernel::HLERequestContext& ctx) { | ||
| 1677 | IPC::RequestParser rp{ctx}; | ||
| 1678 | |||
| 1679 | LOG_WARNING(Service_HID, "(STUBBED) called"); | ||
| 1680 | |||
| 1681 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 1682 | rb.Push(ResultSuccess); | ||
| 1683 | rb.Push(false); | ||
| 1684 | } | ||
| 1685 | |||
| 1676 | void Hid::SetIsPalmaAllConnectable(Kernel::HLERequestContext& ctx) { | 1686 | void Hid::SetIsPalmaAllConnectable(Kernel::HLERequestContext& ctx) { |
| 1677 | IPC::RequestParser rp{ctx}; | 1687 | IPC::RequestParser rp{ctx}; |
| 1678 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 1688 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h index d290df161..c281081a7 100644 --- a/src/core/hle/service/hid/hid.h +++ b/src/core/hle/service/hid/hid.h | |||
| @@ -159,6 +159,7 @@ private: | |||
| 159 | void InitializeSevenSixAxisSensor(Kernel::HLERequestContext& ctx); | 159 | void InitializeSevenSixAxisSensor(Kernel::HLERequestContext& ctx); |
| 160 | void FinalizeSevenSixAxisSensor(Kernel::HLERequestContext& ctx); | 160 | void FinalizeSevenSixAxisSensor(Kernel::HLERequestContext& ctx); |
| 161 | void ResetSevenSixAxisSensorTimestamp(Kernel::HLERequestContext& ctx); | 161 | void ResetSevenSixAxisSensorTimestamp(Kernel::HLERequestContext& ctx); |
| 162 | void IsUsbFullKeyControllerEnabled(Kernel::HLERequestContext& ctx); | ||
| 162 | void SetIsPalmaAllConnectable(Kernel::HLERequestContext& ctx); | 163 | void SetIsPalmaAllConnectable(Kernel::HLERequestContext& ctx); |
| 163 | void SetPalmaBoostMode(Kernel::HLERequestContext& ctx); | 164 | void SetPalmaBoostMode(Kernel::HLERequestContext& ctx); |
| 164 | void SetNpadCommunicationMode(Kernel::HLERequestContext& ctx); | 165 | void SetNpadCommunicationMode(Kernel::HLERequestContext& ctx); |
diff --git a/src/core/hle/service/mii/mii_manager.cpp b/src/core/hle/service/mii/mii_manager.cpp index ca4ed35bb..0a57c3cde 100644 --- a/src/core/hle/service/mii/mii_manager.cpp +++ b/src/core/hle/service/mii/mii_manager.cpp | |||
| @@ -118,16 +118,6 @@ u16 GenerateCrc16(const void* data, std::size_t size) { | |||
| 118 | return Common::swap16(static_cast<u16>(crc)); | 118 | return Common::swap16(static_cast<u16>(crc)); |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | Common::UUID GenerateValidUUID() { | ||
| 122 | auto uuid{Common::UUID::Generate()}; | ||
| 123 | |||
| 124 | // Bit 7 must be set, and bit 6 unset for the UUID to be valid | ||
| 125 | uuid.uuid[1] &= 0xFFFFFFFFFFFFFF3FULL; | ||
| 126 | uuid.uuid[1] |= 0x0000000000000080ULL; | ||
| 127 | |||
| 128 | return uuid; | ||
| 129 | } | ||
| 130 | |||
| 131 | template <typename T> | 121 | template <typename T> |
| 132 | T GetRandomValue(T min, T max) { | 122 | T GetRandomValue(T min, T max) { |
| 133 | std::random_device device; | 123 | std::random_device device; |
| @@ -383,7 +373,7 @@ MiiStoreData::MiiStoreData() = default; | |||
| 383 | MiiStoreData::MiiStoreData(const MiiStoreData::Name& name, const MiiStoreBitFields& bit_fields, | 373 | MiiStoreData::MiiStoreData(const MiiStoreData::Name& name, const MiiStoreBitFields& bit_fields, |
| 384 | const Common::UUID& user_id) { | 374 | const Common::UUID& user_id) { |
| 385 | data.name = name; | 375 | data.name = name; |
| 386 | data.uuid = GenerateValidUUID(); | 376 | data.uuid = Common::UUID::MakeRandomRFC4122V4(); |
| 387 | 377 | ||
| 388 | std::memcpy(data.data.data(), &bit_fields, sizeof(MiiStoreBitFields)); | 378 | std::memcpy(data.data.data(), &bit_fields, sizeof(MiiStoreBitFields)); |
| 389 | data_crc = GenerateCrc16(data.data.data(), sizeof(data)); | 379 | data_crc = GenerateCrc16(data.data.data(), sizeof(data)); |
diff --git a/src/core/hle/service/mii/mii_manager.h b/src/core/hle/service/mii/mii_manager.h index 8e048fc56..6999d15b1 100644 --- a/src/core/hle/service/mii/mii_manager.h +++ b/src/core/hle/service/mii/mii_manager.h | |||
| @@ -202,7 +202,7 @@ struct MiiStoreData { | |||
| 202 | static_assert(sizeof(MiiStoreBitFields) == sizeof(data), "data field has incorrect size."); | 202 | static_assert(sizeof(MiiStoreBitFields) == sizeof(data), "data field has incorrect size."); |
| 203 | 203 | ||
| 204 | Name name{}; | 204 | Name name{}; |
| 205 | Common::UUID uuid{Common::INVALID_UUID}; | 205 | Common::UUID uuid{}; |
| 206 | } data; | 206 | } data; |
| 207 | 207 | ||
| 208 | u16 data_crc{}; | 208 | u16 data_crc{}; |
| @@ -326,7 +326,7 @@ public: | |||
| 326 | ResultCode GetIndex(const MiiInfo& info, u32& index); | 326 | ResultCode GetIndex(const MiiInfo& info, u32& index); |
| 327 | 327 | ||
| 328 | private: | 328 | private: |
| 329 | const Common::UUID user_id{Common::INVALID_UUID}; | 329 | const Common::UUID user_id{}; |
| 330 | u64 update_counter{}; | 330 | u64 update_counter{}; |
| 331 | }; | 331 | }; |
| 332 | 332 | ||
diff --git a/src/core/hle/service/ns/pdm_qry.cpp b/src/core/hle/service/ns/pdm_qry.cpp index e2fab5c3f..36ce46353 100644 --- a/src/core/hle/service/ns/pdm_qry.cpp +++ b/src/core/hle/service/ns/pdm_qry.cpp | |||
| @@ -59,7 +59,7 @@ void PDM_QRY::QueryPlayStatisticsByApplicationIdAndUserAccountId(Kernel::HLERequ | |||
| 59 | 59 | ||
| 60 | LOG_WARNING(Service_NS, | 60 | LOG_WARNING(Service_NS, |
| 61 | "(STUBBED) called. unknown={}. application_id=0x{:016X}, user_account_uid=0x{}", | 61 | "(STUBBED) called. unknown={}. application_id=0x{:016X}, user_account_uid=0x{}", |
| 62 | unknown, application_id, user_account_uid.Format()); | 62 | unknown, application_id, user_account_uid.RawString()); |
| 63 | 63 | ||
| 64 | IPC::ResponseBuilder rb{ctx, 12}; | 64 | IPC::ResponseBuilder rb{ctx, 12}; |
| 65 | rb.Push(ResultSuccess); | 65 | rb.Push(ResultSuccess); |
diff --git a/src/core/hle/service/time/clock_types.h b/src/core/hle/service/time/clock_types.h index 392e16863..d0cacb80c 100644 --- a/src/core/hle/service/time/clock_types.h +++ b/src/core/hle/service/time/clock_types.h | |||
| @@ -36,7 +36,7 @@ struct SteadyClockTimePoint { | |||
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | static SteadyClockTimePoint GetRandom() { | 38 | static SteadyClockTimePoint GetRandom() { |
| 39 | return {0, Common::UUID::Generate()}; | 39 | return {0, Common::UUID::MakeRandom()}; |
| 40 | } | 40 | } |
| 41 | }; | 41 | }; |
| 42 | static_assert(sizeof(SteadyClockTimePoint) == 0x18, "SteadyClockTimePoint is incorrect size"); | 42 | static_assert(sizeof(SteadyClockTimePoint) == 0x18, "SteadyClockTimePoint is incorrect size"); |
diff --git a/src/core/hle/service/time/steady_clock_core.h b/src/core/hle/service/time/steady_clock_core.h index d80a2385f..5ee2c0e0a 100644 --- a/src/core/hle/service/time/steady_clock_core.h +++ b/src/core/hle/service/time/steady_clock_core.h | |||
| @@ -49,7 +49,7 @@ public: | |||
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | private: | 51 | private: |
| 52 | Common::UUID clock_source_id{Common::UUID::Generate()}; | 52 | Common::UUID clock_source_id{Common::UUID::MakeRandom()}; |
| 53 | bool is_initialized{}; | 53 | bool is_initialized{}; |
| 54 | }; | 54 | }; |
| 55 | 55 | ||
diff --git a/src/core/hle/service/time/time_manager.cpp b/src/core/hle/service/time/time_manager.cpp index c1e4e6cce..00f1ae8cf 100644 --- a/src/core/hle/service/time/time_manager.cpp +++ b/src/core/hle/service/time/time_manager.cpp | |||
| @@ -45,7 +45,7 @@ struct TimeManager::Impl final { | |||
| 45 | time_zone_content_manager{system} { | 45 | time_zone_content_manager{system} { |
| 46 | 46 | ||
| 47 | const auto system_time{Clock::TimeSpanType::FromSeconds(GetExternalRtcValue())}; | 47 | const auto system_time{Clock::TimeSpanType::FromSeconds(GetExternalRtcValue())}; |
| 48 | SetupStandardSteadyClock(system, Common::UUID::Generate(), system_time, {}, {}); | 48 | SetupStandardSteadyClock(system, Common::UUID::MakeRandom(), system_time, {}, {}); |
| 49 | SetupStandardLocalSystemClock(system, {}, system_time.ToSeconds()); | 49 | SetupStandardLocalSystemClock(system, {}, system_time.ToSeconds()); |
| 50 | 50 | ||
| 51 | Clock::SystemClockContext clock_context{}; | 51 | Clock::SystemClockContext clock_context{}; |
diff --git a/src/input_common/drivers/gc_adapter.cpp b/src/input_common/drivers/gc_adapter.cpp index 7ab4540a8..155caae42 100644 --- a/src/input_common/drivers/gc_adapter.cpp +++ b/src/input_common/drivers/gc_adapter.cpp | |||
| @@ -248,7 +248,7 @@ bool GCAdapter::Setup() { | |||
| 248 | std::size_t port = 0; | 248 | std::size_t port = 0; |
| 249 | for (GCController& pad : pads) { | 249 | for (GCController& pad : pads) { |
| 250 | pad.identifier = { | 250 | pad.identifier = { |
| 251 | .guid = Common::UUID{Common::INVALID_UUID}, | 251 | .guid = Common::UUID{}, |
| 252 | .port = port++, | 252 | .port = port++, |
| 253 | .pad = 0, | 253 | .pad = 0, |
| 254 | }; | 254 | }; |
diff --git a/src/input_common/drivers/keyboard.cpp b/src/input_common/drivers/keyboard.cpp index 4c1e5bbec..59e3d9cc0 100644 --- a/src/input_common/drivers/keyboard.cpp +++ b/src/input_common/drivers/keyboard.cpp | |||
| @@ -9,17 +9,17 @@ | |||
| 9 | namespace InputCommon { | 9 | namespace InputCommon { |
| 10 | 10 | ||
| 11 | constexpr PadIdentifier key_identifier = { | 11 | constexpr PadIdentifier key_identifier = { |
| 12 | .guid = Common::UUID{Common::INVALID_UUID}, | 12 | .guid = Common::UUID{}, |
| 13 | .port = 0, | 13 | .port = 0, |
| 14 | .pad = 0, | 14 | .pad = 0, |
| 15 | }; | 15 | }; |
| 16 | constexpr PadIdentifier keyboard_key_identifier = { | 16 | constexpr PadIdentifier keyboard_key_identifier = { |
| 17 | .guid = Common::UUID{Common::INVALID_UUID}, | 17 | .guid = Common::UUID{}, |
| 18 | .port = 1, | 18 | .port = 1, |
| 19 | .pad = 0, | 19 | .pad = 0, |
| 20 | }; | 20 | }; |
| 21 | constexpr PadIdentifier keyboard_modifier_identifier = { | 21 | constexpr PadIdentifier keyboard_modifier_identifier = { |
| 22 | .guid = Common::UUID{Common::INVALID_UUID}, | 22 | .guid = Common::UUID{}, |
| 23 | .port = 1, | 23 | .port = 1, |
| 24 | .pad = 1, | 24 | .pad = 1, |
| 25 | }; | 25 | }; |
diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp index d8ae7f0c1..3c9a4e747 100644 --- a/src/input_common/drivers/mouse.cpp +++ b/src/input_common/drivers/mouse.cpp | |||
| @@ -20,7 +20,7 @@ constexpr int motion_wheel_y = 4; | |||
| 20 | constexpr int touch_axis_x = 10; | 20 | constexpr int touch_axis_x = 10; |
| 21 | constexpr int touch_axis_y = 11; | 21 | constexpr int touch_axis_y = 11; |
| 22 | constexpr PadIdentifier identifier = { | 22 | constexpr PadIdentifier identifier = { |
| 23 | .guid = Common::UUID{Common::INVALID_UUID}, | 23 | .guid = Common::UUID{}, |
| 24 | .port = 0, | 24 | .port = 0, |
| 25 | .pad = 0, | 25 | .pad = 0, |
| 26 | }; | 26 | }; |
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp index b031a8523..5cf1987ad 100644 --- a/src/input_common/drivers/sdl_driver.cpp +++ b/src/input_common/drivers/sdl_driver.cpp | |||
| @@ -502,7 +502,7 @@ std::vector<Common::ParamPackage> SDLDriver::GetInputDevices() const { | |||
| 502 | Common::Input::VibrationError SDLDriver::SetRumble( | 502 | Common::Input::VibrationError SDLDriver::SetRumble( |
| 503 | const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) { | 503 | const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) { |
| 504 | const auto joystick = | 504 | const auto joystick = |
| 505 | GetSDLJoystickByGUID(identifier.guid.Format(), static_cast<int>(identifier.port)); | 505 | GetSDLJoystickByGUID(identifier.guid.RawString(), static_cast<int>(identifier.port)); |
| 506 | const auto process_amplitude_exp = [](f32 amplitude, f32 factor) { | 506 | const auto process_amplitude_exp = [](f32 amplitude, f32 factor) { |
| 507 | return (amplitude + std::pow(amplitude, factor)) * 0.5f * 0xFFFF; | 507 | return (amplitude + std::pow(amplitude, factor)) * 0.5f * 0xFFFF; |
| 508 | }; | 508 | }; |
| @@ -599,7 +599,7 @@ Common::ParamPackage SDLDriver::BuildParamPackageForAnalog(PadIdentifier identif | |||
| 599 | Common::ParamPackage params; | 599 | Common::ParamPackage params; |
| 600 | params.Set("engine", GetEngineName()); | 600 | params.Set("engine", GetEngineName()); |
| 601 | params.Set("port", static_cast<int>(identifier.port)); | 601 | params.Set("port", static_cast<int>(identifier.port)); |
| 602 | params.Set("guid", identifier.guid.Format()); | 602 | params.Set("guid", identifier.guid.RawString()); |
| 603 | params.Set("axis_x", axis_x); | 603 | params.Set("axis_x", axis_x); |
| 604 | params.Set("axis_y", axis_y); | 604 | params.Set("axis_y", axis_y); |
| 605 | params.Set("offset_x", offset_x); | 605 | params.Set("offset_x", offset_x); |
| @@ -811,7 +811,7 @@ AnalogMapping SDLDriver::GetAnalogMappingForDevice(const Common::ParamPackage& p | |||
| 811 | PreSetAxis(identifier, binding_left_x.value.axis); | 811 | PreSetAxis(identifier, binding_left_x.value.axis); |
| 812 | PreSetAxis(identifier, binding_left_y.value.axis); | 812 | PreSetAxis(identifier, binding_left_y.value.axis); |
| 813 | const auto left_offset_x = -GetAxis(identifier, binding_left_x.value.axis); | 813 | const auto left_offset_x = -GetAxis(identifier, binding_left_x.value.axis); |
| 814 | const auto left_offset_y = -GetAxis(identifier, binding_left_y.value.axis); | 814 | const auto left_offset_y = GetAxis(identifier, binding_left_y.value.axis); |
| 815 | mapping.insert_or_assign(Settings::NativeAnalog::LStick, | 815 | mapping.insert_or_assign(Settings::NativeAnalog::LStick, |
| 816 | BuildParamPackageForAnalog(identifier, binding_left_x.value.axis, | 816 | BuildParamPackageForAnalog(identifier, binding_left_x.value.axis, |
| 817 | binding_left_y.value.axis, | 817 | binding_left_y.value.axis, |
| @@ -822,7 +822,7 @@ AnalogMapping SDLDriver::GetAnalogMappingForDevice(const Common::ParamPackage& p | |||
| 822 | PreSetAxis(identifier, binding_left_x.value.axis); | 822 | PreSetAxis(identifier, binding_left_x.value.axis); |
| 823 | PreSetAxis(identifier, binding_left_y.value.axis); | 823 | PreSetAxis(identifier, binding_left_y.value.axis); |
| 824 | const auto left_offset_x = -GetAxis(identifier, binding_left_x.value.axis); | 824 | const auto left_offset_x = -GetAxis(identifier, binding_left_x.value.axis); |
| 825 | const auto left_offset_y = -GetAxis(identifier, binding_left_y.value.axis); | 825 | const auto left_offset_y = GetAxis(identifier, binding_left_y.value.axis); |
| 826 | mapping.insert_or_assign(Settings::NativeAnalog::LStick, | 826 | mapping.insert_or_assign(Settings::NativeAnalog::LStick, |
| 827 | BuildParamPackageForAnalog(identifier, binding_left_x.value.axis, | 827 | BuildParamPackageForAnalog(identifier, binding_left_x.value.axis, |
| 828 | binding_left_y.value.axis, | 828 | binding_left_y.value.axis, |
| @@ -837,7 +837,7 @@ AnalogMapping SDLDriver::GetAnalogMappingForDevice(const Common::ParamPackage& p | |||
| 837 | PreSetAxis(identifier, binding_right_x.value.axis); | 837 | PreSetAxis(identifier, binding_right_x.value.axis); |
| 838 | PreSetAxis(identifier, binding_right_y.value.axis); | 838 | PreSetAxis(identifier, binding_right_y.value.axis); |
| 839 | const auto right_offset_x = -GetAxis(identifier, binding_right_x.value.axis); | 839 | const auto right_offset_x = -GetAxis(identifier, binding_right_x.value.axis); |
| 840 | const auto right_offset_y = -GetAxis(identifier, binding_right_y.value.axis); | 840 | const auto right_offset_y = GetAxis(identifier, binding_right_y.value.axis); |
| 841 | mapping.insert_or_assign(Settings::NativeAnalog::RStick, | 841 | mapping.insert_or_assign(Settings::NativeAnalog::RStick, |
| 842 | BuildParamPackageForAnalog(identifier, binding_right_x.value.axis, | 842 | BuildParamPackageForAnalog(identifier, binding_right_x.value.axis, |
| 843 | binding_right_y.value.axis, right_offset_x, | 843 | binding_right_y.value.axis, right_offset_x, |
diff --git a/src/input_common/drivers/touch_screen.cpp b/src/input_common/drivers/touch_screen.cpp index 880781825..30c727df4 100644 --- a/src/input_common/drivers/touch_screen.cpp +++ b/src/input_common/drivers/touch_screen.cpp | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | namespace InputCommon { | 8 | namespace InputCommon { |
| 9 | 9 | ||
| 10 | constexpr PadIdentifier identifier = { | 10 | constexpr PadIdentifier identifier = { |
| 11 | .guid = Common::UUID{Common::INVALID_UUID}, | 11 | .guid = Common::UUID{}, |
| 12 | .port = 0, | 12 | .port = 0, |
| 13 | .pad = 0, | 13 | .pad = 0, |
| 14 | }; | 14 | }; |
diff --git a/src/input_common/drivers/udp_client.cpp b/src/input_common/drivers/udp_client.cpp index 333173e3d..64162f431 100644 --- a/src/input_common/drivers/udp_client.cpp +++ b/src/input_common/drivers/udp_client.cpp | |||
| @@ -353,7 +353,7 @@ PadIdentifier UDPClient::GetPadIdentifier(std::size_t pad_index) const { | |||
| 353 | 353 | ||
| 354 | Common::UUID UDPClient::GetHostUUID(const std::string& host) const { | 354 | Common::UUID UDPClient::GetHostUUID(const std::string& host) const { |
| 355 | const auto ip = boost::asio::ip::make_address_v4(host); | 355 | const auto ip = boost::asio::ip::make_address_v4(host); |
| 356 | const auto hex_host = fmt::format("{:06x}", ip.to_uint()); | 356 | const auto hex_host = fmt::format("00000000-0000-0000-0000-0000{:06x}", ip.to_uint()); |
| 357 | return Common::UUID{hex_host}; | 357 | return Common::UUID{hex_host}; |
| 358 | } | 358 | } |
| 359 | 359 | ||
| @@ -385,7 +385,7 @@ std::vector<Common::ParamPackage> UDPClient::GetInputDevices() const { | |||
| 385 | Common::ParamPackage identifier{}; | 385 | Common::ParamPackage identifier{}; |
| 386 | identifier.Set("engine", GetEngineName()); | 386 | identifier.Set("engine", GetEngineName()); |
| 387 | identifier.Set("display", fmt::format("UDP Controller {}", pad_identifier.pad)); | 387 | identifier.Set("display", fmt::format("UDP Controller {}", pad_identifier.pad)); |
| 388 | identifier.Set("guid", pad_identifier.guid.Format()); | 388 | identifier.Set("guid", pad_identifier.guid.RawString()); |
| 389 | identifier.Set("port", static_cast<int>(pad_identifier.port)); | 389 | identifier.Set("port", static_cast<int>(pad_identifier.port)); |
| 390 | identifier.Set("pad", static_cast<int>(pad_identifier.pad)); | 390 | identifier.Set("pad", static_cast<int>(pad_identifier.pad)); |
| 391 | devices.emplace_back(identifier); | 391 | devices.emplace_back(identifier); |
diff --git a/src/input_common/drivers/udp_client.h b/src/input_common/drivers/udp_client.h index e9c178139..76e32bd04 100644 --- a/src/input_common/drivers/udp_client.h +++ b/src/input_common/drivers/udp_client.h | |||
| @@ -126,7 +126,7 @@ private: | |||
| 126 | struct ClientConnection { | 126 | struct ClientConnection { |
| 127 | ClientConnection(); | 127 | ClientConnection(); |
| 128 | ~ClientConnection(); | 128 | ~ClientConnection(); |
| 129 | Common::UUID uuid{"7F000001"}; | 129 | Common::UUID uuid{"00000000-0000-0000-0000-00007F000001"}; |
| 130 | std::string host{"127.0.0.1"}; | 130 | std::string host{"127.0.0.1"}; |
| 131 | u16 port{26760}; | 131 | u16 port{26760}; |
| 132 | s8 active{-1}; | 132 | s8 active{-1}; |
diff --git a/src/input_common/input_engine.cpp b/src/input_common/input_engine.cpp index 0508b408d..65ae1b848 100644 --- a/src/input_common/input_engine.cpp +++ b/src/input_common/input_engine.cpp | |||
| @@ -96,7 +96,7 @@ bool InputEngine::GetButton(const PadIdentifier& identifier, int button) const { | |||
| 96 | std::lock_guard lock{mutex}; | 96 | std::lock_guard lock{mutex}; |
| 97 | const auto controller_iter = controller_list.find(identifier); | 97 | const auto controller_iter = controller_list.find(identifier); |
| 98 | if (controller_iter == controller_list.cend()) { | 98 | if (controller_iter == controller_list.cend()) { |
| 99 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(), | 99 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.RawString(), |
| 100 | identifier.pad, identifier.port); | 100 | identifier.pad, identifier.port); |
| 101 | return false; | 101 | return false; |
| 102 | } | 102 | } |
| @@ -113,7 +113,7 @@ bool InputEngine::GetHatButton(const PadIdentifier& identifier, int button, u8 d | |||
| 113 | std::lock_guard lock{mutex}; | 113 | std::lock_guard lock{mutex}; |
| 114 | const auto controller_iter = controller_list.find(identifier); | 114 | const auto controller_iter = controller_list.find(identifier); |
| 115 | if (controller_iter == controller_list.cend()) { | 115 | if (controller_iter == controller_list.cend()) { |
| 116 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(), | 116 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.RawString(), |
| 117 | identifier.pad, identifier.port); | 117 | identifier.pad, identifier.port); |
| 118 | return false; | 118 | return false; |
| 119 | } | 119 | } |
| @@ -130,7 +130,7 @@ f32 InputEngine::GetAxis(const PadIdentifier& identifier, int axis) const { | |||
| 130 | std::lock_guard lock{mutex}; | 130 | std::lock_guard lock{mutex}; |
| 131 | const auto controller_iter = controller_list.find(identifier); | 131 | const auto controller_iter = controller_list.find(identifier); |
| 132 | if (controller_iter == controller_list.cend()) { | 132 | if (controller_iter == controller_list.cend()) { |
| 133 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(), | 133 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.RawString(), |
| 134 | identifier.pad, identifier.port); | 134 | identifier.pad, identifier.port); |
| 135 | return 0.0f; | 135 | return 0.0f; |
| 136 | } | 136 | } |
| @@ -147,7 +147,7 @@ BatteryLevel InputEngine::GetBattery(const PadIdentifier& identifier) const { | |||
| 147 | std::lock_guard lock{mutex}; | 147 | std::lock_guard lock{mutex}; |
| 148 | const auto controller_iter = controller_list.find(identifier); | 148 | const auto controller_iter = controller_list.find(identifier); |
| 149 | if (controller_iter == controller_list.cend()) { | 149 | if (controller_iter == controller_list.cend()) { |
| 150 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(), | 150 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.RawString(), |
| 151 | identifier.pad, identifier.port); | 151 | identifier.pad, identifier.port); |
| 152 | return BatteryLevel::Charging; | 152 | return BatteryLevel::Charging; |
| 153 | } | 153 | } |
| @@ -159,7 +159,7 @@ BasicMotion InputEngine::GetMotion(const PadIdentifier& identifier, int motion) | |||
| 159 | std::lock_guard lock{mutex}; | 159 | std::lock_guard lock{mutex}; |
| 160 | const auto controller_iter = controller_list.find(identifier); | 160 | const auto controller_iter = controller_list.find(identifier); |
| 161 | if (controller_iter == controller_list.cend()) { | 161 | if (controller_iter == controller_list.cend()) { |
| 162 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(), | 162 | LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.RawString(), |
| 163 | identifier.pad, identifier.port); | 163 | identifier.pad, identifier.port); |
| 164 | return {}; | 164 | return {}; |
| 165 | } | 165 | } |
diff --git a/src/input_common/input_engine.h b/src/input_common/input_engine.h index fe2faee5a..c6c027aef 100644 --- a/src/input_common/input_engine.h +++ b/src/input_common/input_engine.h | |||
| @@ -16,7 +16,7 @@ | |||
| 16 | 16 | ||
| 17 | // Pad Identifier of data source | 17 | // Pad Identifier of data source |
| 18 | struct PadIdentifier { | 18 | struct PadIdentifier { |
| 19 | Common::UUID guid{Common::INVALID_UUID}; | 19 | Common::UUID guid{}; |
| 20 | std::size_t port{}; | 20 | std::size_t port{}; |
| 21 | std::size_t pad{}; | 21 | std::size_t pad{}; |
| 22 | 22 | ||
| @@ -59,7 +59,7 @@ namespace std { | |||
| 59 | template <> | 59 | template <> |
| 60 | struct hash<PadIdentifier> { | 60 | struct hash<PadIdentifier> { |
| 61 | size_t operator()(const PadIdentifier& pad_id) const noexcept { | 61 | size_t operator()(const PadIdentifier& pad_id) const noexcept { |
| 62 | u64 hash_value = pad_id.guid.uuid[1] ^ pad_id.guid.uuid[0]; | 62 | u64 hash_value = pad_id.guid.Hash(); |
| 63 | hash_value ^= (static_cast<u64>(pad_id.port) << 32); | 63 | hash_value ^= (static_cast<u64>(pad_id.port) << 32); |
| 64 | hash_value ^= static_cast<u64>(pad_id.pad); | 64 | hash_value ^= static_cast<u64>(pad_id.pad); |
| 65 | return static_cast<size_t>(hash_value); | 65 | return static_cast<size_t>(hash_value); |
diff --git a/src/input_common/input_mapping.cpp b/src/input_common/input_mapping.cpp index a7a6ad8c2..fb78093b8 100644 --- a/src/input_common/input_mapping.cpp +++ b/src/input_common/input_mapping.cpp | |||
| @@ -57,7 +57,7 @@ void MappingFactory::RegisterButton(const MappingData& data) { | |||
| 57 | Common::ParamPackage new_input; | 57 | Common::ParamPackage new_input; |
| 58 | new_input.Set("engine", data.engine); | 58 | new_input.Set("engine", data.engine); |
| 59 | if (data.pad.guid.IsValid()) { | 59 | if (data.pad.guid.IsValid()) { |
| 60 | new_input.Set("guid", data.pad.guid.Format()); | 60 | new_input.Set("guid", data.pad.guid.RawString()); |
| 61 | } | 61 | } |
| 62 | new_input.Set("port", static_cast<int>(data.pad.port)); | 62 | new_input.Set("port", static_cast<int>(data.pad.port)); |
| 63 | new_input.Set("pad", static_cast<int>(data.pad.pad)); | 63 | new_input.Set("pad", static_cast<int>(data.pad.pad)); |
| @@ -93,7 +93,7 @@ void MappingFactory::RegisterStick(const MappingData& data) { | |||
| 93 | Common::ParamPackage new_input; | 93 | Common::ParamPackage new_input; |
| 94 | new_input.Set("engine", data.engine); | 94 | new_input.Set("engine", data.engine); |
| 95 | if (data.pad.guid.IsValid()) { | 95 | if (data.pad.guid.IsValid()) { |
| 96 | new_input.Set("guid", data.pad.guid.Format()); | 96 | new_input.Set("guid", data.pad.guid.RawString()); |
| 97 | } | 97 | } |
| 98 | new_input.Set("port", static_cast<int>(data.pad.port)); | 98 | new_input.Set("port", static_cast<int>(data.pad.port)); |
| 99 | new_input.Set("pad", static_cast<int>(data.pad.pad)); | 99 | new_input.Set("pad", static_cast<int>(data.pad.pad)); |
| @@ -138,7 +138,7 @@ void MappingFactory::RegisterMotion(const MappingData& data) { | |||
| 138 | Common::ParamPackage new_input; | 138 | Common::ParamPackage new_input; |
| 139 | new_input.Set("engine", data.engine); | 139 | new_input.Set("engine", data.engine); |
| 140 | if (data.pad.guid.IsValid()) { | 140 | if (data.pad.guid.IsValid()) { |
| 141 | new_input.Set("guid", data.pad.guid.Format()); | 141 | new_input.Set("guid", data.pad.guid.RawString()); |
| 142 | } | 142 | } |
| 143 | new_input.Set("port", static_cast<int>(data.pad.port)); | 143 | new_input.Set("port", static_cast<int>(data.pad.port)); |
| 144 | new_input.Set("pad", static_cast<int>(data.pad.pad)); | 144 | new_input.Set("pad", static_cast<int>(data.pad.pad)); |
diff --git a/src/input_common/input_poller.cpp b/src/input_common/input_poller.cpp index 2f3c0735a..7f3c08597 100644 --- a/src/input_common/input_poller.cpp +++ b/src/input_common/input_poller.cpp | |||
| @@ -181,7 +181,7 @@ public: | |||
| 181 | .raw_value = input_engine->GetAxis(identifier, axis_y), | 181 | .raw_value = input_engine->GetAxis(identifier, axis_y), |
| 182 | .properties = properties_y, | 182 | .properties = properties_y, |
| 183 | }; | 183 | }; |
| 184 | // This is a workaround too keep compatibility with old yuzu versions. Vertical axis is | 184 | // This is a workaround to keep compatibility with old yuzu versions. Vertical axis is |
| 185 | // inverted on SDL compared to Nintendo | 185 | // inverted on SDL compared to Nintendo |
| 186 | if (invert_axis_y) { | 186 | if (invert_axis_y) { |
| 187 | status.y.raw_value = -status.y.raw_value; | 187 | status.y.raw_value = -status.y.raw_value; |
diff --git a/src/yuzu/applets/qt_profile_select.cpp b/src/yuzu/applets/qt_profile_select.cpp index 5b32da923..4cd8f7784 100644 --- a/src/yuzu/applets/qt_profile_select.cpp +++ b/src/yuzu/applets/qt_profile_select.cpp | |||
| @@ -23,13 +23,13 @@ QString FormatUserEntryText(const QString& username, Common::UUID uuid) { | |||
| 23 | return QtProfileSelectionDialog::tr( | 23 | return QtProfileSelectionDialog::tr( |
| 24 | "%1\n%2", "%1 is the profile username, %2 is the formatted UUID (e.g. " | 24 | "%1\n%2", "%1 is the profile username, %2 is the formatted UUID (e.g. " |
| 25 | "00112233-4455-6677-8899-AABBCCDDEEFF))") | 25 | "00112233-4455-6677-8899-AABBCCDDEEFF))") |
| 26 | .arg(username, QString::fromStdString(uuid.FormatSwitch())); | 26 | .arg(username, QString::fromStdString(uuid.FormattedString())); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | QString GetImagePath(Common::UUID uuid) { | 29 | QString GetImagePath(Common::UUID uuid) { |
| 30 | const auto path = | 30 | const auto path = |
| 31 | Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / | 31 | Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / |
| 32 | fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormatSwitch()); | 32 | fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString()); |
| 33 | return QString::fromStdString(Common::FS::PathToUTF8String(path)); | 33 | return QString::fromStdString(Common::FS::PathToUTF8String(path)); |
| 34 | } | 34 | } |
| 35 | 35 | ||
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 2c8c10c50..9ee7992e7 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -65,12 +65,14 @@ const std::array<int, 2> Config::default_stick_mod = { | |||
| 65 | // This must be in alphabetical order according to action name as it must have the same order as | 65 | // This must be in alphabetical order according to action name as it must have the same order as |
| 66 | // UISetting::values.shortcuts, which is alphabetically ordered. | 66 | // UISetting::values.shortcuts, which is alphabetically ordered. |
| 67 | // clang-format off | 67 | // clang-format off |
| 68 | const std::array<UISettings::Shortcut, 20> Config::default_hotkeys{{ | 68 | const std::array<UISettings::Shortcut, 22> Config::default_hotkeys{{ |
| 69 | {QStringLiteral("Audio Mute/Unmute"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+M"), QStringLiteral("Home+Dpad_Right"), Qt::WindowShortcut}}, | 69 | {QStringLiteral("Audio Mute/Unmute"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+M"), QStringLiteral("Home+Dpad_Right"), Qt::WindowShortcut}}, |
| 70 | {QStringLiteral("Audio Volume Down"), QStringLiteral("Main Window"), {QStringLiteral("-"), QStringLiteral("Home+Dpad_Down"), Qt::ApplicationShortcut}}, | 70 | {QStringLiteral("Audio Volume Down"), QStringLiteral("Main Window"), {QStringLiteral("-"), QStringLiteral("Home+Dpad_Down"), Qt::ApplicationShortcut}}, |
| 71 | {QStringLiteral("Audio Volume Up"), QStringLiteral("Main Window"), {QStringLiteral("+"), QStringLiteral("Home+Dpad_Up"), Qt::ApplicationShortcut}}, | 71 | {QStringLiteral("Audio Volume Up"), QStringLiteral("Main Window"), {QStringLiteral("+"), QStringLiteral("Home+Dpad_Up"), Qt::ApplicationShortcut}}, |
| 72 | {QStringLiteral("Capture Screenshot"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+P"), QStringLiteral("Screenshot"), Qt::WidgetWithChildrenShortcut}}, | 72 | {QStringLiteral("Capture Screenshot"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+P"), QStringLiteral("Screenshot"), Qt::WidgetWithChildrenShortcut}}, |
| 73 | {QStringLiteral("Change Adapting Filter"), QStringLiteral("Main Window"), {QStringLiteral("F8"), QStringLiteral("Home+L"), Qt::ApplicationShortcut}}, | ||
| 73 | {QStringLiteral("Change Docked Mode"), QStringLiteral("Main Window"), {QStringLiteral("F10"), QStringLiteral("Home+X"), Qt::ApplicationShortcut}}, | 74 | {QStringLiteral("Change Docked Mode"), QStringLiteral("Main Window"), {QStringLiteral("F10"), QStringLiteral("Home+X"), Qt::ApplicationShortcut}}, |
| 75 | {QStringLiteral("Change GPU Accuracy"), QStringLiteral("Main Window"), {QStringLiteral("F9"), QStringLiteral("Home+R"), Qt::ApplicationShortcut}}, | ||
| 74 | {QStringLiteral("Continue/Pause Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F4"), QStringLiteral("Home+Plus"), Qt::WindowShortcut}}, | 76 | {QStringLiteral("Continue/Pause Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F4"), QStringLiteral("Home+Plus"), Qt::WindowShortcut}}, |
| 75 | {QStringLiteral("Exit Fullscreen"), QStringLiteral("Main Window"), {QStringLiteral("Esc"), QStringLiteral(""), Qt::WindowShortcut}}, | 77 | {QStringLiteral("Exit Fullscreen"), QStringLiteral("Main Window"), {QStringLiteral("Esc"), QStringLiteral(""), Qt::WindowShortcut}}, |
| 76 | {QStringLiteral("Exit yuzu"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+Q"), QStringLiteral("Home+Minus"), Qt::WindowShortcut}}, | 78 | {QStringLiteral("Exit yuzu"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+Q"), QStringLiteral("Home+Minus"), Qt::WindowShortcut}}, |
| @@ -767,6 +769,7 @@ void Config::ReadUIValues() { | |||
| 767 | ReadBasicSetting(UISettings::values.callout_flags); | 769 | ReadBasicSetting(UISettings::values.callout_flags); |
| 768 | ReadBasicSetting(UISettings::values.show_console); | 770 | ReadBasicSetting(UISettings::values.show_console); |
| 769 | ReadBasicSetting(UISettings::values.pause_when_in_background); | 771 | ReadBasicSetting(UISettings::values.pause_when_in_background); |
| 772 | ReadBasicSetting(UISettings::values.mute_when_in_background); | ||
| 770 | ReadBasicSetting(UISettings::values.hide_mouse); | 773 | ReadBasicSetting(UISettings::values.hide_mouse); |
| 771 | 774 | ||
| 772 | qt_config->endGroup(); | 775 | qt_config->endGroup(); |
| @@ -1295,6 +1298,7 @@ void Config::SaveUIValues() { | |||
| 1295 | WriteBasicSetting(UISettings::values.callout_flags); | 1298 | WriteBasicSetting(UISettings::values.callout_flags); |
| 1296 | WriteBasicSetting(UISettings::values.show_console); | 1299 | WriteBasicSetting(UISettings::values.show_console); |
| 1297 | WriteBasicSetting(UISettings::values.pause_when_in_background); | 1300 | WriteBasicSetting(UISettings::values.pause_when_in_background); |
| 1301 | WriteBasicSetting(UISettings::values.mute_when_in_background); | ||
| 1298 | WriteBasicSetting(UISettings::values.hide_mouse); | 1302 | WriteBasicSetting(UISettings::values.hide_mouse); |
| 1299 | 1303 | ||
| 1300 | qt_config->endGroup(); | 1304 | qt_config->endGroup(); |
diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h index 60b20a62f..ae3e36a11 100644 --- a/src/yuzu/configuration/config.h +++ b/src/yuzu/configuration/config.h | |||
| @@ -46,7 +46,7 @@ public: | |||
| 46 | default_mouse_buttons; | 46 | default_mouse_buttons; |
| 47 | static const std::array<int, Settings::NativeKeyboard::NumKeyboardKeys> default_keyboard_keys; | 47 | static const std::array<int, Settings::NativeKeyboard::NumKeyboardKeys> default_keyboard_keys; |
| 48 | static const std::array<int, Settings::NativeKeyboard::NumKeyboardMods> default_keyboard_mods; | 48 | static const std::array<int, Settings::NativeKeyboard::NumKeyboardMods> default_keyboard_mods; |
| 49 | static const std::array<UISettings::Shortcut, 20> default_hotkeys; | 49 | static const std::array<UISettings::Shortcut, 22> default_hotkeys; |
| 50 | 50 | ||
| 51 | static constexpr UISettings::Theme default_theme{ | 51 | static constexpr UISettings::Theme default_theme{ |
| 52 | #ifdef _WIN32 | 52 | #ifdef _WIN32 |
diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index 566879317..978a29fe6 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp | |||
| @@ -46,6 +46,7 @@ void ConfigureGeneral::SetConfiguration() { | |||
| 46 | ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing.GetValue()); | 46 | ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing.GetValue()); |
| 47 | ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot.GetValue()); | 47 | ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot.GetValue()); |
| 48 | ui->toggle_background_pause->setChecked(UISettings::values.pause_when_in_background.GetValue()); | 48 | ui->toggle_background_pause->setChecked(UISettings::values.pause_when_in_background.GetValue()); |
| 49 | ui->toggle_background_mute->setChecked(UISettings::values.mute_when_in_background.GetValue()); | ||
| 49 | ui->toggle_hide_mouse->setChecked(UISettings::values.hide_mouse.GetValue()); | 50 | ui->toggle_hide_mouse->setChecked(UISettings::values.hide_mouse.GetValue()); |
| 50 | 51 | ||
| 51 | ui->toggle_speed_limit->setChecked(Settings::values.use_speed_limit.GetValue()); | 52 | ui->toggle_speed_limit->setChecked(Settings::values.use_speed_limit.GetValue()); |
| @@ -95,6 +96,7 @@ void ConfigureGeneral::ApplyConfiguration() { | |||
| 95 | UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); | 96 | UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); |
| 96 | UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked(); | 97 | UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked(); |
| 97 | UISettings::values.pause_when_in_background = ui->toggle_background_pause->isChecked(); | 98 | UISettings::values.pause_when_in_background = ui->toggle_background_pause->isChecked(); |
| 99 | UISettings::values.mute_when_in_background = ui->toggle_background_mute->isChecked(); | ||
| 98 | UISettings::values.hide_mouse = ui->toggle_hide_mouse->isChecked(); | 100 | UISettings::values.hide_mouse = ui->toggle_hide_mouse->isChecked(); |
| 99 | 101 | ||
| 100 | Settings::values.fps_cap.SetValue(ui->fps_cap->value()); | 102 | Settings::values.fps_cap.SetValue(ui->fps_cap->value()); |
diff --git a/src/yuzu/configuration/configure_general.ui b/src/yuzu/configuration/configure_general.ui index 112dc72b3..bfc771135 100644 --- a/src/yuzu/configuration/configure_general.ui +++ b/src/yuzu/configuration/configure_general.ui | |||
| @@ -164,6 +164,13 @@ | |||
| 164 | </widget> | 164 | </widget> |
| 165 | </item> | 165 | </item> |
| 166 | <item> | 166 | <item> |
| 167 | <widget class="QCheckBox" name="toggle_background_mute"> | ||
| 168 | <property name="text"> | ||
| 169 | <string>Mute audio when in background</string> | ||
| 170 | </property> | ||
| 171 | </widget> | ||
| 172 | </item> | ||
| 173 | <item> | ||
| 167 | <widget class="QCheckBox" name="toggle_hide_mouse"> | 174 | <widget class="QCheckBox" name="toggle_hide_mouse"> |
| 168 | <property name="text"> | 175 | <property name="text"> |
| 169 | <string>Hide mouse on inactivity</string> | 176 | <string>Hide mouse on inactivity</string> |
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index cc0534907..9db564663 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp | |||
| @@ -488,6 +488,32 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i | |||
| 488 | emulated_controller->SetStickParam(analog_id, {}); | 488 | emulated_controller->SetStickParam(analog_id, {}); |
| 489 | analog_map_buttons[analog_id][sub_button_id]->setText(tr("[not set]")); | 489 | analog_map_buttons[analog_id][sub_button_id]->setText(tr("[not set]")); |
| 490 | }); | 490 | }); |
| 491 | context_menu.addAction(tr("Center axis"), [&] { | ||
| 492 | const auto stick_value = | ||
| 493 | emulated_controller->GetSticksValues()[analog_id]; | ||
| 494 | const float offset_x = stick_value.x.properties.offset; | ||
| 495 | const float offset_y = stick_value.y.properties.offset; | ||
| 496 | float raw_value_x = stick_value.x.raw_value; | ||
| 497 | float raw_value_y = stick_value.y.raw_value; | ||
| 498 | // See Core::HID::SanitizeStick() to obtain the original raw axis value | ||
| 499 | if (std::abs(offset_x) < 0.5f) { | ||
| 500 | if (raw_value_x > 0) { | ||
| 501 | raw_value_x *= 1 + offset_x; | ||
| 502 | } else { | ||
| 503 | raw_value_x *= 1 - offset_x; | ||
| 504 | } | ||
| 505 | } | ||
| 506 | if (std::abs(offset_x) < 0.5f) { | ||
| 507 | if (raw_value_y > 0) { | ||
| 508 | raw_value_y *= 1 + offset_y; | ||
| 509 | } else { | ||
| 510 | raw_value_y *= 1 - offset_y; | ||
| 511 | } | ||
| 512 | } | ||
| 513 | param.Set("offset_x", -raw_value_x + offset_x); | ||
| 514 | param.Set("offset_y", -raw_value_y + offset_y); | ||
| 515 | emulated_controller->SetStickParam(analog_id, param); | ||
| 516 | }); | ||
| 491 | context_menu.addAction(tr("Invert axis"), [&] { | 517 | context_menu.addAction(tr("Invert axis"), [&] { |
| 492 | if (sub_button_id == 2 || sub_button_id == 3) { | 518 | if (sub_button_id == 2 || sub_button_id == 3) { |
| 493 | const bool invert_value = param.Get("invert_x", "+") == "-"; | 519 | const bool invert_value = param.Get("invert_x", "+") == "-"; |
diff --git a/src/yuzu/configuration/configure_profile_manager.cpp b/src/yuzu/configuration/configure_profile_manager.cpp index 78b6374c0..d9f6dee4e 100644 --- a/src/yuzu/configuration/configure_profile_manager.cpp +++ b/src/yuzu/configuration/configure_profile_manager.cpp | |||
| @@ -33,10 +33,10 @@ constexpr std::array<u8, 107> backup_jpeg{ | |||
| 33 | 0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9, | 33 | 0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9, |
| 34 | }; | 34 | }; |
| 35 | 35 | ||
| 36 | QString GetImagePath(Common::UUID uuid) { | 36 | QString GetImagePath(const Common::UUID& uuid) { |
| 37 | const auto path = | 37 | const auto path = |
| 38 | Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / | 38 | Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / |
| 39 | fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormatSwitch()); | 39 | fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString()); |
| 40 | return QString::fromStdString(Common::FS::PathToUTF8String(path)); | 40 | return QString::fromStdString(Common::FS::PathToUTF8String(path)); |
| 41 | } | 41 | } |
| 42 | 42 | ||
| @@ -55,10 +55,10 @@ QString FormatUserEntryText(const QString& username, Common::UUID uuid) { | |||
| 55 | return ConfigureProfileManager::tr("%1\n%2", | 55 | return ConfigureProfileManager::tr("%1\n%2", |
| 56 | "%1 is the profile username, %2 is the formatted UUID (e.g. " | 56 | "%1 is the profile username, %2 is the formatted UUID (e.g. " |
| 57 | "00112233-4455-6677-8899-AABBCCDDEEFF))") | 57 | "00112233-4455-6677-8899-AABBCCDDEEFF))") |
| 58 | .arg(username, QString::fromStdString(uuid.FormatSwitch())); | 58 | .arg(username, QString::fromStdString(uuid.FormattedString())); |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | QPixmap GetIcon(Common::UUID uuid) { | 61 | QPixmap GetIcon(const Common::UUID& uuid) { |
| 62 | QPixmap icon{GetImagePath(uuid)}; | 62 | QPixmap icon{GetImagePath(uuid)}; |
| 63 | 63 | ||
| 64 | if (!icon) { | 64 | if (!icon) { |
| @@ -200,7 +200,7 @@ void ConfigureProfileManager::AddUser() { | |||
| 200 | return; | 200 | return; |
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | const auto uuid = Common::UUID::Generate(); | 203 | const auto uuid = Common::UUID::MakeRandom(); |
| 204 | profile_manager->CreateNewUser(uuid, username.toStdString()); | 204 | profile_manager->CreateNewUser(uuid, username.toStdString()); |
| 205 | 205 | ||
| 206 | item_model->appendRow(new QStandardItem{GetIcon(uuid), FormatUserEntryText(username, uuid)}); | 206 | item_model->appendRow(new QStandardItem{GetIcon(uuid), FormatUserEntryText(username, uuid)}); |
diff --git a/src/yuzu/debugger/console.cpp b/src/yuzu/debugger/console.cpp index f89ea8ea7..4b508b466 100644 --- a/src/yuzu/debugger/console.cpp +++ b/src/yuzu/debugger/console.cpp | |||
| @@ -30,6 +30,7 @@ void ToggleConsole() { | |||
| 30 | freopen_s(&temp, "CONIN$", "r", stdin); | 30 | freopen_s(&temp, "CONIN$", "r", stdin); |
| 31 | freopen_s(&temp, "CONOUT$", "w", stdout); | 31 | freopen_s(&temp, "CONOUT$", "w", stdout); |
| 32 | freopen_s(&temp, "CONOUT$", "w", stderr); | 32 | freopen_s(&temp, "CONOUT$", "w", stderr); |
| 33 | SetConsoleOutputCP(65001); | ||
| 33 | SetColorConsoleBackendEnabled(true); | 34 | SetColorConsoleBackendEnabled(true); |
| 34 | } | 35 | } |
| 35 | } else { | 36 | } else { |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index c788db12d..3c2d7d080 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -806,21 +806,8 @@ void GMainWindow::InitializeWidgets() { | |||
| 806 | filter_status_button = new QPushButton(); | 806 | filter_status_button = new QPushButton(); |
| 807 | filter_status_button->setObjectName(QStringLiteral("TogglableStatusBarButton")); | 807 | filter_status_button->setObjectName(QStringLiteral("TogglableStatusBarButton")); |
| 808 | filter_status_button->setFocusPolicy(Qt::NoFocus); | 808 | filter_status_button->setFocusPolicy(Qt::NoFocus); |
| 809 | connect(filter_status_button, &QPushButton::clicked, [&] { | 809 | connect(filter_status_button, &QPushButton::clicked, this, |
| 810 | auto filter = Settings::values.scaling_filter.GetValue(); | 810 | &GMainWindow::OnToggleAdaptingFilter); |
| 811 | if (filter == Settings::ScalingFilter::LastFilter) { | ||
| 812 | filter = Settings::ScalingFilter::NearestNeighbor; | ||
| 813 | } else { | ||
| 814 | filter = static_cast<Settings::ScalingFilter>(static_cast<u32>(filter) + 1); | ||
| 815 | } | ||
| 816 | if (Settings::values.renderer_backend.GetValue() == Settings::RendererBackend::OpenGL && | ||
| 817 | filter == Settings::ScalingFilter::Fsr) { | ||
| 818 | filter = Settings::ScalingFilter::NearestNeighbor; | ||
| 819 | } | ||
| 820 | Settings::values.scaling_filter.SetValue(filter); | ||
| 821 | filter_status_button->setChecked(true); | ||
| 822 | UpdateFilterText(); | ||
| 823 | }); | ||
| 824 | auto filter = Settings::values.scaling_filter.GetValue(); | 811 | auto filter = Settings::values.scaling_filter.GetValue(); |
| 825 | if (Settings::values.renderer_backend.GetValue() == Settings::RendererBackend::OpenGL && | 812 | if (Settings::values.renderer_backend.GetValue() == Settings::RendererBackend::OpenGL && |
| 826 | filter == Settings::ScalingFilter::Fsr) { | 813 | filter == Settings::ScalingFilter::Fsr) { |
| @@ -835,25 +822,7 @@ void GMainWindow::InitializeWidgets() { | |||
| 835 | dock_status_button = new QPushButton(); | 822 | dock_status_button = new QPushButton(); |
| 836 | dock_status_button->setObjectName(QStringLiteral("TogglableStatusBarButton")); | 823 | dock_status_button->setObjectName(QStringLiteral("TogglableStatusBarButton")); |
| 837 | dock_status_button->setFocusPolicy(Qt::NoFocus); | 824 | dock_status_button->setFocusPolicy(Qt::NoFocus); |
| 838 | connect(dock_status_button, &QPushButton::clicked, [&] { | 825 | connect(dock_status_button, &QPushButton::clicked, this, &GMainWindow::OnToggleDockedMode); |
| 839 | const bool is_docked = Settings::values.use_docked_mode.GetValue(); | ||
| 840 | auto* player_1 = system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1); | ||
| 841 | auto* handheld = system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld); | ||
| 842 | |||
| 843 | if (!is_docked && handheld->IsConnected()) { | ||
| 844 | QMessageBox::warning(this, tr("Invalid config detected"), | ||
| 845 | tr("Handheld controller can't be used on docked mode. Pro " | ||
| 846 | "controller will be selected.")); | ||
| 847 | handheld->Disconnect(); | ||
| 848 | player_1->SetNpadStyleIndex(Core::HID::NpadStyleIndex::ProController); | ||
| 849 | player_1->Connect(); | ||
| 850 | controller_dialog->refreshConfiguration(); | ||
| 851 | } | ||
| 852 | |||
| 853 | Settings::values.use_docked_mode.SetValue(!is_docked); | ||
| 854 | dock_status_button->setChecked(!is_docked); | ||
| 855 | OnDockedModeChanged(is_docked, !is_docked, *system); | ||
| 856 | }); | ||
| 857 | dock_status_button->setText(tr("DOCK")); | 826 | dock_status_button->setText(tr("DOCK")); |
| 858 | dock_status_button->setCheckable(true); | 827 | dock_status_button->setCheckable(true); |
| 859 | dock_status_button->setChecked(Settings::values.use_docked_mode.GetValue()); | 828 | dock_status_button->setChecked(Settings::values.use_docked_mode.GetValue()); |
| @@ -863,22 +832,7 @@ void GMainWindow::InitializeWidgets() { | |||
| 863 | gpu_accuracy_button->setObjectName(QStringLiteral("GPUStatusBarButton")); | 832 | gpu_accuracy_button->setObjectName(QStringLiteral("GPUStatusBarButton")); |
| 864 | gpu_accuracy_button->setCheckable(true); | 833 | gpu_accuracy_button->setCheckable(true); |
| 865 | gpu_accuracy_button->setFocusPolicy(Qt::NoFocus); | 834 | gpu_accuracy_button->setFocusPolicy(Qt::NoFocus); |
| 866 | connect(gpu_accuracy_button, &QPushButton::clicked, [this] { | 835 | connect(gpu_accuracy_button, &QPushButton::clicked, this, &GMainWindow::OnToggleGpuAccuracy); |
| 867 | switch (Settings::values.gpu_accuracy.GetValue()) { | ||
| 868 | case Settings::GPUAccuracy::High: { | ||
| 869 | Settings::values.gpu_accuracy.SetValue(Settings::GPUAccuracy::Normal); | ||
| 870 | break; | ||
| 871 | } | ||
| 872 | case Settings::GPUAccuracy::Normal: | ||
| 873 | case Settings::GPUAccuracy::Extreme: | ||
| 874 | default: { | ||
| 875 | Settings::values.gpu_accuracy.SetValue(Settings::GPUAccuracy::High); | ||
| 876 | } | ||
| 877 | } | ||
| 878 | |||
| 879 | system->ApplySettings(); | ||
| 880 | UpdateGPUAccuracyButton(); | ||
| 881 | }); | ||
| 882 | UpdateGPUAccuracyButton(); | 836 | UpdateGPUAccuracyButton(); |
| 883 | statusBar()->insertPermanentWidget(0, gpu_accuracy_button); | 837 | statusBar()->insertPermanentWidget(0, gpu_accuracy_button); |
| 884 | 838 | ||
| @@ -1009,12 +963,10 @@ void GMainWindow::InitializeHotkeys() { | |||
| 1009 | ToggleFullscreen(); | 963 | ToggleFullscreen(); |
| 1010 | } | 964 | } |
| 1011 | }); | 965 | }); |
| 1012 | connect_shortcut(QStringLiteral("Change Docked Mode"), [&] { | 966 | connect_shortcut(QStringLiteral("Change Adapting Filter"), |
| 1013 | Settings::values.use_docked_mode.SetValue(!Settings::values.use_docked_mode.GetValue()); | 967 | &GMainWindow::OnToggleAdaptingFilter); |
| 1014 | OnDockedModeChanged(!Settings::values.use_docked_mode.GetValue(), | 968 | connect_shortcut(QStringLiteral("Change Docked Mode"), &GMainWindow::OnToggleDockedMode); |
| 1015 | Settings::values.use_docked_mode.GetValue(), *system); | 969 | connect_shortcut(QStringLiteral("Change GPU Accuracy"), &GMainWindow::OnToggleGpuAccuracy); |
| 1016 | dock_status_button->setChecked(Settings::values.use_docked_mode.GetValue()); | ||
| 1017 | }); | ||
| 1018 | connect_shortcut(QStringLiteral("Audio Mute/Unmute"), | 970 | connect_shortcut(QStringLiteral("Audio Mute/Unmute"), |
| 1019 | [] { Settings::values.audio_muted = !Settings::values.audio_muted; }); | 971 | [] { Settings::values.audio_muted = !Settings::values.audio_muted; }); |
| 1020 | connect_shortcut(QStringLiteral("Audio Volume Down"), [] { | 972 | connect_shortcut(QStringLiteral("Audio Volume Down"), [] { |
| @@ -1082,14 +1034,14 @@ void GMainWindow::RestoreUIState() { | |||
| 1082 | } | 1034 | } |
| 1083 | 1035 | ||
| 1084 | void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) { | 1036 | void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) { |
| 1085 | if (!UISettings::values.pause_when_in_background) { | ||
| 1086 | return; | ||
| 1087 | } | ||
| 1088 | if (state != Qt::ApplicationHidden && state != Qt::ApplicationInactive && | 1037 | if (state != Qt::ApplicationHidden && state != Qt::ApplicationInactive && |
| 1089 | state != Qt::ApplicationActive) { | 1038 | state != Qt::ApplicationActive) { |
| 1090 | LOG_DEBUG(Frontend, "ApplicationState unusual flag: {} ", state); | 1039 | LOG_DEBUG(Frontend, "ApplicationState unusual flag: {} ", state); |
| 1091 | } | 1040 | } |
| 1092 | if (emulation_running) { | 1041 | if (!emulation_running) { |
| 1042 | return; | ||
| 1043 | } | ||
| 1044 | if (UISettings::values.pause_when_in_background) { | ||
| 1093 | if (emu_thread->IsRunning() && | 1045 | if (emu_thread->IsRunning() && |
| 1094 | (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) { | 1046 | (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) { |
| 1095 | auto_paused = true; | 1047 | auto_paused = true; |
| @@ -1099,6 +1051,16 @@ void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) { | |||
| 1099 | OnStartGame(); | 1051 | OnStartGame(); |
| 1100 | } | 1052 | } |
| 1101 | } | 1053 | } |
| 1054 | if (UISettings::values.mute_when_in_background) { | ||
| 1055 | if (!Settings::values.audio_muted && | ||
| 1056 | (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) { | ||
| 1057 | Settings::values.audio_muted = true; | ||
| 1058 | auto_muted = true; | ||
| 1059 | } else if (auto_muted && state == Qt::ApplicationActive) { | ||
| 1060 | Settings::values.audio_muted = false; | ||
| 1061 | auto_muted = false; | ||
| 1062 | } | ||
| 1063 | } | ||
| 1102 | } | 1064 | } |
| 1103 | 1065 | ||
| 1104 | void GMainWindow::ConnectWidgetEvents() { | 1066 | void GMainWindow::ConnectWidgetEvents() { |
| @@ -1690,7 +1652,7 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target | |||
| 1690 | 1652 | ||
| 1691 | const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath( | 1653 | const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath( |
| 1692 | *system, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData, | 1654 | *system, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData, |
| 1693 | program_id, user_id->uuid, 0); | 1655 | program_id, user_id->AsU128(), 0); |
| 1694 | 1656 | ||
| 1695 | path = Common::FS::ConcatPathSafe(nand_dir, user_save_data_path); | 1657 | path = Common::FS::ConcatPathSafe(nand_dir, user_save_data_path); |
| 1696 | } else { | 1658 | } else { |
| @@ -2868,6 +2830,59 @@ void GMainWindow::OnTasReset() { | |||
| 2868 | input_subsystem->GetTas()->Reset(); | 2830 | input_subsystem->GetTas()->Reset(); |
| 2869 | } | 2831 | } |
| 2870 | 2832 | ||
| 2833 | void GMainWindow::OnToggleDockedMode() { | ||
| 2834 | const bool is_docked = Settings::values.use_docked_mode.GetValue(); | ||
| 2835 | auto* player_1 = system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1); | ||
| 2836 | auto* handheld = system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld); | ||
| 2837 | |||
| 2838 | if (!is_docked && handheld->IsConnected()) { | ||
| 2839 | QMessageBox::warning(this, tr("Invalid config detected"), | ||
| 2840 | tr("Handheld controller can't be used on docked mode. Pro " | ||
| 2841 | "controller will be selected.")); | ||
| 2842 | handheld->Disconnect(); | ||
| 2843 | player_1->SetNpadStyleIndex(Core::HID::NpadStyleIndex::ProController); | ||
| 2844 | player_1->Connect(); | ||
| 2845 | controller_dialog->refreshConfiguration(); | ||
| 2846 | } | ||
| 2847 | |||
| 2848 | Settings::values.use_docked_mode.SetValue(!is_docked); | ||
| 2849 | dock_status_button->setChecked(!is_docked); | ||
| 2850 | OnDockedModeChanged(is_docked, !is_docked, *system); | ||
| 2851 | } | ||
| 2852 | |||
| 2853 | void GMainWindow::OnToggleGpuAccuracy() { | ||
| 2854 | switch (Settings::values.gpu_accuracy.GetValue()) { | ||
| 2855 | case Settings::GPUAccuracy::High: { | ||
| 2856 | Settings::values.gpu_accuracy.SetValue(Settings::GPUAccuracy::Normal); | ||
| 2857 | break; | ||
| 2858 | } | ||
| 2859 | case Settings::GPUAccuracy::Normal: | ||
| 2860 | case Settings::GPUAccuracy::Extreme: | ||
| 2861 | default: { | ||
| 2862 | Settings::values.gpu_accuracy.SetValue(Settings::GPUAccuracy::High); | ||
| 2863 | } | ||
| 2864 | } | ||
| 2865 | |||
| 2866 | system->ApplySettings(); | ||
| 2867 | UpdateGPUAccuracyButton(); | ||
| 2868 | } | ||
| 2869 | |||
| 2870 | void GMainWindow::OnToggleAdaptingFilter() { | ||
| 2871 | auto filter = Settings::values.scaling_filter.GetValue(); | ||
| 2872 | if (filter == Settings::ScalingFilter::LastFilter) { | ||
| 2873 | filter = Settings::ScalingFilter::NearestNeighbor; | ||
| 2874 | } else { | ||
| 2875 | filter = static_cast<Settings::ScalingFilter>(static_cast<u32>(filter) + 1); | ||
| 2876 | } | ||
| 2877 | if (Settings::values.renderer_backend.GetValue() == Settings::RendererBackend::OpenGL && | ||
| 2878 | filter == Settings::ScalingFilter::Fsr) { | ||
| 2879 | filter = Settings::ScalingFilter::NearestNeighbor; | ||
| 2880 | } | ||
| 2881 | Settings::values.scaling_filter.SetValue(filter); | ||
| 2882 | filter_status_button->setChecked(true); | ||
| 2883 | UpdateFilterText(); | ||
| 2884 | } | ||
| 2885 | |||
| 2871 | void GMainWindow::OnConfigurePerGame() { | 2886 | void GMainWindow::OnConfigurePerGame() { |
| 2872 | const u64 title_id = system->GetCurrentProcessProgramID(); | 2887 | const u64 title_id = system->GetCurrentProcessProgramID(); |
| 2873 | OpenPerGameConfiguration(title_id, game_path.toStdString()); | 2888 | OpenPerGameConfiguration(title_id, game_path.toStdString()); |
diff --git a/src/yuzu/main.h b/src/yuzu/main.h index ca4ab9af5..6a35b9e3d 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h | |||
| @@ -284,6 +284,9 @@ private slots: | |||
| 284 | void OnTasStartStop(); | 284 | void OnTasStartStop(); |
| 285 | void OnTasRecord(); | 285 | void OnTasRecord(); |
| 286 | void OnTasReset(); | 286 | void OnTasReset(); |
| 287 | void OnToggleDockedMode(); | ||
| 288 | void OnToggleGpuAccuracy(); | ||
| 289 | void OnToggleAdaptingFilter(); | ||
| 287 | void OnConfigurePerGame(); | 290 | void OnConfigurePerGame(); |
| 288 | void OnLoadAmiibo(); | 291 | void OnLoadAmiibo(); |
| 289 | void OnOpenYuzuFolder(); | 292 | void OnOpenYuzuFolder(); |
| @@ -369,6 +372,7 @@ private: | |||
| 369 | QString game_path; | 372 | QString game_path; |
| 370 | 373 | ||
| 371 | bool auto_paused = false; | 374 | bool auto_paused = false; |
| 375 | bool auto_muted = false; | ||
| 372 | QTimer mouse_hide_timer; | 376 | QTimer mouse_hide_timer; |
| 373 | 377 | ||
| 374 | // FS | 378 | // FS |
diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h index f7298ddad..06e8b46da 100644 --- a/src/yuzu/uisettings.h +++ b/src/yuzu/uisettings.h | |||
| @@ -73,6 +73,7 @@ struct Values { | |||
| 73 | Settings::BasicSetting<bool> confirm_before_closing{true, "confirmClose"}; | 73 | Settings::BasicSetting<bool> confirm_before_closing{true, "confirmClose"}; |
| 74 | Settings::BasicSetting<bool> first_start{true, "firstStart"}; | 74 | Settings::BasicSetting<bool> first_start{true, "firstStart"}; |
| 75 | Settings::BasicSetting<bool> pause_when_in_background{false, "pauseWhenInBackground"}; | 75 | Settings::BasicSetting<bool> pause_when_in_background{false, "pauseWhenInBackground"}; |
| 76 | Settings::BasicSetting<bool> mute_when_in_background{false, "muteWhenInBackground"}; | ||
| 76 | Settings::BasicSetting<bool> hide_mouse{true, "hideInactiveMouse"}; | 77 | Settings::BasicSetting<bool> hide_mouse{true, "hideInactiveMouse"}; |
| 77 | 78 | ||
| 78 | Settings::BasicSetting<bool> select_user_on_boot{false, "select_user_on_boot"}; | 79 | Settings::BasicSetting<bool> select_user_on_boot{false, "select_user_on_boot"}; |