[Ryujinx.HLE] Address dotnet-format issues (#5380)

* dotnet format style --severity info

Some changes were manually reverted.

* dotnet format analyzers --serverity info

Some changes have been minimally adapted.

* Restore a few unused methods and variables

* Silence dotnet format IDE0060 warnings

* Silence dotnet format IDE0052 warnings

* Address or silence dotnet format IDE1006 warnings

* Address dotnet format CA1816 warnings

* Address or silence dotnet format CA2208 warnings

* Address or silence dotnet format CA1806 and a few CA1854 warnings

* Address dotnet format CA2211 warnings

* Address dotnet format CA1822 warnings

* Address or silence dotnet format CA1069 warnings

* Make dotnet format succeed in style mode

* Address or silence dotnet format CA2211 warnings

* Address review comments

* Address dotnet format CA2208 warnings properly

* Make ProcessResult readonly

* Address most dotnet format whitespace warnings

* Apply dotnet format whitespace formatting

A few of them have been manually reverted and the corresponding warning was silenced

* Add previously silenced warnings back

I have no clue how these disappeared

* Revert formatting changes for while and for-loops

* Format if-blocks correctly

* Run dotnet format style after rebase

* Run dotnet format whitespace after rebase

* Run dotnet format style after rebase

* Run dotnet format analyzers after rebase

* Run dotnet format after rebase and remove unused usings

- analyzers
- style
- whitespace

* Disable 'prefer switch expression' rule

* Add comments to disabled warnings

* Fix a few disabled warnings

* Fix naming rule violation, Convert shader properties to auto-property and convert values to const

* Simplify properties and array initialization, Use const when possible, Remove trailing commas

* Start working on disabled warnings

* Fix and silence a few dotnet-format warnings again

* Run dotnet format after rebase

* Use using declaration instead of block syntax

* Address IDE0251 warnings

* Address a few disabled IDE0060 warnings

* Silence IDE0060 in .editorconfig

* Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas"

This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e.

* dotnet format whitespace after rebase

* First dotnet format pass

* Fix naming rule violations

* Fix typo

* Add trailing commas, use targeted new and use array initializer

* Fix build issues

* Fix remaining build issues

* Remove SuppressMessage for CA1069 where possible

* Address dotnet format issues

* Address formatting issues

Co-authored-by: Ac_K <acoustik666@gmail.com>

* Add GetHashCode implementation for RenderingSurfaceInfo

* Explicitly silence CA1822 for every affected method in Syscall

* Address formatting issues in Demangler.cs

* Address review feedback

Co-authored-by: Ac_K <acoustik666@gmail.com>

* Revert marking service methods as static

* Next dotnet format pass

* Address review feedback

---------

Co-authored-by: Ac_K <acoustik666@gmail.com>
This commit is contained in:
TSRBerry 2023-07-16 19:31:14 +02:00 committed by GitHub
parent fec8291c17
commit 326749498b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1015 changed files with 8173 additions and 7615 deletions

View file

@ -13,7 +13,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
{
public class AccountManager
{
public static readonly UserId DefaultUserId = new UserId("00000000000000010000000000000000");
public static readonly UserId DefaultUserId = new("00000000000000010000000000000000");
private readonly AccountSaveDataManager _accountSaveDataManager;
@ -51,7 +51,9 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
{
commandLineUserProfileOverride = _profiles.Values.FirstOrDefault(x => x.Name == initialProfileName)?.UserId ?? default;
if (commandLineUserProfileOverride.IsNull)
{
Logger.Warning?.Print(LogClass.Application, $"The command line specified profile named '{initialProfileName}' was not found");
}
}
OpenUser(commandLineUserProfileOverride.IsNull ? _accountSaveDataManager.LastOpened : commandLineUserProfileOverride);
}
@ -64,7 +66,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
userId = new UserId(Guid.NewGuid().ToString().Replace("-", ""));
}
UserProfile profile = new UserProfile(userId, name, image);
UserProfile profile = new(userId, name, image);
_profiles.AddOrUpdate(userId.ToString(), profile, (key, old) => profile);
@ -238,4 +240,4 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
return _profiles.First().Value;
}
}
}
}

View file

@ -13,7 +13,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
{
private readonly string _profilesJsonPath = Path.Join(AppDataManager.BaseDirPath, "system", "Profiles.json");
private static readonly ProfilesJsonSerializerContext SerializerContext = new(JsonHelper.GetDefaultSerializerOptions());
private static readonly ProfilesJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
public UserId LastOpened { get; set; }
@ -23,22 +23,22 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
if (File.Exists(_profilesJsonPath))
{
try
try
{
ProfilesJson profilesJson = JsonHelper.DeserializeFromFile(_profilesJsonPath, SerializerContext.ProfilesJson);
ProfilesJson profilesJson = JsonHelper.DeserializeFromFile(_profilesJsonPath, _serializerContext.ProfilesJson);
foreach (var profile in profilesJson.Profiles)
{
UserProfile addedProfile = new UserProfile(new UserId(profile.UserId), profile.Name, profile.Image, profile.LastModifiedTimestamp);
UserProfile addedProfile = new(new UserId(profile.UserId), profile.Name, profile.Image, profile.LastModifiedTimestamp);
profiles.AddOrUpdate(profile.UserId, addedProfile, (key, old) => addedProfile);
}
LastOpened = new UserId(profilesJson.LastOpened);
}
catch (Exception e)
catch (Exception ex)
{
Logger.Error?.Print(LogClass.Application, $"Failed to parse {_profilesJsonPath}: {e.Message} Loading default profile!");
Logger.Error?.Print(LogClass.Application, $"Failed to parse {_profilesJsonPath}: {ex.Message} Loading default profile!");
LastOpened = AccountManager.DefaultUserId;
}
@ -51,26 +51,26 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
public void Save(ConcurrentDictionary<string, UserProfile> profiles)
{
ProfilesJson profilesJson = new ProfilesJson()
ProfilesJson profilesJson = new()
{
Profiles = new List<UserProfileJson>(),
LastOpened = LastOpened.ToString()
Profiles = new List<UserProfileJson>(),
LastOpened = LastOpened.ToString(),
};
foreach (var profile in profiles)
{
profilesJson.Profiles.Add(new UserProfileJson()
{
UserId = profile.Value.UserId.ToString(),
Name = profile.Value.Name,
AccountState = profile.Value.AccountState,
OnlinePlayState = profile.Value.OnlinePlayState,
UserId = profile.Value.UserId.ToString(),
Name = profile.Value.Name,
AccountState = profile.Value.AccountState,
OnlinePlayState = profile.Value.OnlinePlayState,
LastModifiedTimestamp = profile.Value.LastModifiedTimestamp,
Image = profile.Value.Image,
Image = profile.Value.Image,
});
}
JsonHelper.SerializeToFile(_profilesJsonPath, profilesJson, SerializerContext.ProfilesJson);
JsonHelper.SerializeToFile(_profilesJsonPath, profilesJson, _serializerContext.ProfilesJson);
}
}
}
}

View file

@ -2,7 +2,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
{
class IManagerForApplication : IpcService
{
private ManagerServer _managerServer;
private readonly ManagerServer _managerServer;
public IManagerForApplication(UserId userId)
{
@ -72,4 +72,4 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
return resultCode;
}
}
}
}

View file

@ -2,7 +2,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
{
class IManagerForSystemService : IpcService
{
private ManagerServer _managerServer;
private readonly ManagerServer _managerServer;
public IManagerForSystemService(UserId userId)
{
@ -44,4 +44,4 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
return _managerServer.LoadIdTokenCache(context);
}
}
}
}

View file

@ -2,7 +2,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
{
class IProfile : IpcService
{
private ProfileServer _profileServer;
private readonly ProfileServer _profileServer;
public IProfile(UserProfile profile)
{
@ -37,4 +37,4 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
return _profileServer.LoadImage(context);
}
}
}
}

View file

@ -2,7 +2,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
{
class IProfileEditor : IpcService
{
private ProfileServer _profileServer;
private readonly ProfileServer _profileServer;
public IProfileEditor(UserProfile profile)
{
@ -51,4 +51,4 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
return _profileServer.StoreWithImage(context);
}
}
}
}

View file

@ -16,7 +16,9 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
// TODO: Determine where and how NetworkServiceAccountId is set.
private const long NetworkServiceAccountId = 0xcafe;
private UserId _userId;
#pragma warning disable IDE0052 // Remove unread private member
private readonly UserId _userId;
#pragma warning restore IDE0052
public ManagerServer(UserId userId)
{
@ -29,15 +31,15 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
RSAParameters parameters = provider.ExportParameters(true);
RsaSecurityKey secKey = new RsaSecurityKey(parameters);
RsaSecurityKey secKey = new(parameters);
SigningCredentials credentials = new SigningCredentials(secKey, "RS256");
SigningCredentials credentials = new(secKey, "RS256");
credentials.Key.KeyId = parameters.ToString();
var header = new JwtHeader(credentials)
{
{ "jku", "https://e0d67c509fb203858ebcb2fe3f88c2aa.baas.nintendo.com/1.0.0/certificates" }
{ "jku", "https://e0d67c509fb203858ebcb2fe3f88c2aa.baas.nintendo.com/1.0.0/certificates" },
};
byte[] rawUserId = new byte[0x10];
@ -60,10 +62,10 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
{ "typ", "id_token" },
{ "iat", DateTimeOffset.UtcNow.ToUnixTimeSeconds() },
{ "jti", Guid.NewGuid().ToString() },
{ "exp", (DateTimeOffset.UtcNow + TimeSpan.FromHours(3)).ToUnixTimeSeconds() }
{ "exp", (DateTimeOffset.UtcNow + TimeSpan.FromHours(3)).ToUnixTimeSeconds() },
};
JwtSecurityToken securityToken = new JwtSecurityToken(header, payload);
JwtSecurityToken securityToken = new(header, payload);
return new JwtSecurityTokenHandler().WriteToken(securityToken);
}
@ -94,8 +96,8 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
public ResultCode EnsureIdTokenCacheAsync(ServiceCtx context, out IAsyncContext asyncContext)
{
KEvent asyncEvent = new KEvent(context.Device.System.KernelContext);
AsyncExecution asyncExecution = new AsyncExecution(asyncEvent);
KEvent asyncEvent = new(context.Device.System.KernelContext);
AsyncExecution asyncExecution = new(asyncEvent);
asyncExecution.Initialize(1000, EnsureIdTokenCacheAsyncImpl);
@ -123,7 +125,9 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
public ResultCode LoadIdTokenCache(ServiceCtx context)
{
ulong bufferPosition = context.Request.ReceiveBuff[0].Position;
ulong bufferSize = context.Request.ReceiveBuff[0].Size;
#pragma warning disable IDE0059 // Remove unnecessary value assignment
ulong bufferSize = context.Request.ReceiveBuff[0].Size;
#pragma warning restore IDE0059
// NOTE: This opens the file at "su/cache/USERID_IN_UUID_STRING.dat" (where USERID_IN_UUID_STRING is formatted as "%08x-%04x-%04x-%02x%02x-%08x%04x")
// in the "account:/" savedata and writes some data in the buffer.
@ -169,8 +173,8 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
public ResultCode LoadNetworkServiceLicenseKindAsync(ServiceCtx context, out IAsyncNetworkServiceLicenseKindContext asyncContext)
{
KEvent asyncEvent = new KEvent(context.Device.System.KernelContext);
AsyncExecution asyncExecution = new AsyncExecution(asyncEvent);
KEvent asyncEvent = new(context.Device.System.KernelContext);
AsyncExecution asyncExecution = new(asyncEvent);
Logger.Stub?.PrintStub(LogClass.ServiceAcc);
@ -184,4 +188,4 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
return ResultCode.Success;
}
}
}
}

