Added "Revert to default profile on unknown process" option to auto-profile screen. If this is enabled then DS4Windows will revert back to default profile when an unknown process is the foreground app. If this option is unchecked then DS4Windows leaves the current profile as active on unknown foreground processes.

This commit is contained in:
mika-n 2019-12-29 01:34:41 +02:00
parent 1d637005cb
commit 39f94ef8d3
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

@ -966,6 +966,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;
@ -2209,6 +2215,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()
@ -3960,6 +3969,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++)
{ {
@ -4032,6 +4043,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

@ -45,7 +45,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;
@ -346,8 +345,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>();