diff options
Diffstat (limited to '')
| -rw-r--r-- | src/common/input.h | 7 | ||||
| -rw-r--r-- | src/input_common/drivers/mouse.cpp | 33 | ||||
| -rw-r--r-- | src/input_common/drivers/mouse.h | 2 | ||||
| -rw-r--r-- | src/input_common/input_mapping.cpp | 13 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.cpp | 10 |
5 files changed, 64 insertions, 1 deletions
diff --git a/src/common/input.h b/src/common/input.h index f775a4c01..f4f9eb30a 100644 --- a/src/common/input.h +++ b/src/common/input.h | |||
| @@ -209,6 +209,13 @@ enum class ButtonNames { | |||
| 209 | Triangle, | 209 | Triangle, |
| 210 | Share, | 210 | Share, |
| 211 | Options, | 211 | Options, |
| 212 | |||
| 213 | // Mouse buttons | ||
| 214 | ButtonMouseWheel, | ||
| 215 | ButtonBackward, | ||
| 216 | ButtonForward, | ||
| 217 | ButtonTask, | ||
| 218 | ButtonExtra, | ||
| 212 | }; | 219 | }; |
| 213 | 220 | ||
| 214 | // Callback data consisting of an input type and the equivalent data status | 221 | // Callback data consisting of an input type and the equivalent data status |
diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp index aa69216c8..261206438 100644 --- a/src/input_common/drivers/mouse.cpp +++ b/src/input_common/drivers/mouse.cpp | |||
| @@ -16,6 +16,7 @@ constexpr int mouse_axis_x = 0; | |||
| 16 | constexpr int mouse_axis_y = 1; | 16 | constexpr int mouse_axis_y = 1; |
| 17 | constexpr int wheel_axis_x = 2; | 17 | constexpr int wheel_axis_x = 2; |
| 18 | constexpr int wheel_axis_y = 3; | 18 | constexpr int wheel_axis_y = 3; |
| 19 | constexpr int motion_wheel_y = 4; | ||
| 19 | constexpr int touch_axis_x = 10; | 20 | constexpr int touch_axis_x = 10; |
| 20 | constexpr int touch_axis_y = 11; | 21 | constexpr int touch_axis_y = 11; |
| 21 | constexpr PadIdentifier identifier = { | 22 | constexpr PadIdentifier identifier = { |
| @@ -30,6 +31,7 @@ Mouse::Mouse(std::string input_engine_) : InputEngine(std::move(input_engine_)) | |||
| 30 | PreSetAxis(identifier, mouse_axis_y); | 31 | PreSetAxis(identifier, mouse_axis_y); |
| 31 | PreSetAxis(identifier, wheel_axis_x); | 32 | PreSetAxis(identifier, wheel_axis_x); |
| 32 | PreSetAxis(identifier, wheel_axis_y); | 33 | PreSetAxis(identifier, wheel_axis_y); |
| 34 | PreSetAxis(identifier, motion_wheel_y); | ||
| 33 | PreSetAxis(identifier, touch_axis_x); | 35 | PreSetAxis(identifier, touch_axis_x); |
| 34 | PreSetAxis(identifier, touch_axis_x); | 36 | PreSetAxis(identifier, touch_axis_x); |
| 35 | update_thread = std::jthread([this](std::stop_token stop_token) { UpdateThread(stop_token); }); | 37 | update_thread = std::jthread([this](std::stop_token stop_token) { UpdateThread(stop_token); }); |
| @@ -48,6 +50,8 @@ void Mouse::UpdateThread(std::stop_token stop_token) { | |||
| 48 | SetAxis(identifier, mouse_axis_y, -last_mouse_change.y * sensitivity); | 50 | SetAxis(identifier, mouse_axis_y, -last_mouse_change.y * sensitivity); |
| 49 | } | 51 | } |
| 50 | 52 | ||
| 53 | SetAxis(identifier, motion_wheel_y, 0.0f); | ||
| 54 | |||
| 51 | if (mouse_panning_timout++ > 20) { | 55 | if (mouse_panning_timout++ > 20) { |
| 52 | StopPanning(); | 56 | StopPanning(); |
| 53 | } | 57 | } |
| @@ -136,6 +140,7 @@ void Mouse::MouseWheelChange(int x, int y) { | |||
| 136 | wheel_position.y += y; | 140 | wheel_position.y += y; |
| 137 | SetAxis(identifier, wheel_axis_x, static_cast<f32>(wheel_position.x)); | 141 | SetAxis(identifier, wheel_axis_x, static_cast<f32>(wheel_position.x)); |
| 138 | SetAxis(identifier, wheel_axis_y, static_cast<f32>(wheel_position.y)); | 142 | SetAxis(identifier, wheel_axis_y, static_cast<f32>(wheel_position.y)); |
| 143 | SetAxis(identifier, motion_wheel_y, static_cast<f32>(y) / 100.0f); | ||
| 139 | } | 144 | } |
| 140 | 145 | ||
| 141 | void Mouse::ReleaseAllButtons() { | 146 | void Mouse::ReleaseAllButtons() { |
| @@ -171,13 +176,39 @@ AnalogMapping Mouse::GetAnalogMappingForDevice( | |||
| 171 | return mapping; | 176 | return mapping; |
| 172 | } | 177 | } |
| 173 | 178 | ||
| 179 | Common::Input::ButtonNames Mouse::GetUIButtonName(const Common::ParamPackage& params) const { | ||
| 180 | const auto button = static_cast<MouseButton>(params.Get("button", 0)); | ||
| 181 | switch (button) { | ||
| 182 | case MouseButton::Left: | ||
| 183 | return Common::Input::ButtonNames::ButtonLeft; | ||
| 184 | case MouseButton::Right: | ||
| 185 | return Common::Input::ButtonNames::ButtonRight; | ||
| 186 | case MouseButton::Wheel: | ||
| 187 | return Common::Input::ButtonNames::ButtonMouseWheel; | ||
| 188 | case MouseButton::Backward: | ||
| 189 | return Common::Input::ButtonNames::ButtonBackward; | ||
| 190 | case MouseButton::Forward: | ||
| 191 | return Common::Input::ButtonNames::ButtonForward; | ||
| 192 | case MouseButton::Task: | ||
| 193 | return Common::Input::ButtonNames::ButtonTask; | ||
| 194 | case MouseButton::Extra: | ||
| 195 | return Common::Input::ButtonNames::ButtonExtra; | ||
| 196 | case MouseButton::Undefined: | ||
| 197 | default: | ||
| 198 | return Common::Input::ButtonNames::Undefined; | ||
| 199 | } | ||
| 200 | } | ||
| 201 | |||
| 174 | Common::Input::ButtonNames Mouse::GetUIName(const Common::ParamPackage& params) const { | 202 | Common::Input::ButtonNames Mouse::GetUIName(const Common::ParamPackage& params) const { |
| 175 | if (params.Has("button")) { | 203 | if (params.Has("button")) { |
| 176 | return Common::Input::ButtonNames::Value; | 204 | return GetUIButtonName(params); |
| 177 | } | 205 | } |
| 178 | if (params.Has("axis")) { | 206 | if (params.Has("axis")) { |
| 179 | return Common::Input::ButtonNames::Value; | 207 | return Common::Input::ButtonNames::Value; |
| 180 | } | 208 | } |
| 209 | if (params.Has("axis_x") && params.Has("axis_y") && params.Has("axis_z")) { | ||
| 210 | return Common::Input::ButtonNames::Engine; | ||
| 211 | } | ||
| 181 | 212 | ||
| 182 | return Common::Input::ButtonNames::Invalid; | 213 | return Common::Input::ButtonNames::Invalid; |
| 183 | } | 214 | } |
diff --git a/src/input_common/drivers/mouse.h b/src/input_common/drivers/mouse.h index 040446178..c5833b8ed 100644 --- a/src/input_common/drivers/mouse.h +++ b/src/input_common/drivers/mouse.h | |||
| @@ -69,6 +69,8 @@ private: | |||
| 69 | void UpdateThread(std::stop_token stop_token); | 69 | void UpdateThread(std::stop_token stop_token); |
| 70 | void StopPanning(); | 70 | void StopPanning(); |
| 71 | 71 | ||
| 72 | Common::Input::ButtonNames GetUIButtonName(const Common::ParamPackage& params) const; | ||
| 73 | |||
| 72 | Common::Vec2<int> mouse_origin; | 74 | Common::Vec2<int> mouse_origin; |
| 73 | Common::Vec2<int> last_mouse_position; | 75 | Common::Vec2<int> last_mouse_position; |
| 74 | Common::Vec2<float> last_mouse_change; | 76 | Common::Vec2<float> last_mouse_change; |
diff --git a/src/input_common/input_mapping.cpp b/src/input_common/input_mapping.cpp index 6e0024b2d..475257f42 100644 --- a/src/input_common/input_mapping.cpp +++ b/src/input_common/input_mapping.cpp | |||
| @@ -143,6 +143,19 @@ void MappingFactory::RegisterMotion(const MappingData& data) { | |||
| 143 | } | 143 | } |
| 144 | new_input.Set("port", static_cast<int>(data.pad.port)); | 144 | new_input.Set("port", static_cast<int>(data.pad.port)); |
| 145 | new_input.Set("pad", static_cast<int>(data.pad.pad)); | 145 | new_input.Set("pad", static_cast<int>(data.pad.pad)); |
| 146 | |||
| 147 | // If engine is mouse map the mouse position as 3 axis motion | ||
| 148 | if (data.engine == "mouse") { | ||
| 149 | new_input.Set("axis_x", 1); | ||
| 150 | new_input.Set("invert_x", "-"); | ||
| 151 | new_input.Set("axis_y", 0); | ||
| 152 | new_input.Set("axis_z", 4); | ||
| 153 | new_input.Set("range", 1.0f); | ||
| 154 | new_input.Set("deadzone", 0.0f); | ||
| 155 | input_queue.Push(new_input); | ||
| 156 | return; | ||
| 157 | } | ||
| 158 | |||
| 146 | switch (data.type) { | 159 | switch (data.type) { |
| 147 | case EngineInputType::Button: | 160 | case EngineInputType::Button: |
| 148 | case EngineInputType::HatButton: | 161 | case EngineInputType::HatButton: |
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index b9342466e..d2132b408 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp | |||
| @@ -102,6 +102,16 @@ QString GetButtonName(Common::Input::ButtonNames button_name) { | |||
| 102 | return QObject::tr("Share"); | 102 | return QObject::tr("Share"); |
| 103 | case Common::Input::ButtonNames::Options: | 103 | case Common::Input::ButtonNames::Options: |
| 104 | return QObject::tr("Options"); | 104 | return QObject::tr("Options"); |
| 105 | case Common::Input::ButtonNames::ButtonMouseWheel: | ||
| 106 | return QObject::tr("Wheel", "Indicates the mouse wheel"); | ||
| 107 | case Common::Input::ButtonNames::ButtonBackward: | ||
| 108 | return QObject::tr("Backward"); | ||
| 109 | case Common::Input::ButtonNames::ButtonForward: | ||
| 110 | return QObject::tr("Forward"); | ||
| 111 | case Common::Input::ButtonNames::ButtonTask: | ||
| 112 | return QObject::tr("Task"); | ||
| 113 | case Common::Input::ButtonNames::ButtonExtra: | ||
| 114 | return QObject::tr("Extra"); | ||
| 105 | default: | 115 | default: |
| 106 | return QObject::tr("[undefined]"); | 116 | return QObject::tr("[undefined]"); |
| 107 | } | 117 | } |