diff options
Diffstat (limited to 'src/Ryujinx.HLE/HOS/Services')
695 files changed, 5024 insertions, 4577 deletions
diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountManager.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountManager.cs index f5364329..a6dde3c5 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountManager.cs @@ -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; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountSaveDataManager.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountSaveDataManager.cs index 535779d2..c2ae0119 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountSaveDataManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountSaveDataManager.cs @@ -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); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/IManagerForApplication.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/IManagerForApplication.cs index 9c058cb5..3cb46d20 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/IManagerForApplication.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/IManagerForApplication.cs @@ -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; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/IManagerForSystemService.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/IManagerForSystemService.cs index ecd51687..8510837b 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/IManagerForSystemService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/IManagerForSystemService.cs @@ -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); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/IProfile.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/IProfile.cs index 14911dfb..a0021917 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/IProfile.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/IProfile.cs @@ -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); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/IProfileEditor.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/IProfileEditor.cs index 64b6070f..5d5d0dd6 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/IProfileEditor.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/IProfileEditor.cs @@ -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); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/ManagerServer.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/ManagerServer.cs index 97240311..c43186de 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/ManagerServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/ManagerServer.cs @@ -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; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/ProfileServer.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/ProfileServer.cs index 8e29f94b..08400baf 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/ProfileServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/ProfileServer.cs @@ -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; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/ApplicationServiceServer.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/ApplicationServiceServer.cs index d9f9864a..b30a81e9 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/ApplicationServiceServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/ApplicationServiceServer.cs @@ -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; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AsyncContext/AsyncExecution.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AsyncContext/AsyncExecution.cs index 2ea92b11..c5f3d91e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AsyncContext/AsyncExecution.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AsyncContext/AsyncExecution.cs @@ -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(); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/IAccountServiceForAdministrator.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/IAccountServiceForAdministrator.cs index 6a457f04..121b7937 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/IAccountServiceForAdministrator.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/IAccountServiceForAdministrator.cs @@ -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; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/IAccountServiceForApplication.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/IAccountServiceForApplication.cs index 8ec83e5c..98af1069 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/IAccountServiceForApplication.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/IAccountServiceForApplication.cs @@ -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; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/IAccountServiceForSystemService.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/IAccountServiceForSystemService.cs index 3b5f3b03..a586d21c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/IAccountServiceForSystemService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/IAccountServiceForSystemService.cs @@ -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); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/IAsyncContext.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/IAsyncContext.cs index c9af0727..2fa354b1 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/IAsyncContext.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/IAsyncContext.cs @@ -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; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/IAsyncNetworkServiceLicenseKindContext.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/IAsyncNetworkServiceLicenseKindContext.cs index 1fa5cf2a..a7b0c063 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/IAsyncNetworkServiceLicenseKindContext.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/IAsyncNetworkServiceLicenseKindContext.cs @@ -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) { diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/IBaasAccessTokenAccessor.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/IBaasAccessTokenAccessor.cs index 223be2f5..f86e3074 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/IBaasAccessTokenAccessor.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/IBaasAccessTokenAccessor.cs @@ -5,4 +5,4 @@ { public IBaasAccessTokenAccessor(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/ProfilesJsonSerializerContext.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/ProfilesJsonSerializerContext.cs index 6b54898e..d6446e73 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/ProfilesJsonSerializerContext.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/ProfilesJsonSerializerContext.cs @@ -8,4 +8,4 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc internal partial class ProfilesJsonSerializerContext : JsonSerializerContext { } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/AccountServiceFlag.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/AccountServiceFlag.cs index a991f977..5dbf9a67 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/AccountServiceFlag.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/AccountServiceFlag.cs @@ -2,9 +2,9 @@ { enum AccountServiceFlag { - Administrator = 100, - SystemService = 101, - Application = 102, - BaasAccessTokenAccessor = 200 + Administrator = 100, + SystemService = 101, + Application = 102, + BaasAccessTokenAccessor = 200, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/AccountState.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/AccountState.cs index 1699abfb..0e35b481 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/AccountState.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/AccountState.cs @@ -7,6 +7,6 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc public enum AccountState { Closed, - Open + Open, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/NetworkServiceLicenseKind.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/NetworkServiceLicenseKind.cs index a33e2670..a766edef 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/NetworkServiceLicenseKind.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/NetworkServiceLicenseKind.cs @@ -3,6 +3,6 @@ enum NetworkServiceLicenseKind : uint { NoSubscription, - Subscribed + Subscribed, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/ProfilesJson.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/ProfilesJson.cs index 09f9d142..4e22f434 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/ProfilesJson.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/ProfilesJson.cs @@ -7,4 +7,4 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.Types public List<UserProfileJson> Profiles { get; set; } public string LastOpened { get; set; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/UserId.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/UserId.cs index e5577a94..ed7bf4e5 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/UserId.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/UserId.cs @@ -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); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/UserProfile.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/UserProfile.cs index 210b369c..4482de2d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/UserProfile.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/UserProfile.cs @@ -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; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/UserProfileJson.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/UserProfileJson.cs index 06ff4833..e51aa8d1 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/UserProfileJson.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/Types/UserProfileJson.cs @@ -9,4 +9,4 @@ public long LastModifiedTimestamp { get; set; } public byte[] Image { get; set; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Dauth/IService.cs b/src/Ryujinx.HLE/HOS/Services/Account/Dauth/IService.cs index 72301349..698c01a4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Dauth/IService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Dauth/IService.cs @@ -5,4 +5,4 @@ { public IService(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Account/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Account/ResultCode.cs index 34114ec9..6bd3cce8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/ResultCode.cs @@ -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, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/ILibraryAppletProxy.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/ILibraryAppletProxy.cs index bf86aaaa..6821c711 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/ILibraryAppletProxy.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/ILibraryAppletProxy.cs @@ -102,4 +102,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/ISystemAppletProxy.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/ISystemAppletProxy.cs index 93dff041..dd015fd8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/ISystemAppletProxy.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/ISystemAppletProxy.cs @@ -110,4 +110,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletCreator/ILibraryAppletAccessor.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletCreator/ILibraryAppletAccessor.cs index 0057eba3..d35cfdbe 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletCreator/ILibraryAppletAccessor.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletCreator/ILibraryAppletAccessor.cs @@ -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."); diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletProxy/AppletStandalone.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletProxy/AppletStandalone.cs index 69967c56..b523f02f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletProxy/AppletStandalone.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletProxy/AppletStandalone.cs @@ -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[]>(); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletProxy/ILibraryAppletSelfAccessor.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletProxy/ILibraryAppletSelfAccessor.cs index 176bd632..85bdd985 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletProxy/ILibraryAppletSelfAccessor.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletProxy/ILibraryAppletSelfAccessor.cs @@ -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; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletProxy/IProcessWindingController.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletProxy/IProcessWindingController.cs index 6acd18cd..e1857fb3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletProxy/IProcessWindingController.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletProxy/IProcessWindingController.cs @@ -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; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IAppletCommonFunctions.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IAppletCommonFunctions.cs index c42202b8..fbcc3320 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IAppletCommonFunctions.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IAppletCommonFunctions.cs @@ -4,4 +4,4 @@ { public IAppletCommonFunctions() { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IApplicationCreator.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IApplicationCreator.cs index 79e5b050..502324ea 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IApplicationCreator.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IApplicationCreator.cs @@ -4,4 +4,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys { public IApplicationCreator() { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IAudioController.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IAudioController.cs index 48dd42e4..05a4b0a6 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IAudioController.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IAudioController.cs @@ -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; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ICommonStateGetter.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ICommonStateGetter.cs index 5e7d0bae..0d2ec8bc 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ICommonStateGetter.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ICommonStateGetter.cs @@ -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 } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IDebugFunctions.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IDebugFunctions.cs index 51a112fd..61cef13b 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IDebugFunctions.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IDebugFunctions.cs @@ -4,4 +4,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys { public IDebugFunctions() { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IDisplayController.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IDisplayController.cs index 92c97d86..6bd35a77 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IDisplayController.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IDisplayController.cs @@ -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; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IGlobalStateController.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IGlobalStateController.cs index 24eeefb9..9e46d1cd 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IGlobalStateController.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IGlobalStateController.cs @@ -4,4 +4,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys { public IGlobalStateController() { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IHomeMenuFunctions.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IHomeMenuFunctions.cs index c7c073ff..78f47e0e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IHomeMenuFunctions.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IHomeMenuFunctions.cs @@ -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; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ILibraryAppletCreator.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ILibraryAppletCreator.cs index fb870c24..23ba99b0 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ILibraryAppletCreator.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ILibraryAppletCreator.cs @@ -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; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ISelfController.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ISelfController.cs index 8f93117e..85898f13 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ISelfController.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ISelfController.cs @@ -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) diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IWindowController.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IWindowController.cs index 730df5d0..46dc4916 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IWindowController.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/IWindowController.cs @@ -33,4 +33,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/Types/AlbumReportOption.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/Types/AlbumReportOption.cs index 84fc5c83..e4b43495 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/Types/AlbumReportOption.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/Types/AlbumReportOption.cs @@ -5,6 +5,6 @@ OverlayNotDisplayed, OverlayDisplayed, Unknown2, - Unknown3 + Unknown3, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/Types/AppletMessage.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/Types/AppletMessage.cs index 2920c329..3f4600fa 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/Types/AppletMessage.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/Types/AppletMessage.cs @@ -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, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/Types/FocusState.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/Types/FocusState.cs index dfd7d7f2..afb7d6b4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/Types/FocusState.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/Types/FocusState.cs @@ -2,7 +2,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys { enum FocusState { - InFocus = 1, - OutOfFocus = 2 + InFocus = 1, + OutOfFocus = 2, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/Types/OperationMode.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/Types/OperationMode.cs index a82ed476..86125978 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/Types/OperationMode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/Types/OperationMode.cs @@ -3,6 +3,6 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys enum OperationMode { Handheld = 0, - Docked = 1 + Docked = 1, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/Types/WirelessPriorityMode.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/Types/WirelessPriorityMode.cs index e8ba9b61..3ea923f5 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/Types/WirelessPriorityMode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/Types/WirelessPriorityMode.cs @@ -4,6 +4,6 @@ { Default, OptimizedForWlan, - Unknown2 + Unknown2, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AppletFifo.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AppletFifo.cs index fb16c86e..e7482b78 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AppletFifo.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AppletFifo.cs @@ -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; diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AppletSession.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AppletSession.cs index 6c9197b3..63eb2ca5 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AppletSession.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AppletSession.cs @@ -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; diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/IAllSystemAppletProxiesService.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/IAllSystemAppletProxiesService.cs index 728a1018..0a032562 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/IAllSystemAppletProxiesService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/IAllSystemAppletProxiesService.cs @@ -26,4 +26,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/IStorage.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/IStorage.cs index 190f1a51..311084aa 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/IStorage.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/IStorage.cs @@ -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; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/IStorageAccessor.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/IStorageAccessor.cs index 4c7e264d..54c7b69e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/IStorageAccessor.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/IStorageAccessor.cs @@ -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; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Storage/StorageHelper.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Storage/StorageHelper.cs index 49e342f2..ef5951d7 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Storage/StorageHelper.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Storage/StorageHelper.cs @@ -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(); } } } diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Types/AppletId.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Types/AppletId.cs index 917f6865..503de4d2 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Types/AppletId.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Types/AppletId.cs @@ -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, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Types/AppletIdentityInfo.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Types/AppletIdentityInfo.cs index 17a485ab..84fd1b4c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Types/AppletIdentityInfo.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Types/AppletIdentityInfo.cs @@ -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; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Types/AppletProcessLaunchReason.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Types/AppletProcessLaunchReason.cs index 6c528337..b6c32da5 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Types/AppletProcessLaunchReason.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Types/AppletProcessLaunchReason.cs @@ -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; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Types/LibraryAppletInfo.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Types/LibraryAppletInfo.cs index fc1c11e4..1205a7dc 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Types/LibraryAppletInfo.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Types/LibraryAppletInfo.cs @@ -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; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Types/LibraryAppletMode.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Types/LibraryAppletMode.cs index 6b9a2284..044a3168 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Types/LibraryAppletMode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Types/LibraryAppletMode.cs @@ -9,6 +9,6 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE PartialForeground, NoUi, PartialForegroundWithIndirectDisplay, - AllForegroundInitiallyHidden + AllForegroundInitiallyHidden, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/IApplicationFunctions.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/IApplicationFunctions.cs index 5ae8f459..271d0060 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/IApplicationFunctions.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/IApplicationFunctions.cs @@ -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; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/Types/LaunchParameterKind.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/Types/LaunchParameterKind.cs index 40432074..7d82dcf5 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/Types/LaunchParameterKind.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/Types/LaunchParameterKind.cs @@ -4,6 +4,6 @@ { UserChannel = 1, PreselectedUser, - Unknown + Unknown, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/Types/ProgramSpecifyKind.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/Types/ProgramSpecifyKind.cs index efc284a5..29ecf421 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/Types/ProgramSpecifyKind.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/Types/ProgramSpecifyKind.cs @@ -4,6 +4,6 @@ { ExecuteProgram, SubApplicationProgram, - RestartProgram + RestartProgram, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/IApplicationProxy.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/IApplicationProxy.cs index 50e3be27..b24e1bf4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/IApplicationProxy.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/IApplicationProxy.cs @@ -84,4 +84,4 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletOE/IApplicationProxyService.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletOE/IApplicationProxyService.cs index 3a4c71e4..9814976f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletOE/IApplicationProxyService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletOE/IApplicationProxyService.cs @@ -16,4 +16,4 @@ namespace Ryujinx.HLE.HOS.Services.Am return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/Idle/IPolicyManagerSystem.cs b/src/Ryujinx.HLE/HOS/Services/Am/Idle/IPolicyManagerSystem.cs index 8c72319c..824d4c22 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/Idle/IPolicyManagerSystem.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/Idle/IPolicyManagerSystem.cs @@ -5,4 +5,4 @@ { public IPolicyManagerSystem(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/Omm/IOperationModeManager.cs b/src/Ryujinx.HLE/HOS/Services/Am/Omm/IOperationModeManager.cs index 2856e6d7..44c4dafc 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/Omm/IOperationModeManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/Omm/IOperationModeManager.cs @@ -5,4 +5,4 @@ { public IOperationModeManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Am/ResultCode.cs index 5cafff67..9142f65e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/ResultCode.cs @@ -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, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Am/Spsm/IPowerStateInterface.cs b/src/Ryujinx.HLE/HOS/Services/Am/Spsm/IPowerStateInterface.cs index a393f76b..40a1300c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/Spsm/IPowerStateInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/Spsm/IPowerStateInterface.cs @@ -5,4 +5,4 @@ { public IPowerStateInterface(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Am/Tcap/IManager.cs b/src/Ryujinx.HLE/HOS/Services/Am/Tcap/IManager.cs index b31ccf8a..edb9618c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/Tcap/IManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/Tcap/IManager.cs @@ -5,4 +5,4 @@ { public IManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Apm/IManager.cs b/src/Ryujinx.HLE/HOS/Services/Apm/IManager.cs index 72e39a77..83215bef 100644 --- a/src/Ryujinx.HLE/HOS/Services/Apm/IManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Apm/IManager.cs @@ -40,4 +40,4 @@ namespace Ryujinx.HLE.HOS.Services.Apm return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Apm/IManagerPrivileged.cs b/src/Ryujinx.HLE/HOS/Services/Apm/IManagerPrivileged.cs index 9620c30a..bb0049d1 100644 --- a/src/Ryujinx.HLE/HOS/Services/Apm/IManagerPrivileged.cs +++ b/src/Ryujinx.HLE/HOS/Services/Apm/IManagerPrivileged.cs @@ -16,4 +16,4 @@ namespace Ryujinx.HLE.HOS.Services.Apm return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Apm/ISession.cs b/src/Ryujinx.HLE/HOS/Services/Apm/ISession.cs index f828cd17..6ee69605 100644 --- a/src/Ryujinx.HLE/HOS/Services/Apm/ISession.cs +++ b/src/Ryujinx.HLE/HOS/Services/Apm/ISession.cs @@ -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; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Apm/ISystemManager.cs b/src/Ryujinx.HLE/HOS/Services/Apm/ISystemManager.cs index 9d2c7b0b..375423cf 100644 --- a/src/Ryujinx.HLE/HOS/Services/Apm/ISystemManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Apm/ISystemManager.cs @@ -39,4 +39,4 @@ namespace Ryujinx.HLE.HOS.Services.Apm return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Apm/ManagerServer.cs b/src/Ryujinx.HLE/HOS/Services/Apm/ManagerServer.cs index af051934..9a3a0462 100644 --- a/src/Ryujinx.HLE/HOS/Services/Apm/ManagerServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Apm/ManagerServer.cs @@ -28,4 +28,4 @@ return _context.Device.System.PerformanceState.CpuOverclockEnabled; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Apm/PerformanceState.cs b/src/Ryujinx.HLE/HOS/Services/Apm/PerformanceState.cs index d03bf6c7..0fb6c28a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Apm/PerformanceState.cs +++ b/src/Ryujinx.HLE/HOS/Services/Apm/PerformanceState.cs @@ -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, }; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Apm/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Apm/ResultCode.cs index c4499b01..3cbfbffb 100644 --- a/src/Ryujinx.HLE/HOS/Services/Apm/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Apm/ResultCode.cs @@ -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, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Apm/SessionServer.cs b/src/Ryujinx.HLE/HOS/Services/Apm/SessionServer.cs index 3ef713cf..260992be 100644 --- a/src/Ryujinx.HLE/HOS/Services/Apm/SessionServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Apm/SessionServer.cs @@ -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. } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Apm/SystemManagerServer.cs b/src/Ryujinx.HLE/HOS/Services/Apm/SystemManagerServer.cs index a6264236..3fe5b383 100644 --- a/src/Ryujinx.HLE/HOS/Services/Apm/SystemManagerServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Apm/SystemManagerServer.cs @@ -25,4 +25,4 @@ return _context.Device.System.PerformanceState.GetCurrentPerformanceConfiguration(_context.Device.System.PerformanceState.PerformanceMode); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Apm/Types/CpuBoostMode.cs b/src/Ryujinx.HLE/HOS/Services/Apm/Types/CpuBoostMode.cs index 587142c8..c84d32ba 100644 --- a/src/Ryujinx.HLE/HOS/Services/Apm/Types/CpuBoostMode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Apm/Types/CpuBoostMode.cs @@ -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. } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Apm/Types/PerformanceConfiguration.cs b/src/Ryujinx.HLE/HOS/Services/Apm/Types/PerformanceConfiguration.cs index e8c5752e..6dd193f9 100644 --- a/src/Ryujinx.HLE/HOS/Services/Apm/Types/PerformanceConfiguration.cs +++ b/src/Ryujinx.HLE/HOS/Services/Apm/Types/PerformanceConfiguration.cs @@ -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+ } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Apm/Types/PerformanceMode.cs b/src/Ryujinx.HLE/HOS/Services/Apm/Types/PerformanceMode.cs index 6d6f9643..0a771965 100644 --- a/src/Ryujinx.HLE/HOS/Services/Apm/Types/PerformanceMode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Apm/Types/PerformanceMode.cs @@ -3,6 +3,6 @@ enum PerformanceMode : uint { Default = 0, - Boost = 1 + Boost = 1, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Arp/ApplicationLaunchProperty.cs b/src/Ryujinx.HLE/HOS/Services/Arp/ApplicationLaunchProperty.cs index 3e4eca0a..9c2b9d19 100644 --- a/src/Ryujinx.HLE/HOS/Services/Arp/ApplicationLaunchProperty.cs +++ b/src/Ryujinx.HLE/HOS/Services/Arp/ApplicationLaunchProperty.cs @@ -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, }; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Arp/IReader.cs b/src/Ryujinx.HLE/HOS/Services/Arp/IReader.cs index 35a2de0c..90cba861 100644 --- a/src/Ryujinx.HLE/HOS/Services/Arp/IReader.cs +++ b/src/Ryujinx.HLE/HOS/Services/Arp/IReader.cs @@ -5,4 +5,4 @@ { public IReader(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Arp/IWriter.cs b/src/Ryujinx.HLE/HOS/Services/Arp/IWriter.cs index 8d13f0fb..7c3992c7 100644 --- a/src/Ryujinx.HLE/HOS/Services/Arp/IWriter.cs +++ b/src/Ryujinx.HLE/HOS/Services/Arp/IWriter.cs @@ -5,4 +5,4 @@ { public IWriter(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Arp/LibHacIReader.cs b/src/Ryujinx.HLE/HOS/Services/Arp/LibHacIReader.cs index d7686871..fdddb79e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Arp/LibHacIReader.cs +++ b/src/Ryujinx.HLE/HOS/Services/Arp/LibHacIReader.cs @@ -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; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/AudioIn/AudioIn.cs b/src/Ryujinx.HLE/HOS/Services/Audio/AudioIn/AudioIn.cs index ee85ded9..ee8e4643 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/AudioIn/AudioIn.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/AudioIn/AudioIn.cs @@ -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(); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/AudioIn/AudioInServer.cs b/src/Ryujinx.HLE/HOS/Services/Audio/AudioIn/AudioInServer.cs index a80b9402..81b76e7a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/AudioIn/AudioInServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/AudioIn/AudioInServer.cs @@ -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+ diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/AudioInManager.cs b/src/Ryujinx.HLE/HOS/Services/Audio/AudioInManager.cs index 36b0ed28..ba7462d3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/AudioInManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/AudioInManager.cs @@ -7,7 +7,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio { class AudioInManager : IAudioInManager { - private AudioInManagerImpl _impl; + private readonly AudioInManagerImpl _impl; public AudioInManager(AudioInManagerImpl impl) { diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/AudioInManagerServer.cs b/src/Ryujinx.HLE/HOS/Services/Audio/AudioInManagerServer.cs index 755caee5..ac1863ab 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/AudioInManagerServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/AudioInManagerServer.cs @@ -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]; diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/AudioOut/AudioOut.cs b/src/Ryujinx.HLE/HOS/Services/Audio/AudioOut/AudioOut.cs index f2588452..8624ab9b 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/AudioOut/AudioOut.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/AudioOut/AudioOut.cs @@ -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 { diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/AudioOut/AudioOutServer.cs b/src/Ryujinx.HLE/HOS/Services/Audio/AudioOut/AudioOutServer.cs index 329e1794..3b6834f7 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/AudioOut/AudioOutServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/AudioOut/AudioOutServer.cs @@ -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+ diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/AudioOutManager.cs b/src/Ryujinx.HLE/HOS/Services/Audio/AudioOutManager.cs index e95de057..fbbb3e1d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/AudioOutManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/AudioOutManager.cs @@ -7,7 +7,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio { class AudioOutManager : IAudioOutManager { - private AudioOutManagerImpl _impl; + private readonly AudioOutManagerImpl _impl; public AudioOutManager(AudioOutManagerImpl impl) { diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/AudioOutManagerServer.cs b/src/Ryujinx.HLE/HOS/Services/Audio/AudioOutManagerServer.cs index 7c5d8c4e..ca4d6163 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/AudioOutManagerServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/AudioOutManagerServer.cs @@ -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]; diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/AudioRenderer/AudioDevice.cs b/src/Ryujinx.HLE/HOS/Services/Audio/AudioRenderer/AudioDevice.cs index 724a1e9e..9a08f1ba 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/AudioRenderer/AudioDevice.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/AudioRenderer/AudioDevice.cs @@ -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(); diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/AudioRenderer/AudioDeviceServer.cs b/src/Ryujinx.HLE/HOS/Services/Audio/AudioRenderer/AudioDeviceServer.cs index e7a75121..9694406d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/AudioRenderer/AudioDeviceServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/AudioRenderer/AudioDeviceServer.cs @@ -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) { diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/AudioRenderer/AudioRenderer.cs b/src/Ryujinx.HLE/HOS/Services/Audio/AudioRenderer/AudioRenderer.cs index 5b682bf8..8b8e55fb 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/AudioRenderer/AudioRenderer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/AudioRenderer/AudioRenderer.cs @@ -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 { diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/AudioRenderer/AudioRendererServer.cs b/src/Ryujinx.HLE/HOS/Services/Audio/AudioRenderer/AudioRendererServer.cs index 5d8e086d..af8d20ba 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/AudioRenderer/AudioRendererServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/AudioRenderer/AudioRendererServer.cs @@ -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)) - { - Memory<byte> output = outputOwner.Memory; - Memory<byte> performanceOutput = performanceOutputOwner.Memory; - - using MemoryHandle outputHandle = output.Pin(); - using MemoryHandle performanceOutputHandle = performanceOutput.Pin(); + using IMemoryOwner<byte> outputOwner = ByteMemoryPool.RentCleared(outputSize); + using IMemoryOwner<byte> performanceOutputOwner = ByteMemoryPool.RentCleared(performanceOutputSize); + Memory<byte> output = outputOwner.Memory; + Memory<byte> performanceOutput = performanceOutputOwner.Memory; - ResultCode result = _impl.RequestUpdate(output, performanceOutput, input); + using MemoryHandle outputHandle = output.Pin(); + using MemoryHandle performanceOutputHandle = performanceOutput.Pin(); - 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}"); - } + ResultCode result = _impl.RequestUpdate(output, performanceOutput, input); - return result; + 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; } [CommandCmif(5)] diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/AudioRenderer/IAudioDevice.cs b/src/Ryujinx.HLE/HOS/Services/Audio/AudioRenderer/IAudioDevice.cs index 1918a977..4a1b5ffb 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/AudioRenderer/IAudioDevice.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/AudioRenderer/IAudioDevice.cs @@ -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(); diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/AudioRendererManager.cs b/src/Ryujinx.HLE/HOS/Services/Audio/AudioRendererManager.cs index 40e71a43..b40c32a1 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/AudioRendererManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/AudioRendererManager.cs @@ -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) { diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/AudioRendererManagerServer.cs b/src/Ryujinx.HLE/HOS/Services/Audio/AudioRendererManagerServer.cs index 80b54e8c..58a1daf1 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/AudioRendererManagerServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/AudioRendererManagerServer.cs @@ -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)) { } diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/HardwareOpusDecoderManager/Decoder.cs b/src/Ryujinx.HLE/HOS/Services/Audio/HardwareOpusDecoderManager/Decoder.cs index b77fc4b0..c5dd2f00 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/HardwareOpusDecoderManager/Decoder.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/HardwareOpusDecoderManager/Decoder.cs @@ -24,4 +24,4 @@ namespace Ryujinx.HLE.HOS.Services.Audio.HardwareOpusDecoderManager _decoder.ResetState(); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/HardwareOpusDecoderManager/DecoderCommon.cs b/src/Ryujinx.HLE/HOS/Services/Audio/HardwareOpusDecoderManager/DecoderCommon.cs index 944541cc..9ff511a5 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/HardwareOpusDecoderManager/DecoderCommon.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/HardwareOpusDecoderManager/DecoderCommon.cs @@ -89,4 +89,4 @@ namespace Ryujinx.HLE.HOS.Services.Audio.HardwareOpusDecoderManager return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/HardwareOpusDecoderManager/IDecoder.cs b/src/Ryujinx.HLE/HOS/Services/Audio/HardwareOpusDecoderManager/IDecoder.cs index 9047c266..cc83be5e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/HardwareOpusDecoderManager/IDecoder.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/HardwareOpusDecoderManager/IDecoder.cs @@ -8,4 +8,4 @@ namespace Ryujinx.HLE.HOS.Services.Audio.HardwareOpusDecoderManager int Decode(byte[] inData, int inDataOffset, int len, short[] outPcm, int outPcmOffset, int frameSize); void ResetState(); } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/HardwareOpusDecoderManager/IHardwareOpusDecoder.cs b/src/Ryujinx.HLE/HOS/Services/Audio/HardwareOpusDecoderManager/IHardwareOpusDecoder.cs index e94b31ca..3d5d2839 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/HardwareOpusDecoderManager/IHardwareOpusDecoder.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/HardwareOpusDecoderManager/IHardwareOpusDecoder.cs @@ -87,10 +87,10 @@ namespace Ryujinx.HLE.HOS.Services.Audio.HardwareOpusDecoderManager private ResultCode DecodeInterleavedInternal(ServiceCtx context, OpusDecoderFlags flags, bool reset, bool withPerf) { - ulong inPosition = context.Request.SendBuff[0].Position; - ulong inSize = context.Request.SendBuff[0].Size; + ulong inPosition = context.Request.SendBuff[0].Position; + ulong inSize = context.Request.SendBuff[0].Size; ulong outputPosition = context.Request.ReceiveBuff[0].Position; - ulong outputSize = context.Request.ReceiveBuff[0].Size; + ulong outputSize = context.Request.ReceiveBuff[0].Size; ReadOnlySpan<byte> input = context.Memory.GetSpan(inPosition, (int)inSize); @@ -113,4 +113,4 @@ namespace Ryujinx.HLE.HOS.Services.Audio.HardwareOpusDecoderManager return result; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/HardwareOpusDecoderManager/MultiSampleDecoder.cs b/src/Ryujinx.HLE/HOS/Services/Audio/HardwareOpusDecoderManager/MultiSampleDecoder.cs index 23721d3b..910bb23e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/HardwareOpusDecoderManager/MultiSampleDecoder.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/HardwareOpusDecoderManager/MultiSampleDecoder.cs @@ -25,4 +25,4 @@ namespace Ryujinx.HLE.HOS.Services.Audio.HardwareOpusDecoderManager _decoder.ResetState(); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/IAudioController.cs b/src/Ryujinx.HLE/HOS/Services/Audio/IAudioController.cs index 1bd2e31d..22367580 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/IAudioController.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/IAudioController.cs @@ -5,4 +5,4 @@ { public IAudioController(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/IAudioInManager.cs b/src/Ryujinx.HLE/HOS/Services/Audio/IAudioInManager.cs index 9bbe5b0e..709320c8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/IAudioInManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/IAudioInManager.cs @@ -9,4 +9,4 @@ namespace Ryujinx.HLE.HOS.Services.Audio public ResultCode OpenAudioIn(ServiceCtx context, out string outputDeviceName, out AudioOutputConfiguration outputConfiguration, out IAudioIn obj, string inputDeviceName, ref AudioInputConfiguration parameter, ulong appletResourceUserId, uint processHandle); } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/IAudioInManagerForApplet.cs b/src/Ryujinx.HLE/HOS/Services/Audio/IAudioInManagerForApplet.cs index 37d9a8fe..1735768c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/IAudioInManagerForApplet.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/IAudioInManagerForApplet.cs @@ -5,4 +5,4 @@ { public IAudioInManagerForApplet(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/IAudioInManagerForDebugger.cs b/src/Ryujinx.HLE/HOS/Services/Audio/IAudioInManagerForDebugger.cs index 1a497efb..ebdcfd8c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/IAudioInManagerForDebugger.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/IAudioInManagerForDebugger.cs @@ -5,4 +5,4 @@ { public IAudioInManagerForDebugger(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/IAudioOutManagerForApplet.cs b/src/Ryujinx.HLE/HOS/Services/Audio/IAudioOutManagerForApplet.cs index 4b41b0cf..1c3502d6 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/IAudioOutManagerForApplet.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/IAudioOutManagerForApplet.cs @@ -5,4 +5,4 @@ { public IAudioOutManagerForApplet(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/IAudioOutManagerForDebugger.cs b/src/Ryujinx.HLE/HOS/Services/Audio/IAudioOutManagerForDebugger.cs index 41cde972..1da017cb 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/IAudioOutManagerForDebugger.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/IAudioOutManagerForDebugger.cs @@ -5,4 +5,4 @@ { public IAudioOutManagerForDebugger(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/IAudioRendererManagerForApplet.cs b/src/Ryujinx.HLE/HOS/Services/Audio/IAudioRendererManagerForApplet.cs index ca5768cc..28aa6d8c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/IAudioRendererManagerForApplet.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/IAudioRendererManagerForApplet.cs @@ -5,4 +5,4 @@ { public IAudioRendererManagerForApplet(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/IAudioRendererManagerForDebugger.cs b/src/Ryujinx.HLE/HOS/Services/Audio/IAudioRendererManagerForDebugger.cs index a970ae45..50754f8a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/IAudioRendererManagerForDebugger.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/IAudioRendererManagerForDebugger.cs @@ -5,4 +5,4 @@ { public IAudioRendererManagerForDebugger(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/IAudioSnoopManager.cs b/src/Ryujinx.HLE/HOS/Services/Audio/IAudioSnoopManager.cs index 59e3ad09..73bc629f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/IAudioSnoopManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/IAudioSnoopManager.cs @@ -5,4 +5,4 @@ { public IAudioSnoopManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/IFinalOutputRecorderManager.cs b/src/Ryujinx.HLE/HOS/Services/Audio/IFinalOutputRecorderManager.cs index 01435008..56647d04 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/IFinalOutputRecorderManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/IFinalOutputRecorderManager.cs @@ -5,4 +5,4 @@ { public IFinalOutputRecorderManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/IFinalOutputRecorderManagerForApplet.cs b/src/Ryujinx.HLE/HOS/Services/Audio/IFinalOutputRecorderManagerForApplet.cs index d8fd270d..6dfd5f96 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/IFinalOutputRecorderManagerForApplet.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/IFinalOutputRecorderManagerForApplet.cs @@ -5,4 +5,4 @@ { public IFinalOutputRecorderManagerForApplet(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/IFinalOutputRecorderManagerForDebugger.cs b/src/Ryujinx.HLE/HOS/Services/Audio/IFinalOutputRecorderManagerForDebugger.cs index a8ec51ee..653ab598 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/IFinalOutputRecorderManagerForDebugger.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/IFinalOutputRecorderManagerForDebugger.cs @@ -5,4 +5,4 @@ { public IFinalOutputRecorderManagerForDebugger(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/IHardwareOpusDecoderManager.cs b/src/Ryujinx.HLE/HOS/Services/Audio/IHardwareOpusDecoderManager.cs index 8df8a38c..b69a2392 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/IHardwareOpusDecoderManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/IHardwareOpusDecoderManager.cs @@ -14,7 +14,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio // Initialize(bytes<8, 4>, u32, handle<copy>) -> object<nn::codec::detail::IHardwareOpusDecoder> public ResultCode Initialize(ServiceCtx context) { - int sampleRate = context.RequestData.ReadInt32(); + int sampleRate = context.RequestData.ReadInt32(); int channelsCount = context.RequestData.ReadInt32(); MakeObject(context, new IHardwareOpusDecoder(sampleRate, channelsCount, OpusDecoderFlags.None)); @@ -29,7 +29,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio // GetWorkBufferSize(bytes<8, 4>) -> u32 public ResultCode GetWorkBufferSize(ServiceCtx context) { - int sampleRate = context.RequestData.ReadInt32(); + int sampleRate = context.RequestData.ReadInt32(); int channelsCount = context.RequestData.ReadInt32(); int opusDecoderSize = GetOpusDecoderSize(channelsCount); @@ -196,10 +196,10 @@ namespace Ryujinx.HLE.HOS.Services.Audio private static int GetCeltDecoderSize(int channelsCount) { const int DecodeBufferSize = 0x2030; - const int Overlap = 120; - const int EBandsCount = 21; + const int Overlap = 120; + const int EBandsCount = 21; return (DecodeBufferSize + Overlap * 4) * channelsCount + EBandsCount * 16 + 0x50; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Audio/ResultCode.cs index fd2091c2..c1d49109 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/ResultCode.cs @@ -2,20 +2,20 @@ namespace Ryujinx.HLE.HOS.Services.Audio { enum ResultCode { - ModuleId = 153, + ModuleId = 153, ErrorCodeShift = 9, Success = 0, - DeviceNotFound = (1 << ErrorCodeShift) | ModuleId, - UnsupportedRevision = (2 << ErrorCodeShift) | ModuleId, + DeviceNotFound = (1 << ErrorCodeShift) | ModuleId, + UnsupportedRevision = (2 << ErrorCodeShift) | ModuleId, UnsupportedSampleRate = (3 << ErrorCodeShift) | ModuleId, - BufferSizeTooSmall = (4 << ErrorCodeShift) | ModuleId, - OpusInvalidInput = (6 << ErrorCodeShift) | ModuleId, - TooManyBuffersInUse = (8 << ErrorCodeShift) | ModuleId, - InvalidChannelCount = (10 << ErrorCodeShift) | ModuleId, - InvalidOperation = (513 << ErrorCodeShift) | ModuleId, - InvalidHandle = (1536 << ErrorCodeShift) | ModuleId, - OutputAlreadyStarted = (1540 << ErrorCodeShift) | ModuleId + BufferSizeTooSmall = (4 << ErrorCodeShift) | ModuleId, + OpusInvalidInput = (6 << ErrorCodeShift) | ModuleId, + TooManyBuffersInUse = (8 << ErrorCodeShift) | ModuleId, + InvalidChannelCount = (10 << ErrorCodeShift) | ModuleId, + InvalidOperation = (513 << ErrorCodeShift) | ModuleId, + InvalidHandle = (1536 << ErrorCodeShift) | ModuleId, + OutputAlreadyStarted = (1540 << ErrorCodeShift) | ModuleId, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Audio/Types/OpusPacketHeader.cs b/src/Ryujinx.HLE/HOS/Services/Audio/Types/OpusPacketHeader.cs index 5ae0eb1e..2c547827 100644 --- a/src/Ryujinx.HLE/HOS/Services/Audio/Types/OpusPacketHeader.cs +++ b/src/Ryujinx.HLE/HOS/Services/Audio/Types/OpusPacketHeader.cs @@ -14,7 +14,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio.Types { OpusPacketHeader header = MemoryMarshal.Cast<byte, OpusPacketHeader>(data)[0]; - header.length = BitConverter.IsLittleEndian ? BinaryPrimitives.ReverseEndianness(header.length) : header.length; + header.length = BitConverter.IsLittleEndian ? BinaryPrimitives.ReverseEndianness(header.length) : header.length; header.finalRange = BitConverter.IsLittleEndian ? BinaryPrimitives.ReverseEndianness(header.finalRange) : header.finalRange; return header; diff --git a/src/Ryujinx.HLE/HOS/Services/Bgtc/IStateControlService.cs b/src/Ryujinx.HLE/HOS/Services/Bgtc/IStateControlService.cs index 4926d4d8..97d0cf94 100644 --- a/src/Ryujinx.HLE/HOS/Services/Bgtc/IStateControlService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Bgtc/IStateControlService.cs @@ -5,4 +5,4 @@ { public IStateControlService(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Bgtc/ITaskService.cs b/src/Ryujinx.HLE/HOS/Services/Bgtc/ITaskService.cs index a032c380..1b4b45f6 100644 --- a/src/Ryujinx.HLE/HOS/Services/Bgtc/ITaskService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Bgtc/ITaskService.cs @@ -5,4 +5,4 @@ { public ITaskService(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Bluetooth/BluetoothDriver/BluetoothEventManager.cs b/src/Ryujinx.HLE/HOS/Services/Bluetooth/BluetoothDriver/BluetoothEventManager.cs index 81f4a7d2..5b862400 100644 --- a/src/Ryujinx.HLE/HOS/Services/Bluetooth/BluetoothDriver/BluetoothEventManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Bluetooth/BluetoothDriver/BluetoothEventManager.cs @@ -5,21 +5,21 @@ namespace Ryujinx.HLE.HOS.Services.Bluetooth.BluetoothDriver static class BluetoothEventManager { public static KEvent InitializeBleDebugEvent; - public static int InitializeBleDebugEventHandle; + public static int InitializeBleDebugEventHandle; public static KEvent UnknownBleDebugEvent; - public static int UnknownBleDebugEventHandle; + public static int UnknownBleDebugEventHandle; public static KEvent RegisterBleDebugEvent; - public static int RegisterBleDebugEventHandle; + public static int RegisterBleDebugEventHandle; public static KEvent InitializeBleEvent; - public static int InitializeBleEventHandle; + public static int InitializeBleEventHandle; public static KEvent UnknownBleEvent; - public static int UnknownBleEventHandle; + public static int UnknownBleEventHandle; public static KEvent RegisterBleEvent; - public static int RegisterBleEventHandle; + public static int RegisterBleEventHandle; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Bluetooth/IBluetoothDriver.cs b/src/Ryujinx.HLE/HOS/Services/Bluetooth/IBluetoothDriver.cs index feff5a73..ace2c86a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Bluetooth/IBluetoothDriver.cs +++ b/src/Ryujinx.HLE/HOS/Services/Bluetooth/IBluetoothDriver.cs @@ -10,9 +10,9 @@ namespace Ryujinx.HLE.HOS.Services.Bluetooth [Service("btdrv")] class IBluetoothDriver : IpcService { -#pragma warning disable CS0414 +#pragma warning disable CS0414, IDE0052 // Remove unread private member private string _unknownLowEnergy; -#pragma warning restore CS0414 +#pragma warning restore CS0414, IDE0052 public IBluetoothDriver(ServiceCtx context) { } @@ -100,4 +100,4 @@ namespace Ryujinx.HLE.HOS.Services.Bluetooth return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Bluetooth/IBluetoothUser.cs b/src/Ryujinx.HLE/HOS/Services/Bluetooth/IBluetoothUser.cs index 1a5e25a4..04782d08 100644 --- a/src/Ryujinx.HLE/HOS/Services/Bluetooth/IBluetoothUser.cs +++ b/src/Ryujinx.HLE/HOS/Services/Bluetooth/IBluetoothUser.cs @@ -27,4 +27,4 @@ namespace Ryujinx.HLE.HOS.Services.Bluetooth return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/BluetoothManager/BtmUser/IBtmUserCore.cs b/src/Ryujinx.HLE/HOS/Services/BluetoothManager/BtmUser/IBtmUserCore.cs index 3c9938ad..da45dc77 100644 --- a/src/Ryujinx.HLE/HOS/Services/BluetoothManager/BtmUser/IBtmUserCore.cs +++ b/src/Ryujinx.HLE/HOS/Services/BluetoothManager/BtmUser/IBtmUserCore.cs @@ -8,16 +8,16 @@ namespace Ryujinx.HLE.HOS.Services.BluetoothManager.BtmUser class IBtmUserCore : IpcService { public KEvent _bleScanEvent; - public int _bleScanEventHandle; + public int _bleScanEventHandle; public KEvent _bleConnectionEvent; - public int _bleConnectionEventHandle; + public int _bleConnectionEventHandle; public KEvent _bleServiceDiscoveryEvent; - public int _bleServiceDiscoveryEventHandle; + public int _bleServiceDiscoveryEventHandle; public KEvent _bleMtuConfigEvent; - public int _bleMtuConfigEventHandle; + public int _bleMtuConfigEventHandle; public IBtmUserCore() { } @@ -125,4 +125,4 @@ namespace Ryujinx.HLE.HOS.Services.BluetoothManager.BtmUser return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtm.cs b/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtm.cs index 48a273a0..13d14151 100644 --- a/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtm.cs +++ b/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtm.cs @@ -5,4 +5,4 @@ { public IBtm(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtmDebug.cs b/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtmDebug.cs index 259698af..43a6ccc6 100644 --- a/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtmDebug.cs +++ b/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtmDebug.cs @@ -5,4 +5,4 @@ { public IBtmDebug(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtmSystem.cs b/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtmSystem.cs index c4210b78..67d851b4 100644 --- a/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtmSystem.cs +++ b/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtmSystem.cs @@ -5,4 +5,4 @@ { public IBtmSystem(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtmUser.cs b/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtmUser.cs index b00f0a2f..225a71e3 100644 --- a/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtmUser.cs +++ b/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtmUser.cs @@ -16,4 +16,4 @@ namespace Ryujinx.HLE.HOS.Services.BluetoothManager return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/BluetoothManager/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/BluetoothManager/ResultCode.cs index 0ad2c485..01e62d2a 100644 --- a/src/Ryujinx.HLE/HOS/Services/BluetoothManager/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/BluetoothManager/ResultCode.cs @@ -2,9 +2,9 @@ { enum ResultCode { - ModuleId = 143, + ModuleId = 143, ErrorCodeShift = 9, - Success = 0 + Success = 0, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Caps/CaptureManager.cs b/src/Ryujinx.HLE/HOS/Services/Caps/CaptureManager.cs index 6320fe28..349dd34f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Caps/CaptureManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Caps/CaptureManager.cs @@ -11,19 +11,21 @@ namespace Ryujinx.HLE.HOS.Services.Caps { class CaptureManager { - private string _sdCardPath; + private readonly string _sdCardPath; private uint _shimLibraryVersion; public CaptureManager(Switch device) { - _sdCardPath = device.FileSystem.GetSdCardPath(); + _sdCardPath = FileSystem.VirtualFileSystem.GetSdCardPath(); } public ResultCode SetShimLibraryVersion(ServiceCtx context) { - ulong shimLibraryVersion = context.RequestData.ReadUInt64(); + ulong shimLibraryVersion = context.RequestData.ReadUInt64(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment ulong appletResourceUserId = context.RequestData.ReadUInt64(); +#pragma warning restore IDE0059 // TODO: Service checks if the pid is present in an internal list and returns ResultCode.BlacklistedPid if it is. // The list contents needs to be determined. @@ -82,28 +84,28 @@ namespace Ryujinx.HLE.HOS.Services.Caps applicationAlbumEntry = new ApplicationAlbumEntry() { - Size = (ulong)Unsafe.SizeOf<ApplicationAlbumEntry>(), - TitleId = titleId, + Size = (ulong)Unsafe.SizeOf<ApplicationAlbumEntry>(), + TitleId = titleId, AlbumFileDateTime = new AlbumFileDateTime() { - Year = (ushort)currentDateTime.Year, - Month = (byte)currentDateTime.Month, - Day = (byte)currentDateTime.Day, - Hour = (byte)currentDateTime.Hour, - Minute = (byte)currentDateTime.Minute, - Second = (byte)currentDateTime.Second, - UniqueId = 0 + Year = (ushort)currentDateTime.Year, + Month = (byte)currentDateTime.Month, + Day = (byte)currentDateTime.Day, + Hour = (byte)currentDateTime.Hour, + Minute = (byte)currentDateTime.Minute, + Second = (byte)currentDateTime.Second, + UniqueId = 0, }, - AlbumStorage = AlbumStorage.Sd, - ContentType = ContentType.Screenshot, - Padding = new Array5<byte>(), - Unknown0x1f = 1 + AlbumStorage = AlbumStorage.Sd, + ContentType = ContentType.Screenshot, + Padding = new Array5<byte>(), + Unknown0x1f = 1, }; // NOTE: The hex hash is a HMAC-SHA256 (first 32 bytes) using a hardcoded secret key over the titleId, we can simulate it by hashing the titleId instead. - string hash = Convert.ToHexString(SHA256.HashData(BitConverter.GetBytes(titleId))).Remove(0x20); + string hash = Convert.ToHexString(SHA256.HashData(BitConverter.GetBytes(titleId))).Remove(0x20); string folderPath = Path.Combine(_sdCardPath, "Nintendo", "Album", currentDateTime.Year.ToString("00"), currentDateTime.Month.ToString("00"), currentDateTime.Day.ToString("00")); - string filePath = GenerateFilePath(folderPath, applicationAlbumEntry, currentDateTime, hash); + string filePath = GenerateFilePath(folderPath, applicationAlbumEntry, currentDateTime, hash); // TODO: Handle that using the FS service implementation and return the right error code instead of throwing exceptions. Directory.CreateDirectory(folderPath); @@ -131,4 +133,4 @@ namespace Ryujinx.HLE.HOS.Services.Caps return Path.Combine(folderPath, fileName); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Caps/IAlbumAccessorService.cs b/src/Ryujinx.HLE/HOS/Services/Caps/IAlbumAccessorService.cs index 4071b9cc..de62b08d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Caps/IAlbumAccessorService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Caps/IAlbumAccessorService.cs @@ -5,4 +5,4 @@ namespace Ryujinx.HLE.HOS.Services.Caps { public IAlbumAccessorService(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Caps/IAlbumApplicationService.cs b/src/Ryujinx.HLE/HOS/Services/Caps/IAlbumApplicationService.cs index af99232e..5fbba310 100644 --- a/src/Ryujinx.HLE/HOS/Services/Caps/IAlbumApplicationService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Caps/IAlbumApplicationService.cs @@ -18,7 +18,7 @@ namespace Ryujinx.HLE.HOS.Services.Caps [CommandCmif(102)] // GetAlbumFileList0AafeAruidDeprecated(pid, u16 content_type, u64 start_time, u64 end_time, nn::applet::AppletResourceUserId) -> (u64 count, buffer<ApplicationAlbumFileEntry, 0x6>) - public ResultCode GetAlbumFileList0AafeAruidDeprecated(ServiceCtx context) + public ResultCode GetAlbumFileList0AafeAruidDeprecated(ServiceCtx context) { // NOTE: ApplicationAlbumFileEntry size is 0x30. return GetAlbumFileList(context); @@ -35,18 +35,18 @@ namespace Ryujinx.HLE.HOS.Services.Caps private ResultCode GetAlbumFileList(ServiceCtx context) { ResultCode resultCode = ResultCode.Success; - ulong count = 0; + ulong count = 0; ContentType contentType = (ContentType)context.RequestData.ReadUInt16(); - ulong startTime = context.RequestData.ReadUInt64(); - ulong endTime = context.RequestData.ReadUInt64(); + ulong startTime = context.RequestData.ReadUInt64(); + ulong endTime = context.RequestData.ReadUInt64(); context.RequestData.ReadUInt16(); // Alignment. ulong appletResourceUserId = context.RequestData.ReadUInt64(); ulong applicationAlbumFileEntryPosition = context.Request.ReceiveBuff[0].Position; - ulong applicationAlbumFileEntrySize = context.Request.ReceiveBuff[0].Size; + ulong applicationAlbumFileEntrySize = context.Request.ReceiveBuff[0].Size; MemoryHelper.FillWithZeros(context.Memory, applicationAlbumFileEntryPosition, (int)applicationAlbumFileEntrySize); @@ -66,4 +66,4 @@ namespace Ryujinx.HLE.HOS.Services.Caps return resultCode; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Caps/IAlbumControlService.cs b/src/Ryujinx.HLE/HOS/Services/Caps/IAlbumControlService.cs index b16a4122..4376c4d1 100644 --- a/src/Ryujinx.HLE/HOS/Services/Caps/IAlbumControlService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Caps/IAlbumControlService.cs @@ -12,4 +12,4 @@ namespace Ryujinx.HLE.HOS.Services.Caps return context.Device.System.CaptureManager.SetShimLibraryVersion(context); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Caps/IScreenShotApplicationService.cs b/src/Ryujinx.HLE/HOS/Services/Caps/IScreenShotApplicationService.cs index a3501286..fb62b710 100644 --- a/src/Ryujinx.HLE/HOS/Services/Caps/IScreenShotApplicationService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Caps/IScreenShotApplicationService.cs @@ -20,14 +20,18 @@ namespace Ryujinx.HLE.HOS.Services.Caps public ResultCode SaveScreenShotEx0(ServiceCtx context) { // TODO: Use the ScreenShotAttribute. +#pragma warning disable IDE0059 // Remove unnecessary value assignment ScreenShotAttribute screenShotAttribute = context.RequestData.ReadStruct<ScreenShotAttribute>(); - uint unknown = context.RequestData.ReadUInt32(); + uint unknown = context.RequestData.ReadUInt32(); +#pragma warning restore IDE0059 ulong appletResourceUserId = context.RequestData.ReadUInt64(); - ulong pidPlaceholder = context.RequestData.ReadUInt64(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment + ulong pidPlaceholder = context.RequestData.ReadUInt64(); +#pragma warning restore IDE0059 ulong screenshotDataPosition = context.Request.SendBuff[0].Position; - ulong screenshotDataSize = context.Request.SendBuff[0].Size; + ulong screenshotDataSize = context.Request.SendBuff[0].Size; byte[] screenshotData = context.Memory.GetSpan(screenshotDataPosition, (int)screenshotDataSize, true).ToArray(); @@ -43,20 +47,22 @@ namespace Ryujinx.HLE.HOS.Services.Caps public ResultCode SaveScreenShotEx1(ServiceCtx context) { // TODO: Use the ScreenShotAttribute. - ScreenShotAttribute screenShotAttribute = context.RequestData.ReadStruct<ScreenShotAttribute>(); + _ = context.RequestData.ReadStruct<ScreenShotAttribute>(); - uint unknown = context.RequestData.ReadUInt32(); + _ = context.RequestData.ReadUInt32(); ulong appletResourceUserId = context.RequestData.ReadUInt64(); - ulong pidPlaceholder = context.RequestData.ReadUInt64(); + + _ = context.RequestData.ReadUInt64(); ulong applicationDataPosition = context.Request.SendBuff[0].Position; - ulong applicationDataSize = context.Request.SendBuff[0].Size; + ulong applicationDataSize = context.Request.SendBuff[0].Size; ulong screenshotDataPosition = context.Request.SendBuff[1].Position; - ulong screenshotDataSize = context.Request.SendBuff[1].Size; + ulong screenshotDataSize = context.Request.SendBuff[1].Size; + // TODO: Parse the application data: At 0x00 it's UserData (Size of 0x400), at 0x404 it's a uint UserDataSize (Always empty for now). - byte[] applicationData = context.Memory.GetSpan(applicationDataPosition, (int)applicationDataSize).ToArray(); + _ = context.Memory.GetSpan(applicationDataPosition, (int)applicationDataSize).ToArray(); byte[] screenshotData = context.Memory.GetSpan(screenshotDataPosition, (int)screenshotDataSize, true).ToArray(); @@ -72,19 +78,20 @@ namespace Ryujinx.HLE.HOS.Services.Caps public ResultCode SaveScreenShotEx2(ServiceCtx context) { // TODO: Use the ScreenShotAttribute. - ScreenShotAttribute screenShotAttribute = context.RequestData.ReadStruct<ScreenShotAttribute>(); + _ = context.RequestData.ReadStruct<ScreenShotAttribute>(); - uint unknown = context.RequestData.ReadUInt32(); + _ = context.RequestData.ReadUInt32(); ulong appletResourceUserId = context.RequestData.ReadUInt64(); ulong userIdListPosition = context.Request.SendBuff[0].Position; - ulong userIdListSize = context.Request.SendBuff[0].Size; + ulong userIdListSize = context.Request.SendBuff[0].Size; ulong screenshotDataPosition = context.Request.SendBuff[1].Position; - ulong screenshotDataSize = context.Request.SendBuff[1].Size; + ulong screenshotDataSize = context.Request.SendBuff[1].Size; + // TODO: Parse the UserIdList. - byte[] userIdList = context.Memory.GetSpan(userIdListPosition, (int)userIdListSize).ToArray(); + _ = context.Memory.GetSpan(userIdListPosition, (int)userIdListSize).ToArray(); byte[] screenshotData = context.Memory.GetSpan(screenshotDataPosition, (int)screenshotDataSize, true).ToArray(); @@ -95,4 +102,4 @@ namespace Ryujinx.HLE.HOS.Services.Caps return resultCode; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Caps/IScreenShotControlService.cs b/src/Ryujinx.HLE/HOS/Services/Caps/IScreenShotControlService.cs index 337fa9ee..c3e2036b 100644 --- a/src/Ryujinx.HLE/HOS/Services/Caps/IScreenShotControlService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Caps/IScreenShotControlService.cs @@ -5,4 +5,4 @@ { public IScreenShotControlService(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Caps/IScreenshotService.cs b/src/Ryujinx.HLE/HOS/Services/Caps/IScreenshotService.cs index 03703e05..ab921e08 100644 --- a/src/Ryujinx.HLE/HOS/Services/Caps/IScreenshotService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Caps/IScreenshotService.cs @@ -5,4 +5,4 @@ namespace Ryujinx.HLE.HOS.Services.Caps { public IScreenshotService(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Caps/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Caps/ResultCode.cs index 2615eeda..51a6fd8a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Caps/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Caps/ResultCode.cs @@ -2,17 +2,17 @@ { enum ResultCode { - ModuleId = 206, + ModuleId = 206, ErrorCodeShift = 9, Success = 0, - InvalidArgument = (2 << ErrorCodeShift) | ModuleId, - ShimLibraryVersionAlreadySet = (7 << ErrorCodeShift) | ModuleId, - OutOfRange = (8 << ErrorCodeShift) | ModuleId, - InvalidContentType = (14 << ErrorCodeShift) | ModuleId, - NullOutputBuffer = (141 << ErrorCodeShift) | ModuleId, - NullInputBuffer = (142 << ErrorCodeShift) | ModuleId, - BlacklistedPid = (822 << ErrorCodeShift) | ModuleId + InvalidArgument = (2 << ErrorCodeShift) | ModuleId, + ShimLibraryVersionAlreadySet = (7 << ErrorCodeShift) | ModuleId, + OutOfRange = (8 << ErrorCodeShift) | ModuleId, + InvalidContentType = (14 << ErrorCodeShift) | ModuleId, + NullOutputBuffer = (141 << ErrorCodeShift) | ModuleId, + NullInputBuffer = (142 << ErrorCodeShift) | ModuleId, + BlacklistedPid = (822 << ErrorCodeShift) | ModuleId, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Caps/Types/AlbumFileDateTime.cs b/src/Ryujinx.HLE/HOS/Services/Caps/Types/AlbumFileDateTime.cs index b9bc799c..09c9b176 100644 --- a/src/Ryujinx.HLE/HOS/Services/Caps/Types/AlbumFileDateTime.cs +++ b/src/Ryujinx.HLE/HOS/Services/Caps/Types/AlbumFileDateTime.cs @@ -6,11 +6,11 @@ namespace Ryujinx.HLE.HOS.Services.Caps.Types struct AlbumFileDateTime { public ushort Year; - public byte Month; - public byte Day; - public byte Hour; - public byte Minute; - public byte Second; - public byte UniqueId; + public byte Month; + public byte Day; + public byte Hour; + public byte Minute; + public byte Second; + public byte UniqueId; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Caps/Types/AlbumImageOrientation.cs b/src/Ryujinx.HLE/HOS/Services/Caps/Types/AlbumImageOrientation.cs index 479675d6..2a1fbcac 100644 --- a/src/Ryujinx.HLE/HOS/Services/Caps/Types/AlbumImageOrientation.cs +++ b/src/Ryujinx.HLE/HOS/Services/Caps/Types/AlbumImageOrientation.cs @@ -5,6 +5,6 @@ Degrees0, Degrees90, Degrees180, - Degrees270 + Degrees270, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Caps/Types/AlbumStorage.cs b/src/Ryujinx.HLE/HOS/Services/Caps/Types/AlbumStorage.cs index cfe6c1e0..2fe99d45 100644 --- a/src/Ryujinx.HLE/HOS/Services/Caps/Types/AlbumStorage.cs +++ b/src/Ryujinx.HLE/HOS/Services/Caps/Types/AlbumStorage.cs @@ -3,6 +3,6 @@ enum AlbumStorage : byte { Nand, - Sd + Sd, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Caps/Types/ApplicationAlbumEntry.cs b/src/Ryujinx.HLE/HOS/Services/Caps/Types/ApplicationAlbumEntry.cs index 699bb418..701fa63d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Caps/Types/ApplicationAlbumEntry.cs +++ b/src/Ryujinx.HLE/HOS/Services/Caps/Types/ApplicationAlbumEntry.cs @@ -6,12 +6,12 @@ namespace Ryujinx.HLE.HOS.Services.Caps.Types [StructLayout(LayoutKind.Sequential, Size = 0x20)] struct ApplicationAlbumEntry { - public ulong Size; - public ulong TitleId; + public ulong Size; + public ulong TitleId; public AlbumFileDateTime AlbumFileDateTime; - public AlbumStorage AlbumStorage; - public ContentType ContentType; - public Array5<byte> Padding; - public byte Unknown0x1f; // Always 1 + public AlbumStorage AlbumStorage; + public ContentType ContentType; + public Array5<byte> Padding; + public byte Unknown0x1f; // Always 1 } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Caps/Types/ContentType.cs b/src/Ryujinx.HLE/HOS/Services/Caps/Types/ContentType.cs index 5f8bb537..56023d2e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Caps/Types/ContentType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Caps/Types/ContentType.cs @@ -5,6 +5,6 @@ Screenshot, Movie, ExtraMovie, - Unknown + Unknown, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Caps/Types/ScreenShotAttribute.cs b/src/Ryujinx.HLE/HOS/Services/Caps/Types/ScreenShotAttribute.cs index 5528379a..e7d8d0af 100644 --- a/src/Ryujinx.HLE/HOS/Services/Caps/Types/ScreenShotAttribute.cs +++ b/src/Ryujinx.HLE/HOS/Services/Caps/Types/ScreenShotAttribute.cs @@ -6,10 +6,10 @@ namespace Ryujinx.HLE.HOS.Services.Caps.Types [StructLayout(LayoutKind.Sequential, Size = 0x40)] struct ScreenShotAttribute { - public uint Unknown0x00; // Always 0 + public uint Unknown0x00; // Always 0 public AlbumImageOrientation AlbumImageOrientation; - public uint Unknown0x08; // Always 0 - public uint Unknown0x0C; // Always 1 - public Array30<byte> Unknown0x10; // Always 0 + public uint Unknown0x08; // Always 0 + public uint Unknown0x0C; // Always 1 + public Array30<byte> Unknown0x10; // Always 0 } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Cec/ICecManager.cs b/src/Ryujinx.HLE/HOS/Services/Cec/ICecManager.cs index 71c26786..044f5b1e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Cec/ICecManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Cec/ICecManager.cs @@ -5,4 +5,4 @@ namespace Ryujinx.HLE.HOS.Services.Cec { public ICecManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/CommandCmifAttribute.cs b/src/Ryujinx.HLE/HOS/Services/CommandCmifAttribute.cs index 3b3279ab..5b4f30da 100644 --- a/src/Ryujinx.HLE/HOS/Services/CommandCmifAttribute.cs +++ b/src/Ryujinx.HLE/HOS/Services/CommandCmifAttribute.cs @@ -9,4 +9,4 @@ namespace Ryujinx.HLE.HOS.Services public CommandCmifAttribute(int id) => Id = id; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/DummyService.cs b/src/Ryujinx.HLE/HOS/Services/DummyService.cs index d69441a3..838a9018 100644 --- a/src/Ryujinx.HLE/HOS/Services/DummyService.cs +++ b/src/Ryujinx.HLE/HOS/Services/DummyService.cs @@ -9,4 +9,4 @@ ServiceName = serviceName; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ectx/IReaderForSystem.cs b/src/Ryujinx.HLE/HOS/Services/Ectx/IReaderForSystem.cs index 52fe8702..09f02fc4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ectx/IReaderForSystem.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ectx/IReaderForSystem.cs @@ -5,4 +5,4 @@ { public IReaderForSystem(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ectx/IWriterForApplication.cs b/src/Ryujinx.HLE/HOS/Services/Ectx/IWriterForApplication.cs index 9401a6d7..a61fca55 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ectx/IWriterForApplication.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ectx/IWriterForApplication.cs @@ -5,4 +5,4 @@ { public IWriterForApplication(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ectx/IWriterForSystem.cs b/src/Ryujinx.HLE/HOS/Services/Ectx/IWriterForSystem.cs index 621ec777..30c22d1f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ectx/IWriterForSystem.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ectx/IWriterForSystem.cs @@ -5,4 +5,4 @@ { public IWriterForSystem(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Erpt/IContext.cs b/src/Ryujinx.HLE/HOS/Services/Erpt/IContext.cs index 9a689172..eadd3ea8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Erpt/IContext.cs +++ b/src/Ryujinx.HLE/HOS/Services/Erpt/IContext.cs @@ -5,4 +5,4 @@ { public IContext(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Erpt/ISession.cs b/src/Ryujinx.HLE/HOS/Services/Erpt/ISession.cs index 6397afae..b43cb30a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Erpt/ISession.cs +++ b/src/Ryujinx.HLE/HOS/Services/Erpt/ISession.cs @@ -5,4 +5,4 @@ { public ISession(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Es/IETicketService.cs b/src/Ryujinx.HLE/HOS/Services/Es/IETicketService.cs index 34be7bdd..ced213f0 100644 --- a/src/Ryujinx.HLE/HOS/Services/Es/IETicketService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Es/IETicketService.cs @@ -5,4 +5,4 @@ { public IETicketService(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Eupld/IControl.cs b/src/Ryujinx.HLE/HOS/Services/Eupld/IControl.cs index dd8705e6..4b069c60 100644 --- a/src/Ryujinx.HLE/HOS/Services/Eupld/IControl.cs +++ b/src/Ryujinx.HLE/HOS/Services/Eupld/IControl.cs @@ -5,4 +5,4 @@ { public IControl(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Eupld/IRequest.cs b/src/Ryujinx.HLE/HOS/Services/Eupld/IRequest.cs index 85097878..e14e4df4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Eupld/IRequest.cs +++ b/src/Ryujinx.HLE/HOS/Services/Eupld/IRequest.cs @@ -5,4 +5,4 @@ { public IRequest(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Fatal/IPrivateService.cs b/src/Ryujinx.HLE/HOS/Services/Fatal/IPrivateService.cs index eb2c9553..4cb3a2c1 100644 --- a/src/Ryujinx.HLE/HOS/Services/Fatal/IPrivateService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Fatal/IPrivateService.cs @@ -5,4 +5,4 @@ { public IPrivateService(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Fatal/IService.cs b/src/Ryujinx.HLE/HOS/Services/Fatal/IService.cs index aaa5c873..a62d633e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Fatal/IService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Fatal/IService.cs @@ -16,7 +16,7 @@ namespace Ryujinx.HLE.HOS.Services.Fatal public ResultCode ThrowFatal(ServiceCtx context) { ResultCode resultCode = (ResultCode)context.RequestData.ReadUInt64(); - ulong pid = context.Request.HandleDesc.PId; + ulong pid = context.Request.HandleDesc.PId; return ThrowFatalWithCpuContextImpl(context, resultCode, pid, FatalPolicy.ErrorReportAndErrorScreen, null); } @@ -25,9 +25,9 @@ namespace Ryujinx.HLE.HOS.Services.Fatal // ThrowFatalWithPolicy(u64 result_code, u32 fatal_policy, u64 pid) public ResultCode ThrowFatalWithPolicy(ServiceCtx context) { - ResultCode resultCode = (ResultCode)context.RequestData.ReadUInt64(); + ResultCode resultCode = (ResultCode)context.RequestData.ReadUInt64(); FatalPolicy fatalPolicy = (FatalPolicy)context.RequestData.ReadUInt32(); - ulong pid = context.Request.HandleDesc.PId; + ulong pid = context.Request.HandleDesc.PId; return ThrowFatalWithCpuContextImpl(context, resultCode, pid, fatalPolicy, null); } @@ -36,12 +36,12 @@ namespace Ryujinx.HLE.HOS.Services.Fatal // ThrowFatalWithCpuContext(u64 result_code, u32 fatal_policy, u64 pid, buffer<bytes, 0x15> cpu_context) public ResultCode ThrowFatalWithCpuContext(ServiceCtx context) { - ResultCode resultCode = (ResultCode)context.RequestData.ReadUInt64(); + ResultCode resultCode = (ResultCode)context.RequestData.ReadUInt64(); FatalPolicy fatalPolicy = (FatalPolicy)context.RequestData.ReadUInt32(); - ulong pid = context.Request.HandleDesc.PId; + ulong pid = context.Request.HandleDesc.PId; ulong cpuContextPosition = context.Request.SendBuff[0].Position; - ulong cpuContextSize = context.Request.SendBuff[0].Size; + ulong cpuContextSize = context.Request.SendBuff[0].Size; ReadOnlySpan<byte> cpuContextData = context.Memory.GetSpan(cpuContextPosition, (int)cpuContextSize); @@ -50,7 +50,7 @@ namespace Ryujinx.HLE.HOS.Services.Fatal private ResultCode ThrowFatalWithCpuContextImpl(ServiceCtx context, ResultCode resultCode, ulong pid, FatalPolicy fatalPolicy, ReadOnlySpan<byte> cpuContext) { - StringBuilder errorReport = new StringBuilder(); + StringBuilder errorReport = new(); errorReport.AppendLine(); errorReport.AppendLine("ErrorReport log:"); @@ -144,4 +144,4 @@ namespace Ryujinx.HLE.HOS.Services.Fatal return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Fatal/Types/CpuContext32.cs b/src/Ryujinx.HLE/HOS/Services/Fatal/Types/CpuContext32.cs index 5c0b116b..5eb1406a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Fatal/Types/CpuContext32.cs +++ b/src/Ryujinx.HLE/HOS/Services/Fatal/Types/CpuContext32.cs @@ -22,4 +22,4 @@ namespace Ryujinx.HLE.HOS.Services.Fatal.Types public uint StartAddress; public uint RegisterSetFlags; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Fatal/Types/CpuContext64.cs b/src/Ryujinx.HLE/HOS/Services/Fatal/Types/CpuContext64.cs index 24829a78..58fd3c4a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Fatal/Types/CpuContext64.cs +++ b/src/Ryujinx.HLE/HOS/Services/Fatal/Types/CpuContext64.cs @@ -19,6 +19,6 @@ namespace Ryujinx.HLE.HOS.Services.Fatal.Types public Array32<ulong> StackTrace; public ulong StartAddress; public ulong RegisterSetFlags; - public uint StackTraceSize; + public uint StackTraceSize; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Fatal/Types/FatalPolicy.cs b/src/Ryujinx.HLE/HOS/Services/Fatal/Types/FatalPolicy.cs index fe55cf12..f536d17d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Fatal/Types/FatalPolicy.cs +++ b/src/Ryujinx.HLE/HOS/Services/Fatal/Types/FatalPolicy.cs @@ -4,6 +4,6 @@ { ErrorReportAndErrorScreen, ErrorReport, - ErrorScreen + ErrorScreen, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Friend/IServiceCreator.cs b/src/Ryujinx.HLE/HOS/Services/Friend/IServiceCreator.cs index d5258a82..3f15f3fc 100644 --- a/src/Ryujinx.HLE/HOS/Services/Friend/IServiceCreator.cs +++ b/src/Ryujinx.HLE/HOS/Services/Friend/IServiceCreator.cs @@ -11,7 +11,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend [Service("friend:v", FriendServicePermissionLevel.Viewer)] class IServiceCreator : IpcService { - private FriendServicePermissionLevel _permissionLevel; + private readonly FriendServicePermissionLevel _permissionLevel; public IServiceCreator(ServiceCtx context, FriendServicePermissionLevel permissionLevel) { @@ -52,4 +52,4 @@ namespace Ryujinx.HLE.HOS.Services.Friend return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Friend/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Friend/ResultCode.cs index 3e66e873..82462b4e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Friend/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Friend/ResultCode.cs @@ -2,13 +2,13 @@ { enum ResultCode { - ModuleId = 121, + ModuleId = 121, ErrorCodeShift = 9, Success = 0, - InvalidArgument = (2 << ErrorCodeShift) | ModuleId, - InternetRequestDenied = (6 << ErrorCodeShift) | ModuleId, - NotificationQueueEmpty = (15 << ErrorCodeShift) | ModuleId + InvalidArgument = (2 << ErrorCodeShift) | ModuleId, + InternetRequestDenied = (6 << ErrorCodeShift) | ModuleId, + NotificationQueueEmpty = (15 << ErrorCodeShift) | ModuleId, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/FriendService/Types/Friend.cs b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/FriendService/Types/Friend.cs index 87f54bf3..e727cafb 100644 --- a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/FriendService/Types/Friend.cs +++ b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/FriendService/Types/Friend.cs @@ -6,8 +6,8 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator.FriendService [StructLayout(LayoutKind.Sequential, Pack = 0x8, Size = 0x200, CharSet = CharSet.Ansi)] struct Friend { - public UserId UserId; - public long NetworkUserId; + public UserId UserId; + public long NetworkUserId; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x21)] public string Nickname; @@ -21,9 +21,9 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator.FriendService public bool IsNew; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x6)] - char[] Unknown; + readonly char[] Unknown; [MarshalAs(UnmanagedType.I1)] public bool IsValid; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/FriendService/Types/FriendFilter.cs b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/FriendService/Types/FriendFilter.cs index 261bf7bf..6f10a757 100644 --- a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/FriendService/Types/FriendFilter.cs +++ b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/FriendService/Types/FriendFilter.cs @@ -21,4 +21,4 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator.FriendService public long PresenceGroupId; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/FriendService/Types/PresenceStatus.cs b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/FriendService/Types/PresenceStatus.cs index df2e6525..0271e61a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/FriendService/Types/PresenceStatus.cs +++ b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/FriendService/Types/PresenceStatus.cs @@ -4,6 +4,6 @@ { Offline, Online, - OnlinePlay + OnlinePlay, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/FriendService/Types/PresenceStatusFilter.cs b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/FriendService/Types/PresenceStatusFilter.cs index 24da7fd3..5949b8f6 100644 --- a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/FriendService/Types/PresenceStatusFilter.cs +++ b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/FriendService/Types/PresenceStatusFilter.cs @@ -5,6 +5,6 @@ None, Online, OnlinePlay, - OnlineOrOnlinePlay + OnlineOrOnlinePlay, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/FriendService/Types/UserPresence.cs b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/FriendService/Types/UserPresence.cs index d36b3f31..9769e160 100644 --- a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/FriendService/Types/UserPresence.cs +++ b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/FriendService/Types/UserPresence.cs @@ -8,8 +8,8 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator.FriendService [StructLayout(LayoutKind.Sequential, Pack = 0x8)] struct UserPresence { - public UserId UserId; - public long LastTimeOnlineTimestamp; + public UserId UserId; + public long LastTimeOnlineTimestamp; public PresenceStatus Status; [MarshalAs(UnmanagedType.I1)] @@ -26,9 +26,9 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator.FriendService public const int Size = 0xC0; } - public override string ToString() + public readonly override string ToString() { return $"UserPresence {{ UserId: {UserId}, LastTimeOnlineTimestamp: {LastTimeOnlineTimestamp}, Status: {Status} }}"; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/IDaemonSuspendSessionService.cs b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/IDaemonSuspendSessionService.cs index 42b34312..3b1601ab 100644 --- a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/IDaemonSuspendSessionService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/IDaemonSuspendSessionService.cs @@ -2,11 +2,13 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator { class IDaemonSuspendSessionService : IpcService { - private FriendServicePermissionLevel PermissionLevel; +#pragma warning disable IDE0052 // Remove unread private member + private readonly FriendServicePermissionLevel _permissionLevel; +#pragma warning restore IDE0052 public IDaemonSuspendSessionService(FriendServicePermissionLevel permissionLevel) { - PermissionLevel = permissionLevel; + _permissionLevel = permissionLevel; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/IFriendService.cs b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/IFriendService.cs index 2858aa46..f084fad1 100644 --- a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/IFriendService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/IFriendService.cs @@ -15,8 +15,10 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator { class IFriendService : IpcService { - private FriendServicePermissionLevel _permissionLevel; - private KEvent _completionEvent; +#pragma warning disable IDE0052 // Remove unread private member + private readonly FriendServicePermissionLevel _permissionLevel; +#pragma warning restore IDE0052 + private KEvent _completionEvent; public IFriendService(FriendServicePermissionLevel permissionLevel) { @@ -27,10 +29,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator // GetCompletionEvent() -> handle<copy> public ResultCode GetCompletionEvent(ServiceCtx context) { - if (_completionEvent == null) - { - _completionEvent = new KEvent(context.Device.System.KernelContext); - } + _completionEvent ??= new KEvent(context.Device.System.KernelContext); if (context.Process.HandleTable.GenerateHandle(_completionEvent.ReadableEvent, out int completionEventHandle) != Result.Success) { @@ -62,7 +61,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator // Padding context.RequestData.ReadInt32(); - UserId userId = context.RequestData.ReadStruct<UserId>(); + UserId userId = context.RequestData.ReadStruct<UserId>(); FriendFilter filter = context.RequestData.ReadStruct<FriendFilter>(); // Pid placeholder @@ -101,7 +100,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator // Padding context.RequestData.ReadInt32(); - UserId userId = context.RequestData.ReadStruct<UserId>(); + UserId userId = context.RequestData.ReadStruct<UserId>(); FriendFilter filter = context.RequestData.ReadStruct<FriendFilter>(); // Pid placeholder @@ -115,7 +114,8 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator // There are no friends online, so we return 0 because the nn::account::NetworkServiceAccountId array is empty. context.ResponseData.Write(0); - Logger.Stub?.PrintStub(LogClass.ServiceFriend, new { + Logger.Stub?.PrintStub(LogClass.ServiceFriend, new + { UserId = userId.ToString(), offset, filter.PresenceStatus, @@ -233,7 +233,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator context.RequestData.ReadInt64(); ulong position = context.Request.PtrBuff[0].Position; - ulong size = context.Request.PtrBuff[0].Size; + ulong size = context.Request.PtrBuff[0].Size; ReadOnlySpan<UserPresence> userPresenceInputArray = MemoryMarshal.Cast<byte, UserPresence>(context.Memory.GetSpan(position, (int)size)); @@ -251,8 +251,8 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator // nn::friends::GetPlayHistoryRegistrationKey(b8 unknown, nn::account::Uid) -> buffer<nn::friends::PlayHistoryRegistrationKey, 0x1a> public ResultCode GetPlayHistoryRegistrationKey(ServiceCtx context) { - bool unknownBool = context.RequestData.ReadBoolean(); - UserId userId = context.RequestData.ReadStruct<UserId>(); + bool unknownBool = context.RequestData.ReadBoolean(); + UserId userId = context.RequestData.ReadStruct<UserId>(); context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize(0x40UL); @@ -274,18 +274,18 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator // Then it checks if an Uuid is already stored for the UserId, if not it generates a random Uuid. // And store it in the savedata 8000000000000080 in the friends:/uid.bin file. - Array16<byte> randomGuid = new Array16<byte>(); + Array16<byte> randomGuid = new(); Guid.NewGuid().ToByteArray().AsSpan().CopyTo(randomGuid.AsSpan()); - PlayHistoryRegistrationKey playHistoryRegistrationKey = new PlayHistoryRegistrationKey + PlayHistoryRegistrationKey playHistoryRegistrationKey = new() { - Type = 0x101, - KeyIndex = (byte)(randomBytes[0] & 7), - UserIdBool = 0, // TODO: Find it. + Type = 0x101, + KeyIndex = (byte)(randomBytes[0] & 7), + UserIdBool = 0, // TODO: Find it. UnknownBool = (byte)(unknownBool ? 1 : 0), // TODO: Find it. - Reserved = new Array11<byte>(), - Uuid = randomGuid + Reserved = new Array11<byte>(), + Uuid = randomGuid, }; ReadOnlySpan<byte> playHistoryRegistrationKeyBuffer = SpanHelpers.AsByteSpan(ref playHistoryRegistrationKey); @@ -303,7 +303,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator */ - context.Memory.Write(bufferPosition, playHistoryRegistrationKeyBuffer); + context.Memory.Write(bufferPosition, playHistoryRegistrationKeyBuffer); context.Memory.Write(bufferPosition + 0x20, new byte[0x20]); // HmacHash return ResultCode.Success; @@ -317,16 +317,20 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator // Pid placeholder context.RequestData.ReadInt64(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment ulong pid = context.Request.HandleDesc.PId; ulong playHistoryRegistrationKeyPosition = context.Request.PtrBuff[0].Position; - ulong PlayHistoryRegistrationKeySize = context.Request.PtrBuff[0].Size; + ulong playHistoryRegistrationKeySize = context.Request.PtrBuff[0].Size; ulong inAppScreenName1Position = context.Request.PtrBuff[1].Position; - ulong inAppScreenName1Size = context.Request.PtrBuff[1].Size; +#pragma warning restore IDE0059 + ulong inAppScreenName1Size = context.Request.PtrBuff[1].Size; +#pragma warning disable IDE0059 // Remove unnecessary value assignment ulong inAppScreenName2Position = context.Request.PtrBuff[2].Position; - ulong inAppScreenName2Size = context.Request.PtrBuff[2].Size; +#pragma warning restore IDE0059 + ulong inAppScreenName2Size = context.Request.PtrBuff[2].Size; if (userId.IsNull || inAppScreenName1Size > 0x48 || inAppScreenName2Size > 0x48) { @@ -334,7 +338,9 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator } // TODO: Call nn::arp::GetApplicationControlProperty here when implemented. +#pragma warning disable IDE0059 // Remove unnecessary value assignment ApplicationControlProperty controlProperty = context.Device.Processes.ActiveApplication.ApplicationControlProperties; +#pragma warning restore IDE0059 /* @@ -349,4 +355,4 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/INotificationService.cs b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/INotificationService.cs index 50558022..8fc7a460 100644 --- a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/INotificationService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/INotificationService.cs @@ -11,24 +11,24 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator { class INotificationService : DisposableIpcService { - private readonly UserId _userId; + private readonly UserId _userId; private readonly FriendServicePermissionLevel _permissionLevel; private readonly object _lock = new(); - private KEvent _notificationEvent; - private int _notificationEventHandle = 0; + private readonly KEvent _notificationEvent; + private int _notificationEventHandle = 0; - private LinkedList<NotificationInfo> _notifications; + private readonly LinkedList<NotificationInfo> _notifications; private bool _hasNewFriendRequest; private bool _hasFriendListUpdate; public INotificationService(ServiceCtx context, UserId userId, FriendServicePermissionLevel permissionLevel) { - _userId = userId; - _permissionLevel = permissionLevel; - _notifications = new LinkedList<NotificationInfo>(); + _userId = userId; + _permissionLevel = permissionLevel; + _notifications = new LinkedList<NotificationInfo>(); _notificationEvent = new KEvent(context.Device.System.KernelContext); _hasNewFriendRequest = false; @@ -106,7 +106,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator { if (!_hasFriendListUpdate) { - NotificationInfo friendListNotification = new NotificationInfo(); + NotificationInfo friendListNotification = new(); if (_notifications.Count != 0) { @@ -119,7 +119,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator if (_hasNewFriendRequest) { - NotificationInfo newFriendRequestNotification = new NotificationInfo(); + NotificationInfo newFriendRequestNotification = new(); if (_notifications.Count != 0) { @@ -153,9 +153,9 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator SignalFriendListUpdate(targetId); } - NotificationInfo newFriendRequestNotification = new NotificationInfo + NotificationInfo newFriendRequestNotification = new() { - Type = NotificationEventType.NewFriendRequest + Type = NotificationEventType.NewFriendRequest, }; _notifications.AddLast(newFriendRequestNotification); @@ -175,4 +175,4 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/NotificationService/NotificationEventHandler.cs b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/NotificationService/NotificationEventHandler.cs index 383ad006..f0970d16 100644 --- a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/NotificationService/NotificationEventHandler.cs +++ b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/NotificationService/NotificationEventHandler.cs @@ -4,23 +4,20 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator.NotificationService { public sealed class NotificationEventHandler { - private static NotificationEventHandler instance; - private static object instanceLock = new object(); + private static NotificationEventHandler _instance; + private static readonly object _instanceLock = new(); - private INotificationService[] _registry; + private readonly INotificationService[] _registry; public static NotificationEventHandler Instance { get { - lock (instanceLock) + lock (_instanceLock) { - if (instance == null) - { - instance = new NotificationEventHandler(); - } + _instance ??= new NotificationEventHandler(); - return instance; + return _instance; } } } @@ -61,10 +58,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator.NotificationService { for (int i = 0; i < _registry.Length; i++) { - if (_registry[i] != null) - { - _registry[i].SignalFriendListUpdate(targetId); - } + _registry[i]?.SignalFriendListUpdate(targetId); } } @@ -73,11 +67,8 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator.NotificationService { for (int i = 0; i < _registry.Length; i++) { - if (_registry[i] != null) - { - _registry[i].SignalNewFriendRequest(targetId); - } + _registry[i]?.SignalNewFriendRequest(targetId); } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/NotificationService/Types/NotificationEventType.cs b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/NotificationService/Types/NotificationEventType.cs index 5136ae8a..d7f3f55d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/NotificationService/Types/NotificationEventType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/NotificationService/Types/NotificationEventType.cs @@ -2,8 +2,8 @@ { enum NotificationEventType : uint { - Invalid = 0x0, + Invalid = 0x0, FriendListUpdate = 0x1, - NewFriendRequest = 0x65 + NewFriendRequest = 0x65, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/NotificationService/Types/NotificationInfo.cs b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/NotificationService/Types/NotificationInfo.cs index e710bf06..1073c47d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/NotificationService/Types/NotificationInfo.cs +++ b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/NotificationService/Types/NotificationInfo.cs @@ -10,4 +10,4 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator.NotificationService private Array4<byte> _padding; public long NetworkUserIdPlaceholder; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/Types/FriendServicePermissionLevel.cs b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/Types/FriendServicePermissionLevel.cs index 12a3d42f..bf7d1bd3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/Types/FriendServicePermissionLevel.cs +++ b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/Types/FriendServicePermissionLevel.cs @@ -5,15 +5,15 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator [Flags] enum FriendServicePermissionLevel { - UserMask = 1, - ViewerMask = 2, + UserMask = 1, + ViewerMask = 2, ManagerMask = 4, - SystemMask = 8, + SystemMask = 8, Administrator = -1, - User = UserMask, - Viewer = UserMask | ViewerMask, - Manager = UserMask | ViewerMask | ManagerMask, - System = UserMask | SystemMask + User = UserMask, + Viewer = UserMask | ViewerMask, + Manager = UserMask | ViewerMask | ManagerMask, + System = UserMask | SystemMask, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/Types/PlayHistoryRegistrationKey.cs b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/Types/PlayHistoryRegistrationKey.cs index 32d962c1..aaeef059 100644 --- a/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/Types/PlayHistoryRegistrationKey.cs +++ b/src/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/Types/PlayHistoryRegistrationKey.cs @@ -6,10 +6,10 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator [StructLayout(LayoutKind.Sequential, Size = 0x20)] struct PlayHistoryRegistrationKey { - public ushort Type; - public byte KeyIndex; - public byte UserIdBool; - public byte UnknownBool; + public ushort Type; + public byte KeyIndex; + public byte UserIdBool; + public byte UnknownBool; public Array11<byte> Reserved; public Array16<byte> Uuid; } diff --git a/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/FileSystemProxyHelper.cs b/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/FileSystemProxyHelper.cs index ba924db8..599025e3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/FileSystemProxyHelper.cs +++ b/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/FileSystemProxyHelper.cs @@ -25,7 +25,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy try { - LocalStorage storage = new LocalStorage(pfsPath, FileAccess.Read, FileMode.Open); + LocalStorage storage = new(pfsPath, FileAccess.Read, FileMode.Open); using SharedRef<LibHac.Fs.Fsa.IFileSystem> nsp = new(new PartitionFileSystem(storage)); ImportTitleKeysFromNsp(nsp.Get, context.Device.System.KeySet); @@ -48,7 +48,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy try { - Nca nca = new Nca(context.Device.System.KeySet, ncaStorage); + Nca nca = new(context.Device.System.KeySet, ncaStorage); if (!nca.SectionExists(NcaSectionType.Data)) { @@ -83,14 +83,14 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy if (archivePath.Extension == ".nsp" && File.Exists(archivePath.FullName)) { - FileStream pfsFile = new FileStream( + FileStream pfsFile = new( archivePath.FullName.TrimEnd(Path.DirectorySeparatorChar), FileMode.Open, FileAccess.Read); try { - PartitionFileSystem nsp = new PartitionFileSystem(pfsFile.AsStorage()); + PartitionFileSystem nsp = new(pfsFile.AsStorage()); ImportTitleKeysFromNsp(nsp, context.Device.System.KeySet); @@ -125,7 +125,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy if (result.IsSuccess()) { - Ticket ticket = new Ticket(ticketFile.Get.AsStream()); + Ticket ticket = new(ticketFile.Get.AsStream()); var titleKey = ticket.GetTitleKey(keySet); if (titleKey != null) diff --git a/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IDirectory.cs b/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IDirectory.cs index b9759449..70d3a6bd 100644 --- a/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IDirectory.cs +++ b/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IDirectory.cs @@ -20,14 +20,12 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy ulong bufferAddress = context.Request.ReceiveBuff[0].Position; ulong bufferLen = context.Request.ReceiveBuff[0].Size; - using (var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true)) - { - Result result = _baseDirectory.Get.Read(out long entriesRead, new OutBuffer(region.Memory.Span)); + using var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true); + Result result = _baseDirectory.Get.Read(out long entriesRead, new OutBuffer(region.Memory.Span)); - context.ResponseData.Write(entriesRead); + context.ResponseData.Write(entriesRead); - return (ResultCode)result.Value; - } + return (ResultCode)result.Value; } [CommandCmif(1)] diff --git a/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IFile.cs b/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IFile.cs index 4bc58ae5..dcc34a75 100644 --- a/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IFile.cs +++ b/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IFile.cs @@ -26,16 +26,14 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy context.RequestData.BaseStream.Position += 4; long offset = context.RequestData.ReadInt64(); - long size = context.RequestData.ReadInt64(); + long size = context.RequestData.ReadInt64(); - using (var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true)) - { - Result result = _baseFile.Get.Read(out long bytesRead, offset, new OutBuffer(region.Memory.Span), size, readOption); + using var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true); + Result result = _baseFile.Get.Read(out long bytesRead, offset, new OutBuffer(region.Memory.Span), size, readOption); - context.ResponseData.Write(bytesRead); + context.ResponseData.Write(bytesRead); - return (ResultCode)result.Value; - } + return (ResultCode)result.Value; } [CommandCmif(1)] @@ -48,7 +46,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy context.RequestData.BaseStream.Position += 4; long offset = context.RequestData.ReadInt64(); - long size = context.RequestData.ReadInt64(); + long size = context.RequestData.ReadInt64(); byte[] data = new byte[context.Request.SendBuff[0].Size]; @@ -92,4 +90,4 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IFileSystem.cs b/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IFileSystem.cs index 9effa79d..4c5c5624 100644 --- a/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IFileSystem.cs +++ b/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IFileSystem.cs @@ -115,7 +115,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy if (result.IsSuccess()) { - IFile fileInterface = new IFile(ref file.Ref); + IFile fileInterface = new(ref file.Ref); MakeObject(context, fileInterface); } @@ -136,7 +136,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy if (result.IsSuccess()) { - IDirectory dirInterface = new IDirectory(ref dir.Ref); + IDirectory dirInterface = new(ref dir.Ref); MakeObject(context, dirInterface); } @@ -210,4 +210,4 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IStorage.cs b/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IStorage.cs index 54c7b800..4299a6c7 100644 --- a/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IStorage.cs +++ b/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IStorage.cs @@ -1,7 +1,6 @@ using LibHac; using LibHac.Common; using LibHac.Sf; -using Ryujinx.HLE.HOS.Ipc; namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy { @@ -19,7 +18,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy public ResultCode Read(ServiceCtx context) { ulong offset = context.RequestData.ReadUInt64(); - ulong size = context.RequestData.ReadUInt64(); + ulong size = context.RequestData.ReadUInt64(); if (context.Request.ReceiveBuff.Count > 0) { @@ -32,12 +31,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy size = bufferLen; } - using (var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true)) - { - Result result = _baseStorage.Get.Read((long)offset, new OutBuffer(region.Memory.Span), (long)size); + using var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true); + Result result = _baseStorage.Get.Read((long)offset, new OutBuffer(region.Memory.Span), (long)size); - return (ResultCode)result.Value; - } + return (ResultCode)result.Value; } return ResultCode.Success; @@ -62,4 +59,4 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Fs/IFileSystemProxy.cs b/src/Ryujinx.HLE/HOS/Services/Fs/IFileSystemProxy.cs index e961e9b1..644e1a17 100644 --- a/src/Ryujinx.HLE/HOS/Services/Fs/IFileSystemProxy.cs +++ b/src/Ryujinx.HLE/HOS/Services/Fs/IFileSystemProxy.cs @@ -18,7 +18,6 @@ using static Ryujinx.HLE.Utilities.StringUtils; using GameCardHandle = System.UInt32; using IFileSystem = LibHac.FsSrv.Sf.IFileSystem; using IStorage = LibHac.FsSrv.Sf.IStorage; -using RightsId = LibHac.Fs.RightsId; namespace Ryujinx.HLE.HOS.Services.Fs { @@ -48,14 +47,16 @@ namespace Ryujinx.HLE.HOS.Services.Fs // -> object<nn::fssrv::sf::IFileSystem> contentFs public ResultCode OpenFileSystemWithId(ServiceCtx context) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment FileSystemType fileSystemType = (FileSystemType)context.RequestData.ReadInt32(); ulong titleId = context.RequestData.ReadUInt64(); +#pragma warning restore IDE0059 string switchPath = ReadUtf8String(context); - string fullPath = context.Device.FileSystem.SwitchPathToSystemPath(switchPath); + string fullPath = FileSystem.VirtualFileSystem.SwitchPathToSystemPath(switchPath); if (!File.Exists(fullPath)) { - if (fullPath.Contains(".")) + if (fullPath.Contains('.')) { ResultCode result = FileSystemProxyHelper.OpenFileSystemFromInternalFile(context, fullPath, out FileSystemProxy.IFileSystem fileSystem); @@ -70,7 +71,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs return ResultCode.PathDoesNotExist; } - FileStream fileStream = new FileStream(fullPath, FileMode.Open, FileAccess.Read); + FileStream fileStream = new(fullPath, FileMode.Open, FileAccess.Read); string extension = System.IO.Path.GetExtension(fullPath); if (extension == ".nca") @@ -109,7 +110,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs using var fileSystem = new SharedRef<IFileSystem>(); Result result = _baseFileSystemProxy.Get.OpenBisFileSystem(ref fileSystem.Ref, in path, bisPartitionId); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref)); @@ -124,7 +128,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs using var storage = new SharedRef<IStorage>(); Result result = _baseFileSystemProxy.Get.OpenBisStorage(ref storage.Ref, bisPartitionId); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } MakeObject(context, new FileSystemProxy.IStorage(ref storage.Ref)); @@ -145,7 +152,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs using var fileSystem = new SharedRef<IFileSystem>(); Result result = _baseFileSystemProxy.Get.OpenSdCardFileSystem(ref fileSystem.Ref); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref)); @@ -221,7 +231,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs public ResultCode IsExFatSupported(ServiceCtx context) { Result result = _baseFileSystemProxy.Get.IsExFatSupported(out bool isSupported); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } context.ResponseData.Write(isSupported); @@ -247,7 +260,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs using var storage = new SharedRef<IStorage>(); Result result = _baseFileSystemProxy.Get.OpenGameCardStorage(ref storage.Ref, handle, partitionId); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } MakeObject(context, new FileSystemProxy.IStorage(ref storage.Ref)); @@ -263,7 +279,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs using var fileSystem = new SharedRef<IFileSystem>(); Result result = _baseFileSystemProxy.Get.OpenGameCardFileSystem(ref fileSystem.Ref, handle, partitionId); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref)); @@ -298,7 +317,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs ushort index = context.RequestData.ReadUInt16(); Result result = _baseFileSystemProxy.Get.GetCacheStorageSize(out long dataSize, out long journalSize, index); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } context.ResponseData.Write(dataSize); context.ResponseData.Write(journalSize); @@ -338,7 +360,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs using var fileSystem = new SharedRef<IFileSystem>(); Result result = _baseFileSystemProxy.Get.OpenSaveDataFileSystem(ref fileSystem.Ref, spaceId, in attribute); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref)); @@ -354,7 +379,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs using var fileSystem = new SharedRef<IFileSystem>(); Result result = _baseFileSystemProxy.Get.OpenSaveDataFileSystemBySystemSaveDataId(ref fileSystem.Ref, spaceId, in attribute); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref)); @@ -370,7 +398,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs using var fileSystem = new SharedRef<IFileSystem>(); Result result = _baseFileSystemProxy.Get.OpenReadOnlySaveDataFileSystem(ref fileSystem.Ref, spaceId, in attribute); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref)); @@ -388,7 +419,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs context.Memory.Read(context.Request.ReceiveBuff[0].Position, extraDataBuffer); Result result = _baseFileSystemProxy.Get.ReadSaveDataFileSystemExtraDataBySaveDataSpaceId(new OutBuffer(extraDataBuffer), spaceId, saveDataId); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } context.Memory.Write(context.Request.ReceiveBuff[0].Position, extraDataBuffer); @@ -405,7 +439,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs context.Memory.Read(context.Request.ReceiveBuff[0].Position, extraDataBuffer); Result result = _baseFileSystemProxy.Get.ReadSaveDataFileSystemExtraData(new OutBuffer(extraDataBuffer), saveDataId); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } context.Memory.Write(context.Request.ReceiveBuff[0].Position, extraDataBuffer); @@ -432,7 +469,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs using var infoReader = new SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader>(); Result result = _baseFileSystemProxy.Get.OpenSaveDataInfoReader(ref infoReader.Ref); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } MakeObject(context, new ISaveDataInfoReader(ref infoReader.Ref)); @@ -447,7 +487,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs using var infoReader = new SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader>(); Result result = _baseFileSystemProxy.Get.OpenSaveDataInfoReaderBySaveDataSpaceId(ref infoReader.Ref, spaceId); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } MakeObject(context, new ISaveDataInfoReader(ref infoReader.Ref)); @@ -461,7 +504,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs using var infoReader = new SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader>(); Result result = _baseFileSystemProxy.Get.OpenSaveDataInfoReaderOnlyCacheStorage(ref infoReader.Ref); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } MakeObject(context, new ISaveDataInfoReader(ref infoReader.Ref)); @@ -477,7 +523,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs using var fileSystem = new SharedRef<IFileSystem>(); Result result = _baseFileSystemProxy.Get.OpenSaveDataInternalStorageFileSystem(ref fileSystem.Ref, spaceId, saveDataId); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref)); @@ -518,14 +567,15 @@ namespace Ryujinx.HLE.HOS.Services.Fs ulong bufferAddress = context.Request.ReceiveBuff[0].Position; ulong bufferLen = context.Request.ReceiveBuff[0].Size; - using (var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true)) + using var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true); + Result result = _baseFileSystemProxy.Get.FindSaveDataWithFilter(out long count, new OutBuffer(region.Memory.Span), spaceId, in filter); + if (result.IsFailure()) { - Result result = _baseFileSystemProxy.Get.FindSaveDataWithFilter(out long count, new OutBuffer(region.Memory.Span), spaceId, in filter); - if (result.IsFailure()) return (ResultCode)result.Value; - - context.ResponseData.Write(count); + return (ResultCode)result.Value; } + context.ResponseData.Write(count); + return ResultCode.Success; } @@ -537,7 +587,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs using var infoReader = new SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader>(); Result result = _baseFileSystemProxy.Get.OpenSaveDataInfoReaderWithFilter(ref infoReader.Ref, spaceId, in filter); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } MakeObject(context, new ISaveDataInfoReader(ref infoReader.Ref)); @@ -554,7 +607,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs context.Memory.Read(context.Request.ReceiveBuff[0].Position, outputBuffer); Result result = _baseFileSystemProxy.Get.ReadSaveDataFileSystemExtraDataBySaveDataAttribute(new OutBuffer(outputBuffer), spaceId, in attribute); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } context.Memory.Write(context.Request.ReceiveBuff[0].Position, outputBuffer); @@ -589,7 +645,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs context.Memory.Read(context.Request.ReceiveBuff[0].Position, outputBuffer); Result result = _baseFileSystemProxy.Get.ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute(new OutBuffer(outputBuffer), spaceId, in attribute, new InBuffer(maskBuffer)); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } context.Memory.Write(context.Request.ReceiveBuff[0].Position, outputBuffer); @@ -605,7 +664,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs using var file = new SharedRef<LibHac.FsSrv.Sf.IFile>(); Result result = _baseFileSystemProxy.Get.OpenSaveDataMetaFile(ref file.Ref, spaceId, in attribute, metaType); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } MakeObject(context, new IFile(ref file.Ref)); @@ -623,7 +685,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs context.Memory.Read(context.Request.ReceiveBuff[0].Position, outputBuffer); Result result = _baseFileSystemProxy.Get.ListAccessibleSaveDataOwnerId(out int readCount, new OutBuffer(outputBuffer), programId, startIndex, bufferCount); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } context.ResponseData.Write(readCount); @@ -637,7 +702,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs using var fileSystem = new SharedRef<IFileSystem>(); Result result = _baseFileSystemProxy.Get.OpenImageDirectoryFileSystem(ref fileSystem.Ref, directoryId); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref)); @@ -651,7 +719,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs using var fileSystem = new SharedRef<IFileSystem>(); Result result = _baseFileSystemProxy.Get.OpenBaseFileSystem(ref fileSystem.Ref, fileSystemId); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref)); @@ -665,7 +736,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs using var fileSystem = new SharedRef<IFileSystem>(); Result result = _baseFileSystemProxy.Get.OpenContentStorageFileSystem(ref fileSystem.Ref, contentStorageId); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref)); @@ -679,7 +753,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs using var fileSystem = new SharedRef<IFileSystem>(); Result result = _baseFileSystemProxy.Get.OpenCloudBackupWorkStorageFileSystem(ref fileSystem.Ref, storageId); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref)); @@ -693,7 +770,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs using var fileSystem = new SharedRef<IFileSystem>(); Result result = _baseFileSystemProxy.Get.OpenCustomStorageFileSystem(ref fileSystem.Ref, customStorageId); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref)); @@ -718,7 +798,9 @@ namespace Ryujinx.HLE.HOS.Services.Fs public ResultCode OpenDataStorageByDataId(ServiceCtx context) { StorageId storageId = (StorageId)context.RequestData.ReadByte(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment byte[] padding = context.RequestData.ReadBytes(7); +#pragma warning restore IDE0059 ulong titleId = context.RequestData.ReadUInt64(); // We do a mitm here to find if the request is for an AOC. @@ -750,7 +832,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs if (installedStorage != StorageId.None) { string contentPath = context.Device.System.ContentManager.GetInstalledContentPath(titleId, storageId, contentType); - string installPath = context.Device.FileSystem.SwitchPathToSystemPath(contentPath); + string installPath = FileSystem.VirtualFileSystem.SwitchPathToSystemPath(contentPath); if (!string.IsNullOrWhiteSpace(installPath)) { @@ -761,7 +843,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs try { LibHac.Fs.IStorage ncaStorage = new LocalStorage(ncaPath, FileAccess.Read, FileMode.Open); - Nca nca = new Nca(context.Device.System.KeySet, ncaStorage); + Nca nca = new(context.Device.System.KeySet, ncaStorage); LibHac.Fs.IStorage romfsStorage = nca.OpenStorage(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel); using var sharedStorage = new SharedRef<LibHac.Fs.IStorage>(romfsStorage); using var sfStorage = new SharedRef<IStorage>(new StorageInterfaceAdapter(ref sharedStorage.Ref)); @@ -829,7 +911,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs using var deviceOperator = new SharedRef<LibHac.FsSrv.Sf.IDeviceOperator>(); Result result = _baseFileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } MakeObject(context, new IDeviceOperator(ref deviceOperator.Ref)); @@ -843,7 +928,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs long journalSize = context.RequestData.ReadInt64(); Result result = _baseFileSystemProxy.Get.QuerySaveDataTotalSize(out long totalSize, dataSize, journalSize); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } context.ResponseData.Write(totalSize); @@ -907,7 +995,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs ProgramId programId = context.RequestData.ReadStruct<ProgramId>(); Result result = _baseFileSystemProxy.Get.GetRightsId(out RightsId rightsId, programId, storageId); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } context.ResponseData.WriteStruct(rightsId); @@ -935,7 +1026,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs ref readonly var path = ref FileSystemProxyHelper.GetFspPath(context); Result result = _baseFileSystemProxy.Get.GetRightsIdByPath(out RightsId rightsId, in path); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } context.ResponseData.WriteStruct(rightsId); @@ -948,7 +1042,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs ref readonly var path = ref FileSystemProxyHelper.GetFspPath(context); Result result = _baseFileSystemProxy.Get.GetRightsIdAndKeyGenerationByPath(out RightsId rightsId, out byte keyGeneration, in path); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } context.ResponseData.Write(keyGeneration); context.ResponseData.BaseStream.Seek(7, SeekOrigin.Current); @@ -973,7 +1070,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs SaveDataSpaceId spaceId = context.RequestData.ReadStruct<SaveDataSpaceId>(); Result result = _baseFileSystemProxy.Get.GetFreeSpaceSizeForSaveData(out long freeSpaceSize, spaceId); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } context.ResponseData.Write(freeSpaceSize); @@ -1008,7 +1108,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs ulong saveDataId = context.RequestData.ReadUInt64(); Result result = _baseFileSystemProxy.Get.QuerySaveDataInternalStorageTotalSize(out long size, spaceId, saveDataId); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } context.ResponseData.Write(size); @@ -1022,7 +1125,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs ulong saveDataId = context.RequestData.ReadUInt64(); Result result = _baseFileSystemProxy.Get.GetSaveDataCommitId(out long commitId, spaceId, saveDataId); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } context.ResponseData.Write(commitId); @@ -1059,7 +1165,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs public ResultCode IsSdCardAccessible(ServiceCtx context) { Result result = _baseFileSystemProxy.Get.IsSdCardAccessible(out bool isAccessible); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } context.ResponseData.Write(isAccessible); @@ -1072,7 +1181,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs ulong processId = context.RequestData.ReadUInt64(); Result result = _baseFileSystemProxy.Get.IsAccessFailureDetected(out bool isDetected, processId); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } context.ResponseData.Write(isDetected); @@ -1099,7 +1211,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs public ResultCode GetAndClearErrorInfo(ServiceCtx context) { Result result = _baseFileSystemProxy.Get.GetAndClearErrorInfo(out FileSystemProxyErrorInfo errorInfo); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } context.ResponseData.WriteStruct(errorInfo); @@ -1195,7 +1310,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs using var fileSystem = new SharedRef<IFileSystem>(); Result result = _baseFileSystemProxy.Get.OpenRegisteredUpdatePartition(ref fileSystem.Ref); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref)); @@ -1206,7 +1324,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs public ResultCode GetAndClearMemoryReportInfo(ServiceCtx context) { Result result = _baseFileSystemProxy.Get.GetAndClearMemoryReportInfo(out MemoryReportInfo reportInfo); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } context.ResponseData.WriteStruct(reportInfo); @@ -1217,7 +1338,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs public ResultCode GetProgramIndexForAccessLog(ServiceCtx context) { Result result = _baseFileSystemProxy.Get.GetProgramIndexForAccessLog(out int programIndex, out int programCount); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } context.ResponseData.Write(programIndex); context.ResponseData.Write(programCount); @@ -1231,7 +1355,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs FsStackUsageThreadType threadType = context.RequestData.ReadStruct<FsStackUsageThreadType>(); Result result = _baseFileSystemProxy.Get.GetFsStackUsage(out uint usage, threadType); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } context.ResponseData.Write(usage); @@ -1290,7 +1417,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs using var commitManager = new SharedRef<LibHac.FsSrv.Sf.IMultiCommitManager>(); Result result = _baseFileSystemProxy.Get.OpenMultiCommitManager(ref commitManager.Ref); - if (result.IsFailure()) return (ResultCode)result.Value; + if (result.IsFailure()) + { + return (ResultCode)result.Value; + } MakeObject(context, new IMultiCommitManager(ref commitManager.Ref)); @@ -1305,4 +1435,4 @@ namespace Ryujinx.HLE.HOS.Services.Fs } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Fs/IFileSystemProxyForLoader.cs b/src/Ryujinx.HLE/HOS/Services/Fs/IFileSystemProxyForLoader.cs index a40821b9..c3e22875 100644 --- a/src/Ryujinx.HLE/HOS/Services/Fs/IFileSystemProxyForLoader.cs +++ b/src/Ryujinx.HLE/HOS/Services/Fs/IFileSystemProxyForLoader.cs @@ -5,4 +5,4 @@ { public IFileSystemProxyForLoader(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Fs/IProgramRegistry.cs b/src/Ryujinx.HLE/HOS/Services/Fs/IProgramRegistry.cs index e11eadf5..4554a053 100644 --- a/src/Ryujinx.HLE/HOS/Services/Fs/IProgramRegistry.cs +++ b/src/Ryujinx.HLE/HOS/Services/Fs/IProgramRegistry.cs @@ -5,4 +5,4 @@ { public IProgramRegistry(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Fs/ISaveDataInfoReader.cs b/src/Ryujinx.HLE/HOS/Services/Fs/ISaveDataInfoReader.cs index 0611375b..022d7b81 100644 --- a/src/Ryujinx.HLE/HOS/Services/Fs/ISaveDataInfoReader.cs +++ b/src/Ryujinx.HLE/HOS/Services/Fs/ISaveDataInfoReader.cs @@ -20,14 +20,12 @@ namespace Ryujinx.HLE.HOS.Services.Fs ulong bufferAddress = context.Request.ReceiveBuff[0].Position; ulong bufferLen = context.Request.ReceiveBuff[0].Size; - using (var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true)) - { - Result result = _baseReader.Get.Read(out long readCount, new OutBuffer(region.Memory.Span)); + using var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true); + Result result = _baseReader.Get.Read(out long readCount, new OutBuffer(region.Memory.Span)); - context.ResponseData.Write(readCount); + context.ResponseData.Write(readCount); - return (ResultCode)result.Value; - } + return (ResultCode)result.Value; } protected override void Dispose(bool isDisposing) diff --git a/src/Ryujinx.HLE/HOS/Services/Fs/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Fs/ResultCode.cs index 8f87142b..e04bd7be 100644 --- a/src/Ryujinx.HLE/HOS/Services/Fs/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Fs/ResultCode.cs @@ -2,15 +2,15 @@ namespace Ryujinx.HLE.HOS.Services.Fs { enum ResultCode { - ModuleId = 2, + ModuleId = 2, ErrorCodeShift = 9, Success = 0, - PathDoesNotExist = (1 << ErrorCodeShift) | ModuleId, - PathAlreadyExists = (2 << ErrorCodeShift) | ModuleId, - PathAlreadyInUse = (7 << ErrorCodeShift) | ModuleId, + PathDoesNotExist = (1 << ErrorCodeShift) | ModuleId, + PathAlreadyExists = (2 << ErrorCodeShift) | ModuleId, + PathAlreadyInUse = (7 << ErrorCodeShift) | ModuleId, PartitionNotFound = (1001 << ErrorCodeShift) | ModuleId, - InvalidInput = (6001 << ErrorCodeShift) | ModuleId + InvalidInput = (6001 << ErrorCodeShift) | ModuleId, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Fs/Types/FileSystemType.cs b/src/Ryujinx.HLE/HOS/Services/Fs/Types/FileSystemType.cs index f12c1661..369df9b6 100644 --- a/src/Ryujinx.HLE/HOS/Services/Fs/Types/FileSystemType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Fs/Types/FileSystemType.cs @@ -2,11 +2,11 @@ { enum FileSystemType { - Logo = 2, - ContentControl = 3, - ContentManual = 4, - ContentMeta = 5, - ContentData = 6, - ApplicationPackage = 7 + Logo = 2, + ContentControl = 3, + ContentManual = 4, + ContentMeta = 5, + ContentData = 6, + ApplicationPackage = 7, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Grc/IGrcService.cs b/src/Ryujinx.HLE/HOS/Services/Grc/IGrcService.cs index 90646b40..131ba541 100644 --- a/src/Ryujinx.HLE/HOS/Services/Grc/IGrcService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Grc/IGrcService.cs @@ -5,4 +5,4 @@ { public IGrcService(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Grc/IRemoteVideoTransfer.cs b/src/Ryujinx.HLE/HOS/Services/Grc/IRemoteVideoTransfer.cs index edb1d64e..1d200ac3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Grc/IRemoteVideoTransfer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Grc/IRemoteVideoTransfer.cs @@ -5,4 +5,4 @@ { public IRemoteVideoTransfer(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Hid.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Hid.cs index e4755f78..dbcbe187 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Hid.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Hid.cs @@ -26,10 +26,10 @@ namespace Ryujinx.HLE.HOS.Services.Hid internal const int SharedMemEntryCount = 17; public DebugPadDevice DebugPad; - public TouchDevice Touchscreen; - public MouseDevice Mouse; + public TouchDevice Touchscreen; + public MouseDevice Mouse; public KeyboardDevice Keyboard; - public NpadDevices Npads; + public NpadDevices Npads; private static void CheckTypeSizeOrThrow<T>(int expectedSize) { @@ -51,7 +51,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid internal Hid(in Switch device, SharedMemoryStorage storage) { - _device = device; + _device = device; _storage = storage; SharedMemory = SharedMemory.Create(); @@ -61,11 +61,11 @@ namespace Ryujinx.HLE.HOS.Services.Hid private void InitDevices() { - DebugPad = new DebugPadDevice(_device, true); + DebugPad = new DebugPadDevice(_device, true); Touchscreen = new TouchDevice(_device, true); - Mouse = new MouseDevice(_device, false); - Keyboard = new KeyboardDevice(_device, false); - Npads = new NpadDevices(_device, true); + Mouse = new MouseDevice(_device, false); + Keyboard = new KeyboardDevice(_device, false); + Npads = new NpadDevices(_device, true); } public void RefreshInputConfig(List<InputConfig> inputConfig) @@ -86,6 +86,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid const int StickButtonThreshold = short.MaxValue / 2; ControllerKeys result = 0; +#pragma warning disable IDE0055 // Disable formatting result |= (leftStick.Dx < -StickButtonThreshold) ? ControllerKeys.LStickLeft : result; result |= (leftStick.Dx > StickButtonThreshold) ? ControllerKeys.LStickRight : result; result |= (leftStick.Dy < -StickButtonThreshold) ? ControllerKeys.LStickDown : result; @@ -95,11 +96,12 @@ namespace Ryujinx.HLE.HOS.Services.Hid result |= (rightStick.Dx > StickButtonThreshold) ? ControllerKeys.RStickRight : result; result |= (rightStick.Dy < -StickButtonThreshold) ? ControllerKeys.RStickDown : result; result |= (rightStick.Dy > StickButtonThreshold) ? ControllerKeys.RStickUp : result; +#pragma warning restore IDE0055 return result; } - internal static ulong GetTimestampTicks() + internal ulong GetTimestampTicks() { return (ulong)PerformanceCounter.ElapsedMilliseconds * 19200; } diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/BaseDevice.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/BaseDevice.cs index 0e3cd18a..a6c21fda 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/BaseDevice.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/BaseDevice.cs @@ -11,4 +11,4 @@ namespace Ryujinx.HLE.HOS.Services.Hid Active = active; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/DebugPadDevice.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/DebugPadDevice.cs index e3b95390..6b1d7af5 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/DebugPadDevice.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/DebugPadDevice.cs @@ -13,7 +13,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid ref DebugPadState previousEntry = ref lifo.GetCurrentEntryRef(); - DebugPadState newState = new DebugPadState(); + DebugPadState newState = new(); if (Active) { @@ -25,4 +25,4 @@ namespace Ryujinx.HLE.HOS.Services.Hid lifo.Write(ref newState); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/KeyboardDevice.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/KeyboardDevice.cs index 8908b74d..0e3630f2 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/KeyboardDevice.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/KeyboardDevice.cs @@ -21,7 +21,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid ref KeyboardState previousEntry = ref lifo.GetCurrentEntryRef(); - KeyboardState newState = new KeyboardState + KeyboardState newState = new() { SamplingNumber = previousEntry.SamplingNumber + 1, }; @@ -32,4 +32,4 @@ namespace Ryujinx.HLE.HOS.Services.Hid lifo.Write(ref newState); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/MouseDevice.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/MouseDevice.cs index 66d1b0c4..b2dd3fea 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/MouseDevice.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/MouseDevice.cs @@ -12,8 +12,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid ref RingLifo<MouseState> lifo = ref _device.Hid.SharedMemory.Mouse; ref MouseState previousEntry = ref lifo.GetCurrentEntryRef(); - - MouseState newState = new MouseState() + + MouseState newState = new() { SamplingNumber = previousEntry.SamplingNumber + 1, }; @@ -33,4 +33,4 @@ namespace Ryujinx.HLE.HOS.Services.Hid lifo.Write(ref newState); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/NpadDevices.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/NpadDevices.cs index edcc47d8..240933ad 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/NpadDevices.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/NpadDevices.cs @@ -19,22 +19,22 @@ namespace Ryujinx.HLE.HOS.Services.Hid public const int MaxControllers = 9; // Players 1-8 and Handheld private ControllerType[] _configuredTypes; - private KEvent[] _styleSetUpdateEvents; - private bool[] _supportedPlayers; - private static VibrationValue _neutralVibrationValue = new VibrationValue + private readonly KEvent[] _styleSetUpdateEvents; + private readonly bool[] _supportedPlayers; + private VibrationValue _neutralVibrationValue = new() { AmplitudeLow = 0f, FrequencyLow = 160f, AmplitudeHigh = 0f, - FrequencyHigh = 320f + FrequencyHigh = 320f, }; internal NpadJoyHoldType JoyHold { get; set; } internal bool SixAxisActive = false; // TODO: link to hidserver when implemented internal ControllerType SupportedStyleSets { get; set; } - public Dictionary<PlayerIndex, ConcurrentQueue<(VibrationValue, VibrationValue)>> RumbleQueues = new Dictionary<PlayerIndex, ConcurrentQueue<(VibrationValue, VibrationValue)>>(); - public Dictionary<PlayerIndex, (VibrationValue, VibrationValue)> LastVibrationValues = new Dictionary<PlayerIndex, (VibrationValue, VibrationValue)>(); + public Dictionary<PlayerIndex, ConcurrentQueue<(VibrationValue, VibrationValue)>> RumbleQueues = new(); + public Dictionary<PlayerIndex, (VibrationValue, VibrationValue)> LastVibrationValues = new(); public NpadDevices(Switch device, bool active = true) : base(device, active) { @@ -129,7 +129,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid if (player > PlayerIndex.Handheld) { - throw new ArgumentOutOfRangeException("Player must be Player1-8 or Handheld"); + throw new InvalidOperationException("Player must be Player1-8 or Handheld"); } if (controllerType == ControllerType.Handheld) @@ -249,6 +249,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid switch (type) { +#pragma warning disable IDE0055 // Disable formatting case ControllerType.ProController: controller.StyleSet = NpadStyleTag.FullKey; controller.DeviceType = DeviceType.FullKey; @@ -296,6 +297,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid controller.DeviceType = DeviceType.Palma; controller.AppletFooterUiType = AppletFooterUiType.None; break; +#pragma warning restore IDE0055 } _styleSetUpdateEvents[(int)player].ReadableEvent.Signal(); @@ -329,7 +331,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid { if (!Unsafe.AreSame(ref currentlyUsed, ref possiblyUnused)) { - NpadCommonState newState = new NpadCommonState(); + NpadCommonState newState = new(); WriteNewInputEntry(ref possiblyUnused, ref newState); } @@ -348,7 +350,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid { if (!Unsafe.AreSame(ref currentlyUsed, ref possiblyUnused)) { - SixAxisSensorState newState = new SixAxisSensorState(); + SixAxisSensorState newState = new(); WriteNewSixInputEntry(ref possiblyUnused, ref newState); } @@ -379,23 +381,22 @@ namespace Ryujinx.HLE.HOS.Services.Hid ref RingLifo<NpadCommonState> lifo = ref GetCommonStateLifo(ref currentNpad); - NpadCommonState newState = new NpadCommonState + NpadCommonState newState = new() { - Buttons = (NpadButton)state.Buttons, + Buttons = (NpadButton)state.Buttons, AnalogStickL = new AnalogStickState { - X = state.LStick.Dx, - Y = state.LStick.Dy, + X = state.LStick.Dx, + Y = state.LStick.Dy, }, AnalogStickR = new AnalogStickState { - X = state.RStick.Dx, - Y = state.RStick.Dy, - } + X = state.RStick.Dx, + Y = state.RStick.Dy, + }, + Attributes = NpadAttribute.IsConnected, }; - newState.Attributes = NpadAttribute.IsConnected; - switch (currentNpad.StyleSet) { case NpadStyleTag.Handheld: @@ -434,7 +435,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid { ref NpadInternalState currentNpad = ref _device.Hid.SharedMemory.Npads[(int)index].InternalState; - NpadCommonState newState = new NpadCommonState(); + NpadCommonState newState = new(); WriteNewInputEntry(ref currentNpad.FullKey, ref newState); WriteNewInputEntry(ref currentNpad.Handheld, ref newState); @@ -514,33 +515,33 @@ namespace Ryujinx.HLE.HOS.Services.Hid return false; } - HidVector accel = new HidVector() + HidVector accel = new() { X = state.Accelerometer.X, Y = state.Accelerometer.Y, - Z = state.Accelerometer.Z + Z = state.Accelerometer.Z, }; - HidVector gyro = new HidVector() + HidVector gyro = new() { X = state.Gyroscope.X, Y = state.Gyroscope.Y, - Z = state.Gyroscope.Z + Z = state.Gyroscope.Z, }; - HidVector rotation = new HidVector() + HidVector rotation = new() { X = state.Rotation.X, Y = state.Rotation.Y, - Z = state.Rotation.Z + Z = state.Rotation.Z, }; - SixAxisSensorState newState = new SixAxisSensorState + SixAxisSensorState newState = new() { - Acceleration = accel, + Acceleration = accel, AngularVelocity = gyro, - Angle = rotation, - Attributes = SixAxisSensorAttribute.IsConnected + Angle = rotation, + Attributes = SixAxisSensorAttribute.IsConnected, }; state.Orientation.AsSpan().CopyTo(newState.Direction.AsSpan()); @@ -562,9 +563,10 @@ namespace Ryujinx.HLE.HOS.Services.Hid if (!needUpdateRight && !isRightPair) { - SixAxisSensorState emptyState = new SixAxisSensorState(); - - emptyState.Attributes = SixAxisSensorAttribute.IsConnected; + SixAxisSensorState emptyState = new() + { + Attributes = SixAxisSensorAttribute.IsConnected, + }; WriteNewSixInputEntry(ref currentNpad.JoyDualRightSixAxisSensor, ref emptyState); } @@ -576,9 +578,10 @@ namespace Ryujinx.HLE.HOS.Services.Hid { ref NpadInternalState currentNpad = ref _device.Hid.SharedMemory.Npads[(int)index].InternalState; - SixAxisSensorState newState = new SixAxisSensorState(); - - newState.Attributes = SixAxisSensorAttribute.IsConnected; + SixAxisSensorState newState = new() + { + Attributes = SixAxisSensorAttribute.IsConnected, + }; WriteNewSixInputEntry(ref currentNpad.FullKeySixAxisSensor, ref newState); WriteNewSixInputEntry(ref currentNpad.HandheldSixAxisSensor, ref newState); @@ -632,4 +635,4 @@ namespace Ryujinx.HLE.HOS.Services.Hid return rumbleQueue; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/TouchDevice.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/TouchDevice.cs index bb58ee51..35ac1a16 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/TouchDevice.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/TouchDevice.cs @@ -14,9 +14,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid ref TouchScreenState previousEntry = ref lifo.GetCurrentEntryRef(); - TouchScreenState newState = new TouchScreenState + TouchScreenState newState = new() { - SamplingNumber = previousEntry.SamplingNumber + 1 + SamplingNumber = previousEntry.SamplingNumber + 1, }; if (Active) @@ -37,7 +37,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid FingerId = (uint)i, DiameterX = pi.DiameterX, DiameterY = pi.DiameterY, - RotationAngle = pi.Angle + RotationAngle = pi.Angle, }; } } @@ -45,4 +45,4 @@ namespace Ryujinx.HLE.HOS.Services.Hid lifo.Write(ref newState); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/Types/ControllerConfig.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/Types/ControllerConfig.cs index 477e1a84..cba5c7b1 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/Types/ControllerConfig.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/Types/ControllerConfig.cs @@ -2,7 +2,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid { public struct ControllerConfig { - public PlayerIndex Player; + public PlayerIndex Player; public ControllerType Type; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/Types/GamepadInput.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/Types/GamepadInput.cs index 633671df..452901a0 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/Types/GamepadInput.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/Types/GamepadInput.cs @@ -2,9 +2,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid { public struct GamepadInput { - public PlayerIndex PlayerId; - public ControllerKeys Buttons; + public PlayerIndex PlayerId; + public ControllerKeys Buttons; public JoystickPosition LStick; public JoystickPosition RStick; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/Types/JoystickPosition.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/Types/JoystickPosition.cs index 6df477d6..47be8d41 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/Types/JoystickPosition.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/Types/JoystickPosition.cs @@ -5,4 +5,4 @@ namespace Ryujinx.HLE.HOS.Services.Hid public int Dx; public int Dy; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/Types/KeyboardInput.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/Types/KeyboardInput.cs index be6857fb..26fe980f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/Types/KeyboardInput.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/Types/KeyboardInput.cs @@ -5,4 +5,4 @@ namespace Ryujinx.HLE.HOS.Services.Hid public int Modifier; public ulong[] Keys; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/Types/SixAxisInput.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/Types/SixAxisInput.cs index 4dda82c7..5c5c5d8c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/Types/SixAxisInput.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/Types/SixAxisInput.cs @@ -5,9 +5,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid public struct SixAxisInput { public PlayerIndex PlayerId; - public Vector3 Accelerometer; - public Vector3 Gyroscope; - public Vector3 Rotation; - public float[] Orientation; + public Vector3 Accelerometer; + public Vector3 Gyroscope; + public Vector3 Rotation; + public float[] Orientation; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/Types/TouchPoint.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/Types/TouchPoint.cs index 457d2b0d..ab0c8526 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/Types/TouchPoint.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/Types/TouchPoint.cs @@ -11,4 +11,4 @@ namespace Ryujinx.HLE.HOS.Services.Hid public uint DiameterY; public uint Angle; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/HidUtils.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/HidUtils.cs index b98f6065..d76704b3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/HidUtils.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/HidUtils.cs @@ -7,6 +7,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.HidServer public static PlayerIndex GetIndexFromNpadIdType(NpadIdType npadIdType) => npadIdType switch { +#pragma warning disable IDE0055 // Disable formatting NpadIdType.Player1 => PlayerIndex.Player1, NpadIdType.Player2 => PlayerIndex.Player2, NpadIdType.Player3 => PlayerIndex.Player3, @@ -17,12 +18,14 @@ namespace Ryujinx.HLE.HOS.Services.Hid.HidServer NpadIdType.Player8 => PlayerIndex.Player8, NpadIdType.Handheld => PlayerIndex.Handheld, NpadIdType.Unknown => PlayerIndex.Unknown, - _ => throw new ArgumentOutOfRangeException(nameof(npadIdType)) + _ => throw new ArgumentOutOfRangeException(nameof(npadIdType)), +#pragma warning restore IDE0055 }; public static NpadIdType GetNpadIdTypeFromIndex(PlayerIndex index) => index switch { +#pragma warning disable IDE0055 // Disable formatting PlayerIndex.Player1 => NpadIdType.Player1, PlayerIndex.Player2 => NpadIdType.Player2, PlayerIndex.Player3 => NpadIdType.Player3, @@ -33,7 +36,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid.HidServer PlayerIndex.Player8 => NpadIdType.Player8, PlayerIndex.Handheld => NpadIdType.Handheld, PlayerIndex.Unknown => NpadIdType.Unknown, - _ => throw new ArgumentOutOfRangeException(nameof(index)) + _ => throw new ArgumentOutOfRangeException(nameof(index)), +#pragma warning restore IDE0055 }; public static bool IsValidNpadIdType(NpadIdType npadIdType) @@ -43,4 +47,4 @@ namespace Ryujinx.HLE.HOS.Services.Hid.HidServer npadIdType == NpadIdType.Unknown; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/IActiveVibrationDeviceList.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/IActiveVibrationDeviceList.cs index 56f63e52..93f19c91 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/IActiveVibrationDeviceList.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/IActiveVibrationDeviceList.cs @@ -8,9 +8,11 @@ namespace Ryujinx.HLE.HOS.Services.Hid.HidServer // ActivateVibrationDevice(nn::hid::VibrationDeviceHandle) public ResultCode ActivateVibrationDevice(ServiceCtx context) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment int vibrationDeviceHandle = context.RequestData.ReadInt32(); +#pragma warning restore IDE0059 return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/IAppletResource.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/IAppletResource.cs index f0aaf5e3..56eb345a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/IAppletResource.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/IAppletResource.cs @@ -7,8 +7,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid.HidServer { class IAppletResource : IpcService { - private KSharedMemory _hidSharedMem; - private int _hidSharedMemHandle; + private readonly KSharedMemory _hidSharedMem; + private int _hidSharedMemHandle; public IAppletResource(KSharedMemory hidSharedMem) { @@ -32,4 +32,4 @@ namespace Ryujinx.HLE.HOS.Services.Hid.HidServer return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Npad/NpadHandheldActivationMode.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Npad/NpadHandheldActivationMode.cs index 0cf4a047..02e3d803 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Npad/NpadHandheldActivationMode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Npad/NpadHandheldActivationMode.cs @@ -4,6 +4,6 @@ { Dual, Single, - None + None, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Npad/NpadJoyDeviceType.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Npad/NpadJoyDeviceType.cs index 05587bfd..f52e18f2 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Npad/NpadJoyDeviceType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Npad/NpadJoyDeviceType.cs @@ -3,6 +3,6 @@ public enum NpadJoyDeviceType { Left, - Right + Right, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/SixAxis/AccelerometerParameters.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/SixAxis/AccelerometerParameters.cs index 4fd0a1b5..8e4d80e2 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/SixAxis/AccelerometerParameters.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/SixAxis/AccelerometerParameters.cs @@ -5,4 +5,4 @@ public float X; public float Y; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/SixAxis/GyroscopeZeroDriftMode.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/SixAxis/GyroscopeZeroDriftMode.cs index db7467fa..659afa0d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/SixAxis/GyroscopeZeroDriftMode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/SixAxis/GyroscopeZeroDriftMode.cs @@ -4,6 +4,6 @@ { Loose, Standard, - Tight + Tight, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/SixAxis/SensorFusionParameters.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/SixAxis/SensorFusionParameters.cs index 2683ffee..37cef783 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/SixAxis/SensorFusionParameters.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/SixAxis/SensorFusionParameters.cs @@ -5,4 +5,4 @@ public float RevisePower; public float ReviseRange; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/VibrationDeviceHandle.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/VibrationDeviceHandle.cs index fe50e671..d59afe51 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/VibrationDeviceHandle.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/VibrationDeviceHandle.cs @@ -7,4 +7,4 @@ public byte Position; public byte Reserved; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/VibrationDevicePosition.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/VibrationDevicePosition.cs index 117451f1..19d52f9f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/VibrationDevicePosition.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/VibrationDevicePosition.cs @@ -4,6 +4,6 @@ { None, Left, - Right + Right, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/VibrationDeviceType.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/VibrationDeviceType.cs index 4e5557c9..4849c342 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/VibrationDeviceType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/VibrationDeviceType.cs @@ -4,6 +4,6 @@ { None, LinearResonantActuator, - GcErm + GcErm, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/VibrationDeviceValue.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/VibrationDeviceValue.cs index 91a23eb7..8ac06cb7 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/VibrationDeviceValue.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/VibrationDeviceValue.cs @@ -2,7 +2,7 @@ { public struct VibrationDeviceValue { - public VibrationDeviceType DeviceType; + public VibrationDeviceType DeviceType; public VibrationDevicePosition Position; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/VibrationValue.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/VibrationValue.cs index 38ac9cca..c6143a01 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/VibrationValue.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidServer/Types/Vibration/VibrationValue.cs @@ -9,16 +9,26 @@ namespace Ryujinx.HLE.HOS.Services.Hid public float AmplitudeHigh; public float FrequencyHigh; - public override bool Equals(object obj) + public readonly override bool Equals(object obj) { return obj is VibrationValue value && AmplitudeLow == value.AmplitudeLow && AmplitudeHigh == value.AmplitudeHigh; } - public override int GetHashCode() + public readonly override int GetHashCode() { return HashCode.Combine(AmplitudeLow, AmplitudeHigh); } + + public static bool operator ==(VibrationValue left, VibrationValue right) + { + return left.Equals(right); + } + + public static bool operator !=(VibrationValue left, VibrationValue right) + { + return !(left == right); + } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/IHidDebugServer.cs b/src/Ryujinx.HLE/HOS/Services/Hid/IHidDebugServer.cs index adaaa012..0d1867db 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/IHidDebugServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/IHidDebugServer.cs @@ -5,4 +5,4 @@ { public IHidDebugServer(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs b/src/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs index d508aba4..1d1b145c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs @@ -15,8 +15,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid [Service("hid")] class IHidServer : IpcService { - private KEvent _xpadIdEvent; - private KEvent _palmaOperationCompleteEvent; + private readonly KEvent _xpadIdEvent; + private readonly KEvent _palmaOperationCompleteEvent; private int _xpadIdEventHandle; @@ -24,33 +24,33 @@ namespace Ryujinx.HLE.HOS.Services.Hid private bool _unintendedHomeButtonInputProtectionEnabled; private bool _vibrationPermitted; private bool _usbFullKeyControllerEnabled; - private bool _isFirmwareUpdateAvailableForSixAxisSensor; + private readonly bool _isFirmwareUpdateAvailableForSixAxisSensor; private bool _isSixAxisSensorUnalteredPassthroughEnabled; private NpadHandheldActivationMode _npadHandheldActivationMode; - private GyroscopeZeroDriftMode _gyroscopeZeroDriftMode; + private GyroscopeZeroDriftMode _gyroscopeZeroDriftMode; - private long _npadCommunicationMode; - private uint _accelerometerPlayMode; -#pragma warning disable CS0649 - private long _vibrationGcErmCommand; + private long _npadCommunicationMode; + private uint _accelerometerPlayMode; +#pragma warning disable CS0649 // Field is never assigned to + private readonly long _vibrationGcErmCommand; #pragma warning restore CS0649 private float _sevenSixAxisSensorFusionStrength; - private SensorFusionParameters _sensorFusionParams; + private SensorFusionParameters _sensorFusionParams; private AccelerometerParameters _accelerometerParams; public IHidServer(ServiceCtx context) : base(context.Device.System.HidServer) { - _xpadIdEvent = new KEvent(context.Device.System.KernelContext); + _xpadIdEvent = new KEvent(context.Device.System.KernelContext); _palmaOperationCompleteEvent = new KEvent(context.Device.System.KernelContext); _npadHandheldActivationMode = NpadHandheldActivationMode.Dual; - _gyroscopeZeroDriftMode = GyroscopeZeroDriftMode.Standard; + _gyroscopeZeroDriftMode = GyroscopeZeroDriftMode.Standard; _isFirmwareUpdateAvailableForSixAxisSensor = false; - _sensorFusionParams = new SensorFusionParameters(); + _sensorFusionParams = new SensorFusionParameters(); _accelerometerParams = new AccelerometerParameters(); // TODO: signal event at right place @@ -63,7 +63,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid // CreateAppletResource(nn::applet::AppletResourceUserId) -> object<nn::hid::IAppletResource> public ResultCode CreateAppletResource(ServiceCtx context) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment long appletResourceUserId = context.RequestData.ReadInt64(); +#pragma warning restore IDE0059 MakeObject(context, new IAppletResource(context.Device.System.HidSharedMem)); @@ -138,8 +140,10 @@ namespace Ryujinx.HLE.HOS.Services.Hid // Initialize entries to avoid issues with some games. - KeyboardInput emptyInput = new KeyboardInput(); - emptyInput.Keys = new ulong[4]; + KeyboardInput emptyInput = new() + { + Keys = new ulong[4], + }; for (int entry = 0; entry < Hid.SharedMemEntryCount; entry++) { @@ -199,7 +203,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid // ActivateXpad(nn::hid::BasicXpadId, nn::applet::AppletResourceUserId) public ResultCode ActivateXpad(ServiceCtx context) { - int basicXpadId = context.RequestData.ReadInt32(); + int basicXpadId = context.RequestData.ReadInt32(); long appletResourceUserId = context.RequestData.ReadInt64(); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, basicXpadId }); @@ -395,7 +399,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid _sensorFusionParams = new SensorFusionParameters { RevisePower = context.RequestData.ReadInt32(), - ReviseRange = context.RequestData.ReadInt32() + ReviseRange = context.RequestData.ReadInt32(), }; long appletResourceUserId = context.RequestData.ReadInt64(); @@ -447,7 +451,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid _accelerometerParams = new AccelerometerParameters { X = context.RequestData.ReadInt32(), - Y = context.RequestData.ReadInt32() + Y = context.RequestData.ReadInt32(), }; long appletResourceUserId = context.RequestData.ReadInt64(); @@ -671,7 +675,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid public ResultCode ActivateGesture(ServiceCtx context) { long appletResourceUserId = context.RequestData.ReadInt64(); - int unknown0 = context.RequestData.ReadInt32(); + int unknown0 = context.RequestData.ReadInt32(); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, unknown0 }); @@ -698,8 +702,10 @@ namespace Ryujinx.HLE.HOS.Services.Hid // GetSupportedNpadStyleSet(pid, nn::applet::AppletResourceUserId) -> uint nn::hid::NpadStyleTag public ResultCode GetSupportedNpadStyleSet(ServiceCtx context) { - ulong pid = context.Request.HandleDesc.PId; - long appletResourceUserId = context.RequestData.ReadInt64(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment + ulong pid = context.Request.HandleDesc.PId; +#pragma warning restore IDE0059 + long appletResourceUserId = context.RequestData.ReadInt64(); context.ResponseData.Write((int)context.Device.Hid.Npads.SupportedStyleSets); @@ -712,9 +718,11 @@ namespace Ryujinx.HLE.HOS.Services.Hid // SetSupportedNpadIdType(nn::applet::AppletResourceUserId, array<NpadIdType, 9>) public ResultCode SetSupportedNpadIdType(ServiceCtx context) { - long appletResourceUserId = context.RequestData.ReadInt64(); - ulong arrayPosition = context.Request.PtrBuff[0].Position; - ulong arraySize = context.Request.PtrBuff[0].Size; +#pragma warning disable IDE0059 // Remove unnecessary value assignment + long appletResourceUserId = context.RequestData.ReadInt64(); +#pragma warning restore IDE0059 + ulong arrayPosition = context.Request.PtrBuff[0].Position; + ulong arraySize = context.Request.PtrBuff[0].Size; ReadOnlySpan<NpadIdType> supportedPlayerIds = MemoryMarshal.Cast<byte, NpadIdType>(context.Memory.GetSpan(arrayPosition, (int)arraySize)); @@ -756,9 +764,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid // AcquireNpadStyleSetUpdateEventHandle(nn::applet::AppletResourceUserId, uint, ulong) -> nn::sf::NativeHandle public ResultCode AcquireNpadStyleSetUpdateEventHandle(ServiceCtx context) { - PlayerIndex npadId = HidUtils.GetIndexFromNpadIdType((NpadIdType)context.RequestData.ReadInt32()); - long appletResourceUserId = context.RequestData.ReadInt64(); - long npadStyleSet = context.RequestData.ReadInt64(); + PlayerIndex npadId = HidUtils.GetIndexFromNpadIdType((NpadIdType)context.RequestData.ReadInt32()); + long appletResourceUserId = context.RequestData.ReadInt64(); + long npadStyleSet = context.RequestData.ReadInt64(); KEvent evnt = context.Device.Hid.Npads.GetStyleSetUpdateEvent(npadId); if (context.Process.HandleTable.GenerateHandle(evnt.ReadableEvent, out int handle) != Result.Success) @@ -780,8 +788,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid // DisconnectNpad(nn::applet::AppletResourceUserId, uint NpadIdType) public ResultCode DisconnectNpad(ServiceCtx context) { - NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadInt32(); - long appletResourceUserId = context.RequestData.ReadInt64(); + NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, npadIdType }); @@ -796,17 +804,17 @@ namespace Ryujinx.HLE.HOS.Services.Hid ulong ledPattern = npadId switch { - NpadIdType.Player1 => 0b0001, - NpadIdType.Player2 => 0b0011, - NpadIdType.Player3 => 0b0111, - NpadIdType.Player4 => 0b1111, - NpadIdType.Player5 => 0b1001, - NpadIdType.Player6 => 0b0101, - NpadIdType.Player7 => 0b1101, - NpadIdType.Player8 => 0b0110, - NpadIdType.Unknown => 0b0000, + NpadIdType.Player1 => 0b0001, + NpadIdType.Player2 => 0b0011, + NpadIdType.Player3 => 0b0111, + NpadIdType.Player4 => 0b1111, + NpadIdType.Player5 => 0b1001, + NpadIdType.Player6 => 0b0101, + NpadIdType.Player7 => 0b1101, + NpadIdType.Player8 => 0b0110, + NpadIdType.Unknown => 0b0000, NpadIdType.Handheld => 0b0000, - _ => throw new ArgumentOutOfRangeException(nameof(npadId)) + _ => throw new InvalidOperationException($"{nameof(npadId)} contains an invalid value: {npadId}"), }; context.ResponseData.Write(ledPattern); @@ -831,13 +839,13 @@ namespace Ryujinx.HLE.HOS.Services.Hid // Initialize entries to avoid issues with some games. - List<GamepadInput> emptyGamepadInputs = new List<GamepadInput>(); - List<SixAxisInput> emptySixAxisInputs = new List<SixAxisInput>(); + List<GamepadInput> emptyGamepadInputs = new(); + List<SixAxisInput> emptySixAxisInputs = new(); for (int player = 0; player < NpadDevices.MaxControllers; player++) { - GamepadInput gamepadInput = new GamepadInput(); - SixAxisInput sixaxisInput = new SixAxisInput(); + GamepadInput gamepadInput = new(); + SixAxisInput sixaxisInput = new(); gamepadInput.PlayerId = (PlayerIndex)player; sixaxisInput.PlayerId = (PlayerIndex)player; @@ -863,13 +871,15 @@ namespace Ryujinx.HLE.HOS.Services.Hid // SetNpadJoyHoldType(nn::applet::AppletResourceUserId, ulong NpadJoyHoldType) public ResultCode SetNpadJoyHoldType(ServiceCtx context) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment long appletResourceUserId = context.RequestData.ReadInt64(); +#pragma warning restore IDE0059 NpadJoyHoldType npadJoyHoldType = (NpadJoyHoldType)context.RequestData.ReadUInt64(); if (npadJoyHoldType > NpadJoyHoldType.Horizontal) { - throw new ArgumentOutOfRangeException(nameof(npadJoyHoldType)); + throw new InvalidOperationException($"{nameof(npadJoyHoldType)} contains an invalid value: {npadJoyHoldType}"); } foreach (PlayerIndex playerIndex in context.Device.Hid.Npads.GetSupportedPlayers()) @@ -889,7 +899,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid // GetNpadJoyHoldType(nn::applet::AppletResourceUserId) -> ulong NpadJoyHoldType public ResultCode GetNpadJoyHoldType(ServiceCtx context) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment long appletResourceUserId = context.RequestData.ReadInt64(); +#pragma warning restore IDE0059 foreach (PlayerIndex playerIndex in context.Device.Hid.Npads.GetSupportedPlayers()) { @@ -910,7 +922,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid { NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadUInt32(); context.RequestData.BaseStream.Position += 4; // Padding +#pragma warning disable IDE0059 // Remove unnecessary value assignment long appletResourceUserId = context.RequestData.ReadInt64(); +#pragma warning restore IDE0059 if (HidUtils.IsValidNpadIdType(npadIdType)) { @@ -943,7 +957,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid { NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadUInt32(); context.RequestData.BaseStream.Position += 4; // Padding +#pragma warning disable IDE0059 // Remove unnecessary value assignment long appletResourceUserId = context.RequestData.ReadInt64(); +#pragma warning restore IDE0059 if (HidUtils.IsValidNpadIdType(npadIdType)) { @@ -957,9 +973,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid // MergeSingleJoyAsDualJoy(uint npadIdType0, uint npadIdType1, nn::applet::AppletResourceUserId) public ResultCode MergeSingleJoyAsDualJoy(ServiceCtx context) { - NpadIdType npadIdType0 = (NpadIdType)context.RequestData.ReadUInt32(); - NpadIdType npadIdType1 = (NpadIdType)context.RequestData.ReadUInt32(); - long appletResourceUserId = context.RequestData.ReadInt64(); + NpadIdType npadIdType0 = (NpadIdType)context.RequestData.ReadUInt32(); + NpadIdType npadIdType1 = (NpadIdType)context.RequestData.ReadUInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); if (HidUtils.IsValidNpadIdType(npadIdType0) && HidUtils.IsValidNpadIdType(npadIdType1)) { @@ -995,7 +1011,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid // SetNpadHandheldActivationMode(nn::applet::AppletResourceUserId, long HidNpadHandheldActivationMode) public ResultCode SetNpadHandheldActivationMode(ServiceCtx context) { - long appletResourceUserId = context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); _npadHandheldActivationMode = (NpadHandheldActivationMode)context.RequestData.ReadInt64(); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, _npadHandheldActivationMode }); @@ -1020,8 +1036,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid // SwapNpadAssignment(uint OldNpadAssignment, uint NewNpadAssignment, nn::applet::AppletResourceUserId) public ResultCode SwapNpadAssignment(ServiceCtx context) { - int oldNpadAssignment = context.RequestData.ReadInt32(); - int newNpadAssignment = context.RequestData.ReadInt32(); + int oldNpadAssignment = context.RequestData.ReadInt32(); + int newNpadAssignment = context.RequestData.ReadInt32(); long appletResourceUserId = context.RequestData.ReadInt64(); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, oldNpadAssignment, newNpadAssignment }); @@ -1033,7 +1049,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid // IsUnintendedHomeButtonInputProtectionEnabled(uint Unknown0, nn::applet::AppletResourceUserId) -> bool IsEnabled public ResultCode IsUnintendedHomeButtonInputProtectionEnabled(ServiceCtx context) { - uint unknown0 = context.RequestData.ReadUInt32(); + uint unknown0 = context.RequestData.ReadUInt32(); long appletResourceUserId = context.RequestData.ReadInt64(); context.ResponseData.Write(_unintendedHomeButtonInputProtectionEnabled); @@ -1048,8 +1064,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid public ResultCode EnableUnintendedHomeButtonInputProtection(ServiceCtx context) { _unintendedHomeButtonInputProtectionEnabled = context.RequestData.ReadBoolean(); - uint unknown0 = context.RequestData.ReadUInt32(); - long appletResourceUserId = context.RequestData.ReadInt64(); + uint unknown0 = context.RequestData.ReadUInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, unknown0, _unintendedHomeButtonInputProtectionEnabled }); @@ -1060,7 +1076,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid // SetNpadJoyAssignmentModeSingleWithDestination(uint npadIdType, uint npadJoyDeviceType, nn::applet::AppletResourceUserId) -> bool npadIdTypeIsSet, uint npadIdTypeSet public ResultCode SetNpadJoyAssignmentModeSingleWithDestination(ServiceCtx context) { - NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadInt32(); + NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadInt32(); NpadJoyDeviceType npadJoyDeviceType = (NpadJoyDeviceType)context.RequestData.ReadInt32(); context.RequestData.BaseStream.Position += 4; // Padding long appletResourceUserId = context.RequestData.ReadInt64(); @@ -1081,7 +1097,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid private void SetNpadJoyAssignmentModeSingleWithDestinationImpl(ServiceCtx context, NpadIdType npadIdType, long appletResourceUserId, NpadJoyDeviceType npadJoyDeviceType, out NpadIdType npadIdTypeSet, out bool npadIdTypeIsSet) { - npadIdTypeSet = default; + npadIdTypeSet = default; npadIdTypeIsSet = false; context.Device.Hid.SharedMemory.Npads[(int)HidUtils.GetIndexFromNpadIdType(npadIdType)].InternalState.JoyAssignmentMode = NpadJoyAssignmentMode.Single; @@ -1096,8 +1112,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid public ResultCode GetVibrationDeviceInfo(ServiceCtx context) { VibrationDeviceHandle deviceHandle = context.RequestData.ReadStruct<VibrationDeviceHandle>(); - NpadStyleIndex deviceType = (NpadStyleIndex)deviceHandle.DeviceType; - NpadIdType npadIdType = (NpadIdType)deviceHandle.PlayerId; + NpadStyleIndex deviceType = (NpadStyleIndex)deviceHandle.DeviceType; + NpadIdType npadIdType = (NpadIdType)deviceHandle.PlayerId; if (deviceType < NpadStyleIndex.System || deviceType >= NpadStyleIndex.FullKey) { @@ -1136,14 +1152,14 @@ namespace Ryujinx.HLE.HOS.Services.Hid } else { - throw new ArgumentOutOfRangeException(nameof(deviceHandle.Position)); + throw new InvalidOperationException($"{nameof(deviceHandle.Position)} contains an invalid value: {deviceHandle.Position}"); } } - VibrationDeviceValue deviceInfo = new VibrationDeviceValue + VibrationDeviceValue deviceInfo = new() { DeviceType = vibrationDeviceType, - Position = vibrationDevicePosition + Position = vibrationDevicePosition, }; context.ResponseData.WriteStruct(deviceInfo); @@ -1158,27 +1174,30 @@ namespace Ryujinx.HLE.HOS.Services.Hid // SendVibrationValue(nn::hid::VibrationDeviceHandle, nn::hid::VibrationValue, nn::applet::AppletResourceUserId) public ResultCode SendVibrationValue(ServiceCtx context) { - VibrationDeviceHandle deviceHandle = new VibrationDeviceHandle + VibrationDeviceHandle deviceHandle = new() { DeviceType = context.RequestData.ReadByte(), - PlayerId = context.RequestData.ReadByte(), - Position = context.RequestData.ReadByte(), - Reserved = context.RequestData.ReadByte() + PlayerId = context.RequestData.ReadByte(), + Position = context.RequestData.ReadByte(), + Reserved = context.RequestData.ReadByte(), }; - VibrationValue vibrationValue = new VibrationValue + VibrationValue vibrationValue = new() { - AmplitudeLow = context.RequestData.ReadSingle(), - FrequencyLow = context.RequestData.ReadSingle(), + AmplitudeLow = context.RequestData.ReadSingle(), + FrequencyLow = context.RequestData.ReadSingle(), AmplitudeHigh = context.RequestData.ReadSingle(), - FrequencyHigh = context.RequestData.ReadSingle() + FrequencyHigh = context.RequestData.ReadSingle(), }; +#pragma warning disable IDE0059 // Remove unnecessary value assignment long appletResourceUserId = context.RequestData.ReadInt64(); +#pragma warning restore IDE0059 - Dictionary<byte, VibrationValue> dualVibrationValues = new Dictionary<byte, VibrationValue>(); - - dualVibrationValues[deviceHandle.Position] = vibrationValue; + Dictionary<byte, VibrationValue> dualVibrationValues = new() + { + [deviceHandle.Position] = vibrationValue, + }; context.Device.Hid.Npads.UpdateRumbleQueue((PlayerIndex)deviceHandle.PlayerId, dualVibrationValues); @@ -1189,15 +1208,17 @@ namespace Ryujinx.HLE.HOS.Services.Hid // GetActualVibrationValue(nn::hid::VibrationDeviceHandle, nn::applet::AppletResourceUserId) -> nn::hid::VibrationValue public ResultCode GetActualVibrationValue(ServiceCtx context) { - VibrationDeviceHandle deviceHandle = new VibrationDeviceHandle + VibrationDeviceHandle deviceHandle = new() { DeviceType = context.RequestData.ReadByte(), - PlayerId = context.RequestData.ReadByte(), - Position = context.RequestData.ReadByte(), - Reserved = context.RequestData.ReadByte() + PlayerId = context.RequestData.ReadByte(), + Position = context.RequestData.ReadByte(), + Reserved = context.RequestData.ReadByte(), }; +#pragma warning disable IDE0059 // Remove unnecessary value assignment long appletResourceUserId = context.RequestData.ReadInt64(); +#pragma warning restore IDE0059 VibrationValue vibrationValue = context.Device.Hid.Npads.GetLastVibrationValue((PlayerIndex)deviceHandle.PlayerId, deviceHandle.Position); @@ -1242,7 +1263,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid // SendVibrationValues(nn::applet::AppletResourceUserId, buffer<array<nn::hid::VibrationDeviceHandle>, type: 9>, buffer<array<nn::hid::VibrationValue>, type: 9>) public ResultCode SendVibrationValues(ServiceCtx context) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment long appletResourceUserId = context.RequestData.ReadInt64(); +#pragma warning restore IDE0059 byte[] vibrationDeviceHandleBuffer = new byte[context.Request.PtrBuff[0].Size]; @@ -1252,12 +1275,12 @@ namespace Ryujinx.HLE.HOS.Services.Hid context.Memory.Read(context.Request.PtrBuff[1].Position, vibrationValueBuffer); - Span<VibrationDeviceHandle> deviceHandles = MemoryMarshal.Cast<byte, VibrationDeviceHandle>(vibrationDeviceHandleBuffer); - Span<VibrationValue> vibrationValues = MemoryMarshal.Cast<byte, VibrationValue>(vibrationValueBuffer); + Span<VibrationDeviceHandle> deviceHandles = MemoryMarshal.Cast<byte, VibrationDeviceHandle>(vibrationDeviceHandleBuffer); + Span<VibrationValue> vibrationValues = MemoryMarshal.Cast<byte, VibrationValue>(vibrationValueBuffer); if (!deviceHandles.IsEmpty && vibrationValues.Length == deviceHandles.Length) { - Dictionary<byte, VibrationValue> dualVibrationValues = new Dictionary<byte, VibrationValue>(); + Dictionary<byte, VibrationValue> dualVibrationValues = new(); PlayerIndex currentIndex = (PlayerIndex)deviceHandles[0].PlayerId; for (int deviceCounter = 0; deviceCounter < deviceHandles.Length; deviceCounter++) @@ -1285,9 +1308,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid // SendVibrationGcErmCommand(nn::hid::VibrationDeviceHandle, nn::hid::VibrationGcErmCommand, nn::applet::AppletResourceUserId) public ResultCode SendVibrationGcErmCommand(ServiceCtx context) { - int vibrationDeviceHandle = context.RequestData.ReadInt32(); + int vibrationDeviceHandle = context.RequestData.ReadInt32(); long vibrationGcErmCommand = context.RequestData.ReadInt64(); - long appletResourceUserId = context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, vibrationDeviceHandle, vibrationGcErmCommand }); @@ -1298,8 +1321,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid // GetActualVibrationGcErmCommand(nn::hid::VibrationDeviceHandle, nn::applet::AppletResourceUserId) -> nn::hid::VibrationGcErmCommand public ResultCode GetActualVibrationGcErmCommand(ServiceCtx context) { - int vibrationDeviceHandle = context.RequestData.ReadInt32(); - long appletResourceUserId = context.RequestData.ReadInt64(); + int vibrationDeviceHandle = context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); context.ResponseData.Write(_vibrationGcErmCommand); @@ -1332,8 +1355,10 @@ namespace Ryujinx.HLE.HOS.Services.Hid // IsVibrationDeviceMounted(nn::hid::VibrationDeviceHandle, nn::applet::AppletResourceUserId) public ResultCode IsVibrationDeviceMounted(ServiceCtx context) { - int vibrationDeviceHandle = context.RequestData.ReadInt32(); - long appletResourceUserId = context.RequestData.ReadInt64(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment + int vibrationDeviceHandle = context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); +#pragma warning restore IDE0059 // NOTE: Service use vibrationDeviceHandle to get the PlayerIndex. // And return false if (npadIdType >= (NpadIdType)8 && npadIdType != NpadIdType.Handheld && npadIdType != NpadIdType.Unknown) @@ -1358,8 +1383,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid // StartConsoleSixAxisSensor(nn::hid::ConsoleSixAxisSensorHandle, nn::applet::AppletResourceUserId) public ResultCode StartConsoleSixAxisSensor(ServiceCtx context) { - int consoleSixAxisSensorHandle = context.RequestData.ReadInt32(); - long appletResourceUserId = context.RequestData.ReadInt64(); + int consoleSixAxisSensorHandle = context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, consoleSixAxisSensorHandle }); @@ -1370,8 +1395,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid // StopConsoleSixAxisSensor(nn::hid::ConsoleSixAxisSensorHandle, nn::applet::AppletResourceUserId) public ResultCode StopConsoleSixAxisSensor(ServiceCtx context) { - int consoleSixAxisSensorHandle = context.RequestData.ReadInt32(); - long appletResourceUserId = context.RequestData.ReadInt64(); + int consoleSixAxisSensorHandle = context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, consoleSixAxisSensorHandle }); @@ -1416,8 +1441,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid public ResultCode InitializeSevenSixAxisSensor(ServiceCtx context) { long appletResourceUserId = context.RequestData.ReadInt64(); - long counter0 = context.RequestData.ReadInt64(); - long counter1 = context.RequestData.ReadInt64(); + long counter0 = context.RequestData.ReadInt64(); + long counter1 = context.RequestData.ReadInt64(); // TODO: Determine if array<nn::sf::NativeHandle> is a buffer or not... @@ -1441,8 +1466,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid // SetSevenSixAxisSensorFusionStrength(float Strength, nn::applet::AppletResourceUserId) public ResultCode SetSevenSixAxisSensorFusionStrength(ServiceCtx context) { - _sevenSixAxisSensorFusionStrength = context.RequestData.ReadSingle(); - long appletResourceUserId = context.RequestData.ReadInt64(); + _sevenSixAxisSensorFusionStrength = context.RequestData.ReadSingle(); + long appletResourceUserId = context.RequestData.ReadInt64(); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, _sevenSixAxisSensorFusionStrength }); @@ -1566,14 +1591,14 @@ namespace Ryujinx.HLE.HOS.Services.Hid // GetPalmaConnectionHandle(uint Unknown0, nn::applet::AppletResourceUserId) -> nn::hid::PalmaConnectionHandle public ResultCode GetPalmaConnectionHandle(ServiceCtx context) { - int unknown0 = context.RequestData.ReadInt32(); + int unknown0 = context.RequestData.ReadInt32(); long appletResourceUserId = context.RequestData.ReadInt64(); int palmaConnectionHandle = 0; context.ResponseData.Write(palmaConnectionHandle); - Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId , unknown0, palmaConnectionHandle }); + Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, unknown0, palmaConnectionHandle }); return ResultCode.Success; } @@ -1628,8 +1653,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid // PlayPalmaActivity(nn::hid::PalmaConnectionHandle, ulong Unknown0) public ResultCode PlayPalmaActivity(ServiceCtx context) { - int palmaConnectionHandle = context.RequestData.ReadInt32(); - long unknown0 = context.RequestData.ReadInt64(); + int palmaConnectionHandle = context.RequestData.ReadInt32(); + long unknown0 = context.RequestData.ReadInt64(); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle, unknown0 }); @@ -1642,8 +1667,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid // SetPalmaFrModeType(nn::hid::PalmaConnectionHandle, ulong FrModeType) public ResultCode SetPalmaFrModeType(ServiceCtx context) { - int palmaConnectionHandle = context.RequestData.ReadInt32(); - long frModeType = context.RequestData.ReadInt64(); + int palmaConnectionHandle = context.RequestData.ReadInt32(); + long frModeType = context.RequestData.ReadInt64(); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle, frModeType }); @@ -1667,8 +1692,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid // EnablePalmaStep(nn::hid::PalmaConnectionHandle, bool Enable) public ResultCode EnablePalmaStep(ServiceCtx context) { - int palmaConnectionHandle = context.RequestData.ReadInt32(); - bool enabledPalmaStep = context.RequestData.ReadBoolean(); + int palmaConnectionHandle = context.RequestData.ReadInt32(); + bool enabledPalmaStep = context.RequestData.ReadBoolean(); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle, enabledPalmaStep }); @@ -1694,9 +1719,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid // ReadPalmaApplicationSection(nn::hid::PalmaConnectionHandle, ulong Unknown0, ulong Unknown1) public ResultCode ReadPalmaApplicationSection(ServiceCtx context) { - int palmaConnectionHandle = context.RequestData.ReadInt32(); - long unknown0 = context.RequestData.ReadInt64(); - long unknown1 = context.RequestData.ReadInt64(); + int palmaConnectionHandle = context.RequestData.ReadInt32(); + long unknown0 = context.RequestData.ReadInt64(); + long unknown1 = context.RequestData.ReadInt64(); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle, unknown0, unknown1 }); @@ -1707,9 +1732,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid // WritePalmaApplicationSection(nn::hid::PalmaConnectionHandle, ulong Unknown0, ulong Unknown1, nn::hid::PalmaApplicationSectionAccessBuffer) public ResultCode WritePalmaApplicationSection(ServiceCtx context) { - int palmaConnectionHandle = context.RequestData.ReadInt32(); - long unknown0 = context.RequestData.ReadInt64(); - long unknown1 = context.RequestData.ReadInt64(); + int palmaConnectionHandle = context.RequestData.ReadInt32(); + long unknown0 = context.RequestData.ReadInt64(); + long unknown1 = context.RequestData.ReadInt64(); // nn::hid::PalmaApplicationSectionAccessBuffer cast is unknown Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle, unknown0, unknown1 }); @@ -1746,7 +1771,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid public ResultCode SetIsPalmaAllConnectable(ServiceCtx context) { long appletResourceUserId = context.RequestData.ReadInt64(); - long unknownBool = context.RequestData.ReadInt64(); + long unknownBool = context.RequestData.ReadInt64(); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, unknownBool }); @@ -1766,8 +1791,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid // SetNpadCommunicationMode(long CommunicationMode, nn::applet::AppletResourceUserId) public ResultCode SetNpadCommunicationMode(ServiceCtx context) { - _npadCommunicationMode = context.RequestData.ReadInt64(); - long appletResourceUserId = context.RequestData.ReadInt64(); + _npadCommunicationMode = context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, _npadCommunicationMode }); @@ -1790,7 +1815,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid public ResultCode SetTouchScreenConfiguration(ServiceCtx context) { long touchScreenConfigurationForNx = context.RequestData.ReadInt64(); - long appletResourceUserId = context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, touchScreenConfigurationForNx }); diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/IHidSystemServer.cs b/src/Ryujinx.HLE/HOS/Services/Hid/IHidSystemServer.cs index 4a5d0e9b..685f6841 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/IHidSystemServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/IHidSystemServer.cs @@ -65,7 +65,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid private ResultCode GetAppletFooterUiTypeImpl(ServiceCtx context, out AppletFooterUiType appletFooterUiType) { - NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadUInt32(); + NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadUInt32(); PlayerIndex playerIndex = HidUtils.GetIndexFromNpadIdType(npadIdType); appletFooterUiType = context.Device.Hid.SharedMemory.Npads[(int)playerIndex].InternalState.AppletFooterUiType; @@ -73,4 +73,4 @@ namespace Ryujinx.HLE.HOS.Services.Hid return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/IHidbusServer.cs b/src/Ryujinx.HLE/HOS/Services/Hid/IHidbusServer.cs index eec5292f..7c624dfc 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/IHidbusServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/IHidbusServer.cs @@ -10,12 +10,14 @@ namespace Ryujinx.HLE.HOS.Services.Hid [CommandCmif(1)] // GetBusHandle(nn::hid::NpadIdType, nn::hidbus::BusType, nn::applet::AppletResourceUserId) -> (bool HasHandle, nn::hidbus::BusHandle) +#pragma warning disable CA1822 // Mark member as static public ResultCode GetBusHandle(ServiceCtx context) +#pragma warning restore CA1822 { - NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadInt32(); + NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadInt32(); context.RequestData.BaseStream.Position += 4; // Padding - BusType busType = (BusType)context.RequestData.ReadInt64(); - long appletResourceUserId = context.RequestData.ReadInt64(); + BusType busType = (BusType)context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); context.ResponseData.Write(false); context.ResponseData.BaseStream.Position += 7; // Padding @@ -26,4 +28,4 @@ namespace Ryujinx.HLE.HOS.Services.Hid return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/ISystemServer.cs b/src/Ryujinx.HLE/HOS/Services/Hid/ISystemServer.cs index 71353344..daff6fda 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/ISystemServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/ISystemServer.cs @@ -5,4 +5,4 @@ { public ISystemServer(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorServer.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorServer.cs index 130fcf68..a13e77e7 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorServer.cs @@ -65,8 +65,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs // StopImageProcessor(pid, nn::irsensor::IrCameraHandle, nn::applet::AppletResourceUserId) public ResultCode StopImageProcessor(ServiceCtx context) { - IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>(); - ulong appletResourceUserId = context.RequestData.ReadUInt64(); + IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>(); + ulong appletResourceUserId = context.RequestData.ReadUInt64(); CheckCameraHandle(irCameraHandle); @@ -79,9 +79,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs // RunMomentProcessor(pid, nn::irsensor::IrCameraHandle, nn::applet::AppletResourceUserId, PackedMomentProcessorConfig) public ResultCode RunMomentProcessor(ServiceCtx context) { - IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>(); - ulong appletResourceUserId = context.RequestData.ReadUInt64(); - var packedMomentProcessorConfig = context.RequestData.ReadStruct<PackedMomentProcessorConfig>(); + IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>(); + ulong appletResourceUserId = context.RequestData.ReadUInt64(); + var packedMomentProcessorConfig = context.RequestData.ReadStruct<PackedMomentProcessorConfig>(); CheckCameraHandle(irCameraHandle); @@ -94,9 +94,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs // RunClusteringProcessor(pid, nn::irsensor::IrCameraHandle, nn::applet::AppletResourceUserId, PackedClusteringProcessorConfig) public ResultCode RunClusteringProcessor(ServiceCtx context) { - IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>(); - ulong appletResourceUserId = context.RequestData.ReadUInt64(); - var packedClusteringProcessorConfig = context.RequestData.ReadStruct<PackedClusteringProcessorConfig>(); + IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>(); + ulong appletResourceUserId = context.RequestData.ReadUInt64(); + var packedClusteringProcessorConfig = context.RequestData.ReadStruct<PackedClusteringProcessorConfig>(); CheckCameraHandle(irCameraHandle); @@ -109,9 +109,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs // RunImageTransferProcessor(pid, nn::irsensor::IrCameraHandle, nn::applet::AppletResourceUserId, PackedImageTransferProcessorConfig, u64 TransferMemorySize, TransferMemoryHandle) public ResultCode RunImageTransferProcessor(ServiceCtx context) { - IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>(); - ulong appletResourceUserId = context.RequestData.ReadUInt64(); - var packedImageTransferProcessorConfig = context.RequestData.ReadStruct<PackedImageTransferProcessorConfig>(); + IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>(); + ulong appletResourceUserId = context.RequestData.ReadUInt64(); + var packedImageTransferProcessorConfig = context.RequestData.ReadStruct<PackedImageTransferProcessorConfig>(); CheckCameraHandle(irCameraHandle); @@ -126,8 +126,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs // GetImageTransferProcessorState(pid, nn::irsensor::IrCameraHandle, nn::applet::AppletResourceUserId) public ResultCode GetImageTransferProcessorState(ServiceCtx context) { - IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>(); - ulong appletResourceUserId = context.RequestData.ReadUInt64(); + IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>(); + ulong appletResourceUserId = context.RequestData.ReadUInt64(); // ulong imageTransferBufferAddress = context.Request.ReceiveBuff[0].Position; ulong imageTransferBufferSize = context.Request.ReceiveBuff[0].Size; @@ -144,8 +144,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs // TODO: Uses the buffer to copy the JoyCon IR data (by using a JoyCon driver) and update the following struct. context.ResponseData.WriteStruct(new ImageTransferProcessorState() { - SamplingNumber = 0, - AmbientNoiseLevel = 0 + SamplingNumber = 0, + AmbientNoiseLevel = 0, }); return ResultCode.Success; @@ -155,9 +155,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs // RunTeraPluginProcessor(pid, nn::irsensor::IrCameraHandle, nn::applet::AppletResourceUserId, PackedTeraPluginProcessorConfig) public ResultCode RunTeraPluginProcessor(ServiceCtx context) { - IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>(); - ulong appletResourceUserId = context.RequestData.ReadUInt64(); - var packedTeraPluginProcessorConfig = context.RequestData.ReadStruct<PackedTeraPluginProcessorConfig>(); + IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>(); + ulong appletResourceUserId = context.RequestData.ReadUInt64(); + var packedTeraPluginProcessorConfig = context.RequestData.ReadStruct<PackedTeraPluginProcessorConfig>(); CheckCameraHandle(irCameraHandle); @@ -172,7 +172,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs { NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadUInt32(); - if (npadIdType > NpadIdType.Player8 && + if (npadIdType > NpadIdType.Player8 && npadIdType != NpadIdType.Unknown && npadIdType != NpadIdType.Handheld) { @@ -193,10 +193,10 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs // CheckFirmwareVersion(nn::irsensor::IrCameraHandle, nn::irsensor::PackedMcuVersion, nn::applet::AppletResourceUserId, pid) public ResultCode CheckFirmwareVersion(ServiceCtx context) { - int irCameraHandle = context.RequestData.ReadInt32(); + int irCameraHandle = context.RequestData.ReadInt32(); short packedMcuVersionMajor = context.RequestData.ReadInt16(); short packedMcuVersionMinor = context.RequestData.ReadInt16(); - long appletResourceUserId = context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId, irCameraHandle, packedMcuVersionMajor, packedMcuVersionMinor }); @@ -207,7 +207,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs // StopImageProcessorAsync(nn::irsensor::IrCameraHandle, nn::applet::AppletResourceUserId, pid) public ResultCode StopImageProcessorAsync(ServiceCtx context) { - int irCameraHandle = context.RequestData.ReadInt32(); + int irCameraHandle = context.RequestData.ReadInt32(); long appletResourceUserId = context.RequestData.ReadInt64(); Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId, irCameraHandle }); @@ -220,7 +220,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs public ResultCode ActivateIrsensorWithFunctionLevel(ServiceCtx context) { long appletResourceUserId = context.RequestData.ReadInt64(); - long packedFunctionLevel = context.RequestData.ReadInt64(); + long packedFunctionLevel = context.RequestData.ReadInt64(); Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId, packedFunctionLevel }); diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorSystemServer.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorSystemServer.cs index 99fcd541..ad78d4f1 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorSystemServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorSystemServer.cs @@ -5,4 +5,4 @@ { public IIrSensorSystemServer(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Irs/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Irs/ResultCode.cs index 3afc03c2..322f9349 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Irs/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Irs/ResultCode.cs @@ -2,14 +2,14 @@ { public enum ResultCode { - ModuleId = 205, + ModuleId = 205, ErrorCodeShift = 9, Success = 0, InvalidCameraHandle = (204 << ErrorCodeShift) | ModuleId, - InvalidBufferSize = (207 << ErrorCodeShift) | ModuleId, + InvalidBufferSize = (207 << ErrorCodeShift) | ModuleId, HandlePointerIsNull = (212 << ErrorCodeShift) | ModuleId, - NpadIdOutOfRange = (709 << ErrorCodeShift) | ModuleId + NpadIdOutOfRange = (709 << ErrorCodeShift) | ModuleId, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Irs/Types/ImageTransferProcessorState.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Irs/Types/ImageTransferProcessorState.cs index 647aef64..7f28667c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Irs/Types/ImageTransferProcessorState.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Irs/Types/ImageTransferProcessorState.cs @@ -6,7 +6,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs.Types struct ImageTransferProcessorState { public ulong SamplingNumber; - public uint AmbientNoiseLevel; - public uint Reserved; + public uint AmbientNoiseLevel; + public uint Reserved; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Irs/Types/IrCameraHandle.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Irs/Types/IrCameraHandle.cs index 8ed7201e..282f9279 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Irs/Types/IrCameraHandle.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Irs/Types/IrCameraHandle.cs @@ -5,8 +5,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs.Types [StructLayout(LayoutKind.Sequential, Size = 0x4)] struct IrCameraHandle { - public byte PlayerNumber; - public byte DeviceType; + public byte PlayerNumber; + public byte DeviceType; public ushort Reserved; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Irs/Types/PackedClusteringProcessorConfig.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Irs/Types/PackedClusteringProcessorConfig.cs index 735f7822..a65a1ba6 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Irs/Types/PackedClusteringProcessorConfig.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Irs/Types/PackedClusteringProcessorConfig.cs @@ -5,21 +5,21 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs.Types [StructLayout(LayoutKind.Sequential, Size = 0x28)] struct PackedClusteringProcessorConfig { - public long ExposureTime; - public byte LightTarget; - public byte Gain; - public byte IsNegativeImageUsed; - public byte Reserved1; - public uint Reserved2; + public long ExposureTime; + public byte LightTarget; + public byte Gain; + public byte IsNegativeImageUsed; + public byte Reserved1; + public uint Reserved2; public ushort WindowOfInterestX; public ushort WindowOfInterestY; public ushort WindowOfInterestWidth; public ushort WindowOfInterestHeight; - public uint RequiredMcuVersion; - public uint ObjectPixelCountMin; - public uint ObjectPixelCountMax; - public byte ObjectIntensityMin; - public byte IsExternalLightFilterEnabled; + public uint RequiredMcuVersion; + public uint ObjectPixelCountMin; + public uint ObjectPixelCountMax; + public byte ObjectIntensityMin; + public byte IsExternalLightFilterEnabled; public ushort Reserved3; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Irs/Types/PackedImageTransferProcessorConfig.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Irs/Types/PackedImageTransferProcessorConfig.cs index 094413e0..c97de27a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Irs/Types/PackedImageTransferProcessorConfig.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Irs/Types/PackedImageTransferProcessorConfig.cs @@ -5,15 +5,15 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs.Types [StructLayout(LayoutKind.Sequential, Size = 0x18)] struct PackedImageTransferProcessorConfig { - public long ExposureTime; - public byte LightTarget; - public byte Gain; - public byte IsNegativeImageUsed; - public byte Reserved1; - public uint Reserved2; - public uint RequiredMcuVersion; - public byte Format; - public byte Reserved3; + public long ExposureTime; + public byte LightTarget; + public byte Gain; + public byte IsNegativeImageUsed; + public byte Reserved1; + public uint Reserved2; + public uint RequiredMcuVersion; + public byte Format; + public byte Reserved3; public ushort Reserved4; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Irs/Types/PackedMomentProcessorConfig.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Irs/Types/PackedMomentProcessorConfig.cs index a1b70b40..bbee2815 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Irs/Types/PackedMomentProcessorConfig.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Irs/Types/PackedMomentProcessorConfig.cs @@ -5,19 +5,19 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs.Types [StructLayout(LayoutKind.Sequential, Size = 0x20)] struct PackedMomentProcessorConfig { - public long ExposureTime; - public byte LightTarget; - public byte Gain; - public byte IsNegativeImageUsed; - public byte Reserved1; - public uint Reserved2; + public long ExposureTime; + public byte LightTarget; + public byte Gain; + public byte IsNegativeImageUsed; + public byte Reserved1; + public uint Reserved2; public ushort WindowOfInterestX; public ushort WindowOfInterestY; public ushort WindowOfInterestWidth; public ushort WindowOfInterestHeight; - public uint RequiredMcuVersion; - public byte Preprocess; - public byte PreprocessIntensityThreshold; + public uint RequiredMcuVersion; + public byte Preprocess; + public byte PreprocessIntensityThreshold; public ushort Reserved3; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Irs/Types/PackedTeraPluginProcessorConfig.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Irs/Types/PackedTeraPluginProcessorConfig.cs index 808b0b72..4fada04a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Irs/Types/PackedTeraPluginProcessorConfig.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Irs/Types/PackedTeraPluginProcessorConfig.cs @@ -11,4 +11,4 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs.Types public byte Unknown2; public byte Unknown3; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Hid/ResultCode.cs index 9c87ac1d..993ff707 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/ResultCode.cs @@ -2,14 +2,14 @@ { enum ResultCode { - ModuleId = 202, + ModuleId = 202, ErrorCodeShift = 9, Success = 0, InvalidNpadDeviceType = (122 << ErrorCodeShift) | ModuleId, - InvalidNpadIdType = (123 << ErrorCodeShift) | ModuleId, - InvalidDeviceIndex = (124 << ErrorCodeShift) | ModuleId, - InvalidBufferSize = (131 << ErrorCodeShift) | ModuleId + InvalidNpadIdType = (123 << ErrorCodeShift) | ModuleId, + InvalidDeviceIndex = (124 << ErrorCodeShift) | ModuleId, + InvalidBufferSize = (131 << ErrorCodeShift) | ModuleId, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/AppletFooterUiType.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/AppletFooterUiType.cs index c4ff8d7e..1eccd856 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/AppletFooterUiType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/AppletFooterUiType.cs @@ -25,6 +25,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types LarkNesLeft, LarkNesRight, Lucia, - Verification + Verification, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/HidVector.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/HidVector.cs index 18d9fd9c..8d667796 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/HidVector.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/HidVector.cs @@ -6,4 +6,4 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types public float Y; public float Z; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/BusHandle.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/BusHandle.cs index 936ee68c..033eb306 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/BusHandle.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/BusHandle.cs @@ -5,7 +5,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid [StructLayout(LayoutKind.Sequential)] struct BusHandle { - public int AbstractedPadId; + public int AbstractedPadId; public byte InternalIndex; public byte PlayerNumber; public byte BusTypeId; diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/BusType.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/BusType.cs index 41852365..25b36ca4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/BusType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/BusType.cs @@ -2,8 +2,8 @@ { public enum BusType : long { - LeftJoyRail = 0, + LeftJoyRail = 0, RightJoyRail = 1, - InternalBus = 2 + InternalBus = 2, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/ControllerKeys.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/ControllerKeys.cs index c91636b2..b43381e6 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/ControllerKeys.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/ControllerKeys.cs @@ -5,41 +5,41 @@ namespace Ryujinx.HLE.HOS.Services.Hid [Flags] public enum ControllerKeys : long { - A = 1 << 0, - B = 1 << 1, - X = 1 << 2, - Y = 1 << 3, - LStick = 1 << 4, - RStick = 1 << 5, - L = 1 << 6, - R = 1 << 7, - Zl = 1 << 8, - Zr = 1 << 9, - Plus = 1 << 10, - Minus = 1 << 11, - DpadLeft = 1 << 12, - DpadUp = 1 << 13, - DpadRight = 1 << 14, - DpadDown = 1 << 15, - LStickLeft = 1 << 16, - LStickUp = 1 << 17, + A = 1 << 0, + B = 1 << 1, + X = 1 << 2, + Y = 1 << 3, + LStick = 1 << 4, + RStick = 1 << 5, + L = 1 << 6, + R = 1 << 7, + Zl = 1 << 8, + Zr = 1 << 9, + Plus = 1 << 10, + Minus = 1 << 11, + DpadLeft = 1 << 12, + DpadUp = 1 << 13, + DpadRight = 1 << 14, + DpadDown = 1 << 15, + LStickLeft = 1 << 16, + LStickUp = 1 << 17, LStickRight = 1 << 18, - LStickDown = 1 << 19, - RStickLeft = 1 << 20, - RStickUp = 1 << 21, + LStickDown = 1 << 19, + RStickLeft = 1 << 20, + RStickUp = 1 << 21, RStickRight = 1 << 22, - RStickDown = 1 << 23, - SlLeft = 1 << 24, - SrLeft = 1 << 25, - SlRight = 1 << 26, - SrRight = 1 << 27, + RStickDown = 1 << 23, + SlLeft = 1 << 24, + SrLeft = 1 << 25, + SlRight = 1 << 26, + SrRight = 1 << 27, // Generic Catch-all - Up = DpadUp | LStickUp | RStickUp, - Down = DpadDown | LStickDown | RStickDown, - Left = DpadLeft | LStickLeft | RStickLeft, + Up = DpadUp | LStickUp | RStickUp, + Down = DpadDown | LStickDown | RStickDown, + Left = DpadLeft | LStickLeft | RStickLeft, Right = DpadRight | LStickRight | RStickRight, - Sl = SlLeft | SlRight, - Sr = SrLeft | SrRight + Sl = SlLeft | SlRight, + Sr = SrLeft | SrRight, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/ControllerType.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/ControllerType.cs index d830f46a..1f5da317 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/ControllerType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/ControllerType.cs @@ -6,14 +6,14 @@ namespace Ryujinx.HLE.HOS.Services.Hid public enum ControllerType { None, - ProController = 1 << 0, - Handheld = 1 << 1, - JoyconPair = 1 << 2, - JoyconLeft = 1 << 3, - JoyconRight = 1 << 4, - Invalid = 1 << 5, - Pokeball = 1 << 6, + ProController = 1 << 0, + Handheld = 1 << 1, + JoyconPair = 1 << 2, + JoyconLeft = 1 << 3, + JoyconRight = 1 << 4, + Invalid = 1 << 5, + Pokeball = 1 << 6, SystemExternal = 1 << 29, - System = 1 << 30 + System = 1 << 30, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/NpadColor.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/NpadColor.cs index 3c311e21..010cffbd 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/NpadColor.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/NpadColor.cs @@ -1,37 +1,37 @@ namespace Ryujinx.HLE.HOS.Services.Hid { - public enum NpadColor : uint + public enum NpadColor : uint { - BodyGray = 0x828282, - BodyNeonRed = 0xFF3C28, - BodyNeonBlue = 0x0AB9E6, - BodyNeonYellow = 0xE6FF00, - BodyNeonGreen = 0x1EDC00, - BodyNeonPink = 0xFF3278, - BodyRed = 0xE10F00, - BodyBlue = 0x4655F5, - BodyNeonPurple = 0xB400E6, - BodyNeonOrange = 0xFAA005, - BodyPokemonLetsGoPikachu = 0xFFDC00, - BodyPokemonLetsGoEevee = 0xC88C32, - BodyNintendoLaboCreatorsContestEdition = 0xD7AA73, - BodyAnimalCrossingSpecialEditionLeftJoyCon = 0x82FF96, - BodyAnimalCrossingSpecialEditionRightJoyCon = 0x96F5F5, + BodyGray = 0x828282, + BodyNeonRed = 0xFF3C28, + BodyNeonBlue = 0x0AB9E6, + BodyNeonYellow = 0xE6FF00, + BodyNeonGreen = 0x1EDC00, + BodyNeonPink = 0xFF3278, + BodyRed = 0xE10F00, + BodyBlue = 0x4655F5, + BodyNeonPurple = 0xB400E6, + BodyNeonOrange = 0xFAA005, + BodyPokemonLetsGoPikachu = 0xFFDC00, + BodyPokemonLetsGoEevee = 0xC88C32, + BodyNintendoLaboCreatorsContestEdition = 0xD7AA73, + BodyAnimalCrossingSpecialEditionLeftJoyCon = 0x82FF96, + BodyAnimalCrossingSpecialEditionRightJoyCon = 0x96F5F5, - ButtonGray = 0x0F0F0F, - ButtonNeonRed = 0x1E0A0A, - ButtonNeonBlue = 0x001E1E, - ButtonNeonYellow = 0x142800, - ButtonNeonGreen = 0x002800, - ButtonNeonPink = 0x28001E, - ButtonRed = 0x280A0A, - ButtonBlue = 0x00000A, - ButtonNeonPurple = 0x140014, - ButtonNeonOrange = 0x0F0A00, - ButtonPokemonLetsGoPikachu = 0x322800, - ButtonPokemonLetsGoEevee = 0x281900, - ButtonNintendoLaboCreatorsContestEdition = 0x1E1914, - ButtonAnimalCrossingSpecialEditionLeftJoyCon = 0x0A1E0A, - ButtonAnimalCrossingSpecialEditionRightJoyCon = 0x0A1E28 + ButtonGray = 0x0F0F0F, + ButtonNeonRed = 0x1E0A0A, + ButtonNeonBlue = 0x001E1E, + ButtonNeonYellow = 0x142800, + ButtonNeonGreen = 0x002800, + ButtonNeonPink = 0x28001E, + ButtonRed = 0x280A0A, + ButtonBlue = 0x00000A, + ButtonNeonPurple = 0x140014, + ButtonNeonOrange = 0x0F0A00, + ButtonPokemonLetsGoPikachu = 0x322800, + ButtonPokemonLetsGoEevee = 0x281900, + ButtonNintendoLaboCreatorsContestEdition = 0x1E1914, + ButtonAnimalCrossingSpecialEditionLeftJoyCon = 0x0A1E0A, + ButtonAnimalCrossingSpecialEditionRightJoyCon = 0x0A1E28, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/NpadIdType.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/NpadIdType.cs index 4b488cd2..5a9247d9 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/NpadIdType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/NpadIdType.cs @@ -2,15 +2,15 @@ { public enum NpadIdType { - Player1 = 0, - Player2 = 1, - Player3 = 2, - Player4 = 3, - Player5 = 4, - Player6 = 5, - Player7 = 6, - Player8 = 7, - Unknown = 16, - Handheld = 32 + Player1 = 0, + Player2 = 1, + Player3 = 2, + Player4 = 3, + Player5 = 4, + Player6 = 5, + Player7 = 6, + Player8 = 7, + Unknown = 16, + Handheld = 32, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/NpadStyleIndex.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/NpadStyleIndex.cs index ddf5d97f..04550b6f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/NpadStyleIndex.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/NpadStyleIndex.cs @@ -2,12 +2,12 @@ { public enum NpadStyleIndex : byte { - FullKey = 3, - Handheld = 4, - JoyDual = 5, - JoyLeft = 6, - JoyRight = 7, + FullKey = 3, + Handheld = 4, + JoyDual = 5, + JoyLeft = 6, + JoyRight = 7, SystemExt = 32, - System = 33 + System = 33, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/PlayerIndex.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/PlayerIndex.cs index 972d69b4..d68b6d93 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/PlayerIndex.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/PlayerIndex.cs @@ -2,16 +2,16 @@ namespace Ryujinx.HLE.HOS.Services.Hid { public enum PlayerIndex { - Player1 = 0, - Player2 = 1, - Player3 = 2, - Player4 = 3, - Player5 = 4, - Player6 = 5, - Player7 = 6, - Player8 = 7, + Player1 = 0, + Player2 = 1, + Player3 = 2, + Player4 = 3, + Player5 = 4, + Player6 = 5, + Player7 = 6, + Player8 = 7, Handheld = 8, - Unknown = 9, - Auto = 10 // Shouldn't be used directly + Unknown = 9, + Auto = 10, // Shouldn't be used directly } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/NpadJoyHoldType.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/NpadJoyHoldType.cs index d3b51a24..19297de4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/NpadJoyHoldType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/NpadJoyHoldType.cs @@ -3,6 +3,6 @@ enum NpadJoyHoldType { Vertical, - Horizontal + Horizontal, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Common/AtomicStorage.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Common/AtomicStorage.cs index da53e421..b6bc288e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Common/AtomicStorage.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Common/AtomicStorage.cs @@ -2,7 +2,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Common { - struct AtomicStorage<T> where T: unmanaged, ISampledDataStruct + struct AtomicStorage<T> where T : unmanaged, ISampledDataStruct { public ulong SamplingNumber; public T Object; diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Common/ISampledDataStruct.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Common/ISampledDataStruct.cs index a382c0c2..ae1997d4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Common/ISampledDataStruct.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Common/ISampledDataStruct.cs @@ -11,9 +11,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Common /// - use <c>StructLayoutAttribute</c> (and related attributes) to explicity control how the struct is laid out in memory. /// - ensure that the method <c>ISampledDataStruct.GetSamplingNumberFieldOffset()</c> correctly returns the offset, in bytes, /// to the ulong "Sampling Number" field within the struct. Most types have it as the first field, so the default offset is 0. - /// + /// /// Example: - /// + /// /// <c> /// [StructLayout(LayoutKind.Sequential, Pack = 8)] /// struct DebugPadState : ISampledDataStruct @@ -45,7 +45,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Common if (fieldOffset > 0) { - byteSpan = byteSpan.Slice(fieldOffset); + byteSpan = byteSpan[fieldOffset..]; } ulong value = BinaryPrimitives.ReadUInt64LittleEndian(byteSpan); @@ -58,7 +58,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Common return sampledDataStruct switch { Npad.SixAxisSensorState _ => sizeof(ulong), - _ => 0 + _ => 0, }; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Common/RingLifo.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Common/RingLifo.cs index ae654d6f..26ea1cff 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Common/RingLifo.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Common/RingLifo.cs @@ -5,16 +5,16 @@ using System.Threading; namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Common { - struct RingLifo<T> where T: unmanaged, ISampledDataStruct + struct RingLifo<T> where T : unmanaged, ISampledDataStruct { private const ulong MaxEntries = 17; -#pragma warning disable CS0169 - private ulong _unused; -#pragma warning restore CS0169 -#pragma warning disable CS0414 +#pragma warning disable IDE0051, CS0169 // Remove unused private member + private readonly ulong _unused; +#pragma warning restore IDE0051, CS0169 +#pragma warning disable CS0414, IDE0052 // Remove unread private member private ulong _bufferCount; -#pragma warning restore CS0414 +#pragma warning restore CS0414, IDE0052 private ulong _index; private ulong _count; private Array17<AtomicStorage<T>> _storage; @@ -32,7 +32,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Common } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static ulong GetNextIndexForWrite(ulong index) + private readonly ulong GetNextIndexForWrite(ulong index) { return (index + 1) % MaxEntries; } @@ -142,7 +142,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Common { return new RingLifo<T> { - _bufferCount = MaxEntries + _bufferCount = MaxEntries, }; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/DebugPad/DebugPadAttribute.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/DebugPad/DebugPadAttribute.cs index ec5bd3c8..abc6990b 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/DebugPad/DebugPadAttribute.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/DebugPad/DebugPadAttribute.cs @@ -6,6 +6,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.DebugPad enum DebugPadAttribute : uint { None = 0, - Connected = 1 << 0 + Connected = 1 << 0, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/DebugPad/DebugPadButton.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/DebugPad/DebugPadButton.cs index e8f28317..dc713a03 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/DebugPad/DebugPadButton.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/DebugPad/DebugPadButton.cs @@ -19,6 +19,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.DebugPad Left = 1 << 10, Up = 1 << 11, Right = 1 << 12, - Down = 1 << 13 + Down = 1 << 13, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Keyboard/KeyboardKey.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Keyboard/KeyboardKey.cs index 22df7c79..336037ab 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Keyboard/KeyboardKey.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Keyboard/KeyboardKey.cs @@ -26,4 +26,4 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Keyboard } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Keyboard/KeyboardKeyShift.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Keyboard/KeyboardKeyShift.cs index 01c2bb30..46461ad8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Keyboard/KeyboardKeyShift.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Keyboard/KeyboardKeyShift.cs @@ -133,6 +133,6 @@ RightControl = 228, RightShift = 229, RightAlt = 230, - RightGui = 231 + RightGui = 231, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Keyboard/KeyboardModifier.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Keyboard/KeyboardModifier.cs index 839a4e82..ad94619e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Keyboard/KeyboardModifier.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Keyboard/KeyboardModifier.cs @@ -15,6 +15,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Keyboard ScrollLock = 1 << 9, NumLock = 1 << 10, Katakana = 1 << 11, - Hiragana = 1 << 12 + Hiragana = 1 << 12, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Mouse/MouseAttribute.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Mouse/MouseAttribute.cs index 5ffba0d7..ce3dd946 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Mouse/MouseAttribute.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Mouse/MouseAttribute.cs @@ -7,6 +7,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Mouse { None = 0, Transferable = 1 << 0, - IsConnected = 1 << 1 + IsConnected = 1 << 1, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Mouse/MouseButton.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Mouse/MouseButton.cs index 7e35140c..3e025993 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Mouse/MouseButton.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Mouse/MouseButton.cs @@ -10,6 +10,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Mouse Right = 1 << 1, Middle = 1 << 2, Forward = 1 << 3, - Back = 1 << 4 + Back = 1 << 4, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/DeviceType.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/DeviceType.cs index 95b1cb51..259c712b 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/DeviceType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/DeviceType.cs @@ -24,6 +24,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Npad HandheldLarkNesRight = 1 << 14, Lucia = 1 << 15, - System = 1 << 31 + System = 1 << 31, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadAttribute.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadAttribute.cs index 0960b7bf..6ad2531f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadAttribute.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadAttribute.cs @@ -11,6 +11,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Npad IsLeftConnected = 1 << 2, IsLeftWired = 1 << 3, IsRightConnected = 1 << 4, - IsRightWired = 1 << 5 + IsRightWired = 1 << 5, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadBatteryLevel.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadBatteryLevel.cs index e10e55cd..a84e0259 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadBatteryLevel.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadBatteryLevel.cs @@ -6,6 +6,6 @@ Percent25, Percent50, Percent75, - Percent100 + Percent100, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadButton.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadButton.cs index 5b3e13a7..442d4089 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadButton.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadButton.cs @@ -39,6 +39,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Npad // FIXME: Probably a button on Lark. Unknown29 = 1 << 29, - HandheldLeftB = 1 << 30 + HandheldLeftB = 1 << 30, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadColorAttribute.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadColorAttribute.cs index 1e547cc8..1a7846db 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadColorAttribute.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadColorAttribute.cs @@ -4,6 +4,6 @@ { Ok, ReadError, - NoController + NoController, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadCommonState.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadCommonState.cs index 64f75ce9..e1d70a8a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadCommonState.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadCommonState.cs @@ -11,6 +11,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Npad public AnalogStickState AnalogStickL; public AnalogStickState AnalogStickR; public NpadAttribute Attributes; - private uint _reserved; + private readonly uint _reserved; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadFullKeyColorState.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadFullKeyColorState.cs index 990eafb2..92d4a2ae 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadFullKeyColorState.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadFullKeyColorState.cs @@ -6,4 +6,4 @@ public uint FullKeyBody; public uint FullKeyButtons; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadGcTriggerState.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadGcTriggerState.cs index bddd6212..39453984 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadGcTriggerState.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadGcTriggerState.cs @@ -6,10 +6,10 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Npad [StructLayout(LayoutKind.Sequential, Pack = 1)] struct NpadGcTriggerState : ISampledDataStruct { -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public ulong SamplingNumber; public uint TriggerL; public uint TriggerR; #pragma warning restore CS0649 } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadInternalState.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadInternalState.cs index b009f95e..60d16fd8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadInternalState.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadInternalState.cs @@ -23,7 +23,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Npad public RingLifo<SixAxisSensorState> JoyLeftSixAxisSensor; public RingLifo<SixAxisSensorState> JoyRightSixAxisSensor; public DeviceType DeviceType; - private uint _reserved1; +#pragma warning disable IDE0051 // Remove unused private member + private readonly uint _reserved1; +#pragma warning restore IDE0051 public NpadSystemProperties SystemProperties; public NpadSystemButtonProperties SystemButtonProperties; public NpadBatteryLevel BatteryLevelJoyDual; @@ -31,7 +33,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Npad public NpadBatteryLevel BatteryLevelJoyRight; public uint AppletFooterUiAttributes; public AppletFooterUiType AppletFooterUiType; - private Reserved2Struct _reserved2; +#pragma warning disable IDE0051 // Remove unused private member + private readonly Reserved2Struct _reserved2; +#pragma warning restore IDE0051 public RingLifo<NpadGcTriggerState> GcTrigger; public NpadLarkType LarkTypeLeftAndMain; public NpadLarkType LarkTypeRight; @@ -39,7 +43,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Npad public uint Unknown43EC; [StructLayout(LayoutKind.Sequential, Size = 123, Pack = 1)] - private struct Reserved2Struct {} + private struct Reserved2Struct { } public static NpadInternalState Create() { @@ -62,4 +66,4 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Npad }; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadJoyAssignmentMode.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadJoyAssignmentMode.cs index 871c4c5a..c50abe16 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadJoyAssignmentMode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadJoyAssignmentMode.cs @@ -3,6 +3,6 @@ enum NpadJoyAssignmentMode : uint { Dual, - Single + Single, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadJoyColorState.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadJoyColorState.cs index 3986dd5e..6fec613b 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadJoyColorState.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadJoyColorState.cs @@ -8,4 +8,4 @@ public uint RightBody; public uint RightButtons; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadLuciaType.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadLuciaType.cs index 95148485..e12e84e4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadLuciaType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadLuciaType.cs @@ -5,6 +5,6 @@ Invalid, J, E, - U + U, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadState.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadState.cs index ed9e7c0d..643234fc 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadState.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadState.cs @@ -11,7 +11,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Npad { return new NpadState { - InternalState = NpadInternalState.Create() + InternalState = NpadInternalState.Create(), }; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadStyleTag.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadStyleTag.cs index f31978e2..d9ecdcd1 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadStyleTag.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadStyleTag.cs @@ -71,6 +71,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Npad /// <summary> /// Generic controller. /// </summary> - System = 1 << 30 + System = 1 << 30, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadSystemButtonProperties.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadSystemButtonProperties.cs index 68603271..56a4a80f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadSystemButtonProperties.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadSystemButtonProperties.cs @@ -6,6 +6,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Npad enum NpadSystemButtonProperties : uint { None = 0, - IsUnintendedHomeButtonInputProtectionEnabled = 1 << 0 + IsUnintendedHomeButtonInputProtectionEnabled = 1 << 0, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadSystemProperties.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadSystemProperties.cs index 13444555..817c6c14 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadSystemProperties.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadSystemProperties.cs @@ -19,6 +19,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Npad IsSlSrButtonOriented = 1 << 12, IsPlusAvailable = 1 << 13, IsMinusAvailable = 1 << 14, - IsDirectionalButtonsAvailable = 1 << 15 + IsDirectionalButtonsAvailable = 1 << 15, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/SixAxisSensorAttribute.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/SixAxisSensorAttribute.cs index 7ed46d98..0190f09d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/SixAxisSensorAttribute.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/SixAxisSensorAttribute.cs @@ -7,6 +7,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Npad { None = 0, IsConnected = 1 << 0, - IsInterpolated = 1 << 1 + IsInterpolated = 1 << 1, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/SixAxisSensorState.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/SixAxisSensorState.cs index 18be3276..25f65a0e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/SixAxisSensorState.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/SixAxisSensorState.cs @@ -14,6 +14,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Npad public HidVector Angle; public Array9<float> Direction; public SixAxisSensorAttribute Attributes; - private uint _reserved; + private readonly uint _reserved; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/SharedMemory.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/SharedMemory.cs index 48acfc3f..640076b3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/SharedMemory.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/SharedMemory.cs @@ -47,7 +47,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory public static SharedMemory Create() { - SharedMemory result = new SharedMemory + SharedMemory result = new() { DebugPad = RingLifo<DebugPadState>.Create(), TouchScreen = RingLifo<TouchScreenState>.Create(), diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/TouchScreen/TouchAttribute.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/TouchScreen/TouchAttribute.cs index d2c5726a..7c43e6cd 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/TouchScreen/TouchAttribute.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/TouchScreen/TouchAttribute.cs @@ -7,6 +7,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.TouchScreen { None = 0, Start = 1 << 0, - End = 1 << 1 + End = 1 << 1, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/TouchScreen/TouchScreenState.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/TouchScreen/TouchScreenState.cs index cdd4cc45..5ce51ee3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/TouchScreen/TouchScreenState.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/TouchScreen/TouchScreenState.cs @@ -9,7 +9,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.TouchScreen { public ulong SamplingNumber; public int TouchesCount; - private int _reserved; + private readonly int _reserved; public Array16<TouchState> Touches; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/TouchScreen/TouchState.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/TouchScreen/TouchState.cs index ba621a2b..908f9ed5 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/TouchScreen/TouchState.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/TouchScreen/TouchState.cs @@ -3,7 +3,7 @@ struct TouchState { public ulong DeltaTime; -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public TouchAttribute Attribute; #pragma warning restore CS0649 public uint FingerId; @@ -12,8 +12,8 @@ public uint DiameterX; public uint DiameterY; public uint RotationAngle; -#pragma warning disable CS0169 - private uint _reserved; -#pragma warning restore CS0169 +#pragma warning disable CS0169, IDE0051 // Remove unused private member + private readonly uint _reserved; +#pragma warning restore CS0169, IDE0051 } } diff --git a/src/Ryujinx.HLE/HOS/Services/Ins/IReceiverManager.cs b/src/Ryujinx.HLE/HOS/Services/Ins/IReceiverManager.cs index 34d4bdfd..8ee00d0e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ins/IReceiverManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ins/IReceiverManager.cs @@ -5,4 +5,4 @@ { public IReceiverManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ins/ISenderManager.cs b/src/Ryujinx.HLE/HOS/Services/Ins/ISenderManager.cs index 38a95ee7..239c4cc8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ins/ISenderManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ins/ISenderManager.cs @@ -5,4 +5,4 @@ { public ISenderManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/IpcService.cs b/src/Ryujinx.HLE/HOS/Services/IpcService.cs index 048a68a9..eb9f6b2f 100644 --- a/src/Ryujinx.HLE/HOS/Services/IpcService.cs +++ b/src/Ryujinx.HLE/HOS/Services/IpcService.cs @@ -17,7 +17,7 @@ namespace Ryujinx.HLE.HOS.Services public ServerBase Server { get; private set; } private IpcService _parent; - private IdDictionary _domainObjects; + private readonly IdDictionary _domainObjects; private int _selfId; private bool _isDomain; @@ -106,7 +106,9 @@ namespace Ryujinx.HLE.HOS.Services } } +#pragma warning disable IDE0059 // Remove unnecessary value assignment long sfciMagic = context.RequestData.ReadInt64(); +#pragma warning restore IDE0059 int commandId = (int)context.RequestData.ReadInt64(); bool serviceExists = service.CmifCommands.TryGetValue(commandId, out MethodInfo processRequest); @@ -127,9 +129,8 @@ namespace Ryujinx.HLE.HOS.Services { string serviceName; - DummyService dummyService = service as DummyService; - serviceName = (dummyService == null) ? service.GetType().FullName : dummyService.ServiceName; + serviceName = (service is not DummyService dummyService) ? service.GetType().FullName : dummyService.ServiceName; Logger.Warning?.Print(LogClass.KernelIpc, $"Missing service {serviceName}: {commandId} ignored"); } @@ -181,9 +182,8 @@ namespace Ryujinx.HLE.HOS.Services { string serviceName; - DummyService dummyService = this as DummyService; - serviceName = (dummyService == null) ? GetType().FullName : dummyService.ServiceName; + serviceName = (this is not DummyService dummyService) ? GetType().FullName : dummyService.ServiceName; Logger.Warning?.Print(LogClass.KernelIpc, $"Missing service {serviceName}: {commandId} ignored"); } diff --git a/src/Ryujinx.HLE/HOS/Services/Lbl/ILblController.cs b/src/Ryujinx.HLE/HOS/Services/Lbl/ILblController.cs index 65074d5f..75d78743 100644 --- a/src/Ryujinx.HLE/HOS/Services/Lbl/ILblController.cs +++ b/src/Ryujinx.HLE/HOS/Services/Lbl/ILblController.cs @@ -89,4 +89,4 @@ return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Lbl/LblControllerServer.cs b/src/Ryujinx.HLE/HOS/Services/Lbl/LblControllerServer.cs index b68be1f2..899e882e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Lbl/LblControllerServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Lbl/LblControllerServer.cs @@ -3,7 +3,7 @@ [Service("lbl")] class LblControllerServer : ILblController { - private bool _vrModeEnabled; + private bool _vrModeEnabled; private float _currentBrightnessSettingForVrMode; public LblControllerServer(ServiceCtx context) : base(context) { } diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/IMonitorServiceCreator.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/IMonitorServiceCreator.cs index 09dfa78f..a7e99241 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/IMonitorServiceCreator.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/IMonitorServiceCreator.cs @@ -5,4 +5,4 @@ { public IMonitorServiceCreator(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/ISystemServiceCreator.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/ISystemServiceCreator.cs index b4dac449..9acfef5c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/ISystemServiceCreator.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/ISystemServiceCreator.cs @@ -5,4 +5,4 @@ { public ISystemServiceCreator(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/IUserServiceCreator.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/IUserServiceCreator.cs index 4f3094ae..317b1dbe 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/IUserServiceCreator.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/IUserServiceCreator.cs @@ -16,4 +16,4 @@ namespace Ryujinx.HLE.HOS.Services.Ldn return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/Lp2p/IServiceCreator.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/Lp2p/IServiceCreator.cs index 9c9ee3be..f2fd482d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/Lp2p/IServiceCreator.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/Lp2p/IServiceCreator.cs @@ -6,4 +6,4 @@ { public IServiceCreator(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/NetworkInterface.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/NetworkInterface.cs index 274b6132..26696cbe 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/NetworkInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/NetworkInterface.cs @@ -7,15 +7,15 @@ namespace Ryujinx.HLE.HOS.Services.Ldn { internal class NetworkInterface { - public ResultCode NifmState { get; set; } - public KEvent StateChangeEvent { get; private set; } + public ResultCode NifmState { get; set; } + public KEvent StateChangeEvent { get; private set; } private NetworkState _state; public NetworkInterface(Horizon system) { // TODO(Ac_K): Determine where the internal state is set. - NifmState = ResultCode.Success; + NifmState = ResultCode.Success; StateChangeEvent = new KEvent(system.KernelContext); _state = NetworkState.None; @@ -56,4 +56,4 @@ namespace Ryujinx.HLE.HOS.Services.Ldn return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/ResultCode.cs index 87674f7c..a9f2cbc3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/ResultCode.cs @@ -2,15 +2,15 @@ namespace Ryujinx.HLE.HOS.Services.Ldn { enum ResultCode { - ModuleId = 203, + ModuleId = 203, ErrorCodeShift = 9, Success = 0, - DeviceDisabled = (22 << ErrorCodeShift) | ModuleId, - InvalidState = (32 << ErrorCodeShift) | ModuleId, - Unknown1 = (48 << ErrorCodeShift) | ModuleId, + DeviceDisabled = (22 << ErrorCodeShift) | ModuleId, + InvalidState = (32 << ErrorCodeShift) | ModuleId, + Unknown1 = (48 << ErrorCodeShift) | ModuleId, InvalidArgument = (96 << ErrorCodeShift) | ModuleId, - InvalidObject = (97 << ErrorCodeShift) | ModuleId, + InvalidObject = (97 << ErrorCodeShift) | ModuleId, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/Types/NetworkState.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/Types/NetworkState.cs index 6ac20483..61fd831d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/Types/NetworkState.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/Types/NetworkState.cs @@ -8,6 +8,6 @@ AccessPointCreated, Station, StationConnected, - Error + Error, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/IUserLocalCommunicationService.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/IUserLocalCommunicationService.cs index f425ddf7..d390a3e6 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/IUserLocalCommunicationService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/IUserLocalCommunicationService.cs @@ -11,7 +11,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator // TODO(Ac_K): Determine what the hardcoded unknown value is. private const int UnknownValue = 90; - private NetworkInterface _networkInterface; + private readonly NetworkInterface _networkInterface; private int _stateChangeEventHandle = 0; @@ -79,10 +79,10 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator public ResultCode Initialize(ServiceCtx context) { // TODO(Ac_K): Determine what addresses are. - IPAddress unknownAddress1 = new IPAddress(context.RequestData.ReadUInt32()); - IPAddress unknownAddress2 = new IPAddress(context.RequestData.ReadUInt32()); + IPAddress unknownAddress1 = new(context.RequestData.ReadUInt32()); + IPAddress unknownAddress2 = new(context.RequestData.ReadUInt32()); return _networkInterface.Initialize(UnknownValue, version: 1, unknownAddress1, unknownAddress2); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Loader/IDebugMonitorInterface.cs b/src/Ryujinx.HLE/HOS/Services/Loader/IDebugMonitorInterface.cs index 82b24a35..78c405b4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Loader/IDebugMonitorInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Loader/IDebugMonitorInterface.cs @@ -5,4 +5,4 @@ { public IDebugMonitorInterface(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Loader/IProcessManagerInterface.cs b/src/Ryujinx.HLE/HOS/Services/Loader/IProcessManagerInterface.cs index 2ecde2ad..693d68da 100644 --- a/src/Ryujinx.HLE/HOS/Services/Loader/IProcessManagerInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Loader/IProcessManagerInterface.cs @@ -5,4 +5,4 @@ { public IProcessManagerInterface(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Loader/IShellInterface.cs b/src/Ryujinx.HLE/HOS/Services/Loader/IShellInterface.cs index 362f82f0..d2dc57bd 100644 --- a/src/Ryujinx.HLE/HOS/Services/Loader/IShellInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Loader/IShellInterface.cs @@ -5,4 +5,4 @@ { public IShellInterface(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Loader/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Loader/ResultCode.cs index 170dfa01..ec116648 100644 --- a/src/Ryujinx.HLE/HOS/Services/Loader/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Loader/ResultCode.cs @@ -1,43 +1,46 @@ -namespace Ryujinx.HLE.HOS.Services.Loader +using System.Diagnostics.CodeAnalysis; + +namespace Ryujinx.HLE.HOS.Services.Loader { + [SuppressMessage("Design", "CA1069: Enums values should not be duplicated")] enum ResultCode { - ModuleId = 9, + ModuleId = 9, ErrorCodeShift = 9, Success = 0, - ArgsTooLong = (1 << ErrorCodeShift) | ModuleId, - MaximumProcessesLoaded = (2 << ErrorCodeShift) | ModuleId, - NPDMTooBig = (3 << ErrorCodeShift) | ModuleId, - InvalidNPDM = (4 << ErrorCodeShift) | ModuleId, - InvalidNSO = (5 << ErrorCodeShift) | ModuleId, - InvalidPath = (6 << ErrorCodeShift) | ModuleId, - AlreadyRegistered = (7 << ErrorCodeShift) | ModuleId, - TitleNotFound = (8 << ErrorCodeShift) | ModuleId, - ACI0TitleIdNotMatchingRangeInACID = (9 << ErrorCodeShift) | ModuleId, - InvalidVersionInNPDM = (10 << ErrorCodeShift) | ModuleId, - InsufficientAddressSpace = (51 << ErrorCodeShift) | ModuleId, - InsufficientNRO = (52 << ErrorCodeShift) | ModuleId, - InvalidNRR = (53 << ErrorCodeShift) | ModuleId, - InvalidSignature = (54 << ErrorCodeShift) | ModuleId, - InsufficientNRORegistrations = (55 << ErrorCodeShift) | ModuleId, - InsufficientNRRRegistrations = (56 << ErrorCodeShift) | ModuleId, - NROAlreadyLoaded = (57 << ErrorCodeShift) | ModuleId, - UnalignedNRRAddress = (81 << ErrorCodeShift) | ModuleId, - BadNRRSize = (82 << ErrorCodeShift) | ModuleId, - NRRNotLoaded = (84 << ErrorCodeShift) | ModuleId, - BadNRRAddress = (85 << ErrorCodeShift) | ModuleId, - BadInitialization = (87 << ErrorCodeShift) | ModuleId, - UnknownACI0Descriptor = (100 << ErrorCodeShift) | ModuleId, - ACI0NotMatchingKernelFlagsDescriptor = (103 << ErrorCodeShift) | ModuleId, - ACI0NotMatchingSyscallMaskDescriptor = (104 << ErrorCodeShift) | ModuleId, - ACI0NotMatchingMapIoOrNormalRangeDescriptor = (106 << ErrorCodeShift) | ModuleId, - ACI0NotMatchingMapNormalPageDescriptor = (107 << ErrorCodeShift) | ModuleId, - ACI0NotMatchingInterruptPairDescriptor = (111 << ErrorCodeShift) | ModuleId, - ACI0NotMatchingApplicationTypeDescriptor = (113 << ErrorCodeShift) | ModuleId, + ArgsTooLong = (1 << ErrorCodeShift) | ModuleId, + MaximumProcessesLoaded = (2 << ErrorCodeShift) | ModuleId, + NPDMTooBig = (3 << ErrorCodeShift) | ModuleId, + InvalidNPDM = (4 << ErrorCodeShift) | ModuleId, + InvalidNSO = (5 << ErrorCodeShift) | ModuleId, + InvalidPath = (6 << ErrorCodeShift) | ModuleId, + AlreadyRegistered = (7 << ErrorCodeShift) | ModuleId, + TitleNotFound = (8 << ErrorCodeShift) | ModuleId, + ACI0TitleIdNotMatchingRangeInACID = (9 << ErrorCodeShift) | ModuleId, + InvalidVersionInNPDM = (10 << ErrorCodeShift) | ModuleId, + InsufficientAddressSpace = (51 << ErrorCodeShift) | ModuleId, + InsufficientNRO = (52 << ErrorCodeShift) | ModuleId, + InvalidNRR = (53 << ErrorCodeShift) | ModuleId, + InvalidSignature = (54 << ErrorCodeShift) | ModuleId, + InsufficientNRORegistrations = (55 << ErrorCodeShift) | ModuleId, + InsufficientNRRRegistrations = (56 << ErrorCodeShift) | ModuleId, + NROAlreadyLoaded = (57 << ErrorCodeShift) | ModuleId, + UnalignedNRRAddress = (81 << ErrorCodeShift) | ModuleId, + BadNRRSize = (82 << ErrorCodeShift) | ModuleId, + NRRNotLoaded = (84 << ErrorCodeShift) | ModuleId, + BadNRRAddress = (85 << ErrorCodeShift) | ModuleId, + BadInitialization = (87 << ErrorCodeShift) | ModuleId, + UnknownACI0Descriptor = (100 << ErrorCodeShift) | ModuleId, + ACI0NotMatchingKernelFlagsDescriptor = (103 << ErrorCodeShift) | ModuleId, + ACI0NotMatchingSyscallMaskDescriptor = (104 << ErrorCodeShift) | ModuleId, + ACI0NotMatchingMapIoOrNormalRangeDescriptor = (106 << ErrorCodeShift) | ModuleId, + ACI0NotMatchingMapNormalPageDescriptor = (107 << ErrorCodeShift) | ModuleId, + ACI0NotMatchingInterruptPairDescriptor = (111 << ErrorCodeShift) | ModuleId, + ACI0NotMatchingApplicationTypeDescriptor = (113 << ErrorCodeShift) | ModuleId, ACI0NotMatchingKernelReleaseVersionDescriptor = (114 << ErrorCodeShift) | ModuleId, - ACI0NotMatchingHandleTableSizeDescriptor = (115 << ErrorCodeShift) | ModuleId, - ACI0NotMatchingDebugFlagsDescriptor = (116 << ErrorCodeShift) | ModuleId + ACI0NotMatchingHandleTableSizeDescriptor = (115 << ErrorCodeShift) | ModuleId, + ACI0NotMatchingDebugFlagsDescriptor = (116 << ErrorCodeShift) | ModuleId, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mig/IService.cs b/src/Ryujinx.HLE/HOS/Services/Mig/IService.cs index 2f6eb99e..81f858f8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mig/IService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mig/IService.cs @@ -5,4 +5,4 @@ { public IService(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/DatabaseImpl.cs b/src/Ryujinx.HLE/HOS/Services/Mii/DatabaseImpl.cs index 6d65de95..d9bcecee 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/DatabaseImpl.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/DatabaseImpl.cs @@ -13,17 +13,14 @@ namespace Ryujinx.HLE.HOS.Services.Mii { get { - if (_instance == null) - { - _instance = new DatabaseImpl(); - } + _instance ??= new DatabaseImpl(); return _instance; } } private UtilityImpl _utilityImpl; - private MiiDatabaseManager _miiDatabase; + private readonly MiiDatabaseManager _miiDatabase; private bool _isBroken; public DatabaseImpl() diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/DatabaseSessionMetadata.cs b/src/Ryujinx.HLE/HOS/Services/Mii/DatabaseSessionMetadata.cs index 6982b0ed..56486c43 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/DatabaseSessionMetadata.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/DatabaseSessionMetadata.cs @@ -4,7 +4,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii { class DatabaseSessionMetadata { - public uint InterfaceVersion; + public uint InterfaceVersion; public ulong UpdateCounter; public SpecialMiiKeyCode MiiKeyCode { get; private set; } @@ -12,8 +12,8 @@ namespace Ryujinx.HLE.HOS.Services.Mii public DatabaseSessionMetadata(ulong updateCounter, SpecialMiiKeyCode miiKeyCode) { InterfaceVersion = 0; - UpdateCounter = updateCounter; - MiiKeyCode = miiKeyCode; + UpdateCounter = updateCounter; + MiiKeyCode = miiKeyCode; } public bool IsInterfaceVersionSupported(uint interfaceVersion) diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Helper.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Helper.cs index b8dbce15..71b9ab43 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Helper.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Helper.cs @@ -39,10 +39,12 @@ namespace Ryujinx.HLE.HOS.Services.Mii return UInt128Utils.FromHex("5279754d69694e780000000000000000"); // RyuMiiNx } +#pragma warning disable IDE0055 // Disable formatting public static ReadOnlySpan<byte> Ver3FacelineColorTable => new byte[] { 0, 1, 2, 3, 4, 5 }; public static ReadOnlySpan<byte> Ver3HairColorTable => new byte[] { 8, 1, 2, 3, 4, 5, 6, 7 }; public static ReadOnlySpan<byte> Ver3EyeColorTable => new byte[] { 8, 9, 10, 11, 12, 13 }; public static ReadOnlySpan<byte> Ver3MouthColorTable => new byte[] { 19, 20, 21, 22, 23 }; public static ReadOnlySpan<byte> Ver3GlassColorTable => new byte[] { 8, 14, 15, 16, 17, 18, 0 }; +#pragma warning restore IDE0055 } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/IImageDatabaseService.cs b/src/Ryujinx.HLE/HOS/Services/Mii/IImageDatabaseService.cs index 7d65c73f..0a763da1 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/IImageDatabaseService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/IImageDatabaseService.cs @@ -18,7 +18,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii bool useHardcodedData = context.RequestData.ReadBoolean(); _imageCount = 0; - _isDirty = false; + _isDirty = false; context.ResponseData.Write(_isDirty); @@ -38,4 +38,4 @@ namespace Ryujinx.HLE.HOS.Services.Mii return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/IStaticService.cs b/src/Ryujinx.HLE/HOS/Services/Mii/IStaticService.cs index a7fc71c9..acf358ee 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/IStaticService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/IStaticService.cs @@ -8,13 +8,13 @@ namespace Ryujinx.HLE.HOS.Services.Mii [Service("mii:u", false)] class IStaticService : IpcService { - private DatabaseImpl _databaseImpl; + private readonly DatabaseImpl _databaseImpl; - private bool _isSystem; + private readonly bool _isSystem; public IStaticService(ServiceCtx context, bool isSystem) { - _isSystem = isSystem; + _isSystem = isSystem; _databaseImpl = DatabaseImpl.Instance; } @@ -29,4 +29,4 @@ namespace Ryujinx.HLE.HOS.Services.Mii return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/MiiDatabaseManager.cs b/src/Ryujinx.HLE/HOS/Services/Mii/MiiDatabaseManager.cs index 682283b0..cb43ed2a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/MiiDatabaseManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/MiiDatabaseManager.cs @@ -11,17 +11,17 @@ namespace Ryujinx.HLE.HOS.Services.Mii { class MiiDatabaseManager { - private static bool IsTestModeEnabled = false; - private static uint MountCounter = 0; + private readonly bool _isTestModeEnabled = false; + private uint _mountCounter = 0; - private const ulong DatabaseTestSaveDataId = 0x8000000000000031; - private const ulong DatabaseSaveDataId = 0x8000000000000030; + private const ulong DatabaseTestSaveDataId = 0x8000000000000031; + private const ulong DatabaseSaveDataId = 0x8000000000000030; - private static U8String DatabasePath = new U8String("mii:/MiiDatabase.dat"); - private static U8String MountName = new U8String("mii"); + private readonly U8String _databasePath = new("mii:/MiiDatabase.dat"); + private readonly U8String _mountName = new("mii"); private NintendoFigurineDatabase _database; - private bool _isDirty; + private bool _isDirty; private HorizonClient _horizonClient; @@ -29,8 +29,8 @@ namespace Ryujinx.HLE.HOS.Services.Mii public MiiDatabaseManager() { - _database = new NintendoFigurineDatabase(); - _isDirty = false; + _database = new NintendoFigurineDatabase(); + _isDirty = false; UpdateCounter = 0; } @@ -106,50 +106,63 @@ namespace Ryujinx.HLE.HOS.Services.Mii private Result MountSave() { - if (MountCounter != 0) + if (_mountCounter != 0) { - MountCounter++; + _mountCounter++; return Result.Success; } - ulong saveDataId = IsTestModeEnabled ? DatabaseTestSaveDataId : DatabaseSaveDataId; + ulong saveDataId = _isTestModeEnabled ? DatabaseTestSaveDataId : DatabaseSaveDataId; - Result result = _horizonClient.Fs.MountSystemSaveData(MountName, SaveDataSpaceId.System, saveDataId); + Result result = _horizonClient.Fs.MountSystemSaveData(_mountName, SaveDataSpaceId.System, saveDataId); if (result.IsFailure()) { if (!ResultFs.TargetNotFound.Includes(result)) + { return result; + } - if (IsTestModeEnabled) + if (_isTestModeEnabled) +#pragma warning disable CS0162 { result = _horizonClient.Fs.CreateSystemSaveData(saveDataId, 0x10000, 0x10000, SaveDataFlags.KeepAfterResettingSystemSaveDataWithoutUserSaveData); - if (result.IsFailure()) return result; + if (result.IsFailure()) + { + return result; + } } +#pragma warning restore CS0162 else { result = _horizonClient.Fs.CreateSystemSaveData(saveDataId, SystemProgramId.Ns.Value, 0x10000, 0x10000, SaveDataFlags.KeepAfterResettingSystemSaveDataWithoutUserSaveData); - if (result.IsFailure()) return result; + if (result.IsFailure()) + { + return result; + } } - result = _horizonClient.Fs.MountSystemSaveData(MountName, SaveDataSpaceId.System, saveDataId); - if (result.IsFailure()) return result; + result = _horizonClient.Fs.MountSystemSaveData(_mountName, SaveDataSpaceId.System, saveDataId); + if (result.IsFailure()) + { + return result; + } } if (result == Result.Success) { - MountCounter++; + _mountCounter++; } return result; } public ResultCode DeleteFile() { - ResultCode result = (ResultCode)_horizonClient.Fs.DeleteFile(DatabasePath).Value; + ResultCode result = (ResultCode)_horizonClient.Fs.DeleteFile(_databasePath).Value; - _horizonClient.Fs.Commit(MountName); + _horizonClient.Fs.Commit(_mountName); return result; } @@ -158,7 +171,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii { isBroken = false; - if (MountCounter == 0) + if (_mountCounter == 0) { return ResultCode.InvalidArgument; } @@ -167,7 +180,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii ResetDatabase(); - Result result = _horizonClient.Fs.OpenFile(out FileHandle handle, DatabasePath, OpenMode.Read); + Result result = _horizonClient.Fs.OpenFile(out FileHandle handle, _databasePath, OpenMode.Read); if (result.IsSuccess()) { @@ -213,11 +226,11 @@ namespace Ryujinx.HLE.HOS.Services.Mii private Result ForceSaveDatabase() { - Result result = _horizonClient.Fs.CreateFile(DatabasePath, Unsafe.SizeOf<NintendoFigurineDatabase>()); + Result result = _horizonClient.Fs.CreateFile(_databasePath, Unsafe.SizeOf<NintendoFigurineDatabase>()); if (result.IsSuccess() || ResultFs.PathAlreadyExists.Includes(result)) { - result = _horizonClient.Fs.OpenFile(out FileHandle handle, DatabasePath, OpenMode.Write); + result = _horizonClient.Fs.OpenFile(out FileHandle handle, _databasePath, OpenMode.Write); if (result.IsSuccess()) { @@ -230,15 +243,15 @@ namespace Ryujinx.HLE.HOS.Services.Mii { _horizonClient.Fs.CloseFile(handle); - result = _horizonClient.Fs.DeleteFile(DatabasePath); + result = _horizonClient.Fs.DeleteFile(_databasePath); if (result.IsSuccess()) { - result = _horizonClient.Fs.CreateFile(DatabasePath, Unsafe.SizeOf<NintendoFigurineDatabase>()); + result = _horizonClient.Fs.CreateFile(_databasePath, Unsafe.SizeOf<NintendoFigurineDatabase>()); if (result.IsSuccess()) { - result = _horizonClient.Fs.OpenFile(out handle, DatabasePath, OpenMode.Write); + result = _horizonClient.Fs.OpenFile(out handle, _databasePath, OpenMode.Write); } } @@ -259,7 +272,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii { _isDirty = false; - result = _horizonClient.Fs.Commit(MountName); + result = _horizonClient.Fs.Commit(_mountName); } return result; diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Mii/ResultCode.cs index 4a4c0c23..8611d5af 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/ResultCode.cs @@ -2,29 +2,29 @@ { public enum ResultCode { - ModuleId = 126, + ModuleId = 126, ErrorCodeShift = 9, Success = 0, - InvalidArgument = (1 << ErrorCodeShift) | ModuleId, - BufferTooSmall = (2 << ErrorCodeShift) | ModuleId, - NotUpdated = (3 << ErrorCodeShift) | ModuleId, - NotFound = (4 << ErrorCodeShift) | ModuleId, - DatabaseFull = (5 << ErrorCodeShift) | ModuleId, - InvalidDatabaseSignatureValue = (67 << ErrorCodeShift) | ModuleId, - InvalidDatabaseEntryCount = (69 << ErrorCodeShift) | ModuleId, - InvalidCharInfo = (100 << ErrorCodeShift) | ModuleId, - InvalidCrc = (101 << ErrorCodeShift) | ModuleId, - InvalidDeviceCrc = (102 << ErrorCodeShift) | ModuleId, - InvalidDatabaseMagic = (103 << ErrorCodeShift) | ModuleId, - InvalidDatabaseVersion = (104 << ErrorCodeShift) | ModuleId, - InvalidDatabaseSize = (105 << ErrorCodeShift) | ModuleId, - InvalidCreateId = (106 << ErrorCodeShift) | ModuleId, - InvalidCoreData = (108 << ErrorCodeShift) | ModuleId, - InvalidStoreData = (109 << ErrorCodeShift) | ModuleId, - InvalidOperationOnSpecialMii = (202 << ErrorCodeShift) | ModuleId, - PermissionDenied = (203 << ErrorCodeShift) | ModuleId, - TestModeNotEnabled = (204 << ErrorCodeShift) | ModuleId + InvalidArgument = (1 << ErrorCodeShift) | ModuleId, + BufferTooSmall = (2 << ErrorCodeShift) | ModuleId, + NotUpdated = (3 << ErrorCodeShift) | ModuleId, + NotFound = (4 << ErrorCodeShift) | ModuleId, + DatabaseFull = (5 << ErrorCodeShift) | ModuleId, + InvalidDatabaseSignatureValue = (67 << ErrorCodeShift) | ModuleId, + InvalidDatabaseEntryCount = (69 << ErrorCodeShift) | ModuleId, + InvalidCharInfo = (100 << ErrorCodeShift) | ModuleId, + InvalidCrc = (101 << ErrorCodeShift) | ModuleId, + InvalidDeviceCrc = (102 << ErrorCodeShift) | ModuleId, + InvalidDatabaseMagic = (103 << ErrorCodeShift) | ModuleId, + InvalidDatabaseVersion = (104 << ErrorCodeShift) | ModuleId, + InvalidDatabaseSize = (105 << ErrorCodeShift) | ModuleId, + InvalidCreateId = (106 << ErrorCodeShift) | ModuleId, + InvalidCoreData = (108 << ErrorCodeShift) | ModuleId, + InvalidStoreData = (109 << ErrorCodeShift) | ModuleId, + InvalidOperationOnSpecialMii = (202 << ErrorCodeShift) | ModuleId, + PermissionDenied = (203 << ErrorCodeShift) | ModuleId, + TestModeNotEnabled = (204 << ErrorCodeShift) | ModuleId, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/StaticService/DatabaseServiceImpl.cs b/src/Ryujinx.HLE/HOS/Services/Mii/StaticService/DatabaseServiceImpl.cs index 4b5ed0d0..0d286e1c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/StaticService/DatabaseServiceImpl.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/StaticService/DatabaseServiceImpl.cs @@ -6,9 +6,9 @@ namespace Ryujinx.HLE.HOS.Services.Mii.StaticService { class DatabaseServiceImpl : IDatabaseService { - private DatabaseImpl _database; - private DatabaseSessionMetadata _metadata; - private bool _isSystem; + private readonly DatabaseImpl _database; + private readonly DatabaseSessionMetadata _metadata; + private readonly bool _isSystem; public DatabaseServiceImpl(DatabaseImpl database, bool isSystem, SpecialMiiKeyCode miiKeyCode) { diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/StaticService/IDatabaseService.cs b/src/Ryujinx.HLE/HOS/Services/Mii/StaticService/IDatabaseService.cs index e95364be..051921f5 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/StaticService/IDatabaseService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/StaticService/IDatabaseService.cs @@ -51,7 +51,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.StaticService ResultCode result = Get(flag, out int count, elementsSpan); - elementsSpan = elementsSpan.Slice(0, count); + elementsSpan = elementsSpan[..count]; context.ResponseData.Write(count); @@ -72,7 +72,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.StaticService ResultCode result = Get1(flag, out int count, elementsSpan); - elementsSpan = elementsSpan.Slice(0, count); + elementsSpan = elementsSpan[..count]; context.ResponseData.Write(count); @@ -85,8 +85,8 @@ namespace Ryujinx.HLE.HOS.Services.Mii.StaticService // UpdateLatest(nn::mii::CharInfo old_char_info, SourceFlag flag) -> nn::mii::CharInfo public ResultCode UpdateLatest(ServiceCtx context) { - CharInfo oldCharInfo = context.RequestData.ReadStruct<CharInfo>(); - SourceFlag flag = (SourceFlag)context.RequestData.ReadInt32(); + CharInfo oldCharInfo = context.RequestData.ReadStruct<CharInfo>(); + SourceFlag flag = (SourceFlag)context.RequestData.ReadInt32(); ResultCode result = UpdateLatest(oldCharInfo, flag, out CharInfo newCharInfo); @@ -99,9 +99,9 @@ namespace Ryujinx.HLE.HOS.Services.Mii.StaticService // BuildRandom(Age age, Gender gender, Race race) -> nn::mii::CharInfo public ResultCode BuildRandom(ServiceCtx context) { - Age age = (Age)context.RequestData.ReadInt32(); + Age age = (Age)context.RequestData.ReadInt32(); Gender gender = (Gender)context.RequestData.ReadInt32(); - Race race = (Race)context.RequestData.ReadInt32(); + Race race = (Race)context.RequestData.ReadInt32(); ResultCode result = BuildRandom(age, gender, race, out CharInfo charInfo); @@ -135,7 +135,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.StaticService ResultCode result = Get2(flag, out int count, elementsSpan); - elementsSpan = elementsSpan.Slice(0, count); + elementsSpan = elementsSpan[..count]; context.ResponseData.Write(count); @@ -156,7 +156,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.StaticService ResultCode result = Get3(flag, out int count, elementsSpan); - elementsSpan = elementsSpan.Slice(0, count); + elementsSpan = elementsSpan[..count]; context.ResponseData.Write(count); @@ -169,8 +169,8 @@ namespace Ryujinx.HLE.HOS.Services.Mii.StaticService // UpdateLatest1(nn::mii::StoreData old_store_data, SourceFlag flag) -> nn::mii::StoreData public ResultCode UpdateLatest1(ServiceCtx context) { - StoreData oldStoreData = context.RequestData.ReadStruct<StoreData>(); - SourceFlag flag = (SourceFlag)context.RequestData.ReadInt32(); + StoreData oldStoreData = context.RequestData.ReadStruct<StoreData>(); + SourceFlag flag = (SourceFlag)context.RequestData.ReadInt32(); ResultCode result = UpdateLatest1(oldStoreData, flag, out StoreData newStoreData); @@ -183,8 +183,8 @@ namespace Ryujinx.HLE.HOS.Services.Mii.StaticService // FindIndex(nn::mii::CreateId create_id, bool is_special) -> s32 public ResultCode FindIndex(ServiceCtx context) { - CreateId createId = context.RequestData.ReadStruct<CreateId>(); - bool isSpecial = context.RequestData.ReadBoolean(); + CreateId createId = context.RequestData.ReadStruct<CreateId>(); + bool isSpecial = context.RequestData.ReadBoolean(); ResultCode result = FindIndex(createId, isSpecial, out int index); @@ -198,7 +198,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.StaticService public ResultCode Move(ServiceCtx context) { CreateId createId = context.RequestData.ReadStruct<CreateId>(); - int newIndex = context.RequestData.ReadInt32(); + int newIndex = context.RequestData.ReadInt32(); return Move(createId, newIndex); } @@ -358,12 +358,12 @@ namespace Ryujinx.HLE.HOS.Services.Mii.StaticService return new Span<byte>(rawData); } - private Span<T> CreateSpanFromBuffer<T>(ServiceCtx context, IpcBuffDesc ipcBuff, bool isOutput) where T: unmanaged + private Span<T> CreateSpanFromBuffer<T>(ServiceCtx context, IpcBuffDesc ipcBuff, bool isOutput) where T : unmanaged { return MemoryMarshal.Cast<byte, T>(CreateByteSpanFromBuffer(context, ipcBuff, isOutput)); } - private void WriteSpanToBuffer<T>(ServiceCtx context, IpcBuffDesc ipcBuff, Span<T> span) where T: unmanaged + private void WriteSpanToBuffer<T>(ServiceCtx context, IpcBuffDesc ipcBuff, Span<T> span) where T : unmanaged { Span<byte> rawData = MemoryMarshal.Cast<T, byte>(span); diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/Age.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/Age.cs index 7beb6ec0..a443ad09 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/Age.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/Age.cs @@ -5,6 +5,6 @@ Young, Normal, Old, - All + All, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/BeardType.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/BeardType.cs index a028b9be..85fda671 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/BeardType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/BeardType.cs @@ -9,7 +9,7 @@ LionsMane, Full, - Min = 0, - Max = 5 + Min = None, + Max = Full, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/CharInfo.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/CharInfo.cs index 256ec9e0..14b61687 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/CharInfo.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/CharInfo.cs @@ -59,11 +59,11 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types public byte MoleY; public byte Reserved; - byte IStoredData<CharInfo>.Type => Type; + readonly byte IStoredData<CharInfo>.Type => Type; - CreateId IStoredData<CharInfo>.CreateId => CreateId; + readonly CreateId IStoredData<CharInfo>.CreateId => CreateId; - public ResultCode InvalidData => ResultCode.InvalidCharInfo; + public readonly ResultCode InvalidData => ResultCode.InvalidCharInfo; public bool IsValid() { @@ -72,118 +72,271 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types public uint Verify() { - if (!CreateId.IsValid) return 50; - if (!Nickname.IsValid()) return 51; - if ((byte)FontRegion > 3) return 23; - if (FavoriteColor > 11) return 22; - if (Gender > Gender.Max) return 24; - if ((sbyte)Height < 0) return 32; - if ((sbyte)Build < 0) return 3; - if (Type > 1) return 53; - if (RegionMove > 3) return 49; - if (FacelineType > FacelineType.Max) return 21; - if (FacelineColor > FacelineColor.Max) return 18; - if (FacelineWrinkle > FacelineWrinkle.Max) return 20; - if (FacelineMake > FacelineMake.Max) return 19; - if (HairType > HairType.Max) return 31; - if (HairColor > CommonColor.Max) return 29; - if (HairFlip > HairFlip.Max) return 30; - if (EyeType > EyeType.Max) return 8; - if (EyeColor > CommonColor.Max) return 5; - if (EyeScale > 7) return 7; - if (EyeAspect > 6) return 4; - if (EyeRotate > 7) return 6; - if (EyeX > 12) return 9; - if (EyeY > 18) return 10; - if (EyebrowType > EyebrowType.Max) return 15; - if (EyebrowColor > CommonColor.Max) return 12; - if (EyebrowScale > 8) return 14; - if (EyebrowAspect > 6) return 11; - if (EyebrowRotate > 11) return 13; - if (EyebrowX > 12) return 16; - if (EyebrowY - 3 > 15) return 17; - if (NoseType > NoseType.Max) return 47; - if (NoseScale > 8) return 46; - if (NoseY> 18) return 48; - if (MouthType > MouthType.Max) return 40; - if (MouthColor > CommonColor.Max) return 38; - if (MouthScale > 8) return 39; - if (MouthAspect > 6) return 37; - if (MouthY > 18) return 41; - if (BeardColor > CommonColor.Max) return 1; - if (BeardType > BeardType.Max) return 2; - if (MustacheType > MustacheType.Max) return 43; - if (MustacheScale > 8) return 42; - if (MustacheY > 16) return 44; - if (GlassType > GlassType.Max) return 27; - if (GlassColor > CommonColor.Max) return 25; - if (GlassScale > 7) return 26; - if (GlassY > 20) return 28; - if (MoleType > MoleType.Max) return 34; - if (MoleScale > 8) return 33; - if (MoleX > 16) return 35; - if (MoleY >= 31) return 36; + if (!CreateId.IsValid) + { + return 50; + } + if (!Nickname.IsValid()) + { + return 51; + } + if ((byte)FontRegion > 3) + { + return 23; + } + if (FavoriteColor > 11) + { + return 22; + } + if (Gender > Gender.Max) + { + return 24; + } + if ((sbyte)Height < 0) + { + return 32; + } + if ((sbyte)Build < 0) + { + return 3; + } + if (Type > 1) + { + return 53; + } + if (RegionMove > 3) + { + return 49; + } + if (FacelineType > FacelineType.Max) + { + return 21; + } + if (FacelineColor > FacelineColor.Max) + { + return 18; + } + if (FacelineWrinkle > FacelineWrinkle.Max) + { + return 20; + } + if (FacelineMake > FacelineMake.Max) + { + return 19; + } + if (HairType > HairType.Max) + { + return 31; + } + if (HairColor > CommonColor.Max) + { + return 29; + } + if (HairFlip > HairFlip.Max) + { + return 30; + } + if (EyeType > EyeType.Max) + { + return 8; + } + if (EyeColor > CommonColor.Max) + { + return 5; + } + if (EyeScale > 7) + { + return 7; + } + if (EyeAspect > 6) + { + return 4; + } + if (EyeRotate > 7) + { + return 6; + } + if (EyeX > 12) + { + return 9; + } + if (EyeY > 18) + { + return 10; + } + if (EyebrowType > EyebrowType.Max) + { + return 15; + } + if (EyebrowColor > CommonColor.Max) + { + return 12; + } + if (EyebrowScale > 8) + { + return 14; + } + if (EyebrowAspect > 6) + { + return 11; + } + if (EyebrowRotate > 11) + { + return 13; + } + if (EyebrowX > 12) + { + return 16; + } + if (EyebrowY - 3 > 15) + { + return 17; + } + if (NoseType > NoseType.Max) + { + return 47; + } + if (NoseScale > 8) + { + return 46; + } + if (NoseY > 18) + { + return 48; + } + if (MouthType > MouthType.Max) + { + return 40; + } + if (MouthColor > CommonColor.Max) + { + return 38; + } + if (MouthScale > 8) + { + return 39; + } + if (MouthAspect > 6) + { + return 37; + } + if (MouthY > 18) + { + return 41; + } + if (BeardColor > CommonColor.Max) + { + return 1; + } + if (BeardType > BeardType.Max) + { + return 2; + } + if (MustacheType > MustacheType.Max) + { + return 43; + } + if (MustacheScale > 8) + { + return 42; + } + if (MustacheY > 16) + { + return 44; + } + if (GlassType > GlassType.Max) + { + return 27; + } + if (GlassColor > CommonColor.Max) + { + return 25; + } + if (GlassScale > 7) + { + return 26; + } + if (GlassY > 20) + { + return 28; + } + if (MoleType > MoleType.Max) + { + return 34; + } + if (MoleScale > 8) + { + return 33; + } + if (MoleX > 16) + { + return 35; + } + if (MoleY >= 31) + { + return 36; + } return 0; } public void SetFromStoreData(StoreData storeData) { - Nickname = storeData.CoreData.Nickname; - CreateId = storeData.CreateId; - FontRegion = storeData.CoreData.FontRegion; - FavoriteColor = storeData.CoreData.FavoriteColor; - Gender = storeData.CoreData.Gender; - Height = storeData.CoreData.Height; - Build = storeData.CoreData.Build; - Type = storeData.CoreData.Type; - RegionMove = storeData.CoreData.RegionMove; - FacelineType = storeData.CoreData.FacelineType; - FacelineColor = storeData.CoreData.FacelineColor; + Nickname = storeData.CoreData.Nickname; + CreateId = storeData.CreateId; + FontRegion = storeData.CoreData.FontRegion; + FavoriteColor = storeData.CoreData.FavoriteColor; + Gender = storeData.CoreData.Gender; + Height = storeData.CoreData.Height; + Build = storeData.CoreData.Build; + Type = storeData.CoreData.Type; + RegionMove = storeData.CoreData.RegionMove; + FacelineType = storeData.CoreData.FacelineType; + FacelineColor = storeData.CoreData.FacelineColor; FacelineWrinkle = storeData.CoreData.FacelineWrinkle; - FacelineMake = storeData.CoreData.FacelineMake; - HairType = storeData.CoreData.HairType; - HairColor = storeData.CoreData.HairColor; - HairFlip = storeData.CoreData.HairFlip; - EyeType = storeData.CoreData.EyeType; - EyeColor = storeData.CoreData.EyeColor; - EyeScale = storeData.CoreData.EyeScale; - EyeAspect = storeData.CoreData.EyeAspect; - EyeRotate = storeData.CoreData.EyeRotate; - EyeX = storeData.CoreData.EyeX; - EyeY = storeData.CoreData.EyeY; - EyebrowType = storeData.CoreData.EyebrowType; - EyebrowColor = storeData.CoreData.EyebrowColor; - EyebrowScale = storeData.CoreData.EyebrowScale; - EyebrowAspect = storeData.CoreData.EyebrowAspect; - EyebrowRotate = storeData.CoreData.EyebrowRotate; - EyebrowX = storeData.CoreData.EyebrowX; - EyebrowY = storeData.CoreData.EyebrowY; - NoseType = storeData.CoreData.NoseType; - NoseScale = storeData.CoreData.NoseScale; - NoseY = storeData.CoreData.NoseY; - MouthType = storeData.CoreData.MouthType; - MouthColor = storeData.CoreData.MouthColor; - MouthScale = storeData.CoreData.MouthScale; - MouthAspect = storeData.CoreData.MouthAspect; - MouthY = storeData.CoreData.MouthY; - BeardColor = storeData.CoreData.BeardColor; - BeardType = storeData.CoreData.BeardType; - MustacheType = storeData.CoreData.MustacheType; - MustacheScale = storeData.CoreData.MustacheScale; - MustacheY = storeData.CoreData.MustacheY; - GlassType = storeData.CoreData.GlassType; - GlassColor = storeData.CoreData.GlassColor; - GlassScale = storeData.CoreData.GlassScale; - GlassY = storeData.CoreData.GlassY; - MoleType = storeData.CoreData.MoleType; - MoleScale = storeData.CoreData.MoleScale; - MoleX = storeData.CoreData.MoleX; - MoleY = storeData.CoreData.MoleY; - Reserved = 0; + FacelineMake = storeData.CoreData.FacelineMake; + HairType = storeData.CoreData.HairType; + HairColor = storeData.CoreData.HairColor; + HairFlip = storeData.CoreData.HairFlip; + EyeType = storeData.CoreData.EyeType; + EyeColor = storeData.CoreData.EyeColor; + EyeScale = storeData.CoreData.EyeScale; + EyeAspect = storeData.CoreData.EyeAspect; + EyeRotate = storeData.CoreData.EyeRotate; + EyeX = storeData.CoreData.EyeX; + EyeY = storeData.CoreData.EyeY; + EyebrowType = storeData.CoreData.EyebrowType; + EyebrowColor = storeData.CoreData.EyebrowColor; + EyebrowScale = storeData.CoreData.EyebrowScale; + EyebrowAspect = storeData.CoreData.EyebrowAspect; + EyebrowRotate = storeData.CoreData.EyebrowRotate; + EyebrowX = storeData.CoreData.EyebrowX; + EyebrowY = storeData.CoreData.EyebrowY; + NoseType = storeData.CoreData.NoseType; + NoseScale = storeData.CoreData.NoseScale; + NoseY = storeData.CoreData.NoseY; + MouthType = storeData.CoreData.MouthType; + MouthColor = storeData.CoreData.MouthColor; + MouthScale = storeData.CoreData.MouthScale; + MouthAspect = storeData.CoreData.MouthAspect; + MouthY = storeData.CoreData.MouthY; + BeardColor = storeData.CoreData.BeardColor; + BeardType = storeData.CoreData.BeardType; + MustacheType = storeData.CoreData.MustacheType; + MustacheScale = storeData.CoreData.MustacheScale; + MustacheY = storeData.CoreData.MustacheY; + GlassType = storeData.CoreData.GlassType; + GlassColor = storeData.CoreData.GlassColor; + GlassScale = storeData.CoreData.GlassScale; + GlassY = storeData.CoreData.GlassY; + MoleType = storeData.CoreData.MoleType; + MoleScale = storeData.CoreData.MoleScale; + MoleX = storeData.CoreData.MoleX; + MoleY = storeData.CoreData.MoleY; + Reserved = 0; } - public void SetSource(Source source) + public readonly void SetSource(Source source) { // Only implemented for Element variants. } @@ -198,12 +351,12 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types return !x.Equals(y); } - public override bool Equals(object obj) + public readonly override bool Equals(object obj) { return obj is CharInfo charInfo && Equals(charInfo); } - public bool Equals(CharInfo cmpObj) + public readonly bool Equals(CharInfo cmpObj) { if (!cmpObj.IsValid()) { @@ -267,9 +420,9 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types return result; } - public override int GetHashCode() + public readonly override int GetHashCode() { - HashCode hashCode = new HashCode(); + HashCode hashCode = new(); hashCode.Add(Nickname); hashCode.Add(CreateId); diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/CharInfoElement.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/CharInfoElement.cs index f1f850fd..fead4861 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/CharInfoElement.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/CharInfoElement.cs @@ -6,7 +6,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types struct CharInfoElement : IElement { public CharInfo CharInfo; - public Source Source; + public Source Source; public void SetFromStoreData(StoreData storeData) { diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/CommonColor.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/CommonColor.cs index 8b613850..3f61232c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/CommonColor.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/CommonColor.cs @@ -4,6 +4,6 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types enum CommonColor : byte { Min = 0, - Max = 99 + Max = 99, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/CoreData.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/CoreData.cs index abf18e36..00e49ecb 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/CoreData.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/CoreData.cs @@ -73,7 +73,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types public void SetDefault() { - Storage.Fill(0); + Storage.Clear(); Nickname = Nickname.Default; } @@ -374,18 +374,18 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types public Span<byte> GetNicknameStorage() { - return Storage.Slice(0x1c); + return Storage[0x1c..]; } public Nickname Nickname { get => Nickname.FromBytes(GetNicknameStorage()); - set => value.Raw.Slice(0, 20).CopyTo(GetNicknameStorage()); + set => value.Raw[..20].CopyTo(GetNicknameStorage()); } public static CoreData BuildRandom(UtilityImpl utilImpl, Age age, Gender gender, Race race) { - CoreData coreData = new CoreData(); + CoreData coreData = new(); coreData.SetDefault(); @@ -439,29 +439,29 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types int indexFor4 = 3 * (int)age + 9 * (int)gender + (int)race; - var facelineTypeInfo = RandomMiiFacelineArray[indexFor4]; - var facelineColorInfo = RandomMiiFacelineColorArray[3 * (int)gender + (int)race]; + var facelineTypeInfo = RandomMiiFacelineArray[indexFor4]; + var facelineColorInfo = RandomMiiFacelineColorArray[3 * (int)gender + (int)race]; var facelineWrinkleInfo = RandomMiiFacelineWrinkleArray[indexFor4]; - var facelineMakeInfo = RandomMiiFacelineMakeArray[indexFor4]; - var hairTypeInfo = RandomMiiHairTypeArray[indexFor4]; - var hairColorInfo = RandomMiiHairColorArray[3 * (int)race + (int)age]; - var eyeTypeInfo = RandomMiiEyeTypeArray[indexFor4]; - var eyeColorInfo = RandomMiiEyeColorArray[(int)race]; - var eyebrowTypeInfo = RandomMiiEyebrowTypeArray[indexFor4]; - var noseTypeInfo = RandomMiiNoseTypeArray[indexFor4]; - var mouthTypeInfo = RandomMiiMouthTypeArray[indexFor4]; - var glassTypeInfo = RandomMiiGlassTypeArray[(int)age]; + var facelineMakeInfo = RandomMiiFacelineMakeArray[indexFor4]; + var hairTypeInfo = RandomMiiHairTypeArray[indexFor4]; + var hairColorInfo = RandomMiiHairColorArray[3 * (int)race + (int)age]; + var eyeTypeInfo = RandomMiiEyeTypeArray[indexFor4]; + var eyeColorInfo = RandomMiiEyeColorArray[(int)race]; + var eyebrowTypeInfo = RandomMiiEyebrowTypeArray[indexFor4]; + var noseTypeInfo = RandomMiiNoseTypeArray[indexFor4]; + var mouthTypeInfo = RandomMiiMouthTypeArray[indexFor4]; + var glassTypeInfo = RandomMiiGlassTypeArray[(int)age]; // Faceline - coreData.FacelineType = (FacelineType)facelineTypeInfo.Values[utilImpl.GetRandom(facelineTypeInfo.ValuesCount)]; - coreData.FacelineColor = (FacelineColor)Helper.Ver3FacelineColorTable[facelineColorInfo.Values[utilImpl.GetRandom(facelineColorInfo.ValuesCount)]]; + coreData.FacelineType = (FacelineType)facelineTypeInfo.Values[utilImpl.GetRandom(facelineTypeInfo.ValuesCount)]; + coreData.FacelineColor = (FacelineColor)Helper.Ver3FacelineColorTable[facelineColorInfo.Values[utilImpl.GetRandom(facelineColorInfo.ValuesCount)]]; coreData.FacelineWrinkle = (FacelineWrinkle)facelineWrinkleInfo.Values[utilImpl.GetRandom(facelineWrinkleInfo.ValuesCount)]; - coreData.FacelineMake = (FacelineMake)facelineMakeInfo.Values[utilImpl.GetRandom(facelineMakeInfo.ValuesCount)]; + coreData.FacelineMake = (FacelineMake)facelineMakeInfo.Values[utilImpl.GetRandom(facelineMakeInfo.ValuesCount)]; // Hair - coreData.HairType = (HairType)hairTypeInfo.Values[utilImpl.GetRandom(hairTypeInfo.ValuesCount)]; + coreData.HairType = (HairType)hairTypeInfo.Values[utilImpl.GetRandom(hairTypeInfo.ValuesCount)]; coreData.HairColor = (CommonColor)Helper.Ver3HairColorTable[hairColorInfo.Values[utilImpl.GetRandom(hairColorInfo.ValuesCount)]]; - coreData.HairFlip = (HairFlip)utilImpl.GetRandom((int)HairFlip.Max + 1); + coreData.HairFlip = (HairFlip)utilImpl.GetRandom((int)HairFlip.Max + 1); // Eye coreData.EyeType = (EyeType)eyeTypeInfo.Values[utilImpl.GetRandom(eyeTypeInfo.ValuesCount)]; @@ -470,56 +470,56 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types int eyeRotateKey2 = gender != Gender.Male ? 3 : 4; byte eyeRotateOffset = (byte)(32 - EyeRotateTable[eyeRotateKey1] + eyeRotateKey2); - byte eyeRotate = (byte)(32 - EyeRotateTable[(int)coreData.EyeType]); + byte eyeRotate = (byte)(32 - EyeRotateTable[(int)coreData.EyeType]); - coreData.EyeColor = (CommonColor)Helper.Ver3EyeColorTable[eyeColorInfo.Values[utilImpl.GetRandom(eyeColorInfo.ValuesCount)]]; - coreData.EyeScale = 4; + coreData.EyeColor = (CommonColor)Helper.Ver3EyeColorTable[eyeColorInfo.Values[utilImpl.GetRandom(eyeColorInfo.ValuesCount)]]; + coreData.EyeScale = 4; coreData.EyeAspect = 3; coreData.EyeRotate = (byte)(eyeRotateOffset - eyeRotate); - coreData.EyeX = 2; - coreData.EyeY = (byte)(axisY + 12); + coreData.EyeX = 2; + coreData.EyeY = (byte)(axisY + 12); // Eyebrow coreData.EyebrowType = (EyebrowType)eyebrowTypeInfo.Values[utilImpl.GetRandom(eyebrowTypeInfo.ValuesCount)]; int eyebrowRotateKey = race == Race.Asian ? 6 : 0; - int eyebrowY = race == Race.Asian ? 9 : 10; + int eyebrowY = race == Race.Asian ? 9 : 10; byte eyebrowRotateOffset = (byte)(32 - EyebrowRotateTable[eyebrowRotateKey] + 6); - byte eyebrowRotate = (byte)(32 - EyebrowRotateTable[(int)coreData.EyebrowType]); + byte eyebrowRotate = (byte)(32 - EyebrowRotateTable[(int)coreData.EyebrowType]); - coreData.EyebrowColor = coreData.HairColor; - coreData.EyebrowScale = 4; + coreData.EyebrowColor = coreData.HairColor; + coreData.EyebrowScale = 4; coreData.EyebrowAspect = 3; coreData.EyebrowRotate = (byte)(eyebrowRotateOffset - eyebrowRotate); - coreData.EyebrowX = 2; - coreData.EyebrowY = (byte)(axisY + eyebrowY); + coreData.EyebrowX = 2; + coreData.EyebrowY = (byte)(axisY + eyebrowY); // Nose int noseScale = gender == Gender.Female ? 3 : 4; - coreData.NoseType = (NoseType)noseTypeInfo.Values[utilImpl.GetRandom(noseTypeInfo.ValuesCount)]; + coreData.NoseType = (NoseType)noseTypeInfo.Values[utilImpl.GetRandom(noseTypeInfo.ValuesCount)]; coreData.NoseScale = (byte)noseScale; - coreData.NoseY = (byte)(axisY + 9); + coreData.NoseY = (byte)(axisY + 9); // Mouth int mouthColor = gender == Gender.Female ? utilImpl.GetRandom(0, 4) : 0; - coreData.MouthType = (MouthType)mouthTypeInfo.Values[utilImpl.GetRandom(mouthTypeInfo.ValuesCount)]; - coreData.MouthColor = (CommonColor)Helper.Ver3MouthColorTable[mouthColor]; - coreData.MouthScale = 4; + coreData.MouthType = (MouthType)mouthTypeInfo.Values[utilImpl.GetRandom(mouthTypeInfo.ValuesCount)]; + coreData.MouthColor = (CommonColor)Helper.Ver3MouthColorTable[mouthColor]; + coreData.MouthScale = 4; coreData.MouthAspect = 3; - coreData.MouthY = (byte)(axisY + 13); + coreData.MouthY = (byte)(axisY + 13); // Beard & Mustache - coreData.BeardColor = coreData.HairColor; + coreData.BeardColor = coreData.HairColor; coreData.MustacheScale = 4; if (gender == Gender.Male && age != Age.Young && utilImpl.GetRandom(10) < 2) { BeardAndMustacheFlag mustacheAndBeardFlag = (BeardAndMustacheFlag)utilImpl.GetRandom(3); - BeardType beardType = BeardType.None; + BeardType beardType = BeardType.None; MustacheType mustacheType = MustacheType.None; if ((mustacheAndBeardFlag & BeardAndMustacheFlag.Beard) == BeardAndMustacheFlag.Beard) @@ -533,14 +533,14 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types } coreData.MustacheType = mustacheType; - coreData.BeardType = beardType; - coreData.MustacheY = 10; + coreData.BeardType = beardType; + coreData.MustacheY = 10; } else { coreData.MustacheType = MustacheType.None; - coreData.BeardType = BeardType.None; - coreData.MustacheY = (byte)(axisY + 10); + coreData.BeardType = BeardType.None; + coreData.MustacheY = (byte)(axisY + 10); } // Glass @@ -557,84 +557,84 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types } } - coreData.GlassType = glassType; + coreData.GlassType = glassType; coreData.GlassColor = (CommonColor)Helper.Ver3GlassColorTable[0]; coreData.GlassScale = 4; - coreData.GlassY = (byte)(axisY + 10); + coreData.GlassY = (byte)(axisY + 10); // Mole - coreData.MoleType = 0; + coreData.MoleType = 0; coreData.MoleScale = 4; - coreData.MoleX = 2; - coreData.MoleY = 20; + coreData.MoleX = 2; + coreData.MoleY = 20; // Body sizing coreData.Height = 64; - coreData.Build = 64; + coreData.Build = 64; // Misc - coreData.Nickname = Nickname.Default; - coreData.Gender = gender; + coreData.Nickname = Nickname.Default; + coreData.Gender = gender; coreData.FavoriteColor = (byte)utilImpl.GetRandom(0, 11); - coreData.RegionMove = 0; - coreData.FontRegion = 0; - coreData.Type = 0; + coreData.RegionMove = 0; + coreData.FontRegion = 0; + coreData.Type = 0; return coreData; } public void SetFromCharInfo(CharInfo charInfo) { - Nickname = charInfo.Nickname; - FontRegion = charInfo.FontRegion; - FavoriteColor = charInfo.FavoriteColor; - Gender = charInfo.Gender; - Height = charInfo.Height; - Build = charInfo.Build; - Type = charInfo.Type; - RegionMove = charInfo.RegionMove; - FacelineType = charInfo.FacelineType; - FacelineColor = charInfo.FacelineColor; + Nickname = charInfo.Nickname; + FontRegion = charInfo.FontRegion; + FavoriteColor = charInfo.FavoriteColor; + Gender = charInfo.Gender; + Height = charInfo.Height; + Build = charInfo.Build; + Type = charInfo.Type; + RegionMove = charInfo.RegionMove; + FacelineType = charInfo.FacelineType; + FacelineColor = charInfo.FacelineColor; FacelineWrinkle = charInfo.FacelineWrinkle; - FacelineMake = charInfo.FacelineMake; - HairType = charInfo.HairType; - HairColor = charInfo.HairColor; - HairFlip = charInfo.HairFlip; - EyeType = charInfo.EyeType; - EyeColor = charInfo.EyeColor; - EyeScale = charInfo.EyeScale; - EyeAspect = charInfo.EyeAspect; - EyeRotate = charInfo.EyeRotate; - EyeX = charInfo.EyeX; - EyeY = charInfo.EyeY; - EyebrowType = charInfo.EyebrowType; - EyebrowColor = charInfo.EyebrowColor; - EyebrowScale = charInfo.EyebrowScale; - EyebrowAspect = charInfo.EyebrowAspect; - EyebrowRotate = charInfo.EyebrowRotate; - EyebrowX = charInfo.EyebrowX; - EyebrowY = charInfo.EyebrowY; - NoseType = charInfo.NoseType; - NoseScale = charInfo.NoseScale; - NoseY = charInfo.NoseY; - MouthType = charInfo.MouthType; - MouthColor = charInfo.MouthColor; - MouthScale = charInfo.MouthScale; - MouthAspect = charInfo.MouthAspect; - MouthY = charInfo.MouthY; - BeardColor = charInfo.BeardColor; - BeardType = charInfo.BeardType; - MustacheType = charInfo.MustacheType; - MustacheScale = charInfo.MustacheScale; - MustacheY = charInfo.MustacheY; - GlassType = charInfo.GlassType; - GlassColor = charInfo.GlassColor; - GlassScale = charInfo.GlassScale; - GlassY = charInfo.GlassY; - MoleType = charInfo.MoleType; - MoleScale = charInfo.MoleScale; - MoleX = charInfo.MoleX; - MoleY = charInfo.MoleY; + FacelineMake = charInfo.FacelineMake; + HairType = charInfo.HairType; + HairColor = charInfo.HairColor; + HairFlip = charInfo.HairFlip; + EyeType = charInfo.EyeType; + EyeColor = charInfo.EyeColor; + EyeScale = charInfo.EyeScale; + EyeAspect = charInfo.EyeAspect; + EyeRotate = charInfo.EyeRotate; + EyeX = charInfo.EyeX; + EyeY = charInfo.EyeY; + EyebrowType = charInfo.EyebrowType; + EyebrowColor = charInfo.EyebrowColor; + EyebrowScale = charInfo.EyebrowScale; + EyebrowAspect = charInfo.EyebrowAspect; + EyebrowRotate = charInfo.EyebrowRotate; + EyebrowX = charInfo.EyebrowX; + EyebrowY = charInfo.EyebrowY; + NoseType = charInfo.NoseType; + NoseScale = charInfo.NoseScale; + NoseY = charInfo.NoseY; + MouthType = charInfo.MouthType; + MouthColor = charInfo.MouthColor; + MouthScale = charInfo.MouthScale; + MouthAspect = charInfo.MouthAspect; + MouthY = charInfo.MouthY; + BeardColor = charInfo.BeardColor; + BeardType = charInfo.BeardType; + MustacheType = charInfo.MustacheType; + MustacheScale = charInfo.MustacheScale; + MustacheY = charInfo.MustacheY; + GlassType = charInfo.GlassType; + GlassColor = charInfo.GlassColor; + GlassScale = charInfo.GlassScale; + GlassY = charInfo.GlassY; + MoleType = charInfo.MoleType; + MoleScale = charInfo.MoleScale; + MoleX = charInfo.MoleX; + MoleY = charInfo.MoleY; } public static bool operator ==(CoreData x, CoreData y) @@ -717,7 +717,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types public override int GetHashCode() { - HashCode hashCode = new HashCode(); + HashCode hashCode = new(); hashCode.Add(Nickname); hashCode.Add(FontRegion); @@ -773,7 +773,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types return hashCode.ToHashCode(); } - private static ReadOnlySpan<ElementInfo> ElementInfos => MemoryMarshal.Cast<byte, ElementInfo>(ElementInfoArray); + private readonly ReadOnlySpan<ElementInfo> ElementInfos => MemoryMarshal.Cast<byte, ElementInfo>(ElementInfoArray); private enum ElementInfoIndex { @@ -825,11 +825,11 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types NoseScale, MouthScale, MustacheScale, - MoleScale + MoleScale, } #region "Element Info Array" - private static ReadOnlySpan<byte> ElementInfoArray => new byte[] + private readonly ReadOnlySpan<byte> ElementInfoArray => new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -904,7 +904,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 + 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, }; #endregion } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/CreateId.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/CreateId.cs index 283d82fc..f61e83d7 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/CreateId.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/CreateId.cs @@ -4,12 +4,12 @@ using System.Runtime.InteropServices; namespace Ryujinx.HLE.HOS.Services.Mii.Types { [StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0x10)] - struct CreateId : IEquatable<CreateId> + readonly struct CreateId : IEquatable<CreateId> { public readonly UInt128 Raw; - public bool IsNull => Raw == UInt128.Zero; - public bool IsValid => !IsNull && ((Raw >> 64) & 0xC0) == 0x80; + public readonly bool IsNull => Raw == UInt128.Zero; + public readonly bool IsValid => !IsNull && ((Raw >> 64) & 0xC0) == 0x80; public CreateId(UInt128 raw) { @@ -26,18 +26,18 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types return !x.Equals(y); } - public override bool Equals(object obj) + public readonly override bool Equals(object obj) { return obj is CreateId createId && Equals(createId); } - public bool Equals(CreateId cmpObj) + public readonly bool Equals(CreateId cmpObj) { // Nintendo additionally check that the CreatorId is valid before doing the actual comparison. return IsValid && Raw == cmpObj.Raw; } - public override int GetHashCode() + public readonly override int GetHashCode() { return Raw.GetHashCode(); } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/DefaultMii.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/DefaultMii.cs index 285a9242..e3c6a42e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/DefaultMii.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/DefaultMii.cs @@ -65,7 +65,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types public Nickname Nickname { get => Nickname.FromBytes(NicknameStorage); - set => value.Raw.Slice(0, 20).CopyTo(NicknameStorage); + set => value.Raw[..20].CopyTo(NicknameStorage); } public static ReadOnlySpan<DefaultMii> Table => MemoryMarshal.Cast<byte, DefaultMii>(TableRawArray); @@ -73,7 +73,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types // The first 2 Mii in the default table are used as base for Male/Female in editor but not exposed via IPC. public static int TableLength => _fromIndex.Length; - private static readonly int[] _fromIndex = new int[] { 2, 3, 4, 5, 6, 7 }; + private static readonly int[] _fromIndex = { 2, 3, 4, 5, 6, 7 }; public static DefaultMii GetDefaultMii(uint index) { @@ -190,7 +190,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6e, 0x00, 0x6f, 0x00, - 0x20, 0x00, 0x6e, 0x00, 0x61, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + 0x20, 0x00, 0x6e, 0x00, 0x61, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; #endregion } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/EyeType.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/EyeType.cs index 2e4502ed..70b6e31c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/EyeType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/EyeType.cs @@ -63,7 +63,7 @@ RoundTired, WhiteLarge, - Min = 0, - Max = 59 + Min = Normal, + Max = WhiteLarge, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/EyebrowType.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/EyebrowType.cs index af870e10..3790128a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/EyebrowType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/EyebrowType.cs @@ -27,7 +27,7 @@ Dotted, None, - Min = 0, - Max = 23 + Min = FlatAngledLarge, + Max = None, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/FacelineColor.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/FacelineColor.cs index 551f053d..4571168f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/FacelineColor.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/FacelineColor.cs @@ -13,7 +13,7 @@ Almond, Espresso, - Min = 0, - Max = 9 + Min = Beige, + Max = Espresso, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/FacelineMake.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/FacelineMake.cs index af6d7276..acd94ca2 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/FacelineMake.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/FacelineMake.cs @@ -15,7 +15,7 @@ LionsManeBeard, StubbleBeard, - Min = 0, - Max = 11 + Min = None, + Max = StubbleBeard, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/FacelineType.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/FacelineType.cs index fe27636f..29d14a12 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/FacelineType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/FacelineType.cs @@ -15,7 +15,7 @@ FlatRounded, AngularSmall, - Min = 0, - Max = 11 + Min = Sharp, + Max = AngularSmall, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/FacelineWrinkle.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/FacelineWrinkle.cs index afb75dd8..1a144748 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/FacelineWrinkle.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/FacelineWrinkle.cs @@ -15,7 +15,7 @@ CrowsFeet, FoldsCrowsFrown, - Min = 0, - Max = 11 + Min = None, + Max = FoldsCrowsFrown, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/FontRegion.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/FontRegion.cs index d1d86f16..c981a5ed 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/FontRegion.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/FontRegion.cs @@ -5,6 +5,6 @@ Standard, China, Korea, - Taiwan + Taiwan, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/Gender.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/Gender.cs index 75f9a745..c120c758 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/Gender.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/Gender.cs @@ -6,7 +6,7 @@ Female, All, - Min = 0, - Max = 1 + Min = Male, + Max = Female, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/GlassType.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/GlassType.cs index ccfed0f6..e2b6e6f5 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/GlassType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/GlassType.cs @@ -23,7 +23,7 @@ OpaqueRectangle, OpaqueAviator, - Min = 0, - Max = 19 + Min = None, + Max = OpaqueAviator, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/HairFlip.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/HairFlip.cs index 2f7f1d73..dee42e0d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/HairFlip.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/HairFlip.cs @@ -5,7 +5,7 @@ Left, Right, - Min = 0, - Max = 1 + Min = Left, + Max = Right, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/HairType.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/HairType.cs index a8a611da..a3e18396 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/HairType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/HairType.cs @@ -135,7 +135,7 @@ TwoLongSidedPonyTails, LongFrontTwoBackPonyTails, - Min = 0, - Max = 131 + Min = NormalLong, + Max = LongFrontTwoBackPonyTails, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/MoleType.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/MoleType.cs index 12cb6dc3..7ed274d2 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/MoleType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/MoleType.cs @@ -5,7 +5,7 @@ None, OneDot, - Min = 0, - Max = 1 + Min = None, + Max = OneDot, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/MouthType.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/MouthType.cs index 2a8e7a00..69236bd4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/MouthType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/MouthType.cs @@ -39,7 +39,7 @@ SmileDownLine, Kiss, - Min = 0, - Max = 35 + Min = Neutral, + Max = Kiss, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/MustacheType.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/MustacheType.cs index a15382dd..7b0255f2 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/MustacheType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/MustacheType.cs @@ -9,7 +9,7 @@ Normal, Toothbrush, - Min = 0, - Max = 5 + Min = None, + Max = Toothbrush, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/Nickname.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/Nickname.cs index 677d81b0..dc21d8e5 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/Nickname.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/Nickname.cs @@ -48,7 +48,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types public bool IsValid() { // Create a new unicode encoding instance with error checking enabled - UnicodeEncoding unicodeEncoding = new UnicodeEncoding(false, false, true); + UnicodeEncoding unicodeEncoding = new(false, false, true); try { @@ -77,10 +77,10 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types { if (data.Length > SizeConst) { - data = data.Slice(0, SizeConst); + data = data[..SizeConst]; } - Nickname result = new Nickname(); + Nickname result = new(); data.CopyTo(result.Raw); diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/NintendoFigurineDatabase.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/NintendoFigurineDatabase.cs index 14eda2ed..1e36788e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/NintendoFigurineDatabase.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/NintendoFigurineDatabase.cs @@ -25,19 +25,19 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types // Set to true to allow fixing database with invalid storedata device crc instead of deleting them. private const bool AcceptInvalidDeviceCrc = true; - public int Length => _figurineCount; + public readonly int Length => _figurineCount; [StructLayout(LayoutKind.Sequential, Size = FigurineArraySize)] private struct FigurineStorageStruct { } private Span<StoreData> Figurines => SpanHelpers.AsSpan<FigurineStorageStruct, StoreData>(ref _figurineStorage); - + public StoreData Get(int index) { return Figurines[index]; } - public bool IsFull() + public readonly bool IsFull() { return Length >= MaxMii; } @@ -74,14 +74,14 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types if (newIndex < oldIndex) { - targetLength = oldIndex - newIndex; - sourceIndex = newIndex; + targetLength = oldIndex - newIndex; + sourceIndex = newIndex; destinationIndex = newIndex + 1; } else { - targetLength = newIndex - oldIndex; - sourceIndex = oldIndex + 1; + targetLength = newIndex - oldIndex; + sourceIndex = oldIndex + 1; destinationIndex = oldIndex; } @@ -113,8 +113,8 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types // If this isn't the only element in the list, move the data in it. if (index < newCount) { - int targetLength = newCount - index; - int sourceIndex = index + 1; + int targetLength = newCount - index; + int sourceIndex = index + 1; int destinationIndex = index; Figurines.Slice(sourceIndex, targetLength).CopyTo(Figurines.Slice(destinationIndex, targetLength)); @@ -204,12 +204,12 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types public void Format() { - _magic = DatabaseMagic; - _version = CurrentVersion; + _magic = DatabaseMagic; + _version = CurrentVersion; _figurineCount = 0; // Fill with empty data - Figurines.Fill(new StoreData()); + Figurines.Clear(); UpdateCrc(); } @@ -248,7 +248,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types private ReadOnlySpan<byte> AsSpanWithoutCrc() { - return AsReadOnlySpan().Slice(0, Unsafe.SizeOf<NintendoFigurineDatabase>() - 2); + return AsReadOnlySpan()[..(Unsafe.SizeOf<NintendoFigurineDatabase>() - 2)]; } } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/NoseType.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/NoseType.cs index e898a02e..3144b132 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/NoseType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/NoseType.cs @@ -21,7 +21,7 @@ Droopy, ArrowLarge, - Min = 0, - Max = 17 + Min = Normal, + Max = ArrowLarge, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/Race.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/Race.cs index 8cf36c27..5f304a4e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/Race.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/Race.cs @@ -5,6 +5,6 @@ Black, White, Asian, - All + All, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/RandomMiiConstants.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/RandomMiiConstants.cs index 6def469d..17333093 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/RandomMiiConstants.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/RandomMiiConstants.cs @@ -6,25 +6,23 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types { static class RandomMiiConstants { - public static int[] EyeRotateTable = new int[] - { + public static int[] EyeRotateTable = { 0x03, 0x04, 0x04, 0x04, 0x03, 0x04, 0x04, 0x04, 0x03, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x04, 0x04, 0x04, 0x03, 0x03, 0x04, 0x03, 0x04, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x03, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x04, 0x04, 0x03, 0x03, 0x03, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, - 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x03, 0x04, 0x04, 0x03, 0x04, 0x04 + 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x03, 0x04, 0x04, 0x03, 0x04, 0x04, }; - public static int[] EyebrowRotateTable = new int[] - { + public static int[] EyebrowRotateTable = { 0x06, 0x06, 0x05, 0x07, 0x06, 0x07, 0x06, 0x07, 0x04, 0x07, 0x06, 0x08, 0x05, 0x05, 0x06, 0x06, - 0x07, 0x07, 0x06, 0x06, 0x05, 0x06, 0x07, 0x05 + 0x07, 0x07, 0x06, 0x06, 0x05, 0x06, 0x07, 0x05, }; [Flags] public enum BeardAndMustacheFlag { Beard = 1, - Mustache + Mustache, } [StructLayout(LayoutKind.Sequential, Pack = 4, Size = ValuesArraySize)] @@ -32,7 +30,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types { private const int ValuesArraySize = 0xbc; - private int _firstValueByte; + private readonly int _firstValueByte; public ReadOnlySpan<int> Values => SpanHelpers.AsSpan<RandomMiiValues, int>(ref this); } @@ -44,34 +42,34 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types public int Age; public int Race; public int ValuesCount; - - private RandomMiiValues _values; - public ReadOnlySpan<int> Values => _values.Values.Slice(0, ValuesCount); + private readonly RandomMiiValues _values; + + public readonly ReadOnlySpan<int> Values => _values.Values[..ValuesCount]; } [StructLayout(LayoutKind.Sequential, Pack = 4, Size = 0xC8)] public struct RandomMiiData3 { - private int _argument1; - private int _argument2; + private readonly int _argument1; + private readonly int _argument2; public int ValuesCount; - - private RandomMiiValues _values; - public ReadOnlySpan<int> Values => _values.Values.Slice(0, ValuesCount); + private readonly RandomMiiValues _values; + + public readonly ReadOnlySpan<int> Values => _values.Values[..ValuesCount]; } [StructLayout(LayoutKind.Sequential, Pack = 4, Size = 0xC4)] public struct RandomMiiData2 { - private int _argument; + private readonly int _argument; public int ValuesCount; - private RandomMiiValues _values; + private readonly RandomMiiValues _values; - public ReadOnlySpan<int> Values => _values.Values.Slice(0, ValuesCount); + public readonly ReadOnlySpan<int> Values => _values.Values[..ValuesCount]; } public static ReadOnlySpan<RandomMiiData4> RandomMiiFacelineArray => MemoryMarshal.Cast<byte, RandomMiiData4>(RandomMiiFacelineRawArray); @@ -332,7 +330,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + , }; private static ReadOnlySpan<byte> RandomMiiFacelineColorRawArray => new byte[] { @@ -411,7 +409,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + , }; private static ReadOnlySpan<byte> RandomMiiFacelineWrinkleRawArray => new byte[] { @@ -645,7 +643,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + , }; private static ReadOnlySpan<byte> RandomMiiFacelineMakeRawArray => new byte[] { @@ -879,7 +877,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + , }; private static ReadOnlySpan<byte> RandomMiiHairTypeRawArray => new byte[] { @@ -1113,7 +1111,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + , }; private static ReadOnlySpan<byte> RandomMiiHairColorRawArray => new byte[] { @@ -1230,7 +1228,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + , }; private static ReadOnlySpan<byte> RandomMiiEyeTypeRawArray => new byte[] { @@ -1464,7 +1462,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + ,}; private static ReadOnlySpan<byte> RandomMiiEyeColorRawArray => new byte[] { diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/Source.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/Source.cs index 2ae02ea0..f4d2b8cb 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/Source.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/Source.cs @@ -3,6 +3,6 @@ enum Source { Database, - Default + Default, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/SourceFlag.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/SourceFlag.cs index c9682bdb..c04eb043 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/SourceFlag.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/SourceFlag.cs @@ -6,7 +6,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types enum SourceFlag { Database = 1 << Source.Database, - Default = 1 << Source.Default, - All = Database | Default + Default = 1 << Source.Default, + All = Database | Default, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/SpecialMiiKeyCode.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/SpecialMiiKeyCode.cs index 7fe13238..be2433dd 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/SpecialMiiKeyCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/SpecialMiiKeyCode.cs @@ -9,7 +9,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types public uint RawValue; - public bool IsEnabledSpecialMii() + public readonly bool IsEnabledSpecialMii() { return RawValue == SpecialMiiMagic; } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/StoreData.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/StoreData.cs index 8411693f..994f6b7c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/StoreData.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/StoreData.cs @@ -9,16 +9,16 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types { public const int Size = 0x44; - public CoreData CoreData; + public CoreData CoreData; private CreateId _createId; - public ushort DataCrc; - public ushort DeviceCrc; + public ushort DataCrc; + public ushort DeviceCrc; public byte Type => CoreData.Type; - public CreateId CreateId => _createId; + public readonly CreateId CreateId => _createId; - public ResultCode InvalidData => ResultCode.InvalidStoreData; + public readonly ResultCode InvalidData => ResultCode.InvalidStoreData; private void UpdateDataCrc() { @@ -81,22 +81,23 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types private ReadOnlySpan<byte> AsSpanWithoutDeviceCrc() { - return AsSpan().Slice(0, Size - 2); + return AsSpan()[..(Size - 2)]; } public static StoreData BuildDefault(UtilityImpl utilImpl, uint index) { - StoreData result = new StoreData + StoreData result = new() { - _createId = utilImpl.MakeCreateId() + _createId = utilImpl.MakeCreateId(), }; - CoreData coreData = new CoreData(); + CoreData coreData = new(); DefaultMii template = DefaultMii.GetDefaultMii(index); coreData.SetDefault(); +#pragma warning disable IDE0055 // Disable formatting coreData.Nickname = template.Nickname; coreData.FontRegion = (FontRegion)template.FontRegion; coreData.FavoriteColor = (byte)template.FavoriteColor; @@ -147,6 +148,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types coreData.MoleScale = (byte)template.MoleScale; coreData.MoleX = (byte)template.MoleX; coreData.MoleY = (byte)template.MoleY; +#pragma warning restore IDE0055 result.CoreData = coreData; @@ -162,10 +164,10 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types public static StoreData BuildFromCoreData(UtilityImpl utilImpl, CoreData coreData) { - StoreData result = new StoreData + StoreData result = new() { - CoreData = coreData, - _createId = utilImpl.MakeCreateId() + CoreData = coreData, + _createId = utilImpl.MakeCreateId(), }; result.UpdateCrc(); @@ -178,7 +180,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types this = storeData; } - public void SetSource(Source source) + public readonly void SetSource(Source source) { // Only implemented for Element variants. } @@ -193,12 +195,12 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types return !x.Equals(y); } - public override bool Equals(object obj) + public readonly override bool Equals(object obj) { return obj is StoreData storeData && Equals(storeData); } - public bool Equals(StoreData cmpObj) + public readonly bool Equals(StoreData cmpObj) { if (!cmpObj.IsValid()) { @@ -215,9 +217,9 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types return result; } - public override int GetHashCode() + public readonly override int GetHashCode() { - HashCode hashCode = new HashCode(); + HashCode hashCode = new(); hashCode.Add(CreateId); hashCode.Add(CoreData); diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/StoreDataElement.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/StoreDataElement.cs index 8d3e96be..2008c1ff 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/StoreDataElement.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/StoreDataElement.cs @@ -6,7 +6,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types struct StoreDataElement : IElement { public StoreData StoreData; - public Source Source; + public Source Source; public void SetFromStoreData(StoreData storeData) { diff --git a/src/Ryujinx.HLE/HOS/Services/Mm/IRequest.cs b/src/Ryujinx.HLE/HOS/Services/Mm/IRequest.cs index fac42555..31d325a9 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mm/IRequest.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mm/IRequest.cs @@ -7,10 +7,10 @@ namespace Ryujinx.HLE.HOS.Services.Mm [Service("mm:u")] class IRequest : IpcService { - private static object _sessionListLock = new object(); - private static List<MultiMediaSession> _sessionList = new List<MultiMediaSession>(); + private readonly object _sessionListLock = new(); + private readonly List<MultiMediaSession> _sessionList = new(); - private static uint _uniqueId = 1; + private uint _uniqueId = 1; public IRequest(ServiceCtx context) { } @@ -18,9 +18,9 @@ namespace Ryujinx.HLE.HOS.Services.Mm // InitializeOld(u32, u32, u32) public ResultCode InitializeOld(ServiceCtx context) { - MultiMediaOperationType operationType = (MultiMediaOperationType)context.RequestData.ReadUInt32(); - int fgmId = context.RequestData.ReadInt32(); - bool isAutoClearEvent = context.RequestData.ReadInt32() != 0; + MultiMediaOperationType operationType = (MultiMediaOperationType)context.RequestData.ReadUInt32(); + int fgmId = context.RequestData.ReadInt32(); + bool isAutoClearEvent = context.RequestData.ReadInt32() != 0; Logger.Stub?.PrintStub(LogClass.ServiceMm, new { operationType, fgmId, isAutoClearEvent }); @@ -50,8 +50,8 @@ namespace Ryujinx.HLE.HOS.Services.Mm public ResultCode SetAndWaitOld(ServiceCtx context) { MultiMediaOperationType operationType = (MultiMediaOperationType)context.RequestData.ReadUInt32(); - uint frequenceHz = context.RequestData.ReadUInt32(); - int timeout = context.RequestData.ReadInt32(); + uint frequenceHz = context.RequestData.ReadUInt32(); + int timeout = context.RequestData.ReadInt32(); Logger.Stub?.PrintStub(LogClass.ServiceMm, new { operationType, frequenceHz, timeout }); @@ -87,9 +87,9 @@ namespace Ryujinx.HLE.HOS.Services.Mm // Initialize(u32, u32, u32) -> u32 public ResultCode Initialize(ServiceCtx context) { - MultiMediaOperationType operationType = (MultiMediaOperationType)context.RequestData.ReadUInt32(); - int fgmId = context.RequestData.ReadInt32(); - bool isAutoClearEvent = context.RequestData.ReadInt32() != 0; + MultiMediaOperationType operationType = (MultiMediaOperationType)context.RequestData.ReadUInt32(); + int fgmId = context.RequestData.ReadInt32(); + bool isAutoClearEvent = context.RequestData.ReadInt32() != 0; Logger.Stub?.PrintStub(LogClass.ServiceMm, new { operationType, fgmId, isAutoClearEvent }); @@ -120,9 +120,9 @@ namespace Ryujinx.HLE.HOS.Services.Mm // SetAndWait(u32, u32, u32) public ResultCode SetAndWait(ServiceCtx context) { - uint id = context.RequestData.ReadUInt32(); + uint id = context.RequestData.ReadUInt32(); uint frequenceHz = context.RequestData.ReadUInt32(); - int timeout = context.RequestData.ReadInt32(); + int timeout = context.RequestData.ReadInt32(); Logger.Stub?.PrintStub(LogClass.ServiceMm, new { id, frequenceHz, timeout }); @@ -185,7 +185,7 @@ namespace Ryujinx.HLE.HOS.Services.Mm lock (_sessionListLock) { // Nintendo ignore the fgm id as the other interfaces were deprecated. - MultiMediaSession session = new MultiMediaSession(_uniqueId++, type, isAutoClearEvent); + MultiMediaSession session = new(_uniqueId++, type, isAutoClearEvent); _sessionList.Add(session); @@ -193,4 +193,4 @@ namespace Ryujinx.HLE.HOS.Services.Mm } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Mm/Types/MultiMediaOperationType.cs b/src/Ryujinx.HLE/HOS/Services/Mm/Types/MultiMediaOperationType.cs index 2742af6c..095dbfc3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mm/Types/MultiMediaOperationType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mm/Types/MultiMediaOperationType.cs @@ -2,9 +2,9 @@ { enum MultiMediaOperationType : uint { - Ram = 2, + Ram = 2, NvEnc = 5, NvDec = 6, - NvJpg = 7 + NvJpg = 7, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Mm/Types/MultiMediaSession.cs b/src/Ryujinx.HLE/HOS/Services/Mm/Types/MultiMediaSession.cs index a6723eca..32b52ca5 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mm/Types/MultiMediaSession.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mm/Types/MultiMediaSession.cs @@ -5,15 +5,15 @@ public MultiMediaOperationType Type { get; } public bool IsAutoClearEvent { get; } - public uint Id { get; } - public uint CurrentValue { get; private set; } + public uint Id { get; } + public uint CurrentValue { get; private set; } public MultiMediaSession(uint id, MultiMediaOperationType type, bool isAutoClearEvent) { - Type = type; - Id = id; + Type = type; + Id = id; IsAutoClearEvent = isAutoClearEvent; - CurrentValue = 0; + CurrentValue = 0; } public void SetAndWait(uint value, int timeout) diff --git a/src/Ryujinx.HLE/HOS/Services/Mnpp/IServiceForApplication.cs b/src/Ryujinx.HLE/HOS/Services/Mnpp/IServiceForApplication.cs index c2a4345c..7c20579b 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mnpp/IServiceForApplication.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mnpp/IServiceForApplication.cs @@ -32,7 +32,7 @@ namespace Ryujinx.HLE.HOS.Services.Mnpp public ResultCode SendRawTelemetryData(ServiceCtx context) { ulong titleIdInputPosition = context.Request.SendBuff[0].Position; - ulong titleIdInputSize = context.Request.SendBuff[0].Size; + ulong titleIdInputSize = context.Request.SendBuff[0].Size; UserId userId = context.RequestData.ReadStruct<UserId>(); @@ -60,4 +60,4 @@ namespace Ryujinx.HLE.HOS.Services.Mnpp return ResultCode.InvalidBufferSize; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Mnpp/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Mnpp/ResultCode.cs index dfc39a73..af3acf0a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mnpp/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mnpp/ResultCode.cs @@ -2,12 +2,12 @@ namespace Ryujinx.HLE.HOS.Services.Mnpp { enum ResultCode { - ModuleId = 239, + ModuleId = 239, ErrorCodeShift = 9, Success = 0, - InvalidArgument = (100 << ErrorCodeShift) | ModuleId, - InvalidBufferSize = (101 << ErrorCodeShift) | ModuleId + InvalidArgument = (100 << ErrorCodeShift) | ModuleId, + InvalidBufferSize = (101 << ErrorCodeShift) | ModuleId, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ncm/IContentManager.cs b/src/Ryujinx.HLE/HOS/Services/Ncm/IContentManager.cs index 7f05d9be..cf0d4149 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ncm/IContentManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ncm/IContentManager.cs @@ -5,4 +5,4 @@ { public IContentManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ncm/Lr/ILocationResolverManager.cs b/src/Ryujinx.HLE/HOS/Services/Ncm/Lr/ILocationResolverManager.cs index 318ad30e..f5921678 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ncm/Lr/ILocationResolverManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ncm/Lr/ILocationResolverManager.cs @@ -19,4 +19,4 @@ namespace Ryujinx.HLE.HOS.Services.Ncm.Lr return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ncm/Lr/LocationResolverManager/ILocationResolver.cs b/src/Ryujinx.HLE/HOS/Services/Ncm/Lr/LocationResolverManager/ILocationResolver.cs index 55b49bce..f5a0c665 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ncm/Lr/LocationResolverManager/ILocationResolver.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ncm/Lr/LocationResolverManager/ILocationResolver.cs @@ -2,14 +2,13 @@ using LibHac.Tools.FsSystem.NcaUtils; using Ryujinx.HLE.FileSystem; using System.Text; - using static Ryujinx.HLE.Utilities.StringUtils; namespace Ryujinx.HLE.HOS.Services.Ncm.Lr.LocationResolverManager { class ILocationResolver : IpcService { - private StorageId _storageId; + private readonly StorageId _storageId; public ILocationResolver(StorageId storageId) { @@ -215,8 +214,8 @@ namespace Ryujinx.HLE.HOS.Services.Ncm.Lr.LocationResolverManager private void RedirectPath(ServiceCtx context, ulong titleId, int flag, NcaContentType contentType) { - string contentPath = ReadUtf8String(context); - LocationEntry newLocation = new LocationEntry(contentPath, flag, titleId, contentType); + string contentPath = ReadUtf8String(context); + LocationEntry newLocation = new(contentPath, flag, titleId, contentType); context.Device.System.ContentManager.RedirectLocation(newLocation, _storageId); } @@ -224,12 +223,14 @@ namespace Ryujinx.HLE.HOS.Services.Ncm.Lr.LocationResolverManager private bool ResolvePath(ServiceCtx context, ulong titleId, NcaContentType contentType) { ContentManager contentManager = context.Device.System.ContentManager; - string contentPath = contentManager.GetInstalledContentPath(titleId, _storageId, NcaContentType.Program); + string contentPath = contentManager.GetInstalledContentPath(titleId, _storageId, NcaContentType.Program); if (!string.IsNullOrWhiteSpace(contentPath)) { ulong position = context.Request.RecvListBuff[0].Position; - ulong size = context.Request.RecvListBuff[0].Size; +#pragma warning disable IDE0059 // Remove unnecessary value assignment + ulong size = context.Request.RecvListBuff[0].Size; +#pragma warning restore IDE0059 byte[] contentPathBuffer = Encoding.UTF8.GetBytes(contentPath); @@ -246,7 +247,9 @@ namespace Ryujinx.HLE.HOS.Services.Ncm.Lr.LocationResolverManager private void DeleteContentPath(ServiceCtx context, ulong titleId, NcaContentType contentType) { ContentManager contentManager = context.Device.System.ContentManager; - string contentPath = contentManager.GetInstalledContentPath(titleId, _storageId, NcaContentType.Manual); +#pragma warning disable IDE0059 // Remove unnecessary value assignment + string contentPath = contentManager.GetInstalledContentPath(titleId, _storageId, NcaContentType.Manual); +#pragma warning restore IDE0059 contentManager.ClearEntry(titleId, NcaContentType.Manual, _storageId); } diff --git a/src/Ryujinx.HLE/HOS/Services/Ncm/Lr/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Ncm/Lr/ResultCode.cs index d21fe634..3a027fd0 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ncm/Lr/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ncm/Lr/ResultCode.cs @@ -2,19 +2,19 @@ { enum ResultCode { - ModuleId = 8, + ModuleId = 8, ErrorCodeShift = 9, Success = 0, - ProgramLocationEntryNotFound = (2 << ErrorCodeShift) | ModuleId, - InvalidContextForControlLocation = (3 << ErrorCodeShift) | ModuleId, - StorageNotFound = (4 << ErrorCodeShift) | ModuleId, - AccessDenied = (5 << ErrorCodeShift) | ModuleId, - OfflineManualHTMLLocationEntryNotFound = (6 << ErrorCodeShift) | ModuleId, - TitleIsNotRegistered = (7 << ErrorCodeShift) | ModuleId, - ControlLocationEntryForHostNotFound = (8 << ErrorCodeShift) | ModuleId, - LegalInfoHTMLLocationEntryNotFound = (9 << ErrorCodeShift) | ModuleId, - ProgramLocationForDebugEntryNotFound = (10 << ErrorCodeShift) | ModuleId + ProgramLocationEntryNotFound = (2 << ErrorCodeShift) | ModuleId, + InvalidContextForControlLocation = (3 << ErrorCodeShift) | ModuleId, + StorageNotFound = (4 << ErrorCodeShift) | ModuleId, + AccessDenied = (5 << ErrorCodeShift) | ModuleId, + OfflineManualHTMLLocationEntryNotFound = (6 << ErrorCodeShift) | ModuleId, + TitleIsNotRegistered = (7 << ErrorCodeShift) | ModuleId, + ControlLocationEntryForHostNotFound = (8 << ErrorCodeShift) | ModuleId, + LegalInfoHTMLLocationEntryNotFound = (9 << ErrorCodeShift) | ModuleId, + ProgramLocationForDebugEntryNotFound = (10 << ErrorCodeShift) | ModuleId, } } diff --git a/src/Ryujinx.HLE/HOS/Services/News/IServiceCreator.cs b/src/Ryujinx.HLE/HOS/Services/News/IServiceCreator.cs index 7ea89b20..5d33e1a2 100644 --- a/src/Ryujinx.HLE/HOS/Services/News/IServiceCreator.cs +++ b/src/Ryujinx.HLE/HOS/Services/News/IServiceCreator.cs @@ -9,4 +9,4 @@ { public IServiceCreator(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/IAmManager.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/IAmManager.cs index 33932568..142c4da4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/IAmManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/IAmManager.cs @@ -5,4 +5,4 @@ { public IAmManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/ISystemManager.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/ISystemManager.cs index ef90b6ad..50453117 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/ISystemManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/ISystemManager.cs @@ -16,4 +16,4 @@ namespace Ryujinx.HLE.HOS.Services.Nfc return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/IUserManager.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/IUserManager.cs index 97959a62..69c3bd19 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/IUserManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/IUserManager.cs @@ -16,4 +16,4 @@ namespace Ryujinx.HLE.HOS.Services.Nfc return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Mifare/IUserManager.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Mifare/IUserManager.cs index cc3cd3aa..2c5aaa2e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Mifare/IUserManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Mifare/IUserManager.cs @@ -5,4 +5,4 @@ { public IUserManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/NfcManager/INfc.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/NfcManager/INfc.cs index b091aabf..dac0c4c3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/NfcManager/INfc.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/NfcManager/INfc.cs @@ -4,7 +4,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.NfcManager { class INfc : IpcService { - private NfcPermissionLevel _permissionLevel; + private readonly NfcPermissionLevel _permissionLevel; private State _state; public INfc(NfcPermissionLevel permissionLevel) @@ -40,7 +40,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.NfcManager [CommandCmif(2)] [CommandCmif(402)] // 4.0.0+ // GetState() -> u32 - public ResultCode GetState(ServiceCtx context) + public ResultCode GetState(ServiceCtx context) { context.ResponseData.Write((int)_state); @@ -60,4 +60,4 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.NfcManager return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/NfcManager/Types/NfcPermissionLevel.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/NfcManager/Types/NfcPermissionLevel.cs index 39babc73..37a78dfd 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/NfcManager/Types/NfcPermissionLevel.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/NfcManager/Types/NfcPermissionLevel.cs @@ -3,6 +3,6 @@ enum NfcPermissionLevel { User, - System + System, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/NfcManager/Types/State.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/NfcManager/Types/State.cs index 85f99950..cfc86dfa 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/NfcManager/Types/State.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/NfcManager/Types/State.cs @@ -3,6 +3,6 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.NfcManager enum State { NonInitialized, - Initialized + Initialized, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/AmiiboJsonSerializerContext.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/AmiiboJsonSerializerContext.cs index e75f6200..d4867112 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/AmiiboJsonSerializerContext.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/AmiiboJsonSerializerContext.cs @@ -7,4 +7,4 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp internal partial class AmiiboJsonSerializerContext : JsonSerializerContext { } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/IDebugManager.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/IDebugManager.cs index fc454473..8196f42d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/IDebugManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/IDebugManager.cs @@ -16,4 +16,4 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/ISystemManager.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/ISystemManager.cs index 3fcf7a87..d5933a4c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/ISystemManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/ISystemManager.cs @@ -16,4 +16,4 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/IUserManager.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/IUserManager.cs index 93da8419..fa80e9b8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/IUserManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/IUserManager.cs @@ -16,4 +16,4 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/INfp.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/INfp.cs index e25a2972..9dc75cd2 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/INfp.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/INfp.cs @@ -18,8 +18,10 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp { class INfp : IpcService { - private ulong _appletResourceUserId; - private ulong _mcuVersionData; +#pragma warning disable IDE0052 // Remove unread private member + private ulong _appletResourceUserId; + private ulong _mcuVersionData; +#pragma warning restore IDE0052 private byte[] _mcuData; private State _state = State.NonInitialized; @@ -28,7 +30,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp private CancellationTokenSource _cancelTokenSource; - private NfpPermissionLevel _permissionLevel; + private readonly NfpPermissionLevel _permissionLevel; public INfp(NfpPermissionLevel permissionLevel) { @@ -40,10 +42,10 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp public ResultCode Initialize(ServiceCtx context) { _appletResourceUserId = context.RequestData.ReadUInt64(); - _mcuVersionData = context.RequestData.ReadUInt64(); + _mcuVersionData = context.RequestData.ReadUInt64(); ulong inputPosition = context.Request.SendBuff[0].Position; - ulong inputSize = context.Request.SendBuff[0].Size; + ulong inputSize = context.Request.SendBuff[0].Size; _mcuData = new byte[inputSize]; @@ -53,11 +55,11 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp // TODO: Handle this in a controller class directly. // Every functions which use the Handle call nn::hid::system::GetXcdHandleForNpadWithNfc(). - NfpDevice devicePlayer1 = new NfpDevice + NfpDevice devicePlayer1 = new() { NpadIdType = NpadIdType.Player1, - Handle = HidUtils.GetIndexFromNpadIdType(NpadIdType.Player1), - State = NfpDeviceState.Initialized + Handle = HidUtils.GetIndexFromNpadIdType(NpadIdType.Player1), + State = NfpDeviceState.Initialized, }; context.Device.System.NfpDevices.Add(devicePlayer1); @@ -75,10 +77,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp { if (_state == State.Initialized) { - if (_cancelTokenSource != null) - { - _cancelTokenSource.Cancel(); - } + _cancelTokenSource?.Cancel(); // NOTE: All events are destroyed here. context.Device.System.NfpDevices.Clear(); @@ -99,7 +98,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp } ulong outputPosition = context.Request.RecvListBuff[0].Position; - ulong outputSize = context.Request.RecvListBuff[0].Size; + ulong outputSize = context.Request.RecvListBuff[0].Size; if (context.Device.System.NfpDevices.Count == 0) { @@ -187,10 +186,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp return resultCode; } - if (_cancelTokenSource != null) - { - _cancelTokenSource.Cancel(); - } + _cancelTokenSource?.Cancel(); uint deviceHandle = (uint)context.RequestData.ReadUInt64(); @@ -218,9 +214,9 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp return resultCode; } - uint deviceHandle = (uint)context.RequestData.ReadUInt64(); - DeviceType deviceType = (DeviceType)context.RequestData.ReadUInt32(); - MountTarget mountTarget = (MountTarget)context.RequestData.ReadUInt32(); + uint deviceHandle = (uint)context.RequestData.ReadUInt64(); + DeviceType deviceType = (DeviceType)context.RequestData.ReadUInt32(); + MountTarget mountTarget = (MountTarget)context.RequestData.ReadUInt32(); if (deviceType != 0) { @@ -382,7 +378,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp } ulong outputPosition = context.Request.ReceiveBuff[0].Position; - ulong outputSize = context.Request.ReceiveBuff[0].Size; + ulong outputSize = context.Request.ReceiveBuff[0].Size; MemoryHelper.FillWithZeros(context.Memory, outputPosition, (int)outputSize); @@ -450,7 +446,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp } ulong inputPosition = context.Request.SendBuff[0].Position; - ulong inputSize = context.Request.SendBuff[0].Size; + ulong inputSize = context.Request.SendBuff[0].Size; byte[] applicationArea = new byte[inputSize]; @@ -489,7 +485,9 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp // Flush(bytes<8, 4>) public ResultCode Flush(ServiceCtx context) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment uint deviceHandle = (uint)context.RequestData.ReadUInt64(); +#pragma warning restore IDE0059 if (context.Device.System.NfpDevices.Count == 0) { @@ -529,7 +527,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp uint applicationAreaId = context.RequestData.ReadUInt32(); ulong inputPosition = context.Request.SendBuff[0].Position; - ulong inputSize = context.Request.SendBuff[0].Size; + ulong inputSize = context.Request.SendBuff[0].Size; byte[] applicationArea = new byte[inputSize]; @@ -612,23 +610,23 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp { if (context.Device.System.NfpDevices[i].State == NfpDeviceState.TagMounted || context.Device.System.NfpDevices[i].State == NfpDeviceState.TagFound) { - byte[] Uuid = VirtualAmiibo.GenerateUuid(context.Device.System.NfpDevices[i].AmiiboId, context.Device.System.NfpDevices[i].UseRandomUuid); + byte[] uuid = VirtualAmiibo.GenerateUuid(context.Device.System.NfpDevices[i].AmiiboId, context.Device.System.NfpDevices[i].UseRandomUuid); - if (Uuid.Length > AmiiboConstants.UuidMaxLength) + if (uuid.Length > AmiiboConstants.UuidMaxLength) { - throw new ArgumentOutOfRangeException(); + throw new InvalidOperationException($"{nameof(uuid)} is too long: {uuid.Length}"); } - TagInfo tagInfo = new TagInfo + TagInfo tagInfo = new() { - UuidLength = (byte)Uuid.Length, - Reserved1 = new Array21<byte>(), - Protocol = uint.MaxValue, // All Protocol - TagType = uint.MaxValue, // All Type - Reserved2 = new Array6<byte>() + UuidLength = (byte)uuid.Length, + Reserved1 = new Array21<byte>(), + Protocol = uint.MaxValue, // All Protocol + TagType = uint.MaxValue, // All Type + Reserved2 = new Array6<byte>(), }; - Uuid.CopyTo(tagInfo.Uuid.AsSpan()); + uuid.CopyTo(tagInfo.Uuid.AsSpan()); context.Memory.Write(outputPosition, tagInfo); @@ -811,17 +809,16 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp { if (context.Device.System.NfpDevices[i].State == NfpDeviceState.TagMounted) { - ModelInfo modelInfo = new ModelInfo + ModelInfo modelInfo = new() { - Reserved = new Array57<byte>() + Reserved = new Array57<byte>(), + CharacterId = BinaryPrimitives.ReverseEndianness(ushort.Parse(context.Device.System.NfpDevices[i].AmiiboId.AsSpan(0, 4), NumberStyles.HexNumber)), + CharacterVariant = byte.Parse(context.Device.System.NfpDevices[i].AmiiboId.AsSpan(4, 2), NumberStyles.HexNumber), + Series = byte.Parse(context.Device.System.NfpDevices[i].AmiiboId.AsSpan(12, 2), NumberStyles.HexNumber), + ModelNumber = ushort.Parse(context.Device.System.NfpDevices[i].AmiiboId.AsSpan(8, 4), NumberStyles.HexNumber), + Type = byte.Parse(context.Device.System.NfpDevices[i].AmiiboId.AsSpan(6, 2), NumberStyles.HexNumber), }; - modelInfo.CharacterId = BinaryPrimitives.ReverseEndianness(ushort.Parse(context.Device.System.NfpDevices[i].AmiiboId.AsSpan(0, 4), NumberStyles.HexNumber)); - modelInfo.CharacterVariant = byte.Parse(context.Device.System.NfpDevices[i].AmiiboId.AsSpan(4, 2), NumberStyles.HexNumber); - modelInfo.Series = byte.Parse(context.Device.System.NfpDevices[i].AmiiboId.AsSpan(12, 2), NumberStyles.HexNumber); - modelInfo.ModelNumber = ushort.Parse(context.Device.System.NfpDevices[i].AmiiboId.AsSpan(8, 4), NumberStyles.HexNumber); - modelInfo.Type = byte.Parse(context.Device.System.NfpDevices[i].AmiiboId.AsSpan(6, 2), NumberStyles.HexNumber); - context.Memory.Write(outputPosition, modelInfo); resultCode = ResultCode.Success; @@ -912,7 +909,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp { if (context.Device.System.NfpDevices[i].State > NfpDeviceState.Finalized) { - throw new ArgumentOutOfRangeException(); + throw new InvalidOperationException($"{nameof(context.Device.System.NfpDevices)} contains an invalid state for device {i}: {context.Device.System.NfpDevices[i].State}"); } context.ResponseData.Write((uint)context.Device.System.NfpDevices[i].State); diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/AmiiboConstants.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/AmiiboConstants.cs index b06492e6..a5d420cb 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/AmiiboConstants.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/AmiiboConstants.cs @@ -2,7 +2,7 @@ { static class AmiiboConstants { - public const int UuidMaxLength = 10; + public const int UuidMaxLength = 10; public const int ApplicationAreaSize = 0xD8; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/CommonInfo.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/CommonInfo.cs index a7976de9..ba953125 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/CommonInfo.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/CommonInfo.cs @@ -6,12 +6,12 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp.NfpManager [StructLayout(LayoutKind.Sequential, Size = 0x40)] struct CommonInfo { - public ushort LastWriteYear; - public byte LastWriteMonth; - public byte LastWriteDay; - public ushort WriteCounter; - public ushort Version; - public uint ApplicationAreaSize; + public ushort LastWriteYear; + public byte LastWriteMonth; + public byte LastWriteDay; + public ushort WriteCounter; + public ushort Version; + public uint ApplicationAreaSize; public Array52<byte> Reserved; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/DeviceType.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/DeviceType.cs index 096522a0..44c8a79a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/DeviceType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/DeviceType.cs @@ -4,4 +4,4 @@ { Amiibo } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/ModelInfo.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/ModelInfo.cs index c66636ae..48aba269 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/ModelInfo.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/ModelInfo.cs @@ -6,11 +6,11 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp.NfpManager [StructLayout(LayoutKind.Sequential, Size = 0x40)] struct ModelInfo { - public ushort CharacterId; - public byte CharacterVariant; - public byte Series; - public ushort ModelNumber; - public byte Type; + public ushort CharacterId; + public byte CharacterVariant; + public byte Series; + public ushort ModelNumber; + public byte Type; public Array57<byte> Reserved; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/MountTarget.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/MountTarget.cs index 4a145773..d71d7eea 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/MountTarget.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/MountTarget.cs @@ -4,6 +4,6 @@ { Rom = 1, Ram = 2, - All = 3 + All = 3, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/NfpDevice.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/NfpDevice.cs index f56d33a9..82602837 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/NfpDevice.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/NfpDevice.cs @@ -8,16 +8,16 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp.NfpManager public KEvent ActivateEvent; public KEvent DeactivateEvent; - public void SignalActivate() => ActivateEvent.ReadableEvent.Signal(); + public void SignalActivate() => ActivateEvent.ReadableEvent.Signal(); public void SignalDeactivate() => DeactivateEvent.ReadableEvent.Signal(); public NfpDeviceState State = NfpDeviceState.Unavailable; public PlayerIndex Handle; - public NpadIdType NpadIdType; + public NpadIdType NpadIdType; public string AmiiboId; public bool UseRandomUuid; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/NfpDeviceState.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/NfpDeviceState.cs index 51e1d060..d0e0c8ba 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/NfpDeviceState.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/NfpDeviceState.cs @@ -2,12 +2,12 @@ { enum NfpDeviceState { - Initialized = 0, + Initialized = 0, SearchingForTag = 1, - TagFound = 2, - TagRemoved = 3, - TagMounted = 4, - Unavailable = 5, - Finalized = 6 + TagFound = 2, + TagRemoved = 3, + TagMounted = 4, + Unavailable = 5, + Finalized = 6, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/NfpPermissionLevel.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/NfpPermissionLevel.cs index 8b84dcfe..972f0af3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/NfpPermissionLevel.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/NfpPermissionLevel.cs @@ -4,6 +4,6 @@ { Debug, User, - System + System, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/RegisterInfo.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/RegisterInfo.cs index 6b30eb8e..28d8fae2 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/RegisterInfo.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/RegisterInfo.cs @@ -7,13 +7,13 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp.NfpManager [StructLayout(LayoutKind.Sequential, Size = 0x100)] struct RegisterInfo { - public CharInfo MiiCharInfo; - public ushort FirstWriteYear; - public byte FirstWriteMonth; - public byte FirstWriteDay; + public CharInfo MiiCharInfo; + public ushort FirstWriteYear; + public byte FirstWriteMonth; + public byte FirstWriteDay; public Array41<byte> Nickname; - public byte FontRegion; + public byte FontRegion; public Array64<byte> Reserved1; public Array58<byte> Reserved2; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/State.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/State.cs index b38cf9e2..ca7faf04 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/State.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/State.cs @@ -3,6 +3,6 @@ enum State { NonInitialized = 0, - Initialized = 1 + Initialized = 1, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/TagInfo.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/TagInfo.cs index d2076b2a..903743f1 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/TagInfo.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/TagInfo.cs @@ -7,10 +7,10 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp.NfpManager struct TagInfo { public Array10<byte> Uuid; - public byte UuidLength; + public byte UuidLength; public Array21<byte> Reserved1; - public uint Protocol; - public uint TagType; - public Array6<byte> Reserved2; + public uint Protocol; + public uint TagType; + public Array6<byte> Reserved2; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/VirtualAmiiboFile.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/VirtualAmiiboFile.cs index be1877e5..51e04dca 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/VirtualAmiiboFile.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/VirtualAmiiboFile.cs @@ -5,18 +5,18 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp.NfpManager { struct VirtualAmiiboFile { - public uint FileVersion { get; set; } - public byte[] TagUuid { get; set; } - public string AmiiboId { get; set; } + public uint FileVersion { get; set; } + public byte[] TagUuid { get; set; } + public string AmiiboId { get; set; } public DateTime FirstWriteDate { get; set; } - public DateTime LastWriteDate { get; set; } - public ushort WriteCounter { get; set; } + public DateTime LastWriteDate { get; set; } + public ushort WriteCounter { get; set; } public List<VirtualAmiiboApplicationArea> ApplicationAreas { get; set; } } struct VirtualAmiiboApplicationArea { - public uint ApplicationAreaId { get; set; } - public byte[] ApplicationArea { get; set; } + public uint ApplicationAreaId { get; set; } + public byte[] ApplicationArea { get; set; } } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/ResultCode.cs index e0ccbc6d..23387707 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/ResultCode.cs @@ -2,17 +2,17 @@ { public enum ResultCode { - ModuleId = 115, + ModuleId = 115, ErrorCodeShift = 9, Success = 0, - DeviceNotFound = (64 << ErrorCodeShift) | ModuleId, - WrongArgument = (65 << ErrorCodeShift) | ModuleId, - WrongDeviceState = (73 << ErrorCodeShift) | ModuleId, - NfcDisabled = (80 << ErrorCodeShift) | ModuleId, - TagNotFound = (97 << ErrorCodeShift) | ModuleId, - ApplicationAreaIsNull = (128 << ErrorCodeShift) | ModuleId, - ApplicationAreaAlreadyCreated = (168 << ErrorCodeShift) | ModuleId + DeviceNotFound = (64 << ErrorCodeShift) | ModuleId, + WrongArgument = (65 << ErrorCodeShift) | ModuleId, + WrongDeviceState = (73 << ErrorCodeShift) | ModuleId, + NfcDisabled = (80 << ErrorCodeShift) | ModuleId, + TagNotFound = (97 << ErrorCodeShift) | ModuleId, + ApplicationAreaIsNull = (128 << ErrorCodeShift) | ModuleId, + ApplicationAreaAlreadyCreated = (168 << ErrorCodeShift) | ModuleId, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs index 9e1db7fc..3d142653 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs @@ -8,7 +8,6 @@ using Ryujinx.HLE.HOS.Services.Nfc.Nfp.NfpManager; using System; using System.Collections.Generic; using System.IO; -using System.Linq; namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp { @@ -16,7 +15,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp { private static uint _openedApplicationAreaId; - private static readonly AmiiboJsonSerializerContext SerializerContext = AmiiboJsonSerializerContext.Default; + private static readonly AmiiboJsonSerializerContext _serializerContext = AmiiboJsonSerializerContext.Default; public static byte[] GenerateUuid(string amiiboId, bool useRandomUuid) { @@ -43,7 +42,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp Random.Shared.NextBytes(uuid); - uuid[3] = (byte)(0x88 ^ uuid[0] ^ uuid[1] ^ uuid[2]); + uuid[3] = (byte)(0x88 ^ uuid[0] ^ uuid[1] ^ uuid[2]); uuid[8] = (byte)(uuid[3] ^ uuid[4] ^ uuid[5] ^ uuid[6]); return uuid; @@ -55,13 +54,13 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp return new CommonInfo() { - LastWriteYear = (ushort)amiiboFile.LastWriteDate.Year, - LastWriteMonth = (byte)amiiboFile.LastWriteDate.Month, - LastWriteDay = (byte)amiiboFile.LastWriteDate.Day, - WriteCounter = amiiboFile.WriteCounter, - Version = 1, + LastWriteYear = (ushort)amiiboFile.LastWriteDate.Year, + LastWriteMonth = (byte)amiiboFile.LastWriteDate.Month, + LastWriteDay = (byte)amiiboFile.LastWriteDate.Day, + WriteCounter = amiiboFile.WriteCounter, + Version = 1, ApplicationAreaSize = AmiiboConstants.ApplicationAreaSize, - Reserved = new Array52<byte>() + Reserved = new Array52<byte>(), }; } @@ -69,22 +68,22 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp { VirtualAmiiboFile amiiboFile = LoadAmiiboFile(amiiboId); - UtilityImpl utilityImpl = new UtilityImpl(tickSource); - CharInfo charInfo = new CharInfo(); + UtilityImpl utilityImpl = new(tickSource); + CharInfo charInfo = new(); charInfo.SetFromStoreData(StoreData.BuildDefault(utilityImpl, 0)); charInfo.Nickname = Nickname.FromString(nickname); - RegisterInfo registerInfo = new RegisterInfo() + RegisterInfo registerInfo = new() { - MiiCharInfo = charInfo, - FirstWriteYear = (ushort)amiiboFile.FirstWriteDate.Year, + MiiCharInfo = charInfo, + FirstWriteYear = (ushort)amiiboFile.FirstWriteDate.Year, FirstWriteMonth = (byte)amiiboFile.FirstWriteDate.Month, - FirstWriteDay = (byte)amiiboFile.FirstWriteDate.Day, - FontRegion = 0, - Reserved1 = new Array64<byte>(), - Reserved2 = new Array58<byte>() + FirstWriteDay = (byte)amiiboFile.FirstWriteDate.Day, + FontRegion = 0, + Reserved1 = new Array64<byte>(), + Reserved2 = new Array58<byte>(), }; "Ryujinx"u8.CopyTo(registerInfo.Nickname.AsSpan()); @@ -132,7 +131,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp virtualAmiiboFile.ApplicationAreas.Add(new VirtualAmiiboApplicationArea() { ApplicationAreaId = applicationAreaId, - ApplicationArea = applicationAreaData + ApplicationArea = applicationAreaData, }); SaveAmiiboFile(virtualAmiiboFile); @@ -153,7 +152,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp virtualAmiiboFile.ApplicationAreas[i] = new VirtualAmiiboApplicationArea() { ApplicationAreaId = _openedApplicationAreaId, - ApplicationArea = applicationAreaData + ApplicationArea = applicationAreaData, }; break; @@ -174,19 +173,19 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp if (File.Exists(filePath)) { - virtualAmiiboFile = JsonHelper.DeserializeFromFile(filePath, SerializerContext.VirtualAmiiboFile); + virtualAmiiboFile = JsonHelper.DeserializeFromFile(filePath, _serializerContext.VirtualAmiiboFile); } else { virtualAmiiboFile = new VirtualAmiiboFile() { - FileVersion = 0, - TagUuid = Array.Empty<byte>(), - AmiiboId = amiiboId, - FirstWriteDate = DateTime.Now, - LastWriteDate = DateTime.Now, - WriteCounter = 0, - ApplicationAreas = new List<VirtualAmiiboApplicationArea>() + FileVersion = 0, + TagUuid = Array.Empty<byte>(), + AmiiboId = amiiboId, + FirstWriteDate = DateTime.Now, + LastWriteDate = DateTime.Now, + WriteCounter = 0, + ApplicationAreas = new List<VirtualAmiiboApplicationArea>(), }; SaveAmiiboFile(virtualAmiiboFile); @@ -198,7 +197,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp private static void SaveAmiiboFile(VirtualAmiiboFile virtualAmiiboFile) { string filePath = Path.Join(AppDataManager.BaseDirPath, "system", "amiibo", $"{virtualAmiiboFile.AmiiboId}.json"); - JsonHelper.SerializeToFile(filePath, virtualAmiiboFile, SerializerContext.VirtualAmiiboFile); + JsonHelper.SerializeToFile(filePath, virtualAmiiboFile, _serializerContext.VirtualAmiiboFile); } } } diff --git a/src/Ryujinx.HLE/HOS/Services/Ngct/IService.cs b/src/Ryujinx.HLE/HOS/Services/Ngct/IService.cs index eacf35f3..802be751 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ngct/IService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ngct/IService.cs @@ -19,4 +19,4 @@ return NgctServer.Filter(context); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ngct/IServiceWithManagementApi.cs b/src/Ryujinx.HLE/HOS/Services/Ngct/IServiceWithManagementApi.cs index 5ad056ba..7ef99835 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ngct/IServiceWithManagementApi.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ngct/IServiceWithManagementApi.cs @@ -19,4 +19,4 @@ return NgctServer.Filter(context); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ngct/NgctServer.cs b/src/Ryujinx.HLE/HOS/Services/Ngct/NgctServer.cs index 8d99721e..ae00842d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ngct/NgctServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ngct/NgctServer.cs @@ -12,10 +12,10 @@ namespace Ryujinx.HLE.HOS.Services.Ngct // If both conditions are true, it does this following code. Since we currently stub it, it's fine to don't check settings service values. ulong bufferPosition = context.Request.PtrBuff[0].Position; - ulong bufferSize = context.Request.PtrBuff[0].Size; + ulong bufferSize = context.Request.PtrBuff[0].Size; - bool isMatch = false; - string text = ""; + bool isMatch = false; + string text = ""; if (bufferSize != 0) { @@ -53,11 +53,11 @@ namespace Ryujinx.HLE.HOS.Services.Ngct // If both conditions are true, it does this following code. Since we currently stub it, it's fine to don't check settings service values. ulong bufferPosition = context.Request.PtrBuff[0].Position; - ulong bufferSize = context.Request.PtrBuff[0].Size; + ulong bufferSize = context.Request.PtrBuff[0].Size; ulong bufferFilteredPosition = context.Request.RecvListBuff[0].Position; - string text = ""; + string text = ""; string textFiltered = ""; if (bufferSize != 0) @@ -89,4 +89,4 @@ namespace Ryujinx.HLE.HOS.Services.Ngct return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nifm/IStaticService.cs b/src/Ryujinx.HLE/HOS/Services/Nifm/IStaticService.cs index d6a4a29f..96e71cd0 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nifm/IStaticService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nifm/IStaticService.cs @@ -27,4 +27,4 @@ namespace Ryujinx.HLE.HOS.Services.Nifm return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nifm/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Nifm/ResultCode.cs index 73cadb11..91a3d0af 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nifm/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nifm/ResultCode.cs @@ -2,14 +2,14 @@ namespace Ryujinx.HLE.HOS.Services.Nifm { enum ResultCode { - ModuleId = 110, + ModuleId = 110, ErrorCodeShift = 9, Success = 0, - Unknown112 = (112 << ErrorCodeShift) | ModuleId, // IRequest::GetResult - Unknown180 = (180 << ErrorCodeShift) | ModuleId, // IRequest::GetAppletInfo + Unknown112 = (112 << ErrorCodeShift) | ModuleId, // IRequest::GetResult + Unknown180 = (180 << ErrorCodeShift) | ModuleId, // IRequest::GetAppletInfo NoInternetConnection = (300 << ErrorCodeShift) | ModuleId, - ObjectIsNull = (350 << ErrorCodeShift) | ModuleId + ObjectIsNull = (350 << ErrorCodeShift) | ModuleId, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/GeneralService/GeneralServiceManager.cs b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/GeneralService/GeneralServiceManager.cs index bbb218bb..5f26f211 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/GeneralService/GeneralServiceManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/GeneralService/GeneralServiceManager.cs @@ -5,7 +5,7 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.GeneralService { static class GeneralServiceManager { - private static List<GeneralServiceDetail> _generalServices = new List<GeneralServiceDetail>(); + private static readonly List<GeneralServiceDetail> _generalServices = new(); public static int Count { @@ -27,4 +27,4 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.GeneralService return _generalServices.First(item => item.ClientId == clientId); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/GeneralService/Types/GeneralServiceDetail.cs b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/GeneralService/Types/GeneralServiceDetail.cs index 3cf55345..fab15851 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/GeneralService/Types/GeneralServiceDetail.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/GeneralService/Types/GeneralServiceDetail.cs @@ -2,7 +2,7 @@ { class GeneralServiceDetail { - public int ClientId; + public int ClientId; public bool IsAnyInternetRequestAccepted; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs index e9712e92..581a2906 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs @@ -11,7 +11,7 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService { class IGeneralService : DisposableIpcService { - private GeneralServiceDetail _generalServiceDetail; + private readonly GeneralServiceDetail _generalServiceDetail; private IPInterfaceProperties _targetPropertiesCache = null; private UnicastIPAddressInformation _targetAddressInfoCache = null; @@ -21,11 +21,11 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService { _generalServiceDetail = new GeneralServiceDetail { - ClientId = GeneralServiceManager.Count, - IsAnyInternetRequestAccepted = true // NOTE: Why not accept any internet request? + ClientId = GeneralServiceManager.Count, + IsAnyInternetRequestAccepted = true, // NOTE: Why not accept any internet request? }; - NetworkChange.NetworkAddressChanged += new NetworkAddressChangedEventHandler(LocalInterfaceCacheHandler); + NetworkChange.NetworkAddressChanged += LocalInterfaceCacheHandler; GeneralServiceManager.Add(_generalServiceDetail); } @@ -76,13 +76,13 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize((uint)Unsafe.SizeOf<NetworkProfileData>()); - NetworkProfileData networkProfile = new NetworkProfileData + NetworkProfileData networkProfile = new() { - Uuid = UInt128Utils.CreateRandom() + Uuid = UInt128Utils.CreateRandom(), }; networkProfile.IpSettingData.IpAddressSetting = new IpAddressSetting(interfaceProperties, unicastAddress); - networkProfile.IpSettingData.DnsSetting = new DnsSetting(interfaceProperties); + networkProfile.IpSettingData.DnsSetting = new DnsSetting(interfaceProperties); "RyujinxNetwork"u8.CopyTo(networkProfile.Name.AsSpan()); @@ -137,11 +137,11 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService return ResultCode.NoInternetConnection; } - InternetConnectionStatus internetConnectionStatus = new InternetConnectionStatus + InternetConnectionStatus internetConnectionStatus = new() { - Type = InternetConnectionType.WiFi, + Type = InternetConnectionType.WiFi, WifiStrength = 3, - State = InternetConnectionState.Connected, + State = InternetConnectionState.Connected, }; context.ResponseData.WriteStruct(internetConnectionStatus); @@ -154,7 +154,9 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService public ResultCode IsAnyInternetRequestAccepted(ServiceCtx context) { ulong position = context.Request.PtrBuff[0].Position; - ulong size = context.Request.PtrBuff[0].Size; +#pragma warning disable IDE0059 // Remove unnecessary value assignment + ulong size = context.Request.PtrBuff[0].Size; +#pragma warning restore IDE0059 int clientId = context.Memory.Read<int>(position); @@ -184,9 +186,9 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService private void LocalInterfaceCacheHandler(object sender, EventArgs e) { - Logger.Info?.Print(LogClass.ServiceNifm, $"NetworkAddress changed, invalidating cached data."); + Logger.Info?.Print(LogClass.ServiceNifm, "NetworkAddress changed, invalidating cached data."); - _targetPropertiesCache = null; + _targetPropertiesCache = null; _targetAddressInfoCache = null; } @@ -200,4 +202,4 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IRequest.cs b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IRequest.cs index 87aad30b..577d0382 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IRequest.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IRequest.cs @@ -12,16 +12,18 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService { Error = 1, OnHold = 2, - Available = 3 + Available = 3, } - private KEvent _event0; - private KEvent _event1; + private readonly KEvent _event0; + private readonly KEvent _event1; private int _event0Handle; private int _event1Handle; - private uint _version; +#pragma warning disable IDE0052 // Remove unread private member + private readonly uint _version; +#pragma warning restore IDE0052 public IRequest(Horizon system, uint version) { @@ -116,7 +118,9 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService // GetAppletInfo(u32) -> (u32, u32, u32, buffer<bytes, 6>) public ResultCode GetAppletInfo(ServiceCtx context) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment uint themeColor = context.RequestData.ReadUInt32(); +#pragma warning restore IDE0059 Logger.Stub?.PrintStub(LogClass.ServiceNifm); @@ -139,4 +143,4 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/DnsSetting.cs b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/DnsSetting.cs index 374558ea..4a9d782d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/DnsSetting.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/DnsSetting.cs @@ -8,7 +8,7 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types struct DnsSetting { [MarshalAs(UnmanagedType.U1)] - public bool IsDynamicDnsEnabled; + public bool IsDynamicDnsEnabled; public IpV4Address PrimaryDns; public IpV4Address SecondaryDns; @@ -18,14 +18,14 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types if (interfaceProperties.DnsAddresses.Count == 0) { - PrimaryDns = new IpV4Address(); + PrimaryDns = new IpV4Address(); SecondaryDns = new IpV4Address(); } else { - PrimaryDns = new IpV4Address(interfaceProperties.DnsAddresses[0]); + PrimaryDns = new IpV4Address(interfaceProperties.DnsAddresses[0]); SecondaryDns = new IpV4Address(interfaceProperties.DnsAddresses[interfaceProperties.DnsAddresses.Count > 1 ? 1 : 0]); } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/InternetConnectionState.cs b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/InternetConnectionState.cs index dfb8f76c..8c9efa61 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/InternetConnectionState.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/InternetConnectionState.cs @@ -6,6 +6,6 @@ ConnectingType1 = 1, ConnectingType2 = 2, ConnectingType3 = 3, - Connected = 4, + Connected = 4, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/InternetConnectionStatus.cs b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/InternetConnectionStatus.cs index ff944eca..1bf41fc6 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/InternetConnectionStatus.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/InternetConnectionStatus.cs @@ -5,8 +5,8 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types [StructLayout(LayoutKind.Sequential)] struct InternetConnectionStatus { - public InternetConnectionType Type; - public byte WifiStrength; + public InternetConnectionType Type; + public byte WifiStrength; public InternetConnectionState State; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/InternetConnectionType.cs b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/InternetConnectionType.cs index af2bcfa1..ab03382d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/InternetConnectionType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/InternetConnectionType.cs @@ -2,8 +2,8 @@ { enum InternetConnectionType : byte { - Invalid = 0, - WiFi = 1, + Invalid = 0, + WiFi = 1, Ethernet = 2, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/IpAddressSetting.cs b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/IpAddressSetting.cs index 59c1f6a7..5ea9d849 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/IpAddressSetting.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/IpAddressSetting.cs @@ -8,17 +8,17 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types struct IpAddressSetting { [MarshalAs(UnmanagedType.U1)] - public bool IsDhcpEnabled; + public bool IsDhcpEnabled; public IpV4Address Address; public IpV4Address IPv4Mask; public IpV4Address GatewayAddress; public IpAddressSetting(IPInterfaceProperties interfaceProperties, UnicastIPAddressInformation unicastIPAddressInformation) { - IsDhcpEnabled = OperatingSystem.IsMacOS() || interfaceProperties.DhcpServerAddresses.Count != 0; - Address = new IpV4Address(unicastIPAddressInformation.Address); - IPv4Mask = new IpV4Address(unicastIPAddressInformation.IPv4Mask); + IsDhcpEnabled = OperatingSystem.IsMacOS() || interfaceProperties.DhcpServerAddresses.Count != 0; + Address = new IpV4Address(unicastIPAddressInformation.Address); + IPv4Mask = new IpV4Address(unicastIPAddressInformation.IPv4Mask); GatewayAddress = (interfaceProperties.GatewayAddresses.Count == 0) ? new IpV4Address() : new IpV4Address(interfaceProperties.GatewayAddresses[0].Address); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/IpSettingData.cs b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/IpSettingData.cs index 8ffe824c..328dc7da 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/IpSettingData.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/IpSettingData.cs @@ -6,8 +6,8 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types struct IpSettingData { public IpAddressSetting IpAddressSetting; - public DnsSetting DnsSetting; - public ProxySetting ProxySetting; - public short Mtu; + public DnsSetting DnsSetting; + public ProxySetting ProxySetting; + public short Mtu; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/NetworkProfileData.cs b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/NetworkProfileData.cs index e270c10a..12a1c30f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/NetworkProfileData.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/NetworkProfileData.cs @@ -7,11 +7,11 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types [StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0x17C)] struct NetworkProfileData { - public IpSettingData IpSettingData; - public UInt128 Uuid; - public Array64<byte> Name; - public Array4<byte> Unknown; + public IpSettingData IpSettingData; + public UInt128 Uuid; + public Array64<byte> Name; + public Array4<byte> Unknown; public WirelessSettingData WirelessSettingData; - public byte Padding; + public byte Padding; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/ProxySetting.cs b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/ProxySetting.cs index 6e534fe1..909138e8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/ProxySetting.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/ProxySetting.cs @@ -9,19 +9,19 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types public struct ProxySetting { [MarshalAs(UnmanagedType.I1)] - public bool Enabled; - private byte _padding; - public short Port; - private NameStruct _name; + public bool Enabled; + private readonly byte _padding; + public short Port; + private NameStruct _name; [MarshalAs(UnmanagedType.I1)] - public bool AutoAuthEnabled; - public Array32<byte> User; - public Array32<byte> Pass; - private byte _padding2; + public bool AutoAuthEnabled; + public Array32<byte> User; + public Array32<byte> Pass; + private readonly byte _padding2; [StructLayout(LayoutKind.Sequential, Size = 0x64)] private struct NameStruct { } public Span<byte> Name => SpanHelpers.AsSpan<NameStruct, byte>(ref _name); } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/WirelessSettingData.cs b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/WirelessSettingData.cs index 8aa122c7..53855a4e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/WirelessSettingData.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/WirelessSettingData.cs @@ -6,10 +6,10 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types [StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0x65)] struct WirelessSettingData { - public byte SsidLength; + public byte SsidLength; public Array32<byte> Ssid; - public Array3<byte> Unknown; + public Array3<byte> Unknown; public Array64<byte> Passphrase1; - public byte Passphrase2; + public byte Passphrase2; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nim/INetworkInstallManager.cs b/src/Ryujinx.HLE/HOS/Services/Nim/INetworkInstallManager.cs index ad79ca0d..7ed1ffa6 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nim/INetworkInstallManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nim/INetworkInstallManager.cs @@ -5,4 +5,4 @@ { public INetworkInstallManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessServer.cs b/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessServer.cs index ab17871f..29a47baf 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessServer.cs @@ -18,4 +18,4 @@ namespace Ryujinx.HLE.HOS.Services.Nim.ShopServiceAccessServerInterface return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessServerInterface.cs b/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessServerInterface.cs index 950004fa..847a432e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessServerInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessServerInterface.cs @@ -41,4 +41,4 @@ namespace Ryujinx.HLE.HOS.Services.Nim return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessSystemInterface.cs b/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessSystemInterface.cs index bf201b98..a57677ae 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessSystemInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessSystemInterface.cs @@ -5,4 +5,4 @@ { public IShopServiceAccessSystemInterface(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessor.cs b/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessor.cs index 3c0136fa..4d3002cc 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessor.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAccessor.cs @@ -39,4 +39,4 @@ namespace Ryujinx.HLE.HOS.Services.Nim.ShopServiceAccessServerInterface.ShopServ return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAsync.cs b/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAsync.cs index 81d892c5..150d48d4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAsync.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceAsync.cs @@ -4,4 +4,4 @@ { public IShopServiceAsync() { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceManager.cs b/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceManager.cs index 2420615a..b5a2f6b5 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nim/IShopServiceManager.cs @@ -5,4 +5,4 @@ { public IShopServiceManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nim/Ntc/IStaticService.cs b/src/Ryujinx.HLE/HOS/Services/Nim/Ntc/IStaticService.cs index 4a63615b..2b078be7 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nim/Ntc/IStaticService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nim/Ntc/IStaticService.cs @@ -21,4 +21,4 @@ namespace Ryujinx.HLE.HOS.Services.Nim.Ntc return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nim/Ntc/StaticService/IEnsureNetworkClockAvailabilityService.cs b/src/Ryujinx.HLE/HOS/Services/Nim/Ntc/StaticService/IEnsureNetworkClockAvailabilityService.cs index 82d0b5a8..9fee7b1a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nim/Ntc/StaticService/IEnsureNetworkClockAvailabilityService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nim/Ntc/StaticService/IEnsureNetworkClockAvailabilityService.cs @@ -8,13 +8,13 @@ namespace Ryujinx.HLE.HOS.Services.Nim.Ntc.StaticService { class IEnsureNetworkClockAvailabilityService : IpcService { - private KEvent _finishNotificationEvent; + private readonly KEvent _finishNotificationEvent; private ResultCode _taskResultCode; public IEnsureNetworkClockAvailabilityService(ServiceCtx context) { _finishNotificationEvent = new KEvent(context.Device.System.KernelContext); - _taskResultCode = ResultCode.Success; + _taskResultCode = ResultCode.Success; // NOTE: The service starts a thread that polls Nintendo NTP server and syncs the time with it. // Additionnally it gets and uses some settings too: @@ -74,4 +74,4 @@ namespace Ryujinx.HLE.HOS.Services.Nim.Ntc.StaticService return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nim/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Nim/ResultCode.cs index 166e39a3..3fcb9024 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nim/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nim/ResultCode.cs @@ -2,11 +2,11 @@ namespace Ryujinx.HLE.HOS.Services.Nim { enum ResultCode { - ModuleId = 137, + ModuleId = 137, ErrorCodeShift = 9, Success = 0, - NullArgument = (90 << ErrorCodeShift) | ModuleId + NullArgument = (90 << ErrorCodeShift) | ModuleId, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Notification/INotificationServicesForApplication.cs b/src/Ryujinx.HLE/HOS/Services/Notification/INotificationServicesForApplication.cs index c4a35b29..0d77dd6e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Notification/INotificationServicesForApplication.cs +++ b/src/Ryujinx.HLE/HOS/Services/Notification/INotificationServicesForApplication.cs @@ -5,4 +5,4 @@ { public INotificationServicesForApplication(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Notification/INotificationServicesForSystem.cs b/src/Ryujinx.HLE/HOS/Services/Notification/INotificationServicesForSystem.cs index 0939dff6..8dc1dac3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Notification/INotificationServicesForSystem.cs +++ b/src/Ryujinx.HLE/HOS/Services/Notification/INotificationServicesForSystem.cs @@ -5,4 +5,4 @@ { public INotificationServicesForSystem(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Npns/INpnsSystem.cs b/src/Ryujinx.HLE/HOS/Services/Npns/INpnsSystem.cs index fd8ccfb5..53c5b539 100644 --- a/src/Ryujinx.HLE/HOS/Services/Npns/INpnsSystem.cs +++ b/src/Ryujinx.HLE/HOS/Services/Npns/INpnsSystem.cs @@ -5,4 +5,4 @@ { public INpnsSystem(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Npns/INpnsUser.cs b/src/Ryujinx.HLE/HOS/Services/Npns/INpnsUser.cs index 68e76938..cfa25255 100644 --- a/src/Ryujinx.HLE/HOS/Services/Npns/INpnsUser.cs +++ b/src/Ryujinx.HLE/HOS/Services/Npns/INpnsUser.cs @@ -5,4 +5,4 @@ { public INpnsUser(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ns/Aoc/IAddOnContentManager.cs b/src/Ryujinx.HLE/HOS/Services/Ns/Aoc/IAddOnContentManager.cs index b4b5bb1f..083a8321 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ns/Aoc/IAddOnContentManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ns/Aoc/IAddOnContentManager.cs @@ -11,11 +11,11 @@ namespace Ryujinx.HLE.HOS.Services.Ns.Aoc class IAddOnContentManager : IpcService { private readonly KEvent _addOnContentListChangedEvent; - private int _addOnContentListChangedEventHandle; + private int _addOnContentListChangedEventHandle; private ulong _addOnContentBaseId; - private List<ulong> _mountedAocTitleIds = new List<ulong>(); + private readonly List<ulong> _mountedAocTitleIds = new(); public IAddOnContentManager(ServiceCtx context) { @@ -44,7 +44,9 @@ namespace Ryujinx.HLE.HOS.Services.Ns.Aoc // CountAddOnContent(pid) -> u32 public ResultCode CountAddOnContent(ServiceCtx context) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment ulong pid = context.Request.HandleDesc.PId; +#pragma warning restore IDE0059 // NOTE: Service call arp:r GetApplicationLaunchProperty to get TitleId using the PId. @@ -55,7 +57,9 @@ namespace Ryujinx.HLE.HOS.Services.Ns.Aoc // ListAddOnContent(u32 start_index, u32 buffer_size, pid) -> (u32 count, buffer<u32>) public ResultCode ListAddOnContent(ServiceCtx context) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment ulong pid = context.Request.HandleDesc.PId; +#pragma warning restore IDE0059 // NOTE: Service call arp:r GetApplicationLaunchProperty to get TitleId using the PId. @@ -75,7 +79,9 @@ namespace Ryujinx.HLE.HOS.Services.Ns.Aoc // GetAddOnContentBaseId(pid) -> u64 public ResultCode GetAddOnContentBaseId(ServiceCtx context) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment ulong pid = context.Request.HandleDesc.PId; +#pragma warning restore IDE0059 // NOTE: Service call arp:r GetApplicationLaunchProperty to get TitleId using the PId. @@ -95,7 +101,9 @@ namespace Ryujinx.HLE.HOS.Services.Ns.Aoc // PrepareAddOnContent(u32 index, pid) public ResultCode PrepareAddOnContent(ServiceCtx context) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment ulong pid = context.Request.HandleDesc.PId; +#pragma warning restore IDE0059 // NOTE: Service call arp:r GetApplicationLaunchProperty to get TitleId using the PId. @@ -123,7 +131,9 @@ namespace Ryujinx.HLE.HOS.Services.Ns.Aoc // GetAddOnContentListChangedEventWithProcessId(pid) -> handle<copy> public ResultCode GetAddOnContentListChangedEventWithProcessId(ServiceCtx context) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment ulong pid = context.Request.HandleDesc.PId; +#pragma warning restore IDE0059 // NOTE: Service call arp:r GetApplicationLaunchProperty to get TitleId using the PId. @@ -142,7 +152,9 @@ namespace Ryujinx.HLE.HOS.Services.Ns.Aoc // NotifyMountAddOnContent(pid, u64 title_id) public ResultCode NotifyMountAddOnContent(ServiceCtx context) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment ulong pid = context.Request.HandleDesc.PId; +#pragma warning restore IDE0059 // NOTE: Service call arp:r GetApplicationLaunchProperty to get TitleId using the PId. @@ -160,7 +172,9 @@ namespace Ryujinx.HLE.HOS.Services.Ns.Aoc // NotifyUnmountAddOnContent(pid, u64 title_id) public ResultCode NotifyUnmountAddOnContent(ServiceCtx context) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment ulong pid = context.Request.HandleDesc.PId; +#pragma warning restore IDE0059 // NOTE: Service call arp:r GetApplicationLaunchProperty to get TitleId using the PId. @@ -175,7 +189,9 @@ namespace Ryujinx.HLE.HOS.Services.Ns.Aoc // CheckAddOnContentMountStatus(pid) public ResultCode CheckAddOnContentMountStatus(ServiceCtx context) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment ulong pid = context.Request.HandleDesc.PId; +#pragma warning restore IDE0059 // NOTE: Service call arp:r GetApplicationLaunchProperty to get TitleId using the PId. // Then it does some internal checks and returns InvalidBufferSize if they fail. @@ -239,10 +255,10 @@ namespace Ryujinx.HLE.HOS.Services.Ns.Aoc // NOTE: Service call sys:set GetQuestFlag and store it internally. // If QuestFlag is true, counts some extra titles. - uint startIndex = context.RequestData.ReadUInt32(); - uint indexNumber = context.RequestData.ReadUInt32(); + uint startIndex = context.RequestData.ReadUInt32(); + uint indexNumber = context.RequestData.ReadUInt32(); ulong bufferPosition = context.Request.ReceiveBuff[0].Position; - ulong bufferSize = context.Request.ReceiveBuff[0].Size; + ulong bufferSize = context.Request.ReceiveBuff[0].Size; // TODO: This should use _addOnContentBaseId; uint aocTotalCount = (uint)context.Device.System.ContentManager.GetAocCount(); @@ -343,4 +359,4 @@ namespace Ryujinx.HLE.HOS.Services.Ns.Aoc return ((ulong)errorCode & 0x1FF | ((((ulong)errorCode >> 9) & 0x1FFF) << 32)) + 2000; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ns/Aoc/IContentsServiceManager.cs b/src/Ryujinx.HLE/HOS/Services/Ns/Aoc/IContentsServiceManager.cs index cb8903d4..40b0b2a8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ns/Aoc/IContentsServiceManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ns/Aoc/IContentsServiceManager.cs @@ -4,4 +4,4 @@ namespace Ryujinx.HLE.HOS.Services.Ns.Aoc { public IContentsServiceManager() { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ns/Aoc/IPurchaseEventManager.cs b/src/Ryujinx.HLE/HOS/Services/Ns/Aoc/IPurchaseEventManager.cs index 1673fafc..c92a10d6 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ns/Aoc/IPurchaseEventManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ns/Aoc/IPurchaseEventManager.cs @@ -19,9 +19,9 @@ namespace Ryujinx.HLE.HOS.Services.Ns.Aoc // SetDefaultDeliveryTarget(pid, buffer<bytes, 5> unknown) public ResultCode SetDefaultDeliveryTarget(ServiceCtx context) { - ulong inBufferPosition = context.Request.SendBuff[0].Position; - ulong inBufferSize = context.Request.SendBuff[0].Size; - byte[] buffer = new byte[inBufferSize]; + ulong inBufferPosition = context.Request.SendBuff[0].Position; + ulong inBufferSize = context.Request.SendBuff[0].Size; + byte[] buffer = new byte[inBufferSize]; context.Memory.Read(inBufferPosition, buffer); @@ -65,4 +65,4 @@ namespace Ryujinx.HLE.HOS.Services.Ns.Aoc return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ns/Aoc/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Ns/Aoc/ResultCode.cs index 7602ecb3..b795a756 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ns/Aoc/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ns/Aoc/ResultCode.cs @@ -2,12 +2,12 @@ namespace Ryujinx.HLE.HOS.Services.Ns.Aoc { enum ResultCode { - ModuleId = 166, + ModuleId = 166, ErrorCodeShift = 9, Success = 0, InvalidBufferSize = (200 << ErrorCodeShift) | ModuleId, - InvalidPid = (300 << ErrorCodeShift) | ModuleId + InvalidPid = (300 << ErrorCodeShift) | ModuleId, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ns/IApplicationManagerInterface.cs b/src/Ryujinx.HLE/HOS/Services/Ns/IApplicationManagerInterface.cs index 06e911f8..a8a2a8e0 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ns/IApplicationManagerInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ns/IApplicationManagerInterface.cs @@ -1,6 +1,5 @@ using LibHac.Ns; using Ryujinx.Common.Utilities; -using System; namespace Ryujinx.HLE.HOS.Services.Ns { @@ -13,8 +12,10 @@ namespace Ryujinx.HLE.HOS.Services.Ns // GetApplicationControlData(u8, u64) -> (unknown<4>, buffer<unknown, 6>) public ResultCode GetApplicationControlData(ServiceCtx context) { - byte source = (byte)context.RequestData.ReadInt64(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment + byte source = (byte)context.RequestData.ReadInt64(); ulong titleId = context.RequestData.ReadUInt64(); +#pragma warning restore IDE0059 ulong position = context.Request.ReceiveBuff[0].Position; @@ -25,4 +26,4 @@ namespace Ryujinx.HLE.HOS.Services.Ns return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ns/IDevelopInterface.cs b/src/Ryujinx.HLE/HOS/Services/Ns/IDevelopInterface.cs index c74ebd69..8f0f6cbe 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ns/IDevelopInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ns/IDevelopInterface.cs @@ -5,4 +5,4 @@ namespace Ryujinx.HLE.HOS.Services.Ns { public IDevelopInterface(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ns/IReadOnlyApplicationControlDataInterface.cs b/src/Ryujinx.HLE/HOS/Services/Ns/IReadOnlyApplicationControlDataInterface.cs index aa37a1e7..8327d619 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ns/IReadOnlyApplicationControlDataInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ns/IReadOnlyApplicationControlDataInterface.cs @@ -11,8 +11,10 @@ namespace Ryujinx.HLE.HOS.Services.Ns // GetApplicationControlData(u8, u64) -> (unknown<4>, buffer<unknown, 6>) public ResultCode GetApplicationControlData(ServiceCtx context) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment byte source = (byte)context.RequestData.ReadInt64(); ulong titleId = context.RequestData.ReadUInt64(); +#pragma warning restore IDE0059 ulong position = context.Request.ReceiveBuff[0].Position; diff --git a/src/Ryujinx.HLE/HOS/Services/Ns/IServiceGetterInterface.cs b/src/Ryujinx.HLE/HOS/Services/Ns/IServiceGetterInterface.cs index 886bffdd..e45c6750 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ns/IServiceGetterInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ns/IServiceGetterInterface.cs @@ -27,4 +27,4 @@ namespace Ryujinx.HLE.HOS.Services.Ns return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ns/ISystemUpdateInterface.cs b/src/Ryujinx.HLE/HOS/Services/Ns/ISystemUpdateInterface.cs index 84ed3d0f..1108778c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ns/ISystemUpdateInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ns/ISystemUpdateInterface.cs @@ -5,4 +5,4 @@ namespace Ryujinx.HLE.HOS.Services.Ns { public ISystemUpdateInterface(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ns/IVulnerabilityManagerInterface.cs b/src/Ryujinx.HLE/HOS/Services/Ns/IVulnerabilityManagerInterface.cs index 0b640992..c1ec50bc 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ns/IVulnerabilityManagerInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ns/IVulnerabilityManagerInterface.cs @@ -5,4 +5,4 @@ namespace Ryujinx.HLE.HOS.Services.Ns { public IVulnerabilityManagerInterface(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/Host1xContext.cs b/src/Ryujinx.HLE/HOS/Services/Nv/Host1xContext.cs index bb609fa4..371edbec 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/Host1xContext.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/Host1xContext.cs @@ -11,7 +11,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv { public MemoryManager Smmu { get; } public NvMemoryAllocator MemoryAllocator { get; } - public Host1xDevice Host1x { get;} + public Host1xDevice Host1x { get; } public Host1xContext(GpuContext gpu, ulong pid) { @@ -29,4 +29,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv Host1x.Dispose(); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/INvDrvDebugFSServices.cs b/src/Ryujinx.HLE/HOS/Services/Nv/INvDrvDebugFSServices.cs index dffe8783..22d0aacc 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/INvDrvDebugFSServices.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/INvDrvDebugFSServices.cs @@ -5,4 +5,4 @@ { public INvDrvDebugFSServices(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs b/src/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs index 1d075d43..a0df66d0 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs @@ -25,13 +25,13 @@ namespace Ryujinx.HLE.HOS.Services.Nv [Service("nvdrv:t")] class INvDrvServices : IpcService { - private static readonly List<string> _deviceFileDebugRegistry = new List<string>() + private static readonly List<string> _deviceFileDebugRegistry = new() { "/dev/nvhost-dbg-gpu", - "/dev/nvhost-prof-gpu" + "/dev/nvhost-prof-gpu", }; - private static readonly Dictionary<string, Type> _deviceFileRegistry = new Dictionary<string, Type>() + private static readonly Dictionary<string, Type> _deviceFileRegistry = new() { { "/dev/nvmap", typeof(NvMapDeviceFile) }, { "/dev/nvhost-ctrl", typeof(NvHostCtrlDeviceFile) }, @@ -47,7 +47,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv { "/dev/nvhost-prof-gpu", typeof(NvHostProfGpuDeviceFile) }, }; - public static IdDictionary DeviceFileIdRegistry = new IdDictionary(); + public static IdDictionary DeviceFileIdRegistry = new(); private IVirtualMemoryManager _clientMemory; private ulong _owner; @@ -55,7 +55,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv private bool _transferMemInitialized = false; // TODO: This should call set:sys::GetDebugModeFlag - private bool _debugModeEnabled = false; + private readonly bool _debugModeEnabled = false; public INvDrvServices(ServiceCtx context) : base(context.Device.System.NvDrvServer) { @@ -73,7 +73,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv if (_deviceFileRegistry.TryGetValue(path, out Type deviceFileClass)) { - ConstructorInfo constructor = deviceFileClass.GetConstructor(new Type[] { typeof(ServiceCtx), typeof(IVirtualMemoryManager), typeof(ulong) }); + ConstructorInfo constructor = deviceFileClass.GetConstructor(new[] { typeof(ServiceCtx), typeof(IVirtualMemoryManager), typeof(ulong) }); NvDeviceFile deviceFile = (NvDeviceFile)constructor.Invoke(new object[] { context, _clientMemory, _owner }); @@ -91,13 +91,15 @@ namespace Ryujinx.HLE.HOS.Services.Nv private NvResult GetIoctlArgument(ServiceCtx context, NvIoctl ioctlCommand, out Span<byte> arguments) { - (ulong inputDataPosition, ulong inputDataSize) = context.Request.GetBufferType0x21(0); + (ulong inputDataPosition, ulong inputDataSize) = context.Request.GetBufferType0x21(0); +#pragma warning disable IDE0059 // Remove unnecessary value assignment (ulong outputDataPosition, ulong outputDataSize) = context.Request.GetBufferType0x22(0); +#pragma warning restore IDE0059 NvIoctl.Direction ioctlDirection = ioctlCommand.DirectionValue; - uint ioctlSize = ioctlCommand.Size; + uint ioctlSize = ioctlCommand.Size; - bool isRead = (ioctlDirection & NvIoctl.Direction.Read) != 0; + bool isRead = (ioctlDirection & NvIoctl.Direction.Read) != 0; bool isWrite = (ioctlDirection & NvIoctl.Direction.Write) != 0; if ((isWrite && ioctlSize > outputDataSize) || (isRead && ioctlSize > inputDataSize)) @@ -186,53 +188,29 @@ namespace Ryujinx.HLE.HOS.Services.Nv return NvResult.Success; } - private static NvResult ConvertInternalErrorCode(NvInternalResult errorCode) + private NvResult ConvertInternalErrorCode(NvInternalResult errorCode) { - switch (errorCode) + return errorCode switch { - case NvInternalResult.Success: - return NvResult.Success; - case NvInternalResult.Unknown0x72: - return NvResult.AlreadyAllocated; - case NvInternalResult.TimedOut: - case NvInternalResult.TryAgain: - case NvInternalResult.Interrupted: - return NvResult.Timeout; - case NvInternalResult.InvalidAddress: - return NvResult.InvalidAddress; - case NvInternalResult.NotSupported: - case NvInternalResult.Unknown0x18: - return NvResult.NotSupported; - case NvInternalResult.InvalidState: - return NvResult.InvalidState; - case NvInternalResult.ReadOnlyAttribute: - return NvResult.ReadOnlyAttribute; - case NvInternalResult.NoSpaceLeft: - case NvInternalResult.FileTooBig: - return NvResult.InvalidSize; - case NvInternalResult.FileTableOverflow: - case NvInternalResult.BadFileNumber: - return NvResult.FileOperationFailed; - case NvInternalResult.InvalidInput: - return NvResult.InvalidValue; - case NvInternalResult.NotADirectory: - return NvResult.DirectoryOperationFailed; - case NvInternalResult.Busy: - return NvResult.Busy; - case NvInternalResult.BadAddress: - return NvResult.InvalidAddress; - case NvInternalResult.AccessDenied: - case NvInternalResult.OperationNotPermitted: - return NvResult.AccessDenied; - case NvInternalResult.OutOfMemory: - return NvResult.InsufficientMemory; - case NvInternalResult.DeviceNotFound: - return NvResult.ModuleNotPresent; - case NvInternalResult.IoError: - return NvResult.ResourceError; - default: - return NvResult.IoctlFailed; - } + NvInternalResult.Success => NvResult.Success, + NvInternalResult.Unknown0x72 => NvResult.AlreadyAllocated, + NvInternalResult.TimedOut or NvInternalResult.TryAgain or NvInternalResult.Interrupted => NvResult.Timeout, + NvInternalResult.InvalidAddress => NvResult.InvalidAddress, + NvInternalResult.NotSupported or NvInternalResult.Unknown0x18 => NvResult.NotSupported, + NvInternalResult.InvalidState => NvResult.InvalidState, + NvInternalResult.ReadOnlyAttribute => NvResult.ReadOnlyAttribute, + NvInternalResult.NoSpaceLeft or NvInternalResult.FileTooBig => NvResult.InvalidSize, + NvInternalResult.FileTableOverflow or NvInternalResult.BadFileNumber => NvResult.FileOperationFailed, + NvInternalResult.InvalidInput => NvResult.InvalidValue, + NvInternalResult.NotADirectory => NvResult.DirectoryOperationFailed, + NvInternalResult.Busy => NvResult.Busy, + NvInternalResult.BadAddress => NvResult.InvalidAddress, + NvInternalResult.AccessDenied or NvInternalResult.OperationNotPermitted => NvResult.AccessDenied, + NvInternalResult.OutOfMemory => NvResult.InsufficientMemory, + NvInternalResult.DeviceNotFound => NvResult.ModuleNotPresent, + NvInternalResult.IoError => NvResult.ResourceError, + _ => NvResult.IoctlFailed, + }; } [CommandCmif(0)] @@ -240,7 +218,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv public ResultCode Open(ServiceCtx context) { NvResult errorCode = EnsureInitialized(); - int fd = -1; + int fd = -1; if (errorCode == NvResult.Success) { @@ -266,7 +244,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv if (errorCode == NvResult.Success) { - int fd = context.RequestData.ReadInt32(); + int fd = context.RequestData.ReadInt32(); NvIoctl ioctlCommand = context.RequestData.ReadStruct<NvIoctl>(); errorCode = GetIoctlArgument(context, ioctlCommand, out Span<byte> arguments); @@ -328,8 +306,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv // Initialize(u32 transfer_memory_size, handle<copy, process> current_process, handle<copy, transfer_memory> transfer_memory) -> u32 error_code public ResultCode Initialize(ServiceCtx context) { - long transferMemSize = context.RequestData.ReadInt64(); - int transferMemHandle = context.Request.HandleDesc.ToCopy[1]; +#pragma warning disable IDE0059 // Remove unnecessary value assignment + long transferMemSize = context.RequestData.ReadInt64(); +#pragma warning restore IDE0059 + int transferMemHandle = context.Request.HandleDesc.ToCopy[1]; // TODO: When transfer memory will be implemented, this could be removed. _transferMemInitialized = true; @@ -357,7 +337,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv if (errorCode == NvResult.Success) { - int fd = context.RequestData.ReadInt32(); + int fd = context.RequestData.ReadInt32(); uint eventId = context.RequestData.ReadUInt32(); errorCode = GetDeviceFileFromFd(fd, out NvDeviceFile deviceFile); @@ -393,9 +373,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv if (errorCode == NvResult.Success) { - int fd = context.RequestData.ReadInt32(); - uint argument = context.RequestData.ReadUInt32(); - int sharedMemoryHandle = context.Request.HandleDesc.ToCopy[0]; + int fd = context.RequestData.ReadInt32(); + uint argument = context.RequestData.ReadUInt32(); + int sharedMemoryHandle = context.Request.HandleDesc.ToCopy[0]; errorCode = GetDeviceFileFromFd(fd, out NvDeviceFile deviceFile); @@ -418,12 +398,12 @@ namespace Ryujinx.HLE.HOS.Services.Nv if (_transferMemInitialized) { // TODO: Populate values when more RE will be done. - NvStatus nvStatus = new NvStatus + NvStatus nvStatus = new() { MemoryValue1 = 0, // GetMemStats(transfer_memory + 0x60, 3) MemoryValue2 = 0, // GetMemStats(transfer_memory + 0x60, 5) MemoryValue3 = 0, // transfer_memory + 0x78 - MemoryValue4 = 0 // transfer_memory + 0x80 + MemoryValue4 = 0, // transfer_memory + 0x80 }; context.ResponseData.WriteStruct(nvStatus); @@ -450,7 +430,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv // SetClientPID(u64, pid) -> u32 error_code public ResultCode SetClientPid(ServiceCtx context) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment long pid = context.RequestData.ReadInt64(); +#pragma warning restore IDE0059 context.ResponseData.Write(0); @@ -481,7 +463,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv if (errorCode == NvResult.Success) { - int fd = context.RequestData.ReadInt32(); + int fd = context.RequestData.ReadInt32(); NvIoctl ioctlCommand = context.RequestData.ReadStruct<NvIoctl>(); (ulong inlineInBufferPosition, ulong inlineInBufferSize) = context.Request.GetBufferType0x21(1); @@ -492,7 +474,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv context.Memory.Read(inlineInBufferPosition, temp); - Span<byte> inlineInBuffer = new Span<byte>(temp); + Span<byte> inlineInBuffer = new(temp); if (errorCode == NvResult.Success) { @@ -530,7 +512,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv if (errorCode == NvResult.Success) { - int fd = context.RequestData.ReadInt32(); + int fd = context.RequestData.ReadInt32(); NvIoctl ioctlCommand = context.RequestData.ReadStruct<NvIoctl>(); (ulong inlineOutBufferPosition, ulong inlineOutBufferSize) = context.Request.GetBufferType0x22(1); @@ -541,7 +523,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv context.Memory.Read(inlineOutBufferPosition, temp); - Span<byte> inlineOutBuffer = new Span<byte>(temp); + Span<byte> inlineOutBuffer = new(temp); if (errorCode == NvResult.Success) { @@ -595,4 +577,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv DeviceFileIdRegistry.Clear(); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/INvGemControl.cs b/src/Ryujinx.HLE/HOS/Services/Nv/INvGemControl.cs index 7bf99ed1..2134c026 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/INvGemControl.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/INvGemControl.cs @@ -5,4 +5,4 @@ { public INvGemControl(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/INvGemCoreDump.cs b/src/Ryujinx.HLE/HOS/Services/Nv/INvGemCoreDump.cs index ff3774da..ecbbe222 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/INvGemCoreDump.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/INvGemCoreDump.cs @@ -5,4 +5,4 @@ { public INvGemCoreDump(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvDeviceFile.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvDeviceFile.cs index 9568fc84..3eaf8a91 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvDeviceFile.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvDeviceFile.cs @@ -10,14 +10,14 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices abstract class NvDeviceFile { public readonly ServiceCtx Context; - public readonly ulong Owner; + public readonly ulong Owner; public string Path; public NvDeviceFile(ServiceCtx context, ulong owner) { Context = context; - Owner = owner; + Owner = owner; } public virtual NvInternalResult QueryEvent(out int eventHandle, uint eventId) diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/NvHostAsGpuDeviceFile.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/NvHostAsGpuDeviceFile.cs index 0e0fe7f2..db460429 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/NvHostAsGpuDeviceFile.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/NvHostAsGpuDeviceFile.cs @@ -15,7 +15,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu private const uint SmallPageSize = 0x1000; private const uint BigPageSize = 0x10000; - private static readonly uint[] _pageSizes = new uint[] { SmallPageSize, BigPageSize }; + private static readonly uint[] _pageSizes = { SmallPageSize, BigPageSize }; private const ulong SmallRegionLimit = 0x400000000UL; // 16 GiB private const ulong DefaultUserSize = 1UL << 37; @@ -32,10 +32,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu } } - private static readonly VmRegion[] _vmRegions = new VmRegion[] - { + private static readonly VmRegion[] _vmRegions = { new VmRegion((ulong)BigPageSize << 16, SmallRegionLimit), - new VmRegion(SmallRegionLimit, DefaultUserSize) + new VmRegion(SmallRegionLimit, DefaultUserSize), }; private readonly AddressSpaceContext _asContext; diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AddressSpaceContext.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AddressSpaceContext.cs index ab9d798e..36aa10f3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AddressSpaceContext.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AddressSpaceContext.cs @@ -8,24 +8,24 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types private class Range { public ulong Start { get; } - public ulong End { get; } + public ulong End { get; } public Range(ulong address, ulong size) { Start = address; - End = size + Start; + End = size + Start; } } private class MappedMemory : Range { public ulong PhysicalAddress { get; } - public bool VaAllocated { get; } + public bool VaAllocated { get; } public MappedMemory(ulong address, ulong size, ulong physicalAddress, bool vaAllocated) : base(address, size) { PhysicalAddress = physicalAddress; - VaAllocated = vaAllocated; + VaAllocated = vaAllocated; } } @@ -38,7 +38,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types { Gmm = gmm; - _maps = new SortedList<ulong, Range>(); + _maps = new SortedList<ulong, Range>(); _reservations = new SortedList<ulong, Range>(); } @@ -123,9 +123,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types return _reservations.Remove(gpuVa); } - private static Range BinarySearch(SortedList<ulong, Range> list, ulong address) + private Range BinarySearch(SortedList<ulong, Range> list, ulong address) { - int left = 0; + int left = 0; int right = list.Count - 1; while (left <= right) @@ -154,11 +154,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types return null; } - private static Range BinarySearchLt(SortedList<ulong, Range> list, ulong address) + private Range BinarySearchLt(SortedList<ulong, Range> list, ulong address) { Range ltRg = null; - int left = 0; + int left = 0; int right = list.Count - 1; while (left <= right) diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AddressSpaceFlags.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AddressSpaceFlags.cs index 611cf78b..0627d56f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AddressSpaceFlags.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AddressSpaceFlags.cs @@ -5,7 +5,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types [Flags] enum AddressSpaceFlags : uint { - FixedOffset = 1, + FixedOffset = 1, RemapSubRange = 0x100, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AllocSpaceArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AllocSpaceArguments.cs index d6dbbc26..c9d7724e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AllocSpaceArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AllocSpaceArguments.cs @@ -5,10 +5,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types [StructLayout(LayoutKind.Sequential)] struct AllocSpaceArguments { - public uint Pages; - public uint PageSize; + public uint Pages; + public uint PageSize; public AddressSpaceFlags Flags; - public uint Padding; - public ulong Offset; + public uint Padding; + public ulong Offset; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/FreeSpaceArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/FreeSpaceArguments.cs index b25d295a..56e9028e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/FreeSpaceArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/FreeSpaceArguments.cs @@ -6,7 +6,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types struct FreeSpaceArguments { public ulong Offset; - public uint Pages; - public uint PageSize; + public uint Pages; + public uint PageSize; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/InitializeExArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/InitializeExArguments.cs index 882bda59..34b80bd3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/InitializeExArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/InitializeExArguments.cs @@ -5,10 +5,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types [StructLayout(LayoutKind.Sequential)] struct InitializeExArguments { - public uint Flags; - public int AsFd; - public uint BigPageSize; - public uint Reserved; + public uint Flags; + public int AsFd; + public uint BigPageSize; + public uint Reserved; public ulong Unknown0; public ulong Unknown1; public ulong Unknown2; diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/MapBufferExArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/MapBufferExArguments.cs index 278793a0..fdeff9f8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/MapBufferExArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/MapBufferExArguments.cs @@ -6,11 +6,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types struct MapBufferExArguments { public AddressSpaceFlags Flags; - public int Kind; - public int NvMapHandle; - public int PageSize; - public ulong BufferOffset; - public ulong MappingSize; - public ulong Offset; + public int Kind; + public int NvMapHandle; + public int PageSize; + public ulong BufferOffset; + public ulong MappingSize; + public ulong Offset; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/RemapArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/RemapArguments.cs index bc149d42..1fb224ff 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/RemapArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/RemapArguments.cs @@ -7,9 +7,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types { public ushort Flags; public ushort Kind; - public int NvMapHandle; - public uint MapOffset; - public uint GpuOffset; - public uint Pages; + public int NvMapHandle; + public uint MapOffset; + public uint GpuOffset; + public uint Pages; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/UnmapBufferArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/UnmapBufferArguments.cs index 8fc4646e..46a9659d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/UnmapBufferArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/UnmapBufferArguments.cs @@ -2,7 +2,7 @@ { struct UnmapBufferArguments { -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public ulong Offset; #pragma warning restore CS0649 } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/ChannelInitialization.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/ChannelInitialization.cs index 87a06bd3..59578775 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/ChannelInitialization.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/ChannelInitialization.cs @@ -1358,4 +1358,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel channel.Write(ClassId.Twod, 0x24C, 0x100); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostChannelDeviceFile.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostChannelDeviceFile.cs index 9f16a280..bd2c5e4d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostChannelDeviceFile.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostChannelDeviceFile.cs @@ -19,9 +19,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel private const uint MaxModuleSyncpoint = 16; +#pragma warning disable IDE0052 // Remove unread private member private uint _timeout; private uint _submitTimeout; private uint _timeslice; +#pragma warning restore IDE0052 private readonly Switch _device; @@ -34,7 +36,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel public enum ResourcePolicy { Device, - Channel + Channel, } protected static uint[] DeviceSyncpoints = new uint[MaxModuleSyncpoint]; @@ -47,14 +49,14 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel public NvHostChannelDeviceFile(ServiceCtx context, IVirtualMemoryManager memory, ulong owner) : base(context, owner) { - _device = context.Device; - _memory = memory; - _timeout = 3000; + _device = context.Device; + _memory = memory; + _timeout = 3000; _submitTimeout = 0; - _timeslice = 0; + _timeslice = 0; _host1xContext = GetHost1XContext(context.Device.Gpu, owner); - _contextId = _host1xContext.Host1x.CreateContext(); - Channel = _device.Gpu.CreateChannel(); + _contextId = _host1xContext.Host1x.CreateContext(); + Channel = _device.Gpu.CreateChannel(); ChannelInitialization.InitializeState(Channel); @@ -143,12 +145,14 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel private NvInternalResult Submit(Span<byte> arguments) { - SubmitArguments submitHeader = GetSpanAndSkip<SubmitArguments>(ref arguments, 1)[0]; - Span<CommandBuffer> commandBuffers = GetSpanAndSkip<CommandBuffer>(ref arguments, submitHeader.CmdBufsCount); - Span<Reloc> relocs = GetSpanAndSkip<Reloc>(ref arguments, submitHeader.RelocsCount); - Span<uint> relocShifts = GetSpanAndSkip<uint>(ref arguments, submitHeader.RelocsCount); - Span<SyncptIncr> syncptIncrs = GetSpanAndSkip<SyncptIncr>(ref arguments, submitHeader.SyncptIncrsCount); - Span<uint> fenceThresholds = GetSpanAndSkip<uint>(ref arguments, submitHeader.FencesCount); + SubmitArguments submitHeader = GetSpanAndSkip<SubmitArguments>(ref arguments, 1)[0]; + Span<CommandBuffer> commandBuffers = GetSpanAndSkip<CommandBuffer>(ref arguments, submitHeader.CmdBufsCount); +#pragma warning disable IDE0059 // Remove unnecessary value assignment + Span<Reloc> relocs = GetSpanAndSkip<Reloc>(ref arguments, submitHeader.RelocsCount); + Span<uint> relocShifts = GetSpanAndSkip<uint>(ref arguments, submitHeader.RelocsCount); +#pragma warning restore IDE0059 + Span<SyncptIncr> syncptIncrs = GetSpanAndSkip<SyncptIncr>(ref arguments, submitHeader.SyncptIncrsCount); + Span<uint> fenceThresholds = GetSpanAndSkip<uint>(ref arguments, submitHeader.FencesCount); lock (_device) { @@ -176,9 +180,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel private Span<T> GetSpanAndSkip<T>(ref Span<byte> arguments, int count) where T : unmanaged { - Span<T> output = MemoryMarshal.Cast<byte, T>(arguments).Slice(0, count); + Span<T> output = MemoryMarshal.Cast<byte, T>(arguments)[..count]; - arguments = arguments.Slice(Unsafe.SizeOf<T>() * count); + arguments = arguments[(Unsafe.SizeOf<T>() * count)..]; return output; } @@ -227,9 +231,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel private NvInternalResult MapCommandBuffer(Span<byte> arguments) { - int headerSize = Unsafe.SizeOf<MapCommandBufferArguments>(); - MapCommandBufferArguments commandBufferHeader = MemoryMarshal.Cast<byte, MapCommandBufferArguments>(arguments)[0]; - Span<CommandBufferHandle> commandBufferEntries = MemoryMarshal.Cast<byte, CommandBufferHandle>(arguments.Slice(headerSize)).Slice(0, commandBufferHeader.NumEntries); + int headerSize = Unsafe.SizeOf<MapCommandBufferArguments>(); + MapCommandBufferArguments commandBufferHeader = MemoryMarshal.Cast<byte, MapCommandBufferArguments>(arguments)[0]; + Span<CommandBufferHandle> commandBufferEntries = MemoryMarshal.Cast<byte, CommandBufferHandle>(arguments[headerSize..])[..commandBufferHeader.NumEntries]; foreach (ref CommandBufferHandle commandBufferEntry in commandBufferEntries) { @@ -269,9 +273,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel private NvInternalResult UnmapCommandBuffer(Span<byte> arguments) { - int headerSize = Unsafe.SizeOf<MapCommandBufferArguments>(); - MapCommandBufferArguments commandBufferHeader = MemoryMarshal.Cast<byte, MapCommandBufferArguments>(arguments)[0]; - Span<CommandBufferHandle> commandBufferEntries = MemoryMarshal.Cast<byte, CommandBufferHandle>(arguments.Slice(headerSize)).Slice(0, commandBufferHeader.NumEntries); + int headerSize = Unsafe.SizeOf<MapCommandBufferArguments>(); + MapCommandBufferArguments commandBufferHeader = MemoryMarshal.Cast<byte, MapCommandBufferArguments>(arguments)[0]; + Span<CommandBufferHandle> commandBufferEntries = MemoryMarshal.Cast<byte, CommandBufferHandle>(arguments[headerSize..])[..commandBufferHeader.NumEntries]; foreach (ref CommandBufferHandle commandBufferEntry in commandBufferEntries) { @@ -320,9 +324,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel private NvInternalResult SubmitGpfifo(Span<byte> arguments) { - int headerSize = Unsafe.SizeOf<SubmitGpfifoArguments>(); + int headerSize = Unsafe.SizeOf<SubmitGpfifoArguments>(); SubmitGpfifoArguments gpfifoSubmissionHeader = MemoryMarshal.Cast<byte, SubmitGpfifoArguments>(arguments)[0]; - Span<ulong> gpfifoEntries = MemoryMarshal.Cast<byte, ulong>(arguments.Slice(headerSize)).Slice(0, gpfifoSubmissionHeader.NumEntries); + Span<ulong> gpfifoEntries = MemoryMarshal.Cast<byte, ulong>(arguments[headerSize..])[..gpfifoSubmissionHeader.NumEntries]; return SubmitGpfifo(ref gpfifoSubmissionHeader, gpfifoEntries); } @@ -473,7 +477,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel return ChannelSyncpoints[index]; } - public static uint GetSyncpointDevice(NvHostSyncpt syncpointManager, uint index, bool isClientManaged) + public uint GetSyncpointDevice(NvHostSyncpt syncpointManager, uint index, bool isClientManaged) { if (DeviceSyncpoints[index] != 0) { diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostGpuDeviceFile.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostGpuDeviceFile.cs index f33cc460..5a1d1a68 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostGpuDeviceFile.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostGpuDeviceFile.cs @@ -8,9 +8,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel { internal class NvHostGpuDeviceFile : NvHostChannelDeviceFile { - private KEvent _smExceptionBptIntReportEvent; - private KEvent _smExceptionBptPauseReportEvent; - private KEvent _errorNotifierEvent; +#pragma warning disable IDE0052 // Remove unread private member + private readonly KEvent _smExceptionBptIntReportEvent; + private readonly KEvent _smExceptionBptPauseReportEvent; + private readonly KEvent _errorNotifierEvent; +#pragma warning restore IDE0052 private int _smExceptionBptIntReportEventHandle; private int _smExceptionBptPauseReportEventHandle; @@ -18,14 +20,14 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel public NvHostGpuDeviceFile(ServiceCtx context, IVirtualMemoryManager memory, ulong owner) : base(context, memory, owner) { - _smExceptionBptIntReportEvent = CreateEvent(context, out _smExceptionBptIntReportEventHandle); + _smExceptionBptIntReportEvent = CreateEvent(context, out _smExceptionBptIntReportEventHandle); _smExceptionBptPauseReportEvent = CreateEvent(context, out _smExceptionBptPauseReportEventHandle); - _errorNotifierEvent = CreateEvent(context, out _errorNotifierEventHandle); + _errorNotifierEvent = CreateEvent(context, out _errorNotifierEventHandle); } - private static KEvent CreateEvent(ServiceCtx context, out int handle) + private KEvent CreateEvent(ServiceCtx context, out int handle) { - KEvent evnt = new KEvent(context.Device.System.KernelContext); + KEvent evnt = new(context.Device.System.KernelContext); if (context.Process.HandleTable.GenerateHandle(evnt.ReadableEvent, out handle) != Result.Success) { @@ -55,22 +57,13 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel public override NvInternalResult QueryEvent(out int eventHandle, uint eventId) { // TODO: accurately represent and implement those events. - switch (eventId) + eventHandle = eventId switch { - case 0x1: - eventHandle = _smExceptionBptIntReportEventHandle; - break; - case 0x2: - eventHandle = _smExceptionBptPauseReportEventHandle; - break; - case 0x3: - eventHandle = _errorNotifierEventHandle; - break; - default: - eventHandle = 0; - break; - } - + 0x1 => _smExceptionBptIntReportEventHandle, + 0x2 => _smExceptionBptPauseReportEventHandle, + 0x3 => _errorNotifierEventHandle, + _ => 0, + }; return eventHandle != 0 ? NvInternalResult.Success : NvInternalResult.InvalidInput; } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/AllocGpfifoExArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/AllocGpfifoExArguments.cs index 8e5a1523..37577a5f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/AllocGpfifoExArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/AllocGpfifoExArguments.cs @@ -6,12 +6,12 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel.Types [StructLayout(LayoutKind.Sequential)] struct AllocGpfifoExArguments { - public uint NumEntries; - public uint NumJobs; - public uint Flags; + public uint NumEntries; + public uint NumJobs; + public uint Flags; public NvFence Fence; - public uint Reserved1; - public uint Reserved2; - public uint Reserved3; + public uint Reserved1; + public uint Reserved2; + public uint Reserved3; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/AllocObjCtxArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/AllocObjCtxArguments.cs index fae91622..1ffbb68f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/AllocObjCtxArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/AllocObjCtxArguments.cs @@ -5,8 +5,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel.Types [StructLayout(LayoutKind.Sequential)] struct AllocObjCtxArguments { - public uint ClassNumber; - public uint Flags; + public uint ClassNumber; + public uint Flags; public ulong ObjectId; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/MapCommandBufferArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/MapCommandBufferArguments.cs index 6a7e3da8..0777e646 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/MapCommandBufferArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/MapCommandBufferArguments.cs @@ -12,10 +12,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel.Types [StructLayout(LayoutKind.Sequential, Pack = 1)] struct MapCommandBufferArguments { - public int NumEntries; - public int DataAddress; // Ignored by the driver. - public bool AttachHostChDas; - public byte Padding1; + public int NumEntries; + public int DataAddress; // Ignored by the driver. + public bool AttachHostChDas; + public byte Padding1; public short Padding2; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/NvChannel.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/NvChannel.cs index 8e2c6ca3..177f483f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/NvChannel.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/NvChannel.cs @@ -2,10 +2,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel { class NvChannel { -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public int Timeout; public int SubmitTimeout; public int Timeslice; #pragma warning restore CS0649 } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/NvChannelPriority.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/NvChannelPriority.cs index 4112a9fc..c267e2df 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/NvChannelPriority.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/NvChannelPriority.cs @@ -2,8 +2,8 @@ { enum NvChannelPriority : uint { - Low = 50, + Low = 50, Medium = 100, - High = 150 + High = 150, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/SetErrorNotifierArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/SetErrorNotifierArguments.cs index 1aba53ca..7e5a5e96 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/SetErrorNotifierArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/SetErrorNotifierArguments.cs @@ -7,7 +7,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel.Types { public ulong Offset; public ulong Size; - public uint Mem; - public uint Reserved; + public uint Mem; + public uint Reserved; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/SubmitGpfifoArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/SubmitGpfifoArguments.cs index a10abd4b..1bb08da1 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/SubmitGpfifoArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/SubmitGpfifoArguments.cs @@ -6,9 +6,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel.Types [StructLayout(LayoutKind.Sequential)] struct SubmitGpfifoArguments { - public long Address; - public int NumEntries; + public long Address; + public int NumEntries; public SubmitGpfifoFlags Flags; - public NvFence Fence; + public NvFence Fence; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/SubmitGpfifoFlags.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/SubmitGpfifoFlags.cs index d81fd386..1f060980 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/SubmitGpfifoFlags.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/SubmitGpfifoFlags.cs @@ -6,10 +6,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel.Types enum SubmitGpfifoFlags : uint { None, - FenceWait = 1 << 0, - FenceIncrement = 1 << 1, - HwFormat = 1 << 2, - SuppressWfi = 1 << 4, + FenceWait = 1 << 0, + FenceIncrement = 1 << 1, + HwFormat = 1 << 2, + SuppressWfi = 1 << 4, IncrementWithValue = 1 << 8, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/ZcullBindArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/ZcullBindArguments.cs index 19a997f4..71b12466 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/ZcullBindArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/ZcullBindArguments.cs @@ -6,7 +6,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel.Types struct ZcullBindArguments { public ulong GpuVirtualAddress; - public uint Mode; - public uint Reserved; + public uint Mode; + public uint Reserved; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/NvHostCtrlDeviceFile.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/NvHostCtrlDeviceFile.cs index f130c455..6142611e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/NvHostCtrlDeviceFile.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/NvHostCtrlDeviceFile.cs @@ -14,9 +14,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl { public const int EventsCount = 64; - private bool _isProductionMode; - private Switch _device; - private NvHostEvent[] _events; + private readonly bool _isProductionMode; + private readonly Switch _device; + private readonly NvHostEvent[] _events; public NvHostCtrlDeviceFile(ServiceCtx context, IVirtualMemoryManager memory, ulong owner) : base(context, owner) { diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/EventWaitArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/EventWaitArguments.cs index 16f970e8..84f678ba 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/EventWaitArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/EventWaitArguments.cs @@ -7,7 +7,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl.Types struct EventWaitArguments { public NvFence Fence; - public int Timeout; - public uint Value; + public int Timeout; + public uint Value; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/GetConfigurationArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/GetConfigurationArguments.cs index 3ee318a3..a1400f8e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/GetConfigurationArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/GetConfigurationArguments.cs @@ -11,14 +11,14 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl.Types public static GetConfigurationArguments FromSpan(Span<byte> span) { - string domain = Encoding.ASCII.GetString(span.Slice(0, 0x41)); + string domain = Encoding.ASCII.GetString(span[..0x41]); string parameter = Encoding.ASCII.GetString(span.Slice(0x41, 0x41)); - GetConfigurationArguments result = new GetConfigurationArguments + GetConfigurationArguments result = new() { - Domain = domain.Substring(0, domain.IndexOf('\0')), - Parameter = parameter.Substring(0, parameter.IndexOf('\0')), - Configuration = span.Slice(0x82, 0x101).ToArray() + Domain = domain[..domain.IndexOf('\0')], + Parameter = parameter[..parameter.IndexOf('\0')], + Configuration = span.Slice(0x82, 0x101).ToArray(), }; return result; @@ -26,7 +26,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl.Types public void CopyTo(Span<byte> span) { - Encoding.ASCII.GetBytes(Domain + '\0').CopyTo(span.Slice(0, 0x41)); + Encoding.ASCII.GetBytes(Domain + '\0').CopyTo(span[..0x41]); Encoding.ASCII.GetBytes(Parameter + '\0').CopyTo(span.Slice(0x41, 0x41)); Configuration.CopyTo(span.Slice(0x82, 0x101)); } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostEvent.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostEvent.cs index 383fb3fb..8f851f37 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostEvent.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostEvent.cs @@ -12,17 +12,19 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl { class NvHostEvent { - public NvFence Fence; + public NvFence Fence; public NvHostEventState State; - public KEvent Event; - public int EventHandle; + public KEvent Event; + public int EventHandle; - private uint _eventId; - private NvHostSyncpt _syncpointManager; + private readonly uint _eventId; +#pragma warning disable IDE0052 // Remove unread private member + private readonly NvHostSyncpt _syncpointManager; +#pragma warning restore IDE0052 private SyncpointWaiterHandle _waiterInformation; private NvFence _previousFailingFence; - private uint _failingCount; + private uint _failingCount; public readonly object Lock = new(); @@ -54,9 +56,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl private void ResetFailingState() { - _previousFailingFence.Id = NvFence.InvalidSyncPointId; + _previousFailingFence.Id = NvFence.InvalidSyncPointId; _previousFailingFence.Value = 0; - _failingCount = 0; + _failingCount = 0; } private void Signal() @@ -182,4 +184,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostEventState.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostEventState.cs index c7b4bc9f..57c99d61 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostEventState.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostEventState.cs @@ -2,11 +2,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl { enum NvHostEventState { - Available = 0, - Waiting = 1, + Available = 0, + Waiting = 1, Cancelling = 2, - Signaling = 3, - Signaled = 4, - Cancelled = 5 + Signaling = 3, + Signaled = 4, + Cancelled = 5, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostSyncPt.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostSyncPt.cs index 1b842aa1..9c6d025e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostSyncPt.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostSyncPt.cs @@ -10,22 +10,22 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl public const int VBlank0SyncpointId = 26; public const int VBlank1SyncpointId = 27; - private int[] _counterMin; - private int[] _counterMax; - private bool[] _clientManaged; - private bool[] _assigned; + private readonly int[] _counterMin; + private readonly int[] _counterMax; + private readonly bool[] _clientManaged; + private readonly bool[] _assigned; - private Switch _device; + private readonly Switch _device; private readonly object _syncpointAllocatorLock = new(); public NvHostSyncpt(Switch device) { - _device = device; - _counterMin = new int[SynchronizationManager.MaxHardwareSyncpoints]; - _counterMax = new int[SynchronizationManager.MaxHardwareSyncpoints]; + _device = device; + _counterMin = new int[SynchronizationManager.MaxHardwareSyncpoints]; + _counterMax = new int[SynchronizationManager.MaxHardwareSyncpoints]; _clientManaged = new bool[SynchronizationManager.MaxHardwareSyncpoints]; - _assigned = new bool[SynchronizationManager.MaxHardwareSyncpoints]; + _assigned = new bool[SynchronizationManager.MaxHardwareSyncpoints]; // Reserve VBLANK syncpoints ReserveSyncpointLocked(VBlank0SyncpointId, true); @@ -39,7 +39,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl throw new ArgumentOutOfRangeException(nameof(id)); } - _assigned[id] = true; + _assigned[id] = true; _clientManaged[id] = isClientManaged; } @@ -76,7 +76,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl throw new ArgumentOutOfRangeException(nameof(id)); } - _assigned[id] = false; + _assigned[id] = false; _clientManaged[id] = false; SetSyncpointMinEqualSyncpointMax(id); @@ -196,4 +196,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/SyncptWaitArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/SyncptWaitArguments.cs index cda97f18..b0efb7ed 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/SyncptWaitArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/SyncptWaitArguments.cs @@ -7,6 +7,6 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl.Types struct SyncptWaitArguments { public NvFence Fence; - public int Timeout; + public int Timeout; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/SyncptWaitExArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/SyncptWaitExArguments.cs index f2279c3d..7471274b 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/SyncptWaitExArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/SyncptWaitExArguments.cs @@ -6,6 +6,6 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl.Types struct SyncptWaitExArguments { public SyncptWaitArguments Input; - public uint Value; + public uint Value; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/NvHostCtrlGpuDeviceFile.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/NvHostCtrlGpuDeviceFile.cs index d6a8e29f..23cf1f00 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/NvHostCtrlGpuDeviceFile.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/NvHostCtrlGpuDeviceFile.cs @@ -10,15 +10,15 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu { class NvHostCtrlGpuDeviceFile : NvDeviceFile { - private static Stopwatch _pTimer = new Stopwatch(); - private static double _ticksToNs = (1.0 / Stopwatch.Frequency) * 1_000_000_000; + private static readonly Stopwatch _pTimer = new(); + private static readonly double _ticksToNs = (1.0 / Stopwatch.Frequency) * 1_000_000_000; - private KEvent _errorEvent; - private KEvent _unknownEvent; + private readonly KEvent _errorEvent; + private readonly KEvent _unknownEvent; public NvHostCtrlGpuDeviceFile(ServiceCtx context, IVirtualMemoryManager memory, ulong owner) : base(context, owner) { - _errorEvent = new KEvent(context.Device.System.KernelContext); + _errorEvent = new KEvent(context.Device.System.KernelContext); _unknownEvent = new KEvent(context.Device.System.KernelContext); } @@ -125,6 +125,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu private NvInternalResult ZcullGetInfo(ref ZcullGetInfoArguments arguments) { +#pragma warning disable IDE0055 // Disable formatting arguments.WidthAlignPixels = 0x20; arguments.HeightAlignPixels = 0x20; arguments.PixelSquaresByAliquots = 0x400; @@ -135,6 +136,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu arguments.SubregionWidthAlignPixels = 0x20; arguments.SubregionHeightAlignPixels = 0x40; arguments.SubregionCount = 0x10; +#pragma warning restore IDE0055 return NvInternalResult.Success; } @@ -155,6 +157,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu { arguments.Header.BufferSize = 0xa0; +#pragma warning disable IDE0055 // Disable formatting characteristics.Arch = 0x120; characteristics.Impl = 0xb; characteristics.Rev = 0xa1; @@ -190,6 +193,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu characteristics.RopL2EnMask1 = 0x0; characteristics.ChipName = 0x6230326d67; characteristics.GrCompbitStoreBaseHw = 0x0; +#pragma warning restore IDE0055 arguments.Characteristics = characteristics; @@ -205,7 +209,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu { if (arguments.MaskBufferSize != 0) { - tpcMask = 3; + tpcMask = 3; arguments.TpcMask = tpcMask; } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/GetCharacteristicsArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/GetCharacteristicsArguments.cs index d6648178..64bfbe88 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/GetCharacteristicsArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/GetCharacteristicsArguments.cs @@ -5,46 +5,46 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu.Types [StructLayout(LayoutKind.Sequential)] struct GpuCharacteristics { - public int Arch; - public int Impl; - public int Rev; - public int NumGpc; + public int Arch; + public int Impl; + public int Rev; + public int NumGpc; public long L2CacheSize; public long OnBoardVideoMemorySize; - public int NumTpcPerGpc; - public int BusType; - public int BigPageSize; - public int CompressionPageSize; - public int PdeCoverageBitCount; - public int AvailableBigPageSizes; - public int GpcMask; - public int SmArchSmVersion; - public int SmArchSpaVersion; - public int SmArchWarpCount; - public int GpuVaBitCount; - public int Reserved; + public int NumTpcPerGpc; + public int BusType; + public int BigPageSize; + public int CompressionPageSize; + public int PdeCoverageBitCount; + public int AvailableBigPageSizes; + public int GpcMask; + public int SmArchSmVersion; + public int SmArchSpaVersion; + public int SmArchWarpCount; + public int GpuVaBitCount; + public int Reserved; public long Flags; - public int TwodClass; - public int ThreedClass; - public int ComputeClass; - public int GpfifoClass; - public int InlineToMemoryClass; - public int DmaCopyClass; - public int MaxFbpsCount; - public int FbpEnMask; - public int MaxLtcPerFbp; - public int MaxLtsPerLtc; - public int MaxTexPerTpc; - public int MaxGpcCount; - public int RopL2EnMask0; - public int RopL2EnMask1; + public int TwodClass; + public int ThreedClass; + public int ComputeClass; + public int GpfifoClass; + public int InlineToMemoryClass; + public int DmaCopyClass; + public int MaxFbpsCount; + public int FbpEnMask; + public int MaxLtcPerFbp; + public int MaxLtsPerLtc; + public int MaxTexPerTpc; + public int MaxGpcCount; + public int RopL2EnMask0; + public int RopL2EnMask1; public long ChipName; public long GrCompbitStoreBaseHw; } struct CharacteristicsHeader { -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public long BufferSize; public long BufferAddress; #pragma warning restore CS0649 @@ -54,6 +54,6 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu.Types struct GetCharacteristicsArguments { public CharacteristicsHeader Header; - public GpuCharacteristics Characteristics; + public GpuCharacteristics Characteristics; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/GetTpcMasksArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/GetTpcMasksArguments.cs index 16ef2d6e..dafde6e5 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/GetTpcMasksArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/GetTpcMasksArguments.cs @@ -6,10 +6,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu.Types [StructLayout(LayoutKind.Sequential)] struct GetTpcMasksArguments { - public int MaskBufferSize; - public int Reserved; + public int MaskBufferSize; + public int Reserved; public long MaskBufferAddress; - public int TpcMask; - public int Padding; + public int TpcMask; + public int Padding; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/ZbcSetTableArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/ZbcSetTableArguments.cs index a4651f84..93c26433 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/ZbcSetTableArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/ZbcSetTableArguments.cs @@ -1,5 +1,4 @@ using Ryujinx.Common.Memory; -using System; using System.Runtime.InteropServices; namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu.Types diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostDbgGpu/NvHostDbgGpuDeviceFile.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostDbgGpu/NvHostDbgGpuDeviceFile.cs index fe302b98..66791578 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostDbgGpu/NvHostDbgGpuDeviceFile.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostDbgGpu/NvHostDbgGpuDeviceFile.cs @@ -1,5 +1,5 @@ using Ryujinx.Memory; -using System; + namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostDbgGpu { class NvHostDbgGpuDeviceFile : NvDeviceFile diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvInternalResult.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvInternalResult.cs index 9a3aa7aa..c7746a55 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvInternalResult.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvInternalResult.cs @@ -2,31 +2,31 @@ { enum NvInternalResult { - Success = 0, + Success = 0, OperationNotPermitted = -1, - NoEntry = -2, - Interrupted = -4, - IoError = -5, - DeviceNotFound = -6, - BadFileNumber = -9, - TryAgain = -11, - OutOfMemory = -12, - AccessDenied = -13, - BadAddress = -14, - Busy = -16, - NotADirectory = -20, - InvalidInput = -22, - FileTableOverflow = -23, - Unknown0x18 = -24, - NotSupported = -25, - FileTooBig = -27, - NoSpaceLeft = -28, - ReadOnlyAttribute = -30, - NotImplemented = -38, - InvalidState = -40, - Restart = -85, - InvalidAddress = -99, - TimedOut = -110, - Unknown0x72 = -114, + NoEntry = -2, + Interrupted = -4, + IoError = -5, + DeviceNotFound = -6, + BadFileNumber = -9, + TryAgain = -11, + OutOfMemory = -12, + AccessDenied = -13, + BadAddress = -14, + Busy = -16, + NotADirectory = -20, + InvalidInput = -22, + FileTableOverflow = -23, + Unknown0x18 = -24, + NotSupported = -25, + FileTooBig = -27, + NoSpaceLeft = -28, + ReadOnlyAttribute = -30, + NotImplemented = -38, + InvalidState = -40, + Restart = -85, + InvalidAddress = -99, + TimedOut = -110, + Unknown0x72 = -114, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/NvMapDeviceFile.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/NvMapDeviceFile.cs index a52b36a2..06df5f93 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/NvMapDeviceFile.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/NvMapDeviceFile.cs @@ -10,7 +10,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap { private const int FlagNotFreedYet = 1; - private static NvMapIdDictionary _maps = new NvMapIdDictionary(); + private static readonly NvMapIdDictionary _maps = new(); public NvMapDeviceFile(ServiceCtx context, IVirtualMemoryManager memory, ulong owner) : base(context, owner) { @@ -125,8 +125,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap { map.Allocated = true; - map.Align = arguments.Align; - map.Kind = (byte)arguments.Kind; + map.Align = arguments.Align; + map.Kind = (byte)arguments.Kind; int size = BitUtils.AlignUp(map.Size, (int)MemoryManager.PageSize); @@ -142,7 +142,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap if (result == NvInternalResult.Success) { - map.Size = size; + map.Size = size; map.Address = address; } } @@ -164,12 +164,12 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap if (DecrementMapRefCount(Owner, arguments.Handle)) { arguments.Address = map.Address; - arguments.Flags = 0; + arguments.Flags = 0; } else { arguments.Address = 0; - arguments.Flags = FlagNotFreedYet; + arguments.Flags = FlagNotFreedYet; } arguments.Size = map.Size; @@ -190,15 +190,26 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap switch (arguments.Param) { - case NvMapHandleParam.Size: arguments.Result = map.Size; break; - case NvMapHandleParam.Align: arguments.Result = map.Align; break; - case NvMapHandleParam.Heap: arguments.Result = 0x40000000; break; - case NvMapHandleParam.Kind: arguments.Result = map.Kind; break; - case NvMapHandleParam.Compr: arguments.Result = 0; break; + case NvMapHandleParam.Size: + arguments.Result = map.Size; + break; + case NvMapHandleParam.Align: + arguments.Result = map.Align; + break; + case NvMapHandleParam.Heap: + arguments.Result = 0x40000000; + break; + case NvMapHandleParam.Kind: + arguments.Result = map.Kind; + break; + case NvMapHandleParam.Compr: + arguments.Result = 0; + break; // Note: Base is not supported and returns an error. // Any other value also returns an error. - default: return NvInternalResult.InvalidInput; + default: + return NvInternalResult.InvalidInput; } return NvInternalResult.Success; diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapAlloc.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapAlloc.cs index 2ec75fc9..dc4f5d60 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapAlloc.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapAlloc.cs @@ -5,11 +5,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap [StructLayout(LayoutKind.Sequential)] struct NvMapAlloc { - public int Handle; - public int HeapMask; - public int Flags; - public int Align; - public long Kind; + public int Handle; + public int HeapMask; + public int Flags; + public int Align; + public long Kind; public ulong Address; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapCreate.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapCreate.cs index b47e4629..5380c45c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapCreate.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapCreate.cs @@ -8,4 +8,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap public int Size; public int Handle; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapFree.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapFree.cs index 34bcbc64..b0b3fa2d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapFree.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapFree.cs @@ -5,10 +5,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap [StructLayout(LayoutKind.Sequential)] struct NvMapFree { - public int Handle; - public int Padding; + public int Handle; + public int Padding; public ulong Address; - public int Size; - public int Flags; + public int Size; + public int Flags; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapFromId.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapFromId.cs index 2e559534..9ec81f9f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapFromId.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapFromId.cs @@ -8,4 +8,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap public int Id; public int Handle; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapGetId.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapGetId.cs index fe574eea..8306ae4c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapGetId.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapGetId.cs @@ -8,4 +8,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap public int Id; public int Handle; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapHandle.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapHandle.cs index c97cee49..30117974 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapHandle.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapHandle.cs @@ -4,15 +4,15 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap { class NvMapHandle { -#pragma warning disable CS0649 - public int Handle; - public int Id; +#pragma warning disable CS0649 // Field is never assigned to + public int Handle; + public int Id; #pragma warning restore CS0649 - public int Size; - public int Align; - public int Kind; + public int Size; + public int Align; + public int Kind; public ulong Address; - public bool Allocated; + public bool Allocated; public ulong DmaMapAddress; private long _dupes; @@ -37,4 +37,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap return Interlocked.Decrement(ref _dupes); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapHandleParam.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapHandleParam.cs index 9eb7efff..21393e7a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapHandleParam.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapHandleParam.cs @@ -2,11 +2,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap { enum NvMapHandleParam { - Size = 1, + Size = 1, Align = 2, - Base = 3, - Heap = 4, - Kind = 5, - Compr = 6 + Base = 3, + Heap = 4, + Kind = 5, + Compr = 6, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapIdDictionary.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapIdDictionary.cs index c4733e94..1b4d8dd4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapIdDictionary.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapIdDictionary.cs @@ -58,4 +58,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap return values; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapParam.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapParam.cs index de5bab77..16fd7804 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapParam.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapParam.cs @@ -5,8 +5,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap [StructLayout(LayoutKind.Sequential)] struct NvMapParam { - public int Handle; + public int Handle; public NvMapHandleParam Param; - public int Result; + public int Result; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvIoctl.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvIoctl.cs index 05858694..c9218e67 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvIoctl.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvIoctl.cs @@ -7,39 +7,39 @@ namespace Ryujinx.HLE.HOS.Services.Nv struct NvIoctl { public const int NvHostCustomMagic = 0x00; - public const int NvMapCustomMagic = 0x01; - public const int NvGpuAsMagic = 0x41; - public const int NvGpuMagic = 0x47; - public const int NvHostMagic = 0x48; + public const int NvMapCustomMagic = 0x01; + public const int NvGpuAsMagic = 0x41; + public const int NvGpuMagic = 0x47; + public const int NvHostMagic = 0x48; - private const int NumberBits = 8; - private const int TypeBits = 8; - private const int SizeBits = 14; + private const int NumberBits = 8; + private const int TypeBits = 8; + private const int SizeBits = 14; private const int DirectionBits = 2; - private const int NumberShift = 0; - private const int TypeShift = NumberShift + NumberBits; - private const int SizeShift = TypeShift + TypeBits; + private const int NumberShift = 0; + private const int TypeShift = NumberShift + NumberBits; + private const int SizeShift = TypeShift + TypeBits; private const int DirectionShift = SizeShift + SizeBits; - private const int NumberMask = (1 << NumberBits) - 1; - private const int TypeMask = (1 << TypeBits) - 1; - private const int SizeMask = (1 << SizeBits) - 1; + private const int NumberMask = (1 << NumberBits) - 1; + private const int TypeMask = (1 << TypeBits) - 1; + private const int SizeMask = (1 << SizeBits) - 1; private const int DirectionMask = (1 << DirectionBits) - 1; [Flags] public enum Direction : uint { - None = 0, - Read = 1, + None = 0, + Read = 1, Write = 2, } public uint RawValue; - public uint Number => (RawValue >> NumberShift) & NumberMask; - public uint Type => (RawValue >> TypeShift) & TypeMask; - public uint Size => (RawValue >> SizeShift) & SizeMask; - public Direction DirectionValue => (Direction)((RawValue >> DirectionShift) & DirectionMask); + public readonly uint Number => (RawValue >> NumberShift) & NumberMask; + public readonly uint Type => (RawValue >> TypeShift) & TypeMask; + public readonly uint Size => (RawValue >> SizeShift) & SizeMask; + public readonly Direction DirectionValue => (Direction)((RawValue >> DirectionShift) & DirectionMask); } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvMemoryAllocator.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvMemoryAllocator.cs index 341b5e57..66c953a2 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvMemoryAllocator.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvMemoryAllocator.cs @@ -20,10 +20,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv // Key --> Start Address of Region // Value --> End Address of Region - private readonly TreeDictionary<ulong, ulong> _tree = new TreeDictionary<ulong, ulong>(); + private readonly TreeDictionary<ulong, ulong> _tree = new(); - private readonly Dictionary<ulong, LinkedListNode<ulong>> _dictionary = new Dictionary<ulong, LinkedListNode<ulong>>(); - private readonly LinkedList<ulong> _list = new LinkedList<ulong>(); + private readonly Dictionary<ulong, LinkedListNode<ulong>> _dictionary = new(); + private readonly LinkedList<ulong> _list = new(); public NvMemoryAllocator() { diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvFence.cs b/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvFence.cs index 664610a4..5af613cd 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvFence.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvFence.cs @@ -13,7 +13,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types public uint Id; public uint Value; - public bool IsValid() + public readonly bool IsValid() { return Id != InvalidSyncPointId; } @@ -28,7 +28,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types Value = gpuContext.Synchronization.IncrementSyncpoint(Id); } - public bool Wait(GpuContext gpuContext, TimeSpan timeout) + public readonly bool Wait(GpuContext gpuContext, TimeSpan timeout) { if (IsValid()) { diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvIoctlNotImplementedException.cs b/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvIoctlNotImplementedException.cs index 9404c18c..7af7e533 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvIoctlNotImplementedException.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvIoctlNotImplementedException.cs @@ -6,9 +6,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types { class NvIoctlNotImplementedException : Exception { - public ServiceCtx Context { get; } + public ServiceCtx Context { get; } public NvDeviceFile DeviceFile { get; } - public NvIoctl Command { get; } + public NvIoctl Command { get; } public NvIoctlNotImplementedException(ServiceCtx context, NvDeviceFile deviceFile, NvIoctl command) : this(context, deviceFile, command, "The ioctl is not implemented.") @@ -17,9 +17,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types public NvIoctlNotImplementedException(ServiceCtx context, NvDeviceFile deviceFile, NvIoctl command, string message) : base(message) { - Context = context; + Context = context; DeviceFile = deviceFile; - Command = command; + Command = command; } public override string Message @@ -35,7 +35,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types private string BuildMessage() { - StringBuilder sb = new StringBuilder(); + StringBuilder sb = new(); sb.AppendLine($"Device File: {DeviceFile.GetType().Name}"); sb.AppendLine(); diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvQueryEventNotImplementedException.cs b/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvQueryEventNotImplementedException.cs index b7a72eba..844bce13 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvQueryEventNotImplementedException.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvQueryEventNotImplementedException.cs @@ -6,9 +6,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types { class NvQueryEventNotImplementedException : Exception { - public ServiceCtx Context { get; } + public ServiceCtx Context { get; } public NvDeviceFile DeviceFile { get; } - public uint EventId { get; } + public uint EventId { get; } public NvQueryEventNotImplementedException(ServiceCtx context, NvDeviceFile deviceFile, uint eventId) : this(context, deviceFile, eventId, "This query event is not implemented.") @@ -17,9 +17,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types public NvQueryEventNotImplementedException(ServiceCtx context, NvDeviceFile deviceFile, uint eventId, string message) : base(message) { - Context = context; + Context = context; DeviceFile = deviceFile; - EventId = eventId; + EventId = eventId; } public override string Message @@ -35,7 +35,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types private string BuildMessage() { - StringBuilder sb = new StringBuilder(); + StringBuilder sb = new(); sb.AppendLine($"Device File: {DeviceFile.GetType().Name}"); sb.AppendLine(); diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvResult.cs b/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvResult.cs index 1c9cae8c..6f7e09a6 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvResult.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvResult.cs @@ -2,29 +2,29 @@ namespace Ryujinx.HLE.HOS.Services.Nv { enum NvResult : uint { - Success = 0, - NotImplemented = 1, - NotSupported = 2, - NotInitialized = 3, - InvalidParameter = 4, - Timeout = 5, - InsufficientMemory = 6, - ReadOnlyAttribute = 7, - InvalidState = 8, - InvalidAddress = 9, - InvalidSize = 10, - InvalidValue = 11, - AlreadyAllocated = 13, - Busy = 14, - ResourceError = 15, - CountMismatch = 16, - SharedMemoryTooSmall = 0x1000, - FileOperationFailed = 0x30003, + Success = 0, + NotImplemented = 1, + NotSupported = 2, + NotInitialized = 3, + InvalidParameter = 4, + Timeout = 5, + InsufficientMemory = 6, + ReadOnlyAttribute = 7, + InvalidState = 8, + InvalidAddress = 9, + InvalidSize = 10, + InvalidValue = 11, + AlreadyAllocated = 13, + Busy = 14, + ResourceError = 15, + CountMismatch = 16, + SharedMemoryTooSmall = 0x1000, + FileOperationFailed = 0x30003, DirectoryOperationFailed = 0x30004, NotAvailableInProduction = 0x30006, - IoctlFailed = 0x3000F, - AccessDenied = 0x30010, - FileNotFound = 0x30013, - ModuleNotPresent = 0xA000E, + IoctlFailed = 0x3000F, + AccessDenied = 0x30010, + FileNotFound = 0x30013, + ModuleNotPresent = 0xA000E, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvStatus.cs b/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvStatus.cs index d5c35265..ad4f7035 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvStatus.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvStatus.cs @@ -12,4 +12,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types public long Padding1; public long Padding2; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Olsc/IOlscServiceForApplication.cs b/src/Ryujinx.HLE/HOS/Services/Olsc/IOlscServiceForApplication.cs index 89fe0c3a..073e9b1b 100644 --- a/src/Ryujinx.HLE/HOS/Services/Olsc/IOlscServiceForApplication.cs +++ b/src/Ryujinx.HLE/HOS/Services/Olsc/IOlscServiceForApplication.cs @@ -8,7 +8,7 @@ namespace Ryujinx.HLE.HOS.Services.Olsc [Service("olsc:u")] // 10.0.0+ class IOlscServiceForApplication : IpcService { - private bool _initialized; + private bool _initialized; private Dictionary<UserId, bool> _saveDataBackupSettingDatabase; public IOlscServiceForApplication(ServiceCtx context) { } @@ -65,8 +65,8 @@ namespace Ryujinx.HLE.HOS.Services.Olsc // SetSaveDataBackupSettingEnabled(nn::account::Uid, bool) public ResultCode SetSaveDataBackupSettingEnabled(ServiceCtx context) { - bool saveDataBackupSettingEnabled = context.RequestData.ReadUInt64() != 0; - UserId userId = context.RequestData.ReadStruct<UserId>(); + bool saveDataBackupSettingEnabled = context.RequestData.ReadUInt64() != 0; + UserId userId = context.RequestData.ReadStruct<UserId>(); if (!_initialized) { @@ -87,4 +87,4 @@ namespace Ryujinx.HLE.HOS.Services.Olsc return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Olsc/IOlscServiceForSystemService.cs b/src/Ryujinx.HLE/HOS/Services/Olsc/IOlscServiceForSystemService.cs index 52f74da9..27ac6b9c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Olsc/IOlscServiceForSystemService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Olsc/IOlscServiceForSystemService.cs @@ -5,4 +5,4 @@ { public IOlscServiceForSystemService(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Olsc/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Olsc/ResultCode.cs index 141d1ae9..78392f6e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Olsc/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Olsc/ResultCode.cs @@ -2,12 +2,12 @@ namespace Ryujinx.HLE.HOS.Services.Olsc { enum ResultCode { - ModuleId = 179, + ModuleId = 179, ErrorCodeShift = 9, Success = 0, - NullArgument = (100 << ErrorCodeShift) | ModuleId, - NotInitialized = (101 << ErrorCodeShift) | ModuleId + NullArgument = (100 << ErrorCodeShift) | ModuleId, + NotInitialized = (101 << ErrorCodeShift) | ModuleId, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Ovln/IReceiverService.cs b/src/Ryujinx.HLE/HOS/Services/Ovln/IReceiverService.cs index 67b82e42..99e929a7 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ovln/IReceiverService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ovln/IReceiverService.cs @@ -5,4 +5,4 @@ { public IReceiverService(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ovln/ISenderService.cs b/src/Ryujinx.HLE/HOS/Services/Ovln/ISenderService.cs index 70c860e1..e445c16c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ovln/ISenderService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ovln/ISenderService.cs @@ -5,4 +5,4 @@ { public ISenderService(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Pcie/ILogManager.cs b/src/Ryujinx.HLE/HOS/Services/Pcie/ILogManager.cs index 9c6387e1..78f927aa 100644 --- a/src/Ryujinx.HLE/HOS/Services/Pcie/ILogManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Pcie/ILogManager.cs @@ -5,4 +5,4 @@ { public ILogManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Pcie/IManager.cs b/src/Ryujinx.HLE/HOS/Services/Pcie/IManager.cs index f189dc8c..0450a1ca 100644 --- a/src/Ryujinx.HLE/HOS/Services/Pcie/IManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Pcie/IManager.cs @@ -5,4 +5,4 @@ { public IManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Pctl/IParentalControlServiceFactory.cs b/src/Ryujinx.HLE/HOS/Services/Pctl/IParentalControlServiceFactory.cs index 990aef09..707f6423 100644 --- a/src/Ryujinx.HLE/HOS/Services/Pctl/IParentalControlServiceFactory.cs +++ b/src/Ryujinx.HLE/HOS/Services/Pctl/IParentalControlServiceFactory.cs @@ -2,13 +2,13 @@ using Ryujinx.HLE.HOS.Services.Pctl.ParentalControlServiceFactory; namespace Ryujinx.HLE.HOS.Services.Pctl { - [Service("pctl", 0x303)] + [Service("pctl", 0x303)] [Service("pctl:a", 0x83BE)] [Service("pctl:r", 0x8040)] [Service("pctl:s", 0x838E)] class IParentalControlServiceFactory : IpcService { - private int _permissionFlag; + private readonly int _permissionFlag; public IParentalControlServiceFactory(ServiceCtx context, int permissionFlag) { @@ -37,4 +37,4 @@ namespace Ryujinx.HLE.HOS.Services.Pctl return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Pctl/ParentalControlServiceFactory/IParentalControlService.cs b/src/Ryujinx.HLE/HOS/Services/Pctl/ParentalControlServiceFactory/IParentalControlService.cs index 594ee4e0..cf8c1f78 100644 --- a/src/Ryujinx.HLE/HOS/Services/Pctl/ParentalControlServiceFactory/IParentalControlService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Pctl/ParentalControlServiceFactory/IParentalControlService.cs @@ -1,31 +1,30 @@ using Ryujinx.Common.Logging; using Ryujinx.HLE.HOS.Services.Arp; using System; - using static LibHac.Ns.ApplicationControlProperty; namespace Ryujinx.HLE.HOS.Services.Pctl.ParentalControlServiceFactory { class IParentalControlService : IpcService { - private ulong _pid; - private int _permissionFlag; - private ulong _titleId; + private readonly ulong _pid; + private readonly int _permissionFlag; + private ulong _titleId; private ParentalControlFlagValue _parentalControlFlag; - private int[] _ratingAge; +#pragma warning disable IDE0052, CS0414 // Remove unread private member + private int[] _ratingAge; -#pragma warning disable CS0414 // TODO: Find where they are set. - private bool _restrictionEnabled = false; - private bool _featuresRestriction = false; - private bool _freeCommunicationEnabled = false; - private bool _stereoVisionRestrictionConfigurable = true; - private bool _stereoVisionRestriction = false; -#pragma warning restore CS0414 + private readonly bool _restrictionEnabled = false; + private readonly bool _featuresRestriction = false; + private bool _freeCommunicationEnabled = false; + private readonly bool _stereoVisionRestrictionConfigurable = true; + private bool _stereoVisionRestriction = false; +#pragma warning restore IDE0052, CS0414 public IParentalControlService(ServiceCtx context, ulong pid, bool withInitialize, int permissionFlag) { - _pid = pid; + _pid = pid; _permissionFlag = permissionFlag; if (withInitialize) @@ -56,19 +55,19 @@ namespace Ryujinx.HLE.HOS.Services.Pctl.ParentalControlServiceFactory _titleId = titleId; // TODO: Call nn::arp::GetApplicationControlProperty here when implemented, if it return ResultCode.Success we assign fields. - _ratingAge = Array.ConvertAll(context.Device.Processes.ActiveApplication.ApplicationControlProperties.RatingAge.ItemsRo.ToArray(), Convert.ToInt32); + _ratingAge = Array.ConvertAll(context.Device.Processes.ActiveApplication.ApplicationControlProperties.RatingAge.ItemsRo.ToArray(), Convert.ToInt32); _parentalControlFlag = context.Device.Processes.ActiveApplication.ApplicationControlProperties.ParentalControlFlag; } } if (_titleId != 0) { - // TODO: Service store some private fields in another static object. + // TODO: Service store some private fields in another object. if ((_permissionFlag & 0x8040) == 0) { - // TODO: Service store TitleId and FreeCommunicationEnabled in another static object. - // When it's done it signal an event in this static object. + // TODO: Service store TitleId and FreeCommunicationEnabled in another object. + // When it's done it signal an event in this object. Logger.Stub?.PrintStub(LogClass.ServicePctl); } } @@ -160,7 +159,9 @@ namespace Ryujinx.HLE.HOS.Services.Pctl.ParentalControlServiceFactory } else { +#pragma warning disable CS0162 // Unreachable code return ResultCode.StereoVisionRestrictionConfigurableDisabled; +#pragma warning restore CS0162 } } @@ -173,7 +174,9 @@ namespace Ryujinx.HLE.HOS.Services.Pctl.ParentalControlServiceFactory return ResultCode.PermissionDenied; } +#pragma warning disable // Remove unnecessary value assignment bool stereoVisionRestriction = false; +#pragma warning restore IDE0059 if (_stereoVisionRestrictionConfigurable) { @@ -202,7 +205,7 @@ namespace Ryujinx.HLE.HOS.Services.Pctl.ParentalControlServiceFactory { _stereoVisionRestriction = stereoVisionRestriction; - // TODO: It signals an internal event of service. We have to determine where this event is used. + // TODO: It signals an internal event of service. We have to determine where this event is used. } } @@ -256,4 +259,4 @@ namespace Ryujinx.HLE.HOS.Services.Pctl.ParentalControlServiceFactory } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Pctl/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Pctl/ResultCode.cs index fcf06ee9..86ff8814 100644 --- a/src/Ryujinx.HLE/HOS/Services/Pctl/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Pctl/ResultCode.cs @@ -2,15 +2,15 @@ { enum ResultCode { - ModuleId = 142, + ModuleId = 142, ErrorCodeShift = 9, Success = 0, - FreeCommunicationDisabled = (101 << ErrorCodeShift) | ModuleId, - StereoVisionDenied = (104 << ErrorCodeShift) | ModuleId, - InvalidPid = (131 << ErrorCodeShift) | ModuleId, - PermissionDenied = (133 << ErrorCodeShift) | ModuleId, + FreeCommunicationDisabled = (101 << ErrorCodeShift) | ModuleId, + StereoVisionDenied = (104 << ErrorCodeShift) | ModuleId, + InvalidPid = (131 << ErrorCodeShift) | ModuleId, + PermissionDenied = (133 << ErrorCodeShift) | ModuleId, StereoVisionRestrictionConfigurableDisabled = (181 << ErrorCodeShift) | ModuleId, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Pcv/Bpc/IBoardPowerControlManager.cs b/src/Ryujinx.HLE/HOS/Services/Pcv/Bpc/IBoardPowerControlManager.cs index 7d0222d5..e078de39 100644 --- a/src/Ryujinx.HLE/HOS/Services/Pcv/Bpc/IBoardPowerControlManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Pcv/Bpc/IBoardPowerControlManager.cs @@ -5,4 +5,4 @@ { public IBoardPowerControlManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Pcv/Clkrst/ClkrstManager/IClkrstSession.cs b/src/Ryujinx.HLE/HOS/Services/Pcv/Clkrst/ClkrstManager/IClkrstSession.cs index b81e7fee..a3ca56bf 100644 --- a/src/Ryujinx.HLE/HOS/Services/Pcv/Clkrst/ClkrstManager/IClkrstSession.cs +++ b/src/Ryujinx.HLE/HOS/Services/Pcv/Clkrst/ClkrstManager/IClkrstSession.cs @@ -6,32 +6,33 @@ namespace Ryujinx.HLE.HOS.Services.Pcv.Clkrst.ClkrstManager { class IClkrstSession : IpcService { - private DeviceCode _deviceCode; - private uint _unknown; - private uint _clockRate; + private readonly DeviceCode _deviceCode; +#pragma warning disable IDE0052 // Remove unread private member + private readonly uint _unknown; +#pragma warning restore IDE0052 + private uint _clockRate; - private DeviceCode[] allowedDeviceCodeTable = new DeviceCode[] - { + private readonly DeviceCode[] _allowedDeviceCodeTable = { DeviceCode.Cpu, DeviceCode.Gpu, DeviceCode.Disp1, DeviceCode.Disp2, DeviceCode.Tsec, DeviceCode.Mselect, DeviceCode.Sor1, DeviceCode.Host1x, DeviceCode.Vic, DeviceCode.Nvenc, DeviceCode.Nvjpg, DeviceCode.Nvdec, DeviceCode.Ape, DeviceCode.AudioDsp, DeviceCode.Emc, DeviceCode.Dsi, DeviceCode.SysBus, DeviceCode.XusbSs, DeviceCode.XusbHost, DeviceCode.XusbDevice, - DeviceCode.Gpuaux, DeviceCode.Pcie, DeviceCode.Apbdma, DeviceCode.Sdmmc1, - DeviceCode.Sdmmc2, DeviceCode.Sdmmc4 + DeviceCode.Gpuaux, DeviceCode.Pcie, DeviceCode.Apbdma, DeviceCode.Sdmmc1, + DeviceCode.Sdmmc2, DeviceCode.Sdmmc4, }; public IClkrstSession(DeviceCode deviceCode, uint unknown) { _deviceCode = deviceCode; - _unknown = unknown; + _unknown = unknown; } [CommandCmif(7)] // SetClockRate(u32 hz) public ResultCode SetClockRate(ServiceCtx context) { - if (!allowedDeviceCodeTable.Contains(_deviceCode)) + if (!_allowedDeviceCodeTable.Contains(_deviceCode)) { return ResultCode.InvalidArgument; } @@ -47,7 +48,7 @@ namespace Ryujinx.HLE.HOS.Services.Pcv.Clkrst.ClkrstManager // GetClockRate() -> u32 hz public ResultCode GetClockRate(ServiceCtx context) { - if (!allowedDeviceCodeTable.Contains(_deviceCode)) + if (!_allowedDeviceCodeTable.Contains(_deviceCode)) { return ResultCode.InvalidArgument; } @@ -59,4 +60,4 @@ namespace Ryujinx.HLE.HOS.Services.Pcv.Clkrst.ClkrstManager return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Pcv/Clkrst/IArbitrationManager.cs b/src/Ryujinx.HLE/HOS/Services/Pcv/Clkrst/IArbitrationManager.cs index 6f1e5d25..492ffa57 100644 --- a/src/Ryujinx.HLE/HOS/Services/Pcv/Clkrst/IArbitrationManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Pcv/Clkrst/IArbitrationManager.cs @@ -5,4 +5,4 @@ { public IArbitrationManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Pcv/Clkrst/IClkrstManager.cs b/src/Ryujinx.HLE/HOS/Services/Pcv/Clkrst/IClkrstManager.cs index 4ba2f094..2e18dba7 100644 --- a/src/Ryujinx.HLE/HOS/Services/Pcv/Clkrst/IClkrstManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Pcv/Clkrst/IClkrstManager.cs @@ -19,7 +19,7 @@ namespace Ryujinx.HLE.HOS.Services.Pcv.Clkrst public ResultCode OpenSession(ServiceCtx context) { DeviceCode deviceCode = (DeviceCode)context.RequestData.ReadUInt32(); - uint unknown = context.RequestData.ReadUInt32(); + uint unknown = context.RequestData.ReadUInt32(); // TODO: Service checks the deviceCode and the unk value. @@ -54,4 +54,4 @@ namespace Ryujinx.HLE.HOS.Services.Pcv.Clkrst return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Pcv/IPcvService.cs b/src/Ryujinx.HLE/HOS/Services/Pcv/IPcvService.cs index 0e74dc3e..5fd8493c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Pcv/IPcvService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Pcv/IPcvService.cs @@ -5,4 +5,4 @@ { public IPcvService(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Pcv/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Pcv/ResultCode.cs index 2041e423..b1694b34 100644 --- a/src/Ryujinx.HLE/HOS/Services/Pcv/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Pcv/ResultCode.cs @@ -2,11 +2,11 @@ namespace Ryujinx.HLE.HOS.Services.Pcv { enum ResultCode { - ModuleId = 30, + ModuleId = 30, ErrorCodeShift = 9, Success = 0, - InvalidArgument = (5 << ErrorCodeShift) | ModuleId + InvalidArgument = (5 << ErrorCodeShift) | ModuleId, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Pcv/Rgltr/IRegulatorManager.cs b/src/Ryujinx.HLE/HOS/Services/Pcv/Rgltr/IRegulatorManager.cs index f7834777..9a7d8a09 100644 --- a/src/Ryujinx.HLE/HOS/Services/Pcv/Rgltr/IRegulatorManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Pcv/Rgltr/IRegulatorManager.cs @@ -5,4 +5,4 @@ { public IRegulatorManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Pcv/Rtc/IRtcManager.cs b/src/Ryujinx.HLE/HOS/Services/Pcv/Rtc/IRtcManager.cs index 2b4a1239..6e255a1d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Pcv/Rtc/IRtcManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Pcv/Rtc/IRtcManager.cs @@ -5,4 +5,4 @@ { public IRtcManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Pcv/Types/DeviceCode.cs b/src/Ryujinx.HLE/HOS/Services/Pcv/Types/DeviceCode.cs index 5380d82f..79f13dbd 100644 --- a/src/Ryujinx.HLE/HOS/Services/Pcv/Types/DeviceCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Pcv/Types/DeviceCode.cs @@ -2,93 +2,93 @@ { enum DeviceCode { - Cpu = 0x40000001, - Gpu = 0x40000002, - I2s1 = 0x40000003, - I2s2 = 0x40000004, - I2s3 = 0x40000005, - Pwm = 0x40000006, - I2c1 = 0x02000001, - I2c2 = 0x02000002, - I2c3 = 0x02000003, - I2c4 = 0x02000004, - I2c5 = 0x02000005, - I2c6 = 0x02000006, - Spi1 = 0x07000000, - Spi2 = 0x07000001, - Spi3 = 0x07000002, - Spi4 = 0x07000003, - Disp1 = 0x40000011, - Disp2 = 0x40000012, - Isp = 0x40000013, - Vi = 0x40000014, - Sdmmc1 = 0x40000015, - Sdmmc2 = 0x40000016, - Sdmmc3 = 0x40000017, - Sdmmc4 = 0x40000018, - Owr = 0x40000019, - Csite = 0x4000001A, - Tsec = 0x4000001B, - Mselect = 0x4000001C, - Hda2codec2x = 0x4000001D, - Actmon = 0x4000001E, - I2cSlow = 0x4000001F, - Sor1 = 0x40000020, - Sata = 0x40000021, - Hda = 0x40000022, + Cpu = 0x40000001, + Gpu = 0x40000002, + I2s1 = 0x40000003, + I2s2 = 0x40000004, + I2s3 = 0x40000005, + Pwm = 0x40000006, + I2c1 = 0x02000001, + I2c2 = 0x02000002, + I2c3 = 0x02000003, + I2c4 = 0x02000004, + I2c5 = 0x02000005, + I2c6 = 0x02000006, + Spi1 = 0x07000000, + Spi2 = 0x07000001, + Spi3 = 0x07000002, + Spi4 = 0x07000003, + Disp1 = 0x40000011, + Disp2 = 0x40000012, + Isp = 0x40000013, + Vi = 0x40000014, + Sdmmc1 = 0x40000015, + Sdmmc2 = 0x40000016, + Sdmmc3 = 0x40000017, + Sdmmc4 = 0x40000018, + Owr = 0x40000019, + Csite = 0x4000001A, + Tsec = 0x4000001B, + Mselect = 0x4000001C, + Hda2codec2x = 0x4000001D, + Actmon = 0x4000001E, + I2cSlow = 0x4000001F, + Sor1 = 0x40000020, + Sata = 0x40000021, + Hda = 0x40000022, XusbCoreHostSrc = 0x40000023, - XusbFalconSrc = 0x40000024, - XusbFsSrc = 0x40000025, - XusbCoreDevSrc = 0x40000026, - XusbSsSrc = 0x40000027, - UartA = 0x03000001, - UartB = 0x35000405, - UartC = 0x3500040F, - UartD = 0x37000001, - Host1x = 0x4000002C, - Entropy = 0x4000002D, - SocTherm = 0x4000002E, - Vic = 0x4000002F, - Nvenc = 0x40000030, - Nvjpg = 0x40000031, - Nvdec = 0x40000032, - Qspi = 0x40000033, - ViI2c = 0x40000034, - Tsecb = 0x40000035, - Ape = 0x40000036, - AudioDsp = 0x40000037, - AudioUart = 0x40000038, - Emc = 0x40000039, - Plle = 0x4000003A, - PlleHwSeq = 0x4000003B, - Dsi = 0x4000003C, - Maud = 0x4000003D, - Dpaux1 = 0x4000003E, - MipiCal = 0x4000003F, - UartFstMipiCal = 0x40000040, - Osc = 0x40000041, - SysBus = 0x40000042, - SorSafe = 0x40000043, - XusbSs = 0x40000044, - XusbHost = 0x40000045, - XusbDevice = 0x40000046, - Extperiph1 = 0x40000047, - Ahub = 0x40000048, - Hda2hdmicodec = 0x40000049, - Gpuaux = 0x4000004A, - UsbD = 0x4000004B, - Usb2 = 0x4000004C, - Pcie = 0x4000004D, - Afi = 0x4000004E, - PciExClk = 0x4000004F, - PExUsbPhy = 0x40000050, - XUsbPadCtl = 0x40000051, - Apbdma = 0x40000052, - Usb2TrkClk = 0x40000053, - XUsbIoPll = 0x40000054, - XUsbIoPllHwSeq = 0x40000055, - Cec = 0x40000056, - Extperiph2 = 0x40000057, - OscClk = 0x40000080 + XusbFalconSrc = 0x40000024, + XusbFsSrc = 0x40000025, + XusbCoreDevSrc = 0x40000026, + XusbSsSrc = 0x40000027, + UartA = 0x03000001, + UartB = 0x35000405, + UartC = 0x3500040F, + UartD = 0x37000001, + Host1x = 0x4000002C, + Entropy = 0x4000002D, + SocTherm = 0x4000002E, + Vic = 0x4000002F, + Nvenc = 0x40000030, + Nvjpg = 0x40000031, + Nvdec = 0x40000032, + Qspi = 0x40000033, + ViI2c = 0x40000034, + Tsecb = 0x40000035, + Ape = 0x40000036, + AudioDsp = 0x40000037, + AudioUart = 0x40000038, + Emc = 0x40000039, + Plle = 0x4000003A, + PlleHwSeq = 0x4000003B, + Dsi = 0x4000003C, + Maud = 0x4000003D, + Dpaux1 = 0x4000003E, + MipiCal = 0x4000003F, + UartFstMipiCal = 0x40000040, + Osc = 0x40000041, + SysBus = 0x40000042, + SorSafe = 0x40000043, + XusbSs = 0x40000044, + XusbHost = 0x40000045, + XusbDevice = 0x40000046, + Extperiph1 = 0x40000047, + Ahub = 0x40000048, + Hda2hdmicodec = 0x40000049, + Gpuaux = 0x4000004A, + UsbD = 0x4000004B, + Usb2 = 0x4000004C, + Pcie = 0x4000004D, + Afi = 0x4000004E, + PciExClk = 0x4000004F, + PExUsbPhy = 0x40000050, + XUsbPadCtl = 0x40000051, + Apbdma = 0x40000052, + Usb2TrkClk = 0x40000053, + XUsbIoPll = 0x40000054, + XUsbIoPllHwSeq = 0x40000055, + Cec = 0x40000056, + Extperiph2 = 0x40000057, + OscClk = 0x40000080, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Pm/IBootModeInterface.cs b/src/Ryujinx.HLE/HOS/Services/Pm/IBootModeInterface.cs index 45771db6..473f7413 100644 --- a/src/Ryujinx.HLE/HOS/Services/Pm/IBootModeInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Pm/IBootModeInterface.cs @@ -5,4 +5,4 @@ { public IBootModeInterface(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Pm/IDebugMonitorInterface.cs b/src/Ryujinx.HLE/HOS/Services/Pm/IDebugMonitorInterface.cs index cce2967a..82190b04 100644 --- a/src/Ryujinx.HLE/HOS/Services/Pm/IDebugMonitorInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Pm/IDebugMonitorInterface.cs @@ -46,4 +46,4 @@ namespace Ryujinx.HLE.HOS.Services.Pm return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Pm/IInformationInterface.cs b/src/Ryujinx.HLE/HOS/Services/Pm/IInformationInterface.cs index b3b5595f..500d121e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Pm/IInformationInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Pm/IInformationInterface.cs @@ -24,4 +24,4 @@ namespace Ryujinx.HLE.HOS.Services.Pm return ResultCode.ProcessNotFound; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Pm/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Pm/ResultCode.cs index 92b5925e..9894cd20 100644 --- a/src/Ryujinx.HLE/HOS/Services/Pm/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Pm/ResultCode.cs @@ -2,16 +2,16 @@ namespace Ryujinx.HLE.HOS.Services.Pm { enum ResultCode { - ModuleId = 15, + ModuleId = 15, ErrorCodeShift = 9, Success = 0, - ProcessNotFound = (1 << ErrorCodeShift) | ModuleId, - AlreadyStarted = (2 << ErrorCodeShift) | ModuleId, - NotTerminated = (3 << ErrorCodeShift) | ModuleId, - DebugHookInUse = (4 << ErrorCodeShift) | ModuleId, + ProcessNotFound = (1 << ErrorCodeShift) | ModuleId, + AlreadyStarted = (2 << ErrorCodeShift) | ModuleId, + NotTerminated = (3 << ErrorCodeShift) | ModuleId, + DebugHookInUse = (4 << ErrorCodeShift) | ModuleId, ApplicationRunning = (5 << ErrorCodeShift) | ModuleId, - InvalidSize = (6 << ErrorCodeShift) | ModuleId, + InvalidSize = (6 << ErrorCodeShift) | ModuleId, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Psc/IPmControl.cs b/src/Ryujinx.HLE/HOS/Services/Psc/IPmControl.cs index 3810c282..6682a848 100644 --- a/src/Ryujinx.HLE/HOS/Services/Psc/IPmControl.cs +++ b/src/Ryujinx.HLE/HOS/Services/Psc/IPmControl.cs @@ -5,4 +5,4 @@ { public IPmControl(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Psc/IPmService.cs b/src/Ryujinx.HLE/HOS/Services/Psc/IPmService.cs index c8dfb32e..1be33866 100644 --- a/src/Ryujinx.HLE/HOS/Services/Psc/IPmService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Psc/IPmService.cs @@ -5,4 +5,4 @@ { public IPmService(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Psc/IPmUnknown.cs b/src/Ryujinx.HLE/HOS/Services/Psc/IPmUnknown.cs index ef48fa41..95aff9ec 100644 --- a/src/Ryujinx.HLE/HOS/Services/Psc/IPmUnknown.cs +++ b/src/Ryujinx.HLE/HOS/Services/Psc/IPmUnknown.cs @@ -5,4 +5,4 @@ { public IPmUnknown(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ptm/Fan/IManager.cs b/src/Ryujinx.HLE/HOS/Services/Ptm/Fan/IManager.cs index e2fe2235..8011f919 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ptm/Fan/IManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ptm/Fan/IManager.cs @@ -5,4 +5,4 @@ { public IManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ptm/Fgm/IDebugger.cs b/src/Ryujinx.HLE/HOS/Services/Ptm/Fgm/IDebugger.cs index a93f5283..8cb671bc 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ptm/Fgm/IDebugger.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ptm/Fgm/IDebugger.cs @@ -5,4 +5,4 @@ { public IDebugger(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ptm/Fgm/ISession.cs b/src/Ryujinx.HLE/HOS/Services/Ptm/Fgm/ISession.cs index 0e3f965b..1488c288 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ptm/Fgm/ISession.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ptm/Fgm/ISession.cs @@ -7,4 +7,4 @@ { public ISession(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ptm/Pcm/IManager.cs b/src/Ryujinx.HLE/HOS/Services/Ptm/Pcm/IManager.cs index 0bec45fa..53f3bc39 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ptm/Pcm/IManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ptm/Pcm/IManager.cs @@ -5,4 +5,4 @@ { public IManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ptm/Psm/IPsmServer.cs b/src/Ryujinx.HLE/HOS/Services/Ptm/Psm/IPsmServer.cs index 4e3d3e8e..0c475150 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ptm/Psm/IPsmServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ptm/Psm/IPsmServer.cs @@ -42,4 +42,4 @@ namespace Ryujinx.HLE.HOS.Services.Ptm.Psm return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ptm/Psm/IPsmSession.cs b/src/Ryujinx.HLE/HOS/Services/Ptm/Psm/IPsmSession.cs index 5d11f227..a603b7e4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ptm/Psm/IPsmSession.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ptm/Psm/IPsmSession.cs @@ -7,12 +7,12 @@ namespace Ryujinx.HLE.HOS.Services.Ptm.Psm { class IPsmSession : IpcService { - private KEvent _stateChangeEvent; - private int _stateChangeEventHandle; + private readonly KEvent _stateChangeEvent; + private int _stateChangeEventHandle; public IPsmSession(Horizon system) { - _stateChangeEvent = new KEvent(system.KernelContext); + _stateChangeEvent = new KEvent(system.KernelContext); _stateChangeEventHandle = -1; } @@ -85,4 +85,4 @@ namespace Ryujinx.HLE.HOS.Services.Ptm.Psm return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ptm/Psm/Types/ChargerType.cs b/src/Ryujinx.HLE/HOS/Services/Ptm/Psm/Types/ChargerType.cs index 3e239711..a0b0c3dd 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ptm/Psm/Types/ChargerType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ptm/Psm/Types/ChargerType.cs @@ -4,6 +4,6 @@ { None, ChargerOrDock, - UsbC + UsbC, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ptm/Tc/IManager.cs b/src/Ryujinx.HLE/HOS/Services/Ptm/Tc/IManager.cs index 1daa4f5e..0317e532 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ptm/Tc/IManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ptm/Tc/IManager.cs @@ -5,4 +5,4 @@ { public IManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ptm/Ts/IMeasurementServer.cs b/src/Ryujinx.HLE/HOS/Services/Ptm/Ts/IMeasurementServer.cs index 6ddc0aef..07a06768 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ptm/Ts/IMeasurementServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ptm/Ts/IMeasurementServer.cs @@ -36,4 +36,4 @@ namespace Ryujinx.HLE.HOS.Services.Ptm.Ts return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ptm/Ts/Types/Location.cs b/src/Ryujinx.HLE/HOS/Services/Ptm/Ts/Types/Location.cs index e72491d5..c04db09c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ptm/Ts/Types/Location.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ptm/Ts/Types/Location.cs @@ -3,6 +3,6 @@ enum Location : byte { Internal, - External + External, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs b/src/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs index 966adcff..3f31fe9f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs @@ -18,16 +18,16 @@ namespace Ryujinx.HLE.HOS.Services.Ro [Service("ro:1")] // 7.0.0+ class IRoInterface : DisposableIpcService { - private const int MaxNrr = 0x40; - private const int MaxNro = 0x40; - private const int MaxMapRetries = 0x200; + private const int MaxNrr = 0x40; + private const int MaxNro = 0x40; + private const int MaxMapRetries = 0x200; private const int GuardPagesSize = 0x4000; private const uint NrrMagic = 0x3052524E; private const uint NroMagic = 0x304F524E; - private List<NrrInfo> _nrrInfos; - private List<NroInfo> _nroInfos; + private readonly List<NrrInfo> _nrrInfos; + private readonly List<NroInfo> _nroInfos; private KProcess _owner; private IVirtualMemoryManager _ownerMm; @@ -36,8 +36,8 @@ namespace Ryujinx.HLE.HOS.Services.Ro { _nrrInfos = new List<NrrInfo>(MaxNrr); _nroInfos = new List<NroInfo>(MaxNro); - _owner = null; - _ownerMm = null; + _owner = null; + _ownerMm = null; } private ResultCode ParseNrr(out NrrInfo nrrInfo, ServiceCtx context, ulong nrrAddress, ulong nrrSize) @@ -64,7 +64,7 @@ namespace Ryujinx.HLE.HOS.Services.Ro return ResultCode.InvalidSize; } - List<byte[]> hashes = new List<byte[]>(); + List<byte[]> hashes = new(); for (int i = 0; i < header.HashesCount; i++) { @@ -130,7 +130,7 @@ namespace Ryujinx.HLE.HOS.Services.Ro return ResultCode.InvalidAddress; } - uint magic = _owner.CpuMemory.Read<uint>(nroAddress + 0x10); + uint magic = _owner.CpuMemory.Read<uint>(nroAddress + 0x10); uint nroFileSize = _owner.CpuMemory.Read<uint>(nroAddress + 0x18); if (magic != NroMagic || nroSize != nroFileSize) @@ -142,7 +142,7 @@ namespace Ryujinx.HLE.HOS.Services.Ro _owner.CpuMemory.Read(nroAddress, nroData); - MemoryStream stream = new MemoryStream(nroData); + MemoryStream stream = new(nroData); byte[] nroHash = SHA256.HashData(stream); @@ -158,19 +158,19 @@ namespace Ryujinx.HLE.HOS.Services.Ro stream.Position = 0; - NroExecutable nro = new NroExecutable(stream.AsStorage(), nroAddress, bssAddress); + NroExecutable nro = new(stream.AsStorage(), nroAddress, bssAddress); // Check if everything is page align. if ((nro.Text.Length & 0xFFF) != 0 || (nro.Ro.Length & 0xFFF) != 0 || - (nro.Data.Length & 0xFFF) != 0 || (nro.BssSize & 0xFFF) != 0) + (nro.Data.Length & 0xFFF) != 0 || (nro.BssSize & 0xFFF) != 0) { return ResultCode.InvalidNro; } // Check if everything is contiguous. - if (nro.RoOffset != nro.TextOffset + nro.Text.Length || - nro.DataOffset != nro.RoOffset + nro.Ro.Length || - nroFileSize != nro.DataOffset + nro.Data.Length) + if (nro.RoOffset != nro.TextOffset + nro.Text.Length || + nro.DataOffset != nro.RoOffset + nro.Ro.Length || + nroFileSize != nro.DataOffset + nro.Data.Length) { return ResultCode.InvalidNro; } @@ -316,7 +316,7 @@ namespace Ryujinx.HLE.HOS.Services.Ro private Result SetNroMemoryPermissions(KProcess process, IExecutable relocatableObject, ulong baseAddress) { ulong textStart = baseAddress + relocatableObject.TextOffset; - ulong roStart = baseAddress + relocatableObject.RoOffset; + ulong roStart = baseAddress + relocatableObject.RoOffset; ulong dataStart = baseAddress + relocatableObject.DataOffset; ulong bssStart = dataStart + (ulong)relocatableObject.Data.Length; @@ -324,7 +324,7 @@ namespace Ryujinx.HLE.HOS.Services.Ro ulong bssEnd = BitUtils.AlignUp<ulong>(bssStart + relocatableObject.BssSize, KPageTableBase.PageSize); process.CpuMemory.Write(textStart, relocatableObject.Text); - process.CpuMemory.Write(roStart, relocatableObject.Ro); + process.CpuMemory.Write(roStart, relocatableObject.Ro); process.CpuMemory.Write(dataStart, relocatableObject.Data); MemoryHelper.FillWithZeros(process.CpuMemory, bssStart, (int)(bssEnd - bssStart)); @@ -381,9 +381,9 @@ namespace Ryujinx.HLE.HOS.Services.Ro private ResultCode UnmapNroFromInfo(NroInfo info) { ulong textSize = (ulong)info.Executable.Text.Length; - ulong roSize = (ulong)info.Executable.Ro.Length; + ulong roSize = (ulong)info.Executable.Ro.Length; ulong dataSize = (ulong)info.Executable.Data.Length; - ulong bssSize = (ulong)info.Executable.BssSize; + ulong bssSize = (ulong)info.Executable.BssSize; Result result = Result.Success; @@ -434,17 +434,16 @@ namespace Ryujinx.HLE.HOS.Services.Ro context.RequestData.ReadUInt64(); ulong nroHeapAddress = context.RequestData.ReadUInt64(); - ulong nroSize = context.RequestData.ReadUInt64(); + ulong nroSize = context.RequestData.ReadUInt64(); ulong bssHeapAddress = context.RequestData.ReadUInt64(); - ulong bssSize = context.RequestData.ReadUInt64(); + ulong bssSize = context.RequestData.ReadUInt64(); ulong nroMappedAddress = 0; if (result == ResultCode.Success) { - NroInfo info; - result = ParseNro(out info, context, nroHeapAddress, nroSize, bssHeapAddress, bssSize); + result = ParseNro(out NroInfo info, context, nroHeapAddress, nroSize, bssHeapAddress, bssSize); if (result == ResultCode.Success) { @@ -503,12 +502,11 @@ namespace Ryujinx.HLE.HOS.Services.Ro context.RequestData.ReadUInt64(); ulong nrrAddress = context.RequestData.ReadUInt64(); - ulong nrrSize = context.RequestData.ReadUInt64(); + ulong nrrSize = context.RequestData.ReadUInt64(); if (result == ResultCode.Success) { - NrrInfo info; - result = ParseNrr(out info, context, nrrAddress, nrrSize); + result = ParseNrr(out NrrInfo info, context, nrrAddress, nrrSize); if (result == ResultCode.Success) { @@ -599,4 +597,4 @@ namespace Ryujinx.HLE.HOS.Services.Ro } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ro/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Ro/ResultCode.cs index 92bb5502..1e31e576 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ro/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ro/ResultCode.cs @@ -2,26 +2,26 @@ { enum ResultCode { - ModuleId = 22, + ModuleId = 22, ErrorCodeShift = 9, Success = 0, InsufficientAddressSpace = (2 << ErrorCodeShift) | ModuleId, - AlreadyLoaded = (3 << ErrorCodeShift) | ModuleId, - InvalidNro = (4 << ErrorCodeShift) | ModuleId, - InvalidNrr = (6 << ErrorCodeShift) | ModuleId, - TooManyNro = (7 << ErrorCodeShift) | ModuleId, - TooManyNrr = (8 << ErrorCodeShift) | ModuleId, - NotAuthorized = (9 << ErrorCodeShift) | ModuleId, + AlreadyLoaded = (3 << ErrorCodeShift) | ModuleId, + InvalidNro = (4 << ErrorCodeShift) | ModuleId, + InvalidNrr = (6 << ErrorCodeShift) | ModuleId, + TooManyNro = (7 << ErrorCodeShift) | ModuleId, + TooManyNrr = (8 << ErrorCodeShift) | ModuleId, + NotAuthorized = (9 << ErrorCodeShift) | ModuleId, - InvalidNrrType = (10 << ErrorCodeShift) | ModuleId, + InvalidNrrType = (10 << ErrorCodeShift) | ModuleId, - InvalidAddress = (1025 << ErrorCodeShift) | ModuleId, - InvalidSize = (1026 << ErrorCodeShift) | ModuleId, - NotLoaded = (1028 << ErrorCodeShift) | ModuleId, - NotRegistered = (1029 << ErrorCodeShift) | ModuleId, - InvalidSession = (1030 << ErrorCodeShift) | ModuleId, - InvalidProcess = (1031 << ErrorCodeShift) | ModuleId, + InvalidAddress = (1025 << ErrorCodeShift) | ModuleId, + InvalidSize = (1026 << ErrorCodeShift) | ModuleId, + NotLoaded = (1028 << ErrorCodeShift) | ModuleId, + NotRegistered = (1029 << ErrorCodeShift) | ModuleId, + InvalidSession = (1030 << ErrorCodeShift) | ModuleId, + InvalidProcess = (1031 << ErrorCodeShift) | ModuleId, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ro/Types/NroInfo.cs b/src/Ryujinx.HLE/HOS/Services/Ro/Types/NroInfo.cs index 45daf1bd..fd4947c6 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ro/Types/NroInfo.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ro/Types/NroInfo.cs @@ -6,30 +6,30 @@ namespace Ryujinx.HLE.HOS.Services.Ro { public NroExecutable Executable { get; private set; } - public byte[] Hash { get; private set; } - public ulong NroAddress { get; private set; } - public ulong NroSize { get; private set; } - public ulong BssAddress { get; private set; } - public ulong BssSize { get; private set; } - public ulong TotalSize { get; private set; } - public ulong NroMappedAddress { get; set; } + public byte[] Hash { get; private set; } + public ulong NroAddress { get; private set; } + public ulong NroSize { get; private set; } + public ulong BssAddress { get; private set; } + public ulong BssSize { get; private set; } + public ulong TotalSize { get; private set; } + public ulong NroMappedAddress { get; set; } public NroInfo( - NroExecutable executable, - byte[] hash, - ulong nroAddress, - ulong nroSize, - ulong bssAddress, - ulong bssSize, - ulong totalSize) + NroExecutable executable, + byte[] hash, + ulong nroAddress, + ulong nroSize, + ulong bssAddress, + ulong bssSize, + ulong totalSize) { Executable = executable; - Hash = hash; + Hash = hash; NroAddress = nroAddress; - NroSize = nroSize; + NroSize = nroSize; BssAddress = bssAddress; - BssSize = bssSize; - TotalSize = totalSize; + BssSize = bssSize; + TotalSize = totalSize; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ro/Types/NrrInfo.cs b/src/Ryujinx.HLE/HOS/Services/Ro/Types/NrrInfo.cs index 45c34f1c..b322c06e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ro/Types/NrrInfo.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ro/Types/NrrInfo.cs @@ -4,15 +4,15 @@ namespace Ryujinx.HLE.HOS.Services.Ro { class NrrInfo { - public NrrHeader Header { get; private set; } - public List<byte[]> Hashes { get; private set; } - public ulong NrrAddress { get; private set; } + public NrrHeader Header { get; private set; } + public List<byte[]> Hashes { get; private set; } + public ulong NrrAddress { get; private set; } public NrrInfo(ulong nrrAddress, NrrHeader header, List<byte[]> hashes) { NrrAddress = nrrAddress; - Header = header; - Hashes = hashes; + Header = header; + Hashes = hashes; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sdb/Avm/IAvmService.cs b/src/Ryujinx.HLE/HOS/Services/Sdb/Avm/IAvmService.cs index d65c8bba..ec312108 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sdb/Avm/IAvmService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sdb/Avm/IAvmService.cs @@ -5,4 +5,4 @@ { public IAvmService(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/INotifyService.cs b/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/INotifyService.cs index 5247a238..c2e04290 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/INotifyService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/INotifyService.cs @@ -5,4 +5,4 @@ { public INotifyService(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/IQueryService.cs b/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/IQueryService.cs index 1f66ff9d..c46050b8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/IQueryService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/IQueryService.cs @@ -21,4 +21,4 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pdm return QueryPlayStatisticsManager.GetPlayStatistics(context, true); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/QueryService/QueryPlayStatisticsManager.cs b/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/QueryService/QueryPlayStatisticsManager.cs index 52a07d46..7017cc50 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/QueryService/QueryPlayStatisticsManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/QueryService/QueryPlayStatisticsManager.cs @@ -9,17 +9,17 @@ using System.Runtime.CompilerServices; namespace Ryujinx.HLE.HOS.Services.Sdb.Pdm.QueryService { - static class QueryPlayStatisticsManager + class QueryPlayStatisticsManager { - private static Dictionary<UserId, ApplicationPlayStatistics> applicationPlayStatistics = new Dictionary<UserId, ApplicationPlayStatistics>(); + private static readonly Dictionary<UserId, ApplicationPlayStatistics> _applicationPlayStatistics = new(); internal static ResultCode GetPlayStatistics(ServiceCtx context, bool byUserId = false) { ulong inputPosition = context.Request.SendBuff[0].Position; - ulong inputSize = context.Request.SendBuff[0].Size; + ulong inputSize = context.Request.SendBuff[0].Size; ulong outputPosition = context.Request.ReceiveBuff[0].Position; - ulong outputSize = context.Request.ReceiveBuff[0].Size; + ulong outputSize = context.Request.ReceiveBuff[0].Size; UserId userId = byUserId ? context.RequestData.ReadStruct<UserId>() : new UserId(); @@ -33,7 +33,7 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pdm.QueryService PlayLogQueryCapability queryCapability = (PlayLogQueryCapability)context.Device.Processes.ActiveApplication.ApplicationControlProperties.PlayLogQueryCapability; - List<ulong> titleIds = new List<ulong>(); + List<ulong> titleIds = new(); for (ulong i = 0; i < inputSize / sizeof(ulong); i++) { @@ -55,7 +55,7 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pdm.QueryService MemoryHelper.FillWithZeros(context.Memory, outputPosition, (int)outputSize); // Return ResultCode.ServiceUnavailable if data is locked by another process. - var filteredApplicationPlayStatistics = applicationPlayStatistics.AsEnumerable(); + var filteredApplicationPlayStatistics = _applicationPlayStatistics.AsEnumerable(); if (queryCapability == PlayLogQueryCapability.None) { @@ -81,4 +81,4 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pdm.QueryService return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/QueryService/Types/ApplicationPlayStatistics.cs b/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/QueryService/Types/ApplicationPlayStatistics.cs index c28d757e..b58fd219 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/QueryService/Types/ApplicationPlayStatistics.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/QueryService/Types/ApplicationPlayStatistics.cs @@ -6,7 +6,7 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pdm.QueryService.Types struct ApplicationPlayStatistics { public ulong TitleId; - public long TotalPlayTime; // In nanoseconds. - public long TotalLaunchCount; + public long TotalPlayTime; // In nanoseconds. + public long TotalLaunchCount; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/QueryService/Types/PlayLogQueryCapability.cs b/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/QueryService/Types/PlayLogQueryCapability.cs index 9e4b85de..c1e77ed3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/QueryService/Types/PlayLogQueryCapability.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/QueryService/Types/PlayLogQueryCapability.cs @@ -4,6 +4,6 @@ { None, WhiteList, - All + All, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/ResultCode.cs index c337051b..dd20220f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/ResultCode.cs @@ -2,14 +2,14 @@ { enum ResultCode { - ModuleId = 178, + ModuleId = 178, ErrorCodeShift = 9, Success = 0, - InvalidUserID = (100 << ErrorCodeShift) | ModuleId, - UserNotFound = (101 << ErrorCodeShift) | ModuleId, + InvalidUserID = (100 << ErrorCodeShift) | ModuleId, + UserNotFound = (101 << ErrorCodeShift) | ModuleId, ServiceUnavailable = (150 << ErrorCodeShift) | ModuleId, - FileStorageFailure = (200 << ErrorCodeShift) | ModuleId + FileStorageFailure = (200 << ErrorCodeShift) | ModuleId, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Sdb/Pl/ISharedFontManager.cs b/src/Ryujinx.HLE/HOS/Services/Sdb/Pl/ISharedFontManager.cs index 9e2f7a4e..45c4ce7e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sdb/Pl/ISharedFontManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sdb/Pl/ISharedFontManager.cs @@ -17,7 +17,9 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pl // RequestLoad(u32) public ResultCode RequestLoad(ServiceCtx context) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment SharedFontType fontType = (SharedFontType)context.RequestData.ReadInt32(); +#pragma warning restore IDE0059 // We don't need to do anything here because we do lazy initialization // on SharedFontManager (the font is loaded when necessary). @@ -28,7 +30,9 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pl // GetLoadState(u32) -> u32 public ResultCode GetLoadState(ServiceCtx context) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment SharedFontType fontType = (SharedFontType)context.RequestData.ReadInt32(); +#pragma warning restore IDE0059 // 1 (true) indicates that the font is already loaded. // All fonts are already loaded. @@ -82,8 +86,10 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pl // GetSharedFontInOrderOfPriority(bytes<8, 1>) -> (u8, u32, buffer<unknown, 6>, buffer<unknown, 6>, buffer<unknown, 6>) public ResultCode GetSharedFontInOrderOfPriority(ServiceCtx context) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment long languageCode = context.RequestData.ReadInt64(); - int loadedCount = 0; +#pragma warning restore IDE0059 + int loadedCount = 0; for (SharedFontType type = 0; type < SharedFontType.Count; type++) { @@ -115,15 +121,15 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pl private bool AddFontToOrderOfPriorityList(ServiceCtx context, SharedFontType fontType, uint offset) { ulong typesPosition = context.Request.ReceiveBuff[0].Position; - ulong typesSize = context.Request.ReceiveBuff[0].Size; + ulong typesSize = context.Request.ReceiveBuff[0].Size; ulong offsetsPosition = context.Request.ReceiveBuff[1].Position; - ulong offsetsSize = context.Request.ReceiveBuff[1].Size; + ulong offsetsSize = context.Request.ReceiveBuff[1].Size; ulong fontSizeBufferPosition = context.Request.ReceiveBuff[2].Position; - ulong fontSizeBufferSize = context.Request.ReceiveBuff[2].Size; + ulong fontSizeBufferSize = context.Request.ReceiveBuff[2].Size; - if (offset + 4 > (uint)typesSize || + if (offset + 4 > (uint)typesSize || offset + 4 > (uint)offsetsSize || offset + 4 > (uint)fontSizeBufferSize) { @@ -137,4 +143,4 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pl return true; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sdb/Pl/SharedFontManager.cs b/src/Ryujinx.HLE/HOS/Services/Sdb/Pl/SharedFontManager.cs index c0556c31..64179589 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sdb/Pl/SharedFontManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sdb/Pl/SharedFontManager.cs @@ -19,10 +19,10 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pl { class SharedFontManager { - private static readonly uint FontKey = 0x06186249; - private static readonly uint BFTTFMagic = 0x18029a7f; + private const uint FontKey = 0x06186249; + private const uint BFTTFMagic = 0x18029a7f; - private readonly Switch _device; + private readonly Switch _device; private readonly SharedMemoryStorage _storage; private struct FontInfo @@ -33,7 +33,7 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pl public FontInfo(int offset, int size) { Offset = offset; - Size = size; + Size = size; } } @@ -41,7 +41,7 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pl public SharedFontManager(Switch device, SharedMemoryStorage storage) { - _device = device; + _device = device; _storage = storage; } @@ -65,7 +65,7 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pl if (contentManager.TryGetFontTitle(name, out ulong fontTitle) && contentManager.TryGetFontFilename(name, out string fontFilename)) { string contentPath = contentManager.GetInstalledContentPath(fontTitle, StorageId.BuiltInSystem, NcaContentType.Data); - string fontPath = _device.FileSystem.SwitchPathToSystemPath(contentPath); + string fontPath = VirtualFileSystem.SwitchPathToSystemPath(contentPath); if (!string.IsNullOrWhiteSpace(fontPath)) { @@ -73,7 +73,7 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pl using (IStorage ncaFileStream = new LocalStorage(fontPath, FileAccess.Read, FileMode.Open)) { - Nca nca = new Nca(_device.System.KeySet, ncaFileStream); + Nca nca = new(_device.System.KeySet, ncaFileStream); IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _device.System.FsIntegrityCheckLevel); using var fontFile = new UniqueRef<IFile>(); @@ -83,7 +83,7 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pl data = DecryptFont(fontFile.Get.AsStream()); } - FontInfo info = new FontInfo((int)fontOffset, data.Length); + FontInfo info = new((int)fontOffset, data.Length); WriteMagicAndSize(fontOffset, data.Length); @@ -121,7 +121,7 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pl { SharedFontType.SimplifiedChineseEx, CreateFont("FontExtendedChineseSimplified") }, { SharedFontType.TraditionalChinese, CreateFont("FontChineseTraditional") }, { SharedFontType.Korean, CreateFont("FontKorean") }, - { SharedFontType.NintendoEx, CreateFont("FontNintendoExtended") } + { SharedFontType.NintendoEx, CreateFont("FontNintendoExtended") }, }; if (fontOffset > Horizon.FontSize) @@ -156,28 +156,27 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pl return _fontData[fontType].Offset + 8; } - private static byte[] DecryptFont(Stream bfttfStream) + private byte[] DecryptFont(Stream bfttfStream) { static uint KXor(uint data) => data ^ FontKey; - using (BinaryReader reader = new BinaryReader(bfttfStream)) - using (MemoryStream ttfStream = MemoryStreamManager.Shared.GetStream()) - using (BinaryWriter output = new BinaryWriter(ttfStream)) + using BinaryReader reader = new(bfttfStream); + using MemoryStream ttfStream = MemoryStreamManager.Shared.GetStream(); + using BinaryWriter output = new(ttfStream); + + if (KXor(reader.ReadUInt32()) != BFTTFMagic) { - if (KXor(reader.ReadUInt32()) != BFTTFMagic) - { - throw new InvalidDataException("Error: Input file is not in BFTTF format!"); - } + throw new InvalidDataException("Error: Input file is not in BFTTF format!"); + } - bfttfStream.Position += 4; + bfttfStream.Position += 4; - for (int i = 0; i < (bfttfStream.Length - 8) / 4; i++) - { - output.Write(KXor(reader.ReadUInt32())); - } - - return ttfStream.ToArray(); + for (int i = 0; i < (bfttfStream.Length - 8) / 4; i++) + { + output.Write(KXor(reader.ReadUInt32())); } + + return ttfStream.ToArray(); } } } diff --git a/src/Ryujinx.HLE/HOS/Services/Sdb/Pl/Types/SharedFontType.cs b/src/Ryujinx.HLE/HOS/Services/Sdb/Pl/Types/SharedFontType.cs index 90ee4f03..273fcafb 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sdb/Pl/Types/SharedFontType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sdb/Pl/Types/SharedFontType.cs @@ -2,12 +2,12 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pl.Types { public enum SharedFontType { - JapanUsEurope = 0, - SimplifiedChinese = 1, + JapanUsEurope = 0, + SimplifiedChinese = 1, SimplifiedChineseEx = 2, - TraditionalChinese = 3, - Korean = 4, - NintendoEx = 5, - Count + TraditionalChinese = 3, + Korean = 4, + NintendoEx = 5, + Count, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/ServerBase.cs b/src/Ryujinx.HLE/HOS/Services/ServerBase.cs index 4cd55a2e..f107f502 100644 --- a/src/Ryujinx.HLE/HOS/Services/ServerBase.cs +++ b/src/Ryujinx.HLE/HOS/Services/ServerBase.cs @@ -23,26 +23,25 @@ namespace Ryujinx.HLE.HOS.Services // not large enough. private const int PointerBufferSize = 0x8000; - private readonly static uint[] DefaultCapabilities = new uint[] - { + private readonly static uint[] _defaultCapabilities = { 0x030363F7, 0x1FFFFFCF, 0x207FFFEF, 0x47E0060F, 0x0048BFFF, - 0x01007FFF + 0x01007FFF, }; // The amount of time Dispose() will wait to Join() the thread executing the ServerLoop() - private static readonly TimeSpan ThreadJoinTimeout = TimeSpan.FromSeconds(3); + private static readonly TimeSpan _threadJoinTimeout = TimeSpan.FromSeconds(3); private readonly KernelContext _context; private KProcess _selfProcess; private KThread _selfThread; - private readonly ReaderWriterLockSlim _handleLock = new ReaderWriterLockSlim(); - private readonly Dictionary<int, IpcService> _sessions = new Dictionary<int, IpcService>(); - private readonly Dictionary<int, Func<IpcService>> _ports = new Dictionary<int, Func<IpcService>>(); + private readonly ReaderWriterLockSlim _handleLock = new(); + private readonly Dictionary<int, IpcService> _sessions = new(); + private readonly Dictionary<int, Func<IpcService>> _ports = new(); private readonly MemoryStream _requestDataStream; private readonly BinaryReader _requestDataReader; @@ -76,9 +75,9 @@ namespace Ryujinx.HLE.HOS.Services ProcessCreationFlags.Is64Bit | ProcessCreationFlags.PoolPartitionSystem; - ProcessCreationInfo creationInfo = new ProcessCreationInfo("Service", 1, 0, 0x8000000, 1, Flags, 0, 0); + ProcessCreationInfo creationInfo = new("Service", 1, 0, 0x8000000, 1, Flags, 0, 0); - KernelStatic.StartInitialProcess(context, creationInfo, DefaultCapabilities, 44, Main); + KernelStatic.StartInitialProcess(context, creationInfo, _defaultCapabilities, 44, Main); } private void AddPort(int serverPortHandle, Func<IpcService> objectFactory) @@ -281,7 +280,7 @@ namespace Ryujinx.HLE.HOS.Services { IpcMessage request = ReadRequest(); - IpcMessage response = new IpcMessage(); + IpcMessage response = new(); ulong tempAddr = recvListAddr; int sizesOffset = request.RawData.Length - ((request.RecvListBuff.Count * 2 + 3) & ~3); @@ -323,7 +322,7 @@ namespace Ryujinx.HLE.HOS.Services _responseDataStream.SetLength(0); - ServiceCtx context = new ServiceCtx( + ServiceCtx context = new( _context.Device, _selfProcess, _selfProcess.CpuMemory, @@ -340,7 +339,9 @@ namespace Ryujinx.HLE.HOS.Services else if (request.Type == IpcMessageType.CmifControl || request.Type == IpcMessageType.CmifControlWithContext) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment uint magic = (uint)_requestDataReader.ReadUInt64(); +#pragma warning restore IDE0059 uint cmdId = (uint)_requestDataReader.ReadUInt64(); switch (cmdId) @@ -382,7 +383,8 @@ namespace Ryujinx.HLE.HOS.Services break; } - default: throw new NotImplementedException(cmdId.ToString()); + default: + throw new NotImplementedException(cmdId.ToString()); } } else if (request.Type == IpcMessageType.CmifCloseSession || request.Type == IpcMessageType.TipcCloseSession) @@ -404,7 +406,7 @@ namespace Ryujinx.HLE.HOS.Services _responseDataStream.SetLength(0); - ServiceCtx context = new ServiceCtx( + ServiceCtx context = new( _context.Device, _selfProcess, _selfProcess.CpuMemory, @@ -437,15 +439,15 @@ namespace Ryujinx.HLE.HOS.Services private IpcMessage ReadRequest() { - const int messageSize = 0x100; + const int MessageSize = 0x100; - using IMemoryOwner<byte> reqDataOwner = ByteMemoryPool.Rent(messageSize); + using IMemoryOwner<byte> reqDataOwner = ByteMemoryPool.Rent(MessageSize); Span<byte> reqDataSpan = reqDataOwner.Memory.Span; _selfProcess.CpuMemory.Read(_selfThread.TlsAddress, reqDataSpan); - IpcMessage request = new IpcMessage(reqDataSpan, (long)_selfThread.TlsAddress); + IpcMessage request = new(reqDataSpan, (long)_selfThread.TlsAddress); return request; } @@ -480,9 +482,9 @@ namespace Ryujinx.HLE.HOS.Services { if (disposing && _selfThread != null) { - if (_selfThread.HostThread.ManagedThreadId != Environment.CurrentManagedThreadId && _selfThread.HostThread.Join(ThreadJoinTimeout) == false) + if (_selfThread.HostThread.ManagedThreadId != Environment.CurrentManagedThreadId && _selfThread.HostThread.Join(_threadJoinTimeout) == false) { - Logger.Warning?.Print(LogClass.Service, $"The ServerBase thread didn't terminate within {ThreadJoinTimeout:g}, waiting longer."); + Logger.Warning?.Print(LogClass.Service, $"The ServerBase thread didn't terminate within {_threadJoinTimeout:g}, waiting longer."); _selfThread.HostThread.Join(Timeout.Infinite); } diff --git a/src/Ryujinx.HLE/HOS/Services/ServiceAttributes.cs b/src/Ryujinx.HLE/HOS/Services/ServiceAttributes.cs index 1b896a27..c625af48 100644 --- a/src/Ryujinx.HLE/HOS/Services/ServiceAttributes.cs +++ b/src/Ryujinx.HLE/HOS/Services/ServiceAttributes.cs @@ -10,8 +10,8 @@ namespace Ryujinx.HLE.HOS.Services public ServiceAttribute(string name, object parameter = null) { - Name = name; + Name = name; Parameter = parameter; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Settings/IFactorySettingsServer.cs b/src/Ryujinx.HLE/HOS/Services/Settings/IFactorySettingsServer.cs index 4dd344f8..174a1c98 100644 --- a/src/Ryujinx.HLE/HOS/Services/Settings/IFactorySettingsServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Settings/IFactorySettingsServer.cs @@ -5,4 +5,4 @@ { public IFactorySettingsServer(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Settings/IFirmwareDebugSettingsServer.cs b/src/Ryujinx.HLE/HOS/Services/Settings/IFirmwareDebugSettingsServer.cs index 3b7e1af2..7368cf44 100644 --- a/src/Ryujinx.HLE/HOS/Services/Settings/IFirmwareDebugSettingsServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Settings/IFirmwareDebugSettingsServer.cs @@ -5,4 +5,4 @@ { public IFirmwareDebugSettingsServer(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Settings/ISettingsServer.cs b/src/Ryujinx.HLE/HOS/Services/Settings/ISettingsServer.cs index 17e9ec68..abb9b6d8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Settings/ISettingsServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Settings/ISettingsServer.cs @@ -123,7 +123,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings public ResultCode GetDeviceNickName(ServiceCtx context) { ulong deviceNickNameBufferPosition = context.Request.ReceiveBuff[0].Position; - ulong deviceNickNameBufferSize = context.Request.ReceiveBuff[0].Size; + ulong deviceNickNameBufferSize = context.Request.ReceiveBuff[0].Size; if (deviceNickNameBufferPosition == 0) { diff --git a/src/Ryujinx.HLE/HOS/Services/Settings/ISystemSettingsServer.cs b/src/Ryujinx.HLE/HOS/Services/Settings/ISystemSettingsServer.cs index 07c9f6b3..65748be3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Settings/ISystemSettingsServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Settings/ISystemSettingsServer.cs @@ -30,7 +30,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings // GetFirmwareVersion2() -> buffer<nn::settings::system::FirmwareVersion, 0x1a, 0x100> public ResultCode GetFirmwareVersion2(ServiceCtx context) { - ulong replyPos = context.Request.RecvListBuff[0].Position; + ulong replyPos = context.Request.RecvListBuff[0].Position; context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize(0x100L); @@ -46,43 +46,42 @@ namespace Ryujinx.HLE.HOS.Services.Settings const byte MajorFwVersion = 0x03; const byte MinorFwVersion = 0x00; const byte MicroFwVersion = 0x00; - const byte Unknown = 0x00; //Build? + const byte Unknown = 0x00; //Build? const int RevisionNumber = 0x0A; - const string Platform = "NX"; + const string Platform = "NX"; const string UnknownHex = "7fbde2b0bba4d14107bf836e4643043d9f6c8e47"; - const string Version = "3.0.0"; - const string Build = "NintendoSDK Firmware for NX 3.0.0-10.0"; + const string Version = "3.0.0"; + const string Build = "NintendoSDK Firmware for NX 3.0.0-10.0"; // http://switchbrew.org/index.php?title=System_Version_Title - using (MemoryStream ms = new MemoryStream(0x100)) - { - BinaryWriter writer = new BinaryWriter(ms); + using MemoryStream ms = new(0x100); - writer.Write(MajorFwVersion); - writer.Write(MinorFwVersion); - writer.Write(MicroFwVersion); - writer.Write(Unknown); + BinaryWriter writer = new(ms); - writer.Write(RevisionNumber); + writer.Write(MajorFwVersion); + writer.Write(MinorFwVersion); + writer.Write(MicroFwVersion); + writer.Write(Unknown); - writer.Write(Encoding.ASCII.GetBytes(Platform)); + writer.Write(RevisionNumber); - ms.Seek(0x28, SeekOrigin.Begin); + writer.Write(Encoding.ASCII.GetBytes(Platform)); - writer.Write(Encoding.ASCII.GetBytes(UnknownHex)); + ms.Seek(0x28, SeekOrigin.Begin); - ms.Seek(0x68, SeekOrigin.Begin); + writer.Write(Encoding.ASCII.GetBytes(UnknownHex)); - writer.Write(Encoding.ASCII.GetBytes(Version)); + ms.Seek(0x68, SeekOrigin.Begin); - ms.Seek(0x80, SeekOrigin.Begin); + writer.Write(Encoding.ASCII.GetBytes(Version)); - writer.Write(Encoding.ASCII.GetBytes(Build)); + ms.Seek(0x80, SeekOrigin.Begin); - context.Memory.Write(replyPos, ms.ToArray()); - } + writer.Write(Encoding.ASCII.GetBytes(Build)); + + context.Memory.Write(replyPos, ms.ToArray()); return ResultCode.Success; } @@ -111,10 +110,10 @@ namespace Ryujinx.HLE.HOS.Services.Settings // GetSettingsItemValueSize(buffer<nn::settings::SettingsName, 0x19>, buffer<nn::settings::SettingsItemKey, 0x19>) -> u64 public ResultCode GetSettingsItemValueSize(ServiceCtx context) { - ulong classPos = context.Request.PtrBuff[0].Position; + ulong classPos = context.Request.PtrBuff[0].Position; ulong classSize = context.Request.PtrBuff[0].Size; - ulong namePos = context.Request.PtrBuff[1].Position; + ulong namePos = context.Request.PtrBuff[1].Position; ulong nameSize = context.Request.PtrBuff[1].Size; byte[] classBuffer = new byte[classSize]; @@ -160,13 +159,13 @@ namespace Ryujinx.HLE.HOS.Services.Settings // GetSettingsItemValue(buffer<nn::settings::SettingsName, 0x19, 0x48>, buffer<nn::settings::SettingsItemKey, 0x19, 0x48>) -> (u64, buffer<unknown, 6, 0>) public ResultCode GetSettingsItemValue(ServiceCtx context) { - ulong classPos = context.Request.PtrBuff[0].Position; + ulong classPos = context.Request.PtrBuff[0].Position; ulong classSize = context.Request.PtrBuff[0].Size; - ulong namePos = context.Request.PtrBuff[1].Position; + ulong namePos = context.Request.PtrBuff[1].Position; ulong nameSize = context.Request.PtrBuff[1].Size; - ulong replyPos = context.Request.ReceiveBuff[0].Position; + ulong replyPos = context.Request.ReceiveBuff[0].Position; ulong replySize = context.Request.ReceiveBuff[0].Size; byte[] classBuffer = new byte[classSize]; @@ -250,7 +249,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings public ResultCode GetDeviceNickName(ServiceCtx context) { ulong deviceNickNameBufferPosition = context.Request.ReceiveBuff[0].Position; - ulong deviceNickNameBufferSize = context.Request.ReceiveBuff[0].Size; + ulong deviceNickNameBufferSize = context.Request.ReceiveBuff[0].Size; if (deviceNickNameBufferPosition == 0) { @@ -272,7 +271,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings public ResultCode SetDeviceNickName(ServiceCtx context) { ulong deviceNickNameBufferPosition = context.Request.SendBuff[0].Position; - ulong deviceNickNameBufferSize = context.Request.SendBuff[0].Size; + ulong deviceNickNameBufferSize = context.Request.SendBuff[0].Size; byte[] deviceNickNameBuffer = new byte[deviceNickNameBufferSize]; @@ -306,43 +305,41 @@ namespace Ryujinx.HLE.HOS.Services.Settings return null; } - string firmwareTitlePath = device.FileSystem.SwitchPathToSystemPath(contentPath); + string firmwareTitlePath = FileSystem.VirtualFileSystem.SwitchPathToSystemPath(contentPath); - using(IStorage firmwareStorage = new LocalStorage(firmwareTitlePath, FileAccess.Read)) - { - Nca firmwareContent = new Nca(device.System.KeySet, firmwareStorage); - - if (!firmwareContent.CanOpenSection(NcaSectionType.Data)) - { - return null; - } + using IStorage firmwareStorage = new LocalStorage(firmwareTitlePath, FileAccess.Read); + Nca firmwareContent = new(device.System.KeySet, firmwareStorage); - IFileSystem firmwareRomFs = firmwareContent.OpenFileSystem(NcaSectionType.Data, device.System.FsIntegrityCheckLevel); + if (!firmwareContent.CanOpenSection(NcaSectionType.Data)) + { + return null; + } - using var firmwareFile = new UniqueRef<IFile>(); + IFileSystem firmwareRomFs = firmwareContent.OpenFileSystem(NcaSectionType.Data, device.System.FsIntegrityCheckLevel); - Result result = firmwareRomFs.OpenFile(ref firmwareFile.Ref, "/file".ToU8Span(), OpenMode.Read); - if (result.IsFailure()) - { - return null; - } + using var firmwareFile = new UniqueRef<IFile>(); - result = firmwareFile.Get.GetSize(out long fileSize); - if (result.IsFailure()) - { - return null; - } + Result result = firmwareRomFs.OpenFile(ref firmwareFile.Ref, "/file".ToU8Span(), OpenMode.Read); + if (result.IsFailure()) + { + return null; + } - byte[] data = new byte[fileSize]; + result = firmwareFile.Get.GetSize(out long fileSize); + if (result.IsFailure()) + { + return null; + } - result = firmwareFile.Get.Read(out _, 0, data); - if (result.IsFailure()) - { - return null; - } + byte[] data = new byte[fileSize]; - return data; + result = firmwareFile.Get.Read(out _, 0, data); + if (result.IsFailure()) + { + return null; } + + return data; } } } diff --git a/src/Ryujinx.HLE/HOS/Services/Settings/KeyCodeMaps.cs b/src/Ryujinx.HLE/HOS/Services/Settings/KeyCodeMaps.cs index 67d1ac92..981fc18e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Settings/KeyCodeMaps.cs +++ b/src/Ryujinx.HLE/HOS/Services/Settings/KeyCodeMaps.cs @@ -1,6 +1,6 @@ namespace Ryujinx.HLE.HOS.Services.Settings { - class KeyCodeMaps + static class KeyCodeMaps { public static byte[] Default = { @@ -345,7 +345,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00, }; public static byte[] EnglishUsInternational = @@ -691,7 +691,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00, }; public static byte[] EnglishUk = @@ -1037,7 +1037,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00, }; public static byte[] French = @@ -1383,7 +1383,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00, }; public static byte[] FrenchCa = @@ -1729,7 +1729,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00, }; public static byte[] Spanish = @@ -2075,7 +2075,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00, }; public static byte[] SpanishLatin = @@ -2421,7 +2421,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00, }; public static byte[] German = @@ -2767,7 +2767,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00, }; public static byte[] Italian = @@ -3113,7 +3113,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00, }; public static byte[] Portuguese = @@ -3459,7 +3459,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00, }; public static byte[] Russian = @@ -3805,7 +3805,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00, }; public static byte[] Korean = @@ -4151,7 +4151,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00, }; public static byte[] ChineseSimplified = @@ -4497,7 +4497,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00, }; public static byte[] ChineseTraditional = @@ -4843,7 +4843,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00, }; }; } diff --git a/src/Ryujinx.HLE/HOS/Services/Settings/NxSettings.cs b/src/Ryujinx.HLE/HOS/Services/Settings/NxSettings.cs index e5f218a6..b2d4d55c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Settings/NxSettings.cs +++ b/src/Ryujinx.HLE/HOS/Services/Settings/NxSettings.cs @@ -5,7 +5,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings static class NxSettings { // Generated automatically from a Switch 3.0 config file (Tid: 0100000000000818). - public static Dictionary<string, object> Settings = new Dictionary<string, object> + public static Dictionary<string, object> Settings = new() { { "account!na_required_for_network_service", true }, { "account.daemon!background_awaking_periodicity", 10800 }, @@ -1706,7 +1706,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings { "time!standard_network_clock_sufficient_accuracy_minutes", 43200 }, { "time!standard_user_clock_initial_year", 2019 }, { "usb!usb30_force_enabled", false }, - { "wlan_debug!skip_wlan_boot", false } + { "wlan_debug!skip_wlan_boot", false }, }; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Settings/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Settings/ResultCode.cs index 8b0fde6c..9d467809 100644 --- a/src/Ryujinx.HLE/HOS/Services/Settings/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Settings/ResultCode.cs @@ -2,125 +2,125 @@ { enum ResultCode { - ModuleId = 105, + ModuleId = 105, ErrorCodeShift = 9, Success = 0, - NullSettingsName = (201 << ErrorCodeShift) | ModuleId, - NullSettingsKey = (202 << ErrorCodeShift) | ModuleId, - NullSettingsValue = (203 << ErrorCodeShift) | ModuleId, - NullSettingsValueBuffer = (205 << ErrorCodeShift) | ModuleId, - NullSettingValueSizeBuffer = (208 << ErrorCodeShift) | ModuleId, - NullDebugModeFlagBuffer = (209 << ErrorCodeShift) | ModuleId, - SettingGroupNameHasZeroLength = (221 << ErrorCodeShift) | ModuleId, - EmptySettingsItemKey = (222 << ErrorCodeShift) | ModuleId, - SettingGroupNameIsTooLong = (241 << ErrorCodeShift) | ModuleId, - SettingNameIsTooLong = (242 << ErrorCodeShift) | ModuleId, - SettingGroupNameEndsWithDotOrContainsInvalidCharacters = (261 << ErrorCodeShift) | ModuleId, - SettingNameEndsWithDotOrContainsInvalidCharacters = (262 << ErrorCodeShift) | ModuleId, - NullLanguageCodeBuffer = (621 << ErrorCodeShift) | ModuleId, - LanguageOutOfRange = (625 << ErrorCodeShift) | ModuleId, - NullNetworkSettingsBuffer = (631 << ErrorCodeShift) | ModuleId, - NullNetworkSettingsOutputCountBuffer = (632 << ErrorCodeShift) | ModuleId, - NullBacklightSettingsBuffer = (641 << ErrorCodeShift) | ModuleId, - NullBluetoothDeviceSettingBuffer = (651 << ErrorCodeShift) | ModuleId, - NullBluetoothDeviceSettingOutputCountBuffer = (652 << ErrorCodeShift) | ModuleId, - NullBluetoothEnableFlagBuffer = (653 << ErrorCodeShift) | ModuleId, - NullBluetoothAFHEnableFlagBuffer = (654 << ErrorCodeShift) | ModuleId, - NullBluetoothBoostEnableFlagBuffer = (655 << ErrorCodeShift) | ModuleId, - NullBLEPairingSettingsBuffer = (656 << ErrorCodeShift) | ModuleId, - NullBLEPairingSettingsEntryCountBuffer = (657 << ErrorCodeShift) | ModuleId, - NullExternalSteadyClockSourceIDBuffer = (661 << ErrorCodeShift) | ModuleId, - NullUserSystemClockContextBuffer = (662 << ErrorCodeShift) | ModuleId, - NullNetworkSystemClockContextBuffer = (663 << ErrorCodeShift) | ModuleId, - NullUserSystemClockAutomaticCorrectionEnabledFlagBuffer = (664 << ErrorCodeShift) | ModuleId, - NullShutdownRTCValueBuffer = (665 << ErrorCodeShift) | ModuleId, - NullExternalSteadyClockInternalOffsetBuffer = (666 << ErrorCodeShift) | ModuleId, - NullAccountSettingsBuffer = (671 << ErrorCodeShift) | ModuleId, - NullAudioVolumeBuffer = (681 << ErrorCodeShift) | ModuleId, - NullForceMuteOnHeadphoneRemovedBuffer = (683 << ErrorCodeShift) | ModuleId, - NullHeadphoneVolumeWarningCountBuffer = (684 << ErrorCodeShift) | ModuleId, - InvalidAudioOutputMode = (687 << ErrorCodeShift) | ModuleId, - NullHeadphoneVolumeUpdateFlagBuffer = (688 << ErrorCodeShift) | ModuleId, - NullConsoleInformationUploadFlagBuffer = (691 << ErrorCodeShift) | ModuleId, - NullAutomaticApplicationDownloadFlagBuffer = (701 << ErrorCodeShift) | ModuleId, - NullNotificationSettingsBuffer = (702 << ErrorCodeShift) | ModuleId, - NullAccountNotificationSettingsEntryCountBuffer = (703 << ErrorCodeShift) | ModuleId, - NullAccountNotificationSettingsBuffer = (704 << ErrorCodeShift) | ModuleId, - NullVibrationMasterVolumeBuffer = (711 << ErrorCodeShift) | ModuleId, - NullNXControllerSettingsBuffer = (712 << ErrorCodeShift) | ModuleId, - NullNXControllerSettingsEntryCountBuffer = (713 << ErrorCodeShift) | ModuleId, - NullUSBFullKeyEnableFlagBuffer = (714 << ErrorCodeShift) | ModuleId, - NullTVSettingsBuffer = (721 << ErrorCodeShift) | ModuleId, - NullEDIDBuffer = (722 << ErrorCodeShift) | ModuleId, - NullDataDeletionSettingsBuffer = (731 << ErrorCodeShift) | ModuleId, - NullInitialSystemAppletProgramIDBuffer = (741 << ErrorCodeShift) | ModuleId, - NullOverlayDispProgramIDBuffer = (742 << ErrorCodeShift) | ModuleId, - NullIsInRepairProcessBuffer = (743 << ErrorCodeShift) | ModuleId, - NullRequiresRunRepairTimeReviserBuffer = (744 << ErrorCodeShift) | ModuleId, - NullDeviceTimezoneLocationNameBuffer = (751 << ErrorCodeShift) | ModuleId, - NullPrimaryAlbumStorageBuffer = (761 << ErrorCodeShift) | ModuleId, - NullUSB30EnableFlagBuffer = (771 << ErrorCodeShift) | ModuleId, - NullUSBTypeCPowerSourceCircuitVersionBuffer = (772 << ErrorCodeShift) | ModuleId, - NullBatteryLotBuffer = (781 << ErrorCodeShift) | ModuleId, - NullSerialNumberBuffer = (791 << ErrorCodeShift) | ModuleId, - NullLockScreenFlagBuffer = (801 << ErrorCodeShift) | ModuleId, - NullColorSetIDBuffer = (803 << ErrorCodeShift) | ModuleId, - NullQuestFlagBuffer = (804 << ErrorCodeShift) | ModuleId, - NullWirelessCertificationFileSizeBuffer = (805 << ErrorCodeShift) | ModuleId, - NullWirelessCertificationFileBuffer = (806 << ErrorCodeShift) | ModuleId, - NullInitialLaunchSettingsBuffer = (807 << ErrorCodeShift) | ModuleId, - NullDeviceNicknameBuffer = (808 << ErrorCodeShift) | ModuleId, - NullBatteryPercentageFlagBuffer = (809 << ErrorCodeShift) | ModuleId, - NullAppletLaunchFlagsBuffer = (810 << ErrorCodeShift) | ModuleId, - NullWirelessLANEnableFlagBuffer = (1012 << ErrorCodeShift) | ModuleId, - NullProductModelBuffer = (1021 << ErrorCodeShift) | ModuleId, - NullNFCEnableFlagBuffer = (1031 << ErrorCodeShift) | ModuleId, - NullECIDeviceCertificateBuffer = (1041 << ErrorCodeShift) | ModuleId, - NullETicketDeviceCertificateBuffer = (1042 << ErrorCodeShift) | ModuleId, - NullSleepSettingsBuffer = (1051 << ErrorCodeShift) | ModuleId, - NullEULAVersionBuffer = (1061 << ErrorCodeShift) | ModuleId, - NullEULAVersionEntryCountBuffer = (1062 << ErrorCodeShift) | ModuleId, - NullLDNChannelBuffer = (1071 << ErrorCodeShift) | ModuleId, - NullSSLKeyBuffer = (1081 << ErrorCodeShift) | ModuleId, - NullSSLCertificateBuffer = (1082 << ErrorCodeShift) | ModuleId, - NullTelemetryFlagsBuffer = (1091 << ErrorCodeShift) | ModuleId, - NullGamecardKeyBuffer = (1101 << ErrorCodeShift) | ModuleId, - NullGamecardCertificateBuffer = (1102 << ErrorCodeShift) | ModuleId, - NullPTMBatteryLotBuffer = (1111 << ErrorCodeShift) | ModuleId, - NullPTMFuelGaugeParameterBuffer = (1112 << ErrorCodeShift) | ModuleId, - NullECIDeviceKeyBuffer = (1121 << ErrorCodeShift) | ModuleId, - NullETicketDeviceKeyBuffer = (1122 << ErrorCodeShift) | ModuleId, - NullSpeakerParameterBuffer = (1131 << ErrorCodeShift) | ModuleId, - NullFirmwareVersionBuffer = (1141 << ErrorCodeShift) | ModuleId, - NullFirmwareVersionDigestBuffer = (1142 << ErrorCodeShift) | ModuleId, - NullRebootlessSystemUpdateVersionBuffer = (1143 << ErrorCodeShift) | ModuleId, - NullMiiAuthorIDBuffer = (1151 << ErrorCodeShift) | ModuleId, - NullFatalFlagsBuffer = (1161 << ErrorCodeShift) | ModuleId, - NullAutoUpdateEnableFlagBuffer = (1171 << ErrorCodeShift) | ModuleId, - NullExternalRTCResetFlagBuffer = (1181 << ErrorCodeShift) | ModuleId, - NullPushNotificationActivityModeBuffer = (1191 << ErrorCodeShift) | ModuleId, - NullServiceDiscoveryControlSettingBuffer = (1201 << ErrorCodeShift) | ModuleId, - NullErrorReportSharePermissionBuffer = (1211 << ErrorCodeShift) | ModuleId, - NullLCDVendorIDBuffer = (1221 << ErrorCodeShift) | ModuleId, - NullConsoleSixAxisSensorAccelerationBiasBuffer = (1231 << ErrorCodeShift) | ModuleId, - NullConsoleSixAxisSensorAngularVelocityBiasBuffer = (1232 << ErrorCodeShift) | ModuleId, - NullConsoleSixAxisSensorAccelerationGainBuffer = (1233 << ErrorCodeShift) | ModuleId, - NullConsoleSixAxisSensorAngularVelocityGainBuffer = (1234 << ErrorCodeShift) | ModuleId, - NullConsoleSixAxisSensorAngularVelocityTimeBiasBuffer = (1235 << ErrorCodeShift) | ModuleId, - NullConsoleSixAxisSensorAngularAccelerationBuffer = (1236 << ErrorCodeShift) | ModuleId, - NullKeyboardLayoutBuffer = (1241 << ErrorCodeShift) | ModuleId, - InvalidKeyboardLayout = (1245 << ErrorCodeShift) | ModuleId, - NullWebInspectorFlagBuffer = (1251 << ErrorCodeShift) | ModuleId, - NullAllowedSSLHostsBuffer = (1252 << ErrorCodeShift) | ModuleId, - NullAllowedSSLHostsEntryCountBuffer = (1253 << ErrorCodeShift) | ModuleId, - NullHostFSMountPointBuffer = (1254 << ErrorCodeShift) | ModuleId, - NullAmiiboKeyBuffer = (1271 << ErrorCodeShift) | ModuleId, - NullAmiiboECQVCertificateBuffer = (1272 << ErrorCodeShift) | ModuleId, - NullAmiiboECDSACertificateBuffer = (1273 << ErrorCodeShift) | ModuleId, - NullAmiiboECQVBLSKeyBuffer = (1274 << ErrorCodeShift) | ModuleId, - NullAmiiboECQVBLSCertificateBuffer = (1275 << ErrorCodeShift) | ModuleId, - NullAmiiboECQVBLSRootCertificateBuffer = (1276 << ErrorCodeShift) | ModuleId + NullSettingsName = (201 << ErrorCodeShift) | ModuleId, + NullSettingsKey = (202 << ErrorCodeShift) | ModuleId, + NullSettingsValue = (203 << ErrorCodeShift) | ModuleId, + NullSettingsValueBuffer = (205 << ErrorCodeShift) | ModuleId, + NullSettingValueSizeBuffer = (208 << ErrorCodeShift) | ModuleId, + NullDebugModeFlagBuffer = (209 << ErrorCodeShift) | ModuleId, + SettingGroupNameHasZeroLength = (221 << ErrorCodeShift) | ModuleId, + EmptySettingsItemKey = (222 << ErrorCodeShift) | ModuleId, + SettingGroupNameIsTooLong = (241 << ErrorCodeShift) | ModuleId, + SettingNameIsTooLong = (242 << ErrorCodeShift) | ModuleId, + SettingGroupNameEndsWithDotOrContainsInvalidCharacters = (261 << ErrorCodeShift) | ModuleId, + SettingNameEndsWithDotOrContainsInvalidCharacters = (262 << ErrorCodeShift) | ModuleId, + NullLanguageCodeBuffer = (621 << ErrorCodeShift) | ModuleId, + LanguageOutOfRange = (625 << ErrorCodeShift) | ModuleId, + NullNetworkSettingsBuffer = (631 << ErrorCodeShift) | ModuleId, + NullNetworkSettingsOutputCountBuffer = (632 << ErrorCodeShift) | ModuleId, + NullBacklightSettingsBuffer = (641 << ErrorCodeShift) | ModuleId, + NullBluetoothDeviceSettingBuffer = (651 << ErrorCodeShift) | ModuleId, + NullBluetoothDeviceSettingOutputCountBuffer = (652 << ErrorCodeShift) | ModuleId, + NullBluetoothEnableFlagBuffer = (653 << ErrorCodeShift) | ModuleId, + NullBluetoothAFHEnableFlagBuffer = (654 << ErrorCodeShift) | ModuleId, + NullBluetoothBoostEnableFlagBuffer = (655 << ErrorCodeShift) | ModuleId, + NullBLEPairingSettingsBuffer = (656 << ErrorCodeShift) | ModuleId, + NullBLEPairingSettingsEntryCountBuffer = (657 << ErrorCodeShift) | ModuleId, + NullExternalSteadyClockSourceIDBuffer = (661 << ErrorCodeShift) | ModuleId, + NullUserSystemClockContextBuffer = (662 << ErrorCodeShift) | ModuleId, + NullNetworkSystemClockContextBuffer = (663 << ErrorCodeShift) | ModuleId, + NullUserSystemClockAutomaticCorrectionEnabledFlagBuffer = (664 << ErrorCodeShift) | ModuleId, + NullShutdownRTCValueBuffer = (665 << ErrorCodeShift) | ModuleId, + NullExternalSteadyClockInternalOffsetBuffer = (666 << ErrorCodeShift) | ModuleId, + NullAccountSettingsBuffer = (671 << ErrorCodeShift) | ModuleId, + NullAudioVolumeBuffer = (681 << ErrorCodeShift) | ModuleId, + NullForceMuteOnHeadphoneRemovedBuffer = (683 << ErrorCodeShift) | ModuleId, + NullHeadphoneVolumeWarningCountBuffer = (684 << ErrorCodeShift) | ModuleId, + InvalidAudioOutputMode = (687 << ErrorCodeShift) | ModuleId, + NullHeadphoneVolumeUpdateFlagBuffer = (688 << ErrorCodeShift) | ModuleId, + NullConsoleInformationUploadFlagBuffer = (691 << ErrorCodeShift) | ModuleId, + NullAutomaticApplicationDownloadFlagBuffer = (701 << ErrorCodeShift) | ModuleId, + NullNotificationSettingsBuffer = (702 << ErrorCodeShift) | ModuleId, + NullAccountNotificationSettingsEntryCountBuffer = (703 << ErrorCodeShift) | ModuleId, + NullAccountNotificationSettingsBuffer = (704 << ErrorCodeShift) | ModuleId, + NullVibrationMasterVolumeBuffer = (711 << ErrorCodeShift) | ModuleId, + NullNXControllerSettingsBuffer = (712 << ErrorCodeShift) | ModuleId, + NullNXControllerSettingsEntryCountBuffer = (713 << ErrorCodeShift) | ModuleId, + NullUSBFullKeyEnableFlagBuffer = (714 << ErrorCodeShift) | ModuleId, + NullTVSettingsBuffer = (721 << ErrorCodeShift) | ModuleId, + NullEDIDBuffer = (722 << ErrorCodeShift) | ModuleId, + NullDataDeletionSettingsBuffer = (731 << ErrorCodeShift) | ModuleId, + NullInitialSystemAppletProgramIDBuffer = (741 << ErrorCodeShift) | ModuleId, + NullOverlayDispProgramIDBuffer = (742 << ErrorCodeShift) | ModuleId, + NullIsInRepairProcessBuffer = (743 << ErrorCodeShift) | ModuleId, + NullRequiresRunRepairTimeReviserBuffer = (744 << ErrorCodeShift) | ModuleId, + NullDeviceTimezoneLocationNameBuffer = (751 << ErrorCodeShift) | ModuleId, + NullPrimaryAlbumStorageBuffer = (761 << ErrorCodeShift) | ModuleId, + NullUSB30EnableFlagBuffer = (771 << ErrorCodeShift) | ModuleId, + NullUSBTypeCPowerSourceCircuitVersionBuffer = (772 << ErrorCodeShift) | ModuleId, + NullBatteryLotBuffer = (781 << ErrorCodeShift) | ModuleId, + NullSerialNumberBuffer = (791 << ErrorCodeShift) | ModuleId, + NullLockScreenFlagBuffer = (801 << ErrorCodeShift) | ModuleId, + NullColorSetIDBuffer = (803 << ErrorCodeShift) | ModuleId, + NullQuestFlagBuffer = (804 << ErrorCodeShift) | ModuleId, + NullWirelessCertificationFileSizeBuffer = (805 << ErrorCodeShift) | ModuleId, + NullWirelessCertificationFileBuffer = (806 << ErrorCodeShift) | ModuleId, + NullInitialLaunchSettingsBuffer = (807 << ErrorCodeShift) | ModuleId, + NullDeviceNicknameBuffer = (808 << ErrorCodeShift) | ModuleId, + NullBatteryPercentageFlagBuffer = (809 << ErrorCodeShift) | ModuleId, + NullAppletLaunchFlagsBuffer = (810 << ErrorCodeShift) | ModuleId, + NullWirelessLANEnableFlagBuffer = (1012 << ErrorCodeShift) | ModuleId, + NullProductModelBuffer = (1021 << ErrorCodeShift) | ModuleId, + NullNFCEnableFlagBuffer = (1031 << ErrorCodeShift) | ModuleId, + NullECIDeviceCertificateBuffer = (1041 << ErrorCodeShift) | ModuleId, + NullETicketDeviceCertificateBuffer = (1042 << ErrorCodeShift) | ModuleId, + NullSleepSettingsBuffer = (1051 << ErrorCodeShift) | ModuleId, + NullEULAVersionBuffer = (1061 << ErrorCodeShift) | ModuleId, + NullEULAVersionEntryCountBuffer = (1062 << ErrorCodeShift) | ModuleId, + NullLDNChannelBuffer = (1071 << ErrorCodeShift) | ModuleId, + NullSSLKeyBuffer = (1081 << ErrorCodeShift) | ModuleId, + NullSSLCertificateBuffer = (1082 << ErrorCodeShift) | ModuleId, + NullTelemetryFlagsBuffer = (1091 << ErrorCodeShift) | ModuleId, + NullGamecardKeyBuffer = (1101 << ErrorCodeShift) | ModuleId, + NullGamecardCertificateBuffer = (1102 << ErrorCodeShift) | ModuleId, + NullPTMBatteryLotBuffer = (1111 << ErrorCodeShift) | ModuleId, + NullPTMFuelGaugeParameterBuffer = (1112 << ErrorCodeShift) | ModuleId, + NullECIDeviceKeyBuffer = (1121 << ErrorCodeShift) | ModuleId, + NullETicketDeviceKeyBuffer = (1122 << ErrorCodeShift) | ModuleId, + NullSpeakerParameterBuffer = (1131 << ErrorCodeShift) | ModuleId, + NullFirmwareVersionBuffer = (1141 << ErrorCodeShift) | ModuleId, + NullFirmwareVersionDigestBuffer = (1142 << ErrorCodeShift) | ModuleId, + NullRebootlessSystemUpdateVersionBuffer = (1143 << ErrorCodeShift) | ModuleId, + NullMiiAuthorIDBuffer = (1151 << ErrorCodeShift) | ModuleId, + NullFatalFlagsBuffer = (1161 << ErrorCodeShift) | ModuleId, + NullAutoUpdateEnableFlagBuffer = (1171 << ErrorCodeShift) | ModuleId, + NullExternalRTCResetFlagBuffer = (1181 << ErrorCodeShift) | ModuleId, + NullPushNotificationActivityModeBuffer = (1191 << ErrorCodeShift) | ModuleId, + NullServiceDiscoveryControlSettingBuffer = (1201 << ErrorCodeShift) | ModuleId, + NullErrorReportSharePermissionBuffer = (1211 << ErrorCodeShift) | ModuleId, + NullLCDVendorIDBuffer = (1221 << ErrorCodeShift) | ModuleId, + NullConsoleSixAxisSensorAccelerationBiasBuffer = (1231 << ErrorCodeShift) | ModuleId, + NullConsoleSixAxisSensorAngularVelocityBiasBuffer = (1232 << ErrorCodeShift) | ModuleId, + NullConsoleSixAxisSensorAccelerationGainBuffer = (1233 << ErrorCodeShift) | ModuleId, + NullConsoleSixAxisSensorAngularVelocityGainBuffer = (1234 << ErrorCodeShift) | ModuleId, + NullConsoleSixAxisSensorAngularVelocityTimeBiasBuffer = (1235 << ErrorCodeShift) | ModuleId, + NullConsoleSixAxisSensorAngularAccelerationBuffer = (1236 << ErrorCodeShift) | ModuleId, + NullKeyboardLayoutBuffer = (1241 << ErrorCodeShift) | ModuleId, + InvalidKeyboardLayout = (1245 << ErrorCodeShift) | ModuleId, + NullWebInspectorFlagBuffer = (1251 << ErrorCodeShift) | ModuleId, + NullAllowedSSLHostsBuffer = (1252 << ErrorCodeShift) | ModuleId, + NullAllowedSSLHostsEntryCountBuffer = (1253 << ErrorCodeShift) | ModuleId, + NullHostFSMountPointBuffer = (1254 << ErrorCodeShift) | ModuleId, + NullAmiiboKeyBuffer = (1271 << ErrorCodeShift) | ModuleId, + NullAmiiboECQVCertificateBuffer = (1272 << ErrorCodeShift) | ModuleId, + NullAmiiboECDSACertificateBuffer = (1273 << ErrorCodeShift) | ModuleId, + NullAmiiboECQVBLSKeyBuffer = (1274 << ErrorCodeShift) | ModuleId, + NullAmiiboECQVBLSCertificateBuffer = (1275 << ErrorCodeShift) | ModuleId, + NullAmiiboECQVBLSRootCertificateBuffer = (1276 << ErrorCodeShift) | ModuleId, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Settings/Types/PlatformRegion.cs b/src/Ryujinx.HLE/HOS/Services/Settings/Types/PlatformRegion.cs index b8ef8e8e..3953c050 100644 --- a/src/Ryujinx.HLE/HOS/Services/Settings/Types/PlatformRegion.cs +++ b/src/Ryujinx.HLE/HOS/Services/Settings/Types/PlatformRegion.cs @@ -3,6 +3,6 @@ enum PlatformRegion { Global = 1, - China = 2 + China = 2, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sm/IManagerInterface.cs b/src/Ryujinx.HLE/HOS/Services/Sm/IManagerInterface.cs index f867f23a..412a3324 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sm/IManagerInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sm/IManagerInterface.cs @@ -5,4 +5,4 @@ { public IManagerInterface(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs b/src/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs index 005ec32d..2d850220 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs @@ -13,7 +13,7 @@ namespace Ryujinx.HLE.HOS.Services.Sm { class IUserInterface : IpcService { - private static Dictionary<string, Type> _services; + private static readonly Dictionary<string, Type> _services; private readonly SmRegistry _registry; private readonly ServerBase _commonServer; @@ -68,7 +68,7 @@ namespace Ryujinx.HLE.HOS.Services.Sm return ResultCode.InvalidName; } - KSession session = new KSession(context.Device.System.KernelContext); + KSession session = new(context.Device.System.KernelContext); if (_registry.TryGetService(name, out KPort port)) { @@ -182,7 +182,7 @@ namespace Ryujinx.HLE.HOS.Services.Sm Logger.Debug?.Print(LogClass.ServiceSm, $"Register \"{name}\"."); - KPort port = new KPort(context.Device.System.KernelContext, maxSessions, isLight, null); + KPort port = new(context.Device.System.KernelContext, maxSessions, isLight, null); if (!_registry.TryRegister(name, port)) { @@ -215,9 +215,10 @@ namespace Ryujinx.HLE.HOS.Services.Sm context.RequestData.BaseStream.Seek(namePosition + 8, SeekOrigin.Begin); +#pragma warning disable IDE0059 // Remove unnecessary value assignment bool isLight = (context.RequestData.ReadInt32() & 1) != 0; - int maxSessions = context.RequestData.ReadInt32(); +#pragma warning restore IDE0059 if (string.IsNullOrEmpty(name)) { @@ -258,4 +259,4 @@ namespace Ryujinx.HLE.HOS.Services.Sm base.DestroyAtExit(); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sm/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Sm/ResultCode.cs index f72bf010..6db33d2a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sm/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sm/ResultCode.cs @@ -2,14 +2,14 @@ namespace Ryujinx.HLE.HOS.Services.Sm { enum ResultCode { - ModuleId = 21, + ModuleId = 21, ErrorCodeShift = 9, Success = 0, - NotInitialized = (2 << ErrorCodeShift) | ModuleId, + NotInitialized = (2 << ErrorCodeShift) | ModuleId, AlreadyRegistered = (4 << ErrorCodeShift) | ModuleId, - InvalidName = (6 << ErrorCodeShift) | ModuleId, - NotRegistered = (7 << ErrorCodeShift) | ModuleId + InvalidName = (6 << ErrorCodeShift) | ModuleId, + NotRegistered = (7 << ErrorCodeShift) | ModuleId, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sm/SmRegistry.cs b/src/Ryujinx.HLE/HOS/Services/Sm/SmRegistry.cs index e62e0eb5..3919eaae 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sm/SmRegistry.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sm/SmRegistry.cs @@ -46,4 +46,4 @@ namespace Ryujinx.HLE.HOS.Services.Sm _serviceRegistrationEvent.WaitOne(); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/BsdContext.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/BsdContext.cs index b0ac6e68..254ad667 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/BsdContext.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/BsdContext.cs @@ -8,11 +8,11 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd { class BsdContext { - private static ConcurrentDictionary<ulong, BsdContext> _registry = new ConcurrentDictionary<ulong, BsdContext>(); + private static readonly ConcurrentDictionary<ulong, BsdContext> _registry = new(); private readonly object _lock = new(); - private List<IFileDescriptor> _fds; + private readonly List<IFileDescriptor> _fds; private BsdContext() { @@ -181,4 +181,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd return processContext; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs index b63864c9..d16e7536 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs @@ -7,7 +7,6 @@ using System; using System.Collections.Generic; using System.Net; using System.Net.Sockets; -using System.Numerics; using System.Runtime.CompilerServices; using System.Text; @@ -17,14 +16,14 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd [Service("bsd:u", false)] class IClient : IpcService { - private static readonly List<IPollManager> _pollManagers = new List<IPollManager> + private static readonly List<IPollManager> _pollManagers = new() { EventFileDescriptorPollManager.Instance, - ManagedSocketPollManager.Instance + ManagedSocketPollManager.Instance, }; private BsdContext _context; - private bool _isPrivileged; + private readonly bool _isPrivileged; public IClient(ServiceCtx context, bool isPrivileged) : base(context.Device.System.BsdServer) { @@ -46,19 +45,14 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd private static AddressFamily ConvertBsdAddressFamily(BsdAddressFamily family) { - switch (family) + return family switch { - case BsdAddressFamily.Unspecified: - return AddressFamily.Unspecified; - case BsdAddressFamily.InterNetwork: - return AddressFamily.InterNetwork; - case BsdAddressFamily.InterNetworkV6: - return AddressFamily.InterNetworkV6; - case BsdAddressFamily.Unknown: - return AddressFamily.Unknown; - default: - throw new NotImplementedException(family.ToString()); - } + BsdAddressFamily.Unspecified => AddressFamily.Unspecified, + BsdAddressFamily.InterNetwork => AddressFamily.InterNetwork, + BsdAddressFamily.InterNetworkV6 => AddressFamily.InterNetworkV6, + BsdAddressFamily.Unknown => AddressFamily.Unknown, + _ => throw new NotImplementedException(family.ToString()), + }; } private LinuxError SetResultErrno(IFileDescriptor socket, int result) @@ -68,9 +62,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd private ResultCode SocketInternal(ServiceCtx context, bool exempt) { - BsdAddressFamily domain = (BsdAddressFamily)context.RequestData.ReadInt32(); - BsdSocketType type = (BsdSocketType)context.RequestData.ReadInt32(); - ProtocolType protocol = (ProtocolType)context.RequestData.ReadInt32(); + BsdAddressFamily domain = (BsdAddressFamily)context.RequestData.ReadInt32(); + BsdSocketType type = (BsdSocketType)context.RequestData.ReadInt32(); + ProtocolType protocol = (ProtocolType)context.RequestData.ReadInt32(); BsdSocketCreationFlags creationFlags = (BsdSocketCreationFlags)((int)type >> (int)BsdSocketCreationFlags.FlagsShift); type &= BsdSocketType.TypeMask; @@ -101,8 +95,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd } } - ISocket newBsdSocket = new ManagedSocket(netDomain, (SocketType)type, protocol); - newBsdSocket.Blocking = !creationFlags.HasFlag(BsdSocketCreationFlags.NonBlocking); + ISocket newBsdSocket = new ManagedSocket(netDomain, (SocketType)type, protocol) + { + Blocking = !creationFlags.HasFlag(BsdSocketCreationFlags.NonBlocking), + }; LinuxError errno = LinuxError.SUCCESS; @@ -210,7 +206,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd public ResultCode Select(ServiceCtx context) { int fdsCount = context.RequestData.ReadInt32(); - int timeout = context.RequestData.ReadInt32(); + int timeout = context.RequestData.ReadInt32(); (ulong readFdsInBufferPosition, ulong readFdsInBufferSize) = context.Request.GetBufferType0x21(0); (ulong writeFdsInBufferPosition, ulong writeFdsInBufferSize) = context.Request.GetBufferType0x21(1); @@ -220,7 +216,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd (ulong writeFdsOutBufferPosition, ulong writeFdsOutBufferSize) = context.Request.GetBufferType0x22(1); (ulong errorFdsOutBufferPosition, ulong errorFdsOutBufferSize) = context.Request.GetBufferType0x22(2); - List<IFileDescriptor> readFds = _context.RetrieveFileDescriptorsFromMask(context.Memory.GetSpan(readFdsInBufferPosition, (int)readFdsInBufferSize)); + List<IFileDescriptor> readFds = _context.RetrieveFileDescriptorsFromMask(context.Memory.GetSpan(readFdsInBufferPosition, (int)readFdsInBufferSize)); List<IFileDescriptor> writeFds = _context.RetrieveFileDescriptorsFromMask(context.Memory.GetSpan(writeFdsInBufferPosition, (int)writeFdsInBufferSize)); List<IFileDescriptor> errorFds = _context.RetrieveFileDescriptorsFromMask(context.Memory.GetSpan(errorFdsInBufferPosition, (int)errorFdsInBufferSize)); @@ -312,7 +308,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd } } - using var readFdsOut = context.Memory.GetWritableRegion(readFdsOutBufferPosition, (int)readFdsOutBufferSize); + using var readFdsOut = context.Memory.GetWritableRegion(readFdsOutBufferPosition, (int)readFdsOutBufferSize); using var writeFdsOut = context.Memory.GetWritableRegion(writeFdsOutBufferPosition, (int)writeFdsOutBufferSize); using var errorFdsOut = context.Memory.GetWritableRegion(errorFdsOutBufferPosition, (int)errorFdsOutBufferSize); @@ -330,10 +326,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd public ResultCode Poll(ServiceCtx context) { int fdsCount = context.RequestData.ReadInt32(); - int timeout = context.RequestData.ReadInt32(); + int timeout = context.RequestData.ReadInt32(); (ulong inputBufferPosition, ulong inputBufferSize) = context.Request.GetBufferType0x21(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment (ulong outputBufferPosition, ulong outputBufferSize) = context.Request.GetBufferType0x22(); +#pragma warning restore IDE0059 if (timeout < -1 || fdsCount < 0 || (ulong)(fdsCount * 8) > inputBufferSize) { @@ -356,7 +354,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd events[i] = new PollEvent(pollEventData, fileDescriptor); } - List<PollEvent> discoveredEvents = new List<PollEvent>(); + List<PollEvent> discoveredEvents = new(); List<PollEvent>[] eventsByPollManager = new List<PollEvent>[_pollManagers.Count]; for (int i = 0; i < eventsByPollManager.Length; i++) @@ -389,7 +387,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd if (fdsCount != 0) { - bool IsUnexpectedLinuxError(LinuxError error) + static bool IsUnexpectedLinuxError(LinuxError error) { return error != LinuxError.SUCCESS && error != LinuxError.ETIMEDOUT; } @@ -478,16 +476,16 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd // Recv(u32 socket, u32 flags) -> (i32 ret, u32 bsd_errno, array<i8, 0x22> message) public ResultCode Recv(ServiceCtx context) { - int socketFd = context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); BsdSocketFlags socketFlags = (BsdSocketFlags)context.RequestData.ReadInt32(); (ulong receivePosition, ulong receiveLength) = context.Request.GetBufferType0x22(); WritableRegion receiveRegion = context.Memory.GetWritableRegion(receivePosition, (int)receiveLength); - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); - int result = -1; + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); + int result = -1; if (socket != null) { @@ -508,17 +506,17 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd // RecvFrom(u32 sock, u32 flags) -> (i32 ret, u32 bsd_errno, u32 addrlen, buffer<i8, 0x22, 0> message, buffer<nn::socket::sockaddr_in, 0x22, 0x10>) public ResultCode RecvFrom(ServiceCtx context) { - int socketFd = context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); BsdSocketFlags socketFlags = (BsdSocketFlags)context.RequestData.ReadInt32(); - (ulong receivePosition, ulong receiveLength) = context.Request.GetBufferType0x22(0); + (ulong receivePosition, ulong receiveLength) = context.Request.GetBufferType0x22(0); (ulong sockAddrOutPosition, ulong sockAddrOutSize) = context.Request.GetBufferType0x22(1); WritableRegion receiveRegion = context.Memory.GetWritableRegion(receivePosition, (int)receiveLength); - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); - int result = -1; + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); + int result = -1; if (socket != null) { @@ -530,7 +528,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd receiveRegion.Dispose(); - if (sockAddrOutSize != 0 && sockAddrOutSize >= (ulong) Unsafe.SizeOf<BsdSockAddr>()) + if (sockAddrOutSize != 0 && sockAddrOutSize >= (ulong)Unsafe.SizeOf<BsdSockAddr>()) { context.Memory.Write(sockAddrOutPosition, BsdSockAddr.FromIPEndPoint(endPoint)); } @@ -548,16 +546,16 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd // Send(u32 socket, u32 flags, buffer<i8, 0x21, 0>) -> (i32 ret, u32 bsd_errno) public ResultCode Send(ServiceCtx context) { - int socketFd = context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); BsdSocketFlags socketFlags = (BsdSocketFlags)context.RequestData.ReadInt32(); (ulong sendPosition, ulong sendSize) = context.Request.GetBufferType0x21(); ReadOnlySpan<byte> sendBuffer = context.Memory.GetSpan(sendPosition, (int)sendSize); - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); - int result = -1; + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); + int result = -1; if (socket != null) { @@ -576,17 +574,19 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd // SendTo(u32 socket, u32 flags, buffer<i8, 0x21, 0>, buffer<nn::socket::sockaddr_in, 0x21, 0x10>) -> (i32 ret, u32 bsd_errno) public ResultCode SendTo(ServiceCtx context) { - int socketFd = context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); BsdSocketFlags socketFlags = (BsdSocketFlags)context.RequestData.ReadInt32(); - (ulong sendPosition, ulong sendSize) = context.Request.GetBufferType0x21(0); + (ulong sendPosition, ulong sendSize) = context.Request.GetBufferType0x21(0); +#pragma warning disable IDE0059 // Remove unnecessary value assignment (ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x21(1); +#pragma warning restore IDE0059 ReadOnlySpan<byte> sendBuffer = context.Memory.GetSpan(sendPosition, (int)sendSize); - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); - int result = -1; + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); + int result = -1; if (socket != null) { @@ -609,10 +609,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd { int socketFd = context.RequestData.ReadInt32(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment (ulong bufferPos, ulong bufferSize) = context.Request.GetBufferType0x22(); +#pragma warning restore IDE0059 - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); if (socket != null) { @@ -652,10 +654,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd { int socketFd = context.RequestData.ReadInt32(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment (ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x21(); +#pragma warning restore IDE0059 - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); if (socket != null) { @@ -673,10 +677,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd { int socketFd = context.RequestData.ReadInt32(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment (ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x21(); +#pragma warning restore IDE0059 - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); if (socket != null) { @@ -694,10 +700,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd { int socketFd = context.RequestData.ReadInt32(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment (ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x22(); +#pragma warning restore IDE0059 - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); if (socket != null) { errno = LinuxError.ENOTCONN; @@ -721,10 +729,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd { int socketFd = context.RequestData.ReadInt32(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment (ulong bufferPos, ulong bufferSize) = context.Request.GetBufferType0x22(); +#pragma warning restore IDE0059 - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); if (socket != null) { @@ -742,15 +752,15 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd // GetSockOpt(u32 socket, u32 level, u32 option_name) -> (i32 ret, u32 bsd_errno, u32, buffer<unknown, 0x22, 0>) public ResultCode GetSockOpt(ServiceCtx context) { - int socketFd = context.RequestData.ReadInt32(); - SocketOptionLevel level = (SocketOptionLevel)context.RequestData.ReadInt32(); - BsdSocketOption option = (BsdSocketOption)context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); + SocketOptionLevel level = (SocketOptionLevel)context.RequestData.ReadInt32(); + BsdSocketOption option = (BsdSocketOption)context.RequestData.ReadInt32(); (ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x22(); WritableRegion optionValue = context.Memory.GetWritableRegion(bufferPosition, (int)bufferSize); - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); if (socket != null) { @@ -770,10 +780,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd public ResultCode Listen(ServiceCtx context) { int socketFd = context.RequestData.ReadInt32(); - int backlog = context.RequestData.ReadInt32(); + int backlog = context.RequestData.ReadInt32(); - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); if (socket != null) { @@ -787,12 +797,14 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd // Ioctl(u32 fd, u32 request, u32 bufcount, buffer<unknown, 0x21, 0>, buffer<unknown, 0x21, 0>, buffer<unknown, 0x21, 0>, buffer<unknown, 0x21, 0>) -> (i32 ret, u32 bsd_errno, buffer<unknown, 0x22, 0>, buffer<unknown, 0x22, 0>, buffer<unknown, 0x22, 0>, buffer<unknown, 0x22, 0>) public ResultCode Ioctl(ServiceCtx context) { - int socketFd = context.RequestData.ReadInt32(); - BsdIoctl cmd = (BsdIoctl)context.RequestData.ReadInt32(); - int bufferCount = context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); + BsdIoctl cmd = (BsdIoctl)context.RequestData.ReadInt32(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment + int bufferCount = context.RequestData.ReadInt32(); +#pragma warning restore IDE0059 - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); if (socket != null) { @@ -801,7 +813,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd case BsdIoctl.AtMark: errno = LinuxError.SUCCESS; +#pragma warning disable IDE0059 // Remove unnecessary value assignment (ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x22(); +#pragma warning restore IDE0059 // FIXME: OOB not implemented. context.Memory.Write(bufferPosition, 0); @@ -823,12 +837,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd public ResultCode Fcntl(ServiceCtx context) { int socketFd = context.RequestData.ReadInt32(); - int cmd = context.RequestData.ReadInt32(); - int arg = context.RequestData.ReadInt32(); + int cmd = context.RequestData.ReadInt32(); + int arg = context.RequestData.ReadInt32(); - int result = 0; - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); + int result = 0; + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); if (socket != null) { @@ -856,16 +870,16 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd // SetSockOpt(u32 socket, u32 level, u32 option_name, buffer<unknown, 0x21, 0> option_value) -> (i32 ret, u32 bsd_errno) public ResultCode SetSockOpt(ServiceCtx context) { - int socketFd = context.RequestData.ReadInt32(); - SocketOptionLevel level = (SocketOptionLevel)context.RequestData.ReadInt32(); - BsdSocketOption option = (BsdSocketOption)context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); + SocketOptionLevel level = (SocketOptionLevel)context.RequestData.ReadInt32(); + BsdSocketOption option = (BsdSocketOption)context.RequestData.ReadInt32(); (ulong bufferPos, ulong bufferSize) = context.Request.GetBufferType0x21(); ReadOnlySpan<byte> optionValue = context.Memory.GetSpan(bufferPos, (int)bufferSize); - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); if (socket != null) { @@ -880,10 +894,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd public ResultCode Shutdown(ServiceCtx context) { int socketFd = context.RequestData.ReadInt32(); - int how = context.RequestData.ReadInt32(); + int how = context.RequestData.ReadInt32(); - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); if (socket != null) { @@ -924,9 +938,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd ReadOnlySpan<byte> sendBuffer = context.Memory.GetSpan(sendPosition, (int)sendSize); - LinuxError errno = LinuxError.EBADF; - IFileDescriptor file = _context.RetrieveFileDescriptor(fd); - int result = -1; + LinuxError errno = LinuxError.EBADF; + IFileDescriptor file = _context.RetrieveFileDescriptor(fd); + int result = -1; if (file != null) { @@ -951,9 +965,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd WritableRegion receiveRegion = context.Memory.GetWritableRegion(receivePosition, (int)receiveLength); - LinuxError errno = LinuxError.EBADF; - IFileDescriptor file = _context.RetrieveFileDescriptor(fd); - int result = -1; + LinuxError errno = LinuxError.EBADF; + IFileDescriptor file = _context.RetrieveFileDescriptor(fd); + int result = -1; if (file != null) { @@ -990,8 +1004,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd // DuplicateSocket(u32 fd, u64 reserved) -> (i32 ret, u32 bsd_errno) public ResultCode DuplicateSocket(ServiceCtx context) { - int fd = context.RequestData.ReadInt32(); + int fd = context.RequestData.ReadInt32(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment ulong reserved = context.RequestData.ReadUInt64(); +#pragma warning restore IDE0059 LinuxError errno = LinuxError.ENOENT; int newSockFd = -1; @@ -1016,20 +1032,22 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd // RecvMMsg(u32 fd, u32 vlen, u32 flags, u32 reserved, nn::socket::TimeVal timeout) -> (i32 ret, u32 bsd_errno, buffer<bytes, 6> message); public ResultCode RecvMMsg(ServiceCtx context) { - int socketFd = context.RequestData.ReadInt32(); - int vlen = context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); + int vlen = context.RequestData.ReadInt32(); BsdSocketFlags socketFlags = (BsdSocketFlags)context.RequestData.ReadInt32(); - uint reserved = context.RequestData.ReadUInt32(); - TimeVal timeout = context.RequestData.ReadStruct<TimeVal>(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment + uint reserved = context.RequestData.ReadUInt32(); +#pragma warning restore IDE0059 + TimeVal timeout = context.RequestData.ReadStruct<TimeVal>(); ulong receivePosition = context.Request.ReceiveBuff[0].Position; ulong receiveLength = context.Request.ReceiveBuff[0].Size; WritableRegion receiveRegion = context.Memory.GetWritableRegion(receivePosition, (int)receiveLength); - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); - int result = -1; + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); + int result = -1; if (socket != null) { @@ -1059,8 +1077,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd // SendMMsg(u32 fd, u32 vlen, u32 flags) -> (i32 ret, u32 bsd_errno, buffer<bytes, 6> message); public ResultCode SendMMsg(ServiceCtx context) { - int socketFd = context.RequestData.ReadInt32(); - int vlen = context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); + int vlen = context.RequestData.ReadInt32(); BsdSocketFlags socketFlags = (BsdSocketFlags)context.RequestData.ReadInt32(); ulong receivePosition = context.Request.ReceiveBuff[0].Position; @@ -1068,9 +1086,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd WritableRegion receiveRegion = context.Memory.GetWritableRegion(receivePosition, (int)receiveLength); - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); - int result = -1; + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); + int result = -1; if (socket != null) { @@ -1104,7 +1122,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd context.RequestData.BaseStream.Position += 4; // Padding ulong initialValue = context.RequestData.ReadUInt64(); - EventFileDescriptor newEventFile = new EventFileDescriptor(initialValue, flags); + EventFileDescriptor newEventFile = new(initialValue, flags); LinuxError errno = LinuxError.SUCCESS; @@ -1118,4 +1136,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd return WriteBsdResult(context, newSockFd, errno); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IFileDescriptor.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IFileDescriptor.cs index 9d4f81ce..dbeb9022 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IFileDescriptor.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IFileDescriptor.cs @@ -12,4 +12,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd LinuxError Write(out int writeSize, ReadOnlySpan<byte> buffer); } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptor.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptor.cs index d7b53158..937d2fd7 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptor.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptor.cs @@ -150,4 +150,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptorPollManager.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptorPollManager.cs index e0ab68c6..9039d49a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptorPollManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptorPollManager.cs @@ -13,10 +13,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl { get { - if (_instance == null) - { - _instance = new EventFileDescriptorPollManager(); - } + _instance ??= new EventFileDescriptorPollManager(); return _instance; } @@ -31,7 +28,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl { updatedCount = 0; - List<ManualResetEvent> waiters = new List<ManualResetEvent>(); + List<ManualResetEvent> waiters = new(); for (int i = 0; i < events.Count; i++) { @@ -119,4 +116,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl return LinuxError.EOPNOTSUPP; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs index 75efc49a..dfc2a672 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs @@ -462,7 +462,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl if (!CanSupportMMsgHdr(message)) { - Logger.Warning?.Print(LogClass.ServiceBsd, $"Unsupported BsdMMsgHdr"); + Logger.Warning?.Print(LogClass.ServiceBsd, "Unsupported BsdMMsgHdr"); return LinuxError.EOPNOTSUPP; } @@ -500,7 +500,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl if (!CanSupportMMsgHdr(message)) { - Logger.Warning?.Print(LogClass.ServiceBsd, $"Unsupported BsdMMsgHdr"); + Logger.Warning?.Print(LogClass.ServiceBsd, "Unsupported BsdMMsgHdr"); return LinuxError.EOPNOTSUPP; } @@ -527,4 +527,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocketPollManager.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocketPollManager.cs index 1b305dfb..10d9882c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocketPollManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocketPollManager.cs @@ -13,10 +13,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl { get { - if (_instance == null) - { - _instance = new ManagedSocketPollManager(); - } + _instance ??= new ManagedSocketPollManager(); return _instance; } @@ -29,9 +26,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl public LinuxError Poll(List<PollEvent> events, int timeoutMilliseconds, out int updatedCount) { - List<Socket> readEvents = new List<Socket>(); - List<Socket> writeEvents = new List<Socket>(); - List<Socket> errorEvents = new List<Socket>(); + List<Socket> readEvents = new(); + List<Socket> writeEvents = new(); + List<Socket> errorEvents = new(); updatedCount = 0; @@ -174,4 +171,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl return LinuxError.SUCCESS; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WSAError.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WSAError.cs index 0f24a57f..5f3495df 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WSAError.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WSAError.cs @@ -9,77 +9,77 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl * All Windows Sockets error constants are biased by WSABASEERR from * the "normal" */ - WSABASEERR = 10000, + WSABASEERR = 10000, /* * Windows Sockets definitions of regular Microsoft C error constants */ - WSAEINTR = (WSABASEERR + 4), - WSAEBADF = (WSABASEERR + 9), - WSAEACCES = (WSABASEERR + 13), - WSAEFAULT = (WSABASEERR + 14), - WSAEINVAL = (WSABASEERR + 22), - WSAEMFILE = (WSABASEERR + 24), + WSAEINTR = (WSABASEERR + 4), + WSAEBADF = (WSABASEERR + 9), + WSAEACCES = (WSABASEERR + 13), + WSAEFAULT = (WSABASEERR + 14), + WSAEINVAL = (WSABASEERR + 22), + WSAEMFILE = (WSABASEERR + 24), /* * Windows Sockets definitions of regular Berkeley error constants */ - WSAEWOULDBLOCK = (WSABASEERR + 35), - WSAEINPROGRESS = (WSABASEERR + 36), - WSAEALREADY = (WSABASEERR + 37), - WSAENOTSOCK = (WSABASEERR + 38), - WSAEDESTADDRREQ = (WSABASEERR + 39), - WSAEMSGSIZE = (WSABASEERR + 40), - WSAEPROTOTYPE = (WSABASEERR + 41), - WSAENOPROTOOPT = (WSABASEERR + 42), - WSAEPROTONOSUPPORT = (WSABASEERR + 43), - WSAESOCKTNOSUPPORT = (WSABASEERR + 44), - WSAEOPNOTSUPP = (WSABASEERR + 45), - WSAEPFNOSUPPORT = (WSABASEERR + 46), - WSAEAFNOSUPPORT = (WSABASEERR + 47), - WSAEADDRINUSE = (WSABASEERR + 48), - WSAEADDRNOTAVAIL = (WSABASEERR + 49), - WSAENETDOWN = (WSABASEERR + 50), - WSAENETUNREACH = (WSABASEERR + 51), - WSAENETRESET = (WSABASEERR + 52), - WSAECONNABORTED = (WSABASEERR + 53), - WSAECONNRESET = (WSABASEERR + 54), - WSAENOBUFS = (WSABASEERR + 55), - WSAEISCONN = (WSABASEERR + 56), - WSAENOTCONN = (WSABASEERR + 57), - WSAESHUTDOWN = (WSABASEERR + 58), - WSAETOOMANYREFS = (WSABASEERR + 59), - WSAETIMEDOUT = (WSABASEERR + 60), - WSAECONNREFUSED = (WSABASEERR + 61), - WSAELOOP = (WSABASEERR + 62), - WSAENAMETOOLONG = (WSABASEERR + 63), - WSAEHOSTDOWN = (WSABASEERR + 64), - WSAEHOSTUNREACH = (WSABASEERR + 65), - WSAENOTEMPTY = (WSABASEERR + 66), - WSAEPROCLIM = (WSABASEERR + 67), - WSAEUSERS = (WSABASEERR + 68), - WSAEDQUOT = (WSABASEERR + 69), - WSAESTALE = (WSABASEERR + 70), - WSAEREMOTE = (WSABASEERR + 71), + WSAEWOULDBLOCK = (WSABASEERR + 35), + WSAEINPROGRESS = (WSABASEERR + 36), + WSAEALREADY = (WSABASEERR + 37), + WSAENOTSOCK = (WSABASEERR + 38), + WSAEDESTADDRREQ = (WSABASEERR + 39), + WSAEMSGSIZE = (WSABASEERR + 40), + WSAEPROTOTYPE = (WSABASEERR + 41), + WSAENOPROTOOPT = (WSABASEERR + 42), + WSAEPROTONOSUPPORT = (WSABASEERR + 43), + WSAESOCKTNOSUPPORT = (WSABASEERR + 44), + WSAEOPNOTSUPP = (WSABASEERR + 45), + WSAEPFNOSUPPORT = (WSABASEERR + 46), + WSAEAFNOSUPPORT = (WSABASEERR + 47), + WSAEADDRINUSE = (WSABASEERR + 48), + WSAEADDRNOTAVAIL = (WSABASEERR + 49), + WSAENETDOWN = (WSABASEERR + 50), + WSAENETUNREACH = (WSABASEERR + 51), + WSAENETRESET = (WSABASEERR + 52), + WSAECONNABORTED = (WSABASEERR + 53), + WSAECONNRESET = (WSABASEERR + 54), + WSAENOBUFS = (WSABASEERR + 55), + WSAEISCONN = (WSABASEERR + 56), + WSAENOTCONN = (WSABASEERR + 57), + WSAESHUTDOWN = (WSABASEERR + 58), + WSAETOOMANYREFS = (WSABASEERR + 59), + WSAETIMEDOUT = (WSABASEERR + 60), + WSAECONNREFUSED = (WSABASEERR + 61), + WSAELOOP = (WSABASEERR + 62), + WSAENAMETOOLONG = (WSABASEERR + 63), + WSAEHOSTDOWN = (WSABASEERR + 64), + WSAEHOSTUNREACH = (WSABASEERR + 65), + WSAENOTEMPTY = (WSABASEERR + 66), + WSAEPROCLIM = (WSABASEERR + 67), + WSAEUSERS = (WSABASEERR + 68), + WSAEDQUOT = (WSABASEERR + 69), + WSAESTALE = (WSABASEERR + 70), + WSAEREMOTE = (WSABASEERR + 71), /* * Extended Windows Sockets error constant definitions */ - WSASYSNOTREADY = (WSABASEERR + 91), - WSAVERNOTSUPPORTED = (WSABASEERR + 92), - WSANOTINITIALISED = (WSABASEERR + 93), - WSAEDISCON = (WSABASEERR + 101), - WSAENOMORE = (WSABASEERR + 102), - WSAECANCELLED = (WSABASEERR + 103), - WSAEINVALIDPROCTABLE = (WSABASEERR + 104), - WSAEINVALIDPROVIDER = (WSABASEERR + 105), - WSAEPROVIDERFAILEDINIT = (WSABASEERR + 106), - WSASYSCALLFAILURE = (WSABASEERR + 107), - WSASERVICE_NOT_FOUND = (WSABASEERR + 108), - WSATYPE_NOT_FOUND = (WSABASEERR + 109), - WSA_E_NO_MORE = (WSABASEERR + 110), - WSA_E_CANCELLED = (WSABASEERR + 111), - WSAEREFUSED = (WSABASEERR + 112), + WSASYSNOTREADY = (WSABASEERR + 91), + WSAVERNOTSUPPORTED = (WSABASEERR + 92), + WSANOTINITIALISED = (WSABASEERR + 93), + WSAEDISCON = (WSABASEERR + 101), + WSAENOMORE = (WSABASEERR + 102), + WSAECANCELLED = (WSABASEERR + 103), + WSAEINVALIDPROCTABLE = (WSABASEERR + 104), + WSAEINVALIDPROVIDER = (WSABASEERR + 105), + WSAEPROVIDERFAILEDINIT = (WSABASEERR + 106), + WSASYSCALLFAILURE = (WSABASEERR + 107), + WSASERVICE_NOT_FOUND = (WSABASEERR + 108), + WSATYPE_NOT_FOUND = (WSABASEERR + 109), + WSA_E_NO_MORE = (WSABASEERR + 110), + WSA_E_CANCELLED = (WSABASEERR + 111), + WSAEREFUSED = (WSABASEERR + 112), /* * Error return codes from gethostbyname() and gethostbyaddr() @@ -93,42 +93,42 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl */ /* Authoritative Answer: Host not found */ - WSAHOST_NOT_FOUND = (WSABASEERR + 1001), + WSAHOST_NOT_FOUND = (WSABASEERR + 1001), /* Non-Authoritative: Host not found, or SERVERFAIL */ - WSATRY_AGAIN = (WSABASEERR + 1002), + WSATRY_AGAIN = (WSABASEERR + 1002), /* Non-recoverable errors, FORMERR, REFUSED, NOTIMP */ - WSANO_RECOVERY = (WSABASEERR + 1003), + WSANO_RECOVERY = (WSABASEERR + 1003), /* Valid name, no data record of requested type */ - WSANO_DATA = (WSABASEERR + 1004), + WSANO_DATA = (WSABASEERR + 1004), /* * Define QOS related error return codes * */ - WSA_QOS_RECEIVERS = (WSABASEERR + 1005), + WSA_QOS_RECEIVERS = (WSABASEERR + 1005), /* at least one Reserve has arrived */ - WSA_QOS_SENDERS = (WSABASEERR + 1006), + WSA_QOS_SENDERS = (WSABASEERR + 1006), /* at least one Path has arrived */ - WSA_QOS_NO_SENDERS = (WSABASEERR + 1007), + WSA_QOS_NO_SENDERS = (WSABASEERR + 1007), /* there are no senders */ - WSA_QOS_NO_RECEIVERS = (WSABASEERR + 1008), + WSA_QOS_NO_RECEIVERS = (WSABASEERR + 1008), /* there are no receivers */ - WSA_QOS_REQUEST_CONFIRMED = (WSABASEERR + 1009), + WSA_QOS_REQUEST_CONFIRMED = (WSABASEERR + 1009), /* Reserve has been confirmed */ - WSA_QOS_ADMISSION_FAILURE = (WSABASEERR + 1010), + WSA_QOS_ADMISSION_FAILURE = (WSABASEERR + 1010), /* error due to lack of resources */ - WSA_QOS_POLICY_FAILURE = (WSABASEERR + 1011), + WSA_QOS_POLICY_FAILURE = (WSABASEERR + 1011), /* rejected for administrative reasons - bad credentials */ - WSA_QOS_BAD_STYLE = (WSABASEERR + 1012), + WSA_QOS_BAD_STYLE = (WSABASEERR + 1012), /* unknown or conflicting style */ - WSA_QOS_BAD_OBJECT = (WSABASEERR + 1013), + WSA_QOS_BAD_OBJECT = (WSABASEERR + 1013), /* problem with some part of the filterspec or providerspecific * buffer in general */ WSA_QOS_TRAFFIC_CTRL_ERROR = (WSABASEERR + 1014), /* problem with some part of the flowspec */ - WSA_QOS_GENERIC_ERROR = (WSABASEERR + 1015) + WSA_QOS_GENERIC_ERROR = (WSABASEERR + 1015), } } diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WinSockHelper.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WinSockHelper.cs index 5668d30b..9df18023 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WinSockHelper.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WinSockHelper.cs @@ -1,5 +1,5 @@ using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types; -using System; +using System; using System.Collections.Generic; using System.Net.Sockets; @@ -88,7 +88,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl // WSAEFAULT { WsaError.WSAEFAULT, LinuxError.EFAULT }, // NOERROR - { 0, 0 } + { 0, 0 }, }; private static readonly Dictionary<int, LinuxError> _errorMapMacOs = new() @@ -136,7 +136,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl { 59, LinuxError.ETOOMANYREFS }, { 92, LinuxError.EILSEQ }, { 89, LinuxError.ECANCELED }, - { 84, LinuxError.EOVERFLOW } + { 84, LinuxError.EOVERFLOW }, }; private static readonly Dictionary<BsdSocketOption, SocketOptionName> _soSocketOptionMap = new() @@ -157,7 +157,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl { BsdSocketOption.SoSndTimeo, SocketOptionName.SendTimeout }, { BsdSocketOption.SoRcvTimeo, SocketOptionName.ReceiveTimeout }, { BsdSocketOption.SoError, SocketOptionName.Error }, - { BsdSocketOption.SoType, SocketOptionName.Type } + { BsdSocketOption.SoType, SocketOptionName.Type }, }; private static readonly Dictionary<BsdSocketOption, SocketOptionName> _ipSocketOptionMap = new() @@ -172,7 +172,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl { BsdSocketOption.IpDropMembership, SocketOptionName.DropMembership }, { BsdSocketOption.IpDontFrag, SocketOptionName.DontFragment }, { BsdSocketOption.IpAddSourceMembership, SocketOptionName.AddSourceMembership }, - { BsdSocketOption.IpDropSourceMembership, SocketOptionName.DropSourceMembership } + { BsdSocketOption.IpDropSourceMembership, SocketOptionName.DropSourceMembership }, }; private static readonly Dictionary<BsdSocketOption, SocketOptionName> _tcpSocketOptionMap = new() @@ -180,7 +180,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl { BsdSocketOption.TcpNoDelay, SocketOptionName.NoDelay }, { BsdSocketOption.TcpKeepIdle, SocketOptionName.TcpKeepAliveTime }, { BsdSocketOption.TcpKeepIntvl, SocketOptionName.TcpKeepAliveInterval }, - { BsdSocketOption.TcpKeepCnt, SocketOptionName.TcpKeepAliveRetryCount } + { BsdSocketOption.TcpKeepCnt, SocketOptionName.TcpKeepAliveRetryCount }, }; public static LinuxError ConvertError(WsaError errorCode) @@ -210,7 +210,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl SocketOptionLevel.Socket => _soSocketOptionMap, SocketOptionLevel.IP => _ipSocketOptionMap, SocketOptionLevel.Tcp => _tcpSocketOptionMap, - _ => null + _ => null, }; if (table == null) @@ -222,4 +222,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl return table.TryGetValue(option, out name); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/ServerInterface.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/ServerInterface.cs index 798fc015..9afdf250 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/ServerInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/ServerInterface.cs @@ -5,4 +5,4 @@ { public ServerInterface(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdAddressFamily.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdAddressFamily.cs index 37461bb2..74794638 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdAddressFamily.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdAddressFamily.cs @@ -6,6 +6,6 @@ InterNetwork = 2, InterNetworkV6 = 28, - Unknown = uint.MaxValue + Unknown = uint.MaxValue, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdIoctl.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdIoctl.cs index 1dfa5a5f..9c330e35 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdIoctl.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdIoctl.cs @@ -2,6 +2,6 @@ { enum BsdIoctl { - AtMark = 0x40047307 + AtMark = 0x40047307, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSockAddr.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSockAddr.cs index 67c11e54..af3a44e8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSockAddr.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSockAddr.cs @@ -16,7 +16,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types public IPEndPoint ToIPEndPoint() { - IPAddress address = new IPAddress(Address.AsSpan()); + IPAddress address = new(Address.AsSpan()); int port = (ushort)IPAddress.NetworkToHostOrder((short)Port); return new IPEndPoint(address, port); @@ -24,11 +24,11 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types public static BsdSockAddr FromIPEndPoint(IPEndPoint endpoint) { - BsdSockAddr result = new BsdSockAddr + BsdSockAddr result = new() { Length = 0, Family = (byte)endpoint.AddressFamily, - Port = (ushort)IPAddress.HostToNetworkOrder((short)endpoint.Port) + Port = (ushort)IPAddress.HostToNetworkOrder((short)endpoint.Port), }; endpoint.Address.GetAddressBytes().AsSpan().CopyTo(result.Address.AsSpan()); diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketCreationFlags.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketCreationFlags.cs index be5991ff..ac79deb3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketCreationFlags.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketCreationFlags.cs @@ -9,6 +9,6 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types CloseOnExecution = 1, NonBlocking = 2, - FlagsShift = 28 + FlagsShift = 28, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketFlags.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketFlags.cs index 4408c89a..63998129 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketFlags.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketFlags.cs @@ -17,6 +17,6 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types Compat = 0x8000, SoCallbck = 0x10000, NoSignal = 0x20000, - CMsgCloExec = 0x40000 + CMsgCloExec = 0x40000, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketOption.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketOption.cs index 4d0d1dcf..5bc3e81f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketOption.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketOption.cs @@ -1,5 +1,8 @@ +using System.Diagnostics.CodeAnalysis; + namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types { + [SuppressMessage("Design", "CA1069: Enums values should not be duplicated")] enum BsdSocketOption { SoDebug = 0x1, @@ -114,6 +117,6 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types TcpKeepInit = 128, TcpKeepIdle = 256, TcpKeepIntvl = 512, - TcpKeepCnt = 1024 + TcpKeepCnt = 1024, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketShutdownFlags.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketShutdownFlags.cs index 13230ac3..883e3c31 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketShutdownFlags.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketShutdownFlags.cs @@ -4,6 +4,6 @@ { Receive, Send, - ReceiveAndSend + ReceiveAndSend, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/EventFdFlags.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/EventFdFlags.cs index e01d8226..996facd3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/EventFdFlags.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/EventFdFlags.cs @@ -7,6 +7,6 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types { None = 0, Semaphore = 1 << 0, - NonBlocking = 1 << 2 + NonBlocking = 1 << 2, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/IPollManager.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/IPollManager.cs index d3663878..66b1bcf1 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/IPollManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/IPollManager.cs @@ -10,4 +10,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types LinuxError Select(List<PollEvent> events, int timeout, out int updatedCount); } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/LinuxError.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/LinuxError.cs index 96602830..aaeee44d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/LinuxError.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/LinuxError.cs @@ -5,44 +5,44 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types [SuppressMessage("ReSharper", "InconsistentNaming")] enum LinuxError { - SUCCESS = 0, - EPERM = 1 /* Operation not permitted */, - ENOENT = 2 /* No such file or directory */, - ESRCH = 3 /* No such process */, - EINTR = 4 /* Interrupted system call */, - EIO = 5 /* I/O error */, - ENXIO = 6 /* No such device or address */, - E2BIG = 7 /* Argument list too long */, - ENOEXEC = 8 /* Exec format error */, - EBADF = 9 /* Bad file number */, - ECHILD = 10 /* No child processes */, - EAGAIN = 11 /* Try again */, - ENOMEM = 12 /* Out of memory */, - EACCES = 13 /* Permission denied */, - EFAULT = 14 /* Bad address */, - ENOTBLK = 15 /* Block device required */, - EBUSY = 16 /* Device or resource busy */, - EEXIST = 17 /* File exists */, - EXDEV = 18 /* Cross-device link */, - ENODEV = 19 /* No such device */, - ENOTDIR = 20 /* Not a directory */, - EISDIR = 21 /* Is a directory */, - EINVAL = 22 /* Invalid argument */, - ENFILE = 23 /* File table overflow */, - EMFILE = 24 /* Too many open files */, - ENOTTY = 25 /* Not a typewriter */, - ETXTBSY = 26 /* Text file busy */, - EFBIG = 27 /* File too large */, - ENOSPC = 28 /* No space left on device */, - ESPIPE = 29 /* Illegal seek */, - EROFS = 30 /* Read-only file system */, - EMLINK = 31 /* Too many links */, - EPIPE = 32 /* Broken pipe */, - EDOM = 33 /* Math argument out of domain of func */, - ERANGE = 34 /* Math result not representable */, - EDEADLK = 35 /* Resource deadlock would occur */, - ENAMETOOLONG = 36 /* File name too long */, - ENOLCK = 37 /* No record locks available */, + SUCCESS = 0, + EPERM = 1 /* Operation not permitted */, + ENOENT = 2 /* No such file or directory */, + ESRCH = 3 /* No such process */, + EINTR = 4 /* Interrupted system call */, + EIO = 5 /* I/O error */, + ENXIO = 6 /* No such device or address */, + E2BIG = 7 /* Argument list too long */, + ENOEXEC = 8 /* Exec format error */, + EBADF = 9 /* Bad file number */, + ECHILD = 10 /* No child processes */, + EAGAIN = 11 /* Try again */, + ENOMEM = 12 /* Out of memory */, + EACCES = 13 /* Permission denied */, + EFAULT = 14 /* Bad address */, + ENOTBLK = 15 /* Block device required */, + EBUSY = 16 /* Device or resource busy */, + EEXIST = 17 /* File exists */, + EXDEV = 18 /* Cross-device link */, + ENODEV = 19 /* No such device */, + ENOTDIR = 20 /* Not a directory */, + EISDIR = 21 /* Is a directory */, + EINVAL = 22 /* Invalid argument */, + ENFILE = 23 /* File table overflow */, + EMFILE = 24 /* Too many open files */, + ENOTTY = 25 /* Not a typewriter */, + ETXTBSY = 26 /* Text file busy */, + EFBIG = 27 /* File too large */, + ENOSPC = 28 /* No space left on device */, + ESPIPE = 29 /* Illegal seek */, + EROFS = 30 /* Read-only file system */, + EMLINK = 31 /* Too many links */, + EPIPE = 32 /* Broken pipe */, + EDOM = 33 /* Math argument out of domain of func */, + ERANGE = 34 /* Math result not representable */, + EDEADLK = 35 /* Resource deadlock would occur */, + ENAMETOOLONG = 36 /* File name too long */, + ENOLCK = 37 /* No record locks available */, /* * This error code is special: arch syscall entry code will return @@ -51,105 +51,105 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types * failures due to attempts to use a nonexistent syscall, syscall * implementations should refrain from returning -ENOSYS. */ - ENOSYS = 38 /* Invalid system call number */, - ENOTEMPTY = 39 /* Directory not empty */, - ELOOP = 40 /* Too many symbolic links encountered */, - EWOULDBLOCK = EAGAIN /* Operation would block */, - ENOMSG = 42 /* No message of desired type */, - EIDRM = 43 /* Identifier removed */, - ECHRNG = 44 /* Channel number out of range */, - EL2NSYNC = 45 /* Level 2 not synchronized */, - EL3HLT = 46 /* Level 3 halted */, - EL3RST = 47 /* Level 3 reset */, - ELNRNG = 48 /* Link number out of range */, - EUNATCH = 49 /* Protocol driver not attached */, - ENOCSI = 50 /* No CSI structure available */, - EL2HLT = 51 /* Level 2 halted */, - EBADE = 52 /* Invalid exchange */, - EBADR = 53 /* Invalid request descriptor */, - EXFULL = 54 /* Exchange full */, - ENOANO = 55 /* No anode */, - EBADRQC = 56 /* Invalid request code */, - EBADSLT = 57 /* Invalid slot */, - EDEADLOCK = EDEADLK, - EBFONT = 59 /* Bad font file format */, - ENOSTR = 60 /* Device not a stream */, - ENODATA = 61 /* No data available */, - ETIME = 62 /* Timer expired */, - ENOSR = 63 /* Out of streams resources */, - ENONET = 64 /* Machine is not on the network */, - ENOPKG = 65 /* Package not installed */, - EREMOTE = 66 /* Object is remote */, - ENOLINK = 67 /* Link has been severed */, - EADV = 68 /* Advertise error */, - ESRMNT = 69 /* Srmount error */, - ECOMM = 70 /* Communication error on send */, - EPROTO = 71 /* Protocol error */, - EMULTIHOP = 72 /* Multihop attempted */, - EDOTDOT = 73 /* RFS specific error */, - EBADMSG = 74 /* Not a data message */, - EOVERFLOW = 75 /* Value too large for defined data type */, - ENOTUNIQ = 76 /* Name not unique on network */, - EBADFD = 77 /* File descriptor in bad state */, - EREMCHG = 78 /* Remote address changed */, - ELIBACC = 79 /* Can not access a needed shared library */, - ELIBBAD = 80 /* Accessing a corrupted shared library */, - ELIBSCN = 81 /* .lib section in a.out corrupted */, - ELIBMAX = 82 /* Attempting to link in too many shared libraries */, - ELIBEXEC = 83 /* Cannot exec a shared library directly */, - EILSEQ = 84 /* Illegal byte sequence */, - ERESTART = 85 /* Interrupted system call should be restarted */, - ESTRPIPE = 86 /* Streams pipe error */, - EUSERS = 87 /* Too many users */, - ENOTSOCK = 88 /* Socket operation on non-socket */, - EDESTADDRREQ = 89 /* Destination address required */, - EMSGSIZE = 90 /* Message too long */, - EPROTOTYPE = 91 /* Protocol wrong type for socket */, - ENOPROTOOPT = 92 /* Protocol not available */, + ENOSYS = 38 /* Invalid system call number */, + ENOTEMPTY = 39 /* Directory not empty */, + ELOOP = 40 /* Too many symbolic links encountered */, + EWOULDBLOCK = EAGAIN /* Operation would block */, + ENOMSG = 42 /* No message of desired type */, + EIDRM = 43 /* Identifier removed */, + ECHRNG = 44 /* Channel number out of range */, + EL2NSYNC = 45 /* Level 2 not synchronized */, + EL3HLT = 46 /* Level 3 halted */, + EL3RST = 47 /* Level 3 reset */, + ELNRNG = 48 /* Link number out of range */, + EUNATCH = 49 /* Protocol driver not attached */, + ENOCSI = 50 /* No CSI structure available */, + EL2HLT = 51 /* Level 2 halted */, + EBADE = 52 /* Invalid exchange */, + EBADR = 53 /* Invalid request descriptor */, + EXFULL = 54 /* Exchange full */, + ENOANO = 55 /* No anode */, + EBADRQC = 56 /* Invalid request code */, + EBADSLT = 57 /* Invalid slot */, + EDEADLOCK = EDEADLK, + EBFONT = 59 /* Bad font file format */, + ENOSTR = 60 /* Device not a stream */, + ENODATA = 61 /* No data available */, + ETIME = 62 /* Timer expired */, + ENOSR = 63 /* Out of streams resources */, + ENONET = 64 /* Machine is not on the network */, + ENOPKG = 65 /* Package not installed */, + EREMOTE = 66 /* Object is remote */, + ENOLINK = 67 /* Link has been severed */, + EADV = 68 /* Advertise error */, + ESRMNT = 69 /* Srmount error */, + ECOMM = 70 /* Communication error on send */, + EPROTO = 71 /* Protocol error */, + EMULTIHOP = 72 /* Multihop attempted */, + EDOTDOT = 73 /* RFS specific error */, + EBADMSG = 74 /* Not a data message */, + EOVERFLOW = 75 /* Value too large for defined data type */, + ENOTUNIQ = 76 /* Name not unique on network */, + EBADFD = 77 /* File descriptor in bad state */, + EREMCHG = 78 /* Remote address changed */, + ELIBACC = 79 /* Can not access a needed shared library */, + ELIBBAD = 80 /* Accessing a corrupted shared library */, + ELIBSCN = 81 /* .lib section in a.out corrupted */, + ELIBMAX = 82 /* Attempting to link in too many shared libraries */, + ELIBEXEC = 83 /* Cannot exec a shared library directly */, + EILSEQ = 84 /* Illegal byte sequence */, + ERESTART = 85 /* Interrupted system call should be restarted */, + ESTRPIPE = 86 /* Streams pipe error */, + EUSERS = 87 /* Too many users */, + ENOTSOCK = 88 /* Socket operation on non-socket */, + EDESTADDRREQ = 89 /* Destination address required */, + EMSGSIZE = 90 /* Message too long */, + EPROTOTYPE = 91 /* Protocol wrong type for socket */, + ENOPROTOOPT = 92 /* Protocol not available */, EPROTONOSUPPORT = 93 /* Protocol not supported */, ESOCKTNOSUPPORT = 94 /* Socket type not supported */, - EOPNOTSUPP = 95 /* Operation not supported on transport endpoint */, - EPFNOSUPPORT = 96 /* Protocol family not supported */, - EAFNOSUPPORT = 97 /* Address family not supported by protocol */, - EADDRINUSE = 98 /* Address already in use */, - EADDRNOTAVAIL = 99 /* Cannot assign requested address */, - ENETDOWN = 100 /* Network is down */, - ENETUNREACH = 101 /* Network is unreachable */, - ENETRESET = 102 /* Network dropped connection because of reset */, - ECONNABORTED = 103 /* Software caused connection abort */, - ECONNRESET = 104 /* Connection reset by peer */, - ENOBUFS = 105 /* No buffer space available */, - EISCONN = 106 /* Transport endpoint is already connected */, - ENOTCONN = 107 /* Transport endpoint is not connected */, - ESHUTDOWN = 108 /* Cannot send after transport endpoint shutdown */, - ETOOMANYREFS = 109 /* Too many references: cannot splice */, - ETIMEDOUT = 110 /* Connection timed out */, - ECONNREFUSED = 111 /* Connection refused */, - EHOSTDOWN = 112 /* Host is down */, - EHOSTUNREACH = 113 /* No route to host */, - EALREADY = 114 /* Operation already in progress */, - EINPROGRESS = 115 /* Operation now in progress */, - ESTALE = 116 /* Stale file handle */, - EUCLEAN = 117 /* Structure needs cleaning */, - ENOTNAM = 118 /* Not a XENIX named type file */, - ENAVAIL = 119 /* No XENIX semaphores available */, - EISNAM = 120 /* Is a named type file */, - EREMOTEIO = 121 /* Remote I/O error */, - EDQUOT = 122 /* Quota exceeded */, - ENOMEDIUM = 123 /* No medium found */, - EMEDIUMTYPE = 124 /* Wrong medium type */, - ECANCELED = 125 /* Operation Canceled */, - ENOKEY = 126 /* Required key not available */, - EKEYEXPIRED = 127 /* Key has expired */, - EKEYREVOKED = 128 /* Key has been revoked */, - EKEYREJECTED = 129 /* Key was rejected by service */, + EOPNOTSUPP = 95 /* Operation not supported on transport endpoint */, + EPFNOSUPPORT = 96 /* Protocol family not supported */, + EAFNOSUPPORT = 97 /* Address family not supported by protocol */, + EADDRINUSE = 98 /* Address already in use */, + EADDRNOTAVAIL = 99 /* Cannot assign requested address */, + ENETDOWN = 100 /* Network is down */, + ENETUNREACH = 101 /* Network is unreachable */, + ENETRESET = 102 /* Network dropped connection because of reset */, + ECONNABORTED = 103 /* Software caused connection abort */, + ECONNRESET = 104 /* Connection reset by peer */, + ENOBUFS = 105 /* No buffer space available */, + EISCONN = 106 /* Transport endpoint is already connected */, + ENOTCONN = 107 /* Transport endpoint is not connected */, + ESHUTDOWN = 108 /* Cannot send after transport endpoint shutdown */, + ETOOMANYREFS = 109 /* Too many references: cannot splice */, + ETIMEDOUT = 110 /* Connection timed out */, + ECONNREFUSED = 111 /* Connection refused */, + EHOSTDOWN = 112 /* Host is down */, + EHOSTUNREACH = 113 /* No route to host */, + EALREADY = 114 /* Operation already in progress */, + EINPROGRESS = 115 /* Operation now in progress */, + ESTALE = 116 /* Stale file handle */, + EUCLEAN = 117 /* Structure needs cleaning */, + ENOTNAM = 118 /* Not a XENIX named type file */, + ENAVAIL = 119 /* No XENIX semaphores available */, + EISNAM = 120 /* Is a named type file */, + EREMOTEIO = 121 /* Remote I/O error */, + EDQUOT = 122 /* Quota exceeded */, + ENOMEDIUM = 123 /* No medium found */, + EMEDIUMTYPE = 124 /* Wrong medium type */, + ECANCELED = 125 /* Operation Canceled */, + ENOKEY = 126 /* Required key not available */, + EKEYEXPIRED = 127 /* Key has expired */, + EKEYREVOKED = 128 /* Key has been revoked */, + EKEYREJECTED = 129 /* Key was rejected by service */, /* for robust mutexes */ - EOWNERDEAD = 130 /* Owner died */, + EOWNERDEAD = 130 /* Owner died */, ENOTRECOVERABLE = 131 /* State not recoverable */, - ERFKILL = 132 /* Operation not possible due to RF-kill */, + ERFKILL = 132 /* Operation not possible due to RF-kill */, - EHWPOISON = 133 /* Memory page has hardware error */ + EHWPOISON = 133, /* Memory page has hardware error */ } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEvent.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEvent.cs index 8b77a6c2..27a96bd8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEvent.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEvent.cs @@ -11,4 +11,4 @@ FileDescriptor = fileDescriptor; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEventData.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEventData.cs index 546b738e..16d01055 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEventData.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEventData.cs @@ -2,10 +2,10 @@ { struct PollEventData { -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public int SocketFd; public PollEventTypeMask InputEvents; #pragma warning restore CS0649 public PollEventTypeMask OutputEvents; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEventTypeMask.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEventTypeMask.cs index f434fa03..d4c96c81 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEventTypeMask.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEventTypeMask.cs @@ -10,6 +10,6 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types Output = 4, Error = 8, Disconnected = 0x10, - Invalid = 0x20 + Invalid = 0x20, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Ethc/IEthInterface.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Ethc/IEthInterface.cs index f5877697..1c216ea5 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Ethc/IEthInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Ethc/IEthInterface.cs @@ -5,4 +5,4 @@ { public IEthInterface(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Ethc/IEthInterfaceGroup.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Ethc/IEthInterfaceGroup.cs index 9832e448..3147a892 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Ethc/IEthInterfaceGroup.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Ethc/IEthInterfaceGroup.cs @@ -5,4 +5,4 @@ { public IEthInterfaceGroup(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/IManager.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/IManager.cs index 0b7adff4..c991db3f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/IManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/IManager.cs @@ -14,9 +14,11 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd class IManager : IpcService { public static readonly NsdSettings NsdSettings; +#pragma warning disable IDE0052 // Remove unread private member private readonly FqdnResolver _fqdnResolver; +#pragma warning restore IDE0052 - private bool _isInitialized = false; + private readonly bool _isInitialized = false; public IManager(ServiceCtx context) { @@ -43,7 +45,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd { Initialized = true, TestMode = (bool)testMode, - Environment = (string)environmentIdentifier + Environment = (string)environmentIdentifier, }; } @@ -158,7 +160,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd public ResultCode Resolve(ServiceCtx context) { ulong outputPosition = context.Request.ReceiveBuff[0].Position; - ulong outputSize = context.Request.ReceiveBuff[0].Size; + ulong outputSize = context.Request.ReceiveBuff[0].Size; ResultCode result = _fqdnResolver.ResolveEx(context, out _, out string resolvedAddress); @@ -181,7 +183,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd public ResultCode ResolveEx(ServiceCtx context) { ulong outputPosition = context.Request.ReceiveBuff[0].Position; - ulong outputSize = context.Request.ReceiveBuff[0].Size; + ulong outputSize = context.Request.ReceiveBuff[0].Size; ResultCode result = _fqdnResolver.ResolveEx(context, out ResultCode errorCode, out string resolvedAddress); @@ -377,7 +379,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd "sd" => (byte)ApplicationServerEnvironmentType.Sd, "sp" => (byte)ApplicationServerEnvironmentType.Sp, "dp" => (byte)ApplicationServerEnvironmentType.Dp, - _ => (byte)ApplicationServerEnvironmentType.None + _ => (byte)ApplicationServerEnvironmentType.None, }; context.ResponseData.Write(environmentType); @@ -399,4 +401,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd throw new ServiceNotImplementedException(this, context); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Manager/FqdnResolver.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Manager/FqdnResolver.cs index 4096e431..a8fbcf09 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Manager/FqdnResolver.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Manager/FqdnResolver.cs @@ -4,7 +4,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd.Manager { class FqdnResolver { - private const string _dummyAddress = "unknown.dummy.nintendo.net"; + private const string DummyAddress = "unknown.dummy.nintendo.net"; public ResultCode GetEnvironmentIdentifier(out string identifier) { @@ -24,8 +24,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd.Manager public static ResultCode Resolve(string address, out string resolvedAddress) { - if (address == "api.sect.srv.nintendo.net" || - address == "ctest.cdn.nintendo.net" || + if (address == "api.sect.srv.nintendo.net" || + address == "ctest.cdn.nintendo.net" || address == "ctest.cdn.n.nintendoswitch.cn" || address == "unknown.dummy.nintendo.net") { @@ -50,6 +50,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd.Manager resolvedAddress = address switch { +#pragma warning disable IDE0055 // Disable formatting "e97b8a9d672e4ce4845ec6947cd66ef6-sb-api.accounts.nintendo.com" => "e97b8a9d672e4ce4845ec6947cd66ef6-sb.baas.nintendo.com", // dp1 environment "api.accounts.nintendo.com" => "e0d67c509fb203858ebcb2fe3f88c2aa.baas.nintendo.com", // dp1 environment "e97b8a9d672e4ce4845ec6947cd66ef6-sb.accounts.nintendo.com" => "e97b8a9d672e4ce4845ec6947cd66ef6-sb.baas.nintendo.com", // lp1 environment @@ -60,6 +61,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd.Manager this + 0x2BE8 => this + 0x2BE8 + 0x300 */ _ => address, +#pragma warning restore IDE0055 }; } @@ -69,7 +71,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd.Manager public ResultCode ResolveEx(ServiceCtx context, out ResultCode resultCode, out string resolvedAddress) { ulong inputPosition = context.Request.SendBuff[0].Position; - ulong inputSize = context.Request.SendBuff[0].Size; + ulong inputSize = context.Request.SendBuff[0].Size; byte[] addressBuffer = new byte[inputSize]; @@ -81,7 +83,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd.Manager if (resultCode != ResultCode.Success) { - resolvedAddress = _dummyAddress; + resolvedAddress = DummyAddress; } if (IManager.NsdSettings.TestMode) @@ -94,4 +96,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd.Manager } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/ResultCode.cs index 993fbe8a..5a62922f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/ResultCode.cs @@ -2,18 +2,18 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd { enum ResultCode { - ModuleId = 141, + ModuleId = 141, ErrorCodeShift = 9, Success = 0, - InvalidSettingsValue = ( 1 << ErrorCodeShift) | ModuleId, - InvalidObject1 = ( 3 << ErrorCodeShift) | ModuleId, - InvalidObject2 = ( 4 << ErrorCodeShift) | ModuleId, - NullOutputObject = ( 5 << ErrorCodeShift) | ModuleId, - SettingsNotLoaded = ( 6 << ErrorCodeShift) | ModuleId, - InvalidArgument = ( 8 << ErrorCodeShift) | ModuleId, - SettingsNotInitialized = ( 10 << ErrorCodeShift) | ModuleId, - ServiceNotInitialized = (400 << ErrorCodeShift) | ModuleId, + InvalidSettingsValue = (1 << ErrorCodeShift) | ModuleId, + InvalidObject1 = (3 << ErrorCodeShift) | ModuleId, + InvalidObject2 = (4 << ErrorCodeShift) | ModuleId, + NullOutputObject = (5 << ErrorCodeShift) | ModuleId, + SettingsNotLoaded = (6 << ErrorCodeShift) | ModuleId, + InvalidArgument = (8 << ErrorCodeShift) | ModuleId, + SettingsNotInitialized = (10 << ErrorCodeShift) | ModuleId, + ServiceNotInitialized = (400 << ErrorCodeShift) | ModuleId, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Types/ApplicationServerEnvironmentType.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Types/ApplicationServerEnvironmentType.cs index 150bdab4..1acb69fc 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Types/ApplicationServerEnvironmentType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Types/ApplicationServerEnvironmentType.cs @@ -6,6 +6,6 @@ Lp, Sd, Sp, - Dp + Dp, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Types/NsdSettings.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Types/NsdSettings.cs index 0a72fa87..08fb15e0 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Types/NsdSettings.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Types/NsdSettings.cs @@ -2,8 +2,8 @@ { class NsdSettings { - public bool Initialized; - public bool TestMode; + public bool Initialized; + public bool TestMode; public string Environment; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/IResolver.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/IResolver.cs index 64c3acbb..93960d13 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/IResolver.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/IResolver.cs @@ -28,8 +28,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres public ResultCode SetDnsAddressesPrivateRequest(ServiceCtx context) { uint cancelHandleRequest = context.RequestData.ReadUInt32(); - ulong bufferPosition = context.Request.SendBuff[0].Position; - ulong bufferSize = context.Request.SendBuff[0].Size; +#pragma warning disable IDE0059 // Remove unnecessary value assignment + ulong bufferPosition = context.Request.SendBuff[0].Position; + ulong bufferSize = context.Request.SendBuff[0].Size; +#pragma warning restore IDE0059 // TODO: This is stubbed in 2.0.0+, reverse 1.0.0 version for the sake of completeness. Logger.Stub?.PrintStub(LogClass.ServiceSfdnsres, new { cancelHandleRequest }); @@ -42,8 +44,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres public ResultCode GetDnsAddressPrivateRequest(ServiceCtx context) { uint cancelHandleRequest = context.RequestData.ReadUInt32(); - ulong bufferPosition = context.Request.ReceiveBuff[0].Position; - ulong bufferSize = context.Request.ReceiveBuff[0].Size; +#pragma warning disable IDE0059 // Remove unnecessary value assignment + ulong bufferPosition = context.Request.ReceiveBuff[0].Position; + ulong bufferSize = context.Request.ReceiveBuff[0].Size; +#pragma warning restore IDE0059 // TODO: This is stubbed in 2.0.0+, reverse 1.0.0 version for the sake of completeness. Logger.Stub?.PrintStub(LogClass.ServiceSfdnsres, new { cancelHandleRequest }); @@ -56,10 +60,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres public ResultCode GetHostByNameRequest(ServiceCtx context) { ulong inputBufferPosition = context.Request.SendBuff[0].Position; - ulong inputBufferSize = context.Request.SendBuff[0].Size; + ulong inputBufferSize = context.Request.SendBuff[0].Size; ulong outputBufferPosition = context.Request.ReceiveBuff[0].Position; - ulong outputBufferSize = context.Request.ReceiveBuff[0].Size; + ulong outputBufferSize = context.Request.ReceiveBuff[0].Size; return GetHostByNameRequestImpl(context, inputBufferPosition, inputBufferSize, outputBufferPosition, outputBufferSize, false, 0, 0); } @@ -69,10 +73,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres public ResultCode GetHostByAddrRequest(ServiceCtx context) { ulong inputBufferPosition = context.Request.SendBuff[0].Position; - ulong inputBufferSize = context.Request.SendBuff[0].Size; + ulong inputBufferSize = context.Request.SendBuff[0].Size; ulong outputBufferPosition = context.Request.ReceiveBuff[0].Position; - ulong outputBufferSize = context.Request.ReceiveBuff[0].Size; + ulong outputBufferSize = context.Request.ReceiveBuff[0].Size; return GetHostByAddrRequestImpl(context, inputBufferPosition, inputBufferSize, outputBufferPosition, outputBufferSize, false, 0, 0); } @@ -82,20 +86,20 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres public ResultCode GetHostStringErrorRequest(ServiceCtx context) { ResultCode resultCode = ResultCode.NotAllocated; - NetDbError errorCode = (NetDbError)context.RequestData.ReadInt32(); + NetDbError errorCode = (NetDbError)context.RequestData.ReadInt32(); string errorString = errorCode switch { - NetDbError.Success => "Resolver Error 0 (no error)", + NetDbError.Success => "Resolver Error 0 (no error)", NetDbError.HostNotFound => "Unknown host", - NetDbError.TryAgain => "Host name lookup failure", - NetDbError.NoRecovery => "Unknown server error", - NetDbError.NoData => "No address associated with name", - _ => (errorCode <= NetDbError.Internal) ? "Resolver internal error" : "Unknown resolver error" + NetDbError.TryAgain => "Host name lookup failure", + NetDbError.NoRecovery => "Unknown server error", + NetDbError.NoData => "No address associated with name", + _ => (errorCode <= NetDbError.Internal) ? "Resolver internal error" : "Unknown resolver error", }; ulong bufferPosition = context.Request.ReceiveBuff[0].Position; - ulong bufferSize = context.Request.ReceiveBuff[0].Size; + ulong bufferSize = context.Request.ReceiveBuff[0].Size; if ((ulong)(errorString.Length + 1) <= bufferSize) { @@ -112,7 +116,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres public ResultCode GetGaiStringErrorRequest(ServiceCtx context) { ResultCode resultCode = ResultCode.NotAllocated; - GaiError errorCode = (GaiError)context.RequestData.ReadInt32(); + GaiError errorCode = (GaiError)context.RequestData.ReadInt32(); if (errorCode > GaiError.Max) { @@ -122,25 +126,25 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres string errorString = errorCode switch { GaiError.AddressFamily => "Address family for hostname not supported", - GaiError.Again => "Temporary failure in name resolution", - GaiError.BadFlags => "Invalid value for ai_flags", - GaiError.Fail => "Non-recoverable failure in name resolution", - GaiError.Family => "ai_family not supported", - GaiError.Memory => "Memory allocation failure", - GaiError.NoData => "No address associated with hostname", - GaiError.NoName => "hostname nor servname provided, or not known", - GaiError.Service => "servname not supported for ai_socktype", - GaiError.SocketType => "ai_socktype not supported", - GaiError.System => "System error returned in errno", - GaiError.BadHints => "Invalid value for hints", - GaiError.Protocol => "Resolved protocol is unknown", - GaiError.Overflow => "Argument buffer overflow", - GaiError.Max => "Unknown error", - _ => "Success" + GaiError.Again => "Temporary failure in name resolution", + GaiError.BadFlags => "Invalid value for ai_flags", + GaiError.Fail => "Non-recoverable failure in name resolution", + GaiError.Family => "ai_family not supported", + GaiError.Memory => "Memory allocation failure", + GaiError.NoData => "No address associated with hostname", + GaiError.NoName => "hostname nor servname provided, or not known", + GaiError.Service => "servname not supported for ai_socktype", + GaiError.SocketType => "ai_socktype not supported", + GaiError.System => "System error returned in errno", + GaiError.BadHints => "Invalid value for hints", + GaiError.Protocol => "Resolved protocol is unknown", + GaiError.Overflow => "Argument buffer overflow", + GaiError.Max => "Unknown error", + _ => "Success", }; ulong bufferPosition = context.Request.ReceiveBuff[0].Position; - ulong bufferSize = context.Request.ReceiveBuff[0].Size; + ulong bufferSize = context.Request.ReceiveBuff[0].Size; if ((ulong)(errorString.Length + 1) <= bufferSize) { @@ -157,7 +161,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres public ResultCode GetAddrInfoRequest(ServiceCtx context) { ulong responseBufferPosition = context.Request.ReceiveBuff[0].Position; - ulong responseBufferSize = context.Request.ReceiveBuff[0].Size; + ulong responseBufferSize = context.Request.ReceiveBuff[0].Size; return GetAddrInfoRequestImpl(context, responseBufferPosition, responseBufferSize, false, 0, 0); } @@ -166,8 +170,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres // GetCancelHandleRequest(u64, pid) -> u32 public ResultCode GetCancelHandleRequest(ServiceCtx context) { - ulong pidPlaceHolder = context.RequestData.ReadUInt64(); - uint cancelHandleRequest = 0; +#pragma warning disable IDE0059 // Remove unnecessary value assignment + ulong pidPlaceHolder = context.RequestData.ReadUInt64(); +#pragma warning restore IDE0059 + uint cancelHandleRequest = 0; context.ResponseData.Write(cancelHandleRequest); @@ -180,8 +186,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres // CancelRequest(u32, u64, pid) public ResultCode CancelRequest(ServiceCtx context) { - uint cancelHandleRequest = context.RequestData.ReadUInt32(); - ulong pidPlaceHolder = context.RequestData.ReadUInt64(); + uint cancelHandleRequest = context.RequestData.ReadUInt32(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment + ulong pidPlaceHolder = context.RequestData.ReadUInt64(); +#pragma warning restore IDE0059 Logger.Stub?.PrintStub(LogClass.ServiceSfdnsres, new { cancelHandleRequest }); @@ -192,8 +200,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres // GetHostByNameRequestWithOptions(u8, u32, u64, pid, buffer<unknown, 21, 0>, buffer<unknown, 21, 0>) -> (u32, u32, u32, buffer<unknown, 22, 0>) public ResultCode GetHostByNameRequestWithOptions(ServiceCtx context) { - (ulong inputBufferPosition, ulong inputBufferSize) = context.Request.GetBufferType0x21(); - (ulong outputBufferPosition, ulong outputBufferSize) = context.Request.GetBufferType0x22(); + (ulong inputBufferPosition, ulong inputBufferSize) = context.Request.GetBufferType0x21(); + (ulong outputBufferPosition, ulong outputBufferSize) = context.Request.GetBufferType0x22(); (ulong optionsBufferPosition, ulong optionsBufferSize) = context.Request.GetBufferType0x21(); return GetHostByNameRequestImpl( @@ -211,8 +219,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres // GetHostByAddrRequestWithOptions(u32, u32, u32, u64, pid, buffer<unknown, 21, 0>, buffer<unknown, 21, 0>) -> (u32, u32, u32, buffer<unknown, 22, 0>) public ResultCode GetHostByAddrRequestWithOptions(ServiceCtx context) { - (ulong inputBufferPosition, ulong inputBufferSize) = context.Request.GetBufferType0x21(); - (ulong outputBufferPosition, ulong outputBufferSize) = context.Request.GetBufferType0x22(); + (ulong inputBufferPosition, ulong inputBufferSize) = context.Request.GetBufferType0x21(); + (ulong outputBufferPosition, ulong outputBufferSize) = context.Request.GetBufferType0x22(); (ulong optionsBufferPosition, ulong optionsBufferSize) = context.Request.GetBufferType0x21(); return GetHostByAddrRequestImpl( @@ -230,7 +238,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres // GetAddrInfoRequestWithOptions(bool enable_nsd_resolve, u32, u64 pid_placeholder, pid, buffer<i8, 5, 0> host, buffer<i8, 5, 0> service, buffer<packed_addrinfo, 5, 0> hints, buffer<unknown, 21, 0>) -> (i32 ret, u32 bsd_errno, u32 unknown, u32 packed_addrinfo_size, buffer<packed_addrinfo, 22, 0> response) public ResultCode GetAddrInfoRequestWithOptions(ServiceCtx context) { - (ulong outputBufferPosition, ulong outputBufferSize) = context.Request.GetBufferType0x22(); + (ulong outputBufferPosition, ulong outputBufferSize) = context.Request.GetBufferType0x22(); (ulong optionsBufferPosition, ulong optionsBufferSize) = context.Request.GetBufferType0x21(); return GetAddrInfoRequestImpl(context, outputBufferPosition, outputBufferSize, true, optionsBufferPosition, optionsBufferSize); @@ -241,7 +249,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres public ResultCode ResolverSetOptionRequest(ServiceCtx context) { ulong bufferPosition = context.Request.SendBuff[0].Position; - ulong bufferSize = context.Request.SendBuff[0].Size; + ulong bufferSize = context.Request.SendBuff[0].Size; ulong unknown = context.RequestData.ReadUInt64(); @@ -254,7 +262,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres Logger.Stub?.PrintStub(LogClass.ServiceSfdnsres, new { unknown }); NetDbError netDbErrorCode = NetDbError.Success; - GaiError errno = GaiError.Success; + GaiError errno = GaiError.Success; context.ResponseData.Write((int)errno); context.ResponseData.Write((int)netDbErrorCode); @@ -294,9 +302,11 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres } // TODO: Use params. - bool enableNsdResolve = (context.RequestData.ReadInt32() & 1) != 0; - int timeOut = context.RequestData.ReadInt32(); - ulong pidPlaceholder = context.RequestData.ReadUInt64(); + bool enableNsdResolve = (context.RequestData.ReadInt32() & 1) != 0; +#pragma warning disable IDE0059 // Remove unnecessary value assignment + int timeOut = context.RequestData.ReadInt32(); + ulong pidPlaceholder = context.RequestData.ReadUInt64(); +#pragma warning restore IDE0059 if (withOptions) { @@ -306,8 +316,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres IPHostEntry hostEntry = null; NetDbError netDbErrorCode = NetDbError.Success; - GaiError errno = GaiError.Overflow; - int serializedSize = 0; + GaiError errno = GaiError.Overflow; + int serializedSize = 0; if (host.Length <= byte.MaxValue) { @@ -326,7 +336,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres Logger.Info?.Print(LogClass.ServiceSfdnsres, $"DNS Blocked: {host}"); netDbErrorCode = NetDbError.HostNotFound; - errno = GaiError.NoData; + errno = GaiError.NoData; } else { @@ -339,7 +349,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres catch (SocketException exception) { netDbErrorCode = ConvertSocketErrorCodeToNetDbError(exception.ErrorCode); - errno = ConvertSocketErrorCodeToGaiError(exception.ErrorCode, errno); + errno = ConvertSocketErrorCodeToGaiError(exception.ErrorCode, errno); } } } @@ -354,12 +364,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres if (!addresses.Any()) { - errno = GaiError.NoData; + errno = GaiError.NoData; netDbErrorCode = NetDbError.NoAddress; } else { - errno = GaiError.Success; + errno = GaiError.Success; serializedSize = SerializeHostEntries(context, outputBufferPosition, outputBufferSize, hostEntry, addresses); } } @@ -381,7 +391,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres { if (!context.Device.Configuration.EnableInternetAccess) { - Logger.Info?.Print(LogClass.ServiceSfdnsres, $"Guest network access disabled, DNS Blocked."); + Logger.Info?.Print(LogClass.ServiceSfdnsres, "Guest network access disabled, DNS Blocked."); WriteResponse(context, withOptions, 0, GaiError.NoData, NetDbError.HostNotFound); @@ -393,10 +403,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres context.Memory.Read(inputBufferPosition, rawIp); // TODO: Use params. - uint socketLength = context.RequestData.ReadUInt32(); - uint type = context.RequestData.ReadUInt32(); - int timeOut = context.RequestData.ReadInt32(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment + uint socketLength = context.RequestData.ReadUInt32(); + uint type = context.RequestData.ReadUInt32(); + int timeOut = context.RequestData.ReadInt32(); ulong pidPlaceholder = context.RequestData.ReadUInt64(); +#pragma warning restore IDE0059 if (withOptions) { @@ -406,21 +418,21 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres IPHostEntry hostEntry = null; NetDbError netDbErrorCode = NetDbError.Success; - GaiError errno = GaiError.AddressFamily; - int serializedSize = 0; + GaiError errno = GaiError.AddressFamily; + int serializedSize = 0; if (rawIp.Length == 4) { try { - IPAddress address = new IPAddress(rawIp); + IPAddress address = new(rawIp); hostEntry = Dns.GetHostEntry(address); } catch (SocketException exception) { netDbErrorCode = ConvertSocketErrorCodeToNetDbError(exception.ErrorCode); - errno = ConvertSocketErrorCodeToGaiError(exception.ErrorCode, errno); + errno = ConvertSocketErrorCodeToGaiError(exception.ErrorCode, errno); } } else @@ -430,7 +442,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres if (hostEntry != null) { - errno = GaiError.Success; + errno = GaiError.Success; serializedSize = SerializeHostEntries(context, outputBufferPosition, outputBufferSize, hostEntry, GetIpv4Addresses(hostEntry)); } @@ -442,7 +454,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres private static int SerializeHostEntries(ServiceCtx context, ulong outputBufferPosition, ulong outputBufferSize, IPHostEntry hostEntry, IEnumerable<IPAddress> addresses = null) { ulong originalBufferPosition = outputBufferPosition; - ulong bufferPosition = originalBufferPosition; + ulong bufferPosition = originalBufferPosition; string hostName = hostEntry.HostName + '\0'; @@ -494,9 +506,11 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres ulong optionsBufferSize) { bool enableNsdResolve = (context.RequestData.ReadInt32() & 1) != 0; - uint cancelHandle = context.RequestData.ReadUInt32(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment + uint cancelHandle = context.RequestData.ReadUInt32(); +#pragma warning restore IDE0059 - string host = MemoryHelper.ReadAsciiString(context.Memory, context.Request.SendBuff[0].Position, (long)context.Request.SendBuff[0].Size); + string host = MemoryHelper.ReadAsciiString(context.Memory, context.Request.SendBuff[0].Position, (long)context.Request.SendBuff[0].Size); string service = MemoryHelper.ReadAsciiString(context.Memory, context.Request.SendBuff[1].Position, (long)context.Request.SendBuff[1].Size); if (!context.Device.Configuration.EnableInternetAccess) @@ -509,21 +523,27 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres } // NOTE: We ignore hints for now. +#pragma warning disable IDE0059 // Remove unnecessary value assignment List<AddrInfoSerialized> hints = DeserializeAddrInfos(context.Memory, context.Request.SendBuff[2].Position, context.Request.SendBuff[2].Size); +#pragma warning restore IDE0059 if (withOptions) { // TODO: Find unknown, Parse and use options. +#pragma warning disable IDE0059 // Remove unnecessary value assignment uint unknown = context.RequestData.ReadUInt32(); +#pragma warning restore IDE0059 } +#pragma warning disable IDE0059 // Remove unnecessary value assignment ulong pidPlaceHolder = context.RequestData.ReadUInt64(); +#pragma warning restore IDE0059 IPHostEntry hostEntry = null; NetDbError netDbErrorCode = NetDbError.Success; - GaiError errno = GaiError.AddressFamily; - int serializedSize = 0; + GaiError errno = GaiError.AddressFamily; + int serializedSize = 0; if (host.Length <= byte.MaxValue) { @@ -542,7 +562,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres Logger.Info?.Print(LogClass.ServiceSfdnsres, $"DNS Blocked: {host}"); netDbErrorCode = NetDbError.HostNotFound; - errno = GaiError.NoData; + errno = GaiError.NoData; } else { @@ -555,7 +575,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres catch (SocketException exception) { netDbErrorCode = ConvertSocketErrorCodeToNetDbError(exception.ErrorCode); - errno = ConvertSocketErrorCodeToGaiError(exception.ErrorCode, errno); + errno = ConvertSocketErrorCodeToGaiError(exception.ErrorCode, errno); } } } @@ -566,10 +586,15 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres if (hostEntry != null) { - int.TryParse(service, out int port); - - errno = GaiError.Success; - serializedSize = SerializeAddrInfos(context, responseBufferPosition, responseBufferSize, hostEntry, port); + if (int.TryParse(service, out int port)) + { + errno = GaiError.Success; + serializedSize = SerializeAddrInfos(context, responseBufferPosition, responseBufferSize, hostEntry, port); + } + else + { + errno = GaiError.Service; + } } WriteResponse(context, withOptions, serializedSize, errno, netDbErrorCode); @@ -601,37 +626,38 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres private static int SerializeAddrInfos(ServiceCtx context, ulong responseBufferPosition, ulong responseBufferSize, IPHostEntry hostEntry, int port) { ulong originalBufferPosition = responseBufferPosition; - ulong bufferPosition = originalBufferPosition; +#pragma warning disable IDE0059 // Remove unnecessary value assignment + ulong bufferPosition = originalBufferPosition; byte[] hostName = Encoding.ASCII.GetBytes(hostEntry.HostName + '\0'); +#pragma warning restore IDE0059 - using (WritableRegion region = context.Memory.GetWritableRegion(responseBufferPosition, (int)responseBufferSize)) - { - Span<byte> data = region.Memory.Span; + using WritableRegion region = context.Memory.GetWritableRegion(responseBufferPosition, (int)responseBufferSize); - for (int i = 0; i < hostEntry.AddressList.Length; i++) - { - IPAddress ip = hostEntry.AddressList[i]; + Span<byte> data = region.Memory.Span; - if (ip.AddressFamily != AddressFamily.InterNetwork) - { - continue; - } - - // NOTE: 0 = Any - AddrInfoSerializedHeader header = new(ip, 0); - AddrInfo4 addr = new(ip, (short)port); - AddrInfoSerialized info = new(header, addr, null, hostEntry.HostName); + for (int i = 0; i < hostEntry.AddressList.Length; i++) + { + IPAddress ip = hostEntry.AddressList[i]; - data = info.Write(data); + if (ip.AddressFamily != AddressFamily.InterNetwork) + { + continue; } - uint sentinel = 0; - MemoryMarshal.Write(data, ref sentinel); - data = data[sizeof(uint)..]; + // NOTE: 0 = Any + AddrInfoSerializedHeader header = new(ip, 0); + AddrInfo4 addr = new(ip, (short)port); + AddrInfoSerialized info = new(header, addr, null, hostEntry.HostName); - return region.Memory.Span.Length - data.Length; + data = info.Write(data); } + + uint sentinel = 0; + MemoryMarshal.Write(data, ref sentinel); + data = data[sizeof(uint)..]; + + return region.Memory.Span.Length - data.Length; } private static void WriteResponse( @@ -669,7 +695,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres 11002 => NetDbError.TryAgain, 11003 => NetDbError.NoRecovery, 11004 => NetDbError.NoData, - _ => NetDbError.Internal + _ => NetDbError.Internal, }; } @@ -679,8 +705,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres { 11001 => GaiError.NoData, 10060 => GaiError.Again, - _ => errno + _ => errno, }; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsBlacklist.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsBlacklist.cs index 776a6f7c..a2ccd190 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsBlacklist.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsBlacklist.cs @@ -19,18 +19,18 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy [GeneratedRegex(@"^accounts\.nintendo\.com$", RegexOpts)] private static partial Regex BlockedHost6(); - private static readonly Regex[] BlockedHosts = { + private static readonly Regex[] _blockedHosts = { BlockedHost1(), BlockedHost2(), BlockedHost3(), BlockedHost4(), BlockedHost5(), - BlockedHost6() + BlockedHost6(), }; public static bool IsHostBlocked(string host) { - foreach (Regex regex in BlockedHosts) + foreach (Regex regex in _blockedHosts) { if (regex.IsMatch(host)) { @@ -41,4 +41,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy return false; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsMitmResolver.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsMitmResolver.cs index 0e18c570..d17a999d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsMitmResolver.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsMitmResolver.cs @@ -19,8 +19,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy public void ReloadEntries(ServiceCtx context) { - string sdPath = context.Device.Configuration.VirtualFileSystem.GetSdCardPath(); - string filePath = context.Device.Configuration.VirtualFileSystem.GetFullPath(sdPath, HostsFilePath); + string sdPath = FileSystem.VirtualFileSystem.GetSdCardPath(); + string filePath = FileSystem.VirtualFileSystem.GetFullPath(sdPath, HostsFilePath); _mitmHostEntries.Clear(); @@ -94,7 +94,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy { AddressList = new[] { hostEntry.Value }, HostName = hostEntry.Key, - Aliases = Array.Empty<string>() + Aliases = Array.Empty<string>(), }; } } @@ -103,4 +103,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy return Dns.GetHostEntry(host); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfo4.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfo4.cs index 0a20e057..68250022 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfo4.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfo4.cs @@ -10,17 +10,17 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Types [StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0x10)] struct AddrInfo4 { - public byte Length; - public byte Family; - public short Port; + public byte Length; + public byte Family; + public short Port; public Array4<byte> Address; public Array8<byte> Padding; public AddrInfo4(IPAddress address, short port) { - Length = (byte)Unsafe.SizeOf<Array4<byte>>(); - Family = (byte)AddressFamily.InterNetwork; - Port = IPAddress.HostToNetworkOrder(port); + Length = (byte)Unsafe.SizeOf<Array4<byte>>(); + Family = (byte)AddressFamily.InterNetwork; + Port = IPAddress.HostToNetworkOrder(port); Address = new Array4<byte>(); address.TryWriteBytes(Address.AsSpan(), out _); @@ -48,4 +48,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Types } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfoSerializedHeader.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfoSerializedHeader.cs index 8e304dfa..9c50b1b8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfoSerializedHeader.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfoSerializedHeader.cs @@ -10,19 +10,19 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Types struct AddrInfoSerializedHeader { public uint Magic; - public int Flags; - public int Family; - public int SocketType; - public int Protocol; + public int Flags; + public int Family; + public int SocketType; + public int Protocol; public uint AddressLength; public AddrInfoSerializedHeader(IPAddress address, SocketType socketType) { - Magic = SfdnsresContants.AddrInfoMagic; - Flags = 0; - Family = (int)address.AddressFamily; + Magic = SfdnsresContants.AddrInfoMagic; + Flags = 0; + Family = (int)address.AddressFamily; SocketType = (int)socketType; - Protocol = 0; + Protocol = 0; if (address.AddressFamily == AddressFamily.InterNetwork) { @@ -36,22 +36,22 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Types public void ToNetworkOrder() { - Magic = (uint)IPAddress.HostToNetworkOrder((int)Magic); - Flags = IPAddress.HostToNetworkOrder(Flags); - Family = IPAddress.HostToNetworkOrder(Family); - SocketType = IPAddress.HostToNetworkOrder(SocketType); - Protocol = IPAddress.HostToNetworkOrder(Protocol); + Magic = (uint)IPAddress.HostToNetworkOrder((int)Magic); + Flags = IPAddress.HostToNetworkOrder(Flags); + Family = IPAddress.HostToNetworkOrder(Family); + SocketType = IPAddress.HostToNetworkOrder(SocketType); + Protocol = IPAddress.HostToNetworkOrder(Protocol); AddressLength = (uint)IPAddress.HostToNetworkOrder((int)AddressLength); } public void ToHostOrder() { - Magic = (uint)IPAddress.NetworkToHostOrder((int)Magic); - Flags = IPAddress.NetworkToHostOrder(Flags); - Family = IPAddress.NetworkToHostOrder(Family); - SocketType = IPAddress.NetworkToHostOrder(SocketType); - Protocol = IPAddress.NetworkToHostOrder(Protocol); + Magic = (uint)IPAddress.NetworkToHostOrder((int)Magic); + Flags = IPAddress.NetworkToHostOrder(Flags); + Family = IPAddress.NetworkToHostOrder(Family); + SocketType = IPAddress.NetworkToHostOrder(SocketType); + Protocol = IPAddress.NetworkToHostOrder(Protocol); AddressLength = (uint)IPAddress.NetworkToHostOrder((int)AddressLength); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/GaiError.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/GaiError.cs index f9f28b44..46682b3c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/GaiError.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/GaiError.cs @@ -17,6 +17,6 @@ BadHints, Protocol, Overflow, - Max + Max, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/NetDBError.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/NetDBError.cs index 3c04c049..0ded5960 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/NetDBError.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/NetDBError.cs @@ -8,6 +8,6 @@ TryAgain, NoRecovery, NoData, - NoAddress = NoData + NoAddress = NoData, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/SfdnsresContants.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/SfdnsresContants.cs index d194a3c6..7c51413c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/SfdnsresContants.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/SfdnsresContants.cs @@ -1,7 +1,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Types { - static class SfdnsresContants + class SfdnsresContants { public const uint AddrInfoMagic = 0xBEEFCAFE; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Spl/IGeneralInterface.cs b/src/Ryujinx.HLE/HOS/Services/Spl/IGeneralInterface.cs index aa350b73..951ed530 100644 --- a/src/Ryujinx.HLE/HOS/Services/Spl/IGeneralInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Spl/IGeneralInterface.cs @@ -58,8 +58,10 @@ namespace Ryujinx.HLE.HOS.Services.Spl { configValue = default; - SystemVersion version = context.Device.System.ContentManager.GetCurrentFirmwareVersion(); - MemorySize memorySize = context.Device.Configuration.MemoryConfiguration.ToKernelMemorySize(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment + SystemVersion version = context.Device.System.ContentManager.GetCurrentFirmwareVersion(); +#pragma warning restore IDE0059 + MemorySize memorySize = context.Device.Configuration.MemoryConfiguration.ToKernelMemorySize(); switch (configItem) { @@ -80,9 +82,9 @@ namespace Ryujinx.HLE.HOS.Services.Spl configValue = (ulong)DramId.IcosaSamsung4GiB; } break; - case ConfigItem.SecurityEngineInterruptNumber: + case ConfigItem.SecurityEngineInterruptNumber: return SmcResult.NotImplemented; - case ConfigItem.FuseVersion: + case ConfigItem.FuseVersion: return SmcResult.NotImplemented; case ConfigItem.HardwareType: configValue = (ulong)HardwareType.Icosa; @@ -93,7 +95,7 @@ namespace Ryujinx.HLE.HOS.Services.Spl case ConfigItem.IsRecoveryBoot: configValue = 0; break; - case ConfigItem.DeviceId: + case ConfigItem.DeviceId: return SmcResult.NotImplemented; case ConfigItem.BootReason: // This was removed in firmware 4.0.0. @@ -123,4 +125,4 @@ namespace Ryujinx.HLE.HOS.Services.Spl return SmcResult.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Spl/IRandomInterface.cs b/src/Ryujinx.HLE/HOS/Services/Spl/IRandomInterface.cs index db224163..922fd34a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Spl/IRandomInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Spl/IRandomInterface.cs @@ -5,9 +5,7 @@ namespace Ryujinx.HLE.HOS.Services.Spl [Service("csrng")] class IRandomInterface : DisposableIpcService { - private RandomNumberGenerator _rng; - - private readonly object _lock = new(); + private readonly RandomNumberGenerator _rng; public IRandomInterface(ServiceCtx context) { @@ -35,4 +33,4 @@ namespace Ryujinx.HLE.HOS.Services.Spl } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Spl/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Spl/ResultCode.cs index 4f61998a..fe77c753 100644 --- a/src/Ryujinx.HLE/HOS/Services/Spl/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Spl/ResultCode.cs @@ -2,11 +2,11 @@ namespace Ryujinx.HLE.HOS.Services.Spl { enum ResultCode { - ModuleId = 26, + ModuleId = 26, ErrorCodeShift = 9, Success = 0, - InvalidArguments = (101 << ErrorCodeShift) | ModuleId + InvalidArguments = (101 << ErrorCodeShift) | ModuleId, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Spl/Types/ConfigItem.cs b/src/Ryujinx.HLE/HOS/Services/Spl/Types/ConfigItem.cs index f08bbeaa..6822ad13 100644 --- a/src/Ryujinx.HLE/HOS/Services/Spl/Types/ConfigItem.cs +++ b/src/Ryujinx.HLE/HOS/Services/Spl/Types/ConfigItem.cs @@ -3,22 +3,22 @@ enum ConfigItem { // Standard config items. - DisableProgramVerification = 1, - DramId = 2, + DisableProgramVerification = 1, + DramId = 2, SecurityEngineInterruptNumber = 3, - FuseVersion = 4, - HardwareType = 5, - HardwareState = 6, - IsRecoveryBoot = 7, - DeviceId = 8, - BootReason = 9, - MemoryMode = 10, - IsDevelopmentFunctionEnabled = 11, - KernelConfiguration = 12, - IsChargerHiZModeEnabled = 13, - QuestState = 14, - RegulatorType = 15, - DeviceUniqueKeyGeneration = 16, - Package2Hash = 17 + FuseVersion = 4, + HardwareType = 5, + HardwareState = 6, + IsRecoveryBoot = 7, + DeviceId = 8, + BootReason = 9, + MemoryMode = 10, + IsDevelopmentFunctionEnabled = 11, + KernelConfiguration = 12, + IsChargerHiZModeEnabled = 13, + QuestState = 14, + RegulatorType = 15, + DeviceUniqueKeyGeneration = 16, + Package2Hash = 17, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Spl/Types/DramId.cs b/src/Ryujinx.HLE/HOS/Services/Spl/Types/DramId.cs index 422c8d69..05a46557 100644 --- a/src/Ryujinx.HLE/HOS/Services/Spl/Types/DramId.cs +++ b/src/Ryujinx.HLE/HOS/Services/Spl/Types/DramId.cs @@ -30,6 +30,6 @@ IowaMicron1y4GiB, HoagMicron1y4GiB, AulaMicron1y4GiB, - AulaSamsung1y8GiBX + AulaSamsung1y8GiBX, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Spl/Types/HardwareState.cs b/src/Ryujinx.HLE/HOS/Services/Spl/Types/HardwareState.cs index 414d0f11..8ab0ba9b 100644 --- a/src/Ryujinx.HLE/HOS/Services/Spl/Types/HardwareState.cs +++ b/src/Ryujinx.HLE/HOS/Services/Spl/Types/HardwareState.cs @@ -3,6 +3,6 @@ enum HardwareState { Development, - Production + Production, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Spl/Types/HardwareType.cs b/src/Ryujinx.HLE/HOS/Services/Spl/Types/HardwareType.cs index 491eb943..82d73330 100644 --- a/src/Ryujinx.HLE/HOS/Services/Spl/Types/HardwareType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Spl/Types/HardwareType.cs @@ -9,4 +9,4 @@ Calcio, Aula } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Spl/Types/SmcResult.cs b/src/Ryujinx.HLE/HOS/Services/Spl/Types/SmcResult.cs index d5f424a6..ade0378c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Spl/Types/SmcResult.cs +++ b/src/Ryujinx.HLE/HOS/Services/Spl/Types/SmcResult.cs @@ -2,19 +2,18 @@ { enum SmcResult { - Success = 0, - NotImplemented = 1, - InvalidArgument = 2, - Busy = 3, - NoAsyncOperation = 4, + Success = 0, + NotImplemented = 1, + InvalidArgument = 2, + Busy = 3, + NoAsyncOperation = 4, InvalidAsyncOperation = 5, - NotPermitted = 6, - NotInitialized = 7, + NotPermitted = 6, + NotInitialized = 7, - PsciSuccess = 0, - PsciNotSupported = -1, + PsciNotSupported = -1, PsciInvalidParameters = -2, - PsciDenied = -3, - PsciAlreadyOn = -4 + PsciDenied = -3, + PsciAlreadyOn = -4, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Srepo/ISrepoService.cs b/src/Ryujinx.HLE/HOS/Services/Srepo/ISrepoService.cs index 167dea67..f5467983 100644 --- a/src/Ryujinx.HLE/HOS/Services/Srepo/ISrepoService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Srepo/ISrepoService.cs @@ -6,4 +6,4 @@ { public ISrepoService(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ssl/BuiltInCertificateManager.cs b/src/Ryujinx.HLE/HOS/Services/Ssl/BuiltInCertificateManager.cs index dae0698c..e31092fd 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ssl/BuiltInCertificateManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ssl/BuiltInCertificateManager.cs @@ -23,7 +23,7 @@ namespace Ryujinx.HLE.HOS.Services.Ssl { private const long CertStoreTitleId = 0x0100000000000800; - private readonly string CertStoreTitleMissingErrorMessage = "CertStore system title not found! SSL CA retrieving will not work, provide the system archive to fix this error. (See https://github.com/Ryujinx/Ryujinx/wiki/Ryujinx-Setup-&-Configuration-Guide#initial-setup-continued---installation-of-firmware for more information)"; + private const string CertStoreTitleMissingErrorMessage = "CertStore system title not found! SSL CA retrieving will not work, provide the system archive to fix this error. (See https://github.com/Ryujinx/Ryujinx/wiki/Ryujinx-Setup-&-Configuration-Guide#initial-setup-continued---installation-of-firmware for more information)"; private static BuiltInCertificateManager _instance; @@ -31,10 +31,7 @@ namespace Ryujinx.HLE.HOS.Services.Ssl { get { - if (_instance == null) - { - _instance = new BuiltInCertificateManager(); - } + _instance ??= new BuiltInCertificateManager(); return _instance; } @@ -52,12 +49,12 @@ namespace Ryujinx.HLE.HOS.Services.Ssl { private const uint ValidMagic = 0x546C7373; -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public uint Magic; public uint EntriesCount; #pragma warning restore CS0649 - public bool IsValid() + public readonly bool IsValid() { return Magic == ValidMagic; } @@ -65,7 +62,7 @@ namespace Ryujinx.HLE.HOS.Services.Ssl private struct CertStoreFileEntry { -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public CaCertificateId Id; public TrustedCertStatus Status; public uint DataSize; @@ -109,7 +106,7 @@ namespace Ryujinx.HLE.HOS.Services.Ssl { Id = entry.Id, Status = entry.Status, - Data = data + Data = data, }; } @@ -125,9 +122,9 @@ namespace Ryujinx.HLE.HOS.Services.Ssl if (HasCertStoreTitle()) { - using LocalStorage ncaFile = new LocalStorage(_virtualFileSystem.SwitchPathToSystemPath(GetCertStoreTitleContentPath()), FileAccess.Read, FileMode.Open); + using LocalStorage ncaFile = new(VirtualFileSystem.SwitchPathToSystemPath(GetCertStoreTitleContentPath()), FileAccess.Read, FileMode.Open); - Nca nca = new Nca(_virtualFileSystem.KeySet, ncaFile); + Nca nca = new(_virtualFileSystem.KeySet, ncaFile); IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel); diff --git a/src/Ryujinx.HLE/HOS/Services/Ssl/ISslService.cs b/src/Ryujinx.HLE/HOS/Services/Ssl/ISslService.cs index 7741ef7e..5e4a0c53 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ssl/ISslService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ssl/ISslService.cs @@ -19,8 +19,10 @@ namespace Ryujinx.HLE.HOS.Services.Ssl // CreateContext(nn::ssl::sf::SslVersion, u64, pid) -> object<nn::ssl::sf::ISslContext> public ResultCode CreateContext(ServiceCtx context) { - SslVersion sslVersion = (SslVersion)context.RequestData.ReadUInt32(); - ulong pidPlaceholder = context.RequestData.ReadUInt64(); + SslVersion sslVersion = (SslVersion)context.RequestData.ReadUInt32(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment + ulong pidPlaceholder = context.RequestData.ReadUInt64(); +#pragma warning restore IDE0059 MakeObject(context, new ISslContext(context.Request.HandleDesc.PId, sslVersion)); @@ -71,7 +73,7 @@ namespace Ryujinx.HLE.HOS.Services.Ssl Id = entries[i].Id, Status = entries[i].Status, CertificateDataSize = (ulong)entries[i].Data.Length, - CertificateDataOffset = (ulong)(rawData.Length - certificatesData.Length) + CertificateDataOffset = (ulong)(rawData.Length - certificatesData.Length), }; certificatesData = certificatesData[entries[i].Data.Length..]; @@ -84,7 +86,7 @@ namespace Ryujinx.HLE.HOS.Services.Ssl Id = CaCertificateId.All, Status = TrustedCertStatus.Invalid, CertificateDataSize = 0, - CertificateDataOffset = 0 + CertificateDataOffset = 0, }; } } @@ -122,4 +124,4 @@ namespace Ryujinx.HLE.HOS.Services.Ssl return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ssl/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Ssl/ResultCode.cs index 862c79cd..6aae11fe 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ssl/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ssl/ResultCode.cs @@ -2,19 +2,19 @@ { public enum ResultCode { - OsModuleId = 123, + OsModuleId = 123, ErrorCodeShift = 9, - Success = 0, - NoSocket = (103 << ErrorCodeShift) | OsModuleId, - InvalidSocket = (106 << ErrorCodeShift) | OsModuleId, + Success = 0, + NoSocket = (103 << ErrorCodeShift) | OsModuleId, + InvalidSocket = (106 << ErrorCodeShift) | OsModuleId, InvalidCertBufSize = (112 << ErrorCodeShift) | OsModuleId, - InvalidOption = (126 << ErrorCodeShift) | OsModuleId, + InvalidOption = (126 << ErrorCodeShift) | OsModuleId, CertBufferTooSmall = (202 << ErrorCodeShift) | OsModuleId, - AlreadyInUse = (203 << ErrorCodeShift) | OsModuleId, - WouldBlock = (204 << ErrorCodeShift) | OsModuleId, - Timeout = (205 << ErrorCodeShift) | OsModuleId, - ConnectionReset = (209 << ErrorCodeShift) | OsModuleId, - ConnectionAbort = (210 << ErrorCodeShift) | OsModuleId + AlreadyInUse = (203 << ErrorCodeShift) | OsModuleId, + WouldBlock = (204 << ErrorCodeShift) | OsModuleId, + Timeout = (205 << ErrorCodeShift) | OsModuleId, + ConnectionReset = (209 << ErrorCodeShift) | OsModuleId, + ConnectionAbort = (210 << ErrorCodeShift) | OsModuleId, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslConnection.cs b/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslConnection.cs index b9087f40..b5c608d3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslConnection.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslConnection.cs @@ -15,7 +15,7 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.SslService private bool _skipDefaultVerify; private bool _enableAlpn; - private SslVersion _sslVersion; + private readonly SslVersion _sslVersion; private IoMode _ioMode; private VerifyOption _verifyOption; private SessionCacheMode _sessionCacheMode; @@ -206,13 +206,12 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.SslService { if (_getServerCertChain) { - using (WritableRegion region = context.Memory.GetWritableRegion(context.Request.ReceiveBuff[0].Position, (int)context.Request.ReceiveBuff[0].Size)) - { - result = _connection.GetServerCertificate(_hostName, region.Memory.Span, out uint bufferSize, out uint certificateCount); + using WritableRegion region = context.Memory.GetWritableRegion(context.Request.ReceiveBuff[0].Position, (int)context.Request.ReceiveBuff[0].Size); - context.ResponseData.Write(bufferSize); - context.ResponseData.Write(certificateCount); - } + result = _connection.GetServerCertificate(_hostName, region.Memory.Span, out uint bufferSize, out uint certificateCount); + + context.ResponseData.Write(bufferSize); + context.ResponseData.Write(certificateCount); } else { @@ -235,15 +234,13 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.SslService ResultCode result; - using (WritableRegion region = context.Memory.GetWritableRegion(context.Request.ReceiveBuff[0].Position, (int)context.Request.ReceiveBuff[0].Size)) - { - // TODO: Better error management. - result = _connection.Read(out int readCount, region.Memory); + using WritableRegion region = context.Memory.GetWritableRegion(context.Request.ReceiveBuff[0].Position, (int)context.Request.ReceiveBuff[0].Size); + // TODO: Better error management. + result = _connection.Read(out int readCount, region.Memory); - if (result == ResultCode.Success) - { - context.ResponseData.Write(readCount); - } + if (result == ResultCode.Success) + { + context.ResponseData.Write(readCount); } return result; @@ -297,15 +294,15 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.SslService ResultCode result; - using (WritableRegion region = context.Memory.GetWritableRegion(context.Request.ReceiveBuff[0].Position, (int)context.Request.ReceiveBuff[0].Size)) - { - // TODO: Better error management. - result = _connection.Peek(out int peekCount, region.Memory); + using WritableRegion region = context.Memory.GetWritableRegion(context.Request.ReceiveBuff[0].Position, (int)context.Request.ReceiveBuff[0].Size); - if (result == ResultCode.Success) - { - context.ResponseData.Write(peekCount); - } + + // TODO: Better error management. + result = _connection.Peek(out int peekCount, region.Memory); + + if (result == ResultCode.Success) + { + context.ResponseData.Write(peekCount); } return result; @@ -381,7 +378,7 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.SslService // SetOption(b8 value, nn::ssl::sf::OptionType option) public ResultCode SetOption(ServiceCtx context) { - bool value = context.RequestData.ReadUInt32() != 0; + bool value = context.RequestData.ReadUInt32() != 0; OptionType option = (OptionType)context.RequestData.ReadUInt32(); Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { option, value }); @@ -516,4 +513,4 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.SslService _connection?.Dispose(); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslConnectionBase.cs b/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslConnectionBase.cs index 18e03e49..500e2b89 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslConnectionBase.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslConnectionBase.cs @@ -3,7 +3,7 @@ using System; namespace Ryujinx.HLE.HOS.Services.Ssl.SslService { - interface ISslConnectionBase: IDisposable + interface ISslConnectionBase : IDisposable { int SocketFd { get; } diff --git a/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslContext.cs b/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslContext.cs index b38ff921..7b371d29 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslContext.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslContext.cs @@ -47,8 +47,10 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.SslService { CertificateFormat certificateFormat = (CertificateFormat)context.RequestData.ReadUInt32(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment ulong certificateDataPosition = context.Request.SendBuff[0].Position; - ulong certificateDataSize = context.Request.SendBuff[0].Size; + ulong certificateDataSize = context.Request.SendBuff[0].Size; +#pragma warning restore IDE0059 context.ResponseData.Write(_serverCertificateId++); @@ -61,11 +63,13 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.SslService // ImportClientPki(buffer<bytes, 5> certificate, buffer<bytes, 5> ascii_password) -> u64 certificateId public ResultCode ImportClientPki(ServiceCtx context) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment ulong certificateDataPosition = context.Request.SendBuff[0].Position; - ulong certificateDataSize = context.Request.SendBuff[0].Size; + ulong certificateDataSize = context.Request.SendBuff[0].Size; +#pragma warning restore IDE0059 ulong asciiPasswordDataPosition = context.Request.SendBuff[1].Position; - ulong asciiPasswordDataSize = context.Request.SendBuff[1].Size; + ulong asciiPasswordDataSize = context.Request.SendBuff[1].Size; byte[] asciiPasswordData = new byte[asciiPasswordDataSize]; @@ -80,4 +84,4 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.SslService return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/SslManagedSocketConnection.cs b/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/SslManagedSocketConnection.cs index 47d3eddb..dab099aa 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/SslManagedSocketConnection.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/SslManagedSocketConnection.cs @@ -15,8 +15,8 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.SslService public ISocket Socket { get; } - private BsdContext _bsdContext; - private SslVersion _sslVersion; + private readonly BsdContext _bsdContext; + private readonly SslVersion _sslVersion; private SslStream _stream; private bool _isBlockingSocket; private int _previousReadTimeout; @@ -67,25 +67,19 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.SslService EndSslOperation(); } -// NOTE: We silence warnings about TLS 1.0 and 1.1 as games will likely use it. + // NOTE: We silence warnings about TLS 1.0 and 1.1 as games will likely use it. #pragma warning disable SYSLIB0039 - private static SslProtocols TranslateSslVersion(SslVersion version) + private SslProtocols TranslateSslVersion(SslVersion version) { - switch (version & SslVersion.VersionMask) + return (version & SslVersion.VersionMask) switch { - case SslVersion.Auto: - return SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Tls13; - case SslVersion.TlsV10: - return SslProtocols.Tls; - case SslVersion.TlsV11: - return SslProtocols.Tls11; - case SslVersion.TlsV12: - return SslProtocols.Tls12; - case SslVersion.TlsV13: - return SslProtocols.Tls13; - default: - throw new NotImplementedException(version.ToString()); - } + SslVersion.Auto => SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Tls13, + SslVersion.TlsV10 => SslProtocols.Tls, + SslVersion.TlsV11 => SslProtocols.Tls11, + SslVersion.TlsV12 => SslProtocols.Tls12, + SslVersion.TlsV13 => SslProtocols.Tls13, + _ => throw new NotImplementedException(version.ToString()), + }; } #pragma warning restore SYSLIB0039 @@ -114,7 +108,7 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.SslService return 0; } - private static bool TryTranslateWinSockError(bool isBlocking, WsaError error, out ResultCode resultCode) + private bool TryTranslateWinSockError(bool isBlocking, WsaError error, out ResultCode resultCode) { switch (error) { diff --git a/src/Ryujinx.HLE/HOS/Services/Ssl/Types/CaCertificateId.cs b/src/Ryujinx.HLE/HOS/Services/Ssl/Types/CaCertificateId.cs index 5c84579a..a351ce54 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ssl/Types/CaCertificateId.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ssl/Types/CaCertificateId.cs @@ -63,6 +63,6 @@ GTSRootR4, SecurityCommunicationRootCA, - All = uint.MaxValue + All = uint.MaxValue, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Ssl/Types/CertificateFormat.cs b/src/Ryujinx.HLE/HOS/Services/Ssl/Types/CertificateFormat.cs index 1d80f739..35842e85 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ssl/Types/CertificateFormat.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ssl/Types/CertificateFormat.cs @@ -3,6 +3,6 @@ enum CertificateFormat : uint { Pem = 1, - Der = 2 + Der = 2, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ssl/Types/IoMode.cs b/src/Ryujinx.HLE/HOS/Services/Ssl/Types/IoMode.cs index 1cd06d6d..c8b3889c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ssl/Types/IoMode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ssl/Types/IoMode.cs @@ -2,7 +2,7 @@ { enum IoMode : uint { - Blocking = 1, - NonBlocking = 2 + Blocking = 1, + NonBlocking = 2, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ssl/Types/OptionType.cs b/src/Ryujinx.HLE/HOS/Services/Ssl/Types/OptionType.cs index 3673200a..85a813dc 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ssl/Types/OptionType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ssl/Types/OptionType.cs @@ -5,6 +5,6 @@ DoNotCloseSocket, GetServerCertChain, // 3.0.0+ SkipDefaultVerify, // 5.0.0+ - EnableAlpn // 9.0.0+ + EnableAlpn, // 9.0.0+ } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ssl/Types/SessionCacheMode.cs b/src/Ryujinx.HLE/HOS/Services/Ssl/Types/SessionCacheMode.cs index cec7b745..b9c73937 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ssl/Types/SessionCacheMode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ssl/Types/SessionCacheMode.cs @@ -4,6 +4,6 @@ { None, SessionId, - SessionTicket + SessionTicket, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ssl/Types/SslVersion.cs b/src/Ryujinx.HLE/HOS/Services/Ssl/Types/SslVersion.cs index 7110fd85..7026596e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ssl/Types/SslVersion.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ssl/Types/SslVersion.cs @@ -5,12 +5,12 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.Types [Flags] enum SslVersion : uint { - Auto = 1 << 0, + Auto = 1 << 0, TlsV10 = 1 << 3, TlsV11 = 1 << 4, TlsV12 = 1 << 5, TlsV13 = 1 << 6, // 11.0.0+ - VersionMask = 0xFFFFFF + VersionMask = 0xFFFFFF, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Ssl/Types/TrustedCertStatus.cs b/src/Ryujinx.HLE/HOS/Services/Ssl/Types/TrustedCertStatus.cs index 7fd5efd6..e9d348c1 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ssl/Types/TrustedCertStatus.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ssl/Types/TrustedCertStatus.cs @@ -7,6 +7,6 @@ EnabledNotTrusted, Revoked, - Invalid = uint.MaxValue + Invalid = uint.MaxValue, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Ssl/Types/VerifyOption.cs b/src/Ryujinx.HLE/HOS/Services/Ssl/Types/VerifyOption.cs index d25bb6c3..1c13e80f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ssl/Types/VerifyOption.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ssl/Types/VerifyOption.cs @@ -5,11 +5,11 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.Types [Flags] enum VerifyOption : uint { - PeerCa = 1 << 0, - HostName = 1 << 1, - DateCheck = 1 << 2, - EvCertPartial = 1 << 3, - EvPolicyOid = 1 << 4, // 6.0.0+ - EvCertFingerprint = 1 << 5 // 6.0.0+ + PeerCa = 1 << 0, + HostName = 1 << 1, + DateCheck = 1 << 2, + EvCertPartial = 1 << 3, + EvPolicyOid = 1 << 4, // 6.0.0+ + EvCertFingerprint = 1 << 5, // 6.0.0+ } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferItemConsumer.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferItemConsumer.cs index 3b33bf8b..26596210 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferItemConsumer.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferItemConsumer.cs @@ -5,7 +5,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { class BufferItemConsumer : ConsumerBase { - private GpuContext _gpuContext; + private readonly GpuContext _gpuContext; public BufferItemConsumer(Switch device, BufferQueueConsumer consumer, diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueue.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueue.cs index bc0901ab..347eb8fb 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueue.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueue.cs @@ -4,7 +4,7 @@ { public static BufferQueueCore CreateBufferQueue(Switch device, ulong pid, out BufferQueueProducer producer, out BufferQueueConsumer consumer) { - BufferQueueCore core = new BufferQueueCore(device, pid); + BufferQueueCore core = new(device, pid); producer = new BufferQueueProducer(core, device.System.TickSource); consumer = new BufferQueueConsumer(core); diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueConsumer.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueConsumer.cs index c9bb0a65..4cd45d69 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueConsumer.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueConsumer.cs @@ -54,10 +54,10 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger if (Core.StillTracking(ref bufferItem)) { - Core.Slots[bufferItem.Slot].AcquireCalled = true; + Core.Slots[bufferItem.Slot].AcquireCalled = true; Core.Slots[bufferItem.Slot].NeedsCleanupOnRelease = true; - Core.Slots[bufferItem.Slot].BufferState = BufferState.Acquired; - Core.Slots[bufferItem.Slot].Fence = AndroidFence.NoFence; + Core.Slots[bufferItem.Slot].BufferState = BufferState.Acquired; + Core.Slots[bufferItem.Slot].Fence = AndroidFence.NoFence; ulong targetFrameNumber = Core.Slots[bufferItem.Slot].FrameNumber; @@ -159,12 +159,12 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger Core.Slots[slot].GraphicBuffer.Set(graphicBuffer); - Core.Slots[slot].BufferState = BufferState.Acquired; - Core.Slots[slot].AttachedByConsumer = true; + Core.Slots[slot].BufferState = BufferState.Acquired; + Core.Slots[slot].AttachedByConsumer = true; Core.Slots[slot].NeedsCleanupOnRelease = false; - Core.Slots[slot].Fence = AndroidFence.NoFence; - Core.Slots[slot].FrameNumber = 0; - Core.Slots[slot].AcquireCalled = false; + Core.Slots[slot].Fence = AndroidFence.NoFence; + Core.Slots[slot].FrameNumber = 0; + Core.Slots[slot].AcquireCalled = false; } return Status.Success; @@ -197,7 +197,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger if (Core.Slots[slot].BufferState == BufferState.Acquired) { Core.Slots[slot].BufferState = BufferState.Free; - Core.Slots[slot].Fence = fence; + Core.Slots[slot].Fence = fence; listener = Core.ProducerListener; } @@ -237,7 +237,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger return Status.NoInit; } - Core.ConsumerListener = consumerListener; + Core.ConsumerListener = consumerListener; Core.ConsumerControlledByApp = controlledByApp; } @@ -253,7 +253,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger return Status.BadValue; } - Core.IsAbandoned = true; + Core.IsAbandoned = true; Core.ConsumerListener = null; Core.Queue.Clear(); @@ -304,7 +304,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger lock (Core.Lock) { - Core.DefaultWidth = (int)width; + Core.DefaultWidth = (int)width; Core.DefaultHeight = (int)height; } diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueCore.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueCore.cs index 8cf55912..f1d2f84b 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueCore.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueCore.cs @@ -9,35 +9,35 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { class BufferQueueCore { - public BufferSlotArray Slots; - public int OverrideMaxBufferCount; - public bool UseAsyncBuffer; - public bool DequeueBufferCannotBlock; - public PixelFormat DefaultBufferFormat; - public int DefaultWidth; - public int DefaultHeight; - public int DefaultMaxBufferCount; - public int MaxAcquiredBufferCount; - public bool BufferHasBeenQueued; - public ulong FrameCounter; + public BufferSlotArray Slots; + public int OverrideMaxBufferCount; + public bool UseAsyncBuffer; + public bool DequeueBufferCannotBlock; + public PixelFormat DefaultBufferFormat; + public int DefaultWidth; + public int DefaultHeight; + public int DefaultMaxBufferCount; + public int MaxAcquiredBufferCount; + public bool BufferHasBeenQueued; + public ulong FrameCounter; public NativeWindowTransform TransformHint; - public bool IsAbandoned; - public NativeWindowApi ConnectedApi; - public bool IsAllocating; - public IProducerListener ProducerListener; - public IConsumerListener ConsumerListener; - public bool ConsumerControlledByApp; - public uint ConsumerUsageBits; - public List<BufferItem> Queue; - public BufferInfo[] BufferHistory; - public uint BufferHistoryPosition; - public bool EnableExternalEvent; - public int MaxBufferCountCached; + public bool IsAbandoned; + public NativeWindowApi ConnectedApi; + public bool IsAllocating; + public IProducerListener ProducerListener; + public IConsumerListener ConsumerListener; + public bool ConsumerControlledByApp; + public uint ConsumerUsageBits; + public List<BufferItem> Queue; + public BufferInfo[] BufferHistory; + public uint BufferHistoryPosition; + public bool EnableExternalEvent; + public int MaxBufferCountCached; public readonly object Lock = new(); - private KEvent _waitBufferFreeEvent; - private KEvent _frameAvailableEvent; + private readonly KEvent _waitBufferFreeEvent; + private readonly KEvent _frameAvailableEvent; public ulong Owner { get; } @@ -49,36 +49,36 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger public BufferQueueCore(Switch device, ulong pid) { - Slots = new BufferSlotArray(); - IsAbandoned = false; - OverrideMaxBufferCount = 0; + Slots = new BufferSlotArray(); + IsAbandoned = false; + OverrideMaxBufferCount = 0; DequeueBufferCannotBlock = false; - UseAsyncBuffer = false; - DefaultWidth = 1; - DefaultHeight = 1; - DefaultMaxBufferCount = 2; - MaxAcquiredBufferCount = 1; - FrameCounter = 0; - TransformHint = 0; - DefaultBufferFormat = PixelFormat.Rgba8888; - IsAllocating = false; - ProducerListener = null; - ConsumerListener = null; - ConsumerUsageBits = 0; + UseAsyncBuffer = false; + DefaultWidth = 1; + DefaultHeight = 1; + DefaultMaxBufferCount = 2; + MaxAcquiredBufferCount = 1; + FrameCounter = 0; + TransformHint = 0; + DefaultBufferFormat = PixelFormat.Rgba8888; + IsAllocating = false; + ProducerListener = null; + ConsumerListener = null; + ConsumerUsageBits = 0; Queue = new List<BufferItem>(); // TODO: CreateGraphicBufferAlloc? - _waitBufferFreeEvent = new KEvent(device.System.KernelContext); + _waitBufferFreeEvent = new KEvent(device.System.KernelContext); _frameAvailableEvent = new KEvent(device.System.KernelContext); Owner = pid; Active = true; - BufferHistory = new BufferInfo[BufferHistoryArraySize]; - EnableExternalEvent = true; + BufferHistory = new BufferInfo[BufferHistoryArraySize]; + EnableExternalEvent = true; MaxBufferCountCached = 0; } @@ -220,9 +220,9 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger Slots[slot].NeedsCleanupOnRelease = true; } - Slots[slot].BufferState = BufferState.Free; - Slots[slot].FrameNumber = uint.MaxValue; - Slots[slot].AcquireCalled = false; + Slots[slot].BufferState = BufferState.Free; + Slots[slot].FrameNumber = uint.MaxValue; + Slots[slot].AcquireCalled = false; Slots[slot].Fence.FenceCount = 0; } @@ -259,7 +259,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger return; } - bool needBufferReleaseSignal = false; + bool needBufferReleaseSignal = false; bool needFrameAvailableSignal = false; if (maxBufferCount > 1) diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueProducer.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueProducer.cs index fa840f2a..887d1861 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueProducer.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueProducer.cs @@ -15,7 +15,9 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger private readonly ITickSource _tickSource; +#pragma warning disable IDE0052 // Remove unread private member private uint _stickyTransform; +#pragma warning restore IDE0052 private uint _nextCallbackTicket; private uint _currentCallbackTicket; @@ -28,9 +30,9 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger Core = core; _tickSource = tickSource; - _stickyTransform = 0; - _callbackTicket = 0; - _nextCallbackTicket = 0; + _stickyTransform = 0; + _callbackTicket = 0; + _nextCallbackTicket = 0; _currentCallbackTicket = 0; } @@ -134,7 +136,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { if ((width == 0 && height != 0) || (height == 0 && width != 0)) { - slot = BufferSlotArray.InvalidBufferSlot; + slot = BufferSlotArray.InvalidBufferSlot; fence = AndroidFence.NoFence; return Status.BadValue; @@ -157,7 +159,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger if (status != Status.Success) { - slot = BufferSlotArray.InvalidBufferSlot; + slot = BufferSlotArray.InvalidBufferSlot; fence = AndroidFence.NoFence; return status; @@ -176,7 +178,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger if (width == 0 || height == 0) { - width = (uint)Core.DefaultWidth; + width = (uint)Core.DefaultWidth; height = (uint)Core.DefaultHeight; } @@ -190,7 +192,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { if (!Core.Slots[slot].IsPreallocated) { - slot = BufferSlotArray.InvalidBufferSlot; + slot = BufferSlotArray.InvalidBufferSlot; fence = AndroidFence.NoFence; return Status.NoMemory; @@ -202,7 +204,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger $"available: Width = {graphicBuffer.Width} Height = {graphicBuffer.Height} Format = {graphicBuffer.Format} Usage = {graphicBuffer.Usage:x} " + $"requested: Width = {width} Height = {height} Format = {format} Usage = {usage:x}"); - slot = BufferSlotArray.InvalidBufferSlot; + slot = BufferSlotArray.InvalidBufferSlot; fence = AndroidFence.NoFence; return Status.NoInit; @@ -215,8 +217,8 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger fence = Core.Slots[slot].Fence; - Core.Slots[slot].Fence = AndroidFence.NoFence; - Core.Slots[slot].QueueTime = TimeSpanType.Zero; + Core.Slots[slot].Fence = AndroidFence.NoFence; + Core.Slots[slot].QueueTime = TimeSpanType.Zero; Core.Slots[slot].PresentationTime = TimeSpanType.Zero; Core.CheckSystemEventsLocked(Core.GetMaxBufferCountLocked(async)); @@ -267,7 +269,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger if (Core.IsAbandoned) { graphicBuffer = default; - fence = AndroidFence.NoFence; + fence = AndroidFence.NoFence; return Status.NoInit; } @@ -288,13 +290,13 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger if (nextBufferSlot == BufferSlotArray.InvalidBufferSlot) { graphicBuffer = default; - fence = AndroidFence.NoFence; + fence = AndroidFence.NoFence; return Status.NoMemory; } graphicBuffer = Core.Slots[nextBufferSlot].GraphicBuffer; - fence = Core.Slots[nextBufferSlot].Fence; + fence = Core.Slots[nextBufferSlot].Fence; Core.FreeBufferLocked(nextBufferSlot); @@ -326,8 +328,8 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger Core.Slots[slot].GraphicBuffer.Set(graphicBuffer); - Core.Slots[slot].BufferState = BufferState.Dequeued; - Core.Slots[slot].Fence = AndroidFence.NoFence; + Core.Slots[slot].BufferState = BufferState.Dequeued; + Core.Slots[slot].Fence = AndroidFence.NoFence; Core.Slots[slot].RequestBufferCalled = true; return returnFlags; @@ -350,10 +352,10 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger return Status.BadValue; } - BufferItem item = new BufferItem(); + BufferItem item = new(); IConsumerListener frameAvailableListener = null; - IConsumerListener frameReplaceListener = null; + IConsumerListener frameReplaceListener = null; lock (Core.Lock) { @@ -388,25 +390,25 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger return Status.BadValue; } - Core.Slots[slot].Fence = input.Fence; + Core.Slots[slot].Fence = input.Fence; Core.Slots[slot].BufferState = BufferState.Queued; Core.FrameCounter++; - Core.Slots[slot].FrameNumber = Core.FrameCounter; - Core.Slots[slot].QueueTime = TimeSpanType.FromTimeSpan(_tickSource.ElapsedTime); + Core.Slots[slot].FrameNumber = Core.FrameCounter; + Core.Slots[slot].QueueTime = TimeSpanType.FromTimeSpan(_tickSource.ElapsedTime); Core.Slots[slot].PresentationTime = TimeSpanType.Zero; - item.AcquireCalled = Core.Slots[slot].AcquireCalled; - item.Crop = input.Crop; - item.Transform = input.Transform; + item.AcquireCalled = Core.Slots[slot].AcquireCalled; + item.Crop = input.Crop; + item.Transform = input.Transform; item.TransformToDisplayInverse = (input.Transform & NativeWindowTransform.InverseDisplay) == NativeWindowTransform.InverseDisplay; - item.ScalingMode = input.ScalingMode; - item.Timestamp = input.Timestamp; - item.IsAutoTimestamp = input.IsAutoTimestamp != 0; - item.SwapInterval = input.SwapInterval; - item.FrameNumber = Core.FrameCounter; - item.Slot = slot; - item.Fence = input.Fence; - item.IsDroppable = Core.DequeueBufferCannotBlock || input.Async != 0; + item.ScalingMode = input.ScalingMode; + item.Timestamp = input.Timestamp; + item.IsAutoTimestamp = input.IsAutoTimestamp != 0; + item.SwapInterval = input.SwapInterval; + item.FrameNumber = Core.FrameCounter; + item.Slot = slot; + item.Fence = input.Fence; + item.IsDroppable = Core.DequeueBufferCannotBlock || input.Async != 0; item.GraphicBuffer.Set(Core.Slots[slot].GraphicBuffer); item.GraphicBuffer.Object.IncrementNvMapHandleRefCount(Core.Owner); @@ -416,8 +418,8 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger Core.BufferHistory[Core.BufferHistoryPosition] = new BufferInfo { FrameNumber = Core.FrameCounter, - QueueTime = Core.Slots[slot].QueueTime, - State = BufferState.Queued + QueueTime = Core.Slots[slot].QueueTime, + State = BufferState.Queued, }; _stickyTransform = input.StickyTransform; @@ -460,10 +462,10 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger output = new QueueBufferOutput { - Width = (uint)Core.DefaultWidth, - Height = (uint)Core.DefaultHeight, - TransformHint = Core.TransformHint, - NumPendingBuffers = (uint)Core.Queue.Count + Width = (uint)Core.DefaultWidth, + Height = (uint)Core.DefaultHeight, + TransformHint = Core.TransformHint, + NumPendingBuffers = (uint)Core.Queue.Count, }; if ((input.StickyTransform & 8) != 0) @@ -506,7 +508,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger Core.Slots[slot].BufferState = BufferState.Free; Core.Slots[slot].FrameNumber = 0; - Core.Slots[slot].Fence = fence; + Core.Slots[slot].Fence = fence; Core.SignalDequeueEvent(); Core.SignalWaitBufferFreeEvent(); } @@ -568,7 +570,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger return Status.BadValue; } - Core.BufferHasBeenQueued = false; + Core.BufferHasBeenQueued = false; Core.DequeueBufferCannotBlock = Core.ConsumerControlledByApp && producerControlledByApp; switch (api) @@ -578,11 +580,11 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger case NativeWindowApi.Media: case NativeWindowApi.Camera: Core.ProducerListener = listener; - Core.ConnectedApi = api; + Core.ConnectedApi = api; - output.Width = (uint)Core.DefaultWidth; - output.Height = (uint)Core.DefaultHeight; - output.TransformHint = Core.TransformHint; + output.Width = (uint)Core.DefaultWidth; + output.Height = (uint)Core.DefaultHeight; + output.TransformHint = Core.TransformHint; output.NumPendingBuffers = (uint)Core.Queue.Count; if (NxSettings.Settings.TryGetValue("nv!nvn_no_vsync_capability", out object noVSyncCapability) && (bool)noVSyncCapability) @@ -627,7 +629,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger producerListener = Core.ProducerListener; Core.ProducerListener = null; - Core.ConnectedApi = NativeWindowApi.NoApi; + Core.ConnectedApi = NativeWindowApi.NoApi; Core.SignalWaitBufferFreeEvent(); Core.SignalFrameAvailableEvent(); @@ -667,13 +669,13 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger lock (Core.Lock) { - Core.Slots[slot].BufferState = BufferState.Free; - Core.Slots[slot].Fence = AndroidFence.NoFence; - Core.Slots[slot].RequestBufferCalled = false; - Core.Slots[slot].AcquireCalled = false; + Core.Slots[slot].BufferState = BufferState.Free; + Core.Slots[slot].Fence = AndroidFence.NoFence; + Core.Slots[slot].RequestBufferCalled = false; + Core.Slots[slot].AcquireCalled = false; Core.Slots[slot].NeedsCleanupOnRelease = false; - Core.Slots[slot].IsPreallocated = !graphicBuffer.IsNull; - Core.Slots[slot].FrameNumber = 0; + Core.Slots[slot].IsPreallocated = !graphicBuffer.IsNull; + Core.Slots[slot].FrameNumber = 0; Core.Slots[slot].GraphicBuffer.Set(graphicBuffer); @@ -689,8 +691,8 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { // NOTE: Nintendo set the default width, height and format from the GraphicBuffer.. // This is entirely wrong and should only be controlled by the consumer... - Core.DefaultWidth = graphicBuffer.Object.Width; - Core.DefaultHeight = graphicBuffer.Object.Height; + Core.DefaultWidth = graphicBuffer.Object.Width; + Core.DefaultHeight = graphicBuffer.Object.Height; Core.DefaultBufferFormat = graphicBuffer.Object.Format; } else @@ -729,7 +731,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { bool tryAgain = true; - freeSlot = BufferSlotArray.InvalidBufferSlot; + freeSlot = BufferSlotArray.InvalidBufferSlot; returnStatus = Status.Success; while (tryAgain) diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferSlot.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferSlot.cs index fb84934a..4632053d 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferSlot.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferSlot.cs @@ -6,24 +6,24 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger class BufferSlot { public AndroidStrongPointer<GraphicBuffer> GraphicBuffer; - public BufferState BufferState; - public bool RequestBufferCalled; - public ulong FrameNumber; - public AndroidFence Fence; - public bool AcquireCalled; - public bool NeedsCleanupOnRelease; - public bool AttachedByConsumer; - public TimeSpanType QueueTime; - public TimeSpanType PresentationTime; - public bool IsPreallocated; + public BufferState BufferState; + public bool RequestBufferCalled; + public ulong FrameNumber; + public AndroidFence Fence; + public bool AcquireCalled; + public bool NeedsCleanupOnRelease; + public bool AttachedByConsumer; + public TimeSpanType QueueTime; + public TimeSpanType PresentationTime; + public bool IsPreallocated; public BufferSlot() { - GraphicBuffer = new AndroidStrongPointer<GraphicBuffer>(); - BufferState = BufferState.Free; - QueueTime = TimeSpanType.Zero; + GraphicBuffer = new AndroidStrongPointer<GraphicBuffer>(); + BufferState = BufferState.Free; + QueueTime = TimeSpanType.Zero; PresentationTime = TimeSpanType.Zero; - IsPreallocated = false; + IsPreallocated = false; } } } diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferSlotArray.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferSlotArray.cs index d2404c58..5a6604f1 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferSlotArray.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferSlotArray.cs @@ -3,11 +3,11 @@ class BufferSlotArray { // TODO: move to BufferQueue - public const int NumBufferSlots = 0x40; + public const int NumBufferSlots = 0x40; public const int MaxAcquiredBuffers = NumBufferSlots - 2; - public const int InvalidBufferSlot = -1; + public const int InvalidBufferSlot = -1; - private BufferSlot[] _raw = new BufferSlot[NumBufferSlots]; + private readonly BufferSlot[] _raw = new BufferSlot[NumBufferSlots]; public BufferSlotArray() { diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/ConsumerBase.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/ConsumerBase.cs index 754fa7d7..d6301997 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/ConsumerBase.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/ConsumerBase.cs @@ -8,8 +8,8 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger public class Slot { public AndroidStrongPointer<GraphicBuffer> GraphicBuffer; - public AndroidFence Fence; - public ulong FrameNumber; + public AndroidFence Fence; + public ulong FrameNumber; public Slot() { @@ -25,7 +25,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger protected readonly object Lock = new(); - private IConsumerListener _listener; + private readonly IConsumerListener _listener; public ConsumerBase(BufferQueueConsumer consumer, bool controlledByApp, IConsumerListener listener) { @@ -35,8 +35,8 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger } IsAbandoned = false; - Consumer = consumer; - _listener = listener; + Consumer = consumer; + _listener = listener; Status connectStatus = consumer.Connect(this, controlledByApp); @@ -81,7 +81,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { Slots[slotIndex].GraphicBuffer.Reset(); - Slots[slotIndex].Fence = AndroidFence.NoFence; + Slots[slotIndex].Fence = AndroidFence.NoFence; Slots[slotIndex].FrameNumber = 0; } @@ -123,7 +123,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger } Slots[bufferItem.Slot].FrameNumber = bufferItem.FrameNumber; - Slots[bufferItem.Slot].Fence = bufferItem.Fence; + Slots[bufferItem.Slot].Fence = bufferItem.Fence; return Status.Success; } diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/HOSBinderDriverServer.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/HOSBinderDriverServer.cs index d6c98be1..f89eaeeb 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/HOSBinderDriverServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/HOSBinderDriverServer.cs @@ -7,11 +7,11 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { class HOSBinderDriverServer : IHOSBinderDriver { - private static Dictionary<int, IBinder> _registeredBinderObjects = new Dictionary<int, IBinder>(); + private static readonly Dictionary<int, IBinder> _registeredBinderObjects = new(); private static int _lastBinderId = 0; - private static object _lock = new object(); + private static readonly object _lock = new(); public static int RegisterBinderObject(IBinder binder) { diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/IBinder.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/IBinder.cs index 9003201b..9690cd4a 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/IBinder.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/IBinder.cs @@ -13,10 +13,10 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger ResultCode OnTransact(uint code, uint flags, ReadOnlySpan<byte> inputParcel, Span<byte> outputParcel) { - Parcel inputParcelReader = new Parcel(inputParcel.ToArray()); + Parcel inputParcelReader = new(inputParcel.ToArray()); // TODO: support objects? - Parcel outputParcelWriter = new Parcel((uint)(outputParcel.Length - Unsafe.SizeOf<ParcelHeader>()), 0); + Parcel outputParcelWriter = new((uint)(outputParcel.Length - Unsafe.SizeOf<ParcelHeader>()), 0); string inputInterfaceToken = inputParcelReader.ReadInterfaceToken(); diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/IGraphicBufferProducer.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/IGraphicBufferProducer.cs index f0b393a0..a70f7fe3 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/IGraphicBufferProducer.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/IGraphicBufferProducer.cs @@ -29,33 +29,33 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger SetPreallocatedBuffer, Reserved15, GetBufferInfo, - GetBufferHistory + GetBufferHistory, } [StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0x54)] public struct QueueBufferInput : IFlattenable { - public long Timestamp; - public int IsAutoTimestamp; - public Rect Crop; + public long Timestamp; + public int IsAutoTimestamp; + public Rect Crop; public NativeWindowScalingMode ScalingMode; - public NativeWindowTransform Transform; - public uint StickyTransform; - public int Async; - public int SwapInterval; - public AndroidFence Fence; + public NativeWindowTransform Transform; + public uint StickyTransform; + public int Async; + public int SwapInterval; + public AndroidFence Fence; public void Flatten(Parcel parcel) { parcel.WriteUnmanagedType(ref this); } - public uint GetFdCount() + public readonly uint GetFdCount() { return 0; } - public uint GetFlattenedSize() + public readonly uint GetFlattenedSize() { return (uint)Unsafe.SizeOf<QueueBufferInput>(); } @@ -68,11 +68,11 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger public struct QueueBufferOutput { - public uint Width; - public uint Height; + public uint Width; + public uint Height; public NativeWindowTransform TransformHint; - public uint NumPendingBuffers; - public ulong FrameNumber; + public uint NumPendingBuffers; + public ulong FrameNumber; public void WriteToParcel(Parcel parcel) { @@ -108,15 +108,15 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger public void OnTransact(uint code, uint flags, Parcel inputParcel, Parcel outputParcel) { - Status status = Status.Success; - int slot; - AndroidFence fence; - QueueBufferInput queueInput; + Status status = Status.Success; + int slot; + AndroidFence fence; + QueueBufferInput queueInput; QueueBufferOutput queueOutput; - NativeWindowApi api; + NativeWindowApi api; AndroidStrongPointer<GraphicBuffer> graphicBuffer; - AndroidStrongPointer<AndroidFence> strongFence; + AndroidStrongPointer<AndroidFence> strongFence; switch ((TransactionCode)code) { @@ -139,13 +139,13 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger break; case TransactionCode.DequeueBuffer: - bool async = inputParcel.ReadBoolean(); - uint width = inputParcel.ReadUInt32(); - uint height = inputParcel.ReadUInt32(); + bool async = inputParcel.ReadBoolean(); + uint width = inputParcel.ReadUInt32(); + uint height = inputParcel.ReadUInt32(); PixelFormat format = inputParcel.ReadUnmanagedType<PixelFormat>(); - uint usage = inputParcel.ReadUInt32(); + uint usage = inputParcel.ReadUInt32(); - status = DequeueBuffer(out int dequeueSlot, out fence, async, width, height, format, usage); + status = DequeueBuffer(out int dequeueSlot, out fence, async, width, height, format, usage); strongFence = new AndroidStrongPointer<AndroidFence>(fence); outputParcel.WriteInt32(dequeueSlot); @@ -163,7 +163,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger break; case TransactionCode.DetachNextBuffer: - status = DetachNextBuffer(out graphicBuffer, out fence); + status = DetachNextBuffer(out graphicBuffer, out fence); strongFence = new AndroidStrongPointer<AndroidFence>(fence); outputParcel.WriteStrongPointer(ref graphicBuffer); @@ -183,7 +183,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger break; case TransactionCode.QueueBuffer: - slot = inputParcel.ReadInt32(); + slot = inputParcel.ReadInt32(); queueInput = inputParcel.ReadFlattenable<QueueBufferInput>(); status = QueueBuffer(slot, ref queueInput, out queueOutput); @@ -194,7 +194,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger break; case TransactionCode.CancelBuffer: - slot = inputParcel.ReadInt32(); + slot = inputParcel.ReadInt32(); fence = inputParcel.ReadFlattenable<AndroidFence>(); CancelBuffer(slot, ref fence); diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/IHOSBinderDriver.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/IHOSBinderDriver.cs index 2f9f4291..3d44e23d 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/IHOSBinderDriver.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/IHOSBinderDriver.cs @@ -17,18 +17,18 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { int binderId = context.RequestData.ReadInt32(); - uint code = context.RequestData.ReadUInt32(); + uint code = context.RequestData.ReadUInt32(); uint flags = context.RequestData.ReadUInt32(); - ulong dataPos = context.Request.SendBuff[0].Position; + ulong dataPos = context.Request.SendBuff[0].Position; ulong dataSize = context.Request.SendBuff[0].Size; - ulong replyPos = context.Request.ReceiveBuff[0].Position; + ulong replyPos = context.Request.ReceiveBuff[0].Position; ulong replySize = context.Request.ReceiveBuff[0].Size; ReadOnlySpan<byte> inputParcel = context.Memory.GetSpan(dataPos, (int)dataSize); - Span<byte> outputParcel = new Span<byte>(new byte[replySize]); + Span<byte> outputParcel = new(new byte[replySize]); ResultCode result = OnTransact(binderId, code, flags, inputParcel, outputParcel); @@ -45,8 +45,8 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger public ResultCode AdjustRefcount(ServiceCtx context) { int binderId = context.RequestData.ReadInt32(); - int addVal = context.RequestData.ReadInt32(); - int type = context.RequestData.ReadInt32(); + int addVal = context.RequestData.ReadInt32(); + int type = context.RequestData.ReadInt32(); return AdjustRefcount(binderId, addVal, type); } @@ -77,27 +77,26 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { int binderId = context.RequestData.ReadInt32(); - uint code = context.RequestData.ReadUInt32(); + uint code = context.RequestData.ReadUInt32(); uint flags = context.RequestData.ReadUInt32(); - (ulong dataPos, ulong dataSize) = context.Request.GetBufferType0x21(); + (ulong dataPos, ulong dataSize) = context.Request.GetBufferType0x21(); (ulong replyPos, ulong replySize) = context.Request.GetBufferType0x22(); ReadOnlySpan<byte> inputParcel = context.Memory.GetSpan(dataPos, (int)dataSize); - using (IMemoryOwner<byte> outputParcelOwner = ByteMemoryPool.RentCleared(replySize)) - { - Span<byte> outputParcel = outputParcelOwner.Memory.Span; + using IMemoryOwner<byte> outputParcelOwner = ByteMemoryPool.RentCleared(replySize); - ResultCode result = OnTransact(binderId, code, flags, inputParcel, outputParcel); + Span<byte> outputParcel = outputParcelOwner.Memory.Span; - if (result == ResultCode.Success) - { - context.Memory.Write(replyPos, outputParcel); - } + ResultCode result = OnTransact(binderId, code, flags, inputParcel, outputParcel); - return result; + if (result == ResultCode.Success) + { + context.Memory.Write(replyPos, outputParcel); } + + return result; } protected abstract ResultCode AdjustRefcount(int binderId, int addVal, int type); diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/LayerState.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/LayerState.cs index 5f014e13..af32be3d 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/LayerState.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/LayerState.cs @@ -5,6 +5,6 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger NotInitialized, ManagedClosed, ManagedOpened, - Stray + Stray, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/NativeWindowApi.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/NativeWindowApi.cs index 794c48b8..b565f3f6 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/NativeWindowApi.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/NativeWindowApi.cs @@ -2,10 +2,10 @@ { enum NativeWindowApi { - NoApi = 0, - NVN = 1, - CPU = 2, - Media = 3, - Camera = 4 + NoApi = 0, + NVN = 1, + CPU = 2, + Media = 3, + Camera = 4, } } diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/NativeWindowAttribute.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/NativeWindowAttribute.cs index c40b4fa1..075f8136 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/NativeWindowAttribute.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/NativeWindowAttribute.cs @@ -2,12 +2,12 @@ { enum NativeWindowAttribute : uint { - Width = 0, - Height = 1, - Format = 2, - MinUnqueuedBuffers = 3, + Width = 0, + Height = 1, + Format = 2, + MinUnqueuedBuffers = 3, ConsumerRunningBehind = 9, - ConsumerUsageBits = 10, - MaxBufferCountAsync = 12 + ConsumerUsageBits = 10, + MaxBufferCountAsync = 12, } } diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/NativeWindowScalingMode.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/NativeWindowScalingMode.cs index 4194c915..9b07e43b 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/NativeWindowScalingMode.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/NativeWindowScalingMode.cs @@ -2,10 +2,10 @@ { enum NativeWindowScalingMode : uint { - Freeze = 0, + Freeze = 0, ScaleToWindow = 1, - ScaleCrop = 2, - Unknown = 3, - NoScaleCrop = 4, + ScaleCrop = 2, + Unknown = 3, + NoScaleCrop = 4, } } diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/NativeWindowTransform.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/NativeWindowTransform.cs index 66482b12..1a0c7d13 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/NativeWindowTransform.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/NativeWindowTransform.cs @@ -5,14 +5,14 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger [Flags] enum NativeWindowTransform : uint { - None = 0, - FlipX = 1, - FlipY = 2, - Rotate90 = 4, - Rotate180 = FlipX | FlipY, - Rotate270 = Rotate90 | Rotate180, - InverseDisplay = 8, + None = 0, + FlipX = 1, + FlipY = 2, + Rotate90 = 4, + Rotate180 = FlipX | FlipY, + Rotate270 = Rotate90 | Rotate180, + InverseDisplay = 8, NoVSyncCapability = 0x10, - ReturnFrameNumber = 0x20 + ReturnFrameNumber = 0x20, } } diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Parcel.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Parcel.cs index 19b22157..431c2cad 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Parcel.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Parcel.cs @@ -13,7 +13,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { private readonly byte[] _rawData; - private Span<byte> Raw => new Span<byte>(_rawData); + private Span<byte> Raw => new(_rawData); private ref ParcelHeader Header => ref MemoryMarshal.Cast<byte, ParcelHeader>(_rawData)[0]; @@ -26,10 +26,10 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger public Parcel(byte[] rawData) { - _rawData = rawData; + _rawData = rawData; _payloadPosition = 0; - _objectPosition = 0; + _objectPosition = 0; } public Parcel(uint payloadSize, uint objectsSize) @@ -38,16 +38,18 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger _rawData = new byte[BitUtils.AlignUp<uint>(headerSize + payloadSize + objectsSize, 4)]; - Header.PayloadSize = payloadSize; - Header.ObjectsSize = objectsSize; + Header.PayloadSize = payloadSize; + Header.ObjectsSize = objectsSize; Header.PayloadOffset = headerSize; - Header.ObjectOffset = Header.PayloadOffset + Header.ObjectsSize; + Header.ObjectOffset = Header.PayloadOffset + Header.ObjectsSize; } public string ReadInterfaceToken() { // Ignore the policy flags +#pragma warning disable IDE0059 // Remove unnecessary value assignment int strictPolicy = ReadInt32(); +#pragma warning restore IDE0059 return ReadString16(); } @@ -64,7 +66,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger ReadOnlySpan<byte> data = ReadInPlace((size + 1) * 2); // Return the unicode string without the last character (null terminator) - return Encoding.Unicode.GetString(data.Slice(0, size * 2)); + return Encoding.Unicode.GetString(data[..(size * 2)]); } public int ReadInt32() => ReadUnmanagedType<int>(); @@ -77,7 +79,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { long flattenableSize = ReadInt64(); - T result = new T(); + T result = new(); Debug.Assert(flattenableSize == result.GetFlattenedSize()); @@ -86,7 +88,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger return result; } - public T ReadUnmanagedType<T>() where T: unmanaged + public T ReadUnmanagedType<T>() where T : unmanaged { ReadOnlySpan<byte> data = ReadInPlace(Unsafe.SizeOf<T>()); @@ -105,8 +107,8 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger [StructLayout(LayoutKind.Sequential, Size = 0x28)] private struct FlatBinderObject { - public int Type; - public int Flags; + public int Type; + public int Flags; public long BinderId; public long Cookie; @@ -115,12 +117,12 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger public Span<byte> ServiceName => MemoryMarshal.CreateSpan(ref _serviceNameStart, 0x8); } - public void WriteObject<T>(T obj, string serviceName) where T: IBinder + public void WriteObject<T>(T obj, string serviceName) where T : IBinder { - FlatBinderObject flatBinderObject = new FlatBinderObject + FlatBinderObject flatBinderObject = new() { - Type = 2, - Flags = 0, + Type = 2, + Flags = 0, BinderId = HOSBinderDriverServer.GetBinderId(obj), }; @@ -149,7 +151,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger } } - public void WriteStrongPointer<T>(ref AndroidStrongPointer<T> value) where T: unmanaged, IFlattenable + public void WriteStrongPointer<T>(ref AndroidStrongPointer<T> value) where T : unmanaged, IFlattenable { WriteBoolean(!value.IsNull); @@ -205,17 +207,17 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { uint headerSize = (uint)Unsafe.SizeOf<ParcelHeader>(); - Header.PayloadSize = (uint)_payloadPosition; - Header.ObjectsSize = (uint)_objectPosition; + Header.PayloadSize = (uint)_payloadPosition; + Header.ObjectsSize = (uint)_objectPosition; Header.PayloadOffset = headerSize; - Header.ObjectOffset = Header.PayloadOffset + Header.PayloadSize; + Header.ObjectOffset = Header.PayloadOffset + Header.PayloadSize; } public ReadOnlySpan<byte> Finish() { UpdateHeader(); - return Raw.Slice(0, (int)(Header.PayloadSize + Header.ObjectsSize + Unsafe.SizeOf<ParcelHeader>())); + return Raw[..(int)(Header.PayloadSize + Header.ObjectsSize + Unsafe.SizeOf<ParcelHeader>())]; } } } diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Status.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Status.cs index 925811fa..d328aee9 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Status.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Status.cs @@ -1,22 +1,25 @@ -namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger +using System.Diagnostics.CodeAnalysis; + +namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { + [SuppressMessage("Design", "CA1069: Enums values should not be duplicated")] enum Status { - Success = 0, - WouldBlock = -11, - NoMemory = -12, - Busy = -16, - NoInit = -19, - BadValue = -22, + Success = 0, + WouldBlock = -11, + NoMemory = -12, + Busy = -16, + NoInit = -19, + BadValue = -22, InvalidOperation = -37, // Producer flags BufferNeedsReallocation = 1, - ReleaseAllBuffers = 2, + ReleaseAllBuffers = 2, // Consumer errors - StaleBufferSlot = 1, + StaleBufferSlot = 1, NoBufferAvailaible = 2, - PresentLater = 3, + PresentLater = 3, } } diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs index 0c1cea51..d3d9dc03 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs @@ -11,49 +11,47 @@ using System.Threading; namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { - using ResultCode = Ryujinx.HLE.HOS.Services.Vi.ResultCode; - class SurfaceFlinger : IConsumerListener, IDisposable { private const int TargetFps = 60; - private Switch _device; + private readonly Switch _device; - private Dictionary<long, Layer> _layers; + private readonly Dictionary<long, Layer> _layers; private bool _isRunning; - private Thread _composerThread; + private readonly Thread _composerThread; - private Stopwatch _chrono; + private readonly Stopwatch _chrono; - private ManualResetEvent _event = new ManualResetEvent(false); - private AutoResetEvent _nextFrameEvent = new AutoResetEvent(true); + private readonly ManualResetEvent _event = new(false); + private readonly AutoResetEvent _nextFrameEvent = new(true); private long _ticks; private long _ticksPerFrame; - private long _spinTicks; - private long _1msTicks; + private readonly long _spinTicks; + private readonly long _1msTicks; private int _swapInterval; private int _swapIntervalDelay; - private readonly object Lock = new(); + private readonly object _lock = new(); public long RenderLayerId { get; private set; } private class Layer { - public int ProducerBinderId; + public int ProducerBinderId; public IGraphicBufferProducer Producer; - public BufferItemConsumer Consumer; - public BufferQueueCore Core; - public ulong Owner; - public LayerState State; + public BufferItemConsumer Consumer; + public BufferQueueCore Core; + public ulong Owner; + public LayerState State; } private class TextureCallbackInformation { - public Layer Layer; + public Layer Layer; public BufferItem Item; } @@ -65,7 +63,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger _composerThread = new Thread(HandleComposition) { - Name = "SurfaceFlinger.Composer" + Name = "SurfaceFlinger.Composer", }; _chrono = new Stopwatch(); @@ -100,7 +98,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { layerId = 1; - lock (Lock) + lock (_lock) { foreach (KeyValuePair<long, Layer> pair in _layers) { @@ -118,7 +116,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger private void CreateLayerFromId(ulong pid, long layerId, LayerState initialState) { - lock (Lock) + lock (_lock) { Logger.Info?.Print(LogClass.SurfaceFlinger, $"Creating layer {layerId}"); @@ -132,16 +130,16 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger _layers.Add(layerId, new Layer { ProducerBinderId = HOSBinderDriverServer.RegisterBinderObject(producer), - Producer = producer, - Consumer = new BufferItemConsumer(_device, consumer, 0, -1, false, this), - Core = core, - Owner = pid, - State = initialState + Producer = producer, + Consumer = new BufferItemConsumer(_device, consumer, 0, -1, false, this), + Core = core, + Owner = pid, + State = initialState, }); } } - public ResultCode OpenLayer(ulong pid, long layerId, out IBinder producer) + public Vi.ResultCode OpenLayer(ulong pid, long layerId, out IBinder producer) { Layer layer = GetLayerByIdLocked(layerId); @@ -149,18 +147,18 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { producer = null; - return ResultCode.InvalidArguments; + return Vi.ResultCode.InvalidArguments; } layer.State = LayerState.ManagedOpened; producer = layer.Producer; - return ResultCode.Success; + return Vi.ResultCode.Success; } - public ResultCode CloseLayer(long layerId) + public Vi.ResultCode CloseLayer(long layerId) { - lock (Lock) + lock (_lock) { Layer layer = GetLayerByIdLocked(layerId); @@ -168,18 +166,18 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { Logger.Error?.Print(LogClass.SurfaceFlinger, $"Failed to close layer {layerId}"); - return ResultCode.InvalidValue; + return Vi.ResultCode.InvalidValue; } CloseLayer(layerId, layer); - return ResultCode.Success; + return Vi.ResultCode.Success; } } - public ResultCode DestroyManagedLayer(long layerId) + public Vi.ResultCode DestroyManagedLayer(long layerId) { - lock (Lock) + lock (_lock) { Layer layer = GetLayerByIdLocked(layerId); @@ -187,14 +185,14 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { Logger.Error?.Print(LogClass.SurfaceFlinger, $"Failed to destroy managed layer {layerId} (not found)"); - return ResultCode.InvalidValue; + return Vi.ResultCode.InvalidValue; } if (layer.State != LayerState.ManagedClosed && layer.State != LayerState.ManagedOpened) { Logger.Error?.Print(LogClass.SurfaceFlinger, $"Failed to destroy managed layer {layerId} (permission denied)"); - return ResultCode.PermissionDenied; + return Vi.ResultCode.PermissionDenied; } HOSBinderDriverServer.UnregisterBinderObject(layer.ProducerBinderId); @@ -204,13 +202,13 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger CloseLayer(layerId, layer); } - return ResultCode.Success; + return Vi.ResultCode.Success; } } - public ResultCode DestroyStrayLayer(long layerId) + public Vi.ResultCode DestroyStrayLayer(long layerId) { - lock (Lock) + lock (_lock) { Layer layer = GetLayerByIdLocked(layerId); @@ -218,14 +216,14 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { Logger.Error?.Print(LogClass.SurfaceFlinger, $"Failed to destroy stray layer {layerId} (not found)"); - return ResultCode.InvalidValue; + return Vi.ResultCode.InvalidValue; } if (layer.State != LayerState.Stray) { Logger.Error?.Print(LogClass.SurfaceFlinger, $"Failed to destroy stray layer {layerId} (permission denied)"); - return ResultCode.PermissionDenied; + return Vi.ResultCode.PermissionDenied; } HOSBinderDriverServer.UnregisterBinderObject(layer.ProducerBinderId); @@ -235,7 +233,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger CloseLayer(layerId, layer); } - return ResultCode.Success; + return Vi.ResultCode.Success; } } @@ -263,7 +261,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger public void SetRenderLayer(long layerId) { - lock (Lock) + lock (_lock) { RenderLayerId = layerId; } @@ -284,7 +282,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger public IGraphicBufferProducer GetProducerByLayerId(long layerId) { - lock (Lock) + lock (_lock) { Layer layer = GetLayerByIdLocked(layerId); @@ -365,7 +363,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger public void Compose() { - lock (Lock) + lock (_lock) { // TODO: support multilayers (& multidisplay ?) if (RenderLayerId == 0) @@ -403,7 +401,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger private void PostFrameBuffer(Layer layer, BufferItem item) { - int frameBufferWidth = item.GraphicBuffer.Object.Width; + int frameBufferWidth = item.GraphicBuffer.Object.Width; int frameBufferHeight = item.GraphicBuffer.Object.Height; int nvMapHandle = item.GraphicBuffer.Object.Buffer.Surfaces[0].NvMapHandle; @@ -434,9 +432,9 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger bool flipY = item.Transform.HasFlag(NativeWindowTransform.FlipY); AspectRatio aspectRatio = _device.Configuration.AspectRatio; - bool isStretched = aspectRatio == AspectRatio.Stretched; + bool isStretched = aspectRatio == AspectRatio.Stretched; - ImageCrop crop = new ImageCrop( + ImageCrop crop = new( cropRect.Left, cropRect.Right, cropRect.Top, @@ -447,10 +445,10 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger aspectRatio.ToFloatX(), aspectRatio.ToFloatY()); - TextureCallbackInformation textureCallbackInformation = new TextureCallbackInformation + TextureCallbackInformation textureCallbackInformation = new() { Layer = layer, - Item = item + Item = item, }; if (_device.Gpu.Window.EnqueueFrameThreadSafe( @@ -543,6 +541,6 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger _device.Statistics.RecordGameFrameTime(); } - public void OnBuffersReleased() {} + public void OnBuffersReleased() { } } } diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/AndroidFence.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/AndroidFence.cs index 5b72e257..448074cd 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/AndroidFence.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/AndroidFence.cs @@ -16,17 +16,17 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger private byte _fenceStorageStart; - private Span<byte> _storage => MemoryMarshal.CreateSpan(ref _fenceStorageStart, Unsafe.SizeOf<NvFence>() * 4); + private Span<byte> Storage => MemoryMarshal.CreateSpan(ref _fenceStorageStart, Unsafe.SizeOf<NvFence>() * 4); - public Span<NvFence> NvFences => MemoryMarshal.Cast<byte, NvFence>(_storage); + public Span<NvFence> NvFences => MemoryMarshal.Cast<byte, NvFence>(Storage); public static AndroidFence NoFence { get { - AndroidFence fence = new AndroidFence + AndroidFence fence = new() { - FenceCount = 0 + FenceCount = 0, }; fence.NvFences[0].Id = NvFence.InvalidSyncPointId; @@ -81,12 +81,12 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger } } - public uint GetFlattenedSize() + public readonly uint GetFlattenedSize() { return (uint)Unsafe.SizeOf<AndroidFence>(); } - public uint GetFdCount() + public readonly uint GetFdCount() { return 0; } @@ -101,4 +101,4 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger this = parcel.ReadUnmanagedType<AndroidFence>(); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/AndroidStrongPointer.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/AndroidStrongPointer.cs index c356671b..963a1fe4 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/AndroidStrongPointer.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/AndroidStrongPointer.cs @@ -1,6 +1,6 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger.Types { - class AndroidStrongPointer<T> where T: unmanaged, IFlattenable + class AndroidStrongPointer<T> where T : unmanaged, IFlattenable { public T Object; @@ -20,13 +20,13 @@ public void Set(AndroidStrongPointer<T> other) { - Object = other.Object; + Object = other.Object; _hasObject = other._hasObject; } public void Set(T obj) { - Object = obj; + Object = obj; _hasObject = true; } diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/BufferInfo.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/BufferInfo.cs index 12c41b0d..faade87f 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/BufferInfo.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/BufferInfo.cs @@ -6,9 +6,9 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger.Types [StructLayout(LayoutKind.Sequential, Size = 0x1C, Pack = 1)] struct BufferInfo { - public ulong FrameNumber; + public ulong FrameNumber; public TimeSpanType QueueTime; public TimeSpanType PresentationTime; - public BufferState State; + public BufferState State; } } diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/BufferItem.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/BufferItem.cs index 19fc7900..cbb5ce76 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/BufferItem.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/BufferItem.cs @@ -6,33 +6,33 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger class BufferItem : ICloneable { public AndroidStrongPointer<GraphicBuffer> GraphicBuffer; - public AndroidFence Fence; - public Rect Crop; - public NativeWindowTransform Transform; - public NativeWindowScalingMode ScalingMode; - public long Timestamp; - public bool IsAutoTimestamp; - public int SwapInterval; - public ulong FrameNumber; - public int Slot; - public bool IsDroppable; - public bool AcquireCalled; - public bool TransformToDisplayInverse; + public AndroidFence Fence; + public Rect Crop; + public NativeWindowTransform Transform; + public NativeWindowScalingMode ScalingMode; + public long Timestamp; + public bool IsAutoTimestamp; + public int SwapInterval; + public ulong FrameNumber; + public int Slot; + public bool IsDroppable; + public bool AcquireCalled; + public bool TransformToDisplayInverse; public BufferItem() { - GraphicBuffer = new AndroidStrongPointer<GraphicBuffer>(); - Transform = NativeWindowTransform.None; - ScalingMode = NativeWindowScalingMode.Freeze; - Timestamp = 0; - IsAutoTimestamp = false; - FrameNumber = 0; - Slot = BufferSlotArray.InvalidBufferSlot; - IsDroppable = false; - AcquireCalled = false; + GraphicBuffer = new AndroidStrongPointer<GraphicBuffer>(); + Transform = NativeWindowTransform.None; + ScalingMode = NativeWindowScalingMode.Freeze; + Timestamp = 0; + IsAutoTimestamp = false; + FrameNumber = 0; + Slot = BufferSlotArray.InvalidBufferSlot; + IsDroppable = false; + AcquireCalled = false; TransformToDisplayInverse = false; - SwapInterval = 1; - Fence = AndroidFence.NoFence; + SwapInterval = 1; + Fence = AndroidFence.NoFence; Crop = new Rect(); Crop.MakeInvalid(); @@ -40,19 +40,20 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger public object Clone() { - BufferItem item = new BufferItem(); - - item.Transform = Transform; - item.ScalingMode = ScalingMode; - item.IsAutoTimestamp = IsAutoTimestamp; - item.FrameNumber = FrameNumber; - item.Slot = Slot; - item.IsDroppable = IsDroppable; - item.AcquireCalled = AcquireCalled; - item.TransformToDisplayInverse = TransformToDisplayInverse; - item.SwapInterval = SwapInterval; - item.Fence = Fence; - item.Crop = Crop; + BufferItem item = new() + { + Transform = Transform, + ScalingMode = ScalingMode, + IsAutoTimestamp = IsAutoTimestamp, + FrameNumber = FrameNumber, + Slot = Slot, + IsDroppable = IsDroppable, + AcquireCalled = AcquireCalled, + TransformToDisplayInverse = TransformToDisplayInverse, + SwapInterval = SwapInterval, + Fence = Fence, + Crop = Crop, + }; item.GraphicBuffer.Set(GraphicBuffer); diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/BufferState.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/BufferState.cs index 1787f5a6..d735a294 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/BufferState.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/BufferState.cs @@ -2,9 +2,9 @@ { internal enum BufferState { - Free = 0, + Free = 0, Dequeued = 1, - Queued = 2, - Acquired = 3 + Queued = 2, + Acquired = 3, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorBytePerPixel.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorBytePerPixel.cs index b47d35b4..ec119d68 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorBytePerPixel.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorBytePerPixel.cs @@ -2,16 +2,16 @@ { enum ColorBytePerPixel { - Bpp1 = 1, - Bpp2 = 2, - Bpp4 = 4, - Bpp8 = 8, - Bpp16 = 16, - Bpp24 = 24, - Bpp32 = 32, - Bpp48 = 48, - Bpp64 = 64, - Bpp96 = 96, - Bpp128 = 128 + Bpp1 = 1, + Bpp2 = 2, + Bpp4 = 4, + Bpp8 = 8, + Bpp16 = 16, + Bpp24 = 24, + Bpp32 = 32, + Bpp48 = 48, + Bpp64 = 64, + Bpp96 = 96, + Bpp128 = 128, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorComponent.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorComponent.cs index e9669f12..e3da2931 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorComponent.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorComponent.cs @@ -2,6 +2,7 @@ { enum ColorComponent : uint { +#pragma warning disable IDE0055 // Disable formatting X1 = (0x01 << ColorShift.Component) | ColorBytePerPixel.Bpp1, X2 = (0x02 << ColorShift.Component) | ColorBytePerPixel.Bpp2, X4 = (0x03 << ColorShift.Component) | ColorBytePerPixel.Bpp4, @@ -38,5 +39,6 @@ Y12X12 = (0x24 << ColorShift.Component) | ColorBytePerPixel.Bpp32, X20Y20Z20 = (0x26 << ColorShift.Component) | ColorBytePerPixel.Bpp64, X16Y16Z16W16 = (0x27 << ColorShift.Component) | ColorBytePerPixel.Bpp64, +#pragma warning restore IDE0055 } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorDataType.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorDataType.cs index cfa3b018..2daa73b8 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorDataType.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorDataType.cs @@ -3,7 +3,7 @@ enum ColorDataType { Integer = 0x0 << ColorShift.DataType, - Float = 0x1 << ColorShift.DataType, - Stencil = 0x2 << ColorShift.DataType + Float = 0x1 << ColorShift.DataType, + Stencil = 0x2 << ColorShift.DataType, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorFormat.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorFormat.cs index 227d648a..e13dbd86 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorFormat.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorFormat.cs @@ -1,7 +1,11 @@ -namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger +using System.Diagnostics.CodeAnalysis; + +namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { + [SuppressMessage("Design", "CA1069: Enums values should not be duplicated")] enum ColorFormat : ulong { +#pragma warning disable IDE0055 // Disable formatting NonColor8 = ColorSpace.NonColor | ColorSwizzle.X000 | ColorComponent.X8 | ColorDataType.Integer, NonColor16 = ColorSpace.NonColor | ColorSwizzle.X000 | ColorComponent.X16 | ColorDataType.Integer, NonColor24 = ColorSpace.NonColor | ColorSwizzle.X000 | ColorComponent.X24 | ColorDataType.Integer, @@ -231,5 +235,6 @@ X4Bayer12GBRG = ColorSpace.BayerGBRG | ColorSwizzle.Y000 | ColorComponent.Y4X12 | ColorDataType.Integer, X6Bayer10GBRG = ColorSpace.BayerGBRG | ColorSwizzle.Y000 | ColorComponent.Y6X10 | ColorDataType.Integer, XYZ = ColorSpace.XYZ | ColorSwizzle.XYZ1 | ColorComponent.X20Y20Z20 | ColorDataType.Float, +#pragma warning restore IDE0055 } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorShift.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorShift.cs index 3ad216a8..e19ed3ef 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorShift.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorShift.cs @@ -2,9 +2,9 @@ { class ColorShift { - public const int Swizzle = 16; - public const int DataType = 14; - public const int Space = 32; + public const int Swizzle = 16; + public const int DataType = 14; + public const int Space = 32; public const int Component = 8; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorSpace.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorSpace.cs index 9003a00b..5021e356 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorSpace.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorSpace.cs @@ -2,32 +2,32 @@ { enum ColorSpace : ulong { - NonColor = 0x0L << ColorShift.Space, - LinearRGBA = 0x1L << ColorShift.Space, - SRGB = 0x2L << ColorShift.Space, + NonColor = 0x0L << ColorShift.Space, + LinearRGBA = 0x1L << ColorShift.Space, + SRGB = 0x2L << ColorShift.Space, - RGB709 = 0x3L << ColorShift.Space, - LinearRGB709 = 0x4L << ColorShift.Space, + RGB709 = 0x3L << ColorShift.Space, + LinearRGB709 = 0x4L << ColorShift.Space, - LinearScRGB = 0x5L << ColorShift.Space, + LinearScRGB = 0x5L << ColorShift.Space, - RGB2020 = 0x6L << ColorShift.Space, + RGB2020 = 0x6L << ColorShift.Space, LinearRGB2020 = 0x7L << ColorShift.Space, - RGB2020_PQ = 0x8L << ColorShift.Space, + RGB2020_PQ = 0x8L << ColorShift.Space, - ColorIndex = 0x9L << ColorShift.Space, + ColorIndex = 0x9L << ColorShift.Space, - YCbCr601 = 0xAL << ColorShift.Space, - YCbCr601_RR = 0xBL << ColorShift.Space, - YCbCr601_ER = 0xCL << ColorShift.Space, - YCbCr709 = 0xDL << ColorShift.Space, - YCbCr709_ER = 0xEL << ColorShift.Space, + YCbCr601 = 0xAL << ColorShift.Space, + YCbCr601_RR = 0xBL << ColorShift.Space, + YCbCr601_ER = 0xCL << ColorShift.Space, + YCbCr709 = 0xDL << ColorShift.Space, + YCbCr709_ER = 0xEL << ColorShift.Space, - BayerRGGB = 0x10L << ColorShift.Space, - BayerBGGR = 0x11L << ColorShift.Space, - BayerGRBG = 0x12L << ColorShift.Space, - BayerGBRG = 0x13L << ColorShift.Space, + BayerRGGB = 0x10L << ColorShift.Space, + BayerBGGR = 0x11L << ColorShift.Space, + BayerGRBG = 0x12L << ColorShift.Space, + BayerGBRG = 0x13L << ColorShift.Space, - XYZ = 0x14L << ColorShift.Space, + XYZ = 0x14L << ColorShift.Space, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorSwizzle.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorSwizzle.cs index 4c1370c7..0473d56b 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorSwizzle.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Color/ColorSwizzle.cs @@ -2,6 +2,7 @@ { enum ColorSwizzle { +#pragma warning disable IDE0055 // Disable formatting XYZW = 0x688 << ColorShift.Swizzle, ZYXW = 0x60a << ColorShift.Swizzle, WZYX = 0x053 << ColorShift.Swizzle, @@ -26,6 +27,7 @@ _000X = 0x124 << ColorShift.Swizzle, _0XY0 = 0x844 << ColorShift.Swizzle, XXXY = 0x200 << ColorShift.Swizzle, - YYYX = 0x049 << ColorShift.Swizzle + YYYX = 0x049 << ColorShift.Swizzle, +#pragma warning restore IDE0055 } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/GraphicBuffer.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/GraphicBuffer.cs index d1143225..f7bd3b24 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/GraphicBuffer.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/GraphicBuffer.cs @@ -9,14 +9,14 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger struct GraphicBuffer : IFlattenable { public GraphicBufferHeader Header; - public NvGraphicBuffer Buffer; + public NvGraphicBuffer Buffer; - public int Width => Header.Width; - public int Height => Header.Height; - public PixelFormat Format => Header.Format; - public int Usage => Header.Usage; + public readonly int Width => Header.Width; + public readonly int Height => Header.Height; + public readonly PixelFormat Format => Header.Format; + public readonly int Usage => Header.Usage; - public Rect ToRect() + public readonly Rect ToRect() { return new Rect(Width, Height); } @@ -41,34 +41,34 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger Buffer = parcel.ReadUnmanagedType<NvGraphicBuffer>(); } - public void IncrementNvMapHandleRefCount(ulong pid) + public readonly void IncrementNvMapHandleRefCount(ulong pid) { NvMapDeviceFile.IncrementMapRefCount(pid, Buffer.NvMapId); - for (int i = 0; i < Buffer.Surfaces.Length; i++) + for (int i = 0; i < NvGraphicBufferSurfaceArray.Length; i++) { NvMapDeviceFile.IncrementMapRefCount(pid, Buffer.Surfaces[i].NvMapHandle); } } - public void DecrementNvMapHandleRefCount(ulong pid) + public readonly void DecrementNvMapHandleRefCount(ulong pid) { NvMapDeviceFile.DecrementMapRefCount(pid, Buffer.NvMapId); - for (int i = 0; i < Buffer.Surfaces.Length; i++) + for (int i = 0; i < NvGraphicBufferSurfaceArray.Length; i++) { NvMapDeviceFile.DecrementMapRefCount(pid, Buffer.Surfaces[i].NvMapHandle); } } - public uint GetFlattenedSize() + public readonly uint GetFlattenedSize() { return (uint)Unsafe.SizeOf<GraphicBuffer>(); } - public uint GetFdCount() + public readonly uint GetFdCount() { return 0; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/GraphicBufferHeader.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/GraphicBufferHeader.cs index 77495922..c6413ec1 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/GraphicBufferHeader.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/GraphicBufferHeader.cs @@ -5,12 +5,12 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger [StructLayout(LayoutKind.Sequential, Size = 0x28, Pack = 1)] struct GraphicBufferHeader { - public int Magic; - public int Width; - public int Height; - public int Stride; + public int Magic; + public int Width; + public int Height; + public int Stride; public PixelFormat Format; - public int Usage; + public int Usage; public int Pid; public int RefCount; @@ -18,4 +18,4 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger public int FdsCount; public int IntsCount; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/NvGraphicBuffer.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/NvGraphicBuffer.cs index 6bb47dcc..cbae4a90 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/NvGraphicBuffer.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/NvGraphicBuffer.cs @@ -38,4 +38,4 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger [FieldOffset(0x34)] public NvGraphicBufferSurfaceArray Surfaces; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/NvGraphicBufferSurface.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/NvGraphicBufferSurface.cs index e084bc73..e0570c70 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/NvGraphicBufferSurface.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/NvGraphicBufferSurface.cs @@ -41,4 +41,4 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger [FieldOffset(0x38)] public long Size; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/NvGraphicBufferSurfaceArray.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/NvGraphicBufferSurfaceArray.cs index 51ac98f8..8bc30c1f 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/NvGraphicBufferSurfaceArray.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/NvGraphicBufferSurfaceArray.cs @@ -15,27 +15,20 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger [FieldOffset(0xb0)] private NvGraphicBufferSurface Surface2; - public NvGraphicBufferSurface this[int index] + public readonly NvGraphicBufferSurface this[int index] { get { - if (index == 0) + return index switch { - return Surface0; - } - else if (index == 1) - { - return Surface1; - } - else if (index == 2) - { - return Surface2; - } - - throw new IndexOutOfRangeException(); + 0 => Surface0, + 1 => Surface1, + 2 => Surface2, + _ => throw new IndexOutOfRangeException(), + }; } } - public int Length => 3; + public static int Length => 3; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Rect.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Rect.cs index a5dec969..a5f7efa5 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Rect.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Types/Rect.cs @@ -11,18 +11,18 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger public int Right; public int Bottom; - public int Width => Right - Left; - public int Height => Bottom - Top; + public readonly int Width => Right - Left; + public readonly int Height => Bottom - Top; public Rect(int width, int height) { - Left = 0; - Top = 0; - Right = width; + Left = 0; + Top = 0; + Right = width; Bottom = height; } - public bool IsEmpty() + public readonly bool IsEmpty() { return Width <= 0 || Height <= 0; } @@ -31,10 +31,10 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { result = new Rect { - Left = Math.Max(Left, other.Left), - Top = Math.Max(Top, other.Top), - Right = Math.Min(Right, other.Right), - Bottom = Math.Min(Bottom, other.Bottom) + Left = Math.Max(Left, other.Left), + Top = Math.Max(Top, other.Top), + Right = Math.Min(Right, other.Right), + Bottom = Math.Min(Bottom, other.Bottom), }; return !result.IsEmpty(); @@ -42,7 +42,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger public void MakeInvalid() { - Right = -1; + Right = -1; Bottom = -1; } @@ -56,16 +56,16 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger return !x.Equals(y); } - public override bool Equals(object obj) + public readonly override bool Equals(object obj) { return obj is Rect rect && Equals(rect); } - public bool Equals(Rect cmpObj) + public readonly bool Equals(Rect cmpObj) { return Left == cmpObj.Left && Top == cmpObj.Top && Right == cmpObj.Right && Bottom == cmpObj.Bottom; } - public override int GetHashCode() => HashCode.Combine(Left, Top, Right, Bottom); + public readonly override int GetHashCode() => HashCode.Combine(Left, Top, Right, Bottom); } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/LocalSystemClockContextWriter.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/LocalSystemClockContextWriter.cs index fb7ebdc5..49da1245 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/LocalSystemClockContextWriter.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/LocalSystemClockContextWriter.cs @@ -2,7 +2,7 @@ { class LocalSystemClockContextWriter : SystemClockContextUpdateCallback { - private TimeSharedMemory _sharedMemory; + private readonly TimeSharedMemory _sharedMemory; public LocalSystemClockContextWriter(TimeSharedMemory sharedMemory) { @@ -11,7 +11,7 @@ protected override ResultCode Update() { - _sharedMemory.UpdateLocalSystemClockContext(_context); + _sharedMemory.UpdateLocalSystemClockContext(Context); return ResultCode.Success; } diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/NetworkSystemClockContextWriter.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/NetworkSystemClockContextWriter.cs index 36468ec1..ef315ea4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/NetworkSystemClockContextWriter.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/NetworkSystemClockContextWriter.cs @@ -2,7 +2,7 @@ { class NetworkSystemClockContextWriter : SystemClockContextUpdateCallback { - private TimeSharedMemory _sharedMemory; + private readonly TimeSharedMemory _sharedMemory; public NetworkSystemClockContextWriter(TimeSharedMemory sharedMemory) { @@ -11,7 +11,7 @@ protected override ResultCode Update() { - _sharedMemory.UpdateNetworkSystemClockContext(_context); + _sharedMemory.UpdateNetworkSystemClockContext(Context); return ResultCode.Success; } diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardLocalSystemClockCore.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardLocalSystemClockCore.cs index 20c334e8..458ec405 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardLocalSystemClockCore.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardLocalSystemClockCore.cs @@ -2,6 +2,6 @@ { class StandardLocalSystemClockCore : SystemClockCore { - public StandardLocalSystemClockCore(StandardSteadyClockCore steadyClockCore) : base(steadyClockCore) {} + public StandardLocalSystemClockCore(StandardSteadyClockCore steadyClockCore) : base(steadyClockCore) { } } } diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardNetworkSystemClockCore.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardNetworkSystemClockCore.cs index aec03485..200ab630 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardNetworkSystemClockCore.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardNetworkSystemClockCore.cs @@ -13,7 +13,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock public bool IsStandardNetworkSystemClockAccuracySufficient(ITickSource tickSource) { - SteadyClockCore steadyClockCore = GetSteadyClockCore(); + SteadyClockCore steadyClockCore = GetSteadyClockCore(); SteadyClockTimePoint currentTimePoint = steadyClockCore.GetCurrentTimePoint(tickSource); bool isStandardNetworkClockSufficientAccuracy = false; diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardSteadyClockCore.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardSteadyClockCore.cs index 8392c4b5..3ae699ae 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardSteadyClockCore.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardSteadyClockCore.cs @@ -11,18 +11,18 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock public StandardSteadyClockCore() { - _setupValue = TimeSpanType.Zero; - _testOffset = TimeSpanType.Zero; - _internalOffset = TimeSpanType.Zero; + _setupValue = TimeSpanType.Zero; + _testOffset = TimeSpanType.Zero; + _internalOffset = TimeSpanType.Zero; _cachedRawTimePoint = TimeSpanType.Zero; } public override SteadyClockTimePoint GetTimePoint(ITickSource tickSource) { - SteadyClockTimePoint result = new SteadyClockTimePoint + SteadyClockTimePoint result = new() { - TimePoint = GetCurrentRawTimePoint(tickSource).ToSeconds(), - ClockSourceId = GetClockSourceId() + TimePoint = GetCurrentRawTimePoint(tickSource).ToSeconds(), + ClockSourceId = GetClockSourceId(), }; return result; @@ -52,7 +52,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock { TimeSpanType ticksTimeSpan = TimeSpanType.FromTicks(tickSource.Counter, tickSource.Frequency); - TimeSpanType rawTimePoint = new TimeSpanType(_setupValue.NanoSeconds + ticksTimeSpan.NanoSeconds); + TimeSpanType rawTimePoint = new(_setupValue.NanoSeconds + ticksTimeSpan.NanoSeconds); if (rawTimePoint.NanoSeconds < _cachedRawTimePoint.NanoSeconds) { diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardUserSystemClockCore.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardUserSystemClockCore.cs index fa485437..e50ee7da 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardUserSystemClockCore.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardUserSystemClockCore.cs @@ -6,19 +6,19 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock { class StandardUserSystemClockCore : SystemClockCore { - private StandardLocalSystemClockCore _localSystemClockCore; - private StandardNetworkSystemClockCore _networkSystemClockCore; - private bool _autoCorrectionEnabled; - private SteadyClockTimePoint _autoCorrectionTime; - private KEvent _autoCorrectionEvent; + private readonly StandardLocalSystemClockCore _localSystemClockCore; + private readonly StandardNetworkSystemClockCore _networkSystemClockCore; + private bool _autoCorrectionEnabled; + private SteadyClockTimePoint _autoCorrectionTime; + private KEvent _autoCorrectionEvent; public StandardUserSystemClockCore(StandardLocalSystemClockCore localSystemClockCore, StandardNetworkSystemClockCore networkSystemClockCore) : base(localSystemClockCore.GetSteadyClockCore()) { - _localSystemClockCore = localSystemClockCore; + _localSystemClockCore = localSystemClockCore; _networkSystemClockCore = networkSystemClockCore; - _autoCorrectionEnabled = false; - _autoCorrectionTime = SteadyClockTimePoint.GetRandom(); - _autoCorrectionEvent = null; + _autoCorrectionEnabled = false; + _autoCorrectionTime = SteadyClockTimePoint.GetRandom(); + _autoCorrectionEvent = null; } protected override ResultCode Flush(SystemClockContext context) diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/SteadyClockCore.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/SteadyClockCore.cs index 18da4ed3..2d12a2a0 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/SteadyClockCore.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/SteadyClockCore.cs @@ -7,14 +7,14 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock abstract class SteadyClockCore { private UInt128 _clockSourceId; - private bool _isRtcResetDetected; - private bool _isInitialized; + private bool _isRtcResetDetected; + private bool _isInitialized; public SteadyClockCore() { - _clockSourceId = UInt128Utils.CreateRandom(); + _clockSourceId = UInt128Utils.CreateRandom(); _isRtcResetDetected = false; - _isInitialized = false; + _isInitialized = false; } public UInt128 GetClockSourceId() @@ -37,7 +37,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock return new TimeSpanType(0); } - public virtual void SetTestOffset(TimeSpanType testOffset) {} + public virtual void SetTestOffset(TimeSpanType testOffset) { } public ResultCode GetRtcValue(out ulong rtcValue) { @@ -61,7 +61,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock return new TimeSpanType(0); } - public virtual void SetInternalOffset(TimeSpanType internalOffset) {} + public virtual void SetInternalOffset(TimeSpanType internalOffset) { } public virtual SteadyClockTimePoint GetTimePoint(ITickSource tickSource) { diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/SystemClockContextUpdateCallback.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/SystemClockContextUpdateCallback.cs index 6229f5ed..3f191820 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/SystemClockContextUpdateCallback.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/SystemClockContextUpdateCallback.cs @@ -6,22 +6,22 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock { abstract class SystemClockContextUpdateCallback { - private List<KWritableEvent> _operationEventList; - protected SystemClockContext _context; - private bool _hasContext; + private readonly List<KWritableEvent> _operationEventList; + protected SystemClockContext Context; + private bool _hasContext; public SystemClockContextUpdateCallback() { _operationEventList = new List<KWritableEvent>(); - _context = new SystemClockContext(); - _hasContext = false; + Context = new SystemClockContext(); + _hasContext = false; } private bool NeedUpdate(SystemClockContext context) { if (_hasContext) { - return _context.Offset != context.Offset || _context.SteadyTimePoint.ClockSourceId != context.SteadyTimePoint.ClockSourceId; + return Context.Offset != context.Offset || Context.SteadyTimePoint.ClockSourceId != context.SteadyTimePoint.ClockSourceId; } return true; @@ -54,7 +54,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock if (NeedUpdate(context)) { - _context = context; + Context = context; _hasContext = true; result = Update(); diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/SystemClockCore.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/SystemClockCore.cs index f4bbaa60..f8a995b7 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/SystemClockCore.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/SystemClockCore.cs @@ -5,19 +5,19 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock { abstract class SystemClockCore { - private SteadyClockCore _steadyClockCore; - private SystemClockContext _context; - private bool _isInitialized; + private readonly SteadyClockCore _steadyClockCore; + private SystemClockContext _context; + private bool _isInitialized; private SystemClockContextUpdateCallback _systemClockContextUpdateCallback; public SystemClockCore(SteadyClockCore steadyClockCore) { _steadyClockCore = steadyClockCore; - _context = new SystemClockContext(); - _isInitialized = false; + _context = new SystemClockContext(); + _isInitialized = false; _context.SteadyTimePoint.ClockSourceId = steadyClockCore.GetClockSourceId(); - _systemClockContextUpdateCallback = null; + _systemClockContextUpdateCallback = null; } public virtual SteadyClockCore GetSteadyClockCore() @@ -52,10 +52,10 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock { SteadyClockTimePoint currentTimePoint = _steadyClockCore.GetCurrentTimePoint(tickSource); - SystemClockContext clockContext = new SystemClockContext() + SystemClockContext clockContext = new() { - Offset = posixTime - currentTimePoint.TimePoint, - SteadyTimePoint = currentTimePoint + Offset = posixTime - currentTimePoint.TimePoint, + SteadyTimePoint = currentTimePoint, }; ResultCode result = SetClockContext(clockContext); @@ -99,10 +99,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock public void RegisterOperationEvent(KWritableEvent writableEvent) { - if (_systemClockContextUpdateCallback != null) - { - _systemClockContextUpdateCallback.RegisterOperationEvent(writableEvent); - } + _systemClockContextUpdateCallback?.RegisterOperationEvent(writableEvent); } public ResultCode SetSystemClockContext(SystemClockContext context) diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/TickBasedSteadyClockCore.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/TickBasedSteadyClockCore.cs index fe74da7e..99e981ec 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/TickBasedSteadyClockCore.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/TickBasedSteadyClockCore.cs @@ -4,14 +4,14 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock { class TickBasedSteadyClockCore : SteadyClockCore { - public TickBasedSteadyClockCore() {} + public TickBasedSteadyClockCore() { } public override SteadyClockTimePoint GetTimePoint(ITickSource tickSource) { - SteadyClockTimePoint result = new SteadyClockTimePoint + SteadyClockTimePoint result = new() { - TimePoint = 0, - ClockSourceId = GetClockSourceId() + TimePoint = 0, + ClockSourceId = GetClockSourceId(), }; TimeSpanType ticksTimeSpan = TimeSpanType.FromTicks(tickSource.Counter, tickSource.Frequency); diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/ClockSnapshot.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/ClockSnapshot.cs index 07c1b405..d0a74a93 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/ClockSnapshot.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/ClockSnapshot.cs @@ -7,23 +7,23 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock [StructLayout(LayoutKind.Sequential, Size = 0xD0)] struct ClockSnapshot { - public SystemClockContext UserContext; - public SystemClockContext NetworkContext; - public long UserTime; - public long NetworkTime; - public CalendarTime UserCalendarTime; - public CalendarTime NetworkCalendarTime; + public SystemClockContext UserContext; + public SystemClockContext NetworkContext; + public long UserTime; + public long NetworkTime; + public CalendarTime UserCalendarTime; + public CalendarTime NetworkCalendarTime; public CalendarAdditionalInfo UserCalendarAdditionalTime; public CalendarAdditionalInfo NetworkCalendarAdditionalTime; - public SteadyClockTimePoint SteadyClockTimePoint; + public SteadyClockTimePoint SteadyClockTimePoint; private LocationNameStorageHolder _locationName; public Span<byte> LocationName => MemoryMarshal.Cast<LocationNameStorageHolder, byte>(MemoryMarshal.CreateSpan(ref _locationName, LocationNameStorageHolder.Size)); [MarshalAs(UnmanagedType.I1)] - public bool IsAutomaticCorrectionEnabled; - public byte Type; + public bool IsAutomaticCorrectionEnabled; + public byte Type; public ushort Unknown; @@ -47,4 +47,4 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock return ResultCode.TimeMismatch; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/SteadyClockTimePoint.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/SteadyClockTimePoint.cs index 729e11b6..2bc99ff8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/SteadyClockTimePoint.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/SteadyClockTimePoint.cs @@ -7,10 +7,10 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock [StructLayout(LayoutKind.Sequential, Pack = 1)] struct SteadyClockTimePoint { - public long TimePoint; + public long TimePoint; public UInt128 ClockSourceId; - public ResultCode GetSpanBetween(SteadyClockTimePoint other, out long outSpan) + public readonly ResultCode GetSpanBetween(SteadyClockTimePoint other, out long outSpan) { outSpan = 0; @@ -35,9 +35,9 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock { return new SteadyClockTimePoint { - TimePoint = 0, - ClockSourceId = UInt128Utils.CreateRandom() + TimePoint = 0, + ClockSourceId = UInt128Utils.CreateRandom(), }; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/SystemClockContext.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/SystemClockContext.cs index 6b589c28..fc47e775 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/SystemClockContext.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/SystemClockContext.cs @@ -5,7 +5,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock [StructLayout(LayoutKind.Sequential, Pack = 1)] struct SystemClockContext { - public long Offset; + public long Offset; public SteadyClockTimePoint SteadyTimePoint; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/TimeSpanType.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/TimeSpanType.cs index 0070193f..a7ef8115 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/TimeSpanType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/TimeSpanType.cs @@ -8,7 +8,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock { private const long NanoSecondsPerSecond = 1000000000; - public static readonly TimeSpanType Zero = new TimeSpanType(0); + public static readonly TimeSpanType Zero = new(0); public long NanoSeconds; @@ -17,17 +17,17 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock NanoSeconds = nanoSeconds; } - public long ToSeconds() + public readonly long ToSeconds() { return NanoSeconds / NanoSecondsPerSecond; } - public TimeSpanType AddSeconds(long seconds) + public readonly TimeSpanType AddSeconds(long seconds) { return new TimeSpanType(NanoSeconds + (seconds * NanoSecondsPerSecond)); } - public bool IsDaylightSavingTime() + public readonly bool IsDaylightSavingTime() { return DateTime.UnixEpoch.AddSeconds(ToSeconds()).ToLocalTime().IsDaylightSavingTime(); } @@ -47,4 +47,4 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock return FromSeconds((long)ticks / (long)frequency); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Time/IAlarmService.cs b/src/Ryujinx.HLE/HOS/Services/Time/IAlarmService.cs index 092fa8ce..46b58408 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/IAlarmService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/IAlarmService.cs @@ -5,4 +5,4 @@ { public IAlarmService(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Time/IPowerStateRequestHandler.cs b/src/Ryujinx.HLE/HOS/Services/Time/IPowerStateRequestHandler.cs index 8ec55c15..64b7e69c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/IPowerStateRequestHandler.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/IPowerStateRequestHandler.cs @@ -5,4 +5,4 @@ { public IPowerStateRequestHandler(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForGlue.cs b/src/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForGlue.cs index 31548b80..32aed90c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForGlue.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForGlue.cs @@ -12,13 +12,13 @@ namespace Ryujinx.HLE.HOS.Services.Time [Service("time:u", TimePermissions.User)] class IStaticServiceForGlue : IpcService { - private IStaticServiceForPsc _inner; - private TimePermissions _permissions; + private readonly IStaticServiceForPsc _inner; + private readonly TimePermissions _permissions; public IStaticServiceForGlue(ServiceCtx context, TimePermissions permissions) : base(context.Device.System.TimeServer) { _permissions = permissions; - _inner = new IStaticServiceForPsc(context, permissions); + _inner = new IStaticServiceForPsc(context, permissions); _inner.TrySetServer(Server); _inner.SetParent(this); } @@ -83,7 +83,9 @@ namespace Ryujinx.HLE.HOS.Services.Time return ResultCode.PermissionDenied; } +#pragma warning disable IDE0059 // Remove unnecessary value assignment TimeSpanType internalOffset = context.RequestData.ReadStruct<TimeSpanType>(); +#pragma warning restore IDE0059 // TODO: set:sys SetExternalSteadyClockInternalOffset(internalOffset.ToSeconds()) diff --git a/src/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForPsc.cs b/src/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForPsc.cs index 145d4e3b..a6b33e4a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForPsc.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForPsc.cs @@ -18,12 +18,12 @@ namespace Ryujinx.HLE.HOS.Services.Time [Service("time:su", TimePermissions.SystemUpdate)] class IStaticServiceForPsc : IpcService { - private TimeManager _timeManager; - private TimePermissions _permissions; + private readonly TimeManager _timeManager; + private readonly TimePermissions _permissions; private int _timeSharedMemoryNativeHandle = 0; - public IStaticServiceForPsc(ServiceCtx context, TimePermissions permissions) : this(TimeManager.Instance, permissions) {} + public IStaticServiceForPsc(ServiceCtx context, TimePermissions permissions) : this(TimeManager.Instance, permissions) { } public IStaticServiceForPsc(TimeManager manager, TimePermissions permissions) { @@ -149,8 +149,8 @@ namespace Ryujinx.HLE.HOS.Services.Time // SetStandardUserSystemClockAutomaticCorrectionEnabled(b8) public ResultCode SetStandardUserSystemClockAutomaticCorrectionEnabled(ServiceCtx context) { - SteadyClockCore steadyClock = _timeManager.StandardSteadyClock; - StandardUserSystemClockCore userClock = _timeManager.StandardUserSystemClock; + SteadyClockCore steadyClock = _timeManager.StandardSteadyClock; + StandardUserSystemClockCore userClock = _timeManager.StandardUserSystemClock; if (!userClock.IsInitialized() || !steadyClock.IsInitialized()) { @@ -229,7 +229,7 @@ namespace Ryujinx.HLE.HOS.Services.Time ITickSource tickSource = context.Device.System.TickSource; - SystemClockContext otherContext = context.RequestData.ReadStruct<SystemClockContext>(); + SystemClockContext otherContext = context.RequestData.ReadStruct<SystemClockContext>(); SteadyClockTimePoint currentTimePoint = steadyClock.GetCurrentTimePoint(tickSource); ResultCode result = ResultCode.TimeMismatch; @@ -237,7 +237,7 @@ namespace Ryujinx.HLE.HOS.Services.Time if (currentTimePoint.ClockSourceId == otherContext.SteadyTimePoint.ClockSourceId) { TimeSpanType ticksTimeSpan = TimeSpanType.FromTicks(tickSource.Counter, tickSource.Frequency); - long baseTimePoint = otherContext.Offset + currentTimePoint.TimePoint - ticksTimeSpan.ToSeconds(); + long baseTimePoint = otherContext.Offset + currentTimePoint.TimePoint - ticksTimeSpan.ToSeconds(); context.ResponseData.Write(baseTimePoint); @@ -287,7 +287,7 @@ namespace Ryujinx.HLE.HOS.Services.Time context.RequestData.BaseStream.Position += 7; - SystemClockContext userContext = context.RequestData.ReadStruct<SystemClockContext>(); + SystemClockContext userContext = context.RequestData.ReadStruct<SystemClockContext>(); SystemClockContext networkContext = context.RequestData.ReadStruct<SystemClockContext>(); ITickSource tickSource = context.Device.System.TickSource; @@ -308,7 +308,7 @@ namespace Ryujinx.HLE.HOS.Services.Time { ClockSnapshot clockSnapshotA = ReadClockSnapshotFromBuffer(context, context.Request.PtrBuff[0]); ClockSnapshot clockSnapshotB = ReadClockSnapshotFromBuffer(context, context.Request.PtrBuff[1]); - TimeSpanType difference = TimeSpanType.FromSeconds(clockSnapshotB.UserContext.Offset - clockSnapshotA.UserContext.Offset); + TimeSpanType difference = TimeSpanType.FromSeconds(clockSnapshotB.UserContext.Offset - clockSnapshotA.UserContext.Offset); if (clockSnapshotB.UserContext.SteadyTimePoint.ClockSourceId != clockSnapshotA.UserContext.SteadyTimePoint.ClockSourceId || (clockSnapshotB.IsAutomaticCorrectionEnabled && clockSnapshotA.IsAutomaticCorrectionEnabled)) { @@ -337,7 +337,7 @@ namespace Ryujinx.HLE.HOS.Services.Time if (clockSnapshotA.NetworkTime != 0 && clockSnapshotB.NetworkTime != 0) { - result = TimeSpanType.FromSeconds(clockSnapshotB.NetworkTime - clockSnapshotA.NetworkTime); + result = TimeSpanType.FromSeconds(clockSnapshotB.NetworkTime - clockSnapshotA.NetworkTime); resultCode = ResultCode.Success; } else @@ -359,13 +359,13 @@ namespace Ryujinx.HLE.HOS.Services.Time { clockSnapshot = new ClockSnapshot(); - SteadyClockCore steadyClockCore = _timeManager.StandardSteadyClock; + SteadyClockCore steadyClockCore = _timeManager.StandardSteadyClock; SteadyClockTimePoint currentTimePoint = steadyClockCore.GetCurrentTimePoint(tickSource); clockSnapshot.IsAutomaticCorrectionEnabled = _timeManager.StandardUserSystemClock.IsAutomaticCorrectionEnabled(); - clockSnapshot.UserContext = userContext; - clockSnapshot.NetworkContext = networkContext; - clockSnapshot.SteadyClockTimePoint = currentTimePoint; + clockSnapshot.UserContext = userContext; + clockSnapshot.NetworkContext = networkContext; + clockSnapshot.SteadyClockTimePoint = currentTimePoint; ResultCode result = _timeManager.TimeZone.Manager.GetDeviceLocationName(out string deviceLocationName); @@ -386,7 +386,7 @@ namespace Ryujinx.HLE.HOS.Services.Time if (result == ResultCode.Success) { - clockSnapshot.UserCalendarTime = userCalendarInfo.Time; + clockSnapshot.UserCalendarTime = userCalendarInfo.Time; clockSnapshot.UserCalendarAdditionalTime = userCalendarInfo.AdditionalInfo; if (ClockSnapshot.GetCurrentTime(out clockSnapshot.NetworkTime, currentTimePoint, clockSnapshot.NetworkContext) != ResultCode.Success) @@ -398,9 +398,9 @@ namespace Ryujinx.HLE.HOS.Services.Time if (result == ResultCode.Success) { - clockSnapshot.NetworkCalendarTime = networkCalendarInfo.Time; + clockSnapshot.NetworkCalendarTime = networkCalendarInfo.Time; clockSnapshot.NetworkCalendarAdditionalTime = networkCalendarInfo.AdditionalInfo; - clockSnapshot.Type = type; + clockSnapshot.Type = type; // Probably a version field? clockSnapshot.Unknown = 0; @@ -419,10 +419,9 @@ namespace Ryujinx.HLE.HOS.Services.Time context.Memory.Read(ipcDesc.Position, temp); - using (BinaryReader bufferReader = new BinaryReader(new MemoryStream(temp))) - { - return bufferReader.ReadStruct<ClockSnapshot>(); - } + using BinaryReader bufferReader = new(new MemoryStream(temp)); + + return bufferReader.ReadStruct<ClockSnapshot>(); } private void WriteClockSnapshotFromBuffer(ServiceCtx context, IpcRecvListBuffDesc ipcDesc, ClockSnapshot clockSnapshot) @@ -430,4 +429,4 @@ namespace Ryujinx.HLE.HOS.Services.Time MemoryHelper.Write(context.Memory, ipcDesc.Position, clockSnapshot); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Time/ITimeServiceManager.cs b/src/Ryujinx.HLE/HOS/Services/Time/ITimeServiceManager.cs index 6c9c15f1..b690b708 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/ITimeServiceManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/ITimeServiceManager.cs @@ -13,12 +13,12 @@ namespace Ryujinx.HLE.HOS.Services.Time [Service("time:m")] // 9.0.0+ class ITimeServiceManager : IpcService { - private TimeManager _timeManager; - private int _automaticCorrectionEvent; + private readonly TimeManager _timeManager; + private int _automaticCorrectionEvent; public ITimeServiceManager(ServiceCtx context) { - _timeManager = TimeManager.Instance; + _timeManager = TimeManager.Instance; _automaticCorrectionEvent = 0; } @@ -62,11 +62,11 @@ namespace Ryujinx.HLE.HOS.Services.Time // SetupStandardSteadyClock(nn::util::Uuid clock_source_id, nn::TimeSpanType setup_value, nn::TimeSpanType internal_offset, nn::TimeSpanType test_offset, bool is_rtc_reset_detected) public ResultCode SetupStandardSteadyClock(ServiceCtx context) { - UInt128 clockSourceId = context.RequestData.ReadStruct<UInt128>(); - TimeSpanType setupValue = context.RequestData.ReadStruct<TimeSpanType>(); - TimeSpanType internalOffset = context.RequestData.ReadStruct<TimeSpanType>(); - TimeSpanType testOffset = context.RequestData.ReadStruct<TimeSpanType>(); - bool isRtcResetDetected = context.RequestData.ReadBoolean(); + UInt128 clockSourceId = context.RequestData.ReadStruct<UInt128>(); + TimeSpanType setupValue = context.RequestData.ReadStruct<TimeSpanType>(); + TimeSpanType internalOffset = context.RequestData.ReadStruct<TimeSpanType>(); + TimeSpanType testOffset = context.RequestData.ReadStruct<TimeSpanType>(); + bool isRtcResetDetected = context.RequestData.ReadBoolean(); ITickSource tickSource = context.Device.System.TickSource; @@ -80,7 +80,7 @@ namespace Ryujinx.HLE.HOS.Services.Time public ResultCode SetupStandardLocalSystemClock(ServiceCtx context) { SystemClockContext clockContext = context.RequestData.ReadStruct<SystemClockContext>(); - long posixTime = context.RequestData.ReadInt64(); + long posixTime = context.RequestData.ReadInt64(); ITickSource tickSource = context.Device.System.TickSource; @@ -93,8 +93,8 @@ namespace Ryujinx.HLE.HOS.Services.Time // SetupStandardNetworkSystemClock(nn::time::SystemClockContext context, nn::TimeSpanType sufficient_accuracy) public ResultCode SetupStandardNetworkSystemClock(ServiceCtx context) { - SystemClockContext clockContext = context.RequestData.ReadStruct<SystemClockContext>(); - TimeSpanType sufficientAccuracy = context.RequestData.ReadStruct<TimeSpanType>(); + SystemClockContext clockContext = context.RequestData.ReadStruct<SystemClockContext>(); + TimeSpanType sufficientAccuracy = context.RequestData.ReadStruct<TimeSpanType>(); _timeManager.SetupStandardNetworkSystemClock(clockContext, sufficientAccuracy); @@ -122,10 +122,10 @@ namespace Ryujinx.HLE.HOS.Services.Time // SetupTimeZoneManager(nn::time::LocationName location_name, nn::time::SteadyClockTimePoint timezone_update_timepoint, u32 total_location_name_count, nn::time::TimeZoneRuleVersion timezone_rule_version, buffer<nn::time::TimeZoneBinary, 0x21> timezone_binary) public ResultCode SetupTimeZoneManager(ServiceCtx context) { - string locationName = StringUtils.ReadInlinedAsciiString(context.RequestData, 0x24); + string locationName = StringUtils.ReadInlinedAsciiString(context.RequestData, 0x24); SteadyClockTimePoint timeZoneUpdateTimePoint = context.RequestData.ReadStruct<SteadyClockTimePoint>(); - uint totalLocationNameCount = context.RequestData.ReadUInt32(); - UInt128 timeZoneRuleVersion = context.RequestData.ReadStruct<UInt128>(); + uint totalLocationNameCount = context.RequestData.ReadUInt32(); + UInt128 timeZoneRuleVersion = context.RequestData.ReadStruct<UInt128>(); (ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x21(); @@ -133,10 +133,9 @@ namespace Ryujinx.HLE.HOS.Services.Time context.Memory.Read(bufferPosition, temp); - using (MemoryStream timeZoneBinaryStream = new MemoryStream(temp)) - { - _timeManager.SetupTimeZoneManager(locationName, timeZoneUpdateTimePoint, totalLocationNameCount, timeZoneRuleVersion, timeZoneBinaryStream); - } + using MemoryStream timeZoneBinaryStream = new(temp); + + _timeManager.SetupTimeZoneManager(locationName, timeZoneUpdateTimePoint, totalLocationNameCount, timeZoneRuleVersion, timeZoneBinaryStream); return ResultCode.Success; } diff --git a/src/Ryujinx.HLE/HOS/Services/Time/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Time/ResultCode.cs index 3b042ec0..66ae6751 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/ResultCode.cs @@ -1,24 +1,27 @@ -namespace Ryujinx.HLE.HOS.Services.Time +using System.Diagnostics.CodeAnalysis; + +namespace Ryujinx.HLE.HOS.Services.Time { + [SuppressMessage("Design", "CA1069: Enums values should not be duplicated")] public enum ResultCode { - ModuleId = 116, + ModuleId = 116, ErrorCodeShift = 9, Success = 0, - TimeServiceNotInitialized = (0 << ErrorCodeShift) | ModuleId, - PermissionDenied = (1 << ErrorCodeShift) | ModuleId, - TimeMismatch = (102 << ErrorCodeShift) | ModuleId, - UninitializedClock = (103 << ErrorCodeShift) | ModuleId, - TimeNotFound = (200 << ErrorCodeShift) | ModuleId, - Overflow = (201 << ErrorCodeShift) | ModuleId, - LocationNameTooLong = (801 << ErrorCodeShift) | ModuleId, - OutOfRange = (902 << ErrorCodeShift) | ModuleId, - TimeZoneConversionFailed = (903 << ErrorCodeShift) | ModuleId, - TimeZoneNotFound = (989 << ErrorCodeShift) | ModuleId, - NotImplemented = (990 << ErrorCodeShift) | ModuleId, - NetworkTimeNotAvailable = (1000 << ErrorCodeShift) | ModuleId, - NetworkTimeTaskCanceled = (1003 << ErrorCodeShift) | ModuleId, + TimeServiceNotInitialized = (0 << ErrorCodeShift) | ModuleId, + PermissionDenied = (1 << ErrorCodeShift) | ModuleId, + TimeMismatch = (102 << ErrorCodeShift) | ModuleId, + UninitializedClock = (103 << ErrorCodeShift) | ModuleId, + TimeNotFound = (200 << ErrorCodeShift) | ModuleId, + Overflow = (201 << ErrorCodeShift) | ModuleId, + LocationNameTooLong = (801 << ErrorCodeShift) | ModuleId, + OutOfRange = (902 << ErrorCodeShift) | ModuleId, + TimeZoneConversionFailed = (903 << ErrorCodeShift) | ModuleId, + TimeZoneNotFound = (989 << ErrorCodeShift) | ModuleId, + NotImplemented = (990 << ErrorCodeShift) | ModuleId, + NetworkTimeNotAvailable = (1000 << ErrorCodeShift) | ModuleId, + NetworkTimeTaskCanceled = (1003 << ErrorCodeShift) | ModuleId, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Time/StaticService/ISteadyClock.cs b/src/Ryujinx.HLE/HOS/Services/Time/StaticService/ISteadyClock.cs index 97d7884e..8ddb646b 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/StaticService/ISteadyClock.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/StaticService/ISteadyClock.cs @@ -6,14 +6,14 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService { class ISteadyClock : IpcService { - private SteadyClockCore _steadyClock; - private bool _writePermission; - private bool _bypassUninitializedClock; + private readonly SteadyClockCore _steadyClock; + private readonly bool _writePermission; + private readonly bool _bypassUninitializedClock; public ISteadyClock(SteadyClockCore steadyClock, bool writePermission, bool bypassUninitializedClock) { - _steadyClock = steadyClock; - _writePermission = writePermission; + _steadyClock = steadyClock; + _writePermission = writePermission; _bypassUninitializedClock = bypassUninitializedClock; } @@ -152,4 +152,4 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Time/StaticService/ISystemClock.cs b/src/Ryujinx.HLE/HOS/Services/Time/StaticService/ISystemClock.cs index 3cd0a4a6..ada5f057 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/StaticService/ISystemClock.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/StaticService/ISystemClock.cs @@ -10,16 +10,16 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService { class ISystemClock : IpcService { - private SystemClockCore _clockCore; - private bool _writePermission; - private bool _bypassUninitializedClock; - private int _operationEventReadableHandle; + private readonly SystemClockCore _clockCore; + private readonly bool _writePermission; + private readonly bool _bypassUninitializedClock; + private int _operationEventReadableHandle; public ISystemClock(SystemClockCore clockCore, bool writePermission, bool bypassUninitializedClock) { - _clockCore = clockCore; - _writePermission = writePermission; - _bypassUninitializedClock = bypassUninitializedClock; + _clockCore = clockCore; + _writePermission = writePermission; + _bypassUninitializedClock = bypassUninitializedClock; _operationEventReadableHandle = 0; } @@ -113,7 +113,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService { if (_operationEventReadableHandle == 0) { - KEvent kEvent = new KEvent(context.Device.System.KernelContext); + KEvent kEvent = new(context.Device.System.KernelContext); _clockCore.RegisterOperationEvent(kEvent.WritableEvent); @@ -128,4 +128,4 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Time/StaticService/ITimeZoneServiceForGlue.cs b/src/Ryujinx.HLE/HOS/Services/Time/StaticService/ITimeZoneServiceForGlue.cs index 96a7e604..81944c83 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/StaticService/ITimeZoneServiceForGlue.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/StaticService/ITimeZoneServiceForGlue.cs @@ -12,15 +12,15 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService { class ITimeZoneServiceForGlue : IpcService { - private TimeZoneContentManager _timeZoneContentManager; - private ITimeZoneServiceForPsc _inner; - private bool _writePermission; + private readonly TimeZoneContentManager _timeZoneContentManager; + private readonly ITimeZoneServiceForPsc _inner; + private readonly bool _writePermission; public ITimeZoneServiceForGlue(TimeZoneContentManager timeZoneContentManager, bool writePermission) { _timeZoneContentManager = timeZoneContentManager; - _writePermission = writePermission; - _inner = new ITimeZoneServiceForPsc(timeZoneContentManager.Manager, writePermission); + _writePermission = writePermission; + _inner = new ITimeZoneServiceForPsc(timeZoneContentManager.Manager, writePermission); } [CommandCmif(0)] @@ -55,9 +55,9 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService // LoadLocationNameList(u32 index) -> (u32 outCount, buffer<nn::time::LocationName, 6>) public ResultCode LoadLocationNameList(ServiceCtx context) { - uint index = context.RequestData.ReadUInt32(); + uint index = context.RequestData.ReadUInt32(); ulong bufferPosition = context.Request.ReceiveBuff[0].Position; - ulong bufferSize = context.Request.ReceiveBuff[0].Size; + ulong bufferSize = context.Request.ReceiveBuff[0].Size; ResultCode errorCode = _timeZoneContentManager.LoadLocationNameList(index, out string[] locationNameArray, (uint)bufferSize / 0x24); @@ -91,7 +91,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService public ResultCode LoadTimeZoneRule(ServiceCtx context) { ulong bufferPosition = context.Request.ReceiveBuff[0].Position; - ulong bufferSize = context.Request.ReceiveBuff[0].Size; + ulong bufferSize = context.Request.ReceiveBuff[0].Size; if (bufferSize != 0x4000) { @@ -103,12 +103,11 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService string locationName = StringUtils.ReadInlinedAsciiString(context.RequestData, 0x24); - using (WritableRegion region = context.Memory.GetWritableRegion(bufferPosition, Unsafe.SizeOf<TimeZoneRule>())) - { - ref TimeZoneRule rules = ref MemoryMarshal.Cast<byte, TimeZoneRule>(region.Memory.Span)[0]; + using WritableRegion region = context.Memory.GetWritableRegion(bufferPosition, Unsafe.SizeOf<TimeZoneRule>()); - return _timeZoneContentManager.LoadTimeZoneRule(ref rules, locationName); - } + ref TimeZoneRule rules = ref MemoryMarshal.Cast<byte, TimeZoneRule>(region.Memory.Span)[0]; + + return _timeZoneContentManager.LoadTimeZoneRule(ref rules, locationName); } [CommandCmif(100)] @@ -139,4 +138,4 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService return _inner.ToPosixTimeWithMyRule(context); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Time/StaticService/ITimeZoneServiceForPsc.cs b/src/Ryujinx.HLE/HOS/Services/Time/StaticService/ITimeZoneServiceForPsc.cs index 3c9ac71f..b3a87b8a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/StaticService/ITimeZoneServiceForPsc.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/StaticService/ITimeZoneServiceForPsc.cs @@ -14,8 +14,8 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService { class ITimeZoneServiceForPsc : IpcService { - private TimeZoneManager _timeZoneManager; - private bool _writePermission; + private readonly TimeZoneManager _timeZoneManager; + private readonly bool _writePermission; public ITimeZoneServiceForPsc(TimeZoneManager timeZoneManager, bool writePermission) { @@ -134,10 +134,8 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService context.Memory.Read(bufferPosition, temp); - using (MemoryStream timeZoneBinaryStream = new MemoryStream(temp)) - { - result = _timeZoneManager.SetDeviceLocationNameWithTimeZoneRule(locationName, timeZoneBinaryStream); - } + using MemoryStream timeZoneBinaryStream = new(temp); + result = _timeZoneManager.SetDeviceLocationNameWithTimeZoneRule(locationName, timeZoneBinaryStream); return result; } @@ -149,7 +147,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService (ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x21(); ulong timeZoneRuleBufferPosition = context.Request.ReceiveBuff[0].Position; - ulong timeZoneRuleBufferSize = context.Request.ReceiveBuff[0].Size; + ulong timeZoneRuleBufferSize = context.Request.ReceiveBuff[0].Size; if (timeZoneRuleBufferSize != 0x4000) { @@ -165,15 +163,12 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService context.Memory.Read(bufferPosition, temp); - using (MemoryStream timeZoneBinaryStream = new MemoryStream(temp)) - { - using (WritableRegion region = context.Memory.GetWritableRegion(timeZoneRuleBufferPosition, Unsafe.SizeOf<TimeZoneRule>())) - { - ref TimeZoneRule rule = ref MemoryMarshal.Cast<byte, TimeZoneRule>(region.Memory.Span)[0]; + using MemoryStream timeZoneBinaryStream = new(temp); + using WritableRegion region = context.Memory.GetWritableRegion(timeZoneRuleBufferPosition, Unsafe.SizeOf<TimeZoneRule>()); - result = _timeZoneManager.ParseTimeZoneRuleBinary(ref rule, timeZoneBinaryStream); - } - } + ref TimeZoneRule rule = ref MemoryMarshal.Cast<byte, TimeZoneRule>(region.Memory.Span)[0]; + + result = _timeZoneManager.ParseTimeZoneRuleBinary(ref rule, timeZoneBinaryStream); return result; } @@ -189,9 +184,9 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService // ToCalendarTime(nn::time::PosixTime time, buffer<nn::time::TimeZoneRule, 0x15> rules) -> (nn::time::CalendarTime, nn::time::sf::CalendarAdditionalInfo) public ResultCode ToCalendarTime(ServiceCtx context) { - long posixTime = context.RequestData.ReadInt64(); + long posixTime = context.RequestData.ReadInt64(); ulong bufferPosition = context.Request.SendBuff[0].Position; - ulong bufferSize = context.Request.SendBuff[0].Size; + ulong bufferSize = context.Request.SendBuff[0].Size; if (bufferSize != 0x4000) { @@ -234,7 +229,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService public ResultCode ToPosixTime(ServiceCtx context) { ulong inBufferPosition = context.Request.SendBuff[0].Position; - ulong inBufferSize = context.Request.SendBuff[0].Size; + ulong inBufferSize = context.Request.SendBuff[0].Size; CalendarTime calendarTime = context.RequestData.ReadStruct<CalendarTime>(); @@ -253,7 +248,9 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService if (resultCode == ResultCode.Success) { ulong outBufferPosition = context.Request.RecvListBuff[0].Position; - ulong outBufferSize = context.Request.RecvListBuff[0].Size; +#pragma warning disable IDE0059 // Remove unnecessary value assignment + ulong outBufferSize = context.Request.RecvListBuff[0].Size; +#pragma warning restore IDE0059 context.Memory.Write(outBufferPosition, posixTime); context.ResponseData.Write(1); @@ -273,7 +270,9 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService if (resultCode == ResultCode.Success) { ulong outBufferPosition = context.Request.RecvListBuff[0].Position; - ulong outBufferSize = context.Request.RecvListBuff[0].Size; +#pragma warning disable IDE0059 // Remove unnecessary value assignment + ulong outBufferSize = context.Request.RecvListBuff[0].Size; +#pragma warning restore IDE0059 context.Memory.Write(outBufferPosition, posixTime); diff --git a/src/Ryujinx.HLE/HOS/Services/Time/TimeManager.cs b/src/Ryujinx.HLE/HOS/Services/Time/TimeManager.cs index e3b65f2a..53c052e4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/TimeManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/TimeManager.cs @@ -16,41 +16,38 @@ namespace Ryujinx.HLE.HOS.Services.Time { get { - if (_instance == null) - { - _instance = new TimeManager(); - } + _instance ??= new TimeManager(); return _instance; } } - public StandardSteadyClockCore StandardSteadyClock { get; } - public TickBasedSteadyClockCore TickBasedSteadyClock { get; } - public StandardLocalSystemClockCore StandardLocalSystemClock { get; } - public StandardNetworkSystemClockCore StandardNetworkSystemClock { get; } - public StandardUserSystemClockCore StandardUserSystemClock { get; } - public TimeZoneContentManager TimeZone { get; } - public EphemeralNetworkSystemClockCore EphemeralNetworkSystemClock { get; } - public TimeSharedMemory SharedMemory { get; } - public LocalSystemClockContextWriter LocalClockContextWriter { get; } - public NetworkSystemClockContextWriter NetworkClockContextWriter { get; } + public StandardSteadyClockCore StandardSteadyClock { get; } + public TickBasedSteadyClockCore TickBasedSteadyClock { get; } + public StandardLocalSystemClockCore StandardLocalSystemClock { get; } + public StandardNetworkSystemClockCore StandardNetworkSystemClock { get; } + public StandardUserSystemClockCore StandardUserSystemClock { get; } + public TimeZoneContentManager TimeZone { get; } + public EphemeralNetworkSystemClockCore EphemeralNetworkSystemClock { get; } + public TimeSharedMemory SharedMemory { get; } + public LocalSystemClockContextWriter LocalClockContextWriter { get; } + public NetworkSystemClockContextWriter NetworkClockContextWriter { get; } public EphemeralNetworkSystemClockContextWriter EphemeralClockContextWriter { get; } // TODO: 9.0.0+ power states and alarms public TimeManager() { - StandardSteadyClock = new StandardSteadyClockCore(); - TickBasedSteadyClock = new TickBasedSteadyClockCore(); - StandardLocalSystemClock = new StandardLocalSystemClockCore(StandardSteadyClock); - StandardNetworkSystemClock = new StandardNetworkSystemClockCore(StandardSteadyClock); - StandardUserSystemClock = new StandardUserSystemClockCore(StandardLocalSystemClock, StandardNetworkSystemClock); - TimeZone = new TimeZoneContentManager(); + StandardSteadyClock = new StandardSteadyClockCore(); + TickBasedSteadyClock = new TickBasedSteadyClockCore(); + StandardLocalSystemClock = new StandardLocalSystemClockCore(StandardSteadyClock); + StandardNetworkSystemClock = new StandardNetworkSystemClockCore(StandardSteadyClock); + StandardUserSystemClock = new StandardUserSystemClockCore(StandardLocalSystemClock, StandardNetworkSystemClock); + TimeZone = new TimeZoneContentManager(); EphemeralNetworkSystemClock = new EphemeralNetworkSystemClockCore(TickBasedSteadyClock); - SharedMemory = new TimeSharedMemory(); - LocalClockContextWriter = new LocalSystemClockContextWriter(SharedMemory); - NetworkClockContextWriter = new NetworkSystemClockContextWriter(SharedMemory); + SharedMemory = new TimeSharedMemory(); + LocalClockContextWriter = new LocalSystemClockContextWriter(SharedMemory); + NetworkClockContextWriter = new NetworkSystemClockContextWriter(SharedMemory); EphemeralClockContextWriter = new EphemeralNetworkSystemClockContextWriter(); } diff --git a/src/Ryujinx.HLE/HOS/Services/Time/TimeSharedMemory.cs b/src/Ryujinx.HLE/HOS/Services/Time/TimeSharedMemory.cs index 6b1e1687..75479a17 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/TimeSharedMemory.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/TimeSharedMemory.cs @@ -11,10 +11,12 @@ namespace Ryujinx.HLE.HOS.Services.Time { class TimeSharedMemory { - private Switch _device; - private KSharedMemory _sharedMemory; + private Switch _device; + private KSharedMemory _sharedMemory; private SharedMemoryStorage _timeSharedMemoryStorage; - private int _timeSharedMemorySize; +#pragma warning disable IDE0052 // Remove unread private member + private int _timeSharedMemorySize; +#pragma warning restore IDE0052 private const uint SteadyClockContextOffset = 0x00; private const uint LocalSystemClockContextOffset = 0x38; @@ -24,10 +26,10 @@ namespace Ryujinx.HLE.HOS.Services.Time public void Initialize(Switch device, KSharedMemory sharedMemory, SharedMemoryStorage timeSharedMemoryStorage, int timeSharedMemorySize) { - _device = device; - _sharedMemory = sharedMemory; + _device = device; + _sharedMemory = sharedMemory; _timeSharedMemoryStorage = timeSharedMemoryStorage; - _timeSharedMemorySize = timeSharedMemorySize; + _timeSharedMemorySize = timeSharedMemorySize; // Clean the shared memory timeSharedMemoryStorage.ZeroFill(); @@ -60,7 +62,7 @@ namespace Ryujinx.HLE.HOS.Services.Time { TimeSpanType ticksTimeSpan = TimeSpanType.FromTicks(tickSource.Counter, tickSource.Frequency); - ContinuousAdjustmentTimePoint adjustmentTimePoint = new ContinuousAdjustmentTimePoint + ContinuousAdjustmentTimePoint adjustmentTimePoint = new() { ClockOffset = (ulong)ticksTimeSpan.NanoSeconds, Multiplier = 1, @@ -71,17 +73,17 @@ namespace Ryujinx.HLE.HOS.Services.Time SteadyTimePoint = new SteadyClockTimePoint { ClockSourceId = clockSourceId, - TimePoint = 0 - } - } + TimePoint = 0, + }, + }, }; WriteObjectToSharedMemory(ContinuousAdjustmentTimePointOffset, 4, adjustmentTimePoint); - SteadyClockContext context = new SteadyClockContext + SteadyClockContext context = new() { InternalOffset = (ulong)(currentTimePoint.NanoSeconds - ticksTimeSpan.NanoSeconds), - ClockSourceId = clockSourceId + ClockSourceId = clockSourceId, }; WriteObjectToSharedMemory(SteadyClockContextOffset, 4, context); @@ -99,7 +101,7 @@ namespace Ryujinx.HLE.HOS.Services.Time private T ReadObjectFromSharedMemory<T>(ulong offset, ulong padding) where T : unmanaged { - T result; + T result; uint index; uint possiblyNewIndex; diff --git a/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZone.cs b/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZone.cs index f7477e97..58ae1cd8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZone.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZone.cs @@ -8,36 +8,34 @@ using System.IO; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; - using static Ryujinx.HLE.HOS.Services.Time.TimeZone.TimeZoneRule; namespace Ryujinx.HLE.HOS.Services.Time.TimeZone { public class TimeZone { - private const int TimeTypeSize = 8; - private const int EpochYear = 1970; - private const int YearBase = 1900; - private const int EpochWeekDay = 4; + private const int TimeTypeSize = 8; + private const int EpochYear = 1970; + private const int YearBase = 1900; + private const int EpochWeekDay = 4; private const int SecondsPerMinute = 60; - private const int MinutesPerHour = 60; - private const int HoursPerDays = 24; - private const int DaysPerWekk = 7; - private const int DaysPerNYear = 365; - private const int DaysPerLYear = 366; - private const int MonthsPerYear = 12; - private const int SecondsPerHour = SecondsPerMinute * MinutesPerHour; - private const int SecondsPerDay = SecondsPerHour * HoursPerDays; - - private const int YearsPerRepeat = 400; + private const int MinutesPerHour = 60; + private const int HoursPerDays = 24; + private const int DaysPerWeek = 7; + private const int DaysPerNYear = 365; + private const int DaysPerLYear = 366; + private const int MonthsPerYear = 12; + private const int SecondsPerHour = SecondsPerMinute * MinutesPerHour; + private const int SecondsPerDay = SecondsPerHour * HoursPerDays; + + private const int YearsPerRepeat = 400; private const long AverageSecondsPerYear = 31556952; - private const long SecondsPerRepeat = YearsPerRepeat * AverageSecondsPerYear; + private const long SecondsPerRepeat = YearsPerRepeat * AverageSecondsPerYear; - private static readonly int[] YearLengths = { DaysPerNYear, DaysPerLYear }; - private static readonly int[][] MonthsLengths = new int[][] - { - new int[] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, - new int[] { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } + private static readonly int[] _yearLengths = { DaysPerNYear, DaysPerLYear }; + private static readonly int[][] _monthsLengths = { + new[] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, + new[] { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, }; private static ReadOnlySpan<byte> TimeZoneDefaultRule => ",M4.1.0,M10.5.0"u8; @@ -46,14 +44,14 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone private struct CalendarTimeInternal { // NOTE: On the IPC side this is supposed to be a 16 bits value but internally this need to be a 64 bits value for ToPosixTime. - public long Year; + public long Year; public sbyte Month; public sbyte Day; public sbyte Hour; public sbyte Minute; public sbyte Second; - public int CompareTo(CalendarTimeInternal other) + public readonly int CompareTo(CalendarTimeInternal other) { if (Year != other.Year) { @@ -98,16 +96,16 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone { JulianDay, DayOfYear, - MonthNthDayOfWeek + MonthNthDayOfWeek, } private struct Rule { public RuleType Type; - public int Day; - public int Week; - public int Month; - public int TransitionTime; + public int Day; + public int Week; + public int Month; + public int TransitionTime; } private static int Detzcode32(ReadOnlySpan<byte> bytes) @@ -145,10 +143,10 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone TimeTypeInfo a = outRules.Ttis[aIndex]; TimeTypeInfo b = outRules.Ttis[bIndex]; - return a.GmtOffset == b.GmtOffset && - a.IsDaySavingTime == b.IsDaySavingTime && + return a.GmtOffset == b.GmtOffset && + a.IsDaySavingTime == b.IsDaySavingTime && a.IsStandardTimeDaylight == b.IsStandardTimeDaylight && - a.IsGMT == b.IsGMT && + a.IsGMT == b.IsGMT && StringUtils.CompareCStr(outRules.Chars[a.AbbreviationListIndex..], outRules.Chars[b.AbbreviationListIndex..]) == 0; } @@ -224,7 +222,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone seconds = 0; - bool isValid = GetNum(name, ref namePosition, out int num, 0, HoursPerDays * DaysPerWekk - 1); + bool isValid = GetNum(name, ref namePosition, out int num, 0, HoursPerDays * DaysPerWeek - 1); if (!isValid) { return false; @@ -310,7 +308,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone { rule = new Rule(); - bool isValid = false; + bool isValid; if (name[namePosition] == 'J') { @@ -347,7 +345,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone return false; } - isValid = GetNum(name, ref namePosition, out rule.Day, 0, DaysPerWekk - 1); + isValid = GetNum(name, ref namePosition, out rule.Day, 0, DaysPerWeek - 1); } else if (char.IsDigit((char)name[namePosition])) { @@ -391,7 +389,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone { outRules = new TimeZoneRule(); - int stdLen; + int stdLen; ReadOnlySpan<byte> stdName = name; int namePosition = 0; @@ -408,7 +406,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone { namePosition++; - stdName = name.Slice(namePosition); + stdName = name[namePosition..]; int stdNamePosition = namePosition; @@ -442,10 +440,10 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone } int charCount = stdLen + 1; - int destLen = 0; + int destLen = 0; int dstOffset = 0; - ReadOnlySpan<byte> destName = name.Slice(namePosition); + ReadOnlySpan<byte> destName = name[namePosition..]; if (TzCharsArraySize < charCount) { @@ -456,7 +454,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone { if (name[namePosition] == '<') { - destName = name.Slice(++namePosition); + destName = name[++namePosition..]; int destNamePosition = namePosition; namePosition = GetQZName(name.ToArray(), namePosition, '>'); @@ -471,9 +469,9 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone } else { - destName = name.Slice(namePosition); + destName = name[namePosition..]; namePosition = GetTZName(name, namePosition); - destLen = namePosition; + destLen = namePosition; } if (destLen == 0) @@ -511,8 +509,8 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone { namePosition++; - bool IsRuleValid = GetRule(name, ref namePosition, out Rule start); - if (!IsRuleValid) + bool isRuleValid = GetRule(name, ref namePosition, out Rule start); + if (!isRuleValid) { return false; } @@ -522,8 +520,8 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone return false; } - IsRuleValid = GetRule(name, ref namePosition, out Rule end); - if (!IsRuleValid) + isRuleValid = GetRule(name, ref namePosition, out Rule end); + if (!isRuleValid) { return false; } @@ -537,28 +535,28 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone outRules.Ttis[0] = new TimeTypeInfo { - GmtOffset = -dstOffset, - IsDaySavingTime = true, - AbbreviationListIndex = stdLen + 1 + GmtOffset = -dstOffset, + IsDaySavingTime = true, + AbbreviationListIndex = stdLen + 1, }; outRules.Ttis[1] = new TimeTypeInfo { - GmtOffset = -stdOffset, - IsDaySavingTime = false, - AbbreviationListIndex = 0 + GmtOffset = -stdOffset, + IsDaySavingTime = false, + AbbreviationListIndex = 0, }; outRules.DefaultType = 0; - int timeCount = 0; - long janFirst = 0; - int janOffset = 0; - int yearBegining = EpochYear; + int timeCount = 0; + long janFirst = 0; + int janOffset = 0; + int yearBegining = EpochYear; do { - int yearSeconds = YearLengths[IsLeap(yearBegining - 1)] * SecondsPerDay; + int yearSeconds = _yearLengths[IsLeap(yearBegining - 1)] * SecondsPerDay; yearBegining--; if (IncrementOverflow64(ref janFirst, -yearSeconds)) { @@ -573,17 +571,14 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone for (year = yearBegining; year < yearLimit; year++) { int startTime = TransitionTime(year, start, stdOffset); - int endTime = TransitionTime(year, end, dstOffset); + int endTime = TransitionTime(year, end, dstOffset); - int yearSeconds = YearLengths[IsLeap(year)] * SecondsPerDay; + int yearSeconds = _yearLengths[IsLeap(year)] * SecondsPerDay; bool isReversed = endTime < startTime; if (isReversed) { - int swap = startTime; - - startTime = endTime; - endTime = swap; + (endTime, startTime) = (startTime, endTime); } if (isReversed || (startTime < endTime && (endTime - startTime < (yearSeconds + (stdOffset - dstOffset))))) @@ -632,7 +627,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone } else if (YearsPerRepeat < year - yearBegining) { - outRules.GoBack = true; + outRules.GoBack = true; outRules.GoAhead = true; } } @@ -653,18 +648,22 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone } } - long theirDstOffset = 0; + long theirDstOffset; for (int i = 0; i < outRules.TimeCount; i++) { int j = outRules.Types[i]; if (outRules.Ttis[j].IsDaySavingTime) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment theirDstOffset = -outRules.Ttis[j].GmtOffset; +#pragma warning restore IDE0059 } } bool isDaySavingTime = false; - long theirOffset = theirStdOffset; +#pragma warning disable IDE0059 // Remove unnecessary value assignment + long theirOffset = theirStdOffset; +#pragma warning restore IDE0059 for (int i = 0; i < outRules.TimeCount; i++) { int j = outRules.Types[i]; @@ -684,7 +683,9 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone theirOffset = -outRules.Ttis[j].GmtOffset; if (outRules.Ttis[j].IsDaySavingTime) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment theirDstOffset = theirOffset; +#pragma warning restore IDE0059 } else { @@ -694,33 +695,33 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone outRules.Ttis[0] = new TimeTypeInfo { - GmtOffset = -stdOffset, - IsDaySavingTime = false, - AbbreviationListIndex = 0 + GmtOffset = -stdOffset, + IsDaySavingTime = false, + AbbreviationListIndex = 0, }; outRules.Ttis[1] = new TimeTypeInfo { - GmtOffset = -dstOffset, - IsDaySavingTime = true, - AbbreviationListIndex = stdLen + 1 + GmtOffset = -dstOffset, + IsDaySavingTime = true, + AbbreviationListIndex = stdLen + 1, }; - outRules.TypeCount = 2; + outRules.TypeCount = 2; outRules.DefaultType = 0; } } else { // default is perpetual standard time - outRules.TypeCount = 1; - outRules.TimeCount = 0; + outRules.TypeCount = 1; + outRules.TimeCount = 0; outRules.DefaultType = 0; - outRules.Ttis[0] = new TimeTypeInfo + outRules.Ttis[0] = new TimeTypeInfo { - GmtOffset = -stdOffset, - IsDaySavingTime = false, - AbbreviationListIndex = 0 + GmtOffset = -stdOffset, + IsDaySavingTime = false, + AbbreviationListIndex = 0, }; } @@ -770,7 +771,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone case RuleType.MonthNthDayOfWeek: // Here we use Zeller's Congruence to get the day of week of the first month. - int m1 = (rule.Month + 9) % 12 + 1; + int m1 = (rule.Month + 9) % 12 + 1; int yy0 = (rule.Month <= 2) ? (year - 1) : year; int yy1 = yy0 / 100; int yy2 = yy0 % 100; @@ -779,7 +780,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone if (dayOfWeek < 0) { - dayOfWeek += DaysPerWekk; + dayOfWeek += DaysPerWeek; } // Get the zero origin @@ -787,23 +788,23 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone if (d < 0) { - d += DaysPerWekk; + d += DaysPerWeek; } for (int i = 1; i < rule.Week; i++) { - if (d + DaysPerWekk >= MonthsLengths[leapYear][rule.Month - 1]) + if (d + DaysPerWeek >= _monthsLengths[leapYear][rule.Month - 1]) { break; } - d += DaysPerWekk; + d += DaysPerWeek; } value = d * SecondsPerDay; for (int i = 0; i < rule.Month - 1; i++) { - value += MonthsLengths[leapYear][i] * SecondsPerDay; + value += _monthsLengths[leapYear][i] * SecondsPerDay; } break; @@ -887,7 +888,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone { outRules = new TimeZoneRule(); - BinaryReader reader = new BinaryReader(inputData); + BinaryReader reader = new(inputData); long streamLength = reader.BaseStream.Length; @@ -902,10 +903,10 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone int ttisGMTCount = Detzcode32(header.TtisGMTCount); int ttisSTDCount = Detzcode32(header.TtisSTDCount); - int leapCount = Detzcode32(header.LeapCount); - int timeCount = Detzcode32(header.TimeCount); - int typeCount = Detzcode32(header.TypeCount); - int charCount = Detzcode32(header.CharCount); + int leapCount = Detzcode32(header.LeapCount); + int timeCount = Detzcode32(header.TimeCount); + int typeCount = Detzcode32(header.TypeCount); + int charCount = Detzcode32(header.CharCount); if (!(0 <= leapCount && leapCount < TzMaxLeaps @@ -1053,7 +1054,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone } long position = (workBuffer.Length - p.Length); - long nRead = streamLength - position; + long nRead = streamLength - position; if (nRead < 0) { @@ -1077,7 +1078,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone byte[] name = new byte[TzNameMax]; Array.Copy(tempName, 1, name, 0, nRead - 1); - Box<TimeZoneRule> tempRulesBox = new Box<TimeZoneRule>(); + Box<TimeZoneRule> tempRulesBox = new(); ref TimeZoneRule tempRules = ref tempRulesBox.Data; if (ParsePosixName(name, ref tempRulesBox.Data, false)) @@ -1247,17 +1248,17 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone private static ResultCode CreateCalendarTime(long time, int gmtOffset, out CalendarTimeInternal calendarTime, out CalendarAdditionalInfo calendarAdditionalInfo) { - long year = EpochYear; - long timeDays = time / SecondsPerDay; + long year = EpochYear; + long timeDays = time / SecondsPerDay; long remainingSeconds = time % SecondsPerDay; - calendarTime = new CalendarTimeInternal(); + calendarTime = new CalendarTimeInternal(); calendarAdditionalInfo = new CalendarAdditionalInfo(); - while (timeDays < 0 || timeDays >= YearLengths[IsLeap((int)year)]) + while (timeDays < 0 || timeDays >= _yearLengths[IsLeap((int)year)]) { long timeDelta = timeDays / DaysPerLYear; - long delta = timeDelta; + long delta = timeDelta; if (delta == 0) { @@ -1298,12 +1299,12 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone return ResultCode.OutOfRange; } - dayOfYear += YearLengths[IsLeap((int)year)]; + dayOfYear += _yearLengths[IsLeap((int)year)]; } - while (dayOfYear >= YearLengths[IsLeap((int)year)]) + while (dayOfYear >= _yearLengths[IsLeap((int)year)]) { - dayOfYear -= YearLengths[IsLeap((int)year)]; + dayOfYear -= _yearLengths[IsLeap((int)year)]; if (IncrementOverflow64(ref year, 1)) { @@ -1311,13 +1312,13 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone } } - calendarTime.Year = year; + calendarTime.Year = year; calendarAdditionalInfo.DayOfYear = (uint)dayOfYear; - long dayOfWeek = (EpochWeekDay + ((year - EpochYear) % DaysPerWekk) * (DaysPerNYear % DaysPerWekk) + GetLeapDays(year - 1) - GetLeapDays(EpochYear - 1) + dayOfYear) % DaysPerWekk; + long dayOfWeek = (EpochWeekDay + ((year - EpochYear) % DaysPerWeek) * (DaysPerNYear % DaysPerWeek) + GetLeapDays(year - 1) - GetLeapDays(EpochYear - 1) + dayOfYear) % DaysPerWeek; if (dayOfWeek < 0) { - dayOfWeek += DaysPerWekk; + dayOfWeek += DaysPerWeek; } calendarAdditionalInfo.DayOfWeek = (uint)dayOfWeek; @@ -1328,7 +1329,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone calendarTime.Minute = (sbyte)(remainingSeconds / SecondsPerMinute); calendarTime.Second = (sbyte)(remainingSeconds % SecondsPerMinute); - int[] ip = MonthsLengths[IsLeap((int)year)]; + int[] ip = _monthsLengths[IsLeap((int)year)]; for (calendarTime.Month = 0; dayOfYear >= ip[calendarTime.Month]; ++calendarTime.Month) { @@ -1338,14 +1339,14 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone calendarTime.Day = (sbyte)(dayOfYear + 1); calendarAdditionalInfo.IsDaySavingTime = false; - calendarAdditionalInfo.GmtOffset = gmtOffset; + calendarAdditionalInfo.GmtOffset = gmtOffset; return 0; } private static ResultCode ToCalendarTimeInternal(in TimeZoneRule rules, long time, out CalendarTimeInternal calendarTime, out CalendarAdditionalInfo calendarAdditionalInfo) { - calendarTime = new CalendarTimeInternal(); + calendarTime = new CalendarTimeInternal(); calendarAdditionalInfo = new CalendarAdditionalInfo(); ResultCode result; @@ -1368,7 +1369,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone seconds -= 1; - years = (seconds / SecondsPerRepeat + 1) * YearsPerRepeat; + years = (seconds / SecondsPerRepeat + 1) * YearsPerRepeat; seconds = years * AverageSecondsPerYear; if (time < rules.Ats[0]) @@ -1411,7 +1412,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone } else { - int low = 1; + int low = 1; int high = rules.TimeCount; while (low < high) @@ -1451,7 +1452,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone { posixTime = 0; - int hour = calendarTime.Hour; + int hour = calendarTime.Hour; int minute = calendarTime.Minute; if (NormalizeOverflow32(ref hour, ref minute, MinutesPerHour)) @@ -1467,10 +1468,10 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone return ResultCode.Overflow; } - calendarTime.Day = (sbyte)day; + calendarTime.Day = (sbyte)day; calendarTime.Hour = (sbyte)hour; - long year = calendarTime.Year; + long year = calendarTime.Year; long month = calendarTime.Month; if (NormalizeOverflow64(ref year, ref month, MonthsPerYear)) @@ -1499,7 +1500,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone li++; } - day += YearLengths[IsLeap((int)li)]; + day += _yearLengths[IsLeap((int)li)]; } while (day > DaysPerLYear) @@ -1511,7 +1512,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone li++; } - day -= YearLengths[IsLeap((int)li)]; + day -= _yearLengths[IsLeap((int)li)]; if (IncrementOverflow64(ref year, 1)) { @@ -1521,7 +1522,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone while (true) { - int i = MonthsLengths[IsLeap((int)year)][calendarTime.Month]; + int i = _monthsLengths[IsLeap((int)year)][calendarTime.Month]; if (day <= i) { @@ -1573,7 +1574,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone calendarTime.Second = 0; } - long low = long.MinValue; + long low = long.MinValue; long high = long.MaxValue; while (true) @@ -1670,15 +1671,15 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone { Time = new CalendarTime() { - Year = (short)calendarTime.Year, + Year = (short)calendarTime.Year, // NOTE: Nintendo's month range is 1-12, internal range is 0-11. Month = (sbyte)(calendarTime.Month + 1), - Day = calendarTime.Day, - Hour = calendarTime.Hour, + Day = calendarTime.Day, + Hour = calendarTime.Hour, Minute = calendarTime.Minute, - Second = calendarTime.Second + Second = calendarTime.Second, }, - AdditionalInfo = calendarAdditionalInfo + AdditionalInfo = calendarAdditionalInfo, }; return result; @@ -1686,18 +1687,18 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone internal static ResultCode ToPosixTime(in TimeZoneRule rules, CalendarTime calendarTime, out long posixTime) { - CalendarTimeInternal calendarTimeInternal = new CalendarTimeInternal() + CalendarTimeInternal calendarTimeInternal = new() { - Year = calendarTime.Year, + Year = calendarTime.Year, // NOTE: Nintendo's month range is 1-12, internal range is 0-11. - Month = (sbyte)(calendarTime.Month - 1), - Day = calendarTime.Day, - Hour = calendarTime.Hour, + Month = (sbyte)(calendarTime.Month - 1), + Day = calendarTime.Day, + Hour = calendarTime.Hour, Minute = calendarTime.Minute, - Second = calendarTime.Second + Second = calendarTime.Second, }; return ToPosixTimeInternal(in rules, calendarTimeInternal, out posixTime); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneContentManager.cs b/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneContentManager.cs index 9367024e..67cb286a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneContentManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneContentManager.cs @@ -11,7 +11,6 @@ using Ryujinx.Cpu; using Ryujinx.HLE.Exceptions; using Ryujinx.HLE.FileSystem; using Ryujinx.HLE.HOS.Services.Time.Clock; -using Ryujinx.HLE.Utilities; using System; using System.Collections.Generic; using System.IO; @@ -24,11 +23,11 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone { private const long TimeZoneBinaryTitleId = 0x010000000000080E; - private readonly string TimeZoneSystemTitleMissingErrorMessage = "TimeZoneBinary system title not found! TimeZone conversions will not work, provide the system archive to fix this error. (See https://github.com/Ryujinx/Ryujinx/wiki/Ryujinx-Setup-&-Configuration-Guide#initial-setup-continued---installation-of-firmware for more information)"; + private const string TimeZoneSystemTitleMissingErrorMessage = "TimeZoneBinary system title not found! TimeZone conversions will not work, provide the system archive to fix this error. (See https://github.com/Ryujinx/Ryujinx/wiki/Ryujinx-Setup-&-Configuration-Guide#initial-setup-continued---installation-of-firmware for more information)"; - private VirtualFileSystem _virtualFileSystem; + private VirtualFileSystem _virtualFileSystem; private IntegrityCheckLevel _fsIntegrityCheckLevel; - private ContentManager _contentManager; + private ContentManager _contentManager; public string[] LocationNameCache { get; private set; } @@ -41,8 +40,8 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone public void InitializeInstance(VirtualFileSystem virtualFileSystem, ContentManager contentManager, IntegrityCheckLevel fsIntegrityCheckLevel) { - _virtualFileSystem = virtualFileSystem; - _contentManager = contentManager; + _virtualFileSystem = virtualFileSystem; + _contentManager = contentManager; _fsIntegrityCheckLevel = fsIntegrityCheckLevel; InitializeLocationNameCache(); @@ -90,31 +89,30 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone { if (HasTimeZoneBinaryTitle()) { - using (IStorage ncaFileStream = new LocalStorage(_virtualFileSystem.SwitchPathToSystemPath(GetTimeZoneBinaryTitleContentPath()), FileAccess.Read, FileMode.Open)) - { - Nca nca = new Nca(_virtualFileSystem.KeySet, ncaFileStream); - IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel); + using IStorage ncaFileStream = new LocalStorage(VirtualFileSystem.SwitchPathToSystemPath(GetTimeZoneBinaryTitleContentPath()), FileAccess.Read, FileMode.Open); - using var binaryListFile = new UniqueRef<IFile>(); + Nca nca = new(_virtualFileSystem.KeySet, ncaFileStream); + IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel); - romfs.OpenFile(ref binaryListFile.Ref, "/binaryList.txt".ToU8Span(), OpenMode.Read).ThrowIfFailure(); + using var binaryListFile = new UniqueRef<IFile>(); - StreamReader reader = new StreamReader(binaryListFile.Get.AsStream()); + romfs.OpenFile(ref binaryListFile.Ref, "/binaryList.txt".ToU8Span(), OpenMode.Read).ThrowIfFailure(); - List<string> locationNameList = new List<string>(); + StreamReader reader = new(binaryListFile.Get.AsStream()); - string locationName; - while ((locationName = reader.ReadLine()) != null) - { - locationNameList.Add(locationName); - } + List<string> locationNameList = new(); - LocationNameCache = locationNameList.ToArray(); + string locationName; + while ((locationName = reader.ReadLine()) != null) + { + locationNameList.Add(locationName); } + + LocationNameCache = locationNameList.ToArray(); } else { - LocationNameCache = new string[] { "UTC" }; + LocationNameCache = new[] { "UTC" }; Logger.Error?.Print(LogClass.ServiceTime, TimeZoneSystemTitleMissingErrorMessage); } @@ -129,9 +127,9 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone return new[] { (0, "UTC", "UTC") }; } - List<(int Offset, string Location, string Abbr)> outList = new List<(int Offset, string Location, string Abbr)>(); + List<(int Offset, string Location, string Abbr)> outList = new(); var now = DateTimeOffset.Now.ToUnixTimeSeconds(); - using (IStorage ncaStorage = new LocalStorage(_virtualFileSystem.SwitchPathToSystemPath(tzBinaryContentPath), FileAccess.Read, FileMode.Open)) + using (IStorage ncaStorage = new LocalStorage(VirtualFileSystem.SwitchPathToSystemPath(tzBinaryContentPath), FileAccess.Read, FileMode.Open)) using (IFileSystem romfs = new Nca(_virtualFileSystem.KeySet, ncaStorage).OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel)) { foreach (string locName in LocationNameCache) @@ -149,7 +147,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone continue; } - TimeZoneRuleBox tzRuleBox = new TimeZoneRuleBox(); + TimeZoneRuleBox tzRuleBox = new(); ref TimeZoneRule tzRule = ref tzRuleBox.Data; TimeZone.ParseTimeZoneBinary(ref tzRule, tzif.Get.AsStream()); @@ -219,7 +217,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone public ResultCode LoadLocationNameList(uint index, out string[] outLocationNameArray, uint maxLength) { - List<string> locationNameList = new List<string>(); + List<string> locationNameList = new(); for (int i = 0; i < LocationNameCache.Length && i < maxLength; i++) { @@ -259,16 +257,16 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone internal ResultCode GetTimeZoneBinary(string locationName, out Stream timeZoneBinaryStream, out LocalStorage ncaFile) { timeZoneBinaryStream = null; - ncaFile = null; + ncaFile = null; if (!HasTimeZoneBinaryTitle() || !IsLocationNameValid(locationName)) { return ResultCode.TimeZoneNotFound; } - ncaFile = new LocalStorage(_virtualFileSystem.SwitchPathToSystemPath(GetTimeZoneBinaryTitleContentPath()), FileAccess.Read, FileMode.Open); + ncaFile = new LocalStorage(VirtualFileSystem.SwitchPathToSystemPath(GetTimeZoneBinaryTitleContentPath()), FileAccess.Read, FileMode.Open); - Nca nca = new Nca(_virtualFileSystem.KeySet, ncaFile); + Nca nca = new(_virtualFileSystem.KeySet, ncaFile); IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel); using var timeZoneBinaryFile = new UniqueRef<IFile>(); diff --git a/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneManager.cs b/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneManager.cs index 8b85d697..219b1d9f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneManager.cs @@ -7,20 +7,20 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone { class TimeZoneManager { - private bool _isInitialized; - private Box<TimeZoneRule> _myRules; - private string _deviceLocationName; - private UInt128 _timeZoneRuleVersion; - private uint _totalLocationNameCount; + private bool _isInitialized; + private Box<TimeZoneRule> _myRules; + private string _deviceLocationName; + private UInt128 _timeZoneRuleVersion; + private uint _totalLocationNameCount; private SteadyClockTimePoint _timeZoneUpdateTimePoint; - private readonly object _lock = new(); + private readonly object _lock = new(); public TimeZoneManager() { - _isInitialized = false; - _deviceLocationName = "UTC"; + _isInitialized = false; + _deviceLocationName = "UTC"; _timeZoneRuleVersion = new UInt128(); - _myRules = new Box<TimeZoneRule>(); + _myRules = new Box<TimeZoneRule>(); _timeZoneUpdateTimePoint = SteadyClockTimePoint.GetRandom(); } @@ -56,7 +56,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone if (_isInitialized) { deviceLocationName = _deviceLocationName; - result = ResultCode.Success; + result = ResultCode.Success; } } @@ -69,15 +69,15 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone lock (_lock) { - Box<TimeZoneRule> rules = new Box<TimeZoneRule>(); + Box<TimeZoneRule> rules = new(); bool timeZoneConversionSuccess = TimeZone.ParseTimeZoneBinary(ref rules.Data, timeZoneBinaryStream); if (timeZoneConversionSuccess) { _deviceLocationName = locationName; - _myRules = rules; - result = ResultCode.Success; + _myRules = rules; + result = ResultCode.Success; } } @@ -103,7 +103,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone if (_isInitialized) { totalLocationNameCount = _totalLocationNameCount; - result = ResultCode.Success; + result = ResultCode.Success; } } @@ -119,7 +119,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone if (_isInitialized || bypassUninitialized) { _timeZoneUpdateTimePoint = timeZoneUpdatedTimePoint; - result = ResultCode.Success; + result = ResultCode.Success; } } @@ -135,12 +135,12 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone if (_isInitialized) { timeZoneUpdatedTimePoint = _timeZoneUpdateTimePoint; - result = ResultCode.Success; + result = ResultCode.Success; } else { timeZoneUpdatedTimePoint = SteadyClockTimePoint.GetRandom(); - result = ResultCode.UninitializedClock; + result = ResultCode.UninitializedClock; } } @@ -181,12 +181,12 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone if (_isInitialized) { timeZoneRuleVersion = _timeZoneRuleVersion; - result = ResultCode.Success; + result = ResultCode.Success; } else { timeZoneRuleVersion = new UInt128(); - result = ResultCode.UninitializedClock; + result = ResultCode.UninitializedClock; } } @@ -206,7 +206,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone else { calendar = new CalendarInfo(); - result = ResultCode.UninitializedClock; + result = ResultCode.UninitializedClock; } } @@ -238,7 +238,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone else { posixTime = 0; - result = ResultCode.UninitializedClock; + result = ResultCode.UninitializedClock; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/Types/CalendarAdditionalInfo.cs b/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/Types/CalendarAdditionalInfo.cs index a84a2785..8e7dc6d5 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/Types/CalendarAdditionalInfo.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/Types/CalendarAdditionalInfo.cs @@ -18,4 +18,4 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone public int GmtOffset; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/Types/CalendarInfo.cs b/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/Types/CalendarInfo.cs index 68e6245b..7fc6f7a0 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/Types/CalendarInfo.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/Types/CalendarInfo.cs @@ -5,7 +5,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone [StructLayout(LayoutKind.Sequential, Pack = 0x4, Size = 0x20, CharSet = CharSet.Ansi)] struct CalendarInfo { - public CalendarTime Time; + public CalendarTime Time; public CalendarAdditionalInfo AdditionalInfo; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/Types/CalendarTime.cs b/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/Types/CalendarTime.cs index d594223d..fa082bde 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/Types/CalendarTime.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/Types/CalendarTime.cs @@ -12,4 +12,4 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone public sbyte Minute; public sbyte Second; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/Types/TimeTypeInfo.cs b/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/Types/TimeTypeInfo.cs index b8b3d917..47620f56 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/Types/TimeTypeInfo.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/Types/TimeTypeInfo.cs @@ -25,4 +25,4 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone public ushort Padding2; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/Types/TimeZoneRule.cs b/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/Types/TimeZoneRule.cs index 67237f3d..b8dd2382 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/Types/TimeZoneRule.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/Types/TimeZoneRule.cs @@ -53,4 +53,4 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone public int DefaultType; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/Types/TzifHeader.cs b/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/Types/TzifHeader.cs index 022c34a9..1d05ee24 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/Types/TzifHeader.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/Types/TzifHeader.cs @@ -16,4 +16,4 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone public int TypeCount; public int CharCount; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Types/SteadyClockContext.cs b/src/Ryujinx.HLE/HOS/Services/Time/Types/SteadyClockContext.cs index 38d37055..2b80604a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Types/SteadyClockContext.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Types/SteadyClockContext.cs @@ -6,7 +6,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Types [StructLayout(LayoutKind.Sequential, Pack = 1)] struct SteadyClockContext { - public ulong InternalOffset; + public ulong InternalOffset; public UInt128 ClockSourceId; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Types/TimePermissions.cs b/src/Ryujinx.HLE/HOS/Services/Time/Types/TimePermissions.cs index 3fcd3a14..34749c42 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Types/TimePermissions.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Types/TimePermissions.cs @@ -5,18 +5,18 @@ namespace Ryujinx.HLE.HOS.Services.Time [Flags] enum TimePermissions { - LocalSystemClockWritableMask = 0x1, - UserSystemClockWritableMask = 0x2, + LocalSystemClockWritableMask = 0x1, + UserSystemClockWritableMask = 0x2, NetworkSystemClockWritableMask = 0x4, - TimeZoneWritableMask = 0x8, - SteadyClockWritableMask = 0x10, - BypassUninitialized = 0x20, + TimeZoneWritableMask = 0x8, + SteadyClockWritableMask = 0x10, + BypassUninitialized = 0x20, - User = 0, - Admin = LocalSystemClockWritableMask | UserSystemClockWritableMask | TimeZoneWritableMask, - System = NetworkSystemClockWritableMask, + User = 0, + Admin = LocalSystemClockWritableMask | UserSystemClockWritableMask | TimeZoneWritableMask, + System = NetworkSystemClockWritableMask, SystemUpdate = BypassUninitialized, - Repair = SteadyClockWritableMask, - Manufacture = LocalSystemClockWritableMask | UserSystemClockWritableMask | NetworkSystemClockWritableMask | TimeZoneWritableMask | SteadyClockWritableMask + Repair = SteadyClockWritableMask, + Manufacture = LocalSystemClockWritableMask | UserSystemClockWritableMask | NetworkSystemClockWritableMask | TimeZoneWritableMask | SteadyClockWritableMask, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Usb/IClientRootSession.cs b/src/Ryujinx.HLE/HOS/Services/Usb/IClientRootSession.cs index 56b12af0..b41b8a48 100644 --- a/src/Ryujinx.HLE/HOS/Services/Usb/IClientRootSession.cs +++ b/src/Ryujinx.HLE/HOS/Services/Usb/IClientRootSession.cs @@ -6,4 +6,4 @@ { public IClientRootSession(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Usb/IDsService.cs b/src/Ryujinx.HLE/HOS/Services/Usb/IDsService.cs index 4dbb6fc1..ee6c8f07 100644 --- a/src/Ryujinx.HLE/HOS/Services/Usb/IDsService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Usb/IDsService.cs @@ -5,4 +5,4 @@ { public IDsService(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Usb/IPdCradleManager.cs b/src/Ryujinx.HLE/HOS/Services/Usb/IPdCradleManager.cs index cecdbc31..18cbce79 100644 --- a/src/Ryujinx.HLE/HOS/Services/Usb/IPdCradleManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Usb/IPdCradleManager.cs @@ -5,4 +5,4 @@ { public IPdCradleManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Usb/IPdManager.cs b/src/Ryujinx.HLE/HOS/Services/Usb/IPdManager.cs index 1fb574d2..011debaf 100644 --- a/src/Ryujinx.HLE/HOS/Services/Usb/IPdManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Usb/IPdManager.cs @@ -5,4 +5,4 @@ { public IPdManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Usb/IPmService.cs b/src/Ryujinx.HLE/HOS/Services/Usb/IPmService.cs index 38beee07..ed6bba69 100644 --- a/src/Ryujinx.HLE/HOS/Services/Usb/IPmService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Usb/IPmService.cs @@ -5,4 +5,4 @@ { public IPmService(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Usb/IUnknown1.cs b/src/Ryujinx.HLE/HOS/Services/Usb/IUnknown1.cs index 0981e4ff..65bf1c9f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Usb/IUnknown1.cs +++ b/src/Ryujinx.HLE/HOS/Services/Usb/IUnknown1.cs @@ -5,4 +5,4 @@ { public IUnknown1(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Usb/IUnknown2.cs b/src/Ryujinx.HLE/HOS/Services/Usb/IUnknown2.cs index 563696bb..e0bf0bf4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Usb/IUnknown2.cs +++ b/src/Ryujinx.HLE/HOS/Services/Usb/IUnknown2.cs @@ -5,4 +5,4 @@ { public IUnknown2(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Vi/IApplicationRootService.cs b/src/Ryujinx.HLE/HOS/Services/Vi/IApplicationRootService.cs index 526cecf8..9cc9d421 100644 --- a/src/Ryujinx.HLE/HOS/Services/Vi/IApplicationRootService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Vi/IApplicationRootService.cs @@ -24,4 +24,4 @@ namespace Ryujinx.HLE.HOS.Services.Vi return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Vi/IManagerRootService.cs b/src/Ryujinx.HLE/HOS/Services/Vi/IManagerRootService.cs index d564dabe..dd4b25a0 100644 --- a/src/Ryujinx.HLE/HOS/Services/Vi/IManagerRootService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Vi/IManagerRootService.cs @@ -25,4 +25,4 @@ namespace Ryujinx.HLE.HOS.Services.Vi return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Vi/ISystemRootService.cs b/src/Ryujinx.HLE/HOS/Services/Vi/ISystemRootService.cs index 0dfd84f5..b2415f2e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Vi/ISystemRootService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Vi/ISystemRootService.cs @@ -25,4 +25,4 @@ namespace Ryujinx.HLE.HOS.Services.Vi return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Vi/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Vi/ResultCode.cs index c64339c9..3bed7e57 100644 --- a/src/Ryujinx.HLE/HOS/Services/Vi/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Vi/ResultCode.cs @@ -2,16 +2,16 @@ namespace Ryujinx.HLE.HOS.Services.Vi { enum ResultCode { - ModuleId = 114, + ModuleId = 114, ErrorCodeShift = 9, Success = 0, - InvalidArguments = (1 << ErrorCodeShift) | ModuleId, - InvalidLayerSize = (4 << ErrorCodeShift) | ModuleId, - PermissionDenied = (5 << ErrorCodeShift) | ModuleId, + InvalidArguments = (1 << ErrorCodeShift) | ModuleId, + InvalidLayerSize = (4 << ErrorCodeShift) | ModuleId, + PermissionDenied = (5 << ErrorCodeShift) | ModuleId, InvalidScalingMode = (6 << ErrorCodeShift) | ModuleId, - InvalidValue = (7 << ErrorCodeShift) | ModuleId, - AlreadyOpened = (9 << ErrorCodeShift) | ModuleId + InvalidValue = (7 << ErrorCodeShift) | ModuleId, + AlreadyOpened = (9 << ErrorCodeShift) | ModuleId, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Vi/RootService/ApplicationDisplayService/AndroidSurfaceComposerClient.cs b/src/Ryujinx.HLE/HOS/Services/Vi/RootService/ApplicationDisplayService/AndroidSurfaceComposerClient.cs index 1fa99e65..782bb7d7 100644 --- a/src/Ryujinx.HLE/HOS/Services/Vi/RootService/ApplicationDisplayService/AndroidSurfaceComposerClient.cs +++ b/src/Ryujinx.HLE/HOS/Services/Vi/RootService/ApplicationDisplayService/AndroidSurfaceComposerClient.cs @@ -1,6 +1,6 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService.ApplicationDisplayService { - static class AndroidSurfaceComposerClient + class AndroidSurfaceComposerClient { // NOTE: This is android::SurfaceComposerClient::getDisplayInfo. public static (ulong, ulong) GetDisplayInfo(ServiceCtx context, ulong displayId = 0) @@ -16,4 +16,4 @@ } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Vi/RootService/ApplicationDisplayService/IManagerDisplayService.cs b/src/Ryujinx.HLE/HOS/Services/Vi/RootService/ApplicationDisplayService/IManagerDisplayService.cs index 6093381c..3a08cdd7 100644 --- a/src/Ryujinx.HLE/HOS/Services/Vi/RootService/ApplicationDisplayService/IManagerDisplayService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Vi/RootService/ApplicationDisplayService/IManagerDisplayService.cs @@ -4,7 +4,9 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService.ApplicationDisplayService { class IManagerDisplayService : IpcService { - private IApplicationDisplayService _applicationDisplayService; +#pragma warning disable IDE0052 // Remove unread private member + private readonly IApplicationDisplayService _applicationDisplayService; +#pragma warning restore IDE0052 public IManagerDisplayService(IApplicationDisplayService applicationDisplayService) { @@ -29,8 +31,10 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService.ApplicationDisplayService // CreateManagedLayer(u32, u64, nn::applet::AppletResourceUserId) -> u64 public ResultCode CreateManagedLayer(ServiceCtx context) { - long layerFlags = context.RequestData.ReadInt64(); - long displayId = context.RequestData.ReadInt64(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment + long layerFlags = context.RequestData.ReadInt64(); + long displayId = context.RequestData.ReadInt64(); +#pragma warning restore IDE0059 long appletResourceUserId = context.RequestData.ReadInt64(); ulong pid = context.Device.System.AppletState.AppletResourceUserIds.GetData<ulong>((int)appletResourceUserId); @@ -77,4 +81,4 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService.ApplicationDisplayService return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Vi/RootService/ApplicationDisplayService/ISystemDisplayService.cs b/src/Ryujinx.HLE/HOS/Services/Vi/RootService/ApplicationDisplayService/ISystemDisplayService.cs index a24aa079..12ac2cf4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Vi/RootService/ApplicationDisplayService/ISystemDisplayService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Vi/RootService/ApplicationDisplayService/ISystemDisplayService.cs @@ -4,7 +4,9 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService.ApplicationDisplayService { class ISystemDisplayService : IpcService { - private IApplicationDisplayService _applicationDisplayService; +#pragma warning disable IDE0052 // Remove unread private member + private readonly IApplicationDisplayService _applicationDisplayService; +#pragma warning restore IDE0052 public ISystemDisplayService(IApplicationDisplayService applicationDisplayService) { @@ -56,4 +58,4 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService.ApplicationDisplayService return ResultCode.Success; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Vi/RootService/ApplicationDisplayService/Types/DestinationScalingMode.cs b/src/Ryujinx.HLE/HOS/Services/Vi/RootService/ApplicationDisplayService/Types/DestinationScalingMode.cs index cf459cb2..c712bb1d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Vi/RootService/ApplicationDisplayService/Types/DestinationScalingMode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Vi/RootService/ApplicationDisplayService/Types/DestinationScalingMode.cs @@ -6,6 +6,6 @@ ScaleToWindow, ScaleAndCrop, None, - PreserveAspectRatio + PreserveAspectRatio, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Vi/RootService/ApplicationDisplayService/Types/DisplayInfo.cs b/src/Ryujinx.HLE/HOS/Services/Vi/RootService/ApplicationDisplayService/Types/DisplayInfo.cs index d46206d4..eae8a800 100644 --- a/src/Ryujinx.HLE/HOS/Services/Vi/RootService/ApplicationDisplayService/Types/DisplayInfo.cs +++ b/src/Ryujinx.HLE/HOS/Services/Vi/RootService/ApplicationDisplayService/Types/DisplayInfo.cs @@ -7,10 +7,10 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService.ApplicationDisplayService.Type struct DisplayInfo { public Array64<byte> Name; - public bool LayerLimitEnabled; - public Array7<byte> Padding; - public ulong LayerLimitMax; - public ulong Width; - public ulong Height; + public bool LayerLimitEnabled; + public Array7<byte> Padding; + public ulong LayerLimitMax; + public ulong Width; + public ulong Height; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Vi/RootService/ApplicationDisplayService/Types/SourceScalingMode.cs b/src/Ryujinx.HLE/HOS/Services/Vi/RootService/ApplicationDisplayService/Types/SourceScalingMode.cs index ac8c3e02..536c0d46 100644 --- a/src/Ryujinx.HLE/HOS/Services/Vi/RootService/ApplicationDisplayService/Types/SourceScalingMode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Vi/RootService/ApplicationDisplayService/Types/SourceScalingMode.cs @@ -6,6 +6,6 @@ Freeze, ScaleToWindow, ScaleAndCrop, - PreserveAspectRatio + PreserveAspectRatio, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Vi/RootService/IApplicationDisplayService.cs b/src/Ryujinx.HLE/HOS/Services/Vi/RootService/IApplicationDisplayService.cs index 89eed5b5..3fbd7d20 100644 --- a/src/Ryujinx.HLE/HOS/Services/Vi/RootService/IApplicationDisplayService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Vi/RootService/IApplicationDisplayService.cs @@ -3,7 +3,6 @@ using Ryujinx.Common.Logging; using Ryujinx.Common.Memory; using Ryujinx.HLE.HOS.Applets; using Ryujinx.HLE.HOS.Ipc; -using Ryujinx.HLE.HOS.Kernel.Common; using Ryujinx.HLE.HOS.Services.SurfaceFlinger; using Ryujinx.HLE.HOS.Services.Vi.RootService.ApplicationDisplayService; using Ryujinx.HLE.HOS.Services.Vi.RootService.ApplicationDisplayService.Types; @@ -27,27 +26,27 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService public int RetrievedEventsCount; } - private readonly List<DisplayInfo> _displayInfo; + private readonly List<DisplayInfo> _displayInfo; private readonly Dictionary<ulong, DisplayState> _openDisplays; private int _vsyncEventHandle; public IApplicationDisplayService(ViServiceType serviceType) { - _serviceType = serviceType; - _displayInfo = new List<DisplayInfo>(); + _serviceType = serviceType; + _displayInfo = new List<DisplayInfo>(); _openDisplays = new Dictionary<ulong, DisplayState>(); void AddDisplayInfo(string name, bool layerLimitEnabled, ulong layerLimitMax, ulong width, ulong height) { - DisplayInfo displayInfo = new DisplayInfo() + DisplayInfo displayInfo = new() { - Name = new Array64<byte>(), + Name = new Array64<byte>(), LayerLimitEnabled = layerLimitEnabled, - Padding = new Array7<byte>(), - LayerLimitMax = layerLimitMax, - Width = width, - Height = height + Padding = new Array7<byte>(), + LayerLimitMax = layerLimitMax, + Width = width, + Height = height, }; Encoding.ASCII.GetBytes(name).AsSpan().CopyTo(displayInfo.Name.AsSpan()); @@ -55,11 +54,11 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService _displayInfo.Add(displayInfo); } - AddDisplayInfo("Default", true, 1, 1920, 1080); - AddDisplayInfo("External", true, 1, 1920, 1080); - AddDisplayInfo("Edid", true, 1, 0, 0); - AddDisplayInfo("Internal", true, 1, 1920, 1080); - AddDisplayInfo("Null", false, 0, 1920, 1080); + AddDisplayInfo("Default", true, 1, 1920, 1080); + AddDisplayInfo("External", true, 1, 1920, 1080); + AddDisplayInfo("Edid", true, 1, 0, 0); + AddDisplayInfo("Internal", true, 1, 1920, 1080); + AddDisplayInfo("Null", false, 0, 1920, 1080); } [CommandCmif(100)] @@ -232,10 +231,14 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService public ResultCode OpenLayer(ServiceCtx context) { // TODO: support multi display. +#pragma warning disable IDE0059 // Remove unnecessary value assignment byte[] displayName = context.RequestData.ReadBytes(0x40); +#pragma warning restore IDE0059 - long layerId = context.RequestData.ReadInt64(); - long userId = context.RequestData.ReadInt64(); + long layerId = context.RequestData.ReadInt64(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment + long userId = context.RequestData.ReadInt64(); +#pragma warning restore IDE0059 ulong parcelPtr = context.Request.ReceiveBuff[0].Position; ResultCode result = context.Device.System.SurfaceFlinger.OpenLayer(context.Request.HandleDesc.PId, layerId, out IBinder producer); @@ -247,7 +250,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService context.Device.System.SurfaceFlinger.SetRenderLayer(layerId); - Parcel parcel = new Parcel(0x28, 0x4); + Parcel parcel = new(0x28, 0x4); parcel.WriteObject(producer, "dispdrv\0"); @@ -273,8 +276,10 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService // CreateStrayLayer(u32, u64) -> (u64, u64, buffer<bytes, 6>) public ResultCode CreateStrayLayer(ServiceCtx context) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment long layerFlags = context.RequestData.ReadInt64(); - long displayId = context.RequestData.ReadInt64(); + long displayId = context.RequestData.ReadInt64(); +#pragma warning restore IDE0059 ulong parcelPtr = context.Request.ReceiveBuff[0].Position; @@ -283,7 +288,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService context.Device.System.SurfaceFlinger.SetRenderLayer(layerId); - Parcel parcel = new Parcel(0x28, 0x4); + Parcel parcel = new(0x28, 0x4); parcel.WriteObject(producer, "dispdrv\0"); @@ -327,10 +332,10 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService DestinationScalingMode? convertedScalingMode = scalingMode switch { - SourceScalingMode.None => DestinationScalingMode.None, - SourceScalingMode.Freeze => DestinationScalingMode.Freeze, - SourceScalingMode.ScaleAndCrop => DestinationScalingMode.ScaleAndCrop, - SourceScalingMode.ScaleToWindow => DestinationScalingMode.ScaleToWindow, + SourceScalingMode.None => DestinationScalingMode.None, + SourceScalingMode.Freeze => DestinationScalingMode.Freeze, + SourceScalingMode.ScaleAndCrop => DestinationScalingMode.ScaleAndCrop, + SourceScalingMode.ScaleToWindow => DestinationScalingMode.ScaleToWindow, SourceScalingMode.PreserveAspectRatio => DestinationScalingMode.PreserveAspectRatio, _ => null, }; @@ -354,13 +359,13 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService private ulong GetA8B8G8R8LayerSize(int width, int height, out int pitch, out int alignment) { - const int DefaultAlignment = 0x1000; - const ulong DefaultSize = 0x20000; + const int DefaultAlignment = 0x1000; + const ulong DefaultSize = 0x20000; alignment = DefaultAlignment; - pitch = BitUtils.AlignUp(BitUtils.DivRoundUp(width * 32, 8), 64); + pitch = BitUtils.AlignUp(BitUtils.DivRoundUp(width * 32, 8), 64); - int memorySize = pitch * BitUtils.AlignUp(height, 64); + int memorySize = pitch * BitUtils.AlignUp(height, 64); ulong requiredMemorySize = (ulong)BitUtils.AlignUp(memorySize, alignment); return (requiredMemorySize + DefaultSize - 1) / DefaultSize * DefaultSize; @@ -373,18 +378,18 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService // The size of the layer buffer should be an aligned multiple of width * height // because it was created using GetIndirectLayerImageRequiredMemoryInfo as a guide. - long layerWidth = context.RequestData.ReadInt64(); - long layerHeight = context.RequestData.ReadInt64(); - long layerHandle = context.RequestData.ReadInt64(); + long layerWidth = context.RequestData.ReadInt64(); + long layerHeight = context.RequestData.ReadInt64(); + long layerHandle = context.RequestData.ReadInt64(); ulong layerBuffPosition = context.Request.ReceiveBuff[0].Position; - ulong layerBuffSize = context.Request.ReceiveBuff[0].Size; + ulong layerBuffSize = context.Request.ReceiveBuff[0].Size; // Get the pitch of the layer that is necessary to render correctly. ulong size = GetA8B8G8R8LayerSize((int)layerWidth, (int)layerHeight, out int pitch, out _); Debug.Assert(layerBuffSize == size); - RenderingSurfaceInfo surfaceInfo = new RenderingSurfaceInfo(ColorFormat.A8B8G8R8, (uint)layerWidth, (uint)layerHeight, (uint)pitch, (uint)layerBuffSize); + RenderingSurfaceInfo surfaceInfo = new(ColorFormat.A8B8G8R8, (uint)layerWidth, (uint)layerHeight, (uint)pitch, (uint)layerBuffSize); // Get the applet associated with the handle. object appletObject = context.Device.System.AppletState.IndirectLayerHandles.GetData((int)layerHandle); @@ -425,7 +430,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService } */ - int width = (int)context.RequestData.ReadUInt64(); + int width = (int)context.RequestData.ReadUInt64(); int height = (int)context.RequestData.ReadUInt64(); if (height < 0 || width < 0) @@ -445,7 +450,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService // NOTE: The official service setup a A8B8G8R8 texture with a linear layout and then query its size. // As we don't need this texture on the emulator, we can just simplify this logic and directly // do a linear layout size calculation. (stride * height * bytePerPixel) - ulong size = GetA8B8G8R8LayerSize(width, height, out int pitch, out int alignment); + ulong size = GetA8B8G8R8LayerSize(width, height, out _, out int alignment); context.ResponseData.Write(size); context.ResponseData.Write(alignment); diff --git a/src/Ryujinx.HLE/HOS/Services/Vi/Types/ViServiceType.cs b/src/Ryujinx.HLE/HOS/Services/Vi/Types/ViServiceType.cs index ba6f8e5f..41c8bbfa 100644 --- a/src/Ryujinx.HLE/HOS/Services/Vi/Types/ViServiceType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Vi/Types/ViServiceType.cs @@ -4,6 +4,6 @@ { Application, Manager, - System + System, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Wlan/IInfraManager.cs b/src/Ryujinx.HLE/HOS/Services/Wlan/IInfraManager.cs index 0416868a..a8462578 100644 --- a/src/Ryujinx.HLE/HOS/Services/Wlan/IInfraManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Wlan/IInfraManager.cs @@ -5,4 +5,4 @@ { public IInfraManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Wlan/ILocalGetActionFrame.cs b/src/Ryujinx.HLE/HOS/Services/Wlan/ILocalGetActionFrame.cs index 6c2e20a4..060e5854 100644 --- a/src/Ryujinx.HLE/HOS/Services/Wlan/ILocalGetActionFrame.cs +++ b/src/Ryujinx.HLE/HOS/Services/Wlan/ILocalGetActionFrame.cs @@ -5,4 +5,4 @@ { public ILocalGetActionFrame(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Wlan/ILocalGetFrame.cs b/src/Ryujinx.HLE/HOS/Services/Wlan/ILocalGetFrame.cs index a224a192..d726b7d4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Wlan/ILocalGetFrame.cs +++ b/src/Ryujinx.HLE/HOS/Services/Wlan/ILocalGetFrame.cs @@ -5,4 +5,4 @@ { public ILocalGetFrame(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Wlan/ILocalManager.cs b/src/Ryujinx.HLE/HOS/Services/Wlan/ILocalManager.cs index 4cc2c4b2..3db07ac7 100644 --- a/src/Ryujinx.HLE/HOS/Services/Wlan/ILocalManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Wlan/ILocalManager.cs @@ -5,4 +5,4 @@ { public ILocalManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Wlan/ISocketGetFrame.cs b/src/Ryujinx.HLE/HOS/Services/Wlan/ISocketGetFrame.cs index ab5b2193..5c932923 100644 --- a/src/Ryujinx.HLE/HOS/Services/Wlan/ISocketGetFrame.cs +++ b/src/Ryujinx.HLE/HOS/Services/Wlan/ISocketGetFrame.cs @@ -5,4 +5,4 @@ { public ISocketGetFrame(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Wlan/ISocketManager.cs b/src/Ryujinx.HLE/HOS/Services/Wlan/ISocketManager.cs index afa1bede..1b40b80e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Wlan/ISocketManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Wlan/ISocketManager.cs @@ -5,4 +5,4 @@ { public ISocketManager(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Wlan/IUnknown1.cs b/src/Ryujinx.HLE/HOS/Services/Wlan/IUnknown1.cs index dfae18e5..731f8c0a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Wlan/IUnknown1.cs +++ b/src/Ryujinx.HLE/HOS/Services/Wlan/IUnknown1.cs @@ -5,4 +5,4 @@ { public IUnknown1(ServiceCtx context) { } } -}
\ No newline at end of file +} |