1313 QComboBox ,
1414 QFormLayout ,
1515 QGroupBox ,
16+ QMessageBox ,
1617)
1718
18- from PySide6 .QtCore import QEvent , Qt , QSize , QEvent , QRect
19+ from PySide6 .QtCore import QEvent , Qt , QSize , QEvent , QRect , QTimer
1920from PySide6 .QtGui import QPaintEvent , QColor , QPainter , QBrush , QImage
2021from mediapipe import solutions
2122import numpy as np
2526from aethervr .tracking_state import TrackingState
2627from aethervr .input_state import ControllerButton
2728from aethervr .runtime_connection import RuntimeConnection
29+ from aethervr .system_openxr_config import SystemOpenXRConfig
2830
2931
3032STYLESHEET = """
4547
4648class Window (QMainWindow ):
4749
48- def __init__ (self , config : Config , connection : RuntimeConnection ):
50+ def __init__ (self , config : Config , connection : RuntimeConnection , system_openxr_config : SystemOpenXRConfig ):
4951 super ().__init__ ()
5052 self .config = config
5153 self .connection = connection
54+ self .system_openxr_config = system_openxr_config
5255
5356 self .camera_view = None
5457
5558 self .setWindowTitle ("AetherVR Tracker" )
56- self .resize (QSize (1080 , 720 ))
59+ self .resize (QSize (1280 , 720 ))
5760
5861 layout = QVBoxLayout ()
5962 layout .setContentsMargins (0 , 0 , 0 , 0 )
@@ -77,16 +80,12 @@ def create_horizontal_widget(self):
7780 layout = QHBoxLayout ()
7881 layout .setContentsMargins (0 , 0 , 0 , 0 )
7982 layout .setSpacing (0 )
80- layout .addWidget (ConfigPanel (self .config ))
83+ layout .addWidget (ConfigPanel (self .config , self . system_openxr_config ))
8184 layout .addWidget (separator )
8285 layout .addWidget (self .camera_view )
8386 widget .setLayout (layout )
8487
85- size_policy = QSizePolicy (
86- QSizePolicy .Policy .Preferred ,
87- QSizePolicy .Policy .Preferred ,
88- )
89-
88+ size_policy = QSizePolicy (QSizePolicy .Policy .Preferred , QSizePolicy .Policy .Preferred )
9089 size_policy .setHorizontalStretch (1 )
9190 size_policy .setVerticalStretch (1 )
9291 widget .setSizePolicy (size_policy )
@@ -102,11 +101,12 @@ def update_camera_overlay(self, tracking_state: TrackingState):
102101
103102class ConfigPanel (QWidget ):
104103
105- def __init__ (self , config : Config ):
104+ def __init__ (self , config : Config , system_openxr_config : SystemOpenXRConfig ):
106105 super ().__init__ ()
107106 self .config = config
108107
109108 layout = QVBoxLayout ()
109+ layout .addWidget (OpenXRConfigGroup (system_openxr_config ))
110110 layout .addWidget (self .build_controller_group ("Left Controller" , config .left_controller_config ))
111111 layout .addWidget (self .build_controller_group ("Right Controller" , config .right_controller_config ))
112112 layout .setAlignment (Qt .AlignmentFlag .AlignTop )
@@ -126,6 +126,47 @@ def build_controller_group(self, label: str, config: ControllerConfig):
126126 return group
127127
128128
129+ class OpenXRConfigGroup (QGroupBox ):
130+
131+ def __init__ (self , system_openxr_config : SystemOpenXRConfig ):
132+ super ().__init__ ("OpenXR" )
133+ self .system_openxr_config = system_openxr_config
134+
135+ self .current_label = QLabel ()
136+
137+ self .set_button = QPushButton ("Set AetherVR as OpenXR Runtime" )
138+ self .set_button .clicked .connect (self ._activate_aethervr )
139+
140+ layout = QFormLayout ()
141+ layout .addRow (QLabel ("Current OpenXR Runtime:" ), self .current_label )
142+ layout .addRow (self .set_button )
143+ self .setLayout (layout )
144+
145+ self .timer = QTimer (self )
146+ self .timer .timeout .connect (self ._refresh )
147+ self .timer .start (2000 )
148+
149+ self ._refresh ()
150+
151+ def _activate_aethervr (self ):
152+ if self .system_openxr_config .activate_aethervr ():
153+ self ._refresh ()
154+ else :
155+ QMessageBox .critical (
156+ self ,
157+ "Error" ,
158+ "Failed to set AetherVR as the system OpenXR runtime. "
159+ + "Please make sure you're running AetherVR as an administrator." ,
160+ )
161+
162+ def _refresh (self ):
163+ active_runtime = self .system_openxr_config .active_runtime_name ()
164+ is_aethervr = self .system_openxr_config .is_aethervr (active_runtime )
165+
166+ self .current_label .setText ("None" if active_runtime is None else active_runtime )
167+ self .set_button .setEnabled (not is_aethervr )
168+
169+
129170class ButtonBindingDropdown (QComboBox ):
130171
131172 def __init__ (self , config : ControllerConfig , gesture : Gesture ):
@@ -275,11 +316,11 @@ def set_state(self, connected: bool):
275316
276317class GUI :
277318
278- def __init__ (self , config : Config , connection : RuntimeConnection ):
319+ def __init__ (self , config : Config , connection : RuntimeConnection , system_openxr_config : SystemOpenXRConfig ):
279320 self .app = QApplication (sys .argv )
280321 self .app .setStyleSheet (STYLESHEET )
281322
282- self .window = Window (config , connection )
323+ self .window = Window (config , connection , system_openxr_config )
283324 self .window .show ()
284325
285326 def update_camera_frame (self , frame ):
0 commit comments