diff --git a/src/addons/openvr_overlay/OverlayCursor.tscn b/src/addons/openvr_overlay/OverlayCursor.tscn deleted file mode 100644 index 7993016..0000000 --- a/src/addons/openvr_overlay/OverlayCursor.tscn +++ /dev/null @@ -1,6 +0,0 @@ -[gd_scene load_steps=2 format=2] - -[ext_resource path="res://addons/openvr_overlay/interaction/overlay_cursor.gd" type="Script" id=1] - -[node name="OverlayCursor" type="Node"] -script = ExtResource( 1 ) diff --git a/src/addons/openvr_overlay/OverlayGrab.tscn b/src/addons/openvr_overlay/OverlayGrab.tscn deleted file mode 100644 index 0535b42..0000000 --- a/src/addons/openvr_overlay/OverlayGrab.tscn +++ /dev/null @@ -1,6 +0,0 @@ -[gd_scene load_steps=2 format=2] - -[ext_resource path="res://addons/openvr_overlay/interaction/overlay_grab.gd" type="Script" id=1] - -[node name="OverlayGrab" type="Node"] -script = ExtResource( 1 ) diff --git a/src/addons/openvr_overlay/OverlayTouchCursor.tscn b/src/addons/openvr_overlay/OverlayTouchCursor.tscn deleted file mode 100644 index 3e0a574..0000000 --- a/src/addons/openvr_overlay/OverlayTouchCursor.tscn +++ /dev/null @@ -1,7 +0,0 @@ -[gd_scene load_steps=2 format=2] - -[ext_resource path="res://addons/openvr_overlay/interaction/overlay_cursor.gd" type="Script" id=1] - -[node name="OverlayTouchCursor" type="Node"] -script = ExtResource( 1 ) -is_touch = true diff --git a/src/addons/openvr_overlay/interaction/mod/Clickable.tscn b/src/addons/openvr_overlay/interaction/mod/Clickable.tscn new file mode 100644 index 0000000..0930847 --- /dev/null +++ b/src/addons/openvr_overlay/interaction/mod/Clickable.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/openvr_overlay/interaction/mod/clickable.gd" type="Script" id=1] + +[node name="Clickable" type="Node"] +script = ExtResource( 1 ) diff --git a/src/addons/openvr_overlay/interaction/mod/Grabbable.tscn b/src/addons/openvr_overlay/interaction/mod/Grabbable.tscn new file mode 100644 index 0000000..41a9f85 --- /dev/null +++ b/src/addons/openvr_overlay/interaction/mod/Grabbable.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/openvr_overlay/interaction/mod/grabbable.gd" type="Script" id=1] + +[node name="Grabbable" type="Node"] +script = ExtResource( 1 ) diff --git a/src/addons/openvr_overlay/interaction/mod/Touchable.tscn b/src/addons/openvr_overlay/interaction/mod/Touchable.tscn new file mode 100644 index 0000000..f75ed18 --- /dev/null +++ b/src/addons/openvr_overlay/interaction/mod/Touchable.tscn @@ -0,0 +1,7 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/openvr_overlay/interaction/mod/clickable.gd" type="Script" id=1] + +[node name="Touchable" type="Node"] +script = ExtResource( 1 ) +is_touch = true diff --git a/src/addons/openvr_overlay/interaction/overlay_cursor.gd b/src/addons/openvr_overlay/interaction/mod/clickable.gd similarity index 85% rename from src/addons/openvr_overlay/interaction/overlay_cursor.gd rename to src/addons/openvr_overlay/interaction/mod/clickable.gd index c6a4f06..f13b674 100644 --- a/src/addons/openvr_overlay/interaction/overlay_cursor.gd +++ b/src/addons/openvr_overlay/interaction/mod/clickable.gd @@ -23,8 +23,6 @@ var cursor_nodes := { "right": preload("res://addons/openvr_overlay/interaction/Cursor.tscn").instance(), "left": preload("res://addons/openvr_overlay/interaction/Cursor.tscn").instance(), } -var temp = 0 -var tstate = true func _ready() -> void: viewport.add_child(cursor_nodes.right) @@ -35,29 +33,18 @@ func _ready() -> void: else: get_parent().connect("trigger_on", self, "_trigger_on") get_parent().connect("trigger_off", self, "_trigger_off") - + func _process(delta: float) -> void: cursor_pos.right = get_canvas_pos("right") cursor_pos.left = get_canvas_pos("left") _update_cursors() - #_send_move_event() +# _send_move_event() prev_pos = cursor_pos.duplicate(true) -# if is_touch: -# temp += delta -# if temp > 0.5: -# temp = 0 -# var click_event = InputEventMouseButton.new() -# click_event.position = Vector2(240, 340) -# click_event.pressed = tstate -# tstate = !tstate -# click_event.button_index = 1 -# viewport.input(click_event) -# print("SENT EVENT ", click_event.position, " -- ", click_event.pressed) -## viewport. -#get canvas position of controller + +# get canvas position of controller func get_canvas_pos(controller) -> Vector2: var controller_local_pos = _i._overlay_area.global_transform.xform_inv(\ _i.tracker_nodes[controller].translation) @@ -83,7 +70,7 @@ func _update_cursors(): func _send_move_event(): if not active_side: return# only send move events while a cursor is held down - + var event = InputEventMouseMotion.new() event.position = prev_pos[active_side] event.relative = cursor_pos[active_side] - prev_pos[active_side] diff --git a/src/addons/openvr_overlay/interaction/overlay_grab.gd b/src/addons/openvr_overlay/interaction/mod/grabbable.gd similarity index 100% rename from src/addons/openvr_overlay/interaction/overlay_grab.gd rename to src/addons/openvr_overlay/interaction/mod/grabbable.gd diff --git a/src/addons/openvr_overlay/interaction/overlay_interaction.gd b/src/addons/openvr_overlay/interaction/overlay_interaction.gd index 7fcdd26..693466a 100644 --- a/src/addons/openvr_overlay/interaction/overlay_interaction.gd +++ b/src/addons/openvr_overlay/interaction/overlay_interaction.gd @@ -155,19 +155,16 @@ func _update_target(): # called by overlay_instance after properties are loaded and before overlay scene enters the tree func spawn_modules(): - # grab module - if get_parent().get_property("has_grab"): - var module = preload("res://addons/openvr_overlay/OverlayGrab.tscn") + if get_parent().get_property("grabbable"): + var module = preload("res://addons/openvr_overlay/interaction/mod/Grabbable.tscn") add_child(module.instance()) - # cursor module - if get_parent().get_property("has_cursor"): - var module = preload("res://addons/openvr_overlay/OverlayCursor.tscn") + if get_parent().get_property("clickable"): + var module = preload("res://addons/openvr_overlay/interaction/mod/Clickable.tscn") add_child(module.instance()) - - # cursor module - if get_parent().get_property("has_touch"): - var module = preload("res://addons/openvr_overlay/OverlayTouchCursor.tscn") + + if get_parent().get_property("touchable"): + var module = preload("res://addons/openvr_overlay/interaction/mod/Touchable.tscn") add_child(module.instance()) diff --git a/src/addons/openvr_overlay/overlay_init.gd b/src/addons/openvr_overlay/overlay_init.gd index ab9a09d..3d46849 100644 --- a/src/addons/openvr_overlay/overlay_init.gd +++ b/src/addons/openvr_overlay/overlay_init.gd @@ -4,10 +4,9 @@ extends Node const OVERLAY_PROPERTIES_DEFAULT = { "allow_delete": true, "allow_hide": true, -# "interaction": true, - "has_cursor": false, - "has_touch": false, - "has_grab": true, + "clickable": false, + "touchable": false, + "grabbable": true, } var ovr_interface: ARVRInterface @@ -21,7 +20,6 @@ var trackers = { } func _init() -> void: -# OS.window_minimized = true ovr_config.set_application_type(2) # Set to OVERLAY MODE ovr_config.set_tracking_universe(1) # Set to SEATED MODE = 0, STANDING MODE = 1, RAW MODE = 2 @@ -32,11 +30,12 @@ func _init() -> void: func _ready() -> void: + OS.window_minimized = true ARVRServer.connect("tracker_added", self, "_tracker_added") ARVRServer.connect("tracker_removed", self, "_tracker_removed") update_hand_ids() #Input.set_use_accumulated_input(true) - + func _tracker_added(tracker_name: String, type: int, id: int): update_hand_ids() diff --git a/src/overlay_resources/image_viewer.gd b/src/overlay_resources/image_viewer.gd index 205a784..f762935 100644 --- a/src/overlay_resources/image_viewer.gd +++ b/src/overlay_resources/image_viewer.gd @@ -1,7 +1,7 @@ extends Control const OVERLAY_PROPERTIES = { - "has_cursor": true, + "clickable": true, } diff --git a/src/overlay_resources/keyboard/keyboard_overlay.gd b/src/overlay_resources/keyboard/keyboard_overlay.gd index b7d411e..4a58465 100644 --- a/src/overlay_resources/keyboard/keyboard_overlay.gd +++ b/src/overlay_resources/keyboard/keyboard_overlay.gd @@ -1,7 +1,7 @@ extends Control const OVERLAY_PROPERTIES = { - "has_touch": true, + "touchable": true, } export var key_size := 100 diff --git a/src/overlay_resources/main_menu.gd b/src/overlay_resources/main_menu.gd index 9a3291d..f0c93ff 100644 --- a/src/overlay_resources/main_menu.gd +++ b/src/overlay_resources/main_menu.gd @@ -3,8 +3,7 @@ extends Control const OVERLAY_PROPERTIES = { "allow_hide": false, "allow_delete": false, - "has_cursor": true, - "has_grab": true, + "clickable": true, } diff --git a/src/overlay_resources/touch_stick/stick.png b/src/overlay_resources/touch_stick/stick.png new file mode 100644 index 0000000..6171580 Binary files /dev/null and b/src/overlay_resources/touch_stick/stick.png differ diff --git a/src/overlay_resources/touch_stick/stick.png.import b/src/overlay_resources/touch_stick/stick.png.import new file mode 100644 index 0000000..71c669a --- /dev/null +++ b/src/overlay_resources/touch_stick/stick.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/stick.png-328b0dfe10d1d71101c4612bcd737746.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://overlay_resources/touch_stick/stick.png" +dest_files=[ "res://.import/stick.png-328b0dfe10d1d71101c4612bcd737746.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/src/overlay_resources/ui_demo.gd b/src/overlay_resources/ui_demo.gd index 9007f5b..4831f65 100644 --- a/src/overlay_resources/ui_demo.gd +++ b/src/overlay_resources/ui_demo.gd @@ -1,8 +1,8 @@ extends Control const OVERLAY_PROPERTIES = { - "has_cursor": true, - "has_touch": true, + "clickable": true, + "touchable": true, } var grabber diff --git a/src/overlays/TouchStick.tscn b/src/overlays/TouchStick.tscn new file mode 100644 index 0000000..6f04011 --- /dev/null +++ b/src/overlays/TouchStick.tscn @@ -0,0 +1,20 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://overlay_resources/touch_stick/stick.png" type="Texture" id=1] + +[node name="stick" type="TextureRect"] +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -128.0 +margin_top = -128.0 +margin_right = -30.0 +margin_bottom = 128.0 +mouse_filter = 2 +texture = ExtResource( 1 ) +expand = true +stretch_mode = 5 +__meta__ = { +"_edit_use_anchors_": false +}