mirror of
https://github.com/CrispyPin/ovr-utils.git
synced 2024-11-22 07:30:25 +01:00
start adding cursor move events
This commit is contained in:
parent
381be25af0
commit
4a89de6af9
2 changed files with 24 additions and 3 deletions
|
@ -5,6 +5,9 @@ var cursor_node = preload("res://addons/openvr_overlay/interaction/Cursor.tscn"
|
||||||
onready var viewport: Viewport = get_node("../../OverlayViewport")
|
onready var viewport: Viewport = get_node("../../OverlayViewport")
|
||||||
onready var _i = get_parent()
|
onready var _i = get_parent()
|
||||||
|
|
||||||
|
var curr_pos: Vector2
|
||||||
|
var prev_pos := Vector2(-1000, 1000)
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
viewport.add_child(cursor_node)
|
viewport.add_child(cursor_node)
|
||||||
get_parent().connect("trigger_on", self, "_trigger_on")
|
get_parent().connect("trigger_on", self, "_trigger_on")
|
||||||
|
@ -12,7 +15,10 @@ func _ready() -> void:
|
||||||
|
|
||||||
|
|
||||||
func _process(_delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
|
curr_pos = get_canvas_pos()
|
||||||
_update_cursor()
|
_update_cursor()
|
||||||
|
_send_move_event()
|
||||||
|
prev_pos = curr_pos
|
||||||
|
|
||||||
|
|
||||||
#get canvas position of active controller
|
#get canvas position of active controller
|
||||||
|
@ -24,7 +30,6 @@ func get_canvas_pos() -> Vector2:
|
||||||
_i.tracker_nodes[_i.active_controller].translation)
|
_i.tracker_nodes[_i.active_controller].translation)
|
||||||
var pos = Vector2(controller_local_pos.x, controller_local_pos.y)
|
var pos = Vector2(controller_local_pos.x, controller_local_pos.y)
|
||||||
|
|
||||||
# var overlay_size = OverlayInit.ovr_interface.get_render_targetsize()
|
|
||||||
var overlay_size = Vector2(2048, 2048)
|
var overlay_size = Vector2(2048, 2048)
|
||||||
# scale to pixels
|
# scale to pixels
|
||||||
pos *= overlay_size.x
|
pos *= overlay_size.x
|
||||||
|
@ -39,9 +44,18 @@ func _update_cursor():
|
||||||
cursor_node.rect_position = get_canvas_pos()
|
cursor_node.rect_position = get_canvas_pos()
|
||||||
|
|
||||||
|
|
||||||
|
func _send_move_event():
|
||||||
|
var event = InputEventMouseMotion.new()
|
||||||
|
event.position = prev_pos
|
||||||
|
event.relative = curr_pos - prev_pos
|
||||||
|
event.speed = event.relative
|
||||||
|
viewport.input(event)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _send_click_event(state: bool):
|
func _send_click_event(state: bool):
|
||||||
var click_event = InputEventMouseButton.new()
|
var click_event = InputEventMouseButton.new()
|
||||||
click_event.position = get_canvas_pos()
|
click_event.position = curr_pos
|
||||||
click_event.pressed = state
|
click_event.pressed = state
|
||||||
click_event.button_index = 1
|
click_event.button_index = 1
|
||||||
viewport.input(click_event)
|
viewport.input(click_event)
|
||||||
|
|
|
@ -103,12 +103,14 @@ alignment = 2
|
||||||
[node name="Remove" type="Button" parent="MoreOptions/Container/List"]
|
[node name="Remove" type="Button" parent="MoreOptions/Container/List"]
|
||||||
margin_right = 176.0
|
margin_right = 176.0
|
||||||
margin_bottom = 191.0
|
margin_bottom = 191.0
|
||||||
|
focus_mode = 0
|
||||||
icon = ExtResource( 2 )
|
icon = ExtResource( 2 )
|
||||||
|
|
||||||
[node name="SetSize" type="Button" parent="MoreOptions/Container/List"]
|
[node name="SetSize" type="Button" parent="MoreOptions/Container/List"]
|
||||||
margin_left = 180.0
|
margin_left = 180.0
|
||||||
margin_right = 356.0
|
margin_right = 356.0
|
||||||
margin_bottom = 191.0
|
margin_bottom = 191.0
|
||||||
|
focus_mode = 0
|
||||||
toggle_mode = true
|
toggle_mode = true
|
||||||
icon = ExtResource( 4 )
|
icon = ExtResource( 4 )
|
||||||
|
|
||||||
|
@ -139,6 +141,7 @@ __meta__ = {
|
||||||
margin_left = 360.0
|
margin_left = 360.0
|
||||||
margin_right = 536.0
|
margin_right = 536.0
|
||||||
margin_bottom = 191.0
|
margin_bottom = 191.0
|
||||||
|
focus_mode = 0
|
||||||
toggle_mode = true
|
toggle_mode = true
|
||||||
icon = ExtResource( 12 )
|
icon = ExtResource( 12 )
|
||||||
|
|
||||||
|
@ -157,7 +160,8 @@ margin_left = 8.0
|
||||||
margin_top = 8.0
|
margin_top = 8.0
|
||||||
margin_right = 168.0
|
margin_right = 168.0
|
||||||
margin_bottom = 441.0
|
margin_bottom = 441.0
|
||||||
min_value = 0.2
|
focus_mode = 0
|
||||||
|
min_value = 0.3
|
||||||
max_value = 1.0
|
max_value = 1.0
|
||||||
step = 0.05
|
step = 0.05
|
||||||
value = 1.0
|
value = 1.0
|
||||||
|
@ -169,6 +173,7 @@ __meta__ = {
|
||||||
margin_left = 540.0
|
margin_left = 540.0
|
||||||
margin_right = 720.0
|
margin_right = 720.0
|
||||||
margin_bottom = 191.0
|
margin_bottom = 191.0
|
||||||
|
focus_mode = 0
|
||||||
text = "Left"
|
text = "Left"
|
||||||
icon = ExtResource( 6 )
|
icon = ExtResource( 6 )
|
||||||
clip_text = true
|
clip_text = true
|
||||||
|
@ -179,12 +184,14 @@ selected = 1
|
||||||
margin_left = 724.0
|
margin_left = 724.0
|
||||||
margin_right = 900.0
|
margin_right = 900.0
|
||||||
margin_bottom = 191.0
|
margin_bottom = 191.0
|
||||||
|
focus_mode = 0
|
||||||
icon = ExtResource( 5 )
|
icon = ExtResource( 5 )
|
||||||
|
|
||||||
[node name="CloseOptions" type="Button" parent="MoreOptions/Container/List"]
|
[node name="CloseOptions" type="Button" parent="MoreOptions/Container/List"]
|
||||||
margin_left = 904.0
|
margin_left = 904.0
|
||||||
margin_right = 1080.0
|
margin_right = 1080.0
|
||||||
margin_bottom = 191.0
|
margin_bottom = 191.0
|
||||||
|
focus_mode = 0
|
||||||
icon = ExtResource( 11 )
|
icon = ExtResource( 11 )
|
||||||
|
|
||||||
[connection signal="toggled" from="BasicOptions/List/Grab" to="." method="_on_Grab_toggled"]
|
[connection signal="toggled" from="BasicOptions/List/Grab" to="." method="_on_Grab_toggled"]
|
||||||
|
|
Loading…
Reference in a new issue