Port yuzu-emu/yuzu#2249: "ipc_helpers: Allow pushing and popping floating-point values" (#4702)

Certain values that are passed through the IPC buffer are actually
floating point values, not solely integral values.
This commit is contained in:
Tobias 2019-06-09 16:03:22 +02:00 committed by GitHub
parent 75ebf1fdf6
commit 318095f9b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 1 deletions

View file

@ -141,6 +141,20 @@ inline void RequestBuilder::Push(u64 value) {
Push(static_cast<u32>(value >> 32));
}
template <>
inline void RequestBuilder::Push(f32 value) {
u32 integral;
std::memcpy(&integral, &value, sizeof(u32));
Push(integral);
}
template <>
inline void RequestBuilder::Push(f64 value) {
u64 integral;
std::memcpy(&integral, &value, sizeof(u64));
Push(integral);
}
template <>
inline void RequestBuilder::Push(bool value) {
Push(static_cast<u8>(value));
@ -341,6 +355,22 @@ inline s32 RequestParser::Pop() {
return data;
}
template <>
inline f32 RequestParser::Pop() {
const u32 value = Pop<u32>();
float real;
std::memcpy(&real, &value, sizeof(real));
return real;
}
template <>
inline f64 RequestParser::Pop() {
const u64 value = Pop<u64>();
f64 real;
std::memcpy(&real, &value, sizeof(real));
return real;
}
template <>
inline bool RequestParser::Pop() {
return Pop<u8>() != 0;

View file

@ -331,7 +331,7 @@ void Module::Interface::GetGyroscopeLowRawToDpsCoefficient(Kernel::HLERequestCon
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.PushRaw<f32>(gyroscope_coef);
rb.Push(gyroscope_coef);
}
void Module::Interface::GetGyroscopeLowCalibrateParam(Kernel::HLERequestContext& ctx) {