mgba: input support

This commit is contained in:
goyuken 2015-06-04 23:30:24 +00:00
parent f30dec819d
commit 6d5d720d55
3 changed files with 9 additions and 7 deletions

View File

@ -25,7 +25,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
public static extern bool BizLoad(IntPtr ctx, byte[] data, int length);
[DllImport(dll, CallingConvention = cc)]
public static extern void BizAdvance(IntPtr ctx, int keys, int[] vbuff, ref int nsamp, short[] sbuff);
public static extern void BizAdvance(IntPtr ctx, LibVBANext.Buttons keys, int[] vbuff, ref int nsamp, short[] sbuff);
}
}

View File

@ -40,15 +40,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
}
public IEmulatorServiceProvider ServiceProvider { get; private set; }
public ControllerDefinition ControllerDefinition { get { return GBA.GBAController; } }
public IController Controller { get; set; }
public void FrameAdvance(bool render, bool rendersound = true)
{
Frame++;
LibmGBA.BizAdvance(core, 0, videobuff, ref nsamp, soundbuff);
if (Controller["Power"])
LibmGBA.BizReset(core);
LibmGBA.BizAdvance(core, VBANext.GetButtons(Controller), videobuff, ref nsamp, soundbuff);
}
public int Frame { get; private set; }
@ -98,6 +99,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
{
nsamp = this.nsamp;
samples = soundbuff;
Console.WriteLine(nsamp);
DiscardSamples();
}
public void DiscardSamples()

View File

@ -108,7 +108,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
SyncTraceCallback();
IsLagFrame = LibVBANext.FrameAdvance(Core, GetButtons(), videobuff, soundbuff, out numsamp, videopalette);
IsLagFrame = LibVBANext.FrameAdvance(Core, GetButtons(Controller), videobuff, soundbuff, out numsamp, videopalette);
if (IsLagFrame)
LagCount++;
@ -210,12 +210,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
public ControllerDefinition ControllerDefinition { get { return GBA.GBAController; } }
public IController Controller { get; set; }
private LibVBANext.Buttons GetButtons()
public static LibVBANext.Buttons GetButtons(IController c)
{
LibVBANext.Buttons ret = 0;
foreach (string s in Enum.GetNames(typeof(LibVBANext.Buttons)))
{
if (Controller[s])
if (c[s])
ret |= (LibVBANext.Buttons)Enum.Parse(typeof(LibVBANext.Buttons), s);
}
return ret;