Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork37
Asset that improves touch input support (includes new gestures) in the Godot game engine. It also translates mouse input to touch input.
License
Federico-Ciuffardi/GodotTouchInputManager
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Godot Touch Input Manager (GDTIM) is an asset that improves touch input support (includesnew gestures) in the Godot game engine. You just need to autoload a script and it will start analyzing the touch input. When a gesture is detected a Custom Input Event corresponding to the detected gesture will be created andfed 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.
There are two active PRs that add some GDTIM gestures as native Godot events, one forversion 3.x and one forversion 4.x, if you are interested, please show your support there.
- Download the latest release fromhttps://github.com/Federico-Ciuffardi/Godot-Touch-Input-Manager/releases
- Extract the downloaded.zip file somewhere in you project
- Locate the extracted
InputManager.gd, andAutoload it. - Done! Now you can use GDTIMsignals and Custom Input Events.
| Gesture name | Signal | Custom input event / Signal arg | Description |
|---|---|---|---|
| Single finger touch | single_touch | InputEventSingleScreenTouch | Touch with a single finger |
| Single finger tap | single_tap | InputEventSingleScreenTap | Fast press and release with a single finger |
| Single finger long press | single_long_press | InputEventSingleScreenLongPress | Press and hold with a single finger |
| Single finger drag | single_drag | InputEventSingleScreenDrag | Drag with a single finger |
| Single finger swipe | single_swipe | InputEventSingleScreenSwipe | Fast drag and release with a single finger |
| Multiple finger tap | multi_tap | InputEventMultiScreenTap | Fast press and release with multiple fingers |
| Multiple finger long press | multi_long_press | InputEventMultiScreenLongPress | Press and hold with multiple fingers |
| Multiple finger drag | multi_drag | InputEventMultiScreenDrag | Drag with multiple fingers (same direction) |
| Multiple finger swipe | multi_swipe | InputEventMultiScreenTap | Fast drag and release with multiple fingers |
| Pinch | pinch | InputEventScreenPinch | Drag with multiple fingers (inward/outward) |
| Twist | twist | InputEventScreenTwist | Drag with multiple fingers (rotate) |
| Raw gesture | raw_gesture | RawGesture | Raw gesture state |
When one of these gestures is detected a Custom Input Event corresponding to the detected gesture will be created andfed up to the Godot built in Input Event system so it triggers functions like_input(InputEvent event).
The gestures can be triggered by namedinput actions with specific names. If the inputaction does not exists there is a default event that will trigger the gesture.
The following table shows the default event and the names of the input actionsthat will trigger each of the gestures that can be emulated.
| Gesture name | Input action name | Default event |
|---|---|---|
| Single touch | single_touch | * |
| Multiple touch (2 fingers) | multi_touch | Middle click |
| Pinch (outward) | pinch_outward | Scroll up |
| Pinch (inward) | pinch_inward | Scroll down |
| Twist | twist | Right click |
| Single finger swipe (up) | single_swipe_up | w |
| Single finger swipe (up-right) | single_swipe_up_right | e |
| Single finger swipe (right) | single_swipe_right | d |
| Single finger swipe (down-right) | single_swipe_down_right | c |
| Single finger swipe (down) | single_swipe_down | x |
| Single finger swipe (down-left) | single_swipe_down_left | z |
| Single finger swipe (left) | single_swipe_left | a |
| Single finger swipe (left-up) | single_swipe_up_left | q |
| Multiple finger swipe (up) | multi_swipe_up | i |
| Multiple finger swipe (up-right) | multi_swipe_up_right | o |
| Multiple finger swipe (right) | multi_swipe_right | l |
| Multiple finger swipe (down-right) | multi_swipe_down_right | . |
| Multiple finger swipe (down) | multi_swipe_down | , |
| Multiple finger swipe (down-left) | multi_swipe_down_left | m |
| Multiple finger swipe (left) | multi_swipe_left | j |
| Multiple finger swipe (left-up) | multi_swipe_up_left | u |
* There are two options to enable single finger gestures:
- Go toProject > Project Settings > General > Input Devices > Pointingand turn onEmulate Touch From Mouse to emulate a single finger touch withthe left click.
- Go toProject > Project Settings > General > Input Devices > Pointingand turn off bothEmulate Touch From Mouse andEmulate Mouse From Touch.Then set an input action called
single_touch.
These are located in the first lines ofInputManager.gd, to change them modify thevalues on the script.
| Name | Default value | Description |
|---|---|---|
| DEFAULT_BINDIGS | true | Enable or disable default events forgesture emulation |
| DEBUG | false | Enable or disable debug information |
| DRAG_STARTUP_TIME | 0.2 | Seconds from the first native drag event to the firstsingle finger drag custom event |
| FINGER_SIZE | 100.0 | The distance between the fingers must be less thanfingers*FINGER_SIZE pixels for themultiple finger tap andmultiple finger swipe gestures to be recognized. Setting it toINF removes this restriction. |
| MULTI_FINGER_RELEASE_THRESHOLD | 0.1 | All fingers must be released withinMULTI_FINGER_REALEASE_THRESHOLD seconds before the gesture ends for themultiple finger tap andmultiple finger swipe gestures to be recognized |
| TAP_TIME_LIMIT | 0.2 | The time between the first press and the last release must be less thanTAP_TIME_LIMIT seconds for thesingle finger tap andmultiple finger tap gestures to be recognized |
| TAP_DISTANCE_LIMIT | 25.0 | The centroid of the finger presses must differ less thanTAP_DISTANCE_LIMIT pixels from the centroid of the finger releases for thesingle finger tap andmultiple finger tap gestures to be recognized. |
| SWIPE_TIME_LIMIT | 0.5 | The time between the first press and the last release must be less thanSWIPE_TIME_LIMIT seconds for thesingle finger swipe andmultiple finger swipe gestures to be recognized. |
| SWIPE_DISTANCE_THRESHOLD | 200.0 | The centroid of the finger presses must differ by more thanSWIPE_DISTANCE_THRESHOLD pixels from the centroid of the finger releases for thesingle finger swipe andmultiple finger swipe gestures to be recognized. |
| LONG_PRESS_TIME_THRESHOLD | 0.75 | The fingers must press forLONG_PRESS_TIME_THRESHOLD seconds forsingle-finger long press andmulti-finger long press gestures to be recognized. |
| LONG_PRESS_DISTANCE_LIMIT | 25.0 | The centroid of the finger presses must differ less thanLONG_PRESS_DISTANCE_LIMIT pixels from the centroid of the fingers last positions for thesingle finger long press andmultiple finger long press gestures to be recognized. |
By default, the control nodes consume events and therefore GDTIM cannot analyze them. To prevent this, setMouse>Filter toIgnore on control nodes as needed.
For more information see thedocumentation.
Custom input events do not trigger collisions, at the moment the solution is to manually check for collisions between shapes and events. For more information and ideas on how to do this seethis issue.
UsingSemVer for versioning. For the versions available, see thereleases.
- 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 comments toFederico.Ciuffardi@outlook.com.
If you are willing to contribute in any way, please contact me.
About
Asset that improves touch input support (includes new gestures) in the Godot game engine. It also translates mouse input to touch input.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Contributors9
Uh oh!
There was an error while loading.Please reload this page.



