-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
openvr_watcher.py
51 lines (38 loc) · 1.58 KB
/
openvr_watcher.py
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
import openvr
# https://github.com/cmbruns/pyopenvr
def main():
# Should we look for VR input to detect AFK state or should
# we just focus on getting the app title?
#
# Possibly useful endpoints:
# IVRApplications.getApplicationPropertyString
# IVRApplications.getApplicationPropertyString
if openvr.isHmdPresent():
print("VR head set found")
if openvr.isRuntimeInstalled():
print("Runtime is installed")
vr_system = openvr.init(openvr.VRApplication_Utility)
print(dir(vr_system))
print(openvr.runtimePath())
print(vr_system.getRecommendedRenderTargetSize())
print(vr_system.isDisplayOnDesktop())
def get_appkeys(ivrapps: openvr.IVRApplications):
appkeys = []
appcount = ivrapps.getApplicationCount()
for idx in range(appcount):
# TODO: I'm not sure how to handle buffer in this C++ interop context
pchAppKeyBuffer = ''
pchAppKeyBufferLen = 90
error = ivrapps.getApplicationKeyByIndex(idx, pchAppKeyBuffer, pchAppKeyBufferLen)
if error:
print(error)
appkeys.append(pchAppKeyBuffer)
return appkeys
def get_app(ivrapps: openvr.IVRApplications):
for pchAppKey in get_appkeys(ivrapps):
pchPropertyValueBuffer = ''
unPropertyValueBufferLen = 90
appname = ivrapps.getApplicationPropertyString(pchAppKey, openvr.VRApplicationProperty_Name_String, pchPropertyValueBuffer, unPropertyValueBufferLen)
print(appname)
if __name__ == "__main__":
main()