summaryrefslogtreecommitdiffstats
path: root/src/input_common/motion_from_button.cpp
diff options
context:
space:
mode:
authorgerman <german@thesoftwareartisans.com>2020-09-26 00:58:27 +0200
committergerman <german@thesoftwareartisans.com>2020-09-26 00:59:52 +0200
commit297823239026d1b5487f9b07f63646ca4a2e3a79 (patch)
treea08b8f0930f4a46d6853fb66d33bf15073613c0b /src/input_common/motion_from_button.cpp
parentAdd random motion input to SDL (diff)
downloadyuzu-297823239026d1b5487f9b07f63646ca4a2e3a79.tar
yuzu-297823239026d1b5487f9b07f63646ca4a2e3a79.tar.gz
yuzu-297823239026d1b5487f9b07f63646ca4a2e3a79.tar.bz2
yuzu-297823239026d1b5487f9b07f63646ca4a2e3a79.tar.lz
yuzu-297823239026d1b5487f9b07f63646ca4a2e3a79.tar.xz
yuzu-297823239026d1b5487f9b07f63646ca4a2e3a79.tar.zst
yuzu-297823239026d1b5487f9b07f63646ca4a2e3a79.zip
Diffstat (limited to 'src/input_common/motion_from_button.cpp')
-rw-r--r--src/input_common/motion_from_button.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/input_common/motion_from_button.cpp b/src/input_common/motion_from_button.cpp
new file mode 100644
index 000000000..9d459f963
--- /dev/null
+++ b/src/input_common/motion_from_button.cpp
@@ -0,0 +1,34 @@
+// Copyright 2020 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#include "input_common/motion_from_button.h"
+#include "input_common/motion_input.h"
+
+namespace InputCommon {
+
+class MotionKey final : public Input::MotionDevice {
+public:
+ using Button = std::unique_ptr<Input::ButtonDevice>;
+
+ MotionKey(Button key_) : key(std::move(key_)) {}
+
+ Input::MotionStatus GetStatus() const override {
+
+ if (key->GetStatus()) {
+ return motion.GetRandomMotion(2, 6);
+ }
+ return motion.GetRandomMotion(0, 0);
+ }
+
+private:
+ Button key;
+ InputCommon::MotionInput motion{0.0f, 0.0f, 0.0f};
+};
+
+std::unique_ptr<Input::MotionDevice> MotionFromButton::Create(const Common::ParamPackage& params) {
+ auto key = Input::CreateDevice<Input::ButtonDevice>(params.Serialize());
+ return std::make_unique<MotionKey>(std::move(key));
+}
+
+} // namespace InputCommon