Fix interger overflow from setting haptics/feedback prescale above 1x

This commit is contained in:
YoshiRulz 2024-10-09 14:13:21 +10:00
parent ab081f7363
commit c36b654eb9
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 4 additions and 1 deletions

View File

@ -3,6 +3,7 @@ using System.Linq;
using BizHawk.Common;
using BizHawk.Common.CollectionExtensions;
using BizHawk.Common.NumberExtensions;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.Common
@ -115,7 +116,9 @@ namespace BizHawk.Client.Common
{
foreach (var hostChannel in v.Channels!.Split('+'))
{
finalHostController.SetHapticChannelStrength(v.GamepadPrefix + hostChannel, (int) ((double) strength * v.Prescale));
finalHostController.SetHapticChannelStrength(
v.GamepadPrefix + hostChannel,
(v.Prescale * strength).Clamp(min: 0.0f, max: 1.0f).RoundToInt());
}
}
}