mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-20 12:33:14 +00:00
Made left and right tool activation shortcuts configurable
Mapped to left and right mouse buttons respectively by default, as well was L1 and R1 buttons respectively in joypads. This commit should allow mouse-free drawing, since it's now possible to activate the left and right tools via joypad and keyboard buttons, thanks to the Keychain plugin.
This commit is contained in:
parent
d028582f27
commit
da65380169
4 changed files with 31 additions and 10 deletions
|
@ -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]
|
||||
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue