diff --git a/Limelight/Input/StreamView.m b/Limelight/Input/StreamView.m index 28b3952..905d84d 100644 --- a/Limelight/Input/StreamView.m +++ b/Limelight/Input/StreamView.m @@ -19,36 +19,64 @@ touchLocation = [touch locationInView:self]; touchMoved = false; - printf("Touch down\n"); + NSLog(@"Touch down"); } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { - UITouch *touch = [[event allTouches] anyObject]; - CGPoint currentLocation = [touch locationInView:self]; - if (touchLocation.x != currentLocation.x || - touchLocation.y != currentLocation.y) - { - LiSendMouseMoveEvent(currentLocation.x - touchLocation.x, - currentLocation.y - touchLocation.y ); + if ([[event allTouches] count] == 1) { + UITouch *touch = [[event allTouches] anyObject]; + CGPoint currentLocation = [touch locationInView:self]; + + if (touchLocation.x != currentLocation.x || + touchLocation.y != currentLocation.y) + { + LiSendMouseMoveEvent(currentLocation.x - touchLocation.x, + currentLocation.y - touchLocation.y ); + + touchMoved = true; + touchLocation = currentLocation; + } + } else if ([[event allTouches] count] == 2) { + CGPoint firstLocation = [[[[event allTouches] allObjects] objectAtIndex:0] locationInView:self]; + CGPoint secondLocation = [[[[event allTouches] allObjects] objectAtIndex:1] locationInView:self]; + CGPoint avgLocation = CGPointMake((firstLocation.x + secondLocation.x) / 2, (firstLocation.y + secondLocation.y) / 2); + if (touchLocation.y != avgLocation.y) { + LiSendScrollEvent(avgLocation.y - touchLocation.y); + } touchMoved = true; - touchLocation = currentLocation; + touchLocation = avgLocation; } + } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { - printf("Touch up\n"); + NSLog(@"Touch up"); + if (!touchMoved) { - printf("Sending left mouse button press\n"); - - LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT); - - // Wait 100 ms to simulate a real button press - usleep(100 * 1000); - - LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT); + if ([[event allTouches] count] == 2) { + NSLog(@"Sending right mouse button press"); + + LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_RIGHT); + + // Wait 100 ms to simulate a real button press + usleep(100 * 1000); + + LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_RIGHT); + + + } else { + NSLog(@"Sending left mouse button press"); + + LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT); + + // Wait 100 ms to simulate a real button press + usleep(100 * 1000); + + LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT); + } } } diff --git a/iPad.storyboard b/iPad.storyboard index 86400a9..6aeb903 100644 --- a/iPad.storyboard +++ b/iPad.storyboard @@ -130,7 +130,7 @@ - + @@ -165,7 +165,7 @@ - + diff --git a/iPhone.storyboard b/iPhone.storyboard index cd22b7f..b350acd 100644 --- a/iPhone.storyboard +++ b/iPhone.storyboard @@ -132,7 +132,7 @@ - + @@ -166,7 +166,7 @@ - +