Hook up rumble for mgba

This commit is contained in:
CasualPokePlayer 2024-10-06 17:12:34 -07:00
parent ce2a6da71f
commit b443eb40a8
6 changed files with 24 additions and 6 deletions

Binary file not shown.

View File

@ -198,6 +198,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
[BizImport(cc)]
public abstract void BizSetInputCallback(IntPtr ctx, InputCallback cb);
[UnmanagedFunctionPointer(cc)]
public delegate void RumbleCallback([MarshalAs(UnmanagedType.Bool)] bool enable);
[BizImport(cc)]
public abstract void BizSetRumbleCallback(IntPtr ctx, RumbleCallback cb);
[UnmanagedFunctionPointer(cc)]
public delegate void TraceCallback(string msg);

View File

@ -11,6 +11,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
public bool FrameAdvance(IController controller, bool render, bool renderSound = true)
{
_controller = controller;
if (controller.IsPressed("Power"))
{
LibmGBA.BizReset(Core);
@ -71,7 +73,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
public static readonly ControllerDefinition GBAController = new ControllerDefinition("GBA Controller")
{
BoolButtons = { "Up", "Down", "Left", "Right", "Start", "Select", "B", "A", "L", "R", "Power" }
BoolButtons = { "Up", "Down", "Left", "Right", "Start", "Select", "B", "A", "L", "R", "Power" },
HapticsChannels = { "Rumble" }
}.AddXYZTriple("Tilt {0}", (-32767).RangeTo(32767), 0)
.AddAxis("Light Sensor", 0.RangeTo(255), 0)
.MakeImmutable();

View File

@ -5,8 +5,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
public partial class MGBAHawk : IInputPollable
{
private readonly LibmGBA.InputCallback InputCallback;
private readonly LibmGBA.RumbleCallback RumbleCallback;
private IController _controller;
public int LagCount { get; set; }
public bool IsLagFrame { get; set; }
public IInputCallbackSystem InputCallbacks { get; } = new InputCallbackSystem();
private void SetRumble(bool enable)
=> _controller.SetHapticChannelStrength("Rumble", enable ? int.MaxValue : 0);
}
}

View File

@ -62,16 +62,19 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
_tracecb = MakeTrace;
ser.Register(Tracer);
_memoryCallbacks = new(LibmGBA, Core);
// most things are already handled in the core, this is just for event.oninputpoll
InputCallback = InputCallbacks.Call;
LibmGBA.BizSetInputCallback(Core, InputCallback);
RumbleCallback = SetRumble;
LibmGBA.BizSetRumbleCallback(Core, RumbleCallback);
}
catch
{
LibmGBA.BizDestroy(Core);
throw;
}
// most things are already handled in the core, this is just for event.oninputpoll
InputCallback = InputCallbacks.Call;
LibmGBA.BizSetInputCallback(Core, InputCallback);
}
private static LibmGBA.OverrideInfo GetOverrideInfo(SyncSettings syncSettings)

@ -1 +1 @@
Subproject commit cb36c7a5bd31faa29aa40546014e75c6db6daa1a
Subproject commit c4e7d330305e221bce704baf1a60cf97b6139f82