Skip to content

Script to handle touch input (including gestures). It also translates mouse input to touch input.

License

Notifications You must be signed in to change notification settings

zhanwuchao/Godot-Touch-Input-Manager

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Godot Touch Input Manager

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.

How to use

Examples

Demo

Demo

Documentation

Supported gestures and it's signals

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

Custom Input Events

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.

InputEventScreenPinch

Pinch center position.

Distance of the pinch.

Relative distance variation of the pinch.

Pinch speed (Average speed length of all the Drags involved).

InputEventSingleScreenDrag

SingleScreenDrag position.

SingleScreenDrag position relative to its previous position.

SingleScreenDrag speed.

InputEventMultiScreenDrag

MultiScreenDrag position (Average position of all the Drags involved).

MultiScreenDrag position relative to its previous position (Average relative of all the Drags involved).

MultiScreenDrag speed (Average speed of all the Drags involved).

InputEventScreenTwist

Twist center position.

Twist relative angle.

Twist speed (Average speed length of all the Drags involved).

InputEventSingleScreenTap

Tap position.

InputEventSingleScreenTouch

SingleScreenTouch position.

If true the touch is starting. If false the touch is ending.

Mouse to gesture

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

Versioning

Using SemVer for versioning. For the versions available, see the releases

Authors

  • Federico Ciuffardi

Feel free to append yourself here if you've made contributions.

Note

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 :)

About

Script to handle touch input (including gestures). It also translates mouse input to touch input.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • GDScript 100.0%