Skip to content

Commit

Permalink
Re-Added 'Hide DS4 Controller' Option to the current build of DS4Win.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yohoki committed Nov 6, 2020
1 parent de16d9c commit e564cbb
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions DS4Windows/DS4Control/ControlService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,8 @@ public bool Start(bool showlog = true)

LogDebug($"Connection to ViGEmBus {Global.vigembusVersion} established");

DS4Devices.isExclusiveMode = getUseExclusiveMode(); //Re-enable Exclusive Mode

UpdateHidGuardAttributes();

//uiContext = tempui as SynchronizationContext;
Expand Down
16 changes: 16 additions & 0 deletions DS4Windows/DS4Control/ScpUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,17 @@ public static ulong CompileVersionNumber(int majorPart, int minorPart,
}

// general values
// -- Re-Enable Exclusive Mode Starts Here --
public static bool UseExclusiveMode
{
set { m_Config.useExclusiveMode = value; }
get { return m_Config.useExclusiveMode; }
} // -- Re-Enable Ex Mode Ends here

public static bool getUseExclusiveMode()
{
return m_Config.useExclusiveMode;
}
public static DateTime LastChecked
{
set { m_Config.lastChecked = value; }
Expand Down Expand Up @@ -2469,6 +2480,7 @@ public void setSZOutCurveMode(int index, int value)
new int[1] { -1 }, new int[1] { -1 }, new int[1] { -1 }, new int[1] { -1 }, new int[1] { -1 }, new int[1] { -1 } };
public int[] lsCurve = new int[Global.TEST_PROFILE_ITEM_COUNT] { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
public int[] rsCurve = new int[Global.TEST_PROFILE_ITEM_COUNT] { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
public Boolean useExclusiveMode = false; // Re-enable Ex Mode
public Int32 formWidth = 782;
public Int32 formHeight = 550;
public int formLocationX = 0;
Expand Down Expand Up @@ -4853,6 +4865,8 @@ public bool Load()

m_Xdoc.Load(m_Profile);

try { Item = m_Xdoc.SelectSingleNode("/Profile/useExclusiveMode"); Boolean.TryParse(Item.InnerText, out useExclusiveMode); } // Ex Mode
catch { missingSetting = true; } // Ex Mode
try { Item = m_Xdoc.SelectSingleNode("/Profile/startMinimized"); Boolean.TryParse(Item.InnerText, out startMinimized); }
catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/Profile/minimizeToTaskbar"); Boolean.TryParse(Item.InnerText, out minToTaskbar); }
Expand Down Expand Up @@ -5088,6 +5102,8 @@ public bool Save()
rootElement.SetAttribute("app_version", Global.exeversion);
rootElement.SetAttribute("config_version", Global.APP_CONFIG_VERSION.ToString());

// Ex Mode (+1 line)
XmlNode xmlUseExclNode = m_Xdoc.CreateNode(XmlNodeType.Element, "useExclusiveMode", null); xmlUseExclNode.InnerText = useExclusiveMode.ToString(); rootElement.AppendChild(xmlUseExclNode);
XmlNode xmlStartMinimized = m_Xdoc.CreateNode(XmlNodeType.Element, "startMinimized", null); xmlStartMinimized.InnerText = startMinimized.ToString(); rootElement.AppendChild(xmlStartMinimized);
XmlNode xmlminToTaskbar = m_Xdoc.CreateNode(XmlNodeType.Element, "minimizeToTaskbar", null); xmlminToTaskbar.InnerText = minToTaskbar.ToString(); rootElement.AppendChild(xmlminToTaskbar);
XmlNode xmlFormWidth = m_Xdoc.CreateNode(XmlNodeType.Element, "formWidth", null); xmlFormWidth.InnerText = formWidth.ToString(); rootElement.AppendChild(xmlFormWidth);
Expand Down
3 changes: 3 additions & 0 deletions DS4Windows/DS4Forms/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@
<WrapPanel.Resources>
<Thickness x:Key="spaceMargin" Left="4" Right="0" Bottom="8" Top="0" />
</WrapPanel.Resources>
<CheckBox x:Name="hideDS4ContCk" Content="Hide DS4 Controller" x:Uid="hideDS4Checkbox"
Margin="{StaticResource spaceMargin}" IsChecked="{Binding HideDS4Controller}" Click="HideDS4ContCk_Click" >
</CheckBox>
<CheckBox x:Name="swipeTouchCk" Content="Swipe Touchpad To Switch Profiles" Margin="{StaticResource spaceMargin}"
IsChecked="{Binding SwipeTouchSwitchProfile}"
ToolTip="{lex:Loc Resources:TwoFingerSwipe}" Click="SwipeTouchCk_Click" />
Expand Down
14 changes: 14 additions & 0 deletions DS4Windows/DS4Forms/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,21 @@ private void NewProfBtn_Click(object sender, RoutedEventArgs e)
mainTabCon.SelectedIndex = 1;
//controllerLV.Focus();
}
// Ex Mode Re-Enable
private async void HideDS4ContCk_Click(object sender, RoutedEventArgs e)
{
StartStopBtn.IsEnabled = false;
//bool checkStatus = hideDS4ContCk.IsChecked == true;
hideDS4ContCk.IsEnabled = false;
await Task.Run(() =>
{
App.rootHub.Stop();
App.rootHub.Start();
});

hideDS4ContCk.IsEnabled = true;
StartStopBtn.IsEnabled = true;
}
private async void UseUdpServerCk_Click(object sender, RoutedEventArgs e)
{
bool status = useUdpServerCk.IsChecked == true;
Expand Down
8 changes: 8 additions & 0 deletions DS4Windows/DS4Forms/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ namespace DS4WinWPF.DS4Forms.ViewModels
{
public class SettingsViewModel
{
// Re-Enable Ex Mode
public bool HideDS4Controller
{
get => DS4Windows.Global.UseExclusiveMode;
set => DS4Windows.Global.UseExclusiveMode = value;
}


public bool SwipeTouchSwitchProfile { get => DS4Windows.Global.SwipeProfiles;
set => DS4Windows.Global.SwipeProfiles = value; }

Expand Down

0 comments on commit e564cbb

Please sign in to comment.