HI guys ! I'm actually tidying up my code since there's not much to do until the demo's ready (replacing everything in static type, finishing little things like this lmb event button..)
And I've hit a wall. No matter what I try, it's impossible for me to make this lmb event works. It only freeze, and fails to do so.
Here's the code used :
var showed:bool = false
var click = InputEventMouseButton.new()
var mouse_pos:Vector2
func _ready() -> void:
self.hide()
func _physics_process(delta) -> void:
if showed == true and GameData.controller == true:
mouse_pos -= (Vector2(Input.get_action_strength("joy_left") - Input.get_action_strength("joy_right"), Input.get_action_strength("joy_up") - Input.get_action_strength("joy_down"))) * 7
Input.warp_mouse_position(mouse_pos)
click.position = mouse_pos
func _input(_event) -> void:
if Input.is_action_just_pressed("l1") and showed == true:
SceneHandler._unpause()
yield(get_tree().create_timer(0.05), "timeout")
$"../Test/Player"._loading_inventory()
showed = false
self.hide()
if GameData.controller == true:
if Input.is_action_just_pressed("cross"):
call_deferred("_hold_left_click")
func _hold_left_click() -> void:
click.set_button_index(1)
click.pressed = true
Input.parse_input_event(click)
#click.pressed = false
#Input.parse_input_event(click)
Here's the goal : I want my player to be able to move the mouse when the inventory is showed (which works using the "getactionstrength") and then be able to drag and drop the textures of the inventory.
I'm using the inner function of control nodes to do that (getdragdata(), candropdata(), drop_data()), which should work fine since it works by a lmb event button when using the mouse.
I tried, just in case, to see if the control node had detected the mouse coming from using the controller as a... mouse doing a print on the event "mouse_entered", and yes, it does. Better safe than sorry.
Back to the problem : If I try to emulate my left_click using the "cross" button of the controller, here's what the output says :
Failed method: Control:holdleft_click target ID: 1619
TOTAL BYTES: 4194288
NULL count: 0
CALL : 174761
CALL holdleft_click: 1
Can't really understand this one, didn't get it once before. I just understand that it fails to call the method asked by call_deferred().
How does it works ? Is it impossible to emulate a holded lmb to drag and drop the textures of my inventory ?
Am I dumb and unable to see what's the problem even though it's a simple one ?
I'm thankful for your help, it's been 3 days and I can't keep hitting that wall forever.