When clearing lua callbacks, handle the case that input callbacks might not be implemented, also handle memory callbacks in a more consistent way
This commit is contained in:
parent
d8dbaf82bc
commit
32a2711303
|
@ -33,22 +33,15 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void ClearAll()
|
||||
{
|
||||
if (Global.Emulator.CanPollInput())
|
||||
if (Global.Emulator.InputCallbacksAvailable())
|
||||
{
|
||||
Global.Emulator.AsInputPollable().InputCallbacks.RemoveAll(this.Select(x => x.Callback));
|
||||
}
|
||||
|
||||
if (Global.Emulator.CanDebug())
|
||||
if (Global.Emulator.MemoryCallbacksAvailable())
|
||||
{
|
||||
try
|
||||
{
|
||||
var cbSys = Global.Emulator.AsDebuggable().MemoryCallbacks;
|
||||
cbSys.RemoveAll(this.Select(x => x.Callback));
|
||||
}
|
||||
catch
|
||||
{
|
||||
//swallow exceptions here. many cores havent implemented memorycallbacks, we ought to have more granular feature querying
|
||||
}
|
||||
var cbSys = Global.Emulator.AsDebuggable().MemoryCallbacks;
|
||||
cbSys.RemoveAll(this.Select(x => x.Callback));
|
||||
}
|
||||
|
||||
Clear();
|
||||
|
|
|
@ -78,6 +78,31 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
|
|||
return (IInputPollable)core.ServiceProvider.GetService<IInputPollable>();
|
||||
}
|
||||
|
||||
public static bool InputCallbacksAvailable(this IEmulator core)
|
||||
{
|
||||
if (core == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: this is a pretty ugly way to handle this
|
||||
var pollable = (IInputPollable)core.ServiceProvider.GetService<IInputPollable>();
|
||||
if (pollable != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var callbacks = pollable.InputCallbacks;
|
||||
return true;
|
||||
}
|
||||
catch (NotImplementedException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool HasDriveLight(this IEmulator core)
|
||||
{
|
||||
if (core == null)
|
||||
|
|
Loading…
Reference in New Issue