Pass Left+Right feedback bind through until PrepareHapticsForHost

This commit is contained in:
YoshiRulz 2021-07-21 11:01:51 +10:00
parent d254c8121d
commit d3733c1fda
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
4 changed files with 10 additions and 9 deletions

View File

@ -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));
}
}
}
}

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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);
}
}
}