UITouch vector util
This commit is contained in:
@@ -1683,8 +1683,9 @@ import UIKit
|
||||
self.mousePointerMoved = true
|
||||
}
|
||||
|
||||
self.deltaX = UITouchUtil.getDeltaX(from: touch, in: self)
|
||||
self.deltaY = UITouchUtil.getDeltaY(from: touch, in: self)
|
||||
let vector = UITouchUtil.vector(of: touch, in: self)
|
||||
self.deltaX = vector.dx
|
||||
self.deltaY = vector.dy
|
||||
self.offSetX = currentTouchLocation.x - self.touchBeganLocation.x
|
||||
self.offSetY = currentTouchLocation.y - self.touchBeganLocation.y
|
||||
}
|
||||
|
||||
@@ -230,8 +230,9 @@ static const float QUICK_TAP_TIME_INTERVAL = 0.2;
|
||||
|
||||
- (void)sendMouseMoveEvent:(CGPoint)currentLocation{
|
||||
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0), ^{
|
||||
int deltaX = ([UITouchUtil getDeltaXFrom:self->touchLockedForMouseMove in:self->streamView]) * 1.35 * self->currentSettings.mousePointerVelocityFactor.floatValue;
|
||||
int deltaY = ([UITouchUtil getDeltaYFrom:self->touchLockedForMouseMove in:self->streamView]) * 1.35 * self->currentSettings.mousePointerVelocityFactor.floatValue;
|
||||
CGVector vector = [UITouchUtil vectorOf:self->touchLockedForMouseMove in:self->streamView];
|
||||
int deltaX = vector.dx * 1.35 * self->currentSettings.mousePointerVelocityFactor.floatValue;
|
||||
int deltaY = vector.dy * 1.35 * self->currentSettings.mousePointerVelocityFactor.floatValue;
|
||||
|
||||
if(self->touchPointSpawnedAtUpperScreenEdge) return; // we're done here. this touch event will not be sent to the remote PC.
|
||||
if(self->firstTouchMoved) LiSendMouseMoveEvent(deltaX, deltaY);
|
||||
|
||||
@@ -10,7 +10,7 @@ import UIKit
|
||||
|
||||
@objc class UITouchUtil: NSObject {
|
||||
@objc public static func touches(in view: UIView, from event: UIEvent?) -> Set<UITouch> {
|
||||
guard let allTouches = event?.allTouches else { return [] }
|
||||
guard (event?.allTouches) != nil else { return [] }
|
||||
return event?.allTouches?.filter({ $0.view == view }) ?? []
|
||||
}
|
||||
|
||||
@@ -28,6 +28,20 @@ import UIKit
|
||||
return hypot(p1.x - p2.x, p1.y - p2.y)
|
||||
}
|
||||
|
||||
@objc public static func vector(from touch1: UITouch?, to touch2: UITouch?, in view: UIView?) -> CGVector {
|
||||
guard let view = view, let touch1 = touch1, let touch2 = touch2 else { return CGVectorMake(0,0) }
|
||||
let p1 = touch1.location(in: view)
|
||||
let p2 = touch2.location(in: view)
|
||||
return CGVectorMake(p2.x - p1.x, p2.y - p1.y)
|
||||
}
|
||||
|
||||
@objc public static func vector(of touch: UITouch?, in view: UIView?) -> CGVector {
|
||||
guard let view = view, let touch = touch else { return CGVectorMake(0,0) }
|
||||
let p2 = touch.location(in: view)
|
||||
let p1 = touch.previousLocation(in: view)
|
||||
return CGVectorMake(p2.x - p1.x, p2.y - p1.y)
|
||||
}
|
||||
|
||||
@objc public static func getDeltaX(from touch: UITouch?, in view: UIView?) -> CGFloat {
|
||||
guard let view = view, let touch = touch else { return 0 }
|
||||
return touch.location(in: view).x - touch.previousLocation(in: view).x
|
||||
|
||||
Reference in New Issue
Block a user