From d3733c1fda6fa0f0846842b6a3ce1ba8b0a409ce Mon Sep 17 00:00:00 2001 From: YoshiRulz <OSSYoshiRulz@gmail.com> Date: Wed, 21 Jul 2021 11:01:51 +1000 Subject: [PATCH] Pass Left+Right feedback bind through until PrepareHapticsForHost --- src/BizHawk.Client.Common/Controller.cs | 5 ++++- src/BizHawk.Client.Common/config/FeedbackBind.cs | 7 ++++--- .../config/ControllerConfig/FeedbackBindControl.cs | 2 +- .../config/ControllerConfig/FeedbacksBindPanel.cs | 5 +---- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/BizHawk.Client.Common/Controller.cs b/src/BizHawk.Client.Common/Controller.cs index 071fd13dac..1b09dc3b0f 100644 --- a/src/BizHawk.Client.Common/Controller.cs +++ b/src/BizHawk.Client.Common/Controller.cs @@ -110,7 +110,10 @@ namespace BizHawk.Client.Common { if (_haptics.TryGetValue(kvp.Key, out var strength)) { - finalHostController.SetHapticChannelStrength(kvp.Value.GamepadPrefix + kvp.Value.Channel, (int) ((double) strength * kvp.Value.Prescale)); + foreach (var hostChannel in kvp.Value.Channels!.Split('+')) + { + finalHostController.SetHapticChannelStrength(kvp.Value.GamepadPrefix + hostChannel, (int) ((double) strength * kvp.Value.Prescale)); + } } } } diff --git a/src/BizHawk.Client.Common/config/FeedbackBind.cs b/src/BizHawk.Client.Common/config/FeedbackBind.cs index 49ba11c031..207e94d763 100644 --- a/src/BizHawk.Client.Common/config/FeedbackBind.cs +++ b/src/BizHawk.Client.Common/config/FeedbackBind.cs @@ -6,7 +6,8 @@ namespace BizHawk.Client.Common { public struct FeedbackBind { - public string? Channel; + /// <remarks>may be a '+'-delimited list (e.g. <c>"Left+Right"</c>), which will be passed through the input pipeline to <see cref="Controller.PrepareHapticsForHost"/></remarks> + public string? Channels; /// <remarks>"X# "/"J# " (with the trailing space)</remarks> public string? GamepadPrefix; @@ -16,10 +17,10 @@ namespace BizHawk.Client.Common public float Prescale; - public FeedbackBind(string prefix, string channel, float prescale) + public FeedbackBind(string prefix, string channels, float prescale) { GamepadPrefix = prefix; - Channel = channel; + Channels = channels; Prescale = prescale; } } diff --git a/src/BizHawk.Client.EmuHawk/config/ControllerConfig/FeedbackBindControl.cs b/src/BizHawk.Client.EmuHawk/config/ControllerConfig/FeedbackBindControl.cs index c7ac6023b8..7d896bff98 100644 --- a/src/BizHawk.Client.EmuHawk/config/ControllerConfig/FeedbackBindControl.cs +++ b/src/BizHawk.Client.EmuHawk/config/ControllerConfig/FeedbackBindControl.cs @@ -24,7 +24,7 @@ namespace BizHawk.Client.EmuHawk public FeedbackBindControl(string vChannel, FeedbackBind existingBind, IHostInputAdapter hostInputAdapter) { - BoundChannels = existingBind.Channel ?? string.Empty; + BoundChannels = existingBind.Channels ?? string.Empty; BoundGamepadPrefix = existingBind.GamepadPrefix ?? string.Empty; Prescale = existingBind.IsZeroed ? 1.0f : existingBind.Prescale; VChannelName = vChannel; diff --git a/src/BizHawk.Client.EmuHawk/config/ControllerConfig/FeedbacksBindPanel.cs b/src/BizHawk.Client.EmuHawk/config/ControllerConfig/FeedbacksBindPanel.cs index 1b83c5b19c..ed7c52f44e 100644 --- a/src/BizHawk.Client.EmuHawk/config/ControllerConfig/FeedbacksBindPanel.cs +++ b/src/BizHawk.Client.EmuHawk/config/ControllerConfig/FeedbacksBindPanel.cs @@ -36,10 +36,7 @@ namespace BizHawk.Client.EmuHawk foreach (var c in _flpMain.Controls.OfType<FeedbackBindControl>()) { if (string.IsNullOrEmpty(c.BoundGamepadPrefix)) continue; - foreach (var channel in c.BoundChannels.Split('+')) - { - saveTo[c.VChannelName] = new(c.BoundGamepadPrefix, channel, c.Prescale); - } + saveTo[c.VChannelName] = new(c.BoundGamepadPrefix, c.BoundChannels, c.Prescale); } } }