diff options
author | bunnei <bunneidev@gmail.com> | 2021-05-20 00:47:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-20 00:47:48 +0200 |
commit | 41b1f8d61642622e09689795515927bc24180f67 (patch) | |
tree | dff9355600630631e279743bb7b5285f2396f470 /src/input_common | |
parent | Merge pull request #6317 from ameerj/fps-fix (diff) | |
parent | input_common: Sanitize motion data (diff) | |
download | yuzu-41b1f8d61642622e09689795515927bc24180f67.tar yuzu-41b1f8d61642622e09689795515927bc24180f67.tar.gz yuzu-41b1f8d61642622e09689795515927bc24180f67.tar.bz2 yuzu-41b1f8d61642622e09689795515927bc24180f67.tar.lz yuzu-41b1f8d61642622e09689795515927bc24180f67.tar.xz yuzu-41b1f8d61642622e09689795515927bc24180f67.tar.zst yuzu-41b1f8d61642622e09689795515927bc24180f67.zip |
Diffstat (limited to 'src/input_common')
-rw-r--r-- | src/input_common/udp/client.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/input_common/udp/client.cpp b/src/input_common/udp/client.cpp index 8a38a380d..bc1dfab3d 100644 --- a/src/input_common/udp/client.cpp +++ b/src/input_common/udp/client.cpp @@ -86,6 +86,7 @@ private: case Type::PadData: { Response::PadData pad_data; std::memcpy(&pad_data, &receive_buffer[sizeof(Header)], sizeof(Response::PadData)); + SanitizeMotion(pad_data); callback.pad_data(std::move(pad_data)); break; } @@ -114,6 +115,28 @@ private: StartSend(timer.expiry()); } + void SanitizeMotion(Response::PadData& data) { + // Zero out any non number value + if (!std::isnormal(data.gyro.pitch)) { + data.gyro.pitch = 0; + } + if (!std::isnormal(data.gyro.roll)) { + data.gyro.roll = 0; + } + if (!std::isnormal(data.gyro.yaw)) { + data.gyro.yaw = 0; + } + if (!std::isnormal(data.accel.x)) { + data.accel.x = 0; + } + if (!std::isnormal(data.accel.y)) { + data.accel.y = 0; + } + if (!std::isnormal(data.accel.z)) { + data.accel.z = 0; + } + } + SocketCallback callback; boost::asio::io_service io_service; boost::asio::basic_waitable_timer<clock> timer; |