View file

@ -7,7 +7,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
{
class ProfileServer
{
private UserProfile _profile;
private readonly UserProfile _profile;
public ProfileServer(UserProfile profile)
{
@ -23,8 +23,8 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
MemoryHelper.FillWithZeros(context.Memory, bufferPosition, 0x80);
// TODO: Determine the struct.
context.Memory.Write(bufferPosition, 0); // Unknown
context.Memory.Write(bufferPosition + 4, 1); // Icon ID. 0 = Mii, the rest are character icon IDs.
context.Memory.Write(bufferPosition, 0); // Unknown
context.Memory.Write(bufferPosition + 4, 1); // Icon ID. 0 = Mii, the rest are character icon IDs.
context.Memory.Write(bufferPosition + 8, (byte)1); // Profile icon background color ID
// 0x07 bytes - Unknown
// 0x10 bytes - Some ID related to the Mii? All zeros when a character icon is used.
@ -58,7 +58,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
public ResultCode LoadImage(ServiceCtx context)
{
ulong bufferPosition = context.Request.ReceiveBuff[0].Position;
ulong bufferLen = context.Request.ReceiveBuff[0].Size;
ulong bufferLen = context.Request.ReceiveBuff[0].Size;
if ((ulong)_profile.Image.Length > bufferLen)
{
@ -75,7 +75,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
public ResultCode Store(ServiceCtx context)
{
ulong userDataPosition = context.Request.PtrBuff[0].Position;
ulong userDataSize = context.Request.PtrBuff[0].Size;
ulong userDataSize = context.Request.PtrBuff[0].Size;
byte[] userData = new byte[userDataSize];
@ -91,14 +91,14 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
public ResultCode StoreWithImage(ServiceCtx context)
{
ulong userDataPosition = context.Request.PtrBuff[0].Position;
ulong userDataSize = context.Request.PtrBuff[0].Size;
ulong userDataSize = context.Request.PtrBuff[0].Size;
byte[] userData = new byte[userDataSize];
context.Memory.Read(userDataPosition, userData);
ulong profileImagePosition = context.Request.SendBuff[0].Position;
ulong profileImageSize = context.Request.SendBuff[0].Size;
ulong profileImageSize = context.Request.SendBuff[0].Size;
byte[] profileImageData = new byte[profileImageSize];
@ -111,4 +111,4 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
return ResultCode.Success;
}
}
}
}

View file

@ -58,7 +58,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
}
ulong outputPosition = context.Request.RecvListBuff[0].Position;
ulong outputSize = context.Request.RecvListBuff[0].Size;
ulong outputSize = context.Request.RecvListBuff[0].Size;
MemoryHelper.FillWithZeros(context.Memory, outputPosition, (int)outputSize);
@ -71,7 +71,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
break;
}
context.Memory.Write(outputPosition + offset, userProfile.UserId.High);
context.Memory.Write(outputPosition + offset, userProfile.UserId.High);
context.Memory.Write(outputPosition + offset + 8, userProfile.UserId.Low);
offset += 0x10;
@ -148,7 +148,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
public ResultCode CheckNetworkServiceAvailabilityAsync(ServiceCtx context, out IAsyncContext asyncContext)
{
KEvent asyncEvent = new(context.Device.System.KernelContext);
KEvent asyncEvent = new(context.Device.System.KernelContext);
AsyncExecution asyncExecution = new(asyncEvent);
asyncExecution.Initialize(1000, CheckNetworkServiceAvailabilityAsyncImpl);
@ -183,7 +183,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
}
ulong inputPosition = context.Request.SendBuff[0].Position;
ulong inputSize = context.Request.SendBuff[0].Size;
ulong inputSize = context.Request.SendBuff[0].Size;
if (inputSize != 0x24000)
{
@ -251,4 +251,4 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
return ResultCode.Success;
}
}
}
}

View file

@ -1,4 +1,4 @@
using Ryujinx.Common.Logging;
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Kernel.Threading;
using System;
using System.Threading;
@ -9,18 +9,18 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AsyncContext
class AsyncExecution
{
private readonly CancellationTokenSource _tokenSource;
private readonly CancellationToken _token;
private readonly CancellationToken _token;
public KEvent SystemEvent { get; }
public bool IsInitialized { get; private set; }
public bool IsRunning { get; private set; }
public KEvent SystemEvent { get; }
public bool IsInitialized { get; private set; }
public bool IsRunning { get; private set; }
public AsyncExecution(KEvent asyncEvent)
{
SystemEvent = asyncEvent;
_tokenSource = new CancellationTokenSource();
_token = _tokenSource.Token;
_token = _tokenSource.Token;
}
public void Initialize(int timeout, Func<CancellationToken, Task> taskAsync)
@ -53,4 +53,4 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AsyncContext
_tokenSource.Cancel();
}
}
}
}

View file

@ -7,7 +7,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
[Service("acc:su", AccountServiceFlag.Administrator)] // Max Sessions: 8
class IAccountServiceForAdministrator : IpcService
{
private ApplicationServiceServer _applicationServiceServer;
private readonly ApplicationServiceServer _applicationServiceServer;
public IAccountServiceForAdministrator(ServiceCtx context, AccountServiceFlag serviceFlag)
{
@ -126,4 +126,4 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
return ResultCode.Success;
}
}
}
}

View file

@ -7,7 +7,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
[Service("acc:u0", AccountServiceFlag.Application)] // Max Sessions: 4
class IAccountServiceForApplication : IpcService
{
private ApplicationServiceServer _applicationServiceServer;
private readonly ApplicationServiceServer _applicationServiceServer;
public IAccountServiceForApplication(ServiceCtx context, AccountServiceFlag serviceFlag)
{
@ -197,4 +197,4 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
return ResultCode.Success;
}
}
}
}

View file

@ -6,7 +6,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
[Service("acc:u1", AccountServiceFlag.SystemService)] // Max Sessions: 16
class IAccountServiceForSystemService : IpcService
{
private ApplicationServiceServer _applicationServiceServer;
private readonly ApplicationServiceServer _applicationServiceServer;
public IAccountServiceForSystemService(ServiceCtx context, AccountServiceFlag serviceFlag)
{
@ -104,4 +104,4 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
return _applicationServiceServer.ListQualifiedUsers(context);
}
}
}
}

View file

@ -1,4 +1,4 @@
using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Services.Account.Acc.AsyncContext;
using Ryujinx.Horizon.Common;
using System;
@ -18,12 +18,12 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
// GetSystemEvent() -> handle<copy>
public ResultCode GetSystemEvent(ServiceCtx context)
{
if (context.Process.HandleTable.GenerateHandle(AsyncExecution.SystemEvent.ReadableEvent, out int _systemEventHandle) != Result.Success)
if (context.Process.HandleTable.GenerateHandle(AsyncExecution.SystemEvent.ReadableEvent, out int systemEventHandle) != Result.Success)
{
throw new InvalidOperationException("Out of handles!");
}
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_systemEventHandle);
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(systemEventHandle);
return ResultCode.Success;
}
@ -76,4 +76,4 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
return ResultCode.Success;
}
}
}
}

View file

@ -4,7 +4,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
{
class IAsyncNetworkServiceLicenseKindContext : IAsyncContext
{
private NetworkServiceLicenseKind? _serviceLicenseKind;
private readonly NetworkServiceLicenseKind? _serviceLicenseKind;
public IAsyncNetworkServiceLicenseKindContext(AsyncExecution asyncExecution, NetworkServiceLicenseKind? serviceLicenseKind) : base(asyncExecution)
{

View file

@ -5,4 +5,4 @@
{
public IBaasAccessTokenAccessor(ServiceCtx context) { }
}
}
}

View file

@ -8,4 +8,4 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
internal partial class ProfilesJsonSerializerContext : JsonSerializerContext
{
}
}
}

View file

@ -2,9 +2,9 @@
{
enum AccountServiceFlag
{
Administrator = 100,
SystemService = 101,
Application = 102,
BaasAccessTokenAccessor = 200
Administrator = 100,
SystemService = 101,
Application = 102,
BaasAccessTokenAccessor = 200,
}
}
}

View file

@ -7,6 +7,6 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
public enum AccountState
{
Closed,
Open
Open,
}
}
}

View file

@ -3,6 +3,6 @@
enum NetworkServiceLicenseKind : uint
{
NoSubscription,
Subscribed
Subscribed,
}
}

View file

@ -7,4 +7,4 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.Types
public List<UserProfileJson> Profiles { get; set; }
public string LastOpened { get; set; }
}
}
}

View file

@ -15,18 +15,18 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
public bool IsNull => (Low | High) == 0;
public static UserId Null => new UserId(0, 0);
public static UserId Null => new(0, 0);
public UserId(long low, long high)
{
Low = low;
Low = low;
High = high;
}
public UserId(byte[] bytes)
{
High = BitConverter.ToInt64(bytes, 0);
Low = BitConverter.ToInt64(bytes, 8);
Low = BitConverter.ToInt64(bytes, 8);
}
public UserId(string hex)
@ -36,7 +36,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
throw new ArgumentException("Invalid Hex value!", nameof(hex));
}
Low = long.Parse(hex.AsSpan(16), NumberStyles.HexNumber);
Low = long.Parse(hex.AsSpan(16), NumberStyles.HexNumber);
High = long.Parse(hex.AsSpan(0, 16), NumberStyles.HexNumber);
}
@ -61,4 +61,4 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
return new UInt128((ulong)High, (ulong)Low);
}
}
}
}

