mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-12-24 15:41:49 +01:00
Enable xinput hotplug from a sync change when using Sony dongle
This commit is contained in:
parent
b34c258a59
commit
2fabd860a2
@ -143,12 +143,13 @@ namespace DS4Windows
|
||||
device.setUiContext(SynchronizationContext.Current);
|
||||
device.Removal += this.On_DS4Removal;
|
||||
device.Removal += DS4Devices.On_Removal;
|
||||
device.SyncChange += this.On_SyncChange;
|
||||
device.SyncChange += DS4Devices.UpdateSerial;
|
||||
device.SerialChange += this.On_SerialChange;
|
||||
touchPad[i] = new Mouse(i, device);
|
||||
device.LightBarColor = getMainColor(i);
|
||||
|
||||
if (!getDInputOnly(i))
|
||||
if (!getDInputOnly(i) && device.isSynced())
|
||||
{
|
||||
int xinputIndex = x360Bus.FirstController + i;
|
||||
LogDebug("Plugging in X360 Controller #" + xinputIndex);
|
||||
@ -319,12 +320,13 @@ namespace DS4Windows
|
||||
device.setUiContext(uiContext);
|
||||
device.Removal += this.On_DS4Removal;
|
||||
device.Removal += DS4Devices.On_Removal;
|
||||
device.SyncChange += this.On_SyncChange;
|
||||
device.SyncChange += DS4Devices.UpdateSerial;
|
||||
device.SerialChange += this.On_SerialChange;
|
||||
touchPad[Index] = new Mouse(Index, device);
|
||||
device.LightBarColor = getMainColor(Index);
|
||||
device.Report += this.On_Report;
|
||||
if (!getDInputOnly(Index))
|
||||
if (!getDInputOnly(Index) && device.isSynced())
|
||||
{
|
||||
int xinputIndex = x360Bus.FirstController + Index;
|
||||
LogDebug("Plugging in X360 Controller #" + xinputIndex);
|
||||
@ -562,6 +564,60 @@ namespace DS4Windows
|
||||
}
|
||||
}
|
||||
|
||||
protected void On_SyncChange(object sender, EventArgs e)
|
||||
{
|
||||
DS4Device device = (DS4Device)sender;
|
||||
int ind = -1;
|
||||
for (int i = 0, arlength = DS4_CONTROLLER_COUNT; ind == -1 && i < arlength; i++)
|
||||
{
|
||||
DS4Device tempDev = DS4Controllers[i];
|
||||
if (tempDev != null && device == tempDev)
|
||||
ind = i;
|
||||
}
|
||||
|
||||
if (ind >= 0)
|
||||
{
|
||||
bool synced = device.isSynced();
|
||||
|
||||
if (!synced)
|
||||
{
|
||||
if (!useDInputOnly[ind])
|
||||
{
|
||||
bool unplugResult = x360Bus.Unplug(ind);
|
||||
int xinputIndex = x360Bus.FirstController + ind;
|
||||
if (unplugResult)
|
||||
{
|
||||
LogDebug("X360 Controller # " + xinputIndex + " unplugged");
|
||||
useDInputOnly[ind] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogDebug("X360 Controller # " + xinputIndex + " failed to unplug");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!getDInputOnly(ind))
|
||||
{
|
||||
int xinputIndex = x360Bus.FirstController + ind;
|
||||
LogDebug("Plugging in X360 Controller #" + xinputIndex);
|
||||
bool xinputResult = x360Bus.Plugin(ind);
|
||||
if (xinputResult)
|
||||
{
|
||||
LogDebug("X360 Controller # " + xinputIndex + " connected");
|
||||
useDInputOnly[ind] = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogDebug("X360 Controller # " + xinputIndex + " failed. Using DInput only mode");
|
||||
useDInputOnly[ind] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Called when DS4 is disconnected or timed out
|
||||
protected virtual void On_DS4Removal(object sender, EventArgs e)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user