diff --git a/Assets/dll/mgba.dll b/Assets/dll/mgba.dll index 045bb045da..749fc56f67 100644 Binary files a/Assets/dll/mgba.dll and b/Assets/dll/mgba.dll differ diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/LibmGBA.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/LibmGBA.cs index d73abfb266..411f399ac6 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/LibmGBA.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/LibmGBA.cs @@ -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); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.IEmulator.cs index b5bde2c7bc..25467b0b64 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.IEmulator.cs @@ -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(); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.IInputPollable.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.IInputPollable.cs index 3bce70546f..82d1cbb7a1 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.IInputPollable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.IInputPollable.cs @@ -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); } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs index 520fb85f37..8c4716283a 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs @@ -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) diff --git a/submodules/mgba b/submodules/mgba index cb36c7a5bd..c4e7d33030 160000 --- a/submodules/mgba +++ b/submodules/mgba @@ -1 +1 @@ -Subproject commit cb36c7a5bd31faa29aa40546014e75c6db6daa1a +Subproject commit c4e7d330305e221bce704baf1a60cf97b6139f82