View file

@ -47,7 +47,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
}
}
public AccountState _onlinePlayState;
private AccountState _onlinePlayState;
public AccountState OnlinePlayState
{
@ -63,10 +63,10 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
public UserProfile(UserId userId, string name, byte[] image, long lastModifiedTimestamp = 0)
{
UserId = userId;
Name = name;
Image = image;
Name = name;
Image = image;
AccountState = AccountState.Closed;
AccountState = AccountState.Closed;
OnlinePlayState = AccountState.Closed;
if (lastModifiedTimestamp != 0)
@ -84,4 +84,4 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
LastModifiedTimestamp = (long)(DateTime.Now - DateTime.UnixEpoch).TotalSeconds;
}
}
}
}

View file

@ -9,4 +9,4 @@
public long LastModifiedTimestamp { get; set; }
public byte[] Image { get; set; }
}
}
}

View file

@ -5,4 +5,4 @@
{
public IService(ServiceCtx context) { }
}
}
}

View file

@ -2,23 +2,23 @@ namespace Ryujinx.HLE.HOS.Services.Account
{
enum ResultCode
{
ModuleId = 124,
ModuleId = 124,
ErrorCodeShift = 9,
Success = 0,
NullArgument = (20 << ErrorCodeShift) | ModuleId,
InvalidArgument = (22 << ErrorCodeShift) | ModuleId,
NullInputBuffer = (30 << ErrorCodeShift) | ModuleId,
InvalidBufferSize = (31 << ErrorCodeShift) | ModuleId,
InvalidBuffer = (32 << ErrorCodeShift) | ModuleId,
AsyncExecutionNotInitialized = (40 << ErrorCodeShift) | ModuleId,
Unknown41 = (41 << ErrorCodeShift) | ModuleId,
InternetRequestDenied = (59 << ErrorCodeShift) | ModuleId,
UserNotFound = (100 << ErrorCodeShift) | ModuleId,
NullObject = (302 << ErrorCodeShift) | ModuleId,
Unknown341 = (341 << ErrorCodeShift) | ModuleId,
NullArgument = (20 << ErrorCodeShift) | ModuleId,
InvalidArgument = (22 << ErrorCodeShift) | ModuleId,
NullInputBuffer = (30 << ErrorCodeShift) | ModuleId,
InvalidBufferSize = (31 << ErrorCodeShift) | ModuleId,
InvalidBuffer = (32 << ErrorCodeShift) | ModuleId,
AsyncExecutionNotInitialized = (40 << ErrorCodeShift) | ModuleId,
Unknown41 = (41 << ErrorCodeShift) | ModuleId,
InternetRequestDenied = (59 << ErrorCodeShift) | ModuleId,
UserNotFound = (100 << ErrorCodeShift) | ModuleId,
NullObject = (302 << ErrorCodeShift) | ModuleId,
Unknown341 = (341 << ErrorCodeShift) | ModuleId,
MissingNetworkServiceLicenseKind = (400 << ErrorCodeShift) | ModuleId,
InvalidIdTokenCacheBufferSize = (451 << ErrorCodeShift) | ModuleId
InvalidIdTokenCacheBufferSize = (451 << ErrorCodeShift) | ModuleId,
}
}

View file

@ -102,4 +102,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService
return ResultCode.Success;
}
}
}
}

View file

@ -110,4 +110,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService
return ResultCode.Success;
}
}
}
}

View file

@ -10,16 +10,16 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Lib
{
class ILibraryAppletAccessor : DisposableIpcService
{
private KernelContext _kernelContext;
private readonly KernelContext _kernelContext;
private IApplet _applet;
private readonly IApplet _applet;
private AppletSession _normalSession;
private AppletSession _interactiveSession;
private readonly AppletSession _normalSession;
private readonly AppletSession _interactiveSession;
private KEvent _stateChangedEvent;
private KEvent _normalOutDataEvent;
private KEvent _interactiveOutDataEvent;
private readonly KEvent _stateChangedEvent;
private readonly KEvent _normalOutDataEvent;
private readonly KEvent _interactiveOutDataEvent;
private int _stateChangedEventHandle;
private int _normalOutDataEventHandle;
@ -31,17 +31,17 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Lib
{
_kernelContext = system.KernelContext;
_stateChangedEvent = new KEvent(system.KernelContext);
_normalOutDataEvent = new KEvent(system.KernelContext);
_stateChangedEvent = new KEvent(system.KernelContext);
_normalOutDataEvent = new KEvent(system.KernelContext);
_interactiveOutDataEvent = new KEvent(system.KernelContext);
_applet = AppletManager.Create(appletId, system);
_normalSession = new AppletSession();
_normalSession = new AppletSession();
_interactiveSession = new AppletSession();
_applet.AppletStateChanged += OnAppletStateChanged;
_normalSession.DataAvailable += OnNormalOutData;
_applet.AppletStateChanged += OnAppletStateChanged;
_normalSession.DataAvailable += OnNormalOutData;
_interactiveSession.DataAvailable += OnInteractiveOutData;
Logger.Info?.Print(LogClass.ServiceAm, $"Applet '{appletId}' created.");

View file

@ -4,13 +4,13 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Lib
{
class AppletStandalone
{
public AppletId AppletId;
public AppletId AppletId;
public LibraryAppletMode LibraryAppletMode;
public Queue<byte[]> InputData;
public Queue<byte[]> InputData;
public AppletStandalone()
{
InputData = new Queue<byte[]>();
}
}
}
}

View file

@ -5,7 +5,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Lib
{
class ILibraryAppletSelfAccessor : IpcService
{
private AppletStandalone _appletStandalone = new AppletStandalone();
private readonly AppletStandalone _appletStandalone = new();
public ILibraryAppletSelfAccessor(ServiceCtx context)
{
@ -14,8 +14,8 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Lib
// Create MiiEdit data.
_appletStandalone = new AppletStandalone()
{
AppletId = AppletId.MiiEdit,
LibraryAppletMode = LibraryAppletMode.AllForeground
AppletId = AppletId.MiiEdit,
LibraryAppletMode = LibraryAppletMode.AllForeground,
};
byte[] miiEditInputData = new byte[0x100];
@ -49,10 +49,10 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Lib
// GetLibraryAppletInfo() -> nn::am::service::LibraryAppletInfo
public ResultCode GetLibraryAppletInfo(ServiceCtx context)
{
LibraryAppletInfo libraryAppletInfo = new LibraryAppletInfo()
LibraryAppletInfo libraryAppletInfo = new()
{
AppletId = _appletStandalone.AppletId,
LibraryAppletMode = _appletStandalone.LibraryAppletMode
AppletId = _appletStandalone.AppletId,
LibraryAppletMode = _appletStandalone.LibraryAppletMode,
};
context.ResponseData.WriteStruct(libraryAppletInfo);
@ -64,10 +64,10 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Lib
// GetCallerAppletIdentityInfo() -> nn::am::service::AppletIdentityInfo
public ResultCode GetCallerAppletIdentityInfo(ServiceCtx context)
{
AppletIdentifyInfo appletIdentifyInfo = new AppletIdentifyInfo()
AppletIdentifyInfo appletIdentifyInfo = new()
{
AppletId = AppletId.QLaunch,
TitleId = 0x0100000000001000
TitleId = 0x0100000000001000,
};
context.ResponseData.WriteStruct(appletIdentifyInfo);
@ -75,4 +75,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Lib
return ResultCode.Success;
}
}
}
}

View file

@ -11,9 +11,9 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Lib
public ResultCode GetLaunchReason(ServiceCtx context)
{
// NOTE: Flag is set by using an internal field.
AppletProcessLaunchReason appletProcessLaunchReason = new AppletProcessLaunchReason()
AppletProcessLaunchReason appletProcessLaunchReason = new()
{
Flag = 0
Flag = 0,
};
context.ResponseData.WriteStruct(appletProcessLaunchReason);
@ -21,4 +21,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Lib
return ResultCode.Success;
}
}
}
}

View file

@ -4,4 +4,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
{
public IApplicationCreator() { }
}
}
}

View file

@ -10,8 +10,10 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
// SetExpectedMasterVolume(f32, f32)
public ResultCode SetExpectedMasterVolume(ServiceCtx context)
{
float appletVolume = context.RequestData.ReadSingle();
#pragma warning disable IDE0059 // Remove unnecessary value assignment
float appletVolume = context.RequestData.ReadSingle();
float libraryAppletVolume = context.RequestData.ReadSingle();
#pragma warning restore IDE0059
Logger.Stub?.PrintStub(LogClass.ServiceAm);
@ -44,8 +46,10 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
// ChangeMainAppletMasterVolume(f32, u64)
public ResultCode ChangeMainAppletMasterVolume(ServiceCtx context)
{
#pragma warning disable IDE0059 // Remove unnecessary value assignment
float unknown0 = context.RequestData.ReadSingle();
long unknown1 = context.RequestData.ReadInt64();
long unknown1 = context.RequestData.ReadInt64();
#pragma warning restore IDE0059
Logger.Stub?.PrintStub(LogClass.ServiceAm);
@ -56,11 +60,13 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
// SetTransparentVolumeRate(f32)
public ResultCode SetTransparentVolumeRate(ServiceCtx context)
{
#pragma warning disable IDE0059 // Remove unnecessary value assignment
float unknown0 = context.RequestData.ReadSingle();
#pragma warning restore IDE0059
Logger.Stub?.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
}
}
}

View file

@ -13,28 +13,28 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
{
private readonly ServiceCtx _context;
private Apm.ManagerServer _apmManagerServer;
private Apm.SystemManagerServer _apmSystemManagerServer;
private Lbl.LblControllerServer _lblControllerServer;
private readonly Apm.ManagerServer _apmManagerServer;
private readonly Apm.SystemManagerServer _apmSystemManagerServer;
private readonly Lbl.LblControllerServer _lblControllerServer;
private bool _vrModeEnabled;
#pragma warning disable CS0414
#pragma warning disable CS0414, IDE0052 // Remove unread private member
private bool _lcdBacklighOffEnabled;
private bool _requestExitToLibraryAppletAtExecuteNextProgramEnabled;
#pragma warning restore CS0414
private int _messageEventHandle;
private int _displayResolutionChangedEventHandle;
#pragma warning restore CS0414, IDE0052
private int _messageEventHandle;
private int _displayResolutionChangedEventHandle;
private KEvent _acquiredSleepLockEvent;
private readonly KEvent _acquiredSleepLockEvent;
private int _acquiredSleepLockEventHandle;
public ICommonStateGetter(ServiceCtx context)
{
_context = context;
_apmManagerServer = new Apm.ManagerServer(context);
_apmManagerServer = new Apm.ManagerServer(context);
_apmSystemManagerServer = new Apm.SystemManagerServer(context);
_lblControllerServer = new Lbl.LblControllerServer(context);
_lblControllerServer = new Lbl.LblControllerServer(context);
_acquiredSleepLockEvent = new KEvent(context.Device.System.KernelContext);
}
@ -331,4 +331,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
}
}
}
}
}

