@@ -148,27 +148,30 @@ def swipe_vector(self, vector, box=(123, 159, 1175, 628), random_range=(0, 0, 0,
148148 self .swipe (p1 , p2 , duration = duration , name = name , distance_check = distance_check )
149149
150150 def drag (self , p1 , p2 , segments = 1 , shake = (0 , 15 ), point_random = (- 10 , - 10 , 10 , 10 ), shake_random = (- 5 , - 5 , 5 , 5 ),
151- swipe_duration = 0.25 , shake_duration = 0.1 , name = 'DRAG' ):
151+ swipe_duration = 0.25 , shake_duration = 0.1 , hold_duration = 0.0 , name = 'DRAG' ):
152152 self .handle_control_check (name )
153153 p1 , p2 = ensure_int (p1 , p2 )
154154 logger .info (
155155 'Drag %s -> %s' % (point2str (* p1 ), point2str (* p2 ))
156156 )
157157 method = self .config .Emulator_ControlMethod
158158 if method == 'minitouch' :
159- self .drag_minitouch (p1 , p2 , point_random = point_random )
159+ self .drag_minitouch (p1 , p2 , point_random = point_random , hold_duration = hold_duration )
160160 elif method == 'uiautomator2' :
161161 self .drag_uiautomator2 (
162162 p1 , p2 , segments = segments , shake = shake , point_random = point_random , shake_random = shake_random ,
163- swipe_duration = swipe_duration , shake_duration = shake_duration )
163+ swipe_duration = swipe_duration , shake_duration = shake_duration , hold_duration = hold_duration )
164164 elif method == 'scrcpy' :
165- self .drag_scrcpy (p1 , p2 , point_random = point_random )
165+ self .drag_scrcpy (p1 , p2 , point_random = point_random , hold_duration = hold_duration )
166166 elif method == 'MaaTouch' :
167- self .drag_maatouch (p1 , p2 , point_random = point_random )
167+ self .drag_maatouch (p1 , p2 , point_random = point_random , hold_duration = hold_duration )
168168 elif method == 'nemu_ipc' :
169- self .drag_nemu_ipc (p1 , p2 , point_random = point_random )
169+ self .drag_nemu_ipc (p1 , p2 , point_random = point_random , hold_duration = hold_duration )
170170 else :
171171 logger .warning (f'Control method { method } does not support drag well, '
172172 f'falling back to ADB swipe may cause unexpected behaviour' )
173173 self .swipe_adb (p1 , p2 , duration = ensure_time (swipe_duration * 2 ))
174+ hold_duration = ensure_time (hold_duration )
175+ if hold_duration > 0 :
176+ self .sleep (hold_duration )
174177 self .click (Button (area = (), color = (), button = area_offset (point_random , p2 ), name = name ), False )
0 commit comments