iOS: move touch delay to settings

This commit is contained in:
Sergey Minakov 2020-09-27 20:31:02 +03:00
parent c723711bf4
commit 42de81e235
5 changed files with 18 additions and 5 deletions

View File

@ -567,6 +567,9 @@
<member name="input_devices/pointing/emulate_touch_from_mouse" type="bool" setter="" getter="" default="false"> <member name="input_devices/pointing/emulate_touch_from_mouse" type="bool" setter="" getter="" default="false">
If [code]true[/code], sends touch input events when clicking or dragging the mouse. If [code]true[/code], sends touch input events when clicking or dragging the mouse.
</member> </member>
<member name="input_devices/pointing/ios/touch_delay" type="float" setter="" getter="" default="0.150">
Default delay for touch events. This only affects iOS devices.
</member>
<member name="layer_names/2d_physics/layer_1" type="String" setter="" getter="" default="&quot;&quot;"> <member name="layer_names/2d_physics/layer_1" type="String" setter="" getter="" default="&quot;&quot;">
Optional name for the 2D physics layer 1. Optional name for the 2D physics layer 1.
</member> </member>

View File

@ -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 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("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); Engine::get_singleton()->set_frame_delay(frame_delay);

View File

@ -14,7 +14,7 @@ iphone_lib = [
"in_app_store.mm", "in_app_store.mm",
"icloud.mm", "icloud.mm",
"ios.mm", "ios.mm",
"gl_view_gesture_recognizer.m", "gl_view_gesture_recognizer.mm",
] ]
env_ios = env.Clone() env_ios = env.Clone()

View File

@ -49,6 +49,8 @@
UIEvent *delayedEvent; UIEvent *delayedEvent;
} }
@property(nonatomic, readonly, assign) NSTimeInterval delayTimeInterval;
- (instancetype)init; - (instancetype)init;
@end @end

View File

@ -1,5 +1,5 @@
/*************************************************************************/ /*************************************************************************/
/* gl_view_gesture_recognizer.m */ /* gl_view_gesture_recognizer.mm */
/*************************************************************************/ /*************************************************************************/
/* This file is part of: */ /* This file is part of: */
/* GODOT ENGINE */ /* GODOT ENGINE */
@ -30,8 +30,7 @@
#import "gl_view_gesture_recognizer.h" #import "gl_view_gesture_recognizer.h"
// Using same delay interval that is used for `UIScrollView` #include "core/project_settings.h"
const NSTimeInterval kGLGestureDelayInterval = 0.150;
// Minimum distance for touches to move to fire // Minimum distance for touches to move to fire
// a delay timer before scheduled time. // a delay timer before scheduled time.
@ -39,6 +38,12 @@ const NSTimeInterval kGLGestureDelayInterval = 0.150;
// but big enough to allow click to work. // but big enough to allow click to work.
const CGFloat kGLGestureMovementDistance = 0.5; const CGFloat kGLGestureMovementDistance = 0.5;
@interface GLViewGestureRecognizer ()
@property(nonatomic, readwrite, assign) NSTimeInterval delayTimeInterval;
@end
@implementation GLViewGestureRecognizer @implementation GLViewGestureRecognizer
- (instancetype)init { - (instancetype)init {
@ -48,6 +53,8 @@ const CGFloat kGLGestureMovementDistance = 0.5;
self.delaysTouchesBegan = YES; self.delaysTouchesBegan = YES;
self.delaysTouchesEnded = YES; self.delaysTouchesEnded = YES;
self.delayTimeInterval = GLOBAL_GET("input_devices/pointing/ios/touch_delay");
return self; return self;
} }
@ -57,7 +64,7 @@ const CGFloat kGLGestureMovementDistance = 0.5;
delayedTouches = touches; delayedTouches = touches;
delayedEvent = event; 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 { - (void)fireDelayedTouches:(id)timer {