Skip to content

Commit

Permalink
Updated & ability to turn off steamVR check for hover buttons incase …
Browse files Browse the repository at this point in the history
…detection fails
  • Loading branch information
KrisIsBackAU committed Mar 12, 2023
1 parent f43d483 commit 1da78c4
Show file tree
Hide file tree
Showing 14 changed files with 125 additions and 65 deletions.
33 changes: 17 additions & 16 deletions Oculus VR Dash Manager/Dashes/Dash Manager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Diagnostics;
using System.IO;
using System.ServiceProcess;
using System.Threading;

namespace OVR_Dash_Manager.Dashes
{
Expand Down Expand Up @@ -172,21 +171,23 @@ public static Boolean Activate_FastTransition(Dash_Type Dash)
}
else
{
ServiceController Service = new ServiceController("OVRService");
Boolean OVRServiceRunning = Running(Service.Status);

try
{
Debug.WriteLine("Stopping OVRService");

Service.Stop();
if (OVRServiceRunning)
Service.Start();
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
Software.Steam.Close_SteamVR_ResetLink();

//ServiceController Service = new ServiceController("OVRService");
//Boolean OVRServiceRunning = Running(Service.Status);

//try
//{
// Debug.WriteLine("Stopping OVRService");

// Service.Stop();
// if (OVRServiceRunning)
// Service.Start();
//}
//catch (Exception ex)
//{
// Debug.WriteLine(ex.Message);
//}
}
return Activated;
}
Expand Down
2 changes: 1 addition & 1 deletion Oculus VR Dash Manager/Dashes/OVR_Dash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public bool Activate_Dash_Fast_v2()
private bool SwitchFiles(String NewFile, String OldFile)
{
bool Activated = false;

String DashPath = Path.Combine(Software.Oculus.Oculus_Dash_Directory, DashFileName);
if (File.Exists(NewFile))
{
Expand Down
10 changes: 6 additions & 4 deletions Oculus VR Dash Manager/Forms/Settings/frm_Settings_v2.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:OVR_Dash_Manager.Forms.Settings"
mc:Ignorable="d"
Title="Settings" Width="863" Height="547" ResizeMode="CanMinimize" WindowStartupLocation="CenterScreen">
Title="Settings" Width="863" Height="581.283" ResizeMode="CanMinimize" WindowStartupLocation="CenterScreen">

<Window.Resources>
<ResourceDictionary>
Expand All @@ -16,15 +16,17 @@
</Window.Resources>

<Grid x:Name="gd_Settings" Background="#FF212121">
<GroupBox Header="Dash Manager Settings" Margin="10,10,10,0" Height="136" VerticalAlignment="Top">
<GroupBox Header="Dash Manager Settings" Margin="10,10,10,0" Height="177" VerticalAlignment="Top">
<Grid Margin="0">
<local:uc_Setting Setting="AlwaysOnTop" Margin="10,3,0,0" HorizontalAlignment="Left" Width="150" Height="30" VerticalAlignment="Top" />
<Label Content="Keep Dash Manager On Top" Margin="166,3,10,0" VerticalAlignment="Top" Height="30" />
<local:uc_Setting Setting="FastSwitch" Margin="10,41,0,0" HorizontalAlignment="Left" Width="150" Height="30" VerticalAlignment="Top" />
<Label Content="Switch Dashes with out Stopping Link (Cable &amp; Air Link Supported)" HorizontalAlignment="Left" Margin="166,41,0,0" VerticalAlignment="Top" Height="30" />
<local:uc_Setting Setting="Ignore_SteamVR_Status_HoverButtonAction" Margin="10,79,0,0" HorizontalAlignment="Left" Width="150" Height="30" VerticalAlignment="Top" />
<Label Content="Ignore SteamVR Status for Hover Button Actions" HorizontalAlignment="Left" Margin="166,79,0,0" VerticalAlignment="Top" Height="30" />
</Grid>
</GroupBox>
<GroupBox Header="Oculus Settings" Margin="10,151,10,0" Height="210" VerticalAlignment="Top">
<GroupBox Header="Oculus Settings" Margin="10,192,10,0" Height="210" VerticalAlignment="Top">
<Grid Margin="0">
<local:uc_Setting Setting="RunOculusClientOnStartup" Margin="10,8,0,0" HorizontalAlignment="Left" Width="150" Height="30" VerticalAlignment="Top" />
<Label Content="Start Oculus Client Software - When Dash Manager Launches" Margin="165,8,10,0" VerticalAlignment="Top" Height="30" />
Expand All @@ -36,7 +38,7 @@
<Label Content="Stop Oculus Services - When Manager Exits (When Oculus Services set to Manual Startup)" Margin="165,122,10,0" VerticalAlignment="Top" Height="30" />
</Grid>
</GroupBox>
<GroupBox Header="Steam / SteamVR Settings" Margin="10,366,10,0" Height="135" VerticalAlignment="Top">
<GroupBox Header="Steam / SteamVR Settings" Margin="10,407,10,0" Height="135" VerticalAlignment="Top">
<Grid Margin="0">
<local:uc_Setting Setting="SteamVRFocusFix" Margin="10,3,0,0" HorizontalAlignment="Left" Width="150" Height="30" VerticalAlignment="Top" />
<Label Content="Fix SteamVR Admin Program Focus Issue When it Occurs (Task View Glitch)" Margin="166,3,10,0" VerticalAlignment="Top" Height="30" />
Expand Down
14 changes: 1 addition & 13 deletions Oculus VR Dash Manager/Forms/frm_SteamVR_Settings.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows;

namespace OVR_Dash_Manager.Forms
{
Expand Down
5 changes: 0 additions & 5 deletions Oculus VR Dash Manager/Forms/frm_TestWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
using System.Timers;
using System.Windows;
using WindowsInput;
using WindowsInput.Native;

namespace OVR_Dash_Manager.Forms
{
Expand Down
3 changes: 0 additions & 3 deletions Oculus VR Dash Manager/Functions/Native Functions.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace OVR_Dash_Manager.Functions
Expand Down
2 changes: 1 addition & 1 deletion Oculus VR Dash Manager/Hover Button.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void SetHovering()
{
Hovering = true;
Hover_Started = DateTime.Now;
Bar.Value = 0;
Bar.Value = 10;
}

public void StopHovering()
Expand Down
2 changes: 2 additions & 0 deletions Oculus VR Dash Manager/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@
</UniformGrid>
<Label Content="OpenXR Runtime:" HorizontalAlignment="Left" Margin="479,0,0,48" VerticalAlignment="Bottom" Height="30" Width="168" HorizontalContentAlignment="Center"/>
<Button x:Name="btn_OpenSteamVRSettings" Content="SteamVR Settings" HorizontalAlignment="Left" Margin="10,0,0,85" VerticalAlignment="Bottom" Click="btn_OpenSteamVRSettings_Click" Height="22" Width="150" IsEnabled="False" />
<Label Content="SteamVR Status:" HorizontalAlignment="Left" Margin="165,0,0,85" VerticalAlignment="Bottom" Height="30" Width="114" HorizontalContentAlignment="Center"/>
<Label x:Name="lbl_SteamVR_Status" Content="N/A" HorizontalAlignment="Left" Margin="284,0,0,85" VerticalAlignment="Bottom" Height="30" Width="114" HorizontalContentAlignment="Center"/>
</Grid>
</Window>
22 changes: 18 additions & 4 deletions Oculus VR Dash Manager/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public MainWindow()
InitializeComponent();

Title += " v" + typeof(MainWindow).Assembly.GetName().Version;
Title += " - Early Build";
Topmost = Properties.Settings.Default.AlwaysOnTop;
}

Expand All @@ -41,12 +40,22 @@ private void Window_Loaded(object sender, RoutedEventArgs e)
Generate_Hover_Buttons();

Dashes.Dash_Manager.PassMainForm(this);
Software.Steam.Steam_VR_Running_State_Changed_Event += Steam_Steam_VR_Running_State_Changed_Event;

Thread Start = new Thread(Startup);
Start.IsBackground = true;
Start.Start();
}

private void Steam_Steam_VR_Running_State_Changed_Event()
{

Functions_Old.DoAction(this, new Action(delegate ()
{
lbl_SteamVR_Status.Content = Software.Steam.Steam_VR_Server_Running ? "Running" : "N/A";
}));
}

private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
Functions.Process_Watcher.Stop();
Expand Down Expand Up @@ -146,6 +155,8 @@ private void Generate_Hover_Buttons()
{
Oculus_Dash = new Hover_Button { Hover_Complete_Action = Oculus_Dash_Hover_Activate, Bar = pb_Normal, Check_SteamVR = true, Hovered_Seconds_To_Activate = Properties.Settings.Default.Hover_Activation_Time };
Exit_Link = new Hover_Button { Hover_Complete_Action = Exit_Link_Hover_Activate, Bar = pb_Exit, Check_SteamVR = true, Hovered_Seconds_To_Activate = Properties.Settings.Default.Hover_Activation_Time };
pb_Normal.Maximum = Properties.Settings.Default.Hover_Activation_Time * 1000;
pb_Exit.Maximum = Properties.Settings.Default.Hover_Activation_Time * 1000;
}

private void Check_Hover(object sender, ElapsedEventArgs args)
Expand Down Expand Up @@ -192,7 +203,7 @@ private void Oculus_Dash_Hover_Activate()
private void Exit_Link_Hover_Activate()
{
Exit_Link.Bar.Value = 0;
btn_ActivateDash_Click(btn_ExitOculusLink, null);
Software.Steam.Close_SteamVR_ResetLink();
}

private void Update_Dash_Buttons()
Expand Down Expand Up @@ -318,8 +329,11 @@ private void CheckHovering(Hover_Button Button)
{
if (Button.Check_SteamVR)
{
if (!Software.Steam.Steam_VR_Server_Running)
return;
if (!Properties.Settings.Default.Ignore_SteamVR_Status_HoverButtonAction)
{
if (!Software.Steam.Steam_VR_Server_Running)
return;
}
}

TimeSpan Passed = DateTime.Now.Subtract(Button.Hover_Started);
Expand Down
6 changes: 3 additions & 3 deletions Oculus VR Dash Manager/Oculus VR Dash Manager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
<Copyright>KrisIsBack (AU)</Copyright>
<PackageIcon>Icon.ico</PackageIcon>
<PackageIconUrl />
<Version>1.0.3.0</Version>
<Version>1.0.3.1</Version>
<Authors>KrisIsBack (AU)</Authors>
<PackageReleaseNotes>Official &amp; Oculus Killer - Supported with Updates
https://github.com/KrisIsBackAU/Oculus-VR-Dash-Manager</PackageReleaseNotes>
<NeutralLanguage>en-AU</NeutralLanguage>
<RepositoryUrl>https://github.com/KrisIsBackAU/Oculus-VR-Dash-Manager</RepositoryUrl>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AssemblyVersion>1.0.3.0</AssemblyVersion>
<FileVersion>1.0.3.0</FileVersion>
<AssemblyVersion>1.0.3.1</AssemblyVersion>
<FileVersion>1.0.3.1</FileVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>

Expand Down
12 changes: 12 additions & 0 deletions Oculus VR Dash Manager/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Oculus VR Dash Manager/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@
<Setting Name="Hover_Activation_Time" Type="System.Int32" Scope="User">
<Value Profile="(Default)">3</Value>
</Setting>
<Setting Name="Ignore_SteamVR_Status_HoverButtonAction" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
22 changes: 18 additions & 4 deletions Oculus VR Dash Manager/Software/Oculus Link.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OVR_Dash_Manager.Software
{
Expand All @@ -23,6 +19,24 @@ public static void ResetLink()
}
}

public static void StopLink()
{
if (Service_Manager.GetState("OVRService") == "Running")
{
Steam.ManagerCalledExit = true;

Service_Manager.StopService("OVRService");

Steam.ManagerCalledExit = true;
}
}

public static void StartLink()
{
if (Service_Manager.GetState("OVRService") != "Running")
Service_Manager.StartService("OVRService");
}

public static void SetToOculusRunTime()
{
if (Oculus.Oculus_Is_Installed)
Expand Down
54 changes: 43 additions & 11 deletions Oculus VR Dash Manager/Software/Steam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Timers;

namespace OVR_Dash_Manager.Software
Expand All @@ -25,9 +24,9 @@ public static class Steam

public static bool Steam_VR_Monitor_Running { get; private set; }

private delegate void Steam_VR_Running_State_Changed();
public delegate void Steam_VR_Running_State_Changed();

private static event Steam_VR_Running_State_Changed Steam_VR_Running_State_Changed_Event;
public static event Steam_VR_Running_State_Changed Steam_VR_Running_State_Changed_Event;

public static Boolean ManagerCalledExit = false;

Expand Down Expand Up @@ -65,16 +64,36 @@ private static void Steam_Steam_VR_Running_State_Changed_Event()
{
if (Properties.Settings.Default.ExitLinkOn_UserExit_SteamVR)
{
Close_SteamVR_Server();
Software.Oculus_Link.ResetLink();
Close_SteamVR_Server();
Close_SteamVR_ResetLink();
}
}
}

ManagerCalledExit = false;
}

public static void Close_SteamVR_ResetLink()
{
Close_SteamVR_Server();

Software.Oculus_Link.StopLink();
Close_SteamVR_Server();

Thread pInAMoment = new Thread(StartLinkInAMoment);
pInAMoment.Start();
}

private static void StartLinkInAMoment()
{
Thread.Sleep(2000);
ManagerCalledExit = true;
Close_SteamVR_Server();
Software.Oculus_Link.StartLink();
Thread.Sleep(2000);
ManagerCalledExit = true;
Close_SteamVR_Server();
}

public static void CheckInstalled()
{
string LocalAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
Expand Down Expand Up @@ -194,17 +213,30 @@ public static void Close_SteamVR_Server()
if (Steam_VR_Server_Running)
{
Process[] vrServer = Process.GetProcessesByName("vrserver");

if (vrServer.Length == 1)
vrServer[0].Kill();
}

Process[] vrmonitor = Process.GetProcessesByName("vrmonitor");
if (vrmonitor.Length == 1)
CloseSteamVRMonitor();
}

private static void CloseSteamVRMonitor()
{
Process[] vrmonitor = Process.GetProcessesByName("vrmonitor");
if (vrmonitor.Length == 1)
{
if (vrmonitor[0].MainWindowHandle != IntPtr.Zero)
{
if (vrmonitor[0].MainWindowHandle != IntPtr.Zero)
try
{
vrmonitor[0].CloseMainWindow();
}
catch (Exception)
{
try
{
vrmonitor[0].CloseMainWindow();
vrmonitor[0].Kill();
}
catch (Exception)
{
Expand Down

0 comments on commit 1da78c4

Please sign in to comment.