Simulate finger long press somewhere. (1000ms = 1s)
169409
def long_press(self, x: int, y: int, duration: int = 1000) -> None:
        ''''''
        self._execute('-s', self.device_sn, 'shell',
                      'input', 'swipe', str(x), str(y), str(x), str(y), str(duration))
194441
private long toEpochNano() {
        long nod = time.toNanoOfDay();
        long offsetNanos = offset.getTotalSeconds() * NANOS_PER_SECOND;
        return nod - offsetNanos;
    }
43255
function simulateKeys(editor, keysString) {
    // there can be multiple pressed keys separated by spaces. To simulate a
    // space press use a double space. split up the individual keys and
    // simulate each
    function ensureSpaces(s) { return s.length ? s : ' '; }
    var pressedKeys = keysString.length === 1 ?
        [keysString] :
        keysString.split(/ /g).map(ensureSpaces)
    pressedKeys.forEach(exports.simulateKey.bind(null,editor));
}
376189
def triggerHapticPulse(self, unControllerDeviceIndex, unAxisId, usDurationMicroSec):
        

        fn = self.function_table.triggerHapticPulse
        fn(unControllerDeviceIndex, unAxisId, usDurationMicroSec)
1276853
function SingleTouchInput() {
    this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
    this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
    this.started = false;

    Input.apply(this, arguments);
}
365743
void robotPress(int click)
    {
        lastClick = click;
        if (lastClick < clicks.length)
        {
            clicks[lastClick] = true;
        }
    }
295151
def load_finger_tapping_mpower_data(filename, button_left_rect, button_right_rect, convert_times=1000.0):
    
    raw_data = pd.read_json(filename)
    date_times = pd.to_datetime(raw_data.TapTimeStamp * convert_times - raw_data.TapTimeStamp[0] * convert_times)
    time_difference = (raw_data.TapTimeStamp - raw_data.TapTimeStamp[0])
    time_difference = time_difference.values
    x = []
    y = []
    x_target = []
    y_target = []

    x_left, y_left, width_left, height_left = re.findall(r'-?\d+\.?\d*', button_left_rect)
    x_right, y_right, width_right, height_right = re.findall(r'-?\d+\.?\d*', button_right_rect)

    x_left_target = float(x_left) + ( float(width_left) / 2.0 )
    y_left_target = float(y_left) + ( float(height_left) / 2.0 )

    x_right_target = float(x_right) + ( float(width_right) / 2.0 )
    y_right_target = float(y_right) + ( float(height_right) / 2.0 )

    for row_index, row in raw_data.iterrows():
        x_coord, y_coord = re.findall(r'-?\d+\.?\d*', row.TapCoordinate)
        x.append(float(x_coord))
        y.append(float(y_coord))
        if row.TappedButtonId == 'TappedButtonLeft':
            x_target.append(x_left_target)
            y_target.append(y_left_target)
        else:
            x_target.append(x_right_target)
            y_target.append(y_right_target)

    data = {'td': time_difference, 'action_type': 1.0, 'x': x, 'y': y, 'x_target': x_target, 'y_target': y_target}
    data_frame = pd.DataFrame(data, index=date_times, columns=['td', 'action_type', 'x', 'y', 'x_target', 'y_target'])
    data_frame.index.name = 'timestamp'
    return data_frame
250625
function multitouch(position, element, done) {
                var points = config.randomizer.integer({ min: 2, max: config.maxTouches});
                var gesture = {
                    scale:     config.randomizer.floating({ min: 0, max: 2 }),
                    rotation:  config.randomizer.natural({ min: -100, max: 100 }),
                    radius:    config.randomizer.integer({ min: 50, max: 200 }),
                    distanceX: config.randomizer.integer({ min: -20, max: 20 }),
                    distanceY: config.randomizer.integer({ min: -20, max: 20 }),
                    duration:  config.randomizer.integer({ min: 100, max: 1500 })
                };
                var touches = getTouches(position, points, gesture.radius);

                triggerGesture(element, position, touches, gesture, function(touches) {
                    done(touches, gesture);
                });
            }
1116753
def longTouchPoint(self, x, y):
        '''
        
        '''

        if DEBUG:
            print >> sys.stderr, 'longTouchPoint(%d, %d)' % (x, y)
        if self.areEventsDisabled:
            if DEBUG:
                print >> sys.stderr, "Ignoring event"
            self.canvas.update_idletasks()
            return
        if DEBUG:
            print >> sys.stderr, "Is long touching point:", self.isLongTouchingPoint
        if self.isLongTouchingPoint:
            self.showVignette()
            self.vc.longTouch(x, y)
            if self.coordinatesUnit == Unit.DIP:
                x = round(x / self.device.display['density'], 2)
                y = round(y / self.device.display['density'], 2)
            self.printOperation(None, Operation.LONG_TOUCH_POINT, x, y, 2000, self.coordinatesUnit,
                                self.device.display['orientation'])
            self.sleep(5)
            self.isLongTouchingPoint = False
            self.takeScreenshotAndShowItOnWindow()
            # self.hideVignette()
            self.statusBar.clear()
            return
1358159
def longTouch(self, duration=2000):
        '''
        
        '''

        (x, y) = self.getCenter()
        if self.uiAutomatorHelper:
            self.uiAutomatorHelper.swipe(startX=x, startY=y, endX=x, endY=y, steps=200)
        else:
            # FIXME: get orientation
            self.device.longTouch(x, y, duration, orientation=-1)
1235694
def FromNanoseconds(self, nanos):
    """"""
    self.seconds = nanos // _NANOS_PER_SECOND
    self.nanos = nanos % _NANOS_PER_SECOND
