diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index c845a157b89c..6d0c3025f65a 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -567,6 +567,9 @@ If [code]true[/code], sends touch input events when clicking or dragging the mouse. + + Default delay for touch events. This only affects iOS devices. + Optional name for the 2D physics layer 1. diff --git a/main/main.cpp b/main/main.cpp index c6bac052d2da..679170c0e1f5 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1202,6 +1202,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph ProjectSettings::get_singleton()->set_custom_property_info("application/run/low_processor_mode_sleep_usec", PropertyInfo(Variant::INT, "application/run/low_processor_mode_sleep_usec", PROPERTY_HINT_RANGE, "0,33200,1,or_greater")); // No negative numbers GLOBAL_DEF("display/window/ios/hide_home_indicator", true); + GLOBAL_DEF("input_devices/pointing/ios/touch_delay", 0.150); Engine::get_singleton()->set_frame_delay(frame_delay); diff --git a/platform/iphone/SCsub b/platform/iphone/SCsub index 168d2acd5be8..e5552200d7d9 100644 --- a/platform/iphone/SCsub +++ b/platform/iphone/SCsub @@ -14,7 +14,7 @@ iphone_lib = [ "in_app_store.mm", "icloud.mm", "ios.mm", - "gl_view_gesture_recognizer.m", + "gl_view_gesture_recognizer.mm", ] env_ios = env.Clone() diff --git a/platform/iphone/gl_view_gesture_recognizer.h b/platform/iphone/gl_view_gesture_recognizer.h index f94870c05dba..6c4ebd1201d8 100644 --- a/platform/iphone/gl_view_gesture_recognizer.h +++ b/platform/iphone/gl_view_gesture_recognizer.h @@ -49,6 +49,8 @@ UIEvent *delayedEvent; } +@property(nonatomic, readonly, assign) NSTimeInterval delayTimeInterval; + - (instancetype)init; @end diff --git a/platform/iphone/gl_view_gesture_recognizer.m b/platform/iphone/gl_view_gesture_recognizer.mm similarity index 91% rename from platform/iphone/gl_view_gesture_recognizer.m rename to platform/iphone/gl_view_gesture_recognizer.mm index 7a568a262bed..bf3572e8c3a8 100644 --- a/platform/iphone/gl_view_gesture_recognizer.m +++ b/platform/iphone/gl_view_gesture_recognizer.mm @@ -1,5 +1,5 @@ /*************************************************************************/ -/* gl_view_gesture_recognizer.m */ +/* gl_view_gesture_recognizer.mm */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -30,8 +30,7 @@ #import "gl_view_gesture_recognizer.h" -// Using same delay interval that is used for `UIScrollView` -const NSTimeInterval kGLGestureDelayInterval = 0.150; +#include "core/project_settings.h" // Minimum distance for touches to move to fire // a delay timer before scheduled time. @@ -39,6 +38,12 @@ // but big enough to allow click to work. const CGFloat kGLGestureMovementDistance = 0.5; +@interface GLViewGestureRecognizer () + +@property(nonatomic, readwrite, assign) NSTimeInterval delayTimeInterval; + +@end + @implementation GLViewGestureRecognizer - (instancetype)init { @@ -48,6 +53,8 @@ - (instancetype)init { self.delaysTouchesBegan = YES; self.delaysTouchesEnded = YES; + self.delayTimeInterval = GLOBAL_GET("input_devices/pointing/ios/touch_delay"); + return self; } @@ -57,7 +64,7 @@ - (void)delayTouches:(NSSet *)touches andEvent:(UIEvent *)event { delayedTouches = touches; delayedEvent = event; - delayTimer = [NSTimer scheduledTimerWithTimeInterval:kGLGestureDelayInterval target:self selector:@selector(fireDelayedTouches:) userInfo:nil repeats:NO]; + delayTimer = [NSTimer scheduledTimerWithTimeInterval:self.delayTimeInterval target:self selector:@selector(fireDelayedTouches:) userInfo:nil repeats:NO]; } - (void)fireDelayedTouches:(id)timer {