summaryrefslogtreecommitdiffstats
path: root/src/input_common/drivers
diff options
context:
space:
mode:
authorgerman77 <juangerman-13@hotmail.com>2022-01-17 01:03:11 +0100
committergerman77 <juangerman-13@hotmail.com>2022-01-17 03:37:34 +0100
commit9eab07f86370eb97eb6e87624163ae07fb055ac9 (patch)
tree1a6a123331324404cd64dd6622ac191a76e6bd4e /src/input_common/drivers
parentMerge pull request #7713 from gidoly/patch-3 (diff)
downloadyuzu-9eab07f86370eb97eb6e87624163ae07fb055ac9.tar
yuzu-9eab07f86370eb97eb6e87624163ae07fb055ac9.tar.gz
yuzu-9eab07f86370eb97eb6e87624163ae07fb055ac9.tar.bz2
yuzu-9eab07f86370eb97eb6e87624163ae07fb055ac9.tar.lz
yuzu-9eab07f86370eb97eb6e87624163ae07fb055ac9.tar.xz
yuzu-9eab07f86370eb97eb6e87624163ae07fb055ac9.tar.zst
yuzu-9eab07f86370eb97eb6e87624163ae07fb055ac9.zip
Diffstat (limited to 'src/input_common/drivers')
-rw-r--r--src/input_common/drivers/mouse.cpp33
-rw-r--r--src/input_common/drivers/mouse.h2
2 files changed, 34 insertions, 1 deletions
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;
constexpr int mouse_axis_y = 1;
constexpr int wheel_axis_x = 2;
constexpr int wheel_axis_y = 3;
+constexpr int motion_wheel_y = 4;
constexpr int touch_axis_x = 10;
constexpr int touch_axis_y = 11;
constexpr PadIdentifier identifier = {
@@ -30,6 +31,7 @@ Mouse::Mouse(std::string input_engine_) : InputEngine(std::move(input_engine_))
PreSetAxis(identifier, mouse_axis_y);
PreSetAxis(identifier, wheel_axis_x);
PreSetAxis(identifier, wheel_axis_y);
+ PreSetAxis(identifier, motion_wheel_y);
PreSetAxis(identifier, touch_axis_x);
PreSetAxis(identifier, touch_axis_x);
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) {
SetAxis(identifier, mouse_axis_y, -last_mouse_change.y * sensitivity);
}
+ SetAxis(identifier, motion_wheel_y, 0.0f);
+
if (mouse_panning_timout++ > 20) {
StopPanning();
}
@@ -136,6 +140,7 @@ void Mouse::MouseWheelChange(int x, int y) {
wheel_position.y += y;
SetAxis(identifier, wheel_axis_x, static_cast<f32>(wheel_position.x));
SetAxis(identifier, wheel_axis_y, static_cast<f32>(wheel_position.y));
+ SetAxis(identifier, motion_wheel_y, static_cast<f32>(y) / 100.0f);
}
void Mouse::ReleaseAllButtons() {
@@ -171,13 +176,39 @@ AnalogMapping Mouse::GetAnalogMappingForDevice(
return mapping;
}
+Common::Input::ButtonNames Mouse::GetUIButtonName(const Common::ParamPackage& params) const {
+ const auto button = static_cast<MouseButton>(params.Get("button", 0));
+ switch (button) {
+ case MouseButton::Left:
+ return Common::Input::ButtonNames::ButtonLeft;
+ case MouseButton::Right:
+ return Common::Input::ButtonNames::ButtonRight;
+ case MouseButton::Wheel:
+ return Common::Input::ButtonNames::ButtonMouseWheel;
+ case MouseButton::Backward:
+ return Common::Input::ButtonNames::ButtonBackward;
+ case MouseButton::Forward:
+ return Common::Input::ButtonNames::ButtonForward;
+ case MouseButton::Task:
+ return Common::Input::ButtonNames::ButtonTask;
+ case MouseButton::Extra:
+ return Common::Input::ButtonNames::ButtonExtra;
+ case MouseButton::Undefined:
+ default:
+ return Common::Input::ButtonNames::Undefined;
+ }
+}
+
Common::Input::ButtonNames Mouse::GetUIName(const Common::ParamPackage& params) const {
if (params.Has("button")) {
- return Common::Input::ButtonNames::Value;
+ return GetUIButtonName(params);
}
if (params.Has("axis")) {
return Common::Input::ButtonNames::Value;
}
+ if (params.Has("axis_x") && params.Has("axis_y") && params.Has("axis_z")) {
+ return Common::Input::ButtonNames::Engine;
+ }
return Common::Input::ButtonNames::Invalid;
}
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:
void UpdateThread(std::stop_token stop_token);
void StopPanning();
+ Common::Input::ButtonNames GetUIButtonName(const Common::ParamPackage& params) const;
+
Common::Vec2<int> mouse_origin;
Common::Vec2<int> last_mouse_position;
Common::Vec2<float> last_mouse_change;