diff options
Diffstat (limited to 'src/input_common/mouse/mouse_input.h')
| -rw-r--r-- | src/input_common/mouse/mouse_input.h | 116 |
1 files changed, 0 insertions, 116 deletions
diff --git a/src/input_common/mouse/mouse_input.h b/src/input_common/mouse/mouse_input.h deleted file mode 100644 index c8bae99c1..000000000 --- a/src/input_common/mouse/mouse_input.h +++ /dev/null | |||
| @@ -1,116 +0,0 @@ | |||
| 1 | // Copyright 2020 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <array> | ||
| 8 | #include <mutex> | ||
| 9 | #include <stop_token> | ||
| 10 | #include <thread> | ||
| 11 | |||
| 12 | #include "common/common_types.h" | ||
| 13 | #include "common/threadsafe_queue.h" | ||
| 14 | #include "common/vector_math.h" | ||
| 15 | #include "core/frontend/input.h" | ||
| 16 | #include "input_common/motion_input.h" | ||
| 17 | |||
| 18 | namespace MouseInput { | ||
| 19 | |||
| 20 | enum class MouseButton { | ||
| 21 | Left, | ||
| 22 | Right, | ||
| 23 | Wheel, | ||
| 24 | Backward, | ||
| 25 | Forward, | ||
| 26 | Task, | ||
| 27 | Extra, | ||
| 28 | Undefined, | ||
| 29 | }; | ||
| 30 | |||
| 31 | struct MouseStatus { | ||
| 32 | MouseButton button{MouseButton::Undefined}; | ||
| 33 | }; | ||
| 34 | |||
| 35 | struct MouseData { | ||
| 36 | bool pressed{}; | ||
| 37 | std::array<int, 2> axis{}; | ||
| 38 | Input::MotionStatus motion{}; | ||
| 39 | Input::TouchStatus touch{}; | ||
| 40 | }; | ||
| 41 | |||
| 42 | class Mouse { | ||
| 43 | public: | ||
| 44 | Mouse(); | ||
| 45 | ~Mouse(); | ||
| 46 | |||
| 47 | /// Used for polling | ||
| 48 | void BeginConfiguration(); | ||
| 49 | void EndConfiguration(); | ||
| 50 | |||
| 51 | /** | ||
| 52 | * Signals that a button is pressed. | ||
| 53 | * @param x the x-coordinate of the cursor | ||
| 54 | * @param y the y-coordinate of the cursor | ||
| 55 | * @param button_ the button pressed | ||
| 56 | */ | ||
| 57 | void PressButton(int x, int y, MouseButton button_); | ||
| 58 | |||
| 59 | /** | ||
| 60 | * Signals that mouse has moved. | ||
| 61 | * @param x the x-coordinate of the cursor | ||
| 62 | * @param y the y-coordinate of the cursor | ||
| 63 | * @param center_x the x-coordinate of the middle of the screen | ||
| 64 | * @param center_y the y-coordinate of the middle of the screen | ||
| 65 | */ | ||
| 66 | void MouseMove(int x, int y, int center_x, int center_y); | ||
| 67 | |||
| 68 | /** | ||
| 69 | * Signals that a button is released. | ||
| 70 | * @param button_ the button pressed | ||
| 71 | */ | ||
| 72 | void ReleaseButton(MouseButton button_); | ||
| 73 | |||
| 74 | /** | ||
| 75 | * Signals that all buttons are released | ||
| 76 | */ | ||
| 77 | void ReleaseAllButtons(); | ||
| 78 | |||
| 79 | [[nodiscard]] bool ToggleButton(std::size_t button_); | ||
| 80 | [[nodiscard]] bool UnlockButton(std::size_t button_); | ||
| 81 | |||
| 82 | [[nodiscard]] Common::SPSCQueue<MouseStatus>& GetMouseQueue(); | ||
| 83 | [[nodiscard]] const Common::SPSCQueue<MouseStatus>& GetMouseQueue() const; | ||
| 84 | |||
| 85 | [[nodiscard]] MouseData& GetMouseState(std::size_t button); | ||
| 86 | [[nodiscard]] const MouseData& GetMouseState(std::size_t button) const; | ||
| 87 | |||
| 88 | private: | ||
| 89 | void UpdateThread(std::stop_token stop_token); | ||
| 90 | void UpdateYuzuSettings(); | ||
| 91 | void StopPanning(); | ||
| 92 | |||
| 93 | struct MouseInfo { | ||
| 94 | InputCommon::MotionInput motion{0.0f, 0.0f, 0.0f}; | ||
| 95 | Common::Vec2<int> mouse_origin; | ||
| 96 | Common::Vec2<int> last_mouse_position; | ||
| 97 | Common::Vec2<float> last_mouse_change; | ||
| 98 | bool is_tilting = false; | ||
| 99 | float sensitivity{0.120f}; | ||
| 100 | |||
| 101 | float tilt_speed = 0; | ||
| 102 | Common::Vec2<float> tilt_direction; | ||
| 103 | MouseData data; | ||
| 104 | }; | ||
| 105 | |||
| 106 | u16 buttons{}; | ||
| 107 | u16 toggle_buttons{}; | ||
| 108 | u16 lock_buttons{}; | ||
| 109 | std::jthread update_thread; | ||
| 110 | MouseButton last_button{MouseButton::Undefined}; | ||
| 111 | std::array<MouseInfo, 7> mouse_info; | ||
| 112 | Common::SPSCQueue<MouseStatus> mouse_queue; | ||
| 113 | bool configuring{false}; | ||
| 114 | int mouse_panning_timout{}; | ||
| 115 | }; | ||
| 116 | } // namespace MouseInput | ||