View file

@ -4,4 +4,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
{
public IDebugFunctions() { }
}
}
}

View file

@ -8,9 +8,9 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
{
class IDisplayController : IpcService
{
private KTransferMemory _transferMem;
private bool _lastApplicationCaptureBufferAcquired;
private bool _callerAppletCaptureBufferAcquired;
private readonly KTransferMemory _transferMem;
private bool _lastApplicationCaptureBufferAcquired;
private bool _callerAppletCaptureBufferAcquired;
public IDisplayController(ServiceCtx context)
{
@ -22,7 +22,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
public ResultCode TakeScreenShotOfOwnLayer(ServiceCtx context)
{
bool unknown1 = context.RequestData.ReadBoolean();
int unknown2 = context.RequestData.ReadInt32();
int unknown2 = context.RequestData.ReadInt32();
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { unknown1, unknown2 });
@ -103,4 +103,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
return ResultCode.Success;
}
}
}
}

View file

@ -4,4 +4,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
{
public IGlobalStateController() { }
}
}
}

View file

@ -8,8 +8,8 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
{
class IHomeMenuFunctions : IpcService
{
private KEvent _channelEvent;
private int _channelEventHandle;
private readonly KEvent _channelEvent;
private int _channelEventHandle;
public IHomeMenuFunctions(Horizon system)
{
@ -45,4 +45,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
return ResultCode.Success;
}
}
}
}

View file

@ -11,8 +11,10 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
// CreateLibraryApplet(u32, u32) -> object<nn::am::service::ILibraryAppletAccessor>
public ResultCode CreateLibraryApplet(ServiceCtx context)
{
AppletId appletId = (AppletId)context.RequestData.ReadInt32();
int libraryAppletMode = context.RequestData.ReadInt32();
AppletId appletId = (AppletId)context.RequestData.ReadInt32();
#pragma warning disable IDE0059 // Remove unnecessary value assignment
int libraryAppletMode = context.RequestData.ReadInt32();
#pragma warning restore IDE0059
MakeObject(context, new ILibraryAppletAccessor(appletId, context.Device.System));
@ -42,8 +44,8 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
public ResultCode CreateTransferMemoryStorage(ServiceCtx context)
{
bool isReadOnly = (context.RequestData.ReadInt64() & 1) == 0;
long size = context.RequestData.ReadInt64();
int handle = context.Request.HandleDesc.ToCopy[0];
long size = context.RequestData.ReadInt64();
int handle = context.Request.HandleDesc.ToCopy[0];
KTransferMemory transferMem = context.Process.HandleTable.GetObject<KTransferMemory>(handle);
@ -67,8 +69,8 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
// CreateHandleStorage(u64, handle<copy>) -> object<nn::am::service::IStorage>
public ResultCode CreateHandleStorage(ServiceCtx context)
{
long size = context.RequestData.ReadInt64();
int handle = context.Request.HandleDesc.ToCopy[0];
long size = context.RequestData.ReadInt64();
int handle = context.Request.HandleDesc.ToCopy[0];
KTransferMemory transferMem = context.Process.HandleTable.GetObject<KTransferMemory>(handle);
@ -88,4 +90,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
return ResultCode.Success;
}
}
}
}

View file

@ -11,30 +11,34 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
{
private readonly ulong _pid;
private KEvent _libraryAppletLaunchableEvent;
private int _libraryAppletLaunchableEventHandle;
private readonly KEvent _libraryAppletLaunchableEvent;
private int _libraryAppletLaunchableEventHandle;
private KEvent _accumulatedSuspendedTickChangedEvent;
private int _accumulatedSuspendedTickChangedEventHandle;
private int _accumulatedSuspendedTickChangedEventHandle;
private readonly object _fatalSectionLock = new();
private int _fatalSectionCount;
// TODO: Set this when the game goes in suspension (go back to home menu ect), we currently don't support that so we can keep it set to 0.
private ulong _accumulatedSuspendedTickValue = 0;
private readonly ulong _accumulatedSuspendedTickValue = 0;
// TODO: Determine where those fields are used.
private bool _screenShotPermission = false;
private bool _operationModeChangedNotification = false;
#pragma warning disable IDE0052 // Remove unread private member
private bool _screenShotPermission = false;
private bool _operationModeChangedNotification = false;
private bool _performanceModeChangedNotification = false;
private bool _restartMessageEnabled = false;
private bool _outOfFocusSuspendingEnabled = false;
private bool _handlesRequestToDisplay = false;
private bool _autoSleepDisabled = false;
private bool _restartMessageEnabled = false;
private bool _outOfFocusSuspendingEnabled = false;
private bool _handlesRequestToDisplay = false;
#pragma warning restore IDE0052
private bool _autoSleepDisabled = false;
#pragma warning disable IDE0052 // Remove unread private member
private bool _albumImageTakenNotificationEnabled = false;
private bool _recordVolumeMuted = false;
private uint _screenShotImageOrientation = 0;
#pragma warning restore IDE0052
private uint _idleTimeDetectionExtension = 0;
public ISelfController(ServiceCtx context, ulong pid)

View file

@ -33,4 +33,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
return ResultCode.Success;
}
}
}
}

View file

@ -5,6 +5,6 @@
OverlayNotDisplayed,
OverlayDisplayed,
Unknown2,
Unknown3
Unknown3,
}
}
}

View file

@ -2,35 +2,35 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
{
enum AppletMessage
{
None = 0,
ChangeIntoForeground = 1,
ChangeIntoBackground = 2,
Exit = 4,
ApplicationExited = 6,
FocusStateChanged = 15,
Resume = 16,
DetectShortPressingHomeButton = 20,
DetectLongPressingHomeButton = 21,
DetectShortPressingPowerButton = 22,
DetectMiddlePressingPowerButton = 23,
DetectLongPressingPowerButton = 24,
RequestToPrepareSleep = 25,
FinishedSleepSequence = 26,
SleepRequiredByHighTemperature = 27,
SleepRequiredByLowBattery = 28,
AutoPowerDown = 29,
OperationModeChanged = 30,
PerformanceModeChanged = 31,
DetectReceivingCecSystemStandby = 32,
SdCardRemoved = 33,
LaunchApplicationRequested = 50,
RequestToDisplay = 51,
ShowApplicationLogo = 55,
HideApplicationLogo = 56,
ForceHideApplicationLogo = 57,
FloatingApplicationDetected = 60,
None = 0,
ChangeIntoForeground = 1,
ChangeIntoBackground = 2,
Exit = 4,
ApplicationExited = 6,
FocusStateChanged = 15,
Resume = 16,
DetectShortPressingHomeButton = 20,
DetectLongPressingHomeButton = 21,
DetectShortPressingPowerButton = 22,
DetectMiddlePressingPowerButton = 23,
DetectLongPressingPowerButton = 24,
RequestToPrepareSleep = 25,
FinishedSleepSequence = 26,
SleepRequiredByHighTemperature = 27,
SleepRequiredByLowBattery = 28,
AutoPowerDown = 29,
OperationModeChanged = 30,
PerformanceModeChanged = 31,
DetectReceivingCecSystemStandby = 32,
SdCardRemoved = 33,
LaunchApplicationRequested = 50,
RequestToDisplay = 51,
ShowApplicationLogo = 55,
HideApplicationLogo = 56,
ForceHideApplicationLogo = 57,
FloatingApplicationDetected = 60,
DetectShortPressingCaptureButton = 90,
AlbumScreenShotTaken = 92,
AlbumRecordingSaved = 93
AlbumScreenShotTaken = 92,
AlbumRecordingSaved = 93,
}
}
}

View file

@ -2,7 +2,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
{
enum FocusState
{
InFocus = 1,
OutOfFocus = 2
InFocus = 1,
OutOfFocus = 2,
}
}
}

View file

@ -3,6 +3,6 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
enum OperationMode
{
Handheld = 0,
Docked = 1
Docked = 1,
}
}
}

View file

@ -4,6 +4,6 @@
{
Default,
OptimizedForWlan,
Unknown2
Unknown2,
}
}
}

View file

@ -7,7 +7,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE
{
internal class AppletFifo<T> : IAppletFifo<T>
{
private ConcurrentQueue<T> _dataQueue;
private readonly ConcurrentQueue<T> _dataQueue;
public event EventHandler DataAvailable;

View file

@ -4,8 +4,8 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE
{
internal class AppletSession
{
private IAppletFifo<byte[]> _inputData;
private IAppletFifo<byte[]> _outputData;
private readonly IAppletFifo<byte[]> _inputData;
private readonly IAppletFifo<byte[]> _outputData;
public event EventHandler DataAvailable;
@ -23,7 +23,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE
IAppletFifo<byte[]> inputData,
IAppletFifo<byte[]> outputData)
{
_inputData = inputData;
_inputData = inputData;
_outputData = outputData;
_inputData.DataAvailable += OnDataAvailable;

View file

@ -26,4 +26,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE
return ResultCode.Success;
}
}
}
}

View file

@ -2,13 +2,13 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE
{
class IStorage : IpcService
{
public bool IsReadOnly { get; private set; }
public byte[] Data { get; private set; }
public bool IsReadOnly { get; private set; }
public byte[] Data { get; private set; }
public IStorage(byte[] data, bool isReadOnly = false)
{
IsReadOnly = isReadOnly;
Data = data;
Data = data;
}
[CommandCmif(0)]
@ -20,4 +20,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE
return ResultCode.Success;
}
}
}
}

View file

@ -4,7 +4,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE
{
class IStorageAccessor : IpcService
{
private IStorage _storage;
private readonly IStorage _storage;
public IStorageAccessor(IStorage storage)
{
@ -83,4 +83,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE
return ResultCode.Success;
}
}
}
}

View file

