Added setting for the controller plugin type and the controller connection to N64SyncSettings
This commit is contained in:
parent
2c0cd80071
commit
52ee4984fa
|
@ -432,7 +432,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
|
|||
// Order is important because the register with the mupen core
|
||||
videoProvider = new N64VideoProvider(api, videosettings);
|
||||
audioProvider = new N64Audio(api);
|
||||
inputProvider = new N64Input(api, comm);
|
||||
inputProvider = new N64Input(api, comm, this.SyncSettings.Controllers);
|
||||
api.AttachPlugin(mupen64plusApi.m64p_plugin_type.M64PLUGIN_RSP,
|
||||
"mupen64plus-rsp-hle.dll");
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.Nintendo.N64.NativeApi;
|
||||
using BizHawk.Emulation.Cores.Consoles.Nintendo.N64;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Nintendo.N64
|
||||
{
|
||||
|
@ -44,7 +45,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
|
|||
}
|
||||
};
|
||||
|
||||
public N64Input(mupen64plusApi core, CoreComm comm)
|
||||
public N64Input(mupen64plusApi core, CoreComm comm, N64ControllerSettings[] controllerSettings)
|
||||
{
|
||||
api = new mupen64plusInputApi(core);
|
||||
CoreComm = comm;
|
||||
|
@ -52,6 +53,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
|
|||
api.SetM64PInputCallback(new mupen64plusInputApi.InputCallback(GetControllerInput));
|
||||
|
||||
core.VInterrupt += ShiftInputPolledBools;
|
||||
for (int i = 0; i < controllerSettings.Length; ++i)
|
||||
{
|
||||
SetControllerConnected(i, controllerSettings[i].IsConnected);
|
||||
SetControllerPakType(i, controllerSettings[i].PakType);
|
||||
}
|
||||
}
|
||||
|
||||
public void ShiftInputPolledBools()
|
||||
|
@ -116,5 +122,25 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
|
|||
|
||||
return buttons;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the controller pak of the controller to the specified type
|
||||
/// </summary>
|
||||
/// <param name="controller">Id of the controller</param>
|
||||
/// <param name="type">Type to which the controller pak is set. Currently only NO_PAK and MEMORY_CARD are supported</param>
|
||||
public void SetControllerPakType(int controller, N64ControllerSettings.N64ControllerPakType type)
|
||||
{
|
||||
api.SetM64PControllerPakType(controller, type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the connection status of the controller
|
||||
/// </summary>
|
||||
/// <param name="controller">Id of the controller to connect or disconnect</param>
|
||||
/// <param name="connectionStatus">New status of the controller connection</param>
|
||||
public void SetControllerConnected(int controller, bool connectionStatus)
|
||||
{
|
||||
api.SetM64PControllerConnected(controller, connectionStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,13 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.N64
|
|||
public PLUGINTYPE VidPlugin = PLUGINTYPE.RICE;
|
||||
public int VideoSizeX = 320;
|
||||
public int VideoSizeY = 240;
|
||||
public N64ControllerSettings[] Controllers = new N64ControllerSettings[4]
|
||||
{
|
||||
new N64ControllerSettings(),
|
||||
new N64ControllerSettings(),
|
||||
new N64ControllerSettings(),
|
||||
new N64ControllerSettings()
|
||||
};
|
||||
|
||||
public N64RicePluginSettings RicePlugin = new N64RicePluginSettings();
|
||||
public N64GlidePluginSettings GlidePlugin = new N64GlidePluginSettings();
|
||||
|
@ -24,7 +31,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.N64
|
|||
VideoSizeY = VideoSizeY,
|
||||
RicePlugin = RicePlugin.Clone(),
|
||||
GlidePlugin = GlidePlugin.Clone(),
|
||||
Glide64mk2Plugin = Glide64mk2Plugin.Clone()
|
||||
Glide64mk2Plugin = Glide64mk2Plugin.Clone(),
|
||||
Controllers = System.Array.ConvertAll(Controllers, a => a.Clone())
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -420,4 +428,59 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.N64
|
|||
}
|
||||
}
|
||||
|
||||
public class N64ControllerSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// Enumeration defining the different controller pak types
|
||||
/// for N64
|
||||
/// </summary>
|
||||
public enum N64ControllerPakType
|
||||
{
|
||||
NO_PAK = 1,
|
||||
MEMORY_CARD = 2,
|
||||
RUMBLE_PAK = 3,
|
||||
TRANSFER_PAK = 4
|
||||
}
|
||||
|
||||
private N64ControllerPakType _type = N64ControllerPakType.MEMORY_CARD;
|
||||
/// <summary>
|
||||
/// Type of the pak inserted in the controller
|
||||
/// Currently only NO_PAK and MEMORY_CARD are
|
||||
/// supported. Other values may be set and
|
||||
/// are recognized but they have no function
|
||||
/// yet. e.g. TRANSFER_PAK makes the N64
|
||||
/// recognize a transfer pak inserted in
|
||||
/// the controller but there is no
|
||||
/// communication to the transfer pak.
|
||||
/// </summary>
|
||||
public N64ControllerPakType PakType
|
||||
{
|
||||
get { return _type; }
|
||||
set { _type = value; }
|
||||
}
|
||||
|
||||
private bool _isConnected = true;
|
||||
/// <summary>
|
||||
/// Connection status of the controller i.e.:
|
||||
/// Is the controller plugged into the N64?
|
||||
/// </summary>
|
||||
public bool IsConnected
|
||||
{
|
||||
get { return _isConnected; }
|
||||
set { _isConnected = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clones this object
|
||||
/// </summary>
|
||||
/// <returns>New object with the same values</returns>
|
||||
public N64ControllerSettings Clone()
|
||||
{
|
||||
return new N64ControllerSettings
|
||||
{
|
||||
PakType = PakType,
|
||||
IsConnected = IsConnected
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using BizHawk.Emulation.Cores.Nintendo.N64;
|
||||
using BizHawk.Emulation.Cores.Consoles.Nintendo.N64;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
|
||||
{
|
||||
|
@ -43,6 +44,24 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
|
|||
public delegate void RumbleCallback(int Control, int on);
|
||||
RumbleCallback m64pRumbleCallback;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the controller pak type
|
||||
/// </summary>
|
||||
/// <param name="controller">Controller id</param>
|
||||
/// <param name="type">Type id according to (well documented... hurr hurr) mupen api</param>
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void SetControllerPakType(int controller, int type);
|
||||
SetControllerPakType InpSetControllerPakType;
|
||||
|
||||
/// <summary>
|
||||
/// Connects and disconnects controllers
|
||||
/// </summary>
|
||||
/// <param name="controller">Controller id</param>
|
||||
/// <param name="connected">1 if controller should be connected, 0 if controller should be disconnected</param>
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
delegate void SetControllerConnected(int controller, int connected);
|
||||
SetControllerConnected InpSetControllerConnected;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when mupen changes rumble pak status
|
||||
/// </summary>
|
||||
|
@ -56,6 +75,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
|
|||
mupen64plusApi.m64p_error result;
|
||||
InpSetInputCallback = (SetInputCallback)Marshal.GetDelegateForFunctionPointer(GetProcAddress(InpDll, "SetInputCallback"), typeof(SetInputCallback));
|
||||
InpSetRumbleCallback = (SetRumbleCallback)Marshal.GetDelegateForFunctionPointer(GetProcAddress(InpDll, "SetRumbleCallback"), typeof(SetRumbleCallback));
|
||||
InpSetControllerPakType = (SetControllerPakType)Marshal.GetDelegateForFunctionPointer(GetProcAddress(InpDll, "SetControllerPakType"), typeof(SetControllerPakType));
|
||||
InpSetControllerConnected = (SetControllerConnected)Marshal.GetDelegateForFunctionPointer(GetProcAddress(InpDll, "SetControllerConnected"), typeof(SetControllerConnected));
|
||||
|
||||
m64pRumbleCallback = new RumbleCallback(FireOnRumbleChange);
|
||||
result = InpSetRumbleCallback(m64pRumbleCallback);
|
||||
|
@ -67,10 +88,20 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
|
|||
InpSetInputCallback(InpInputCallback);
|
||||
}
|
||||
|
||||
void FireOnRumbleChange(int Control, int on)
|
||||
private void FireOnRumbleChange(int Control, int on)
|
||||
{
|
||||
if (OnRumbleChange != null)
|
||||
OnRumbleChange(Control, on);
|
||||
}
|
||||
|
||||
public void SetM64PControllerPakType(int controller, N64ControllerSettings.N64ControllerPakType type)
|
||||
{
|
||||
InpSetControllerPakType(controller, (int)type);
|
||||
}
|
||||
|
||||
public void SetM64PControllerConnected(int controller, bool connected)
|
||||
{
|
||||
InpSetControllerConnected(controller, connected?1:0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue