mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-06-17 14:11:35 +00:00
Scale mouse input deltas based on the ratio of the stream resolution to the screen size and the screen scale
This commit is contained in:
@@ -12,5 +12,6 @@
|
|||||||
@interface StreamView : UIView
|
@interface StreamView : UIView
|
||||||
|
|
||||||
- (void) setupOnScreenControls:(ControllerSupport*)controllerSupport;
|
- (void) setupOnScreenControls:(ControllerSupport*)controllerSupport;
|
||||||
|
- (void) setMouseDeltaFactors:(float)x y:(float)y;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -16,6 +16,17 @@
|
|||||||
CGPoint touchLocation;
|
CGPoint touchLocation;
|
||||||
BOOL touchMoved;
|
BOOL touchMoved;
|
||||||
OnScreenControls* onScreenControls;
|
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 {
|
- (void) setupOnScreenControls:(ControllerSupport*)controllerSupport {
|
||||||
@@ -50,8 +61,13 @@
|
|||||||
if (touchLocation.x != currentLocation.x ||
|
if (touchLocation.x != currentLocation.x ||
|
||||||
touchLocation.y != currentLocation.y)
|
touchLocation.y != currentLocation.y)
|
||||||
{
|
{
|
||||||
LiSendMouseMoveEvent(currentLocation.x - touchLocation.x,
|
int deltaX = currentLocation.x - touchLocation.x;
|
||||||
currentLocation.y - touchLocation.y );
|
int deltaY = currentLocation.y - touchLocation.y;
|
||||||
|
|
||||||
|
deltaX *= xDeltaFactor * screenFactor;
|
||||||
|
deltaY *= yDeltaFactor * screenFactor;
|
||||||
|
|
||||||
|
LiSendMouseMoveEvent(deltaX, deltaY);
|
||||||
|
|
||||||
touchMoved = true;
|
touchMoved = true;
|
||||||
touchLocation = currentLocation;
|
touchLocation = currentLocation;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#import "HttpManager.h"
|
#import "HttpManager.h"
|
||||||
#import "Utils.h"
|
#import "Utils.h"
|
||||||
#import "OnScreenControls.h"
|
#import "OnScreenControls.h"
|
||||||
|
#import "StreamView.h"
|
||||||
|
|
||||||
@implementation StreamManager {
|
@implementation StreamManager {
|
||||||
StreamConfiguration* _config;
|
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];
|
VideoDecoderRenderer* renderer = [[VideoDecoderRenderer alloc]initWithView:_renderView];
|
||||||
_connection = [[Connection alloc] initWithConfig:_config renderer:renderer connectionCallbacks:_callbacks];
|
_connection = [[Connection alloc] initWithConfig:_config renderer:renderer connectionCallbacks:_callbacks];
|
||||||
NSOperationQueue* opQueue = [[NSOperationQueue alloc] init];
|
NSOperationQueue* opQueue = [[NSOperationQueue alloc] init];
|
||||||
|
|||||||
Reference in New Issue
Block a user