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:
Meerkov 2021-07-20 17:06:16 -07:00 committed by GitHub
parent 52333e4862
commit 664ab7fab6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 18 deletions

Binary file not shown.

View File

@ -21,6 +21,7 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{3D8BD211-6002-4698-B5C1-A0F3146B6ACF}</ProjectGuid>
<RootNamespace>mupen64plusinputbkm</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">

View File

@ -424,6 +424,7 @@ EXPORT void CALL SetInputCallback(int (*inputCallback)(int i))
---------------------------------------------------------------------- */
EXPORT void CALL SetRumbleCallback(void (*rumbleCallback)(int Control, int on))
{
l_setrumbleCallback = rumbleCallback;
}
/* ----------------------------------------------------------------------

View File

@ -18,7 +18,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
_emuCore = emuCore;
_api = new mupen64plusInputApi(core);
_api.SetM64PInputCallback(GetControllerInput);
_api.SetM64PInputCallbacks(GetControllerInput, SetRumble);
core.VInterrupt += ShiftInputPolledBools;
for (int i = 0; i < controllerSettings.Length; ++i)
@ -86,6 +86,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
return value;
}
private void SetRumble(int player, int bIsActive)
=> Controller.SetHapticChannelStrength($"P{player + 1} Rumble Pak", bIsActive == 0 ? 0 : int.MaxValue);
/// <summary>
/// Read all buttons from a controller and translate them
/// into a form the N64 understands

View File

@ -58,11 +58,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
private readonly SetControllerConnected InpSetControllerConnected;
/// <summary>
/// Event fired when mupen changes rumble pak status
/// </summary>
private event RumbleCallback OnRumbleChange;
public mupen64plusInputApi(mupen64plusApi core)
{
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,
"mupen64plus-input-bkm.dll");
mupen64plusApi.m64p_error result;
InpSetInputCallback = GetInputDelegate<SetInputCallback>("SetInputCallback");
InpSetRumbleCallback = GetInputDelegate<SetRumbleCallback>("SetRumbleCallback");
InpSetControllerPakType = GetInputDelegate<SetControllerPakType>("SetControllerPakType");
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);
}
private void FireOnRumbleChange(int Control, int on)
{
OnRumbleChange?.Invoke(Control, @on);
InpSetInputCallback(InpInputCallback = inputCallback);
_ = InpSetRumbleCallback(m64pRumbleCallback = rumbleCallback);
}
public void SetM64PControllerPakType(int controller, N64SyncSettings.N64ControllerSettings.N64ControllerPakType type)