@@ -30,7 +30,7 @@ internal class SetupData : ICoreSetupData
3030
3131internal class DriverInstaller : IDependencyInstaller
3232{
33- public IDependencyInstaller . ILocalizationHost Host { get ; set ; }
33+ public IDependencyInstaller . ILocalizationHost Host { get ; set ; }
3434
3535 public List < IDependency > ListDependencies ( )
3636 {
@@ -44,7 +44,10 @@ public List<IDependency> ListDependencies()
4444 ] ;
4545 }
4646
47- public List < IFix > ListFixes ( ) => [ ] ;
47+ public List < IFix > ListFixes ( )
48+ {
49+ return [ ] ;
50+ }
4851}
4952
5053internal class VrDriver : IDependency
@@ -107,58 +110,7 @@ public async Task<bool> Install(IProgress<InstallationProgress> progress, Cancel
107110
108111 /* 1 */
109112
110- // Create a placeholder for the driver path
111- var localAmethystDriverPath = "" ;
112-
113- // Check whether Amethyst is installed as a package
114- if ( ! PackageUtils . IsAmethystPackaged )
115- {
116- // Optionally change to the other variant
117- if ( ! new DirectoryInfo ( localAmethystDriverPath ) . Exists )
118- {
119- // Get plugin_OpenVR.dll parent path
120- var parentPath = Directory . GetParent ( Assembly . GetExecutingAssembly ( ) . Location ) ;
121-
122- // Search for driver manifests, try max 2 times
123- for ( var i = 0 ; i < 2 ; i ++ )
124- {
125- // Double that to get Amethyst exe path
126- if ( parentPath ? . Parent != null ) parentPath = parentPath . Parent ;
127- if ( parentPath is null ) goto p_search_loop_end ;
128-
129- // Find all vr driver manifests there
130- var allLocalDriverManifests = Directory . GetFiles ( parentPath . ToString ( ) ,
131- "driver.vrdrivermanifest" , SearchOption . AllDirectories ) ;
132-
133- // For each found manifest, check if there is an ame driver dll inside
134- foreach ( var localDriverManifest in allLocalDriverManifests )
135- if ( File . Exists ( Path . Combine ( Directory . GetParent ( localDriverManifest ) ! . ToString ( ) , "bin" ,
136- "win64" ,
137- "driver_Amethyst.dll" ) ) )
138- {
139- // We've found it! Now cache it and break free
140- localAmethystDriverPath = Directory . GetParent ( localDriverManifest ) ! . ToString ( ) ;
141- goto p_search_loop_end ;
142- }
143- // Else redo once more & then check
144- }
145- }
146-
147- // End of the searching loop
148- p_search_loop_end :
149-
150- // If there's none (still), cry about it and abort
151- if ( string . IsNullOrEmpty ( localAmethystDriverPath ) || ! new DirectoryInfo ( localAmethystDriverPath ) . Exists )
152- {
153- progress . Report ( new InstallationProgress
154- {
155- IsIndeterminate = true ,
156- StageTitle = Host ? . RequestLocalizedString ( "/CrashHandler/ReRegister/DriverNotFound" ) !
157- } ) ;
158-
159- return false ; // Hide and exit the handler
160- }
161- }
113+ await PathsHandler . Setup ( ) ;
162114
163115 /* 2 */
164116
@@ -184,29 +136,26 @@ public async Task<bool> Install(IProgress<InstallationProgress> progress, Cancel
184136 /* 1.1 Copy packaged Amethyst drivers */
185137
186138 // Check whether Amethyst is installed as a package
187- if ( PackageUtils . IsAmethystPackaged )
188- {
189- // Copy all driver files to Amethyst's local data folder
190- new DirectoryInfo ( Path . Join ( Directory . GetParent (
191- Assembly . GetExecutingAssembly ( ) . Location ) ! . FullName , "Driver" , "Amethyst" ) )
192- . CopyToFolder ( ( await ApplicationData . Current . LocalFolder . CreateFolderAsync (
193- "Amethyst" , CreationCollisionOption . OpenIfExists ) ) . Path ) ;
139+ // Copy all driver files to Amethyst's local data folder
140+ new DirectoryInfo ( Path . Join ( Directory . GetParent (
141+ Assembly . GetExecutingAssembly ( ) . Location ) ! . FullName , "Driver" , "Amethyst" ) )
142+ . CopyToFolder ( ( await PathsHandler . LocalFolder . CreateFolderAsync (
143+ "Amethyst" , CreationCollisionOption . OpenIfExists ) ) . Path ) ;
194144
195- // Assume it's done now and get the path
196- localAmethystDriverPath = Path . Join ( PackageUtils . GetAmethystAppDataPath ( ) , "Amethyst" ) ;
145+ // Assume it's done now and get the path
146+ var localAmethystDriverPath = Path . Join ( PathsHandler . LocalFolder . Path , "Amethyst" ) ;
197147
198- // If there's none (still), cry about it and abort
199- if ( string . IsNullOrEmpty ( localAmethystDriverPath ) || ! Directory . Exists ( localAmethystDriverPath ) )
148+ // If there's none (still), cry about it and abort
149+ if ( string . IsNullOrEmpty ( localAmethystDriverPath ) || ! Directory . Exists ( localAmethystDriverPath ) )
150+ {
151+ Host ? . Log ( $ "Copied driver not present at expectant path of: { localAmethystDriverPath } ") ;
152+ progress . Report ( new InstallationProgress
200153 {
201- Host ? . Log ( $ "Copied driver not present at expectant path of: { localAmethystDriverPath } ") ;
202- progress . Report ( new InstallationProgress
203- {
204- IsIndeterminate = true ,
205- StageTitle = Host ? . RequestLocalizedString ( "/CrashHandler/ReRegister/DriverNotFound" ) !
206- } ) ;
154+ IsIndeterminate = true ,
155+ StageTitle = Host ? . RequestLocalizedString ( "/CrashHandler/ReRegister/DriverNotFound" ) !
156+ } ) ;
207157
208- return false ; // Hide and exit the handler
209- }
158+ return false ; // Hide and exit the handler
210159 }
211160
212161 /* 2.5 */
@@ -266,7 +215,8 @@ public async Task<bool> Install(IProgress<InstallationProgress> progress, Cancel
266215 . Where ( externalDriver => externalDriver . Contains ( "Amethyst" ) ) )
267216 {
268217 // Don't un-register the already-existent one
269- if ( externalDriver == localAmethystDriverPath )
218+ if ( externalDriver == localAmethystDriverPath ||
219+ externalDriver == localAmethystDriverPath . ShortPath ( ) )
270220 {
271221 isLocalAmethystDriverRegistered = true ;
272222 continue ; // Don't report it
@@ -289,7 +239,8 @@ public async Task<bool> Install(IProgress<InstallationProgress> progress, Cancel
289239 if ( amethystDriverPathsList . Any ( ) )
290240 {
291241 foreach ( var amethystDriverPath in amethystDriverPathsList . Where ( amethystDriverPath =>
292- amethystDriverPath != localAmethystDriverPath ) )
242+ amethystDriverPath != localAmethystDriverPath &&
243+ amethystDriverPath != localAmethystDriverPath . ShortPath ( ) ) )
293244 openVrPaths . external_drivers . Remove ( amethystDriverPath ) ; // Un-register
294245
295246 // Save it
@@ -315,12 +266,13 @@ public async Task<bool> Install(IProgress<InstallationProgress> progress, Cancel
315266 try // Try-Catch it
316267 {
317268 // Register the local Amethyst Driver via OpenVRPaths
318- openVrPaths . external_drivers . Add ( localAmethystDriverPath ) ;
269+ openVrPaths . external_drivers . Add ( localAmethystDriverPath . ShortPath ( ) ) ;
319270 openVrPaths . Write ( ) ; // Save it
320271
321272 // If failed, cry about it and abort
322273 var openVrPathsCheck = OpenVrPaths . Read ( ) ;
323- if ( ! openVrPathsCheck . external_drivers . Contains ( localAmethystDriverPath ) )
274+ if ( ! openVrPathsCheck . external_drivers . Contains ( localAmethystDriverPath ) &&
275+ ! openVrPathsCheck . external_drivers . Contains ( localAmethystDriverPath . ShortPath ( ) ) )
324276 {
325277 progress . Report ( new InstallationProgress
326278 {
@@ -356,8 +308,8 @@ public async Task<bool> Install(IProgress<InstallationProgress> progress, Cancel
356308 steamVrSettings . Add ( "driver_Amethyst" ,
357309 new JsonObject
358310 {
359- new ( "enable" , JsonValue . CreateBooleanValue ( true ) ) ,
360- new ( "blocked_by_safe_mode" , JsonValue . CreateBooleanValue ( false ) )
311+ new KeyValuePair < string , IJsonValue > ( "enable" , JsonValue . CreateBooleanValue ( true ) ) ,
312+ new KeyValuePair < string , IJsonValue > ( "blocked_by_safe_mode" , JsonValue . CreateBooleanValue ( false ) )
361313 } ) ;
362314
363315 await File . WriteAllTextAsync ( resultPaths . Path . VrSettingsPath , steamVrSettings . ToString ( ) ,
0 commit comments