This repository has been archived by the owner on Dec 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathinstaller.gd
90 lines (66 loc) · 2.6 KB
/
installer.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
extends Node
class_name Installer
export var db_path: NodePath;
onready var db: GDMLReactiveDatablock = get_node(db_path);
func get_runtime_path(extra_path: String) -> String:
var OVRInterface = OpenVRInterface.new();
return OVRInterface.get_runtime_path() + extra_path;
func get_driver_path() -> String:
return OS.get_executable_path().get_base_dir() + "\\driver";
func get_runtime_exe_path(exe: String) -> String:
var win64_dir = get_runtime_path("\\bin\\win64");
var dir = Directory.new();
if(dir.open(win64_dir) != OK):
db.fatal_error = "Failed! Could not find SteamVR runtime at " + win64_dir + ". Try manual installation.";
return "";
return win64_dir + "\\" + exe + ".exe";
func is_driver_installed() -> bool:
if(OS.is_debug_build()):
return true;
var output := [];
var result := OS.execute(get_runtime_exe_path("vrpathreg"),
[], true, output, true);
var driver_path = get_driver_path();
print(get_runtime_exe_path("vrpathreg"));
print(driver_path);
print(str(output));
return (driver_path in str(output));
func is_ascii(s: String) -> bool:
var ascii_v = s.to_ascii().get_string_from_ascii();
return ascii_v == s;
func generic_vrpathreg(command: String) -> void:
var driver_path := get_driver_path();
if(!is_ascii(driver_path)):
db.fatal_error = "Your path (" + driver_path + ") contains non-ASCII characters. Please move the folder to another directory.";
return;
var dir := Directory.new();
if(dir.open(driver_path) != OK):
db.fatal_error = "Could not open path " + driver_path + "! Ensure that it exists.";
return;
var output = [];
var result = OS.execute(get_runtime_exe_path("vrpathreg"),
[command, driver_path], true, output, true)
if(result == 0):
db.install_result = var2str([command, output]);
else:
db.fatal_error = "Something has went wrong! " + var2str([command, result, output]);
const OpenVRInterface = preload("res://GDN_bin/OpenVRInterface.gdns");
const key = "abb.owoTrackOverlay"
func install_manifest(b: bool) -> void:
var manifest_path = OS.get_executable_path().get_base_dir() + "\\" + "manifest.vrmanifest";
var interface := OpenVRInterface.new();
if(interface.is_initialized()):
var is_installed: bool = interface.is_installed(key);
if(is_installed && !b):
interface.set_auto_launch(key, false);
interface.remove_manifest(manifest_path);
elif(!is_installed && b):
interface.add_manifest(manifest_path, false);
if(b):
interface.set_auto_launch(key, true);
func install() -> void:
generic_vrpathreg("adddriver");
install_manifest(true);
func uninstall() -> void:
generic_vrpathreg("removedriver");
install_manifest(false);