Skip to content

Commit

Permalink
Add debug readout for haptic feedback (SDL2 only)
Browse files Browse the repository at this point in the history
build with `-p:MachineExtraCompilationFlag=BIZHAWKBUILD_DEBUG_RUMBLE`
there's nothing special about SDL2 I just can't be bothered finding the
other impls
  • Loading branch information
YoshiRulz committed Oct 8, 2024
1 parent 154a49c commit f6da980
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/BizHawk.Bizware.Input/SDL2/SDL2InputAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
using BizHawk.Client.Common;
using BizHawk.Common;
using BizHawk.Common.CollectionExtensions;
#if BIZHAWKBUILD_DEBUG_RUMBLE
using BizHawk.Common.NumberExtensions;
#endif

using static SDL2.SDL;

Expand Down Expand Up @@ -170,6 +173,12 @@ public override void ProcessHostGamepads(Action<string?, bool, ClientInputFocus>
{
var leftStrength = _lastHapticsSnapshot.GetValueOrDefault(pad.InputNamePrefix + "Left");
var rightStrength = _lastHapticsSnapshot.GetValueOrDefault(pad.InputNamePrefix + "Right");
#if BIZHAWKBUILD_DEBUG_RUMBLE
const int WIDTH = 50; // don't forget to change PACKED_BAR_GRAPHICS too
const string PACKED_BAR_GRAPHICS = " ################################################## ";
const float SCALE_FACTOR = (float) (WIDTH / (double) int.MaxValue);
Console.WriteLine($"rumble: [{PACKED_BAR_GRAPHICS.Substring(startIndex: (leftStrength * SCALE_FACTOR).RoundToInt(), length: WIDTH)}] L / R [{PACKED_BAR_GRAPHICS.Substring(startIndex: 2 * WIDTH - (rightStrength * SCALE_FACTOR).RoundToInt(), length: WIDTH)}]");
#endif
pad.SetVibration(leftStrength, rightStrength);
}
}
Expand Down

0 comments on commit f6da980

Please sign in to comment.