diff --git a/project.godot b/project.godot index 4b585f887..61b1c0630 100644 --- a/project.godot +++ b/project.godot @@ -742,6 +742,18 @@ move_mouse_down={ , Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null) ] } +activate_left_tool={ +"deadzone": 0.5, +"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":4,"pressure":0.0,"pressed":false,"script":null) + ] +} +activate_right_tool={ +"deadzone": 0.5, +"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":2,"pressed":false,"doubleclick":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":5,"pressure":0.0,"pressed":false,"script":null) + ] +} [locale] diff --git a/src/Autoload/Global.gd b/src/Autoload/Global.gd index a742ef29e..cffd0c522 100644 --- a/src/Autoload/Global.gd +++ b/src/Autoload/Global.gd @@ -288,6 +288,8 @@ func _initialize_keychain() -> void: "camera_up": Keychain.InputAction.new("", "Canvas"), "camera_down": Keychain.InputAction.new("", "Canvas"), "pan": Keychain.InputAction.new("", "Canvas"), + "activate_left_tool": Keychain.InputAction.new("", "Canvas"), + "activate_right_tool": Keychain.InputAction.new("", "Canvas"), "move_mouse_left": Keychain.InputAction.new("", "Cursor movement"), "move_mouse_right": Keychain.InputAction.new("", "Cursor movement"), "move_mouse_up": Keychain.InputAction.new("", "Cursor movement"), diff --git a/src/Autoload/Tools.gd b/src/Autoload/Tools.gd index b8255aad9..cf6e597c7 100644 --- a/src/Autoload/Tools.gd +++ b/src/Autoload/Tools.gd @@ -380,14 +380,18 @@ func handle_draw(position: Vector2, event: InputEvent) -> void: if Global.mirror_view: draw_pos.x = Global.current_project.size.x - position.x - 1 - if event is InputEventMouseButton: - if event.button_index in [BUTTON_LEFT, BUTTON_RIGHT]: - if event.pressed and _active_button == -1: - _active_button = event.button_index - _slots[_active_button].tool_node.draw_start(draw_pos) - elif not event.pressed and event.button_index == _active_button: - _slots[_active_button].tool_node.draw_end(draw_pos) - _active_button = -1 + if event.is_action_pressed("activate_left_tool") and _active_button == -1: + _active_button = BUTTON_LEFT + _slots[_active_button].tool_node.draw_start(draw_pos) + elif event.is_action_released("activate_left_tool") and _active_button == BUTTON_LEFT: + _slots[_active_button].tool_node.draw_end(draw_pos) + _active_button = -1 + elif event.is_action("activate_right_tool") and _active_button == -1: + _active_button = BUTTON_RIGHT + _slots[_active_button].tool_node.draw_start(draw_pos) + elif event.is_action_released("activate_right_tool") and _active_button == BUTTON_RIGHT: + _slots[_active_button].tool_node.draw_end(draw_pos) + _active_button = -1 if event is InputEventMouseMotion: pen_pressure = event.pressure diff --git a/src/UI/Canvas/Canvas.gd b/src/UI/Canvas/Canvas.gd index 7e896960a..cbdb41caf 100644 --- a/src/UI/Canvas/Canvas.gd +++ b/src/UI/Canvas/Canvas.gd @@ -61,11 +61,14 @@ func _input(event: InputEvent) -> void: # Don't process anything below if the input isn't a mouse event, or Shift/Ctrl. # This decreases CPU/GPU usage slightly. var get_velocity := false - if not event is InputEventMouse: + if not event is InputEventMouseMotion: for action in MOVE_ACTIONS: if event.is_action(action): get_velocity = true - if !get_velocity: + if ( + !get_velocity + and !(event.is_action("activate_left_tool") or event.is_action("activate_right_tool")) + ): return var tmp_position: Vector2 = Global.main_viewport.get_local_mouse_position()