diff options
Diffstat (limited to 'Ryujinx.HLE/HOS/Services')
120 files changed, 4745 insertions, 4759 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Acc/IAccountService.cs b/Ryujinx.HLE/HOS/Services/Acc/IAccountService.cs index f920c00b..7ff25c4b 100644 --- a/Ryujinx.HLE/HOS/Services/Acc/IAccountService.cs +++ b/Ryujinx.HLE/HOS/Services/Acc/IAccountService.cs @@ -10,13 +10,13 @@ namespace Ryujinx.HLE.HOS.Services.Acc { class IAccountService : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IAccountService() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, GetUserCount }, { 1, GetUserExistence }, @@ -32,131 +32,131 @@ namespace Ryujinx.HLE.HOS.Services.Acc } // GetUserCount() -> i32 - public long GetUserCount(ServiceCtx Context) + public long GetUserCount(ServiceCtx context) { - Context.ResponseData.Write(Context.Device.System.State.GetUserCount()); + context.ResponseData.Write(context.Device.System.State.GetUserCount()); return 0; } // GetUserExistence(nn::account::Uid) -> bool - public long GetUserExistence(ServiceCtx Context) + public long GetUserExistence(ServiceCtx context) { - UInt128 Uuid = new UInt128( - Context.RequestData.ReadInt64(), - Context.RequestData.ReadInt64()); + UInt128 uuid = new UInt128( + context.RequestData.ReadInt64(), + context.RequestData.ReadInt64()); - Context.ResponseData.Write(Context.Device.System.State.TryGetUser(Uuid, out _)); + context.ResponseData.Write(context.Device.System.State.TryGetUser(uuid, out _)); return 0; } // ListAllUsers() -> array<nn::account::Uid, 0xa> - public long ListAllUsers(ServiceCtx Context) + public long ListAllUsers(ServiceCtx context) { - return WriteUserList(Context, Context.Device.System.State.GetAllUsers()); + return WriteUserList(context, context.Device.System.State.GetAllUsers()); } // ListOpenUsers() -> array<nn::account::Uid, 0xa> - public long ListOpenUsers(ServiceCtx Context) + public long ListOpenUsers(ServiceCtx context) { - return WriteUserList(Context, Context.Device.System.State.GetOpenUsers()); + return WriteUserList(context, context.Device.System.State.GetOpenUsers()); } - private long WriteUserList(ServiceCtx Context, IEnumerable<UserProfile> Profiles) + private long WriteUserList(ServiceCtx context, IEnumerable<UserProfile> profiles) { - long OutputPosition = Context.Request.RecvListBuff[0].Position; - long OutputSize = Context.Request.RecvListBuff[0].Size; + long outputPosition = context.Request.RecvListBuff[0].Position; + long outputSize = context.Request.RecvListBuff[0].Size; - long Offset = 0; + long offset = 0; - foreach (UserProfile Profile in Profiles) + foreach (UserProfile profile in profiles) { - if ((ulong)Offset + 16 > (ulong)OutputSize) + if ((ulong)offset + 16 > (ulong)outputSize) { break; } - Context.Memory.WriteInt64(OutputPosition, Profile.Uuid.Low); - Context.Memory.WriteInt64(OutputPosition + 8, Profile.Uuid.High); + context.Memory.WriteInt64(outputPosition, profile.Uuid.Low); + context.Memory.WriteInt64(outputPosition + 8, profile.Uuid.High); } return 0; } // GetLastOpenedUser() -> nn::account::Uid - public long GetLastOpenedUser(ServiceCtx Context) + public long GetLastOpenedUser(ServiceCtx context) { - UserProfile LastOpened = Context.Device.System.State.LastOpenUser; + UserProfile lastOpened = context.Device.System.State.LastOpenUser; - LastOpened.Uuid.Write(Context.ResponseData); + lastOpened.Uuid.Write(context.ResponseData); return 0; } // GetProfile(nn::account::Uid) -> object<nn::account::profile::IProfile> - public long GetProfile(ServiceCtx Context) + public long GetProfile(ServiceCtx context) { - UInt128 Uuid = new UInt128( - Context.RequestData.ReadInt64(), - Context.RequestData.ReadInt64()); + UInt128 uuid = new UInt128( + context.RequestData.ReadInt64(), + context.RequestData.ReadInt64()); - if (!Context.Device.System.State.TryGetUser(Uuid, out UserProfile Profile)) + if (!context.Device.System.State.TryGetUser(uuid, out UserProfile profile)) { - Logger.PrintWarning(LogClass.ServiceAcc, $"User 0x{Uuid} not found!"); + Logger.PrintWarning(LogClass.ServiceAcc, $"User 0x{uuid} not found!"); return MakeError(ErrorModule.Account, AccErr.UserNotFound); } - MakeObject(Context, new IProfile(Profile)); + MakeObject(context, new IProfile(profile)); return 0; } // IsUserRegistrationRequestPermitted(u64, pid) -> bool - public long IsUserRegistrationRequestPermitted(ServiceCtx Context) + public long IsUserRegistrationRequestPermitted(ServiceCtx context) { - long Unknown = Context.RequestData.ReadInt64(); + long unknown = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceAcc, $"Stubbed. Unknown: {Unknown}"); + Logger.PrintStub(LogClass.ServiceAcc, $"Stubbed. Unknown: {unknown}"); - Context.ResponseData.Write(false); + context.ResponseData.Write(false); return 0; } // TrySelectUserWithoutInteraction(bool) -> nn::account::Uid - public long TrySelectUserWithoutInteraction(ServiceCtx Context) + public long TrySelectUserWithoutInteraction(ServiceCtx context) { - bool Unknown = Context.RequestData.ReadBoolean(); + bool unknown = context.RequestData.ReadBoolean(); - Logger.PrintStub(LogClass.ServiceAcc, $"Stubbed. Unknown: {Unknown}"); + Logger.PrintStub(LogClass.ServiceAcc, $"Stubbed. Unknown: {unknown}"); - UserProfile Profile = Context.Device.System.State.LastOpenUser; + UserProfile profile = context.Device.System.State.LastOpenUser; - Profile.Uuid.Write(Context.ResponseData); + profile.Uuid.Write(context.ResponseData); return 0; } // InitializeApplicationInfo(u64, pid) - public long InitializeApplicationInfo(ServiceCtx Context) + public long InitializeApplicationInfo(ServiceCtx context) { - long Unknown = Context.RequestData.ReadInt64(); + long unknown = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceAcc, $"Stubbed. Unknown: {Unknown}"); + Logger.PrintStub(LogClass.ServiceAcc, $"Stubbed. Unknown: {unknown}"); return 0; } // GetBaasAccountManagerForApplication(nn::account::Uid) -> object<nn::account::baas::IManagerForApplication> - public long GetBaasAccountManagerForApplication(ServiceCtx Context) + public long GetBaasAccountManagerForApplication(ServiceCtx context) { - UInt128 Uuid = new UInt128( - Context.RequestData.ReadInt64(), - Context.RequestData.ReadInt64()); + UInt128 uuid = new UInt128( + context.RequestData.ReadInt64(), + context.RequestData.ReadInt64()); - MakeObject(Context, new IManagerForApplication(Uuid)); + MakeObject(context, new IManagerForApplication(uuid)); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Acc/IManagerForApplication.cs b/Ryujinx.HLE/HOS/Services/Acc/IManagerForApplication.cs index 9312b2bc..93b4b4a1 100644 --- a/Ryujinx.HLE/HOS/Services/Acc/IManagerForApplication.cs +++ b/Ryujinx.HLE/HOS/Services/Acc/IManagerForApplication.cs @@ -7,25 +7,25 @@ namespace Ryujinx.HLE.HOS.Services.Acc { class IManagerForApplication : IpcService { - private UInt128 Uuid; + private UInt128 _uuid; - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - public IManagerForApplication(UInt128 Uuid) + public IManagerForApplication(UInt128 uuid) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, CheckAvailability }, { 1, GetAccountId } }; - this.Uuid = Uuid; + _uuid = uuid; } // CheckAvailability() - public long CheckAvailability(ServiceCtx Context) + public long CheckAvailability(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceAcc, "Stubbed."); @@ -33,13 +33,13 @@ namespace Ryujinx.HLE.HOS.Services.Acc } // GetAccountId() -> nn::account::NetworkServiceAccountId - public long GetAccountId(ServiceCtx Context) + public long GetAccountId(ServiceCtx context) { - long NetworkServiceAccountId = 0xcafe; + long networkServiceAccountId = 0xcafe; - Logger.PrintStub(LogClass.ServiceAcc, $"Stubbed. NetworkServiceAccountId: {NetworkServiceAccountId}"); + Logger.PrintStub(LogClass.ServiceAcc, $"Stubbed. NetworkServiceAccountId: {networkServiceAccountId}"); - Context.ResponseData.Write(NetworkServiceAccountId); + context.ResponseData.Write(networkServiceAccountId); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Acc/IProfile.cs b/Ryujinx.HLE/HOS/Services/Acc/IProfile.cs index 1d1a15cb..c50e9540 100644 --- a/Ryujinx.HLE/HOS/Services/Acc/IProfile.cs +++ b/Ryujinx.HLE/HOS/Services/Acc/IProfile.cs @@ -12,76 +12,76 @@ namespace Ryujinx.HLE.HOS.Services.Acc { class IProfile : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private UserProfile Profile; + private UserProfile _profile; - private Stream ProfilePictureStream; + private Stream _profilePictureStream; - public IProfile(UserProfile Profile) + public IProfile(UserProfile profile) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, Get }, { 1, GetBase }, { 10, GetImageSize }, - { 11, LoadImage }, + { 11, LoadImage } }; - this.Profile = Profile; + _profile = profile; - ProfilePictureStream = Assembly.GetCallingAssembly().GetManifestResourceStream("Ryujinx.HLE.RyujinxProfileImage.jpg"); + _profilePictureStream = Assembly.GetCallingAssembly().GetManifestResourceStream("Ryujinx.HLE.RyujinxProfileImage.jpg"); } - public long Get(ServiceCtx Context) + public long Get(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceAcc, "Stubbed."); - long Position = Context.Request.ReceiveBuff[0].Position; + long position = context.Request.ReceiveBuff[0].Position; - MemoryHelper.FillWithZeros(Context.Memory, Position, 0x80); + MemoryHelper.FillWithZeros(context.Memory, position, 0x80); - Context.Memory.WriteInt32(Position, 0); - Context.Memory.WriteInt32(Position + 4, 1); - Context.Memory.WriteInt64(Position + 8, 1); + context.Memory.WriteInt32(position, 0); + context.Memory.WriteInt32(position + 4, 1); + context.Memory.WriteInt64(position + 8, 1); - return GetBase(Context); + return GetBase(context); } - public long GetBase(ServiceCtx Context) + public long GetBase(ServiceCtx context) { - Profile.Uuid.Write(Context.ResponseData); + _profile.Uuid.Write(context.ResponseData); - Context.ResponseData.Write(Profile.LastModifiedTimestamp); + context.ResponseData.Write(_profile.LastModifiedTimestamp); - byte[] Username = StringUtils.GetFixedLengthBytes(Profile.Name, 0x20, Encoding.UTF8); + byte[] username = StringUtils.GetFixedLengthBytes(_profile.Name, 0x20, Encoding.UTF8); - Context.ResponseData.Write(Username); + context.ResponseData.Write(username); return 0; } - private long LoadImage(ServiceCtx Context) + private long LoadImage(ServiceCtx context) { - long BufferPosition = Context.Request.ReceiveBuff[0].Position; - long BufferLen = Context.Request.ReceiveBuff[0].Size; + long bufferPosition = context.Request.ReceiveBuff[0].Position; + long bufferLen = context.Request.ReceiveBuff[0].Size; - byte[] ProfilePictureData = new byte[BufferLen]; + byte[] profilePictureData = new byte[bufferLen]; - ProfilePictureStream.Read(ProfilePictureData, 0, ProfilePictureData.Length); + _profilePictureStream.Read(profilePictureData, 0, profilePictureData.Length); - Context.Memory.WriteBytes(BufferPosition, ProfilePictureData); + context.Memory.WriteBytes(bufferPosition, profilePictureData); - Context.ResponseData.Write(ProfilePictureStream.Length); + context.ResponseData.Write(_profilePictureStream.Length); return 0; } - private long GetImageSize(ServiceCtx Context) + private long GetImageSize(ServiceCtx context) { - Context.ResponseData.Write(ProfilePictureStream.Length); + context.ResponseData.Write(_profilePictureStream.Length); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Am/IAllSystemAppletProxiesService.cs b/Ryujinx.HLE/HOS/Services/Am/IAllSystemAppletProxiesService.cs index 2d44526a..0d067b16 100644 --- a/Ryujinx.HLE/HOS/Services/Am/IAllSystemAppletProxiesService.cs +++ b/Ryujinx.HLE/HOS/Services/Am/IAllSystemAppletProxiesService.cs @@ -5,21 +5,21 @@ namespace Ryujinx.HLE.HOS.Services.Am { class IAllSystemAppletProxiesService : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IAllSystemAppletProxiesService() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 100, OpenSystemAppletProxy } }; } - public long OpenSystemAppletProxy(ServiceCtx Context) + public long OpenSystemAppletProxy(ServiceCtx context) { - MakeObject(Context, new ISystemAppletProxy()); + MakeObject(context, new ISystemAppletProxy()); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Am/IApplicationCreator.cs b/Ryujinx.HLE/HOS/Services/Am/IApplicationCreator.cs index c5ed09f5..eac609ed 100644 --- a/Ryujinx.HLE/HOS/Services/Am/IApplicationCreator.cs +++ b/Ryujinx.HLE/HOS/Services/Am/IApplicationCreator.cs @@ -5,13 +5,13 @@ namespace Ryujinx.HLE.HOS.Services.Am { class IApplicationCreator : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IApplicationCreator() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { //... }; diff --git a/Ryujinx.HLE/HOS/Services/Am/IApplicationFunctions.cs b/Ryujinx.HLE/HOS/Services/Am/IApplicationFunctions.cs index 1934798b..fbc5dee5 100644 --- a/Ryujinx.HLE/HOS/Services/Am/IApplicationFunctions.cs +++ b/Ryujinx.HLE/HOS/Services/Am/IApplicationFunctions.cs @@ -6,13 +6,13 @@ namespace Ryujinx.HLE.HOS.Services.Am { class IApplicationFunctions : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IApplicationFunctions() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 1, PopLaunchParameter }, { 20, EnsureSaveData }, @@ -26,88 +26,88 @@ namespace Ryujinx.HLE.HOS.Services.Am }; } - public long PopLaunchParameter(ServiceCtx Context) + public long PopLaunchParameter(ServiceCtx context) { //Only the first 0x18 bytes of the Data seems to be actually used. - MakeObject(Context, new IStorage(StorageHelper.MakeLaunchParams())); + MakeObject(context, new IStorage(StorageHelper.MakeLaunchParams())); return 0; } - public long EnsureSaveData(ServiceCtx Context) + public long EnsureSaveData(ServiceCtx context) { - long UIdLow = Context.RequestData.ReadInt64(); - long UIdHigh = Context.RequestData.ReadInt64(); + long uIdLow = context.RequestData.ReadInt64(); + long uIdHigh = context.RequestData.ReadInt64(); Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); - Context.ResponseData.Write(0L); + context.ResponseData.Write(0L); return 0; } - public long GetDesiredLanguage(ServiceCtx Context) + public long GetDesiredLanguage(ServiceCtx context) { - Context.ResponseData.Write(Context.Device.System.State.DesiredLanguageCode); + context.ResponseData.Write(context.Device.System.State.DesiredLanguageCode); return 0; } - public long SetTerminateResult(ServiceCtx Context) + public long SetTerminateResult(ServiceCtx context) { - int ErrorCode = Context.RequestData.ReadInt32(); + int errorCode = context.RequestData.ReadInt32(); - string Result = GetFormattedErrorCode(ErrorCode); + string result = GetFormattedErrorCode(errorCode); - Logger.PrintInfo(LogClass.ServiceAm, $"Result = 0x{ErrorCode:x8} ({Result})."); + Logger.PrintInfo(LogClass.ServiceAm, $"Result = 0x{errorCode:x8} ({result})."); return 0; } - private string GetFormattedErrorCode(int ErrorCode) + private string GetFormattedErrorCode(int errorCode) { - int Module = (ErrorCode >> 0) & 0x1ff; - int Description = (ErrorCode >> 9) & 0x1fff; + int module = (errorCode >> 0) & 0x1ff; + int description = (errorCode >> 9) & 0x1fff; - return $"{(2000 + Module):d4}-{Description:d4}"; + return $"{(2000 + module):d4}-{description:d4}"; } - public long GetDisplayVersion(ServiceCtx Context) + public long GetDisplayVersion(ServiceCtx context) { //FIXME: Need to check correct version on a switch. - Context.ResponseData.Write(1L); - Context.ResponseData.Write(0L); + context.ResponseData.Write(1L); + context.ResponseData.Write(0L); return 0; } - public long NotifyRunning(ServiceCtx Context) + public long NotifyRunning(ServiceCtx context) { - Context.ResponseData.Write(1); + context.ResponseData.Write(1); return 0; } - public long GetPseudoDeviceId(ServiceCtx Context) + public long GetPseudoDeviceId(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); - Context.ResponseData.Write(0L); - Context.ResponseData.Write(0L); + context.ResponseData.Write(0L); + context.ResponseData.Write(0L); return 0; } - public long InitializeGamePlayRecording(ServiceCtx Context) + public long InitializeGamePlayRecording(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); return 0; } - public long SetGamePlayRecordingState(ServiceCtx Context) + public long SetGamePlayRecordingState(ServiceCtx context) { - int State = Context.RequestData.ReadInt32(); + int state = context.RequestData.ReadInt32(); Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); diff --git a/Ryujinx.HLE/HOS/Services/Am/IApplicationProxy.cs b/Ryujinx.HLE/HOS/Services/Am/IApplicationProxy.cs index 2aaeda78..fd785a70 100644 --- a/Ryujinx.HLE/HOS/Services/Am/IApplicationProxy.cs +++ b/Ryujinx.HLE/HOS/Services/Am/IApplicationProxy.cs @@ -5,13 +5,13 @@ namespace Ryujinx.HLE.HOS.Services.Am { class IApplicationProxy : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IApplicationProxy() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, GetCommonStateGetter }, { 1, GetSelfController }, @@ -24,58 +24,58 @@ namespace Ryujinx.HLE.HOS.Services.Am }; } - public long GetCommonStateGetter(ServiceCtx Context) + public long GetCommonStateGetter(ServiceCtx context) { - MakeObject(Context, new ICommonStateGetter(Context.Device.System)); + MakeObject(context, new ICommonStateGetter(context.Device.System)); return 0; } - public long GetSelfController(ServiceCtx Context) + public long GetSelfController(ServiceCtx context) { - MakeObject(Context, new ISelfController(Context.Device.System)); + MakeObject(context, new ISelfController(context.Device.System)); return 0; } - public long GetWindowController(ServiceCtx Context) + public long GetWindowController(ServiceCtx context) { - MakeObject(Context, new IWindowController()); + MakeObject(context, new IWindowController()); return 0; } - public long GetAudioController(ServiceCtx Context) + public long GetAudioController(ServiceCtx context) { - MakeObject(Context, new IAudioController()); + MakeObject(context, new IAudioController()); return 0; } - public long GetDisplayController(ServiceCtx Context) + public long GetDisplayController(ServiceCtx context) { - MakeObject(Context, new IDisplayController()); + MakeObject(context, new IDisplayController()); return 0; } - public long GetLibraryAppletCreator(ServiceCtx Context) + public long GetLibraryAppletCreator(ServiceCtx context) { - MakeObject(Context, new ILibraryAppletCreator()); + MakeObject(context, new ILibraryAppletCreator()); return 0; } - public long GetApplicationFunctions(ServiceCtx Context) + public long GetApplicationFunctions(ServiceCtx context) { - MakeObject(Context, new IApplicationFunctions()); + MakeObject(context, new IApplicationFunctions()); return 0; } - public long GetDebugFunctions(ServiceCtx Context) + public long GetDebugFunctions(ServiceCtx context) { - MakeObject(Context, new IDebugFunctions()); + MakeObject(context, new IDebugFunctions()); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Am/IApplicationProxyService.cs b/Ryujinx.HLE/HOS/Services/Am/IApplicationProxyService.cs index fb518af9..88792a16 100644 --- a/Ryujinx.HLE/HOS/Services/Am/IApplicationProxyService.cs +++ b/Ryujinx.HLE/HOS/Services/Am/IApplicationProxyService.cs @@ -5,21 +5,21 @@ namespace Ryujinx.HLE.HOS.Services.Am { class IApplicationProxyService : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IApplicationProxyService() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, OpenApplicationProxy } }; } - public long OpenApplicationProxy(ServiceCtx Context) + public long OpenApplicationProxy(ServiceCtx context) { - MakeObject(Context, new IApplicationProxy()); + MakeObject(context, new IApplicationProxy()); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Am/IAudioController.cs b/Ryujinx.HLE/HOS/Services/Am/IAudioController.cs index 062f2d86..a03a3266 100644 --- a/Ryujinx.HLE/HOS/Services/Am/IAudioController.cs +++ b/Ryujinx.HLE/HOS/Services/Am/IAudioController.cs @@ -6,13 +6,13 @@ namespace Ryujinx.HLE.HOS.Services.Am { class IAudioController : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IAudioController() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, SetExpectedMasterVolume }, { 1, GetMainAppletExpectedMasterVolume }, @@ -22,47 +22,47 @@ namespace Ryujinx.HLE.HOS.Services.Am }; } - public long SetExpectedMasterVolume(ServiceCtx Context) + public long SetExpectedMasterVolume(ServiceCtx context) { - float AppletVolume = Context.RequestData.ReadSingle(); - float LibraryAppletVolume = Context.RequestData.ReadSingle(); + float appletVolume = context.RequestData.ReadSingle(); + float libraryAppletVolume = context.RequestData.ReadSingle(); Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); return 0; } - public long GetMainAppletExpectedMasterVolume(ServiceCtx Context) + public long GetMainAppletExpectedMasterVolume(ServiceCtx context) { - Context.ResponseData.Write(1f); + context.ResponseData.Write(1f); Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); return 0; } - public long GetLibraryAppletExpectedMasterVolume(ServiceCtx Context) + public long GetLibraryAppletExpectedMasterVolume(ServiceCtx context) { - Context.ResponseData.Write(1f); + context.ResponseData.Write(1f); Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); return 0; } - public long ChangeMainAppletMasterVolume(ServiceCtx Context) + public long ChangeMainAppletMasterVolume(ServiceCtx context) { - float Unknown0 = Context.RequestData.ReadSingle(); - long Unknown1 = Context.RequestData.ReadInt64(); + float unknown0 = context.RequestData.ReadSingle(); + long unknown1 = context.RequestData.ReadInt64(); Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); return 0; } - public long SetTransparentVolumeRate(ServiceCtx Context) + public long SetTransparentVolumeRate(ServiceCtx context) { - float Unknown0 = Context.RequestData.ReadSingle(); + float unknown0 = context.RequestData.ReadSingle(); Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); diff --git a/Ryujinx.HLE/HOS/Services/Am/ICommonStateGetter.cs b/Ryujinx.HLE/HOS/Services/Am/ICommonStateGetter.cs index 2feaf8fc..8ec42152 100644 --- a/Ryujinx.HLE/HOS/Services/Am/ICommonStateGetter.cs +++ b/Ryujinx.HLE/HOS/Services/Am/ICommonStateGetter.cs @@ -10,15 +10,15 @@ namespace Ryujinx.HLE.HOS.Services.Am { class ICommonStateGetter : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private KEvent DisplayResolutionChangeEvent; + private KEvent _displayResolutionChangeEvent; - public ICommonStateGetter(Horizon System) + public ICommonStateGetter(Horizon system) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, GetEventHandle }, { 1, ReceiveMessage }, @@ -30,89 +30,89 @@ namespace Ryujinx.HLE.HOS.Services.Am { 61, GetDefaultDisplayResolutionChangeEvent } }; - DisplayResolutionChangeEvent = new KEvent(System); + _displayResolutionChangeEvent = new KEvent(system); } - public long GetEventHandle(ServiceCtx Context) + public long GetEventHandle(ServiceCtx context) { - KEvent Event = Context.Device.System.AppletState.MessageEvent; + KEvent Event = context.Device.System.AppletState.MessageEvent; - if (Context.Process.HandleTable.GenerateHandle(Event.ReadableEvent, out int Handle) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(Event.ReadableEvent, out int handle) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle); return 0; } - public long ReceiveMessage(ServiceCtx Context) + public long ReceiveMessage(ServiceCtx context) { - if (!Context.Device.System.AppletState.TryDequeueMessage(out MessageInfo Message)) + if (!context.Device.System.AppletState.TryDequeueMessage(out MessageInfo message)) { return MakeError(ErrorModule.Am, AmErr.NoMessages); } - Context.ResponseData.Write((int)Message); + context.ResponseData.Write((int)message); return 0; } - public long GetOperationMode(ServiceCtx Context) + public long GetOperationMode(ServiceCtx context) { - OperationMode Mode = Context.Device.System.State.DockedMode + OperationMode mode = context.Device.System.State.DockedMode ? OperationMode.Docked : OperationMode.Handheld; - Context.ResponseData.Write((byte)Mode); + context.ResponseData.Write((byte)mode); return 0; } - public long GetPerformanceMode(ServiceCtx Context) + public long GetPerformanceMode(ServiceCtx context) { - Apm.PerformanceMode Mode = Context.Device.System.State.DockedMode + Apm.PerformanceMode mode = context.Device.System.State.DockedMode ? Apm.PerformanceMode.Docked : Apm.PerformanceMode.Handheld; - Context.ResponseData.Write((int)Mode); + context.ResponseData.Write((int)mode); return 0; } - public long GetBootMode(ServiceCtx Context) + public long GetBootMode(ServiceCtx context) { - Context.ResponseData.Write((byte)0); //Unknown value. + context.ResponseData.Write((byte)0); //Unknown value. Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); return 0; } - public long GetCurrentFocusState(ServiceCtx Context) + public long GetCurrentFocusState(ServiceCtx context) { - Context.ResponseData.Write((byte)Context.Device.System.AppletState.FocusState); + context.ResponseData.Write((byte)context.Device.System.AppletState.FocusState); return 0; } - public long GetDefaultDisplayResolution(ServiceCtx Context) + public long GetDefaultDisplayResolution(ServiceCtx context) { - Context.ResponseData.Write(1280); - Context.ResponseData.Write(720); + context.ResponseData.Write(1280); + context.ResponseData.Write(720); return 0; } - public long GetDefaultDisplayResolutionChangeEvent(ServiceCtx Context) + public long GetDefaultDisplayResolutionChangeEvent(ServiceCtx context) { - if (Context.Process.HandleTable.GenerateHandle(DisplayResolutionChangeEvent.ReadableEvent, out int Handle) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(_displayResolutionChangeEvent.ReadableEvent, out int handle) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle); Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); diff --git a/Ryujinx.HLE/HOS/Services/Am/IDebugFunctions.cs b/Ryujinx.HLE/HOS/Services/Am/IDebugFunctions.cs index d86743c0..f7ea253d 100644 --- a/Ryujinx.HLE/HOS/Services/Am/IDebugFunctions.cs +++ b/Ryujinx.HLE/HOS/Services/Am/IDebugFunctions.cs @@ -5,13 +5,13 @@ namespace Ryujinx.HLE.HOS.Services.Am { class IDebugFunctions : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IDebugFunctions() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { //... }; diff --git a/Ryujinx.HLE/HOS/Services/Am/IDisplayController.cs b/Ryujinx.HLE/HOS/Services/Am/IDisplayController.cs index c4d49579..91fd864c 100644 --- a/Ryujinx.HLE/HOS/Services/Am/IDisplayController.cs +++ b/Ryujinx.HLE/HOS/Services/Am/IDisplayController.cs @@ -5,13 +5,13 @@ namespace Ryujinx.HLE.HOS.Services.Am { class IDisplayController : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IDisplayController() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { //... }; diff --git a/Ryujinx.HLE/HOS/Services/Am/IGlobalStateController.cs b/Ryujinx.HLE/HOS/Services/Am/IGlobalStateController.cs index e646327f..b9387661 100644 --- a/Ryujinx.HLE/HOS/Services/Am/IGlobalStateController.cs +++ b/Ryujinx.HLE/HOS/Services/Am/IGlobalStateController.cs @@ -5,13 +5,13 @@ namespace Ryujinx.HLE.HOS.Services.Am { class IGlobalStateController : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IGlobalStateController() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { //... }; diff --git a/Ryujinx.HLE/HOS/Services/Am/IHomeMenuFunctions.cs b/Ryujinx.HLE/HOS/Services/Am/IHomeMenuFunctions.cs index 3f026e2f..db116f33 100644 --- a/Ryujinx.HLE/HOS/Services/Am/IHomeMenuFunctions.cs +++ b/Ryujinx.HLE/HOS/Services/Am/IHomeMenuFunctions.cs @@ -8,39 +8,39 @@ namespace Ryujinx.HLE.HOS.Services.Am { class IHomeMenuFunctions : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private KEvent ChannelEvent; + private KEvent _channelEvent; - public IHomeMenuFunctions(Horizon System) + public IHomeMenuFunctions(Horizon system) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 10, RequestToGetForeground }, { 21, GetPopFromGeneralChannelEvent } }; //ToDo: Signal this Event somewhere in future. - ChannelEvent = new KEvent(System); + _channelEvent = new KEvent(system); } - public long RequestToGetForeground(ServiceCtx Context) + public long RequestToGetForeground(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); return 0; } - public long GetPopFromGeneralChannelEvent(ServiceCtx Context) + public long GetPopFromGeneralChannelEvent(ServiceCtx context) { - if (Context.Process.HandleTable.GenerateHandle(ChannelEvent.ReadableEvent, out int Handle) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(_channelEvent.ReadableEvent, out int handle) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle); Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); diff --git a/Ryujinx.HLE/HOS/Services/Am/ILibraryAppletAccessor.cs b/Ryujinx.HLE/HOS/Services/Am/ILibraryAppletAccessor.cs index 9e0d0e70..7c4aa16c 100644 --- a/Ryujinx.HLE/HOS/Services/Am/ILibraryAppletAccessor.cs +++ b/Ryujinx.HLE/HOS/Services/Am/ILibraryAppletAccessor.cs @@ -8,15 +8,15 @@ namespace Ryujinx.HLE.HOS.Services.Am { class ILibraryAppletAccessor : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private KEvent StateChangedEvent; + private KEvent _stateChangedEvent; - public ILibraryAppletAccessor(Horizon System) + public ILibraryAppletAccessor(Horizon system) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, GetAppletStateChangedEvent }, { 10, Start }, @@ -25,49 +25,49 @@ namespace Ryujinx.HLE.HOS.Services.Am { 101, PopOutData } }; - StateChangedEvent = new KEvent(System); + _stateChangedEvent = new KEvent(system); } - public long GetAppletStateChangedEvent(ServiceCtx Context) + public long GetAppletStateChangedEvent(ServiceCtx context) { - StateChangedEvent.ReadableEvent.Signal(); + _stateChangedEvent.ReadableEvent.Signal(); - if (Context.Process.HandleTable.GenerateHandle(StateChangedEvent.ReadableEvent, out int Handle) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(_stateChangedEvent.ReadableEvent, out int handle) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle); Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); return 0; } - public long Start(ServiceCtx Context) + public long Start(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); return 0; } - public long GetResult(ServiceCtx Context) + public long GetResult(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); return 0; } - public long PushInData(ServiceCtx Context) + public long PushInData(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); return 0; } - public long PopOutData(ServiceCtx Context) + public long PopOutData(ServiceCtx context) { - MakeObject(Context, new IStorage(StorageHelper.MakeLaunchParams())); + MakeObject(context, new IStorage(StorageHelper.MakeLaunchParams())); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Am/ILibraryAppletCreator.cs b/Ryujinx.HLE/HOS/Services/Am/ILibraryAppletCreator.cs index 5535a43c..3f88c545 100644 --- a/Ryujinx.HLE/HOS/Services/Am/ILibraryAppletCreator.cs +++ b/Ryujinx.HLE/HOS/Services/Am/ILibraryAppletCreator.cs @@ -5,31 +5,31 @@ namespace Ryujinx.HLE.HOS.Services.Am { class ILibraryAppletCreator : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public ILibraryAppletCreator() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, CreateLibraryApplet }, { 10, CreateStorage } }; } - public long CreateLibraryApplet(ServiceCtx Context) + public long CreateLibraryApplet(ServiceCtx context) { - MakeObject(Context, new ILibraryAppletAccessor(Context.Device.System)); + MakeObject(context, new ILibraryAppletAccessor(context.Device.System)); return 0; } - public long CreateStorage(ServiceCtx Context) + public long CreateStorage(ServiceCtx context) { - long Size = Context.RequestData.ReadInt64(); + long size = context.RequestData.ReadInt64(); - MakeObject(Context, new IStorage(new byte[Size])); + MakeObject(context, new IStorage(new byte[size])); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Am/ISelfController.cs b/Ryujinx.HLE/HOS/Services/Am/ISelfController.cs index 2abaee2e..dc922037 100644 --- a/Ryujinx.HLE/HOS/Services/Am/ISelfController.cs +++ b/Ryujinx.HLE/HOS/Services/Am/ISelfController.cs @@ -8,17 +8,17 @@ namespace Ryujinx.HLE.HOS.Services.Am { class ISelfController : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private KEvent LaunchableEvent; + private KEvent _launchableEvent; - private int IdleTimeDetectionExtension; + private int _idleTimeDetectionExtension; - public ISelfController(Horizon System) + public ISelfController(Horizon system) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, Exit }, { 1, LockExit }, @@ -36,114 +36,114 @@ namespace Ryujinx.HLE.HOS.Services.Am { 63, GetIdleTimeDetectionExtension } }; - LaunchableEvent = new KEvent(System); + _launchableEvent = new KEvent(system); } - public long Exit(ServiceCtx Context) + public long Exit(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); return 0; } - public long LockExit(ServiceCtx Context) + public long LockExit(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); return 0; } - public long UnlockExit(ServiceCtx Context) + public long UnlockExit(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); return 0; } - public long GetLibraryAppletLaunchableEvent(ServiceCtx Context) + public long GetLibraryAppletLaunchableEvent(ServiceCtx context) { - LaunchableEvent.ReadableEvent.Signal(); + _launchableEvent.ReadableEvent.Signal(); - if (Context.Process.HandleTable.GenerateHandle(LaunchableEvent.ReadableEvent, out int Handle) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(_launchableEvent.ReadableEvent, out int handle) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle); Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); return 0; } - public long SetScreenShotPermission(ServiceCtx Context) + public long SetScreenShotPermission(ServiceCtx context) { - bool Enable = Context.RequestData.ReadByte() != 0 ? true : false; + bool enable = context.RequestData.ReadByte() != 0; Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); return 0; } - public long SetOperationModeChangedNotification(ServiceCtx Context) + public long SetOperationModeChangedNotification(ServiceCtx context) { - bool Enable = Context.RequestData.ReadByte() != 0 ? true : false; + bool enable = context.RequestData.ReadByte() != 0; Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); return 0; } - public long SetPerformanceModeChangedNotification(ServiceCtx Context) + public long SetPerformanceModeChangedNotification(ServiceCtx context) { - bool Enable = Context.RequestData.ReadByte() != 0 ? true : false; + bool enable = context.RequestData.ReadByte() != 0; Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); return 0; } - public long SetFocusHandlingMode(ServiceCtx Context) + public long SetFocusHandlingMode(ServiceCtx context) { - bool Flag1 = Context.RequestData.ReadByte() != 0 ? true : false; - bool Flag2 = Context.RequestData.ReadByte() != 0 ? true : false; - bool Flag3 = Context.RequestData.ReadByte() != 0 ? true : false; + bool flag1 = context.RequestData.ReadByte() != 0; + bool flag2 = context.RequestData.ReadByte() != 0; + bool flag3 = context.RequestData.ReadByte() != 0; Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); return 0; } - public long SetRestartMessageEnabled(ServiceCtx Context) + public long SetRestartMessageEnabled(ServiceCtx context) { - bool Enable = Context.RequestData.ReadByte() != 0 ? true : false; + bool enable = context.RequestData.ReadByte() != 0; Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); return 0; } - public long SetOutOfFocusSuspendingEnabled(ServiceCtx Context) + public long SetOutOfFocusSuspendingEnabled(ServiceCtx context) { - bool Enable = Context.RequestData.ReadByte() != 0 ? true : false; + bool enable = context.RequestData.ReadByte() != 0; Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); return 0; } - public long SetScreenShotImageOrientation(ServiceCtx Context) + public long SetScreenShotImageOrientation(ServiceCtx context) { - int Orientation = Context.RequestData.ReadInt32(); + int orientation = context.RequestData.ReadInt32(); Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); return 0; } - public long SetHandlesRequestToDisplay(ServiceCtx Context) + public long SetHandlesRequestToDisplay(ServiceCtx context) { - bool Enable = Context.RequestData.ReadByte() != 0 ? true : false; + bool enable = context.RequestData.ReadByte() != 0; Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); @@ -151,21 +151,21 @@ namespace Ryujinx.HLE.HOS.Services.Am } // SetIdleTimeDetectionExtension(u32) - public long SetIdleTimeDetectionExtension(ServiceCtx Context) + public long SetIdleTimeDetectionExtension(ServiceCtx context) { - IdleTimeDetectionExtension = Context.RequestData.ReadInt32(); + _idleTimeDetectionExtension = context.RequestData.ReadInt32(); - Logger.PrintStub(LogClass.ServiceAm, $"Stubbed. IdleTimeDetectionExtension: {IdleTimeDetectionExtension}"); + Logger.PrintStub(LogClass.ServiceAm, $"Stubbed. IdleTimeDetectionExtension: {_idleTimeDetectionExtension}"); return 0; } // GetIdleTimeDetectionExtension() -> u32 - public long GetIdleTimeDetectionExtension(ServiceCtx Context) + public long GetIdleTimeDetectionExtension(ServiceCtx context) { - Context.ResponseData.Write(IdleTimeDetectionExtension); + context.ResponseData.Write(_idleTimeDetectionExtension); - Logger.PrintStub(LogClass.ServiceAm, $"Stubbed. IdleTimeDetectionExtension: {IdleTimeDetectionExtension}"); + Logger.PrintStub(LogClass.ServiceAm, $"Stubbed. IdleTimeDetectionExtension: {_idleTimeDetectionExtension}"); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Am/IStorage.cs b/Ryujinx.HLE/HOS/Services/Am/IStorage.cs index 10778122..c39a847b 100644 --- a/Ryujinx.HLE/HOS/Services/Am/IStorage.cs +++ b/Ryujinx.HLE/HOS/Services/Am/IStorage.cs @@ -5,25 +5,25 @@ namespace Ryujinx.HLE.HOS.Services.Am { class IStorage : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - public byte[] Data { get; private set; } + public byte[] Data { get; } - public IStorage(byte[] Data) + public IStorage(byte[] data) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, Open } }; - this.Data = Data; + Data = data; } - public long Open(ServiceCtx Context) + public long Open(ServiceCtx context) { - MakeObject(Context, new IStorageAccessor(this)); + MakeObject(context, new IStorageAccessor(this)); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Am/IStorageAccessor.cs b/Ryujinx.HLE/HOS/Services/Am/IStorageAccessor.cs index a60cf149..ac54069a 100644 --- a/Ryujinx.HLE/HOS/Services/Am/IStorageAccessor.cs +++ b/Ryujinx.HLE/HOS/Services/Am/IStorageAccessor.cs @@ -6,76 +6,76 @@ namespace Ryujinx.HLE.HOS.Services.Am { class IStorageAccessor : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private IStorage Storage; + private IStorage _storage; - public IStorageAccessor(IStorage Storage) + public IStorageAccessor(IStorage storage) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, GetSize }, { 10, Write }, { 11, Read } }; - this.Storage = Storage; + _storage = storage; } - public long GetSize(ServiceCtx Context) + public long GetSize(ServiceCtx context) { - Context.ResponseData.Write((long)Storage.Data.Length); + context.ResponseData.Write((long)_storage.Data.Length); return 0; } - public long Write(ServiceCtx Context) + public long Write(ServiceCtx context) { //TODO: Error conditions. - long WritePosition = Context.RequestData.ReadInt64(); + long writePosition = context.RequestData.ReadInt64(); - (long Position, long Size) = Context.Request.GetBufferType0x21(); + (long position, long size) = context.Request.GetBufferType0x21(); - if (Size > 0) + if (size > 0) { - long MaxSize = Storage.Data.Length - WritePosition; + long maxSize = _storage.Data.Length - writePosition; - if (Size > MaxSize) + if (size > maxSize) { - Size = MaxSize; + size = maxSize; } - byte[] Data = Context.Memory.ReadBytes(Position, Size); + byte[] data = context.Memory.ReadBytes(position, size); - Buffer.BlockCopy(Data, 0, Storage.Data, (int)WritePosition, (int)Size); + Buffer.BlockCopy(data, 0, _storage.Data, (int)writePosition, (int)size); } return 0; } - public long Read(ServiceCtx Context) + public long Read(ServiceCtx context) { //TODO: Error conditions. - long ReadPosition = Context.RequestData.ReadInt64(); + long readPosition = context.RequestData.ReadInt64(); - (long Position, long Size) = Context.Request.GetBufferType0x22(); + (long position, long size) = context.Request.GetBufferType0x22(); - byte[] Data; + byte[] data; - if (Storage.Data.Length > Size) + if (_storage.Data.Length > size) { - Data = new byte[Size]; + data = new byte[size]; - Buffer.BlockCopy(Storage.Data, 0, Data, 0, (int)Size); + Buffer.BlockCopy(_storage.Data, 0, data, 0, (int)size); } else { - Data = Storage.Data; + data = _storage.Data; } - Context.Memory.WriteBytes(Position, Data); + context.Memory.WriteBytes(position, data); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Am/ISystemAppletProxy.cs b/Ryujinx.HLE/HOS/Services/Am/ISystemAppletProxy.cs index 85e11e0f..e8a442ae 100644 --- a/Ryujinx.HLE/HOS/Services/Am/ISystemAppletProxy.cs +++ b/Ryujinx.HLE/HOS/Services/Am/ISystemAppletProxy.cs @@ -5,13 +5,13 @@ namespace Ryujinx.HLE.HOS.Services.Am { class ISystemAppletProxy : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public ISystemAppletProxy() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, GetCommonStateGetter }, { 1, GetSelfController }, @@ -26,72 +26,72 @@ namespace Ryujinx.HLE.HOS.Services.Am }; } - public long GetCommonStateGetter(ServiceCtx Context) + public long GetCommonStateGetter(ServiceCtx context) { - MakeObject(Context, new ICommonStateGetter(Context.Device.System)); + MakeObject(context, new ICommonStateGetter(context.Device.System)); return 0; } - public long GetSelfController(ServiceCtx Context) + public long GetSelfController(ServiceCtx context) { - MakeObject(Context, new ISelfController(Context.Device.System)); + MakeObject(context, new ISelfController(context.Device.System)); return 0; } - public long GetWindowController(ServiceCtx Context) + public long GetWindowController(ServiceCtx context) { - MakeObject(Context, new IWindowController()); + MakeObject(context, new IWindowController()); return 0; } - public long GetAudioController(ServiceCtx Context) + public long GetAudioController(ServiceCtx context) { - MakeObject(Context, new IAudioController()); + MakeObject(context, new IAudioController()); return 0; } - public long GetDisplayController(ServiceCtx Context) + public long GetDisplayController(ServiceCtx context) { - MakeObject(Context, new IDisplayController()); + MakeObject(context, new IDisplayController()); return 0; } - public long GetLibraryAppletCreator(ServiceCtx Context) + public long GetLibraryAppletCreator(ServiceCtx context) { - MakeObject(Context, new ILibraryAppletCreator()); + MakeObject(context, new ILibraryAppletCreator()); return 0; } - public long GetHomeMenuFunctions(ServiceCtx Context) + public long GetHomeMenuFunctions(ServiceCtx context) { - MakeObject(Context, new IHomeMenuFunctions(Context.Device.System)); + MakeObject(context, new IHomeMenuFunctions(context.Device.System)); return 0; } - public long GetGlobalStateController(ServiceCtx Context) + public long GetGlobalStateController(ServiceCtx context) { - MakeObject(Context, new IGlobalStateController()); + MakeObject(context, new IGlobalStateController()); return 0; } - public long GetApplicationCreator(ServiceCtx Context) + public long GetApplicationCreator(ServiceCtx context) { - MakeObject(Context, new IApplicationCreator()); + MakeObject(context, new IApplicationCreator()); return 0; } - public long GetDebugFunctions(ServiceCtx Context) + public long GetDebugFunctions(ServiceCtx context) { - MakeObject(Context, new IDebugFunctions()); + MakeObject(context, new IDebugFunctions()); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Am/IWindowController.cs b/Ryujinx.HLE/HOS/Services/Am/IWindowController.cs index de5137d1..aca7a666 100644 --- a/Ryujinx.HLE/HOS/Services/Am/IWindowController.cs +++ b/Ryujinx.HLE/HOS/Services/Am/IWindowController.cs @@ -6,29 +6,29 @@ namespace Ryujinx.HLE.HOS.Services.Am { class IWindowController : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IWindowController() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 1, GetAppletResourceUserId }, { 10, AcquireForegroundRights } }; } - public long GetAppletResourceUserId(ServiceCtx Context) + public long GetAppletResourceUserId(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); - Context.ResponseData.Write(0L); + context.ResponseData.Write(0L); return 0; } - public long AcquireForegroundRights(ServiceCtx Context) + public long AcquireForegroundRights(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceAm, "Stubbed."); diff --git a/Ryujinx.HLE/HOS/Services/Am/StorageHelper.cs b/Ryujinx.HLE/HOS/Services/Am/StorageHelper.cs index b97ffc1e..39a4c6dd 100644 --- a/Ryujinx.HLE/HOS/Services/Am/StorageHelper.cs +++ b/Ryujinx.HLE/HOS/Services/Am/StorageHelper.cs @@ -9,18 +9,18 @@ namespace Ryujinx.HLE.HOS.Services.Am public static byte[] MakeLaunchParams() { //Size needs to be at least 0x88 bytes otherwise application errors. - using (MemoryStream MS = new MemoryStream()) + using (MemoryStream ms = new MemoryStream()) { - BinaryWriter Writer = new BinaryWriter(MS); + BinaryWriter writer = new BinaryWriter(ms); - MS.SetLength(0x88); + ms.SetLength(0x88); - Writer.Write(LaunchParamsMagic); - Writer.Write(1); //IsAccountSelected? Only lower 8 bits actually used. - Writer.Write(1L); //User Id Low (note: User Id needs to be != 0) - Writer.Write(0L); //User Id High + writer.Write(LaunchParamsMagic); + writer.Write(1); //IsAccountSelected? Only lower 8 bits actually used. + writer.Write(1L); //User Id Low (note: User Id needs to be != 0) + writer.Write(0L); //User Id High - return MS.ToArray(); + return ms.ToArray(); } } } diff --git a/Ryujinx.HLE/HOS/Services/Apm/IManager.cs b/Ryujinx.HLE/HOS/Services/Apm/IManager.cs index 50822def..cd86e516 100644 --- a/Ryujinx.HLE/HOS/Services/Apm/IManager.cs +++ b/Ryujinx.HLE/HOS/Services/Apm/IManager.cs @@ -5,21 +5,21 @@ namespace Ryujinx.HLE.HOS.Services.Apm { class IManager : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IManager() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, OpenSession } }; } - public long OpenSession(ServiceCtx Context) + public long OpenSession(ServiceCtx context) { - MakeObject(Context, new ISession()); + MakeObject(context, new ISession()); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Apm/ISession.cs b/Ryujinx.HLE/HOS/Services/Apm/ISession.cs index d04bcfc9..cef34383 100644 --- a/Ryujinx.HLE/HOS/Services/Apm/ISession.cs +++ b/Ryujinx.HLE/HOS/Services/Apm/ISession.cs @@ -6,32 +6,32 @@ namespace Ryujinx.HLE.HOS.Services.Apm { class ISession : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public ISession() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, SetPerformanceConfiguration }, { 1, GetPerformanceConfiguration } }; } - public long SetPerformanceConfiguration(ServiceCtx Context) + public long SetPerformanceConfiguration(ServiceCtx context) { - PerformanceMode PerfMode = (PerformanceMode)Context.RequestData.ReadInt32(); - PerformanceConfiguration PerfConfig = (PerformanceConfiguration)Context.RequestData.ReadInt32(); + PerformanceMode perfMode = (PerformanceMode)context.RequestData.ReadInt32(); + PerformanceConfiguration perfConfig = (PerformanceConfiguration)context.RequestData.ReadInt32(); return 0; } - public long GetPerformanceConfiguration(ServiceCtx Context) + public long GetPerformanceConfiguration(ServiceCtx context) { - PerformanceMode PerfMode = (PerformanceMode)Context.RequestData.ReadInt32(); + PerformanceMode perfMode = (PerformanceMode)context.RequestData.ReadInt32(); - Context.ResponseData.Write((uint)PerformanceConfiguration.PerformanceConfiguration1); + context.ResponseData.Write((uint)PerformanceConfiguration.PerformanceConfiguration1); Logger.PrintStub(LogClass.ServiceApm, "Stubbed."); diff --git a/Ryujinx.HLE/HOS/Services/Aud/AudioOut/IAudioOut.cs b/Ryujinx.HLE/HOS/Services/Aud/AudioOut/IAudioOut.cs index 1ad049c6..93bda210 100644 --- a/Ryujinx.HLE/HOS/Services/Aud/AudioOut/IAudioOut.cs +++ b/Ryujinx.HLE/HOS/Services/Aud/AudioOut/IAudioOut.cs @@ -9,19 +9,19 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut { class IAudioOut : IpcService, IDisposable { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private IAalOutput AudioOut; + private IAalOutput _audioOut; - private KEvent ReleaseEvent; + private KEvent _releaseEvent; - private int Track; + private int _track; - public IAudioOut(IAalOutput AudioOut, KEvent ReleaseEvent, int Track) + public IAudioOut(IAalOutput audioOut, KEvent releaseEvent, int track) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, GetAudioOutState }, { 1, StartAudioOut }, @@ -34,116 +34,116 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut { 8, GetReleasedAudioOutBufferAuto } }; - this.AudioOut = AudioOut; - this.ReleaseEvent = ReleaseEvent; - this.Track = Track; + _audioOut = audioOut; + _releaseEvent = releaseEvent; + _track = track; } - public long GetAudioOutState(ServiceCtx Context) + public long GetAudioOutState(ServiceCtx context) { - Context.ResponseData.Write((int)AudioOut.GetState(Track)); + context.ResponseData.Write((int)_audioOut.GetState(_track)); return 0; } - public long StartAudioOut(ServiceCtx Context) + public long StartAudioOut(ServiceCtx context) { - AudioOut.Start(Track); + _audioOut.Start(_track); return 0; } - public long StopAudioOut(ServiceCtx Context) + public long StopAudioOut(ServiceCtx context) { - AudioOut.Stop(Track); + _audioOut.Stop(_track); return 0; } - public long AppendAudioOutBuffer(ServiceCtx Context) + public long AppendAudioOutBuffer(ServiceCtx context) { - return AppendAudioOutBufferImpl(Context, Context.Request.SendBuff[0].Position); + return AppendAudioOutBufferImpl(context, context.Request.SendBuff[0].Position); } - public long RegisterBufferEvent(ServiceCtx Context) + public long RegisterBufferEvent(ServiceCtx context) { - if (Context.Process.HandleTable.GenerateHandle(ReleaseEvent.ReadableEvent, out int Handle) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(_releaseEvent.ReadableEvent, out int handle) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle); return 0; } - public long GetReleasedAudioOutBuffer(ServiceCtx Context) + public long GetReleasedAudioOutBuffer(ServiceCtx context) { - long Position = Context.Request.ReceiveBuff[0].Position; - long Size = Context.Request.ReceiveBuff[0].Size; + long position = context.Request.ReceiveBuff[0].Position; + long size = context.Request.ReceiveBuff[0].Size; - return GetReleasedAudioOutBufferImpl(Context, Position, Size); + return GetReleasedAudioOutBufferImpl(context, position, size); } - public long ContainsAudioOutBuffer(ServiceCtx Context) + public long ContainsAudioOutBuffer(ServiceCtx context) { - long Tag = Context.RequestData.ReadInt64(); + long tag = context.RequestData.ReadInt64(); - Context.ResponseData.Write(AudioOut.ContainsBuffer(Track, Tag) ? 1 : 0); + context.ResponseData.Write(_audioOut.ContainsBuffer(_track, tag) ? 1 : 0); return 0; } - public long AppendAudioOutBufferAuto(ServiceCtx Context) + public long AppendAudioOutBufferAuto(ServiceCtx context) { - (long Position, long Size) = Context.Request.GetBufferType0x21(); + (long position, long size) = context.Request.GetBufferType0x21(); - return AppendAudioOutBufferImpl(Context, Position); + return AppendAudioOutBufferImpl(context, position); } - public long AppendAudioOutBufferImpl(ServiceCtx Context, long Position) + public long AppendAudioOutBufferImpl(ServiceCtx context, long position) { - long Tag = Context.RequestData.ReadInt64(); + long tag = context.RequestData.ReadInt64(); - AudioOutData Data = MemoryHelper.Read<AudioOutData>( - Context.Memory, - Position); + AudioOutData data = MemoryHelper.Read<AudioOutData>( + context.Memory, + position); - byte[] Buffer = Context.Memory.ReadBytes( - Data.SampleBufferPtr, - Data.SampleBufferSize); + byte[] buffer = context.Memory.ReadBytes( + data.SampleBufferPtr, + data.SampleBufferSize); - AudioOut.AppendBuffer(Track, Tag, Buffer); + _audioOut.AppendBuffer(_track, tag, buffer); return 0; } - public long GetReleasedAudioOutBufferAuto(ServiceCtx Context) + public long GetReleasedAudioOutBufferAuto(ServiceCtx context) { - (long Position, long Size) = Context.Request.GetBufferType0x22(); + (long position, long size) = context.Request.GetBufferType0x22(); - return GetReleasedAudioOutBufferImpl(Context, Position, Size); + return GetReleasedAudioOutBufferImpl(context, position, size); } - public long GetReleasedAudioOutBufferImpl(ServiceCtx Context, long Position, long Size) + public long GetReleasedAudioOutBufferImpl(ServiceCtx context, long position, long size) { - uint Count = (uint)((ulong)Size >> 3); + uint count = (uint)((ulong)size >> 3); - long[] ReleasedBuffers = AudioOut.GetReleasedBuffers(Track, (int)Count); + long[] releasedBuffers = _audioOut.GetReleasedBuffers(_track, (int)count); - for (uint Index = 0; Index < Count; Index++) + for (uint index = 0; index < count; index++) { - long Tag = 0; + long tag = 0; - if (Index < ReleasedBuffers.Length) + if (index < releasedBuffers.Length) { - Tag = ReleasedBuffers[Index]; + tag = releasedBuffers[index]; } - Context.Memory.WriteInt64(Position + Index * 8, Tag); + context.Memory.WriteInt64(position + index * 8, tag); } - Context.ResponseData.Write(ReleasedBuffers.Length); + context.ResponseData.Write(releasedBuffers.Length); return 0; } @@ -153,11 +153,11 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut Dispose(true); } - protected virtual void Dispose(bool Disposing) + protected virtual void Dispose(bool disposing) { - if (Disposing) + if (disposing) { - AudioOut.CloseTrack(Track); + _audioOut.CloseTrack(_track); } } } diff --git a/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/IAudioRenderer.cs b/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/IAudioRenderer.cs index 50a87893..5d90fa5d 100644 --- a/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/IAudioRenderer.cs +++ b/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/IAudioRenderer.cs @@ -22,33 +22,33 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer //high latency). private const int MixBufferSamplesCount = 960; - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private KEvent UpdateEvent; + private KEvent _updateEvent; - private MemoryManager Memory; + private MemoryManager _memory; - private IAalOutput AudioOut; + private IAalOutput _audioOut; - private AudioRendererParameter Params; + private AudioRendererParameter _params; - private MemoryPoolContext[] MemoryPools; + private MemoryPoolContext[] _memoryPools; - private VoiceContext[] Voices; + private VoiceContext[] _voices; - private int Track; + private int _track; - private PlayState PlayState; + private PlayState _playState; public IAudioRenderer( - Horizon System, - MemoryManager Memory, - IAalOutput AudioOut, + Horizon system, + MemoryManager memory, + IAalOutput audioOut, AudioRendererParameter Params) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, GetSampleRate }, { 1, GetSampleCount }, @@ -60,75 +60,75 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer { 7, QuerySystemEvent } }; - UpdateEvent = new KEvent(System); + _updateEvent = new KEvent(system); - this.Memory = Memory; - this.AudioOut = AudioOut; - this.Params = Params; + _memory = memory; + _audioOut = audioOut; + _params = Params; - Track = AudioOut.OpenTrack( + _track = audioOut.OpenTrack( AudioConsts.HostSampleRate, AudioConsts.HostChannelsCount, AudioCallback); - MemoryPools = CreateArray<MemoryPoolContext>(Params.EffectCount + Params.VoiceCount * 4); + _memoryPools = CreateArray<MemoryPoolContext>(Params.EffectCount + Params.VoiceCount * 4); - Voices = CreateArray<VoiceContext>(Params.VoiceCount); + _voices = CreateArray<VoiceContext>(Params.VoiceCount); InitializeAudioOut(); - PlayState = PlayState.Stopped; + _playState = PlayState.Stopped; } // GetSampleRate() -> u32 - public long GetSampleRate(ServiceCtx Context) + public long GetSampleRate(ServiceCtx context) { - Context.ResponseData.Write(Params.SampleRate); + context.ResponseData.Write(_params.SampleRate); return 0; } // GetSampleCount() -> u32 - public long GetSampleCount(ServiceCtx Context) + public long GetSampleCount(ServiceCtx context) { - Context.ResponseData.Write(Params.SampleCount); + context.ResponseData.Write(_params.SampleCount); return 0; } // GetMixBufferCount() -> u32 - public long GetMixBufferCount(ServiceCtx Context) + public long GetMixBufferCount(ServiceCtx context) { - Context.ResponseData.Write(Params.MixCount); + context.ResponseData.Write(_params.MixCount); return 0; } // GetState() -> u32 - private long GetState(ServiceCtx Context) + private long GetState(ServiceCtx context) { - Context.ResponseData.Write((int)PlayState); + context.ResponseData.Write((int)_playState); - Logger.PrintStub(LogClass.ServiceAudio, $"Stubbed. Renderer State: {Enum.GetName(typeof(PlayState), PlayState)}"); + Logger.PrintStub(LogClass.ServiceAudio, $"Stubbed. Renderer State: {Enum.GetName(typeof(PlayState), _playState)}"); return 0; } private void AudioCallback() { - UpdateEvent.ReadableEvent.Signal(); + _updateEvent.ReadableEvent.Signal(); } - private static T[] CreateArray<T>(int Size) where T : new() + private static T[] CreateArray<T>(int size) where T : new() { - T[] Output = new T[Size]; + T[] output = new T[size]; - for (int Index = 0; Index < Size; Index++) + for (int index = 0; index < size; index++) { - Output[Index] = new T(); + output[index] = new T(); } - return Output; + return output; } private void InitializeAudioOut() @@ -137,258 +137,258 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer AppendMixedBuffer(1); AppendMixedBuffer(2); - AudioOut.Start(Track); + _audioOut.Start(_track); } - public long RequestUpdateAudioRenderer(ServiceCtx Context) + public long RequestUpdateAudioRenderer(ServiceCtx context) { - long OutputPosition = Context.Request.ReceiveBuff[0].Position; - long OutputSize = Context.Request.ReceiveBuff[0].Size; + long outputPosition = context.Request.ReceiveBuff[0].Position; + long outputSize = context.Request.ReceiveBuff[0].Size; - MemoryHelper.FillWithZeros(Context.Memory, OutputPosition, (int)OutputSize); + MemoryHelper.FillWithZeros(context.Memory, outputPosition, (int)outputSize); - long InputPosition = Context.Request.SendBuff[0].Position; + long inputPosition = context.Request.SendBuff[0].Position; - StructReader Reader = new StructReader(Context.Memory, InputPosition); - StructWriter Writer = new StructWriter(Context.Memory, OutputPosition); + StructReader reader = new StructReader(context.Memory, inputPosition); + StructWriter writer = new StructWriter(context.Memory, outputPosition); - UpdateDataHeader InputHeader = Reader.Read<UpdateDataHeader>(); + UpdateDataHeader inputHeader = reader.Read<UpdateDataHeader>(); - Reader.Read<BehaviorIn>(InputHeader.BehaviorSize); + reader.Read<BehaviorIn>(inputHeader.BehaviorSize); - MemoryPoolIn[] MemoryPoolsIn = Reader.Read<MemoryPoolIn>(InputHeader.MemoryPoolSize); + MemoryPoolIn[] memoryPoolsIn = reader.Read<MemoryPoolIn>(inputHeader.MemoryPoolSize); - for (int Index = 0; Index < MemoryPoolsIn.Length; Index++) + for (int index = 0; index < memoryPoolsIn.Length; index++) { - MemoryPoolIn MemoryPool = MemoryPoolsIn[Index]; + MemoryPoolIn memoryPool = memoryPoolsIn[index]; - if (MemoryPool.State == MemoryPoolState.RequestAttach) + if (memoryPool.State == MemoryPoolState.RequestAttach) { - MemoryPools[Index].OutStatus.State = MemoryPoolState.Attached; + _memoryPools[index].OutStatus.State = MemoryPoolState.Attached; } - else if (MemoryPool.State == MemoryPoolState.RequestDetach) + else if (memoryPool.State == MemoryPoolState.RequestDetach) { - MemoryPools[Index].OutStatus.State = MemoryPoolState.Detached; + _memoryPools[index].OutStatus.State = MemoryPoolState.Detached; } } - Reader.Read<VoiceChannelResourceIn>(InputHeader.VoiceResourceSize); + reader.Read<VoiceChannelResourceIn>(inputHeader.VoiceResourceSize); - VoiceIn[] VoicesIn = Reader.Read<VoiceIn>(InputHeader.VoiceSize); + VoiceIn[] voicesIn = reader.Read<VoiceIn>(inputHeader.VoiceSize); - for (int Index = 0; Index < VoicesIn.Length; Index++) + for (int index = 0; index < voicesIn.Length; index++) { - VoiceIn Voice = VoicesIn[Index]; + VoiceIn voice = voicesIn[index]; - VoiceContext VoiceCtx = Voices[Index]; + VoiceContext voiceCtx = _voices[index]; - VoiceCtx.SetAcquireState(Voice.Acquired != 0); + voiceCtx.SetAcquireState(voice.Acquired != 0); - if (Voice.Acquired == 0) + if (voice.Acquired == 0) { continue; } - if (Voice.FirstUpdate != 0) + if (voice.FirstUpdate != 0) { - VoiceCtx.AdpcmCtx = GetAdpcmDecoderContext( - Voice.AdpcmCoeffsPosition, - Voice.AdpcmCoeffsSize); + voiceCtx.AdpcmCtx = GetAdpcmDecoderContext( + voice.AdpcmCoeffsPosition, + voice.AdpcmCoeffsSize); - VoiceCtx.SampleFormat = Voice.SampleFormat; - VoiceCtx.SampleRate = Voice.SampleRate; - VoiceCtx.ChannelsCount = Voice.ChannelsCount; + voiceCtx.SampleFormat = voice.SampleFormat; + voiceCtx.SampleRate = voice.SampleRate; + voiceCtx.ChannelsCount = voice.ChannelsCount; - VoiceCtx.SetBufferIndex(Voice.BaseWaveBufferIndex); + voiceCtx.SetBufferIndex(voice.BaseWaveBufferIndex); } - VoiceCtx.WaveBuffers[0] = Voice.WaveBuffer0; - VoiceCtx.WaveBuffers[1] = Voice.WaveBuffer1; - VoiceCtx.WaveBuffers[2] = Voice.WaveBuffer2; - VoiceCtx.WaveBuffers[3] = Voice.WaveBuffer3; - VoiceCtx.Volume = Voice.Volume; - VoiceCtx.PlayState = Voice.PlayState; + voiceCtx.WaveBuffers[0] = voice.WaveBuffer0; + voiceCtx.WaveBuffers[1] = voice.WaveBuffer1; + voiceCtx.WaveBuffers[2] = voice.WaveBuffer2; + voiceCtx.WaveBuffers[3] = voice.WaveBuffer3; + voiceCtx.Volume = voice.Volume; + voiceCtx.PlayState = voice.PlayState; } UpdateAudio(); - UpdateDataHeader OutputHeader = new UpdateDataHeader(); + UpdateDataHeader outputHeader = new UpdateDataHeader(); - int UpdateHeaderSize = Marshal.SizeOf<UpdateDataHeader>(); + int updateHeaderSize = Marshal.SizeOf<UpdateDataHeader>(); - OutputHeader.Revision = IAudioRendererManager.RevMagic; - OutputHeader.BehaviorSize = 0xb0; - OutputHeader.MemoryPoolSize = (Params.EffectCount + Params.VoiceCount * 4) * 0x10; - OutputHeader.VoiceSize = Params.VoiceCount * 0x10; - OutputHeader.EffectSize = Params.EffectCount * 0x10; - OutputHeader.SinkSize = Params.SinkCount * 0x20; - OutputHeader.PerformanceManagerSize = 0x10; - OutputHeader.TotalSize = UpdateHeaderSize + - OutputHeader.BehaviorSize + - OutputHeader.MemoryPoolSize + - OutputHeader.VoiceSize + - OutputHeader.EffectSize + - OutputHeader.SinkSize + - OutputHeader.PerformanceManagerSize; + outputHeader.Revision = IAudioRendererManager.RevMagic; + outputHeader.BehaviorSize = 0xb0; + outputHeader.MemoryPoolSize = (_params.EffectCount + _params.VoiceCount * 4) * 0x10; + outputHeader.VoiceSize = _params.VoiceCount * 0x10; + outputHeader.EffectSize = _params.EffectCount * 0x10; + outputHeader.SinkSize = _params.SinkCount * 0x20; + outputHeader.PerformanceManagerSize = 0x10; + outputHeader.TotalSize = updateHeaderSize + + outputHeader.BehaviorSize + + outputHeader.MemoryPoolSize + + outputHeader.VoiceSize + + outputHeader.EffectSize + + outputHeader.SinkSize + + outputHeader.PerformanceManagerSize; - Writer.Write(OutputHeader); + writer.Write(outputHeader); - foreach (MemoryPoolContext MemoryPool in MemoryPools) + foreach (MemoryPoolContext memoryPool in _memoryPools) { - Writer.Write(MemoryPool.OutStatus); + writer.Write(memoryPool.OutStatus); } - foreach (VoiceContext Voice in Voices) + foreach (VoiceContext voice in _voices) { - Writer.Write(Voice.OutStatus); + writer.Write(voice.OutStatus); } return 0; } - public long StartAudioRenderer(ServiceCtx Context) + public long StartAudioRenderer(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceAudio, "Stubbed."); - PlayState = PlayState.Playing; + _playState = PlayState.Playing; return 0; } - public long StopAudioRenderer(ServiceCtx Context) + public long StopAudioRenderer(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceAudio, "Stubbed."); - PlayState = PlayState.Stopped; + _playState = PlayState.Stopped; return 0; } - public long QuerySystemEvent(ServiceCtx Context) + public long QuerySystemEvent(ServiceCtx context) { - if (Context.Process.HandleTable.GenerateHandle(UpdateEvent.ReadableEvent, out int Handle) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(_updateEvent.ReadableEvent, out int handle) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle); return 0; } - private AdpcmDecoderContext GetAdpcmDecoderContext(long Position, long Size) + private AdpcmDecoderContext GetAdpcmDecoderContext(long position, long size) { - if (Size == 0) + if (size == 0) { return null; } - AdpcmDecoderContext Context = new AdpcmDecoderContext(); + AdpcmDecoderContext context = new AdpcmDecoderContext(); - Context.Coefficients = new short[Size >> 1]; + context.Coefficients = new short[size >> 1]; - for (int Offset = 0; Offset < Size; Offset += 2) + for (int offset = 0; offset < size; offset += 2) { - Context.Coefficients[Offset >> 1] = Memory.ReadInt16(Position + Offset); + context.Coefficients[offset >> 1] = _memory.ReadInt16(position + offset); } - return Context; + return context; } private void UpdateAudio() { - long[] Released = AudioOut.GetReleasedBuffers(Track, 2); + long[] released = _audioOut.GetReleasedBuffers(_track, 2); - for (int Index = 0; Index < Released.Length; Index++) + for (int index = 0; index < released.Length; index++) { - AppendMixedBuffer(Released[Index]); + AppendMixedBuffer(released[index]); } } - private unsafe void AppendMixedBuffer(long Tag) + private void AppendMixedBuffer(long tag) { - int[] MixBuffer = new int[MixBufferSamplesCount * AudioConsts.HostChannelsCount]; + int[] mixBuffer = new int[MixBufferSamplesCount * AudioConsts.HostChannelsCount]; - foreach (VoiceContext Voice in Voices) + foreach (VoiceContext voice in _voices) { - if (!Voice.Playing) + if (!voice.Playing) { continue; } - int OutOffset = 0; - int PendingSamples = MixBufferSamplesCount; - float Volume = Voice.Volume; + int outOffset = 0; + int pendingSamples = MixBufferSamplesCount; + float volume = voice.Volume; - while (PendingSamples > 0) + while (pendingSamples > 0) { - int[] Samples = Voice.GetBufferData(Memory, PendingSamples, out int ReturnedSamples); + int[] samples = voice.GetBufferData(_memory, pendingSamples, out int returnedSamples); - if (ReturnedSamples == 0) + if (returnedSamples == 0) { break; } - PendingSamples -= ReturnedSamples; + pendingSamples -= returnedSamples; - for (int Offset = 0; Offset < Samples.Length; Offset++) + for (int offset = 0; offset < samples.Length; offset++) { - MixBuffer[OutOffset++] += (int)(Samples[Offset] * Voice.Volume); + mixBuffer[outOffset++] += (int)(samples[offset] * voice.Volume); } } } - AudioOut.AppendBuffer(Track, Tag, GetFinalBuffer(MixBuffer)); + _audioOut.AppendBuffer(_track, tag, GetFinalBuffer(mixBuffer)); } - private unsafe static short[] GetFinalBuffer(int[] Buffer) + private static unsafe short[] GetFinalBuffer(int[] buffer) { - short[] Output = new short[Buffer.Length]; + short[] output = new short[buffer.Length]; - int Offset = 0; + int offset = 0; // Perform Saturation using SSE2 if supported if (Sse2.IsSupported) { - fixed (int* inptr = Buffer) - fixed (short* outptr = Output) + fixed (int* inptr = buffer) + fixed (short* outptr = output) { - for (; Offset + 32 <= Buffer.Length; Offset += 32) + for (; offset + 32 <= buffer.Length; offset += 32) { // Unroll the loop a little to ensure the CPU pipeline // is always full. - Vector128<int> block1A = Sse2.LoadVector128(inptr + Offset + 0); - Vector128<int> block1B = Sse2.LoadVector128(inptr + Offset + 4); + Vector128<int> block1A = Sse2.LoadVector128(inptr + offset + 0); + Vector128<int> block1B = Sse2.LoadVector128(inptr + offset + 4); - Vector128<int> block2A = Sse2.LoadVector128(inptr + Offset + 8); - Vector128<int> block2B = Sse2.LoadVector128(inptr + Offset + 12); + Vector128<int> block2A = Sse2.LoadVector128(inptr + offset + 8); + Vector128<int> block2B = Sse2.LoadVector128(inptr + offset + 12); - Vector128<int> block3A = Sse2.LoadVector128(inptr + Offset + 16); - Vector128<int> block3B = Sse2.LoadVector128(inptr + Offset + 20); + Vector128<int> block3A = Sse2.LoadVector128(inptr + offset + 16); + Vector128<int> block3B = Sse2.LoadVector128(inptr + offset + 20); - Vector128<int> block4A = Sse2.LoadVector128(inptr + Offset + 24); - Vector128<int> block4B = Sse2.LoadVector128(inptr + Offset + 28); + Vector128<int> block4A = Sse2.LoadVector128(inptr + offset + 24); + Vector128<int> block4B = Sse2.LoadVector128(inptr + offset + 28); Vector128<short> output1 = Sse2.PackSignedSaturate(block1A, block1B); Vector128<short> output2 = Sse2.PackSignedSaturate(block2A, block2B); Vector128<short> output3 = Sse2.PackSignedSaturate(block3A, block3B); Vector128<short> output4 = Sse2.PackSignedSaturate(block4A, block4B); - Sse2.Store(outptr + Offset + 0, output1); - Sse2.Store(outptr + Offset + 8, output2); - Sse2.Store(outptr + Offset + 16, output3); - Sse2.Store(outptr + Offset + 24, output4); + Sse2.Store(outptr + offset + 0, output1); + Sse2.Store(outptr + offset + 8, output2); + Sse2.Store(outptr + offset + 16, output3); + Sse2.Store(outptr + offset + 24, output4); } } } // Process left overs - for (; Offset < Buffer.Length; Offset++) + for (; offset < buffer.Length; offset++) { - Output[Offset] = DspUtils.Saturate(Buffer[Offset]); + output[offset] = DspUtils.Saturate(buffer[offset]); } - return Output; + return output; } public void Dispose() @@ -396,11 +396,11 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer Dispose(true); } - protected virtual void Dispose(bool Disposing) + protected virtual void Dispose(bool disposing) { - if (Disposing) + if (disposing) { - AudioOut.CloseTrack(Track); + _audioOut.CloseTrack(_track); } } } diff --git a/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/MemoryPoolState.cs b/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/MemoryPoolState.cs index 6baf507c..6a37c1af 100644 --- a/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/MemoryPoolState.cs +++ b/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/MemoryPoolState.cs @@ -1,6 +1,6 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer { - enum MemoryPoolState : int + enum MemoryPoolState { Invalid = 0, Unknown = 1, diff --git a/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/Resampler.cs b/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/Resampler.cs index baa0bc62..9714f6d8 100644 --- a/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/Resampler.cs +++ b/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/Resampler.cs @@ -5,7 +5,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer static class Resampler { #region "LookUp Tables" - private static short[] CurveLut0 = new short[] + private static short[] _curveLut0 = new short[] { 6600, 19426, 6722, 3, 6479, 19424, 6845, 9, 6359, 19419, 6968, 15, 6239, 19412, 7093, 22, 6121, 19403, 7219, 28, 6004, 19391, 7345, 34, 5888, 19377, 7472, 41, 5773, 19361, 7600, 48, @@ -41,7 +41,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer 22, 7093, 19412, 6239, 15, 6968, 19419, 6359, 9, 6845, 19424, 6479, 3, 6722, 19426, 6600 }; - private static short[] CurveLut1 = new short[] + private static short[] _curveLut1 = new short[] { -68, 32639, 69, -5, -200, 32630, 212, -15, -328, 32613, 359, -26, -450, 32586, 512, -36, -568, 32551, 669, -47, -680, 32507, 832, -58, -788, 32454, 1000, -69, -891, 32393, 1174, -80, @@ -77,7 +77,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer -36, 512, 32586, -450, -26, 359, 32613, -328, -15, 212, 32630, -200, -5, 69, 32639, -68 }; - private static short[] CurveLut2 = new short[] + private static short[] _curveLut2 = new short[] { 3195, 26287, 3329, -32, 3064, 26281, 3467, -34, 2936, 26270, 3608, -38, 2811, 26253, 3751, -42, 2688, 26230, 3897, -46, 2568, 26202, 4046, -50, 2451, 26169, 4199, -54, 2338, 26130, 4354, -58, @@ -115,77 +115,77 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer #endregion public static int[] Resample2Ch( - int[] Buffer, - int SrcSampleRate, - int DstSampleRate, - int SamplesCount, - ref int FracPart) + int[] buffer, + int srcSampleRate, + int dstSampleRate, + int samplesCount, + ref int fracPart) { - if (Buffer == null) + if (buffer == null) { - throw new ArgumentNullException(nameof(Buffer)); + throw new ArgumentNullException(nameof(buffer)); } - if (SrcSampleRate <= 0) + if (srcSampleRate <= 0) { - throw new ArgumentOutOfRangeException(nameof(SrcSampleRate)); + throw new ArgumentOutOfRangeException(nameof(srcSampleRate)); } - if (DstSampleRate <= 0) + if (dstSampleRate <= 0) { - throw new ArgumentOutOfRangeException(nameof(DstSampleRate)); + throw new ArgumentOutOfRangeException(nameof(dstSampleRate)); } - double Ratio = (double)SrcSampleRate / DstSampleRate; + double ratio = (double)srcSampleRate / dstSampleRate; - int NewSamplesCount = (int)(SamplesCount / Ratio); + int newSamplesCount = (int)(samplesCount / ratio); - int Step = (int)(Ratio * 0x8000); + int step = (int)(ratio * 0x8000); - int[] Output = new int[NewSamplesCount * 2]; + int[] output = new int[newSamplesCount * 2]; - short[] Lut; + short[] lut; - if (Step > 0xaaaa) + if (step > 0xaaaa) { - Lut = CurveLut0; + lut = _curveLut0; } - else if (Step <= 0x8000) + else if (step <= 0x8000) { - Lut = CurveLut1; + lut = _curveLut1; } else { - Lut = CurveLut2; + lut = _curveLut2; } - int InOffs = 0; + int inOffs = 0; - for (int OutOffs = 0; OutOffs < Output.Length; OutOffs += 2) + for (int outOffs = 0; outOffs < output.Length; outOffs += 2) { - int LutIndex = (FracPart >> 8) * 4; + int lutIndex = (fracPart >> 8) * 4; - int Sample0 = Buffer[(InOffs + 0) * 2 + 0] * Lut[LutIndex + 0] + - Buffer[(InOffs + 1) * 2 + 0] * Lut[LutIndex + 1] + - Buffer[(InOffs + 2) * 2 + 0] * Lut[LutIndex + 2] + - Buffer[(InOffs + 3) * 2 + 0] * Lut[LutIndex + 3]; + int sample0 = buffer[(inOffs + 0) * 2 + 0] * lut[lutIndex + 0] + + buffer[(inOffs + 1) * 2 + 0] * lut[lutIndex + 1] + + buffer[(inOffs + 2) * 2 + 0] * lut[lutIndex + 2] + + buffer[(inOffs + 3) * 2 + 0] * lut[lutIndex + 3]; - int Sample1 = Buffer[(InOffs + 0) * 2 + 1] * Lut[LutIndex + 0] + - Buffer[(InOffs + 1) * 2 + 1] * Lut[LutIndex + 1] + - Buffer[(InOffs + 2) * 2 + 1] * Lut[LutIndex + 2] + - Buffer[(InOffs + 3) * 2 + 1] * Lut[LutIndex + 3]; + int sample1 = buffer[(inOffs + 0) * 2 + 1] * lut[lutIndex + 0] + + buffer[(inOffs + 1) * 2 + 1] * lut[lutIndex + 1] + + buffer[(inOffs + 2) * 2 + 1] * lut[lutIndex + 2] + + buffer[(inOffs + 3) * 2 + 1] * lut[lutIndex + 3]; - int NewOffset = FracPart + Step; + int newOffset = fracPart + step; - InOffs += NewOffset >> 15; + inOffs += newOffset >> 15; - FracPart = NewOffset & 0x7fff; + fracPart = newOffset & 0x7fff; - Output[OutOffs + 0] = Sample0 >> 15; - Output[OutOffs + 1] = Sample1 >> 15; + output[outOffs + 0] = sample0 >> 15; + output[outOffs + 1] = sample1 >> 15; } - return Output; + return output; } } }
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/VoiceContext.cs b/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/VoiceContext.cs index 7d6e1c58..a877081d 100644 --- a/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/VoiceContext.cs +++ b/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/VoiceContext.cs @@ -6,13 +6,13 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer { class VoiceContext { - private bool Acquired; - private bool BufferReload; + private bool _acquired; + private bool _bufferReload; - private int ResamplerFracPart; + private int _resamplerFracPart; - private int BufferIndex; - private int Offset; + private int _bufferIndex; + private int _offset; public int SampleRate; public int ChannelsCount; @@ -29,138 +29,138 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer public VoiceOut OutStatus; - private int[] Samples; + private int[] _samples; - public bool Playing => Acquired && PlayState == PlayState.Playing; + public bool Playing => _acquired && PlayState == PlayState.Playing; public VoiceContext() { WaveBuffers = new WaveBuffer[4]; } - public void SetAcquireState(bool NewState) + public void SetAcquireState(bool newState) { - if (Acquired && !NewState) + if (_acquired && !newState) { //Release. Reset(); } - Acquired = NewState; + _acquired = newState; } private void Reset() { - BufferReload = true; + _bufferReload = true; - BufferIndex = 0; - Offset = 0; + _bufferIndex = 0; + _offset = 0; OutStatus.PlayedSamplesCount = 0; OutStatus.PlayedWaveBuffersCount = 0; OutStatus.VoiceDropsCount = 0; } - public int[] GetBufferData(MemoryManager Memory, int MaxSamples, out int SamplesCount) + public int[] GetBufferData(MemoryManager memory, int maxSamples, out int samplesCount) { if (!Playing) { - SamplesCount = 0; + samplesCount = 0; return null; } - if (BufferReload) + if (_bufferReload) { - BufferReload = false; + _bufferReload = false; - UpdateBuffer(Memory); + UpdateBuffer(memory); } - WaveBuffer Wb = WaveBuffers[BufferIndex]; + WaveBuffer wb = WaveBuffers[_bufferIndex]; - int MaxSize = Samples.Length - Offset; + int maxSize = _samples.Length - _offset; - int Size = MaxSamples * AudioConsts.HostChannelsCount; + int size = maxSamples * AudioConsts.HostChannelsCount; - if (Size > MaxSize) + if (size > maxSize) { - Size = MaxSize; + size = maxSize; } - int[] Output = new int[Size]; + int[] output = new int[size]; - Array.Copy(Samples, Offset, Output, 0, Size); + Array.Copy(_samples, _offset, output, 0, size); - SamplesCount = Size / AudioConsts.HostChannelsCount; + samplesCount = size / AudioConsts.HostChannelsCount; - OutStatus.PlayedSamplesCount += SamplesCount; + OutStatus.PlayedSamplesCount += samplesCount; - Offset += Size; + _offset += size; - if (Offset == Samples.Length) + if (_offset == _samples.Length) { - Offset = 0; + _offset = 0; - if (Wb.Looping == 0) + if (wb.Looping == 0) { - SetBufferIndex((BufferIndex + 1) & 3); + SetBufferIndex((_bufferIndex + 1) & 3); } OutStatus.PlayedWaveBuffersCount++; - if (Wb.LastBuffer != 0) + if (wb.LastBuffer != 0) { PlayState = PlayState.Paused; } } - return Output; + return output; } - private void UpdateBuffer(MemoryManager Memory) + private void UpdateBuffer(MemoryManager memory) { //TODO: Implement conversion for formats other //than interleaved stereo (2 channels). //As of now, it assumes that HostChannelsCount == 2. - WaveBuffer Wb = WaveBuffers[BufferIndex]; + WaveBuffer wb = WaveBuffers[_bufferIndex]; - if (Wb.Position == 0) + if (wb.Position == 0) { - Samples = new int[0]; + _samples = new int[0]; return; } if (SampleFormat == SampleFormat.PcmInt16) { - int SamplesCount = (int)(Wb.Size / (sizeof(short) * ChannelsCount)); + int samplesCount = (int)(wb.Size / (sizeof(short) * ChannelsCount)); - Samples = new int[SamplesCount * AudioConsts.HostChannelsCount]; + _samples = new int[samplesCount * AudioConsts.HostChannelsCount]; if (ChannelsCount == 1) { - for (int Index = 0; Index < SamplesCount; Index++) + for (int index = 0; index < samplesCount; index++) { - short Sample = Memory.ReadInt16(Wb.Position + Index * 2); + short sample = memory.ReadInt16(wb.Position + index * 2); - Samples[Index * 2 + 0] = Sample; - Samples[Index * 2 + 1] = Sample; + _samples[index * 2 + 0] = sample; + _samples[index * 2 + 1] = sample; } } else { - for (int Index = 0; Index < SamplesCount * 2; Index++) + for (int index = 0; index < samplesCount * 2; index++) { - Samples[Index] = Memory.ReadInt16(Wb.Position + Index * 2); + _samples[index] = memory.ReadInt16(wb.Position + index * 2); } } } else if (SampleFormat == SampleFormat.Adpcm) { - byte[] Buffer = Memory.ReadBytes(Wb.Position, Wb.Size); + byte[] buffer = memory.ReadBytes(wb.Position, wb.Size); - Samples = AdpcmDecoder.Decode(Buffer, AdpcmCtx); + _samples = AdpcmDecoder.Decode(buffer, AdpcmCtx); } else { @@ -172,24 +172,24 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer //TODO: We should keep the frames being discarded (see the 4 below) //on a buffer and include it on the next samples buffer, to allow //the resampler to do seamless interpolation between wave buffers. - int SamplesCount = Samples.Length / AudioConsts.HostChannelsCount; + int samplesCount = _samples.Length / AudioConsts.HostChannelsCount; - SamplesCount = Math.Max(SamplesCount - 4, 0); + samplesCount = Math.Max(samplesCount - 4, 0); - Samples = Resampler.Resample2Ch( - Samples, + _samples = Resampler.Resample2Ch( + _samples, SampleRate, AudioConsts.HostSampleRate, - SamplesCount, - ref ResamplerFracPart); + samplesCount, + ref _resamplerFracPart); } } - public void SetBufferIndex(int Index) + public void SetBufferIndex(int index) { - BufferIndex = Index & 3; + _bufferIndex = index & 3; - BufferReload = true; + _bufferReload = true; } } } diff --git a/Ryujinx.HLE/HOS/Services/Aud/IAudioDevice.cs b/Ryujinx.HLE/HOS/Services/Aud/IAudioDevice.cs index f9c0d315..585d7e43 100644 --- a/Ryujinx.HLE/HOS/Services/Aud/IAudioDevice.cs +++ b/Ryujinx.HLE/HOS/Services/Aud/IAudioDevice.cs @@ -10,15 +10,15 @@ namespace Ryujinx.HLE.HOS.Services.Aud { class IAudioDevice : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private KEvent SystemEvent; + private KEvent _systemEvent; - public IAudioDevice(Horizon System) + public IAudioDevice(Horizon system) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, ListAudioDeviceName }, { 1, SetAudioDeviceOutputVolume }, @@ -33,197 +33,197 @@ namespace Ryujinx.HLE.HOS.Services.Aud { 12, QueryAudioDeviceOutputEvent } }; - SystemEvent = new KEvent(System); + _systemEvent = new KEvent(system); //TODO: We shouldn't be signaling this here. - SystemEvent.ReadableEvent.Signal(); + _systemEvent.ReadableEvent.Signal(); } - public long ListAudioDeviceName(ServiceCtx Context) + public long ListAudioDeviceName(ServiceCtx context) { - string[] DeviceNames = SystemStateMgr.AudioOutputs; + string[] deviceNames = SystemStateMgr.AudioOutputs; - Context.ResponseData.Write(DeviceNames.Length); + context.ResponseData.Write(deviceNames.Length); - long Position = Context.Request.ReceiveBuff[0].Position; - long Size = Context.Request.ReceiveBuff[0].Size; + long position = context.Request.ReceiveBuff[0].Position; + long size = context.Request.ReceiveBuff[0].Size; - long BasePosition = Position; + long basePosition = position; - foreach (string Name in DeviceNames) + foreach (string name in deviceNames) { - byte[] Buffer = Encoding.ASCII.GetBytes(Name + "\0"); + byte[] buffer = Encoding.ASCII.GetBytes(name + "\0"); - if ((Position - BasePosition) + Buffer.Length > Size) + if ((position - basePosition) + buffer.Length > size) { - Logger.PrintError(LogClass.ServiceAudio, $"Output buffer size {Size} too small!"); + Logger.PrintError(LogClass.ServiceAudio, $"Output buffer size {size} too small!"); break; } - Context.Memory.WriteBytes(Position, Buffer); + context.Memory.WriteBytes(position, buffer); - Position += Buffer.Length; + position += buffer.Length; } return 0; } - public long SetAudioDeviceOutputVolume(ServiceCtx Context) + public long SetAudioDeviceOutputVolume(ServiceCtx context) { - float Volume = Context.RequestData.ReadSingle(); + float volume = context.RequestData.ReadSingle(); - long Position = Context.Request.SendBuff[0].Position; - long Size = Context.Request.SendBuff[0].Size; + long position = context.Request.SendBuff[0].Position; + long size = context.Request.SendBuff[0].Size; - byte[] DeviceNameBuffer = Context.Memory.ReadBytes(Position, Size); + byte[] deviceNameBuffer = context.Memory.ReadBytes(position, size); - string DeviceName = Encoding.ASCII.GetString(DeviceNameBuffer); + string deviceName = Encoding.ASCII.GetString(deviceNameBuffer); Logger.PrintStub(LogClass.ServiceAudio, "Stubbed."); return 0; } - public long GetActiveAudioDeviceName(ServiceCtx Context) + public long GetActiveAudioDeviceName(ServiceCtx context) { - string Name = Context.Device.System.State.ActiveAudioOutput; + string name = context.Device.System.State.ActiveAudioOutput; - long Position = Context.Request.ReceiveBuff[0].Position; - long Size = Context.Request.ReceiveBuff[0].Size; + long position = context.Request.ReceiveBuff[0].Position; + long size = context.Request.ReceiveBuff[0].Size; - byte[] DeviceNameBuffer = Encoding.ASCII.GetBytes(Name + "\0"); + byte[] deviceNameBuffer = Encoding.ASCII.GetBytes(name + "\0"); - if ((ulong)DeviceNameBuffer.Length <= (ulong)Size) + if ((ulong)deviceNameBuffer.Length <= (ulong)size) { - Context.Memory.WriteBytes(Position, DeviceNameBuffer); + context.Memory.WriteBytes(position, deviceNameBuffer); } else { - Logger.PrintError(LogClass.ServiceAudio, $"Output buffer size {Size} too small!"); + Logger.PrintError(LogClass.ServiceAudio, $"Output buffer size {size} too small!"); } return 0; } - public long QueryAudioDeviceSystemEvent(ServiceCtx Context) + public long QueryAudioDeviceSystemEvent(ServiceCtx context) { - if (Context.Process.HandleTable.GenerateHandle(SystemEvent.ReadableEvent, out int Handle) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(_systemEvent.ReadableEvent, out int handle) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle); Logger.PrintStub(LogClass.ServiceAudio, "Stubbed."); return 0; } - public long GetActiveChannelCount(ServiceCtx Context) + public long GetActiveChannelCount(ServiceCtx context) { - Context.ResponseData.Write(2); + context.ResponseData.Write(2); Logger.PrintStub(LogClass.ServiceAudio, "Stubbed."); return 0; } - public long ListAudioDeviceNameAuto(ServiceCtx Context) + public long ListAudioDeviceNameAuto(ServiceCtx context) { - string[] DeviceNames = SystemStateMgr.AudioOutputs; + string[] deviceNames = SystemStateMgr.AudioOutputs; - Context.ResponseData.Write(DeviceNames.Length); + context.ResponseData.Write(deviceNames.Length); - (long Position, long Size) = Context.Request.GetBufferType0x22(); + (long position, long size) = context.Request.GetBufferType0x22(); - long BasePosition = Position; + long basePosition = position; - foreach (string Name in DeviceNames) + foreach (string name in deviceNames) { - byte[] Buffer = Encoding.UTF8.GetBytes(Name + '\0'); + byte[] buffer = Encoding.UTF8.GetBytes(name + '\0'); - if ((Position - BasePosition) + Buffer.Length > Size) + if ((position - basePosition) + buffer.Length > size) { - Logger.PrintError(LogClass.ServiceAudio, $"Output buffer size {Size} too small!"); + Logger.PrintError(LogClass.ServiceAudio, $"Output buffer size {size} too small!"); break; } - Context.Memory.WriteBytes(Position, Buffer); + context.Memory.WriteBytes(position, buffer); - Position += Buffer.Length; + position += buffer.Length; } return 0; } - public long SetAudioDeviceOutputVolumeAuto(ServiceCtx Context) + public long SetAudioDeviceOutputVolumeAuto(ServiceCtx context) { - float Volume = Context.RequestData.ReadSingle(); + float volume = context.RequestData.ReadSingle(); - (long Position, long Size) = Context.Request.GetBufferType0x21(); + (long position, long size) = context.Request.GetBufferType0x21(); - byte[] DeviceNameBuffer = Context.Memory.ReadBytes(Position, Size); + byte[] deviceNameBuffer = context.Memory.ReadBytes(position, size); - string DeviceName = Encoding.UTF8.GetString(DeviceNameBuffer); + string deviceName = Encoding.UTF8.GetString(deviceNameBuffer); Logger.PrintStub(LogClass.ServiceAudio, "Stubbed."); return 0; } - public long GetAudioDeviceOutputVolumeAuto(ServiceCtx Context) + public long GetAudioDeviceOutputVolumeAuto(ServiceCtx context) { - Context.ResponseData.Write(1f); + context.ResponseData.Write(1f); Logger.PrintStub(LogClass.ServiceAudio, "Stubbed."); return 0; } - public long GetActiveAudioDeviceNameAuto(ServiceCtx Context) + public long GetActiveAudioDeviceNameAuto(ServiceCtx context) { - string Name = Context.Device.System.State.ActiveAudioOutput; + string name = context.Device.System.State.ActiveAudioOutput; - (long Position, long Size) = Context.Request.GetBufferType0x22(); + (long position, long size) = context.Request.GetBufferType0x22(); - byte[] DeviceNameBuffer = Encoding.UTF8.GetBytes(Name + '\0'); + byte[] deviceNameBuffer = Encoding.UTF8.GetBytes(name + '\0'); - if ((ulong)DeviceNameBuffer.Length <= (ulong)Size) + if ((ulong)deviceNameBuffer.Length <= (ulong)size) { - Context.Memory.WriteBytes(Position, DeviceNameBuffer); + context.Memory.WriteBytes(position, deviceNameBuffer); } else { - Logger.PrintError(LogClass.ServiceAudio, $"Output buffer size {Size} too small!"); + Logger.PrintError(LogClass.ServiceAudio, $"Output buffer size {size} too small!"); } return 0; } - public long QueryAudioDeviceInputEvent(ServiceCtx Context) + public long QueryAudioDeviceInputEvent(ServiceCtx context) { - if (Context.Process.HandleTable.GenerateHandle(SystemEvent.ReadableEvent, out int Handle) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(_systemEvent.ReadableEvent, out int handle) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle); Logger.PrintStub(LogClass.ServiceAudio, "Stubbed."); return 0; } - public long QueryAudioDeviceOutputEvent(ServiceCtx Context) + public long QueryAudioDeviceOutputEvent(ServiceCtx context) { - if (Context.Process.HandleTable.GenerateHandle(SystemEvent.ReadableEvent, out int Handle) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(_systemEvent.ReadableEvent, out int handle) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle); Logger.PrintStub(LogClass.ServiceAudio, "Stubbed."); diff --git a/Ryujinx.HLE/HOS/Services/Aud/IAudioOutManager.cs b/Ryujinx.HLE/HOS/Services/Aud/IAudioOutManager.cs index b08f7640..4b1440a0 100644 --- a/Ryujinx.HLE/HOS/Services/Aud/IAudioOutManager.cs +++ b/Ryujinx.HLE/HOS/Services/Aud/IAudioOutManager.cs @@ -19,13 +19,13 @@ namespace Ryujinx.HLE.HOS.Services.Aud private const int DefaultChannelsCount = 2; - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IAudioOutManager() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, ListAudioOuts }, { 1, OpenAudioOut }, @@ -34,135 +34,135 @@ namespace Ryujinx.HLE.HOS.Services.Aud }; } - public long ListAudioOuts(ServiceCtx Context) + public long ListAudioOuts(ServiceCtx context) { return ListAudioOutsImpl( - Context, - Context.Request.ReceiveBuff[0].Position, - Context.Request.ReceiveBuff[0].Size); + context, + context.Request.ReceiveBuff[0].Position, + context.Request.ReceiveBuff[0].Size); } - public long OpenAudioOut(ServiceCtx Context) + public long OpenAudioOut(ServiceCtx context) { return OpenAudioOutImpl( - Context, - Context.Request.SendBuff[0].Position, - Context.Request.SendBuff[0].Size, - Context.Request.ReceiveBuff[0].Position, - Context.Request.ReceiveBuff[0].Size); + context, + context.Request.SendBuff[0].Position, + context.Request.SendBuff[0].Size, + context.Request.ReceiveBuff[0].Position, + context.Request.ReceiveBuff[0].Size); } - public long ListAudioOutsAuto(ServiceCtx Context) + public long ListAudioOutsAuto(ServiceCtx context) { - (long RecvPosition, long RecvSize) = Context.Request.GetBufferType0x22(); + (long recvPosition, long recvSize) = context.Request.GetBufferType0x22(); - return ListAudioOutsImpl(Context, RecvPosition, RecvSize); + return ListAudioOutsImpl(context, recvPosition, recvSize); } - public long OpenAudioOutAuto(ServiceCtx Context) + public long OpenAudioOutAuto(ServiceCtx context) { - (long SendPosition, long SendSize) = Context.Request.GetBufferType0x21(); - (long RecvPosition, long RecvSize) = Context.Request.GetBufferType0x22(); + (long sendPosition, long sendSize) = context.Request.GetBufferType0x21(); + (long recvPosition, long recvSize) = context.Request.GetBufferType0x22(); return OpenAudioOutImpl( - Context, - SendPosition, - SendSize, - RecvPosition, - RecvSize); + context, + sendPosition, + sendSize, + recvPosition, + recvSize); } - private long ListAudioOutsImpl(ServiceCtx Context, long Position, long Size) + private long ListAudioOutsImpl(ServiceCtx context, long position, long size) { - int NameCount = 0; + int nameCount = 0; - byte[] DeviceNameBuffer = Encoding.ASCII.GetBytes(DefaultAudioOutput + "\0"); + byte[] deviceNameBuffer = Encoding.ASCII.GetBytes(DefaultAudioOutput + "\0"); - if ((ulong)DeviceNameBuffer.Length <= (ulong)Size) + if ((ulong)deviceNameBuffer.Length <= (ulong)size) { - Context.Memory.WriteBytes(Position, DeviceNameBuffer); + context.Memory.WriteBytes(position, deviceNameBuffer); - NameCount++; + nameCount++; } else { - Logger.PrintError(LogClass.ServiceAudio, $"Output buffer size {Size} too small!"); + Logger.PrintError(LogClass.ServiceAudio, $"Output buffer size {size} too small!"); } - Context.ResponseData.Write(NameCount); + context.ResponseData.Write(nameCount); return 0; } - private long OpenAudioOutImpl(ServiceCtx Context, long SendPosition, long SendSize, long ReceivePosition, long ReceiveSize) + private long OpenAudioOutImpl(ServiceCtx context, long sendPosition, long sendSize, long receivePosition, long receiveSize) { - string DeviceName = MemoryHelper.ReadAsciiString( - Context.Memory, - SendPosition, - SendSize); + string deviceName = MemoryHelper.ReadAsciiString( + context.Memory, + sendPosition, + sendSize); - if (DeviceName == string.Empty) + if (deviceName == string.Empty) { - DeviceName = DefaultAudioOutput; + deviceName = DefaultAudioOutput; } - if (DeviceName != DefaultAudioOutput) + if (deviceName != DefaultAudioOutput) { Logger.PrintWarning(LogClass.Audio, "Invalid device name!"); return MakeError(ErrorModule.Audio, AudErr.DeviceNotFound); } - byte[] DeviceNameBuffer = Encoding.ASCII.GetBytes(DeviceName + "\0"); + byte[] deviceNameBuffer = Encoding.ASCII.GetBytes(deviceName + "\0"); - if ((ulong)DeviceNameBuffer.Length <= (ulong)ReceiveSize) + if ((ulong)deviceNameBuffer.Length <= (ulong)receiveSize) { - Context.Memory.WriteBytes(ReceivePosition, DeviceNameBuffer); + context.Memory.WriteBytes(receivePosition, deviceNameBuffer); } else { - Logger.PrintError(LogClass.ServiceAudio, $"Output buffer size {ReceiveSize} too small!"); + Logger.PrintError(LogClass.ServiceAudio, $"Output buffer size {receiveSize} too small!"); } - int SampleRate = Context.RequestData.ReadInt32(); - int Channels = Context.RequestData.ReadInt32(); + int sampleRate = context.RequestData.ReadInt32(); + int channels = context.RequestData.ReadInt32(); - if (SampleRate == 0) + if (sampleRate == 0) { - SampleRate = DefaultSampleRate; + sampleRate = DefaultSampleRate; } - if (SampleRate != DefaultSampleRate) + if (sampleRate != DefaultSampleRate) { Logger.PrintWarning(LogClass.Audio, "Invalid sample rate!"); return MakeError(ErrorModule.Audio, AudErr.UnsupportedSampleRate); } - Channels = (ushort)Channels; + channels = (ushort)channels; - if (Channels == 0) + if (channels == 0) { - Channels = DefaultChannelsCount; + channels = DefaultChannelsCount; } - KEvent ReleaseEvent = new KEvent(Context.Device.System); + KEvent releaseEvent = new KEvent(context.Device.System); - ReleaseCallback Callback = () => + ReleaseCallback callback = () => { - ReleaseEvent.ReadableEvent.Signal(); + releaseEvent.ReadableEvent.Signal(); }; - IAalOutput AudioOut = Context.Device.AudioOut; + IAalOutput audioOut = context.Device.AudioOut; - int Track = AudioOut.OpenTrack(SampleRate, Channels, Callback); + int track = audioOut.OpenTrack(sampleRate, channels, callback); - MakeObject(Context, new IAudioOut(AudioOut, ReleaseEvent, Track)); + MakeObject(context, new IAudioOut(audioOut, releaseEvent, track)); - Context.ResponseData.Write(SampleRate); - Context.ResponseData.Write(Channels); - Context.ResponseData.Write((int)SampleFormat.PcmInt16); - Context.ResponseData.Write((int)PlaybackState.Stopped); + context.ResponseData.Write(sampleRate); + context.ResponseData.Write(channels); + context.ResponseData.Write((int)SampleFormat.PcmInt16); + context.ResponseData.Write((int)PlaybackState.Stopped); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Aud/IAudioRendererManager.cs b/Ryujinx.HLE/HOS/Services/Aud/IAudioRendererManager.cs index 48a449cc..a319537a 100644 --- a/Ryujinx.HLE/HOS/Services/Aud/IAudioRendererManager.cs +++ b/Ryujinx.HLE/HOS/Services/Aud/IAudioRendererManager.cs @@ -20,13 +20,13 @@ namespace Ryujinx.HLE.HOS.Services.Aud public const int RevMagic = Rev0Magic + (Rev << 24); - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IAudioRendererManager() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, OpenAudioRenderer }, { 1, GetAudioRendererWorkBufferSize }, @@ -35,81 +35,81 @@ namespace Ryujinx.HLE.HOS.Services.Aud }; } - public long OpenAudioRenderer(ServiceCtx Context) + public long OpenAudioRenderer(ServiceCtx context) { - IAalOutput AudioOut = Context.Device.AudioOut; + IAalOutput audioOut = context.Device.AudioOut; - AudioRendererParameter Params = GetAudioRendererParameter(Context); + AudioRendererParameter Params = GetAudioRendererParameter(context); - MakeObject(Context, new IAudioRenderer( - Context.Device.System, - Context.Memory, - AudioOut, + MakeObject(context, new IAudioRenderer( + context.Device.System, + context.Memory, + audioOut, Params)); return 0; } - public long GetAudioRendererWorkBufferSize(ServiceCtx Context) + public long GetAudioRendererWorkBufferSize(ServiceCtx context) { - AudioRendererParameter Params = GetAudioRendererParameter(Context); + AudioRendererParameter Params = GetAudioRendererParameter(context); - int Revision = (Params.Revision - Rev0Magic) >> 24; + int revision = (Params.Revision - Rev0Magic) >> 24; - if (Revision <= Rev) + if (revision <= Rev) { - bool IsSplitterSupported = Revision >= 3; + bool isSplitterSupported = revision >= 3; - long Size; + long size; - Size = IntUtils.AlignUp(Params.Unknown8 * 4, 64); - Size += Params.MixCount * 0x400; - Size += (Params.MixCount + 1) * 0x940; - Size += Params.VoiceCount * 0x3F0; - Size += IntUtils.AlignUp((Params.MixCount + 1) * 8, 16); - Size += IntUtils.AlignUp(Params.VoiceCount * 8, 16); - Size += IntUtils.AlignUp( + size = IntUtils.AlignUp(Params.Unknown8 * 4, 64); + size += Params.MixCount * 0x400; + size += (Params.MixCount + 1) * 0x940; + size += Params.VoiceCount * 0x3F0; + size += IntUtils.AlignUp((Params.MixCount + 1) * 8, 16); + size += IntUtils.AlignUp(Params.VoiceCount * 8, 16); + size += IntUtils.AlignUp( ((Params.SinkCount + Params.MixCount) * 0x3C0 + Params.SampleCount * 4) * (Params.Unknown8 + 6), 64); - Size += (Params.SinkCount + Params.MixCount) * 0x2C0; - Size += (Params.EffectCount + Params.VoiceCount * 4) * 0x30 + 0x50; + size += (Params.SinkCount + Params.MixCount) * 0x2C0; + size += (Params.EffectCount + Params.VoiceCount * 4) * 0x30 + 0x50; - if (IsSplitterSupported) + if (isSplitterSupported) { - Size += IntUtils.AlignUp(( + size += IntUtils.AlignUp(( NodeStatesGetWorkBufferSize(Params.MixCount + 1) + EdgeMatrixGetWorkBufferSize(Params.MixCount + 1)), 16); - Size += Params.SplitterDestinationDataCount * 0xE0; - Size += Params.SplitterCount * 0x20; - Size += IntUtils.AlignUp(Params.SplitterDestinationDataCount * 4, 16); + size += Params.SplitterDestinationDataCount * 0xE0; + size += Params.SplitterCount * 0x20; + size += IntUtils.AlignUp(Params.SplitterDestinationDataCount * 4, 16); } - Size = Params.EffectCount * 0x4C0 + + size = Params.EffectCount * 0x4C0 + Params.SinkCount * 0x170 + Params.VoiceCount * 0x100 + - IntUtils.AlignUp(Size, 64) + 0x40; + IntUtils.AlignUp(size, 64) + 0x40; if (Params.PerformanceManagerCount >= 1) { - Size += (((Params.EffectCount + + size += (((Params.EffectCount + Params.SinkCount + Params.VoiceCount + Params.MixCount + 1) * 16 + 0x658) * (Params.PerformanceManagerCount + 1) + 0x13F) & ~0x3FL; } - Size = (Size + 0x1907D) & ~0xFFFL; + size = (size + 0x1907D) & ~0xFFFL; - Context.ResponseData.Write(Size); + context.ResponseData.Write(size); - Logger.PrintDebug(LogClass.ServiceAudio, $"WorkBufferSize is 0x{Size:x16}."); + Logger.PrintDebug(LogClass.ServiceAudio, $"WorkBufferSize is 0x{size:x16}."); return 0; } else { - Context.ResponseData.Write(0L); + context.ResponseData.Write(0L); Logger.PrintWarning(LogClass.ServiceAudio, $"Library Revision 0x{Params.Revision:x8} is not supported!"); @@ -117,71 +117,71 @@ namespace Ryujinx.HLE.HOS.Services.Aud } } - private AudioRendererParameter GetAudioRendererParameter(ServiceCtx Context) + private AudioRendererParameter GetAudioRendererParameter(ServiceCtx context) { AudioRendererParameter Params = new AudioRendererParameter(); - Params.SampleRate = Context.RequestData.ReadInt32(); - Params.SampleCount = Context.RequestData.ReadInt32(); - Params.Unknown8 = Context.RequestData.ReadInt32(); - Params.MixCount = Context.RequestData.ReadInt32(); - Params.VoiceCount = Context.RequestData.ReadInt32(); - Params.SinkCount = Context.RequestData.ReadInt32(); - Params.EffectCount = Context.RequestData.ReadInt32(); - Params.PerformanceManagerCount = Context.RequestData.ReadInt32(); - Params.VoiceDropEnable = Context.RequestData.ReadInt32(); - Params.SplitterCount = Context.RequestData.ReadInt32(); - Params.SplitterDestinationDataCount = Context.RequestData.ReadInt32(); - Params.Unknown2C = Context.RequestData.ReadInt32(); - Params.Revision = Context.RequestData.ReadInt32(); + Params.SampleRate = context.RequestData.ReadInt32(); + Params.SampleCount = context.RequestData.ReadInt32(); + Params.Unknown8 = context.RequestData.ReadInt32(); + Params.MixCount = context.RequestData.ReadInt32(); + Params.VoiceCount = context.RequestData.ReadInt32(); + Params.SinkCount = context.RequestData.ReadInt32(); + Params.EffectCount = context.RequestData.ReadInt32(); + Params.PerformanceManagerCount = context.RequestData.ReadInt32(); + Params.VoiceDropEnable = context.RequestData.ReadInt32(); + Params.SplitterCount = context.RequestData.ReadInt32(); + Params.SplitterDestinationDataCount = context.RequestData.ReadInt32(); + Params.Unknown2C = context.RequestData.ReadInt32(); + Params.Revision = context.RequestData.ReadInt32(); return Params; } - private static int NodeStatesGetWorkBufferSize(int Value) + private static int NodeStatesGetWorkBufferSize(int value) { - int Result = IntUtils.AlignUp(Value, 64); + int result = IntUtils.AlignUp(value, 64); - if (Result < 0) + if (result < 0) { - Result |= 7; + result |= 7; } - return 4 * (Value * Value) + 0x12 * Value + 2 * (Result / 8); + return 4 * (value * value) + 0x12 * value + 2 * (result / 8); } - private static int EdgeMatrixGetWorkBufferSize(int Value) + private static int EdgeMatrixGetWorkBufferSize(int value) { - int Result = IntUtils.AlignUp(Value * Value, 64); + int result = IntUtils.AlignUp(value * value, 64); - if (Result < 0) + if (result < 0) { - Result |= 7; + result |= 7; } - return Result / 8; + return result / 8; } // GetAudioDeviceService(nn::applet::AppletResourceUserId) -> object<nn::audio::detail::IAudioDevice> - public long GetAudioDeviceService(ServiceCtx Context) + public long GetAudioDeviceService(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - MakeObject(Context, new IAudioDevice(Context.Device.System)); + MakeObject(context, new IAudioDevice(context.Device.System)); return 0; } // GetAudioDeviceServiceWithRevisionInfo(nn::applet::AppletResourceUserId, u32) -> object<nn::audio::detail::IAudioDevice> - private long GetAudioDeviceServiceWithRevisionInfo(ServiceCtx Context) + private long GetAudioDeviceServiceWithRevisionInfo(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); - int RevisionInfo = Context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); + int revisionInfo = context.RequestData.ReadInt32(); - Logger.PrintStub(LogClass.ServiceAudio, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"RevisionInfo: {RevisionInfo}"); + Logger.PrintStub(LogClass.ServiceAudio, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"RevisionInfo: {revisionInfo}"); - return GetAudioDeviceService(Context); + return GetAudioDeviceService(context); } } } diff --git a/Ryujinx.HLE/HOS/Services/Aud/IHardwareOpusDecoder.cs b/Ryujinx.HLE/HOS/Services/Aud/IHardwareOpusDecoder.cs index a71b8602..fc0bd8db 100644 --- a/Ryujinx.HLE/HOS/Services/Aud/IHardwareOpusDecoder.cs +++ b/Ryujinx.HLE/HOS/Services/Aud/IHardwareOpusDecoder.cs @@ -10,80 +10,80 @@ namespace Ryujinx.HLE.HOS.Services.Aud { private const int FixedSampleRate = 48000; - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private int SampleRate; - private int ChannelsCount; + private int _sampleRate; + private int _channelsCount; - private OpusDecoder Decoder; + private OpusDecoder _decoder; - public IHardwareOpusDecoder(int SampleRate, int ChannelsCount) + public IHardwareOpusDecoder(int sampleRate, int channelsCount) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, DecodeInterleaved }, { 4, DecodeInterleavedWithPerf } }; - this.SampleRate = SampleRate; - this.ChannelsCount = ChannelsCount; + _sampleRate = sampleRate; + _channelsCount = channelsCount; - Decoder = new OpusDecoder(FixedSampleRate, ChannelsCount); + _decoder = new OpusDecoder(FixedSampleRate, channelsCount); } - public long DecodeInterleavedWithPerf(ServiceCtx Context) + public long DecodeInterleavedWithPerf(ServiceCtx context) { - long Result = DecodeInterleaved(Context); + long result = DecodeInterleaved(context); //TODO: Figure out what this value is. //According to switchbrew, it is now used. - Context.ResponseData.Write(0L); + context.ResponseData.Write(0L); - return Result; + return result; } - public long DecodeInterleaved(ServiceCtx Context) + public long DecodeInterleaved(ServiceCtx context) { - long InPosition = Context.Request.SendBuff[0].Position; - long InSize = Context.Request.SendBuff[0].Size; + long inPosition = context.Request.SendBuff[0].Position; + long inSize = context.Request.SendBuff[0].Size; - if (InSize < 8) + if (inSize < 8) { return MakeError(ErrorModule.Audio, AudErr.OpusInvalidInput); } - long OutPosition = Context.Request.ReceiveBuff[0].Position; - long OutSize = Context.Request.ReceiveBuff[0].Size; + long outPosition = context.Request.ReceiveBuff[0].Position; + long outSize = context.Request.ReceiveBuff[0].Size; - byte[] OpusData = Context.Memory.ReadBytes(InPosition, InSize); + byte[] opusData = context.Memory.ReadBytes(inPosition, inSize); - int Processed = ((OpusData[0] << 24) | - (OpusData[1] << 16) | - (OpusData[2] << 8) | - (OpusData[3] << 0)) + 8; + int processed = ((opusData[0] << 24) | + (opusData[1] << 16) | + (opusData[2] << 8) | + (opusData[3] << 0)) + 8; - if ((uint)Processed > (ulong)InSize) + if ((uint)processed > (ulong)inSize) { return MakeError(ErrorModule.Audio, AudErr.OpusInvalidInput); } - short[] Pcm = new short[OutSize / 2]; + short[] pcm = new short[outSize / 2]; - int FrameSize = Pcm.Length / (ChannelsCount * 2); + int frameSize = pcm.Length / (_channelsCount * 2); - int Samples = Decoder.Decode(OpusData, 0, OpusData.Length, Pcm, 0, FrameSize); + int samples = _decoder.Decode(opusData, 0, opusData.Length, pcm, 0, frameSize); - foreach (short Sample in Pcm) + foreach (short sample in pcm) { - Context.Memory.WriteInt16(OutPosition, Sample); + context.Memory.WriteInt16(outPosition, sample); - OutPosition += 2; + outPosition += 2; } - Context.ResponseData.Write(Processed); - Context.ResponseData.Write(Samples); + context.ResponseData.Write(processed); + context.ResponseData.Write(samples); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Aud/IHardwareOpusDecoderManager.cs b/Ryujinx.HLE/HOS/Services/Aud/IHardwareOpusDecoderManager.cs index 875dc74c..495c8ab4 100644 --- a/Ryujinx.HLE/HOS/Services/Aud/IHardwareOpusDecoderManager.cs +++ b/Ryujinx.HLE/HOS/Services/Aud/IHardwareOpusDecoderManager.cs @@ -5,68 +5,68 @@ namespace Ryujinx.HLE.HOS.Services.Aud { class IHardwareOpusDecoderManager : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IHardwareOpusDecoderManager() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, Initialize }, { 1, GetWorkBufferSize } }; } - public long Initialize(ServiceCtx Context) + public long Initialize(ServiceCtx context) { - int SampleRate = Context.RequestData.ReadInt32(); - int ChannelsCount = Context.RequestData.ReadInt32(); + int sampleRate = context.RequestData.ReadInt32(); + int channelsCount = context.RequestData.ReadInt32(); - MakeObject(Context, new IHardwareOpusDecoder(SampleRate, ChannelsCount)); + MakeObject(context, new IHardwareOpusDecoder(sampleRate, channelsCount)); return 0; } - public long GetWorkBufferSize(ServiceCtx Context) + public long GetWorkBufferSize(ServiceCtx context) { //Note: The sample rate is ignored because it is fixed to 48KHz. - int SampleRate = Context.RequestData.ReadInt32(); - int ChannelsCount = Context.RequestData.ReadInt32(); + int sampleRate = context.RequestData.ReadInt32(); + int channelsCount = context.RequestData.ReadInt32(); - Context.ResponseData.Write(GetOpusDecoderSize(ChannelsCount)); + context.ResponseData.Write(GetOpusDecoderSize(channelsCount)); return 0; } - private static int GetOpusDecoderSize(int ChannelsCount) + private static int GetOpusDecoderSize(int channelsCount) { - const int SilkDecoderSize = 0x2198; + const int silkDecoderSize = 0x2198; - if (ChannelsCount < 1 || ChannelsCount > 2) + if (channelsCount < 1 || channelsCount > 2) { return 0; } - int CeltDecoderSize = GetCeltDecoderSize(ChannelsCount); + int celtDecoderSize = GetCeltDecoderSize(channelsCount); - int OpusDecoderSize = (ChannelsCount * 0x800 + 0x4807) & -0x800 | 0x50; + int opusDecoderSize = (channelsCount * 0x800 + 0x4807) & -0x800 | 0x50; - return OpusDecoderSize + SilkDecoderSize + CeltDecoderSize; + return opusDecoderSize + silkDecoderSize + celtDecoderSize; } - private static int GetCeltDecoderSize(int ChannelsCount) + private static int GetCeltDecoderSize(int channelsCount) { - const int DecodeBufferSize = 0x2030; - const int CeltDecoderSize = 0x58; - const int CeltSigSize = 0x4; - const int Overlap = 120; - const int EBandsCount = 21; - - return (DecodeBufferSize + Overlap * 4) * ChannelsCount + - EBandsCount * 16 + - CeltDecoderSize + - CeltSigSize; + const int decodeBufferSize = 0x2030; + const int celtDecoderSize = 0x58; + const int celtSigSize = 0x4; + const int overlap = 120; + const int eBandsCount = 21; + + return (decodeBufferSize + overlap * 4) * channelsCount + + eBandsCount * 16 + + celtDecoderSize + + celtSigSize; } } } diff --git a/Ryujinx.HLE/HOS/Services/Bcat/IBcatService.cs b/Ryujinx.HLE/HOS/Services/Bcat/IBcatService.cs index 6263dfa8..051b75d6 100644 --- a/Ryujinx.HLE/HOS/Services/Bcat/IBcatService.cs +++ b/Ryujinx.HLE/HOS/Services/Bcat/IBcatService.cs @@ -5,13 +5,13 @@ namespace Ryujinx.HLE.HOS.Services.Bcat { class IBcatService : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IBcatService() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { //... }; diff --git a/Ryujinx.HLE/HOS/Services/Bcat/IDeliveryCacheStorageService.cs b/Ryujinx.HLE/HOS/Services/Bcat/IDeliveryCacheStorageService.cs index 7a55c6c8..043cb607 100644 --- a/Ryujinx.HLE/HOS/Services/Bcat/IDeliveryCacheStorageService.cs +++ b/Ryujinx.HLE/HOS/Services/Bcat/IDeliveryCacheStorageService.cs @@ -5,13 +5,13 @@ namespace Ryujinx.HLE.HOS.Services.Bcat { class IDeliveryCacheStorageService : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IDeliveryCacheStorageService() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { //... }; diff --git a/Ryujinx.HLE/HOS/Services/Bcat/IServiceCreator.cs b/Ryujinx.HLE/HOS/Services/Bcat/IServiceCreator.cs index 55583c94..6523aa63 100644 --- a/Ryujinx.HLE/HOS/Services/Bcat/IServiceCreator.cs +++ b/Ryujinx.HLE/HOS/Services/Bcat/IServiceCreator.cs @@ -5,33 +5,33 @@ namespace Ryujinx.HLE.HOS.Services.Bcat { class IServiceCreator : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IServiceCreator() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, CreateBcatService }, { 1, CreateDeliveryCacheStorageService } }; } - public long CreateBcatService(ServiceCtx Context) + public long CreateBcatService(ServiceCtx context) { - long Id = Context.RequestData.ReadInt64(); + long id = context.RequestData.ReadInt64(); - MakeObject(Context, new IBcatService()); + MakeObject(context, new IBcatService()); return 0; } - public long CreateDeliveryCacheStorageService(ServiceCtx Context) + public long CreateDeliveryCacheStorageService(ServiceCtx context) { - long Id = Context.RequestData.ReadInt64(); + long id = context.RequestData.ReadInt64(); - MakeObject(Context, new IDeliveryCacheStorageService()); + MakeObject(context, new IDeliveryCacheStorageService()); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Bsd/BsdIoctl.cs b/Ryujinx.HLE/HOS/Services/Bsd/BsdIoctl.cs index 15fc7a82..de6fa73f 100644 --- a/Ryujinx.HLE/HOS/Services/Bsd/BsdIoctl.cs +++ b/Ryujinx.HLE/HOS/Services/Bsd/BsdIoctl.cs @@ -2,6 +2,6 @@ { enum BsdIoctl { - AtMark = 0x40047307, + AtMark = 0x40047307 } } diff --git a/Ryujinx.HLE/HOS/Services/Bsd/IClient.cs b/Ryujinx.HLE/HOS/Services/Bsd/IClient.cs index 37d0fcfd..aac85021 100644 --- a/Ryujinx.HLE/HOS/Services/Bsd/IClient.cs +++ b/Ryujinx.HLE/HOS/Services/Bsd/IClient.cs @@ -11,101 +11,101 @@ namespace Ryujinx.HLE.HOS.Services.Bsd class IClient : IpcService { - private static Dictionary<WSAError, LinuxError> ErrorMap = new Dictionary<WSAError, LinuxError> + private static Dictionary<WsaError, LinuxError> _errorMap = new Dictionary<WsaError, LinuxError> { // WSAEINTR - {WSAError.WSAEINTR, LinuxError.EINTR}, + {WsaError.WSAEINTR, LinuxError.EINTR}, // WSAEWOULDBLOCK - {WSAError.WSAEWOULDBLOCK, LinuxError.EWOULDBLOCK}, + {WsaError.WSAEWOULDBLOCK, LinuxError.EWOULDBLOCK}, // WSAEINPROGRESS - {WSAError.WSAEINPROGRESS, LinuxError.EINPROGRESS}, + {WsaError.WSAEINPROGRESS, LinuxError.EINPROGRESS}, // WSAEALREADY - {WSAError.WSAEALREADY, LinuxError.EALREADY}, + {WsaError.WSAEALREADY, LinuxError.EALREADY}, // WSAENOTSOCK - {WSAError.WSAENOTSOCK, LinuxError.ENOTSOCK}, + {WsaError.WSAENOTSOCK, LinuxError.ENOTSOCK}, // WSAEDESTADDRREQ - {WSAError.WSAEDESTADDRREQ, LinuxError.EDESTADDRREQ}, + {WsaError.WSAEDESTADDRREQ, LinuxError.EDESTADDRREQ}, // WSAEMSGSIZE - {WSAError.WSAEMSGSIZE, LinuxError.EMSGSIZE}, + {WsaError.WSAEMSGSIZE, LinuxError.EMSGSIZE}, // WSAEPROTOTYPE - {WSAError.WSAEPROTOTYPE, LinuxError.EPROTOTYPE}, + {WsaError.WSAEPROTOTYPE, LinuxError.EPROTOTYPE}, // WSAENOPROTOOPT - {WSAError.WSAENOPROTOOPT, LinuxError.ENOPROTOOPT}, + {WsaError.WSAENOPROTOOPT, LinuxError.ENOPROTOOPT}, // WSAEPROTONOSUPPORT - {WSAError.WSAEPROTONOSUPPORT, LinuxError.EPROTONOSUPPORT}, + {WsaError.WSAEPROTONOSUPPORT, LinuxError.EPROTONOSUPPORT}, // WSAESOCKTNOSUPPORT - {WSAError.WSAESOCKTNOSUPPORT, LinuxError.ESOCKTNOSUPPORT}, + {WsaError.WSAESOCKTNOSUPPORT, LinuxError.ESOCKTNOSUPPORT}, // WSAEOPNOTSUPP - {WSAError.WSAEOPNOTSUPP, LinuxError.EOPNOTSUPP}, + {WsaError.WSAEOPNOTSUPP, LinuxError.EOPNOTSUPP}, // WSAEPFNOSUPPORT - {WSAError.WSAEPFNOSUPPORT, LinuxError.EPFNOSUPPORT}, + {WsaError.WSAEPFNOSUPPORT, LinuxError.EPFNOSUPPORT}, // WSAEAFNOSUPPORT - {WSAError.WSAEAFNOSUPPORT, LinuxError.EAFNOSUPPORT}, + {WsaError.WSAEAFNOSUPPORT, LinuxError.EAFNOSUPPORT}, // WSAEADDRINUSE - {WSAError.WSAEADDRINUSE, LinuxError.EADDRINUSE}, + {WsaError.WSAEADDRINUSE, LinuxError.EADDRINUSE}, // WSAEADDRNOTAVAIL - {WSAError.WSAEADDRNOTAVAIL, LinuxError.EADDRNOTAVAIL}, + {WsaError.WSAEADDRNOTAVAIL, LinuxError.EADDRNOTAVAIL}, // WSAENETDOWN - {WSAError.WSAENETDOWN, LinuxError.ENETDOWN}, + {WsaError.WSAENETDOWN, LinuxError.ENETDOWN}, // WSAENETUNREACH - {WSAError.WSAENETUNREACH, LinuxError.ENETUNREACH}, + {WsaError.WSAENETUNREACH, LinuxError.ENETUNREACH}, // WSAENETRESET - {WSAError.WSAENETRESET, LinuxError.ENETRESET}, + {WsaError.WSAENETRESET, LinuxError.ENETRESET}, // WSAECONNABORTED - {WSAError.WSAECONNABORTED, LinuxError.ECONNABORTED}, + {WsaError.WSAECONNABORTED, LinuxError.ECONNABORTED}, // WSAECONNRESET - {WSAError.WSAECONNRESET, LinuxError.ECONNRESET}, + {WsaError.WSAECONNRESET, LinuxError.ECONNRESET}, // WSAENOBUFS - {WSAError.WSAENOBUFS, LinuxError.ENOBUFS}, + {WsaError.WSAENOBUFS, LinuxError.ENOBUFS}, // WSAEISCONN - {WSAError.WSAEISCONN, LinuxError.EISCONN}, + {WsaError.WSAEISCONN, LinuxError.EISCONN}, // WSAENOTCONN - {WSAError.WSAENOTCONN, LinuxError.ENOTCONN}, + {WsaError.WSAENOTCONN, LinuxError.ENOTCONN}, // WSAESHUTDOWN - {WSAError.WSAESHUTDOWN, LinuxError.ESHUTDOWN}, + {WsaError.WSAESHUTDOWN, LinuxError.ESHUTDOWN}, // WSAETOOMANYREFS - {WSAError.WSAETOOMANYREFS, LinuxError.ETOOMANYREFS}, + {WsaError.WSAETOOMANYREFS, LinuxError.ETOOMANYREFS}, // WSAETIMEDOUT - {WSAError.WSAETIMEDOUT, LinuxError.ETIMEDOUT}, + {WsaError.WSAETIMEDOUT, LinuxError.ETIMEDOUT}, // WSAECONNREFUSED - {WSAError.WSAECONNREFUSED, LinuxError.ECONNREFUSED}, + {WsaError.WSAECONNREFUSED, LinuxError.ECONNREFUSED}, // WSAELOOP - {WSAError.WSAELOOP, LinuxError.ELOOP}, + {WsaError.WSAELOOP, LinuxError.ELOOP}, // WSAENAMETOOLONG - {WSAError.WSAENAMETOOLONG, LinuxError.ENAMETOOLONG}, + {WsaError.WSAENAMETOOLONG, LinuxError.ENAMETOOLONG}, // WSAEHOSTDOWN - {WSAError.WSAEHOSTDOWN, LinuxError.EHOSTDOWN}, + {WsaError.WSAEHOSTDOWN, LinuxError.EHOSTDOWN}, // WSAEHOSTUNREACH - {WSAError.WSAEHOSTUNREACH, LinuxError.EHOSTUNREACH}, + {WsaError.WSAEHOSTUNREACH, LinuxError.EHOSTUNREACH}, // WSAENOTEMPTY - {WSAError.WSAENOTEMPTY, LinuxError.ENOTEMPTY}, + {WsaError.WSAENOTEMPTY, LinuxError.ENOTEMPTY}, // WSAEUSERS - {WSAError.WSAEUSERS, LinuxError.EUSERS}, + {WsaError.WSAEUSERS, LinuxError.EUSERS}, // WSAEDQUOT - {WSAError.WSAEDQUOT, LinuxError.EDQUOT}, + {WsaError.WSAEDQUOT, LinuxError.EDQUOT}, // WSAESTALE - {WSAError.WSAESTALE, LinuxError.ESTALE}, + {WsaError.WSAESTALE, LinuxError.ESTALE}, // WSAEREMOTE - {WSAError.WSAEREMOTE, LinuxError.EREMOTE}, + {WsaError.WSAEREMOTE, LinuxError.EREMOTE}, // WSAEINVAL - {WSAError.WSAEINVAL, LinuxError.EINVAL}, + {WsaError.WSAEINVAL, LinuxError.EINVAL}, // WSAEFAULT - {WSAError.WSAEFAULT, LinuxError.EFAULT}, + {WsaError.WSAEFAULT, LinuxError.EFAULT}, // NOERROR {0, 0} }; - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private bool IsPrivileged; + private bool _isPrivileged; - private List<BsdSocket> Sockets = new List<BsdSocket>(); + private List<BsdSocket> _sockets = new List<BsdSocket>(); - public IClient(bool IsPrivileged) + public IClient(bool isPrivileged) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, RegisterClient }, { 1, StartMonitoring }, @@ -134,60 +134,60 @@ namespace Ryujinx.HLE.HOS.Services.Bsd { 24, Write }, { 25, Read }, { 26, Close }, - { 27, DuplicateSocket }, + { 27, DuplicateSocket } }; - this.IsPrivileged = IsPrivileged; + _isPrivileged = isPrivileged; } - private LinuxError ConvertError(WSAError ErrorCode) + private LinuxError ConvertError(WsaError errorCode) { - LinuxError Errno; + LinuxError errno; - if (!ErrorMap.TryGetValue(ErrorCode, out Errno)) + if (!_errorMap.TryGetValue(errorCode, out errno)) { - Errno = (LinuxError)ErrorCode; + errno = (LinuxError)errorCode; } - return Errno; + return errno; } - private long WriteWinSock2Error(ServiceCtx Context, WSAError ErrorCode) + private long WriteWinSock2Error(ServiceCtx context, WsaError errorCode) { - return WriteBsdResult(Context, -1, ConvertError(ErrorCode)); + return WriteBsdResult(context, -1, ConvertError(errorCode)); } - private long WriteBsdResult(ServiceCtx Context, int Result, LinuxError ErrorCode = 0) + private long WriteBsdResult(ServiceCtx context, int result, LinuxError errorCode = 0) { - if (ErrorCode != LinuxError.SUCCESS) + if (errorCode != LinuxError.SUCCESS) { - Result = -1; + result = -1; } - Context.ResponseData.Write(Result); - Context.ResponseData.Write((int)ErrorCode); + context.ResponseData.Write(result); + context.ResponseData.Write((int)errorCode); return 0; } - private BsdSocket RetrieveSocket(int SocketFd) + private BsdSocket RetrieveSocket(int socketFd) { - if (SocketFd >= 0 && Sockets.Count > SocketFd) + if (socketFd >= 0 && _sockets.Count > socketFd) { - return Sockets[SocketFd]; + return _sockets[socketFd]; } return null; } - private LinuxError SetResultErrno(Socket Socket, int Result) + private LinuxError SetResultErrno(Socket socket, int result) { - return Result == 0 && !Socket.Blocking ? LinuxError.EWOULDBLOCK : LinuxError.SUCCESS; + return result == 0 && !socket.Blocking ? LinuxError.EWOULDBLOCK : LinuxError.SUCCESS; } - private AddressFamily ConvertFromBsd(int Domain) + private AddressFamily ConvertFromBsd(int domain) { - if (Domain == 2) + if (domain == 2) { return AddressFamily.InterNetwork; } @@ -196,70 +196,70 @@ namespace Ryujinx.HLE.HOS.Services.Bsd return AddressFamily.Unknown; } - private long SocketInternal(ServiceCtx Context, bool Exempt) + private long SocketInternal(ServiceCtx context, bool exempt) { - AddressFamily Domain = (AddressFamily)Context.RequestData.ReadInt32(); - SocketType Type = (SocketType)Context.RequestData.ReadInt32(); - ProtocolType Protocol = (ProtocolType)Context.RequestData.ReadInt32(); + AddressFamily domain = (AddressFamily)context.RequestData.ReadInt32(); + SocketType type = (SocketType)context.RequestData.ReadInt32(); + ProtocolType protocol = (ProtocolType)context.RequestData.ReadInt32(); - if (Domain == AddressFamily.Unknown) + if (domain == AddressFamily.Unknown) { - return WriteBsdResult(Context, -1, LinuxError.EPROTONOSUPPORT); + return WriteBsdResult(context, -1, LinuxError.EPROTONOSUPPORT); } - else if ((Type == SocketType.Seqpacket || Type == SocketType.Raw) && !IsPrivileged) + else if ((type == SocketType.Seqpacket || type == SocketType.Raw) && !_isPrivileged) { - if (Domain != AddressFamily.InterNetwork || Type != SocketType.Raw || Protocol != ProtocolType.Icmp) + if (domain != AddressFamily.InterNetwork || type != SocketType.Raw || protocol != ProtocolType.Icmp) { - return WriteBsdResult(Context, -1, LinuxError.ENOENT); + return WriteBsdResult(context, -1, LinuxError.ENOENT); } } - BsdSocket NewBsdSocket = new BsdSocket + BsdSocket newBsdSocket = new BsdSocket { - Family = (int)Domain, - Type = (int)Type, - Protocol = (int)Protocol, - Handle = new Socket(Domain, Type, Protocol) + Family = (int)domain, + Type = (int)type, + Protocol = (int)protocol, + Handle = new Socket(domain, type, protocol) }; - Sockets.Add(NewBsdSocket); + _sockets.Add(newBsdSocket); - if (Exempt) + if (exempt) { - NewBsdSocket.Handle.Disconnect(true); + newBsdSocket.Handle.Disconnect(true); } - return WriteBsdResult(Context, Sockets.Count - 1); + return WriteBsdResult(context, _sockets.Count - 1); } - private IPEndPoint ParseSockAddr(ServiceCtx Context, long BufferPosition, long BufferSize) + private IPEndPoint ParseSockAddr(ServiceCtx context, long bufferPosition, long bufferSize) { - int Size = Context.Memory.ReadByte(BufferPosition); - int Family = Context.Memory.ReadByte(BufferPosition + 1); - int Port = EndianSwap.Swap16(Context.Memory.ReadUInt16(BufferPosition + 2)); + int size = context.Memory.ReadByte(bufferPosition); + int family = context.Memory.ReadByte(bufferPosition + 1); + int port = EndianSwap.Swap16(context.Memory.ReadUInt16(bufferPosition + 2)); - byte[] RawIp = Context.Memory.ReadBytes(BufferPosition + 4, 4); + byte[] rawIp = context.Memory.ReadBytes(bufferPosition + 4, 4); - return new IPEndPoint(new IPAddress(RawIp), Port); + return new IPEndPoint(new IPAddress(rawIp), port); } - private void WriteSockAddr(ServiceCtx Context, long BufferPosition, IPEndPoint EndPoint) + private void WriteSockAddr(ServiceCtx context, long bufferPosition, IPEndPoint endPoint) { - Context.Memory.WriteByte(BufferPosition, 0); - Context.Memory.WriteByte(BufferPosition + 1, (byte)EndPoint.AddressFamily); - Context.Memory.WriteUInt16(BufferPosition + 2, EndianSwap.Swap16((ushort)EndPoint.Port)); - Context.Memory.WriteBytes(BufferPosition + 4, EndPoint.Address.GetAddressBytes()); + context.Memory.WriteByte(bufferPosition, 0); + context.Memory.WriteByte(bufferPosition + 1, (byte)endPoint.AddressFamily); + context.Memory.WriteUInt16(bufferPosition + 2, EndianSwap.Swap16((ushort)endPoint.Port)); + context.Memory.WriteBytes(bufferPosition + 4, endPoint.Address.GetAddressBytes()); } - private void WriteSockAddr(ServiceCtx Context, long BufferPosition, BsdSocket Socket, bool IsRemote) + private void WriteSockAddr(ServiceCtx context, long bufferPosition, BsdSocket socket, bool isRemote) { - IPEndPoint EndPoint = (IsRemote ? Socket.Handle.RemoteEndPoint : Socket.Handle.LocalEndPoint) as IPEndPoint; + IPEndPoint endPoint = (isRemote ? socket.Handle.RemoteEndPoint : socket.Handle.LocalEndPoint) as IPEndPoint; - WriteSockAddr(Context, BufferPosition, EndPoint); + WriteSockAddr(context, bufferPosition, endPoint); } // Initialize(nn::socket::BsdBufferConfig config, u64 pid, u64 transferMemorySize, KObject<copy, transfer_memory>, pid) -> u32 bsd_errno - public long RegisterClient(ServiceCtx Context) + public long RegisterClient(ServiceCtx context) { /* typedef struct { @@ -275,7 +275,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd */ // bsd_error - Context.ResponseData.Write(0); + context.ResponseData.Write(0); Logger.PrintStub(LogClass.ServiceBsd, "Stubbed."); @@ -283,49 +283,49 @@ namespace Ryujinx.HLE.HOS.Services.Bsd } // StartMonitoring(u64, pid) - public long StartMonitoring(ServiceCtx Context) + public long StartMonitoring(ServiceCtx context) { - ulong Unknown0 = Context.RequestData.ReadUInt64(); + ulong unknown0 = context.RequestData.ReadUInt64(); - Logger.PrintStub(LogClass.ServiceBsd, $"Stubbed. Unknown0: {Unknown0}"); + Logger.PrintStub(LogClass.ServiceBsd, $"Stubbed. Unknown0: {unknown0}"); return 0; } // Socket(u32 domain, u32 type, u32 protocol) -> (i32 ret, u32 bsd_errno) - public long Socket(ServiceCtx Context) + public long Socket(ServiceCtx context) { - return SocketInternal(Context, false); + return SocketInternal(context, false); } // SocketExempt(u32 domain, u32 type, u32 protocol) -> (i32 ret, u32 bsd_errno) - public long SocketExempt(ServiceCtx Context) + public long SocketExempt(ServiceCtx context) { - return SocketInternal(Context, true); + return SocketInternal(context, true); } // Open(u32 flags, array<unknown, 0x21> path) -> (i32 ret, u32 bsd_errno) - public long Open(ServiceCtx Context) + public long Open(ServiceCtx context) { - (long BufferPosition, long BufferSize) = Context.Request.GetBufferType0x21(); + (long bufferPosition, long bufferSize) = context.Request.GetBufferType0x21(); - int Flags = Context.RequestData.ReadInt32(); + int flags = context.RequestData.ReadInt32(); - byte[] RawPath = Context.Memory.ReadBytes(BufferPosition, BufferSize); - string Path = Encoding.ASCII.GetString(RawPath); + byte[] rawPath = context.Memory.ReadBytes(bufferPosition, bufferSize); + string path = Encoding.ASCII.GetString(rawPath); - WriteBsdResult(Context, -1, LinuxError.EOPNOTSUPP); + WriteBsdResult(context, -1, LinuxError.EOPNOTSUPP); - Logger.PrintStub(LogClass.ServiceBsd, $"Stubbed. Path: {Path} - " + - $"Flags: {Flags}"); + Logger.PrintStub(LogClass.ServiceBsd, $"Stubbed. Path: {path} - " + + $"Flags: {flags}"); return 0; } // Select(u32 nfds, nn::socket::timeout timeout, buffer<nn::socket::fd_set, 0x21, 0> readfds_in, buffer<nn::socket::fd_set, 0x21, 0> writefds_in, buffer<nn::socket::fd_set, 0x21, 0> errorfds_in) -> (i32 ret, u32 bsd_errno, buffer<nn::socket::fd_set, 0x22, 0> readfds_out, buffer<nn::socket::fd_set, 0x22, 0> writefds_out, buffer<nn::socket::fd_set, 0x22, 0> errorfds_out) - public long Select(ServiceCtx Context) + public long Select(ServiceCtx context) { - WriteBsdResult(Context, -1, LinuxError.EOPNOTSUPP); + WriteBsdResult(context, -1, LinuxError.EOPNOTSUPP); Logger.PrintStub(LogClass.ServiceBsd, $"Stubbed."); @@ -333,135 +333,134 @@ namespace Ryujinx.HLE.HOS.Services.Bsd } // Poll(u32 nfds, u32 timeout, buffer<unknown, 0x21, 0> fds) -> (i32 ret, u32 bsd_errno, buffer<unknown, 0x22, 0>) - public long Poll(ServiceCtx Context) + public long Poll(ServiceCtx context) { - int FdsCount = Context.RequestData.ReadInt32(); - int Timeout = Context.RequestData.ReadInt32(); + int fdsCount = context.RequestData.ReadInt32(); + int timeout = context.RequestData.ReadInt32(); - (long BufferPosition, long BufferSize) = Context.Request.GetBufferType0x21(); + (long bufferPosition, long bufferSize) = context.Request.GetBufferType0x21(); - if (Timeout < -1 || FdsCount < 0 || (FdsCount * 8) > BufferSize) + if (timeout < -1 || fdsCount < 0 || (fdsCount * 8) > bufferSize) { - return WriteBsdResult(Context, -1, LinuxError.EINVAL); + return WriteBsdResult(context, -1, LinuxError.EINVAL); } - PollEvent[] Events = new PollEvent[FdsCount]; + PollEvent[] events = new PollEvent[fdsCount]; - for (int i = 0; i < FdsCount; i++) + for (int i = 0; i < fdsCount; i++) { - int SocketFd = Context.Memory.ReadInt32(BufferPosition + i * 8); + int socketFd = context.Memory.ReadInt32(bufferPosition + i * 8); - BsdSocket Socket = RetrieveSocket(SocketFd); + BsdSocket socket = RetrieveSocket(socketFd); - if (Socket == null) + if (socket == null) { - return WriteBsdResult(Context, -1, LinuxError.EBADF); - } + return WriteBsdResult(context, -1, LinuxError.EBADF);} - PollEvent.EventTypeMask InputEvents = (PollEvent.EventTypeMask)Context.Memory.ReadInt16(BufferPosition + i * 8 + 4); - PollEvent.EventTypeMask OutputEvents = (PollEvent.EventTypeMask)Context.Memory.ReadInt16(BufferPosition + i * 8 + 6); + PollEvent.EventTypeMask inputEvents = (PollEvent.EventTypeMask)context.Memory.ReadInt16(bufferPosition + i * 8 + 4); + PollEvent.EventTypeMask outputEvents = (PollEvent.EventTypeMask)context.Memory.ReadInt16(bufferPosition + i * 8 + 6); - Events[i] = new PollEvent(SocketFd, Socket, InputEvents, OutputEvents); + events[i] = new PollEvent(socketFd, socket, inputEvents, outputEvents); } - List<Socket> ReadEvents = new List<Socket>(); - List<Socket> WriteEvents = new List<Socket>(); - List<Socket> ErrorEvents = new List<Socket>(); + List<Socket> readEvents = new List<Socket>(); + List<Socket> writeEvents = new List<Socket>(); + List<Socket> errorEvents = new List<Socket>(); - foreach (PollEvent Event in Events) + foreach (PollEvent Event in events) { - bool IsValidEvent = false; + bool isValidEvent = false; if ((Event.InputEvents & PollEvent.EventTypeMask.Input) != 0) { - ReadEvents.Add(Event.Socket.Handle); - ErrorEvents.Add(Event.Socket.Handle); + readEvents.Add(Event.Socket.Handle); + errorEvents.Add(Event.Socket.Handle); - IsValidEvent = true; + isValidEvent = true; } if ((Event.InputEvents & PollEvent.EventTypeMask.UrgentInput) != 0) { - ReadEvents.Add(Event.Socket.Handle); - ErrorEvents.Add(Event.Socket.Handle); + readEvents.Add(Event.Socket.Handle); + errorEvents.Add(Event.Socket.Handle); - IsValidEvent = true; + isValidEvent = true; } if ((Event.InputEvents & PollEvent.EventTypeMask.Output) != 0) { - WriteEvents.Add(Event.Socket.Handle); - ErrorEvents.Add(Event.Socket.Handle); + writeEvents.Add(Event.Socket.Handle); + errorEvents.Add(Event.Socket.Handle); - IsValidEvent = true; + isValidEvent = true; } if ((Event.InputEvents & PollEvent.EventTypeMask.Error) != 0) { - ErrorEvents.Add(Event.Socket.Handle); - IsValidEvent = true; + errorEvents.Add(Event.Socket.Handle); + isValidEvent = true; } - if (!IsValidEvent) + if (!isValidEvent) { Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported Poll input event type: {Event.InputEvents}"); - return WriteBsdResult(Context, -1, LinuxError.EINVAL); + return WriteBsdResult(context, -1, LinuxError.EINVAL); } } try { - System.Net.Sockets.Socket.Select(ReadEvents, WriteEvents, ErrorEvents, Timeout); + System.Net.Sockets.Socket.Select(readEvents, writeEvents, errorEvents, timeout); } - catch (SocketException Exception) + catch (SocketException exception) { - return WriteWinSock2Error(Context, (WSAError)Exception.ErrorCode); + return WriteWinSock2Error(context, (WsaError)exception.ErrorCode); } - for (int i = 0; i < FdsCount; i++) + for (int i = 0; i < fdsCount; i++) { - PollEvent Event = Events[i]; - Context.Memory.WriteInt32(BufferPosition + i * 8, Event.SocketFd); - Context.Memory.WriteInt16(BufferPosition + i * 8 + 4, (short)Event.InputEvents); + PollEvent Event = events[i]; + context.Memory.WriteInt32(bufferPosition + i * 8, Event.SocketFd); + context.Memory.WriteInt16(bufferPosition + i * 8 + 4, (short)Event.InputEvents); - PollEvent.EventTypeMask OutputEvents = 0; + PollEvent.EventTypeMask outputEvents = 0; - Socket Socket = Event.Socket.Handle; + Socket socket = Event.Socket.Handle; - if (ErrorEvents.Contains(Socket)) + if (errorEvents.Contains(socket)) { - OutputEvents |= PollEvent.EventTypeMask.Error; + outputEvents |= PollEvent.EventTypeMask.Error; - if (!Socket.Connected || !Socket.IsBound) + if (!socket.Connected || !socket.IsBound) { - OutputEvents |= PollEvent.EventTypeMask.Disconnected; + outputEvents |= PollEvent.EventTypeMask.Disconnected; } } - if (ReadEvents.Contains(Socket)) + if (readEvents.Contains(socket)) { if ((Event.InputEvents & PollEvent.EventTypeMask.Input) != 0) { - OutputEvents |= PollEvent.EventTypeMask.Input; + outputEvents |= PollEvent.EventTypeMask.Input; } } - if (WriteEvents.Contains(Socket)) + if (writeEvents.Contains(socket)) { - OutputEvents |= PollEvent.EventTypeMask.Output; + outputEvents |= PollEvent.EventTypeMask.Output; } - Context.Memory.WriteInt16(BufferPosition + i * 8 + 6, (short)OutputEvents); + context.Memory.WriteInt16(bufferPosition + i * 8 + 6, (short)outputEvents); } - return WriteBsdResult(Context, ReadEvents.Count + WriteEvents.Count + ErrorEvents.Count, LinuxError.SUCCESS); + return WriteBsdResult(context, readEvents.Count + writeEvents.Count + errorEvents.Count, LinuxError.SUCCESS); } // Sysctl(buffer<unknown, 0x21, 0>, buffer<unknown, 0x21, 0>) -> (i32 ret, u32 bsd_errno, u32, buffer<unknown, 0x22, 0>) - public long Sysctl(ServiceCtx Context) + public long Sysctl(ServiceCtx context) { - WriteBsdResult(Context, -1, LinuxError.EOPNOTSUPP); + WriteBsdResult(context, -1, LinuxError.EOPNOTSUPP); Logger.PrintStub(LogClass.ServiceBsd, $"Stubbed."); @@ -469,452 +468,452 @@ namespace Ryujinx.HLE.HOS.Services.Bsd } // Recv(u32 socket, u32 flags) -> (i32 ret, u32 bsd_errno, array<i8, 0x22> message) - public long Recv(ServiceCtx Context) + public long Recv(ServiceCtx context) { - int SocketFd = Context.RequestData.ReadInt32(); - SocketFlags SocketFlags = (SocketFlags)Context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); + SocketFlags socketFlags = (SocketFlags)context.RequestData.ReadInt32(); - (long ReceivePosition, long ReceiveLength) = Context.Request.GetBufferType0x22(); + (long receivePosition, long receiveLength) = context.Request.GetBufferType0x22(); - LinuxError Errno = LinuxError.EBADF; - BsdSocket Socket = RetrieveSocket(SocketFd); - int Result = -1; + LinuxError errno = LinuxError.EBADF; + BsdSocket socket = RetrieveSocket(socketFd); + int result = -1; - if (Socket != null) + if (socket != null) { - if (SocketFlags != SocketFlags.None && (SocketFlags & SocketFlags.OutOfBand) == 0 - && (SocketFlags & SocketFlags.Peek) == 0) + if (socketFlags != SocketFlags.None && (socketFlags & SocketFlags.OutOfBand) == 0 + && (socketFlags & SocketFlags.Peek) == 0) { - Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported Recv flags: {SocketFlags}"); - return WriteBsdResult(Context, -1, LinuxError.EOPNOTSUPP); + Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported Recv flags: {socketFlags}"); + return WriteBsdResult(context, -1, LinuxError.EOPNOTSUPP); } - byte[] ReceivedBuffer = new byte[ReceiveLength]; + byte[] receivedBuffer = new byte[receiveLength]; try { - Result = Socket.Handle.Receive(ReceivedBuffer, SocketFlags); - Errno = SetResultErrno(Socket.Handle, Result); + result = socket.Handle.Receive(receivedBuffer, socketFlags); + errno = SetResultErrno(socket.Handle, result); - Context.Memory.WriteBytes(ReceivePosition, ReceivedBuffer); + context.Memory.WriteBytes(receivePosition, receivedBuffer); } - catch (SocketException Exception) + catch (SocketException exception) { - Errno = ConvertError((WSAError)Exception.ErrorCode); + errno = ConvertError((WsaError)exception.ErrorCode); } } - return WriteBsdResult(Context, Result, Errno); + return WriteBsdResult(context, result, errno); } // 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 long RecvFrom(ServiceCtx Context) + public long RecvFrom(ServiceCtx context) { - int SocketFd = Context.RequestData.ReadInt32(); - SocketFlags SocketFlags = (SocketFlags)Context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); + SocketFlags socketFlags = (SocketFlags)context.RequestData.ReadInt32(); - (long ReceivePosition, long ReceiveLength) = Context.Request.GetBufferType0x22(); - (long SockAddrInPosition, long SockAddrInSize) = Context.Request.GetBufferType0x21(); - (long SockAddrOutPosition, long SockAddrOutSize) = Context.Request.GetBufferType0x22(1); + (long receivePosition, long receiveLength) = context.Request.GetBufferType0x22(); + (long sockAddrInPosition, long sockAddrInSize) = context.Request.GetBufferType0x21(); + (long sockAddrOutPosition, long sockAddrOutSize) = context.Request.GetBufferType0x22(1); - LinuxError Errno = LinuxError.EBADF; - BsdSocket Socket = RetrieveSocket(SocketFd); - int Result = -1; + LinuxError errno = LinuxError.EBADF; + BsdSocket socket = RetrieveSocket(socketFd); + int result = -1; - if (Socket != null) + if (socket != null) { - if (SocketFlags != SocketFlags.None && (SocketFlags & SocketFlags.OutOfBand) == 0 - && (SocketFlags & SocketFlags.Peek) == 0) + if (socketFlags != SocketFlags.None && (socketFlags & SocketFlags.OutOfBand) == 0 + && (socketFlags & SocketFlags.Peek) == 0) { - Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported Recv flags: {SocketFlags}"); + Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported Recv flags: {socketFlags}"); - return WriteBsdResult(Context, -1, LinuxError.EOPNOTSUPP); + return WriteBsdResult(context, -1, LinuxError.EOPNOTSUPP); } - byte[] ReceivedBuffer = new byte[ReceiveLength]; - EndPoint EndPoint = ParseSockAddr(Context, SockAddrInPosition, SockAddrInSize); + byte[] receivedBuffer = new byte[receiveLength]; + EndPoint endPoint = ParseSockAddr(context, sockAddrInPosition, sockAddrInSize); try { - Result = Socket.Handle.ReceiveFrom(ReceivedBuffer, ReceivedBuffer.Length, SocketFlags, ref EndPoint); - Errno = SetResultErrno(Socket.Handle, Result); + result = socket.Handle.ReceiveFrom(receivedBuffer, receivedBuffer.Length, socketFlags, ref endPoint); + errno = SetResultErrno(socket.Handle, result); - Context.Memory.WriteBytes(ReceivePosition, ReceivedBuffer); - WriteSockAddr(Context, SockAddrOutPosition, (IPEndPoint)EndPoint); + context.Memory.WriteBytes(receivePosition, receivedBuffer); + WriteSockAddr(context, sockAddrOutPosition, (IPEndPoint)endPoint); } - catch (SocketException Exception) + catch (SocketException exception) { - Errno = ConvertError((WSAError)Exception.ErrorCode); + errno = ConvertError((WsaError)exception.ErrorCode); } } - return WriteBsdResult(Context, Result, Errno); + return WriteBsdResult(context, result, errno); } // Send(u32 socket, u32 flags, buffer<i8, 0x21, 0>) -> (i32 ret, u32 bsd_errno) - public long Send(ServiceCtx Context) + public long Send(ServiceCtx context) { - int SocketFd = Context.RequestData.ReadInt32(); - SocketFlags SocketFlags = (SocketFlags)Context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); + SocketFlags socketFlags = (SocketFlags)context.RequestData.ReadInt32(); - (long SendPosition, long SendSize) = Context.Request.GetBufferType0x21(); + (long sendPosition, long sendSize) = context.Request.GetBufferType0x21(); - LinuxError Errno = LinuxError.EBADF; - BsdSocket Socket = RetrieveSocket(SocketFd); - int Result = -1; + LinuxError errno = LinuxError.EBADF; + BsdSocket socket = RetrieveSocket(socketFd); + int result = -1; - if (Socket != null) + if (socket != null) { - if (SocketFlags != SocketFlags.None && SocketFlags != SocketFlags.OutOfBand - && SocketFlags != SocketFlags.Peek && SocketFlags != SocketFlags.DontRoute) + if (socketFlags != SocketFlags.None && socketFlags != SocketFlags.OutOfBand + && socketFlags != SocketFlags.Peek && socketFlags != SocketFlags.DontRoute) { - Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported Send flags: {SocketFlags}"); + Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported Send flags: {socketFlags}"); - return WriteBsdResult(Context, -1, LinuxError.EOPNOTSUPP); + return WriteBsdResult(context, -1, LinuxError.EOPNOTSUPP); } - byte[] SendBuffer = Context.Memory.ReadBytes(SendPosition, SendSize); + byte[] sendBuffer = context.Memory.ReadBytes(sendPosition, sendSize); try { - Result = Socket.Handle.Send(SendBuffer, SocketFlags); - Errno = SetResultErrno(Socket.Handle, Result); + result = socket.Handle.Send(sendBuffer, socketFlags); + errno = SetResultErrno(socket.Handle, result); } - catch (SocketException Exception) + catch (SocketException exception) { - Errno = ConvertError((WSAError)Exception.ErrorCode); + errno = ConvertError((WsaError)exception.ErrorCode); } } - return WriteBsdResult(Context, Result, Errno); + return WriteBsdResult(context, result, errno); } // SendTo(u32 socket, u32 flags, buffer<i8, 0x21, 0>, buffer<nn::socket::sockaddr_in, 0x21, 0x10>) -> (i32 ret, u32 bsd_errno) - public long SendTo(ServiceCtx Context) + public long SendTo(ServiceCtx context) { - int SocketFd = Context.RequestData.ReadInt32(); - SocketFlags SocketFlags = (SocketFlags)Context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); + SocketFlags socketFlags = (SocketFlags)context.RequestData.ReadInt32(); - (long SendPosition, long SendSize) = Context.Request.GetBufferType0x21(); - (long BufferPosition, long BufferSize) = Context.Request.GetBufferType0x21(1); + (long sendPosition, long sendSize) = context.Request.GetBufferType0x21(); + (long bufferPosition, long bufferSize) = context.Request.GetBufferType0x21(1); - LinuxError Errno = LinuxError.EBADF; - BsdSocket Socket = RetrieveSocket(SocketFd); - int Result = -1; + LinuxError errno = LinuxError.EBADF; + BsdSocket socket = RetrieveSocket(socketFd); + int result = -1; - if (Socket != null) + if (socket != null) { - if (SocketFlags != SocketFlags.None && SocketFlags != SocketFlags.OutOfBand - && SocketFlags != SocketFlags.Peek && SocketFlags != SocketFlags.DontRoute) + if (socketFlags != SocketFlags.None && socketFlags != SocketFlags.OutOfBand + && socketFlags != SocketFlags.Peek && socketFlags != SocketFlags.DontRoute) { - Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported Send flags: {SocketFlags}"); + Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported Send flags: {socketFlags}"); - return WriteBsdResult(Context, -1, LinuxError.EOPNOTSUPP); + return WriteBsdResult(context, -1, LinuxError.EOPNOTSUPP); } - byte[] SendBuffer = Context.Memory.ReadBytes(SendPosition, SendSize); - EndPoint EndPoint = ParseSockAddr(Context, BufferPosition, BufferSize); + byte[] sendBuffer = context.Memory.ReadBytes(sendPosition, sendSize); + EndPoint endPoint = ParseSockAddr(context, bufferPosition, bufferSize); try { - Result = Socket.Handle.SendTo(SendBuffer, SendBuffer.Length, SocketFlags, EndPoint); - Errno = SetResultErrno(Socket.Handle, Result); + result = socket.Handle.SendTo(sendBuffer, sendBuffer.Length, socketFlags, endPoint); + errno = SetResultErrno(socket.Handle, result); } - catch (SocketException Exception) + catch (SocketException exception) { - Errno = ConvertError((WSAError)Exception.ErrorCode); + errno = ConvertError((WsaError)exception.ErrorCode); } } - return WriteBsdResult(Context, Result, Errno); + return WriteBsdResult(context, result, errno); } // Accept(u32 socket) -> (i32 ret, u32 bsd_errno, u32 addrlen, buffer<nn::socket::sockaddr_in, 0x22, 0x10> addr) - public long Accept(ServiceCtx Context) + public long Accept(ServiceCtx context) { - int SocketFd = Context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); - (long BufferPos, long BufferSize) = Context.Request.GetBufferType0x22(); + (long bufferPos, long bufferSize) = context.Request.GetBufferType0x22(); - LinuxError Errno = LinuxError.EBADF; - BsdSocket Socket = RetrieveSocket(SocketFd); + LinuxError errno = LinuxError.EBADF; + BsdSocket socket = RetrieveSocket(socketFd); - if (Socket != null) + if (socket != null) { - Errno = LinuxError.SUCCESS; + errno = LinuxError.SUCCESS; - Socket NewSocket = null; + Socket newSocket = null; try { - NewSocket = Socket.Handle.Accept(); + newSocket = socket.Handle.Accept(); } - catch (SocketException Exception) + catch (SocketException exception) { - Errno = ConvertError((WSAError)Exception.ErrorCode); + errno = ConvertError((WsaError)exception.ErrorCode); } - if (NewSocket == null && Errno == LinuxError.SUCCESS) + if (newSocket == null && errno == LinuxError.SUCCESS) { - Errno = LinuxError.EWOULDBLOCK; + errno = LinuxError.EWOULDBLOCK; } - else if (Errno == LinuxError.SUCCESS) + else if (errno == LinuxError.SUCCESS) { - BsdSocket NewBsdSocket = new BsdSocket + BsdSocket newBsdSocket = new BsdSocket { - Family = (int)NewSocket.AddressFamily, - Type = (int)NewSocket.SocketType, - Protocol = (int)NewSocket.ProtocolType, - Handle = NewSocket, + Family = (int)newSocket.AddressFamily, + Type = (int)newSocket.SocketType, + Protocol = (int)newSocket.ProtocolType, + Handle = newSocket }; - Sockets.Add(NewBsdSocket); + _sockets.Add(newBsdSocket); - WriteSockAddr(Context, BufferPos, NewBsdSocket, true); + WriteSockAddr(context, bufferPos, newBsdSocket, true); - WriteBsdResult(Context, Sockets.Count - 1, Errno); + WriteBsdResult(context, _sockets.Count - 1, errno); - Context.ResponseData.Write(0x10); + context.ResponseData.Write(0x10); return 0; } } - return WriteBsdResult(Context, -1, Errno); + return WriteBsdResult(context, -1, errno); } // Bind(u32 socket, buffer<nn::socket::sockaddr_in, 0x21, 0x10> addr) -> (i32 ret, u32 bsd_errno) - public long Bind(ServiceCtx Context) + public long Bind(ServiceCtx context) { - int SocketFd = Context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); - (long BufferPos, long BufferSize) = Context.Request.GetBufferType0x21(); + (long bufferPos, long bufferSize) = context.Request.GetBufferType0x21(); - LinuxError Errno = LinuxError.EBADF; - BsdSocket Socket = RetrieveSocket(SocketFd); + LinuxError errno = LinuxError.EBADF; + BsdSocket socket = RetrieveSocket(socketFd); - if (Socket != null) + if (socket != null) { - Errno = LinuxError.SUCCESS; + errno = LinuxError.SUCCESS; try { - IPEndPoint EndPoint = ParseSockAddr(Context, BufferPos, BufferSize); + IPEndPoint endPoint = ParseSockAddr(context, bufferPos, bufferSize); - Socket.Handle.Bind(EndPoint); + socket.Handle.Bind(endPoint); } - catch (SocketException Exception) + catch (SocketException exception) { - Errno = ConvertError((WSAError)Exception.ErrorCode); + errno = ConvertError((WsaError)exception.ErrorCode); } } - return WriteBsdResult(Context, 0, Errno); + return WriteBsdResult(context, 0, errno); } // Connect(u32 socket, buffer<nn::socket::sockaddr_in, 0x21, 0x10>) -> (i32 ret, u32 bsd_errno) - public long Connect(ServiceCtx Context) + public long Connect(ServiceCtx context) { - int SocketFd = Context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); - (long BufferPos, long BufferSize) = Context.Request.GetBufferType0x21(); + (long bufferPos, long bufferSize) = context.Request.GetBufferType0x21(); - LinuxError Errno = LinuxError.EBADF; - BsdSocket Socket = RetrieveSocket(SocketFd); + LinuxError errno = LinuxError.EBADF; + BsdSocket socket = RetrieveSocket(socketFd); - if (Socket != null) + if (socket != null) { - Errno = LinuxError.SUCCESS; + errno = LinuxError.SUCCESS; try { - IPEndPoint EndPoint = ParseSockAddr(Context, BufferPos, BufferSize); + IPEndPoint endPoint = ParseSockAddr(context, bufferPos, bufferSize); - Socket.Handle.Connect(EndPoint); + socket.Handle.Connect(endPoint); } - catch (SocketException Exception) + catch (SocketException exception) { - Errno = ConvertError((WSAError)Exception.ErrorCode); + errno = ConvertError((WsaError)exception.ErrorCode); } } - return WriteBsdResult(Context, 0, Errno); + return WriteBsdResult(context, 0, errno); } // GetPeerName(u32 socket) -> (i32 ret, u32 bsd_errno, u32 addrlen, buffer<nn::socket::sockaddr_in, 0x22, 0x10> addr) - public long GetPeerName(ServiceCtx Context) + public long GetPeerName(ServiceCtx context) { - int SocketFd = Context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); - (long BufferPos, long BufferSize) = Context.Request.GetBufferType0x22(); + (long bufferPos, long bufferSize) = context.Request.GetBufferType0x22(); - LinuxError Errno = LinuxError.EBADF; - BsdSocket Socket = RetrieveSocket(SocketFd); + LinuxError errno = LinuxError.EBADF; + BsdSocket socket = RetrieveSocket(socketFd); - if (Socket != null) + if (socket != null) { - Errno = LinuxError.SUCCESS; + errno = LinuxError.SUCCESS; - WriteSockAddr(Context, BufferPos, Socket, true); - WriteBsdResult(Context, 0, Errno); - Context.ResponseData.Write(0x10); + WriteSockAddr(context, bufferPos, socket, true); + WriteBsdResult(context, 0, errno); + context.ResponseData.Write(0x10); } - return WriteBsdResult(Context, 0, Errno); + return WriteBsdResult(context, 0, errno); } // GetSockName(u32 socket) -> (i32 ret, u32 bsd_errno, u32 addrlen, buffer<nn::socket::sockaddr_in, 0x22, 0x10> addr) - public long GetSockName(ServiceCtx Context) + public long GetSockName(ServiceCtx context) { - int SocketFd = Context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); - (long BufferPos, long BufferSize) = Context.Request.GetBufferType0x22(); + (long bufferPos, long bufferSize) = context.Request.GetBufferType0x22(); - LinuxError Errno = LinuxError.EBADF; - BsdSocket Socket = RetrieveSocket(SocketFd); + LinuxError errno = LinuxError.EBADF; + BsdSocket socket = RetrieveSocket(socketFd); - if (Socket != null) + if (socket != null) { - Errno = LinuxError.SUCCESS; + errno = LinuxError.SUCCESS; - WriteSockAddr(Context, BufferPos, Socket, false); - WriteBsdResult(Context, 0, Errno); - Context.ResponseData.Write(0x10); + WriteSockAddr(context, bufferPos, socket, false); + WriteBsdResult(context, 0, errno); + context.ResponseData.Write(0x10); } - return WriteBsdResult(Context, 0, Errno); + return WriteBsdResult(context, 0, errno); } // GetSockOpt(u32 socket, u32 level, u32 option_name) -> (i32 ret, u32 bsd_errno, u32, buffer<unknown, 0x22, 0>) - public long GetSockOpt(ServiceCtx Context) + public long GetSockOpt(ServiceCtx context) { - int SocketFd = Context.RequestData.ReadInt32(); - int Level = Context.RequestData.ReadInt32(); - int OptionName = Context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); + int level = context.RequestData.ReadInt32(); + int optionName = context.RequestData.ReadInt32(); - (long BufferPosition, long BufferSize) = Context.Request.GetBufferType0x22(); + (long bufferPosition, long bufferSize) = context.Request.GetBufferType0x22(); - LinuxError Errno = LinuxError.EBADF; - BsdSocket Socket = RetrieveSocket(SocketFd); + LinuxError errno = LinuxError.EBADF; + BsdSocket socket = RetrieveSocket(socketFd); - if (Socket != null) + if (socket != null) { - Errno = LinuxError.ENOPROTOOPT; + errno = LinuxError.ENOPROTOOPT; - if (Level == 0xFFFF) + if (level == 0xFFFF) { - Errno = HandleGetSocketOption(Context, Socket, (SocketOptionName)OptionName, BufferPosition, BufferSize); + errno = HandleGetSocketOption(context, socket, (SocketOptionName)optionName, bufferPosition, bufferSize); } else { - Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported GetSockOpt Level: {(SocketOptionLevel)Level}"); + Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported GetSockOpt Level: {(SocketOptionLevel)level}"); } } - return WriteBsdResult(Context, 0, Errno); + return WriteBsdResult(context, 0, errno); } // Listen(u32 socket, u32 backlog) -> (i32 ret, u32 bsd_errno) - public long Listen(ServiceCtx Context) + public long Listen(ServiceCtx context) { - int SocketFd = Context.RequestData.ReadInt32(); - int Backlog = Context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); + int backlog = context.RequestData.ReadInt32(); - LinuxError Errno = LinuxError.EBADF; - BsdSocket Socket = RetrieveSocket(SocketFd); + LinuxError errno = LinuxError.EBADF; + BsdSocket socket = RetrieveSocket(socketFd); - if (Socket != null) + if (socket != null) { - Errno = LinuxError.SUCCESS; + errno = LinuxError.SUCCESS; try { - Socket.Handle.Listen(Backlog); + socket.Handle.Listen(backlog); } - catch (SocketException Exception) + catch (SocketException exception) { - Errno = ConvertError((WSAError)Exception.ErrorCode); + errno = ConvertError((WsaError)exception.ErrorCode); } } - return WriteBsdResult(Context, 0, Errno); + return WriteBsdResult(context, 0, errno); } // 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 long Ioctl(ServiceCtx Context) + public long 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(); + int bufferCount = context.RequestData.ReadInt32(); - LinuxError Errno = LinuxError.EBADF; - BsdSocket Socket = RetrieveSocket(SocketFd); + LinuxError errno = LinuxError.EBADF; + BsdSocket socket = RetrieveSocket(socketFd); - if (Socket != null) + if (socket != null) { - switch (Cmd) + switch (cmd) { case BsdIoctl.AtMark: - Errno = LinuxError.SUCCESS; + errno = LinuxError.SUCCESS; - (long BufferPosition, long BufferSize) = Context.Request.GetBufferType0x22(); + (long bufferPosition, long bufferSize) = context.Request.GetBufferType0x22(); // FIXME: OOB not implemented. - Context.Memory.WriteInt32(BufferPosition, 0); + context.Memory.WriteInt32(bufferPosition, 0); break; default: - Errno = LinuxError.EOPNOTSUPP; + errno = LinuxError.EOPNOTSUPP; - Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported Ioctl Cmd: {Cmd}"); + Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported Ioctl Cmd: {cmd}"); break; } } - return WriteBsdResult(Context, 0, Errno); + return WriteBsdResult(context, 0, errno); } // Fcntl(u32 socket, u32 cmd, u32 arg) -> (i32 ret, u32 bsd_errno) - public long Fcntl(ServiceCtx Context) + public long Fcntl(ServiceCtx context) { - int SocketFd = Context.RequestData.ReadInt32(); - int Cmd = Context.RequestData.ReadInt32(); - int Arg = Context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); + int cmd = context.RequestData.ReadInt32(); + int arg = context.RequestData.ReadInt32(); - int Result = 0; - LinuxError Errno = LinuxError.EBADF; - BsdSocket Socket = RetrieveSocket(SocketFd); + int result = 0; + LinuxError errno = LinuxError.EBADF; + BsdSocket socket = RetrieveSocket(socketFd); - if (Socket != null) + if (socket != null) { - Errno = LinuxError.SUCCESS; + errno = LinuxError.SUCCESS; - if (Cmd == 0x3) + if (cmd == 0x3) { - Result = !Socket.Handle.Blocking ? 0x800 : 0; + result = !socket.Handle.Blocking ? 0x800 : 0; } - else if (Cmd == 0x4 && Arg == 0x800) + else if (cmd == 0x4 && arg == 0x800) { - Socket.Handle.Blocking = false; - Result = 0; + socket.Handle.Blocking = false; + result = 0; } else { - Errno = LinuxError.EOPNOTSUPP; + errno = LinuxError.EOPNOTSUPP; } } - return WriteBsdResult(Context, Result, Errno); + return WriteBsdResult(context, result, errno); } - private LinuxError HandleGetSocketOption(ServiceCtx Context, BsdSocket Socket, SocketOptionName OptionName, long OptionValuePosition, long OptionValueSize) + private LinuxError HandleGetSocketOption(ServiceCtx context, BsdSocket socket, SocketOptionName optionName, long optionValuePosition, long optionValueSize) { try { - byte[] OptionValue = new byte[OptionValueSize]; + byte[] optionValue = new byte[optionValueSize]; - switch (OptionName) + switch (optionName) { case SocketOptionName.Broadcast: case SocketOptionName.DontLinger: @@ -928,34 +927,34 @@ namespace Ryujinx.HLE.HOS.Services.Bsd case SocketOptionName.SendTimeout: case SocketOptionName.Type: case SocketOptionName.Linger: - Socket.Handle.GetSocketOption(SocketOptionLevel.Socket, OptionName, OptionValue); - Context.Memory.WriteBytes(OptionValuePosition, OptionValue); + socket.Handle.GetSocketOption(SocketOptionLevel.Socket, optionName, optionValue); + context.Memory.WriteBytes(optionValuePosition, optionValue); return LinuxError.SUCCESS; case (SocketOptionName)0x200: - Socket.Handle.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, OptionValue); - Context.Memory.WriteBytes(OptionValuePosition, OptionValue); + socket.Handle.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, optionValue); + context.Memory.WriteBytes(optionValuePosition, optionValue); return LinuxError.SUCCESS; default: - Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported SetSockOpt OptionName: {OptionName}"); + Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported SetSockOpt OptionName: {optionName}"); return LinuxError.EOPNOTSUPP; } } - catch (SocketException Exception) + catch (SocketException exception) { - return ConvertError((WSAError)Exception.ErrorCode); + return ConvertError((WsaError)exception.ErrorCode); } } - private LinuxError HandleSetSocketOption(ServiceCtx Context, BsdSocket Socket, SocketOptionName OptionName, long OptionValuePosition, long OptionValueSize) + private LinuxError HandleSetSocketOption(ServiceCtx context, BsdSocket socket, SocketOptionName optionName, long optionValuePosition, long optionValueSize) { try { - switch (OptionName) + switch (optionName) { case SocketOptionName.Broadcast: case SocketOptionName.DontLinger: @@ -969,225 +968,225 @@ namespace Ryujinx.HLE.HOS.Services.Bsd case SocketOptionName.SendTimeout: case SocketOptionName.Type: case SocketOptionName.ReuseAddress: - Socket.Handle.SetSocketOption(SocketOptionLevel.Socket, OptionName, Context.Memory.ReadInt32(OptionValuePosition)); + socket.Handle.SetSocketOption(SocketOptionLevel.Socket, optionName, context.Memory.ReadInt32(optionValuePosition)); return LinuxError.SUCCESS; case (SocketOptionName)0x200: - Socket.Handle.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, Context.Memory.ReadInt32(OptionValuePosition)); + socket.Handle.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, context.Memory.ReadInt32(optionValuePosition)); return LinuxError.SUCCESS; case SocketOptionName.Linger: - Socket.Handle.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger, - new LingerOption(Context.Memory.ReadInt32(OptionValuePosition) != 0, Context.Memory.ReadInt32(OptionValuePosition + 4))); + socket.Handle.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger, + new LingerOption(context.Memory.ReadInt32(optionValuePosition) != 0, context.Memory.ReadInt32(optionValuePosition + 4))); return LinuxError.SUCCESS; default: - Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported SetSockOpt OptionName: {OptionName}"); + Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported SetSockOpt OptionName: {optionName}"); return LinuxError.EOPNOTSUPP; } } - catch (SocketException Exception) + catch (SocketException exception) { - return ConvertError((WSAError)Exception.ErrorCode); + return ConvertError((WsaError)exception.ErrorCode); } } // SetSockOpt(u32 socket, u32 level, u32 option_name, buffer<unknown, 0x21, 0> option_value) -> (i32 ret, u32 bsd_errno) - public long SetSockOpt(ServiceCtx Context) + public long SetSockOpt(ServiceCtx context) { - int SocketFd = Context.RequestData.ReadInt32(); - int Level = Context.RequestData.ReadInt32(); - int OptionName = Context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); + int level = context.RequestData.ReadInt32(); + int optionName = context.RequestData.ReadInt32(); - (long BufferPos, long BufferSize) = Context.Request.GetBufferType0x21(); + (long bufferPos, long bufferSize) = context.Request.GetBufferType0x21(); - LinuxError Errno = LinuxError.EBADF; - BsdSocket Socket = RetrieveSocket(SocketFd); + LinuxError errno = LinuxError.EBADF; + BsdSocket socket = RetrieveSocket(socketFd); - if (Socket != null) + if (socket != null) { - Errno = LinuxError.ENOPROTOOPT; + errno = LinuxError.ENOPROTOOPT; - if (Level == 0xFFFF) + if (level == 0xFFFF) { - Errno = HandleSetSocketOption(Context, Socket, (SocketOptionName)OptionName, BufferPos, BufferSize); + errno = HandleSetSocketOption(context, socket, (SocketOptionName)optionName, bufferPos, bufferSize); } else { - Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported SetSockOpt Level: {(SocketOptionLevel)Level}"); + Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported SetSockOpt Level: {(SocketOptionLevel)level}"); } } - return WriteBsdResult(Context, 0, Errno); + return WriteBsdResult(context, 0, errno); } // Shutdown(u32 socket, u32 how) -> (i32 ret, u32 bsd_errno) - public long Shutdown(ServiceCtx Context) + public long Shutdown(ServiceCtx context) { - int SocketFd = Context.RequestData.ReadInt32(); - int How = Context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); + int how = context.RequestData.ReadInt32(); - LinuxError Errno = LinuxError.EBADF; - BsdSocket Socket = RetrieveSocket(SocketFd); + LinuxError errno = LinuxError.EBADF; + BsdSocket socket = RetrieveSocket(socketFd); - if (Socket != null) + if (socket != null) { - Errno = LinuxError.EINVAL; + errno = LinuxError.EINVAL; - if (How >= 0 && How <= 2) + if (how >= 0 && how <= 2) { - Errno = LinuxError.SUCCESS; + errno = LinuxError.SUCCESS; try { - Socket.Handle.Shutdown((SocketShutdown)How); + socket.Handle.Shutdown((SocketShutdown)how); } - catch (SocketException Exception) + catch (SocketException exception) { - Errno = ConvertError((WSAError)Exception.ErrorCode); + errno = ConvertError((WsaError)exception.ErrorCode); } } } - return WriteBsdResult(Context, 0, Errno); + return WriteBsdResult(context, 0, errno); } // ShutdownAllSockets(u32 how) -> (i32 ret, u32 bsd_errno) - public long ShutdownAllSockets(ServiceCtx Context) + public long ShutdownAllSockets(ServiceCtx context) { - int How = Context.RequestData.ReadInt32(); + int how = context.RequestData.ReadInt32(); - LinuxError Errno = LinuxError.EINVAL; + LinuxError errno = LinuxError.EINVAL; - if (How >= 0 && How <= 2) + if (how >= 0 && how <= 2) { - Errno = LinuxError.SUCCESS; + errno = LinuxError.SUCCESS; - foreach (BsdSocket Socket in Sockets) + foreach (BsdSocket socket in _sockets) { - if (Socket != null) + if (socket != null) { try { - Socket.Handle.Shutdown((SocketShutdown)How); + socket.Handle.Shutdown((SocketShutdown)how); } - catch (SocketException Exception) + catch (SocketException exception) { - Errno = ConvertError((WSAError)Exception.ErrorCode); + errno = ConvertError((WsaError)exception.ErrorCode); break; } } } } - return WriteBsdResult(Context, 0, Errno); + return WriteBsdResult(context, 0, errno); } // Write(u32 socket, buffer<i8, 0x21, 0> message) -> (i32 ret, u32 bsd_errno) - public long Write(ServiceCtx Context) + public long Write(ServiceCtx context) { - int SocketFd = Context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); - (long SendPosition, long SendSize) = Context.Request.GetBufferType0x21(); + (long sendPosition, long sendSize) = context.Request.GetBufferType0x21(); - LinuxError Errno = LinuxError.EBADF; - BsdSocket Socket = RetrieveSocket(SocketFd); - int Result = -1; + LinuxError errno = LinuxError.EBADF; + BsdSocket socket = RetrieveSocket(socketFd); + int result = -1; - if (Socket != null) + if (socket != null) { - byte[] SendBuffer = Context.Memory.ReadBytes(SendPosition, SendSize); + byte[] sendBuffer = context.Memory.ReadBytes(sendPosition, sendSize); try { - Result = Socket.Handle.Send(SendBuffer); - Errno = SetResultErrno(Socket.Handle, Result); + result = socket.Handle.Send(sendBuffer); + errno = SetResultErrno(socket.Handle, result); } - catch (SocketException Exception) + catch (SocketException exception) { - Errno = ConvertError((WSAError)Exception.ErrorCode); + errno = ConvertError((WsaError)exception.ErrorCode); } } - return WriteBsdResult(Context, Result, Errno); + return WriteBsdResult(context, result, errno); } // Read(u32 socket) -> (i32 ret, u32 bsd_errno, buffer<i8, 0x22, 0> message) - public long Read(ServiceCtx Context) + public long Read(ServiceCtx context) { - int SocketFd = Context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); - (long ReceivePosition, long ReceiveLength) = Context.Request.GetBufferType0x22(); + (long receivePosition, long receiveLength) = context.Request.GetBufferType0x22(); - LinuxError Errno = LinuxError.EBADF; - BsdSocket Socket = RetrieveSocket(SocketFd); - int Result = -1; + LinuxError errno = LinuxError.EBADF; + BsdSocket socket = RetrieveSocket(socketFd); + int result = -1; - if (Socket != null) + if (socket != null) { - byte[] ReceivedBuffer = new byte[ReceiveLength]; + byte[] receivedBuffer = new byte[receiveLength]; try { - Result = Socket.Handle.Receive(ReceivedBuffer); - Errno = SetResultErrno(Socket.Handle, Result); + result = socket.Handle.Receive(receivedBuffer); + errno = SetResultErrno(socket.Handle, result); } - catch (SocketException Exception) + catch (SocketException exception) { - Errno = ConvertError((WSAError)Exception.ErrorCode); + errno = ConvertError((WsaError)exception.ErrorCode); } } - return WriteBsdResult(Context, Result, Errno); + return WriteBsdResult(context, result, errno); } // Close(u32 socket) -> (i32 ret, u32 bsd_errno) - public long Close(ServiceCtx Context) + public long Close(ServiceCtx context) { - int SocketFd = Context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); - LinuxError Errno = LinuxError.EBADF; - BsdSocket Socket = RetrieveSocket(SocketFd); + LinuxError errno = LinuxError.EBADF; + BsdSocket socket = RetrieveSocket(socketFd); - if (Socket != null) + if (socket != null) { - Socket.Handle.Close(); + socket.Handle.Close(); - Sockets[SocketFd] = null; + _sockets[socketFd] = null; - Errno = LinuxError.SUCCESS; + errno = LinuxError.SUCCESS; } - return WriteBsdResult(Context, 0, Errno); + return WriteBsdResult(context, 0, errno); } // DuplicateSocket(u32 socket, u64 reserved) -> (i32 ret, u32 bsd_errno) - public long DuplicateSocket(ServiceCtx Context) + public long DuplicateSocket(ServiceCtx context) { - int SocketFd = Context.RequestData.ReadInt32(); - ulong Reserved = Context.RequestData.ReadUInt64(); + int socketFd = context.RequestData.ReadInt32(); + ulong reserved = context.RequestData.ReadUInt64(); - LinuxError Errno = LinuxError.ENOENT; - int NewSockFd = -1; + LinuxError errno = LinuxError.ENOENT; + int newSockFd = -1; - if (IsPrivileged) + if (_isPrivileged) { - Errno = LinuxError.EBADF; + errno = LinuxError.EBADF; - BsdSocket OldSocket = RetrieveSocket(SocketFd); + BsdSocket oldSocket = RetrieveSocket(socketFd); - if (OldSocket != null) + if (oldSocket != null) { - Sockets.Add(OldSocket); - NewSockFd = Sockets.Count - 1; + _sockets.Add(oldSocket); + newSockFd = _sockets.Count - 1; } } - return WriteBsdResult(Context, NewSockFd, Errno); + return WriteBsdResult(context, newSockFd, errno); } } } diff --git a/Ryujinx.HLE/HOS/Services/Bsd/PollEvent.cs b/Ryujinx.HLE/HOS/Services/Bsd/PollEvent.cs index 49cd4877..ff1ccb29 100644 --- a/Ryujinx.HLE/HOS/Services/Bsd/PollEvent.cs +++ b/Ryujinx.HLE/HOS/Services/Bsd/PollEvent.cs @@ -9,20 +9,20 @@ Output = 4, Error = 8, Disconnected = 0x10, - Invalid = 0x20, + Invalid = 0x20 } - public int SocketFd { get; private set; } - public BsdSocket Socket { get; private set; } - public EventTypeMask InputEvents { get; private set; } - public EventTypeMask OutputEvents { get; private set; } + public int SocketFd { get; } + public BsdSocket Socket { get; } + public EventTypeMask InputEvents { get; } + public EventTypeMask OutputEvents { get; } - public PollEvent(int SocketFd, BsdSocket Socket, EventTypeMask InputEvents, EventTypeMask OutputEvents) + public PollEvent(int socketFd, BsdSocket socket, EventTypeMask inputEvents, EventTypeMask outputEvents) { - this.SocketFd = SocketFd; - this.Socket = Socket; - this.InputEvents = InputEvents; - this.OutputEvents = OutputEvents; + SocketFd = socketFd; + Socket = socket; + InputEvents = inputEvents; + OutputEvents = outputEvents; } } } diff --git a/Ryujinx.HLE/HOS/Services/Caps/IAlbumAccessorService.cs b/Ryujinx.HLE/HOS/Services/Caps/IAlbumAccessorService.cs index 6d96b769..7b334ac4 100644 --- a/Ryujinx.HLE/HOS/Services/Caps/IAlbumAccessorService.cs +++ b/Ryujinx.HLE/HOS/Services/Caps/IAlbumAccessorService.cs @@ -5,13 +5,13 @@ namespace Ryujinx.HLE.HOS.Services.Caps { class IAlbumAccessorService : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IAlbumAccessorService() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { //... }; diff --git a/Ryujinx.HLE/HOS/Services/Caps/IScreenshotService.cs b/Ryujinx.HLE/HOS/Services/Caps/IScreenshotService.cs index 5a54d563..63b155e0 100644 --- a/Ryujinx.HLE/HOS/Services/Caps/IScreenshotService.cs +++ b/Ryujinx.HLE/HOS/Services/Caps/IScreenshotService.cs @@ -5,13 +5,13 @@ namespace Ryujinx.HLE.HOS.Services.Caps { class IScreenshotService : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IScreenshotService() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { //... }; diff --git a/Ryujinx.HLE/HOS/Services/Es/IETicketService.cs b/Ryujinx.HLE/HOS/Services/Es/IETicketService.cs index f11c78cc..049e94db 100644 --- a/Ryujinx.HLE/HOS/Services/Es/IETicketService.cs +++ b/Ryujinx.HLE/HOS/Services/Es/IETicketService.cs @@ -1,20 +1,19 @@ using Ryujinx.HLE.HOS.Ipc; -using Ryujinx.HLE.HOS.Kernel; using System.Collections.Generic; namespace Ryujinx.HLE.HOS.Services.Es { - class IETicketService : IpcService + class IeTicketService : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private bool IsInitialized; + private bool _isInitialized; - public IETicketService() + public IeTicketService() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { }; diff --git a/Ryujinx.HLE/HOS/Services/Friend/IFriendService.cs b/Ryujinx.HLE/HOS/Services/Friend/IFriendService.cs index e20de267..98348125 100644 --- a/Ryujinx.HLE/HOS/Services/Friend/IFriendService.cs +++ b/Ryujinx.HLE/HOS/Services/Friend/IFriendService.cs @@ -8,13 +8,13 @@ namespace Ryujinx.HLE.HOS.Services.Friend { class IFriendService : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IFriendService() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 10101, GetFriendList }, { 10601, DeclareCloseOnlinePlaySession }, @@ -23,76 +23,76 @@ namespace Ryujinx.HLE.HOS.Services.Friend } // nn::friends::GetFriendListGetFriendListIds(nn::account::Uid, int Unknown0, nn::friends::detail::ipc::SizedFriendFilter, ulong Unknown1) -> int CounterIds, array<nn::account::NetworkServiceAccountId> - public long GetFriendList(ServiceCtx Context) + public long GetFriendList(ServiceCtx context) { - UInt128 Uuid = new UInt128( - Context.RequestData.ReadInt64(), - Context.RequestData.ReadInt64()); + UInt128 uuid = new UInt128( + context.RequestData.ReadInt64(), + context.RequestData.ReadInt64()); - int Unknown0 = Context.RequestData.ReadInt32(); + int unknown0 = context.RequestData.ReadInt32(); - FriendFilter Filter = new FriendFilter() + FriendFilter filter = new FriendFilter { - PresenceStatus = (PresenceStatusFilter)Context.RequestData.ReadInt32(), - IsFavoriteOnly = Context.RequestData.ReadBoolean(), - IsSameAppPresenceOnly = Context.RequestData.ReadBoolean(), - IsSameAppPlayedOnly = Context.RequestData.ReadBoolean(), - IsArbitraryAppPlayedOnly = Context.RequestData.ReadBoolean(), - PresenceGroupId = Context.RequestData.ReadInt64() + PresenceStatus = (PresenceStatusFilter)context.RequestData.ReadInt32(), + IsFavoriteOnly = context.RequestData.ReadBoolean(), + IsSameAppPresenceOnly = context.RequestData.ReadBoolean(), + IsSameAppPlayedOnly = context.RequestData.ReadBoolean(), + IsArbitraryAppPlayedOnly = context.RequestData.ReadBoolean(), + PresenceGroupId = context.RequestData.ReadInt64() }; - long Unknown1 = Context.RequestData.ReadInt64(); + long unknown1 = context.RequestData.ReadInt64(); // There are no friends online, so we return 0 because the nn::account::NetworkServiceAccountId array is empty. - Context.ResponseData.Write(0); - - Logger.PrintStub(LogClass.ServiceFriend, $"Stubbed. UserId: {Uuid.ToString()} - " + - $"Unknown0: {Unknown0} - " + - $"PresenceStatus: {Filter.PresenceStatus} - " + - $"IsFavoriteOnly: {Filter.IsFavoriteOnly} - " + - $"IsSameAppPresenceOnly: {Filter.IsSameAppPresenceOnly} - " + - $"IsSameAppPlayedOnly: {Filter.IsSameAppPlayedOnly} - " + - $"IsArbitraryAppPlayedOnly: {Filter.IsArbitraryAppPlayedOnly} - " + - $"PresenceGroupId: {Filter.PresenceGroupId} - " + - $"Unknown1: {Unknown1}"); + context.ResponseData.Write(0); + + Logger.PrintStub(LogClass.ServiceFriend, $"Stubbed. UserId: {uuid.ToString()} - " + + $"Unknown0: {unknown0} - " + + $"PresenceStatus: {filter.PresenceStatus} - " + + $"IsFavoriteOnly: {filter.IsFavoriteOnly} - " + + $"IsSameAppPresenceOnly: {filter.IsSameAppPresenceOnly} - " + + $"IsSameAppPlayedOnly: {filter.IsSameAppPlayedOnly} - " + + $"IsArbitraryAppPlayedOnly: {filter.IsArbitraryAppPlayedOnly} - " + + $"PresenceGroupId: {filter.PresenceGroupId} - " + + $"Unknown1: {unknown1}"); return 0; } // DeclareCloseOnlinePlaySession(nn::account::Uid) - public long DeclareCloseOnlinePlaySession(ServiceCtx Context) + public long DeclareCloseOnlinePlaySession(ServiceCtx context) { - UInt128 Uuid = new UInt128( - Context.RequestData.ReadInt64(), - Context.RequestData.ReadInt64()); + UInt128 uuid = new UInt128( + context.RequestData.ReadInt64(), + context.RequestData.ReadInt64()); - if (Context.Device.System.State.TryGetUser(Uuid, out UserProfile Profile)) + if (context.Device.System.State.TryGetUser(uuid, out UserProfile profile)) { - Profile.OnlinePlayState = OpenCloseState.Closed; + profile.OnlinePlayState = OpenCloseState.Closed; } - Logger.PrintStub(LogClass.ServiceFriend, $"Stubbed. Uuid: {Uuid.ToString()} - " + - $"OnlinePlayState: {Profile.OnlinePlayState}"); + Logger.PrintStub(LogClass.ServiceFriend, $"Stubbed. Uuid: {uuid.ToString()} - " + + $"OnlinePlayState: {profile.OnlinePlayState}"); return 0; } // UpdateUserPresence(nn::account::Uid, ulong Unknown0) -> buffer<Unknown1, type: 0x19, size: 0xe0> - public long UpdateUserPresence(ServiceCtx Context) + public long UpdateUserPresence(ServiceCtx context) { - UInt128 Uuid = new UInt128( - Context.RequestData.ReadInt64(), - Context.RequestData.ReadInt64()); + UInt128 uuid = new UInt128( + context.RequestData.ReadInt64(), + context.RequestData.ReadInt64()); - long Unknown0 = Context.RequestData.ReadInt64(); + long unknown0 = context.RequestData.ReadInt64(); - long Position = Context.Request.PtrBuff[0].Position; - long Size = Context.Request.PtrBuff[0].Size; + long position = context.Request.PtrBuff[0].Position; + long size = context.Request.PtrBuff[0].Size; //Todo: Write the buffer content. - Logger.PrintStub(LogClass.ServiceFriend, $"Stubbed. Uuid: {Uuid.ToString()} - " + - $"Unknown0: {Unknown0}"); + Logger.PrintStub(LogClass.ServiceFriend, $"Stubbed. Uuid: {uuid.ToString()} - " + + $"Unknown0: {unknown0}"); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Friend/IServiceCreator.cs b/Ryujinx.HLE/HOS/Services/Friend/IServiceCreator.cs index 065e230d..d7f99997 100644 --- a/Ryujinx.HLE/HOS/Services/Friend/IServiceCreator.cs +++ b/Ryujinx.HLE/HOS/Services/Friend/IServiceCreator.cs @@ -5,21 +5,21 @@ namespace Ryujinx.HLE.HOS.Services.Friend { class IServiceCreator : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IServiceCreator() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, CreateFriendService } }; } - public static long CreateFriendService(ServiceCtx Context) + public static long CreateFriendService(ServiceCtx context) { - MakeObject(Context, new IFriendService()); + MakeObject(context, new IFriendService()); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/FspSrv/DirectoryEntry.cs b/Ryujinx.HLE/HOS/Services/FspSrv/DirectoryEntry.cs index 74ebddc2..bdb0c1cd 100644 --- a/Ryujinx.HLE/HOS/Services/FspSrv/DirectoryEntry.cs +++ b/Ryujinx.HLE/HOS/Services/FspSrv/DirectoryEntry.cs @@ -1,21 +1,17 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Ryujinx.HLE.HOS.Services.FspSrv +namespace Ryujinx.HLE.HOS.Services.FspSrv { public struct DirectoryEntry { - public string Path { get; private set; } - public long Size { get; private set; } + public string Path { get; } + public long Size { get; } public DirectoryEntryType EntryType { get; set; } - public DirectoryEntry(string Path, DirectoryEntryType DirectoryEntryType, long Size = 0) + public DirectoryEntry(string path, DirectoryEntryType directoryEntryType, long size = 0) { - this.Path = Path; - EntryType = DirectoryEntryType; - this.Size = Size; + Path = path; + EntryType = directoryEntryType; + Size = size; } } } diff --git a/Ryujinx.HLE/HOS/Services/FspSrv/FileSystemType.cs b/Ryujinx.HLE/HOS/Services/FspSrv/FileSystemType.cs index 2fd59673..20fc9bdc 100644 --- a/Ryujinx.HLE/HOS/Services/FspSrv/FileSystemType.cs +++ b/Ryujinx.HLE/HOS/Services/FspSrv/FileSystemType.cs @@ -1,6 +1,6 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv { - enum FileSystemType : int + enum FileSystemType { Logo = 2, ContentControl = 3, diff --git a/Ryujinx.HLE/HOS/Services/FspSrv/IDirectory.cs b/Ryujinx.HLE/HOS/Services/FspSrv/IDirectory.cs index c964eecb..e5dcd8b1 100644 --- a/Ryujinx.HLE/HOS/Services/FspSrv/IDirectory.cs +++ b/Ryujinx.HLE/HOS/Services/FspSrv/IDirectory.cs @@ -11,88 +11,88 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv { private const int DirectoryEntrySize = 0x310; - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private List<DirectoryEntry> DirectoryEntries; + private List<DirectoryEntry> _directoryEntries; - private int CurrentItemIndex; + private int _currentItemIndex; public event EventHandler<EventArgs> Disposed; - public string DirectoryPath { get; private set; } + public string DirectoryPath { get; } - private IFileSystemProvider Provider; + private IFileSystemProvider _provider; - public IDirectory(string DirectoryPath, int Flags, IFileSystemProvider Provider) + public IDirectory(string directoryPath, int flags, IFileSystemProvider provider) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, Read }, { 1, GetEntryCount } }; - this.Provider = Provider; - this.DirectoryPath = DirectoryPath; + _provider = provider; + DirectoryPath = directoryPath; - DirectoryEntries = new List<DirectoryEntry>(); + _directoryEntries = new List<DirectoryEntry>(); - if ((Flags & 1) != 0) + if ((flags & 1) != 0) { - DirectoryEntries.AddRange(Provider.GetDirectories(DirectoryPath)); + _directoryEntries.AddRange(provider.GetDirectories(directoryPath)); } - if ((Flags & 2) != 0) + if ((flags & 2) != 0) { - DirectoryEntries.AddRange(Provider.GetFiles(DirectoryPath)); + _directoryEntries.AddRange(provider.GetFiles(directoryPath)); } - CurrentItemIndex = 0; + _currentItemIndex = 0; } // Read() -> (u64 count, buffer<nn::fssrv::sf::IDirectoryEntry, 6, 0> entries) - public long Read(ServiceCtx Context) + public long Read(ServiceCtx context) { - long BufferPosition = Context.Request.ReceiveBuff[0].Position; - long BufferLen = Context.Request.ReceiveBuff[0].Size; + long bufferPosition = context.Request.ReceiveBuff[0].Position; + long bufferLen = context.Request.ReceiveBuff[0].Size; - int MaxReadCount = (int)(BufferLen / DirectoryEntrySize); + int maxReadCount = (int)(bufferLen / DirectoryEntrySize); - int Count = Math.Min(DirectoryEntries.Count - CurrentItemIndex, MaxReadCount); + int count = Math.Min(_directoryEntries.Count - _currentItemIndex, maxReadCount); - for (int Index = 0; Index < Count; Index++) + for (int index = 0; index < count; index++) { - long Position = BufferPosition + Index * DirectoryEntrySize; + long position = bufferPosition + index * DirectoryEntrySize; - WriteDirectoryEntry(Context, Position, DirectoryEntries[CurrentItemIndex++]); + WriteDirectoryEntry(context, position, _directoryEntries[_currentItemIndex++]); } - Context.ResponseData.Write((long)Count); + context.ResponseData.Write((long)count); return 0; } - private void WriteDirectoryEntry(ServiceCtx Context, long Position, DirectoryEntry Entry) + private void WriteDirectoryEntry(ServiceCtx context, long position, DirectoryEntry entry) { - for (int Offset = 0; Offset < 0x300; Offset += 8) + for (int offset = 0; offset < 0x300; offset += 8) { - Context.Memory.WriteInt64(Position + Offset, 0); + context.Memory.WriteInt64(position + offset, 0); } - byte[] NameBuffer = Encoding.UTF8.GetBytes(Path.GetFileName(Entry.Path)); + byte[] nameBuffer = Encoding.UTF8.GetBytes(Path.GetFileName(entry.Path)); - Context.Memory.WriteBytes(Position, NameBuffer); + context.Memory.WriteBytes(position, nameBuffer); - Context.Memory.WriteInt32(Position + 0x300, 0); //Padding? - Context.Memory.WriteInt32(Position + 0x304, (byte)Entry.EntryType); - Context.Memory.WriteInt64(Position + 0x308, Entry.Size); + context.Memory.WriteInt32(position + 0x300, 0); //Padding? + context.Memory.WriteInt32(position + 0x304, (byte)entry.EntryType); + context.Memory.WriteInt64(position + 0x308, entry.Size); } // GetEntryCount() -> u64 - public long GetEntryCount(ServiceCtx Context) + public long GetEntryCount(ServiceCtx context) { - Context.ResponseData.Write((long)DirectoryEntries.Count); + context.ResponseData.Write((long)_directoryEntries.Count); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/FspSrv/IFile.cs b/Ryujinx.HLE/HOS/Services/FspSrv/IFile.cs index 9bf152c4..03cfad99 100644 --- a/Ryujinx.HLE/HOS/Services/FspSrv/IFile.cs +++ b/Ryujinx.HLE/HOS/Services/FspSrv/IFile.cs @@ -7,19 +7,19 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv { class IFile : IpcService, IDisposable { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private Stream BaseStream; + private Stream _baseStream; public event EventHandler<EventArgs> Disposed; - public string HostPath { get; private set; } + public string HostPath { get; } - public IFile(Stream BaseStream, string HostPath) + public IFile(Stream baseStream, string hostPath) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, Read }, { 1, Write }, @@ -28,71 +28,71 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv { 4, GetSize } }; - this.BaseStream = BaseStream; - this.HostPath = HostPath; + _baseStream = baseStream; + HostPath = hostPath; } // Read(u32, u64 offset, u64 size) -> (u64 out_size, buffer<u8, 0x46, 0> out_buf) - public long Read(ServiceCtx Context) + public long Read(ServiceCtx context) { - long Position = Context.Request.ReceiveBuff[0].Position; + long position = context.Request.ReceiveBuff[0].Position; - long Zero = Context.RequestData.ReadInt64(); - long Offset = Context.RequestData.ReadInt64(); - long Size = Context.RequestData.ReadInt64(); + long zero = context.RequestData.ReadInt64(); + long offset = context.RequestData.ReadInt64(); + long size = context.RequestData.ReadInt64(); - byte[] Data = new byte[Size]; + byte[] data = new byte[size]; - BaseStream.Seek(Offset, SeekOrigin.Begin); + _baseStream.Seek(offset, SeekOrigin.Begin); - int ReadSize = BaseStream.Read(Data, 0, (int)Size); + int readSize = _baseStream.Read(data, 0, (int)size); - Context.Memory.WriteBytes(Position, Data); + context.Memory.WriteBytes(position, data); - Context.ResponseData.Write((long)ReadSize); + context.ResponseData.Write((long)readSize); return 0; } // Write(u32, u64 offset, u64 size, buffer<u8, 0x45, 0>) - public long Write(ServiceCtx Context) + public long Write(ServiceCtx context) { - long Position = Context.Request.SendBuff[0].Position; + long position = context.Request.SendBuff[0].Position; - long Zero = Context.RequestData.ReadInt64(); - long Offset = Context.RequestData.ReadInt64(); - long Size = Context.RequestData.ReadInt64(); + long zero = context.RequestData.ReadInt64(); + long offset = context.RequestData.ReadInt64(); + long size = context.RequestData.ReadInt64(); - byte[] Data = Context.Memory.ReadBytes(Position, Size); + byte[] data = context.Memory.ReadBytes(position, size); - BaseStream.Seek(Offset, SeekOrigin.Begin); - BaseStream.Write(Data, 0, (int)Size); + _baseStream.Seek(offset, SeekOrigin.Begin); + _baseStream.Write(data, 0, (int)size); return 0; } // Flush() - public long Flush(ServiceCtx Context) + public long Flush(ServiceCtx context) { - BaseStream.Flush(); + _baseStream.Flush(); return 0; } // SetSize(u64 size) - public long SetSize(ServiceCtx Context) + public long SetSize(ServiceCtx context) { - long Size = Context.RequestData.ReadInt64(); + long size = context.RequestData.ReadInt64(); - BaseStream.SetLength(Size); + _baseStream.SetLength(size); return 0; } // GetSize() -> u64 fileSize - public long GetSize(ServiceCtx Context) + public long GetSize(ServiceCtx context) { - Context.ResponseData.Write(BaseStream.Length); + context.ResponseData.Write(_baseStream.Length); return 0; } @@ -104,9 +104,9 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv protected virtual void Dispose(bool disposing) { - if (disposing && BaseStream != null) + if (disposing && _baseStream != null) { - BaseStream.Dispose(); + _baseStream.Dispose(); Disposed?.Invoke(this, EventArgs.Empty); } diff --git a/Ryujinx.HLE/HOS/Services/FspSrv/IFileSystem.cs b/Ryujinx.HLE/HOS/Services/FspSrv/IFileSystem.cs index edcdfa58..9e294460 100644 --- a/Ryujinx.HLE/HOS/Services/FspSrv/IFileSystem.cs +++ b/Ryujinx.HLE/HOS/Services/FspSrv/IFileSystem.cs @@ -11,19 +11,19 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv { class IFileSystem : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private HashSet<string> OpenPaths; + private HashSet<string> _openPaths; - private string Path; + private string _path; - private IFileSystemProvider Provider; + private IFileSystemProvider _provider; - public IFileSystem(string Path, IFileSystemProvider Provider) + public IFileSystem(string path, IFileSystemProvider provider) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, CreateFile }, { 1, DeleteFile }, @@ -38,196 +38,196 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv { 10, Commit }, { 11, GetFreeSpaceSize }, { 12, GetTotalSpaceSize }, - { 13, CleanDirectoryRecursively }, + { 13, CleanDirectoryRecursively } //{ 14, GetFileTimeStampRaw } }; - OpenPaths = new HashSet<string>(); + _openPaths = new HashSet<string>(); - this.Path = Path; - this.Provider = Provider; + _path = path; + _provider = provider; } // CreateFile(u32 mode, u64 size, buffer<bytes<0x301>, 0x19, 0x301> path) - public long CreateFile(ServiceCtx Context) + public long CreateFile(ServiceCtx context) { - string Name = ReadUtf8String(Context); + string name = ReadUtf8String(context); - long Mode = Context.RequestData.ReadInt64(); - int Size = Context.RequestData.ReadInt32(); + long mode = context.RequestData.ReadInt64(); + int size = context.RequestData.ReadInt32(); - string FileName = Provider.GetFullPath(Name); + string fileName = _provider.GetFullPath(name); - if (FileName == null) + if (fileName == null) { return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist); } - if (Provider.FileExists(FileName)) + if (_provider.FileExists(fileName)) { return MakeError(ErrorModule.Fs, FsErr.PathAlreadyExists); } - if (IsPathAlreadyInUse(FileName)) + if (IsPathAlreadyInUse(fileName)) { return MakeError(ErrorModule.Fs, FsErr.PathAlreadyInUse); } - return Provider.CreateFile(FileName, Size); + return _provider.CreateFile(fileName, size); } // DeleteFile(buffer<bytes<0x301>, 0x19, 0x301> path) - public long DeleteFile(ServiceCtx Context) + public long DeleteFile(ServiceCtx context) { - string Name = ReadUtf8String(Context); + string name = ReadUtf8String(context); - string FileName = Provider.GetFullPath(Name); + string fileName = _provider.GetFullPath(name); - if (!Provider.FileExists(FileName)) + if (!_provider.FileExists(fileName)) { return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist); } - if (IsPathAlreadyInUse(FileName)) + if (IsPathAlreadyInUse(fileName)) { return MakeError(ErrorModule.Fs, FsErr.PathAlreadyInUse); } - return Provider.DeleteFile(FileName); + return _provider.DeleteFile(fileName); } // CreateDirectory(buffer<bytes<0x301>, 0x19, 0x301> path) - public long CreateDirectory(ServiceCtx Context) + public long CreateDirectory(ServiceCtx context) { - string Name = ReadUtf8String(Context); + string name = ReadUtf8String(context); - string DirName = Provider.GetFullPath(Name); + string dirName = _provider.GetFullPath(name); - if (DirName == null) + if (dirName == null) { return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist); } - if (Provider.DirectoryExists(DirName)) + if (_provider.DirectoryExists(dirName)) { return MakeError(ErrorModule.Fs, FsErr.PathAlreadyExists); } - if (IsPathAlreadyInUse(DirName)) + if (IsPathAlreadyInUse(dirName)) { return MakeError(ErrorModule.Fs, FsErr.PathAlreadyInUse); } - Provider.CreateDirectory(DirName); + _provider.CreateDirectory(dirName); return 0; } // DeleteDirectory(buffer<bytes<0x301>, 0x19, 0x301> path) - public long DeleteDirectory(ServiceCtx Context) + public long DeleteDirectory(ServiceCtx context) { - return DeleteDirectory(Context, false); + return DeleteDirectory(context, false); } // DeleteDirectoryRecursively(buffer<bytes<0x301>, 0x19, 0x301> path) - public long DeleteDirectoryRecursively(ServiceCtx Context) + public long DeleteDirectoryRecursively(ServiceCtx context) { - return DeleteDirectory(Context, true); + return DeleteDirectory(context, true); } - private long DeleteDirectory(ServiceCtx Context, bool Recursive) + private long DeleteDirectory(ServiceCtx context, bool recursive) { - string Name = ReadUtf8String(Context); + string name = ReadUtf8String(context); - string DirName = Provider.GetFullPath(Name); + string dirName = _provider.GetFullPath(name); - if (!Directory.Exists(DirName)) + if (!Directory.Exists(dirName)) { return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist); } - if (IsPathAlreadyInUse(DirName)) + if (IsPathAlreadyInUse(dirName)) { return MakeError(ErrorModule.Fs, FsErr.PathAlreadyInUse); } - Provider.DeleteDirectory(DirName, Recursive); + _provider.DeleteDirectory(dirName, recursive); return 0; } // RenameFile(buffer<bytes<0x301>, 0x19, 0x301> oldPath, buffer<bytes<0x301>, 0x19, 0x301> newPath) - public long RenameFile(ServiceCtx Context) + public long RenameFile(ServiceCtx context) { - string OldName = ReadUtf8String(Context, 0); - string NewName = ReadUtf8String(Context, 1); + string oldName = ReadUtf8String(context, 0); + string newName = ReadUtf8String(context, 1); - string OldFileName = Provider.GetFullPath(OldName); - string NewFileName = Provider.GetFullPath(NewName); + string oldFileName = _provider.GetFullPath(oldName); + string newFileName = _provider.GetFullPath(newName); - if (Provider.FileExists(OldFileName)) + if (_provider.FileExists(oldFileName)) { return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist); } - if (Provider.FileExists(NewFileName)) + if (_provider.FileExists(newFileName)) { return MakeError(ErrorModule.Fs, FsErr.PathAlreadyExists); } - if (IsPathAlreadyInUse(OldFileName)) + if (IsPathAlreadyInUse(oldFileName)) { return MakeError(ErrorModule.Fs, FsErr.PathAlreadyInUse); } - return Provider.RenameFile(OldFileName, NewFileName); + return _provider.RenameFile(oldFileName, newFileName); } // RenameDirectory(buffer<bytes<0x301>, 0x19, 0x301> oldPath, buffer<bytes<0x301>, 0x19, 0x301> newPath) - public long RenameDirectory(ServiceCtx Context) + public long RenameDirectory(ServiceCtx context) { - string OldName = ReadUtf8String(Context, 0); - string NewName = ReadUtf8String(Context, 1); + string oldName = ReadUtf8String(context, 0); + string newName = ReadUtf8String(context, 1); - string OldDirName = Provider.GetFullPath(OldName); - string NewDirName = Provider.GetFullPath(NewName); + string oldDirName = _provider.GetFullPath(oldName); + string newDirName = _provider.GetFullPath(newName); - if (!Provider.DirectoryExists(OldDirName)) + if (!_provider.DirectoryExists(oldDirName)) { return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist); } - if (!Provider.DirectoryExists(NewDirName)) + if (!_provider.DirectoryExists(newDirName)) { return MakeError(ErrorModule.Fs, FsErr.PathAlreadyExists); } - if (IsPathAlreadyInUse(OldDirName)) + if (IsPathAlreadyInUse(oldDirName)) { return MakeError(ErrorModule.Fs, FsErr.PathAlreadyInUse); } - return Provider.RenameDirectory(OldDirName, NewDirName); + return _provider.RenameDirectory(oldDirName, newDirName); } // GetEntryType(buffer<bytes<0x301>, 0x19, 0x301> path) -> nn::fssrv::sf::DirectoryEntryType - public long GetEntryType(ServiceCtx Context) + public long GetEntryType(ServiceCtx context) { - string Name = ReadUtf8String(Context); + string name = ReadUtf8String(context); - string FileName = Provider.GetFullPath(Name); + string fileName = _provider.GetFullPath(name); - if (Provider.FileExists(FileName)) + if (_provider.FileExists(fileName)) { - Context.ResponseData.Write(1); + context.ResponseData.Write(1); } - else if (Provider.DirectoryExists(FileName)) + else if (_provider.DirectoryExists(fileName)) { - Context.ResponseData.Write(0); + context.ResponseData.Write(0); } else { - Context.ResponseData.Write(0); + context.ResponseData.Write(0); return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist); } @@ -236,167 +236,167 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv } // OpenFile(u32 mode, buffer<bytes<0x301>, 0x19, 0x301> path) -> object<nn::fssrv::sf::IFile> file - public long OpenFile(ServiceCtx Context) + public long OpenFile(ServiceCtx context) { - int FilterFlags = Context.RequestData.ReadInt32(); + int filterFlags = context.RequestData.ReadInt32(); - string Name = ReadUtf8String(Context); + string name = ReadUtf8String(context); - string FileName = Provider.GetFullPath(Name); + string fileName = _provider.GetFullPath(name); - if (!Provider.FileExists(FileName)) + if (!_provider.FileExists(fileName)) { return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist); } - if (IsPathAlreadyInUse(FileName)) + if (IsPathAlreadyInUse(fileName)) { return MakeError(ErrorModule.Fs, FsErr.PathAlreadyInUse); } - long Error = Provider.OpenFile(FileName, out IFile FileInterface); + long error = _provider.OpenFile(fileName, out IFile fileInterface); - if (Error == 0) + if (error == 0) { - FileInterface.Disposed += RemoveFileInUse; + fileInterface.Disposed += RemoveFileInUse; - lock (OpenPaths) + lock (_openPaths) { - OpenPaths.Add(FileName); + _openPaths.Add(fileName); } - MakeObject(Context, FileInterface); + MakeObject(context, fileInterface); return 0; } - return Error; + return error; } // OpenDirectory(u32 filter_flags, buffer<bytes<0x301>, 0x19, 0x301> path) -> object<nn::fssrv::sf::IDirectory> directory - public long OpenDirectory(ServiceCtx Context) + public long OpenDirectory(ServiceCtx context) { - int FilterFlags = Context.RequestData.ReadInt32(); + int filterFlags = context.RequestData.ReadInt32(); - string Name = ReadUtf8String(Context); + string name = ReadUtf8String(context); - string DirName = Provider.GetFullPath(Name); + string dirName = _provider.GetFullPath(name); - if (!Provider.DirectoryExists(DirName)) + if (!_provider.DirectoryExists(dirName)) { return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist); } - if (IsPathAlreadyInUse(DirName)) + if (IsPathAlreadyInUse(dirName)) { return MakeError(ErrorModule.Fs, FsErr.PathAlreadyInUse); } - long Error = Provider.OpenDirectory(DirName, FilterFlags, out IDirectory DirInterface); + long error = _provider.OpenDirectory(dirName, filterFlags, out IDirectory dirInterface); - if (Error == 0) + if (error == 0) { - DirInterface.Disposed += RemoveDirectoryInUse; + dirInterface.Disposed += RemoveDirectoryInUse; - lock (OpenPaths) + lock (_openPaths) { - OpenPaths.Add(DirName); + _openPaths.Add(dirName); } - MakeObject(Context, DirInterface); + MakeObject(context, dirInterface); } - return Error; + return error; } // Commit() - public long Commit(ServiceCtx Context) + public long Commit(ServiceCtx context) { return 0; } // GetFreeSpaceSize(buffer<bytes<0x301>, 0x19, 0x301> path) -> u64 totalFreeSpace - public long GetFreeSpaceSize(ServiceCtx Context) + public long GetFreeSpaceSize(ServiceCtx context) { - string Name = ReadUtf8String(Context); + string name = ReadUtf8String(context); - Context.ResponseData.Write(Provider.GetFreeSpace(Context)); + context.ResponseData.Write(_provider.GetFreeSpace(context)); return 0; } // GetTotalSpaceSize(buffer<bytes<0x301>, 0x19, 0x301> path) -> u64 totalSize - public long GetTotalSpaceSize(ServiceCtx Context) + public long GetTotalSpaceSize(ServiceCtx context) { - string Name = ReadUtf8String(Context); + string name = ReadUtf8String(context); - Context.ResponseData.Write(Provider.GetFreeSpace(Context)); + context.ResponseData.Write(_provider.GetFreeSpace(context)); return 0; } // CleanDirectoryRecursively(buffer<bytes<0x301>, 0x19, 0x301> path) - public long CleanDirectoryRecursively(ServiceCtx Context) + public long CleanDirectoryRecursively(ServiceCtx context) { - string Name = ReadUtf8String(Context); + string name = ReadUtf8String(context); - string DirName = Provider.GetFullPath(Name); + string dirName = _provider.GetFullPath(name); - if (!Provider.DirectoryExists(DirName)) + if (!_provider.DirectoryExists(dirName)) { return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist); } - if (IsPathAlreadyInUse(DirName)) + if (IsPathAlreadyInUse(dirName)) { return MakeError(ErrorModule.Fs, FsErr.PathAlreadyInUse); } - foreach (DirectoryEntry Entry in Provider.GetEntries(DirName)) + foreach (DirectoryEntry entry in _provider.GetEntries(dirName)) { - if (Provider.DirectoryExists(Entry.Path)) + if (_provider.DirectoryExists(entry.Path)) { - Provider.DeleteDirectory(Entry.Path, true); + _provider.DeleteDirectory(entry.Path, true); } - else if (Provider.FileExists(Entry.Path)) + else if (_provider.FileExists(entry.Path)) { - Provider.DeleteFile(Entry.Path); + _provider.DeleteFile(entry.Path); } } return 0; } - private bool IsPathAlreadyInUse(string Path) + private bool IsPathAlreadyInUse(string path) { - lock (OpenPaths) + lock (_openPaths) { - return OpenPaths.Contains(Path); + return _openPaths.Contains(path); } } private void RemoveFileInUse(object sender, EventArgs e) { - IFile FileInterface = (IFile)sender; + IFile fileInterface = (IFile)sender; - lock (OpenPaths) + lock (_openPaths) { - FileInterface.Disposed -= RemoveFileInUse; + fileInterface.Disposed -= RemoveFileInUse; - OpenPaths.Remove(FileInterface.HostPath); + _openPaths.Remove(fileInterface.HostPath); } } private void RemoveDirectoryInUse(object sender, EventArgs e) { - IDirectory DirInterface = (IDirectory)sender; + IDirectory dirInterface = (IDirectory)sender; - lock (OpenPaths) + lock (_openPaths) { - DirInterface.Disposed -= RemoveDirectoryInUse; + dirInterface.Disposed -= RemoveDirectoryInUse; - OpenPaths.Remove(DirInterface.DirectoryPath); + _openPaths.Remove(dirInterface.DirectoryPath); } } } diff --git a/Ryujinx.HLE/HOS/Services/FspSrv/IFileSystemProxy.cs b/Ryujinx.HLE/HOS/Services/FspSrv/IFileSystemProxy.cs index 0fc1eb80..8764792c 100644 --- a/Ryujinx.HLE/HOS/Services/FspSrv/IFileSystemProxy.cs +++ b/Ryujinx.HLE/HOS/Services/FspSrv/IFileSystemProxy.cs @@ -14,13 +14,13 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv { class IFileSystemProxy : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IFileSystemProxy() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 1, Initialize }, { 8, OpenFileSystemWithId }, @@ -36,246 +36,246 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv } // Initialize(u64, pid) - public long Initialize(ServiceCtx Context) + public long Initialize(ServiceCtx context) { return 0; } // OpenFileSystemWithId(nn::fssrv::sf::FileSystemType filesystem_type, nn::ApplicationId tid, buffer<bytes<0x301>, 0x19, 0x301> path) // -> object<nn::fssrv::sf::IFileSystem> contentFs - public long OpenFileSystemWithId(ServiceCtx Context) + public long OpenFileSystemWithId(ServiceCtx context) { - FileSystemType FileSystemType = (FileSystemType)Context.RequestData.ReadInt32(); - long TitleId = Context.RequestData.ReadInt64(); - string SwitchPath = ReadUtf8String(Context); - string FullPath = Context.Device.FileSystem.SwitchPathToSystemPath(SwitchPath); + FileSystemType fileSystemType = (FileSystemType)context.RequestData.ReadInt32(); + long titleId = context.RequestData.ReadInt64(); + string switchPath = ReadUtf8String(context); + string fullPath = context.Device.FileSystem.SwitchPathToSystemPath(switchPath); - if (!File.Exists(FullPath)) + if (!File.Exists(fullPath)) { - if (FullPath.Contains(".")) + if (fullPath.Contains(".")) { - return OpenFileSystemFromInternalFile(Context, FullPath); + return OpenFileSystemFromInternalFile(context, fullPath); } return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist); } - FileStream FileStream = new FileStream(FullPath, FileMode.Open, FileAccess.Read); - string Extension = Path.GetExtension(FullPath); + FileStream fileStream = new FileStream(fullPath, FileMode.Open, FileAccess.Read); + string extension = Path.GetExtension(fullPath); - if (Extension == ".nca") + if (extension == ".nca") { - return OpenNcaFs(Context, FullPath, FileStream); + return OpenNcaFs(context, fullPath, fileStream); } - else if (Extension == ".nsp") + else if (extension == ".nsp") { - return OpenNsp(Context, FullPath); + return OpenNsp(context, fullPath); } return MakeError(ErrorModule.Fs, FsErr.InvalidInput); } // OpenBisFileSystem(nn::fssrv::sf::Partition partitionID, buffer<bytes<0x301>, 0x19, 0x301>) -> object<nn::fssrv::sf::IFileSystem> Bis - public long OpenBisFileSystem(ServiceCtx Context) + public long OpenBisFileSystem(ServiceCtx context) { - int BisPartitionId = Context.RequestData.ReadInt32(); - string PartitionString = ReadUtf8String(Context); - string BisPartitonPath = string.Empty; + int bisPartitionId = context.RequestData.ReadInt32(); + string partitionString = ReadUtf8String(context); + string bisPartitonPath = string.Empty; - switch (BisPartitionId) + switch (bisPartitionId) { case 29: - BisPartitonPath = SafeNandPath; + bisPartitonPath = SafeNandPath; break; case 30: case 31: - BisPartitonPath = SystemNandPath; + bisPartitonPath = SystemNandPath; break; case 32: - BisPartitonPath = UserNandPath; + bisPartitonPath = UserNandPath; break; default: return MakeError(ErrorModule.Fs, FsErr.InvalidInput); } - string FullPath = Context.Device.FileSystem.GetFullPartitionPath(BisPartitonPath); + string fullPath = context.Device.FileSystem.GetFullPartitionPath(bisPartitonPath); - FileSystemProvider FileSystemProvider = new FileSystemProvider(FullPath, Context.Device.FileSystem.GetBasePath()); + FileSystemProvider fileSystemProvider = new FileSystemProvider(fullPath, context.Device.FileSystem.GetBasePath()); - MakeObject(Context, new IFileSystem(FullPath, FileSystemProvider)); + MakeObject(context, new IFileSystem(fullPath, fileSystemProvider)); return 0; } // OpenSdCardFileSystem() -> object<nn::fssrv::sf::IFileSystem> - public long OpenSdCardFileSystem(ServiceCtx Context) + public long OpenSdCardFileSystem(ServiceCtx context) { - string SdCardPath = Context.Device.FileSystem.GetSdCardPath(); + string sdCardPath = context.Device.FileSystem.GetSdCardPath(); - FileSystemProvider FileSystemProvider = new FileSystemProvider(SdCardPath, Context.Device.FileSystem.GetBasePath()); + FileSystemProvider fileSystemProvider = new FileSystemProvider(sdCardPath, context.Device.FileSystem.GetBasePath()); - MakeObject(Context, new IFileSystem(SdCardPath, FileSystemProvider)); + MakeObject(context, new IFileSystem(sdCardPath, fileSystemProvider)); return 0; } // OpenSaveDataFileSystem(u8 save_data_space_id, nn::fssrv::sf::SaveStruct saveStruct) -> object<nn::fssrv::sf::IFileSystem> saveDataFs - public long OpenSaveDataFileSystem(ServiceCtx Context) + public long OpenSaveDataFileSystem(ServiceCtx context) { - LoadSaveDataFileSystem(Context); + LoadSaveDataFileSystem(context); return 0; } // OpenSaveDataFileSystemBySystemSaveDataId(u8 save_data_space_id, nn::fssrv::sf::SaveStruct saveStruct) -> object<nn::fssrv::sf::IFileSystem> systemSaveDataFs - public long OpenSaveDataFileSystemBySystemSaveDataId(ServiceCtx Context) + public long OpenSaveDataFileSystemBySystemSaveDataId(ServiceCtx context) { - LoadSaveDataFileSystem(Context); + LoadSaveDataFileSystem(context); return 0; } // OpenDataStorageByCurrentProcess() -> object<nn::fssrv::sf::IStorage> dataStorage - public long OpenDataStorageByCurrentProcess(ServiceCtx Context) + public long OpenDataStorageByCurrentProcess(ServiceCtx context) { - MakeObject(Context, new IStorage(Context.Device.FileSystem.RomFs)); + MakeObject(context, new IStorage(context.Device.FileSystem.RomFs)); return 0; } // OpenDataStorageByDataId(u8 storageId, nn::ApplicationId tid) -> object<nn::fssrv::sf::IStorage> dataStorage - public long OpenDataStorageByDataId(ServiceCtx Context) + public long OpenDataStorageByDataId(ServiceCtx context) { - StorageId StorageId = (StorageId)Context.RequestData.ReadByte(); - byte[] Padding = Context.RequestData.ReadBytes(7); - long TitleId = Context.RequestData.ReadInt64(); + StorageId storageId = (StorageId)context.RequestData.ReadByte(); + byte[] padding = context.RequestData.ReadBytes(7); + long titleId = context.RequestData.ReadInt64(); - StorageId InstalledStorage = - Context.Device.System.ContentManager.GetInstalledStorage(TitleId, ContentType.Data, StorageId); + StorageId installedStorage = + context.Device.System.ContentManager.GetInstalledStorage(titleId, ContentType.Data, storageId); - if (InstalledStorage == StorageId.None) + if (installedStorage == StorageId.None) { - InstalledStorage = - Context.Device.System.ContentManager.GetInstalledStorage(TitleId, ContentType.AocData, StorageId); + installedStorage = + context.Device.System.ContentManager.GetInstalledStorage(titleId, ContentType.AocData, storageId); } - if (InstalledStorage != StorageId.None) + if (installedStorage != StorageId.None) { - string ContentPath = Context.Device.System.ContentManager.GetInstalledContentPath(TitleId, StorageId, ContentType.AocData); + string contentPath = context.Device.System.ContentManager.GetInstalledContentPath(titleId, storageId, ContentType.AocData); - if (string.IsNullOrWhiteSpace(ContentPath)) + if (string.IsNullOrWhiteSpace(contentPath)) { - ContentPath = Context.Device.System.ContentManager.GetInstalledContentPath(TitleId, StorageId, ContentType.AocData); + contentPath = context.Device.System.ContentManager.GetInstalledContentPath(titleId, storageId, ContentType.AocData); } - string InstallPath = Context.Device.FileSystem.SwitchPathToSystemPath(ContentPath); + string installPath = context.Device.FileSystem.SwitchPathToSystemPath(contentPath); - if (!string.IsNullOrWhiteSpace(InstallPath)) + if (!string.IsNullOrWhiteSpace(installPath)) { - string NcaPath = InstallPath; + string ncaPath = installPath; - if (File.Exists(NcaPath)) + if (File.Exists(ncaPath)) { - FileStream NcaStream = new FileStream(NcaPath, FileMode.Open, FileAccess.Read); - Nca Nca = new Nca(Context.Device.System.KeySet, NcaStream, false); - NcaSection RomfsSection = Nca.Sections.FirstOrDefault(x => x?.Type == SectionType.Romfs); - Stream RomfsStream = Nca.OpenSection(RomfsSection.SectionNum, false, Context.Device.System.FsIntegrityCheckLevel); + FileStream ncaStream = new FileStream(ncaPath, FileMode.Open, FileAccess.Read); + Nca nca = new Nca(context.Device.System.KeySet, ncaStream, false); + NcaSection romfsSection = nca.Sections.FirstOrDefault(x => x?.Type == SectionType.Romfs); + Stream romfsStream = nca.OpenSection(romfsSection.SectionNum, false, context.Device.System.FsIntegrityCheckLevel); - MakeObject(Context, new IStorage(RomfsStream)); + MakeObject(context, new IStorage(romfsStream)); return 0; } else { - throw new FileNotFoundException($"No Nca found in Path `{NcaPath}`."); + throw new FileNotFoundException($"No Nca found in Path `{ncaPath}`."); } } else { - throw new DirectoryNotFoundException($"Path for title id {TitleId:x16} on Storage {StorageId} was not found in Path {InstallPath}."); + throw new DirectoryNotFoundException($"Path for title id {titleId:x16} on Storage {storageId} was not found in Path {installPath}."); } } - throw new FileNotFoundException($"System archive with titleid {TitleId:x16} was not found on Storage {StorageId}. Found in {InstalledStorage}."); + throw new FileNotFoundException($"System archive with titleid {titleId:x16} was not found on Storage {storageId}. Found in {installedStorage}."); } // OpenPatchDataStorageByCurrentProcess() -> object<nn::fssrv::sf::IStorage> - public long OpenPatchDataStorageByCurrentProcess(ServiceCtx Context) + public long OpenPatchDataStorageByCurrentProcess(ServiceCtx context) { - MakeObject(Context, new IStorage(Context.Device.FileSystem.RomFs)); + MakeObject(context, new IStorage(context.Device.FileSystem.RomFs)); return 0; } // GetGlobalAccessLogMode() -> u32 logMode - public long GetGlobalAccessLogMode(ServiceCtx Context) + public long GetGlobalAccessLogMode(ServiceCtx context) { - Context.ResponseData.Write(0); + context.ResponseData.Write(0); return 0; } - public void LoadSaveDataFileSystem(ServiceCtx Context) + public void LoadSaveDataFileSystem(ServiceCtx context) { - SaveSpaceId SaveSpaceId = (SaveSpaceId)Context.RequestData.ReadInt64(); + SaveSpaceId saveSpaceId = (SaveSpaceId)context.RequestData.ReadInt64(); - long TitleId = Context.RequestData.ReadInt64(); + long titleId = context.RequestData.ReadInt64(); - UInt128 UserId = new UInt128( - Context.RequestData.ReadInt64(), - Context.RequestData.ReadInt64()); + UInt128 userId = new UInt128( + context.RequestData.ReadInt64(), + context.RequestData.ReadInt64()); - long SaveId = Context.RequestData.ReadInt64(); - SaveDataType SaveDataType = (SaveDataType)Context.RequestData.ReadByte(); - SaveInfo SaveInfo = new SaveInfo(TitleId, SaveId, SaveDataType, UserId, SaveSpaceId); - string SavePath = Context.Device.FileSystem.GetGameSavePath(SaveInfo, Context); - FileSystemProvider FileSystemProvider = new FileSystemProvider(SavePath, Context.Device.FileSystem.GetBasePath()); + long saveId = context.RequestData.ReadInt64(); + SaveDataType saveDataType = (SaveDataType)context.RequestData.ReadByte(); + SaveInfo saveInfo = new SaveInfo(titleId, saveId, saveDataType, userId, saveSpaceId); + string savePath = context.Device.FileSystem.GetGameSavePath(saveInfo, context); + FileSystemProvider fileSystemProvider = new FileSystemProvider(savePath, context.Device.FileSystem.GetBasePath()); - MakeObject(Context, new IFileSystem(SavePath, FileSystemProvider)); + MakeObject(context, new IFileSystem(savePath, fileSystemProvider)); } - private long OpenNsp(ServiceCtx Context, string PfsPath) + private long OpenNsp(ServiceCtx context, string pfsPath) { - FileStream PfsFile = new FileStream(PfsPath, FileMode.Open, FileAccess.Read); - Pfs Nsp = new Pfs(PfsFile); - PfsFileEntry TicketFile = Nsp.Files.FirstOrDefault(x => x.Name.EndsWith(".tik")); + FileStream pfsFile = new FileStream(pfsPath, FileMode.Open, FileAccess.Read); + Pfs nsp = new Pfs(pfsFile); + PfsFileEntry ticketFile = nsp.Files.FirstOrDefault(x => x.Name.EndsWith(".tik")); - if (TicketFile != null) + if (ticketFile != null) { - Ticket Ticket = new Ticket(Nsp.OpenFile(TicketFile)); + Ticket ticket = new Ticket(nsp.OpenFile(ticketFile)); - Context.Device.System.KeySet.TitleKeys[Ticket.RightsId] = - Ticket.GetTitleKey(Context.Device.System.KeySet); + context.Device.System.KeySet.TitleKeys[ticket.RightsId] = + ticket.GetTitleKey(context.Device.System.KeySet); } - IFileSystem NspFileSystem = new IFileSystem(PfsPath, new PFsProvider(Nsp)); + IFileSystem nspFileSystem = new IFileSystem(pfsPath, new PFsProvider(nsp)); - MakeObject(Context, NspFileSystem); + MakeObject(context, nspFileSystem); return 0; } - private long OpenNcaFs(ServiceCtx Context,string NcaPath, Stream NcaStream) + private long OpenNcaFs(ServiceCtx context,string ncaPath, Stream ncaStream) { - Nca Nca = new Nca(Context.Device.System.KeySet, NcaStream, false); + Nca nca = new Nca(context.Device.System.KeySet, ncaStream, false); - NcaSection RomfsSection = Nca.Sections.FirstOrDefault(x => x?.Type == SectionType.Romfs); - NcaSection PfsSection = Nca.Sections.FirstOrDefault(x => x?.Type == SectionType.Pfs0); + NcaSection romfsSection = nca.Sections.FirstOrDefault(x => x?.Type == SectionType.Romfs); + NcaSection pfsSection = nca.Sections.FirstOrDefault(x => x?.Type == SectionType.Pfs0); - if (RomfsSection != null) + if (romfsSection != null) { - Stream RomfsStream = Nca.OpenSection(RomfsSection.SectionNum, false, Context.Device.System.FsIntegrityCheckLevel); - IFileSystem NcaFileSystem = new IFileSystem(NcaPath, new RomFsProvider(RomfsStream)); + Stream romfsStream = nca.OpenSection(romfsSection.SectionNum, false, context.Device.System.FsIntegrityCheckLevel); + IFileSystem ncaFileSystem = new IFileSystem(ncaPath, new RomFsProvider(romfsStream)); - MakeObject(Context, NcaFileSystem); + MakeObject(context, ncaFileSystem); } - else if(PfsSection !=null) + else if(pfsSection !=null) { - Stream PfsStream = Nca.OpenSection(PfsSection.SectionNum, false, Context.Device.System.FsIntegrityCheckLevel); - Pfs Pfs = new Pfs(PfsStream); - IFileSystem NcaFileSystem = new IFileSystem(NcaPath, new PFsProvider(Pfs)); + Stream pfsStream = nca.OpenSection(pfsSection.SectionNum, false, context.Device.System.FsIntegrityCheckLevel); + Pfs pfs = new Pfs(pfsStream); + IFileSystem ncaFileSystem = new IFileSystem(ncaPath, new PFsProvider(pfs)); - MakeObject(Context, NcaFileSystem); + MakeObject(context, ncaFileSystem); } else { @@ -285,38 +285,38 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv return 0; } - private long OpenFileSystemFromInternalFile(ServiceCtx Context, string FullPath) + private long OpenFileSystemFromInternalFile(ServiceCtx context, string fullPath) { - DirectoryInfo ArchivePath = new DirectoryInfo(FullPath).Parent; + DirectoryInfo archivePath = new DirectoryInfo(fullPath).Parent; - while (string.IsNullOrWhiteSpace(ArchivePath.Extension)) + while (string.IsNullOrWhiteSpace(archivePath.Extension)) { - ArchivePath = ArchivePath.Parent; + archivePath = archivePath.Parent; } - if (ArchivePath.Extension == ".nsp" && File.Exists(ArchivePath.FullName)) + if (archivePath.Extension == ".nsp" && File.Exists(archivePath.FullName)) { - FileStream PfsFile = new FileStream( - ArchivePath.FullName.TrimEnd(Path.DirectorySeparatorChar), + FileStream pfsFile = new FileStream( + archivePath.FullName.TrimEnd(Path.DirectorySeparatorChar), FileMode.Open, FileAccess.Read); - Pfs Nsp = new Pfs(PfsFile); - PfsFileEntry TicketFile = Nsp.Files.FirstOrDefault(x => x.Name.EndsWith(".tik")); + Pfs nsp = new Pfs(pfsFile); + PfsFileEntry ticketFile = nsp.Files.FirstOrDefault(x => x.Name.EndsWith(".tik")); - if (TicketFile != null) + if (ticketFile != null) { - Ticket Ticket = new Ticket(Nsp.OpenFile(TicketFile)); + Ticket ticket = new Ticket(nsp.OpenFile(ticketFile)); - Context.Device.System.KeySet.TitleKeys[Ticket.RightsId] = - Ticket.GetTitleKey(Context.Device.System.KeySet); + context.Device.System.KeySet.TitleKeys[ticket.RightsId] = + ticket.GetTitleKey(context.Device.System.KeySet); } - string Filename = FullPath.Replace(ArchivePath.FullName, string.Empty).TrimStart('\\'); + string filename = fullPath.Replace(archivePath.FullName, string.Empty).TrimStart('\\'); - if (Nsp.FileExists(Filename)) + if (nsp.FileExists(filename)) { - return OpenNcaFs(Context, FullPath, Nsp.OpenFile(Filename)); + return OpenNcaFs(context, fullPath, nsp.OpenFile(filename)); } } diff --git a/Ryujinx.HLE/HOS/Services/FspSrv/IStorage.cs b/Ryujinx.HLE/HOS/Services/FspSrv/IStorage.cs index 6a78cdfe..d000635d 100644 --- a/Ryujinx.HLE/HOS/Services/FspSrv/IStorage.cs +++ b/Ryujinx.HLE/HOS/Services/FspSrv/IStorage.cs @@ -6,47 +6,47 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv { class IStorage : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private Stream BaseStream; + private Stream _baseStream; - public IStorage(Stream BaseStream) + public IStorage(Stream baseStream) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, Read } }; - this.BaseStream = BaseStream; + _baseStream = baseStream; } // Read(u64 offset, u64 length) -> buffer<u8, 0x46, 0> buffer - public long Read(ServiceCtx Context) + public long Read(ServiceCtx context) { - long Offset = Context.RequestData.ReadInt64(); - long Size = Context.RequestData.ReadInt64(); + long offset = context.RequestData.ReadInt64(); + long size = context.RequestData.ReadInt64(); - if (Context.Request.ReceiveBuff.Count > 0) + if (context.Request.ReceiveBuff.Count > 0) { - IpcBuffDesc BuffDesc = Context.Request.ReceiveBuff[0]; + IpcBuffDesc buffDesc = context.Request.ReceiveBuff[0]; //Use smaller length to avoid overflows. - if (Size > BuffDesc.Size) + if (size > buffDesc.Size) { - Size = BuffDesc.Size; + size = buffDesc.Size; } - byte[] Data = new byte[Size]; + byte[] data = new byte[size]; - lock (BaseStream) + lock (_baseStream) { - BaseStream.Seek(Offset, SeekOrigin.Begin); - BaseStream.Read(Data, 0, Data.Length); + _baseStream.Seek(offset, SeekOrigin.Begin); + _baseStream.Read(data, 0, data.Length); } - Context.Memory.WriteBytes(BuffDesc.Position, Data); + context.Memory.WriteBytes(buffDesc.Position, data); } return 0; diff --git a/Ryujinx.HLE/HOS/Services/Hid/HidNpad.cs b/Ryujinx.HLE/HOS/Services/Hid/HidNpad.cs index d2731857..14bff315 100644 --- a/Ryujinx.HLE/HOS/Services/Hid/HidNpad.cs +++ b/Ryujinx.HLE/HOS/Services/Hid/HidNpad.cs @@ -5,26 +5,26 @@ namespace Ryujinx.HLE.HOS.Services.Hid public enum HidNpadJoyAssignmentMode { Dual, - Single, + Single } public enum HidNpadHandheldActivationMode { Dual, Single, - None, + None } public enum HidNpadJoyDeviceType { Left, - Right, + Right } public enum HidNpadJoyHoldType { Vertical, - Horizontal, + Horizontal } [Flags] @@ -36,6 +36,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid Dual = 1 << 2, Left = 1 << 3, Right = 1 << 4, - Invalid = 1 << 5, + Invalid = 1 << 5 } } diff --git a/Ryujinx.HLE/HOS/Services/Hid/HidVibration.cs b/Ryujinx.HLE/HOS/Services/Hid/HidVibration.cs index cb2427e7..9a22ff01 100644 --- a/Ryujinx.HLE/HOS/Services/Hid/HidVibration.cs +++ b/Ryujinx.HLE/HOS/Services/Hid/HidVibration.cs @@ -10,7 +10,7 @@ { None, Left, - Right, + Right } public struct HidVibrationDeviceValue diff --git a/Ryujinx.HLE/HOS/Services/Hid/IActiveVibrationDeviceList.cs b/Ryujinx.HLE/HOS/Services/Hid/IActiveVibrationDeviceList.cs index 6e666919..586b852d 100644 --- a/Ryujinx.HLE/HOS/Services/Hid/IActiveVibrationDeviceList.cs +++ b/Ryujinx.HLE/HOS/Services/Hid/IActiveVibrationDeviceList.cs @@ -5,21 +5,21 @@ namespace Ryujinx.HLE.HOS.Services.Hid { class IActiveApplicationDeviceList : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IActiveApplicationDeviceList() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, ActivateVibrationDevice } }; } - public long ActivateVibrationDevice(ServiceCtx Context) + public long ActivateVibrationDevice(ServiceCtx context) { - int VibrationDeviceHandle = Context.RequestData.ReadInt32(); + int vibrationDeviceHandle = context.RequestData.ReadInt32(); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Hid/IAppletResource.cs b/Ryujinx.HLE/HOS/Services/Hid/IAppletResource.cs index 89a17acf..e82b824e 100644 --- a/Ryujinx.HLE/HOS/Services/Hid/IAppletResource.cs +++ b/Ryujinx.HLE/HOS/Services/Hid/IAppletResource.cs @@ -7,30 +7,30 @@ namespace Ryujinx.HLE.HOS.Services.Hid { class IAppletResource : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private KSharedMemory HidSharedMem; + private KSharedMemory _hidSharedMem; - public IAppletResource(KSharedMemory HidSharedMem) + public IAppletResource(KSharedMemory hidSharedMem) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, GetSharedMemoryHandle } }; - this.HidSharedMem = HidSharedMem; + _hidSharedMem = hidSharedMem; } - public long GetSharedMemoryHandle(ServiceCtx Context) + public long GetSharedMemoryHandle(ServiceCtx context) { - if (Context.Process.HandleTable.GenerateHandle(HidSharedMem, out int Handle) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(_hidSharedMem, out int handle) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs b/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs index 1af734ff..4e14943b 100644 --- a/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs +++ b/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs @@ -9,39 +9,39 @@ namespace Ryujinx.HLE.HOS.Services.Hid { class IHidServer : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - private KEvent NpadStyleSetUpdateEvent; - private KEvent XpadIdEvent; - private KEvent PalmaOperationCompleteEvent; + private KEvent _npadStyleSetUpdateEvent; + private KEvent _xpadIdEvent; + private KEvent _palmaOperationCompleteEvent; - private int XpadIdEventHandle; + private int _xpadIdEventHandle; - private bool SixAxisSensorFusionEnabled; - private bool UnintendedHomeButtonInputProtectionEnabled; - private bool VibrationPermitted; - private bool UsbFullKeyControllerEnabled; + private bool _sixAxisSensorFusionEnabled; + private bool _unintendedHomeButtonInputProtectionEnabled; + private bool _vibrationPermitted; + private bool _usbFullKeyControllerEnabled; - private HidNpadJoyHoldType NpadJoyHoldType; - private HidNpadStyle NpadStyleSet; - private HidNpadJoyAssignmentMode NpadJoyAssignmentMode; - private HidNpadHandheldActivationMode NpadHandheldActivationMode; - private HidGyroscopeZeroDriftMode GyroscopeZeroDriftMode; + private HidNpadJoyHoldType _npadJoyHoldType; + private HidNpadStyle _npadStyleSet; + private HidNpadJoyAssignmentMode _npadJoyAssignmentMode; + private HidNpadHandheldActivationMode _npadHandheldActivationMode; + private HidGyroscopeZeroDriftMode _gyroscopeZeroDriftMode; - private long NpadCommunicationMode; - private uint AccelerometerPlayMode; - private long VibrationGcErmCommand; - private float SevenSixAxisSensorFusionStrength; + private long _npadCommunicationMode; + private uint _accelerometerPlayMode; + private long _vibrationGcErmCommand; + private float _sevenSixAxisSensorFusionStrength; - private HidSensorFusionParameters SensorFusionParams; - private HidAccelerometerParameters AccelerometerParams; - private HidVibrationValue VibrationValue; + private HidSensorFusionParameters _sensorFusionParams; + private HidAccelerometerParameters _accelerometerParams; + private HidVibrationValue _vibrationValue; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - public IHidServer(Horizon System) + public IHidServer(Horizon system) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, CreateAppletResource }, { 1, ActivateDebugPad }, @@ -145,123 +145,123 @@ namespace Ryujinx.HLE.HOS.Services.Hid { 512, ReadPalmaUniqueCode }, { 513, SetPalmaUniqueCodeInvalid }, { 1000, SetNpadCommunicationMode }, - { 1001, GetNpadCommunicationMode }, + { 1001, GetNpadCommunicationMode } }; - NpadStyleSetUpdateEvent = new KEvent(System); - XpadIdEvent = new KEvent(System); - PalmaOperationCompleteEvent = new KEvent(System); + _npadStyleSetUpdateEvent = new KEvent(system); + _xpadIdEvent = new KEvent(system); + _palmaOperationCompleteEvent = new KEvent(system); - NpadJoyHoldType = HidNpadJoyHoldType.Vertical; - NpadStyleSet = HidNpadStyle.FullKey | HidNpadStyle.Dual | HidNpadStyle.Left | HidNpadStyle.Right | HidNpadStyle.Handheld; - NpadJoyAssignmentMode = HidNpadJoyAssignmentMode.Dual; - NpadHandheldActivationMode = HidNpadHandheldActivationMode.Dual; - GyroscopeZeroDriftMode = HidGyroscopeZeroDriftMode.Standard; + _npadJoyHoldType = HidNpadJoyHoldType.Vertical; + _npadStyleSet = HidNpadStyle.FullKey | HidNpadStyle.Dual | HidNpadStyle.Left | HidNpadStyle.Right | HidNpadStyle.Handheld; + _npadJoyAssignmentMode = HidNpadJoyAssignmentMode.Dual; + _npadHandheldActivationMode = HidNpadHandheldActivationMode.Dual; + _gyroscopeZeroDriftMode = HidGyroscopeZeroDriftMode.Standard; - SensorFusionParams = new HidSensorFusionParameters(); - AccelerometerParams = new HidAccelerometerParameters(); - VibrationValue = new HidVibrationValue(); + _sensorFusionParams = new HidSensorFusionParameters(); + _accelerometerParams = new HidAccelerometerParameters(); + _vibrationValue = new HidVibrationValue(); // TODO: signal event at right place - XpadIdEvent.ReadableEvent.Signal(); + _xpadIdEvent.ReadableEvent.Signal(); } // CreateAppletResource(nn::applet::AppletResourceUserId) -> object<nn::hid::IAppletResource> - public long CreateAppletResource(ServiceCtx Context) + public long CreateAppletResource(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - MakeObject(Context, new IAppletResource(Context.Device.System.HidSharedMem)); + MakeObject(context, new IAppletResource(context.Device.System.HidSharedMem)); return 0; } // ActivateDebugPad(nn::applet::AppletResourceUserId) - public long ActivateDebugPad(ServiceCtx Context) + public long ActivateDebugPad(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId}"); return 0; } // ActivateTouchScreen(nn::applet::AppletResourceUserId) - public long ActivateTouchScreen(ServiceCtx Context) + public long ActivateTouchScreen(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId}"); return 0; } // ActivateMouse(nn::applet::AppletResourceUserId) - public long ActivateMouse(ServiceCtx Context) + public long ActivateMouse(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId}"); return 0; } // ActivateKeyboard(nn::applet::AppletResourceUserId) - public long ActivateKeyboard(ServiceCtx Context) + public long ActivateKeyboard(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId}"); return 0; } // AcquireXpadIdEventHandle(ulong XpadId) -> nn::sf::NativeHandle - public long AcquireXpadIdEventHandle(ServiceCtx Context) + public long AcquireXpadIdEventHandle(ServiceCtx context) { - long XpadId = Context.RequestData.ReadInt64(); + long xpadId = context.RequestData.ReadInt64(); - if (Context.Process.HandleTable.GenerateHandle(XpadIdEvent.ReadableEvent, out XpadIdEventHandle) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(_xpadIdEvent.ReadableEvent, out _xpadIdEventHandle) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(XpadIdEventHandle); + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_xpadIdEventHandle); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. XpadId: {XpadId}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. XpadId: {xpadId}"); return 0; } // ReleaseXpadIdEventHandle(ulong XpadId) - public long ReleaseXpadIdEventHandle(ServiceCtx Context) + public long ReleaseXpadIdEventHandle(ServiceCtx context) { - long XpadId = Context.RequestData.ReadInt64(); + long xpadId = context.RequestData.ReadInt64(); - Context.Process.HandleTable.CloseHandle(XpadIdEventHandle); + context.Process.HandleTable.CloseHandle(_xpadIdEventHandle); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. XpadId: {XpadId}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. XpadId: {xpadId}"); return 0; } // ActivateXpad(nn::hid::BasicXpadId, nn::applet::AppletResourceUserId) - public long ActivateXpad(ServiceCtx Context) + public long ActivateXpad(ServiceCtx context) { - int BasicXpadId = Context.RequestData.ReadInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + int basicXpadId = context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"BasicXpadId: {BasicXpadId}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"BasicXpadId: {basicXpadId}"); return 0; } // GetXpadIds() -> long IdsCount, buffer<array<nn::hid::BasicXpadId>, type: 0xa> - public long GetXpadIds(ServiceCtx Context) + public long GetXpadIds(ServiceCtx context) { // There is any Xpad, so we return 0 and write nothing inside the type-0xa buffer. - Context.ResponseData.Write(0L); + context.ResponseData.Write(0L); Logger.PrintStub(LogClass.ServiceHid, $"Stubbed."); @@ -269,34 +269,34 @@ namespace Ryujinx.HLE.HOS.Services.Hid } // ActivateJoyXpad(nn::hid::JoyXpadId) - public long ActivateJoyXpad(ServiceCtx Context) + public long ActivateJoyXpad(ServiceCtx context) { - int JoyXpadId = Context.RequestData.ReadInt32(); + int joyXpadId = context.RequestData.ReadInt32(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. JoyXpadId: {JoyXpadId}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. JoyXpadId: {joyXpadId}"); return 0; } // GetJoyXpadLifoHandle(nn::hid::JoyXpadId) -> nn::sf::NativeHandle - public long GetJoyXpadLifoHandle(ServiceCtx Context) + public long GetJoyXpadLifoHandle(ServiceCtx context) { - int JoyXpadId = Context.RequestData.ReadInt32(); + int joyXpadId = context.RequestData.ReadInt32(); - int Handle = 0; + int handle = 0; - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. JoyXpadId: {JoyXpadId}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. JoyXpadId: {joyXpadId}"); return 0; } // GetJoyXpadIds() -> long IdsCount, buffer<array<nn::hid::JoyXpadId>, type: 0xa> - public long GetJoyXpadIds(ServiceCtx Context) + public long GetJoyXpadIds(ServiceCtx context) { // There is any JoyXpad, so we return 0 and write nothing inside the type-0xa buffer. - Context.ResponseData.Write(0L); + context.ResponseData.Write(0L); Logger.PrintStub(LogClass.ServiceHid, $"Stubbed."); @@ -304,662 +304,662 @@ namespace Ryujinx.HLE.HOS.Services.Hid } // ActivateSixAxisSensor(nn::hid::BasicXpadId) - public long ActivateSixAxisSensor(ServiceCtx Context) + public long ActivateSixAxisSensor(ServiceCtx context) { - int BasicXpadId = Context.RequestData.ReadInt32(); + int basicXpadId = context.RequestData.ReadInt32(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. BasicXpadId: {BasicXpadId}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. BasicXpadId: {basicXpadId}"); return 0; } // DeactivateSixAxisSensor(nn::hid::BasicXpadId) - public long DeactivateSixAxisSensor(ServiceCtx Context) + public long DeactivateSixAxisSensor(ServiceCtx context) { - int BasicXpadId = Context.RequestData.ReadInt32(); + int basicXpadId = context.RequestData.ReadInt32(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. BasicXpadId: {BasicXpadId}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. BasicXpadId: {basicXpadId}"); return 0; } // GetSixAxisSensorLifoHandle(nn::hid::BasicXpadId) -> nn::sf::NativeHandle - public long GetSixAxisSensorLifoHandle(ServiceCtx Context) + public long GetSixAxisSensorLifoHandle(ServiceCtx context) { - int BasicXpadId = Context.RequestData.ReadInt32(); + int basicXpadId = context.RequestData.ReadInt32(); - int Handle = 0; + int handle = 0; - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. BasicXpadId: {BasicXpadId}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. BasicXpadId: {basicXpadId}"); return 0; } // ActivateJoySixAxisSensor(nn::hid::JoyXpadId) - public long ActivateJoySixAxisSensor(ServiceCtx Context) + public long ActivateJoySixAxisSensor(ServiceCtx context) { - int JoyXpadId = Context.RequestData.ReadInt32(); + int joyXpadId = context.RequestData.ReadInt32(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. JoyXpadId: {JoyXpadId}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. JoyXpadId: {joyXpadId}"); return 0; } // DeactivateJoySixAxisSensor(nn::hid::JoyXpadId) - public long DeactivateJoySixAxisSensor(ServiceCtx Context) + public long DeactivateJoySixAxisSensor(ServiceCtx context) { - int JoyXpadId = Context.RequestData.ReadInt32(); + int joyXpadId = context.RequestData.ReadInt32(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. JoyXpadId: {JoyXpadId}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. JoyXpadId: {joyXpadId}"); return 0; } // GetJoySixAxisSensorLifoHandle(nn::hid::JoyXpadId) -> nn::sf::NativeHandle - public long GetJoySixAxisSensorLifoHandle(ServiceCtx Context) + public long GetJoySixAxisSensorLifoHandle(ServiceCtx context) { - int JoyXpadId = Context.RequestData.ReadInt32(); + int joyXpadId = context.RequestData.ReadInt32(); - int Handle = 0; + int handle = 0; - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. JoyXpadId: {JoyXpadId}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. JoyXpadId: {joyXpadId}"); return 0; } // StartSixAxisSensor(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId) - public long StartSixAxisSensor(ServiceCtx Context) + public long StartSixAxisSensor(ServiceCtx context) { - int SixAxisSensorHandle = Context.RequestData.ReadInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + int sixAxisSensorHandle = context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"SixAxisSensorHandle: {SixAxisSensorHandle}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"SixAxisSensorHandle: {sixAxisSensorHandle}"); return 0; } // StopSixAxisSensor(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId) - public long StopSixAxisSensor(ServiceCtx Context) + public long StopSixAxisSensor(ServiceCtx context) { - int SixAxisSensorHandle = Context.RequestData.ReadInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + int sixAxisSensorHandle = context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"SixAxisSensorHandle: {SixAxisSensorHandle}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"SixAxisSensorHandle: {sixAxisSensorHandle}"); return 0; } // IsSixAxisSensorFusionEnabled(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId) -> bool IsEnabled - public long IsSixAxisSensorFusionEnabled(ServiceCtx Context) + public long IsSixAxisSensorFusionEnabled(ServiceCtx context) { - int SixAxisSensorHandle = Context.RequestData.ReadInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + int sixAxisSensorHandle = context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Context.ResponseData.Write(SixAxisSensorFusionEnabled); + context.ResponseData.Write(_sixAxisSensorFusionEnabled); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"SixAxisSensorHandle: {SixAxisSensorHandle} - " + - $"SixAxisSensorFusionEnabled: {SixAxisSensorFusionEnabled}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"SixAxisSensorHandle: {sixAxisSensorHandle} - " + + $"SixAxisSensorFusionEnabled: {_sixAxisSensorFusionEnabled}"); return 0; } // EnableSixAxisSensorFusion(bool Enabled, nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId) - public long EnableSixAxisSensorFusion(ServiceCtx Context) + public long EnableSixAxisSensorFusion(ServiceCtx context) { - SixAxisSensorFusionEnabled = Context.RequestData.ReadBoolean(); - int SixAxisSensorHandle = Context.RequestData.ReadInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + _sixAxisSensorFusionEnabled = context.RequestData.ReadBoolean(); + int sixAxisSensorHandle = context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"SixAxisSensorHandle: {SixAxisSensorHandle} - " + - $"SixAxisSensorFusionEnabled: {SixAxisSensorFusionEnabled}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"SixAxisSensorHandle: {sixAxisSensorHandle} - " + + $"SixAxisSensorFusionEnabled: {_sixAxisSensorFusionEnabled}"); return 0; } // SetSixAxisSensorFusionParameters(nn::hid::SixAxisSensorHandle, float RevisePower, float ReviseRange, nn::applet::AppletResourceUserId) - public long SetSixAxisSensorFusionParameters(ServiceCtx Context) + public long SetSixAxisSensorFusionParameters(ServiceCtx context) { - int SixAxisSensorHandle = Context.RequestData.ReadInt32(); + int sixAxisSensorHandle = context.RequestData.ReadInt32(); - SensorFusionParams = new HidSensorFusionParameters() + _sensorFusionParams = new HidSensorFusionParameters { - RevisePower = Context.RequestData.ReadInt32(), - ReviseRange = Context.RequestData.ReadInt32(), + RevisePower = context.RequestData.ReadInt32(), + ReviseRange = context.RequestData.ReadInt32() }; - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"SixAxisSensorHandle: {SixAxisSensorHandle} - " + - $"RevisePower: {SensorFusionParams.RevisePower} - " + - $"ReviseRange: {SensorFusionParams.ReviseRange}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"SixAxisSensorHandle: {sixAxisSensorHandle} - " + + $"RevisePower: {_sensorFusionParams.RevisePower} - " + + $"ReviseRange: {_sensorFusionParams.ReviseRange}"); return 0; } // GetSixAxisSensorFusionParameters(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId) -> float RevisePower, float ReviseRange) - public long GetSixAxisSensorFusionParameters(ServiceCtx Context) + public long GetSixAxisSensorFusionParameters(ServiceCtx context) { - int SixAxisSensorHandle = Context.RequestData.ReadInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + int sixAxisSensorHandle = context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Context.ResponseData.Write(SensorFusionParams.RevisePower); - Context.ResponseData.Write(SensorFusionParams.ReviseRange); + context.ResponseData.Write(_sensorFusionParams.RevisePower); + context.ResponseData.Write(_sensorFusionParams.ReviseRange); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"SixAxisSensorHandle: {SixAxisSensorHandle} - " + - $"RevisePower: {SensorFusionParams.RevisePower} - " + - $"ReviseRange: {SensorFusionParams.ReviseRange}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"SixAxisSensorHandle: {sixAxisSensorHandle} - " + + $"RevisePower: {_sensorFusionParams.RevisePower} - " + + $"ReviseRange: {_sensorFusionParams.ReviseRange}"); return 0; } // ResetSixAxisSensorFusionParameters(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId) - public long ResetSixAxisSensorFusionParameters(ServiceCtx Context) + public long ResetSixAxisSensorFusionParameters(ServiceCtx context) { - int SixAxisSensorHandle = Context.RequestData.ReadInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + int sixAxisSensorHandle = context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); - SensorFusionParams.RevisePower = 0; - SensorFusionParams.ReviseRange = 0; + _sensorFusionParams.RevisePower = 0; + _sensorFusionParams.ReviseRange = 0; - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"SixAxisSensorHandle: {SixAxisSensorHandle} - " + - $"RevisePower: {SensorFusionParams.RevisePower} - " + - $"ReviseRange: {SensorFusionParams.ReviseRange}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"SixAxisSensorHandle: {sixAxisSensorHandle} - " + + $"RevisePower: {_sensorFusionParams.RevisePower} - " + + $"ReviseRange: {_sensorFusionParams.ReviseRange}"); return 0; } // SetAccelerometerParameters(nn::hid::SixAxisSensorHandle, float X, float Y, nn::applet::AppletResourceUserId) - public long SetAccelerometerParameters(ServiceCtx Context) + public long SetAccelerometerParameters(ServiceCtx context) { - int SixAxisSensorHandle = Context.RequestData.ReadInt32(); + int sixAxisSensorHandle = context.RequestData.ReadInt32(); - AccelerometerParams = new HidAccelerometerParameters() + _accelerometerParams = new HidAccelerometerParameters { - X = Context.RequestData.ReadInt32(), - Y = Context.RequestData.ReadInt32(), + X = context.RequestData.ReadInt32(), + Y = context.RequestData.ReadInt32() }; - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"SixAxisSensorHandle: {SixAxisSensorHandle} - " + - $"X: {AccelerometerParams.X} - " + - $"Y: {AccelerometerParams.Y}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"SixAxisSensorHandle: {sixAxisSensorHandle} - " + + $"X: {_accelerometerParams.X} - " + + $"Y: {_accelerometerParams.Y}"); return 0; } // GetAccelerometerParameters(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId) -> float X, float Y - public long GetAccelerometerParameters(ServiceCtx Context) + public long GetAccelerometerParameters(ServiceCtx context) { - int SixAxisSensorHandle = Context.RequestData.ReadInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + int sixAxisSensorHandle = context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Context.ResponseData.Write(AccelerometerParams.X); - Context.ResponseData.Write(AccelerometerParams.Y); + context.ResponseData.Write(_accelerometerParams.X); + context.ResponseData.Write(_accelerometerParams.Y); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"SixAxisSensorHandle: {SixAxisSensorHandle} - " + - $"X: {AccelerometerParams.X} - " + - $"Y: {AccelerometerParams.Y}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"SixAxisSensorHandle: {sixAxisSensorHandle} - " + + $"X: {_accelerometerParams.X} - " + + $"Y: {_accelerometerParams.Y}"); return 0; } // ResetAccelerometerParameters(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId) - public long ResetAccelerometerParameters(ServiceCtx Context) + public long ResetAccelerometerParameters(ServiceCtx context) { - int SixAxisSensorHandle = Context.RequestData.ReadInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + int sixAxisSensorHandle = context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); - AccelerometerParams.X = 0; - AccelerometerParams.Y = 0; + _accelerometerParams.X = 0; + _accelerometerParams.Y = 0; - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"SixAxisSensorHandle: {SixAxisSensorHandle} - " + - $"X: {AccelerometerParams.X} - " + - $"Y: {AccelerometerParams.Y}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"SixAxisSensorHandle: {sixAxisSensorHandle} - " + + $"X: {_accelerometerParams.X} - " + + $"Y: {_accelerometerParams.Y}"); return 0; } // SetAccelerometerPlayMode(nn::hid::SixAxisSensorHandle, uint PlayMode, nn::applet::AppletResourceUserId) - public long SetAccelerometerPlayMode(ServiceCtx Context) + public long SetAccelerometerPlayMode(ServiceCtx context) { - int SixAxisSensorHandle = Context.RequestData.ReadInt32(); - AccelerometerPlayMode = Context.RequestData.ReadUInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + int sixAxisSensorHandle = context.RequestData.ReadInt32(); + _accelerometerPlayMode = context.RequestData.ReadUInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"SixAxisSensorHandle: {SixAxisSensorHandle} - " + - $"PlayMode: {AccelerometerPlayMode}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"SixAxisSensorHandle: {sixAxisSensorHandle} - " + + $"PlayMode: {_accelerometerPlayMode}"); return 0; } // GetAccelerometerPlayMode(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId) -> uint PlayMode - public long GetAccelerometerPlayMode(ServiceCtx Context) + public long GetAccelerometerPlayMode(ServiceCtx context) { - int SixAxisSensorHandle = Context.RequestData.ReadInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + int sixAxisSensorHandle = context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Context.ResponseData.Write(AccelerometerPlayMode); + context.ResponseData.Write(_accelerometerPlayMode); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"SixAxisSensorHandle: {SixAxisSensorHandle} - " + - $"PlayMode: {AccelerometerPlayMode}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"SixAxisSensorHandle: {sixAxisSensorHandle} - " + + $"PlayMode: {_accelerometerPlayMode}"); return 0; } // ResetAccelerometerPlayMode(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId) - public long ResetAccelerometerPlayMode(ServiceCtx Context) + public long ResetAccelerometerPlayMode(ServiceCtx context) { - int SixAxisSensorHandle = Context.RequestData.ReadInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + int sixAxisSensorHandle = context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); - AccelerometerPlayMode = 0; + _accelerometerPlayMode = 0; - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"SixAxisSensorHandle: {SixAxisSensorHandle} - " + - $"PlayMode: {AccelerometerPlayMode}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"SixAxisSensorHandle: {sixAxisSensorHandle} - " + + $"PlayMode: {_accelerometerPlayMode}"); return 0; } // SetGyroscopeZeroDriftMode(nn::hid::SixAxisSensorHandle, uint GyroscopeZeroDriftMode, nn::applet::AppletResourceUserId) - public long SetGyroscopeZeroDriftMode(ServiceCtx Context) + public long SetGyroscopeZeroDriftMode(ServiceCtx context) { - int SixAxisSensorHandle = Context.RequestData.ReadInt32(); - GyroscopeZeroDriftMode = (HidGyroscopeZeroDriftMode)Context.RequestData.ReadInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + int sixAxisSensorHandle = context.RequestData.ReadInt32(); + _gyroscopeZeroDriftMode = (HidGyroscopeZeroDriftMode)context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"SixAxisSensorHandle: {SixAxisSensorHandle} - " + - $"GyroscopeZeroDriftMode: {GyroscopeZeroDriftMode}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"SixAxisSensorHandle: {sixAxisSensorHandle} - " + + $"GyroscopeZeroDriftMode: {_gyroscopeZeroDriftMode}"); return 0; } // GetGyroscopeZeroDriftMode(nn::applet::AppletResourceUserId, nn::hid::SixAxisSensorHandle) -> int GyroscopeZeroDriftMode - public long GetGyroscopeZeroDriftMode(ServiceCtx Context) + public long GetGyroscopeZeroDriftMode(ServiceCtx context) { - int SixAxisSensorHandle = Context.RequestData.ReadInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + int sixAxisSensorHandle = context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Context.ResponseData.Write((int)GyroscopeZeroDriftMode); + context.ResponseData.Write((int)_gyroscopeZeroDriftMode); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"SixAxisSensorHandle: {SixAxisSensorHandle} - " + - $"GyroscopeZeroDriftMode: {GyroscopeZeroDriftMode}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"SixAxisSensorHandle: {sixAxisSensorHandle} - " + + $"GyroscopeZeroDriftMode: {_gyroscopeZeroDriftMode}"); return 0; } // ResetGyroscopeZeroDriftMode(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId) - public long ResetGyroscopeZeroDriftMode(ServiceCtx Context) + public long ResetGyroscopeZeroDriftMode(ServiceCtx context) { - int SixAxisSensorHandle = Context.RequestData.ReadInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + int sixAxisSensorHandle = context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); - GyroscopeZeroDriftMode = HidGyroscopeZeroDriftMode.Standard; + _gyroscopeZeroDriftMode = HidGyroscopeZeroDriftMode.Standard; - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"SixAxisSensorHandle: {SixAxisSensorHandle} - " + - $"GyroscopeZeroDriftMode: {GyroscopeZeroDriftMode}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"SixAxisSensorHandle: {sixAxisSensorHandle} - " + + $"GyroscopeZeroDriftMode: {_gyroscopeZeroDriftMode}"); return 0; } // IsSixAxisSensorAtRest(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId) -> bool IsAsRest - public long IsSixAxisSensorAtRest(ServiceCtx Context) + public long IsSixAxisSensorAtRest(ServiceCtx context) { - int SixAxisSensorHandle = Context.RequestData.ReadInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + int sixAxisSensorHandle = context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); - bool IsAtRest = true; + bool isAtRest = true; - Context.ResponseData.Write(IsAtRest); + context.ResponseData.Write(isAtRest); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"SixAxisSensorHandle: {SixAxisSensorHandle} - " + - $"IsAtRest: {IsAtRest}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"SixAxisSensorHandle: {sixAxisSensorHandle} - " + + $"IsAtRest: {isAtRest}"); return 0; } // ActivateGesture(nn::applet::AppletResourceUserId, int Unknown0) - public long ActivateGesture(ServiceCtx Context) + public long ActivateGesture(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); - int Unknown0 = Context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); + int unknown0 = context.RequestData.ReadInt32(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"Unknown0: {Unknown0}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"Unknown0: {unknown0}"); return 0; } // SetSupportedNpadStyleSet(nn::applet::AppletResourceUserId, nn::hid::NpadStyleTag) - public long SetSupportedNpadStyleSet(ServiceCtx Context) + public long SetSupportedNpadStyleSet(ServiceCtx context) { - NpadStyleSet = (HidNpadStyle)Context.RequestData.ReadInt32(); + _npadStyleSet = (HidNpadStyle)context.RequestData.ReadInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"NpadStyleSet: {NpadStyleSet}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"NpadStyleSet: {_npadStyleSet}"); - NpadStyleSetUpdateEvent.ReadableEvent.Signal(); + _npadStyleSetUpdateEvent.ReadableEvent.Signal(); return 0; } // GetSupportedNpadStyleSet(nn::applet::AppletResourceUserId) -> uint nn::hid::NpadStyleTag - public long GetSupportedNpadStyleSet(ServiceCtx Context) + public long GetSupportedNpadStyleSet(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Context.ResponseData.Write((int)NpadStyleSet); + context.ResponseData.Write((int)_npadStyleSet); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"NpadStyleSet: {NpadStyleSet}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"NpadStyleSet: {_npadStyleSet}"); return 0; } // SetSupportedNpadIdType(nn::applet::AppletResourceUserId, array<NpadIdType, 9>) - public long SetSupportedNpadIdType(ServiceCtx Context) + public long SetSupportedNpadIdType(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); - HidControllerId NpadIdType = (HidControllerId)Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); + HidControllerId npadIdType = (HidControllerId)context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"NpadIdType: {NpadIdType}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"NpadIdType: {npadIdType}"); return 0; } // ActivateNpad(nn::applet::AppletResourceUserId) - public long ActivateNpad(ServiceCtx Context) + public long ActivateNpad(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId}"); return 0; } // DeactivateNpad(nn::applet::AppletResourceUserId) - public long DeactivateNpad(ServiceCtx Context) + public long DeactivateNpad(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId}"); return 0; } // AcquireNpadStyleSetUpdateEventHandle(nn::applet::AppletResourceUserId, uint, ulong) -> nn::sf::NativeHandle - public long AcquireNpadStyleSetUpdateEventHandle(ServiceCtx Context) + public long AcquireNpadStyleSetUpdateEventHandle(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); - int NpadId = Context.RequestData.ReadInt32(); - long NpadStyleSet = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); + int npadId = context.RequestData.ReadInt32(); + long npadStyleSet = context.RequestData.ReadInt64(); - if (Context.Process.HandleTable.GenerateHandle(NpadStyleSetUpdateEvent.ReadableEvent, out int Handle) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(_npadStyleSetUpdateEvent.ReadableEvent, out int handle) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"NpadId: {NpadId} - " + - $"NpadStyleSet: {NpadStyleSet}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"NpadId: {npadId} - " + + $"NpadStyleSet: {npadStyleSet}"); return 0; } // DisconnectNpad(nn::applet::AppletResourceUserId, uint NpadIdType) - public long DisconnectNpad(ServiceCtx Context) + public long DisconnectNpad(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); - int NpadIdType = Context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); + int npadIdType = context.RequestData.ReadInt32(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"NpadIdType: {NpadIdType}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"NpadIdType: {npadIdType}"); return 0; } // GetPlayerLedPattern(uint NpadId) -> ulong LedPattern - public long GetPlayerLedPattern(ServiceCtx Context) + public long GetPlayerLedPattern(ServiceCtx context) { - int NpadId = Context.RequestData.ReadInt32(); + int npadId = context.RequestData.ReadInt32(); - long LedPattern = 0; + long ledPattern = 0; - Context.ResponseData.Write(LedPattern); + context.ResponseData.Write(ledPattern); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. NpadId: {NpadId} - Pattern: {LedPattern}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. NpadId: {npadId} - Pattern: {ledPattern}"); return 0; } // ActivateNpadWithRevision(nn::applet::AppletResourceUserId, int Unknown) - public long ActivateNpadWithRevision(ServiceCtx Context) + public long ActivateNpadWithRevision(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); - int Unknown = Context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); + int unknown = context.RequestData.ReadInt32(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - Unknown: {Unknown}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - Unknown: {unknown}"); return 0; } // SetNpadJoyHoldType(nn::applet::AppletResourceUserId, long NpadJoyHoldType) - public long SetNpadJoyHoldType(ServiceCtx Context) + public long SetNpadJoyHoldType(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); - NpadJoyHoldType = (HidNpadJoyHoldType)Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); + _npadJoyHoldType = (HidNpadJoyHoldType)context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"NpadJoyHoldType: {NpadJoyHoldType}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"NpadJoyHoldType: {_npadJoyHoldType}"); return 0; } // GetNpadJoyHoldType(nn::applet::AppletResourceUserId) -> long NpadJoyHoldType - public long GetNpadJoyHoldType(ServiceCtx Context) + public long GetNpadJoyHoldType(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Context.ResponseData.Write((long)NpadJoyHoldType); + context.ResponseData.Write((long)_npadJoyHoldType); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"NpadJoyHoldTypeValue: {NpadJoyHoldType}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"NpadJoyHoldTypeValue: {_npadJoyHoldType}"); return 0; } // SetNpadJoyAssignmentModeSingleByDefault(uint HidControllerId, nn::applet::AppletResourceUserId) - public long SetNpadJoyAssignmentModeSingleByDefault(ServiceCtx Context) + public long SetNpadJoyAssignmentModeSingleByDefault(ServiceCtx context) { - HidControllerId HidControllerId = (HidControllerId)Context.RequestData.ReadInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + HidControllerId hidControllerId = (HidControllerId)context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); - NpadJoyAssignmentMode = HidNpadJoyAssignmentMode.Single; + _npadJoyAssignmentMode = HidNpadJoyAssignmentMode.Single; - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"HidControllerId: {HidControllerId} - " + - $"NpadJoyAssignmentModeValue: {NpadJoyAssignmentMode}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"HidControllerId: {hidControllerId} - " + + $"NpadJoyAssignmentModeValue: {_npadJoyAssignmentMode}"); return 0; } // SetNpadJoyAssignmentModeSingle(uint HidControllerId, nn::applet::AppletResourceUserId, long HidNpadJoyDeviceType) - public long SetNpadJoyAssignmentModeSingle(ServiceCtx Context) + public long SetNpadJoyAssignmentModeSingle(ServiceCtx context) { - HidControllerId HidControllerId = (HidControllerId)Context.RequestData.ReadInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); - HidNpadJoyDeviceType HidNpadJoyDeviceType = (HidNpadJoyDeviceType)Context.RequestData.ReadInt64(); + HidControllerId hidControllerId = (HidControllerId)context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); + HidNpadJoyDeviceType hidNpadJoyDeviceType = (HidNpadJoyDeviceType)context.RequestData.ReadInt64(); - NpadJoyAssignmentMode = HidNpadJoyAssignmentMode.Single; + _npadJoyAssignmentMode = HidNpadJoyAssignmentMode.Single; - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"HidControllerId: {HidControllerId} - " + - $"HidNpadJoyDeviceType: {HidNpadJoyDeviceType} - " + - $"NpadJoyAssignmentModeValue: {NpadJoyAssignmentMode}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"HidControllerId: {hidControllerId} - " + + $"HidNpadJoyDeviceType: {hidNpadJoyDeviceType} - " + + $"NpadJoyAssignmentModeValue: {_npadJoyAssignmentMode}"); return 0; } // SetNpadJoyAssignmentModeDual(uint HidControllerId, nn::applet::AppletResourceUserId) - public long SetNpadJoyAssignmentModeDual(ServiceCtx Context) + public long SetNpadJoyAssignmentModeDual(ServiceCtx context) { - HidControllerId HidControllerId = (HidControllerId)Context.RequestData.ReadInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + HidControllerId hidControllerId = (HidControllerId)context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); - NpadJoyAssignmentMode = HidNpadJoyAssignmentMode.Dual; + _npadJoyAssignmentMode = HidNpadJoyAssignmentMode.Dual; - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"HidControllerId: {HidControllerId} - " + - $"NpadJoyAssignmentModeValue: {NpadJoyAssignmentMode}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"HidControllerId: {hidControllerId} - " + + $"NpadJoyAssignmentModeValue: {_npadJoyAssignmentMode}"); return 0; } // MergeSingleJoyAsDualJoy(uint SingleJoyId0, uint SingleJoyId1, nn::applet::AppletResourceUserId) - public long MergeSingleJoyAsDualJoy(ServiceCtx Context) + public long MergeSingleJoyAsDualJoy(ServiceCtx context) { - long SingleJoyId0 = Context.RequestData.ReadInt32(); - long SingleJoyId1 = Context.RequestData.ReadInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long singleJoyId0 = context.RequestData.ReadInt32(); + long singleJoyId1 = context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"SingleJoyId0: {SingleJoyId0} - " + - $"SingleJoyId1: {SingleJoyId1}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"SingleJoyId0: {singleJoyId0} - " + + $"SingleJoyId1: {singleJoyId1}"); return 0; } // StartLrAssignmentMode(nn::applet::AppletResourceUserId) - public long StartLrAssignmentMode(ServiceCtx Context) + public long StartLrAssignmentMode(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId}"); return 0; } // StopLrAssignmentMode(nn::applet::AppletResourceUserId) - public long StopLrAssignmentMode(ServiceCtx Context) + public long StopLrAssignmentMode(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId}"); return 0; } // SetNpadHandheldActivationMode(nn::applet::AppletResourceUserId, long HidNpadHandheldActivationMode) - public long SetNpadHandheldActivationMode(ServiceCtx Context) + public long SetNpadHandheldActivationMode(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); - NpadHandheldActivationMode = (HidNpadHandheldActivationMode)Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); + _npadHandheldActivationMode = (HidNpadHandheldActivationMode)context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"NpadHandheldActivationMode: {NpadHandheldActivationMode}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"NpadHandheldActivationMode: {_npadHandheldActivationMode}"); return 0; } // GetNpadHandheldActivationMode(nn::applet::AppletResourceUserId) -> long HidNpadHandheldActivationMode - public long GetNpadHandheldActivationMode(ServiceCtx Context) + public long GetNpadHandheldActivationMode(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Context.ResponseData.Write((long)NpadHandheldActivationMode); + context.ResponseData.Write((long)_npadHandheldActivationMode); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"NpadHandheldActivationMode: {NpadHandheldActivationMode}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"NpadHandheldActivationMode: {_npadHandheldActivationMode}"); return 0; } // SwapNpadAssignment(uint OldNpadAssignment, uint NewNpadAssignment, nn::applet::AppletResourceUserId) - public long SwapNpadAssignment(ServiceCtx Context) + public long SwapNpadAssignment(ServiceCtx context) { - int OldNpadAssignment = Context.RequestData.ReadInt32(); - int NewNpadAssignment = Context.RequestData.ReadInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + int oldNpadAssignment = context.RequestData.ReadInt32(); + int newNpadAssignment = context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"OldNpadAssignment: {OldNpadAssignment} - " + - $"NewNpadAssignment: {NewNpadAssignment}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"OldNpadAssignment: {oldNpadAssignment} - " + + $"NewNpadAssignment: {newNpadAssignment}"); return 0; } // IsUnintendedHomeButtonInputProtectionEnabled(uint Unknown0, nn::applet::AppletResourceUserId) -> bool IsEnabled - public long IsUnintendedHomeButtonInputProtectionEnabled(ServiceCtx Context) + public long IsUnintendedHomeButtonInputProtectionEnabled(ServiceCtx context) { - uint Unknown0 = Context.RequestData.ReadUInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + uint unknown0 = context.RequestData.ReadUInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Context.ResponseData.Write(UnintendedHomeButtonInputProtectionEnabled); + context.ResponseData.Write(_unintendedHomeButtonInputProtectionEnabled); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"Unknown0: {Unknown0} - " + - $"UnintendedHomeButtonInputProtectionEnabled: {UnintendedHomeButtonInputProtectionEnabled}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"Unknown0: {unknown0} - " + + $"UnintendedHomeButtonInputProtectionEnabled: {_unintendedHomeButtonInputProtectionEnabled}"); return 0; } // EnableUnintendedHomeButtonInputProtection(bool Enable, uint Unknown0, nn::applet::AppletResourceUserId) - public long EnableUnintendedHomeButtonInputProtection(ServiceCtx Context) + public long EnableUnintendedHomeButtonInputProtection(ServiceCtx context) { - UnintendedHomeButtonInputProtectionEnabled = Context.RequestData.ReadBoolean(); - uint Unknown0 = Context.RequestData.ReadUInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + _unintendedHomeButtonInputProtectionEnabled = context.RequestData.ReadBoolean(); + uint unknown0 = context.RequestData.ReadUInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"Unknown0: {Unknown0} - " + - $"UnintendedHomeButtonInputProtectionEnable: {UnintendedHomeButtonInputProtectionEnabled}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"Unknown0: {unknown0} - " + + $"UnintendedHomeButtonInputProtectionEnable: {_unintendedHomeButtonInputProtectionEnabled}"); return 0; } // SetNpadJoyAssignmentModeSingleWithDestination(uint HidControllerId, long HidNpadJoyDeviceType, nn::applet::AppletResourceUserId) -> bool Unknown0, uint Unknown1 - public long SetNpadJoyAssignmentModeSingleWithDestination(ServiceCtx Context) + public long SetNpadJoyAssignmentModeSingleWithDestination(ServiceCtx context) { - HidControllerId HidControllerId = (HidControllerId)Context.RequestData.ReadInt32(); - HidNpadJoyDeviceType HidNpadJoyDeviceType = (HidNpadJoyDeviceType)Context.RequestData.ReadInt64(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + HidControllerId hidControllerId = (HidControllerId)context.RequestData.ReadInt32(); + HidNpadJoyDeviceType hidNpadJoyDeviceType = (HidNpadJoyDeviceType)context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - NpadJoyAssignmentMode = HidNpadJoyAssignmentMode.Single; + _npadJoyAssignmentMode = HidNpadJoyAssignmentMode.Single; - Context.ResponseData.Write(0); //Unknown0 - Context.ResponseData.Write(0); //Unknown1 + context.ResponseData.Write(0); //Unknown0 + context.ResponseData.Write(0); //Unknown1 - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"HidControllerId: {HidControllerId} - " + - $"HidNpadJoyDeviceType: {HidNpadJoyDeviceType} - " + - $"NpadJoyAssignmentModeValue: {NpadJoyAssignmentMode} - " + + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"HidControllerId: {hidControllerId} - " + + $"HidNpadJoyDeviceType: {hidNpadJoyDeviceType} - " + + $"NpadJoyAssignmentModeValue: {_npadJoyAssignmentMode} - " + $"Unknown0: 0 - " + $"Unknown1: 0"); @@ -967,163 +967,163 @@ namespace Ryujinx.HLE.HOS.Services.Hid } // GetVibrationDeviceInfo(nn::hid::VibrationDeviceHandle) -> nn::hid::VibrationDeviceInfo - public long GetVibrationDeviceInfo(ServiceCtx Context) + public long GetVibrationDeviceInfo(ServiceCtx context) { - int VibrationDeviceHandle = Context.RequestData.ReadInt32(); + int vibrationDeviceHandle = context.RequestData.ReadInt32(); - HidVibrationDeviceValue DeviceInfo = new HidVibrationDeviceValue + HidVibrationDeviceValue deviceInfo = new HidVibrationDeviceValue { DeviceType = HidVibrationDeviceType.None, Position = HidVibrationDevicePosition.None }; - Context.ResponseData.Write((int)DeviceInfo.DeviceType); - Context.ResponseData.Write((int)DeviceInfo.Position); + context.ResponseData.Write((int)deviceInfo.DeviceType); + context.ResponseData.Write((int)deviceInfo.Position); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. VibrationDeviceHandle: {VibrationDeviceHandle} - " + - $"DeviceType: {DeviceInfo.DeviceType} - " + - $"Position: {DeviceInfo.Position}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. VibrationDeviceHandle: {vibrationDeviceHandle} - " + + $"DeviceType: {deviceInfo.DeviceType} - " + + $"Position: {deviceInfo.Position}"); return 0; } // SendVibrationValue(nn::hid::VibrationDeviceHandle, nn::hid::VibrationValue, nn::applet::AppletResourceUserId) - public long SendVibrationValue(ServiceCtx Context) + public long SendVibrationValue(ServiceCtx context) { - int VibrationDeviceHandle = Context.RequestData.ReadInt32(); + int vibrationDeviceHandle = context.RequestData.ReadInt32(); - VibrationValue = new HidVibrationValue + _vibrationValue = new HidVibrationValue { - AmplitudeLow = Context.RequestData.ReadSingle(), - FrequencyLow = Context.RequestData.ReadSingle(), - AmplitudeHigh = Context.RequestData.ReadSingle(), - FrequencyHigh = Context.RequestData.ReadSingle() + AmplitudeLow = context.RequestData.ReadSingle(), + FrequencyLow = context.RequestData.ReadSingle(), + AmplitudeHigh = context.RequestData.ReadSingle(), + FrequencyHigh = context.RequestData.ReadSingle() }; - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"VibrationDeviceHandle: {VibrationDeviceHandle} - " + - $"AmplitudeLow: {VibrationValue.AmplitudeLow} - " + - $"FrequencyLow: {VibrationValue.FrequencyLow} - " + - $"AmplitudeHigh: {VibrationValue.AmplitudeHigh} - " + - $"FrequencyHigh: {VibrationValue.FrequencyHigh}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"VibrationDeviceHandle: {vibrationDeviceHandle} - " + + $"AmplitudeLow: {_vibrationValue.AmplitudeLow} - " + + $"FrequencyLow: {_vibrationValue.FrequencyLow} - " + + $"AmplitudeHigh: {_vibrationValue.AmplitudeHigh} - " + + $"FrequencyHigh: {_vibrationValue.FrequencyHigh}"); return 0; } // GetActualVibrationValue(nn::hid::VibrationDeviceHandle, nn::applet::AppletResourceUserId) -> nn::hid::VibrationValue - public long GetActualVibrationValue(ServiceCtx Context) + public long GetActualVibrationValue(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(VibrationValue.AmplitudeLow); - Context.ResponseData.Write(VibrationValue.FrequencyLow); - Context.ResponseData.Write(VibrationValue.AmplitudeHigh); - Context.ResponseData.Write(VibrationValue.FrequencyHigh); + context.ResponseData.Write(_vibrationValue.AmplitudeLow); + context.ResponseData.Write(_vibrationValue.FrequencyLow); + context.ResponseData.Write(_vibrationValue.AmplitudeHigh); + context.ResponseData.Write(_vibrationValue.FrequencyHigh); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"VibrationDeviceHandle: {VibrationDeviceHandle} - " + - $"AmplitudeLow: {VibrationValue.AmplitudeLow} - " + - $"FrequencyLow: {VibrationValue.FrequencyLow} - " + - $"AmplitudeHigh: {VibrationValue.AmplitudeHigh} - " + - $"FrequencyHigh: {VibrationValue.FrequencyHigh}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"VibrationDeviceHandle: {vibrationDeviceHandle} - " + + $"AmplitudeLow: {_vibrationValue.AmplitudeLow} - " + + $"FrequencyLow: {_vibrationValue.FrequencyLow} - " + + $"AmplitudeHigh: {_vibrationValue.AmplitudeHigh} - " + + $"FrequencyHigh: {_vibrationValue.FrequencyHigh}"); return 0; } // CreateActiveVibrationDeviceList() -> object<nn::hid::IActiveVibrationDeviceList> - public long CreateActiveVibrationDeviceList(ServiceCtx Context) + public long CreateActiveVibrationDeviceList(ServiceCtx context) { - MakeObject(Context, new IActiveApplicationDeviceList()); + MakeObject(context, new IActiveApplicationDeviceList()); return 0; } // PermitVibration(bool Enable) - public long PermitVibration(ServiceCtx Context) + public long PermitVibration(ServiceCtx context) { - VibrationPermitted = Context.RequestData.ReadBoolean(); + _vibrationPermitted = context.RequestData.ReadBoolean(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. VibrationPermitted: {VibrationPermitted}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. VibrationPermitted: {_vibrationPermitted}"); return 0; } // IsVibrationPermitted() -> bool IsEnabled - public long IsVibrationPermitted(ServiceCtx Context) + public long IsVibrationPermitted(ServiceCtx context) { - Context.ResponseData.Write(VibrationPermitted); + context.ResponseData.Write(_vibrationPermitted); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. VibrationPermitted: {VibrationPermitted}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. VibrationPermitted: {_vibrationPermitted}"); return 0; } // SendVibrationValues(nn::applet::AppletResourceUserId, buffer<array<nn::hid::VibrationDeviceHandle>, type: 9>, buffer<array<nn::hid::VibrationValue>, type: 9>) - public long SendVibrationValues(ServiceCtx Context) + public long SendVibrationValues(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - byte[] VibrationDeviceHandleBuffer = Context.Memory.ReadBytes( - Context.Request.PtrBuff[0].Position, - Context.Request.PtrBuff[0].Size); + byte[] vibrationDeviceHandleBuffer = context.Memory.ReadBytes( + context.Request.PtrBuff[0].Position, + context.Request.PtrBuff[0].Size); - byte[] VibrationValueBuffer = Context.Memory.ReadBytes( - Context.Request.PtrBuff[1].Position, - Context.Request.PtrBuff[1].Size); + byte[] vibrationValueBuffer = context.Memory.ReadBytes( + context.Request.PtrBuff[1].Position, + context.Request.PtrBuff[1].Size); //Todo: Read all handles and values from buffer. - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"VibrationDeviceHandleBufferLength: {VibrationDeviceHandleBuffer.Length} - " + - $"VibrationValueBufferLength: {VibrationValueBuffer.Length}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"VibrationDeviceHandleBufferLength: {vibrationDeviceHandleBuffer.Length} - " + + $"VibrationValueBufferLength: {vibrationValueBuffer.Length}"); return 0; } // SendVibrationGcErmCommand(nn::hid::VibrationDeviceHandle, nn::hid::VibrationGcErmCommand, nn::applet::AppletResourceUserId) - public long SendVibrationGcErmCommand(ServiceCtx Context) + public long SendVibrationGcErmCommand(ServiceCtx context) { - int VibrationDeviceHandle = Context.RequestData.ReadInt32(); - long VibrationGcErmCommand = Context.RequestData.ReadInt64(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + int vibrationDeviceHandle = context.RequestData.ReadInt32(); + long vibrationGcErmCommand = context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"VibrationDeviceHandle: {VibrationDeviceHandle} - " + - $"VibrationGcErmCommand: {VibrationGcErmCommand}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"VibrationDeviceHandle: {vibrationDeviceHandle} - " + + $"VibrationGcErmCommand: {vibrationGcErmCommand}"); return 0; } // GetActualVibrationGcErmCommand(nn::hid::VibrationDeviceHandle, nn::applet::AppletResourceUserId) -> nn::hid::VibrationGcErmCommand - public long GetActualVibrationGcErmCommand(ServiceCtx Context) + public long 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); + context.ResponseData.Write(_vibrationGcErmCommand); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"VibrationDeviceHandle: {VibrationDeviceHandle} - " + - $"VibrationGcErmCommand: {VibrationGcErmCommand}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"VibrationDeviceHandle: {vibrationDeviceHandle} - " + + $"VibrationGcErmCommand: {_vibrationGcErmCommand}"); return 0; } // BeginPermitVibrationSession(nn::applet::AppletResourceUserId) - public long BeginPermitVibrationSession(ServiceCtx Context) + public long BeginPermitVibrationSession(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId}"); return 0; } // EndPermitVibrationSession() - public long EndPermitVibrationSession(ServiceCtx Context) + public long EndPermitVibrationSession(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceHid, $"Stubbed."); @@ -1131,198 +1131,198 @@ namespace Ryujinx.HLE.HOS.Services.Hid } // ActivateConsoleSixAxisSensor(nn::applet::AppletResourceUserId) - public long ActivateConsoleSixAxisSensor(ServiceCtx Context) + public long ActivateConsoleSixAxisSensor(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId}"); return 0; } // StartConsoleSixAxisSensor(nn::hid::ConsoleSixAxisSensorHandle, nn::applet::AppletResourceUserId) - public long StartConsoleSixAxisSensor(ServiceCtx Context) + public long StartConsoleSixAxisSensor(ServiceCtx context) { - int ConsoleSixAxisSensorHandle = Context.RequestData.ReadInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + int consoleSixAxisSensorHandle = context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"ConsoleSixAxisSensorHandle: {ConsoleSixAxisSensorHandle}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"ConsoleSixAxisSensorHandle: {consoleSixAxisSensorHandle}"); return 0; } // StopConsoleSixAxisSensor(nn::hid::ConsoleSixAxisSensorHandle, nn::applet::AppletResourceUserId) - public long StopConsoleSixAxisSensor(ServiceCtx Context) + public long StopConsoleSixAxisSensor(ServiceCtx context) { - int ConsoleSixAxisSensorHandle = Context.RequestData.ReadInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + int consoleSixAxisSensorHandle = context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"ConsoleSixAxisSensorHandle: {ConsoleSixAxisSensorHandle}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"ConsoleSixAxisSensorHandle: {consoleSixAxisSensorHandle}"); return 0; } // ActivateSevenSixAxisSensor(nn::applet::AppletResourceUserId) - public long ActivateSevenSixAxisSensor(ServiceCtx Context) + public long ActivateSevenSixAxisSensor(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId}"); return 0; } // StartSevenSixAxisSensor(nn::applet::AppletResourceUserId) - public long StartSevenSixAxisSensor(ServiceCtx Context) + public long StartSevenSixAxisSensor(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId}"); return 0; } // StopSevenSixAxisSensor(nn::applet::AppletResourceUserId) - public long StopSevenSixAxisSensor(ServiceCtx Context) + public long StopSevenSixAxisSensor(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId}"); return 0; } // InitializeSevenSixAxisSensor(array<nn::sf::NativeHandle>, ulong Counter0, array<nn::sf::NativeHandle>, ulong Counter1, nn::applet::AppletResourceUserId) - public long InitializeSevenSixAxisSensor(ServiceCtx Context) + public long InitializeSevenSixAxisSensor(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); - long Counter0 = Context.RequestData.ReadInt64(); - long Counter1 = Context.RequestData.ReadInt64(); + long appletResourceUserId = 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... - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"Counter0: {Counter0} - " + - $"Counter1: {Counter1}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"Counter0: {counter0} - " + + $"Counter1: {counter1}"); return 0; } // FinalizeSevenSixAxisSensor(nn::applet::AppletResourceUserId) - public long FinalizeSevenSixAxisSensor(ServiceCtx Context) + public long FinalizeSevenSixAxisSensor(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); - - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId}"); + long appletResourceUserId = context.RequestData.ReadInt64(); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId}"); + return 0; } // SetSevenSixAxisSensorFusionStrength(float Strength, nn::applet::AppletResourceUserId) - public long SetSevenSixAxisSensorFusionStrength(ServiceCtx Context) + public long SetSevenSixAxisSensorFusionStrength(ServiceCtx context) { - SevenSixAxisSensorFusionStrength = Context.RequestData.ReadSingle(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + _sevenSixAxisSensorFusionStrength = context.RequestData.ReadSingle(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"SevenSixAxisSensorFusionStrength: {SevenSixAxisSensorFusionStrength}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"SevenSixAxisSensorFusionStrength: {_sevenSixAxisSensorFusionStrength}"); return 0; } // GetSevenSixAxisSensorFusionStrength(nn::applet::AppletResourceUserId) -> float Strength - public long GetSevenSixAxisSensorFusionStrength(ServiceCtx Context) + public long GetSevenSixAxisSensorFusionStrength(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Context.ResponseData.Write(SevenSixAxisSensorFusionStrength); + context.ResponseData.Write(_sevenSixAxisSensorFusionStrength); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"SevenSixAxisSensorFusionStrength: {SevenSixAxisSensorFusionStrength}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"SevenSixAxisSensorFusionStrength: {_sevenSixAxisSensorFusionStrength}"); return 0; } // IsUsbFullKeyControllerEnabled() -> bool IsEnabled - public long IsUsbFullKeyControllerEnabled(ServiceCtx Context) + public long IsUsbFullKeyControllerEnabled(ServiceCtx context) { - Context.ResponseData.Write(UsbFullKeyControllerEnabled); + context.ResponseData.Write(_usbFullKeyControllerEnabled); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. UsbFullKeyControllerEnabled: {UsbFullKeyControllerEnabled}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. UsbFullKeyControllerEnabled: {_usbFullKeyControllerEnabled}"); return 0; } // EnableUsbFullKeyController(bool Enable) - public long EnableUsbFullKeyController(ServiceCtx Context) + public long EnableUsbFullKeyController(ServiceCtx context) { - UsbFullKeyControllerEnabled = Context.RequestData.ReadBoolean(); + _usbFullKeyControllerEnabled = context.RequestData.ReadBoolean(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. UsbFullKeyControllerEnabled: {UsbFullKeyControllerEnabled}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. UsbFullKeyControllerEnabled: {_usbFullKeyControllerEnabled}"); return 0; } // IsUsbFullKeyControllerConnected(uint Unknown0) -> bool Connected - public long IsUsbFullKeyControllerConnected(ServiceCtx Context) + public long IsUsbFullKeyControllerConnected(ServiceCtx context) { - int Unknown0 = Context.RequestData.ReadInt32(); + int unknown0 = context.RequestData.ReadInt32(); - Context.ResponseData.Write(true); //FullKeyController is always connected ? + context.ResponseData.Write(true); //FullKeyController is always connected ? - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. Unknown0: {Unknown0} - Connected: true"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. Unknown0: {unknown0} - Connected: true"); return 0; } // HasBattery(uint NpadId) -> bool HasBattery - public long HasBattery(ServiceCtx Context) + public long HasBattery(ServiceCtx context) { - int NpadId = Context.RequestData.ReadInt32(); + int npadId = context.RequestData.ReadInt32(); - Context.ResponseData.Write(true); //Npad always got a battery ? + context.ResponseData.Write(true); //Npad always got a battery ? - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. NpadId: {NpadId} - HasBattery: true"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. NpadId: {npadId} - HasBattery: true"); return 0; } // HasLeftRightBattery(uint NpadId) -> bool HasLeftBattery, bool HasRightBattery - public long HasLeftRightBattery(ServiceCtx Context) + public long HasLeftRightBattery(ServiceCtx context) { - int NpadId = Context.RequestData.ReadInt32(); + int npadId = context.RequestData.ReadInt32(); - Context.ResponseData.Write(true); //Npad always got a left battery ? - Context.ResponseData.Write(true); //Npad always got a right battery ? + context.ResponseData.Write(true); //Npad always got a left battery ? + context.ResponseData.Write(true); //Npad always got a right battery ? - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. NpadId: {NpadId} - HasLeftBattery: true - HasRightBattery: true"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. NpadId: {npadId} - HasLeftBattery: true - HasRightBattery: true"); return 0; } // GetNpadInterfaceType(uint NpadId) -> uchar InterfaceType - public long GetNpadInterfaceType(ServiceCtx Context) + public long GetNpadInterfaceType(ServiceCtx context) { - int NpadId = Context.RequestData.ReadInt32(); + int npadId = context.RequestData.ReadInt32(); - Context.ResponseData.Write((byte)0); + context.ResponseData.Write((byte)0); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. NpadId: {NpadId} - NpadInterfaceType: 0"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. NpadId: {npadId} - NpadInterfaceType: 0"); return 0; } // GetNpadLeftRightInterfaceType(uint NpadId) -> uchar LeftInterfaceType, uchar RightInterfaceType - public long GetNpadLeftRightInterfaceType(ServiceCtx Context) + public long GetNpadLeftRightInterfaceType(ServiceCtx context) { - int NpadId = Context.RequestData.ReadInt32(); + int npadId = context.RequestData.ReadInt32(); - Context.ResponseData.Write((byte)0); - Context.ResponseData.Write((byte)0); + context.ResponseData.Write((byte)0); + context.ResponseData.Write((byte)0); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. NpadId: {NpadId} - " + + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. NpadId: {npadId} - " + $"LeftInterfaceType: 0 - " + $"RightInterfaceType: 0"); @@ -1330,211 +1330,211 @@ namespace Ryujinx.HLE.HOS.Services.Hid } // GetPalmaConnectionHandle(uint Unknown0, nn::applet::AppletResourceUserId) -> nn::hid::PalmaConnectionHandle - public long GetPalmaConnectionHandle(ServiceCtx Context) + public long GetPalmaConnectionHandle(ServiceCtx context) { - int Unknown0 = Context.RequestData.ReadInt32(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + int unknown0 = context.RequestData.ReadInt32(); + long appletResourceUserId = context.RequestData.ReadInt64(); - int PalmaConnectionHandle = 0; + int palmaConnectionHandle = 0; - Context.ResponseData.Write(PalmaConnectionHandle); + context.ResponseData.Write(palmaConnectionHandle); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"Unknown0: {Unknown0} - " + - $"PalmaConnectionHandle: {PalmaConnectionHandle}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"Unknown0: {unknown0} - " + + $"PalmaConnectionHandle: {palmaConnectionHandle}"); return 0; } // InitializePalma(nn::hid::PalmaConnectionHandle) - public long InitializePalma(ServiceCtx Context) + public long InitializePalma(ServiceCtx context) { - int PalmaConnectionHandle = Context.RequestData.ReadInt32(); + int palmaConnectionHandle = context.RequestData.ReadInt32(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {PalmaConnectionHandle}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {palmaConnectionHandle}"); - PalmaOperationCompleteEvent.ReadableEvent.Signal(); + _palmaOperationCompleteEvent.ReadableEvent.Signal(); return 0; } // AcquirePalmaOperationCompleteEvent(nn::hid::PalmaConnectionHandle) -> nn::sf::NativeHandle - public long AcquirePalmaOperationCompleteEvent(ServiceCtx Context) + public long AcquirePalmaOperationCompleteEvent(ServiceCtx context) { - int PalmaConnectionHandle = Context.RequestData.ReadInt32(); + int palmaConnectionHandle = context.RequestData.ReadInt32(); - if (Context.Process.HandleTable.GenerateHandle(PalmaOperationCompleteEvent.ReadableEvent, out int Handle) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(_palmaOperationCompleteEvent.ReadableEvent, out int handle) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {PalmaConnectionHandle}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {palmaConnectionHandle}"); return 0; } // GetPalmaOperationInfo(nn::hid::PalmaConnectionHandle) -> long Unknown0, buffer<Unknown> - public long GetPalmaOperationInfo(ServiceCtx Context) + public long GetPalmaOperationInfo(ServiceCtx context) { - int PalmaConnectionHandle = Context.RequestData.ReadInt32(); + int palmaConnectionHandle = context.RequestData.ReadInt32(); - long Unknown0 = 0; //Counter? + long unknown0 = 0; //Counter? - Context.ResponseData.Write(Unknown0); + context.ResponseData.Write(unknown0); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {PalmaConnectionHandle} - " + - $"Unknown0: {Unknown0}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {palmaConnectionHandle} - " + + $"Unknown0: {unknown0}"); return 0; } // PlayPalmaActivity(nn::hid::PalmaConnectionHandle, ulong Unknown0) - public long PlayPalmaActivity(ServiceCtx Context) + public long PlayPalmaActivity(ServiceCtx context) { - int PalmaConnectionHandle = Context.RequestData.ReadInt32(); - long Unknown0 = Context.RequestData.ReadInt64(); + int palmaConnectionHandle = context.RequestData.ReadInt32(); + long unknown0 = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {PalmaConnectionHandle} - " + - $"Unknown0: {Unknown0}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {palmaConnectionHandle} - " + + $"Unknown0: {unknown0}"); - PalmaOperationCompleteEvent.ReadableEvent.Signal(); + _palmaOperationCompleteEvent.ReadableEvent.Signal(); return 0; } // SetPalmaFrModeType(nn::hid::PalmaConnectionHandle, ulong FrModeType) - public long SetPalmaFrModeType(ServiceCtx Context) + public long SetPalmaFrModeType(ServiceCtx context) { - int PalmaConnectionHandle = Context.RequestData.ReadInt32(); - long FrModeType = Context.RequestData.ReadInt64(); + int palmaConnectionHandle = context.RequestData.ReadInt32(); + long frModeType = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {PalmaConnectionHandle} - " + - $"FrModeType: {FrModeType}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {palmaConnectionHandle} - " + + $"FrModeType: {frModeType}"); - PalmaOperationCompleteEvent.ReadableEvent.Signal(); + _palmaOperationCompleteEvent.ReadableEvent.Signal(); return 0; } // ReadPalmaStep(nn::hid::PalmaConnectionHandle) - public long ReadPalmaStep(ServiceCtx Context) + public long ReadPalmaStep(ServiceCtx context) { - int PalmaConnectionHandle = Context.RequestData.ReadInt32(); + int palmaConnectionHandle = context.RequestData.ReadInt32(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {PalmaConnectionHandle}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {palmaConnectionHandle}"); return 0; } // EnablePalmaStep(nn::hid::PalmaConnectionHandle, bool Enable) - public long EnablePalmaStep(ServiceCtx Context) + public long EnablePalmaStep(ServiceCtx context) { - int PalmaConnectionHandle = Context.RequestData.ReadInt32(); - bool EnabledPalmaStep = Context.RequestData.ReadBoolean(); + int palmaConnectionHandle = context.RequestData.ReadInt32(); + bool enabledPalmaStep = context.RequestData.ReadBoolean(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {PalmaConnectionHandle} - " + - $"EnabledPalmaStep: {EnabledPalmaStep}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {palmaConnectionHandle} - " + + $"EnabledPalmaStep: {enabledPalmaStep}"); - PalmaOperationCompleteEvent.ReadableEvent.Signal(); + _palmaOperationCompleteEvent.ReadableEvent.Signal(); return 0; } // SuspendPalmaStep(nn::hid::PalmaConnectionHandle) - public long SuspendPalmaStep(ServiceCtx Context) + public long SuspendPalmaStep(ServiceCtx context) { - int PalmaConnectionHandle = Context.RequestData.ReadInt32(); + int palmaConnectionHandle = context.RequestData.ReadInt32(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {PalmaConnectionHandle}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {palmaConnectionHandle}"); - PalmaOperationCompleteEvent.ReadableEvent.Signal(); + _palmaOperationCompleteEvent.ReadableEvent.Signal(); return 0; } // ResetPalmaStep(nn::hid::PalmaConnectionHandle) - public long ResetPalmaStep(ServiceCtx Context) + public long ResetPalmaStep(ServiceCtx context) { - int PalmaConnectionHandle = Context.RequestData.ReadInt32(); + int palmaConnectionHandle = context.RequestData.ReadInt32(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {PalmaConnectionHandle}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {palmaConnectionHandle}"); - PalmaOperationCompleteEvent.ReadableEvent.Signal(); + _palmaOperationCompleteEvent.ReadableEvent.Signal(); return 0; } // ReadPalmaApplicationSection(nn::hid::PalmaConnectionHandle, ulong Unknown0, ulong Unknown1) - public long ReadPalmaApplicationSection(ServiceCtx Context) + public long 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.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {PalmaConnectionHandle} - " + - $"Unknown0: {Unknown0} - " + - $"Unknown1: {Unknown1}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {palmaConnectionHandle} - " + + $"Unknown0: {unknown0} - " + + $"Unknown1: {unknown1}"); return 0; } // WritePalmaApplicationSection(nn::hid::PalmaConnectionHandle, ulong Unknown0, ulong Unknown1, nn::hid::PalmaApplicationSectionAccessBuffer) - public long WritePalmaApplicationSection(ServiceCtx Context) + public long 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.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {PalmaConnectionHandle} - " + - $"Unknown0: {Unknown0} - " + - $"Unknown1: {Unknown1}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {palmaConnectionHandle} - " + + $"Unknown0: {unknown0} - " + + $"Unknown1: {unknown1}"); - PalmaOperationCompleteEvent.ReadableEvent.Signal(); + _palmaOperationCompleteEvent.ReadableEvent.Signal(); return 0; } // ReadPalmaUniqueCode(nn::hid::PalmaConnectionHandle) - public long ReadPalmaUniqueCode(ServiceCtx Context) + public long ReadPalmaUniqueCode(ServiceCtx context) { - int PalmaConnectionHandle = Context.RequestData.ReadInt32(); + int palmaConnectionHandle = context.RequestData.ReadInt32(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {PalmaConnectionHandle}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {palmaConnectionHandle}"); return 0; } // SetPalmaUniqueCodeInvalid(nn::hid::PalmaConnectionHandle) - public long SetPalmaUniqueCodeInvalid(ServiceCtx Context) + public long SetPalmaUniqueCodeInvalid(ServiceCtx context) { - int PalmaConnectionHandle = Context.RequestData.ReadInt32(); + int palmaConnectionHandle = context.RequestData.ReadInt32(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {PalmaConnectionHandle}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {palmaConnectionHandle}"); return 0; } // SetNpadCommunicationMode(long CommunicationMode, nn::applet::AppletResourceUserId) - public long SetNpadCommunicationMode(ServiceCtx Context) + public long SetNpadCommunicationMode(ServiceCtx context) { - NpadCommunicationMode = Context.RequestData.ReadInt64(); - long AppletResourceUserId = Context.RequestData.ReadInt64(); + _npadCommunicationMode = context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " + - $"NpadCommunicationMode: {NpadCommunicationMode}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {appletResourceUserId} - " + + $"NpadCommunicationMode: {_npadCommunicationMode}"); return 0; } // GetNpadCommunicationMode() -> long CommunicationMode - public long GetNpadCommunicationMode(ServiceCtx Context) + public long GetNpadCommunicationMode(ServiceCtx context) { - Context.ResponseData.Write(NpadCommunicationMode); + context.ResponseData.Write(_npadCommunicationMode); - Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. CommunicationMode: {NpadCommunicationMode}"); + Logger.PrintStub(LogClass.ServiceHid, $"Stubbed. CommunicationMode: {_npadCommunicationMode}"); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/IpcService.cs b/Ryujinx.HLE/HOS/Services/IpcService.cs index 60a4431e..ec43430e 100644 --- a/Ryujinx.HLE/HOS/Services/IpcService.cs +++ b/Ryujinx.HLE/HOS/Services/IpcService.cs @@ -11,176 +11,176 @@ namespace Ryujinx.HLE.HOS.Services { public abstract IReadOnlyDictionary<int, ServiceProcessRequest> Commands { get; } - private IdDictionary DomainObjects; + private IdDictionary _domainObjects; - private int SelfId; + private int _selfId; - private bool IsDomain; + private bool _isDomain; public IpcService() { - DomainObjects = new IdDictionary(); + _domainObjects = new IdDictionary(); - SelfId = -1; + _selfId = -1; } public int ConvertToDomain() { - if (SelfId == -1) + if (_selfId == -1) { - SelfId = DomainObjects.Add(this); + _selfId = _domainObjects.Add(this); } - IsDomain = true; + _isDomain = true; - return SelfId; + return _selfId; } public void ConvertToSession() { - IsDomain = false; + _isDomain = false; } - public void CallMethod(ServiceCtx Context) + public void CallMethod(ServiceCtx context) { - IIpcService Service = this; + IIpcService service = this; - if (IsDomain) + if (_isDomain) { - int DomainWord0 = Context.RequestData.ReadInt32(); - int DomainObjId = Context.RequestData.ReadInt32(); + int domainWord0 = context.RequestData.ReadInt32(); + int domainObjId = context.RequestData.ReadInt32(); - int DomainCmd = (DomainWord0 >> 0) & 0xff; - int InputObjCount = (DomainWord0 >> 8) & 0xff; - int DataPayloadSize = (DomainWord0 >> 16) & 0xffff; + int domainCmd = (domainWord0 >> 0) & 0xff; + int inputObjCount = (domainWord0 >> 8) & 0xff; + int dataPayloadSize = (domainWord0 >> 16) & 0xffff; - Context.RequestData.BaseStream.Seek(0x10 + DataPayloadSize, SeekOrigin.Begin); + context.RequestData.BaseStream.Seek(0x10 + dataPayloadSize, SeekOrigin.Begin); - for (int Index = 0; Index < InputObjCount; Index++) + for (int index = 0; index < inputObjCount; index++) { - Context.Request.ObjectIds.Add(Context.RequestData.ReadInt32()); + context.Request.ObjectIds.Add(context.RequestData.ReadInt32()); } - Context.RequestData.BaseStream.Seek(0x10, SeekOrigin.Begin); + context.RequestData.BaseStream.Seek(0x10, SeekOrigin.Begin); - if (DomainCmd == 1) + if (domainCmd == 1) { - Service = GetObject(DomainObjId); + service = GetObject(domainObjId); - Context.ResponseData.Write(0L); - Context.ResponseData.Write(0L); + context.ResponseData.Write(0L); + context.ResponseData.Write(0L); } - else if (DomainCmd == 2) + else if (domainCmd == 2) { - Delete(DomainObjId); + Delete(domainObjId); - Context.ResponseData.Write(0L); + context.ResponseData.Write(0L); return; } else { - throw new NotImplementedException($"Domain command: {DomainCmd}"); + throw new NotImplementedException($"Domain command: {domainCmd}"); } } - long SfciMagic = Context.RequestData.ReadInt64(); - int CommandId = (int)Context.RequestData.ReadInt64(); + long sfciMagic = context.RequestData.ReadInt64(); + int commandId = (int)context.RequestData.ReadInt64(); - if (Service.Commands.TryGetValue(CommandId, out ServiceProcessRequest ProcessRequest)) + if (service.Commands.TryGetValue(commandId, out ServiceProcessRequest processRequest)) { - Context.ResponseData.BaseStream.Seek(IsDomain ? 0x20 : 0x10, SeekOrigin.Begin); + context.ResponseData.BaseStream.Seek(_isDomain ? 0x20 : 0x10, SeekOrigin.Begin); - Logger.PrintDebug(LogClass.KernelIpc, $"{Service.GetType().Name}: {ProcessRequest.Method.Name}"); + Logger.PrintDebug(LogClass.KernelIpc, $"{service.GetType().Name}: {processRequest.Method.Name}"); - long Result = ProcessRequest(Context); + long result = processRequest(context); - if (IsDomain) + if (_isDomain) { - foreach (int Id in Context.Response.ObjectIds) + foreach (int id in context.Response.ObjectIds) { - Context.ResponseData.Write(Id); + context.ResponseData.Write(id); } - Context.ResponseData.BaseStream.Seek(0, SeekOrigin.Begin); + context.ResponseData.BaseStream.Seek(0, SeekOrigin.Begin); - Context.ResponseData.Write(Context.Response.ObjectIds.Count); + context.ResponseData.Write(context.Response.ObjectIds.Count); } - Context.ResponseData.BaseStream.Seek(IsDomain ? 0x10 : 0, SeekOrigin.Begin); + context.ResponseData.BaseStream.Seek(_isDomain ? 0x10 : 0, SeekOrigin.Begin); - Context.ResponseData.Write(IpcMagic.Sfco); - Context.ResponseData.Write(Result); + context.ResponseData.Write(IpcMagic.Sfco); + context.ResponseData.Write(result); } else { - string DbgMessage = $"{Context.Session.ServiceName} {Service.GetType().Name}: {CommandId}"; + string dbgMessage = $"{context.Session.ServiceName} {service.GetType().Name}: {commandId}"; - throw new NotImplementedException(DbgMessage); + throw new NotImplementedException(dbgMessage); } } - protected static void MakeObject(ServiceCtx Context, IpcService Obj) + protected static void MakeObject(ServiceCtx context, IpcService obj) { - IpcService Service = Context.Session.Service; + IpcService service = context.Session.Service; - if (Service.IsDomain) + if (service._isDomain) { - Context.Response.ObjectIds.Add(Service.Add(Obj)); + context.Response.ObjectIds.Add(service.Add(obj)); } else { - KSession Session = new KSession(Obj, Context.Session.ServiceName); + KSession session = new KSession(obj, context.Session.ServiceName); - if (Context.Process.HandleTable.GenerateHandle(Session, out int Handle) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(session, out int handle) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } - Context.Response.HandleDesc = IpcHandleDesc.MakeMove(Handle); + context.Response.HandleDesc = IpcHandleDesc.MakeMove(handle); } } - protected static T GetObject<T>(ServiceCtx Context, int Index) where T : IpcService + protected static T GetObject<T>(ServiceCtx context, int index) where T : IpcService { - IpcService Service = Context.Session.Service; + IpcService service = context.Session.Service; - if (!Service.IsDomain) + if (!service._isDomain) { - int Handle = Context.Request.HandleDesc.ToMove[Index]; + int handle = context.Request.HandleDesc.ToMove[index]; - KSession Session = Context.Process.HandleTable.GetObject<KSession>(Handle); + KSession session = context.Process.HandleTable.GetObject<KSession>(handle); - return Session?.Service is T ? (T)Session.Service : null; + return session?.Service is T ? (T)session.Service : null; } - int ObjId = Context.Request.ObjectIds[Index]; + int objId = context.Request.ObjectIds[index]; - IIpcService Obj = Service.GetObject(ObjId); + IIpcService obj = service.GetObject(objId); - return Obj is T ? (T)Obj : null; + return obj is T ? (T)obj : null; } - private int Add(IIpcService Obj) + private int Add(IIpcService obj) { - return DomainObjects.Add(Obj); + return _domainObjects.Add(obj); } - private bool Delete(int Id) + private bool Delete(int id) { - object Obj = DomainObjects.Delete(Id); + object obj = _domainObjects.Delete(id); - if (Obj is IDisposable DisposableObj) + if (obj is IDisposable disposableObj) { - DisposableObj.Dispose(); + disposableObj.Dispose(); } - return Obj != null; + return obj != null; } - private IIpcService GetObject(int Id) + private IIpcService GetObject(int id) { - return DomainObjects.GetData<IIpcService>(Id); + return _domainObjects.GetData<IIpcService>(id); } } }
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Irs/IIrSensorServer.cs b/Ryujinx.HLE/HOS/Services/Irs/IIrSensorServer.cs index 155faea3..d6683877 100644 --- a/Ryujinx.HLE/HOS/Services/Irs/IIrSensorServer.cs +++ b/Ryujinx.HLE/HOS/Services/Irs/IIrSensorServer.cs @@ -6,15 +6,15 @@ namespace Ryujinx.HLE.HOS.Services.Irs { class IIrSensorServer : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private bool Activated; + private bool _activated; public IIrSensorServer() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 302, ActivateIrsensor }, { 303, DeactivateIrsensor } @@ -22,21 +22,21 @@ namespace Ryujinx.HLE.HOS.Services.Irs } // ActivateIrsensor(nn::applet::AppletResourceUserId, pid) - public long ActivateIrsensor(ServiceCtx Context) + public long ActivateIrsensor(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceIrs, $"Stubbed. AppletResourceUserId: {AppletResourceUserId}"); + Logger.PrintStub(LogClass.ServiceIrs, $"Stubbed. AppletResourceUserId: {appletResourceUserId}"); return 0; } // DeactivateIrsensor(nn::applet::AppletResourceUserId, pid) - public long DeactivateIrsensor(ServiceCtx Context) + public long DeactivateIrsensor(ServiceCtx context) { - long AppletResourceUserId = Context.RequestData.ReadInt64(); + long appletResourceUserId = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceIrs, $"Stubbed. AppletResourceUserId: {AppletResourceUserId}"); + Logger.PrintStub(LogClass.ServiceIrs, $"Stubbed. AppletResourceUserId: {appletResourceUserId}"); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Ldr/IRoInterface.cs b/Ryujinx.HLE/HOS/Services/Ldr/IRoInterface.cs index f0899bd4..b0eebe53 100644 --- a/Ryujinx.HLE/HOS/Services/Ldr/IRoInterface.cs +++ b/Ryujinx.HLE/HOS/Services/Ldr/IRoInterface.cs @@ -4,7 +4,6 @@ using Ryujinx.HLE.HOS.Ipc; using Ryujinx.HLE.HOS.Kernel; using Ryujinx.HLE.Loaders.Executables; using Ryujinx.HLE.Utilities; -using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -51,54 +50,54 @@ namespace Ryujinx.HLE.HOS.Services.Ldr class NrrInfo { - public NrrHeader Header { get; private set; } - public List<byte[]> Hashes { get; private set; } - public long NrrAddress { get; private set; } + public NrrHeader Header { get; } + public List<byte[]> Hashes { get; } + public long NrrAddress { get; } - public NrrInfo(long NrrAddress, NrrHeader Header, List<byte[]> Hashes) + public NrrInfo(long nrrAddress, NrrHeader header, List<byte[]> hashes) { - this.NrrAddress = NrrAddress; - this.Header = Header; - this.Hashes = Hashes; + NrrAddress = nrrAddress; + Header = header; + Hashes = hashes; } } class NroInfo { - public NxRelocatableObject 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 NxRelocatableObject Executable { get; } + + public byte[] Hash { get; } + public ulong NroAddress { get; } + public ulong NroSize { get; } + public ulong BssAddress { get; } + public ulong BssSize { get; } + public ulong TotalSize { get; } public ulong NroMappedAddress { get; set; } public NroInfo( - NxRelocatableObject Executable, - byte[] Hash, - ulong NroAddress, - ulong NroSize, - ulong BssAddress, - ulong BssSize, - ulong TotalSize) + NxRelocatableObject executable, + byte[] hash, + ulong nroAddress, + ulong nroSize, + ulong bssAddress, + ulong bssSize, + ulong totalSize) { - this.Executable = Executable; - this.Hash = Hash; - this.NroAddress = NroAddress; - this.NroSize = NroSize; - this.BssAddress = BssAddress; - this.BssSize = BssSize; - this.TotalSize = TotalSize; + Executable = executable; + Hash = hash; + NroAddress = nroAddress; + NroSize = nroSize; + BssAddress = bssAddress; + BssSize = bssSize; + TotalSize = totalSize; } } class IRoInterface : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; private const int MaxNrr = 0x40; private const int MaxNro = 0x40; @@ -106,70 +105,70 @@ namespace Ryujinx.HLE.HOS.Services.Ldr private const uint NrrMagic = 0x3052524E; private const uint NroMagic = 0x304F524E; - private List<NrrInfo> NrrInfos; - private List<NroInfo> NroInfos; + private List<NrrInfo> _nrrInfos; + private List<NroInfo> _nroInfos; - private bool IsInitialized; + private bool _isInitialized; public IRoInterface() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, LoadNro }, { 1, UnloadNro }, { 2, LoadNrr }, { 3, UnloadNrr }, - { 4, Initialize }, + { 4, Initialize } }; - NrrInfos = new List<NrrInfo>(MaxNrr); - NroInfos = new List<NroInfo>(MaxNro); + _nrrInfos = new List<NrrInfo>(MaxNrr); + _nroInfos = new List<NroInfo>(MaxNro); } - private long ParseNrr(out NrrInfo NrrInfo, ServiceCtx Context, long NrrAddress, long NrrSize) + private long ParseNrr(out NrrInfo nrrInfo, ServiceCtx context, long nrrAddress, long nrrSize) { - NrrInfo = null; + nrrInfo = null; - if (NrrSize == 0 || NrrAddress + NrrSize <= NrrAddress || (NrrSize & 0xFFF) != 0) + if (nrrSize == 0 || nrrAddress + nrrSize <= nrrAddress || (nrrSize & 0xFFF) != 0) { return MakeError(ErrorModule.Loader, LoaderErr.BadSize); } - else if ((NrrAddress & 0xFFF) != 0) + else if ((nrrAddress & 0xFFF) != 0) { return MakeError(ErrorModule.Loader, LoaderErr.UnalignedAddress); } - StructReader Reader = new StructReader(Context.Memory, NrrAddress); - NrrHeader Header = Reader.Read<NrrHeader>(); + StructReader reader = new StructReader(context.Memory, nrrAddress); + NrrHeader header = reader.Read<NrrHeader>(); - if (Header.Magic != NrrMagic) + if (header.Magic != NrrMagic) { return MakeError(ErrorModule.Loader, LoaderErr.InvalidNrr); } - else if (Header.NrrSize != NrrSize) + else if (header.NrrSize != nrrSize) { return MakeError(ErrorModule.Loader, LoaderErr.BadSize); } - List<byte[]> Hashes = new List<byte[]>(); + List<byte[]> hashes = new List<byte[]>(); - for (int i = 0; i < Header.HashCount; i++) + for (int i = 0; i < header.HashCount; i++) { - Hashes.Add(Context.Memory.ReadBytes(NrrAddress + Header.HashOffset + (i * 0x20), 0x20)); + hashes.Add(context.Memory.ReadBytes(nrrAddress + header.HashOffset + (i * 0x20), 0x20)); } - NrrInfo = new NrrInfo(NrrAddress, Header, Hashes); + nrrInfo = new NrrInfo(nrrAddress, header, hashes); return 0; } - public bool IsNroHashPresent(byte[] NroHash) + public bool IsNroHashPresent(byte[] nroHash) { - foreach (NrrInfo Info in NrrInfos) + foreach (NrrInfo info in _nrrInfos) { - foreach (byte[] Hash in Info.Hashes) + foreach (byte[] hash in info.Hashes) { - if (Hash.SequenceEqual(NroHash)) + if (hash.SequenceEqual(nroHash)) { return true; } @@ -179,11 +178,11 @@ namespace Ryujinx.HLE.HOS.Services.Ldr return false; } - public bool IsNroLoaded(byte[] NroHash) + public bool IsNroLoaded(byte[] nroHash) { - foreach (NroInfo Info in NroInfos) + foreach (NroInfo info in _nroInfos) { - if (Info.Hash.SequenceEqual(NroHash)) + if (info.Hash.SequenceEqual(nroHash)) { return true; } @@ -192,206 +191,206 @@ namespace Ryujinx.HLE.HOS.Services.Ldr return false; } - public long ParseNro(out NroInfo Res, ServiceCtx Context, ulong NroAddress, ulong NroSize, ulong BssAddress, ulong BssSize) + public long ParseNro(out NroInfo res, ServiceCtx context, ulong nroAddress, ulong nroSize, ulong bssAddress, ulong bssSize) { - Res = null; + res = null; - if (NroInfos.Count >= MaxNro) + if (_nroInfos.Count >= MaxNro) { return MakeError(ErrorModule.Loader, LoaderErr.MaxNro); } - else if (NroSize == 0 || NroAddress + NroSize <= NroAddress || (NroSize & 0xFFF) != 0) + else if (nroSize == 0 || nroAddress + nroSize <= nroAddress || (nroSize & 0xFFF) != 0) { return MakeError(ErrorModule.Loader, LoaderErr.BadSize); } - else if (BssSize != 0 && BssAddress + BssSize <= BssAddress) + else if (bssSize != 0 && bssAddress + bssSize <= bssAddress) { return MakeError(ErrorModule.Loader, LoaderErr.BadSize); } - else if ((NroAddress & 0xFFF) != 0) + else if ((nroAddress & 0xFFF) != 0) { return MakeError(ErrorModule.Loader, LoaderErr.UnalignedAddress); } - uint Magic = Context.Memory.ReadUInt32((long)NroAddress + 0x10); - uint NroFileSize = Context.Memory.ReadUInt32((long)NroAddress + 0x18); + uint magic = context.Memory.ReadUInt32((long)nroAddress + 0x10); + uint nroFileSize = context.Memory.ReadUInt32((long)nroAddress + 0x18); - if (Magic != NroMagic || NroSize != NroFileSize) + if (magic != NroMagic || nroSize != nroFileSize) { return MakeError(ErrorModule.Loader, LoaderErr.InvalidNro); } - byte[] NroData = Context.Memory.ReadBytes((long)NroAddress, (long)NroSize); - byte[] NroHash = null; + byte[] nroData = context.Memory.ReadBytes((long)nroAddress, (long)nroSize); + byte[] nroHash = null; - MemoryStream Stream = new MemoryStream(NroData); + MemoryStream stream = new MemoryStream(nroData); - using (SHA256 Hasher = SHA256.Create()) + using (SHA256 hasher = SHA256.Create()) { - NroHash = Hasher.ComputeHash(Stream); + nroHash = hasher.ComputeHash(stream); } - if (!IsNroHashPresent(NroHash)) + if (!IsNroHashPresent(nroHash)) { return MakeError(ErrorModule.Loader, LoaderErr.NroHashNotPresent); } - if (IsNroLoaded(NroHash)) + if (IsNroLoaded(nroHash)) { return MakeError(ErrorModule.Loader, LoaderErr.NroAlreadyLoaded); } - Stream.Position = 0; + stream.Position = 0; - NxRelocatableObject Executable = new NxRelocatableObject(Stream, NroAddress, BssAddress); + NxRelocatableObject executable = new NxRelocatableObject(stream, nroAddress, bssAddress); // check if everything is page align. - if ((Executable.Text.Length & 0xFFF) != 0 || (Executable.RO.Length & 0xFFF) != 0 || - (Executable.Data.Length & 0xFFF) != 0 || (Executable.BssSize & 0xFFF) != 0) + if ((executable.Text.Length & 0xFFF) != 0 || (executable.Ro.Length & 0xFFF) != 0 || + (executable.Data.Length & 0xFFF) != 0 || (executable.BssSize & 0xFFF) != 0) { return MakeError(ErrorModule.Loader, LoaderErr.InvalidNro); } // check if everything is contiguous. - if (Executable.ROOffset != Executable.TextOffset + Executable.Text.Length || - Executable.DataOffset != Executable.ROOffset + Executable.RO.Length || - NroFileSize != Executable.DataOffset + Executable.Data.Length) + if (executable.RoOffset != executable.TextOffset + executable.Text.Length || + executable.DataOffset != executable.RoOffset + executable.Ro.Length || + nroFileSize != executable.DataOffset + executable.Data.Length) { return MakeError(ErrorModule.Loader, LoaderErr.InvalidNro); } // finally check the bss size match. - if ((ulong)Executable.BssSize != BssSize) + if ((ulong)executable.BssSize != bssSize) { return MakeError(ErrorModule.Loader, LoaderErr.InvalidNro); } - int TotalSize = Executable.Text.Length + Executable.RO.Length + Executable.Data.Length + Executable.BssSize; + int totalSize = executable.Text.Length + executable.Ro.Length + executable.Data.Length + executable.BssSize; - Res = new NroInfo( - Executable, - NroHash, - NroAddress, - NroSize, - BssAddress, - BssSize, - (ulong)TotalSize); + res = new NroInfo( + executable, + nroHash, + nroAddress, + nroSize, + bssAddress, + bssSize, + (ulong)totalSize); return 0; } - private long MapNro(ServiceCtx Context, NroInfo Info, out ulong NroMappedAddress) + private long MapNro(ServiceCtx context, NroInfo info, out ulong nroMappedAddress) { - NroMappedAddress = 0; + nroMappedAddress = 0; - KMemoryManager MemMgr = Context.Process.MemoryManager; + KMemoryManager memMgr = context.Process.MemoryManager; - ulong TargetAddress = MemMgr.GetAddrSpaceBaseAddr(); + ulong targetAddress = memMgr.GetAddrSpaceBaseAddr(); while (true) { - if (TargetAddress + Info.TotalSize >= MemMgr.AddrSpaceEnd) + if (targetAddress + info.TotalSize >= memMgr.AddrSpaceEnd) { return MakeError(ErrorModule.Loader, LoaderErr.InvalidMemoryState); } - KMemoryInfo MemInfo = MemMgr.QueryMemory(TargetAddress); + KMemoryInfo memInfo = memMgr.QueryMemory(targetAddress); - if (MemInfo.State == MemoryState.Unmapped && MemInfo.Size >= Info.TotalSize) + if (memInfo.State == MemoryState.Unmapped && memInfo.Size >= info.TotalSize) { - if (!MemMgr.InsideHeapRegion (TargetAddress, Info.TotalSize) && - !MemMgr.InsideAliasRegion(TargetAddress, Info.TotalSize)) + if (!memMgr.InsideHeapRegion (targetAddress, info.TotalSize) && + !memMgr.InsideAliasRegion(targetAddress, info.TotalSize)) { break; } } - TargetAddress += MemInfo.Size; + targetAddress += memInfo.Size; } - KernelResult Result = MemMgr.MapProcessCodeMemory(TargetAddress, Info.NroAddress, Info.NroSize); + KernelResult result = memMgr.MapProcessCodeMemory(targetAddress, info.NroAddress, info.NroSize); - if (Result != KernelResult.Success) + if (result != KernelResult.Success) { return MakeError(ErrorModule.Loader, LoaderErr.InvalidMemoryState); } - ulong BssTargetAddress = TargetAddress + Info.NroSize; + ulong bssTargetAddress = targetAddress + info.NroSize; - if (Info.BssSize != 0) + if (info.BssSize != 0) { - Result = MemMgr.MapProcessCodeMemory(BssTargetAddress, Info.BssAddress, Info.BssSize); + result = memMgr.MapProcessCodeMemory(bssTargetAddress, info.BssAddress, info.BssSize); - if (Result != KernelResult.Success) + if (result != KernelResult.Success) { - MemMgr.UnmapProcessCodeMemory(TargetAddress, Info.NroAddress, Info.NroSize); + memMgr.UnmapProcessCodeMemory(targetAddress, info.NroAddress, info.NroSize); return MakeError(ErrorModule.Loader, LoaderErr.InvalidMemoryState); } } - Result = LoadNroIntoMemory(Context.Process, Info.Executable, TargetAddress); + result = LoadNroIntoMemory(context.Process, info.Executable, targetAddress); - if (Result != KernelResult.Success) + if (result != KernelResult.Success) { - MemMgr.UnmapProcessCodeMemory(TargetAddress, Info.NroAddress, Info.NroSize); + memMgr.UnmapProcessCodeMemory(targetAddress, info.NroAddress, info.NroSize); - if (Info.BssSize != 0) + if (info.BssSize != 0) { - MemMgr.UnmapProcessCodeMemory(BssTargetAddress, Info.BssAddress, Info.BssSize); + memMgr.UnmapProcessCodeMemory(bssTargetAddress, info.BssAddress, info.BssSize); } return 0; } - Info.NroMappedAddress = TargetAddress; - NroMappedAddress = TargetAddress; + info.NroMappedAddress = targetAddress; + nroMappedAddress = targetAddress; return 0; } - private KernelResult LoadNroIntoMemory(KProcess Process, IExecutable RelocatableObject, ulong BaseAddress) + private KernelResult LoadNroIntoMemory(KProcess process, IExecutable relocatableObject, ulong baseAddress) { - ulong TextStart = BaseAddress + (ulong)RelocatableObject.TextOffset; - ulong ROStart = BaseAddress + (ulong)RelocatableObject.ROOffset; - ulong DataStart = BaseAddress + (ulong)RelocatableObject.DataOffset; + ulong textStart = baseAddress + (ulong)relocatableObject.TextOffset; + ulong roStart = baseAddress + (ulong)relocatableObject.RoOffset; + ulong dataStart = baseAddress + (ulong)relocatableObject.DataOffset; - ulong BssStart = DataStart + (ulong)RelocatableObject.Data.Length; + ulong bssStart = dataStart + (ulong)relocatableObject.Data.Length; - ulong BssEnd = BitUtils.AlignUp(BssStart + (ulong)RelocatableObject.BssSize, KMemoryManager.PageSize); + ulong bssEnd = BitUtils.AlignUp(bssStart + (ulong)relocatableObject.BssSize, KMemoryManager.PageSize); - Process.CpuMemory.WriteBytes((long)TextStart, RelocatableObject.Text); - Process.CpuMemory.WriteBytes((long)ROStart, RelocatableObject.RO); - Process.CpuMemory.WriteBytes((long)DataStart, RelocatableObject.Data); + process.CpuMemory.WriteBytes((long)textStart, relocatableObject.Text); + process.CpuMemory.WriteBytes((long)roStart, relocatableObject.Ro); + process.CpuMemory.WriteBytes((long)dataStart, relocatableObject.Data); - MemoryHelper.FillWithZeros(Process.CpuMemory, (long)BssStart, (int)(BssEnd - BssStart)); + MemoryHelper.FillWithZeros(process.CpuMemory, (long)bssStart, (int)(bssEnd - bssStart)); - KernelResult Result; + KernelResult result; - Result = Process.MemoryManager.SetProcessMemoryPermission(TextStart, ROStart - TextStart, MemoryPermission.ReadAndExecute); + result = process.MemoryManager.SetProcessMemoryPermission(textStart, roStart - textStart, MemoryPermission.ReadAndExecute); - if (Result != KernelResult.Success) + if (result != KernelResult.Success) { - return Result; + return result; } - Result = Process.MemoryManager.SetProcessMemoryPermission(ROStart, DataStart - ROStart, MemoryPermission.Read); + result = process.MemoryManager.SetProcessMemoryPermission(roStart, dataStart - roStart, MemoryPermission.Read); - if (Result != KernelResult.Success) + if (result != KernelResult.Success) { - return Result; + return result; } - return Process.MemoryManager.SetProcessMemoryPermission(DataStart, BssEnd - DataStart, MemoryPermission.ReadAndWrite); + return process.MemoryManager.SetProcessMemoryPermission(dataStart, bssEnd - dataStart, MemoryPermission.ReadAndWrite); } - private long RemoveNrrInfo(long NrrAddress) + private long RemoveNrrInfo(long nrrAddress) { - foreach (NrrInfo Info in NrrInfos) + foreach (NrrInfo info in _nrrInfos) { - if (Info.NrrAddress == NrrAddress) + if (info.NrrAddress == nrrAddress) { - NrrInfos.Remove(Info); + _nrrInfos.Remove(info); return 0; } @@ -400,46 +399,46 @@ namespace Ryujinx.HLE.HOS.Services.Ldr return MakeError(ErrorModule.Loader, LoaderErr.BadNrrAddress); } - private long RemoveNroInfo(ServiceCtx Context, ulong NroMappedAddress) + private long RemoveNroInfo(ServiceCtx context, ulong nroMappedAddress) { - foreach (NroInfo Info in NroInfos) + foreach (NroInfo info in _nroInfos) { - if (Info.NroMappedAddress == NroMappedAddress) + if (info.NroMappedAddress == nroMappedAddress) { - NroInfos.Remove(Info); + _nroInfos.Remove(info); - ulong TextSize = (ulong)Info.Executable.Text.Length; - ulong ROSize = (ulong)Info.Executable.RO.Length; - ulong DataSize = (ulong)Info.Executable.Data.Length; - ulong BssSize = (ulong)Info.Executable.BssSize; + ulong textSize = (ulong)info.Executable.Text.Length; + ulong roSize = (ulong)info.Executable.Ro.Length; + ulong dataSize = (ulong)info.Executable.Data.Length; + ulong bssSize = (ulong)info.Executable.BssSize; - KernelResult Result = KernelResult.Success; + KernelResult result = KernelResult.Success; - if (Info.Executable.BssSize != 0) + if (info.Executable.BssSize != 0) { - Result = Context.Process.MemoryManager.UnmapProcessCodeMemory( - Info.NroMappedAddress + TextSize + ROSize + DataSize, - Info.Executable.BssAddress, - BssSize); + result = context.Process.MemoryManager.UnmapProcessCodeMemory( + info.NroMappedAddress + textSize + roSize + dataSize, + info.Executable.BssAddress, + bssSize); } - if (Result == KernelResult.Success) + if (result == KernelResult.Success) { - Result = Context.Process.MemoryManager.UnmapProcessCodeMemory( - Info.NroMappedAddress + TextSize + ROSize, - Info.Executable.SourceAddress + TextSize + ROSize, - DataSize); + result = context.Process.MemoryManager.UnmapProcessCodeMemory( + info.NroMappedAddress + textSize + roSize, + info.Executable.SourceAddress + textSize + roSize, + dataSize); - if (Result == KernelResult.Success) + if (result == KernelResult.Success) { - Result = Context.Process.MemoryManager.UnmapProcessCodeMemory( - Info.NroMappedAddress, - Info.Executable.SourceAddress, - TextSize + ROSize); + result = context.Process.MemoryManager.UnmapProcessCodeMemory( + info.NroMappedAddress, + info.Executable.SourceAddress, + textSize + roSize); } } - return (long)Result; + return (long)result; } } @@ -447,125 +446,125 @@ namespace Ryujinx.HLE.HOS.Services.Ldr } // LoadNro(u64, u64, u64, u64, u64, pid) -> u64 - public long LoadNro(ServiceCtx Context) + public long LoadNro(ServiceCtx context) { - long Result = MakeError(ErrorModule.Loader, LoaderErr.BadInitialization); + long result = MakeError(ErrorModule.Loader, LoaderErr.BadInitialization); // Zero - Context.RequestData.ReadUInt64(); + context.RequestData.ReadUInt64(); - ulong NroHeapAddress = Context.RequestData.ReadUInt64(); - ulong NroSize = Context.RequestData.ReadUInt64(); - ulong BssHeapAddress = Context.RequestData.ReadUInt64(); - ulong BssSize = Context.RequestData.ReadUInt64(); + ulong nroHeapAddress = context.RequestData.ReadUInt64(); + ulong nroSize = context.RequestData.ReadUInt64(); + ulong bssHeapAddress = context.RequestData.ReadUInt64(); + ulong bssSize = context.RequestData.ReadUInt64(); - ulong NroMappedAddress = 0; + ulong nroMappedAddress = 0; - if (IsInitialized) + if (_isInitialized) { - NroInfo Info; + NroInfo info; - Result = ParseNro(out Info, Context, NroHeapAddress, NroSize, BssHeapAddress, BssSize); + result = ParseNro(out info, context, nroHeapAddress, nroSize, bssHeapAddress, bssSize); - if (Result == 0) + if (result == 0) { - Result = MapNro(Context, Info, out NroMappedAddress); + result = MapNro(context, info, out nroMappedAddress); - if (Result == 0) + if (result == 0) { - NroInfos.Add(Info); + _nroInfos.Add(info); } } } - Context.ResponseData.Write(NroMappedAddress); + context.ResponseData.Write(nroMappedAddress); - return Result; + return result; } // UnloadNro(u64, u64, pid) - public long UnloadNro(ServiceCtx Context) + public long UnloadNro(ServiceCtx context) { - long Result = MakeError(ErrorModule.Loader, LoaderErr.BadInitialization); + long result = MakeError(ErrorModule.Loader, LoaderErr.BadInitialization); // Zero - Context.RequestData.ReadUInt64(); + context.RequestData.ReadUInt64(); - ulong NroMappedAddress = Context.RequestData.ReadUInt64(); + ulong nroMappedAddress = context.RequestData.ReadUInt64(); - if (IsInitialized) + if (_isInitialized) { - if ((NroMappedAddress & 0xFFF) != 0) + if ((nroMappedAddress & 0xFFF) != 0) { return MakeError(ErrorModule.Loader, LoaderErr.UnalignedAddress); } - Result = RemoveNroInfo(Context, NroMappedAddress); + result = RemoveNroInfo(context, nroMappedAddress); } - return Result; + return result; } // LoadNrr(u64, u64, u64, pid) - public long LoadNrr(ServiceCtx Context) + public long LoadNrr(ServiceCtx context) { - long Result = MakeError(ErrorModule.Loader, LoaderErr.BadInitialization); + long result = MakeError(ErrorModule.Loader, LoaderErr.BadInitialization); // Zero - Context.RequestData.ReadUInt64(); + context.RequestData.ReadUInt64(); - long NrrAddress = Context.RequestData.ReadInt64(); - long NrrSize = Context.RequestData.ReadInt64(); + long nrrAddress = context.RequestData.ReadInt64(); + long nrrSize = context.RequestData.ReadInt64(); - if (IsInitialized) + if (_isInitialized) { - NrrInfo Info; - Result = ParseNrr(out Info, Context, NrrAddress, NrrSize); + NrrInfo info; + result = ParseNrr(out info, context, nrrAddress, nrrSize); - if(Result == 0) + if(result == 0) { - if (NrrInfos.Count >= MaxNrr) + if (_nrrInfos.Count >= MaxNrr) { - Result = MakeError(ErrorModule.Loader, LoaderErr.MaxNrr); + result = MakeError(ErrorModule.Loader, LoaderErr.MaxNrr); } else { - NrrInfos.Add(Info); + _nrrInfos.Add(info); } } } - return Result; + return result; } // UnloadNrr(u64, u64, pid) - public long UnloadNrr(ServiceCtx Context) + public long UnloadNrr(ServiceCtx context) { - long Result = MakeError(ErrorModule.Loader, LoaderErr.BadInitialization); + long result = MakeError(ErrorModule.Loader, LoaderErr.BadInitialization); // Zero - Context.RequestData.ReadUInt64(); + context.RequestData.ReadUInt64(); - long NrrHeapAddress = Context.RequestData.ReadInt64(); + long nrrHeapAddress = context.RequestData.ReadInt64(); - if (IsInitialized) + if (_isInitialized) { - if ((NrrHeapAddress & 0xFFF) != 0) + if ((nrrHeapAddress & 0xFFF) != 0) { return MakeError(ErrorModule.Loader, LoaderErr.UnalignedAddress); } - Result = RemoveNrrInfo(NrrHeapAddress); + result = RemoveNrrInfo(nrrHeapAddress); } - return Result; + return result; } // Initialize(u64, pid, KObject) - public long Initialize(ServiceCtx Context) + public long Initialize(ServiceCtx context) { // TODO: we actually ignore the pid and process handle receive, we will need to use them when we will have multi process support. - IsInitialized = true; + _isInitialized = true; return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Lm/ILogService.cs b/Ryujinx.HLE/HOS/Services/Lm/ILogService.cs index d79da515..37621c31 100644 --- a/Ryujinx.HLE/HOS/Services/Lm/ILogService.cs +++ b/Ryujinx.HLE/HOS/Services/Lm/ILogService.cs @@ -5,21 +5,21 @@ namespace Ryujinx.HLE.HOS.Services.Lm { class ILogService : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public ILogService() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, Initialize } }; } - public long Initialize(ServiceCtx Context) + public long Initialize(ServiceCtx context) { - MakeObject(Context, new ILogger()); + MakeObject(context, new ILogger()); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Lm/ILogger.cs b/Ryujinx.HLE/HOS/Services/Lm/ILogger.cs index 20579dfd..070cf9ae 100644 --- a/Ryujinx.HLE/HOS/Services/Lm/ILogger.cs +++ b/Ryujinx.HLE/HOS/Services/Lm/ILogger.cs @@ -8,91 +8,91 @@ namespace Ryujinx.HLE.HOS.Services.Lm { class ILogger : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public ILogger() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, Log } }; } - public long Log(ServiceCtx Context) + public long Log(ServiceCtx context) { - (long BufPos, long BufSize) = Context.Request.GetBufferType0x21(); - byte[] LogBuffer = Context.Memory.ReadBytes(BufPos, BufSize); + (long bufPos, long bufSize) = context.Request.GetBufferType0x21(); + byte[] logBuffer = context.Memory.ReadBytes(bufPos, bufSize); - using (MemoryStream MS = new MemoryStream(LogBuffer)) + using (MemoryStream ms = new MemoryStream(logBuffer)) { - BinaryReader Reader = new BinaryReader(MS); + BinaryReader reader = new BinaryReader(ms); - long Pid = Reader.ReadInt64(); - long ThreadContext = Reader.ReadInt64(); - short Flags = Reader.ReadInt16(); - byte Level = Reader.ReadByte(); - byte Verbosity = Reader.ReadByte(); - int PayloadLength = Reader.ReadInt32(); + long pid = reader.ReadInt64(); + long threadContext = reader.ReadInt64(); + short flags = reader.ReadInt16(); + byte level = reader.ReadByte(); + byte verbosity = reader.ReadByte(); + int payloadLength = reader.ReadInt32(); - StringBuilder SB = new StringBuilder(); + StringBuilder sb = new StringBuilder(); - SB.AppendLine("Guest log:"); + sb.AppendLine("Guest log:"); - while (MS.Position < MS.Length) + while (ms.Position < ms.Length) { - byte Type = Reader.ReadByte(); - byte Size = Reader.ReadByte(); + byte type = reader.ReadByte(); + byte size = reader.ReadByte(); - LmLogField Field = (LmLogField)Type; + LmLogField field = (LmLogField)type; - string FieldStr = string.Empty; + string fieldStr = string.Empty; - if (Field == LmLogField.Start) + if (field == LmLogField.Start) { - Reader.ReadBytes(Size); + reader.ReadBytes(size); continue; } - else if (Field == LmLogField.Stop) + else if (field == LmLogField.Stop) { break; } - else if (Field == LmLogField.Line) + else if (field == LmLogField.Line) { - FieldStr = $"{Field}: {Reader.ReadInt32()}"; + fieldStr = $"{field}: {reader.ReadInt32()}"; } - else if (Field == LmLogField.DropCount) + else if (field == LmLogField.DropCount) { - FieldStr = $"{Field}: {Reader.ReadInt64()}"; + fieldStr = $"{field}: {reader.ReadInt64()}"; } - else if (Field == LmLogField.Time) + else if (field == LmLogField.Time) { - FieldStr = $"{Field}: {Reader.ReadInt64()}s"; + fieldStr = $"{field}: {reader.ReadInt64()}s"; } - else if (Field < LmLogField.Count) + else if (field < LmLogField.Count) { - FieldStr = $"{Field}: '{Encoding.UTF8.GetString(Reader.ReadBytes(Size)).TrimEnd()}'"; + fieldStr = $"{field}: '{Encoding.UTF8.GetString(reader.ReadBytes(size)).TrimEnd()}'"; } else { - FieldStr = $"Field{Field}: '{Encoding.UTF8.GetString(Reader.ReadBytes(Size)).TrimEnd()}'"; + fieldStr = $"Field{field}: '{Encoding.UTF8.GetString(reader.ReadBytes(size)).TrimEnd()}'"; } - SB.AppendLine(" " + FieldStr); + sb.AppendLine(" " + fieldStr); } - string Text = SB.ToString(); + string text = sb.ToString(); - switch((LmLogLevel)Level) + switch((LmLogLevel)level) { - case LmLogLevel.Trace: Logger.PrintDebug (LogClass.ServiceLm, Text); break; - case LmLogLevel.Info: Logger.PrintInfo (LogClass.ServiceLm, Text); break; - case LmLogLevel.Warning: Logger.PrintWarning(LogClass.ServiceLm, Text); break; - case LmLogLevel.Error: Logger.PrintError (LogClass.ServiceLm, Text); break; - case LmLogLevel.Critical: Logger.PrintError (LogClass.ServiceLm, Text); break; + case LmLogLevel.Trace: Logger.PrintDebug (LogClass.ServiceLm, text); break; + case LmLogLevel.Info: Logger.PrintInfo (LogClass.ServiceLm, text); break; + case LmLogLevel.Warning: Logger.PrintWarning(LogClass.ServiceLm, text); break; + case LmLogLevel.Error: Logger.PrintError (LogClass.ServiceLm, text); break; + case LmLogLevel.Critical: Logger.PrintError (LogClass.ServiceLm, text); break; } } diff --git a/Ryujinx.HLE/HOS/Services/Lr/ILocationResolver.cs b/Ryujinx.HLE/HOS/Services/Lr/ILocationResolver.cs index dc057bc1..6c2f1970 100644 --- a/Ryujinx.HLE/HOS/Services/Lr/ILocationResolver.cs +++ b/Ryujinx.HLE/HOS/Services/Lr/ILocationResolver.cs @@ -12,15 +12,15 @@ namespace Ryujinx.HLE.HOS.Services.Lr { class ILocationResolver : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private StorageId StorageId; + private StorageId _storageId; - public ILocationResolver(StorageId StorageId) + public ILocationResolver(StorageId storageId) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, ResolveProgramPath }, { 1, RedirectProgramPath }, @@ -40,103 +40,103 @@ namespace Ryujinx.HLE.HOS.Services.Lr { 15, DeleteInfoHtmlNcaPath } }; - this.StorageId = StorageId; + _storageId = storageId; } // DeleteInfoHtmlNcaPath() - public long DeleteInfoHtmlNcaPath(ServiceCtx Context) + public long DeleteInfoHtmlNcaPath(ServiceCtx context) { - long TitleId = Context.RequestData.ReadInt64(); + long titleId = context.RequestData.ReadInt64(); - DeleteContentPath(Context, TitleId, ContentType.Manual); + DeleteContentPath(context, titleId, ContentType.Manual); return 0; } // DeleteDocHtmlNcaPath() - public long DeleteDocHtmlNcaPath(ServiceCtx Context) + public long DeleteDocHtmlNcaPath(ServiceCtx context) { - long TitleId = Context.RequestData.ReadInt64(); + long titleId = context.RequestData.ReadInt64(); - DeleteContentPath(Context, TitleId, ContentType.Manual); + DeleteContentPath(context, titleId, ContentType.Manual); return 0; } // DeleteControlNcaPath() - public long DeleteControlNcaPath(ServiceCtx Context) + public long DeleteControlNcaPath(ServiceCtx context) { - long TitleId = Context.RequestData.ReadInt64(); + long titleId = context.RequestData.ReadInt64(); - DeleteContentPath(Context, TitleId, ContentType.Control); + DeleteContentPath(context, titleId, ContentType.Control); return 0; } // DeleteProgramNcaPath() - public long DeleteProgramNcaPath(ServiceCtx Context) + public long DeleteProgramNcaPath(ServiceCtx context) { - long TitleId = Context.RequestData.ReadInt64(); + long titleId = context.RequestData.ReadInt64(); - DeleteContentPath(Context, TitleId, ContentType.Program); + DeleteContentPath(context, titleId, ContentType.Program); return 0; } // ClearLocationResolver2() - public long ClearLocationResolver2(ServiceCtx Context) + public long ClearLocationResolver2(ServiceCtx context) { - Context.Device.System.ContentManager.RefreshEntries(StorageId, 1); + context.Device.System.ContentManager.RefreshEntries(_storageId, 1); return 0; } // SetProgramNcaPath2() - public long SetProgramNcaPath2(ServiceCtx Context) + public long SetProgramNcaPath2(ServiceCtx context) { - long TitleId = Context.RequestData.ReadInt64(); + long titleId = context.RequestData.ReadInt64(); - RedirectPath(Context, TitleId, 1, ContentType.Program); + RedirectPath(context, titleId, 1, ContentType.Program); return 0; } // RedirectApplicationControlPath() - public long RedirectApplicationControlPath(ServiceCtx Context) + public long RedirectApplicationControlPath(ServiceCtx context) { - long TitleId = Context.RequestData.ReadInt64(); + long titleId = context.RequestData.ReadInt64(); - RedirectPath(Context, TitleId, 1, ContentType.Control); + RedirectPath(context, titleId, 1, ContentType.Control); return 0; } // RedirectApplicationHtmlDocumentPath() - public long RedirectApplicationHtmlDocumentPath(ServiceCtx Context) + public long RedirectApplicationHtmlDocumentPath(ServiceCtx context) { - long TitleId = Context.RequestData.ReadInt64(); + long titleId = context.RequestData.ReadInt64(); - RedirectPath(Context, TitleId, 1, ContentType.Manual); + RedirectPath(context, titleId, 1, ContentType.Manual); return 0; } // RedirectApplicationLegalInformationPath() - public long RedirectApplicationLegalInformationPath(ServiceCtx Context) + public long RedirectApplicationLegalInformationPath(ServiceCtx context) { - long TitleId = Context.RequestData.ReadInt64(); + long titleId = context.RequestData.ReadInt64(); - RedirectPath(Context, TitleId, 1, ContentType.Manual); + RedirectPath(context, titleId, 1, ContentType.Manual); return 0; } // ResolveDataPath() - public long ResolveDataPath(ServiceCtx Context) + public long ResolveDataPath(ServiceCtx context) { - long TitleId = Context.RequestData.ReadInt64(); + long titleId = context.RequestData.ReadInt64(); - if (ResolvePath(Context, TitleId, ContentType.Data) || ResolvePath(Context, TitleId, ContentType.AocData)) + if (ResolvePath(context, titleId, ContentType.Data) || ResolvePath(context, titleId, ContentType.AocData)) { return 0; } @@ -147,11 +147,11 @@ namespace Ryujinx.HLE.HOS.Services.Lr } // ResolveApplicationHtmlDocumentPath() - public long ResolveApplicationHtmlDocumentPath(ServiceCtx Context) + public long ResolveApplicationHtmlDocumentPath(ServiceCtx context) { - long TitleId = Context.RequestData.ReadInt64(); + long titleId = context.RequestData.ReadInt64(); - if (ResolvePath(Context, TitleId, ContentType.Manual)) + if (ResolvePath(context, titleId, ContentType.Manual)) { return 0; } @@ -162,11 +162,11 @@ namespace Ryujinx.HLE.HOS.Services.Lr } // ResolveApplicationLegalInformationPath() - public long ResolveApplicationLegalInformationPath(ServiceCtx Context) + public long ResolveApplicationLegalInformationPath(ServiceCtx context) { - long TitleId = Context.RequestData.ReadInt64(); + long titleId = context.RequestData.ReadInt64(); - if (ResolvePath(Context, TitleId, ContentType.Manual)) + if (ResolvePath(context, titleId, ContentType.Manual)) { return 0; } @@ -177,11 +177,11 @@ namespace Ryujinx.HLE.HOS.Services.Lr } // ResolveApplicationControlPath() - public long ResolveApplicationControlPath(ServiceCtx Context) + public long ResolveApplicationControlPath(ServiceCtx context) { - long TitleId = Context.RequestData.ReadInt64(); + long titleId = context.RequestData.ReadInt64(); - if (ResolvePath(Context, TitleId, ContentType.Control)) + if (ResolvePath(context, titleId, ContentType.Control)) { return 0; } @@ -192,29 +192,29 @@ namespace Ryujinx.HLE.HOS.Services.Lr } // RedirectProgramPath() - public long RedirectProgramPath(ServiceCtx Context) + public long RedirectProgramPath(ServiceCtx context) { - long TitleId = Context.RequestData.ReadInt64(); + long titleId = context.RequestData.ReadInt64(); - RedirectPath(Context, TitleId, 0, ContentType.Program); + RedirectPath(context, titleId, 0, ContentType.Program); return 0; } // Refresh() - public long Refresh(ServiceCtx Context) + public long Refresh(ServiceCtx context) { - Context.Device.System.ContentManager.RefreshEntries(StorageId, 1); + context.Device.System.ContentManager.RefreshEntries(_storageId, 1); return 0; } // ResolveProgramPath() - public long ResolveProgramPath(ServiceCtx Context) + public long ResolveProgramPath(ServiceCtx context) { - long TitleId = Context.RequestData.ReadInt64(); + long titleId = context.RequestData.ReadInt64(); - if (ResolvePath(Context, TitleId, ContentType.Program)) + if (ResolvePath(context, titleId, ContentType.Program)) { return 0; } @@ -224,27 +224,27 @@ namespace Ryujinx.HLE.HOS.Services.Lr } } - private void RedirectPath(ServiceCtx Context, long TitleId, int Flag, ContentType ContentType) + private void RedirectPath(ServiceCtx context, long titleId, int flag, ContentType contentType) { - string ContentPath = ReadUtf8String(Context); - LocationEntry NewLocation = new LocationEntry(ContentPath, Flag, TitleId, ContentType); + string contentPath = ReadUtf8String(context); + LocationEntry newLocation = new LocationEntry(contentPath, flag, titleId, contentType); - Context.Device.System.ContentManager.RedirectLocation(NewLocation, StorageId); + context.Device.System.ContentManager.RedirectLocation(newLocation, _storageId); } - private bool ResolvePath(ServiceCtx Context, long TitleId,ContentType ContentType) + private bool ResolvePath(ServiceCtx context, long titleId,ContentType contentType) { - ContentManager ContentManager = Context.Device.System.ContentManager; - string ContentPath = ContentManager.GetInstalledContentPath(TitleId, StorageId, ContentType.Program); + ContentManager contentManager = context.Device.System.ContentManager; + string contentPath = contentManager.GetInstalledContentPath(titleId, _storageId, ContentType.Program); - if (!string.IsNullOrWhiteSpace(ContentPath)) + if (!string.IsNullOrWhiteSpace(contentPath)) { - long Position = Context.Request.RecvListBuff[0].Position; - long Size = Context.Request.RecvListBuff[0].Size; + long position = context.Request.RecvListBuff[0].Position; + long size = context.Request.RecvListBuff[0].Size; - byte[] ContentPathBuffer = Encoding.UTF8.GetBytes(ContentPath); + byte[] contentPathBuffer = Encoding.UTF8.GetBytes(contentPath); - Context.Memory.WriteBytes(Position, ContentPathBuffer); + context.Memory.WriteBytes(position, contentPathBuffer); } else { @@ -254,12 +254,12 @@ namespace Ryujinx.HLE.HOS.Services.Lr return true; } - private void DeleteContentPath(ServiceCtx Context, long TitleId, ContentType ContentType) + private void DeleteContentPath(ServiceCtx context, long titleId, ContentType contentType) { - ContentManager ContentManager = Context.Device.System.ContentManager; - string ContentPath = ContentManager.GetInstalledContentPath(TitleId, StorageId, ContentType.Manual); + ContentManager contentManager = context.Device.System.ContentManager; + string contentPath = contentManager.GetInstalledContentPath(titleId, _storageId, ContentType.Manual); - ContentManager.ClearEntry(TitleId, ContentType.Manual, StorageId); + contentManager.ClearEntry(titleId, ContentType.Manual, _storageId); } } } diff --git a/Ryujinx.HLE/HOS/Services/Lr/ILocationResolverManager.cs b/Ryujinx.HLE/HOS/Services/Lr/ILocationResolverManager.cs index 77710f76..4b2de6b3 100644 --- a/Ryujinx.HLE/HOS/Services/Lr/ILocationResolverManager.cs +++ b/Ryujinx.HLE/HOS/Services/Lr/ILocationResolverManager.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using Ryujinx.HLE.HOS.Ipc; using Ryujinx.HLE.FileSystem; @@ -7,24 +6,24 @@ namespace Ryujinx.HLE.HOS.Services.Lr { class ILocationResolverManager : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public ILocationResolverManager() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { - { 0, OpenLocationResolver }, + { 0, OpenLocationResolver } }; } // OpenLocationResolver() - private long OpenLocationResolver(ServiceCtx Context) + private long OpenLocationResolver(ServiceCtx context) { - StorageId StorageId = (StorageId)Context.RequestData.ReadByte(); + StorageId storageId = (StorageId)context.RequestData.ReadByte(); - MakeObject(Context, new ILocationResolver(StorageId)); + MakeObject(context, new ILocationResolver(storageId)); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Mm/IRequest.cs b/Ryujinx.HLE/HOS/Services/Mm/IRequest.cs index 72067d71..a92106cf 100644 --- a/Ryujinx.HLE/HOS/Services/Mm/IRequest.cs +++ b/Ryujinx.HLE/HOS/Services/Mm/IRequest.cs @@ -6,13 +6,13 @@ namespace Ryujinx.HLE.HOS.Services.Mm { class IRequest : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IRequest() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 1, InitializeOld }, { 4, Initialize }, @@ -23,43 +23,43 @@ namespace Ryujinx.HLE.HOS.Services.Mm } // InitializeOld(u32, u32, u32) - public long InitializeOld(ServiceCtx Context) + public long InitializeOld(ServiceCtx context) { - int Unknown0 = Context.RequestData.ReadInt32(); - int Unknown1 = Context.RequestData.ReadInt32(); - int Unknown2 = Context.RequestData.ReadInt32(); + int unknown0 = context.RequestData.ReadInt32(); + int unknown1 = context.RequestData.ReadInt32(); + int unknown2 = context.RequestData.ReadInt32(); Logger.PrintStub(LogClass.ServiceMm, "Stubbed."); return 0; } - public long Initialize(ServiceCtx Context) + public long Initialize(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceMm, "Stubbed."); return 0; } - public long Finalize(ServiceCtx Context) + public long Finalize(ServiceCtx context) { - Context.Device.Gpu.UninitializeVideoDecoder(); + context.Device.Gpu.UninitializeVideoDecoder(); Logger.PrintStub(LogClass.ServiceMm, "Stubbed."); return 0; } - public long SetAndWait(ServiceCtx Context) + public long SetAndWait(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceMm, "Stubbed."); return 0; } - public long Get(ServiceCtx Context) + public long Get(ServiceCtx context) { - Context.ResponseData.Write(0); + context.ResponseData.Write(0); Logger.PrintStub(LogClass.ServiceMm, "Stubbed."); diff --git a/Ryujinx.HLE/HOS/Services/Ncm/IContentManager.cs b/Ryujinx.HLE/HOS/Services/Ncm/IContentManager.cs index 29792a1b..bd92a450 100644 --- a/Ryujinx.HLE/HOS/Services/Ncm/IContentManager.cs +++ b/Ryujinx.HLE/HOS/Services/Ncm/IContentManager.cs @@ -5,13 +5,13 @@ namespace Ryujinx.HLE.HOS.Services.Ncm { class IContentManager : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IContentManager() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { }; diff --git a/Ryujinx.HLE/HOS/Services/Ncm/IContentStorage.cs b/Ryujinx.HLE/HOS/Services/Ncm/IContentStorage.cs index a19fe079..7134bb4c 100644 --- a/Ryujinx.HLE/HOS/Services/Ncm/IContentStorage.cs +++ b/Ryujinx.HLE/HOS/Services/Ncm/IContentStorage.cs @@ -5,13 +5,13 @@ namespace Ryujinx.HLE.HOS.Services.Ncm { class IContentStorage : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IContentStorage() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { }; diff --git a/Ryujinx.HLE/HOS/Services/Nfp/IUser.cs b/Ryujinx.HLE/HOS/Services/Nfp/IUser.cs index f0dc825b..9e19e77f 100644 --- a/Ryujinx.HLE/HOS/Services/Nfp/IUser.cs +++ b/Ryujinx.HLE/HOS/Services/Nfp/IUser.cs @@ -9,25 +9,25 @@ namespace Ryujinx.HLE.HOS.Services.Nfp { class IUser : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private const HidControllerId NpadId = HidControllerId.CONTROLLER_PLAYER_1; + private const HidControllerId NpadId = HidControllerId.ControllerPlayer1; - private State State = State.NonInitialized; + private State _state = State.NonInitialized; - private DeviceState DeviceState = DeviceState.Initialized; + private DeviceState _deviceState = DeviceState.Initialized; - private KEvent ActivateEvent; + private KEvent _activateEvent; - private KEvent DeactivateEvent; + private KEvent _deactivateEvent; - private KEvent AvailabilityChangeEvent; + private KEvent _availabilityChangeEvent; - public IUser(Horizon System) + public IUser(Horizon system) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, Initialize }, { 17, AttachActivateEvent }, @@ -38,85 +38,85 @@ namespace Ryujinx.HLE.HOS.Services.Nfp { 23, AttachAvailabilityChangeEvent } }; - ActivateEvent = new KEvent(System); - DeactivateEvent = new KEvent(System); - AvailabilityChangeEvent = new KEvent(System); + _activateEvent = new KEvent(system); + _deactivateEvent = new KEvent(system); + _availabilityChangeEvent = new KEvent(system); } - public long Initialize(ServiceCtx Context) + public long Initialize(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceNfp, "Stubbed."); - State = State.Initialized; + _state = State.Initialized; return 0; } - public long AttachActivateEvent(ServiceCtx Context) + public long AttachActivateEvent(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceNfp, "Stubbed."); - if (Context.Process.HandleTable.GenerateHandle(ActivateEvent.ReadableEvent, out int Handle) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(_activateEvent.ReadableEvent, out int handle) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);; + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle); return 0; } - public long AttachDeactivateEvent(ServiceCtx Context) + public long AttachDeactivateEvent(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceNfp, "Stubbed."); - if (Context.Process.HandleTable.GenerateHandle(DeactivateEvent.ReadableEvent, out int Handle) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(_deactivateEvent.ReadableEvent, out int handle) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle); return 0; } - public long GetState(ServiceCtx Context) + public long GetState(ServiceCtx context) { - Context.ResponseData.Write((int)State); + context.ResponseData.Write((int)_state); Logger.PrintStub(LogClass.ServiceNfp, "Stubbed."); return 0; } - public long GetDeviceState(ServiceCtx Context) + public long GetDeviceState(ServiceCtx context) { - Context.ResponseData.Write((int)DeviceState); + context.ResponseData.Write((int)_deviceState); Logger.PrintStub(LogClass.ServiceNfp, "Stubbed."); return 0; } - public long GetNpadId(ServiceCtx Context) + public long GetNpadId(ServiceCtx context) { - Context.ResponseData.Write((int)NpadId); + context.ResponseData.Write((int)NpadId); Logger.PrintStub(LogClass.ServiceNfp, "Stubbed."); return 0; } - public long AttachAvailabilityChangeEvent(ServiceCtx Context) + public long AttachAvailabilityChangeEvent(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceNfp, "Stubbed."); - if (Context.Process.HandleTable.GenerateHandle(AvailabilityChangeEvent.ReadableEvent, out int Handle) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(_availabilityChangeEvent.ReadableEvent, out int handle) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Nfp/IUserManager.cs b/Ryujinx.HLE/HOS/Services/Nfp/IUserManager.cs index e5d5a4f1..1bf93746 100644 --- a/Ryujinx.HLE/HOS/Services/Nfp/IUserManager.cs +++ b/Ryujinx.HLE/HOS/Services/Nfp/IUserManager.cs @@ -5,21 +5,21 @@ namespace Ryujinx.HLE.HOS.Services.Nfp { class IUserManager : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IUserManager() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, GetUserInterface } }; } - public long GetUserInterface(ServiceCtx Context) + public long GetUserInterface(ServiceCtx context) { - MakeObject(Context, new IUser(Context.Device.System)); + MakeObject(context, new IUser(context.Device.System)); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Nifm/IGeneralService.cs b/Ryujinx.HLE/HOS/Services/Nifm/IGeneralService.cs index bc23ea91..4b87c2c7 100644 --- a/Ryujinx.HLE/HOS/Services/Nifm/IGeneralService.cs +++ b/Ryujinx.HLE/HOS/Services/Nifm/IGeneralService.cs @@ -13,44 +13,44 @@ namespace Ryujinx.HLE.HOS.Services.Nifm { class IGeneralService : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IGeneralService() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 4, CreateRequest }, { 12, GetCurrentIpAddress } }; } - public long CreateRequest(ServiceCtx Context) + public long CreateRequest(ServiceCtx context) { - int Unknown = Context.RequestData.ReadInt32(); + int unknown = context.RequestData.ReadInt32(); - MakeObject(Context, new IRequest(Context.Device.System)); + MakeObject(context, new IRequest(context.Device.System)); Logger.PrintStub(LogClass.ServiceNifm, "Stubbed."); return 0; } - public long GetCurrentIpAddress(ServiceCtx Context) + public long GetCurrentIpAddress(ServiceCtx context) { if (!NetworkInterface.GetIsNetworkAvailable()) { return MakeError(ErrorModule.Nifm, NifmErr.NoInternetConnection); } - IPHostEntry Host = Dns.GetHostEntry(Dns.GetHostName()); + IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName()); - IPAddress Address = Host.AddressList.FirstOrDefault(A => A.AddressFamily == AddressFamily.InterNetwork); + IPAddress address = host.AddressList.FirstOrDefault(a => a.AddressFamily == AddressFamily.InterNetwork); - Context.ResponseData.Write(BitConverter.ToUInt32(Address.GetAddressBytes())); + context.ResponseData.Write(BitConverter.ToUInt32(address.GetAddressBytes())); - Logger.PrintInfo(LogClass.ServiceNifm, $"Console's local IP is \"{Address}\"."); + Logger.PrintInfo(LogClass.ServiceNifm, $"Console's local IP is \"{address}\"."); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Nifm/IRequest.cs b/Ryujinx.HLE/HOS/Services/Nifm/IRequest.cs index 98327860..52adce9e 100644 --- a/Ryujinx.HLE/HOS/Services/Nifm/IRequest.cs +++ b/Ryujinx.HLE/HOS/Services/Nifm/IRequest.cs @@ -8,16 +8,16 @@ namespace Ryujinx.HLE.HOS.Services.Nifm { class IRequest : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private KEvent Event0; - private KEvent Event1; + private KEvent _event0; + private KEvent _event1; - public IRequest(Horizon System) + public IRequest(Horizon system) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, GetRequestState }, { 1, GetResult }, @@ -27,58 +27,58 @@ namespace Ryujinx.HLE.HOS.Services.Nifm { 11, SetConnectionConfirmationOption } }; - Event0 = new KEvent(System); - Event1 = new KEvent(System); + _event0 = new KEvent(system); + _event1 = new KEvent(system); } - public long GetRequestState(ServiceCtx Context) + public long GetRequestState(ServiceCtx context) { - Context.ResponseData.Write(1); + context.ResponseData.Write(1); Logger.PrintStub(LogClass.ServiceNifm, "Stubbed."); return 0; } - public long GetResult(ServiceCtx Context) + public long GetResult(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceNifm, "Stubbed."); return 0; } - public long GetSystemEventReadableHandles(ServiceCtx Context) + public long GetSystemEventReadableHandles(ServiceCtx context) { - if (Context.Process.HandleTable.GenerateHandle(Event0.ReadableEvent, out int Handle0) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(_event0.ReadableEvent, out int handle0) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } - if (Context.Process.HandleTable.GenerateHandle(Event1.ReadableEvent, out int Handle1) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(_event1.ReadableEvent, out int handle1) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle0, Handle1); + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle0, handle1); return 0; } - public long Cancel(ServiceCtx Context) + public long Cancel(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceNifm, "Stubbed."); return 0; } - public long Submit(ServiceCtx Context) + public long Submit(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceNifm, "Stubbed."); return 0; } - public long SetConnectionConfirmationOption(ServiceCtx Context) + public long SetConnectionConfirmationOption(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceNifm, "Stubbed."); diff --git a/Ryujinx.HLE/HOS/Services/Nifm/IStaticService.cs b/Ryujinx.HLE/HOS/Services/Nifm/IStaticService.cs index 19e7d247..42d9c78e 100644 --- a/Ryujinx.HLE/HOS/Services/Nifm/IStaticService.cs +++ b/Ryujinx.HLE/HOS/Services/Nifm/IStaticService.cs @@ -5,29 +5,29 @@ namespace Ryujinx.HLE.HOS.Services.Nifm { class IStaticService : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IStaticService() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 4, CreateGeneralServiceOld }, { 5, CreateGeneralService } }; } - public long CreateGeneralServiceOld(ServiceCtx Context) + public long CreateGeneralServiceOld(ServiceCtx context) { - MakeObject(Context, new IGeneralService()); + MakeObject(context, new IGeneralService()); return 0; } - public long CreateGeneralService(ServiceCtx Context) + public long CreateGeneralService(ServiceCtx context) { - MakeObject(Context, new IGeneralService()); + MakeObject(context, new IGeneralService()); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Ns/IAddOnContentManager.cs b/Ryujinx.HLE/HOS/Services/Ns/IAddOnContentManager.cs index 82fce6b9..8bbd0dea 100644 --- a/Ryujinx.HLE/HOS/Services/Ns/IAddOnContentManager.cs +++ b/Ryujinx.HLE/HOS/Services/Ns/IAddOnContentManager.cs @@ -6,35 +6,35 @@ namespace Ryujinx.HLE.HOS.Services.Ns { class IAddOnContentManager : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IAddOnContentManager() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 2, CountAddOnContent }, { 3, ListAddOnContent } }; } - public static long CountAddOnContent(ServiceCtx Context) + public static long CountAddOnContent(ServiceCtx context) { - Context.ResponseData.Write(0); + context.ResponseData.Write(0); Logger.PrintStub(LogClass.ServiceNs, "Stubbed."); return 0; } - public static long ListAddOnContent(ServiceCtx Context) + public static long ListAddOnContent(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceNs, "Stubbed."); //TODO: This is supposed to write a u32 array aswell. //It's unknown what it contains. - Context.ResponseData.Write(0); + context.ResponseData.Write(0); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Ns/IApplicationManagerInterface.cs b/Ryujinx.HLE/HOS/Services/Ns/IApplicationManagerInterface.cs index ee438d99..72d7787f 100644 --- a/Ryujinx.HLE/HOS/Services/Ns/IApplicationManagerInterface.cs +++ b/Ryujinx.HLE/HOS/Services/Ns/IApplicationManagerInterface.cs @@ -1,20 +1,19 @@ using Ryujinx.HLE.HOS.Ipc; -using Ryujinx.HLE.HOS.Kernel; using System.Collections.Generic; namespace Ryujinx.HLE.HOS.Services.Ns { class IApplicationManagerInterface : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private bool IsInitialized; + private bool _isInitialized; public IApplicationManagerInterface() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { }; diff --git a/Ryujinx.HLE/HOS/Services/Ns/IServiceGetterInterface.cs b/Ryujinx.HLE/HOS/Services/Ns/IServiceGetterInterface.cs index a27cfe60..12f7b69b 100644 --- a/Ryujinx.HLE/HOS/Services/Ns/IServiceGetterInterface.cs +++ b/Ryujinx.HLE/HOS/Services/Ns/IServiceGetterInterface.cs @@ -5,13 +5,13 @@ namespace Ryujinx.HLE.HOS.Services.Ns { class IServiceGetterInterface : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IServiceGetterInterface() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { //... }; diff --git a/Ryujinx.HLE/HOS/Services/Ns/ISystemUpdateInterface.cs b/Ryujinx.HLE/HOS/Services/Ns/ISystemUpdateInterface.cs index 6ade8865..1b898561 100644 --- a/Ryujinx.HLE/HOS/Services/Ns/ISystemUpdateInterface.cs +++ b/Ryujinx.HLE/HOS/Services/Ns/ISystemUpdateInterface.cs @@ -5,13 +5,13 @@ namespace Ryujinx.HLE.HOS.Services.Ns { class ISystemUpdateInterface : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public ISystemUpdateInterface() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { //... }; diff --git a/Ryujinx.HLE/HOS/Services/Ns/IVulnerabilityManagerInterface.cs b/Ryujinx.HLE/HOS/Services/Ns/IVulnerabilityManagerInterface.cs index cff334c0..922703ec 100644 --- a/Ryujinx.HLE/HOS/Services/Ns/IVulnerabilityManagerInterface.cs +++ b/Ryujinx.HLE/HOS/Services/Ns/IVulnerabilityManagerInterface.cs @@ -5,13 +5,13 @@ namespace Ryujinx.HLE.HOS.Services.Ns { class IVulnerabilityManagerInterface : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IVulnerabilityManagerInterface() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { //... }; diff --git a/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs b/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs index 1b034bfa..a8459cf4 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs @@ -14,15 +14,15 @@ namespace Ryujinx.HLE.HOS.Services.Nv { class INvDrvServices : IpcService { - private delegate int IoctlProcessor(ServiceCtx Context, int Cmd); + private delegate int IoctlProcessor(ServiceCtx context, int cmd); - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private static Dictionary<string, IoctlProcessor> IoctlProcessors = - new Dictionary<string, IoctlProcessor>() - { + private static Dictionary<string, IoctlProcessor> _ioctlProcessors = + new Dictionary<string, IoctlProcessor> + { { "/dev/nvhost-as-gpu", ProcessIoctlNvGpuAS }, { "/dev/nvhost-ctrl", ProcessIoctlNvHostCtrl }, { "/dev/nvhost-ctrl-gpu", ProcessIoctlNvGpuGpu }, @@ -32,13 +32,13 @@ namespace Ryujinx.HLE.HOS.Services.Nv { "/dev/nvmap", ProcessIoctlNvMap } }; - public static GlobalStateTable Fds { get; private set; } + public static GlobalStateTable Fds { get; } - private KEvent Event; + private KEvent _event; - public INvDrvServices(Horizon System) + public INvDrvServices(Horizon system) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, Open }, { 1, Ioctl }, @@ -50,7 +50,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv { 13, FinishInitialize } }; - Event = new KEvent(System); + _event = new KEvent(system); } static INvDrvServices() @@ -58,166 +58,166 @@ namespace Ryujinx.HLE.HOS.Services.Nv Fds = new GlobalStateTable(); } - public long Open(ServiceCtx Context) + public long Open(ServiceCtx context) { - long NamePtr = Context.Request.SendBuff[0].Position; + long namePtr = context.Request.SendBuff[0].Position; - string Name = MemoryHelper.ReadAsciiString(Context.Memory, NamePtr); + string name = MemoryHelper.ReadAsciiString(context.Memory, namePtr); - int Fd = Fds.Add(Context.Process, new NvFd(Name)); + int fd = Fds.Add(context.Process, new NvFd(name)); - Context.ResponseData.Write(Fd); - Context.ResponseData.Write(0); + context.ResponseData.Write(fd); + context.ResponseData.Write(0); return 0; } - public long Ioctl(ServiceCtx Context) + public long Ioctl(ServiceCtx context) { - int Fd = Context.RequestData.ReadInt32(); - int Cmd = Context.RequestData.ReadInt32(); + int fd = context.RequestData.ReadInt32(); + int cmd = context.RequestData.ReadInt32(); - NvFd FdData = Fds.GetData<NvFd>(Context.Process, Fd); + NvFd fdData = Fds.GetData<NvFd>(context.Process, fd); - int Result; + int result; - if (IoctlProcessors.TryGetValue(FdData.Name, out IoctlProcessor Process)) + if (_ioctlProcessors.TryGetValue(fdData.Name, out IoctlProcessor process)) { - Result = Process(Context, Cmd); + result = process(context, cmd); } else { - throw new NotImplementedException($"{FdData.Name} {Cmd:x4}"); + throw new NotImplementedException($"{fdData.Name} {cmd:x4}"); } //TODO: Verify if the error codes needs to be translated. - Context.ResponseData.Write(Result); + context.ResponseData.Write(result); return 0; } - public long Close(ServiceCtx Context) + public long Close(ServiceCtx context) { - int Fd = Context.RequestData.ReadInt32(); + int fd = context.RequestData.ReadInt32(); - Fds.Delete(Context.Process, Fd); + Fds.Delete(context.Process, fd); - Context.ResponseData.Write(0); + context.ResponseData.Write(0); return 0; } - public long Initialize(ServiceCtx Context) + public long Initialize(ServiceCtx context) { - long TransferMemSize = Context.RequestData.ReadInt64(); - int TransferMemHandle = Context.Request.HandleDesc.ToCopy[0]; + long transferMemSize = context.RequestData.ReadInt64(); + int transferMemHandle = context.Request.HandleDesc.ToCopy[0]; - NvMapIoctl.InitializeNvMap(Context); + NvMapIoctl.InitializeNvMap(context); - Context.ResponseData.Write(0); + context.ResponseData.Write(0); return 0; } - public long QueryEvent(ServiceCtx Context) + public long QueryEvent(ServiceCtx context) { - int Fd = Context.RequestData.ReadInt32(); - int EventId = Context.RequestData.ReadInt32(); + int fd = context.RequestData.ReadInt32(); + int eventId = context.RequestData.ReadInt32(); //TODO: Use Fd/EventId, different channels have different events. - if (Context.Process.HandleTable.GenerateHandle(Event.ReadableEvent, out int Handle) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(_event.ReadableEvent, out int handle) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle); - Context.ResponseData.Write(0); + context.ResponseData.Write(0); return 0; } - public long SetClientPid(ServiceCtx Context) + public long SetClientPid(ServiceCtx context) { - long Pid = Context.RequestData.ReadInt64(); + long pid = context.RequestData.ReadInt64(); - Context.ResponseData.Write(0); + context.ResponseData.Write(0); return 0; } - public long FinishInitialize(ServiceCtx Context) + public long FinishInitialize(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceNv, "Stubbed."); return 0; } - private static int ProcessIoctlNvGpuAS(ServiceCtx Context, int Cmd) + private static int ProcessIoctlNvGpuAS(ServiceCtx context, int cmd) { - return ProcessIoctl(Context, Cmd, NvGpuASIoctl.ProcessIoctl); + return ProcessIoctl(context, cmd, NvGpuASIoctl.ProcessIoctl); } - private static int ProcessIoctlNvHostCtrl(ServiceCtx Context, int Cmd) + private static int ProcessIoctlNvHostCtrl(ServiceCtx context, int cmd) { - return ProcessIoctl(Context, Cmd, NvHostCtrlIoctl.ProcessIoctl); + return ProcessIoctl(context, cmd, NvHostCtrlIoctl.ProcessIoctl); } - private static int ProcessIoctlNvGpuGpu(ServiceCtx Context, int Cmd) + private static int ProcessIoctlNvGpuGpu(ServiceCtx context, int cmd) { - return ProcessIoctl(Context, Cmd, NvGpuGpuIoctl.ProcessIoctl); + return ProcessIoctl(context, cmd, NvGpuGpuIoctl.ProcessIoctl); } - private static int ProcessIoctlNvHostChannel(ServiceCtx Context, int Cmd) + private static int ProcessIoctlNvHostChannel(ServiceCtx context, int cmd) { - return ProcessIoctl(Context, Cmd, NvHostChannelIoctl.ProcessIoctl); + return ProcessIoctl(context, cmd, NvHostChannelIoctl.ProcessIoctl); } - private static int ProcessIoctlNvMap(ServiceCtx Context, int Cmd) + private static int ProcessIoctlNvMap(ServiceCtx context, int cmd) { - return ProcessIoctl(Context, Cmd, NvMapIoctl.ProcessIoctl); + return ProcessIoctl(context, cmd, NvMapIoctl.ProcessIoctl); } - private static int ProcessIoctl(ServiceCtx Context, int Cmd, IoctlProcessor Processor) + private static int ProcessIoctl(ServiceCtx context, int cmd, IoctlProcessor processor) { - if (CmdIn(Cmd) && Context.Request.GetBufferType0x21().Position == 0) + if (CmdIn(cmd) && context.Request.GetBufferType0x21().Position == 0) { Logger.PrintError(LogClass.ServiceNv, "Input buffer is null!"); return NvResult.InvalidInput; } - if (CmdOut(Cmd) && Context.Request.GetBufferType0x22().Position == 0) + if (CmdOut(cmd) && context.Request.GetBufferType0x22().Position == 0) { Logger.PrintError(LogClass.ServiceNv, "Output buffer is null!"); return NvResult.InvalidInput; } - return Processor(Context, Cmd); + return processor(context, cmd); } - private static bool CmdIn(int Cmd) + private static bool CmdIn(int cmd) { - return ((Cmd >> 30) & 1) != 0; + return ((cmd >> 30) & 1) != 0; } - private static bool CmdOut(int Cmd) + private static bool CmdOut(int cmd) { - return ((Cmd >> 31) & 1) != 0; + return ((cmd >> 31) & 1) != 0; } - public static void UnloadProcess(KProcess Process) + public static void UnloadProcess(KProcess process) { - Fds.DeleteProcess(Process); + Fds.DeleteProcess(process); - NvGpuASIoctl.UnloadProcess(Process); + NvGpuASIoctl.UnloadProcess(process); - NvHostChannelIoctl.UnloadProcess(Process); + NvHostChannelIoctl.UnloadProcess(process); - NvHostCtrlIoctl.UnloadProcess(Process); + NvHostCtrlIoctl.UnloadProcess(process); - NvMapIoctl.UnloadProcess(Process); + NvMapIoctl.UnloadProcess(process); } } } diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvFd.cs b/Ryujinx.HLE/HOS/Services/Nv/NvFd.cs index 96f97f41..0f7e4acd 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/NvFd.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/NvFd.cs @@ -2,11 +2,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv { class NvFd { - public string Name { get; private set; } + public string Name { get; } - public NvFd(string Name) + public NvFd(string name) { - this.Name = Name; + Name = name; } } }
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASCtx.cs b/Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASCtx.cs index 70275b2a..cd1ab7cd 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASCtx.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASCtx.cs @@ -5,73 +5,73 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvGpuAS { class NvGpuASCtx { - public NvGpuVmm Vmm { get; private set; } + public NvGpuVmm Vmm { get; } private class Range { - public ulong Start { get; private set; } - public ulong End { get; private set; } + public ulong Start { get; } + public ulong End { get; } - public Range(long Position, long Size) + public Range(long position, long size) { - Start = (ulong)Position; - End = (ulong)Size + Start; + Start = (ulong)position; + End = (ulong)size + Start; } } private class MappedMemory : Range { - public long PhysicalAddress { get; private set; } - public bool VaAllocated { get; private set; } + public long PhysicalAddress { get; } + public bool VaAllocated { get; } public MappedMemory( - long Position, - long Size, - long PhysicalAddress, - bool VaAllocated) : base(Position, Size) + long position, + long size, + long physicalAddress, + bool vaAllocated) : base(position, size) { - this.PhysicalAddress = PhysicalAddress; - this.VaAllocated = VaAllocated; + PhysicalAddress = physicalAddress; + VaAllocated = vaAllocated; } } - private SortedList<long, Range> Maps; - private SortedList<long, Range> Reservations; + private SortedList<long, Range> _maps; + private SortedList<long, Range> _reservations; - public NvGpuASCtx(ServiceCtx Context) + public NvGpuASCtx(ServiceCtx context) { - Vmm = new NvGpuVmm(Context.Memory); + Vmm = new NvGpuVmm(context.Memory); - Maps = new SortedList<long, Range>(); - Reservations = new SortedList<long, Range>(); + _maps = new SortedList<long, Range>(); + _reservations = new SortedList<long, Range>(); } - public bool ValidateFixedBuffer(long Position, long Size) + public bool ValidateFixedBuffer(long position, long size) { - long MapEnd = Position + Size; + long mapEnd = position + size; //Check if size is valid (0 is also not allowed). - if ((ulong)MapEnd <= (ulong)Position) + if ((ulong)mapEnd <= (ulong)position) { return false; } //Check if address is page aligned. - if ((Position & NvGpuVmm.PageMask) != 0) + if ((position & NvGpuVmm.PageMask) != 0) { return false; } //Check if region is reserved. - if (BinarySearch(Reservations, Position) == null) + if (BinarySearch(_reservations, position) == null) { return false; } //Check for overlap with already mapped buffers. - Range Map = BinarySearchLt(Maps, MapEnd); + Range map = BinarySearchLt(_maps, mapEnd); - if (Map != null && Map.End > (ulong)Position) + if (map != null && map.End > (ulong)position) { return false; } @@ -80,25 +80,25 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvGpuAS } public void AddMap( - long Position, - long Size, - long PhysicalAddress, - bool VaAllocated) + long position, + long size, + long physicalAddress, + bool vaAllocated) { - Maps.Add(Position, new MappedMemory(Position, Size, PhysicalAddress, VaAllocated)); + _maps.Add(position, new MappedMemory(position, size, physicalAddress, vaAllocated)); } - public bool RemoveMap(long Position, out long Size) + public bool RemoveMap(long position, out long size) { - Size = 0; + size = 0; - if (Maps.Remove(Position, out Range Value)) + if (_maps.Remove(position, out Range value)) { - MappedMemory Map = (MappedMemory)Value; + MappedMemory map = (MappedMemory)value; - if (Map.VaAllocated) + if (map.VaAllocated) { - Size = (long)(Map.End - Map.Start); + size = (long)(map.End - map.Start); } return true; @@ -107,94 +107,94 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvGpuAS return false; } - public bool TryGetMapPhysicalAddress(long Position, out long PhysicalAddress) + public bool TryGetMapPhysicalAddress(long position, out long physicalAddress) { - Range Map = BinarySearch(Maps, Position); + Range map = BinarySearch(_maps, position); - if (Map != null) + if (map != null) { - PhysicalAddress = ((MappedMemory)Map).PhysicalAddress; + physicalAddress = ((MappedMemory)map).PhysicalAddress; return true; } - PhysicalAddress = 0; + physicalAddress = 0; return false; } - public void AddReservation(long Position, long Size) + public void AddReservation(long position, long size) { - Reservations.Add(Position, new Range(Position, Size)); + _reservations.Add(position, new Range(position, size)); } - public bool RemoveReservation(long Position) + public bool RemoveReservation(long position) { - return Reservations.Remove(Position); + return _reservations.Remove(position); } - private Range BinarySearch(SortedList<long, Range> Lst, long Position) + private Range BinarySearch(SortedList<long, Range> lst, long position) { - int Left = 0; - int Right = Lst.Count - 1; + int left = 0; + int right = lst.Count - 1; - while (Left <= Right) + while (left <= right) { - int Size = Right - Left; + int size = right - left; - int Middle = Left + (Size >> 1); + int middle = left + (size >> 1); - Range Rg = Lst.Values[Middle]; + Range rg = lst.Values[middle]; - if ((ulong)Position >= Rg.Start && (ulong)Position < Rg.End) + if ((ulong)position >= rg.Start && (ulong)position < rg.End) { - return Rg; + return rg; } - if ((ulong)Position < Rg.Start) + if ((ulong)position < rg.Start) { - Right = Middle - 1; + right = middle - 1; } else { - Left = Middle + 1; + left = middle + 1; } } return null; } - private Range BinarySearchLt(SortedList<long, Range> Lst, long Position) + private Range BinarySearchLt(SortedList<long, Range> lst, long position) { - Range LtRg = null; + Range ltRg = null; - int Left = 0; - int Right = Lst.Count - 1; + int left = 0; + int right = lst.Count - 1; - while (Left <= Right) + while (left <= right) { - int Size = Right - Left; + int size = right - left; - int Middle = Left + (Size >> 1); + int middle = left + (size >> 1); - Range Rg = Lst.Values[Middle]; + Range rg = lst.Values[middle]; - if ((ulong)Position < Rg.Start) + if ((ulong)position < rg.Start) { - Right = Middle - 1; + right = middle - 1; } else { - Left = Middle + 1; + left = middle + 1; - if ((ulong)Position > Rg.Start) + if ((ulong)position > rg.Start) { - LtRg = Rg; + ltRg = rg; } } } - return LtRg; + return ltRg; } } }
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASIoctl.cs b/Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASIoctl.cs index 7fe3bbed..8e128a0d 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASIoctl.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASIoctl.cs @@ -14,182 +14,182 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvGpuAS private const int FlagRemapSubRange = 0x100; - private static ConcurrentDictionary<KProcess, NvGpuASCtx> ASCtxs; + private static ConcurrentDictionary<KProcess, NvGpuASCtx> _asCtxs; static NvGpuASIoctl() { - ASCtxs = new ConcurrentDictionary<KProcess, NvGpuASCtx>(); + _asCtxs = new ConcurrentDictionary<KProcess, NvGpuASCtx>(); } - public static int ProcessIoctl(ServiceCtx Context, int Cmd) + public static int ProcessIoctl(ServiceCtx context, int cmd) { - switch (Cmd & 0xffff) + switch (cmd & 0xffff) { - case 0x4101: return BindChannel (Context); - case 0x4102: return AllocSpace (Context); - case 0x4103: return FreeSpace (Context); - case 0x4105: return UnmapBuffer (Context); - case 0x4106: return MapBufferEx (Context); - case 0x4108: return GetVaRegions(Context); - case 0x4109: return InitializeEx(Context); - case 0x4114: return Remap (Context, Cmd); + case 0x4101: return BindChannel (context); + case 0x4102: return AllocSpace (context); + case 0x4103: return FreeSpace (context); + case 0x4105: return UnmapBuffer (context); + case 0x4106: return MapBufferEx (context); + case 0x4108: return GetVaRegions(context); + case 0x4109: return InitializeEx(context); + case 0x4114: return Remap (context, cmd); } - throw new NotImplementedException(Cmd.ToString("x8")); + throw new NotImplementedException(cmd.ToString("x8")); } - private static int BindChannel(ServiceCtx Context) + private static int BindChannel(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; Logger.PrintStub(LogClass.ServiceNv, "Stubbed."); return NvResult.Success; } - private static int AllocSpace(ServiceCtx Context) + private static int AllocSpace(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - NvGpuASAllocSpace Args = MemoryHelper.Read<NvGpuASAllocSpace>(Context.Memory, InputPosition); + NvGpuASAllocSpace args = MemoryHelper.Read<NvGpuASAllocSpace>(context.Memory, inputPosition); - NvGpuASCtx ASCtx = GetASCtx(Context); + NvGpuASCtx asCtx = GetASCtx(context); - ulong Size = (ulong)Args.Pages * - (ulong)Args.PageSize; + ulong size = (ulong)args.Pages * + (ulong)args.PageSize; - int Result = NvResult.Success; + int result = NvResult.Success; - lock (ASCtx) + lock (asCtx) { //Note: When the fixed offset flag is not set, //the Offset field holds the alignment size instead. - if ((Args.Flags & FlagFixedOffset) != 0) + if ((args.Flags & FlagFixedOffset) != 0) { - Args.Offset = ASCtx.Vmm.ReserveFixed(Args.Offset, (long)Size); + args.Offset = asCtx.Vmm.ReserveFixed(args.Offset, (long)size); } else { - Args.Offset = ASCtx.Vmm.Reserve((long)Size, Args.Offset); + args.Offset = asCtx.Vmm.Reserve((long)size, args.Offset); } - if (Args.Offset < 0) + if (args.Offset < 0) { - Args.Offset = 0; + args.Offset = 0; - Logger.PrintWarning(LogClass.ServiceNv, $"Failed to allocate size {Size:x16}!"); + Logger.PrintWarning(LogClass.ServiceNv, $"Failed to allocate size {size:x16}!"); - Result = NvResult.OutOfMemory; + result = NvResult.OutOfMemory; } else { - ASCtx.AddReservation(Args.Offset, (long)Size); + asCtx.AddReservation(args.Offset, (long)size); } } - MemoryHelper.Write(Context.Memory, OutputPosition, Args); + MemoryHelper.Write(context.Memory, outputPosition, args); - return Result; + return result; } - private static int FreeSpace(ServiceCtx Context) + private static int FreeSpace(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - NvGpuASAllocSpace Args = MemoryHelper.Read<NvGpuASAllocSpace>(Context.Memory, InputPosition); + NvGpuASAllocSpace args = MemoryHelper.Read<NvGpuASAllocSpace>(context.Memory, inputPosition); - NvGpuASCtx ASCtx = GetASCtx(Context); + NvGpuASCtx asCtx = GetASCtx(context); - int Result = NvResult.Success; + int result = NvResult.Success; - lock (ASCtx) + lock (asCtx) { - ulong Size = (ulong)Args.Pages * - (ulong)Args.PageSize; + ulong size = (ulong)args.Pages * + (ulong)args.PageSize; - if (ASCtx.RemoveReservation(Args.Offset)) + if (asCtx.RemoveReservation(args.Offset)) { - ASCtx.Vmm.Free(Args.Offset, (long)Size); + asCtx.Vmm.Free(args.Offset, (long)size); } else { Logger.PrintWarning(LogClass.ServiceNv, - $"Failed to free offset 0x{Args.Offset:x16} size 0x{Size:x16}!"); + $"Failed to free offset 0x{args.Offset:x16} size 0x{size:x16}!"); - Result = NvResult.InvalidInput; + result = NvResult.InvalidInput; } } - return Result; + return result; } - private static int UnmapBuffer(ServiceCtx Context) + private static int UnmapBuffer(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - NvGpuASUnmapBuffer Args = MemoryHelper.Read<NvGpuASUnmapBuffer>(Context.Memory, InputPosition); + NvGpuASUnmapBuffer args = MemoryHelper.Read<NvGpuASUnmapBuffer>(context.Memory, inputPosition); - NvGpuASCtx ASCtx = GetASCtx(Context); + NvGpuASCtx asCtx = GetASCtx(context); - lock (ASCtx) + lock (asCtx) { - if (ASCtx.RemoveMap(Args.Offset, out long Size)) + if (asCtx.RemoveMap(args.Offset, out long size)) { - if (Size != 0) + if (size != 0) { - ASCtx.Vmm.Free(Args.Offset, Size); + asCtx.Vmm.Free(args.Offset, size); } } else { - Logger.PrintWarning(LogClass.ServiceNv, $"Invalid buffer offset {Args.Offset:x16}!"); + Logger.PrintWarning(LogClass.ServiceNv, $"Invalid buffer offset {args.Offset:x16}!"); } } return NvResult.Success; } - private static int MapBufferEx(ServiceCtx Context) + private static int MapBufferEx(ServiceCtx context) { - const string MapErrorMsg = "Failed to map fixed buffer with offset 0x{0:x16} and size 0x{1:x16}!"; + const string mapErrorMsg = "Failed to map fixed buffer with offset 0x{0:x16} and size 0x{1:x16}!"; - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - NvGpuASMapBufferEx Args = MemoryHelper.Read<NvGpuASMapBufferEx>(Context.Memory, InputPosition); + NvGpuASMapBufferEx args = MemoryHelper.Read<NvGpuASMapBufferEx>(context.Memory, inputPosition); - NvGpuASCtx ASCtx = GetASCtx(Context); + NvGpuASCtx asCtx = GetASCtx(context); - NvMapHandle Map = NvMapIoctl.GetNvMapWithFb(Context, Args.NvMapHandle); + NvMapHandle map = NvMapIoctl.GetNvMapWithFb(context, args.NvMapHandle); - if (Map == null) + if (map == null) { - Logger.PrintWarning(LogClass.ServiceNv, $"Invalid NvMap handle 0x{Args.NvMapHandle:x8}!"); + Logger.PrintWarning(LogClass.ServiceNv, $"Invalid NvMap handle 0x{args.NvMapHandle:x8}!"); return NvResult.InvalidInput; } - long PA; + long pa; - if ((Args.Flags & FlagRemapSubRange) != 0) + if ((args.Flags & FlagRemapSubRange) != 0) { - lock (ASCtx) + lock (asCtx) { - if (ASCtx.TryGetMapPhysicalAddress(Args.Offset, out PA)) + if (asCtx.TryGetMapPhysicalAddress(args.Offset, out pa)) { - long VA = Args.Offset + Args.BufferOffset; + long va = args.Offset + args.BufferOffset; - PA += Args.BufferOffset; + pa += args.BufferOffset; - if (ASCtx.Vmm.Map(PA, VA, Args.MappingSize) < 0) + if (asCtx.Vmm.Map(pa, va, args.MappingSize) < 0) { - string Msg = string.Format(MapErrorMsg, VA, Args.MappingSize); + string msg = string.Format(mapErrorMsg, va, args.MappingSize); - Logger.PrintWarning(LogClass.ServiceNv, Msg); + Logger.PrintWarning(LogClass.ServiceNv, msg); return NvResult.InvalidInput; } @@ -198,117 +198,117 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvGpuAS } else { - Logger.PrintWarning(LogClass.ServiceNv, $"Address 0x{Args.Offset:x16} not mapped!"); + Logger.PrintWarning(LogClass.ServiceNv, $"Address 0x{args.Offset:x16} not mapped!"); return NvResult.InvalidInput; } } } - PA = Map.Address + Args.BufferOffset; + pa = map.Address + args.BufferOffset; - long Size = Args.MappingSize; + long size = args.MappingSize; - if (Size == 0) + if (size == 0) { - Size = (uint)Map.Size; + size = (uint)map.Size; } - int Result = NvResult.Success; + int result = NvResult.Success; - lock (ASCtx) + lock (asCtx) { //Note: When the fixed offset flag is not set, //the Offset field holds the alignment size instead. - bool VaAllocated = (Args.Flags & FlagFixedOffset) == 0; + bool vaAllocated = (args.Flags & FlagFixedOffset) == 0; - if (!VaAllocated) + if (!vaAllocated) { - if (ASCtx.ValidateFixedBuffer(Args.Offset, Size)) + if (asCtx.ValidateFixedBuffer(args.Offset, size)) { - Args.Offset = ASCtx.Vmm.Map(PA, Args.Offset, Size); + args.Offset = asCtx.Vmm.Map(pa, args.Offset, size); } else { - string Msg = string.Format(MapErrorMsg, Args.Offset, Size); + string msg = string.Format(mapErrorMsg, args.Offset, size); - Logger.PrintWarning(LogClass.ServiceNv, Msg); + Logger.PrintWarning(LogClass.ServiceNv, msg); - Result = NvResult.InvalidInput; + result = NvResult.InvalidInput; } } else { - Args.Offset = ASCtx.Vmm.Map(PA, Size); + args.Offset = asCtx.Vmm.Map(pa, size); } - if (Args.Offset < 0) + if (args.Offset < 0) { - Args.Offset = 0; + args.Offset = 0; - Logger.PrintWarning(LogClass.ServiceNv, $"Failed to map size 0x{Size:x16}!"); + Logger.PrintWarning(LogClass.ServiceNv, $"Failed to map size 0x{size:x16}!"); - Result = NvResult.InvalidInput; + result = NvResult.InvalidInput; } else { - ASCtx.AddMap(Args.Offset, Size, PA, VaAllocated); + asCtx.AddMap(args.Offset, size, pa, vaAllocated); } } - MemoryHelper.Write(Context.Memory, OutputPosition, Args); + MemoryHelper.Write(context.Memory, outputPosition, args); - return Result; + return result; } - private static int GetVaRegions(ServiceCtx Context) + private static int GetVaRegions(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; Logger.PrintStub(LogClass.ServiceNv, "Stubbed."); return NvResult.Success; } - private static int InitializeEx(ServiceCtx Context) + private static int InitializeEx(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; Logger.PrintStub(LogClass.ServiceNv, "Stubbed."); return NvResult.Success; } - private static int Remap(ServiceCtx Context, int Cmd) + private static int Remap(ServiceCtx context, int cmd) { - int Count = ((Cmd >> 16) & 0xff) / 0x14; + int count = ((cmd >> 16) & 0xff) / 0x14; - long InputPosition = Context.Request.GetBufferType0x21().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; - for (int Index = 0; Index < Count; Index++, InputPosition += 0x14) + for (int index = 0; index < count; index++, inputPosition += 0x14) { - NvGpuASRemap Args = MemoryHelper.Read<NvGpuASRemap>(Context.Memory, InputPosition); + NvGpuASRemap args = MemoryHelper.Read<NvGpuASRemap>(context.Memory, inputPosition); - NvGpuVmm Vmm = GetASCtx(Context).Vmm; + NvGpuVmm vmm = GetASCtx(context).Vmm; - NvMapHandle Map = NvMapIoctl.GetNvMapWithFb(Context, Args.NvMapHandle); + NvMapHandle map = NvMapIoctl.GetNvMapWithFb(context, args.NvMapHandle); - if (Map == null) + if (map == null) { - Logger.PrintWarning(LogClass.ServiceNv, $"Invalid NvMap handle 0x{Args.NvMapHandle:x8}!"); + Logger.PrintWarning(LogClass.ServiceNv, $"Invalid NvMap handle 0x{args.NvMapHandle:x8}!"); return NvResult.InvalidInput; } - long Result = Vmm.Map(Map.Address, (long)(uint)Args.Offset << 16, - (long)(uint)Args.Pages << 16); + long result = vmm.Map(map.Address, (long)(uint)args.Offset << 16, + (long)(uint)args.Pages << 16); - if (Result < 0) + if (result < 0) { Logger.PrintWarning(LogClass.ServiceNv, - $"Page 0x{Args.Offset:x16} size 0x{Args.Pages:x16} not allocated!"); + $"Page 0x{args.Offset:x16} size 0x{args.Pages:x16} not allocated!"); return NvResult.InvalidInput; } @@ -317,14 +317,14 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvGpuAS return NvResult.Success; } - public static NvGpuASCtx GetASCtx(ServiceCtx Context) + public static NvGpuASCtx GetASCtx(ServiceCtx context) { - return ASCtxs.GetOrAdd(Context.Process, (Key) => new NvGpuASCtx(Context)); + return _asCtxs.GetOrAdd(context.Process, (key) => new NvGpuASCtx(context)); } - public static void UnloadProcess(KProcess Process) + public static void UnloadProcess(KProcess process) { - ASCtxs.TryRemove(Process, out _); + _asCtxs.TryRemove(process, out _); } } }
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvGpuGpu/NvGpuGpuIoctl.cs b/Ryujinx.HLE/HOS/Services/Nv/NvGpuGpu/NvGpuGpuIoctl.cs index 7ee770f4..5680fb8e 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/NvGpuGpu/NvGpuGpuIoctl.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/NvGpuGpu/NvGpuGpuIoctl.cs @@ -7,181 +7,181 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvGpuGpu { class NvGpuGpuIoctl { - private static Stopwatch PTimer; + private static Stopwatch _pTimer; - private static double TicksToNs; + private static double _ticksToNs; static NvGpuGpuIoctl() { - PTimer = new Stopwatch(); + _pTimer = new Stopwatch(); - PTimer.Start(); + _pTimer.Start(); - TicksToNs = (1.0 / Stopwatch.Frequency) * 1_000_000_000; + _ticksToNs = (1.0 / Stopwatch.Frequency) * 1_000_000_000; } - public static int ProcessIoctl(ServiceCtx Context, int Cmd) + public static int ProcessIoctl(ServiceCtx context, int cmd) { - switch (Cmd & 0xffff) + switch (cmd & 0xffff) { - case 0x4701: return ZcullGetCtxSize (Context); - case 0x4702: return ZcullGetInfo (Context); - case 0x4703: return ZbcSetTable (Context); - case 0x4705: return GetCharacteristics(Context); - case 0x4706: return GetTpcMasks (Context); - case 0x4714: return GetActiveSlotMask (Context); - case 0x471c: return GetGpuTime (Context); + case 0x4701: return ZcullGetCtxSize (context); + case 0x4702: return ZcullGetInfo (context); + case 0x4703: return ZbcSetTable (context); + case 0x4705: return GetCharacteristics(context); + case 0x4706: return GetTpcMasks (context); + case 0x4714: return GetActiveSlotMask (context); + case 0x471c: return GetGpuTime (context); } - throw new NotImplementedException(Cmd.ToString("x8")); + throw new NotImplementedException(cmd.ToString("x8")); } - private static int ZcullGetCtxSize(ServiceCtx Context) + private static int ZcullGetCtxSize(ServiceCtx context) { - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - NvGpuGpuZcullGetCtxSize Args = new NvGpuGpuZcullGetCtxSize(); + NvGpuGpuZcullGetCtxSize args = new NvGpuGpuZcullGetCtxSize(); - Args.Size = 1; + args.Size = 1; - MemoryHelper.Write(Context.Memory, OutputPosition, Args); + MemoryHelper.Write(context.Memory, outputPosition, args); Logger.PrintStub(LogClass.ServiceNv, "Stubbed."); return NvResult.Success; } - private static int ZcullGetInfo(ServiceCtx Context) + private static int ZcullGetInfo(ServiceCtx context) { - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - NvGpuGpuZcullGetInfo Args = new NvGpuGpuZcullGetInfo(); + NvGpuGpuZcullGetInfo args = new NvGpuGpuZcullGetInfo(); - Args.WidthAlignPixels = 0x20; - Args.HeightAlignPixels = 0x20; - Args.PixelSquaresByAliquots = 0x400; - Args.AliquotTotal = 0x800; - Args.RegionByteMultiplier = 0x20; - Args.RegionHeaderSize = 0x20; - Args.SubregionHeaderSize = 0xc0; - Args.SubregionWidthAlignPixels = 0x20; - Args.SubregionHeightAlignPixels = 0x40; - Args.SubregionCount = 0x10; + args.WidthAlignPixels = 0x20; + args.HeightAlignPixels = 0x20; + args.PixelSquaresByAliquots = 0x400; + args.AliquotTotal = 0x800; + args.RegionByteMultiplier = 0x20; + args.RegionHeaderSize = 0x20; + args.SubregionHeaderSize = 0xc0; + args.SubregionWidthAlignPixels = 0x20; + args.SubregionHeightAlignPixels = 0x40; + args.SubregionCount = 0x10; - MemoryHelper.Write(Context.Memory, OutputPosition, Args); + MemoryHelper.Write(context.Memory, outputPosition, args); Logger.PrintStub(LogClass.ServiceNv, "Stubbed."); return NvResult.Success; } - private static int ZbcSetTable(ServiceCtx Context) + private static int ZbcSetTable(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; Logger.PrintStub(LogClass.ServiceNv, "Stubbed."); return NvResult.Success; } - private static int GetCharacteristics(ServiceCtx Context) + private static int GetCharacteristics(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; - - NvGpuGpuGetCharacteristics Args = MemoryHelper.Read<NvGpuGpuGetCharacteristics>(Context.Memory, InputPosition); - - Args.BufferSize = 0xa0; - - Args.Arch = 0x120; - Args.Impl = 0xb; - Args.Rev = 0xa1; - Args.NumGpc = 0x1; - Args.L2CacheSize = 0x40000; - Args.OnBoardVideoMemorySize = 0x0; - Args.NumTpcPerGpc = 0x2; - Args.BusType = 0x20; - Args.BigPageSize = 0x20000; - Args.CompressionPageSize = 0x20000; - Args.PdeCoverageBitCount = 0x1b; - Args.AvailableBigPageSizes = 0x30000; - Args.GpcMask = 0x1; - Args.SmArchSmVersion = 0x503; - Args.SmArchSpaVersion = 0x503; - Args.SmArchWarpCount = 0x80; - Args.GpuVaBitCount = 0x28; - Args.Reserved = 0x0; - Args.Flags = 0x55; - Args.TwodClass = 0x902d; - Args.ThreedClass = 0xb197; - Args.ComputeClass = 0xb1c0; - Args.GpfifoClass = 0xb06f; - Args.InlineToMemoryClass = 0xa140; - Args.DmaCopyClass = 0xb0b5; - Args.MaxFbpsCount = 0x1; - Args.FbpEnMask = 0x0; - Args.MaxLtcPerFbp = 0x2; - Args.MaxLtsPerLtc = 0x1; - Args.MaxTexPerTpc = 0x0; - Args.MaxGpcCount = 0x1; - Args.RopL2EnMask0 = 0x21d70; - Args.RopL2EnMask1 = 0x0; - Args.ChipName = 0x6230326d67; - Args.GrCompbitStoreBaseHw = 0x0; - - MemoryHelper.Write(Context.Memory, OutputPosition, Args); + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; + + NvGpuGpuGetCharacteristics args = MemoryHelper.Read<NvGpuGpuGetCharacteristics>(context.Memory, inputPosition); + + args.BufferSize = 0xa0; + + args.Arch = 0x120; + args.Impl = 0xb; + args.Rev = 0xa1; + args.NumGpc = 0x1; + args.L2CacheSize = 0x40000; + args.OnBoardVideoMemorySize = 0x0; + args.NumTpcPerGpc = 0x2; + args.BusType = 0x20; + args.BigPageSize = 0x20000; + args.CompressionPageSize = 0x20000; + args.PdeCoverageBitCount = 0x1b; + args.AvailableBigPageSizes = 0x30000; + args.GpcMask = 0x1; + args.SmArchSmVersion = 0x503; + args.SmArchSpaVersion = 0x503; + args.SmArchWarpCount = 0x80; + args.GpuVaBitCount = 0x28; + args.Reserved = 0x0; + args.Flags = 0x55; + args.TwodClass = 0x902d; + args.ThreedClass = 0xb197; + args.ComputeClass = 0xb1c0; + args.GpfifoClass = 0xb06f; + args.InlineToMemoryClass = 0xa140; + args.DmaCopyClass = 0xb0b5; + args.MaxFbpsCount = 0x1; + args.FbpEnMask = 0x0; + args.MaxLtcPerFbp = 0x2; + args.MaxLtsPerLtc = 0x1; + args.MaxTexPerTpc = 0x0; + args.MaxGpcCount = 0x1; + args.RopL2EnMask0 = 0x21d70; + args.RopL2EnMask1 = 0x0; + args.ChipName = 0x6230326d67; + args.GrCompbitStoreBaseHw = 0x0; + + MemoryHelper.Write(context.Memory, outputPosition, args); return NvResult.Success; } - private static int GetTpcMasks(ServiceCtx Context) + private static int GetTpcMasks(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - NvGpuGpuGetTpcMasks Args = MemoryHelper.Read<NvGpuGpuGetTpcMasks>(Context.Memory, InputPosition); + NvGpuGpuGetTpcMasks args = MemoryHelper.Read<NvGpuGpuGetTpcMasks>(context.Memory, inputPosition); - if (Args.MaskBufferSize != 0) + if (args.MaskBufferSize != 0) { - Args.TpcMask = 3; + args.TpcMask = 3; } - MemoryHelper.Write(Context.Memory, OutputPosition, Args); + MemoryHelper.Write(context.Memory, outputPosition, args); return NvResult.Success; } - private static int GetActiveSlotMask(ServiceCtx Context) + private static int GetActiveSlotMask(ServiceCtx context) { - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - NvGpuGpuGetActiveSlotMask Args = new NvGpuGpuGetActiveSlotMask(); + NvGpuGpuGetActiveSlotMask args = new NvGpuGpuGetActiveSlotMask(); - Args.Slot = 0x07; - Args.Mask = 0x01; + args.Slot = 0x07; + args.Mask = 0x01; - MemoryHelper.Write(Context.Memory, OutputPosition, Args); + MemoryHelper.Write(context.Memory, outputPosition, args); Logger.PrintStub(LogClass.ServiceNv, "Stubbed."); return NvResult.Success; } - private static int GetGpuTime(ServiceCtx Context) + private static int GetGpuTime(ServiceCtx context) { - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - Context.Memory.WriteInt64(OutputPosition, GetPTimerNanoSeconds()); + context.Memory.WriteInt64(outputPosition, GetPTimerNanoSeconds()); return NvResult.Success; } private static long GetPTimerNanoSeconds() { - double Ticks = PTimer.ElapsedTicks; + double ticks = _pTimer.ElapsedTicks; - return (long)(Ticks * TicksToNs) & 0xff_ffff_ffff_ffff; + return (long)(ticks * _ticksToNs) & 0xff_ffff_ffff_ffff; } } }
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvHostChannel/NvHostChannelIoctl.cs b/Ryujinx.HLE/HOS/Services/Nv/NvHostChannel/NvHostChannelIoctl.cs index 466f3e9b..140e8c96 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/NvHostChannel/NvHostChannelIoctl.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/NvHostChannel/NvHostChannelIoctl.cs @@ -11,62 +11,57 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvHostChannel { class NvHostChannelIoctl { - private static ConcurrentDictionary<KProcess, NvChannel> Channels; + private static ConcurrentDictionary<KProcess, NvChannel> _channels; static NvHostChannelIoctl() { - Channels = new ConcurrentDictionary<KProcess, NvChannel>(); + _channels = new ConcurrentDictionary<KProcess, NvChannel>(); } - public static int ProcessIoctl(ServiceCtx Context, int Cmd) + public static int ProcessIoctl(ServiceCtx context, int cmd) { - switch (Cmd & 0xffff) + switch (cmd & 0xffff) { - case 0x0001: return Submit (Context); - case 0x0002: return GetSyncpoint (Context); - case 0x0003: return GetWaitBase (Context); - case 0x0009: return MapBuffer (Context); - case 0x000a: return UnmapBuffer (Context); - case 0x4714: return SetUserData (Context); - case 0x4801: return SetNvMap (Context); - case 0x4803: return SetTimeout (Context); - case 0x4808: return SubmitGpfifo (Context); - case 0x4809: return AllocObjCtx (Context); - case 0x480b: return ZcullBind (Context); - case 0x480c: return SetErrorNotifier (Context); - case 0x480d: return SetPriority (Context); - case 0x481a: return AllocGpfifoEx2 (Context); - case 0x481b: return KickoffPbWithAttr(Context); + case 0x0001: return Submit (context); + case 0x0002: return GetSyncpoint (context); + case 0x0003: return GetWaitBase (context); + case 0x0009: return MapBuffer (context); + case 0x000a: return UnmapBuffer (context); + case 0x480b: return ZcullBind (context); + case 0x480c: return SetErrorNotifier (context); + case 0x4803: return SetTimeout (context); + case 0x481a: return AllocGpfifoEx2 (context); + case 0x481b: return KickoffPbWithAttr(context); } - throw new NotImplementedException(Cmd.ToString("x8")); + throw new NotImplementedException(cmd.ToString("x8")); } - private static int Submit(ServiceCtx Context) + private static int Submit(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - NvHostChannelSubmit Args = MemoryHelper.Read<NvHostChannelSubmit>(Context.Memory, InputPosition); + NvHostChannelSubmit args = MemoryHelper.Read<NvHostChannelSubmit>(context.Memory, inputPosition); - NvGpuVmm Vmm = NvGpuASIoctl.GetASCtx(Context).Vmm; + NvGpuVmm vmm = NvGpuASIoctl.GetASCtx(context).Vmm; - for (int Index = 0; Index < Args.CmdBufsCount; Index++) + for (int index = 0; index < args.CmdBufsCount; index++) { - long CmdBufOffset = InputPosition + 0x10 + Index * 0xc; + long cmdBufOffset = inputPosition + 0x10 + index * 0xc; - NvHostChannelCmdBuf CmdBuf = MemoryHelper.Read<NvHostChannelCmdBuf>(Context.Memory, CmdBufOffset); + NvHostChannelCmdBuf cmdBuf = MemoryHelper.Read<NvHostChannelCmdBuf>(context.Memory, cmdBufOffset); - NvMapHandle Map = NvMapIoctl.GetNvMap(Context, CmdBuf.MemoryId); + NvMapHandle map = NvMapIoctl.GetNvMap(context, cmdBuf.MemoryId); - int[] CmdBufData = new int[CmdBuf.WordsCount]; + int[] cmdBufData = new int[cmdBuf.WordsCount]; - for (int Offset = 0; Offset < CmdBufData.Length; Offset++) + for (int offset = 0; offset < cmdBufData.Length; offset++) { - CmdBufData[Offset] = Context.Memory.ReadInt32(Map.Address + CmdBuf.Offset + Offset * 4); + cmdBufData[offset] = context.Memory.ReadInt32(map.Address + cmdBuf.Offset + offset * 4); } - Context.Device.Gpu.PushCommandBuffer(Vmm, CmdBufData); + context.Device.Gpu.PushCommandBuffer(vmm, cmdBufData); } //TODO: Relocation, waitchecks, etc. @@ -74,99 +69,99 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvHostChannel return NvResult.Success; } - private static int GetSyncpoint(ServiceCtx Context) + private static int GetSyncpoint(ServiceCtx context) { //TODO - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - NvHostChannelGetParamArg Args = MemoryHelper.Read<NvHostChannelGetParamArg>(Context.Memory, InputPosition); + NvHostChannelGetParamArg args = MemoryHelper.Read<NvHostChannelGetParamArg>(context.Memory, inputPosition); - Args.Value = 0; + args.Value = 0; - MemoryHelper.Write(Context.Memory, OutputPosition, Args); + MemoryHelper.Write(context.Memory, outputPosition, args); return NvResult.Success; } - private static int GetWaitBase(ServiceCtx Context) + private static int GetWaitBase(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - NvHostChannelGetParamArg Args = MemoryHelper.Read<NvHostChannelGetParamArg>(Context.Memory, InputPosition); + NvHostChannelGetParamArg args = MemoryHelper.Read<NvHostChannelGetParamArg>(context.Memory, inputPosition); - Args.Value = 0; + args.Value = 0; - MemoryHelper.Write(Context.Memory, OutputPosition, Args); + MemoryHelper.Write(context.Memory, outputPosition, args); return NvResult.Success; } - private static int MapBuffer(ServiceCtx Context) + private static int MapBuffer(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - NvHostChannelMapBuffer Args = MemoryHelper.Read<NvHostChannelMapBuffer>(Context.Memory, InputPosition); + NvHostChannelMapBuffer args = MemoryHelper.Read<NvHostChannelMapBuffer>(context.Memory, inputPosition); - NvGpuVmm Vmm = NvGpuASIoctl.GetASCtx(Context).Vmm; + NvGpuVmm vmm = NvGpuASIoctl.GetASCtx(context).Vmm; - for (int Index = 0; Index < Args.NumEntries; Index++) + for (int index = 0; index < args.NumEntries; index++) { - int Handle = Context.Memory.ReadInt32(InputPosition + 0xc + Index * 8); + int handle = context.Memory.ReadInt32(inputPosition + 0xc + index * 8); - NvMapHandle Map = NvMapIoctl.GetNvMap(Context, Handle); + NvMapHandle map = NvMapIoctl.GetNvMap(context, handle); - if (Map == null) + if (map == null) { - Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{Handle:x8}!"); + Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{handle:x8}!"); return NvResult.InvalidInput; } - lock (Map) + lock (map) { - if (Map.DmaMapAddress == 0) + if (map.DmaMapAddress == 0) { - Map.DmaMapAddress = Vmm.MapLow(Map.Address, Map.Size); + map.DmaMapAddress = vmm.MapLow(map.Address, map.Size); } - Context.Memory.WriteInt32(OutputPosition + 0xc + 4 + Index * 8, (int)Map.DmaMapAddress); + context.Memory.WriteInt32(outputPosition + 0xc + 4 + index * 8, (int)map.DmaMapAddress); } } return NvResult.Success; } - private static int UnmapBuffer(ServiceCtx Context) + private static int UnmapBuffer(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; - NvHostChannelMapBuffer Args = MemoryHelper.Read<NvHostChannelMapBuffer>(Context.Memory, InputPosition); + NvHostChannelMapBuffer args = MemoryHelper.Read<NvHostChannelMapBuffer>(context.Memory, inputPosition); - NvGpuVmm Vmm = NvGpuASIoctl.GetASCtx(Context).Vmm; + NvGpuVmm vmm = NvGpuASIoctl.GetASCtx(context).Vmm; - for (int Index = 0; Index < Args.NumEntries; Index++) + for (int index = 0; index < args.NumEntries; index++) { - int Handle = Context.Memory.ReadInt32(InputPosition + 0xc + Index * 8); + int handle = context.Memory.ReadInt32(inputPosition + 0xc + index * 8); - NvMapHandle Map = NvMapIoctl.GetNvMap(Context, Handle); + NvMapHandle map = NvMapIoctl.GetNvMap(context, handle); - if (Map == null) + if (map == null) { - Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{Handle:x8}!"); + Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{handle:x8}!"); return NvResult.InvalidInput; } - lock (Map) + lock (map) { - if (Map.DmaMapAddress != 0) + if (map.DmaMapAddress != 0) { - Vmm.Free(Map.DmaMapAddress, Map.Size); + vmm.Free(map.DmaMapAddress, map.Size); - Map.DmaMapAddress = 0; + map.DmaMapAddress = 0; } } } @@ -174,146 +169,146 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvHostChannel return NvResult.Success; } - private static int SetUserData(ServiceCtx Context) + private static int SetUserData(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; Logger.PrintStub(LogClass.ServiceNv, "Stubbed."); return NvResult.Success; } - private static int SetNvMap(ServiceCtx Context) + private static int SetNvMap(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; Logger.PrintStub(LogClass.ServiceNv, "Stubbed."); return NvResult.Success; } - private static int SetTimeout(ServiceCtx Context) + private static int SetTimeout(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; - GetChannel(Context).Timeout = Context.Memory.ReadInt32(InputPosition); + GetChannel(context).Timeout = context.Memory.ReadInt32(inputPosition); return NvResult.Success; } - private static int SubmitGpfifo(ServiceCtx Context) + private static int SubmitGpfifo(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - NvHostChannelSubmitGpfifo Args = MemoryHelper.Read<NvHostChannelSubmitGpfifo>(Context.Memory, InputPosition); + NvHostChannelSubmitGpfifo args = MemoryHelper.Read<NvHostChannelSubmitGpfifo>(context.Memory, inputPosition); - NvGpuVmm Vmm = NvGpuASIoctl.GetASCtx(Context).Vmm;; + NvGpuVmm vmm = NvGpuASIoctl.GetASCtx(context).Vmm; - for (int Index = 0; Index < Args.NumEntries; Index++) + for (int index = 0; index < args.NumEntries; index++) { - long Gpfifo = Context.Memory.ReadInt64(InputPosition + 0x18 + Index * 8); + long gpfifo = context.Memory.ReadInt64(inputPosition + 0x18 + index * 8); - PushGpfifo(Context, Vmm, Gpfifo); + PushGpfifo(context, vmm, gpfifo); } - Args.SyncptId = 0; - Args.SyncptValue = 0; + args.SyncptId = 0; + args.SyncptValue = 0; - MemoryHelper.Write(Context.Memory, OutputPosition, Args); + MemoryHelper.Write(context.Memory, outputPosition, args); return NvResult.Success; } - private static int AllocObjCtx(ServiceCtx Context) + private static int AllocObjCtx(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; Logger.PrintStub(LogClass.ServiceNv, "Stubbed."); return NvResult.Success; } - private static int ZcullBind(ServiceCtx Context) + private static int ZcullBind(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; Logger.PrintStub(LogClass.ServiceNv, "Stubbed."); return NvResult.Success; } - private static int SetErrorNotifier(ServiceCtx Context) + private static int SetErrorNotifier(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; Logger.PrintStub(LogClass.ServiceNv, "Stubbed."); return NvResult.Success; } - private static int SetPriority(ServiceCtx Context) + private static int SetPriority(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; Logger.PrintStub(LogClass.ServiceNv, "Stubbed."); return NvResult.Success; } - private static int AllocGpfifoEx2(ServiceCtx Context) + private static int AllocGpfifoEx2(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; Logger.PrintStub(LogClass.ServiceNv, "Stubbed."); return NvResult.Success; } - private static int KickoffPbWithAttr(ServiceCtx Context) + private static int KickoffPbWithAttr(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - NvHostChannelSubmitGpfifo Args = MemoryHelper.Read<NvHostChannelSubmitGpfifo>(Context.Memory, InputPosition); + NvHostChannelSubmitGpfifo args = MemoryHelper.Read<NvHostChannelSubmitGpfifo>(context.Memory, inputPosition); - NvGpuVmm Vmm = NvGpuASIoctl.GetASCtx(Context).Vmm;; + NvGpuVmm vmm = NvGpuASIoctl.GetASCtx(context).Vmm; - for (int Index = 0; Index < Args.NumEntries; Index++) + for (int index = 0; index < args.NumEntries; index++) { - long Gpfifo = Context.Memory.ReadInt64(Args.Address + Index * 8); + long gpfifo = context.Memory.ReadInt64(args.Address + index * 8); - PushGpfifo(Context, Vmm, Gpfifo); + PushGpfifo(context, vmm, gpfifo); } - Args.SyncptId = 0; - Args.SyncptValue = 0; + args.SyncptId = 0; + args.SyncptValue = 0; - MemoryHelper.Write(Context.Memory, OutputPosition, Args); + MemoryHelper.Write(context.Memory, outputPosition, args); return NvResult.Success; } - private static void PushGpfifo(ServiceCtx Context, NvGpuVmm Vmm, long Gpfifo) + private static void PushGpfifo(ServiceCtx context, NvGpuVmm vmm, long gpfifo) { - Context.Device.Gpu.Pusher.Push(Vmm, Gpfifo); + context.Device.Gpu.Pusher.Push(vmm, gpfifo); } - public static NvChannel GetChannel(ServiceCtx Context) + public static NvChannel GetChannel(ServiceCtx context) { - return Channels.GetOrAdd(Context.Process, (Key) => new NvChannel()); + return _channels.GetOrAdd(context.Process, (key) => new NvChannel()); } - public static void UnloadProcess(KProcess Process) + public static void UnloadProcess(KProcess process) { - Channels.TryRemove(Process, out _); + _channels.TryRemove(process, out _); } } }
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlIoctl.cs b/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlIoctl.cs index bf92afb4..f13f7a68 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlIoctl.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlIoctl.cs @@ -10,116 +10,116 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvHostCtrl { class NvHostCtrlIoctl { - private static ConcurrentDictionary<KProcess, NvHostCtrlUserCtx> UserCtxs; + private static ConcurrentDictionary<KProcess, NvHostCtrlUserCtx> _userCtxs; - private static bool IsProductionMode = true; + private static bool _isProductionMode = true; static NvHostCtrlIoctl() { - UserCtxs = new ConcurrentDictionary<KProcess, NvHostCtrlUserCtx>(); + _userCtxs = new ConcurrentDictionary<KProcess, NvHostCtrlUserCtx>(); - if (Set.NxSettings.Settings.TryGetValue("nv!rmos_set_production_mode", out object ProductionModeSetting)) + if (Set.NxSettings.Settings.TryGetValue("nv!rmos_set_production_mode", out object productionModeSetting)) { - IsProductionMode = ((string)ProductionModeSetting) != "0"; // Default value is "" + _isProductionMode = ((string)productionModeSetting) != "0"; // Default value is "" } } - public static int ProcessIoctl(ServiceCtx Context, int Cmd) + public static int ProcessIoctl(ServiceCtx context, int cmd) { - switch (Cmd & 0xffff) + switch (cmd & 0xffff) { - case 0x0014: return SyncptRead (Context); - case 0x0015: return SyncptIncr (Context); - case 0x0016: return SyncptWait (Context); - case 0x0019: return SyncptWaitEx (Context); - case 0x001a: return SyncptReadMax (Context); - case 0x001b: return GetConfig (Context); - case 0x001d: return EventWait (Context); - case 0x001e: return EventWaitAsync(Context); - case 0x001f: return EventRegister (Context); + case 0x0014: return SyncptRead (context); + case 0x0015: return SyncptIncr (context); + case 0x0016: return SyncptWait (context); + case 0x0019: return SyncptWaitEx (context); + case 0x001a: return SyncptReadMax (context); + case 0x001b: return GetConfig (context); + case 0x001d: return EventWait (context); + case 0x001e: return EventWaitAsync(context); + case 0x001f: return EventRegister (context); } - throw new NotImplementedException(Cmd.ToString("x8")); + throw new NotImplementedException(cmd.ToString("x8")); } - private static int SyncptRead(ServiceCtx Context) + private static int SyncptRead(ServiceCtx context) { - return SyncptReadMinOrMax(Context, Max: false); + return SyncptReadMinOrMax(context, max: false); } - private static int SyncptIncr(ServiceCtx Context) + private static int SyncptIncr(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; - int Id = Context.Memory.ReadInt32(InputPosition); + int id = context.Memory.ReadInt32(inputPosition); - if ((uint)Id >= NvHostSyncpt.SyncptsCount) + if ((uint)id >= NvHostSyncpt.SyncptsCount) { return NvResult.InvalidInput; } - GetUserCtx(Context).Syncpt.Increment(Id); + GetUserCtx(context).Syncpt.Increment(id); return NvResult.Success; } - private static int SyncptWait(ServiceCtx Context) + private static int SyncptWait(ServiceCtx context) { - return SyncptWait(Context, Extended: false); + return SyncptWait(context, extended: false); } - private static int SyncptWaitEx(ServiceCtx Context) + private static int SyncptWaitEx(ServiceCtx context) { - return SyncptWait(Context, Extended: true); + return SyncptWait(context, extended: true); } - private static int SyncptReadMax(ServiceCtx Context) + private static int SyncptReadMax(ServiceCtx context) { - return SyncptReadMinOrMax(Context, Max: true); + return SyncptReadMinOrMax(context, max: true); } - private static int GetConfig(ServiceCtx Context) + private static int GetConfig(ServiceCtx context) { - if (!IsProductionMode) + if (!_isProductionMode) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - string Domain = MemoryHelper.ReadAsciiString(Context.Memory, InputPosition + 0, 0x41); - string Name = MemoryHelper.ReadAsciiString(Context.Memory, InputPosition + 0x41, 0x41); + string domain = MemoryHelper.ReadAsciiString(context.Memory, inputPosition + 0, 0x41); + string name = MemoryHelper.ReadAsciiString(context.Memory, inputPosition + 0x41, 0x41); - if (Set.NxSettings.Settings.TryGetValue($"{Domain}!{Name}", out object NvSetting)) + if (Set.NxSettings.Settings.TryGetValue($"{domain}!{name}", out object nvSetting)) { - byte[] SettingBuffer = new byte[0x101]; + byte[] settingBuffer = new byte[0x101]; - if (NvSetting is string StringValue) + if (nvSetting is string stringValue) { - if (StringValue.Length > 0x100) + if (stringValue.Length > 0x100) { - Logger.PrintError(LogClass.ServiceNv, $"{Domain}!{Name} String value size is too big!"); + Logger.PrintError(LogClass.ServiceNv, $"{domain}!{name} String value size is too big!"); } else { - SettingBuffer = Encoding.ASCII.GetBytes(StringValue + "\0"); + settingBuffer = Encoding.ASCII.GetBytes(stringValue + "\0"); } } - if (NvSetting is int IntValue) + if (nvSetting is int intValue) { - SettingBuffer = BitConverter.GetBytes(IntValue); + settingBuffer = BitConverter.GetBytes(intValue); } - else if (NvSetting is bool BoolValue) + else if (nvSetting is bool boolValue) { - SettingBuffer[0] = BoolValue ? (byte)1 : (byte)0; + settingBuffer[0] = boolValue ? (byte)1 : (byte)0; } else { - throw new NotImplementedException(NvSetting.GetType().Name); + throw new NotImplementedException(nvSetting.GetType().Name); } - Context.Memory.WriteBytes(OutputPosition + 0x82, SettingBuffer); + context.Memory.WriteBytes(outputPosition + 0x82, settingBuffer); - Logger.PrintDebug(LogClass.ServiceNv, $"Got setting {Domain}!{Name}"); + Logger.PrintDebug(LogClass.ServiceNv, $"Got setting {domain}!{name}"); } return NvResult.Success; @@ -128,156 +128,156 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvHostCtrl return NvResult.NotAvailableInProduction; } - private static int EventWait(ServiceCtx Context) + private static int EventWait(ServiceCtx context) { - return EventWait(Context, Async: false); + return EventWait(context, async: false); } - private static int EventWaitAsync(ServiceCtx Context) + private static int EventWaitAsync(ServiceCtx context) { - return EventWait(Context, Async: true); + return EventWait(context, async: true); } - private static int EventRegister(ServiceCtx Context) + private static int EventRegister(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - int EventId = Context.Memory.ReadInt32(InputPosition); + int eventId = context.Memory.ReadInt32(inputPosition); Logger.PrintStub(LogClass.ServiceNv, "Stubbed."); return NvResult.Success; } - private static int SyncptReadMinOrMax(ServiceCtx Context, bool Max) + private static int SyncptReadMinOrMax(ServiceCtx context, bool max) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - NvHostCtrlSyncptRead Args = MemoryHelper.Read<NvHostCtrlSyncptRead>(Context.Memory, InputPosition); + NvHostCtrlSyncptRead args = MemoryHelper.Read<NvHostCtrlSyncptRead>(context.Memory, inputPosition); - if ((uint)Args.Id >= NvHostSyncpt.SyncptsCount) + if ((uint)args.Id >= NvHostSyncpt.SyncptsCount) { return NvResult.InvalidInput; } - if (Max) + if (max) { - Args.Value = GetUserCtx(Context).Syncpt.GetMax(Args.Id); + args.Value = GetUserCtx(context).Syncpt.GetMax(args.Id); } else { - Args.Value = GetUserCtx(Context).Syncpt.GetMin(Args.Id); + args.Value = GetUserCtx(context).Syncpt.GetMin(args.Id); } - MemoryHelper.Write(Context.Memory, OutputPosition, Args); + MemoryHelper.Write(context.Memory, outputPosition, args); return NvResult.Success; } - private static int SyncptWait(ServiceCtx Context, bool Extended) + private static int SyncptWait(ServiceCtx context, bool extended) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - NvHostCtrlSyncptWait Args = MemoryHelper.Read<NvHostCtrlSyncptWait>(Context.Memory, InputPosition); + NvHostCtrlSyncptWait args = MemoryHelper.Read<NvHostCtrlSyncptWait>(context.Memory, inputPosition); - NvHostSyncpt Syncpt = GetUserCtx(Context).Syncpt; + NvHostSyncpt syncpt = GetUserCtx(context).Syncpt; - if ((uint)Args.Id >= NvHostSyncpt.SyncptsCount) + if ((uint)args.Id >= NvHostSyncpt.SyncptsCount) { return NvResult.InvalidInput; } - int Result; + int result; - if (Syncpt.MinCompare(Args.Id, Args.Thresh)) + if (syncpt.MinCompare(args.Id, args.Thresh)) { - Result = NvResult.Success; + result = NvResult.Success; } - else if (Args.Timeout == 0) + else if (args.Timeout == 0) { - Result = NvResult.TryAgain; + result = NvResult.TryAgain; } else { - Logger.PrintDebug(LogClass.ServiceNv, "Waiting syncpt with timeout of " + Args.Timeout + "ms..."); + Logger.PrintDebug(LogClass.ServiceNv, "Waiting syncpt with timeout of " + args.Timeout + "ms..."); - using (ManualResetEvent WaitEvent = new ManualResetEvent(false)) + using (ManualResetEvent waitEvent = new ManualResetEvent(false)) { - Syncpt.AddWaiter(Args.Thresh, WaitEvent); + syncpt.AddWaiter(args.Thresh, waitEvent); //Note: Negative (> INT_MAX) timeouts aren't valid on .NET, //in this case we just use the maximum timeout possible. - int Timeout = Args.Timeout; + int timeout = args.Timeout; - if (Timeout < -1) + if (timeout < -1) { - Timeout = int.MaxValue; + timeout = int.MaxValue; } - if (Timeout == -1) + if (timeout == -1) { - WaitEvent.WaitOne(); + waitEvent.WaitOne(); - Result = NvResult.Success; + result = NvResult.Success; } - else if (WaitEvent.WaitOne(Timeout)) + else if (waitEvent.WaitOne(timeout)) { - Result = NvResult.Success; + result = NvResult.Success; } else { - Result = NvResult.TimedOut; + result = NvResult.TimedOut; } } Logger.PrintDebug(LogClass.ServiceNv, "Resuming..."); } - if (Extended) + if (extended) { - Context.Memory.WriteInt32(OutputPosition + 0xc, Syncpt.GetMin(Args.Id)); + context.Memory.WriteInt32(outputPosition + 0xc, syncpt.GetMin(args.Id)); } - return Result; + return result; } - private static int EventWait(ServiceCtx Context, bool Async) + private static int EventWait(ServiceCtx context, bool async) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - NvHostCtrlSyncptWaitEx Args = MemoryHelper.Read<NvHostCtrlSyncptWaitEx>(Context.Memory, InputPosition); + NvHostCtrlSyncptWaitEx args = MemoryHelper.Read<NvHostCtrlSyncptWaitEx>(context.Memory, inputPosition); - if ((uint)Args.Id >= NvHostSyncpt.SyncptsCount) + if ((uint)args.Id >= NvHostSyncpt.SyncptsCount) { return NvResult.InvalidInput; } void WriteArgs() { - MemoryHelper.Write(Context.Memory, OutputPosition, Args); + MemoryHelper.Write(context.Memory, outputPosition, args); } - NvHostSyncpt Syncpt = GetUserCtx(Context).Syncpt; + NvHostSyncpt syncpt = GetUserCtx(context).Syncpt; - if (Syncpt.MinCompare(Args.Id, Args.Thresh)) + if (syncpt.MinCompare(args.Id, args.Thresh)) { - Args.Value = Syncpt.GetMin(Args.Id); + args.Value = syncpt.GetMin(args.Id); WriteArgs(); return NvResult.Success; } - if (!Async) + if (!async) { - Args.Value = 0; + args.Value = 0; } - if (Args.Timeout == 0) + if (args.Timeout == 0) { WriteArgs(); @@ -286,114 +286,114 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvHostCtrl NvHostEvent Event; - int Result, EventIndex; + int result, eventIndex; - if (Async) + if (async) { - EventIndex = Args.Value; + eventIndex = args.Value; - if ((uint)EventIndex >= NvHostCtrlUserCtx.EventsCount) + if ((uint)eventIndex >= NvHostCtrlUserCtx.EventsCount) { return NvResult.InvalidInput; } - Event = GetUserCtx(Context).Events[EventIndex]; + Event = GetUserCtx(context).Events[eventIndex]; } else { - Event = GetFreeEvent(Context, Syncpt, Args.Id, out EventIndex); + Event = GetFreeEvent(context, syncpt, args.Id, out eventIndex); } if (Event != null && (Event.State == NvHostEventState.Registered || Event.State == NvHostEventState.Free)) { - Event.Id = Args.Id; - Event.Thresh = Args.Thresh; + Event.Id = args.Id; + Event.Thresh = args.Thresh; Event.State = NvHostEventState.Waiting; - if (!Async) + if (!async) { - Args.Value = ((Args.Id & 0xfff) << 16) | 0x10000000; + args.Value = ((args.Id & 0xfff) << 16) | 0x10000000; } else { - Args.Value = Args.Id << 4; + args.Value = args.Id << 4; } - Args.Value |= EventIndex; + args.Value |= eventIndex; - Result = NvResult.TryAgain; + result = NvResult.TryAgain; } else { - Result = NvResult.InvalidInput; + result = NvResult.InvalidInput; } WriteArgs(); - return Result; + return result; } private static NvHostEvent GetFreeEvent( - ServiceCtx Context, - NvHostSyncpt Syncpt, - int Id, - out int EventIndex) + ServiceCtx context, + NvHostSyncpt syncpt, + int id, + out int eventIndex) { - NvHostEvent[] Events = GetUserCtx(Context).Events; + NvHostEvent[] events = GetUserCtx(context).Events; - EventIndex = NvHostCtrlUserCtx.EventsCount; + eventIndex = NvHostCtrlUserCtx.EventsCount; - int NullIndex = NvHostCtrlUserCtx.EventsCount; + int nullIndex = NvHostCtrlUserCtx.EventsCount; - for (int Index = 0; Index < NvHostCtrlUserCtx.EventsCount; Index++) + for (int index = 0; index < NvHostCtrlUserCtx.EventsCount; index++) { - NvHostEvent Event = Events[Index]; + NvHostEvent Event = events[index]; if (Event != null) { if (Event.State == NvHostEventState.Registered || Event.State == NvHostEventState.Free) { - EventIndex = Index; + eventIndex = index; - if (Event.Id == Id) + if (Event.Id == id) { return Event; } } } - else if (NullIndex == NvHostCtrlUserCtx.EventsCount) + else if (nullIndex == NvHostCtrlUserCtx.EventsCount) { - NullIndex = Index; + nullIndex = index; } } - if (NullIndex < NvHostCtrlUserCtx.EventsCount) + if (nullIndex < NvHostCtrlUserCtx.EventsCount) { - EventIndex = NullIndex; + eventIndex = nullIndex; - return Events[NullIndex] = new NvHostEvent(); + return events[nullIndex] = new NvHostEvent(); } - if (EventIndex < NvHostCtrlUserCtx.EventsCount) + if (eventIndex < NvHostCtrlUserCtx.EventsCount) { - return Events[EventIndex]; + return events[eventIndex]; } return null; } - public static NvHostCtrlUserCtx GetUserCtx(ServiceCtx Context) + public static NvHostCtrlUserCtx GetUserCtx(ServiceCtx context) { - return UserCtxs.GetOrAdd(Context.Process, (Key) => new NvHostCtrlUserCtx()); + return _userCtxs.GetOrAdd(context.Process, (key) => new NvHostCtrlUserCtx()); } - public static void UnloadProcess(KProcess Process) + public static void UnloadProcess(KProcess process) { - UserCtxs.TryRemove(Process, out _); + _userCtxs.TryRemove(process, out _); } } } diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlUserCtx.cs b/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlUserCtx.cs index fcb80836..aa4577ed 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlUserCtx.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlUserCtx.cs @@ -5,9 +5,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvHostCtrl public const int LocksCount = 16; public const int EventsCount = 64; - public NvHostSyncpt Syncpt { get; private set; } + public NvHostSyncpt Syncpt { get; } - public NvHostEvent[] Events { get; private set; } + public NvHostEvent[] Events { get; } public NvHostCtrlUserCtx() { diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostSyncPt.cs b/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostSyncPt.cs index 9ffa93f2..d27f7c53 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostSyncPt.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostSyncPt.cs @@ -9,98 +9,98 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvHostCtrl { public const int SyncptsCount = 192; - private int[] CounterMin; - private int[] CounterMax; + private int[] _counterMin; + private int[] _counterMax; - private long EventMask; + private long _eventMask; - private ConcurrentDictionary<EventWaitHandle, int> Waiters; + private ConcurrentDictionary<EventWaitHandle, int> _waiters; public NvHostSyncpt() { - CounterMin = new int[SyncptsCount]; - CounterMax = new int[SyncptsCount]; + _counterMin = new int[SyncptsCount]; + _counterMax = new int[SyncptsCount]; - Waiters = new ConcurrentDictionary<EventWaitHandle, int>(); + _waiters = new ConcurrentDictionary<EventWaitHandle, int>(); } - public int GetMin(int Id) + public int GetMin(int id) { - return CounterMin[Id]; + return _counterMin[id]; } - public int GetMax(int Id) + public int GetMax(int id) { - return CounterMax[Id]; + return _counterMax[id]; } - public int Increment(int Id) + public int Increment(int id) { - if (((EventMask >> Id) & 1) != 0) + if (((_eventMask >> id) & 1) != 0) { - Interlocked.Increment(ref CounterMax[Id]); + Interlocked.Increment(ref _counterMax[id]); } - return IncrementMin(Id); + return IncrementMin(id); } - public int IncrementMin(int Id) + public int IncrementMin(int id) { - int Value = Interlocked.Increment(ref CounterMin[Id]); + int value = Interlocked.Increment(ref _counterMin[id]); - WakeUpWaiters(Id, Value); + WakeUpWaiters(id, value); - return Value; + return value; } - public int IncrementMax(int Id) + public int IncrementMax(int id) { - return Interlocked.Increment(ref CounterMax[Id]); + return Interlocked.Increment(ref _counterMax[id]); } - public void AddWaiter(int Threshold, EventWaitHandle WaitEvent) + public void AddWaiter(int threshold, EventWaitHandle waitEvent) { - if (!Waiters.TryAdd(WaitEvent, Threshold)) + if (!_waiters.TryAdd(waitEvent, threshold)) { throw new InvalidOperationException(); } } - public bool RemoveWaiter(EventWaitHandle WaitEvent) + public bool RemoveWaiter(EventWaitHandle waitEvent) { - return Waiters.TryRemove(WaitEvent, out _); + return _waiters.TryRemove(waitEvent, out _); } - private void WakeUpWaiters(int Id, int NewValue) + private void WakeUpWaiters(int id, int newValue) { - foreach (KeyValuePair<EventWaitHandle, int> KV in Waiters) + foreach (KeyValuePair<EventWaitHandle, int> kv in _waiters) { - if (MinCompare(Id, NewValue, CounterMax[Id], KV.Value)) + if (MinCompare(id, newValue, _counterMax[id], kv.Value)) { - KV.Key.Set(); + kv.Key.Set(); - Waiters.TryRemove(KV.Key, out _); + _waiters.TryRemove(kv.Key, out _); } } } - public bool MinCompare(int Id, int Threshold) + public bool MinCompare(int id, int threshold) { - return MinCompare(Id, CounterMin[Id], CounterMax[Id], Threshold); + return MinCompare(id, _counterMin[id], _counterMax[id], threshold); } - private bool MinCompare(int Id, int Min, int Max, int Threshold) + private bool MinCompare(int id, int min, int max, int threshold) { - int MinDiff = Min - Threshold; - int MaxDiff = Max - Threshold; + int minDiff = min - threshold; + int maxDiff = max - threshold; - if (((EventMask >> Id) & 1) != 0) + if (((_eventMask >> id) & 1) != 0) { - return MinDiff >= 0; + return minDiff >= 0; } else { - return (uint)MaxDiff >= (uint)MinDiff; + return (uint)maxDiff >= (uint)minDiff; } } } diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapHandle.cs b/Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapHandle.cs index e97e4ff4..31bf8329 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapHandle.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapHandle.cs @@ -13,26 +13,26 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvMap public bool Allocated; public long DmaMapAddress; - private long Dupes; + private long _dupes; public NvMapHandle() { - Dupes = 1; + _dupes = 1; } - public NvMapHandle(int Size) : this() + public NvMapHandle(int size) : this() { - this.Size = Size; + Size = size; } public void IncrementRefCount() { - Interlocked.Increment(ref Dupes); + Interlocked.Increment(ref _dupes); } public long DecrementRefCount() { - return Interlocked.Decrement(ref Dupes); + return Interlocked.Decrement(ref _dupes); } } }
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapIoctl.cs b/Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapIoctl.cs index adc523e5..75a76b91 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapIoctl.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapIoctl.cs @@ -11,290 +11,290 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvMap { private const int FlagNotFreedYet = 1; - private static ConcurrentDictionary<KProcess, IdDictionary> Maps; + private static ConcurrentDictionary<KProcess, IdDictionary> _maps; static NvMapIoctl() { - Maps = new ConcurrentDictionary<KProcess, IdDictionary>(); + _maps = new ConcurrentDictionary<KProcess, IdDictionary>(); } - public static int ProcessIoctl(ServiceCtx Context, int Cmd) + public static int ProcessIoctl(ServiceCtx context, int cmd) { - switch (Cmd & 0xffff) + switch (cmd & 0xffff) { - case 0x0101: return Create(Context); - case 0x0103: return FromId(Context); - case 0x0104: return Alloc (Context); - case 0x0105: return Free (Context); - case 0x0109: return Param (Context); - case 0x010e: return GetId (Context); + case 0x0101: return Create(context); + case 0x0103: return FromId(context); + case 0x0104: return Alloc (context); + case 0x0105: return Free (context); + case 0x0109: return Param (context); + case 0x010e: return GetId (context); } - Logger.PrintWarning(LogClass.ServiceNv, $"Unsupported Ioctl command 0x{Cmd:x8}!"); + Logger.PrintWarning(LogClass.ServiceNv, $"Unsupported Ioctl command 0x{cmd:x8}!"); return NvResult.NotSupported; } - private static int Create(ServiceCtx Context) + private static int Create(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - NvMapCreate Args = MemoryHelper.Read<NvMapCreate>(Context.Memory, InputPosition); + NvMapCreate args = MemoryHelper.Read<NvMapCreate>(context.Memory, inputPosition); - if (Args.Size == 0) + if (args.Size == 0) { - Logger.PrintWarning(LogClass.ServiceNv, $"Invalid size 0x{Args.Size:x8}!"); + Logger.PrintWarning(LogClass.ServiceNv, $"Invalid size 0x{args.Size:x8}!"); return NvResult.InvalidInput; } - int Size = IntUtils.AlignUp(Args.Size, NvGpuVmm.PageSize); + int size = IntUtils.AlignUp(args.Size, NvGpuVmm.PageSize); - Args.Handle = AddNvMap(Context, new NvMapHandle(Size)); + args.Handle = AddNvMap(context, new NvMapHandle(size)); - Logger.PrintInfo(LogClass.ServiceNv, $"Created map {Args.Handle} with size 0x{Size:x8}!"); + Logger.PrintInfo(LogClass.ServiceNv, $"Created map {args.Handle} with size 0x{size:x8}!"); - MemoryHelper.Write(Context.Memory, OutputPosition, Args); + MemoryHelper.Write(context.Memory, outputPosition, args); return NvResult.Success; } - private static int FromId(ServiceCtx Context) + private static int FromId(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - NvMapFromId Args = MemoryHelper.Read<NvMapFromId>(Context.Memory, InputPosition); + NvMapFromId args = MemoryHelper.Read<NvMapFromId>(context.Memory, inputPosition); - NvMapHandle Map = GetNvMap(Context, Args.Id); + NvMapHandle map = GetNvMap(context, args.Id); - if (Map == null) + if (map == null) { - Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{Args.Handle:x8}!"); + Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{args.Handle:x8}!"); return NvResult.InvalidInput; } - Map.IncrementRefCount(); + map.IncrementRefCount(); - Args.Handle = Args.Id; + args.Handle = args.Id; - MemoryHelper.Write(Context.Memory, OutputPosition, Args); + MemoryHelper.Write(context.Memory, outputPosition, args); return NvResult.Success; } - private static int Alloc(ServiceCtx Context) + private static int Alloc(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - NvMapAlloc Args = MemoryHelper.Read<NvMapAlloc>(Context.Memory, InputPosition); + NvMapAlloc args = MemoryHelper.Read<NvMapAlloc>(context.Memory, inputPosition); - NvMapHandle Map = GetNvMap(Context, Args.Handle); + NvMapHandle map = GetNvMap(context, args.Handle); - if (Map == null) + if (map == null) { - Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{Args.Handle:x8}!"); + Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{args.Handle:x8}!"); return NvResult.InvalidInput; } - if ((Args.Align & (Args.Align - 1)) != 0) + if ((args.Align & (args.Align - 1)) != 0) { - Logger.PrintWarning(LogClass.ServiceNv, $"Invalid alignment 0x{Args.Align:x8}!"); + Logger.PrintWarning(LogClass.ServiceNv, $"Invalid alignment 0x{args.Align:x8}!"); return NvResult.InvalidInput; } - if ((uint)Args.Align < NvGpuVmm.PageSize) + if ((uint)args.Align < NvGpuVmm.PageSize) { - Args.Align = NvGpuVmm.PageSize; + args.Align = NvGpuVmm.PageSize; } - int Result = NvResult.Success; + int result = NvResult.Success; - if (!Map.Allocated) + if (!map.Allocated) { - Map.Allocated = true; + map.Allocated = true; - Map.Align = Args.Align; - Map.Kind = (byte)Args.Kind; + map.Align = args.Align; + map.Kind = (byte)args.Kind; - int Size = IntUtils.AlignUp(Map.Size, NvGpuVmm.PageSize); + int size = IntUtils.AlignUp(map.Size, NvGpuVmm.PageSize); - long Address = Args.Address; + long address = args.Address; - if (Address == 0) + if (address == 0) { //When the address is zero, we need to allocate //our own backing memory for the NvMap. //TODO: Is this allocation inside the transfer memory? - Result = NvResult.OutOfMemory; + result = NvResult.OutOfMemory; } - if (Result == NvResult.Success) + if (result == NvResult.Success) { - Map.Size = Size; - Map.Address = Address; + map.Size = size; + map.Address = address; } } - MemoryHelper.Write(Context.Memory, OutputPosition, Args); + MemoryHelper.Write(context.Memory, outputPosition, args); - return Result; + return result; } - private static int Free(ServiceCtx Context) + private static int Free(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - NvMapFree Args = MemoryHelper.Read<NvMapFree>(Context.Memory, InputPosition); + NvMapFree args = MemoryHelper.Read<NvMapFree>(context.Memory, inputPosition); - NvMapHandle Map = GetNvMap(Context, Args.Handle); + NvMapHandle map = GetNvMap(context, args.Handle); - if (Map == null) + if (map == null) { - Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{Args.Handle:x8}!"); + Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{args.Handle:x8}!"); return NvResult.InvalidInput; } - if (Map.DecrementRefCount() <= 0) + if (map.DecrementRefCount() <= 0) { - DeleteNvMap(Context, Args.Handle); + DeleteNvMap(context, args.Handle); - Logger.PrintInfo(LogClass.ServiceNv, $"Deleted map {Args.Handle}!"); + Logger.PrintInfo(LogClass.ServiceNv, $"Deleted map {args.Handle}!"); - Args.Address = Map.Address; - Args.Flags = 0; + args.Address = map.Address; + args.Flags = 0; } else { - Args.Address = 0; - Args.Flags = FlagNotFreedYet; + args.Address = 0; + args.Flags = FlagNotFreedYet; } - Args.Size = Map.Size; + args.Size = map.Size; - MemoryHelper.Write(Context.Memory, OutputPosition, Args); + MemoryHelper.Write(context.Memory, outputPosition, args); return NvResult.Success; } - private static int Param(ServiceCtx Context) + private static int Param(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - NvMapParam Args = MemoryHelper.Read<NvMapParam>(Context.Memory, InputPosition); + NvMapParam args = MemoryHelper.Read<NvMapParam>(context.Memory, inputPosition); - NvMapHandle Map = GetNvMap(Context, Args.Handle); + NvMapHandle map = GetNvMap(context, args.Handle); - if (Map == null) + if (map == null) { - Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{Args.Handle:x8}!"); + Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{args.Handle:x8}!"); return NvResult.InvalidInput; } - switch ((NvMapHandleParam)Args.Param) + switch ((NvMapHandleParam)args.Param) { - case NvMapHandleParam.Size: Args.Result = Map.Size; break; - case NvMapHandleParam.Align: Args.Result = Map.Align; break; - case NvMapHandleParam.Heap: Args.Result = 0x40000000; break; - case NvMapHandleParam.Kind: Args.Result = Map.Kind; break; - case NvMapHandleParam.Compr: Args.Result = 0; break; + case NvMapHandleParam.Size: args.Result = map.Size; break; + case NvMapHandleParam.Align: args.Result = map.Align; break; + case NvMapHandleParam.Heap: args.Result = 0x40000000; break; + case NvMapHandleParam.Kind: args.Result = map.Kind; break; + case NvMapHandleParam.Compr: args.Result = 0; break; //Note: Base is not supported and returns an error. //Any other value also returns an error. default: return NvResult.InvalidInput; } - MemoryHelper.Write(Context.Memory, OutputPosition, Args); + MemoryHelper.Write(context.Memory, outputPosition, args); return NvResult.Success; } - private static int GetId(ServiceCtx Context) + private static int GetId(ServiceCtx context) { - long InputPosition = Context.Request.GetBufferType0x21().Position; - long OutputPosition = Context.Request.GetBufferType0x22().Position; + long inputPosition = context.Request.GetBufferType0x21().Position; + long outputPosition = context.Request.GetBufferType0x22().Position; - NvMapGetId Args = MemoryHelper.Read<NvMapGetId>(Context.Memory, InputPosition); + NvMapGetId args = MemoryHelper.Read<NvMapGetId>(context.Memory, inputPosition); - NvMapHandle Map = GetNvMap(Context, Args.Handle); + NvMapHandle map = GetNvMap(context, args.Handle); - if (Map == null) + if (map == null) { - Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{Args.Handle:x8}!"); + Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{args.Handle:x8}!"); return NvResult.InvalidInput; } - Args.Id = Args.Handle; + args.Id = args.Handle; - MemoryHelper.Write(Context.Memory, OutputPosition, Args); + MemoryHelper.Write(context.Memory, outputPosition, args); return NvResult.Success; } - private static int AddNvMap(ServiceCtx Context, NvMapHandle Map) + private static int AddNvMap(ServiceCtx context, NvMapHandle map) { - IdDictionary Dict = Maps.GetOrAdd(Context.Process, (Key) => + IdDictionary dict = _maps.GetOrAdd(context.Process, (key) => { - IdDictionary NewDict = new IdDictionary(); + IdDictionary newDict = new IdDictionary(); - NewDict.Add(0, new NvMapHandle()); + newDict.Add(0, new NvMapHandle()); - return NewDict; + return newDict; }); - return Dict.Add(Map); + return dict.Add(map); } - private static bool DeleteNvMap(ServiceCtx Context, int Handle) + private static bool DeleteNvMap(ServiceCtx context, int handle) { - if (Maps.TryGetValue(Context.Process, out IdDictionary Dict)) + if (_maps.TryGetValue(context.Process, out IdDictionary dict)) { - return Dict.Delete(Handle) != null; + return dict.Delete(handle) != null; } return false; } - public static void InitializeNvMap(ServiceCtx Context) + public static void InitializeNvMap(ServiceCtx context) { - IdDictionary Dict = Maps.GetOrAdd(Context.Process, (Key) =>new IdDictionary()); + IdDictionary dict = _maps.GetOrAdd(context.Process, (key) =>new IdDictionary()); - Dict.Add(0, new NvMapHandle()); + dict.Add(0, new NvMapHandle()); } - public static NvMapHandle GetNvMapWithFb(ServiceCtx Context, int Handle) + public static NvMapHandle GetNvMapWithFb(ServiceCtx context, int handle) { - if (Maps.TryGetValue(Context.Process, out IdDictionary Dict)) + if (_maps.TryGetValue(context.Process, out IdDictionary dict)) { - return Dict.GetData<NvMapHandle>(Handle); + return dict.GetData<NvMapHandle>(handle); } return null; } - public static NvMapHandle GetNvMap(ServiceCtx Context, int Handle) + public static NvMapHandle GetNvMap(ServiceCtx context, int handle) { - if (Handle != 0 && Maps.TryGetValue(Context.Process, out IdDictionary Dict)) + if (handle != 0 && _maps.TryGetValue(context.Process, out IdDictionary dict)) { - return Dict.GetData<NvMapHandle>(Handle); + return dict.GetData<NvMapHandle>(handle); } return null; } - public static void UnloadProcess(KProcess Process) + public static void UnloadProcess(KProcess process) { - Maps.TryRemove(Process, out _); + _maps.TryRemove(process, out _); } } }
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Pctl/IParentalControlService.cs b/Ryujinx.HLE/HOS/Services/Pctl/IParentalControlService.cs index 3e9d276a..0c539aa1 100644 --- a/Ryujinx.HLE/HOS/Services/Pctl/IParentalControlService.cs +++ b/Ryujinx.HLE/HOS/Services/Pctl/IParentalControlService.cs @@ -6,29 +6,29 @@ namespace Ryujinx.HLE.HOS.Services.Pctl { class IParentalControlService : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private bool Initialized = false; + private bool _initialized = false; - private bool NeedInitialize; + private bool _needInitialize; - public IParentalControlService(bool NeedInitialize = true) + public IParentalControlService(bool needInitialize = true) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 1, Initialize } }; - this.NeedInitialize = NeedInitialize; + _needInitialize = needInitialize; } - public long Initialize(ServiceCtx Context) + public long Initialize(ServiceCtx context) { - if (NeedInitialize && !Initialized) + if (_needInitialize && !_initialized) { - Initialized = true; + _initialized = true; } else { diff --git a/Ryujinx.HLE/HOS/Services/Pctl/IParentalControlServiceFactory.cs b/Ryujinx.HLE/HOS/Services/Pctl/IParentalControlServiceFactory.cs index 157d594d..92500187 100644 --- a/Ryujinx.HLE/HOS/Services/Pctl/IParentalControlServiceFactory.cs +++ b/Ryujinx.HLE/HOS/Services/Pctl/IParentalControlServiceFactory.cs @@ -5,29 +5,29 @@ namespace Ryujinx.HLE.HOS.Services.Pctl { class IParentalControlServiceFactory : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IParentalControlServiceFactory() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, CreateService }, { 1, CreateServiceWithoutInitialize } }; } - public long CreateService(ServiceCtx Context) + public long CreateService(ServiceCtx context) { - MakeObject(Context, new IParentalControlService()); + MakeObject(context, new IParentalControlService()); return 0; } - public long CreateServiceWithoutInitialize(ServiceCtx Context) + public long CreateServiceWithoutInitialize(ServiceCtx context) { - MakeObject(Context, new IParentalControlService(false)); + MakeObject(context, new IParentalControlService(false)); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Pl/ISharedFontManager.cs b/Ryujinx.HLE/HOS/Services/Pl/ISharedFontManager.cs index 0495a388..c555c504 100644 --- a/Ryujinx.HLE/HOS/Services/Pl/ISharedFontManager.cs +++ b/Ryujinx.HLE/HOS/Services/Pl/ISharedFontManager.cs @@ -8,13 +8,13 @@ namespace Ryujinx.HLE.HOS.Services.Pl { class ISharedFontManager : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public ISharedFontManager() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, RequestLoad }, { 1, GetLoadState }, @@ -25,104 +25,104 @@ namespace Ryujinx.HLE.HOS.Services.Pl }; } - public long RequestLoad(ServiceCtx Context) + public long RequestLoad(ServiceCtx context) { - SharedFontType FontType = (SharedFontType)Context.RequestData.ReadInt32(); + SharedFontType fontType = (SharedFontType)context.RequestData.ReadInt32(); //We don't need to do anything here because we do lazy initialization //on SharedFontManager (the font is loaded when necessary). return 0; } - public long GetLoadState(ServiceCtx Context) + public long GetLoadState(ServiceCtx context) { - SharedFontType FontType = (SharedFontType)Context.RequestData.ReadInt32(); + SharedFontType fontType = (SharedFontType)context.RequestData.ReadInt32(); //1 (true) indicates that the font is already loaded. //All fonts are already loaded. - Context.ResponseData.Write(1); + context.ResponseData.Write(1); return 0; } - public long GetFontSize(ServiceCtx Context) + public long GetFontSize(ServiceCtx context) { - SharedFontType FontType = (SharedFontType)Context.RequestData.ReadInt32(); + SharedFontType fontType = (SharedFontType)context.RequestData.ReadInt32(); - Context.ResponseData.Write(Context.Device.System.Font.GetFontSize(FontType)); + context.ResponseData.Write(context.Device.System.Font.GetFontSize(fontType)); return 0; } - public long GetSharedMemoryAddressOffset(ServiceCtx Context) + public long GetSharedMemoryAddressOffset(ServiceCtx context) { - SharedFontType FontType = (SharedFontType)Context.RequestData.ReadInt32(); + SharedFontType fontType = (SharedFontType)context.RequestData.ReadInt32(); - Context.ResponseData.Write(Context.Device.System.Font.GetSharedMemoryAddressOffset(FontType)); + context.ResponseData.Write(context.Device.System.Font.GetSharedMemoryAddressOffset(fontType)); return 0; } - public long GetSharedMemoryNativeHandle(ServiceCtx Context) + public long GetSharedMemoryNativeHandle(ServiceCtx context) { - Context.Device.System.Font.EnsureInitialized(Context.Device.System.ContentManager); + context.Device.System.Font.EnsureInitialized(context.Device.System.ContentManager); - if (Context.Process.HandleTable.GenerateHandle(Context.Device.System.FontSharedMem, out int Handle) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(context.Device.System.FontSharedMem, out int handle) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle); return 0; } - public long GetSharedFontInOrderOfPriority(ServiceCtx Context) + public long GetSharedFontInOrderOfPriority(ServiceCtx context) { - long LanguageCode = Context.RequestData.ReadInt64(); - int LoadedCount = 0; + long languageCode = context.RequestData.ReadInt64(); + int loadedCount = 0; - for (SharedFontType Type = 0; Type < SharedFontType.Count; Type++) + for (SharedFontType type = 0; type < SharedFontType.Count; type++) { - int Offset = (int)Type * 4; + int offset = (int)type * 4; - if (!AddFontToOrderOfPriorityList(Context, (SharedFontType)Type, Offset)) + if (!AddFontToOrderOfPriorityList(context, type, offset)) { break; } - LoadedCount++; + loadedCount++; } - Context.ResponseData.Write(LoadedCount); - Context.ResponseData.Write((int)SharedFontType.Count); + context.ResponseData.Write(loadedCount); + context.ResponseData.Write((int)SharedFontType.Count); return 0; } - private bool AddFontToOrderOfPriorityList(ServiceCtx Context, SharedFontType FontType, int Offset) + private bool AddFontToOrderOfPriorityList(ServiceCtx context, SharedFontType fontType, int offset) { - long TypesPosition = Context.Request.ReceiveBuff[0].Position; - long TypesSize = Context.Request.ReceiveBuff[0].Size; + long typesPosition = context.Request.ReceiveBuff[0].Position; + long typesSize = context.Request.ReceiveBuff[0].Size; - long OffsetsPosition = Context.Request.ReceiveBuff[1].Position; - long OffsetsSize = Context.Request.ReceiveBuff[1].Size; + long offsetsPosition = context.Request.ReceiveBuff[1].Position; + long offsetsSize = context.Request.ReceiveBuff[1].Size; - long FontSizeBufferPosition = Context.Request.ReceiveBuff[2].Position; - long FontSizeBufferSize = Context.Request.ReceiveBuff[2].Size; + long fontSizeBufferPosition = context.Request.ReceiveBuff[2].Position; + long fontSizeBufferSize = context.Request.ReceiveBuff[2].Size; - if ((uint)Offset + 4 > (uint)TypesSize || - (uint)Offset + 4 > (uint)OffsetsSize || - (uint)Offset + 4 > (uint)FontSizeBufferSize) + if ((uint)offset + 4 > (uint)typesSize || + (uint)offset + 4 > (uint)offsetsSize || + (uint)offset + 4 > (uint)fontSizeBufferSize) { return false; } - Context.Memory.WriteInt32(TypesPosition + Offset, (int)FontType); + context.Memory.WriteInt32(typesPosition + offset, (int)fontType); - Context.Memory.WriteInt32(OffsetsPosition + Offset, Context.Device.System.Font.GetSharedMemoryAddressOffset(FontType)); + context.Memory.WriteInt32(offsetsPosition + offset, context.Device.System.Font.GetSharedMemoryAddressOffset(fontType)); - Context.Memory.WriteInt32(FontSizeBufferPosition + Offset, Context.Device.System.Font.GetFontSize(FontType)); + context.Memory.WriteInt32(fontSizeBufferPosition + offset, context.Device.System.Font.GetFontSize(fontType)); return true; } diff --git a/Ryujinx.HLE/HOS/Services/Prepo/IPrepoService.cs b/Ryujinx.HLE/HOS/Services/Prepo/IPrepoService.cs index cc96a5c9..f8198fa9 100644 --- a/Ryujinx.HLE/HOS/Services/Prepo/IPrepoService.cs +++ b/Ryujinx.HLE/HOS/Services/Prepo/IPrepoService.cs @@ -6,19 +6,19 @@ namespace Ryujinx.HLE.HOS.Services.Prepo { class IPrepoService : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IPrepoService() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 10101, SaveReportWithUser } }; } - public static long SaveReportWithUser(ServiceCtx Context) + public static long SaveReportWithUser(ServiceCtx context) { Logger.PrintStub(LogClass.ServicePrepo, "Stubbed."); diff --git a/Ryujinx.HLE/HOS/Services/Psm/IPsmServer.cs b/Ryujinx.HLE/HOS/Services/Psm/IPsmServer.cs index 0b45e3c9..c7f6083c 100644 --- a/Ryujinx.HLE/HOS/Services/Psm/IPsmServer.cs +++ b/Ryujinx.HLE/HOS/Services/Psm/IPsmServer.cs @@ -6,20 +6,20 @@ namespace Ryujinx.HLE.HOS.Services.Psm { class IPsmServer : IpcService { - enum ChargerType : int + enum ChargerType { None, ChargerOrDock, UsbC } - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IPsmServer() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, GetBatteryChargePercentage }, { 1, GetChargerType }, @@ -28,21 +28,21 @@ namespace Ryujinx.HLE.HOS.Services.Psm } // GetBatteryChargePercentage() -> u32 - public static long GetBatteryChargePercentage(ServiceCtx Context) + public static long GetBatteryChargePercentage(ServiceCtx context) { - int ChargePercentage = 100; + int chargePercentage = 100; - Context.ResponseData.Write(ChargePercentage); + context.ResponseData.Write(chargePercentage); - Logger.PrintStub(LogClass.ServicePsm, $"Stubbed. ChargePercentage: {ChargePercentage}"); + Logger.PrintStub(LogClass.ServicePsm, $"Stubbed. ChargePercentage: {chargePercentage}"); return 0; } // GetChargerType() -> u32 - public static long GetChargerType(ServiceCtx Context) + public static long GetChargerType(ServiceCtx context) { - Context.ResponseData.Write((int)ChargerType.ChargerOrDock); + context.ResponseData.Write((int)ChargerType.ChargerOrDock); Logger.PrintStub(LogClass.ServicePsm, $"Stubbed. ChargerType: {ChargerType.ChargerOrDock}"); @@ -50,9 +50,9 @@ namespace Ryujinx.HLE.HOS.Services.Psm } // OpenSession() -> IPsmSession - public long OpenSession(ServiceCtx Context) + public long OpenSession(ServiceCtx context) { - MakeObject(Context, new IPsmSession(Context.Device.System)); + MakeObject(context, new IPsmSession(context.Device.System)); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Psm/IPsmSession.cs b/Ryujinx.HLE/HOS/Services/Psm/IPsmSession.cs index 30e5d532..4763f2d5 100644 --- a/Ryujinx.HLE/HOS/Services/Psm/IPsmSession.cs +++ b/Ryujinx.HLE/HOS/Services/Psm/IPsmSession.cs @@ -7,16 +7,16 @@ namespace Ryujinx.HLE.HOS.Services.Psm { class IPsmSession : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private KEvent StateChangeEvent; - private int StateChangeEventHandle; + private KEvent _stateChangeEvent; + private int _stateChangeEventHandle; - public IPsmSession(Horizon System) + public IPsmSession(Horizon system) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, BindStateChangeEvent }, { 1, UnbindStateChangeEvent }, @@ -25,24 +25,24 @@ namespace Ryujinx.HLE.HOS.Services.Psm { 4, SetBatteryVoltageStateChangeEventEnabled } }; - StateChangeEvent = new KEvent(System); - StateChangeEventHandle = -1; + _stateChangeEvent = new KEvent(system); + _stateChangeEventHandle = -1; } // BindStateChangeEvent() -> KObject - public long BindStateChangeEvent(ServiceCtx Context) + public long BindStateChangeEvent(ServiceCtx context) { - if (StateChangeEventHandle == -1) + if (_stateChangeEventHandle == -1) { - KernelResult ResultCode = Context.Process.HandleTable.GenerateHandle(StateChangeEvent, out int StateChangeEventHandle); + KernelResult resultCode = context.Process.HandleTable.GenerateHandle(_stateChangeEvent, out int stateChangeEventHandle); - if (ResultCode != KernelResult.Success) + if (resultCode != KernelResult.Success) { - return (long)ResultCode; + return (long)resultCode; } } - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(StateChangeEventHandle); + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_stateChangeEventHandle); Logger.PrintStub(LogClass.ServicePsm, "Stubbed."); @@ -50,12 +50,12 @@ namespace Ryujinx.HLE.HOS.Services.Psm } // UnbindStateChangeEvent() - public long UnbindStateChangeEvent(ServiceCtx Context) + public long UnbindStateChangeEvent(ServiceCtx context) { - if (StateChangeEventHandle != -1) + if (_stateChangeEventHandle != -1) { - Context.Process.HandleTable.CloseHandle(StateChangeEventHandle); - StateChangeEventHandle = -1; + context.Process.HandleTable.CloseHandle(_stateChangeEventHandle); + _stateChangeEventHandle = -1; } Logger.PrintStub(LogClass.ServicePsm, "Stubbed."); @@ -64,31 +64,31 @@ namespace Ryujinx.HLE.HOS.Services.Psm } // SetChargerTypeChangeEventEnabled(u8) - public long SetChargerTypeChangeEventEnabled(ServiceCtx Context) + public long SetChargerTypeChangeEventEnabled(ServiceCtx context) { - bool ChargerTypeChangeEventEnabled = Context.RequestData.ReadBoolean(); + bool chargerTypeChangeEventEnabled = context.RequestData.ReadBoolean(); - Logger.PrintStub(LogClass.ServicePsm, $"Stubbed. ChargerTypeChangeEventEnabled: {ChargerTypeChangeEventEnabled}"); + Logger.PrintStub(LogClass.ServicePsm, $"Stubbed. ChargerTypeChangeEventEnabled: {chargerTypeChangeEventEnabled}"); return 0; } // SetPowerSupplyChangeEventEnabled(u8) - public long SetPowerSupplyChangeEventEnabled(ServiceCtx Context) + public long SetPowerSupplyChangeEventEnabled(ServiceCtx context) { - bool PowerSupplyChangeEventEnabled = Context.RequestData.ReadBoolean(); + bool powerSupplyChangeEventEnabled = context.RequestData.ReadBoolean(); - Logger.PrintStub(LogClass.ServicePsm, $"Stubbed. PowerSupplyChangeEventEnabled: {PowerSupplyChangeEventEnabled}"); + Logger.PrintStub(LogClass.ServicePsm, $"Stubbed. PowerSupplyChangeEventEnabled: {powerSupplyChangeEventEnabled}"); return 0; } // SetBatteryVoltageStateChangeEventEnabled(u8) - public long SetBatteryVoltageStateChangeEventEnabled(ServiceCtx Context) + public long SetBatteryVoltageStateChangeEventEnabled(ServiceCtx context) { - bool BatteryVoltageStateChangeEventEnabled = Context.RequestData.ReadBoolean(); + bool batteryVoltageStateChangeEventEnabled = context.RequestData.ReadBoolean(); - Logger.PrintStub(LogClass.ServicePsm, $"Stubbed. BatteryVoltageStateChangeEventEnabled: {BatteryVoltageStateChangeEventEnabled}"); + Logger.PrintStub(LogClass.ServicePsm, $"Stubbed. BatteryVoltageStateChangeEventEnabled: {batteryVoltageStateChangeEventEnabled}"); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/ServiceFactory.cs b/Ryujinx.HLE/HOS/Services/ServiceFactory.cs index 2be1db70..3853d82e 100644 --- a/Ryujinx.HLE/HOS/Services/ServiceFactory.cs +++ b/Ryujinx.HLE/HOS/Services/ServiceFactory.cs @@ -31,9 +31,9 @@ namespace Ryujinx.HLE.HOS.Services { static class ServiceFactory { - public static IpcService MakeService(Horizon System, string Name) + public static IpcService MakeService(Horizon system, string name) { - switch (Name) + switch (name) { case "acc:u0": return new IAccountService(); @@ -90,7 +90,7 @@ namespace Ryujinx.HLE.HOS.Services return new IRandomInterface(); case "es": - return new IETicketService(); + return new IeTicketService(); case "friend:a": return new Friend.IServiceCreator(); @@ -102,7 +102,7 @@ namespace Ryujinx.HLE.HOS.Services return new IFileSystemProxy(); case "hid": - return new IHidServer(System); + return new IHidServer(system); case "irs": return new IIrSensorServer(); @@ -141,10 +141,10 @@ namespace Ryujinx.HLE.HOS.Services return new IVulnerabilityManagerInterface(); case "nvdrv": - return new INvDrvServices(System); + return new INvDrvServices(system); case "nvdrv:a": - return new INvDrvServices(System); + return new INvDrvServices(system); case "pctl:s": return new IParentalControlServiceFactory(); @@ -204,7 +204,7 @@ namespace Ryujinx.HLE.HOS.Services return new IApplicationRootService(); } - throw new NotImplementedException(Name); + throw new NotImplementedException(name); } } } diff --git a/Ryujinx.HLE/HOS/Services/Set/ISettingsServer.cs b/Ryujinx.HLE/HOS/Services/Set/ISettingsServer.cs index 690d6de9..bc812d5c 100644 --- a/Ryujinx.HLE/HOS/Services/Set/ISettingsServer.cs +++ b/Ryujinx.HLE/HOS/Services/Set/ISettingsServer.cs @@ -6,13 +6,13 @@ namespace Ryujinx.HLE.HOS.Services.Set { class ISettingsServer : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public ISettingsServer() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, GetLanguageCode }, { 1, GetAvailableLanguageCodes }, @@ -21,57 +21,57 @@ namespace Ryujinx.HLE.HOS.Services.Set }; } - public static long GetLanguageCode(ServiceCtx Context) + public static long GetLanguageCode(ServiceCtx context) { - Context.ResponseData.Write(Context.Device.System.State.DesiredLanguageCode); + context.ResponseData.Write(context.Device.System.State.DesiredLanguageCode); return 0; } - public static long GetAvailableLanguageCodes(ServiceCtx Context) + public static long GetAvailableLanguageCodes(ServiceCtx context) { GetAvailableLanguagesCodesImpl( - Context, - Context.Request.RecvListBuff[0].Position, - Context.Request.RecvListBuff[0].Size); + context, + context.Request.RecvListBuff[0].Position, + context.Request.RecvListBuff[0].Size); return 0; } - public static long GetAvailableLanguageCodeCount(ServiceCtx Context) + public static long GetAvailableLanguageCodeCount(ServiceCtx context) { - Context.ResponseData.Write(SystemStateMgr.LanguageCodes.Length); + context.ResponseData.Write(SystemStateMgr.LanguageCodes.Length); return 0; } - public static long GetAvailableLanguageCodes2(ServiceCtx Context) + public static long GetAvailableLanguageCodes2(ServiceCtx context) { GetAvailableLanguagesCodesImpl( - Context, - Context.Request.ReceiveBuff[0].Position, - Context.Request.ReceiveBuff[0].Size); + context, + context.Request.ReceiveBuff[0].Position, + context.Request.ReceiveBuff[0].Size); return 0; } - public static long GetAvailableLanguagesCodesImpl(ServiceCtx Context, long Position, long Size) + public static long GetAvailableLanguagesCodesImpl(ServiceCtx context, long position, long size) { - int Count = (int)(Size / 8); + int count = (int)(size / 8); - if (Count > SystemStateMgr.LanguageCodes.Length) + if (count > SystemStateMgr.LanguageCodes.Length) { - Count = SystemStateMgr.LanguageCodes.Length; + count = SystemStateMgr.LanguageCodes.Length; } - for (int Index = 0; Index < Count; Index++) + for (int index = 0; index < count; index++) { - Context.Memory.WriteInt64(Position, SystemStateMgr.GetLanguageCode(Index)); + context.Memory.WriteInt64(position, SystemStateMgr.GetLanguageCode(index)); - Position += 8; + position += 8; } - Context.ResponseData.Write(Count); + context.ResponseData.Write(count); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Set/ISystemSettingsServer.cs b/Ryujinx.HLE/HOS/Services/Set/ISystemSettingsServer.cs index 416ea1fb..b4464b77 100644 --- a/Ryujinx.HLE/HOS/Services/Set/ISystemSettingsServer.cs +++ b/Ryujinx.HLE/HOS/Services/Set/ISystemSettingsServer.cs @@ -12,13 +12,13 @@ namespace Ryujinx.HLE.HOS.Services.Set { class ISystemSettingsServer : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public ISystemSettingsServer() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 3, GetFirmwareVersion }, { 4, GetFirmwareVersion2 }, @@ -29,185 +29,185 @@ namespace Ryujinx.HLE.HOS.Services.Set } // GetFirmwareVersion() -> buffer<nn::settings::system::FirmwareVersion, 0x1a, 0x100> - public static long GetFirmwareVersion(ServiceCtx Context) + public static long GetFirmwareVersion(ServiceCtx context) { - return GetFirmwareVersion2(Context); + return GetFirmwareVersion2(context); } // GetFirmwareVersion2() -> buffer<nn::settings::system::FirmwareVersion, 0x1a, 0x100> - public static long GetFirmwareVersion2(ServiceCtx Context) + public static long GetFirmwareVersion2(ServiceCtx context) { - long ReplyPos = Context.Request.RecvListBuff[0].Position; - long ReplySize = Context.Request.RecvListBuff[0].Size; + long replyPos = context.Request.RecvListBuff[0].Position; + long replySize = context.Request.RecvListBuff[0].Size; - byte[] FirmwareData = GetFirmwareData(Context.Device); + byte[] firmwareData = GetFirmwareData(context.Device); - if (FirmwareData != null) + if (firmwareData != null) { - Context.Memory.WriteBytes(ReplyPos, FirmwareData); + context.Memory.WriteBytes(replyPos, firmwareData); return 0; } - const byte MajorFWVersion = 0x03; - const byte MinorFWVersion = 0x00; - const byte MicroFWVersion = 0x00; - const byte Unknown = 0x00; //Build? + const byte majorFwVersion = 0x03; + const byte minorFwVersion = 0x00; + const byte microFwVersion = 0x00; + const byte unknown = 0x00; //Build? - const int RevisionNumber = 0x0A; + const int revisionNumber = 0x0A; - 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 platform = "NX"; + const string unknownHex = "7fbde2b0bba4d14107bf836e4643043d9f6c8e47"; + 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)) + using (MemoryStream ms = new MemoryStream(0x100)) { - BinaryWriter Writer = new BinaryWriter(MS); + BinaryWriter writer = new BinaryWriter(ms); - Writer.Write(MajorFWVersion); - Writer.Write(MinorFWVersion); - Writer.Write(MicroFWVersion); - Writer.Write(Unknown); + writer.Write(majorFwVersion); + writer.Write(minorFwVersion); + writer.Write(microFwVersion); + writer.Write(unknown); - Writer.Write(RevisionNumber); + writer.Write(revisionNumber); - Writer.Write(Encoding.ASCII.GetBytes(Platform)); + writer.Write(Encoding.ASCII.GetBytes(platform)); - MS.Seek(0x28, SeekOrigin.Begin); + ms.Seek(0x28, SeekOrigin.Begin); - Writer.Write(Encoding.ASCII.GetBytes(UnknownHex)); + writer.Write(Encoding.ASCII.GetBytes(unknownHex)); - MS.Seek(0x68, SeekOrigin.Begin); + ms.Seek(0x68, SeekOrigin.Begin); - Writer.Write(Encoding.ASCII.GetBytes(Version)); + writer.Write(Encoding.ASCII.GetBytes(version)); - MS.Seek(0x80, SeekOrigin.Begin); + ms.Seek(0x80, SeekOrigin.Begin); - Writer.Write(Encoding.ASCII.GetBytes(Build)); + writer.Write(Encoding.ASCII.GetBytes(build)); - Context.Memory.WriteBytes(ReplyPos, MS.ToArray()); + context.Memory.WriteBytes(replyPos, ms.ToArray()); } return 0; } // GetColorSetId() -> i32 - public static long GetColorSetId(ServiceCtx Context) + public static long GetColorSetId(ServiceCtx context) { - Context.ResponseData.Write((int)Context.Device.System.State.ThemeColor); + context.ResponseData.Write((int)context.Device.System.State.ThemeColor); return 0; } // GetColorSetId() -> i32 - public static long SetColorSetId(ServiceCtx Context) + public static long SetColorSetId(ServiceCtx context) { - int ColorSetId = Context.RequestData.ReadInt32(); + int colorSetId = context.RequestData.ReadInt32(); - Context.Device.System.State.ThemeColor = (ColorSet)ColorSetId; + context.Device.System.State.ThemeColor = (ColorSet)colorSetId; return 0; } // GetSettingsItemValue(buffer<nn::settings::SettingsName, 0x19, 0x48>, buffer<nn::settings::SettingsItemKey, 0x19, 0x48>) -> (u64, buffer<unknown, 6, 0>) - public static long GetSettingsItemValue(ServiceCtx Context) + public static long GetSettingsItemValue(ServiceCtx context) { - long ClassPos = Context.Request.PtrBuff[0].Position; - long ClassSize = Context.Request.PtrBuff[0].Size; + long classPos = context.Request.PtrBuff[0].Position; + long classSize = context.Request.PtrBuff[0].Size; - long NamePos = Context.Request.PtrBuff[1].Position; - long NameSize = Context.Request.PtrBuff[1].Size; + long namePos = context.Request.PtrBuff[1].Position; + long nameSize = context.Request.PtrBuff[1].Size; - long ReplyPos = Context.Request.ReceiveBuff[0].Position; - long ReplySize = Context.Request.ReceiveBuff[0].Size; + long replyPos = context.Request.ReceiveBuff[0].Position; + long replySize = context.Request.ReceiveBuff[0].Size; - byte[] Class = Context.Memory.ReadBytes(ClassPos, ClassSize); - byte[] Name = Context.Memory.ReadBytes(NamePos, NameSize); + byte[] Class = context.Memory.ReadBytes(classPos, classSize); + byte[] name = context.Memory.ReadBytes(namePos, nameSize); - string AskedSetting = Encoding.ASCII.GetString(Class).Trim('\0') + "!" + Encoding.ASCII.GetString(Name).Trim('\0'); + string askedSetting = Encoding.ASCII.GetString(Class).Trim('\0') + "!" + Encoding.ASCII.GetString(name).Trim('\0'); - NxSettings.Settings.TryGetValue(AskedSetting, out object NxSetting); + NxSettings.Settings.TryGetValue(askedSetting, out object nxSetting); - if (NxSetting != null) + if (nxSetting != null) { - byte[] SettingBuffer = new byte[ReplySize]; + byte[] settingBuffer = new byte[replySize]; - if (NxSetting is string StringValue) + if (nxSetting is string stringValue) { - if (StringValue.Length + 1 > ReplySize) + if (stringValue.Length + 1 > replySize) { - Logger.PrintError(LogClass.ServiceSet, $"{AskedSetting} String value size is too big!"); + Logger.PrintError(LogClass.ServiceSet, $"{askedSetting} String value size is too big!"); } else { - SettingBuffer = Encoding.ASCII.GetBytes(StringValue + "\0"); + settingBuffer = Encoding.ASCII.GetBytes(stringValue + "\0"); } } - if (NxSetting is int IntValue) + if (nxSetting is int intValue) { - SettingBuffer = BitConverter.GetBytes(IntValue); + settingBuffer = BitConverter.GetBytes(intValue); } - else if (NxSetting is bool BoolValue) + else if (nxSetting is bool boolValue) { - SettingBuffer[0] = BoolValue ? (byte)1 : (byte)0; + settingBuffer[0] = boolValue ? (byte)1 : (byte)0; } else { - throw new NotImplementedException(NxSetting.GetType().Name); + throw new NotImplementedException(nxSetting.GetType().Name); } - Context.Memory.WriteBytes(ReplyPos, SettingBuffer); + context.Memory.WriteBytes(replyPos, settingBuffer); - Logger.PrintDebug(LogClass.ServiceSet, $"{AskedSetting} set value: {NxSetting} as {NxSetting.GetType()}"); + Logger.PrintDebug(LogClass.ServiceSet, $"{askedSetting} set value: {nxSetting} as {nxSetting.GetType()}"); } else { - Logger.PrintError(LogClass.ServiceSet, $"{AskedSetting} not found!"); + Logger.PrintError(LogClass.ServiceSet, $"{askedSetting} not found!"); } return 0; } - public static byte[] GetFirmwareData(Switch Device) + public static byte[] GetFirmwareData(Switch device) { - byte[] Data = null; - long TitleId = 0x0100000000000809; - string ContentPath = Device.System.ContentManager.GetInstalledContentPath(TitleId, StorageId.NandSystem, ContentType.Data); + byte[] data = null; + long titleId = 0x0100000000000809; + string contentPath = device.System.ContentManager.GetInstalledContentPath(titleId, StorageId.NandSystem, ContentType.Data); - if(string.IsNullOrWhiteSpace(ContentPath)) + if(string.IsNullOrWhiteSpace(contentPath)) { return null; } - string FirmwareTitlePath = Device.FileSystem.SwitchPathToSystemPath(ContentPath); - FileStream FirmwareStream = File.Open(FirmwareTitlePath, FileMode.Open, FileAccess.Read); - Nca FirmwareContent = new Nca(Device.System.KeySet, FirmwareStream, false); - Stream RomFsStream = FirmwareContent.OpenSection(0, false, Device.System.FsIntegrityCheckLevel); + string firmwareTitlePath = device.FileSystem.SwitchPathToSystemPath(contentPath); + FileStream firmwareStream = File.Open(firmwareTitlePath, FileMode.Open, FileAccess.Read); + Nca firmwareContent = new Nca(device.System.KeySet, firmwareStream, false); + Stream romFsStream = firmwareContent.OpenSection(0, false, device.System.FsIntegrityCheckLevel); - if(RomFsStream == null) + if(romFsStream == null) { return null; } - Romfs FirmwareRomFs = new Romfs(RomFsStream); + Romfs firmwareRomFs = new Romfs(romFsStream); - using(MemoryStream MemoryStream = new MemoryStream()) + using(MemoryStream memoryStream = new MemoryStream()) { - using (Stream FirmwareFile = FirmwareRomFs.OpenFile("/file")) + using (Stream firmwareFile = firmwareRomFs.OpenFile("/file")) { - FirmwareFile.CopyTo(MemoryStream); + firmwareFile.CopyTo(memoryStream); } - Data = MemoryStream.ToArray(); + data = memoryStream.ToArray(); } - FirmwareContent.Dispose(); - FirmwareStream.Dispose(); + firmwareContent.Dispose(); + firmwareStream.Dispose(); - return Data; + return data; } } } diff --git a/Ryujinx.HLE/HOS/Services/Set/NxSettings.cs b/Ryujinx.HLE/HOS/Services/Set/NxSettings.cs index 7d1dd2ed..70ab55f9 100644 --- a/Ryujinx.HLE/HOS/Services/Set/NxSettings.cs +++ b/Ryujinx.HLE/HOS/Services/Set/NxSettings.cs @@ -5,7 +5,7 @@ namespace Ryujinx.HLE.HOS.Services.Set 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 Dictionary<string, object> { { "account!na_required_for_network_service", true }, { "account.daemon!background_awaking_periodicity", 10800 }, @@ -1705,7 +1705,7 @@ namespace Ryujinx.HLE.HOS.Services.Set { "time!standard_steady_clock_rtc_update_interval_minutes", 5 }, { "time!standard_network_clock_sufficient_accuracy_minutes", 43200 }, { "usb!usb30_force_enabled", false }, - { "wlan_debug!skip_wlan_boot", false }, + { "wlan_debug!skip_wlan_boot", false } }; } } diff --git a/Ryujinx.HLE/HOS/Services/Sfdnsres/GaiError.cs b/Ryujinx.HLE/HOS/Services/Sfdnsres/GaiError.cs index 65d54577..2d3d8e9b 100644 --- a/Ryujinx.HLE/HOS/Services/Sfdnsres/GaiError.cs +++ b/Ryujinx.HLE/HOS/Services/Sfdnsres/GaiError.cs @@ -17,6 +17,6 @@ BadHints, Protocol, Overflow, - Max, + Max } } diff --git a/Ryujinx.HLE/HOS/Services/Sfdnsres/IResolver.cs b/Ryujinx.HLE/HOS/Services/Sfdnsres/IResolver.cs index a351e3de..5de03551 100644 --- a/Ryujinx.HLE/HOS/Services/Sfdnsres/IResolver.cs +++ b/Ryujinx.HLE/HOS/Services/Sfdnsres/IResolver.cs @@ -12,13 +12,13 @@ namespace Ryujinx.HLE.HOS.Services.Sfdnsres { class IResolver : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IResolver() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, SetDnsAddressesPrivate }, { 1, GetDnsAddressesPrivate }, @@ -28,65 +28,65 @@ namespace Ryujinx.HLE.HOS.Services.Sfdnsres { 5, GetGaiStringError }, { 8, RequestCancelHandle }, { 9, CancelSocketCall }, - { 11, ClearDnsAddresses }, + { 11, ClearDnsAddresses } }; } - private long SerializeHostEnt(ServiceCtx Context, IPHostEntry HostEntry, List<IPAddress> Addresses = null) + private long SerializeHostEnt(ServiceCtx context, IPHostEntry hostEntry, List<IPAddress> addresses = null) { - long OriginalBufferPosition = Context.Request.ReceiveBuff[0].Position; - long BufferPosition = OriginalBufferPosition; - long BufferSize = Context.Request.ReceiveBuff[0].Size; + long originalBufferPosition = context.Request.ReceiveBuff[0].Position; + long bufferPosition = originalBufferPosition; + long bufferSize = context.Request.ReceiveBuff[0].Size; - string HostName = HostEntry.HostName + '\0'; + string hostName = hostEntry.HostName + '\0'; // h_name - Context.Memory.WriteBytes(BufferPosition, Encoding.ASCII.GetBytes(HostName)); - BufferPosition += HostName.Length; + context.Memory.WriteBytes(bufferPosition, Encoding.ASCII.GetBytes(hostName)); + bufferPosition += hostName.Length; // h_aliases list size - Context.Memory.WriteInt32(BufferPosition, IPAddress.HostToNetworkOrder(HostEntry.Aliases.Length)); - BufferPosition += 4; + context.Memory.WriteInt32(bufferPosition, IPAddress.HostToNetworkOrder(hostEntry.Aliases.Length)); + bufferPosition += 4; // Actual aliases - foreach (string Alias in HostEntry.Aliases) + foreach (string alias in hostEntry.Aliases) { - Context.Memory.WriteBytes(BufferPosition, Encoding.ASCII.GetBytes(Alias + '\0')); - BufferPosition += Alias.Length + 1; + context.Memory.WriteBytes(bufferPosition, Encoding.ASCII.GetBytes(alias + '\0')); + bufferPosition += alias.Length + 1; } // h_addrtype but it's a short (also only support IPv4) - Context.Memory.WriteInt16(BufferPosition, IPAddress.HostToNetworkOrder((short)2)); - BufferPosition += 2; + context.Memory.WriteInt16(bufferPosition, IPAddress.HostToNetworkOrder((short)2)); + bufferPosition += 2; // h_length but it's a short - Context.Memory.WriteInt16(BufferPosition, IPAddress.HostToNetworkOrder((short)4)); - BufferPosition += 2; + context.Memory.WriteInt16(bufferPosition, IPAddress.HostToNetworkOrder((short)4)); + bufferPosition += 2; // Ip address count, we can only support ipv4 (blame Nintendo) - Context.Memory.WriteInt32(BufferPosition, Addresses != null ? IPAddress.HostToNetworkOrder(Addresses.Count) : 0); - BufferPosition += 4; + context.Memory.WriteInt32(bufferPosition, addresses != null ? IPAddress.HostToNetworkOrder(addresses.Count) : 0); + bufferPosition += 4; - if (Addresses != null) + if (addresses != null) { - foreach (IPAddress Ip in Addresses) + foreach (IPAddress ip in addresses) { - Context.Memory.WriteInt32(BufferPosition, IPAddress.HostToNetworkOrder(BitConverter.ToInt32(Ip.GetAddressBytes(), 0))); - BufferPosition += 4; + context.Memory.WriteInt32(bufferPosition, IPAddress.HostToNetworkOrder(BitConverter.ToInt32(ip.GetAddressBytes(), 0))); + bufferPosition += 4; } } - return BufferPosition - OriginalBufferPosition; + return bufferPosition - originalBufferPosition; } - private string GetGaiStringErrorFromErrorCode(GaiError ErrorCode) + private string GetGaiStringErrorFromErrorCode(GaiError errorCode) { - if (ErrorCode > GaiError.Max) + if (errorCode > GaiError.Max) { - ErrorCode = GaiError.Max; + errorCode = GaiError.Max; } - switch (ErrorCode) + switch (errorCode) { case GaiError.AddressFamily: return "Address family for hostname not supported"; @@ -123,275 +123,275 @@ namespace Ryujinx.HLE.HOS.Services.Sfdnsres } } - private string GetHostStringErrorFromErrorCode(NetDBError ErrorCode) + private string GetHostStringErrorFromErrorCode(NetDbError errorCode) { - if (ErrorCode <= NetDBError.Internal) + if (errorCode <= NetDbError.Internal) { return "Resolver internal error"; } - switch (ErrorCode) + switch (errorCode) { - case NetDBError.Success: + case NetDbError.Success: return "Resolver Error 0 (no error)"; - case NetDBError.HostNotFound: + case NetDbError.HostNotFound: return "Unknown host"; - case NetDBError.TryAgain: + case NetDbError.TryAgain: return "Host name lookup failure"; - case NetDBError.NoRecovery: + case NetDbError.NoRecovery: return "Unknown server error"; - case NetDBError.NoData: + case NetDbError.NoData: return "No address associated with name"; default: return "Unknown resolver error"; } } - private List<IPAddress> GetIPV4Addresses(IPHostEntry HostEntry) + private List<IPAddress> GetIpv4Addresses(IPHostEntry hostEntry) { - List<IPAddress> Result = new List<IPAddress>(); - foreach (IPAddress Ip in HostEntry.AddressList) + List<IPAddress> result = new List<IPAddress>(); + foreach (IPAddress ip in hostEntry.AddressList) { - if (Ip.AddressFamily == AddressFamily.InterNetwork) - Result.Add(Ip); + if (ip.AddressFamily == AddressFamily.InterNetwork) + result.Add(ip); } - return Result; + return result; } // SetDnsAddressesPrivate(u32, buffer<unknown, 5, 0>) - public long SetDnsAddressesPrivate(ServiceCtx Context) + public long SetDnsAddressesPrivate(ServiceCtx context) { - uint Unknown0 = Context.RequestData.ReadUInt32(); - long BufferPosition = Context.Request.SendBuff[0].Position; - long BufferSize = Context.Request.SendBuff[0].Size; + uint unknown0 = context.RequestData.ReadUInt32(); + long bufferPosition = context.Request.SendBuff[0].Position; + long bufferSize = context.Request.SendBuff[0].Size; // TODO: This is stubbed in 2.0.0+, reverse 1.0.0 version for the sake completeness. - Logger.PrintStub(LogClass.ServiceSfdnsres, $"Stubbed. Unknown0: {Unknown0}"); + Logger.PrintStub(LogClass.ServiceSfdnsres, $"Stubbed. Unknown0: {unknown0}"); return MakeError(ErrorModule.Os, 1023); } // GetDnsAddressPrivate(u32) -> buffer<unknown, 6, 0> - public long GetDnsAddressesPrivate(ServiceCtx Context) + public long GetDnsAddressesPrivate(ServiceCtx context) { - uint Unknown0 = Context.RequestData.ReadUInt32(); + uint unknown0 = context.RequestData.ReadUInt32(); // TODO: This is stubbed in 2.0.0+, reverse 1.0.0 version for the sake completeness. - Logger.PrintStub(LogClass.ServiceSfdnsres, $"Stubbed. Unknown0: {Unknown0}"); + Logger.PrintStub(LogClass.ServiceSfdnsres, $"Stubbed. Unknown0: {unknown0}"); return MakeError(ErrorModule.Os, 1023); } // GetHostByName(u8, u32, u64, pid, buffer<unknown, 5, 0>) -> (u32, u32, u32, buffer<unknown, 6, 0>) - public long GetHostByName(ServiceCtx Context) + public long GetHostByName(ServiceCtx context) { - byte[] RawName = Context.Memory.ReadBytes(Context.Request.SendBuff[0].Position, Context.Request.SendBuff[0].Size); - string Name = Encoding.ASCII.GetString(RawName).TrimEnd('\0'); + byte[] rawName = context.Memory.ReadBytes(context.Request.SendBuff[0].Position, context.Request.SendBuff[0].Size); + string name = Encoding.ASCII.GetString(rawName).TrimEnd('\0'); // TODO: use params - bool EnableNsdResolve = Context.RequestData.ReadInt32() == 1; - int TimeOut = Context.RequestData.ReadInt32(); - ulong PidPlaceholder = Context.RequestData.ReadUInt64(); + bool enableNsdResolve = context.RequestData.ReadInt32() == 1; + int timeOut = context.RequestData.ReadInt32(); + ulong pidPlaceholder = context.RequestData.ReadUInt64(); - IPHostEntry HostEntry = null; + IPHostEntry hostEntry = null; - NetDBError NetDBErrorCode = NetDBError.Success; - GaiError Errno = GaiError.Overflow; - long SerializedSize = 0; + NetDbError netDbErrorCode = NetDbError.Success; + GaiError errno = GaiError.Overflow; + long serializedSize = 0; - if (Name.Length <= 255) + if (name.Length <= 255) { try { - HostEntry = Dns.GetHostEntry(Name); + hostEntry = Dns.GetHostEntry(name); } - catch (SocketException Exception) + catch (SocketException exception) { - NetDBErrorCode = NetDBError.Internal; + netDbErrorCode = NetDbError.Internal; - if (Exception.ErrorCode == 11001) + if (exception.ErrorCode == 11001) { - NetDBErrorCode = NetDBError.HostNotFound; - Errno = GaiError.NoData; + netDbErrorCode = NetDbError.HostNotFound; + errno = GaiError.NoData; } - else if (Exception.ErrorCode == 11002) + else if (exception.ErrorCode == 11002) { - NetDBErrorCode = NetDBError.TryAgain; + netDbErrorCode = NetDbError.TryAgain; } - else if (Exception.ErrorCode == 11003) + else if (exception.ErrorCode == 11003) { - NetDBErrorCode = NetDBError.NoRecovery; + netDbErrorCode = NetDbError.NoRecovery; } - else if (Exception.ErrorCode == 11004) + else if (exception.ErrorCode == 11004) { - NetDBErrorCode = NetDBError.NoData; + netDbErrorCode = NetDbError.NoData; } - else if (Exception.ErrorCode == 10060) + else if (exception.ErrorCode == 10060) { - Errno = GaiError.Again; + errno = GaiError.Again; } } } else { - NetDBErrorCode = NetDBError.HostNotFound; + netDbErrorCode = NetDbError.HostNotFound; } - if (HostEntry != null) + if (hostEntry != null) { - Errno = GaiError.Success; + errno = GaiError.Success; - List<IPAddress> Addresses = GetIPV4Addresses(HostEntry); + List<IPAddress> addresses = GetIpv4Addresses(hostEntry); - if (Addresses.Count == 0) + if (addresses.Count == 0) { - Errno = GaiError.NoData; - NetDBErrorCode = NetDBError.NoAddress; + errno = GaiError.NoData; + netDbErrorCode = NetDbError.NoAddress; } else { - SerializedSize = SerializeHostEnt(Context, HostEntry, Addresses); + serializedSize = SerializeHostEnt(context, hostEntry, addresses); } } - Context.ResponseData.Write((int)NetDBErrorCode); - Context.ResponseData.Write((int)Errno); - Context.ResponseData.Write(SerializedSize); + context.ResponseData.Write((int)netDbErrorCode); + context.ResponseData.Write((int)errno); + context.ResponseData.Write(serializedSize); return 0; } // GetHostByAddr(u32, u32, u32, u64, pid, buffer<unknown, 5, 0>) -> (u32, u32, u32, buffer<unknown, 6, 0>) - public long GetHostByAddress(ServiceCtx Context) + public long GetHostByAddress(ServiceCtx context) { - byte[] RawIp = Context.Memory.ReadBytes(Context.Request.SendBuff[0].Position, Context.Request.SendBuff[0].Size); + byte[] rawIp = context.Memory.ReadBytes(context.Request.SendBuff[0].Position, context.Request.SendBuff[0].Size); // TODO: use params - uint SocketLength = Context.RequestData.ReadUInt32(); - uint Type = Context.RequestData.ReadUInt32(); - int TimeOut = Context.RequestData.ReadInt32(); - ulong PidPlaceholder = Context.RequestData.ReadUInt64(); + uint socketLength = context.RequestData.ReadUInt32(); + uint type = context.RequestData.ReadUInt32(); + int timeOut = context.RequestData.ReadInt32(); + ulong pidPlaceholder = context.RequestData.ReadUInt64(); - IPHostEntry HostEntry = null; + IPHostEntry hostEntry = null; - NetDBError NetDBErrorCode = NetDBError.Success; - GaiError Errno = GaiError.AddressFamily; - long SerializedSize = 0; + NetDbError netDbErrorCode = NetDbError.Success; + GaiError errno = GaiError.AddressFamily; + long serializedSize = 0; - if (RawIp.Length == 4) + if (rawIp.Length == 4) { try { - IPAddress Address = new IPAddress(RawIp); + IPAddress address = new IPAddress(rawIp); - HostEntry = Dns.GetHostEntry(Address); + hostEntry = Dns.GetHostEntry(address); } - catch (SocketException Exception) + catch (SocketException exception) { - NetDBErrorCode = NetDBError.Internal; - if (Exception.ErrorCode == 11001) + netDbErrorCode = NetDbError.Internal; + if (exception.ErrorCode == 11001) { - NetDBErrorCode = NetDBError.HostNotFound; - Errno = GaiError.NoData; + netDbErrorCode = NetDbError.HostNotFound; + errno = GaiError.NoData; } - else if (Exception.ErrorCode == 11002) + else if (exception.ErrorCode == 11002) { - NetDBErrorCode = NetDBError.TryAgain; + netDbErrorCode = NetDbError.TryAgain; } - else if (Exception.ErrorCode == 11003) + else if (exception.ErrorCode == 11003) { - NetDBErrorCode = NetDBError.NoRecovery; + netDbErrorCode = NetDbError.NoRecovery; } - else if (Exception.ErrorCode == 11004) + else if (exception.ErrorCode == 11004) { - NetDBErrorCode = NetDBError.NoData; + netDbErrorCode = NetDbError.NoData; } - else if (Exception.ErrorCode == 10060) + else if (exception.ErrorCode == 10060) { - Errno = GaiError.Again; + errno = GaiError.Again; } } } else { - NetDBErrorCode = NetDBError.NoAddress; + netDbErrorCode = NetDbError.NoAddress; } - if (HostEntry != null) + if (hostEntry != null) { - Errno = GaiError.Success; - SerializedSize = SerializeHostEnt(Context, HostEntry, GetIPV4Addresses(HostEntry)); + errno = GaiError.Success; + serializedSize = SerializeHostEnt(context, hostEntry, GetIpv4Addresses(hostEntry)); } - Context.ResponseData.Write((int)NetDBErrorCode); - Context.ResponseData.Write((int)Errno); - Context.ResponseData.Write(SerializedSize); + context.ResponseData.Write((int)netDbErrorCode); + context.ResponseData.Write((int)errno); + context.ResponseData.Write(serializedSize); return 0; } // GetHostStringError(u32) -> buffer<unknown, 6, 0> - public long GetHostStringError(ServiceCtx Context) + public long GetHostStringError(ServiceCtx context) { - long ResultCode = MakeError(ErrorModule.Os, 1023); - NetDBError ErrorCode = (NetDBError)Context.RequestData.ReadInt32(); - string ErrorString = GetHostStringErrorFromErrorCode(ErrorCode); + long resultCode = MakeError(ErrorModule.Os, 1023); + NetDbError errorCode = (NetDbError)context.RequestData.ReadInt32(); + string errorString = GetHostStringErrorFromErrorCode(errorCode); - if (ErrorString.Length + 1 <= Context.Request.ReceiveBuff[0].Size) + if (errorString.Length + 1 <= context.Request.ReceiveBuff[0].Size) { - ResultCode = 0; - Context.Memory.WriteBytes(Context.Request.ReceiveBuff[0].Position, Encoding.ASCII.GetBytes(ErrorString + '\0')); + resultCode = 0; + context.Memory.WriteBytes(context.Request.ReceiveBuff[0].Position, Encoding.ASCII.GetBytes(errorString + '\0')); } - return ResultCode; + return resultCode; } // GetGaiStringError(u32) -> buffer<unknown, 6, 0> - public long GetGaiStringError(ServiceCtx Context) + public long GetGaiStringError(ServiceCtx context) { - long ResultCode = MakeError(ErrorModule.Os, 1023); - GaiError ErrorCode = (GaiError)Context.RequestData.ReadInt32(); - string ErrorString = GetGaiStringErrorFromErrorCode(ErrorCode); + long resultCode = MakeError(ErrorModule.Os, 1023); + GaiError errorCode = (GaiError)context.RequestData.ReadInt32(); + string errorString = GetGaiStringErrorFromErrorCode(errorCode); - if (ErrorString.Length + 1 <= Context.Request.ReceiveBuff[0].Size) + if (errorString.Length + 1 <= context.Request.ReceiveBuff[0].Size) { - ResultCode = 0; - Context.Memory.WriteBytes(Context.Request.ReceiveBuff[0].Position, Encoding.ASCII.GetBytes(ErrorString + '\0')); + resultCode = 0; + context.Memory.WriteBytes(context.Request.ReceiveBuff[0].Position, Encoding.ASCII.GetBytes(errorString + '\0')); } - return ResultCode; + return resultCode; } // RequestCancelHandle(u64, pid) -> u32 - public long RequestCancelHandle(ServiceCtx Context) + public long RequestCancelHandle(ServiceCtx context) { - ulong Unknown0 = Context.RequestData.ReadUInt64(); + ulong unknown0 = context.RequestData.ReadUInt64(); - Context.ResponseData.Write(0); + context.ResponseData.Write(0); - Logger.PrintStub(LogClass.ServiceSfdnsres, $"Stubbed. Unknown0: {Unknown0}"); + Logger.PrintStub(LogClass.ServiceSfdnsres, $"Stubbed. Unknown0: {unknown0}"); return 0; } // CancelSocketCall(u32, u64, pid) - public long CancelSocketCall(ServiceCtx Context) + public long CancelSocketCall(ServiceCtx context) { - uint Unknown0 = Context.RequestData.ReadUInt32(); - ulong Unknown1 = Context.RequestData.ReadUInt64(); + uint unknown0 = context.RequestData.ReadUInt32(); + ulong unknown1 = context.RequestData.ReadUInt64(); - Logger.PrintStub(LogClass.ServiceSfdnsres, $"Stubbed. Unknown0: {Unknown0} - " + - $"Unknown1: {Unknown1}"); + Logger.PrintStub(LogClass.ServiceSfdnsres, $"Stubbed. Unknown0: {unknown0} - " + + $"Unknown1: {unknown1}"); return 0; } // ClearDnsAddresses(u32) - public long ClearDnsAddresses(ServiceCtx Context) + public long ClearDnsAddresses(ServiceCtx context) { - uint Unknown0 = Context.RequestData.ReadUInt32(); + uint unknown0 = context.RequestData.ReadUInt32(); - Logger.PrintStub(LogClass.ServiceSfdnsres, $"Stubbed. Unknown0: {Unknown0}"); + Logger.PrintStub(LogClass.ServiceSfdnsres, $"Stubbed. Unknown0: {unknown0}"); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Sfdnsres/NetDBError.cs b/Ryujinx.HLE/HOS/Services/Sfdnsres/NetDBError.cs index 6c1b7825..dad02cf2 100644 --- a/Ryujinx.HLE/HOS/Services/Sfdnsres/NetDBError.cs +++ b/Ryujinx.HLE/HOS/Services/Sfdnsres/NetDBError.cs @@ -1,6 +1,6 @@ namespace Ryujinx.HLE.HOS.Services.Sfdnsres { - enum NetDBError + enum NetDbError { Internal = -1, Success, @@ -8,6 +8,6 @@ TryAgain, NoRecovery, NoData, - NoAddress = NoData, + NoAddress = NoData } } diff --git a/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs b/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs index 0c26b7d9..2bfafd95 100644 --- a/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs +++ b/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs @@ -7,15 +7,15 @@ namespace Ryujinx.HLE.HOS.Services.Sm { class IUserInterface : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private bool IsInitialized; + private bool _isInitialized; public IUserInterface() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, Initialize }, { 1, GetService } @@ -24,48 +24,48 @@ namespace Ryujinx.HLE.HOS.Services.Sm private const int SmNotInitialized = 0x415; - public long Initialize(ServiceCtx Context) + public long Initialize(ServiceCtx context) { - IsInitialized = true; + _isInitialized = true; return 0; } - public long GetService(ServiceCtx Context) + public long GetService(ServiceCtx context) { //Only for kernel version > 3.0.0. - if (!IsInitialized) + if (!_isInitialized) { //return SmNotInitialized; } - string Name = string.Empty; + string name = string.Empty; - for (int Index = 0; Index < 8 && - Context.RequestData.BaseStream.Position < - Context.RequestData.BaseStream.Length; Index++) + for (int index = 0; index < 8 && + context.RequestData.BaseStream.Position < + context.RequestData.BaseStream.Length; index++) { - byte Chr = Context.RequestData.ReadByte(); + byte chr = context.RequestData.ReadByte(); - if (Chr >= 0x20 && Chr < 0x7f) + if (chr >= 0x20 && chr < 0x7f) { - Name += (char)Chr; + name += (char)chr; } } - if (Name == string.Empty) + if (name == string.Empty) { return 0; } - KSession Session = new KSession(ServiceFactory.MakeService(Context.Device.System, Name), Name); + KSession session = new KSession(ServiceFactory.MakeService(context.Device.System, name), name); - if (Context.Process.HandleTable.GenerateHandle(Session, out int Handle) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(session, out int handle) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } - Context.Response.HandleDesc = IpcHandleDesc.MakeMove(Handle); + context.Response.HandleDesc = IpcHandleDesc.MakeMove(handle); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Spl/IRandomInterface.cs b/Ryujinx.HLE/HOS/Services/Spl/IRandomInterface.cs index 6391d981..cae8d8d0 100644 --- a/Ryujinx.HLE/HOS/Services/Spl/IRandomInterface.cs +++ b/Ryujinx.HLE/HOS/Services/Spl/IRandomInterface.cs @@ -7,29 +7,29 @@ namespace Ryujinx.HLE.HOS.Services.Spl { class IRandomInterface : IpcService, IDisposable { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private RNGCryptoServiceProvider Rng; + private RNGCryptoServiceProvider _rng; public IRandomInterface() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, GetRandomBytes } }; - Rng = new RNGCryptoServiceProvider(); + _rng = new RNGCryptoServiceProvider(); } - public long GetRandomBytes(ServiceCtx Context) + public long GetRandomBytes(ServiceCtx context) { - byte[] RandomBytes = new byte[Context.Request.ReceiveBuff[0].Size]; + byte[] randomBytes = new byte[context.Request.ReceiveBuff[0].Size]; - Rng.GetBytes(RandomBytes); + _rng.GetBytes(randomBytes); - Context.Memory.WriteBytes(Context.Request.ReceiveBuff[0].Position, RandomBytes); + context.Memory.WriteBytes(context.Request.ReceiveBuff[0].Position, randomBytes); return 0; } @@ -39,11 +39,11 @@ namespace Ryujinx.HLE.HOS.Services.Spl Dispose(true); } - protected virtual void Dispose(bool Disposing) + protected virtual void Dispose(bool disposing) { - if (Disposing) + if (disposing) { - Rng.Dispose(); + _rng.Dispose(); } } } diff --git a/Ryujinx.HLE/HOS/Services/Ssl/ISslContext.cs b/Ryujinx.HLE/HOS/Services/Ssl/ISslContext.cs index 8f3a0649..cf58ed87 100644 --- a/Ryujinx.HLE/HOS/Services/Ssl/ISslContext.cs +++ b/Ryujinx.HLE/HOS/Services/Ssl/ISslContext.cs @@ -5,13 +5,13 @@ namespace Ryujinx.HLE.HOS.Services.Ssl { class ISslContext : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public ISslContext() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { //... }; diff --git a/Ryujinx.HLE/HOS/Services/Ssl/ISslService.cs b/Ryujinx.HLE/HOS/Services/Ssl/ISslService.cs index 3046aab7..b40e9473 100644 --- a/Ryujinx.HLE/HOS/Services/Ssl/ISslService.cs +++ b/Ryujinx.HLE/HOS/Services/Ssl/ISslService.cs @@ -6,13 +6,13 @@ namespace Ryujinx.HLE.HOS.Services.Ssl { class ISslService : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public ISslService() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, CreateContext }, { 5, SetInterfaceVersion } @@ -20,24 +20,24 @@ namespace Ryujinx.HLE.HOS.Services.Ssl } // CreateContext(nn::ssl::sf::SslVersion, u64, pid) -> object<nn::ssl::sf::ISslContext> - public long CreateContext(ServiceCtx Context) + public long CreateContext(ServiceCtx context) { - int SslVersion = Context.RequestData.ReadInt32(); - long Unknown = Context.RequestData.ReadInt64(); + int sslVersion = context.RequestData.ReadInt32(); + long unknown = context.RequestData.ReadInt64(); - Logger.PrintStub(LogClass.ServiceSsl, $"Stubbed. SslVersion: {SslVersion} - Unknown: {Unknown}"); + Logger.PrintStub(LogClass.ServiceSsl, $"Stubbed. SslVersion: {sslVersion} - Unknown: {unknown}"); - MakeObject(Context, new ISslContext()); + MakeObject(context, new ISslContext()); return 0; } // SetInterfaceVersion(u32) - public long SetInterfaceVersion(ServiceCtx Context) + public long SetInterfaceVersion(ServiceCtx context) { - int Version = Context.RequestData.ReadInt32(); + int version = context.RequestData.ReadInt32(); - Logger.PrintStub(LogClass.ServiceSsl, $"Stubbed. Version: {Version}"); + Logger.PrintStub(LogClass.ServiceSsl, $"Stubbed. Version: {version}"); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Time/IStaticService.cs b/Ryujinx.HLE/HOS/Services/Time/IStaticService.cs index 66f16501..fcbaa492 100644 --- a/Ryujinx.HLE/HOS/Services/Time/IStaticService.cs +++ b/Ryujinx.HLE/HOS/Services/Time/IStaticService.cs @@ -6,15 +6,15 @@ namespace Ryujinx.HLE.HOS.Services.Time { class IStaticService : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; private static readonly DateTime StartupDate = DateTime.UtcNow; public IStaticService() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, GetStandardUserSystemClock }, { 1, GetStandardNetworkSystemClock }, @@ -25,47 +25,47 @@ namespace Ryujinx.HLE.HOS.Services.Time }; } - public long GetStandardUserSystemClock(ServiceCtx Context) + public long GetStandardUserSystemClock(ServiceCtx context) { - MakeObject(Context, new ISystemClock(SystemClockType.User)); + MakeObject(context, new ISystemClock(SystemClockType.User)); return 0; } - public long GetStandardNetworkSystemClock(ServiceCtx Context) + public long GetStandardNetworkSystemClock(ServiceCtx context) { - MakeObject(Context, new ISystemClock(SystemClockType.Network)); + MakeObject(context, new ISystemClock(SystemClockType.Network)); return 0; } - public long GetStandardSteadyClock(ServiceCtx Context) + public long GetStandardSteadyClock(ServiceCtx context) { - MakeObject(Context, new ISteadyClock()); + MakeObject(context, new ISteadyClock()); return 0; } - public long GetTimeZoneService(ServiceCtx Context) + public long GetTimeZoneService(ServiceCtx context) { - MakeObject(Context, new ITimeZoneService()); + MakeObject(context, new ITimeZoneService()); return 0; } - public long GetStandardLocalSystemClock(ServiceCtx Context) + public long GetStandardLocalSystemClock(ServiceCtx context) { - MakeObject(Context, new ISystemClock(SystemClockType.Local)); + MakeObject(context, new ISystemClock(SystemClockType.Local)); return 0; } - public long CalculateMonotonicSystemClockBaseTimePoint(ServiceCtx Context) + public long CalculateMonotonicSystemClockBaseTimePoint(ServiceCtx context) { - long TimeOffset = (long)(DateTime.UtcNow - StartupDate).TotalSeconds; - long SystemClockContextEpoch = Context.RequestData.ReadInt64(); + long timeOffset = (long)(DateTime.UtcNow - StartupDate).TotalSeconds; + long systemClockContextEpoch = context.RequestData.ReadInt64(); - Context.ResponseData.Write(TimeOffset + SystemClockContextEpoch); + context.ResponseData.Write(timeOffset + systemClockContextEpoch); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Time/ISteadyClock.cs b/Ryujinx.HLE/HOS/Services/Time/ISteadyClock.cs index e4020bb1..f535ed9c 100644 --- a/Ryujinx.HLE/HOS/Services/Time/ISteadyClock.cs +++ b/Ryujinx.HLE/HOS/Services/Time/ISteadyClock.cs @@ -6,46 +6,46 @@ namespace Ryujinx.HLE.HOS.Services.Time { class ISteadyClock : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private ulong TestOffset; + private ulong _testOffset; public ISteadyClock() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, GetCurrentTimePoint }, { 1, GetTestOffset }, { 2, SetTestOffset } }; - TestOffset = 0; + _testOffset = 0; } - public long GetCurrentTimePoint(ServiceCtx Context) + public long GetCurrentTimePoint(ServiceCtx context) { - Context.ResponseData.Write((long)(System.Diagnostics.Process.GetCurrentProcess().StartTime - DateTime.Now).TotalSeconds); + context.ResponseData.Write((long)(System.Diagnostics.Process.GetCurrentProcess().StartTime - DateTime.Now).TotalSeconds); for (int i = 0; i < 0x10; i++) { - Context.ResponseData.Write((byte)0); + context.ResponseData.Write((byte)0); } return 0; } - public long GetTestOffset(ServiceCtx Context) + public long GetTestOffset(ServiceCtx context) { - Context.ResponseData.Write(TestOffset); + context.ResponseData.Write(_testOffset); return 0; } - public long SetTestOffset(ServiceCtx Context) + public long SetTestOffset(ServiceCtx context) { - TestOffset = Context.RequestData.ReadUInt64(); + _testOffset = context.RequestData.ReadUInt64(); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Time/ISystemClock.cs b/Ryujinx.HLE/HOS/Services/Time/ISystemClock.cs index f574826a..1dfd7d74 100644 --- a/Ryujinx.HLE/HOS/Services/Time/ISystemClock.cs +++ b/Ryujinx.HLE/HOS/Services/Time/ISystemClock.cs @@ -6,25 +6,25 @@ namespace Ryujinx.HLE.HOS.Services.Time { class ISystemClock : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); - private SystemClockType ClockType; + private SystemClockType _clockType; - private DateTime SystemClockContextEpoch; + private DateTime _systemClockContextEpoch; - private long SystemClockTimePoint; + private long _systemClockTimePoint; - private byte[] SystemClockContextEnding; + private byte[] _systemClockContextEnding; - private long TimeOffset; + private long _timeOffset; - public ISystemClock(SystemClockType ClockType) + public ISystemClock(SystemClockType clockType) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, GetCurrentTime }, { 1, SetCurrentTime }, @@ -32,74 +32,74 @@ namespace Ryujinx.HLE.HOS.Services.Time { 3, SetSystemClockContext } }; - this.ClockType = ClockType; - SystemClockContextEpoch = System.Diagnostics.Process.GetCurrentProcess().StartTime; - SystemClockContextEnding = new byte[0x10]; - TimeOffset = 0; + _clockType = clockType; + _systemClockContextEpoch = System.Diagnostics.Process.GetCurrentProcess().StartTime; + _systemClockContextEnding = new byte[0x10]; + _timeOffset = 0; - if (ClockType == SystemClockType.User || - ClockType == SystemClockType.Network) + if (clockType == SystemClockType.User || + clockType == SystemClockType.Network) { - SystemClockContextEpoch = SystemClockContextEpoch.ToUniversalTime(); + _systemClockContextEpoch = _systemClockContextEpoch.ToUniversalTime(); } - SystemClockTimePoint = (long)(SystemClockContextEpoch - Epoch).TotalSeconds; + _systemClockTimePoint = (long)(_systemClockContextEpoch - Epoch).TotalSeconds; } - public long GetCurrentTime(ServiceCtx Context) + public long GetCurrentTime(ServiceCtx context) { - DateTime CurrentTime = DateTime.Now; + DateTime currentTime = DateTime.Now; - if (ClockType == SystemClockType.User || - ClockType == SystemClockType.Network) + if (_clockType == SystemClockType.User || + _clockType == SystemClockType.Network) { - CurrentTime = CurrentTime.ToUniversalTime(); + currentTime = currentTime.ToUniversalTime(); } - Context.ResponseData.Write((long)((CurrentTime - Epoch).TotalSeconds) + TimeOffset); + context.ResponseData.Write((long)((currentTime - Epoch).TotalSeconds) + _timeOffset); return 0; } - public long SetCurrentTime(ServiceCtx Context) + public long SetCurrentTime(ServiceCtx context) { - DateTime CurrentTime = DateTime.Now; + DateTime currentTime = DateTime.Now; - if (ClockType == SystemClockType.User || - ClockType == SystemClockType.Network) + if (_clockType == SystemClockType.User || + _clockType == SystemClockType.Network) { - CurrentTime = CurrentTime.ToUniversalTime(); + currentTime = currentTime.ToUniversalTime(); } - TimeOffset = (Context.RequestData.ReadInt64() - (long)(CurrentTime - Epoch).TotalSeconds); + _timeOffset = (context.RequestData.ReadInt64() - (long)(currentTime - Epoch).TotalSeconds); return 0; } - public long GetSystemClockContext(ServiceCtx Context) + public long GetSystemClockContext(ServiceCtx context) { - Context.ResponseData.Write((long)(SystemClockContextEpoch - Epoch).TotalSeconds); + context.ResponseData.Write((long)(_systemClockContextEpoch - Epoch).TotalSeconds); // The point in time, TODO: is there a link between epoch and this? - Context.ResponseData.Write(SystemClockTimePoint); + context.ResponseData.Write(_systemClockTimePoint); // This seems to be some kind of identifier? for (int i = 0; i < 0x10; i++) { - Context.ResponseData.Write(SystemClockContextEnding[i]); + context.ResponseData.Write(_systemClockContextEnding[i]); } return 0; } - public long SetSystemClockContext(ServiceCtx Context) + public long SetSystemClockContext(ServiceCtx context) { - long NewSystemClockEpoch = Context.RequestData.ReadInt64(); - long NewSystemClockTimePoint = Context.RequestData.ReadInt64(); + long newSystemClockEpoch = context.RequestData.ReadInt64(); + long newSystemClockTimePoint = context.RequestData.ReadInt64(); - SystemClockContextEpoch = Epoch.Add(TimeSpan.FromSeconds(NewSystemClockEpoch)); - SystemClockTimePoint = NewSystemClockTimePoint; - SystemClockContextEnding = Context.RequestData.ReadBytes(0x10); + _systemClockContextEpoch = Epoch.Add(TimeSpan.FromSeconds(newSystemClockEpoch)); + _systemClockTimePoint = newSystemClockTimePoint; + _systemClockContextEnding = context.RequestData.ReadBytes(0x10); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Time/ITimeZoneService.cs b/Ryujinx.HLE/HOS/Services/Time/ITimeZoneService.cs index 0e321e44..563a9753 100644 --- a/Ryujinx.HLE/HOS/Services/Time/ITimeZoneService.cs +++ b/Ryujinx.HLE/HOS/Services/Time/ITimeZoneService.cs @@ -10,17 +10,17 @@ namespace Ryujinx.HLE.HOS.Services.Time { class ITimeZoneService : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); - private TimeZoneInfo TimeZone = TimeZoneInfo.Local; + private TimeZoneInfo _timeZone = TimeZoneInfo.Local; public ITimeZoneService() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, GetDeviceLocationName }, { 1, SetDeviceLocationName }, @@ -34,245 +34,245 @@ namespace Ryujinx.HLE.HOS.Services.Time }; } - public long GetDeviceLocationName(ServiceCtx Context) + public long GetDeviceLocationName(ServiceCtx context) { - char[] TzName = TimeZone.Id.ToCharArray(); + char[] tzName = _timeZone.Id.ToCharArray(); - Context.ResponseData.Write(TzName); + context.ResponseData.Write(tzName); - int Padding = 0x24 - TzName.Length; + int padding = 0x24 - tzName.Length; - for (int Index = 0; Index < Padding; Index++) + for (int index = 0; index < padding; index++) { - Context.ResponseData.Write((byte)0); + context.ResponseData.Write((byte)0); } return 0; } - public long SetDeviceLocationName(ServiceCtx Context) + public long SetDeviceLocationName(ServiceCtx context) { - byte[] LocationName = Context.RequestData.ReadBytes(0x24); + byte[] locationName = context.RequestData.ReadBytes(0x24); - string TzID = Encoding.ASCII.GetString(LocationName).TrimEnd('\0'); + string tzId = Encoding.ASCII.GetString(locationName).TrimEnd('\0'); - long ResultCode = 0; + long resultCode = 0; try { - TimeZone = TimeZoneInfo.FindSystemTimeZoneById(TzID); + _timeZone = TimeZoneInfo.FindSystemTimeZoneById(tzId); } catch (TimeZoneNotFoundException) { - ResultCode = MakeError(ErrorModule.Time, 0x3dd); + resultCode = MakeError(ErrorModule.Time, 0x3dd); } - return ResultCode; + return resultCode; } - public long GetTotalLocationNameCount(ServiceCtx Context) + public long GetTotalLocationNameCount(ServiceCtx context) { - Context.ResponseData.Write(TimeZoneInfo.GetSystemTimeZones().Count); + context.ResponseData.Write(TimeZoneInfo.GetSystemTimeZones().Count); return 0; } - public long LoadLocationNameList(ServiceCtx Context) + public long LoadLocationNameList(ServiceCtx context) { - long BufferPosition = Context.Response.SendBuff[0].Position; - long BufferSize = Context.Response.SendBuff[0].Size; + long bufferPosition = context.Response.SendBuff[0].Position; + long bufferSize = context.Response.SendBuff[0].Size; - int Offset = 0; + int offset = 0; foreach (TimeZoneInfo info in TimeZoneInfo.GetSystemTimeZones()) { - byte[] TzData = Encoding.ASCII.GetBytes(info.Id); + byte[] tzData = Encoding.ASCII.GetBytes(info.Id); - Context.Memory.WriteBytes(BufferPosition + Offset, TzData); + context.Memory.WriteBytes(bufferPosition + offset, tzData); - int Padding = 0x24 - TzData.Length; + int padding = 0x24 - tzData.Length; - for (int Index = 0; Index < Padding; Index++) + for (int index = 0; index < padding; index++) { - Context.ResponseData.Write((byte)0); + context.ResponseData.Write((byte)0); } - Offset += 0x24; + offset += 0x24; } return 0; } - public long LoadTimeZoneRule(ServiceCtx Context) + public long LoadTimeZoneRule(ServiceCtx context) { - long BufferPosition = Context.Request.ReceiveBuff[0].Position; - long BufferSize = Context.Request.ReceiveBuff[0].Size; + long bufferPosition = context.Request.ReceiveBuff[0].Position; + long bufferSize = context.Request.ReceiveBuff[0].Size; - if (BufferSize != 0x4000) + if (bufferSize != 0x4000) { - Logger.PrintWarning(LogClass.ServiceTime, $"TimeZoneRule buffer size is 0x{BufferSize:x} (expected 0x4000)"); + Logger.PrintWarning(LogClass.ServiceTime, $"TimeZoneRule buffer size is 0x{bufferSize:x} (expected 0x4000)"); } - long ResultCode = 0; + long resultCode = 0; - byte[] LocationName = Context.RequestData.ReadBytes(0x24); + byte[] locationName = context.RequestData.ReadBytes(0x24); - string TzID = Encoding.ASCII.GetString(LocationName).TrimEnd('\0'); + string tzId = Encoding.ASCII.GetString(locationName).TrimEnd('\0'); // Check if the Time Zone exists, otherwise error out. try { - TimeZoneInfo Info = TimeZoneInfo.FindSystemTimeZoneById(TzID); + TimeZoneInfo info = TimeZoneInfo.FindSystemTimeZoneById(tzId); - byte[] TzData = Encoding.ASCII.GetBytes(Info.Id); + byte[] tzData = Encoding.ASCII.GetBytes(info.Id); // FIXME: This is not in ANY cases accurate, but the games don't care about the content of the buffer, they only pass it. // TODO: Reverse the TZif2 conversion in PCV to make this match with real hardware. - Context.Memory.WriteBytes(BufferPosition, TzData); + context.Memory.WriteBytes(bufferPosition, tzData); } catch (TimeZoneNotFoundException) { - Logger.PrintWarning(LogClass.ServiceTime, $"Timezone not found for string: {TzID} (len: {TzID.Length})"); + Logger.PrintWarning(LogClass.ServiceTime, $"Timezone not found for string: {tzId} (len: {tzId.Length})"); - ResultCode = MakeError(ErrorModule.Time, 0x3dd); + resultCode = MakeError(ErrorModule.Time, 0x3dd); } - return ResultCode; + return resultCode; } - private long ToCalendarTimeWithTz(ServiceCtx Context, long PosixTime, TimeZoneInfo Info) + private long ToCalendarTimeWithTz(ServiceCtx context, long posixTime, TimeZoneInfo info) { - DateTime CurrentTime = Epoch.AddSeconds(PosixTime); - - CurrentTime = TimeZoneInfo.ConvertTimeFromUtc(CurrentTime, Info); - - Context.ResponseData.Write((ushort)CurrentTime.Year); - Context.ResponseData.Write((byte)CurrentTime.Month); - Context.ResponseData.Write((byte)CurrentTime.Day); - Context.ResponseData.Write((byte)CurrentTime.Hour); - Context.ResponseData.Write((byte)CurrentTime.Minute); - Context.ResponseData.Write((byte)CurrentTime.Second); - Context.ResponseData.Write((byte)0); //MilliSecond ? - Context.ResponseData.Write((int)CurrentTime.DayOfWeek); - Context.ResponseData.Write(CurrentTime.DayOfYear - 1); - Context.ResponseData.Write(new byte[8]); //TODO: Find out the names used. - Context.ResponseData.Write((byte)(CurrentTime.IsDaylightSavingTime() ? 1 : 0)); - Context.ResponseData.Write((int)Info.GetUtcOffset(CurrentTime).TotalSeconds); + DateTime currentTime = Epoch.AddSeconds(posixTime); + + currentTime = TimeZoneInfo.ConvertTimeFromUtc(currentTime, info); + + context.ResponseData.Write((ushort)currentTime.Year); + context.ResponseData.Write((byte)currentTime.Month); + context.ResponseData.Write((byte)currentTime.Day); + context.ResponseData.Write((byte)currentTime.Hour); + context.ResponseData.Write((byte)currentTime.Minute); + context.ResponseData.Write((byte)currentTime.Second); + context.ResponseData.Write((byte)0); //MilliSecond ? + context.ResponseData.Write((int)currentTime.DayOfWeek); + context.ResponseData.Write(currentTime.DayOfYear - 1); + context.ResponseData.Write(new byte[8]); //TODO: Find out the names used. + context.ResponseData.Write((byte)(currentTime.IsDaylightSavingTime() ? 1 : 0)); + context.ResponseData.Write((int)info.GetUtcOffset(currentTime).TotalSeconds); return 0; } - public long ToCalendarTime(ServiceCtx Context) + public long ToCalendarTime(ServiceCtx context) { - long PosixTime = Context.RequestData.ReadInt64(); - long BufferPosition = Context.Request.SendBuff[0].Position; - long BufferSize = Context.Request.SendBuff[0].Size; + long posixTime = context.RequestData.ReadInt64(); + long bufferPosition = context.Request.SendBuff[0].Position; + long bufferSize = context.Request.SendBuff[0].Size; - if (BufferSize != 0x4000) + if (bufferSize != 0x4000) { - Logger.PrintWarning(LogClass.ServiceTime, $"TimeZoneRule buffer size is 0x{BufferSize:x} (expected 0x4000)"); + Logger.PrintWarning(LogClass.ServiceTime, $"TimeZoneRule buffer size is 0x{bufferSize:x} (expected 0x4000)"); } // TODO: Reverse the TZif2 conversion in PCV to make this match with real hardware. - byte[] TzData = Context.Memory.ReadBytes(BufferPosition, 0x24); + byte[] tzData = context.Memory.ReadBytes(bufferPosition, 0x24); - string TzID = Encoding.ASCII.GetString(TzData).TrimEnd('\0'); + string tzId = Encoding.ASCII.GetString(tzData).TrimEnd('\0'); - long ResultCode = 0; + long resultCode = 0; // Check if the Time Zone exists, otherwise error out. try { - TimeZoneInfo Info = TimeZoneInfo.FindSystemTimeZoneById(TzID); + TimeZoneInfo info = TimeZoneInfo.FindSystemTimeZoneById(tzId); - ResultCode = ToCalendarTimeWithTz(Context, PosixTime, Info); + resultCode = ToCalendarTimeWithTz(context, posixTime, info); } catch (TimeZoneNotFoundException) { - Logger.PrintWarning(LogClass.ServiceTime, $"Timezone not found for string: {TzID} (len: {TzID.Length})"); + Logger.PrintWarning(LogClass.ServiceTime, $"Timezone not found for string: {tzId} (len: {tzId.Length})"); - ResultCode = MakeError(ErrorModule.Time, 0x3dd); + resultCode = MakeError(ErrorModule.Time, 0x3dd); } - return ResultCode; + return resultCode; } - public long ToCalendarTimeWithMyRule(ServiceCtx Context) + public long ToCalendarTimeWithMyRule(ServiceCtx context) { - long PosixTime = Context.RequestData.ReadInt64(); + long posixTime = context.RequestData.ReadInt64(); - return ToCalendarTimeWithTz(Context, PosixTime, TimeZone); + return ToCalendarTimeWithTz(context, posixTime, _timeZone); } - public long ToPosixTime(ServiceCtx Context) + public long ToPosixTime(ServiceCtx context) { - long BufferPosition = Context.Request.SendBuff[0].Position; - long BufferSize = Context.Request.SendBuff[0].Size; + long bufferPosition = context.Request.SendBuff[0].Position; + long bufferSize = context.Request.SendBuff[0].Size; - ushort Year = Context.RequestData.ReadUInt16(); - byte Month = Context.RequestData.ReadByte(); - byte Day = Context.RequestData.ReadByte(); - byte Hour = Context.RequestData.ReadByte(); - byte Minute = Context.RequestData.ReadByte(); - byte Second = Context.RequestData.ReadByte(); + ushort year = context.RequestData.ReadUInt16(); + byte month = context.RequestData.ReadByte(); + byte day = context.RequestData.ReadByte(); + byte hour = context.RequestData.ReadByte(); + byte minute = context.RequestData.ReadByte(); + byte second = context.RequestData.ReadByte(); - DateTime CalendarTime = new DateTime(Year, Month, Day, Hour, Minute, Second); + DateTime calendarTime = new DateTime(year, month, day, hour, minute, second); - if (BufferSize != 0x4000) + if (bufferSize != 0x4000) { - Logger.PrintWarning(LogClass.ServiceTime, $"TimeZoneRule buffer size is 0x{BufferSize:x} (expected 0x4000)"); + Logger.PrintWarning(LogClass.ServiceTime, $"TimeZoneRule buffer size is 0x{bufferSize:x} (expected 0x4000)"); } // TODO: Reverse the TZif2 conversion in PCV to make this match with real hardware. - byte[] TzData = Context.Memory.ReadBytes(BufferPosition, 0x24); + byte[] tzData = context.Memory.ReadBytes(bufferPosition, 0x24); - string TzID = Encoding.ASCII.GetString(TzData).TrimEnd('\0'); + string tzId = Encoding.ASCII.GetString(tzData).TrimEnd('\0'); - long ResultCode = 0; + long resultCode = 0; // Check if the Time Zone exists, otherwise error out. try { - TimeZoneInfo Info = TimeZoneInfo.FindSystemTimeZoneById(TzID); + TimeZoneInfo info = TimeZoneInfo.FindSystemTimeZoneById(tzId); - return ToPosixTimeWithTz(Context, CalendarTime, Info); + return ToPosixTimeWithTz(context, calendarTime, info); } catch (TimeZoneNotFoundException) { - Logger.PrintWarning(LogClass.ServiceTime, $"Timezone not found for string: {TzID} (len: {TzID.Length})"); + Logger.PrintWarning(LogClass.ServiceTime, $"Timezone not found for string: {tzId} (len: {tzId.Length})"); - ResultCode = MakeError(ErrorModule.Time, 0x3dd); + resultCode = MakeError(ErrorModule.Time, 0x3dd); } - return ResultCode; + return resultCode; } - public long ToPosixTimeWithMyRule(ServiceCtx Context) + public long ToPosixTimeWithMyRule(ServiceCtx context) { - ushort Year = Context.RequestData.ReadUInt16(); - byte Month = Context.RequestData.ReadByte(); - byte Day = Context.RequestData.ReadByte(); - byte Hour = Context.RequestData.ReadByte(); - byte Minute = Context.RequestData.ReadByte(); - byte Second = Context.RequestData.ReadByte(); + ushort year = context.RequestData.ReadUInt16(); + byte month = context.RequestData.ReadByte(); + byte day = context.RequestData.ReadByte(); + byte hour = context.RequestData.ReadByte(); + byte minute = context.RequestData.ReadByte(); + byte second = context.RequestData.ReadByte(); - DateTime CalendarTime = new DateTime(Year, Month, Day, Hour, Minute, Second, DateTimeKind.Local); + DateTime calendarTime = new DateTime(year, month, day, hour, minute, second, DateTimeKind.Local); - return ToPosixTimeWithTz(Context, CalendarTime, TimeZone); + return ToPosixTimeWithTz(context, calendarTime, _timeZone); } - private long ToPosixTimeWithTz(ServiceCtx Context, DateTime CalendarTime, TimeZoneInfo Info) + private long ToPosixTimeWithTz(ServiceCtx context, DateTime calendarTime, TimeZoneInfo info) { - DateTime CalenderTimeUTC = TimeZoneInfo.ConvertTimeToUtc(CalendarTime, Info); + DateTime calenderTimeUtc = TimeZoneInfo.ConvertTimeToUtc(calendarTime, info); - long PosixTime = ((DateTimeOffset)CalenderTimeUTC).ToUnixTimeSeconds(); + long posixTime = ((DateTimeOffset)calenderTimeUtc).ToUnixTimeSeconds(); - long Position = Context.Request.RecvListBuff[0].Position; - long Size = Context.Request.RecvListBuff[0].Size; + long position = context.Request.RecvListBuff[0].Position; + long size = context.Request.RecvListBuff[0].Size; - Context.Memory.WriteInt64(Position, PosixTime); + context.Memory.WriteInt64(position, posixTime); - Context.ResponseData.Write(1); + context.ResponseData.Write(1); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Vi/Display.cs b/Ryujinx.HLE/HOS/Services/Vi/Display.cs index 50fe5e1d..54e00789 100644 --- a/Ryujinx.HLE/HOS/Services/Vi/Display.cs +++ b/Ryujinx.HLE/HOS/Services/Vi/Display.cs @@ -2,11 +2,11 @@ namespace Ryujinx.HLE.HOS.Services.Vi { class Display { - public string Name { get; private set; } + public string Name { get; } - public Display(string Name) + public Display(string name) { - this.Name = Name; + Name = name; } } }
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Vi/GbpBuffer.cs b/Ryujinx.HLE/HOS/Services/Vi/GbpBuffer.cs index 4f00c3de..4a247d1b 100644 --- a/Ryujinx.HLE/HOS/Services/Vi/GbpBuffer.cs +++ b/Ryujinx.HLE/HOS/Services/Vi/GbpBuffer.cs @@ -4,57 +4,57 @@ namespace Ryujinx.HLE.HOS.Services.Android { struct GbpBuffer { - public int Magic { get; private set; } - public int Width { get; private set; } - public int Height { get; private set; } - public int Stride { get; private set; } - public int Format { get; private set; } - public int Usage { get; private set; } + public int Magic { get; } + public int Width { get; } + public int Height { get; } + public int Stride { get; } + public int Format { get; } + public int Usage { get; } - public int Pid { get; private set; } - public int RefCount { get; private set; } + public int Pid { get; } + public int RefCount { get; } - public int FdsCount { get; private set; } - public int IntsCount { get; private set; } + public int FdsCount { get; } + public int IntsCount { get; } - public byte[] RawData { get; private set; } + public byte[] RawData { get; } public int Size => RawData.Length + 10 * 4; - public GbpBuffer(BinaryReader Reader) + public GbpBuffer(BinaryReader reader) { - Magic = Reader.ReadInt32(); - Width = Reader.ReadInt32(); - Height = Reader.ReadInt32(); - Stride = Reader.ReadInt32(); - Format = Reader.ReadInt32(); - Usage = Reader.ReadInt32(); + Magic = reader.ReadInt32(); + Width = reader.ReadInt32(); + Height = reader.ReadInt32(); + Stride = reader.ReadInt32(); + Format = reader.ReadInt32(); + Usage = reader.ReadInt32(); - Pid = Reader.ReadInt32(); - RefCount = Reader.ReadInt32(); + Pid = reader.ReadInt32(); + RefCount = reader.ReadInt32(); - FdsCount = Reader.ReadInt32(); - IntsCount = Reader.ReadInt32(); + FdsCount = reader.ReadInt32(); + IntsCount = reader.ReadInt32(); - RawData = Reader.ReadBytes((FdsCount + IntsCount) * 4); + RawData = reader.ReadBytes((FdsCount + IntsCount) * 4); } - public void Write(BinaryWriter Writer) + public void Write(BinaryWriter writer) { - Writer.Write(Magic); - Writer.Write(Width); - Writer.Write(Height); - Writer.Write(Stride); - Writer.Write(Format); - Writer.Write(Usage); + writer.Write(Magic); + writer.Write(Width); + writer.Write(Height); + writer.Write(Stride); + writer.Write(Format); + writer.Write(Usage); - Writer.Write(Pid); - Writer.Write(RefCount); + writer.Write(Pid); + writer.Write(RefCount); - Writer.Write(FdsCount); - Writer.Write(IntsCount); + writer.Write(FdsCount); + writer.Write(IntsCount); - Writer.Write(RawData); + writer.Write(RawData); } } }
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Vi/IApplicationDisplayService.cs b/Ryujinx.HLE/HOS/Services/Vi/IApplicationDisplayService.cs index 5d1ddd84..63e542d2 100644 --- a/Ryujinx.HLE/HOS/Services/Vi/IApplicationDisplayService.cs +++ b/Ryujinx.HLE/HOS/Services/Vi/IApplicationDisplayService.cs @@ -12,15 +12,15 @@ namespace Ryujinx.HLE.HOS.Services.Vi { class IApplicationDisplayService : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private IdDictionary Displays; + private IdDictionary _displays; public IApplicationDisplayService() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 100, GetRelayService }, { 101, GetSystemDisplayService }, @@ -38,205 +38,205 @@ namespace Ryujinx.HLE.HOS.Services.Vi { 5202, GetDisplayVSyncEvent } }; - Displays = new IdDictionary(); + _displays = new IdDictionary(); } - public long GetRelayService(ServiceCtx Context) + public long GetRelayService(ServiceCtx context) { - MakeObject(Context, new IHOSBinderDriver( - Context.Device.System, - Context.Device.Gpu.Renderer)); + MakeObject(context, new IhosBinderDriver( + context.Device.System, + context.Device.Gpu.Renderer)); return 0; } - public long GetSystemDisplayService(ServiceCtx Context) + public long GetSystemDisplayService(ServiceCtx context) { - MakeObject(Context, new ISystemDisplayService()); + MakeObject(context, new ISystemDisplayService()); return 0; } - public long GetManagerDisplayService(ServiceCtx Context) + public long GetManagerDisplayService(ServiceCtx context) { - MakeObject(Context, new IManagerDisplayService()); + MakeObject(context, new IManagerDisplayService()); return 0; } - public long GetIndirectDisplayTransactionService(ServiceCtx Context) + public long GetIndirectDisplayTransactionService(ServiceCtx context) { - MakeObject(Context, new IHOSBinderDriver( - Context.Device.System, - Context.Device.Gpu.Renderer)); + MakeObject(context, new IhosBinderDriver( + context.Device.System, + context.Device.Gpu.Renderer)); return 0; } - public long ListDisplays(ServiceCtx Context) + public long ListDisplays(ServiceCtx context) { - long RecBuffPtr = Context.Request.ReceiveBuff[0].Position; + long recBuffPtr = context.Request.ReceiveBuff[0].Position; - MemoryHelper.FillWithZeros(Context.Memory, RecBuffPtr, 0x60); + MemoryHelper.FillWithZeros(context.Memory, recBuffPtr, 0x60); //Add only the default display to buffer - Context.Memory.WriteBytes(RecBuffPtr, Encoding.ASCII.GetBytes("Default")); - Context.Memory.WriteInt64(RecBuffPtr + 0x40, 0x1L); - Context.Memory.WriteInt64(RecBuffPtr + 0x48, 0x1L); - Context.Memory.WriteInt64(RecBuffPtr + 0x50, 1920L); - Context.Memory.WriteInt64(RecBuffPtr + 0x58, 1080L); + context.Memory.WriteBytes(recBuffPtr, Encoding.ASCII.GetBytes("Default")); + context.Memory.WriteInt64(recBuffPtr + 0x40, 0x1L); + context.Memory.WriteInt64(recBuffPtr + 0x48, 0x1L); + context.Memory.WriteInt64(recBuffPtr + 0x50, 1920L); + context.Memory.WriteInt64(recBuffPtr + 0x58, 1080L); - Context.ResponseData.Write(1L); + context.ResponseData.Write(1L); return 0; } - public long OpenDisplay(ServiceCtx Context) + public long OpenDisplay(ServiceCtx context) { - string Name = GetDisplayName(Context); + string name = GetDisplayName(context); - long DisplayId = Displays.Add(new Display(Name)); + long displayId = _displays.Add(new Display(name)); - Context.ResponseData.Write(DisplayId); + context.ResponseData.Write(displayId); return 0; } - public long CloseDisplay(ServiceCtx Context) + public long CloseDisplay(ServiceCtx context) { - int DisplayId = Context.RequestData.ReadInt32(); + int displayId = context.RequestData.ReadInt32(); - Displays.Delete(DisplayId); + _displays.Delete(displayId); return 0; } - public long GetDisplayResolution(ServiceCtx Context) + public long GetDisplayResolution(ServiceCtx context) { - long DisplayId = Context.RequestData.ReadInt32(); + long displayId = context.RequestData.ReadInt32(); - Context.ResponseData.Write(1280); - Context.ResponseData.Write(720); + context.ResponseData.Write(1280); + context.ResponseData.Write(720); return 0; } - public long OpenLayer(ServiceCtx Context) + public long OpenLayer(ServiceCtx context) { - long LayerId = Context.RequestData.ReadInt64(); - long UserId = Context.RequestData.ReadInt64(); + long layerId = context.RequestData.ReadInt64(); + long userId = context.RequestData.ReadInt64(); - long ParcelPtr = Context.Request.ReceiveBuff[0].Position; + long parcelPtr = context.Request.ReceiveBuff[0].Position; - byte[] Parcel = MakeIGraphicsBufferProducer(ParcelPtr); + byte[] parcel = MakeIGraphicsBufferProducer(parcelPtr); - Context.Memory.WriteBytes(ParcelPtr, Parcel); + context.Memory.WriteBytes(parcelPtr, parcel); - Context.ResponseData.Write((long)Parcel.Length); + context.ResponseData.Write((long)parcel.Length); return 0; } - public long CloseLayer(ServiceCtx Context) + public long CloseLayer(ServiceCtx context) { - long LayerId = Context.RequestData.ReadInt64(); + long layerId = context.RequestData.ReadInt64(); return 0; } - public long CreateStrayLayer(ServiceCtx Context) + public long CreateStrayLayer(ServiceCtx context) { - long LayerFlags = Context.RequestData.ReadInt64(); - long DisplayId = Context.RequestData.ReadInt64(); + long layerFlags = context.RequestData.ReadInt64(); + long displayId = context.RequestData.ReadInt64(); - long ParcelPtr = Context.Request.ReceiveBuff[0].Position; + long parcelPtr = context.Request.ReceiveBuff[0].Position; - Display Disp = Displays.GetData<Display>((int)DisplayId); + Display disp = _displays.GetData<Display>((int)displayId); - byte[] Parcel = MakeIGraphicsBufferProducer(ParcelPtr); + byte[] parcel = MakeIGraphicsBufferProducer(parcelPtr); - Context.Memory.WriteBytes(ParcelPtr, Parcel); + context.Memory.WriteBytes(parcelPtr, parcel); - Context.ResponseData.Write(0L); - Context.ResponseData.Write((long)Parcel.Length); + context.ResponseData.Write(0L); + context.ResponseData.Write((long)parcel.Length); return 0; } - public long DestroyStrayLayer(ServiceCtx Context) + public long DestroyStrayLayer(ServiceCtx context) { return 0; } - public long SetLayerScalingMode(ServiceCtx Context) + public long SetLayerScalingMode(ServiceCtx context) { - int ScalingMode = Context.RequestData.ReadInt32(); - long Unknown = Context.RequestData.ReadInt64(); + int scalingMode = context.RequestData.ReadInt32(); + long unknown = context.RequestData.ReadInt64(); return 0; } - public long GetDisplayVSyncEvent(ServiceCtx Context) + public long GetDisplayVSyncEvent(ServiceCtx context) { - string Name = GetDisplayName(Context); + string name = GetDisplayName(context); - if (Context.Process.HandleTable.GenerateHandle(Context.Device.System.VsyncEvent.ReadableEvent, out int Handle) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(context.Device.System.VsyncEvent.ReadableEvent, out int handle) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle); return 0; } - private byte[] MakeIGraphicsBufferProducer(long BasePtr) + private byte[] MakeIGraphicsBufferProducer(long basePtr) { - long Id = 0x20; - long CookiePtr = 0L; + long id = 0x20; + long cookiePtr = 0L; - using (MemoryStream MS = new MemoryStream()) + using (MemoryStream ms = new MemoryStream()) { - BinaryWriter Writer = new BinaryWriter(MS); + BinaryWriter writer = new BinaryWriter(ms); //flat_binder_object (size is 0x28) - Writer.Write(2); //Type (BINDER_TYPE_WEAK_BINDER) - Writer.Write(0); //Flags - Writer.Write((int)(Id >> 0)); - Writer.Write((int)(Id >> 32)); - Writer.Write((int)(CookiePtr >> 0)); - Writer.Write((int)(CookiePtr >> 32)); - Writer.Write((byte)'d'); - Writer.Write((byte)'i'); - Writer.Write((byte)'s'); - Writer.Write((byte)'p'); - Writer.Write((byte)'d'); - Writer.Write((byte)'r'); - Writer.Write((byte)'v'); - Writer.Write((byte)'\0'); - Writer.Write(0L); //Pad - - return MakeParcel(MS.ToArray(), new byte[] { 0, 0, 0, 0 }); + writer.Write(2); //Type (BINDER_TYPE_WEAK_BINDER) + writer.Write(0); //Flags + writer.Write((int)(id >> 0)); + writer.Write((int)(id >> 32)); + writer.Write((int)(cookiePtr >> 0)); + writer.Write((int)(cookiePtr >> 32)); + writer.Write((byte)'d'); + writer.Write((byte)'i'); + writer.Write((byte)'s'); + writer.Write((byte)'p'); + writer.Write((byte)'d'); + writer.Write((byte)'r'); + writer.Write((byte)'v'); + writer.Write((byte)'\0'); + writer.Write(0L); //Pad + + return MakeParcel(ms.ToArray(), new byte[] { 0, 0, 0, 0 }); } } - private string GetDisplayName(ServiceCtx Context) + private string GetDisplayName(ServiceCtx context) { - string Name = string.Empty; + string name = string.Empty; - for (int Index = 0; Index < 8 && - Context.RequestData.BaseStream.Position < - Context.RequestData.BaseStream.Length; Index++) + for (int index = 0; index < 8 && + context.RequestData.BaseStream.Position < + context.RequestData.BaseStream.Length; index++) { - byte Chr = Context.RequestData.ReadByte(); + byte chr = context.RequestData.ReadByte(); - if (Chr >= 0x20 && Chr < 0x7f) + if (chr >= 0x20 && chr < 0x7f) { - Name += (char)Chr; + name += (char)chr; } } - return Name; + return name; } } }
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Vi/IApplicationRootService.cs b/Ryujinx.HLE/HOS/Services/Vi/IApplicationRootService.cs index e86734e6..66ab16bd 100644 --- a/Ryujinx.HLE/HOS/Services/Vi/IApplicationRootService.cs +++ b/Ryujinx.HLE/HOS/Services/Vi/IApplicationRootService.cs @@ -5,23 +5,23 @@ namespace Ryujinx.HLE.HOS.Services.Vi { class IApplicationRootService : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IApplicationRootService() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, GetDisplayService } }; } - public long GetDisplayService(ServiceCtx Context) + public long GetDisplayService(ServiceCtx context) { - int ServiceType = Context.RequestData.ReadInt32(); + int serviceType = context.RequestData.ReadInt32(); - MakeObject(Context, new IApplicationDisplayService()); + MakeObject(context, new IApplicationDisplayService()); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Vi/IHOSBinderDriver.cs b/Ryujinx.HLE/HOS/Services/Vi/IHOSBinderDriver.cs index 09a37b0f..7ca3053d 100644 --- a/Ryujinx.HLE/HOS/Services/Vi/IHOSBinderDriver.cs +++ b/Ryujinx.HLE/HOS/Services/Vi/IHOSBinderDriver.cs @@ -7,19 +7,19 @@ using System.Collections.Generic; namespace Ryujinx.HLE.HOS.Services.Vi { - class IHOSBinderDriver : IpcService, IDisposable + class IhosBinderDriver : IpcService, IDisposable { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private KEvent BinderEvent; + private KEvent _binderEvent; - private NvFlinger Flinger; + private NvFlinger _flinger; - public IHOSBinderDriver(Horizon System, IGalRenderer Renderer) + public IhosBinderDriver(Horizon system, IGalRenderer renderer) { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 0, TransactParcel }, { 1, AdjustRefcount }, @@ -27,62 +27,62 @@ namespace Ryujinx.HLE.HOS.Services.Vi { 3, TransactParcelAuto } }; - BinderEvent = new KEvent(System); + _binderEvent = new KEvent(system); - BinderEvent.ReadableEvent.Signal(); + _binderEvent.ReadableEvent.Signal(); - Flinger = new NvFlinger(Renderer, BinderEvent); + _flinger = new NvFlinger(renderer, _binderEvent); } - public long TransactParcel(ServiceCtx Context) + public long TransactParcel(ServiceCtx context) { - int Id = Context.RequestData.ReadInt32(); - int Code = Context.RequestData.ReadInt32(); + int id = context.RequestData.ReadInt32(); + int code = context.RequestData.ReadInt32(); - long DataPos = Context.Request.SendBuff[0].Position; - long DataSize = Context.Request.SendBuff[0].Size; + long dataPos = context.Request.SendBuff[0].Position; + long dataSize = context.Request.SendBuff[0].Size; - byte[] Data = Context.Memory.ReadBytes(DataPos, DataSize); + byte[] data = context.Memory.ReadBytes(dataPos, dataSize); - Data = Parcel.GetParcelData(Data); + data = Parcel.GetParcelData(data); - return Flinger.ProcessParcelRequest(Context, Data, Code); + return _flinger.ProcessParcelRequest(context, data, code); } - public long TransactParcelAuto(ServiceCtx Context) + public long TransactParcelAuto(ServiceCtx context) { - int Id = Context.RequestData.ReadInt32(); - int Code = Context.RequestData.ReadInt32(); + int id = context.RequestData.ReadInt32(); + int code = context.RequestData.ReadInt32(); - (long DataPos, long DataSize) = Context.Request.GetBufferType0x21(); + (long dataPos, long dataSize) = context.Request.GetBufferType0x21(); - byte[] Data = Context.Memory.ReadBytes(DataPos, DataSize); + byte[] data = context.Memory.ReadBytes(dataPos, dataSize); - Data = Parcel.GetParcelData(Data); + data = Parcel.GetParcelData(data); - return Flinger.ProcessParcelRequest(Context, Data, Code); + return _flinger.ProcessParcelRequest(context, data, code); } - public long AdjustRefcount(ServiceCtx Context) + public long AdjustRefcount(ServiceCtx context) { - int Id = Context.RequestData.ReadInt32(); - int AddVal = Context.RequestData.ReadInt32(); - int Type = Context.RequestData.ReadInt32(); + int id = context.RequestData.ReadInt32(); + int addVal = context.RequestData.ReadInt32(); + int type = context.RequestData.ReadInt32(); return 0; } - public long GetNativeHandle(ServiceCtx Context) + public long GetNativeHandle(ServiceCtx context) { - int Id = Context.RequestData.ReadInt32(); - uint Unk = Context.RequestData.ReadUInt32(); + int id = context.RequestData.ReadInt32(); + uint unk = context.RequestData.ReadUInt32(); - if (Context.Process.HandleTable.GenerateHandle(BinderEvent.ReadableEvent, out int Handle) != KernelResult.Success) + if (context.Process.HandleTable.GenerateHandle(_binderEvent.ReadableEvent, out int handle) != KernelResult.Success) { throw new InvalidOperationException("Out of handles!"); } - Context.Response.HandleDesc = IpcHandleDesc.MakeMove(Handle); + context.Response.HandleDesc = IpcHandleDesc.MakeMove(handle); return 0; } @@ -92,11 +92,11 @@ namespace Ryujinx.HLE.HOS.Services.Vi Dispose(true); } - protected virtual void Dispose(bool Disposing) + protected virtual void Dispose(bool disposing) { - if (Disposing) + if (disposing) { - Flinger.Dispose(); + _flinger.Dispose(); } } } diff --git a/Ryujinx.HLE/HOS/Services/Vi/IManagerDisplayService.cs b/Ryujinx.HLE/HOS/Services/Vi/IManagerDisplayService.cs index a78f1812..369c376f 100644 --- a/Ryujinx.HLE/HOS/Services/Vi/IManagerDisplayService.cs +++ b/Ryujinx.HLE/HOS/Services/Vi/IManagerDisplayService.cs @@ -6,13 +6,13 @@ namespace Ryujinx.HLE.HOS.Services.Vi { class IManagerDisplayService : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IManagerDisplayService() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 2010, CreateManagedLayer }, { 2011, DestroyManagedLayer }, @@ -21,30 +21,30 @@ namespace Ryujinx.HLE.HOS.Services.Vi }; } - public static long CreateManagedLayer(ServiceCtx Context) + public static long CreateManagedLayer(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceVi, "Stubbed."); - Context.ResponseData.Write(0L); //LayerId + context.ResponseData.Write(0L); //LayerId return 0; } - public long DestroyManagedLayer(ServiceCtx Context) + public long DestroyManagedLayer(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceVi, "Stubbed."); return 0; } - public static long AddToLayerStack(ServiceCtx Context) + public static long AddToLayerStack(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceVi, "Stubbed."); return 0; } - public static long SetLayerVisibility(ServiceCtx Context) + public static long SetLayerVisibility(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceVi, "Stubbed."); diff --git a/Ryujinx.HLE/HOS/Services/Vi/IManagerRootService.cs b/Ryujinx.HLE/HOS/Services/Vi/IManagerRootService.cs index 14b8fc3c..0f0a4f26 100644 --- a/Ryujinx.HLE/HOS/Services/Vi/IManagerRootService.cs +++ b/Ryujinx.HLE/HOS/Services/Vi/IManagerRootService.cs @@ -5,23 +5,23 @@ namespace Ryujinx.HLE.HOS.Services.Vi { class IManagerRootService : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public IManagerRootService() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 2, GetDisplayService } }; } - public long GetDisplayService(ServiceCtx Context) + public long GetDisplayService(ServiceCtx context) { - int ServiceType = Context.RequestData.ReadInt32(); + int serviceType = context.RequestData.ReadInt32(); - MakeObject(Context, new IApplicationDisplayService()); + MakeObject(context, new IApplicationDisplayService()); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Vi/ISystemDisplayService.cs b/Ryujinx.HLE/HOS/Services/Vi/ISystemDisplayService.cs index 4545579b..5266a253 100644 --- a/Ryujinx.HLE/HOS/Services/Vi/ISystemDisplayService.cs +++ b/Ryujinx.HLE/HOS/Services/Vi/ISystemDisplayService.cs @@ -6,13 +6,13 @@ namespace Ryujinx.HLE.HOS.Services.Vi { class ISystemDisplayService : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public ISystemDisplayService() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 2205, SetLayerZ }, { 2207, SetLayerVisibility }, @@ -20,27 +20,27 @@ namespace Ryujinx.HLE.HOS.Services.Vi }; } - public static long SetLayerZ(ServiceCtx Context) + public static long SetLayerZ(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceVi, "Stubbed."); return 0; } - public static long SetLayerVisibility(ServiceCtx Context) + public static long SetLayerVisibility(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceVi, "Stubbed."); return 0; } - public static long GetDisplayMode(ServiceCtx Context) + public static long GetDisplayMode(ServiceCtx context) { //TODO: De-hardcode resolution. - Context.ResponseData.Write(1280); - Context.ResponseData.Write(720); - Context.ResponseData.Write(60.0f); - Context.ResponseData.Write(0); + context.ResponseData.Write(1280); + context.ResponseData.Write(720); + context.ResponseData.Write(60.0f); + context.ResponseData.Write(0); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Vi/ISystemRootService.cs b/Ryujinx.HLE/HOS/Services/Vi/ISystemRootService.cs index d9b7c220..5e255ce5 100644 --- a/Ryujinx.HLE/HOS/Services/Vi/ISystemRootService.cs +++ b/Ryujinx.HLE/HOS/Services/Vi/ISystemRootService.cs @@ -5,23 +5,23 @@ namespace Ryujinx.HLE.HOS.Services.Vi { class ISystemRootService : IpcService { - private Dictionary<int, ServiceProcessRequest> m_Commands; + private Dictionary<int, ServiceProcessRequest> _commands; - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands; + public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; public ISystemRootService() { - m_Commands = new Dictionary<int, ServiceProcessRequest>() + _commands = new Dictionary<int, ServiceProcessRequest> { { 1, GetDisplayService } }; } - public long GetDisplayService(ServiceCtx Context) + public long GetDisplayService(ServiceCtx context) { - int ServiceType = Context.RequestData.ReadInt32(); + int serviceType = context.RequestData.ReadInt32(); - MakeObject(Context, new IApplicationDisplayService()); + MakeObject(context, new IApplicationDisplayService()); return 0; } diff --git a/Ryujinx.HLE/HOS/Services/Vi/NvFlinger.cs b/Ryujinx.HLE/HOS/Services/Vi/NvFlinger.cs index facfbe60..1b57b331 100644 --- a/Ryujinx.HLE/HOS/Services/Vi/NvFlinger.cs +++ b/Ryujinx.HLE/HOS/Services/Vi/NvFlinger.cs @@ -16,13 +16,13 @@ namespace Ryujinx.HLE.HOS.Services.Android { class NvFlinger : IDisposable { - private delegate long ServiceProcessParcel(ServiceCtx Context, BinaryReader ParcelReader); + private delegate long ServiceProcessParcel(ServiceCtx context, BinaryReader parcelReader); - private Dictionary<(string, int), ServiceProcessParcel> Commands; + private Dictionary<(string, int), ServiceProcessParcel> _commands; - private KEvent BinderEvent; + private KEvent _binderEvent; - private IGalRenderer Renderer; + private IGalRenderer _renderer; private const int BufferQueueCount = 0x40; private const int BufferQueueMask = BufferQueueCount - 1; @@ -62,15 +62,15 @@ namespace Ryujinx.HLE.HOS.Services.Android public GbpBuffer Data; } - private BufferEntry[] BufferQueue; + private BufferEntry[] _bufferQueue; - private AutoResetEvent WaitBufferFree; + private AutoResetEvent _waitBufferFree; - private bool Disposed; + private bool _disposed; - public NvFlinger(IGalRenderer Renderer, KEvent BinderEvent) + public NvFlinger(IGalRenderer renderer, KEvent binderEvent) { - Commands = new Dictionary<(string, int), ServiceProcessParcel>() + _commands = new Dictionary<(string, int), ServiceProcessParcel> { { ("android.gui.IGraphicBufferProducer", 0x1), GbpRequestBuffer }, { ("android.gui.IGraphicBufferProducer", 0x3), GbpDequeueBuffer }, @@ -83,307 +83,307 @@ namespace Ryujinx.HLE.HOS.Services.Android { ("android.gui.IGraphicBufferProducer", 0xe), GbpPreallocBuffer } }; - this.Renderer = Renderer; - this.BinderEvent = BinderEvent; + _renderer = renderer; + _binderEvent = binderEvent; - BufferQueue = new BufferEntry[0x40]; + _bufferQueue = new BufferEntry[0x40]; - WaitBufferFree = new AutoResetEvent(false); + _waitBufferFree = new AutoResetEvent(false); } - public long ProcessParcelRequest(ServiceCtx Context, byte[] ParcelData, int Code) + public long ProcessParcelRequest(ServiceCtx context, byte[] parcelData, int code) { - using (MemoryStream MS = new MemoryStream(ParcelData)) + using (MemoryStream ms = new MemoryStream(parcelData)) { - BinaryReader Reader = new BinaryReader(MS); + BinaryReader reader = new BinaryReader(ms); - MS.Seek(4, SeekOrigin.Current); + ms.Seek(4, SeekOrigin.Current); - int StrSize = Reader.ReadInt32(); + int strSize = reader.ReadInt32(); - string InterfaceName = Encoding.Unicode.GetString(Reader.ReadBytes(StrSize * 2)); + string interfaceName = Encoding.Unicode.GetString(reader.ReadBytes(strSize * 2)); - long Remainder = MS.Position & 0xf; + long remainder = ms.Position & 0xf; - if (Remainder != 0) + if (remainder != 0) { - MS.Seek(0x10 - Remainder, SeekOrigin.Current); + ms.Seek(0x10 - remainder, SeekOrigin.Current); } - MS.Seek(0x50, SeekOrigin.Begin); + ms.Seek(0x50, SeekOrigin.Begin); - if (Commands.TryGetValue((InterfaceName, Code), out ServiceProcessParcel ProcReq)) + if (_commands.TryGetValue((interfaceName, code), out ServiceProcessParcel procReq)) { - Logger.PrintDebug(LogClass.ServiceVi, $"{InterfaceName} {ProcReq.Method.Name}"); + Logger.PrintDebug(LogClass.ServiceVi, $"{interfaceName} {procReq.Method.Name}"); - return ProcReq(Context, Reader); + return procReq(context, reader); } else { - throw new NotImplementedException($"{InterfaceName} {Code}"); + throw new NotImplementedException($"{interfaceName} {code}"); } } } - private long GbpRequestBuffer(ServiceCtx Context, BinaryReader ParcelReader) + private long GbpRequestBuffer(ServiceCtx context, BinaryReader parcelReader) { - int Slot = ParcelReader.ReadInt32(); + int slot = parcelReader.ReadInt32(); - using (MemoryStream MS = new MemoryStream()) + using (MemoryStream ms = new MemoryStream()) { - BinaryWriter Writer = new BinaryWriter(MS); + BinaryWriter writer = new BinaryWriter(ms); - BufferEntry Entry = BufferQueue[Slot]; + BufferEntry entry = _bufferQueue[slot]; - int BufferCount = 1; //? - long BufferSize = Entry.Data.Size; + int bufferCount = 1; //? + long bufferSize = entry.Data.Size; - Writer.Write(BufferCount); - Writer.Write(BufferSize); + writer.Write(bufferCount); + writer.Write(bufferSize); - Entry.Data.Write(Writer); + entry.Data.Write(writer); - Writer.Write(0); + writer.Write(0); - return MakeReplyParcel(Context, MS.ToArray()); + return MakeReplyParcel(context, ms.ToArray()); } } - private long GbpDequeueBuffer(ServiceCtx Context, BinaryReader ParcelReader) + private long GbpDequeueBuffer(ServiceCtx context, BinaryReader parcelReader) { //TODO: Errors. - int Format = ParcelReader.ReadInt32(); - int Width = ParcelReader.ReadInt32(); - int Height = ParcelReader.ReadInt32(); - int GetTimestamps = ParcelReader.ReadInt32(); - int Usage = ParcelReader.ReadInt32(); + int format = parcelReader.ReadInt32(); + int width = parcelReader.ReadInt32(); + int height = parcelReader.ReadInt32(); + int getTimestamps = parcelReader.ReadInt32(); + int usage = parcelReader.ReadInt32(); - int Slot = GetFreeSlotBlocking(Width, Height); + int slot = GetFreeSlotBlocking(width, height); - return MakeReplyParcel(Context, Slot, 1, 0x24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + return MakeReplyParcel(context, slot, 1, 0x24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); } - private long GbpQueueBuffer(ServiceCtx Context, BinaryReader ParcelReader) + private long GbpQueueBuffer(ServiceCtx context, BinaryReader parcelReader) { - Context.Device.Statistics.RecordGameFrameTime(); + context.Device.Statistics.RecordGameFrameTime(); //TODO: Errors. - int Slot = ParcelReader.ReadInt32(); - int Unknown4 = ParcelReader.ReadInt32(); - int Unknown8 = ParcelReader.ReadInt32(); - int Unknownc = ParcelReader.ReadInt32(); - int Timestamp = ParcelReader.ReadInt32(); - int IsAutoTimestamp = ParcelReader.ReadInt32(); - int CropTop = ParcelReader.ReadInt32(); - int CropLeft = ParcelReader.ReadInt32(); - int CropRight = ParcelReader.ReadInt32(); - int CropBottom = ParcelReader.ReadInt32(); - int ScalingMode = ParcelReader.ReadInt32(); - int Transform = ParcelReader.ReadInt32(); - int StickyTransform = ParcelReader.ReadInt32(); - int Unknown34 = ParcelReader.ReadInt32(); - int Unknown38 = ParcelReader.ReadInt32(); - int IsFenceValid = ParcelReader.ReadInt32(); - int Fence0Id = ParcelReader.ReadInt32(); - int Fence0Value = ParcelReader.ReadInt32(); - int Fence1Id = ParcelReader.ReadInt32(); - int Fence1Value = ParcelReader.ReadInt32(); - - BufferQueue[Slot].Transform = (HalTransform)Transform; - - BufferQueue[Slot].Crop.Top = CropTop; - BufferQueue[Slot].Crop.Left = CropLeft; - BufferQueue[Slot].Crop.Right = CropRight; - BufferQueue[Slot].Crop.Bottom = CropBottom; - - BufferQueue[Slot].State = BufferState.Queued; - - SendFrameBuffer(Context, Slot); - - if (Context.Device.EnableDeviceVsync) + int slot = parcelReader.ReadInt32(); + int unknown4 = parcelReader.ReadInt32(); + int unknown8 = parcelReader.ReadInt32(); + int unknownC = parcelReader.ReadInt32(); + int timestamp = parcelReader.ReadInt32(); + int isAutoTimestamp = parcelReader.ReadInt32(); + int cropTop = parcelReader.ReadInt32(); + int cropLeft = parcelReader.ReadInt32(); + int cropRight = parcelReader.ReadInt32(); + int cropBottom = parcelReader.ReadInt32(); + int scalingMode = parcelReader.ReadInt32(); + int transform = parcelReader.ReadInt32(); + int stickyTransform = parcelReader.ReadInt32(); + int unknown34 = parcelReader.ReadInt32(); + int unknown38 = parcelReader.ReadInt32(); + int isFenceValid = parcelReader.ReadInt32(); + int fence0Id = parcelReader.ReadInt32(); + int fence0Value = parcelReader.ReadInt32(); + int fence1Id = parcelReader.ReadInt32(); + int fence1Value = parcelReader.ReadInt32(); + + _bufferQueue[slot].Transform = (HalTransform)transform; + + _bufferQueue[slot].Crop.Top = cropTop; + _bufferQueue[slot].Crop.Left = cropLeft; + _bufferQueue[slot].Crop.Right = cropRight; + _bufferQueue[slot].Crop.Bottom = cropBottom; + + _bufferQueue[slot].State = BufferState.Queued; + + SendFrameBuffer(context, slot); + + if (context.Device.EnableDeviceVsync) { - Context.Device.VsyncEvent.WaitOne(); + context.Device.VsyncEvent.WaitOne(); } - return MakeReplyParcel(Context, 1280, 720, 0, 0, 0); + return MakeReplyParcel(context, 1280, 720, 0, 0, 0); } - private long GbpDetachBuffer(ServiceCtx Context, BinaryReader ParcelReader) + private long GbpDetachBuffer(ServiceCtx context, BinaryReader parcelReader) { - return MakeReplyParcel(Context, 0); + return MakeReplyParcel(context, 0); } - private long GbpCancelBuffer(ServiceCtx Context, BinaryReader ParcelReader) + private long GbpCancelBuffer(ServiceCtx context, BinaryReader parcelReader) { //TODO: Errors. - int Slot = ParcelReader.ReadInt32(); + int slot = parcelReader.ReadInt32(); - BufferQueue[Slot].State = BufferState.Free; + _bufferQueue[slot].State = BufferState.Free; - WaitBufferFree.Set(); + _waitBufferFree.Set(); - return MakeReplyParcel(Context, 0); + return MakeReplyParcel(context, 0); } - private long GbpQuery(ServiceCtx Context, BinaryReader ParcelReader) + private long GbpQuery(ServiceCtx context, BinaryReader parcelReader) { - return MakeReplyParcel(Context, 0, 0); + return MakeReplyParcel(context, 0, 0); } - private long GbpConnect(ServiceCtx Context, BinaryReader ParcelReader) + private long GbpConnect(ServiceCtx context, BinaryReader parcelReader) { - return MakeReplyParcel(Context, 1280, 720, 0, 0, 0); + return MakeReplyParcel(context, 1280, 720, 0, 0, 0); } - private long GbpDisconnect(ServiceCtx Context, BinaryReader ParcelReader) + private long GbpDisconnect(ServiceCtx context, BinaryReader parcelReader) { - return MakeReplyParcel(Context, 0); + return MakeReplyParcel(context, 0); } - private long GbpPreallocBuffer(ServiceCtx Context, BinaryReader ParcelReader) + private long GbpPreallocBuffer(ServiceCtx context, BinaryReader parcelReader) { - int Slot = ParcelReader.ReadInt32(); + int slot = parcelReader.ReadInt32(); - int BufferCount = ParcelReader.ReadInt32(); + int bufferCount = parcelReader.ReadInt32(); - if (BufferCount > 0) + if (bufferCount > 0) { - long BufferSize = ParcelReader.ReadInt64(); + long bufferSize = parcelReader.ReadInt64(); - BufferQueue[Slot].State = BufferState.Free; + _bufferQueue[slot].State = BufferState.Free; - BufferQueue[Slot].Data = new GbpBuffer(ParcelReader); + _bufferQueue[slot].Data = new GbpBuffer(parcelReader); } - return MakeReplyParcel(Context, 0); + return MakeReplyParcel(context, 0); } - private long MakeReplyParcel(ServiceCtx Context, params int[] Ints) + private long MakeReplyParcel(ServiceCtx context, params int[] ints) { - using (MemoryStream MS = new MemoryStream()) + using (MemoryStream ms = new MemoryStream()) { - BinaryWriter Writer = new BinaryWriter(MS); + BinaryWriter writer = new BinaryWriter(ms); - foreach (int Int in Ints) + foreach (int Int in ints) { - Writer.Write(Int); + writer.Write(Int); } - return MakeReplyParcel(Context, MS.ToArray()); + return MakeReplyParcel(context, ms.ToArray()); } } - private long MakeReplyParcel(ServiceCtx Context, byte[] Data) + private long MakeReplyParcel(ServiceCtx context, byte[] data) { - (long ReplyPos, long ReplySize) = Context.Request.GetBufferType0x22(); + (long replyPos, long replySize) = context.Request.GetBufferType0x22(); - byte[] Reply = MakeParcel(Data, new byte[0]); + byte[] reply = MakeParcel(data, new byte[0]); - Context.Memory.WriteBytes(ReplyPos, Reply); + context.Memory.WriteBytes(replyPos, reply); return 0; } - private void SendFrameBuffer(ServiceCtx Context, int Slot) + private void SendFrameBuffer(ServiceCtx context, int slot) { - int FbWidth = BufferQueue[Slot].Data.Width; - int FbHeight = BufferQueue[Slot].Data.Height; + int fbWidth = _bufferQueue[slot].Data.Width; + int fbHeight = _bufferQueue[slot].Data.Height; - int NvMapHandle = BitConverter.ToInt32(BufferQueue[Slot].Data.RawData, 0x4c); - int BufferOffset = BitConverter.ToInt32(BufferQueue[Slot].Data.RawData, 0x50); + int nvMapHandle = BitConverter.ToInt32(_bufferQueue[slot].Data.RawData, 0x4c); + int bufferOffset = BitConverter.ToInt32(_bufferQueue[slot].Data.RawData, 0x50); - NvMapHandle Map = NvMapIoctl.GetNvMap(Context, NvMapHandle);; + NvMapHandle map = NvMapIoctl.GetNvMap(context, nvMapHandle); - long FbAddr = Map.Address + BufferOffset; + long fbAddr = map.Address + bufferOffset; - BufferQueue[Slot].State = BufferState.Acquired; + _bufferQueue[slot].State = BufferState.Acquired; - Rect Crop = BufferQueue[Slot].Crop; + Rect crop = _bufferQueue[slot].Crop; - bool FlipX = BufferQueue[Slot].Transform.HasFlag(HalTransform.FlipX); - bool FlipY = BufferQueue[Slot].Transform.HasFlag(HalTransform.FlipY); + bool flipX = _bufferQueue[slot].Transform.HasFlag(HalTransform.FlipX); + bool flipY = _bufferQueue[slot].Transform.HasFlag(HalTransform.FlipY); //Note: Rotation is being ignored. - int Top = Crop.Top; - int Left = Crop.Left; - int Right = Crop.Right; - int Bottom = Crop.Bottom; + int top = crop.Top; + int left = crop.Left; + int right = crop.Right; + int bottom = crop.Bottom; - NvGpuVmm Vmm = NvGpuASIoctl.GetASCtx(Context).Vmm; + NvGpuVmm vmm = NvGpuASIoctl.GetASCtx(context).Vmm; - Renderer.QueueAction(() => + _renderer.QueueAction(() => { - if (!Renderer.Texture.TryGetImage(FbAddr, out GalImage Image)) + if (!_renderer.Texture.TryGetImage(fbAddr, out GalImage image)) { - Image = new GalImage( - FbWidth, - FbHeight, 1, 16, + image = new GalImage( + fbWidth, + fbHeight, 1, 16, GalMemoryLayout.BlockLinear, GalImageFormat.RGBA8 | GalImageFormat.Unorm); } - Context.Device.Gpu.ResourceManager.ClearPbCache(); - Context.Device.Gpu.ResourceManager.SendTexture(Vmm, FbAddr, Image); + context.Device.Gpu.ResourceManager.ClearPbCache(); + context.Device.Gpu.ResourceManager.SendTexture(vmm, fbAddr, image); - Renderer.RenderTarget.SetTransform(FlipX, FlipY, Top, Left, Right, Bottom); - Renderer.RenderTarget.Present(FbAddr); + _renderer.RenderTarget.SetTransform(flipX, flipY, top, left, right, bottom); + _renderer.RenderTarget.Present(fbAddr); - ReleaseBuffer(Slot); + ReleaseBuffer(slot); }); } - private void ReleaseBuffer(int Slot) + private void ReleaseBuffer(int slot) { - BufferQueue[Slot].State = BufferState.Free; + _bufferQueue[slot].State = BufferState.Free; - BinderEvent.ReadableEvent.Signal(); + _binderEvent.ReadableEvent.Signal(); - WaitBufferFree.Set(); + _waitBufferFree.Set(); } - private int GetFreeSlotBlocking(int Width, int Height) + private int GetFreeSlotBlocking(int width, int height) { - int Slot; + int slot; do { - if ((Slot = GetFreeSlot(Width, Height)) != -1) + if ((slot = GetFreeSlot(width, height)) != -1) { break; } - if (Disposed) + if (_disposed) { break; } - WaitBufferFree.WaitOne(); + _waitBufferFree.WaitOne(); } - while (!Disposed); + while (!_disposed); - return Slot; + return slot; } - private int GetFreeSlot(int Width, int Height) + private int GetFreeSlot(int width, int height) { - lock (BufferQueue) + lock (_bufferQueue) { - for (int Slot = 0; Slot < BufferQueue.Length; Slot++) + for (int slot = 0; slot < _bufferQueue.Length; slot++) { - if (BufferQueue[Slot].State != BufferState.Free) + if (_bufferQueue[slot].State != BufferState.Free) { continue; } - GbpBuffer Data = BufferQueue[Slot].Data; + GbpBuffer data = _bufferQueue[slot].Data; - if (Data.Width == Width && - Data.Height == Height) + if (data.Width == width && + data.Height == height) { - BufferQueue[Slot].State = BufferState.Dequeued; + _bufferQueue[slot].State = BufferState.Dequeued; - return Slot; + return slot; } } } @@ -396,14 +396,14 @@ namespace Ryujinx.HLE.HOS.Services.Android Dispose(true); } - protected virtual void Dispose(bool Disposing) + protected virtual void Dispose(bool disposing) { - if (Disposing && !Disposed) + if (disposing && !_disposed) { - Disposed = true; + _disposed = true; - WaitBufferFree.Set(); - WaitBufferFree.Dispose(); + _waitBufferFree.Set(); + _waitBufferFree.Dispose(); } } } diff --git a/Ryujinx.HLE/HOS/Services/Vi/Parcel.cs b/Ryujinx.HLE/HOS/Services/Vi/Parcel.cs index bb842795..63c5a82f 100644 --- a/Ryujinx.HLE/HOS/Services/Vi/Parcel.cs +++ b/Ryujinx.HLE/HOS/Services/Vi/Parcel.cs @@ -5,53 +5,53 @@ namespace Ryujinx.HLE.HOS.Services.Android { static class Parcel { - public static byte[] GetParcelData(byte[] Parcel) + public static byte[] GetParcelData(byte[] parcel) { - if (Parcel == null) + if (parcel == null) { - throw new ArgumentNullException(nameof(Parcel)); + throw new ArgumentNullException(nameof(parcel)); } - using (MemoryStream MS = new MemoryStream(Parcel)) + using (MemoryStream ms = new MemoryStream(parcel)) { - BinaryReader Reader = new BinaryReader(MS); + BinaryReader reader = new BinaryReader(ms); - int DataSize = Reader.ReadInt32(); - int DataOffset = Reader.ReadInt32(); - int ObjsSize = Reader.ReadInt32(); - int ObjsOffset = Reader.ReadInt32(); + int dataSize = reader.ReadInt32(); + int dataOffset = reader.ReadInt32(); + int objsSize = reader.ReadInt32(); + int objsOffset = reader.ReadInt32(); - MS.Seek(DataOffset - 0x10, SeekOrigin.Current); + ms.Seek(dataOffset - 0x10, SeekOrigin.Current); - return Reader.ReadBytes(DataSize); + return reader.ReadBytes(dataSize); } } - public static byte[] MakeParcel(byte[] Data, byte[] Objs) + public static byte[] MakeParcel(byte[] data, byte[] objs) { - if (Data == null) + if (data == null) { - throw new ArgumentNullException(nameof(Data)); + throw new ArgumentNullException(nameof(data)); } - if (Objs == null) + if (objs == null) { - throw new ArgumentNullException(nameof(Objs)); + throw new ArgumentNullException(nameof(objs)); } - using (MemoryStream MS = new MemoryStream()) + using (MemoryStream ms = new MemoryStream()) { - BinaryWriter Writer = new BinaryWriter(MS); + BinaryWriter writer = new BinaryWriter(ms); - Writer.Write(Data.Length); - Writer.Write(0x10); - Writer.Write(Objs.Length); - Writer.Write(Data.Length + 0x10); + writer.Write(data.Length); + writer.Write(0x10); + writer.Write(objs.Length); + writer.Write(data.Length + 0x10); - Writer.Write(Data); - Writer.Write(Objs); + writer.Write(data); + writer.Write(objs); - return MS.ToArray(); + return ms.ToArray(); } } } |
