[Gambatte] Remote control controls and remote control emulation expanded to HuC1 IR and CGB IR (previously only done in HuC3)
This commit is contained in:
parent
aba3359dde
commit
0ff4aca182
Binary file not shown.
Binary file not shown.
|
@ -139,7 +139,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
[Description("Initial time of emulation in seconds.")]
|
||||
[DefaultValue(typeof(ulong), "0")]
|
||||
public ulong InitialTime { get; set; }
|
||||
|
||||
|
||||
[DisplayName("Enable remote control")]
|
||||
[Description("Adds control for the command sent from a TV remote pointed to the system or cart IR.")]
|
||||
[DefaultValue(false)]
|
||||
public bool EnableRemote { get; set; }
|
||||
|
||||
public enum FrameLengthType
|
||||
{
|
||||
[Display(Name = "VBlank Driven Frames")]
|
||||
|
|
|
@ -127,6 +127,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
|
||||
LibGambatte.gambatte_setinputgetter(GambatteState, InputCallback, IntPtr.Zero);
|
||||
|
||||
if (_syncSettings.EnableRemote)
|
||||
{
|
||||
RemoteCallback = new LibGambatte.RemoteCallback(RemoteInputCallback);
|
||||
LibGambatte.gambatte_setremotecallback(GambatteState, RemoteCallback);
|
||||
}
|
||||
|
||||
InitMemoryDomains();
|
||||
|
||||
byte[] mbcBuf = new byte[32];
|
||||
|
@ -182,7 +188,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
|
||||
_cdCallback = new LibGambatte.CDCallback(CDCallbackProc);
|
||||
|
||||
ControllerDefinition = CreateControllerDefinition(sgb: IsSgb, sub: _syncSettings.FrameLength is GambatteSyncSettings.FrameLengthType.UserDefinedFrames, tilt: false, rumble: false);
|
||||
ControllerDefinition = CreateControllerDefinition(
|
||||
sgb: IsSgb,
|
||||
sub: _syncSettings.FrameLength is GambatteSyncSettings.FrameLengthType.UserDefinedFrames,
|
||||
tilt: false,
|
||||
rumble: false,
|
||||
remote: _syncSettings.EnableRemote);
|
||||
|
||||
NewSaveCoreSetBuff();
|
||||
}
|
||||
|
@ -222,6 +233,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
/// </summary>
|
||||
private LibGambatte.Buttons CurrentButtons = 0;
|
||||
|
||||
/// <summary>
|
||||
/// remote callback delegate
|
||||
/// </summary>
|
||||
private readonly LibGambatte.RemoteCallback RemoteCallback;
|
||||
|
||||
/// <summary>
|
||||
/// remote command to send
|
||||
/// </summary>
|
||||
private byte RemoteCommand = 0;
|
||||
|
||||
/// <summary>
|
||||
/// internal gambatte state
|
||||
/// </summary>
|
||||
|
@ -247,7 +268,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
public long CycleCount => (long)_cycleCount;
|
||||
public double ClockRate => TICKSPERSECOND;
|
||||
|
||||
public static ControllerDefinition CreateControllerDefinition(bool sgb, bool sub, bool tilt, bool rumble)
|
||||
public static ControllerDefinition CreateControllerDefinition(bool sgb, bool sub, bool tilt, bool rumble, bool remote)
|
||||
{
|
||||
var ret = new ControllerDefinition((sub ? "Subframe " : "") + "Gameboy Controller" + (tilt ? " + Tilt" : ""));
|
||||
if (sub)
|
||||
|
@ -262,6 +283,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
{
|
||||
ret.HapticsChannels.Add("Rumble");
|
||||
}
|
||||
if (remote)
|
||||
{
|
||||
ret.AddAxis("Remote Command", 0.RangeTo(127), 127);
|
||||
}
|
||||
if (sgb)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
|
@ -305,6 +330,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
}
|
||||
}
|
||||
|
||||
private byte RemoteInputCallback()
|
||||
{
|
||||
InputCallbacks.Call();
|
||||
IsLagFrame = false;
|
||||
return RemoteCommand;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// true if the emulator is currently emulating CGB
|
||||
/// </summary>
|
||||
|
@ -366,8 +398,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
if (controller.IsPressed(GB_BUTTON_ORDER_IN_BITMASK[i])) b |= 1;
|
||||
}
|
||||
}
|
||||
|
||||
CurrentButtons = (LibGambatte.Buttons)b;
|
||||
|
||||
RemoteCommand = (byte)controller.AxisValue("Remote Command");
|
||||
|
||||
// the controller callback will set this to false if it actually gets called during the frame
|
||||
IsLagFrame = true;
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
_linkedCores[i] = new Gameboy(lp.Comm, lp.Roms[i].Game, lp.Roms[i].RomData, _settings._linkedSettings[i], _syncSettings._linkedSyncSettings[i], lp.DeterministicEmulationRequested);
|
||||
_linkedCores[i].ConnectInputCallbackSystem(_inputCallbacks);
|
||||
_linkedCores[i].ConnectMemoryCallbackSystem(_memoryCallbacks, i);
|
||||
_linkedConts[i] = new SaveController(Gameboy.CreateControllerDefinition(sgb: false, sub: false, tilt: false, rumble: false));
|
||||
_linkedConts[i] = new SaveController(Gameboy.CreateControllerDefinition(sgb: false, sub: false, tilt: false, rumble: false, remote: false));
|
||||
_linkedBlips[i] = new BlipBuffer(1024);
|
||||
_linkedBlips[i].SetRates(2097152 * 2, 44100);
|
||||
_linkedOverflow[i] = 0;
|
||||
|
|
|
@ -287,6 +287,22 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
[DllImport("libgambatte", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void gambatte_setcameracallback(IntPtr core, CameraCallback callback);
|
||||
|
||||
/// <summary>
|
||||
/// type of the remote input callback
|
||||
/// </summary>
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate byte RemoteCallback();
|
||||
|
||||
/// <summary>
|
||||
/// sets the remote input callback.
|
||||
/// the callback will return a value from 0 to 127.
|
||||
/// this value represents a remote command.
|
||||
/// </summary>
|
||||
/// <param name="core">opaque state pointer</param>
|
||||
/// <param name="callback">the callback</param>
|
||||
[DllImport("libgambatte", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void gambatte_setremotecallback(IntPtr core, RemoteCallback callback);
|
||||
|
||||
/// <summary>
|
||||
/// Changes between cycle-based and real-time RTC. Defaults to cycle-based.
|
||||
/// </summary>
|
||||
|
|
|
@ -117,7 +117,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Sameboy
|
|||
BoardName = MapperName(file);
|
||||
|
||||
_hasAcc = BoardName is "MBC7 ROM+ACCEL+EEPROM";
|
||||
ControllerDefinition = Gameboy.Gameboy.CreateControllerDefinition(sgb: false, sub: false, tilt: _hasAcc, rumble: true);
|
||||
ControllerDefinition = Gameboy.Gameboy.CreateControllerDefinition(sgb: false, sub: false, tilt: _hasAcc, rumble: true, remote: false);
|
||||
|
||||
LibSameboy.sameboy_setrtcdivisoroffset(SameboyState, _syncSettings.RTCDivisorOffset);
|
||||
CycleCount = 0;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 41c6f9165a2bd143771d2df8913551bc7bbd246a
|
||||
Subproject commit cb8d6ee1e97f7757ba75e1934e8eb6437ef9f959
|
Loading…
Reference in New Issue