Godot Touch Input Manager is a script to handle touch input. You just need to autoload the script and it will start analyzing the touch input and when a gesture is detected a Custom Input Event corresponding to the detected gesture will be created and fed up to the Godot built in Input Event system so it triggers functions like _input(InputEvent event)
. There is also a signal for each gesture if you prefer using signals to the aforementioned.
This asset was ported to be added to Godot and is now a milestone to version 4.0, PR: godotengine/godot#36953.
- Dowload the latest release from https://github.com/Federico-Ciuffardi/Godot-Touch-Input-Manager/releases
- Extract the downloaded .zip file somewhere in you project
- Locate the extracted
InputManager.gd
, and Autoload it. - Done! Now you can use the GodotTouchInputManager's signals and it's Custom Input Events.
Name | Signal | Args |
---|---|---|
Single finger tap | single_tap | InputEventSingleScreenTap |
Single finger touch | single_touch | InputEventSingleScreenTouch |
Single finger drag | single_drag | InputEventSingleScreenDrag |
Pinch | pinch | InputEventScreenPinch |
Multiple finger drag | multi_drag | InputEventMultiScreenDrag |
Twist | twist | InputEventScreenTwist |
any gesture | any_gesture | signal_name, InputEvent |
The purpose of these is to provide a InputEvent for the inputs that are not considered by the built-in InputsEvents.
When a gesture is detected _input(InputEvent event)
will be called with the input event associated to the detected gesture as the event
parameter.
- Vector2 position
Pinch center position.
- float distance
Distance of the pinch.
- float relative
Relative distance variation of the pinch.
- float speed
Pinch speed (Average speed length of all the Drags involved).
- Vector2 position
SingleScreenDrag position.
- Vector2 relative
SingleScreenDrag position relative to its previous position.
- Vector2 speed
SingleScreenDrag speed.
- Vector2 position
MultiScreenDrag position (Average position of all the Drags involved).
- Vector2 relative
MultiScreenDrag position relative to its previous position (Average relative of all the Drags involved).
- Vector2 speed
MultiScreenDrag speed (Average speed of all the Drags involved).
- Vector2 position
Twist center position.
- float relative
Twist relative angle.
- float speed
Twist speed (Average speed length of all the Drags involved).
- Vector2 position
Tap position.
- Vector2 position
SingleScreenTouch position.
- boolean pressed
If true
the touch is starting. If false
the touch is ending.
To enable single finger gestures go to Project > Project Settings > Input Devices > Pointing and turn on Emulate Touch From Mouse to emulate a single finger press with the left click. For the other gestures
Gesture | Mouse action |
---|---|
Pinch outward | Scroll up |
Pinch inward | Scroll down |
Multiple finger drag | Middle click |
Using SemVer for versioning. For the versions available, see the releases
- Federico Ciuffardi
Feel free to append yourself here if you've made contributions.
Thank you for checking out this repository, you can send all your questions and feedback to Federico.Ciuffardi@outlook.com.
If you are up to contribute on some way please contact me :)