From 297823239026d1b5487f9b07f63646ca4a2e3a79 Mon Sep 17 00:00:00 2001 From: german Date: Fri, 25 Sep 2020 17:58:27 -0500 Subject: Add random motion input to keyboard --- src/input_common/motion_from_button.cpp | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/input_common/motion_from_button.cpp (limited to 'src/input_common/motion_from_button.cpp') 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; + + 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 MotionFromButton::Create(const Common::ParamPackage& params) { + auto key = Input::CreateDevice(params.Serialize()); + return std::make_unique(std::move(key)); +} + +} // namespace InputCommon -- cgit v1.2.3 From 046c0c91a3ed665531f20955e7cfb86fe5b73213 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 14 Oct 2020 02:51:14 -0400 Subject: input_common/CMakeLists: Make some warnings errors Makes the input_common code warnings consistent with the rest of the codebase. --- src/input_common/motion_from_button.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/input_common/motion_from_button.cpp') diff --git a/src/input_common/motion_from_button.cpp b/src/input_common/motion_from_button.cpp index 9d459f963..29045a673 100644 --- a/src/input_common/motion_from_button.cpp +++ b/src/input_common/motion_from_button.cpp @@ -11,7 +11,7 @@ class MotionKey final : public Input::MotionDevice { public: using Button = std::unique_ptr; - MotionKey(Button key_) : key(std::move(key_)) {} + explicit MotionKey(Button key_) : key(std::move(key_)) {} Input::MotionStatus GetStatus() const override { -- cgit v1.2.3