mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-22 09:19:18 +01:00
Store force feedback delegate and unsubscribe before virtual controller disconnect
Should not be necessary but do it as a pre-caution
This commit is contained in:
parent
5528c6956a
commit
1fd423b663
@ -393,10 +393,12 @@ namespace DS4Windows
|
||||
as Xbox360OutDevice;
|
||||
//outputDevices[index] = tempXbox;
|
||||
int devIndex = index;
|
||||
tempXbox.cont.FeedbackReceived += (sender, args) =>
|
||||
Nefarius.ViGEm.Client.Targets.Xbox360FeedbackReceivedEventHandler p = (sender, args) =>
|
||||
{
|
||||
SetDevRumble(device, args.LargeMotor, args.SmallMotor, devIndex);
|
||||
};
|
||||
tempXbox.cont.FeedbackReceived += p;
|
||||
tempXbox.forceFeedbackCall = p;
|
||||
|
||||
outputslotMan.DeferredPlugin(tempXbox, index, outputDevices);
|
||||
//tempXbox.Connect();
|
||||
@ -411,7 +413,7 @@ namespace DS4Windows
|
||||
as DS4OutDevice;
|
||||
//outputDevices[index] = tempDS4;
|
||||
int devIndex = index;
|
||||
tempDS4.cont.FeedbackReceived += (sender, args) =>
|
||||
Nefarius.ViGEm.Client.Targets.DualShock4FeedbackReceivedEventHandler p = (sender, args) =>
|
||||
{
|
||||
//bool useRumble = false; bool useLight = false;
|
||||
byte largeMotor = args.LargeMotor;
|
||||
@ -468,6 +470,8 @@ namespace DS4Windows
|
||||
|
||||
//Console.WriteLine();
|
||||
};
|
||||
tempDS4.cont.FeedbackReceived += p;
|
||||
tempDS4.forceFeedbackCall = p;
|
||||
|
||||
outputslotMan.DeferredPlugin(tempDS4, index, outputDevices);
|
||||
//tempDS4.Connect();
|
||||
|
@ -15,6 +15,7 @@ namespace DS4Windows
|
||||
|
||||
public DualShock4Controller cont;
|
||||
private DualShock4Report report;
|
||||
public DualShock4FeedbackReceivedEventHandler forceFeedbackCall;
|
||||
|
||||
public DS4OutDevice(ViGEmClient client)
|
||||
{
|
||||
@ -141,7 +142,18 @@ namespace DS4Windows
|
||||
}
|
||||
|
||||
public override void Connect() => cont.Connect();
|
||||
public override void Disconnect() => cont.Disconnect();
|
||||
public override void Disconnect()
|
||||
{
|
||||
if (forceFeedbackCall != null)
|
||||
{
|
||||
cont.FeedbackReceived -= forceFeedbackCall;
|
||||
forceFeedbackCall = null;
|
||||
}
|
||||
|
||||
cont.Disconnect();
|
||||
cont.Dispose();
|
||||
cont = null;
|
||||
}
|
||||
public override string GetDeviceType() => devtype;
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ namespace DS4Windows
|
||||
|
||||
public Xbox360Controller cont;
|
||||
private Xbox360Report report;
|
||||
public Xbox360FeedbackReceivedEventHandler forceFeedbackCall;
|
||||
|
||||
public Xbox360OutDevice(ViGEmClient client)
|
||||
{
|
||||
@ -137,7 +138,18 @@ namespace DS4Windows
|
||||
}
|
||||
|
||||
public override void Connect() => cont.Connect();
|
||||
public override void Disconnect() => cont.Disconnect();
|
||||
public override void Disconnect()
|
||||
{
|
||||
if (forceFeedbackCall != null)
|
||||
{
|
||||
cont.FeedbackReceived -= forceFeedbackCall;
|
||||
forceFeedbackCall = null;
|
||||
}
|
||||
|
||||
cont.Disconnect();
|
||||
cont.Dispose();
|
||||
cont = null;
|
||||
}
|
||||
public override string GetDeviceType() => devType;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user