@ -11,18 +11,16 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.Storage
public static byte[] MakeLaunchParams(UserProfile userProfile)
{
// Size needs to be at least 0x88 bytes otherwise application errors.
using (MemoryStream ms = MemoryStreamManager.Shared.GetStream())
{
BinaryWriter writer = new BinaryWriter(ms);
using MemoryStream ms = MemoryStreamManager.Shared.GetStream();
BinaryWriter writer = new(ms);
ms.SetLength(0x88);
ms.SetLength(0x88);
writer.Write(LaunchParamsMagic);
writer.Write(1); // IsAccountSelected? Only lower 8 bits actually used.
userProfile.UserId.Write(writer);
writer.Write(LaunchParamsMagic);
writer.Write(1); // IsAccountSelected? Only lower 8 bits actually used.
userProfile.UserId.Write(writer);
return ms.ToArray();
}
return ms.ToArray();
}
}
}

View file

@ -2,26 +2,26 @@
{
enum AppletId
{
Application = 0x01,
OverlayDisplay = 0x02,
QLaunch = 0x03,
Starter = 0x04,
Auth = 0x0A,
Cabinet = 0x0B,
Controller = 0x0C,
DataErase = 0x0D,
Error = 0x0E,
NetConnect = 0x0F,
PlayerSelect = 0x10,
SoftwareKeyboard = 0x11,
MiiEdit = 0x12,
LibAppletWeb = 0x13,
LibAppletShop = 0x14,
PhotoViewer = 0x15,
Settings = 0x16,
LibAppletOff = 0x17,
Application = 0x01,
OverlayDisplay = 0x02,
QLaunch = 0x03,
Starter = 0x04,
Auth = 0x0A,
Cabinet = 0x0B,
Controller = 0x0C,
DataErase = 0x0D,
Error = 0x0E,
NetConnect = 0x0F,
PlayerSelect = 0x10,
SoftwareKeyboard = 0x11,
MiiEdit = 0x12,
LibAppletWeb = 0x13,
LibAppletShop = 0x14,
PhotoViewer = 0x15,
Settings = 0x16,
LibAppletOff = 0x17,
LibAppletWhitelisted = 0x18,
LibAppletAuth = 0x19,
MyPage = 0x1A
LibAppletAuth = 0x19,
MyPage = 0x1A,
}
}

View file

@ -6,7 +6,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE
struct AppletIdentifyInfo
{
public AppletId AppletId;
public uint Padding;
public ulong TitleId;
public uint Padding;
public ulong TitleId;
}
}
}

View file

@ -5,8 +5,8 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE
[StructLayout(LayoutKind.Sequential, Size = 0x4)]
struct AppletProcessLaunchReason
{
public byte Flag;
public byte Flag;
public ushort Unknown1;
public byte Unknown2;
public byte Unknown2;
}
}
}

View file

@ -5,7 +5,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE
[StructLayout(LayoutKind.Sequential, Size = 0x8)]
struct LibraryAppletInfo
{
public AppletId AppletId;
public AppletId AppletId;
public LibraryAppletMode LibraryAppletMode;
}
}
}

View file

@ -9,6 +9,6 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE
PartialForeground,
NoUi,
PartialForegroundWithIndirectDisplay,
AllForegroundInitiallyHidden
AllForegroundInitiallyHidden,
}
}
}

View file

@ -1,5 +1,4 @@
using LibHac.Account;
using LibHac.Common;
using LibHac.Fs;
using LibHac.Ncm;
using LibHac.Ns;
@ -18,20 +17,20 @@ using Ryujinx.Horizon.Common;
using System;
using System.Numerics;
using System.Threading;
using AccountUid = Ryujinx.HLE.HOS.Services.Account.Acc.UserId;
using AccountUid = Ryujinx.HLE.HOS.Services.Account.Acc.UserId;
using ApplicationId = LibHac.Ncm.ApplicationId;
namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.ApplicationProxy
{
class IApplicationFunctions : IpcService
{
private long _defaultSaveDataSize = 200000000;
private long _defaultSaveDataSize = 200000000;
private long _defaultJournalSaveDataSize = 200000000;
private KEvent _gpuErrorDetectedSystemEvent;
private KEvent _friendInvitationStorageChannelEvent;
private KEvent _notificationStorageChannelEvent;
private KEvent _healthWarningDisappearedSystemEvent;
private readonly KEvent _gpuErrorDetectedSystemEvent;
private readonly KEvent _friendInvitationStorageChannelEvent;
private readonly KEvent _notificationStorageChannelEvent;
private readonly KEvent _healthWarningDisappearedSystemEvent;
private int _gpuErrorDetectedSystemEventHandle;
private int _friendInvitationStorageChannelEventHandle;
@ -42,14 +41,14 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
private int _jitLoaded;
private LibHac.HorizonClient _horizon;
private readonly LibHac.HorizonClient _horizon;
public IApplicationFunctions(Horizon system)
{
// TODO: Find where they are signaled.
_gpuErrorDetectedSystemEvent = new KEvent(system.KernelContext);
_gpuErrorDetectedSystemEvent = new KEvent(system.KernelContext);
_friendInvitationStorageChannelEvent = new KEvent(system.KernelContext);
_notificationStorageChannelEvent = new KEvent(system.KernelContext);
_notificationStorageChannelEvent = new KEvent(system.KernelContext);
_healthWarningDisappearedSystemEvent = new KEvent(system.KernelContext);
_horizon = system.LibHacHorizonManager.AmClient;
@ -115,7 +114,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
Uid userId = context.RequestData.ReadStruct<AccountUid>().ToLibHacUid();
// Mask out the low nibble of the program ID to get the application ID
ApplicationId applicationId = new ApplicationId(context.Device.Processes.ActiveApplication.ProgramId & ~0xFul);
ApplicationId applicationId = new(context.Device.Processes.ActiveApplication.ProgramId & ~0xFul);
ApplicationControlProperty nacp = context.Device.Processes.ActiveApplication.ApplicationControlProperties;
@ -137,8 +136,8 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
// TODO: When above calls are implemented, switch to using ns:am
long desiredLanguageCode = context.Device.System.State.DesiredLanguageCode;
int supportedLanguages = (int)context.Device.Processes.ActiveApplication.ApplicationControlProperties.SupportedLanguageFlag;
int firstSupported = BitOperations.TrailingZeroCount(supportedLanguages);
int supportedLanguages = (int)context.Device.Processes.ActiveApplication.ApplicationControlProperties.SupportedLanguageFlag;
int firstSupported = BitOperations.TrailingZeroCount(supportedLanguages);
if (firstSupported > (int)TitleLanguage.BrazilianPortuguese)
{
@ -168,7 +167,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
// SetTerminateResult(u32)
public ResultCode SetTerminateResult(ServiceCtx context)
{
LibHac.Result result = new LibHac.Result(context.RequestData.ReadUInt32());
LibHac.Result result = new(context.RequestData.ReadUInt32());
Logger.Info?.Print(LogClass.ServiceAm, $"Result = 0x{result.Value:x8} ({result.ToStringWithName()}).");
@ -190,14 +189,14 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
public ResultCode ExtendSaveData(ServiceCtx context)
{
SaveDataType saveDataType = (SaveDataType)context.RequestData.ReadUInt64();
Uid userId = context.RequestData.ReadStruct<Uid>();
long saveDataSize = context.RequestData.ReadInt64();
long journalSize = context.RequestData.ReadInt64();
Uid userId = context.RequestData.ReadStruct<Uid>();
long saveDataSize = context.RequestData.ReadInt64();
long journalSize = context.RequestData.ReadInt64();
// NOTE: Service calls nn::fs::ExtendApplicationSaveData.
// Since LibHac currently doesn't support this method, we can stub it for now.
_defaultSaveDataSize = saveDataSize;
_defaultSaveDataSize = saveDataSize;
_defaultJournalSaveDataSize = journalSize;
context.ResponseData.Write((uint)ResultCode.Success);
@ -212,7 +211,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
public ResultCode GetSaveDataSize(ServiceCtx context)
{
SaveDataType saveDataType = (SaveDataType)context.RequestData.ReadUInt64();
Uid userId = context.RequestData.ReadStruct<Uid>();
Uid userId = context.RequestData.ReadStruct<Uid>();
// NOTE: Service calls nn::fs::FindSaveDataWithFilter with SaveDataType = 1 hardcoded.
// Then it calls nn::fs::GetSaveDataAvailableSize and nn::fs::GetSaveDataJournalSize to get the sizes.
@ -235,14 +234,17 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
long journalSize = context.RequestData.ReadInt64();
// Mask out the low nibble of the program ID to get the application ID
ApplicationId applicationId = new ApplicationId(context.Device.Processes.ActiveApplication.ProgramId & ~0xFul);
ApplicationId applicationId = new(context.Device.Processes.ActiveApplication.ProgramId & ~0xFul);
ApplicationControlProperty nacp = context.Device.Processes.ActiveApplication.ApplicationControlProperties;
LibHac.Result result = _horizon.Fs.CreateApplicationCacheStorage(out long requiredSize,
out CacheStorageTargetMedia storageTarget, applicationId, in nacp, index, saveSize, journalSize);
if (result.IsFailure()) return (ResultCode)result.Value;
if (result.IsFailure())
{
return (ResultCode)result.Value;
}
context.ResponseData.Write((ulong)storageTarget);
context.ResponseData.Write(requiredSize);
@ -391,10 +393,10 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
// InitializeApplicationCopyrightFrameBuffer(s32 width, s32 height, handle<copy, transfer_memory> transfer_memory, u64 transfer_memory_size)
public ResultCode InitializeApplicationCopyrightFrameBuffer(ServiceCtx context)
{
int width = context.RequestData.ReadInt32();
int height = context.RequestData.ReadInt32();
ulong transferMemorySize = context.RequestData.ReadUInt64();
int transferMemoryHandle = context.Request.HandleDesc.ToCopy[0];
int width = context.RequestData.ReadInt32();
int height = context.RequestData.ReadInt32();
ulong transferMemorySize = context.RequestData.ReadUInt64();
int transferMemoryHandle = context.Request.HandleDesc.ToCopy[0];
ulong transferMemoryAddress = context.Process.HandleTable.GetObject<KTransferMemory>(transferMemoryHandle).Address;
ResultCode resultCode = ResultCode.InvalidParameters;
@ -437,13 +439,13 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
// SetApplicationCopyrightImage(buffer<bytes, 0x45> frame_buffer, s32 x, s32 y, s32 width, s32 height, s32 window_origin_mode)
public ResultCode SetApplicationCopyrightImage(ServiceCtx context)
{
ulong frameBufferPos = context.Request.SendBuff[0].Position;
ulong frameBufferSize = context.Request.SendBuff[0].Size;
int x = context.RequestData.ReadInt32();
int y = context.RequestData.ReadInt32();
int width = context.RequestData.ReadInt32();
int height = context.RequestData.ReadInt32();
uint windowOriginMode = context.RequestData.ReadUInt32();
ulong frameBufferPos = context.Request.SendBuff[0].Position;
ulong frameBufferSize = context.Request.SendBuff[0].Size;
int x = context.RequestData.ReadInt32();
int y = context.RequestData.ReadInt32();
int width = context.RequestData.ReadInt32();
int height = context.RequestData.ReadInt32();
uint windowOriginMode = context.RequestData.ReadUInt32();
ResultCode resultCode = ResultCode.InvalidParameters;
@ -653,11 +655,11 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
if (Interlocked.Exchange(ref _jitLoaded, 1) == 0)
{
string jitPath = context.Device.System.ContentManager.GetInstalledContentPath(0x010000000000003B, StorageId.BuiltInSystem, NcaContentType.Program);
string filePath = context.Device.FileSystem.SwitchPathToSystemPath(jitPath);
string filePath = FileSystem.VirtualFileSystem.SwitchPathToSystemPath(jitPath);
if (string.IsNullOrWhiteSpace(filePath))
{
throw new InvalidSystemResourceException($"JIT (010000000000003B) system title not found! The JIT will not work, provide the system archive to fix this error. (See https://github.com/Ryujinx/Ryujinx#requirements for more information)");
throw new InvalidSystemResourceException("JIT (010000000000003B) system title not found! The JIT will not work, provide the system archive to fix this error. (See https://github.com/Ryujinx/Ryujinx#requirements for more information)");
}
context.Device.LoadNca(filePath);
@ -672,4 +674,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
return ResultCode.Success;
}
}
}
}

View file

@ -4,6 +4,6 @@
{
UserChannel = 1,
PreselectedUser,
Unknown
Unknown,
}
}

View file

@ -4,6 +4,6 @@
{
ExecuteProgram,
SubApplicationProgram,
RestartProgram
RestartProgram,
}
}

View file

@ -84,4 +84,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService
return ResultCode.Success;
}
}
}
}

