mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-28 08:35:29 +03:00
More code style aligning
* Null terminate nickname array and correct character limit in settings perference
This commit is contained in:
parent
93da9f2826
commit
1f282af87e
@ -41,6 +41,7 @@ namespace skyline {
|
|||||||
constexpr u32 NoMessages = 0x680; //!< "No message available"
|
constexpr u32 NoMessages = 0x680; //!< "No message available"
|
||||||
constexpr u32 ServiceInvName = 0xC15; //!< "Invalid name"
|
constexpr u32 ServiceInvName = 0xC15; //!< "Invalid name"
|
||||||
constexpr u32 ServiceNotReg = 0xE15; //!< "Service not registered"
|
constexpr u32 ServiceNotReg = 0xE15; //!< "Service not registered"
|
||||||
|
constexpr u32 InvUser = 0xC87C; //!< Invalid user
|
||||||
constexpr u32 InvSize = 0xCA01; //!< "Invalid size"
|
constexpr u32 InvSize = 0xCA01; //!< "Invalid size"
|
||||||
constexpr u32 InvAddress = 0xCC01; //!< "Invalid address"
|
constexpr u32 InvAddress = 0xCC01; //!< "Invalid address"
|
||||||
constexpr u32 InvState = 0xD401; //!< "Invalid MemoryState"
|
constexpr u32 InvState = 0xD401; //!< "Invalid MemoryState"
|
||||||
|
@ -29,7 +29,7 @@ namespace skyline::service::account {
|
|||||||
void IAccountServiceForApplication::GetProfile(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
void IAccountServiceForApplication::GetProfile(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
auto id = request.Pop<UserId>();
|
auto id = request.Pop<UserId>();
|
||||||
if (id != constant::DefaultUserId) {
|
if (id != constant::DefaultUserId) {
|
||||||
response.errorCode = constant::InvUser;
|
response.errorCode = constant::status::InvUser;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,5 @@ namespace skyline {
|
|||||||
|
|
||||||
namespace constant {
|
namespace constant {
|
||||||
constexpr service::account::UserId DefaultUserId = {0x0000000000000001, 0x0000000000000000}; //!< The default user ID
|
constexpr service::account::UserId DefaultUserId = {0x0000000000000001, 0x0000000000000000}; //!< The default user ID
|
||||||
|
|
||||||
constexpr u32 InvUser = 0xC87C; //!< Invalid user
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,25 +11,28 @@ namespace skyline::service::account {
|
|||||||
|
|
||||||
void IProfile::Get(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
void IProfile::Get(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
struct AccountUserData {
|
struct AccountUserData {
|
||||||
u32 _unk0_; //!< Unknown.
|
u32 _unk0_;
|
||||||
u32 iconID; //!< Icon ID (0 = Mii, the rest are character icon IDs).
|
u32 iconID; //!< Icon ID (0 = Mii, the rest are character icon IDs)
|
||||||
u8 iconBackgroundColorID; //!< Profile icon background color ID
|
u8 iconBackgroundColorID; //!< Profile icon background color ID
|
||||||
std::array<u8, 0x7> _unk1_; //!< Unknown.
|
u8 _unk1_[0x7];
|
||||||
std::array<u8, 0x10> miiID; //!< Some ID related to the Mii? All zeros when a character icon is used.
|
std::array<u8, 0x10> miiID; //!< Some ID related to the Mii? All zeros when a character icon is used
|
||||||
std::array<u8, 0x60> _unk2_; //!< Unknown.
|
u8 _unk2_[0x60];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
UserId uid; //!< The UID of the corresponding account
|
UserId uid; //!< The UID of the corresponding account
|
||||||
u64 lastEditTimestamp; //!< A POSIX UTC timestamp denoting the last account edit.
|
u64 lastEditTimestamp; //!< A POSIX UTC timestamp denoting the last account edit
|
||||||
std::array<char, 0x20> nickname; //!< UTF-8 Nickname.
|
std::array<char, 0x20> nickname; //!< UTF-8 Nickname
|
||||||
} accountProfileBase = {.uid = userId};
|
} accountProfileBase = {
|
||||||
|
.uid = userId
|
||||||
|
};
|
||||||
|
|
||||||
std::string username = state.settings->GetString("username_value");
|
auto username = state.settings->GetString("username_value");
|
||||||
size_t usernameSize = std::min(accountProfileBase.nickname.size(), username.size());
|
size_t usernameSize = std::min(accountProfileBase.nickname.size(), username.size());
|
||||||
std::memcpy(accountProfileBase.nickname.data(), username.c_str(), usernameSize);
|
std::memcpy(accountProfileBase.nickname.data(), username.c_str(), usernameSize);
|
||||||
|
accountProfileBase.nickname[accountProfileBase.nickname.size() - 1] = '\0';
|
||||||
|
|
||||||
AccountUserData *userData = state.process->GetPointer<AccountUserData>(request.outputBuf.at(0).address);
|
auto userData = state.process->GetPointer<AccountUserData>(request.outputBuf.at(0).address);
|
||||||
userData->iconBackgroundColorID = 0x1; // Color indexing starts at 0x1
|
userData->iconBackgroundColorID = 0x1; // Color indexing starts at 0x1
|
||||||
|
|
||||||
response.Push(accountProfileBase);
|
response.Push(accountProfileBase);
|
||||||
|
@ -16,7 +16,6 @@ namespace skyline::service::account {
|
|||||||
IProfile(const DeviceState &state, ServiceManager &manager, const UserId &userId);
|
IProfile(const DeviceState &state, ServiceManager &manager, const UserId &userId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
UserId userId;
|
UserId userId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,7 +16,6 @@ import emu.skyline.R
|
|||||||
* This class adapts [EditTextPreference] so that it supports setting the value as the summary automatically. Also added useful attributes.
|
* This class adapts [EditTextPreference] so that it supports setting the value as the summary automatically. Also added useful attributes.
|
||||||
*/
|
*/
|
||||||
class CustomEditTextPreference : EditTextPreference {
|
class CustomEditTextPreference : EditTextPreference {
|
||||||
|
|
||||||
constructor(context : Context, attrs : AttributeSet?, defStyleAttr : Int, defStyleRes : Int) : super(context, attrs, defStyleAttr, defStyleRes) {
|
constructor(context : Context, attrs : AttributeSet?, defStyleAttr : Int, defStyleRes : Int) : super(context, attrs, defStyleAttr, defStyleRes) {
|
||||||
attrs?.let {
|
attrs?.let {
|
||||||
val a = context.obtainStyledAttributes(it, R.styleable.CustomEditTextPreference, defStyleAttr, 0)
|
val a = context.obtainStyledAttributes(it, R.styleable.CustomEditTextPreference, defStyleAttr, 0)
|
||||||
|
@ -65,7 +65,7 @@
|
|||||||
<emu.skyline.preference.CustomEditTextPreference
|
<emu.skyline.preference.CustomEditTextPreference
|
||||||
android:defaultValue="@string/username_default"
|
android:defaultValue="@string/username_default"
|
||||||
app:key="username_value"
|
app:key="username_value"
|
||||||
app:limit="32"
|
app:limit="31"
|
||||||
app:title="@string/username" />
|
app:title="@string/username" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
|
Loading…
Reference in New Issue
Block a user