diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs
index 83228cedb4..65d8db3c4e 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs
@@ -141,32 +141,32 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
}
///
- /// Translates controller inputs from EmuHawk and
- /// shoves them into mupen64plus
+ /// Translates controller input from EmuHawk into
+ /// N64 controller data
///
- public void setControllers()
+ /// Id of controller to update and shove
+ public int GetControllerInput(int i)
{
CoreComm.InputCallback.Call();
IsLagFrame = false;
// Analog stick right = +X
// Analog stick up = +Y
+ string p = "P" + (i + 1);
+ sbyte x;
+ if (Controller.IsPressed(p + " A Left")) { x = -127; }
+ else if (Controller.IsPressed(p + " A Right")) { x = 127; }
+ else { x = (sbyte)Controller.GetFloat(p + " X Axis"); }
- for (int i = 0; i < 4; i++)
- {
- string p = "P" + (i + 1);
- sbyte x;
- if (Controller.IsPressed(p + " A Left")) { x = -127; }
- else if (Controller.IsPressed(p + " A Right")) { x = 127; }
- else { x = (sbyte)Controller.GetFloat(p + " X Axis"); }
+ sbyte y;
+ if (Controller.IsPressed(p + " A Up")) { y = 127; }
+ else if (Controller.IsPressed(p + " A Down")) { y = -127; }
+ else { y = (sbyte)Controller.GetFloat(p + " Y Axis"); }
- sbyte y;
- if (Controller.IsPressed(p + " A Up")) { y = 127; }
- else if (Controller.IsPressed(p + " A Down")) { y = -127; }
- else { y = (sbyte)Controller.GetFloat(p + " Y Axis"); }
-
- api.set_buttons(i, ReadController(i+1), x, y);
- }
+ int value = ReadController(i + 1);
+ value |= (x & 0xFF) << 16;
+ value |= (y & 0xFF) << 24;
+ return value;
}
///
@@ -456,7 +456,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
}
api = new mupen64plusApi(this, rom, this.SyncSettings.GetVPS(game), SaveType);
- api.SetM64PInputCallback(new mupen64plusApi.InputCallback(setControllers));
+ api.SetM64PInputCallback(new mupen64plusApi.InputCallback(GetControllerInput));
audioProvider = new N64Audio(api);
videoProvider = new N64VideoProvider(api);
diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/mupen64plusApi.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/mupen64plusApi.cs
index 7d1076d2d8..55da55b39b 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/mupen64plusApi.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/mupen64plusApi.cs
@@ -316,18 +316,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
// Input plugin specific
- ///
- /// Sets the buttons for a controller
- ///
- /// The controller number to set buttons for (0-3)
- /// The button data
- /// The value for the X axis
- /// The value for the Y axis
- ///
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- private delegate int SetKeys(int num, int keys, sbyte X, sbyte Y);
- SetKeys InpSetKeys;
-
///
/// Sets a callback to use when the mupen core wants controller buttons
///
@@ -337,7 +325,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
SetInputCallback InpSetInputCallback;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- public delegate void InputCallback();
+ public delegate int InputCallback(int i);
InputCallback InpInputCallback;
@@ -600,7 +588,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
InpPluginStartup = (PluginStartup)Marshal.GetDelegateForFunctionPointer(GetProcAddress(InpDll, "PluginStartup"), typeof(PluginStartup));
InpPluginShutdown = (PluginShutdown)Marshal.GetDelegateForFunctionPointer(GetProcAddress(InpDll, "PluginShutdown"), typeof(PluginShutdown));
- InpSetKeys = (SetKeys)Marshal.GetDelegateForFunctionPointer(GetProcAddress(InpDll, "SetKeys"), typeof(SetKeys));
InpSetInputCallback = (SetInputCallback)Marshal.GetDelegateForFunctionPointer(GetProcAddress(InpDll, "SetInputCallback"), typeof(SetInputCallback));
RspPluginStartup = (PluginStartup)Marshal.GetDelegateForFunctionPointer(GetProcAddress(RspDll, "PluginStartup"), typeof(PluginStartup));
@@ -692,11 +679,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
return m64pDebugMemGetPointer(id);
}
- public void set_buttons(int num, int keys, sbyte X, sbyte Y)
- {
- InpSetKeys(num, keys, X, Y);
- }
-
public void soft_reset()
{
m64pCoreDoCommandPtr(m64p_command.M64CMD_RESET, 0, IntPtr.Zero);
diff --git a/libmupen64plus/mupen64plus-input-bkm/plugin.c b/libmupen64plus/mupen64plus-input-bkm/plugin.c
index 486673fb1f..78fa15452a 100644
--- a/libmupen64plus/mupen64plus-input-bkm/plugin.c
+++ b/libmupen64plus/mupen64plus-input-bkm/plugin.c
@@ -47,7 +47,7 @@ static void (*l_DebugCallback)(void *, int, const char *) = NULL;
static void *l_DebugCallContext = NULL;
static int l_PluginInit = 0;
-static void (*l_inputCallback)() = NULL;
+static int (*l_inputCallback)(int i) = NULL;
static int romopen = 0; // is a rom opened
@@ -272,22 +272,10 @@ EXPORT void CALL SDL_KeyUp(int keymod, int keysym)
*******************************************************************/
EXPORT void CALL GetKeys( int Control, BUTTONS *Keys )
{
- (*l_inputCallback)();
- Keys->Value = controller[Control].buttons.Value;
+ Keys->Value = (*l_inputCallback)(Control);
}
-/* ----------------------------------------------------------------------
- ----------- Sets the internal buttons delegated to mupen64 -----------
- ---------------------------------------------------------------------- */
-EXPORT void CALL SetKeys(int num, int keys, char X, char Y)
-{
- controller[num].buttons.Value = keys;
-
- controller[num].buttons.X_AXIS = X;
- controller[num].buttons.Y_AXIS = Y;
-}
-
-EXPORT void CALL SetInputCallback(void (*inputCallback)())
+EXPORT void CALL SetInputCallback(int (*inputCallback)(int i))
{
l_inputCallback = inputCallback;
}
\ No newline at end of file
diff --git a/libmupen64plus/mupen64plus-input-bkm/plugin.h b/libmupen64plus/mupen64plus-input-bkm/plugin.h
index 46899380f3..596712288e 100644
--- a/libmupen64plus/mupen64plus-input-bkm/plugin.h
+++ b/libmupen64plus/mupen64plus-input-bkm/plugin.h
@@ -31,7 +31,6 @@
typedef struct
{
CONTROL *control; // pointer to CONTROL struct in Core library
- BUTTONS buttons;
} SController;
/* global data definitions */
diff --git a/output/dll/mupen64plus-input-bkm.dll b/output/dll/mupen64plus-input-bkm.dll
index 9e891c985b..8820d992ca 100644
Binary files a/output/dll/mupen64plus-input-bkm.dll and b/output/dll/mupen64plus-input-bkm.dll differ