View file

@ -16,4 +16,4 @@ namespace Ryujinx.HLE.HOS.Services.Am
return ResultCode.Success;
}
}
}
}

View file

@ -5,4 +5,4 @@
{
public IPolicyManagerSystem(ServiceCtx context) { }
}
}
}

View file

@ -5,4 +5,4 @@
{
public IOperationModeManager(ServiceCtx context) { }
}
}
}

View file

@ -2,29 +2,29 @@ namespace Ryujinx.HLE.HOS.Services.Am
{
enum ResultCode
{
ModuleId = 128,
ModuleId = 128,
ErrorCodeShift = 9,
Success = 0,
NotAvailable = (2 << ErrorCodeShift) | ModuleId,
NoMessages = (3 << ErrorCodeShift) | ModuleId,
AppletLaunchFailed = (35 << ErrorCodeShift) | ModuleId,
TitleIdNotFound = (37 << ErrorCodeShift) | ModuleId,
ObjectInvalid = (500 << ErrorCodeShift) | ModuleId,
IStorageInUse = (502 << ErrorCodeShift) | ModuleId,
OutOfBounds = (503 << ErrorCodeShift) | ModuleId,
BufferNotAcquired = (504 << ErrorCodeShift) | ModuleId,
BufferAlreadyAcquired = (505 << ErrorCodeShift) | ModuleId,
InvalidParameters = (506 << ErrorCodeShift) | ModuleId,
OpenedAsWrongType = (511 << ErrorCodeShift) | ModuleId,
NotAvailable = (2 << ErrorCodeShift) | ModuleId,
NoMessages = (3 << ErrorCodeShift) | ModuleId,
AppletLaunchFailed = (35 << ErrorCodeShift) | ModuleId,
TitleIdNotFound = (37 << ErrorCodeShift) | ModuleId,
ObjectInvalid = (500 << ErrorCodeShift) | ModuleId,
IStorageInUse = (502 << ErrorCodeShift) | ModuleId,
OutOfBounds = (503 << ErrorCodeShift) | ModuleId,
BufferNotAcquired = (504 << ErrorCodeShift) | ModuleId,
BufferAlreadyAcquired = (505 << ErrorCodeShift) | ModuleId,
InvalidParameters = (506 << ErrorCodeShift) | ModuleId,
OpenedAsWrongType = (511 << ErrorCodeShift) | ModuleId,
UnbalancedFatalSection = (512 << ErrorCodeShift) | ModuleId,
NullObject = (518 << ErrorCodeShift) | ModuleId,
NullObject = (518 << ErrorCodeShift) | ModuleId,
MemoryAllocationFailed = (600 << ErrorCodeShift) | ModuleId,
StackPoolExhausted = (712 << ErrorCodeShift) | ModuleId,
DebugModeNotEnabled = (974 << ErrorCodeShift) | ModuleId,
DevFunctionNotEnabled = (980 << ErrorCodeShift) | ModuleId,
NotImplemented = (998 << ErrorCodeShift) | ModuleId,
Stubbed = (999 << ErrorCodeShift) | ModuleId
StackPoolExhausted = (712 << ErrorCodeShift) | ModuleId,
DebugModeNotEnabled = (974 << ErrorCodeShift) | ModuleId,
DevFunctionNotEnabled = (980 << ErrorCodeShift) | ModuleId,
NotImplemented = (998 << ErrorCodeShift) | ModuleId,
Stubbed = (999 << ErrorCodeShift) | ModuleId,
}
}

View file

@ -5,4 +5,4 @@
{
public IPowerStateInterface(ServiceCtx context) { }
}
}
}

View file

@ -5,4 +5,4 @@
{
public IManager(ServiceCtx context) { }
}
}
}

View file

@ -40,4 +40,4 @@ namespace Ryujinx.HLE.HOS.Services.Apm
return ResultCode.Success;
}
}
}
}

View file

@ -16,4 +16,4 @@ namespace Ryujinx.HLE.HOS.Services.Apm
return ResultCode.Success;
}
}
}
}

View file

@ -12,7 +12,7 @@ namespace Ryujinx.HLE.HOS.Services.Apm
// SetPerformanceConfiguration(nn::apm::PerformanceMode, nn::apm::PerformanceConfiguration)
public ResultCode SetPerformanceConfiguration(ServiceCtx context)
{
PerformanceMode performanceMode = (PerformanceMode)context.RequestData.ReadInt32();
PerformanceMode performanceMode = (PerformanceMode)context.RequestData.ReadInt32();
PerformanceConfiguration performanceConfiguration = (PerformanceConfiguration)context.RequestData.ReadInt32();
return SetPerformanceConfiguration(performanceMode, performanceConfiguration);
@ -42,4 +42,4 @@ namespace Ryujinx.HLE.HOS.Services.Apm
return ResultCode.Success;
}
}
}
}

View file

@ -39,4 +39,4 @@ namespace Ryujinx.HLE.HOS.Services.Apm
return ResultCode.Success;
}
}
}
}

View file

@ -28,4 +28,4 @@
return _context.Device.System.PerformanceState.CpuOverclockEnabled;
}
}
}
}

View file

@ -7,19 +7,19 @@
public bool CpuOverclockEnabled = false;
public PerformanceMode PerformanceMode = PerformanceMode.Default;
public CpuBoostMode CpuBoostMode = CpuBoostMode.Disabled;
public CpuBoostMode CpuBoostMode = CpuBoostMode.Disabled;
public PerformanceConfiguration DefaultPerformanceConfiguration = PerformanceConfiguration.PerformanceConfiguration7;
public PerformanceConfiguration BoostPerformanceConfiguration = PerformanceConfiguration.PerformanceConfiguration8;
public PerformanceConfiguration BoostPerformanceConfiguration = PerformanceConfiguration.PerformanceConfiguration8;
public PerformanceConfiguration GetCurrentPerformanceConfiguration(PerformanceMode performanceMode)
{
return performanceMode switch
{
PerformanceMode.Default => DefaultPerformanceConfiguration,
PerformanceMode.Boost => BoostPerformanceConfiguration,
_ => PerformanceConfiguration.PerformanceConfiguration7
PerformanceMode.Boost => BoostPerformanceConfiguration,
_ => PerformanceConfiguration.PerformanceConfiguration7,
};
}
}
}
}

View file

@ -2,11 +2,11 @@ namespace Ryujinx.HLE.HOS.Services.Apm
{
enum ResultCode
{
ModuleId = 148,
ModuleId = 148,
ErrorCodeShift = 9,
Success = 0,
InvalidParameters = (1 << ErrorCodeShift) | ModuleId
InvalidParameters = (1 << ErrorCodeShift) | ModuleId,
}
}
}

View file

@ -6,7 +6,7 @@ namespace Ryujinx.HLE.HOS.Services.Apm
{
private readonly ServiceCtx _context;
public SessionServer(ServiceCtx context) : base(context)
public SessionServer(ServiceCtx context) : base(context)
{
_context = context;
}
@ -55,4 +55,4 @@ namespace Ryujinx.HLE.HOS.Services.Apm
// NOTE: This call seems to overclock the system, since we emulate it, it's fine to do nothing instead.
}
}
}
}

View file

@ -25,4 +25,4 @@
return _context.Device.System.PerformanceState.GetCurrentPerformanceConfiguration(_context.Device.System.PerformanceState.PerformanceMode);
}
}
}
}

View file

@ -2,8 +2,8 @@
{
enum CpuBoostMode
{
Disabled = 0,
BoostCPU = 1, // Uses PerformanceConfiguration13 and PerformanceConfiguration14, or PerformanceConfiguration15 and PerformanceConfiguration16
ConservePower = 2 // Uses PerformanceConfiguration15 and PerformanceConfiguration16.
Disabled = 0,
BoostCPU = 1, // Uses PerformanceConfiguration13 and PerformanceConfiguration14, or PerformanceConfiguration15 and PerformanceConfiguration16
ConservePower = 2, // Uses PerformanceConfiguration15 and PerformanceConfiguration16.
}
}
}

View file

