Have Disconnect BT Special Action wait for Idle controller status with SONYWA

Related to issue #1079
This commit is contained in:
Travis Nickles 2020-02-10 19:32:48 -06:00
parent 3177530ccd
commit e92a15aa1e

View File

@ -2257,34 +2257,17 @@ namespace DS4Windows
if (synced && !d.isCharging()) if (synced && !d.isCharging())
{ {
ConnectionType deviceConn = d.getConnectionType(); ConnectionType deviceConn = d.getConnectionType();
bool exclusive = /*tempBool =*/ d.isExclusive(); //bool exclusive = /*tempBool =*/ d.isExclusive();
if (deviceConn == ConnectionType.BT) if (deviceConn == ConnectionType.BT)
{ {
d.DisconnectBT(); d.DisconnectBT();
ReleaseActionKeys(action, device);
return;
} }
else if (deviceConn == ConnectionType.SONYWA && exclusive) else if (deviceConn == ConnectionType.SONYWA)
{ {
d.DisconnectDongle(); action.pressRelease = true;
} }
//foreach (DS4Controls dc in action.trigger)
for (int i = 0, arlen = action.trigger.Count; i < arlen; i++)
{
DS4Controls dc = action.trigger[i];
DS4ControlSettings dcs = getDS4CSetting(device, dc);
if (dcs.action != null)
{
if (dcs.actionType == DS4ControlSettings.ActionType.Key)
InputMethods.performKeyRelease((ushort)dcs.action);
else if (dcs.actionType == DS4ControlSettings.ActionType.Macro)
{
int[] keys = (int[])dcs.action;
for (int j = 0, keysLen = keys.Length; j < keysLen; j++)
InputMethods.performKeyRelease((ushort)keys[j]);
}
}
}
return;
} }
} }
else if (action.typeID == SpecialAction.ActionTypeId.BatteryCheck) else if (action.typeID == SpecialAction.ActionTypeId.BatteryCheck)
@ -2354,6 +2337,22 @@ namespace DS4Windows
actionDone[index].dev[device] = false; actionDone[index].dev[device] = false;
} }
} }
else if (action.typeID == SpecialAction.ActionTypeId.DisconnectBT && action.pressRelease)
{
actionFound = true;
DS4Device d = ctrl.DS4Controllers[device];
ConnectionType deviceConn = d.getConnectionType();
if (deviceConn == ConnectionType.SONYWA && d.isSynced())
{
if (d.isDS4Idle())
{
d.DisconnectDongle();
ReleaseActionKeys(action, device);
actionDone[index].dev[device] = false;
action.pressRelease = false;
}
}
}
else if (action.typeID != SpecialAction.ActionTypeId.Key && else if (action.typeID != SpecialAction.ActionTypeId.Key &&
action.typeID != SpecialAction.ActionTypeId.XboxGameDVR && action.typeID != SpecialAction.ActionTypeId.XboxGameDVR &&
action.typeID != SpecialAction.ActionTypeId.MultiAction) action.typeID != SpecialAction.ActionTypeId.MultiAction)
@ -2625,6 +2624,27 @@ namespace DS4Windows
} }
} }
private static void ReleaseActionKeys(SpecialAction action, int device)
{
//foreach (DS4Controls dc in action.trigger)
for (int i = 0, arlen = action.trigger.Count; i < arlen; i++)
{
DS4Controls dc = action.trigger[i];
DS4ControlSettings dcs = getDS4CSetting(device, dc);
if (dcs.action != null)
{
if (dcs.actionType == DS4ControlSettings.ActionType.Key)
InputMethods.performKeyRelease((ushort)dcs.action);
else if (dcs.actionType == DS4ControlSettings.ActionType.Macro)
{
int[] keys = (int[])dcs.action;
for (int j = 0, keysLen = keys.Length; j < keysLen; j++)
InputMethods.performKeyRelease((ushort)keys[j]);
}
}
}
}
// Play macro as a background task. Optionally the new macro play waits for completion of a previous macro execution (synchronized macro special action). // Play macro as a background task. Optionally the new macro play waits for completion of a previous macro execution (synchronized macro special action).
// Macro steps are defined either as macrostr string value, macroLst list<int> object or as macroArr integer array. Only one of these should have a valid macro definition when this method is called. // Macro steps are defined either as macrostr string value, macroLst list<int> object or as macroArr integer array. Only one of these should have a valid macro definition when this method is called.
// If the macro definition is a macroStr string value then it will be converted as integer array on the fl. If steps are already defined as list or array of integers then there is no need to do type cast conversion. // If the macro definition is a macroStr string value then it will be converted as integer array on the fl. If steps are already defined as list or array of integers then there is no need to do type cast conversion.