diff --git a/Assets/dll/libquicknes.dll b/Assets/dll/libquicknes.dll
index 21cf4377c9f..aace3fed092 100644
Binary files a/Assets/dll/libquicknes.dll and b/Assets/dll/libquicknes.dll differ
diff --git a/Assets/dll/libquicknes.so b/Assets/dll/libquicknes.so
index aacef8d1ccb..f16a87a1856 100755
Binary files a/Assets/dll/libquicknes.so and b/Assets/dll/libquicknes.so differ
diff --git a/quicknes/bizinterface.cpp b/quicknes/bizinterface.cpp
index 81249c60dc8..fb85f05de81 100644
--- a/quicknes/bizinterface.cpp
+++ b/quicknes/bizinterface.cpp
@@ -50,6 +50,11 @@ QN_EXPORT const char *qn_set_sample_rate(quickerNES::Emu *e, int rate)
return ret;
}
+void (*input_callback_cb)(void) = nullptr;
+QN_EXPORT void qn_set_input_callback(void (*fecb)(void))
+{
+ input_callback_cb = fecb;
+}
QN_EXPORT const char *qn_emulate_frame(quickerNES::Emu *e, uint32_t pad1, uint32_t pad2, uint8_t arkanoidPosition, uint8_t arkanoidFire, int controllerType)
{
diff --git a/quicknes/core b/quicknes/core
index 61ff28710c4..be584d7ee34 160000
--- a/quicknes/core
+++ b/quicknes/core
@@ -1 +1 @@
-Subproject commit 61ff28710c44b75c170dff1ee8f89831296e34b5
+Subproject commit be584d7ee341212a01dd2cb52ea5457d36d3d04b
diff --git a/quicknes/make/Makefile b/quicknes/make/Makefile
index 41869e05a27..4677da0f76f 100644
--- a/quicknes/make/Makefile
+++ b/quicknes/make/Makefile
@@ -4,7 +4,7 @@ CP = cp
CXXFLAGS = -I../core/source/quickerNES/core/ -I../core/extern/jaffarCommon/include -Wall -Wfatal-errors -Werror \
-std=c++20 -O3 -fomit-frame-pointer -flto -fvisibility=internal -fvisibility-inlines-hidden \
- -D_GNU_SOURCE -D__INLINE__=inline -D_QUICKERNES_DETECT_JOYPAD_READS -D_QUICKERNES_ENABLE_TRACEBACK_SUPPORT -D_QUICKERNES_SUPPORT_ARKANOID_INPUTS
+ -D_GNU_SOURCE -D__INLINE__=inline -D_QUICKERNES_DETECT_JOYPAD_READS -D_QUICKERNES_ENABLE_TRACEBACK_SUPPORT -D_QUICKERNES_SUPPORT_ARKANOID_INPUTS -D_QUICKERNES_ENABLE_INPUT_CALLBACK
# TODO: include these as options in the Makefile
# -fprofile-generate
diff --git a/quicknes/msvc/libquicknes.vcxproj b/quicknes/msvc/libquicknes.vcxproj
index eda1f20bdda..1135ee05e42 100644
--- a/quicknes/msvc/libquicknes.vcxproj
+++ b/quicknes/msvc/libquicknes.vcxproj
@@ -160,7 +160,7 @@
Disabled
4244;4800;4804;4996
$(ProjectDir)\..
- _WINDLL;%(PreprocessorDefinitions);_QUICKERNES_DETECT_JOYPAD_READS;_QUICKERNES_ENABLE_TRACEBACK_SUPPORT;_QUICKERNES_SUPPORT_ARKANOID_INPUTS;__INLINE__=inline
+ _WINDLL;%(PreprocessorDefinitions);_QUICKERNES_DETECT_JOYPAD_READS;_QUICKERNES_ENABLE_TRACEBACK_SUPPORT;_QUICKERNES_SUPPORT_ARKANOID_INPUTS;__INLINE__=inline;_QUICKERNES_ENABLE_INPUT_CALLBACK
true
stdcpp20
diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/LibQuickNES.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/LibQuickNES.cs
index bb19e0ef59c..6668b6bc5f2 100644
--- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/LibQuickNES.cs
+++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/LibQuickNES.cs
@@ -207,7 +207,11 @@ public abstract class LibQuickNES
[BizImport(CallingConvention.Cdecl)]
public abstract void qn_set_tracecb(IntPtr e, TraceCallback cb);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ public delegate void input_cb();
+ [BizImport(CallingConvention.Cdecl)]
+ public abstract void qn_set_input_callback(input_cb cb);
[BizImport(CallingConvention.Cdecl)]
public abstract byte qn_get_reg2000(IntPtr e);
diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IInputPollable.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IInputPollable.cs
index a7eb3fc9be7..5642c1bd455 100644
--- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IInputPollable.cs
+++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IInputPollable.cs
@@ -5,12 +5,18 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
public partial class QuickNES : IInputPollable
{
public int LagCount { get; set; }
+
public bool IsLagFrame { get; set; }
- public IInputCallbackSystem InputCallbacks
+ public IInputCallbackSystem InputCallbacks => _inputCallbacks;
+
+ private readonly LibQuickNES.input_cb _inputCallback;
+
+ private readonly InputCallbackSystem _inputCallbacks = [ ];
+
+ private void InputCallback()
{
- [FeatureNotImplemented]
- get => throw new NotImplementedException();
+ InputCallbacks.Call();
}
}
}
diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs
index abf6c4b2421..01714f5e67e 100644
--- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs
+++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs
@@ -32,6 +32,7 @@ public QuickNES(byte[] file, QuickNESSettings settings, QuickNESSyncSettings syn
{
ServiceProvider = new BasicServiceProvider(this);
Context = QN.qn_new();
+
if (Context == IntPtr.Zero)
{
throw new InvalidOperationException($"{nameof(QN.qn_new)}() returned NULL");
@@ -47,6 +48,10 @@ public QuickNES(byte[] file, QuickNESSettings settings, QuickNESSyncSettings syn
InitAudio();
InitMemoryDomains();
+ // Setting input callback
+ _inputCallback = InputCallback;
+ QN.qn_set_input_callback(_inputCallback);
+
int mapper = 0;
string mappername = Marshal.PtrToStringAnsi(QN.qn_get_mapper(Context, ref mapper));
Console.WriteLine($"{CoreNames.QuickNes}: Booted with Mapper #{mapper} \"{mappername}\"");