@ -2,21 +2,21 @@
{
enum PerformanceConfiguration : uint // Clocks are all in MHz.
{ // CPU | GPU | RAM | NOTE
PerformanceConfiguration1 = 0x00010000, // 1020 | 384 | 1600 | Only available while docked.
PerformanceConfiguration2 = 0x00010001, // 1020 | 768 | 1600 | Only available while docked.
PerformanceConfiguration3 = 0x00010002, // 1224 | 691.2 | 1600 | Only available for SDEV units.
PerformanceConfiguration4 = 0x00020000, // 1020 | 230.4 | 1600 | Only available for SDEV units.
PerformanceConfiguration5 = 0x00020001, // 1020 | 307.2 | 1600 |
PerformanceConfiguration6 = 0x00020002, // 1224 | 230.4 | 1600 |
PerformanceConfiguration7 = 0x00020003, // 1020 | 307 | 1331.2 |
PerformanceConfiguration8 = 0x00020004, // 1020 | 384 | 1331.2 |
PerformanceConfiguration9 = 0x00020005, // 1020 | 307.2 | 1065.6 |
PerformanceConfiguration1 = 0x00010000, // 1020 | 384 | 1600 | Only available while docked.
PerformanceConfiguration2 = 0x00010001, // 1020 | 768 | 1600 | Only available while docked.
PerformanceConfiguration3 = 0x00010002, // 1224 | 691.2 | 1600 | Only available for SDEV units.
PerformanceConfiguration4 = 0x00020000, // 1020 | 230.4 | 1600 | Only available for SDEV units.
PerformanceConfiguration5 = 0x00020001, // 1020 | 307.2 | 1600 |
PerformanceConfiguration6 = 0x00020002, // 1224 | 230.4 | 1600 |
PerformanceConfiguration7 = 0x00020003, // 1020 | 307 | 1331.2 |
PerformanceConfiguration8 = 0x00020004, // 1020 | 384 | 1331.2 |
PerformanceConfiguration9 = 0x00020005, // 1020 | 307.2 | 1065.6 |
PerformanceConfiguration10 = 0x00020006, // 1020 | 384 | 1065.6 |
PerformanceConfiguration11 = 0x92220007, // 1020 | 460.8 | 1600 |
PerformanceConfiguration12 = 0x92220008, // 1020 | 460.8 | 1331.2 |
PerformanceConfiguration13 = 0x92220009, // 1785 | 768 | 1600 | 7.0.0+
PerformanceConfiguration14 = 0x9222000A, // 1785 | 768 | 1331.2 | 7.0.0+
PerformanceConfiguration15 = 0x9222000B, // 1020 | 768 | 1600 | 7.0.0+
PerformanceConfiguration16 = 0x9222000C // 1020 | 768 | 1331.2 | 7.0.0+
PerformanceConfiguration16 = 0x9222000C, // 1020 | 768 | 1331.2 | 7.0.0+
}
}
}

View file

@ -3,6 +3,6 @@
enum PerformanceMode : uint
{
Default = 0,
Boost = 1
Boost = 1,
}
}
}

View file

@ -5,10 +5,10 @@ namespace Ryujinx.HLE.HOS.Services.Arp
class ApplicationLaunchProperty
{
public ulong TitleId;
public int Version;
public byte BaseGameStorageId;
public byte UpdateGameStorageId;
#pragma warning disable CS0649
public int Version;
public byte BaseGameStorageId;
public byte UpdateGameStorageId;
#pragma warning disable CS0649 // Field is never assigned to
public short Padding;
#pragma warning restore CS0649
@ -18,10 +18,10 @@ namespace Ryujinx.HLE.HOS.Services.Arp
{
return new ApplicationLaunchProperty
{
TitleId = 0x00,
Version = 0x00,
BaseGameStorageId = (byte)StorageId.BuiltInSystem,
UpdateGameStorageId = (byte)StorageId.None
TitleId = 0x00,
Version = 0x00,
BaseGameStorageId = (byte)StorageId.BuiltInSystem,
UpdateGameStorageId = (byte)StorageId.None,
};
}
}
@ -33,11 +33,11 @@ namespace Ryujinx.HLE.HOS.Services.Arp
return new ApplicationLaunchProperty
{
TitleId = context.Device.Processes.ActiveApplication.ProgramId,
Version = 0x00,
BaseGameStorageId = (byte)StorageId.BuiltInSystem,
UpdateGameStorageId = (byte)StorageId.None
TitleId = context.Device.Processes.ActiveApplication.ProgramId,
Version = 0x00,
BaseGameStorageId = (byte)StorageId.BuiltInSystem,
UpdateGameStorageId = (byte)StorageId.None,
};
}
}
}
}

View file

@ -5,4 +5,4 @@
{
public IReader(ServiceCtx context) { }
}
}
}

View file

@ -5,4 +5,4 @@
{
public IWriter(ServiceCtx context) { }
}
}
}

View file

@ -3,7 +3,6 @@ using LibHac.Common;
using LibHac.Ncm;
using LibHac.Ns;
using System;
using ApplicationId = LibHac.ApplicationId;
namespace Ryujinx.HLE.HOS.Services.Arp
@ -17,7 +16,7 @@ namespace Ryujinx.HLE.HOS.Services.Arp
launchProperty = new LibHac.Arp.ApplicationLaunchProperty
{
StorageId = StorageId.BuiltInUser,
ApplicationId = ApplicationId
ApplicationId = ApplicationId,
};
return Result.Success;
@ -30,7 +29,7 @@ namespace Ryujinx.HLE.HOS.Services.Arp
launchProperty = new LibHac.Arp.ApplicationLaunchProperty
{
StorageId = StorageId.BuiltInUser,
ApplicationId = applicationId
ApplicationId = applicationId,
};
return Result.Success;
@ -73,4 +72,4 @@ namespace Ryujinx.HLE.HOS.Services.Arp
return Result.Success;
}
}
}
}

View file

