diff options
author | James Rowe <jroweboy@gmail.com> | 2017-08-19 23:43:01 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-19 23:43:01 -0600 |
commit | bbfa9d0635ce4b9226bed02ea1b6e8ddbb7e8a56 (patch) | |
tree | 5bfecf66096077d72346da902a9646314cb60631 /src/input_common/motion_emu.h | |
parent | 8afa81ac1bbb0ffb67faf87e9ee696145a40bb99 (diff) | |
parent | 54c0c8adee90d374e954e742d6d03279ef2e7ed7 (diff) |
Merge pull request #2861 from wwylele/motion-refactor
Refactor MotionEmu into a InputDevice
Diffstat (limited to 'src/input_common/motion_emu.h')
-rw-r--r-- | src/input_common/motion_emu.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/input_common/motion_emu.h b/src/input_common/motion_emu.h new file mode 100644 index 000000000..7a7e22467 --- /dev/null +++ b/src/input_common/motion_emu.h @@ -0,0 +1,46 @@ +// Copyright 2017 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include "core/frontend/input.h" + +namespace InputCommon { + +class MotionEmuDevice; + +class MotionEmu : public Input::Factory<Input::MotionDevice> { +public: + /** + * 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. + * @param x the x-coordinate of the cursor + * @param y the y-coordinate of the cursor + */ + void BeginTilt(int x, int y); + + /** + * Signals that a motion sensor tilt is occurring. + * @param x the x-coordinate of the cursor + * @param y the y-coordinate of the cursor + */ + void Tilt(int x, int y); + + /** + * Signals that a motion sensor tilt has ended. + */ + void EndTilt(); + +private: + std::weak_ptr<MotionEmuDevice> current_device; +}; + +} // namespace InputCommon |