From 7f9adc0c1dc936b50c588bdba185dfd6871ebdb5 Mon Sep 17 00:00:00 2001 From: goyuken Date: Thu, 4 Dec 2014 02:04:14 +0000 Subject: [PATCH] dgb: reenable input callbacks. --- .../Interfaces/IInputCallbackSystem.cs | 2 +- .../Consoles/Nintendo/Gameboy/Gambatte.cs | 11 ++++++++++- .../Consoles/Nintendo/Gameboy/GambatteLink.cs | 6 ++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/BizHawk.Emulation.Common/Interfaces/IInputCallbackSystem.cs b/BizHawk.Emulation.Common/Interfaces/IInputCallbackSystem.cs index 82204f8ad7..e2f80df4a6 100644 --- a/BizHawk.Emulation.Common/Interfaces/IInputCallbackSystem.cs +++ b/BizHawk.Emulation.Common/Interfaces/IInputCallbackSystem.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; namespace BizHawk.Emulation.Common { // TODO: This isn't a CoreService, it is a sub class of a core service, it would be nice to make that clear - public interface IInputCallbackSystem : IList + public interface IInputCallbackSystem : ICollection { /// /// Will iterate and call every callback diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs index bf764b8154..55baa04f85 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs @@ -36,11 +36,20 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy public int LagCount { get; set; } public bool IsLagFrame { get; private set; } - private readonly InputCallbackSystem _inputCallbacks = new InputCallbackSystem(); + private InputCallbackSystem _inputCallbacks = new InputCallbackSystem(); // low priority TODO: due to certain aspects of the core implementation, // we don't smartly use the ActiveChanged event here. public IInputCallbackSystem InputCallbacks { get { return _inputCallbacks; } } + /// + /// for use in dual core + /// + /// + public void ConnectInputCallbackSystem(InputCallbackSystem ics) + { + _inputCallbacks = ics; + } + // all cycle counts are relative to a 2*1024*1024 mhz refclock /// diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs index c871a4b272..ae0e19437d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs @@ -57,6 +57,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy L.Controller = LCont; R.Controller = RCont; + L.ConnectInputCallbackSystem(_inputCallbacks); + R.ConnectInputCallbackSystem(_inputCallbacks); comm.VsyncNum = L.CoreComm.VsyncNum; comm.VsyncDen = L.CoreComm.VsyncDen; @@ -80,8 +82,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy SetMemoryDomains(); } - // TODO: how to best work this under the new system? IInputCallbackSystem is far too unwieldly to actually implement - public IInputCallbackSystem InputCallbacks { [FeatureNotImplemented]get { throw new NotImplementedException(); } } + private InputCallbackSystem _inputCallbacks = new InputCallbackSystem(); + public IInputCallbackSystem InputCallbacks { get { return _inputCallbacks; } } public IVideoProvider VideoProvider { get { return this; } } public ISoundProvider SoundProvider { get { return null; } }