aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs
diff options
context:
space:
mode:
authormageven <62494521+mageven@users.noreply.github.com>2020-04-03 12:23:06 +0530
committerGitHub <noreply@github.com>2020-04-03 17:53:06 +1100
commit4d93f97408a2ab36b45c1027f6230a941a7297ea (patch)
treeca089d6ea1033256311dfe713949611abaecd40d /Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs
parente93ca84b14cc325364f1ccc45a6e8622978e959d (diff)
Revert SwKbd Applet ReadStruct and fix IApplet's ReadStruct to catch (#1087)
error at compile time
Diffstat (limited to 'Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs')
-rw-r--r--Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs17
1 files changed, 16 insertions, 1 deletions
diff --git a/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs b/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs
index ed54eb98..e142838c 100644
--- a/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs
+++ b/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs
@@ -41,7 +41,7 @@ namespace Ryujinx.HLE.HOS.Applets
var keyboardConfig = _normalSession.Pop();
var transferMemory = _normalSession.Pop();
- _keyboardConfig = IApplet.ReadStruct<SoftwareKeyboardConfig>(keyboardConfig);
+ _keyboardConfig = ReadStruct<SoftwareKeyboardConfig>(keyboardConfig);
if (_keyboardConfig.UseUtf8)
{
@@ -176,5 +176,20 @@ namespace Ryujinx.HLE.HOS.Applets
return stream.ToArray();
}
}
+
+ private static T ReadStruct<T>(byte[] data)
+ where T : struct
+ {
+ GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);
+
+ try
+ {
+ return Marshal.PtrToStructure<T>(handle.AddrOfPinnedObject());
+ }
+ finally
+ {
+ handle.Free();
+ }
+ }
}
}