600845
function touchMove(jqEvent) {
			
			//As we use Jquery bind for events, we need to target the original event object
			//If these events are being programmatically triggered, we don't have an original event object, so use the Jq one.
			var event = jqEvent.originalEvent ? jqEvent.originalEvent : jqEvent;
			
			//If we are ending, cancelling, or within the threshold of 2 fingers being released, don't track anything..
			if (phase === PHASE_END || phase === PHASE_CANCEL || inMultiFingerRelease())
				return;

			var ret,
				touches = event.touches,
				evt = touches ? touches[0] : event;
			

			//Update the  finger data 
			var currentFinger = updateFingerData(evt);
			endTime = getTimeStamp();
			
			if (touches) {
				fingerCount = touches.length;
			}

			if (options.hold)
				clearTimeout(holdTimeout);

			phase = PHASE_MOVE;

			//If we have 2 fingers get Touches distance as well
			if(fingerCount==2) {
				
				//Keep track of the initial pinch distance, so we can calculate the diff later
				//We do this here as well as the start event, in case they start with 1 finger, and the press 2 fingers
				if(startTouchesDistance==0) {
					//Create second finger if this is the first time...
					createFingerData( 1, touches[1] );
					
					startTouchesDistance = endTouchesDistance = calculateTouchesDistance(fingerData[0].start, fingerData[1].start);
				} else {
					//Else just update the second finger
					updateFingerData(touches[1]);
				
					endTouchesDistance = calculateTouchesDistance(fingerData[0].end, fingerData[1].end);
					pinchDirection = calculatePinchDirection(fingerData[0].end, fingerData[1].end);
				}
				
				
				pinchZoom = calculatePinchZoom(startTouchesDistance, endTouchesDistance);
				pinchDistance = Math.abs(startTouchesDistance - endTouchesDistance);
			}
			
			
			

			if ( (fingerCount === options.fingers || options.fingers === ALL_FINGERS) || !touches || hasPinches() ) {
				
				direction = calculateDirection(currentFinger.start, currentFinger.end);
				
				//Check if we need to prevent default event (page scroll / pinch zoom) or not
				validateDefaultEvent(jqEvent, direction);

				//Distance and duration are all off the main finger
				distance = calculateDistance(currentFinger.start, currentFinger.end);
				duration = calculateDuration();

                //Cache the maximum distance we made in this direction
                setMaxDistance(direction, distance);


				if (options.swipeStatus || options.pinchStatus) {
					ret = triggerHandler(event, phase);
				}
				
				
				//If we trigger end events when threshold are met, or trigger events when touch leaves element
				if(!options.triggerOnTouchEnd || options.triggerOnTouchLeave) {
					
					var inBounds = true;
					
					//If checking if we leave the element, run the bounds check (we can use touchleave as its not supported on webkit)
					if(options.triggerOnTouchLeave) {
						var bounds = getbounds( this );
						inBounds = isInBounds( currentFinger.end, bounds );
					}
					
					//Trigger end handles as we swipe if thresholds met or if we have left the element if the user has asked to check these..
					if(!options.triggerOnTouchEnd && inBounds) {
						phase = getNextPhase( PHASE_MOVE );
					} 
					//We end if out of bounds here, so set current phase to END, and check if its modified 
					else if(options.triggerOnTouchLeave && !inBounds ) {
						phase = getNextPhase( PHASE_END );
					}
						
					if(phase==PHASE_CANCEL || phase==PHASE_END)	{
						triggerHandler(event, phase);
					}				
				}
			}
			else {
				phase = PHASE_CANCEL;
				triggerHandler(event, phase);
			}

			if (ret === false) {
				phase = PHASE_CANCEL;
				triggerHandler(event, phase);
			}
		}
1027038
def press(button=LEFT):
    
    location = get_position()
    button_code, button_down, _, _ = _button_mapping[button]
    e = Quartz.CGEventCreateMouseEvent(
        None,
        button_down,
        location,
        button_code)

    # Check if this is a double-click (same location within the last 300ms)
    if _last_click["time"] is not None and datetime.datetime.now() - _last_click["time"] < datetime.timedelta(seconds=0.3) and _last_click["button"] == button and _last_click["position"] == location:
        # Repeated Click
        _last_click["click_count"] = min(3, _last_click["click_count"]+1)
    else:
        # Not a double-click - Reset last click
        _last_click["click_count"] = 1
    Quartz.CGEventSetIntegerValueField(
        e,
        Quartz.kCGMouseEventClickState,
        _last_click["click_count"])
    Quartz.CGEventPost(Quartz.kCGHIDEventTap, e)
    _button_state[button] = True
    _last_click["time"] = datetime.datetime.now()
    _last_click["button"] = button
    _last_click["position"] = location
960691
def long_click(self, pos, duration=2.0):
        

        try:
            duration = float(duration)
        except ValueError:
            raise ValueError('Argument `duration` should be <float>. Got {}'.format(repr(duration)))

        if not (0 <= pos[0] <= 1) or not (0 <= pos[1] <= 1):
            raise InvalidOperationException('Click position out of screen. {}'.format(repr(pos)))
        return self.agent.input.longClick(pos[0], pos[1], duration)
729128
private static void waiting(int milliseconds) {
        long t0, t1;
        t0 = System.currentTimeMillis();
        do {
            t1 = System.currentTimeMillis();
        } while ((t1 - t0) < milliseconds);
    }
1110841
def end(self, n=1, interval=0, pre_dl=None, post_dl=None):
        
        self.delay(pre_dl)
        self.k.tap_key(self.k.end_key, n, interval)
        self.delay(post_dl)
854743
def tap_hold(self, x, y, duration=1.0):
        
        data = {'x': x, 'y': y, 'duration': duration}
        return self.http.post('/wda/touchAndHold', data=data)