Skip to content

Commit

Permalink
Disable mobile controls if keyboard/controller input detected
Browse files Browse the repository at this point in the history
  • Loading branch information
Alzter committed Sep 1, 2023
1 parent cb7ae96 commit 745d455
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions SourceCode/autoload/MobileControls.gd
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,16 @@ func update_mobile_controls_scale(ui_scale : float):
scale_buttons.rect_scale = Vector2.ONE * ui_scale

func _input(event):

if event is InputEventScreenTouch or event is InputEventScreenDrag:
if !is_using_mobile: activate_mobile_controls()

if !is_using_mobile: return

# Disable mobile controls if a keyboard or controller input is detected.
if event is InputEventKey or event is InputEventJoypadButton or event is InputEventJoypadMotion:
deactivate_mobile_controls()

if button_just_released:
button_just_released = false
return
Expand Down Expand Up @@ -167,6 +172,10 @@ func activate_mobile_controls():
is_using_mobile = true
mobile_controls.show()

func deactivate_mobile_controls():
is_using_mobile = false
mobile_controls.hide()

func _on_JumpButton_pressed():
Input.action_press("jump")
button_just_pressed = true
Expand Down

0 comments on commit 745d455

Please sign in to comment.