diff --git a/addons/vr-simulator/SimulatedController.gd b/addons/vr-simulator/SimulatedController.gd index 9d35262..4f66855 100644 --- a/addons/vr-simulator/SimulatedController.gd +++ b/addons/vr-simulator/SimulatedController.gd @@ -6,28 +6,17 @@ var grip_axis = 0 var trigger_axis = 0 var buttons = [] -var genuine_controller: ARVRController - func _ready(): - genuine_controller = ARVRController.new() - genuine_controller.controller_id = controller_id - get_parent().call_deferred("add_child", genuine_controller) - genuine_controller.connect("button_pressed", self, "press_button") - genuine_controller.connect("button_release", self, "release_button") for _i in range(16): buttons.append(false) func get_controller_name(): - if genuine_controller.get_is_active(): - return genuine_controller.get_controller_name() return "Simulated controller" func get_is_active(): return true func get_joystick_axis(axis): - if genuine_controller.get_is_active(): - return genuine_controller.get_joystick_axis(axis) if axis == 0: return x_axis elif axis == 1: @@ -37,10 +26,10 @@ func get_joystick_axis(axis): elif axis == 4: return grip_axis else: - return genuine_controller.get_joystick_axis(axis) + return 0 func get_joystick_id(): - return genuine_controller.get_joystick_id() + return 0 func is_button_pressed(button: int): return buttons[button] diff --git a/addons/vr-simulator/VRSimulator.gd b/addons/vr-simulator/VRSimulator.gd index 97c97e0..571370f 100644 --- a/addons/vr-simulator/VRSimulator.gd +++ b/addons/vr-simulator/VRSimulator.gd @@ -1,6 +1,7 @@ extends Node export var enabled: bool +export var xr_interface = "OpenXR" export var device_x_sensitivity: float = 1 export var device_y_sensitivity: float = 1 export var scroll_sensitivity: float = 1 @@ -31,7 +32,9 @@ var key_map = { } func _enter_tree(): - if not enabled: + var interface = ARVRServer.find_interface(xr_interface) + if not enabled or (interface and interface.initialize()): + enabled = false return Input.mouse_mode = Input.MOUSE_MODE_CAPTURED @@ -56,7 +59,6 @@ func bind_simulated_controller(controller: ARVRController, simulated_controller: origin.add_child(simulated_controller) var new_name = controller.name - print(new_name) for controller_child in controller.get_children(): controller.remove_child(controller_child)