summaryrefslogtreecommitdiffstats
path: root/src/input_common/motion_input.cpp
diff options
context:
space:
mode:
authorgerman <german@thesoftwareartisans.com>2020-09-18 03:26:34 +0200
committergerman <german@thesoftwareartisans.com>2020-09-26 00:59:52 +0200
commit03b574ae2272fc8465e7d38f21b198fcb1885186 (patch)
treee6e70906677339fce1a7bedafab8d8fcb39026b4 /src/input_common/motion_input.cpp
parentMerge pull request #4717 from lioncash/debug (diff)
downloadyuzu-03b574ae2272fc8465e7d38f21b198fcb1885186.tar
yuzu-03b574ae2272fc8465e7d38f21b198fcb1885186.tar.gz
yuzu-03b574ae2272fc8465e7d38f21b198fcb1885186.tar.bz2
yuzu-03b574ae2272fc8465e7d38f21b198fcb1885186.tar.lz
yuzu-03b574ae2272fc8465e7d38f21b198fcb1885186.tar.xz
yuzu-03b574ae2272fc8465e7d38f21b198fcb1885186.tar.zst
yuzu-03b574ae2272fc8465e7d38f21b198fcb1885186.zip
Diffstat (limited to '')
-rw-r--r--src/input_common/motion_input.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/input_common/motion_input.cpp b/src/input_common/motion_input.cpp
index 22a849866..b99d3497f 100644
--- a/src/input_common/motion_input.cpp
+++ b/src/input_common/motion_input.cpp
@@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included
+#include <random>
#include "common/math_util.h"
#include "input_common/motion_input.h"
@@ -159,6 +160,37 @@ Common::Vec3f MotionInput::GetRotations() const {
return rotations;
}
+Input::MotionStatus MotionInput::GetMotion() const {
+ const Common::Vec3f gyroscope = GetGyroscope();
+ const Common::Vec3f accelerometer = GetAcceleration();
+ const Common::Vec3f rotation = GetRotations();
+ const std::array<Common::Vec3f, 3> orientation = GetOrientation();
+ return {accelerometer, gyroscope, rotation, orientation};
+}
+
+Input::MotionStatus MotionInput::GetRandomMotion(int accel_magnitude, int gyro_magnitude) const {
+ std::random_device device;
+ std::mt19937 gen(device());
+ std::uniform_int_distribution<s16> distribution(-1000, 1000);
+ const Common::Vec3f gyroscope = {
+ distribution(gen) * 0.001f,
+ distribution(gen) * 0.001f,
+ distribution(gen) * 0.001f,
+ };
+ const Common::Vec3f accelerometer = {
+ distribution(gen) * 0.001f,
+ distribution(gen) * 0.001f,
+ distribution(gen) * 0.001f,
+ };
+ const Common::Vec3f rotation = {};
+ const std::array<Common::Vec3f, 3> orientation = {
+ Common::Vec3f{1.0f, 0, 0},
+ Common::Vec3f{0, 1.0f, 0},
+ Common::Vec3f{0, 0, 1.0f},
+ };
+ return {accelerometer * accel_magnitude, gyroscope * gyro_magnitude, rotation, orientation};
+}
+
void MotionInput::ResetOrientation() {
if (!reset_enabled) {
return;