Skip to content

Commit

Permalink
removed genuine controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Cafezinhu committed Feb 2, 2023
1 parent 0527339 commit 3953e86
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
15 changes: 2 additions & 13 deletions addons/vr-simulator/SimulatedController.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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]
Expand Down
6 changes: 4 additions & 2 deletions addons/vr-simulator/VRSimulator.gd
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 3953e86

Please sign in to comment.