@ -10,9 +10,9 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioIn
{
class AudioIn : IAudioIn
{
private AudioInputSystem _system;
private uint _processHandle;
private KernelContext _kernelContext;
private readonly AudioInputSystem _system;
private readonly uint _processHandle;
private readonly KernelContext _kernelContext;
public AudioIn(AudioInputSystem system, KernelContext kernelContext, uint processHandle)
{
@ -80,9 +80,9 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioIn
{
IWritableEvent outEvent = _system.RegisterBufferEvent();
if (outEvent is AudioKernelEvent)
if (outEvent is AudioKernelEvent kernelEvent)
{
return ((AudioKernelEvent)outEvent).Event;
return kernelEvent.Event;
}
else
{
@ -105,4 +105,4 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioIn
return (ResultCode)_system.Stop();
}
}
}
}

View file

@ -11,7 +11,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioIn
{
class AudioInServer : DisposableIpcService
{
private IAudioIn _impl;
private readonly IAudioIn _impl;
public AudioInServer(IAudioIn impl)
{
@ -77,14 +77,12 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioIn
ulong position = context.Request.ReceiveBuff[0].Position;
ulong size = context.Request.ReceiveBuff[0].Size;
using (WritableRegion outputRegion = context.Memory.GetWritableRegion((ulong)position, (int)size))
{
ResultCode result = _impl.GetReleasedBuffers(MemoryMarshal.Cast<byte, ulong>(outputRegion.Memory.Span), out uint releasedCount);
using WritableRegion outputRegion = context.Memory.GetWritableRegion((ulong)position, (int)size);
ResultCode result = _impl.GetReleasedBuffers(MemoryMarshal.Cast<byte, ulong>(outputRegion.Memory.Span), out uint releasedCount);
context.ResponseData.Write(releasedCount);
context.ResponseData.Write(releasedCount);
return result;
}
return result;
}
[CommandCmif(6)]
@ -131,14 +129,12 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioIn
{
(ulong position, ulong size) = context.Request.GetBufferType0x22();
using (WritableRegion outputRegion = context.Memory.GetWritableRegion(position, (int)size))
{
ResultCode result = _impl.GetReleasedBuffers(MemoryMarshal.Cast<byte, ulong>(outputRegion.Memory.Span), out uint releasedCount);
using WritableRegion outputRegion = context.Memory.GetWritableRegion(position, (int)size);
ResultCode result = _impl.GetReleasedBuffers(MemoryMarshal.Cast<byte, ulong>(outputRegion.Memory.Span), out uint releasedCount);
context.ResponseData.Write(releasedCount);
context.ResponseData.Write(releasedCount);
return result;
}
return result;
}
[CommandCmif(10)] // 3.0.0+

View file

@ -7,7 +7,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio
{
class AudioInManager : IAudioInManager
{
private AudioInManagerImpl _impl;
private readonly AudioInManagerImpl _impl;
public AudioInManager(AudioInManagerImpl impl)
{

View file

@ -12,7 +12,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio
{
private const int AudioInNameSize = 0x100;
private IAudioInManager _impl;
private readonly IAudioInManager _impl;
public AudioInManagerServer(ServiceCtx context) : this(context, new AudioInManager(context.Device.System.AudioInputManager)) { }
@ -69,7 +69,9 @@ namespace Ryujinx.HLE.HOS.Services.Audio
ulong deviceNameInputSize = context.Request.SendBuff[0].Size;
ulong deviceNameOutputPosition = context.Request.ReceiveBuff[0].Position;
#pragma warning disable IDE0059 // Remove unnecessary value assignment
ulong deviceNameOutputSize = context.Request.ReceiveBuff[0].Size;
#pragma warning restore IDE0059
uint processHandle = (uint)context.Request.HandleDesc.ToCopy[0];
@ -136,7 +138,9 @@ namespace Ryujinx.HLE.HOS.Services.Audio
ulong appletResourceUserId = context.RequestData.ReadUInt64();
(ulong deviceNameInputPosition, ulong deviceNameInputSize) = context.Request.GetBufferType0x21();
#pragma warning disable IDE0059 // Remove unnecessary value assignment
(ulong deviceNameOutputPosition, ulong deviceNameOutputSize) = context.Request.GetBufferType0x22();
#pragma warning restore IDE0059
uint processHandle = (uint)context.Request.HandleDesc.ToCopy[0];
@ -200,7 +204,9 @@ namespace Ryujinx.HLE.HOS.Services.Audio
public ResultCode OpenAudioInProtocolSpecified(ServiceCtx context)
{
// NOTE: We always assume that only the default device will be plugged (we never report any USB Audio Class type devices).
#pragma warning disable IDE0059 // Remove unnecessary value assignment
bool protocolSpecifiedRelated = context.RequestData.ReadUInt64() == 1;
#pragma warning restore IDE0059
AudioInputConfiguration inputConfiguration = context.RequestData.ReadStruct<AudioInputConfiguration>();
ulong appletResourceUserId = context.RequestData.ReadUInt64();
@ -209,7 +215,9 @@ namespace Ryujinx.HLE.HOS.Services.Audio
ulong deviceNameInputSize = context.Request.SendBuff[0].Size;
ulong deviceNameOutputPosition = context.Request.ReceiveBuff[0].Position;
#pragma warning disable IDE0051, IDE0059 // Remove unused private member
ulong deviceNameOutputSize = context.Request.ReceiveBuff[0].Size;
#pragma warning restore IDE0051, IDE0059
uint processHandle = (uint)context.Request.HandleDesc.ToCopy[0];

View file

@ -10,9 +10,9 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioOut
{
class AudioOut : IAudioOut
{
private AudioOutputSystem _system;
private uint _processHandle;
private KernelContext _kernelContext;
private readonly AudioOutputSystem _system;
private readonly uint _processHandle;
private readonly KernelContext _kernelContext;
public AudioOut(AudioOutputSystem system, KernelContext kernelContext, uint processHandle)
{
@ -80,9 +80,9 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioOut
{
IWritableEvent outEvent = _system.RegisterBufferEvent();
if (outEvent is AudioKernelEvent)
if (outEvent is AudioKernelEvent kernelEvent)
{
return ((AudioKernelEvent)outEvent).Event;
return kernelEvent.Event;
}
else
{

View file

@ -11,7 +11,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioOut
{
class AudioOutServer : DisposableIpcService
{
private IAudioOut _impl;
private readonly IAudioOut _impl;
public AudioOutServer(IAudioOut impl)
{
@ -77,14 +77,12 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioOut
ulong position = context.Request.ReceiveBuff[0].Position;
ulong size = context.Request.ReceiveBuff[0].Size;
using (WritableRegion outputRegion = context.Memory.GetWritableRegion(position, (int)size))
{
ResultCode result = _impl.GetReleasedBuffers(MemoryMarshal.Cast<byte, ulong>(outputRegion.Memory.Span), out uint releasedCount);
using WritableRegion outputRegion = context.Memory.GetWritableRegion(position, (int)size);
ResultCode result = _impl.GetReleasedBuffers(MemoryMarshal.Cast<byte, ulong>(outputRegion.Memory.Span), out uint releasedCount);
context.ResponseData.Write(releasedCount);
context.ResponseData.Write(releasedCount);
return result;
}
return result;
}
[CommandCmif(6)]
@ -117,14 +115,12 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioOut
{
(ulong position, ulong size) = context.Request.GetBufferType0x22();
using (WritableRegion outputRegion = context.Memory.GetWritableRegion(position, (int)size))
{
ResultCode result = _impl.GetReleasedBuffers(MemoryMarshal.Cast<byte, ulong>(outputRegion.Memory.Span), out uint releasedCount);
using WritableRegion outputRegion = context.Memory.GetWritableRegion(position, (int)size);
ResultCode result = _impl.GetReleasedBuffers(MemoryMarshal.Cast<byte, ulong>(outputRegion.Memory.Span), out uint releasedCount);
context.ResponseData.Write(releasedCount);
context.ResponseData.Write(releasedCount);
return result;
}
return result;
}
[CommandCmif(9)] // 4.0.0+

View file

@ -7,7 +7,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio
{
class AudioOutManager : IAudioOutManager
{
private AudioOutManagerImpl _impl;
private readonly AudioOutManagerImpl _impl;
public AudioOutManager(AudioOutManagerImpl impl)
{

View file

@ -12,7 +12,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio
{
private const int AudioOutNameSize = 0x100;
private IAudioOutManager _impl;
private readonly IAudioOutManager _impl;
public AudioOutManagerServer(ServiceCtx context) : this(context, new AudioOutManager(context.Device.System.AudioOutputManager)) { }
@ -69,7 +69,9 @@ namespace Ryujinx.HLE.HOS.Services.Audio
ulong deviceNameInputSize = context.Request.SendBuff[0].Size;
ulong deviceNameOutputPosition = context.Request.ReceiveBuff[0].Position;
#pragma warning disable IDE0059 // Remove unnecessary value assignment
ulong deviceNameOutputSize = context.Request.ReceiveBuff[0].Size;
#pragma warning restore IDE0059
uint processHandle = (uint)context.Request.HandleDesc.ToCopy[0];
@ -136,7 +138,9 @@ namespace Ryujinx.HLE.HOS.Services.Audio
ulong appletResourceUserId = context.RequestData.ReadUInt64();
(ulong deviceNameInputPosition, ulong deviceNameInputSize) = context.Request.GetBufferType0x21();
#pragma warning disable IDE0059 // Remove unnecessary value assignment
(ulong deviceNameOutputPosition, ulong deviceNameOutputSize) = context.Request.GetBufferType0x22();
#pragma warning restore IDE0059
uint processHandle = (uint)context.Request.HandleDesc.ToCopy[0];

View file

@ -7,13 +7,15 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioRenderer
{
class AudioDevice : IAudioDevice
{
private VirtualDeviceSession[] _sessions;
private ulong _appletResourceId;
private int _revision;
private bool _isUsbDeviceSupported;
private readonly VirtualDeviceSession[] _sessions;
#pragma warning disable IDE0052 // Remove unread private member
private readonly ulong _appletResourceId;
private readonly int _revision;
#pragma warning restore IDE0052
private readonly bool _isUsbDeviceSupported;
private VirtualDeviceSessionRegistry _registry;
private KEvent _systemEvent;
private readonly VirtualDeviceSessionRegistry _registry;
private readonly KEvent _systemEvent;
public AudioDevice(VirtualDeviceSessionRegistry registry, KernelContext context, ulong appletResourceId, int revision)
{
@ -21,7 +23,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioRenderer
_appletResourceId = appletResourceId;
_revision = revision;
BehaviourContext behaviourContext = new BehaviourContext();
BehaviourContext behaviourContext = new();
behaviourContext.SetUserRevision(revision);
_isUsbDeviceSupported = behaviourContext.IsAudioUsbDeviceOutputSupported();

View file

@ -12,7 +12,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioRenderer
{
private const int AudioDeviceNameSize = 0x100;
private IAudioDevice _impl;
private readonly IAudioDevice _impl;
public AudioDeviceServer(IAudioDevice impl)
{

View file

@ -7,7 +7,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioRenderer
{
class AudioRenderer : IAudioRenderer
{
private AudioRenderSystem _impl;
private readonly AudioRenderSystem _impl;
public AudioRenderer(AudioRenderSystem impl)
{
@ -55,9 +55,9 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioRenderer
if (resultCode == ResultCode.Success)
{
if (outEvent is AudioKernelEvent)
if (outEvent is AudioKernelEvent kernelEvent)
{
systemEvent = ((AudioKernelEvent)outEvent).Event;
systemEvent = kernelEvent.Event;
}
else
{

View file

@ -10,7 +10,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioRenderer
{
class AudioRendererServer : DisposableIpcService
{
private IAudioRenderer _impl;
private readonly IAudioRenderer _impl;
public AudioRendererServer(IAudioRenderer impl)
{
@ -69,29 +69,27 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioRenderer
ReadOnlyMemory<byte> input = context.Memory.GetSpan(inputPosition, (int)inputSize).ToArray();
using (IMemoryOwner<byte> outputOwner = ByteMemoryPool.RentCleared(outputSize))
using (IMemoryOwner<byte> performanceOutputOwner = ByteMemoryPool.RentCleared(performanceOutputSize))
using IMemoryOwner<byte> outputOwner = ByteMemoryPool.RentCleared(outputSize);
using IMemoryOwner<byte> performanceOutputOwner = ByteMemoryPool.RentCleared(performanceOutputSize);
Memory<byte> output = outputOwner.Memory;
Memory<byte> performanceOutput = performanceOutputOwner.Memory;
using MemoryHandle outputHandle = output.Pin();
using MemoryHandle performanceOutputHandle = performanceOutput.Pin();
ResultCode result = _impl.RequestUpdate(output, performanceOutput, input);
if (result == ResultCode.Success)
{
Memory<byte> output = outputOwner.Memory;
Memory<byte> performanceOutput = performanceOutputOwner.Memory;
using MemoryHandle outputHandle = output.Pin();
using MemoryHandle performanceOutputHandle = performanceOutput.Pin();
ResultCode result = _impl.RequestUpdate(output, performanceOutput, input);
if (result == ResultCode.Success)
{
context.Memory.Write(outputPosition, output.Span);
context.Memory.Write(performanceOutputPosition, performanceOutput.Span);
}
else
{
Logger.Error?.Print(LogClass.ServiceAudio, $"Error while processing renderer update: 0x{(int)result:X}");
}
return result;
context.Memory.Write(outputPosition, output.Span);
context.Memory.Write(performanceOutputPosition, performanceOutput.Span);
}
else
{
Logger.Error?.Print(LogClass.ServiceAudio, $"Error while processing renderer update: 0x{(int)result:X}");
}
return result;
}
[CommandCmif(5)]

View file

@ -6,7 +6,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioRenderer
{
string[] ListAudioDeviceName();
ResultCode SetAudioDeviceOutputVolume(string name, float volume);
ResultCode GetAudioDeviceOutputVolume(string name, out float volume);
ResultCode GetAudioDeviceOutputVolume(string name, out float volume);
string GetActiveAudioDeviceName();
KEvent QueryAudioDeviceSystemEvent();
uint GetActiveChannelCount();

View file

@ -10,8 +10,8 @@ namespace Ryujinx.HLE.HOS.Services.Audio
{
class AudioRendererManager : IAudioRendererManager
{
private AudioRendererManagerImpl _impl;
private VirtualDeviceSessionRegistry _registry;
private readonly AudioRendererManagerImpl _impl;
private readonly VirtualDeviceSessionRegistry _registry;
public AudioRendererManager(AudioRendererManagerImpl impl, VirtualDeviceSessionRegistry registry)
{

View file

@ -12,7 +12,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio
{
private const int InitialRevision = ('R' << 0) | ('E' << 8) | ('V' << 16) | ('1' << 24);
private IAudioRendererManager _impl;
private readonly IAudioRendererManager _impl;
public AudioRendererManagerServer(ServiceCtx context) : this(context, new AudioRendererManager(context.Device.System.AudioRendererManager, context.Device.System.AudioDeviceSessionRegistry)) { }

Some files were not shown because too many files have changed in this diff Show more