aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Pl
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-08-16 20:47:36 -0300
committerGitHub <noreply@github.com>2018-08-16 20:47:36 -0300
commit521751795a1c97c0d97f6f8904a3be69b13d3a9d (patch)
tree942a05899c40e2de6d92a38b93a494bd96ee64b8 /Ryujinx.HLE/HOS/Services/Pl
parent182d716867ae477c2b15a5332430dc2641fa1cc3 (diff)
Code style fixes and nits on the HLE project (#355)
* Some style fixes and nits on ITimeZoneService * Remove some unneeded usings * Remove the Ryujinx.HLE.OsHle.Handles namespace * Remove hbmenu automatic load on process exit * Rename Ns to Device, rename Os to System, rename SystemState to State * Move Exceptions and Utilities out of OsHle * Rename OsHle to HOS * Rename OsHle folder to HOS * IManagerDisplayService and ISystemDisplayService style fixes * BsdError shouldn't be public * Add a empty new line before using static * Remove unused file * Some style fixes on NPDM * Exit gracefully when the application is closed * Code style fixes on IGeneralService * Add 0x prefix on values printed as hex * Small improvements on finalization code * Move ProcessId and ThreadId out of AThreadState * Rename VFs to FileSystem * FsAccessHeader shouldn't be public. Also fix file names casing * More case changes on NPDM * Remove unused files * Move using to the correct place on NPDM * Use properties on KernelAccessControlMmio * Address PR feedback
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Pl')
-rw-r--r--Ryujinx.HLE/HOS/Services/Pl/ISharedFontManager.cs125
1 files changed, 125 insertions, 0 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Pl/ISharedFontManager.cs b/Ryujinx.HLE/HOS/Services/Pl/ISharedFontManager.cs
new file mode 100644
index 00000000..92821217
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Services/Pl/ISharedFontManager.cs
@@ -0,0 +1,125 @@
+using Ryujinx.HLE.HOS.Font;
+using Ryujinx.HLE.HOS.Ipc;
+using System.Collections.Generic;
+
+namespace Ryujinx.HLE.HOS.Services.Pl
+{
+ class ISharedFontManager : IpcService
+ {
+ private Dictionary<int, ServiceProcessRequest> m_Commands;
+
+ public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
+
+ public ISharedFontManager()
+ {
+ m_Commands = new Dictionary<int, ServiceProcessRequest>()
+ {
+ { 0, RequestLoad },
+ { 1, GetLoadState },
+ { 2, GetFontSize },
+ { 3, GetSharedMemoryAddressOffset },
+ { 4, GetSharedMemoryNativeHandle },
+ { 5, GetSharedFontInOrderOfPriority }
+ };
+ }
+
+ public long RequestLoad(ServiceCtx Context)
+ {
+ 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)
+ {
+ SharedFontType FontType = (SharedFontType)Context.RequestData.ReadInt32();
+
+ //1 (true) indicates that the font is already loaded.
+ //All fonts are already loaded.
+ Context.ResponseData.Write(1);
+
+ return 0;
+ }
+
+ public long GetFontSize(ServiceCtx Context)
+ {
+ SharedFontType FontType = (SharedFontType)Context.RequestData.ReadInt32();
+
+ Context.ResponseData.Write(Context.Device.System.Font.GetFontSize(FontType));
+
+ return 0;
+ }
+
+ public long GetSharedMemoryAddressOffset(ServiceCtx Context)
+ {
+ SharedFontType FontType = (SharedFontType)Context.RequestData.ReadInt32();
+
+ Context.ResponseData.Write(Context.Device.System.Font.GetSharedMemoryAddressOffset(FontType));
+
+ return 0;
+ }
+
+ public long GetSharedMemoryNativeHandle(ServiceCtx Context)
+ {
+ Context.Device.System.Font.EnsureInitialized();
+
+ int Handle = Context.Process.HandleTable.OpenHandle(Context.Device.System.FontSharedMem);
+
+ Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
+
+ return 0;
+ }
+
+ public long GetSharedFontInOrderOfPriority(ServiceCtx Context)
+ {
+ long LanguageCode = Context.RequestData.ReadInt64();
+ int LoadedCount = 0;
+
+ for (SharedFontType Type = 0; Type < SharedFontType.Count; Type++)
+ {
+ int Offset = (int)Type * 4;
+
+ if (!AddFontToOrderOfPriorityList(Context, (SharedFontType)Type, Offset))
+ {
+ break;
+ }
+
+ LoadedCount++;
+ }
+
+ Context.ResponseData.Write(LoadedCount);
+ Context.ResponseData.Write((int)SharedFontType.Count);
+
+ return 0;
+ }
+
+ private bool AddFontToOrderOfPriorityList(ServiceCtx Context, SharedFontType FontType, int Offset)
+ {
+ 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 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)
+ {
+ return false;
+ }
+
+ Context.Memory.WriteInt32(TypesPosition + Offset, (int)FontType);
+
+ Context.Memory.WriteInt32(OffsetsPosition + Offset, Context.Device.System.Font.GetSharedMemoryAddressOffset(FontType));
+
+ Context.Memory.WriteInt32(FontSizeBufferPosition + Offset, Context.Device.System.Font.GetFontSize(FontType));
+
+ return true;
+ }
+ }
+} \ No newline at end of file