mirror of
https://github.com/starr-dusT/yuzu-mainline
synced 2024-03-05 21:12:25 -08:00
general: Rename NewUUID to UUID, and remove the previous UUID impl
This completes the removal of the old UUID implementation.
This commit is contained in:
parent
dfe11d72e3
commit
25db62ce15
@ -99,8 +99,6 @@ add_library(common STATIC
|
|||||||
microprofile.cpp
|
microprofile.cpp
|
||||||
microprofile.h
|
microprofile.h
|
||||||
microprofileui.h
|
microprofileui.h
|
||||||
new_uuid.cpp
|
|
||||||
new_uuid.h
|
|
||||||
nvidia_flags.cpp
|
nvidia_flags.cpp
|
||||||
nvidia_flags.h
|
nvidia_flags.h
|
||||||
page_table.cpp
|
page_table.cpp
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/new_uuid.h"
|
|
||||||
#include "common/param_package.h"
|
#include "common/param_package.h"
|
||||||
|
#include "common/uuid.h"
|
||||||
|
|
||||||
namespace Common::Input {
|
namespace Common::Input {
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ struct AnalogStatus {
|
|||||||
|
|
||||||
// Button data
|
// Button data
|
||||||
struct ButtonStatus {
|
struct ButtonStatus {
|
||||||
Common::NewUUID uuid{};
|
Common::UUID uuid{};
|
||||||
bool value{};
|
bool value{};
|
||||||
bool inverted{};
|
bool inverted{};
|
||||||
bool toggle{};
|
bool toggle{};
|
||||||
@ -109,7 +109,7 @@ using BatteryStatus = BatteryLevel;
|
|||||||
|
|
||||||
// Analog and digital joystick data
|
// Analog and digital joystick data
|
||||||
struct StickStatus {
|
struct StickStatus {
|
||||||
Common::NewUUID uuid{};
|
Common::UUID uuid{};
|
||||||
AnalogStatus x{};
|
AnalogStatus x{};
|
||||||
AnalogStatus y{};
|
AnalogStatus y{};
|
||||||
bool left{};
|
bool left{};
|
||||||
@ -120,7 +120,7 @@ struct StickStatus {
|
|||||||
|
|
||||||
// Analog and digital trigger data
|
// Analog and digital trigger data
|
||||||
struct TriggerStatus {
|
struct TriggerStatus {
|
||||||
Common::NewUUID uuid{};
|
Common::UUID uuid{};
|
||||||
AnalogStatus analog{};
|
AnalogStatus analog{};
|
||||||
ButtonStatus pressed{};
|
ButtonStatus pressed{};
|
||||||
};
|
};
|
||||||
|
@ -1,188 +0,0 @@
|
|||||||
// Copyright 2022 yuzu Emulator Project
|
|
||||||
// Licensed under GPLv2 or any later version
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#include <bit>
|
|
||||||
#include <random>
|
|
||||||
|
|
||||||
#include <fmt/format.h>
|
|
||||||
|
|
||||||
#include "common/assert.h"
|
|
||||||
#include "common/new_uuid.h"
|
|
||||||
#include "common/tiny_mt.h"
|
|
||||||
|
|
||||||
namespace Common {
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
constexpr size_t RawStringSize = sizeof(NewUUID) * 2;
|
|
||||||
constexpr size_t FormattedStringSize = RawStringSize + 4;
|
|
||||||
|
|
||||||
u8 HexCharToByte(char c) {
|
|
||||||
if (c >= '0' && c <= '9') {
|
|
||||||
return static_cast<u8>(c - '0');
|
|
||||||
}
|
|
||||||
if (c >= 'a' && c <= 'f') {
|
|
||||||
return static_cast<u8>(c - 'a' + 10);
|
|
||||||
}
|
|
||||||
if (c >= 'A' && c <= 'F') {
|
|
||||||
return static_cast<u8>(c - 'A' + 10);
|
|
||||||
}
|
|
||||||
ASSERT_MSG(false, "{} is not a hexadecimal digit!", c);
|
|
||||||
return u8{0};
|
|
||||||
}
|
|
||||||
|
|
||||||
std::array<u8, 0x10> ConstructFromRawString(std::string_view raw_string) {
|
|
||||||
std::array<u8, 0x10> uuid;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < RawStringSize; i += 2) {
|
|
||||||
uuid[i / 2] =
|
|
||||||
static_cast<u8>((HexCharToByte(raw_string[i]) << 4) | HexCharToByte(raw_string[i + 1]));
|
|
||||||
}
|
|
||||||
|
|
||||||
return uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::array<u8, 0x10> ConstructFromFormattedString(std::string_view formatted_string) {
|
|
||||||
std::array<u8, 0x10> uuid;
|
|
||||||
|
|
||||||
size_t i = 0;
|
|
||||||
|
|
||||||
// Process the first 8 characters.
|
|
||||||
const auto* str = formatted_string.data();
|
|
||||||
|
|
||||||
for (; i < 4; ++i) {
|
|
||||||
uuid[i] = static_cast<u8>((HexCharToByte(*(str++)) << 4));
|
|
||||||
uuid[i] |= HexCharToByte(*(str++));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process the next 4 characters.
|
|
||||||
++str;
|
|
||||||
|
|
||||||
for (; i < 6; ++i) {
|
|
||||||
uuid[i] = static_cast<u8>((HexCharToByte(*(str++)) << 4));
|
|
||||||
uuid[i] |= HexCharToByte(*(str++));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process the next 4 characters.
|
|
||||||
++str;
|
|
||||||
|
|
||||||
for (; i < 8; ++i) {
|
|
||||||
uuid[i] = static_cast<u8>((HexCharToByte(*(str++)) << 4));
|
|
||||||
uuid[i] |= HexCharToByte(*(str++));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process the next 4 characters.
|
|
||||||
++str;
|
|
||||||
|
|
||||||
for (; i < 10; ++i) {
|
|
||||||
uuid[i] = static_cast<u8>((HexCharToByte(*(str++)) << 4));
|
|
||||||
uuid[i] |= HexCharToByte(*(str++));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process the last 12 characters.
|
|
||||||
++str;
|
|
||||||
|
|
||||||
for (; i < 16; ++i) {
|
|
||||||
uuid[i] = static_cast<u8>((HexCharToByte(*(str++)) << 4));
|
|
||||||
uuid[i] |= HexCharToByte(*(str++));
|
|
||||||
}
|
|
||||||
|
|
||||||
return uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::array<u8, 0x10> ConstructUUID(std::string_view uuid_string) {
|
|
||||||
const auto length = uuid_string.length();
|
|
||||||
|
|
||||||
if (length == 0) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the input string contains 32 hexadecimal characters.
|
|
||||||
if (length == RawStringSize) {
|
|
||||||
return ConstructFromRawString(uuid_string);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the input string has the length of a RFC 4122 formatted UUID string.
|
|
||||||
if (length == FormattedStringSize) {
|
|
||||||
return ConstructFromFormattedString(uuid_string);
|
|
||||||
}
|
|
||||||
|
|
||||||
ASSERT_MSG(false, "UUID string has an invalid length of {} characters!", length);
|
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
} // Anonymous namespace
|
|
||||||
|
|
||||||
NewUUID::NewUUID(std::string_view uuid_string) : uuid{ConstructUUID(uuid_string)} {}
|
|
||||||
|
|
||||||
std::string NewUUID::RawString() const {
|
|
||||||
return fmt::format("{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}"
|
|
||||||
"{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}",
|
|
||||||
uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7],
|
|
||||||
uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14],
|
|
||||||
uuid[15]);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string NewUUID::FormattedString() const {
|
|
||||||
return fmt::format("{:02x}{:02x}{:02x}{:02x}"
|
|
||||||
"-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-"
|
|
||||||
"{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}",
|
|
||||||
uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7],
|
|
||||||
uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14],
|
|
||||||
uuid[15]);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t NewUUID::Hash() const noexcept {
|
|
||||||
u64 hash;
|
|
||||||
u64 temp;
|
|
||||||
|
|
||||||
std::memcpy(&hash, uuid.data(), sizeof(u64));
|
|
||||||
std::memcpy(&temp, uuid.data() + 8, sizeof(u64));
|
|
||||||
|
|
||||||
return hash ^ std::rotl(temp, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
u128 NewUUID::AsU128() const {
|
|
||||||
u128 uuid_old;
|
|
||||||
std::memcpy(&uuid_old, uuid.data(), sizeof(NewUUID));
|
|
||||||
return uuid_old;
|
|
||||||
}
|
|
||||||
|
|
||||||
NewUUID NewUUID::MakeRandom() {
|
|
||||||
std::random_device device;
|
|
||||||
|
|
||||||
return MakeRandomWithSeed(device());
|
|
||||||
}
|
|
||||||
|
|
||||||
NewUUID NewUUID::MakeRandomWithSeed(u32 seed) {
|
|
||||||
// Create and initialize our RNG.
|
|
||||||
TinyMT rng;
|
|
||||||
rng.Initialize(seed);
|
|
||||||
|
|
||||||
NewUUID uuid;
|
|
||||||
|
|
||||||
// Populate the UUID with random bytes.
|
|
||||||
rng.GenerateRandomBytes(uuid.uuid.data(), sizeof(NewUUID));
|
|
||||||
|
|
||||||
return uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
NewUUID NewUUID::MakeRandomRFC4122V4() {
|
|
||||||
auto uuid = MakeRandom();
|
|
||||||
|
|
||||||
// According to Proposed Standard RFC 4122 Section 4.4, we must:
|
|
||||||
|
|
||||||
// 1. Set the two most significant bits (bits 6 and 7) of the
|
|
||||||
// clock_seq_hi_and_reserved to zero and one, respectively.
|
|
||||||
uuid.uuid[8] = 0x80 | (uuid.uuid[8] & 0x3F);
|
|
||||||
|
|
||||||
// 2. Set the four most significant bits (bits 12 through 15) of the
|
|
||||||
// time_hi_and_version field to the 4-bit version number from Section 4.1.3.
|
|
||||||
uuid.uuid[6] = 0x40 | (uuid.uuid[6] & 0xF);
|
|
||||||
|
|
||||||
return uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Common
|
|
@ -1,141 +0,0 @@
|
|||||||
// Copyright 2022 yuzu Emulator Project
|
|
||||||
// Licensed under GPLv2 or any later version
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <array>
|
|
||||||
#include <functional>
|
|
||||||
#include <string>
|
|
||||||
#include <string_view>
|
|
||||||
|
|
||||||
#include "common/common_types.h"
|
|
||||||
|
|
||||||
namespace Common {
|
|
||||||
|
|
||||||
struct NewUUID {
|
|
||||||
std::array<u8, 0x10> uuid{};
|
|
||||||
|
|
||||||
/// Constructs an invalid UUID.
|
|
||||||
constexpr NewUUID() = default;
|
|
||||||
|
|
||||||
/// Constructs a UUID from a reference to a 128 bit array.
|
|
||||||
constexpr explicit NewUUID(const std::array<u8, 16>& uuid_) : uuid{uuid_} {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a UUID from either:
|
|
||||||
* 1. A 32 hexadecimal character string representing the bytes of the UUID
|
|
||||||
* 2. A RFC 4122 formatted UUID string, in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
|
||||||
*
|
|
||||||
* The input string may contain uppercase or lowercase characters, but they must:
|
|
||||||
* 1. Contain valid hexadecimal characters (0-9, a-f, A-F)
|
|
||||||
* 2. Not contain the "0x" hexadecimal prefix
|
|
||||||
*
|
|
||||||
* Should the input string not meet the above requirements,
|
|
||||||
* an assert will be triggered and an invalid UUID is set instead.
|
|
||||||
*/
|
|
||||||
explicit NewUUID(std::string_view uuid_string);
|
|
||||||
|
|
||||||
~NewUUID() = default;
|
|
||||||
|
|
||||||
constexpr NewUUID(const NewUUID&) noexcept = default;
|
|
||||||
constexpr NewUUID(NewUUID&&) noexcept = default;
|
|
||||||
|
|
||||||
constexpr NewUUID& operator=(const NewUUID&) noexcept = default;
|
|
||||||
constexpr NewUUID& operator=(NewUUID&&) noexcept = default;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether the stored UUID is valid or not.
|
|
||||||
*
|
|
||||||
* @returns True if the stored UUID is valid, false otherwise.
|
|
||||||
*/
|
|
||||||
constexpr bool IsValid() const {
|
|
||||||
return uuid != std::array<u8, 0x10>{};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether the stored UUID is invalid or not.
|
|
||||||
*
|
|
||||||
* @returns True if the stored UUID is invalid, false otherwise.
|
|
||||||
*/
|
|
||||||
constexpr bool IsInvalid() const {
|
|
||||||
return !IsValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a 32 hexadecimal character string representing the bytes of the UUID.
|
|
||||||
*
|
|
||||||
* @returns A 32 hexadecimal character string of the UUID.
|
|
||||||
*/
|
|
||||||
std::string RawString() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a RFC 4122 formatted UUID string in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
|
|
||||||
*
|
|
||||||
* @returns A RFC 4122 formatted UUID string.
|
|
||||||
*/
|
|
||||||
std::string FormattedString() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a 64-bit hash of the UUID for use in hash table data structures.
|
|
||||||
*
|
|
||||||
* @returns A 64-bit hash of the UUID.
|
|
||||||
*/
|
|
||||||
size_t Hash() const noexcept;
|
|
||||||
|
|
||||||
/// DO NOT USE. Copies the contents of the UUID into a u128.
|
|
||||||
u128 AsU128() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a default UUID "yuzu Default UID".
|
|
||||||
*
|
|
||||||
* @returns A UUID with its bytes set to the ASCII values of "yuzu Default UID".
|
|
||||||
*/
|
|
||||||
static constexpr NewUUID MakeDefault() {
|
|
||||||
return NewUUID{
|
|
||||||
{'y', 'u', 'z', 'u', ' ', 'D', 'e', 'f', 'a', 'u', 'l', 't', ' ', 'U', 'I', 'D'},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a random UUID.
|
|
||||||
*
|
|
||||||
* @returns A random UUID.
|
|
||||||
*/
|
|
||||||
static NewUUID MakeRandom();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a random UUID with a seed.
|
|
||||||
*
|
|
||||||
* @param seed A seed to initialize the Mersenne-Twister RNG
|
|
||||||
*
|
|
||||||
* @returns A random UUID.
|
|
||||||
*/
|
|
||||||
static NewUUID MakeRandomWithSeed(u32 seed);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a random UUID. The generated UUID is RFC 4122 Version 4 compliant.
|
|
||||||
*
|
|
||||||
* @returns A random UUID that is RFC 4122 Version 4 compliant.
|
|
||||||
*/
|
|
||||||
static NewUUID MakeRandomRFC4122V4();
|
|
||||||
|
|
||||||
friend constexpr bool operator==(const NewUUID& lhs, const NewUUID& rhs) = default;
|
|
||||||
};
|
|
||||||
static_assert(sizeof(NewUUID) == 0x10, "UUID has incorrect size.");
|
|
||||||
|
|
||||||
/// An invalid UUID. This UUID has all its bytes set to 0.
|
|
||||||
constexpr NewUUID InvalidUUID = {};
|
|
||||||
|
|
||||||
} // namespace Common
|
|
||||||
|
|
||||||
namespace std {
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct hash<Common::NewUUID> {
|
|
||||||
size_t operator()(const Common::NewUUID& uuid) const noexcept {
|
|
||||||
return uuid.Hash();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace std
|
|
@ -1,21 +1,22 @@
|
|||||||
// Copyright 2018 yuzu Emulator Project
|
// Copyright 2022 yuzu Emulator Project
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <bit>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
|
#include "common/tiny_mt.h"
|
||||||
#include "common/uuid.h"
|
#include "common/uuid.h"
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
bool IsHexDigit(char c) {
|
constexpr size_t RawStringSize = sizeof(UUID) * 2;
|
||||||
return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
|
constexpr size_t FormattedStringSize = RawStringSize + 4;
|
||||||
}
|
|
||||||
|
|
||||||
u8 HexCharToByte(char c) {
|
u8 HexCharToByte(char c) {
|
||||||
if (c >= '0' && c <= '9') {
|
if (c >= '0' && c <= '9') {
|
||||||
@ -31,57 +32,157 @@ u8 HexCharToByte(char c) {
|
|||||||
return u8{0};
|
return u8{0};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::array<u8, 0x10> ConstructFromRawString(std::string_view raw_string) {
|
||||||
|
std::array<u8, 0x10> uuid;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < RawStringSize; i += 2) {
|
||||||
|
uuid[i / 2] =
|
||||||
|
static_cast<u8>((HexCharToByte(raw_string[i]) << 4) | HexCharToByte(raw_string[i + 1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::array<u8, 0x10> ConstructFromFormattedString(std::string_view formatted_string) {
|
||||||
|
std::array<u8, 0x10> uuid;
|
||||||
|
|
||||||
|
size_t i = 0;
|
||||||
|
|
||||||
|
// Process the first 8 characters.
|
||||||
|
const auto* str = formatted_string.data();
|
||||||
|
|
||||||
|
for (; i < 4; ++i) {
|
||||||
|
uuid[i] = static_cast<u8>((HexCharToByte(*(str++)) << 4));
|
||||||
|
uuid[i] |= HexCharToByte(*(str++));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process the next 4 characters.
|
||||||
|
++str;
|
||||||
|
|
||||||
|
for (; i < 6; ++i) {
|
||||||
|
uuid[i] = static_cast<u8>((HexCharToByte(*(str++)) << 4));
|
||||||
|
uuid[i] |= HexCharToByte(*(str++));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process the next 4 characters.
|
||||||
|
++str;
|
||||||
|
|
||||||
|
for (; i < 8; ++i) {
|
||||||
|
uuid[i] = static_cast<u8>((HexCharToByte(*(str++)) << 4));
|
||||||
|
uuid[i] |= HexCharToByte(*(str++));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process the next 4 characters.
|
||||||
|
++str;
|
||||||
|
|
||||||
|
for (; i < 10; ++i) {
|
||||||
|
uuid[i] = static_cast<u8>((HexCharToByte(*(str++)) << 4));
|
||||||
|
uuid[i] |= HexCharToByte(*(str++));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process the last 12 characters.
|
||||||
|
++str;
|
||||||
|
|
||||||
|
for (; i < 16; ++i) {
|
||||||
|
uuid[i] = static_cast<u8>((HexCharToByte(*(str++)) << 4));
|
||||||
|
uuid[i] |= HexCharToByte(*(str++));
|
||||||
|
}
|
||||||
|
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::array<u8, 0x10> ConstructUUID(std::string_view uuid_string) {
|
||||||
|
const auto length = uuid_string.length();
|
||||||
|
|
||||||
|
if (length == 0) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the input string contains 32 hexadecimal characters.
|
||||||
|
if (length == RawStringSize) {
|
||||||
|
return ConstructFromRawString(uuid_string);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the input string has the length of a RFC 4122 formatted UUID string.
|
||||||
|
if (length == FormattedStringSize) {
|
||||||
|
return ConstructFromFormattedString(uuid_string);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT_MSG(false, "UUID string has an invalid length of {} characters!", length);
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
u128 HexStringToU128(std::string_view hex_string) {
|
UUID::UUID(std::string_view uuid_string) : uuid{ConstructUUID(uuid_string)} {}
|
||||||
const size_t length = hex_string.length();
|
|
||||||
|
|
||||||
// Detect "0x" prefix.
|
std::string UUID::RawString() const {
|
||||||
const bool has_0x_prefix = length > 2 && hex_string[0] == '0' && hex_string[1] == 'x';
|
return fmt::format("{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}"
|
||||||
const size_t offset = has_0x_prefix ? 2 : 0;
|
"{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}",
|
||||||
|
uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7],
|
||||||
// Check length.
|
uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14],
|
||||||
if (length > 32 + offset) {
|
uuid[15]);
|
||||||
ASSERT_MSG(false, "hex_string has more than 32 hexadecimal characters!");
|
|
||||||
return INVALID_UUID;
|
|
||||||
}
|
|
||||||
|
|
||||||
u64 lo = 0;
|
|
||||||
u64 hi = 0;
|
|
||||||
for (size_t i = 0; i < length - offset; ++i) {
|
|
||||||
const char c = hex_string[length - 1 - i];
|
|
||||||
if (!IsHexDigit(c)) {
|
|
||||||
ASSERT_MSG(false, "{} is not a hexadecimal digit!", c);
|
|
||||||
return INVALID_UUID;
|
|
||||||
}
|
|
||||||
if (i < 16) {
|
|
||||||
lo |= u64{HexCharToByte(c)} << (i * 4);
|
|
||||||
}
|
|
||||||
if (i >= 16) {
|
|
||||||
hi |= u64{HexCharToByte(c)} << ((i - 16) * 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return u128{lo, hi};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UUID UUID::Generate() {
|
std::string UUID::FormattedString() const {
|
||||||
|
return fmt::format("{:02x}{:02x}{:02x}{:02x}"
|
||||||
|
"-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-"
|
||||||
|
"{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}",
|
||||||
|
uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7],
|
||||||
|
uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14],
|
||||||
|
uuid[15]);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t UUID::Hash() const noexcept {
|
||||||
|
u64 hash;
|
||||||
|
u64 temp;
|
||||||
|
|
||||||
|
std::memcpy(&hash, uuid.data(), sizeof(u64));
|
||||||
|
std::memcpy(&temp, uuid.data() + 8, sizeof(u64));
|
||||||
|
|
||||||
|
return hash ^ std::rotl(temp, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
u128 UUID::AsU128() const {
|
||||||
|
u128 uuid_old;
|
||||||
|
std::memcpy(&uuid_old, uuid.data(), sizeof(UUID));
|
||||||
|
return uuid_old;
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID UUID::MakeRandom() {
|
||||||
std::random_device device;
|
std::random_device device;
|
||||||
std::mt19937 gen(device());
|
|
||||||
std::uniform_int_distribution<u64> distribution(1, std::numeric_limits<u64>::max());
|
return MakeRandomWithSeed(device());
|
||||||
return UUID{distribution(gen), distribution(gen)};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string UUID::Format() const {
|
UUID UUID::MakeRandomWithSeed(u32 seed) {
|
||||||
return fmt::format("{:016x}{:016x}", uuid[1], uuid[0]);
|
// Create and initialize our RNG.
|
||||||
|
TinyMT rng;
|
||||||
|
rng.Initialize(seed);
|
||||||
|
|
||||||
|
UUID uuid;
|
||||||
|
|
||||||
|
// Populate the UUID with random bytes.
|
||||||
|
rng.GenerateRandomBytes(uuid.uuid.data(), sizeof(UUID));
|
||||||
|
|
||||||
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string UUID::FormatSwitch() const {
|
UUID UUID::MakeRandomRFC4122V4() {
|
||||||
std::array<u8, 16> s{};
|
auto uuid = MakeRandom();
|
||||||
std::memcpy(s.data(), uuid.data(), sizeof(u128));
|
|
||||||
return fmt::format("{:02x}{:02x}{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{"
|
// According to Proposed Standard RFC 4122 Section 4.4, we must:
|
||||||
":02x}{:02x}{:02x}{:02x}{:02x}",
|
|
||||||
s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[8], s[9], s[10], s[11],
|
// 1. Set the two most significant bits (bits 6 and 7) of the
|
||||||
s[12], s[13], s[14], s[15]);
|
// clock_seq_hi_and_reserved to zero and one, respectively.
|
||||||
|
uuid.uuid[8] = 0x80 | (uuid.uuid[8] & 0x3F);
|
||||||
|
|
||||||
|
// 2. Set the four most significant bits (bits 12 through 15) of the
|
||||||
|
// time_hi_and_version field to the 4-bit version number from Section 4.1.3.
|
||||||
|
uuid.uuid[6] = 0x40 | (uuid.uuid[6] & 0xF);
|
||||||
|
|
||||||
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
// Copyright 2018 yuzu Emulator Project
|
// Copyright 2022 yuzu Emulator Project
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
@ -11,69 +13,119 @@
|
|||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
constexpr u128 INVALID_UUID{{0, 0}};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a hex string to a 128-bit unsigned integer.
|
|
||||||
*
|
|
||||||
* The hex string can be formatted in lowercase or uppercase, with or without the "0x" prefix.
|
|
||||||
*
|
|
||||||
* This function will assert and return INVALID_UUID under the following conditions:
|
|
||||||
* - If the hex string is more than 32 characters long
|
|
||||||
* - If the hex string contains non-hexadecimal characters
|
|
||||||
*
|
|
||||||
* @param hex_string Hexadecimal string
|
|
||||||
*
|
|
||||||
* @returns A 128-bit unsigned integer if successfully converted, INVALID_UUID otherwise.
|
|
||||||
*/
|
|
||||||
[[nodiscard]] u128 HexStringToU128(std::string_view hex_string);
|
|
||||||
|
|
||||||
struct UUID {
|
struct UUID {
|
||||||
// UUIDs which are 0 are considered invalid!
|
std::array<u8, 0x10> uuid{};
|
||||||
u128 uuid;
|
|
||||||
UUID() = default;
|
/// Constructs an invalid UUID.
|
||||||
constexpr explicit UUID(const u128& id) : uuid{id} {}
|
constexpr UUID() = default;
|
||||||
constexpr explicit UUID(const u64 lo, const u64 hi) : uuid{{lo, hi}} {}
|
|
||||||
explicit UUID(std::string_view hex_string) {
|
/// Constructs a UUID from a reference to a 128 bit array.
|
||||||
uuid = HexStringToU128(hex_string);
|
constexpr explicit UUID(const std::array<u8, 16>& uuid_) : uuid{uuid_} {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a UUID from either:
|
||||||
|
* 1. A 32 hexadecimal character string representing the bytes of the UUID
|
||||||
|
* 2. A RFC 4122 formatted UUID string, in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||||
|
*
|
||||||
|
* The input string may contain uppercase or lowercase characters, but they must:
|
||||||
|
* 1. Contain valid hexadecimal characters (0-9, a-f, A-F)
|
||||||
|
* 2. Not contain the "0x" hexadecimal prefix
|
||||||
|
*
|
||||||
|
* Should the input string not meet the above requirements,
|
||||||
|
* an assert will be triggered and an invalid UUID is set instead.
|
||||||
|
*/
|
||||||
|
explicit UUID(std::string_view uuid_string);
|
||||||
|
|
||||||
|
~UUID() = default;
|
||||||
|
|
||||||
|
constexpr UUID(const UUID&) noexcept = default;
|
||||||
|
constexpr UUID(UUID&&) noexcept = default;
|
||||||
|
|
||||||
|
constexpr UUID& operator=(const UUID&) noexcept = default;
|
||||||
|
constexpr UUID& operator=(UUID&&) noexcept = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the stored UUID is valid or not.
|
||||||
|
*
|
||||||
|
* @returns True if the stored UUID is valid, false otherwise.
|
||||||
|
*/
|
||||||
|
constexpr bool IsValid() const {
|
||||||
|
return uuid != std::array<u8, 0x10>{};
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] constexpr explicit operator bool() const {
|
/**
|
||||||
return uuid != INVALID_UUID;
|
* Returns whether the stored UUID is invalid or not.
|
||||||
|
*
|
||||||
|
* @returns True if the stored UUID is invalid, false otherwise.
|
||||||
|
*/
|
||||||
|
constexpr bool IsInvalid() const {
|
||||||
|
return !IsValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] constexpr bool operator==(const UUID& rhs) const {
|
/**
|
||||||
return uuid == rhs.uuid;
|
* Returns a 32 hexadecimal character string representing the bytes of the UUID.
|
||||||
|
*
|
||||||
|
* @returns A 32 hexadecimal character string of the UUID.
|
||||||
|
*/
|
||||||
|
std::string RawString() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a RFC 4122 formatted UUID string in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
|
||||||
|
*
|
||||||
|
* @returns A RFC 4122 formatted UUID string.
|
||||||
|
*/
|
||||||
|
std::string FormattedString() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a 64-bit hash of the UUID for use in hash table data structures.
|
||||||
|
*
|
||||||
|
* @returns A 64-bit hash of the UUID.
|
||||||
|
*/
|
||||||
|
size_t Hash() const noexcept;
|
||||||
|
|
||||||
|
/// DO NOT USE. Copies the contents of the UUID into a u128.
|
||||||
|
u128 AsU128() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a default UUID "yuzu Default UID".
|
||||||
|
*
|
||||||
|
* @returns A UUID with its bytes set to the ASCII values of "yuzu Default UID".
|
||||||
|
*/
|
||||||
|
static constexpr UUID MakeDefault() {
|
||||||
|
return UUID{
|
||||||
|
{'y', 'u', 'z', 'u', ' ', 'D', 'e', 'f', 'a', 'u', 'l', 't', ' ', 'U', 'I', 'D'},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] constexpr bool operator!=(const UUID& rhs) const {
|
/**
|
||||||
return !operator==(rhs);
|
* Creates a random UUID.
|
||||||
}
|
*
|
||||||
|
* @returns A random UUID.
|
||||||
|
*/
|
||||||
|
static UUID MakeRandom();
|
||||||
|
|
||||||
// TODO(ogniK): Properly generate uuids based on RFC-4122
|
/**
|
||||||
[[nodiscard]] static UUID Generate();
|
* Creates a random UUID with a seed.
|
||||||
|
*
|
||||||
|
* @param seed A seed to initialize the Mersenne-Twister RNG
|
||||||
|
*
|
||||||
|
* @returns A random UUID.
|
||||||
|
*/
|
||||||
|
static UUID MakeRandomWithSeed(u32 seed);
|
||||||
|
|
||||||
// Set the UUID to {0,0} to be considered an invalid user
|
/**
|
||||||
constexpr void Invalidate() {
|
* Creates a random UUID. The generated UUID is RFC 4122 Version 4 compliant.
|
||||||
uuid = INVALID_UUID;
|
*
|
||||||
}
|
* @returns A random UUID that is RFC 4122 Version 4 compliant.
|
||||||
|
*/
|
||||||
|
static UUID MakeRandomRFC4122V4();
|
||||||
|
|
||||||
[[nodiscard]] constexpr bool IsInvalid() const {
|
friend constexpr bool operator==(const UUID& lhs, const UUID& rhs) = default;
|
||||||
return uuid == INVALID_UUID;
|
|
||||||
}
|
|
||||||
[[nodiscard]] constexpr bool IsValid() const {
|
|
||||||
return !IsInvalid();
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(ogniK): Properly generate a Nintendo ID
|
|
||||||
[[nodiscard]] constexpr u64 GetNintendoID() const {
|
|
||||||
return uuid[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] std::string Format() const;
|
|
||||||
[[nodiscard]] std::string FormatSwitch() const;
|
|
||||||
};
|
};
|
||||||
static_assert(sizeof(UUID) == 16, "UUID is an invalid size!");
|
static_assert(sizeof(UUID) == 0x10, "UUID has incorrect size.");
|
||||||
|
|
||||||
|
/// An invalid UUID. This UUID has all its bytes set to 0.
|
||||||
|
constexpr UUID InvalidUUID = {};
|
||||||
|
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
|
||||||
@ -82,7 +134,7 @@ namespace std {
|
|||||||
template <>
|
template <>
|
||||||
struct hash<Common::UUID> {
|
struct hash<Common::UUID> {
|
||||||
size_t operator()(const Common::UUID& uuid) const noexcept {
|
size_t operator()(const Common::UUID& uuid) const noexcept {
|
||||||
return uuid.uuid[1] ^ uuid.uuid[0];
|
return uuid.Hash();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -11,9 +11,9 @@ namespace Core::Frontend {
|
|||||||
ProfileSelectApplet::~ProfileSelectApplet() = default;
|
ProfileSelectApplet::~ProfileSelectApplet() = default;
|
||||||
|
|
||||||
void DefaultProfileSelectApplet::SelectProfile(
|
void DefaultProfileSelectApplet::SelectProfile(
|
||||||
std::function<void(std::optional<Common::NewUUID>)> callback) const {
|
std::function<void(std::optional<Common::UUID>)> callback) const {
|
||||||
Service::Account::ProfileManager manager;
|
Service::Account::ProfileManager manager;
|
||||||
callback(manager.GetUser(Settings::values.current_user.GetValue()).value_or(Common::NewUUID{}));
|
callback(manager.GetUser(Settings::values.current_user.GetValue()).value_or(Common::UUID{}));
|
||||||
LOG_INFO(Service_ACC, "called, selecting current user instead of prompting...");
|
LOG_INFO(Service_ACC, "called, selecting current user instead of prompting...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include "common/new_uuid.h"
|
#include "common/uuid.h"
|
||||||
|
|
||||||
namespace Core::Frontend {
|
namespace Core::Frontend {
|
||||||
|
|
||||||
@ -14,13 +14,12 @@ class ProfileSelectApplet {
|
|||||||
public:
|
public:
|
||||||
virtual ~ProfileSelectApplet();
|
virtual ~ProfileSelectApplet();
|
||||||
|
|
||||||
virtual void SelectProfile(
|
virtual void SelectProfile(std::function<void(std::optional<Common::UUID>)> callback) const = 0;
|
||||||
std::function<void(std::optional<Common::NewUUID>)> callback) const = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DefaultProfileSelectApplet final : public ProfileSelectApplet {
|
class DefaultProfileSelectApplet final : public ProfileSelectApplet {
|
||||||
public:
|
public:
|
||||||
void SelectProfile(std::function<void(std::optional<Common::NewUUID>)> callback) const override;
|
void SelectProfile(std::function<void(std::optional<Common::UUID>)> callback) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Core::Frontend
|
} // namespace Core::Frontend
|
||||||
|
@ -204,7 +204,7 @@ void EmulatedController::ReloadInput() {
|
|||||||
if (!button_devices[index]) {
|
if (!button_devices[index]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const auto uuid = Common::NewUUID{button_params[index].Get("guid", "")};
|
const auto uuid = Common::UUID{button_params[index].Get("guid", "")};
|
||||||
button_devices[index]->SetCallback({
|
button_devices[index]->SetCallback({
|
||||||
.on_change =
|
.on_change =
|
||||||
[this, index, uuid](const Common::Input::CallbackStatus& callback) {
|
[this, index, uuid](const Common::Input::CallbackStatus& callback) {
|
||||||
@ -218,7 +218,7 @@ void EmulatedController::ReloadInput() {
|
|||||||
if (!stick_devices[index]) {
|
if (!stick_devices[index]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const auto uuid = Common::NewUUID{stick_params[index].Get("guid", "")};
|
const auto uuid = Common::UUID{stick_params[index].Get("guid", "")};
|
||||||
stick_devices[index]->SetCallback({
|
stick_devices[index]->SetCallback({
|
||||||
.on_change =
|
.on_change =
|
||||||
[this, index, uuid](const Common::Input::CallbackStatus& callback) {
|
[this, index, uuid](const Common::Input::CallbackStatus& callback) {
|
||||||
@ -232,7 +232,7 @@ void EmulatedController::ReloadInput() {
|
|||||||
if (!trigger_devices[index]) {
|
if (!trigger_devices[index]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const auto uuid = Common::NewUUID{trigger_params[index].Get("guid", "")};
|
const auto uuid = Common::UUID{trigger_params[index].Get("guid", "")};
|
||||||
trigger_devices[index]->SetCallback({
|
trigger_devices[index]->SetCallback({
|
||||||
.on_change =
|
.on_change =
|
||||||
[this, index, uuid](const Common::Input::CallbackStatus& callback) {
|
[this, index, uuid](const Common::Input::CallbackStatus& callback) {
|
||||||
@ -269,7 +269,7 @@ void EmulatedController::ReloadInput() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Use a common UUID for TAS
|
// Use a common UUID for TAS
|
||||||
static constexpr Common::NewUUID TAS_UUID = Common::NewUUID{
|
static constexpr Common::UUID TAS_UUID = Common::UUID{
|
||||||
{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xA5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}};
|
{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xA5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}};
|
||||||
|
|
||||||
// Register TAS devices. No need to force update
|
// Register TAS devices. No need to force update
|
||||||
@ -490,7 +490,7 @@ void EmulatedController::SetMotionParam(std::size_t index, Common::ParamPackage
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback, std::size_t index,
|
void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback, std::size_t index,
|
||||||
Common::NewUUID uuid) {
|
Common::UUID uuid) {
|
||||||
if (index >= controller.button_values.size()) {
|
if (index >= controller.button_values.size()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -639,7 +639,7 @@ void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EmulatedController::SetStick(const Common::Input::CallbackStatus& callback, std::size_t index,
|
void EmulatedController::SetStick(const Common::Input::CallbackStatus& callback, std::size_t index,
|
||||||
Common::NewUUID uuid) {
|
Common::UUID uuid) {
|
||||||
if (index >= controller.stick_values.size()) {
|
if (index >= controller.stick_values.size()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -689,7 +689,7 @@ void EmulatedController::SetStick(const Common::Input::CallbackStatus& callback,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EmulatedController::SetTrigger(const Common::Input::CallbackStatus& callback,
|
void EmulatedController::SetTrigger(const Common::Input::CallbackStatus& callback,
|
||||||
std::size_t index, Common::NewUUID uuid) {
|
std::size_t index, Common::UUID uuid) {
|
||||||
if (index >= controller.trigger_values.size()) {
|
if (index >= controller.trigger_values.size()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -354,7 +354,7 @@ private:
|
|||||||
* @param index Button ID of the to be updated
|
* @param index Button ID of the to be updated
|
||||||
*/
|
*/
|
||||||
void SetButton(const Common::Input::CallbackStatus& callback, std::size_t index,
|
void SetButton(const Common::Input::CallbackStatus& callback, std::size_t index,
|
||||||
Common::NewUUID uuid);
|
Common::UUID uuid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the analog stick status of the controller
|
* Updates the analog stick status of the controller
|
||||||
@ -362,7 +362,7 @@ private:
|
|||||||
* @param index stick ID of the to be updated
|
* @param index stick ID of the to be updated
|
||||||
*/
|
*/
|
||||||
void SetStick(const Common::Input::CallbackStatus& callback, std::size_t index,
|
void SetStick(const Common::Input::CallbackStatus& callback, std::size_t index,
|
||||||
Common::NewUUID uuid);
|
Common::UUID uuid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the trigger status of the controller
|
* Updates the trigger status of the controller
|
||||||
@ -370,7 +370,7 @@ private:
|
|||||||
* @param index trigger ID of the to be updated
|
* @param index trigger ID of the to be updated
|
||||||
*/
|
*/
|
||||||
void SetTrigger(const Common::Input::CallbackStatus& callback, std::size_t index,
|
void SetTrigger(const Common::Input::CallbackStatus& callback, std::size_t index,
|
||||||
Common::NewUUID uuid);
|
Common::UUID uuid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the motion status of the controller
|
* Updates the motion status of the controller
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
#include "common/bit_field.h"
|
#include "common/bit_field.h"
|
||||||
#include "common/common_funcs.h"
|
#include "common/common_funcs.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/new_uuid.h"
|
|
||||||
#include "common/point.h"
|
#include "common/point.h"
|
||||||
|
#include "common/uuid.h"
|
||||||
|
|
||||||
namespace Core::HID {
|
namespace Core::HID {
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ constexpr ResultCode ERR_FAILED_SAVE_DATA{ErrorModule::Account, 100};
|
|||||||
// Thumbnails are hard coded to be at least this size
|
// Thumbnails are hard coded to be at least this size
|
||||||
constexpr std::size_t THUMBNAIL_SIZE = 0x24000;
|
constexpr std::size_t THUMBNAIL_SIZE = 0x24000;
|
||||||
|
|
||||||
static std::filesystem::path GetImagePath(const Common::NewUUID& uuid) {
|
static std::filesystem::path GetImagePath(const Common::UUID& uuid) {
|
||||||
return Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) /
|
return Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) /
|
||||||
fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString());
|
fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString());
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ static constexpr u32 SanitizeJPEGSize(std::size_t size) {
|
|||||||
|
|
||||||
class IManagerForSystemService final : public ServiceFramework<IManagerForSystemService> {
|
class IManagerForSystemService final : public ServiceFramework<IManagerForSystemService> {
|
||||||
public:
|
public:
|
||||||
explicit IManagerForSystemService(Core::System& system_, Common::NewUUID)
|
explicit IManagerForSystemService(Core::System& system_, Common::UUID)
|
||||||
: ServiceFramework{system_, "IManagerForSystemService"} {
|
: ServiceFramework{system_, "IManagerForSystemService"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
@ -87,7 +87,7 @@ public:
|
|||||||
// 3.0.0+
|
// 3.0.0+
|
||||||
class IFloatingRegistrationRequest final : public ServiceFramework<IFloatingRegistrationRequest> {
|
class IFloatingRegistrationRequest final : public ServiceFramework<IFloatingRegistrationRequest> {
|
||||||
public:
|
public:
|
||||||
explicit IFloatingRegistrationRequest(Core::System& system_, Common::NewUUID)
|
explicit IFloatingRegistrationRequest(Core::System& system_, Common::UUID)
|
||||||
: ServiceFramework{system_, "IFloatingRegistrationRequest"} {
|
: ServiceFramework{system_, "IFloatingRegistrationRequest"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
@ -112,7 +112,7 @@ public:
|
|||||||
|
|
||||||
class IAdministrator final : public ServiceFramework<IAdministrator> {
|
class IAdministrator final : public ServiceFramework<IAdministrator> {
|
||||||
public:
|
public:
|
||||||
explicit IAdministrator(Core::System& system_, Common::NewUUID)
|
explicit IAdministrator(Core::System& system_, Common::UUID)
|
||||||
: ServiceFramework{system_, "IAdministrator"} {
|
: ServiceFramework{system_, "IAdministrator"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
@ -170,7 +170,7 @@ public:
|
|||||||
|
|
||||||
class IAuthorizationRequest final : public ServiceFramework<IAuthorizationRequest> {
|
class IAuthorizationRequest final : public ServiceFramework<IAuthorizationRequest> {
|
||||||
public:
|
public:
|
||||||
explicit IAuthorizationRequest(Core::System& system_, Common::NewUUID)
|
explicit IAuthorizationRequest(Core::System& system_, Common::UUID)
|
||||||
: ServiceFramework{system_, "IAuthorizationRequest"} {
|
: ServiceFramework{system_, "IAuthorizationRequest"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
@ -189,7 +189,7 @@ public:
|
|||||||
|
|
||||||
class IOAuthProcedure final : public ServiceFramework<IOAuthProcedure> {
|
class IOAuthProcedure final : public ServiceFramework<IOAuthProcedure> {
|
||||||
public:
|
public:
|
||||||
explicit IOAuthProcedure(Core::System& system_, Common::NewUUID)
|
explicit IOAuthProcedure(Core::System& system_, Common::UUID)
|
||||||
: ServiceFramework{system_, "IOAuthProcedure"} {
|
: ServiceFramework{system_, "IOAuthProcedure"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
@ -208,7 +208,7 @@ public:
|
|||||||
// 3.0.0+
|
// 3.0.0+
|
||||||
class IOAuthProcedureForExternalNsa final : public ServiceFramework<IOAuthProcedureForExternalNsa> {
|
class IOAuthProcedureForExternalNsa final : public ServiceFramework<IOAuthProcedureForExternalNsa> {
|
||||||
public:
|
public:
|
||||||
explicit IOAuthProcedureForExternalNsa(Core::System& system_, Common::NewUUID)
|
explicit IOAuthProcedureForExternalNsa(Core::System& system_, Common::UUID)
|
||||||
: ServiceFramework{system_, "IOAuthProcedureForExternalNsa"} {
|
: ServiceFramework{system_, "IOAuthProcedureForExternalNsa"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
@ -231,7 +231,7 @@ public:
|
|||||||
class IOAuthProcedureForNintendoAccountLinkage final
|
class IOAuthProcedureForNintendoAccountLinkage final
|
||||||
: public ServiceFramework<IOAuthProcedureForNintendoAccountLinkage> {
|
: public ServiceFramework<IOAuthProcedureForNintendoAccountLinkage> {
|
||||||
public:
|
public:
|
||||||
explicit IOAuthProcedureForNintendoAccountLinkage(Core::System& system_, Common::NewUUID)
|
explicit IOAuthProcedureForNintendoAccountLinkage(Core::System& system_, Common::UUID)
|
||||||
: ServiceFramework{system_, "IOAuthProcedureForNintendoAccountLinkage"} {
|
: ServiceFramework{system_, "IOAuthProcedureForNintendoAccountLinkage"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
@ -252,7 +252,7 @@ public:
|
|||||||
|
|
||||||
class INotifier final : public ServiceFramework<INotifier> {
|
class INotifier final : public ServiceFramework<INotifier> {
|
||||||
public:
|
public:
|
||||||
explicit INotifier(Core::System& system_, Common::NewUUID)
|
explicit INotifier(Core::System& system_, Common::UUID)
|
||||||
: ServiceFramework{system_, "INotifier"} {
|
: ServiceFramework{system_, "INotifier"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
@ -267,7 +267,7 @@ public:
|
|||||||
class IProfileCommon : public ServiceFramework<IProfileCommon> {
|
class IProfileCommon : public ServiceFramework<IProfileCommon> {
|
||||||
public:
|
public:
|
||||||
explicit IProfileCommon(Core::System& system_, const char* name, bool editor_commands,
|
explicit IProfileCommon(Core::System& system_, const char* name, bool editor_commands,
|
||||||
Common::NewUUID user_id_, ProfileManager& profile_manager_)
|
Common::UUID user_id_, ProfileManager& profile_manager_)
|
||||||
: ServiceFramework{system_, name}, profile_manager{profile_manager_}, user_id{user_id_} {
|
: ServiceFramework{system_, name}, profile_manager{profile_manager_}, user_id{user_id_} {
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, &IProfileCommon::Get, "Get"},
|
{0, &IProfileCommon::Get, "Get"},
|
||||||
@ -435,26 +435,26 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
ProfileManager& profile_manager;
|
ProfileManager& profile_manager;
|
||||||
Common::NewUUID user_id{}; ///< The user id this profile refers to.
|
Common::UUID user_id{}; ///< The user id this profile refers to.
|
||||||
};
|
};
|
||||||
|
|
||||||
class IProfile final : public IProfileCommon {
|
class IProfile final : public IProfileCommon {
|
||||||
public:
|
public:
|
||||||
explicit IProfile(Core::System& system_, Common::NewUUID user_id_,
|
explicit IProfile(Core::System& system_, Common::UUID user_id_,
|
||||||
ProfileManager& profile_manager_)
|
ProfileManager& profile_manager_)
|
||||||
: IProfileCommon{system_, "IProfile", false, user_id_, profile_manager_} {}
|
: IProfileCommon{system_, "IProfile", false, user_id_, profile_manager_} {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class IProfileEditor final : public IProfileCommon {
|
class IProfileEditor final : public IProfileCommon {
|
||||||
public:
|
public:
|
||||||
explicit IProfileEditor(Core::System& system_, Common::NewUUID user_id_,
|
explicit IProfileEditor(Core::System& system_, Common::UUID user_id_,
|
||||||
ProfileManager& profile_manager_)
|
ProfileManager& profile_manager_)
|
||||||
: IProfileCommon{system_, "IProfileEditor", true, user_id_, profile_manager_} {}
|
: IProfileCommon{system_, "IProfileEditor", true, user_id_, profile_manager_} {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ISessionObject final : public ServiceFramework<ISessionObject> {
|
class ISessionObject final : public ServiceFramework<ISessionObject> {
|
||||||
public:
|
public:
|
||||||
explicit ISessionObject(Core::System& system_, Common::NewUUID)
|
explicit ISessionObject(Core::System& system_, Common::UUID)
|
||||||
: ServiceFramework{system_, "ISessionObject"} {
|
: ServiceFramework{system_, "ISessionObject"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
@ -468,7 +468,7 @@ public:
|
|||||||
|
|
||||||
class IGuestLoginRequest final : public ServiceFramework<IGuestLoginRequest> {
|
class IGuestLoginRequest final : public ServiceFramework<IGuestLoginRequest> {
|
||||||
public:
|
public:
|
||||||
explicit IGuestLoginRequest(Core::System& system_, Common::NewUUID)
|
explicit IGuestLoginRequest(Core::System& system_, Common::UUID)
|
||||||
: ServiceFramework{system_, "IGuestLoginRequest"} {
|
: ServiceFramework{system_, "IGuestLoginRequest"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
@ -514,7 +514,7 @@ protected:
|
|||||||
|
|
||||||
class IManagerForApplication final : public ServiceFramework<IManagerForApplication> {
|
class IManagerForApplication final : public ServiceFramework<IManagerForApplication> {
|
||||||
public:
|
public:
|
||||||
explicit IManagerForApplication(Core::System& system_, Common::NewUUID user_id_)
|
explicit IManagerForApplication(Core::System& system_, Common::UUID user_id_)
|
||||||
: ServiceFramework{system_, "IManagerForApplication"},
|
: ServiceFramework{system_, "IManagerForApplication"},
|
||||||
ensure_token_id{std::make_shared<EnsureTokenIdCacheAsyncInterface>(system)},
|
ensure_token_id{std::make_shared<EnsureTokenIdCacheAsyncInterface>(system)},
|
||||||
user_id{user_id_} {
|
user_id{user_id_} {
|
||||||
@ -587,14 +587,14 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<EnsureTokenIdCacheAsyncInterface> ensure_token_id{};
|
std::shared_ptr<EnsureTokenIdCacheAsyncInterface> ensure_token_id{};
|
||||||
Common::NewUUID user_id{};
|
Common::UUID user_id{};
|
||||||
};
|
};
|
||||||
|
|
||||||
// 6.0.0+
|
// 6.0.0+
|
||||||
class IAsyncNetworkServiceLicenseKindContext final
|
class IAsyncNetworkServiceLicenseKindContext final
|
||||||
: public ServiceFramework<IAsyncNetworkServiceLicenseKindContext> {
|
: public ServiceFramework<IAsyncNetworkServiceLicenseKindContext> {
|
||||||
public:
|
public:
|
||||||
explicit IAsyncNetworkServiceLicenseKindContext(Core::System& system_, Common::NewUUID)
|
explicit IAsyncNetworkServiceLicenseKindContext(Core::System& system_, Common::UUID)
|
||||||
: ServiceFramework{system_, "IAsyncNetworkServiceLicenseKindContext"} {
|
: ServiceFramework{system_, "IAsyncNetworkServiceLicenseKindContext"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
@ -614,7 +614,7 @@ public:
|
|||||||
class IOAuthProcedureForUserRegistration final
|
class IOAuthProcedureForUserRegistration final
|
||||||
: public ServiceFramework<IOAuthProcedureForUserRegistration> {
|
: public ServiceFramework<IOAuthProcedureForUserRegistration> {
|
||||||
public:
|
public:
|
||||||
explicit IOAuthProcedureForUserRegistration(Core::System& system_, Common::NewUUID)
|
explicit IOAuthProcedureForUserRegistration(Core::System& system_, Common::UUID)
|
||||||
: ServiceFramework{system_, "IOAuthProcedureForUserRegistration"} {
|
: ServiceFramework{system_, "IOAuthProcedureForUserRegistration"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
@ -638,8 +638,7 @@ public:
|
|||||||
|
|
||||||
class DAUTH_O final : public ServiceFramework<DAUTH_O> {
|
class DAUTH_O final : public ServiceFramework<DAUTH_O> {
|
||||||
public:
|
public:
|
||||||
explicit DAUTH_O(Core::System& system_, Common::NewUUID)
|
explicit DAUTH_O(Core::System& system_, Common::UUID) : ServiceFramework{system_, "dauth:o"} {
|
||||||
: ServiceFramework{system_, "dauth:o"} {
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, nullptr, "EnsureAuthenticationTokenCacheAsync"},
|
{0, nullptr, "EnsureAuthenticationTokenCacheAsync"},
|
||||||
@ -663,7 +662,7 @@ public:
|
|||||||
// 6.0.0+
|
// 6.0.0+
|
||||||
class IAsyncResult final : public ServiceFramework<IAsyncResult> {
|
class IAsyncResult final : public ServiceFramework<IAsyncResult> {
|
||||||
public:
|
public:
|
||||||
explicit IAsyncResult(Core::System& system_, Common::NewUUID)
|
explicit IAsyncResult(Core::System& system_, Common::UUID)
|
||||||
: ServiceFramework{system_, "IAsyncResult"} {
|
: ServiceFramework{system_, "IAsyncResult"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
@ -687,7 +686,7 @@ void Module::Interface::GetUserCount(Kernel::HLERequestContext& ctx) {
|
|||||||
|
|
||||||
void Module::Interface::GetUserExistence(Kernel::HLERequestContext& ctx) {
|
void Module::Interface::GetUserExistence(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
Common::NewUUID user_id = rp.PopRaw<Common::NewUUID>();
|
Common::UUID user_id = rp.PopRaw<Common::UUID>();
|
||||||
LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.RawString());
|
LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.RawString());
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
@ -713,12 +712,12 @@ void Module::Interface::GetLastOpenedUser(Kernel::HLERequestContext& ctx) {
|
|||||||
LOG_DEBUG(Service_ACC, "called");
|
LOG_DEBUG(Service_ACC, "called");
|
||||||
IPC::ResponseBuilder rb{ctx, 6};
|
IPC::ResponseBuilder rb{ctx, 6};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
rb.PushRaw<Common::NewUUID>(profile_manager->GetLastOpenedUser());
|
rb.PushRaw<Common::UUID>(profile_manager->GetLastOpenedUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::Interface::GetProfile(Kernel::HLERequestContext& ctx) {
|
void Module::Interface::GetProfile(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
Common::NewUUID user_id = rp.PopRaw<Common::NewUUID>();
|
Common::UUID user_id = rp.PopRaw<Common::UUID>();
|
||||||
LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.RawString());
|
LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.RawString());
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||||
@ -832,7 +831,7 @@ void Module::Interface::InitializeApplicationInfoV2(Kernel::HLERequestContext& c
|
|||||||
|
|
||||||
void Module::Interface::GetProfileEditor(Kernel::HLERequestContext& ctx) {
|
void Module::Interface::GetProfileEditor(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
Common::NewUUID user_id = rp.PopRaw<Common::NewUUID>();
|
Common::UUID user_id = rp.PopRaw<Common::UUID>();
|
||||||
|
|
||||||
LOG_DEBUG(Service_ACC, "called, user_id=0x{}", user_id.RawString());
|
LOG_DEBUG(Service_ACC, "called, user_id=0x{}", user_id.RawString());
|
||||||
|
|
||||||
@ -874,7 +873,7 @@ void Module::Interface::ListOpenContextStoredUsers(Kernel::HLERequestContext& ct
|
|||||||
|
|
||||||
void Module::Interface::StoreSaveDataThumbnailApplication(Kernel::HLERequestContext& ctx) {
|
void Module::Interface::StoreSaveDataThumbnailApplication(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
const auto uuid = rp.PopRaw<Common::NewUUID>();
|
const auto uuid = rp.PopRaw<Common::UUID>();
|
||||||
|
|
||||||
LOG_WARNING(Service_ACC, "(STUBBED) called, uuid=0x{}", uuid.RawString());
|
LOG_WARNING(Service_ACC, "(STUBBED) called, uuid=0x{}", uuid.RawString());
|
||||||
|
|
||||||
@ -887,7 +886,7 @@ void Module::Interface::StoreSaveDataThumbnailApplication(Kernel::HLERequestCont
|
|||||||
|
|
||||||
void Module::Interface::StoreSaveDataThumbnailSystem(Kernel::HLERequestContext& ctx) {
|
void Module::Interface::StoreSaveDataThumbnailSystem(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
const auto uuid = rp.PopRaw<Common::NewUUID>();
|
const auto uuid = rp.PopRaw<Common::UUID>();
|
||||||
const auto tid = rp.Pop<u64_le>();
|
const auto tid = rp.Pop<u64_le>();
|
||||||
|
|
||||||
LOG_WARNING(Service_ACC, "(STUBBED) called, uuid=0x{}, tid={:016X}", uuid.RawString(), tid);
|
LOG_WARNING(Service_ACC, "(STUBBED) called, uuid=0x{}, tid={:016X}", uuid.RawString(), tid);
|
||||||
@ -895,7 +894,7 @@ void Module::Interface::StoreSaveDataThumbnailSystem(Kernel::HLERequestContext&
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Module::Interface::StoreSaveDataThumbnail(Kernel::HLERequestContext& ctx,
|
void Module::Interface::StoreSaveDataThumbnail(Kernel::HLERequestContext& ctx,
|
||||||
const Common::NewUUID& uuid, const u64 tid) {
|
const Common::UUID& uuid, const u64 tid) {
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
|
||||||
if (tid == 0) {
|
if (tid == 0) {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/new_uuid.h"
|
#include "common/uuid.h"
|
||||||
#include "core/hle/service/glue/glue_manager.h"
|
#include "core/hle/service/glue/glue_manager.h"
|
||||||
#include "core/hle/service/service.h"
|
#include "core/hle/service/service.h"
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
ResultCode InitializeApplicationInfoBase();
|
ResultCode InitializeApplicationInfoBase();
|
||||||
void StoreSaveDataThumbnail(Kernel::HLERequestContext& ctx, const Common::NewUUID& uuid,
|
void StoreSaveDataThumbnail(Kernel::HLERequestContext& ctx, const Common::UUID& uuid,
|
||||||
const u64 tid);
|
const u64 tid);
|
||||||
|
|
||||||
enum class ApplicationType : u32_le {
|
enum class ApplicationType : u32_le {
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
namespace Service::Account {
|
namespace Service::Account {
|
||||||
|
|
||||||
namespace FS = Common::FS;
|
namespace FS = Common::FS;
|
||||||
using Common::NewUUID;
|
using Common::UUID;
|
||||||
|
|
||||||
struct UserRaw {
|
struct UserRaw {
|
||||||
NewUUID uuid{};
|
UUID uuid{};
|
||||||
NewUUID uuid2{};
|
UUID uuid2{};
|
||||||
u64 timestamp{};
|
u64 timestamp{};
|
||||||
ProfileUsername username{};
|
ProfileUsername username{};
|
||||||
ProfileData extra_data{};
|
ProfileData extra_data{};
|
||||||
@ -45,7 +45,7 @@ ProfileManager::ProfileManager() {
|
|||||||
|
|
||||||
// Create an user if none are present
|
// Create an user if none are present
|
||||||
if (user_count == 0) {
|
if (user_count == 0) {
|
||||||
CreateNewUser(NewUUID::MakeRandom(), "yuzu");
|
CreateNewUser(UUID::MakeRandom(), "yuzu");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto current =
|
auto current =
|
||||||
@ -97,7 +97,7 @@ ResultCode ProfileManager::AddUser(const ProfileInfo& user) {
|
|||||||
|
|
||||||
/// Create a new user on the system. If the uuid of the user already exists, the user is not
|
/// Create a new user on the system. If the uuid of the user already exists, the user is not
|
||||||
/// created.
|
/// created.
|
||||||
ResultCode ProfileManager::CreateNewUser(NewUUID uuid, const ProfileUsername& username) {
|
ResultCode ProfileManager::CreateNewUser(UUID uuid, const ProfileUsername& username) {
|
||||||
if (user_count == MAX_USERS) {
|
if (user_count == MAX_USERS) {
|
||||||
return ERROR_TOO_MANY_USERS;
|
return ERROR_TOO_MANY_USERS;
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ ResultCode ProfileManager::CreateNewUser(NewUUID uuid, const ProfileUsername& us
|
|||||||
/// Creates a new user on the system. This function allows a much simpler method of registration
|
/// Creates a new user on the system. This function allows a much simpler method of registration
|
||||||
/// specifically by allowing an std::string for the username. This is required specifically since
|
/// specifically by allowing an std::string for the username. This is required specifically since
|
||||||
/// we're loading a string straight from the config
|
/// we're loading a string straight from the config
|
||||||
ResultCode ProfileManager::CreateNewUser(NewUUID uuid, const std::string& username) {
|
ResultCode ProfileManager::CreateNewUser(UUID uuid, const std::string& username) {
|
||||||
ProfileUsername username_output{};
|
ProfileUsername username_output{};
|
||||||
|
|
||||||
if (username.size() > username_output.size()) {
|
if (username.size() > username_output.size()) {
|
||||||
@ -135,7 +135,7 @@ ResultCode ProfileManager::CreateNewUser(NewUUID uuid, const std::string& userna
|
|||||||
return CreateNewUser(uuid, username_output);
|
return CreateNewUser(uuid, username_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<NewUUID> ProfileManager::GetUser(std::size_t index) const {
|
std::optional<UUID> ProfileManager::GetUser(std::size_t index) const {
|
||||||
if (index >= MAX_USERS) {
|
if (index >= MAX_USERS) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
@ -144,7 +144,7 @@ std::optional<NewUUID> ProfileManager::GetUser(std::size_t index) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a users profile index based on their user id.
|
/// Returns a users profile index based on their user id.
|
||||||
std::optional<std::size_t> ProfileManager::GetUserIndex(const NewUUID& uuid) const {
|
std::optional<std::size_t> ProfileManager::GetUserIndex(const UUID& uuid) const {
|
||||||
if (uuid.IsInvalid()) {
|
if (uuid.IsInvalid()) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
@ -176,7 +176,7 @@ bool ProfileManager::GetProfileBase(std::optional<std::size_t> index, ProfileBas
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the data structure used by the switch when GetProfileBase is called on acc:*
|
/// Returns the data structure used by the switch when GetProfileBase is called on acc:*
|
||||||
bool ProfileManager::GetProfileBase(NewUUID uuid, ProfileBase& profile) const {
|
bool ProfileManager::GetProfileBase(UUID uuid, ProfileBase& profile) const {
|
||||||
const auto idx = GetUserIndex(uuid);
|
const auto idx = GetUserIndex(uuid);
|
||||||
return GetProfileBase(idx, profile);
|
return GetProfileBase(idx, profile);
|
||||||
}
|
}
|
||||||
@ -203,7 +203,7 @@ std::size_t ProfileManager::GetOpenUserCount() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if a user id exists in our profile manager
|
/// Checks if a user id exists in our profile manager
|
||||||
bool ProfileManager::UserExists(NewUUID uuid) const {
|
bool ProfileManager::UserExists(UUID uuid) const {
|
||||||
return GetUserIndex(uuid).has_value();
|
return GetUserIndex(uuid).has_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ bool ProfileManager::UserExistsIndex(std::size_t index) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Opens a specific user
|
/// Opens a specific user
|
||||||
void ProfileManager::OpenUser(NewUUID uuid) {
|
void ProfileManager::OpenUser(UUID uuid) {
|
||||||
const auto idx = GetUserIndex(uuid);
|
const auto idx = GetUserIndex(uuid);
|
||||||
if (!idx) {
|
if (!idx) {
|
||||||
return;
|
return;
|
||||||
@ -226,7 +226,7 @@ void ProfileManager::OpenUser(NewUUID uuid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Closes a specific user
|
/// Closes a specific user
|
||||||
void ProfileManager::CloseUser(NewUUID uuid) {
|
void ProfileManager::CloseUser(UUID uuid) {
|
||||||
const auto idx = GetUserIndex(uuid);
|
const auto idx = GetUserIndex(uuid);
|
||||||
if (!idx) {
|
if (!idx) {
|
||||||
return;
|
return;
|
||||||
@ -253,12 +253,12 @@ UserIDArray ProfileManager::GetOpenUsers() const {
|
|||||||
return Common::InvalidUUID;
|
return Common::InvalidUUID;
|
||||||
});
|
});
|
||||||
std::stable_partition(output.begin(), output.end(),
|
std::stable_partition(output.begin(), output.end(),
|
||||||
[](const NewUUID& uuid) { return uuid.IsValid(); });
|
[](const UUID& uuid) { return uuid.IsValid(); });
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the last user which was opened
|
/// Returns the last user which was opened
|
||||||
NewUUID ProfileManager::GetLastOpenedUser() const {
|
UUID ProfileManager::GetLastOpenedUser() const {
|
||||||
return last_opened_user;
|
return last_opened_user;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,7 +273,7 @@ bool ProfileManager::GetProfileBaseAndData(std::optional<std::size_t> index, Pro
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Return the users profile base and the unknown arbitary data.
|
/// Return the users profile base and the unknown arbitary data.
|
||||||
bool ProfileManager::GetProfileBaseAndData(NewUUID uuid, ProfileBase& profile,
|
bool ProfileManager::GetProfileBaseAndData(UUID uuid, ProfileBase& profile,
|
||||||
ProfileData& data) const {
|
ProfileData& data) const {
|
||||||
const auto idx = GetUserIndex(uuid);
|
const auto idx = GetUserIndex(uuid);
|
||||||
return GetProfileBaseAndData(idx, profile, data);
|
return GetProfileBaseAndData(idx, profile, data);
|
||||||
@ -292,7 +292,7 @@ bool ProfileManager::CanSystemRegisterUser() const {
|
|||||||
// emulate qlaunch. Update this to dynamically change.
|
// emulate qlaunch. Update this to dynamically change.
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProfileManager::RemoveUser(NewUUID uuid) {
|
bool ProfileManager::RemoveUser(UUID uuid) {
|
||||||
const auto index = GetUserIndex(uuid);
|
const auto index = GetUserIndex(uuid);
|
||||||
if (!index) {
|
if (!index) {
|
||||||
return false;
|
return false;
|
||||||
@ -304,7 +304,7 @@ bool ProfileManager::RemoveUser(NewUUID uuid) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProfileManager::SetProfileBase(NewUUID uuid, const ProfileBase& profile_new) {
|
bool ProfileManager::SetProfileBase(UUID uuid, const ProfileBase& profile_new) {
|
||||||
const auto index = GetUserIndex(uuid);
|
const auto index = GetUserIndex(uuid);
|
||||||
if (!index || profile_new.user_uuid.IsInvalid()) {
|
if (!index || profile_new.user_uuid.IsInvalid()) {
|
||||||
return false;
|
return false;
|
||||||
@ -318,7 +318,7 @@ bool ProfileManager::SetProfileBase(NewUUID uuid, const ProfileBase& profile_new
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProfileManager::SetProfileBaseAndData(Common::NewUUID uuid, const ProfileBase& profile_new,
|
bool ProfileManager::SetProfileBaseAndData(Common::UUID uuid, const ProfileBase& profile_new,
|
||||||
const ProfileData& data_new) {
|
const ProfileData& data_new) {
|
||||||
const auto index = GetUserIndex(uuid);
|
const auto index = GetUserIndex(uuid);
|
||||||
if (index.has_value() && SetProfileBase(uuid, profile_new)) {
|
if (index.has_value() && SetProfileBase(uuid, profile_new)) {
|
||||||
@ -336,14 +336,14 @@ void ProfileManager::ParseUserSaveFile() {
|
|||||||
|
|
||||||
if (!save.IsOpen()) {
|
if (!save.IsOpen()) {
|
||||||
LOG_WARNING(Service_ACC, "Failed to load profile data from save data... Generating new "
|
LOG_WARNING(Service_ACC, "Failed to load profile data from save data... Generating new "
|
||||||
"user 'yuzu' with random NewUUID.");
|
"user 'yuzu' with random UUID.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileDataRaw data;
|
ProfileDataRaw data;
|
||||||
if (!save.ReadObject(data)) {
|
if (!save.ReadObject(data)) {
|
||||||
LOG_WARNING(Service_ACC, "profiles.dat is smaller than expected... Generating new user "
|
LOG_WARNING(Service_ACC, "profiles.dat is smaller than expected... Generating new user "
|
||||||
"'yuzu' with random NewUUID.");
|
"'yuzu' with random UUID.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,8 +8,8 @@
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/new_uuid.h"
|
|
||||||
#include "common/swap.h"
|
#include "common/swap.h"
|
||||||
|
#include "common/uuid.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
|
|
||||||
namespace Service::Account {
|
namespace Service::Account {
|
||||||
@ -18,7 +18,7 @@ constexpr std::size_t MAX_USERS{8};
|
|||||||
constexpr std::size_t profile_username_size{32};
|
constexpr std::size_t profile_username_size{32};
|
||||||
|
|
||||||
using ProfileUsername = std::array<u8, profile_username_size>;
|
using ProfileUsername = std::array<u8, profile_username_size>;
|
||||||
using UserIDArray = std::array<Common::NewUUID, MAX_USERS>;
|
using UserIDArray = std::array<Common::UUID, MAX_USERS>;
|
||||||
|
|
||||||
/// Contains extra data related to a user.
|
/// Contains extra data related to a user.
|
||||||
/// TODO: RE this structure
|
/// TODO: RE this structure
|
||||||
@ -35,7 +35,7 @@ static_assert(sizeof(ProfileData) == 0x80, "ProfileData structure has incorrect
|
|||||||
/// This holds general information about a users profile. This is where we store all the information
|
/// This holds general information about a users profile. This is where we store all the information
|
||||||
/// based on a specific user
|
/// based on a specific user
|
||||||
struct ProfileInfo {
|
struct ProfileInfo {
|
||||||
Common::NewUUID user_uuid{};
|
Common::UUID user_uuid{};
|
||||||
ProfileUsername username{};
|
ProfileUsername username{};
|
||||||
u64 creation_time{};
|
u64 creation_time{};
|
||||||
ProfileData data{}; // TODO(ognik): Work out what this is
|
ProfileData data{}; // TODO(ognik): Work out what this is
|
||||||
@ -43,7 +43,7 @@ struct ProfileInfo {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct ProfileBase {
|
struct ProfileBase {
|
||||||
Common::NewUUID user_uuid;
|
Common::UUID user_uuid;
|
||||||
u64_le timestamp;
|
u64_le timestamp;
|
||||||
ProfileUsername username;
|
ProfileUsername username;
|
||||||
|
|
||||||
@ -65,34 +65,34 @@ public:
|
|||||||
~ProfileManager();
|
~ProfileManager();
|
||||||
|
|
||||||
ResultCode AddUser(const ProfileInfo& user);
|
ResultCode AddUser(const ProfileInfo& user);
|
||||||
ResultCode CreateNewUser(Common::NewUUID uuid, const ProfileUsername& username);
|
ResultCode CreateNewUser(Common::UUID uuid, const ProfileUsername& username);
|
||||||
ResultCode CreateNewUser(Common::NewUUID uuid, const std::string& username);
|
ResultCode CreateNewUser(Common::UUID uuid, const std::string& username);
|
||||||
std::optional<Common::NewUUID> GetUser(std::size_t index) const;
|
std::optional<Common::UUID> GetUser(std::size_t index) const;
|
||||||
std::optional<std::size_t> GetUserIndex(const Common::NewUUID& uuid) const;
|
std::optional<std::size_t> GetUserIndex(const Common::UUID& uuid) const;
|
||||||
std::optional<std::size_t> GetUserIndex(const ProfileInfo& user) const;
|
std::optional<std::size_t> GetUserIndex(const ProfileInfo& user) const;
|
||||||
bool GetProfileBase(std::optional<std::size_t> index, ProfileBase& profile) const;
|
bool GetProfileBase(std::optional<std::size_t> index, ProfileBase& profile) const;
|
||||||
bool GetProfileBase(Common::NewUUID uuid, ProfileBase& profile) const;
|
bool GetProfileBase(Common::UUID uuid, ProfileBase& profile) const;
|
||||||
bool GetProfileBase(const ProfileInfo& user, ProfileBase& profile) const;
|
bool GetProfileBase(const ProfileInfo& user, ProfileBase& profile) const;
|
||||||
bool GetProfileBaseAndData(std::optional<std::size_t> index, ProfileBase& profile,
|
bool GetProfileBaseAndData(std::optional<std::size_t> index, ProfileBase& profile,
|
||||||
ProfileData& data) const;
|
ProfileData& data) const;
|
||||||
bool GetProfileBaseAndData(Common::NewUUID uuid, ProfileBase& profile, ProfileData& data) const;
|
bool GetProfileBaseAndData(Common::UUID uuid, ProfileBase& profile, ProfileData& data) const;
|
||||||
bool GetProfileBaseAndData(const ProfileInfo& user, ProfileBase& profile,
|
bool GetProfileBaseAndData(const ProfileInfo& user, ProfileBase& profile,
|
||||||
ProfileData& data) const;
|
ProfileData& data) const;
|
||||||
std::size_t GetUserCount() const;
|
std::size_t GetUserCount() const;
|
||||||
std::size_t GetOpenUserCount() const;
|
std::size_t GetOpenUserCount() const;
|
||||||
bool UserExists(Common::NewUUID uuid) const;
|
bool UserExists(Common::UUID uuid) const;
|
||||||
bool UserExistsIndex(std::size_t index) const;
|
bool UserExistsIndex(std::size_t index) const;
|
||||||
void OpenUser(Common::NewUUID uuid);
|
void OpenUser(Common::UUID uuid);
|
||||||
void CloseUser(Common::NewUUID uuid);
|
void CloseUser(Common::UUID uuid);
|
||||||
UserIDArray GetOpenUsers() const;
|
UserIDArray GetOpenUsers() const;
|
||||||
UserIDArray GetAllUsers() const;
|
UserIDArray GetAllUsers() const;
|
||||||
Common::NewUUID GetLastOpenedUser() const;
|
Common::UUID GetLastOpenedUser() const;
|
||||||
|
|
||||||
bool CanSystemRegisterUser() const;
|
bool CanSystemRegisterUser() const;
|
||||||
|
|
||||||
bool RemoveUser(Common::NewUUID uuid);
|
bool RemoveUser(Common::UUID uuid);
|
||||||
bool SetProfileBase(Common::NewUUID uuid, const ProfileBase& profile_new);
|
bool SetProfileBase(Common::UUID uuid, const ProfileBase& profile_new);
|
||||||
bool SetProfileBaseAndData(Common::NewUUID uuid, const ProfileBase& profile_new,
|
bool SetProfileBaseAndData(Common::UUID uuid, const ProfileBase& profile_new,
|
||||||
const ProfileData& data_new);
|
const ProfileData& data_new);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -103,7 +103,7 @@ private:
|
|||||||
|
|
||||||
std::array<ProfileInfo, MAX_USERS> profiles{};
|
std::array<ProfileInfo, MAX_USERS> profiles{};
|
||||||
std::size_t user_count{};
|
std::size_t user_count{};
|
||||||
Common::NewUUID last_opened_user{};
|
Common::UUID last_opened_user{};
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // namespace Service::Account
|
}; // namespace Service::Account
|
||||||
|
@ -55,7 +55,7 @@ constexpr u32 LAUNCH_PARAMETER_ACCOUNT_PRESELECTED_USER_MAGIC = 0xC79497CA;
|
|||||||
struct LaunchParameterAccountPreselectedUser {
|
struct LaunchParameterAccountPreselectedUser {
|
||||||
u32_le magic;
|
u32_le magic;
|
||||||
u32_le is_account_selected;
|
u32_le is_account_selected;
|
||||||
Common::NewUUID current_user;
|
Common::UUID current_user;
|
||||||
INSERT_PADDING_BYTES(0x70);
|
INSERT_PADDING_BYTES(0x70);
|
||||||
};
|
};
|
||||||
static_assert(sizeof(LaunchParameterAccountPreselectedUser) == 0x88);
|
static_assert(sizeof(LaunchParameterAccountPreselectedUser) == 0x88);
|
||||||
|
@ -54,11 +54,10 @@ void ProfileSelect::Execute() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
frontend.SelectProfile(
|
frontend.SelectProfile([this](std::optional<Common::UUID> uuid) { SelectionComplete(uuid); });
|
||||||
[this](std::optional<Common::NewUUID> uuid) { SelectionComplete(uuid); });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileSelect::SelectionComplete(std::optional<Common::NewUUID> uuid) {
|
void ProfileSelect::SelectionComplete(std::optional<Common::UUID> uuid) {
|
||||||
UserSelectionOutput output{};
|
UserSelectionOutput output{};
|
||||||
|
|
||||||
if (uuid.has_value() && uuid->IsValid()) {
|
if (uuid.has_value() && uuid->IsValid()) {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "common/common_funcs.h"
|
#include "common/common_funcs.h"
|
||||||
#include "common/new_uuid.h"
|
#include "common/uuid.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
#include "core/hle/service/am/applets/applets.h"
|
#include "core/hle/service/am/applets/applets.h"
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ static_assert(sizeof(UserSelectionConfig) == 0xA0, "UserSelectionConfig has inco
|
|||||||
|
|
||||||
struct UserSelectionOutput {
|
struct UserSelectionOutput {
|
||||||
u64 result;
|
u64 result;
|
||||||
Common::NewUUID uuid_selected;
|
Common::UUID uuid_selected;
|
||||||
};
|
};
|
||||||
static_assert(sizeof(UserSelectionOutput) == 0x18, "UserSelectionOutput has incorrect size.");
|
static_assert(sizeof(UserSelectionOutput) == 0x18, "UserSelectionOutput has incorrect size.");
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ public:
|
|||||||
void ExecuteInteractive() override;
|
void ExecuteInteractive() override;
|
||||||
void Execute() override;
|
void Execute() override;
|
||||||
|
|
||||||
void SelectionComplete(std::optional<Common::NewUUID> uuid);
|
void SelectionComplete(std::optional<Common::UUID> uuid);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Core::Frontend::ProfileSelectApplet& frontend;
|
const Core::Frontend::ProfileSelectApplet& frontend;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/new_uuid.h"
|
#include "common/uuid.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/hle/ipc_helpers.h"
|
#include "core/hle/ipc_helpers.h"
|
||||||
#include "core/hle/kernel/k_event.h"
|
#include "core/hle/kernel/k_event.h"
|
||||||
@ -170,7 +170,7 @@ private:
|
|||||||
void GetPlayHistoryRegistrationKey(Kernel::HLERequestContext& ctx) {
|
void GetPlayHistoryRegistrationKey(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
const auto local_play = rp.Pop<bool>();
|
const auto local_play = rp.Pop<bool>();
|
||||||
const auto uuid = rp.PopRaw<Common::NewUUID>();
|
const auto uuid = rp.PopRaw<Common::UUID>();
|
||||||
|
|
||||||
LOG_WARNING(Service_Friend, "(STUBBED) called, local_play={}, uuid=0x{}", local_play,
|
LOG_WARNING(Service_Friend, "(STUBBED) called, local_play={}, uuid=0x{}", local_play,
|
||||||
uuid.RawString());
|
uuid.RawString());
|
||||||
@ -182,7 +182,7 @@ private:
|
|||||||
void GetFriendList(Kernel::HLERequestContext& ctx) {
|
void GetFriendList(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
const auto friend_offset = rp.Pop<u32>();
|
const auto friend_offset = rp.Pop<u32>();
|
||||||
const auto uuid = rp.PopRaw<Common::NewUUID>();
|
const auto uuid = rp.PopRaw<Common::UUID>();
|
||||||
[[maybe_unused]] const auto filter = rp.PopRaw<SizedFriendFilter>();
|
[[maybe_unused]] const auto filter = rp.PopRaw<SizedFriendFilter>();
|
||||||
const auto pid = rp.Pop<u64>();
|
const auto pid = rp.Pop<u64>();
|
||||||
LOG_WARNING(Service_Friend, "(STUBBED) called, offset={}, uuid=0x{}, pid={}", friend_offset,
|
LOG_WARNING(Service_Friend, "(STUBBED) called, offset={}, uuid=0x{}, pid={}", friend_offset,
|
||||||
@ -202,7 +202,7 @@ private:
|
|||||||
|
|
||||||
class INotificationService final : public ServiceFramework<INotificationService> {
|
class INotificationService final : public ServiceFramework<INotificationService> {
|
||||||
public:
|
public:
|
||||||
explicit INotificationService(Core::System& system_, Common::NewUUID uuid_)
|
explicit INotificationService(Core::System& system_, Common::UUID uuid_)
|
||||||
: ServiceFramework{system_, "INotificationService"}, uuid{uuid_},
|
: ServiceFramework{system_, "INotificationService"}, uuid{uuid_},
|
||||||
service_context{system_, "INotificationService"} {
|
service_context{system_, "INotificationService"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
@ -293,7 +293,7 @@ private:
|
|||||||
bool has_received_friend_request;
|
bool has_received_friend_request;
|
||||||
};
|
};
|
||||||
|
|
||||||
Common::NewUUID uuid;
|
Common::UUID uuid;
|
||||||
KernelHelpers::ServiceContext service_context;
|
KernelHelpers::ServiceContext service_context;
|
||||||
|
|
||||||
Kernel::KEvent* notification_event;
|
Kernel::KEvent* notification_event;
|
||||||
@ -310,7 +310,7 @@ void Module::Interface::CreateFriendService(Kernel::HLERequestContext& ctx) {
|
|||||||
|
|
||||||
void Module::Interface::CreateNotificationService(Kernel::HLERequestContext& ctx) {
|
void Module::Interface::CreateNotificationService(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
auto uuid = rp.PopRaw<Common::NewUUID>();
|
auto uuid = rp.PopRaw<Common::UUID>();
|
||||||
|
|
||||||
LOG_DEBUG(Service_Friend, "called, uuid=0x{}", uuid.RawString());
|
LOG_DEBUG(Service_Friend, "called, uuid=0x{}", uuid.RawString());
|
||||||
|
|
||||||
|
@ -131,8 +131,7 @@ T GetRandomValue(T max) {
|
|||||||
return GetRandomValue<T>({}, max);
|
return GetRandomValue<T>({}, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
MiiStoreData BuildRandomStoreData(Age age, Gender gender, Race race,
|
MiiStoreData BuildRandomStoreData(Age age, Gender gender, Race race, const Common::UUID& user_id) {
|
||||||
const Common::NewUUID& user_id) {
|
|
||||||
MiiStoreBitFields bf{};
|
MiiStoreBitFields bf{};
|
||||||
|
|
||||||
if (gender == Gender::All) {
|
if (gender == Gender::All) {
|
||||||
@ -311,7 +310,7 @@ MiiStoreData BuildRandomStoreData(Age age, Gender gender, Race race,
|
|||||||
return {DefaultMiiName, bf, user_id};
|
return {DefaultMiiName, bf, user_id};
|
||||||
}
|
}
|
||||||
|
|
||||||
MiiStoreData BuildDefaultStoreData(const DefaultMii& info, const Common::NewUUID& user_id) {
|
MiiStoreData BuildDefaultStoreData(const DefaultMii& info, const Common::UUID& user_id) {
|
||||||
MiiStoreBitFields bf{};
|
MiiStoreBitFields bf{};
|
||||||
|
|
||||||
bf.font_region.Assign(info.font_region);
|
bf.font_region.Assign(info.font_region);
|
||||||
@ -372,13 +371,13 @@ MiiStoreData BuildDefaultStoreData(const DefaultMii& info, const Common::NewUUID
|
|||||||
MiiStoreData::MiiStoreData() = default;
|
MiiStoreData::MiiStoreData() = default;
|
||||||
|
|
||||||
MiiStoreData::MiiStoreData(const MiiStoreData::Name& name, const MiiStoreBitFields& bit_fields,
|
MiiStoreData::MiiStoreData(const MiiStoreData::Name& name, const MiiStoreBitFields& bit_fields,
|
||||||
const Common::NewUUID& user_id) {
|
const Common::UUID& user_id) {
|
||||||
data.name = name;
|
data.name = name;
|
||||||
data.uuid = Common::NewUUID::MakeRandomRFC4122V4();
|
data.uuid = Common::UUID::MakeRandomRFC4122V4();
|
||||||
|
|
||||||
std::memcpy(data.data.data(), &bit_fields, sizeof(MiiStoreBitFields));
|
std::memcpy(data.data.data(), &bit_fields, sizeof(MiiStoreBitFields));
|
||||||
data_crc = GenerateCrc16(data.data.data(), sizeof(data));
|
data_crc = GenerateCrc16(data.data.data(), sizeof(data));
|
||||||
device_crc = GenerateCrc16(&user_id, sizeof(Common::NewUUID));
|
device_crc = GenerateCrc16(&user_id, sizeof(Common::UUID));
|
||||||
}
|
}
|
||||||
|
|
||||||
MiiManager::MiiManager() : user_id{Service::Account::ProfileManager().GetLastOpenedUser()} {}
|
MiiManager::MiiManager() : user_id{Service::Account::ProfileManager().GetLastOpenedUser()} {}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include "common/bit_field.h"
|
#include "common/bit_field.h"
|
||||||
#include "common/common_funcs.h"
|
#include "common/common_funcs.h"
|
||||||
#include "common/new_uuid.h"
|
#include "common/uuid.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
#include "core/hle/service/mii/types.h"
|
#include "core/hle/service/mii/types.h"
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ enum class SourceFlag : u32 {
|
|||||||
DECLARE_ENUM_FLAG_OPERATORS(SourceFlag);
|
DECLARE_ENUM_FLAG_OPERATORS(SourceFlag);
|
||||||
|
|
||||||
struct MiiInfo {
|
struct MiiInfo {
|
||||||
Common::NewUUID uuid;
|
Common::UUID uuid;
|
||||||
std::array<char16_t, 11> name;
|
std::array<char16_t, 11> name;
|
||||||
u8 font_region;
|
u8 font_region;
|
||||||
u8 favorite_color;
|
u8 favorite_color;
|
||||||
@ -192,7 +192,7 @@ struct MiiStoreData {
|
|||||||
|
|
||||||
MiiStoreData();
|
MiiStoreData();
|
||||||
MiiStoreData(const Name& name, const MiiStoreBitFields& bit_fields,
|
MiiStoreData(const Name& name, const MiiStoreBitFields& bit_fields,
|
||||||
const Common::NewUUID& user_id);
|
const Common::UUID& user_id);
|
||||||
|
|
||||||
// This corresponds to the above structure MiiStoreBitFields. I did it like this because the
|
// This corresponds to the above structure MiiStoreBitFields. I did it like this because the
|
||||||
// BitField<> type makes this (and any thing that contains it) not trivially copyable, which is
|
// BitField<> type makes this (and any thing that contains it) not trivially copyable, which is
|
||||||
@ -202,7 +202,7 @@ struct MiiStoreData {
|
|||||||
static_assert(sizeof(MiiStoreBitFields) == sizeof(data), "data field has incorrect size.");
|
static_assert(sizeof(MiiStoreBitFields) == sizeof(data), "data field has incorrect size.");
|
||||||
|
|
||||||
Name name{};
|
Name name{};
|
||||||
Common::NewUUID uuid{};
|
Common::UUID uuid{};
|
||||||
} data;
|
} data;
|
||||||
|
|
||||||
u16 data_crc{};
|
u16 data_crc{};
|
||||||
@ -326,7 +326,7 @@ public:
|
|||||||
ResultCode GetIndex(const MiiInfo& info, u32& index);
|
ResultCode GetIndex(const MiiInfo& info, u32& index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Common::NewUUID user_id{};
|
const Common::UUID user_id{};
|
||||||
u64 update_counter{};
|
u64 update_counter{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/new_uuid.h"
|
#include "common/uuid.h"
|
||||||
#include "core/hle/ipc_helpers.h"
|
#include "core/hle/ipc_helpers.h"
|
||||||
#include "core/hle/service/ns/pdm_qry.h"
|
#include "core/hle/service/ns/pdm_qry.h"
|
||||||
#include "core/hle/service/service.h"
|
#include "core/hle/service/service.h"
|
||||||
@ -49,7 +49,7 @@ void PDM_QRY::QueryPlayStatisticsByApplicationIdAndUserAccountId(Kernel::HLERequ
|
|||||||
const auto unknown = rp.Pop<bool>();
|
const auto unknown = rp.Pop<bool>();
|
||||||
rp.Pop<u8>(); // Padding
|
rp.Pop<u8>(); // Padding
|
||||||
const auto application_id = rp.Pop<u64>();
|
const auto application_id = rp.Pop<u64>();
|
||||||
const auto user_account_uid = rp.PopRaw<Common::NewUUID>();
|
const auto user_account_uid = rp.PopRaw<Common::UUID>();
|
||||||
|
|
||||||
// TODO(German77): Read statistics of the game
|
// TODO(German77): Read statistics of the game
|
||||||
PlayStatistics statistics{
|
PlayStatistics statistics{
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include "common/common_funcs.h"
|
#include "common/common_funcs.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/new_uuid.h"
|
#include "common/uuid.h"
|
||||||
#include "core/hle/service/time/errors.h"
|
#include "core/hle/service/time/errors.h"
|
||||||
#include "core/hle/service/time/time_zone_types.h"
|
#include "core/hle/service/time/time_zone_types.h"
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ enum class TimeType : u8 {
|
|||||||
/// https://switchbrew.org/wiki/Glue_services#SteadyClockTimePoint
|
/// https://switchbrew.org/wiki/Glue_services#SteadyClockTimePoint
|
||||||
struct SteadyClockTimePoint {
|
struct SteadyClockTimePoint {
|
||||||
s64 time_point;
|
s64 time_point;
|
||||||
Common::NewUUID clock_source_id;
|
Common::UUID clock_source_id;
|
||||||
|
|
||||||
ResultCode GetSpanBetween(SteadyClockTimePoint other, s64& span) const {
|
ResultCode GetSpanBetween(SteadyClockTimePoint other, s64& span) const {
|
||||||
span = 0;
|
span = 0;
|
||||||
@ -36,7 +36,7 @@ struct SteadyClockTimePoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static SteadyClockTimePoint GetRandom() {
|
static SteadyClockTimePoint GetRandom() {
|
||||||
return {0, Common::NewUUID::MakeRandom()};
|
return {0, Common::UUID::MakeRandom()};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
static_assert(sizeof(SteadyClockTimePoint) == 0x18, "SteadyClockTimePoint is incorrect size");
|
static_assert(sizeof(SteadyClockTimePoint) == 0x18, "SteadyClockTimePoint is incorrect size");
|
||||||
@ -45,7 +45,7 @@ static_assert(std::is_trivially_copyable_v<SteadyClockTimePoint>,
|
|||||||
|
|
||||||
struct SteadyClockContext {
|
struct SteadyClockContext {
|
||||||
u64 internal_offset;
|
u64 internal_offset;
|
||||||
Common::NewUUID steady_time_point;
|
Common::UUID steady_time_point;
|
||||||
};
|
};
|
||||||
static_assert(sizeof(SteadyClockContext) == 0x18, "SteadyClockContext is incorrect size");
|
static_assert(sizeof(SteadyClockContext) == 0x18, "SteadyClockContext is incorrect size");
|
||||||
static_assert(std::is_trivially_copyable_v<SteadyClockContext>,
|
static_assert(std::is_trivially_copyable_v<SteadyClockContext>,
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/new_uuid.h"
|
#include "common/uuid.h"
|
||||||
#include "core/hle/service/time/clock_types.h"
|
#include "core/hle/service/time/clock_types.h"
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
@ -18,11 +18,11 @@ public:
|
|||||||
SteadyClockCore() = default;
|
SteadyClockCore() = default;
|
||||||
virtual ~SteadyClockCore() = default;
|
virtual ~SteadyClockCore() = default;
|
||||||
|
|
||||||
const Common::NewUUID& GetClockSourceId() const {
|
const Common::UUID& GetClockSourceId() const {
|
||||||
return clock_source_id;
|
return clock_source_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetClockSourceId(const Common::NewUUID& value) {
|
void SetClockSourceId(const Common::UUID& value) {
|
||||||
clock_source_id = value;
|
clock_source_id = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Common::NewUUID clock_source_id{Common::NewUUID::MakeRandom()};
|
Common::UUID clock_source_id{Common::UUID::MakeRandom()};
|
||||||
bool is_initialized{};
|
bool is_initialized{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ struct TimeManager::Impl final {
|
|||||||
time_zone_content_manager{system} {
|
time_zone_content_manager{system} {
|
||||||
|
|
||||||
const auto system_time{Clock::TimeSpanType::FromSeconds(GetExternalRtcValue())};
|
const auto system_time{Clock::TimeSpanType::FromSeconds(GetExternalRtcValue())};
|
||||||
SetupStandardSteadyClock(system, Common::NewUUID::MakeRandom(), system_time, {}, {});
|
SetupStandardSteadyClock(system, Common::UUID::MakeRandom(), system_time, {}, {});
|
||||||
SetupStandardLocalSystemClock(system, {}, system_time.ToSeconds());
|
SetupStandardLocalSystemClock(system, {}, system_time.ToSeconds());
|
||||||
|
|
||||||
Clock::SystemClockContext clock_context{};
|
Clock::SystemClockContext clock_context{};
|
||||||
@ -132,7 +132,7 @@ struct TimeManager::Impl final {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupStandardSteadyClock(Core::System& system_, Common::NewUUID clock_source_id,
|
void SetupStandardSteadyClock(Core::System& system_, Common::UUID clock_source_id,
|
||||||
Clock::TimeSpanType setup_value,
|
Clock::TimeSpanType setup_value,
|
||||||
Clock::TimeSpanType internal_offset, bool is_rtc_reset_detected) {
|
Clock::TimeSpanType internal_offset, bool is_rtc_reset_detected) {
|
||||||
standard_steady_clock_core.SetClockSourceId(clock_source_id);
|
standard_steady_clock_core.SetClockSourceId(clock_source_id);
|
||||||
|
@ -20,7 +20,7 @@ SharedMemory::SharedMemory(Core::System& system_) : system(system_) {
|
|||||||
|
|
||||||
SharedMemory::~SharedMemory() = default;
|
SharedMemory::~SharedMemory() = default;
|
||||||
|
|
||||||
void SharedMemory::SetupStandardSteadyClock(const Common::NewUUID& clock_source_id,
|
void SharedMemory::SetupStandardSteadyClock(const Common::UUID& clock_source_id,
|
||||||
Clock::TimeSpanType current_time_point) {
|
Clock::TimeSpanType current_time_point) {
|
||||||
const Clock::TimeSpanType ticks_time_span{Clock::TimeSpanType::FromTicks(
|
const Clock::TimeSpanType ticks_time_span{Clock::TimeSpanType::FromTicks(
|
||||||
system.CoreTiming().GetClockTicks(), Core::Hardware::CNTFREQ)};
|
system.CoreTiming().GetClockTicks(), Core::Hardware::CNTFREQ)};
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/new_uuid.h"
|
#include "common/uuid.h"
|
||||||
#include "core/hle/kernel/k_shared_memory.h"
|
#include "core/hle/kernel/k_shared_memory.h"
|
||||||
#include "core/hle/service/time/clock_types.h"
|
#include "core/hle/service/time/clock_types.h"
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ public:
|
|||||||
};
|
};
|
||||||
static_assert(sizeof(Format) == 0xd8, "Format is an invalid size");
|
static_assert(sizeof(Format) == 0xd8, "Format is an invalid size");
|
||||||
|
|
||||||
void SetupStandardSteadyClock(const Common::NewUUID& clock_source_id,
|
void SetupStandardSteadyClock(const Common::UUID& clock_source_id,
|
||||||
Clock::TimeSpanType current_time_point);
|
Clock::TimeSpanType current_time_point);
|
||||||
void UpdateLocalSystemClockContext(const Clock::SystemClockContext& context);
|
void UpdateLocalSystemClockContext(const Clock::SystemClockContext& context);
|
||||||
void UpdateNetworkSystemClockContext(const Clock::SystemClockContext& context);
|
void UpdateNetworkSystemClockContext(const Clock::SystemClockContext& context);
|
||||||
|
@ -248,7 +248,7 @@ bool GCAdapter::Setup() {
|
|||||||
std::size_t port = 0;
|
std::size_t port = 0;
|
||||||
for (GCController& pad : pads) {
|
for (GCController& pad : pads) {
|
||||||
pad.identifier = {
|
pad.identifier = {
|
||||||
.guid = Common::NewUUID{},
|
.guid = Common::UUID{},
|
||||||
.port = port++,
|
.port = port++,
|
||||||
.pad = 0,
|
.pad = 0,
|
||||||
};
|
};
|
||||||
|
@ -9,17 +9,17 @@
|
|||||||
namespace InputCommon {
|
namespace InputCommon {
|
||||||
|
|
||||||
constexpr PadIdentifier key_identifier = {
|
constexpr PadIdentifier key_identifier = {
|
||||||
.guid = Common::NewUUID{},
|
.guid = Common::UUID{},
|
||||||
.port = 0,
|
.port = 0,
|
||||||
.pad = 0,
|
.pad = 0,
|
||||||
};
|
};
|
||||||
constexpr PadIdentifier keyboard_key_identifier = {
|
constexpr PadIdentifier keyboard_key_identifier = {
|
||||||
.guid = Common::NewUUID{},
|
.guid = Common::UUID{},
|
||||||
.port = 1,
|
.port = 1,
|
||||||
.pad = 0,
|
.pad = 0,
|
||||||
};
|
};
|
||||||
constexpr PadIdentifier keyboard_modifier_identifier = {
|
constexpr PadIdentifier keyboard_modifier_identifier = {
|
||||||
.guid = Common::NewUUID{},
|
.guid = Common::UUID{},
|
||||||
.port = 1,
|
.port = 1,
|
||||||
.pad = 1,
|
.pad = 1,
|
||||||
};
|
};
|
||||||
|
@ -20,7 +20,7 @@ constexpr int motion_wheel_y = 4;
|
|||||||
constexpr int touch_axis_x = 10;
|
constexpr int touch_axis_x = 10;
|
||||||
constexpr int touch_axis_y = 11;
|
constexpr int touch_axis_y = 11;
|
||||||
constexpr PadIdentifier identifier = {
|
constexpr PadIdentifier identifier = {
|
||||||
.guid = Common::NewUUID{},
|
.guid = Common::UUID{},
|
||||||
.port = 0,
|
.port = 0,
|
||||||
.pad = 0,
|
.pad = 0,
|
||||||
};
|
};
|
||||||
|
@ -120,7 +120,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
const PadIdentifier GetPadIdentifier() const {
|
const PadIdentifier GetPadIdentifier() const {
|
||||||
return {
|
return {
|
||||||
.guid = Common::NewUUID{guid},
|
.guid = Common::UUID{guid},
|
||||||
.port = static_cast<std::size_t>(port),
|
.port = static_cast<std::size_t>(port),
|
||||||
.pad = 0,
|
.pad = 0,
|
||||||
};
|
};
|
||||||
|
@ -50,7 +50,7 @@ constexpr std::array<std::pair<std::string_view, TasButton>, 18> text_to_tas_but
|
|||||||
Tas::Tas(std::string input_engine_) : InputEngine(std::move(input_engine_)) {
|
Tas::Tas(std::string input_engine_) : InputEngine(std::move(input_engine_)) {
|
||||||
for (size_t player_index = 0; player_index < PLAYER_NUMBER; player_index++) {
|
for (size_t player_index = 0; player_index < PLAYER_NUMBER; player_index++) {
|
||||||
PadIdentifier identifier{
|
PadIdentifier identifier{
|
||||||
.guid = Common::NewUUID{},
|
.guid = Common::UUID{},
|
||||||
.port = player_index,
|
.port = player_index,
|
||||||
.pad = 0,
|
.pad = 0,
|
||||||
};
|
};
|
||||||
@ -203,7 +203,7 @@ void Tas::UpdateThread() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PadIdentifier identifier{
|
PadIdentifier identifier{
|
||||||
.guid = Common::NewUUID{},
|
.guid = Common::UUID{},
|
||||||
.port = player_index,
|
.port = player_index,
|
||||||
.pad = 0,
|
.pad = 0,
|
||||||
};
|
};
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
namespace InputCommon {
|
namespace InputCommon {
|
||||||
|
|
||||||
constexpr PadIdentifier identifier = {
|
constexpr PadIdentifier identifier = {
|
||||||
.guid = Common::NewUUID{},
|
.guid = Common::UUID{},
|
||||||
.port = 0,
|
.port = 0,
|
||||||
.pad = 0,
|
.pad = 0,
|
||||||
};
|
};
|
||||||
|
@ -351,10 +351,10 @@ PadIdentifier UDPClient::GetPadIdentifier(std::size_t pad_index) const {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::NewUUID UDPClient::GetHostUUID(const std::string& host) const {
|
Common::UUID UDPClient::GetHostUUID(const std::string& host) const {
|
||||||
const auto ip = boost::asio::ip::make_address_v4(host);
|
const auto ip = boost::asio::ip::make_address_v4(host);
|
||||||
const auto hex_host = fmt::format("00000000-0000-0000-0000-0000{:06x}", ip.to_uint());
|
const auto hex_host = fmt::format("00000000-0000-0000-0000-0000{:06x}", ip.to_uint());
|
||||||
return Common::NewUUID{hex_host};
|
return Common::UUID{hex_host};
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDPClient::Reset() {
|
void UDPClient::Reset() {
|
||||||
|
@ -126,7 +126,7 @@ private:
|
|||||||
struct ClientConnection {
|
struct ClientConnection {
|
||||||
ClientConnection();
|
ClientConnection();
|
||||||
~ClientConnection();
|
~ClientConnection();
|
||||||
Common::NewUUID uuid{"00000000-0000-0000-0000-00007F000001"};
|
Common::UUID uuid{"00000000-0000-0000-0000-00007F000001"};
|
||||||
std::string host{"127.0.0.1"};
|
std::string host{"127.0.0.1"};
|
||||||
u16 port{26760};
|
u16 port{26760};
|
||||||
s8 active{-1};
|
s8 active{-1};
|
||||||
@ -148,7 +148,7 @@ private:
|
|||||||
void OnPadData(Response::PadData, std::size_t client);
|
void OnPadData(Response::PadData, std::size_t client);
|
||||||
void StartCommunication(std::size_t client, const std::string& host, u16 port);
|
void StartCommunication(std::size_t client, const std::string& host, u16 port);
|
||||||
PadIdentifier GetPadIdentifier(std::size_t pad_index) const;
|
PadIdentifier GetPadIdentifier(std::size_t pad_index) const;
|
||||||
Common::NewUUID GetHostUUID(const std::string& host) const;
|
Common::UUID GetHostUUID(const std::string& host) const;
|
||||||
|
|
||||||
Common::Input::ButtonNames GetUIButtonName(const Common::ParamPackage& params) const;
|
Common::Input::ButtonNames GetUIButtonName(const Common::ParamPackage& params) const;
|
||||||
|
|
||||||
|
@ -10,13 +10,13 @@
|
|||||||
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/input.h"
|
#include "common/input.h"
|
||||||
#include "common/new_uuid.h"
|
|
||||||
#include "common/param_package.h"
|
#include "common/param_package.h"
|
||||||
|
#include "common/uuid.h"
|
||||||
#include "input_common/main.h"
|
#include "input_common/main.h"
|
||||||
|
|
||||||
// Pad Identifier of data source
|
// Pad Identifier of data source
|
||||||
struct PadIdentifier {
|
struct PadIdentifier {
|
||||||
Common::NewUUID guid{};
|
Common::UUID guid{};
|
||||||
std::size_t port{};
|
std::size_t port{};
|
||||||
std::size_t pad{};
|
std::size_t pad{};
|
||||||
|
|
||||||
|
@ -691,7 +691,7 @@ private:
|
|||||||
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateButtonDevice(
|
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateButtonDevice(
|
||||||
const Common::ParamPackage& params) {
|
const Common::ParamPackage& params) {
|
||||||
const PadIdentifier identifier = {
|
const PadIdentifier identifier = {
|
||||||
.guid = Common::NewUUID{params.Get("guid", "")},
|
.guid = Common::UUID{params.Get("guid", "")},
|
||||||
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
||||||
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
||||||
};
|
};
|
||||||
@ -714,7 +714,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateButtonDevice(
|
|||||||
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateHatButtonDevice(
|
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateHatButtonDevice(
|
||||||
const Common::ParamPackage& params) {
|
const Common::ParamPackage& params) {
|
||||||
const PadIdentifier identifier = {
|
const PadIdentifier identifier = {
|
||||||
.guid = Common::NewUUID{params.Get("guid", "")},
|
.guid = Common::UUID{params.Get("guid", "")},
|
||||||
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
||||||
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
||||||
};
|
};
|
||||||
@ -736,7 +736,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateStickDevice(
|
|||||||
const auto range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f);
|
const auto range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f);
|
||||||
const auto threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f);
|
const auto threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f);
|
||||||
const PadIdentifier identifier = {
|
const PadIdentifier identifier = {
|
||||||
.guid = Common::NewUUID{params.Get("guid", "")},
|
.guid = Common::UUID{params.Get("guid", "")},
|
||||||
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
||||||
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
||||||
};
|
};
|
||||||
@ -768,7 +768,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateStickDevice(
|
|||||||
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateAnalogDevice(
|
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateAnalogDevice(
|
||||||
const Common::ParamPackage& params) {
|
const Common::ParamPackage& params) {
|
||||||
const PadIdentifier identifier = {
|
const PadIdentifier identifier = {
|
||||||
.guid = Common::NewUUID{params.Get("guid", "")},
|
.guid = Common::UUID{params.Get("guid", "")},
|
||||||
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
||||||
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
||||||
};
|
};
|
||||||
@ -789,7 +789,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateAnalogDevice(
|
|||||||
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTriggerDevice(
|
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTriggerDevice(
|
||||||
const Common::ParamPackage& params) {
|
const Common::ParamPackage& params) {
|
||||||
const PadIdentifier identifier = {
|
const PadIdentifier identifier = {
|
||||||
.guid = Common::NewUUID{params.Get("guid", "")},
|
.guid = Common::UUID{params.Get("guid", "")},
|
||||||
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
||||||
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
||||||
};
|
};
|
||||||
@ -820,7 +820,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTouchDevice(
|
|||||||
const auto range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f);
|
const auto range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f);
|
||||||
const auto threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f);
|
const auto threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f);
|
||||||
const PadIdentifier identifier = {
|
const PadIdentifier identifier = {
|
||||||
.guid = Common::NewUUID{params.Get("guid", "")},
|
.guid = Common::UUID{params.Get("guid", "")},
|
||||||
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
||||||
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
||||||
};
|
};
|
||||||
@ -857,7 +857,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTouchDevice(
|
|||||||
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateBatteryDevice(
|
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateBatteryDevice(
|
||||||
const Common::ParamPackage& params) {
|
const Common::ParamPackage& params) {
|
||||||
const PadIdentifier identifier = {
|
const PadIdentifier identifier = {
|
||||||
.guid = Common::NewUUID{params.Get("guid", "")},
|
.guid = Common::UUID{params.Get("guid", "")},
|
||||||
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
||||||
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
||||||
};
|
};
|
||||||
@ -869,7 +869,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateBatteryDevice(
|
|||||||
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateMotionDevice(
|
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateMotionDevice(
|
||||||
Common::ParamPackage params) {
|
Common::ParamPackage params) {
|
||||||
const PadIdentifier identifier = {
|
const PadIdentifier identifier = {
|
||||||
.guid = Common::NewUUID{params.Get("guid", "")},
|
.guid = Common::UUID{params.Get("guid", "")},
|
||||||
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
||||||
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
||||||
};
|
};
|
||||||
@ -963,7 +963,7 @@ OutputFactory::OutputFactory(std::shared_ptr<InputEngine> input_engine_)
|
|||||||
std::unique_ptr<Common::Input::OutputDevice> OutputFactory::Create(
|
std::unique_ptr<Common::Input::OutputDevice> OutputFactory::Create(
|
||||||
const Common::ParamPackage& params) {
|
const Common::ParamPackage& params) {
|
||||||
const PadIdentifier identifier = {
|
const PadIdentifier identifier = {
|
||||||
.guid = Common::NewUUID{params.Get("guid", "")},
|
.guid = Common::UUID{params.Get("guid", "")},
|
||||||
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
.port = static_cast<std::size_t>(params.Get("port", 0)),
|
||||||
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
|
||||||
};
|
};
|
||||||
|
@ -19,21 +19,21 @@
|
|||||||
#include "yuzu/util/controller_navigation.h"
|
#include "yuzu/util/controller_navigation.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
QString FormatUserEntryText(const QString& username, Common::NewUUID uuid) {
|
QString FormatUserEntryText(const QString& username, Common::UUID uuid) {
|
||||||
return QtProfileSelectionDialog::tr(
|
return QtProfileSelectionDialog::tr(
|
||||||
"%1\n%2", "%1 is the profile username, %2 is the formatted UUID (e.g. "
|
"%1\n%2", "%1 is the profile username, %2 is the formatted UUID (e.g. "
|
||||||
"00112233-4455-6677-8899-AABBCCDDEEFF))")
|
"00112233-4455-6677-8899-AABBCCDDEEFF))")
|
||||||
.arg(username, QString::fromStdString(uuid.FormattedString()));
|
.arg(username, QString::fromStdString(uuid.FormattedString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GetImagePath(Common::NewUUID uuid) {
|
QString GetImagePath(Common::UUID uuid) {
|
||||||
const auto path =
|
const auto path =
|
||||||
Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) /
|
Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) /
|
||||||
fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString());
|
fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString());
|
||||||
return QString::fromStdString(Common::FS::PathToUTF8String(path));
|
return QString::fromStdString(Common::FS::PathToUTF8String(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap GetIcon(Common::NewUUID uuid) {
|
QPixmap GetIcon(Common::UUID uuid) {
|
||||||
QPixmap icon{GetImagePath(uuid)};
|
QPixmap icon{GetImagePath(uuid)};
|
||||||
|
|
||||||
if (!icon) {
|
if (!icon) {
|
||||||
@ -163,11 +163,11 @@ QtProfileSelector::QtProfileSelector(GMainWindow& parent) {
|
|||||||
QtProfileSelector::~QtProfileSelector() = default;
|
QtProfileSelector::~QtProfileSelector() = default;
|
||||||
|
|
||||||
void QtProfileSelector::SelectProfile(
|
void QtProfileSelector::SelectProfile(
|
||||||
std::function<void(std::optional<Common::NewUUID>)> callback_) const {
|
std::function<void(std::optional<Common::UUID>)> callback_) const {
|
||||||
callback = std::move(callback_);
|
callback = std::move(callback_);
|
||||||
emit MainWindowSelectProfile();
|
emit MainWindowSelectProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtProfileSelector::MainWindowFinishedSelection(std::optional<Common::NewUUID> uuid) {
|
void QtProfileSelector::MainWindowFinishedSelection(std::optional<Common::UUID> uuid) {
|
||||||
callback(uuid);
|
callback(uuid);
|
||||||
}
|
}
|
||||||
|
@ -66,14 +66,13 @@ public:
|
|||||||
explicit QtProfileSelector(GMainWindow& parent);
|
explicit QtProfileSelector(GMainWindow& parent);
|
||||||
~QtProfileSelector() override;
|
~QtProfileSelector() override;
|
||||||
|
|
||||||
void SelectProfile(
|
void SelectProfile(std::function<void(std::optional<Common::UUID>)> callback_) const override;
|
||||||
std::function<void(std::optional<Common::NewUUID>)> callback_) const override;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void MainWindowSelectProfile() const;
|
void MainWindowSelectProfile() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void MainWindowFinishedSelection(std::optional<Common::NewUUID> uuid);
|
void MainWindowFinishedSelection(std::optional<Common::UUID> uuid);
|
||||||
|
|
||||||
mutable std::function<void(std::optional<Common::NewUUID>)> callback;
|
mutable std::function<void(std::optional<Common::UUID>)> callback;
|
||||||
};
|
};
|
||||||
|
@ -33,14 +33,14 @@ constexpr std::array<u8, 107> backup_jpeg{
|
|||||||
0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9,
|
0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9,
|
||||||
};
|
};
|
||||||
|
|
||||||
QString GetImagePath(const Common::NewUUID& uuid) {
|
QString GetImagePath(const Common::UUID& uuid) {
|
||||||
const auto path =
|
const auto path =
|
||||||
Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) /
|
Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) /
|
||||||
fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString());
|
fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString());
|
||||||
return QString::fromStdString(Common::FS::PathToUTF8String(path));
|
return QString::fromStdString(Common::FS::PathToUTF8String(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GetAccountUsername(const Service::Account::ProfileManager& manager, Common::NewUUID uuid) {
|
QString GetAccountUsername(const Service::Account::ProfileManager& manager, Common::UUID uuid) {
|
||||||
Service::Account::ProfileBase profile{};
|
Service::Account::ProfileBase profile{};
|
||||||
if (!manager.GetProfileBase(uuid, profile)) {
|
if (!manager.GetProfileBase(uuid, profile)) {
|
||||||
return {};
|
return {};
|
||||||
@ -51,14 +51,14 @@ QString GetAccountUsername(const Service::Account::ProfileManager& manager, Comm
|
|||||||
return QString::fromStdString(text);
|
return QString::fromStdString(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FormatUserEntryText(const QString& username, Common::NewUUID uuid) {
|
QString FormatUserEntryText(const QString& username, Common::UUID uuid) {
|
||||||
return ConfigureProfileManager::tr("%1\n%2",
|
return ConfigureProfileManager::tr("%1\n%2",
|
||||||
"%1 is the profile username, %2 is the formatted UUID (e.g. "
|
"%1 is the profile username, %2 is the formatted UUID (e.g. "
|
||||||
"00112233-4455-6677-8899-AABBCCDDEEFF))")
|
"00112233-4455-6677-8899-AABBCCDDEEFF))")
|
||||||
.arg(username, QString::fromStdString(uuid.FormattedString()));
|
.arg(username, QString::fromStdString(uuid.FormattedString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap GetIcon(const Common::NewUUID& uuid) {
|
QPixmap GetIcon(const Common::UUID& uuid) {
|
||||||
QPixmap icon{GetImagePath(uuid)};
|
QPixmap icon{GetImagePath(uuid)};
|
||||||
|
|
||||||
if (!icon) {
|
if (!icon) {
|
||||||
@ -200,7 +200,7 @@ void ConfigureProfileManager::AddUser() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto uuid = Common::NewUUID::MakeRandom();
|
const auto uuid = Common::UUID::MakeRandom();
|
||||||
profile_manager->CreateNewUser(uuid, username.toStdString());
|
profile_manager->CreateNewUser(uuid, username.toStdString());
|
||||||
|
|
||||||
item_model->appendRow(new QStandardItem{GetIcon(uuid), FormatUserEntryText(username, uuid)});
|
item_model->appendRow(new QStandardItem{GetIcon(uuid), FormatUserEntryText(username, uuid)});
|
||||||
|
@ -153,7 +153,7 @@ signals:
|
|||||||
|
|
||||||
void ErrorDisplayFinished();
|
void ErrorDisplayFinished();
|
||||||
|
|
||||||
void ProfileSelectorFinishedSelection(std::optional<Common::NewUUID> uuid);
|
void ProfileSelectorFinishedSelection(std::optional<Common::UUID> uuid);
|
||||||
|
|
||||||
void SoftwareKeyboardSubmitNormalText(Service::AM::Applets::SwkbdResult result,
|
void SoftwareKeyboardSubmitNormalText(Service::AM::Applets::SwkbdResult result,
|
||||||
std::u16string submitted_text, bool confirmed);
|
std::u16string submitted_text, bool confirmed);
|
||||||
|
Loading…
Reference in New Issue
Block a user