Wire up haptics in Mupen core (squashed PR #2683)
* Wire up host haptics, but only for OpenTK which doesn't support it and I'm hijacking the Fast Forward hotkey too * Fix Mupen 64 Vibration DLL * Enable Mupen 64 Vibration for DirectInput * Remove unused SDL dep from Mupen input-bkm plugin this allows it to be built without checking out the deps submodule, I guess * Fix <OutDir/> in Mupen lib projects * Remove "Debug" haptic channel and debug hotkey, prepare Mupen * Fix remaining merge conflicts * ...with the correct channel name and hopefully no dangling whitespace changes * Fix typo from resolving merge conflict, and off-by-one error Co-authored-by: YoshiRulz <OSSYoshiRulz@gmail.com>
This commit is contained in:
parent
52333e4862
commit
664ab7fab6
Binary file not shown.
|
@ -21,6 +21,7 @@
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{3D8BD211-6002-4698-B5C1-A0F3146B6ACF}</ProjectGuid>
|
<ProjectGuid>{3D8BD211-6002-4698-B5C1-A0F3146B6ACF}</ProjectGuid>
|
||||||
<RootNamespace>mupen64plusinputbkm</RootNamespace>
|
<RootNamespace>mupen64plusinputbkm</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
|
|
@ -424,6 +424,7 @@ EXPORT void CALL SetInputCallback(int (*inputCallback)(int i))
|
||||||
---------------------------------------------------------------------- */
|
---------------------------------------------------------------------- */
|
||||||
EXPORT void CALL SetRumbleCallback(void (*rumbleCallback)(int Control, int on))
|
EXPORT void CALL SetRumbleCallback(void (*rumbleCallback)(int Control, int on))
|
||||||
{
|
{
|
||||||
|
l_setrumbleCallback = rumbleCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
|
||||||
_emuCore = emuCore;
|
_emuCore = emuCore;
|
||||||
_api = new mupen64plusInputApi(core);
|
_api = new mupen64plusInputApi(core);
|
||||||
|
|
||||||
_api.SetM64PInputCallback(GetControllerInput);
|
_api.SetM64PInputCallbacks(GetControllerInput, SetRumble);
|
||||||
|
|
||||||
core.VInterrupt += ShiftInputPolledBools;
|
core.VInterrupt += ShiftInputPolledBools;
|
||||||
for (int i = 0; i < controllerSettings.Length; ++i)
|
for (int i = 0; i < controllerSettings.Length; ++i)
|
||||||
|
@ -86,6 +86,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetRumble(int player, int bIsActive)
|
||||||
|
=> Controller.SetHapticChannelStrength($"P{player + 1} Rumble Pak", bIsActive == 0 ? 0 : int.MaxValue);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Read all buttons from a controller and translate them
|
/// Read all buttons from a controller and translate them
|
||||||
/// into a form the N64 understands
|
/// into a form the N64 understands
|
||||||
|
|
|
@ -58,11 +58,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
|
||||||
|
|
||||||
private readonly SetControllerConnected InpSetControllerConnected;
|
private readonly SetControllerConnected InpSetControllerConnected;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Event fired when mupen changes rumble pak status
|
|
||||||
/// </summary>
|
|
||||||
private event RumbleCallback OnRumbleChange;
|
|
||||||
|
|
||||||
public mupen64plusInputApi(mupen64plusApi core)
|
public mupen64plusInputApi(mupen64plusApi core)
|
||||||
{
|
{
|
||||||
T GetInputDelegate<T>(string proc) where T : Delegate => mupen64plusApi.GetTypedDelegate<T>(InpDll, proc);
|
T GetInputDelegate<T>(string proc) where T : Delegate => mupen64plusApi.GetTypedDelegate<T>(InpDll, proc);
|
||||||
|
@ -70,25 +65,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
|
||||||
InpDll = core.AttachPlugin(mupen64plusApi.m64p_plugin_type.M64PLUGIN_INPUT,
|
InpDll = core.AttachPlugin(mupen64plusApi.m64p_plugin_type.M64PLUGIN_INPUT,
|
||||||
"mupen64plus-input-bkm.dll");
|
"mupen64plus-input-bkm.dll");
|
||||||
|
|
||||||
mupen64plusApi.m64p_error result;
|
|
||||||
InpSetInputCallback = GetInputDelegate<SetInputCallback>("SetInputCallback");
|
InpSetInputCallback = GetInputDelegate<SetInputCallback>("SetInputCallback");
|
||||||
InpSetRumbleCallback = GetInputDelegate<SetRumbleCallback>("SetRumbleCallback");
|
InpSetRumbleCallback = GetInputDelegate<SetRumbleCallback>("SetRumbleCallback");
|
||||||
InpSetControllerPakType = GetInputDelegate<SetControllerPakType>("SetControllerPakType");
|
InpSetControllerPakType = GetInputDelegate<SetControllerPakType>("SetControllerPakType");
|
||||||
InpSetControllerConnected = GetInputDelegate<SetControllerConnected>("SetControllerConnected");
|
InpSetControllerConnected = GetInputDelegate<SetControllerConnected>("SetControllerConnected");
|
||||||
|
|
||||||
m64pRumbleCallback = new RumbleCallback(FireOnRumbleChange);
|
|
||||||
result = InpSetRumbleCallback(m64pRumbleCallback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetM64PInputCallback(InputCallback inputCallback)
|
public void SetM64PInputCallbacks(InputCallback inputCallback, RumbleCallback rumbleCallback)
|
||||||
{
|
{
|
||||||
InpInputCallback = inputCallback;
|
InpSetInputCallback(InpInputCallback = inputCallback);
|
||||||
InpSetInputCallback(InpInputCallback);
|
_ = InpSetRumbleCallback(m64pRumbleCallback = rumbleCallback);
|
||||||
}
|
|
||||||
|
|
||||||
private void FireOnRumbleChange(int Control, int on)
|
|
||||||
{
|
|
||||||
OnRumbleChange?.Invoke(Control, @on);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetM64PControllerPakType(int controller, N64SyncSettings.N64ControllerSettings.N64ControllerPakType type)
|
public void SetM64PControllerPakType(int controller, N64SyncSettings.N64ControllerSettings.N64ControllerPakType type)
|
||||||
|
|
Loading…
Reference in New Issue