summaryrefslogtreecommitdiffstats
path: root/src/input_common/motion_emu.h
diff options
context:
space:
mode:
authorwwylele <wwylele@gmail.com>2017-08-06 23:04:06 +0200
committerwwylele <wwylele@gmail.com>2017-08-11 10:05:08 +0200
commit188194908c2785bd1e03485941b9148777cdddd7 (patch)
treeab6cd04195f5e18bd1e7dd21a7c2896066827a6f /src/input_common/motion_emu.h
parentHID: use MotionDevice for Accelerometer and Gyroscope (diff)
downloadyuzu-188194908c2785bd1e03485941b9148777cdddd7.tar
yuzu-188194908c2785bd1e03485941b9148777cdddd7.tar.gz
yuzu-188194908c2785bd1e03485941b9148777cdddd7.tar.bz2
yuzu-188194908c2785bd1e03485941b9148777cdddd7.tar.lz
yuzu-188194908c2785bd1e03485941b9148777cdddd7.tar.xz
yuzu-188194908c2785bd1e03485941b9148777cdddd7.tar.zst
yuzu-188194908c2785bd1e03485941b9148777cdddd7.zip
Diffstat (limited to '')
-rw-r--r--src/input_common/motion_emu.h (renamed from src/core/frontend/motion_emu.h)33
1 files changed, 14 insertions, 19 deletions
diff --git a/src/core/frontend/motion_emu.h b/src/input_common/motion_emu.h
index 99d41a726..195fb69d2 100644
--- a/src/core/frontend/motion_emu.h
+++ b/src/input_common/motion_emu.h
@@ -1,19 +1,25 @@
-// Copyright 2016 Citra Emulator Project
+// Copyright 2017 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include "common/thread.h"
#include "common/vector_math.h"
+#include "core/frontend/input.h"
-class EmuWindow;
+namespace InputCommon {
-namespace Motion {
+class MotionEmuDevice;
-class MotionEmu final {
+class MotionEmu : public Input::Factory<Input::MotionDevice> {
public:
- MotionEmu(EmuWindow& emu_window);
- ~MotionEmu();
+ /**
+ * Creates a motion device emulated from mouse input
+ * @param params contains parameters for creating the device:
+ * - "update_period": update period in milliseconds
+ * - "sensitivity": the coefficient converting mouse movement to tilting angle
+ */
+ std::unique_ptr<Input::MotionDevice> Create(const Common::ParamPackage& params) override;
/**
* Signals that a motion sensor tilt has begun.
@@ -35,18 +41,7 @@ public:
void EndTilt();
private:
- Math::Vec2<int> mouse_origin;
-
- std::mutex tilt_mutex;
- Math::Vec2<float> tilt_direction;
- float tilt_angle = 0;
-
- bool is_tilting = false;
-
- Common::Event shutdown_event;
- std::thread motion_emu_thread;
-
- void MotionEmuThread(EmuWindow& emu_window);
+ std::weak_ptr<MotionEmuDevice> current_device;
};
-} // namespace Motion
+} // namespace InputCommon