From e8ea942ad2692967746f1f7104bef0430479cd4f Mon Sep 17 00:00:00 2001 From: Mimiste Date: Fri, 8 Apr 2016 00:12:59 +0200 Subject: [PATCH 1/3] Drag and drop Possibility to initiate a drag and drop - Touch for 2 second to initiate a drag - Move the cursor as usual - Tap top drop --- Limelight/Input/StreamView.m | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/Limelight/Input/StreamView.m b/Limelight/Input/StreamView.m index 3f6cb9a..ee387b1 100644 --- a/Limelight/Input/StreamView.m +++ b/Limelight/Input/StreamView.m @@ -17,6 +17,9 @@ BOOL touchMoved; OnScreenControls* onScreenControls; + BOOL isDragging; + NSTimer* dragTimer; + float xDeltaFactor; float yDeltaFactor; float screenFactor; @@ -49,11 +52,25 @@ UITouch *touch = [[event allTouches] anyObject]; touchLocation = [touch locationInView:self]; touchMoved = false; + dragTimer = [NSTimer scheduledTimerWithTimeInterval:2.0 + target:self + selector:@selector(onDragStart:) + userInfo:nil + repeats:NO]; + } +} + +- (void)onDragStart:(NSTimer*)timer { + if (!touchMoved && !isDragging){ + isDragging = true; + LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT); } } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { if (![onScreenControls handleTouchMovedEvent:touches]) { + [dragTimer invalidate]; + dragTimer = nil; if ([[event allTouches] count] == 1) { UITouch *touch = [[event allTouches] anyObject]; CGPoint currentLocation = [touch locationInView:self]; @@ -91,6 +108,8 @@ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { Log(LOG_D, @"Touch up"); if (![onScreenControls handleTouchUpEvent:touches]) { + [dragTimer invalidate]; + dragTimer = nil; if (!touchMoved) { if ([[event allTouches] count] == 2) { Log(LOG_D, @"Sending right mouse button press"); @@ -104,13 +123,15 @@ } else { - Log(LOG_D, @"Sending left mouse button press"); - - LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT); - - // Wait 100 ms to simulate a real button press - usleep(100 * 1000); - + if (!isDragging){ + Log(LOG_D, @"Sending left mouse button press"); + + LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT); + + // Wait 100 ms to simulate a real button press + usleep(100 * 1000); + } + isDragging = false; LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT); } } From 4caa9672c9a9bfa178a65809b2642ac837d89f86 Mon Sep 17 00:00:00 2001 From: Mimiste Date: Sun, 10 Apr 2016 13:02:00 +0200 Subject: [PATCH 2/3] Drag and drop The drag and drop is now enabled only if touching with one finger. The tap to drop does not fire another timer --- Limelight/Input/StreamView.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Limelight/Input/StreamView.m b/Limelight/Input/StreamView.m index ee387b1..9886d7d 100644 --- a/Limelight/Input/StreamView.m +++ b/Limelight/Input/StreamView.m @@ -52,11 +52,13 @@ UITouch *touch = [[event allTouches] anyObject]; touchLocation = [touch locationInView:self]; touchMoved = false; - dragTimer = [NSTimer scheduledTimerWithTimeInterval:2.0 + if ([[event allTouches] count] == 1 && !isDragging) { + dragTimer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(onDragStart:) userInfo:nil repeats:NO]; + } } } From 256e40acdc91cce244c5dfea82bde98303ddc475 Mon Sep 17 00:00:00 2001 From: Mimiste Date: Mon, 18 Apr 2016 19:44:00 +0200 Subject: [PATCH 3/3] 1 Second touch for the drag and drop Changed the timer duration to 1 second to initiate the drag and drop --- Limelight/Input/StreamView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Limelight/Input/StreamView.m b/Limelight/Input/StreamView.m index 9886d7d..70c425e 100644 --- a/Limelight/Input/StreamView.m +++ b/Limelight/Input/StreamView.m @@ -53,7 +53,7 @@ touchLocation = [touch locationInView:self]; touchMoved = false; if ([[event allTouches] count] == 1 && !isDragging) { - dragTimer = [NSTimer scheduledTimerWithTimeInterval:2.0 + dragTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(onDragStart:) userInfo:nil