Split PSX (Nymashock) rumble channel into left and right

This commit is contained in:
YoshiRulz 2024-10-09 14:26:01 +10:00
parent eb3ab3f05a
commit d8778aa232
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 12 additions and 4 deletions

View File

@ -3,6 +3,7 @@ using System.IO;
using System.Linq; using System.Linq;
using BizHawk.Common; using BizHawk.Common;
using BizHawk.Common.NumberExtensions;
using BizHawk.Common.StringExtensions; using BizHawk.Common.StringExtensions;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using NymaTypes; using NymaTypes;
@ -295,14 +296,21 @@ namespace BizHawk.Emulation.Cores.Waterbox
// TODO: wire up statuses to something (not controller, of course) // TODO: wire up statuses to something (not controller, of course)
break; break;
case InputType.Rumble: case InputType.Rumble:
ret.HapticsChannels.Add(name); //TODO Does this apply to all Mednafen's systems? (This is for PSX.) Might need to pass more metadata through to here
var nameLeft = $"{name} Left (strong)";
var nameRight = $"{name} Right (weak)";
ret.HapticsChannels.Add(nameLeft);
ret.HapticsChannels.Add(nameRight);
// this is a special case, we treat b here as output rather than input // this is a special case, we treat b here as output rather than input
// so these thunks are called after the frame has advanced // so these thunks are called after the frame has advanced
_rumblers.Add((c, b) => _rumblers.Add((c, b) =>
{ {
// TODO: not entirely sure this is correct... const double S32_MAX_AS_F64 = int.MaxValue;
var val = b[byteStart] | (b[byteStart + 1] << 8); static int Scale(byte b)
c.SetHapticChannelStrength(name, val << 7); => (b * S32_MAX_AS_F64).RoundToInt();
//TODO double-check order
c.SetHapticChannelStrength(nameRight, Scale(b[byteStart]));
c.SetHapticChannelStrength(nameLeft, Scale(b[byteStart + 1]));
}); });
break; break;
default: default: