Merge branch 'mika-n-AutoProfileTweaks' into jay

This commit is contained in:
Travis Nickles 2020-01-04 15:32:33 -06:00
commit 06e64292ce
6 changed files with 33 additions and 6 deletions

View File

@ -98,12 +98,20 @@ namespace DS4WinWPF
for (int j = 0; j < 4; j++) for (int j = 0; j < 4; j++)
{ {
if (Global.useTempProfile[j]) if (Global.useTempProfile[j])
{
if (DS4Windows.Global.AutoProfileRevertDefaultProfile)
{ {
if (autoProfileDebugLogLevel > 0) if (autoProfileDebugLogLevel > 0)
DS4Windows.AppLogger.LogToGui($"DEBUG: Auto-Profile. RestoreProfile Controller {j + 1}={Global.ProfilePath[j]} (default)", false); DS4Windows.AppLogger.LogToGui($"DEBUG: Auto-Profile. Unknown process. Reverting to default profile. Controller {j + 1}={Global.ProfilePath[j]} (default)", false);
Global.LoadProfile(j, false, Program.rootHub); Global.LoadProfile(j, false, Program.rootHub);
} }
else
{
if (autoProfileDebugLogLevel > 0)
DS4Windows.AppLogger.LogToGui($"DEBUG: Auto-Profile. Unknown process. Existing profile left as active. Controller {j + 1}={Global.tempprofilename[j]}", false);
}
}
} }
if (turnOffTemp) if (turnOffTemp)

View File

@ -965,6 +965,12 @@ namespace DS4Windows
get { return m_Config.customSteamFolder; } get { return m_Config.customSteamFolder; }
} }
public static bool AutoProfileRevertDefaultProfile
{
set { m_Config.autoProfileRevertDefaultProfile = value; }
get { return m_Config.autoProfileRevertDefaultProfile; }
}
// controller/profile specfic values // controller/profile specfic values
public static int[] ButtonMouseSensitivity => m_Config.buttonMouseSensitivity; public static int[] ButtonMouseSensitivity => m_Config.buttonMouseSensitivity;
@ -2208,6 +2214,9 @@ namespace DS4Windows
OutContType.X360, OutContType.X360, OutContType.X360, OutContType.X360,
OutContType.X360, OutContType.X360 }; OutContType.X360, OutContType.X360 };
// TRUE=AutoProfile reverts to default profile if current foreground process is unknown, FALSE=Leave existing profile active when a foreground proces is unknown (ie. no matching auto-profile rule)
public bool autoProfileRevertDefaultProfile = true;
bool tempBool = false; bool tempBool = false;
public BackingStore() public BackingStore()
@ -3959,6 +3968,8 @@ namespace DS4Windows
catch { missingSetting = true; } catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/Profile/CustomSteamFolder"); customSteamFolder = Item.InnerText; } try { Item = m_Xdoc.SelectSingleNode("/Profile/CustomSteamFolder"); customSteamFolder = Item.InnerText; }
catch { missingSetting = true; } catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/Profile/AutoProfileRevertDefaultProfile"); Boolean.TryParse(Item.InnerText, out autoProfileRevertDefaultProfile); }
catch { missingSetting = true; }
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
@ -4031,6 +4042,7 @@ namespace DS4Windows
XmlNode xmlUDPServListenAddress = m_Xdoc.CreateNode(XmlNodeType.Element, "UDPServerListenAddress", null); xmlUDPServListenAddress.InnerText = udpServListenAddress; Node.AppendChild(xmlUDPServListenAddress); XmlNode xmlUDPServListenAddress = m_Xdoc.CreateNode(XmlNodeType.Element, "UDPServerListenAddress", null); xmlUDPServListenAddress.InnerText = udpServListenAddress; Node.AppendChild(xmlUDPServListenAddress);
XmlNode xmlUseCustomSteamFolder = m_Xdoc.CreateNode(XmlNodeType.Element, "UseCustomSteamFolder", null); xmlUseCustomSteamFolder.InnerText = useCustomSteamFolder.ToString(); Node.AppendChild(xmlUseCustomSteamFolder); XmlNode xmlUseCustomSteamFolder = m_Xdoc.CreateNode(XmlNodeType.Element, "UseCustomSteamFolder", null); xmlUseCustomSteamFolder.InnerText = useCustomSteamFolder.ToString(); Node.AppendChild(xmlUseCustomSteamFolder);
XmlNode xmlCustomSteamFolder = m_Xdoc.CreateNode(XmlNodeType.Element, "CustomSteamFolder", null); xmlCustomSteamFolder.InnerText = customSteamFolder; Node.AppendChild(xmlCustomSteamFolder); XmlNode xmlCustomSteamFolder = m_Xdoc.CreateNode(XmlNodeType.Element, "CustomSteamFolder", null); xmlCustomSteamFolder.InnerText = customSteamFolder; Node.AppendChild(xmlCustomSteamFolder);
XmlNode xmlAutoProfileRevertDefaultProfile = m_Xdoc.CreateNode(XmlNodeType.Element, "AutoProfileRevertDefaultProfile", null); xmlAutoProfileRevertDefaultProfile.InnerText = autoProfileRevertDefaultProfile.ToString(); Node.AppendChild(xmlAutoProfileRevertDefaultProfile);
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {

View File

@ -120,6 +120,7 @@
<TextBox Text="{Binding Title, UpdateSourceTrigger=LostFocus}" Margin="{StaticResource spaceMargin}" /> <TextBox Text="{Binding Title, UpdateSourceTrigger=LostFocus}" Margin="{StaticResource spaceMargin}" />
<Border Height="4" Background="#FFDADADA" Margin="0,10,0,0" /> <Border Height="4" Background="#FFDADADA" Margin="0,10,0,0" />
</StackPanel> </StackPanel>
<CheckBox x:Name="revertDefaultProfileOnUnknownCk" Content="Revert to default profile on unknown" Margin="0,10,0,0" IsChecked="{Binding RevertDefaultProfileOnUnknown}" />
<CheckBox x:Name="showAutoDebugCk" Content="Show auto-profile debug messages" Margin="0,10,0,0" Click="ShowAutoDebugCk_Click" /> <CheckBox x:Name="showAutoDebugCk" Content="Show auto-profile debug messages" Margin="0,10,0,0" Click="ShowAutoDebugCk_Click" />
</StackPanel> </StackPanel>
<DockPanel> <DockPanel>

View File

@ -67,6 +67,8 @@ namespace DS4WinWPF.DS4Forms
programListLV.DataContext = autoProfVM; programListLV.DataContext = autoProfVM;
programListLV.ItemsSource = autoProfVM.ProgramColl; programListLV.ItemsSource = autoProfVM.ProgramColl;
revertDefaultProfileOnUnknownCk.DataContext = autoProfVM;
autoProfVM.SearchFinished += AutoProfVM_SearchFinished; autoProfVM.SearchFinished += AutoProfVM_SearchFinished;
autoProfVM.CurrentItemChange += AutoProfVM_CurrentItemChange; autoProfVM.CurrentItemChange += AutoProfVM_CurrentItemChange;

View File

@ -46,7 +46,6 @@ namespace DS4WinWPF.DS4Forms
private AutoProfileHolder autoProfileHolder; private AutoProfileHolder autoProfileHolder;
private NonFormTimer hotkeysTimer; private NonFormTimer hotkeysTimer;
private NonFormTimer autoProfilesTimer; private NonFormTimer autoProfilesTimer;
private static int autoProfileDebugLogLevel = 0; // 0=Dont log debug messages about active process and window titles to GUI Log screen. 1=Show debug log messages
private AutoProfileChecker autoprofileChecker; private AutoProfileChecker autoprofileChecker;
private ProfileEditor editor; private ProfileEditor editor;
private bool preserveSize = true; private bool preserveSize = true;
@ -359,8 +358,7 @@ Suspend support not enabled.", true);
private void AutoProfControl_AutoDebugChanged(object sender, EventArgs e) private void AutoProfControl_AutoDebugChanged(object sender, EventArgs e)
{ {
autoprofileChecker.AutoProfileDebugLogLevel = autoprofileChecker.AutoProfileDebugLogLevel = autoProfControl.AutoDebug == true ? 1 : 0;
autoProfileDebugLogLevel = autoProfControl.AutoDebug == true ? 1 : 0;
} }
private void PowerEventArrive(object sender, EventArrivedEventArgs e) private void PowerEventArrive(object sender, EventArrivedEventArgs e)

View File

@ -50,6 +50,12 @@ namespace DS4WinWPF.DS4Forms.ViewModels
public delegate void AutoProfileStateHandler(AutoProfilesViewModel sender, bool state); public delegate void AutoProfileStateHandler(AutoProfilesViewModel sender, bool state);
public event AutoProfileStateHandler AutoProfileSystemChange; public event AutoProfileStateHandler AutoProfileSystemChange;
public bool RevertDefaultProfileOnUnknown
{
get => DS4Windows.Global.AutoProfileRevertDefaultProfile;
set => DS4Windows.Global.AutoProfileRevertDefaultProfile = value;
}
public AutoProfilesViewModel(AutoProfileHolder autoProfileHolder, ProfileList profileList) public AutoProfilesViewModel(AutoProfileHolder autoProfileHolder, ProfileList profileList)
{ {
programColl = new ObservableCollection<ProgramItem>(); programColl = new ObservableCollection<ProgramItem>();