From 179110508c0885288d535c00389fbc8eb2806a25 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 10 Jan 2015 00:37:34 -0500 Subject: [PATCH] Scale mouse input deltas based on the ratio of the stream resolution to the screen size and the screen scale --- Limelight/Input/StreamView.h | 1 + Limelight/Input/StreamView.m | 20 ++++++++++++++++++-- Limelight/Stream/StreamManager.m | 8 ++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Limelight/Input/StreamView.h b/Limelight/Input/StreamView.h index ef4b009..e011409 100644 --- a/Limelight/Input/StreamView.h +++ b/Limelight/Input/StreamView.h @@ -12,5 +12,6 @@ @interface StreamView : UIView - (void) setupOnScreenControls:(ControllerSupport*)controllerSupport; +- (void) setMouseDeltaFactors:(float)x y:(float)y; @end diff --git a/Limelight/Input/StreamView.m b/Limelight/Input/StreamView.m index 1d68a5c..70508e6 100644 --- a/Limelight/Input/StreamView.m +++ b/Limelight/Input/StreamView.m @@ -16,6 +16,17 @@ CGPoint touchLocation; BOOL touchMoved; OnScreenControls* onScreenControls; + + float xDeltaFactor; + float yDeltaFactor; + float screenFactor; +} + +- (void) setMouseDeltaFactors:(float)x y:(float)y { + xDeltaFactor = x; + yDeltaFactor = y; + + screenFactor = [[UIScreen mainScreen] scale]; } - (void) setupOnScreenControls:(ControllerSupport*)controllerSupport { @@ -50,8 +61,13 @@ if (touchLocation.x != currentLocation.x || touchLocation.y != currentLocation.y) { - LiSendMouseMoveEvent(currentLocation.x - touchLocation.x, - currentLocation.y - touchLocation.y ); + int deltaX = currentLocation.x - touchLocation.x; + int deltaY = currentLocation.y - touchLocation.y; + + deltaX *= xDeltaFactor * screenFactor; + deltaY *= yDeltaFactor * screenFactor; + + LiSendMouseMoveEvent(deltaX, deltaY); touchMoved = true; touchLocation = currentLocation; diff --git a/Limelight/Stream/StreamManager.m b/Limelight/Stream/StreamManager.m index 577df4a..f57c6b9 100644 --- a/Limelight/Stream/StreamManager.m +++ b/Limelight/Stream/StreamManager.m @@ -11,6 +11,7 @@ #import "HttpManager.h" #import "Utils.h" #import "OnScreenControls.h" +#import "StreamView.h" @implementation StreamManager { StreamConfiguration* _config; @@ -73,6 +74,13 @@ } } + // Set mouse delta factors from the screen resolution and stream size + CGFloat screenScale = [[UIScreen mainScreen] scale]; + CGRect screenBounds = [[UIScreen mainScreen] bounds]; + CGSize screenSize = CGSizeMake(screenBounds.size.width * screenScale, screenBounds.size.height * screenScale); + [((StreamView*)_renderView) setMouseDeltaFactors:_config.width / screenSize.width + y:_config.height / screenSize.height]; + VideoDecoderRenderer* renderer = [[VideoDecoderRenderer alloc]initWithView:_renderView]; _connection = [[Connection alloc] initWithConfig:_config renderer:renderer connectionCallbacks:_callbacks]; NSOperationQueue* opQueue = [[NSOperationQueue alloc] init];