diff options
author | german77 <juangerman-13@hotmail.com> | 2021-10-24 18:22:20 +0200 |
---|---|---|
committer | Narr the Reg <juangerman-13@hotmail.com> | 2021-11-25 03:30:25 +0100 |
commit | 464c4d26ac8e7af6302390684445b357e5cda4e4 (patch) | |
tree | 160f98a8bce324756f46b7b5aee889bb5b53f8af /src/input_common | |
parent | web_applet: Replace HIDButton with NpadButton (diff) | |
download | yuzu-464c4d26ac8e7af6302390684445b357e5cda4e4.tar yuzu-464c4d26ac8e7af6302390684445b357e5cda4e4.tar.gz yuzu-464c4d26ac8e7af6302390684445b357e5cda4e4.tar.bz2 yuzu-464c4d26ac8e7af6302390684445b357e5cda4e4.tar.lz yuzu-464c4d26ac8e7af6302390684445b357e5cda4e4.tar.xz yuzu-464c4d26ac8e7af6302390684445b357e5cda4e4.tar.zst yuzu-464c4d26ac8e7af6302390684445b357e5cda4e4.zip |
Diffstat (limited to '')
-rw-r--r-- | src/input_common/drivers/mouse.cpp | 17 | ||||
-rw-r--r-- | src/input_common/drivers/mouse.h | 1 | ||||
-rw-r--r-- | src/input_common/input_engine.cpp | 2 | ||||
-rw-r--r-- | src/input_common/main.cpp | 3 |
4 files changed, 22 insertions, 1 deletions
diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp index 2c2432fb7..1c32b54be 100644 --- a/src/input_common/drivers/mouse.cpp +++ b/src/input_common/drivers/mouse.cpp @@ -121,12 +121,27 @@ void Mouse::StopPanning() { std::vector<Common::ParamPackage> Mouse::GetInputDevices() const { std::vector<Common::ParamPackage> devices; devices.emplace_back(Common::ParamPackage{ - {"engine", "keyboard"}, + {"engine", GetEngineName()}, {"display", "Keyboard/Mouse"}, }); return devices; } +AnalogMapping Mouse::GetAnalogMappingForDevice( + [[maybe_unused]] const Common::ParamPackage& params) { + // Only overwrite different buttons from default + AnalogMapping mapping = {}; + Common::ParamPackage right_analog_params; + right_analog_params.Set("engine", GetEngineName()); + right_analog_params.Set("axis_x", 0); + right_analog_params.Set("axis_y", 1); + right_analog_params.Set("threshold", 0.5f); + right_analog_params.Set("range", 1.0f); + right_analog_params.Set("deadzone", 0.0f); + mapping.insert_or_assign(Settings::NativeAnalog::RStick, std::move(right_analog_params)); + return mapping; +} + std::string Mouse::GetUIName(const Common::ParamPackage& params) const { if (params.Has("button")) { return fmt::format("Mouse {}", params.Get("button", 0)); diff --git a/src/input_common/drivers/mouse.h b/src/input_common/drivers/mouse.h index e8355751a..d3178b1a9 100644 --- a/src/input_common/drivers/mouse.h +++ b/src/input_common/drivers/mouse.h @@ -55,6 +55,7 @@ public: void ReleaseAllButtons(); std::vector<Common::ParamPackage> GetInputDevices() const override; + AnalogMapping GetAnalogMappingForDevice(const Common::ParamPackage& params) override; std::string GetUIName(const Common::ParamPackage& params) const override; private: diff --git a/src/input_common/input_engine.cpp b/src/input_common/input_engine.cpp index 1534f24b0..9cfe0f232 100644 --- a/src/input_common/input_engine.cpp +++ b/src/input_common/input_engine.cpp @@ -202,6 +202,8 @@ void InputEngine::TriggerOnButtonChange(const PadIdentifier& identifier, int but if (!configuring || !mapping_callback.on_data) { return; } + + PreSetButton(identifier, button); if (value == GetButton(identifier, button)) { return; } diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index 8f7ce59b7..07d514ad7 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp @@ -143,6 +143,9 @@ struct InputSubsystem::Impl { return {}; } const std::string engine = params.Get("engine", ""); + if (engine == mouse->GetEngineName()) { + return mouse->GetAnalogMappingForDevice(params); + } if (engine == gcadapter->GetEngineName()) { return gcadapter->GetAnalogMappingForDevice(params); } |