From 64444ff48178835b554c1b5d86b70ce2f7d82553 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 16 Mar 2019 14:05:01 -0400 Subject: [PATCH] ipc_helpers: Allow pushing and popping floating-point values Certain values that are passed through the IPC buffer are actually floating point values, not solely integral values. --- src/core/hle/ipc_helpers.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h index a1e4be070..68406eb63 100644 --- a/src/core/hle/ipc_helpers.h +++ b/src/core/hle/ipc_helpers.h @@ -274,6 +274,20 @@ inline void ResponseBuilder::Push(u64 value) { Push(static_cast(value >> 32)); } +template <> +inline void ResponseBuilder::Push(float value) { + u32 integral; + std::memcpy(&integral, &value, sizeof(u32)); + Push(integral); +} + +template <> +inline void ResponseBuilder::Push(double value) { + u64 integral; + std::memcpy(&integral, &value, sizeof(u64)); + Push(integral); +} + template <> inline void ResponseBuilder::Push(bool value) { Push(static_cast(value)); @@ -415,6 +429,22 @@ inline s64 RequestParser::Pop() { return static_cast(Pop()); } +template <> +inline float RequestParser::Pop() { + const u32 value = Pop(); + float real; + std::memcpy(&real, &value, sizeof(real)); + return real; +} + +template <> +inline double RequestParser::Pop() { + const u64 value = Pop(); + float real; + std::memcpy(&real, &value, sizeof(real)); + return real; +} + template <> inline bool RequestParser::Pop() { return Pop() != 0;