Fixed auto profile use for hotplugging

Related to issue #578
This commit is contained in:
Travis Nickles 2019-03-05 05:14:39 -06:00
parent 098bbf057d
commit 8d4d4b0758
3 changed files with 29 additions and 18 deletions

View File

@ -364,6 +364,8 @@ namespace DS4Windows
device.SyncChange += this.On_SyncChange;
device.SyncChange += DS4Devices.UpdateSerial;
device.SerialChange += this.On_SerialChange;
if (!useTempProfile[i])
{
if (device.isValidSerial() && containsLinkedProfile(device.getMacAddress()))
{
ProfilePath[i] = getLinkedProfile(device.getMacAddress());
@ -373,8 +375,10 @@ namespace DS4Windows
ProfilePath[i] = OlderProfilePath[i];
}
touchPad[i] = new Mouse(i, device);
LoadProfile(i, false, this, false, false);
}
touchPad[i] = new Mouse(i, device);
device.LightBarColor = getMainColor(i);
if (!getDInputOnly(i) && device.isSynced())
@ -605,6 +609,8 @@ namespace DS4Windows
device.SyncChange += this.On_SyncChange;
device.SyncChange += DS4Devices.UpdateSerial;
device.SerialChange += this.On_SerialChange;
if (!useTempProfile[Index])
{
if (device.isValidSerial() && containsLinkedProfile(device.getMacAddress()))
{
ProfilePath[Index] = getLinkedProfile(device.getMacAddress());
@ -614,8 +620,10 @@ namespace DS4Windows
ProfilePath[Index] = OlderProfilePath[Index];
}
touchPad[Index] = new Mouse(Index, device);
LoadProfile(Index, false, this, false, false);
}
touchPad[Index] = new Mouse(Index, device);
device.LightBarColor = getMainColor(Index);
int tempIdx = Index;
@ -1093,7 +1101,7 @@ namespace DS4Windows
cState = Mapping.SetCurveAndDeadzone(ind, cState, TempState[ind]);
if (!recordingMacro && (!string.IsNullOrEmpty(tempprofilename[ind]) ||
if (!recordingMacro && (useTempProfile[ind] ||
containsCustomAction(ind) || containsCustomExtras(ind) ||
getProfileActionCount(ind) > 0))
{

View File

@ -1317,7 +1317,7 @@ namespace DS4Windows
//DS4StateFieldMapping outputfieldMapping = new DS4StateFieldMapping(cState, eState, tp);
SyntheticState deviceState = Mapping.deviceState[device];
if (getProfileActionCount(device) > 0 || !string.IsNullOrEmpty(tempprofilename[device]))
if (getProfileActionCount(device) > 0 || useTempProfile[device])
MapCustomAction(device, cState, MappedState, eState, tp, ctrl, fieldMapping, outputfieldMapping);
if (ctrl.DS4Controllers[device] == null) return;
@ -1896,7 +1896,7 @@ namespace DS4Windows
{
actionFound = true;
if (!actionDone[index].dev[device] && string.IsNullOrEmpty(tempprofilename[device]))
if (!actionDone[index].dev[device] && !useTempProfile[device])
{
actionDone[index].dev[device] = true;
untriggeraction[device] = action;
@ -2286,7 +2286,7 @@ namespace DS4Windows
if ((action.controls == action.ucontrols && !actionDone[index].dev[device]) || //if trigger and end trigger are the same
action.controls != action.ucontrols)
{
if (!string.IsNullOrEmpty(tempprofilename[device]))
if (useTempProfile[device])
{
//foreach (DS4Controls dc in action.uTrigger)
for (int i = 0, arlen = action.uTrigger.Count; i < arlen; i++)

View File

@ -237,6 +237,7 @@ namespace DS4Windows
public static bool runHotPlug = false;
public const int XINPUT_UNPLUG_SETTLE_TIME = 250; // Inhibit races that occur with the asynchronous teardown of ScpVBus -> X360 driver instance.
public static string[] tempprofilename = new string[5] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty };
public static bool[] useTempProfile = new bool[5] { false, false, false, false, false };
public static bool[] tempprofileDistance = new bool[5] { false, false, false, false, false };
public static bool[] useDInputOnly = new bool[5] { true, true, true, true, true };
public static bool[] linkedProfileCheck = new bool[4] { true, true, true, true };
@ -1308,6 +1309,7 @@ namespace DS4Windows
{
m_Config.LoadProfile(device, launchprogram, control, "", xinputChange, postLoad);
tempprofilename[device] = string.Empty;
useTempProfile[device] = false;
tempprofileDistance[device] = false;
}
@ -1316,6 +1318,7 @@ namespace DS4Windows
{
m_Config.LoadProfile(device, launchprogram, control, appdatapath + @"\Profiles\" + name + ".xml");
tempprofilename[device] = name;
useTempProfile[device] = true;
tempprofileDistance[device] = name.ToLower().Contains("distance");
}