mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-06-17 06:01:13 +00:00
Allow click and drag via tvOS remote trackpad
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
@property (nonatomic, retain) IBOutlet UITextField* keyInputField;
|
@property (nonatomic, retain) IBOutlet UITextField* keyInputField;
|
||||||
|
|
||||||
|
- (void) setupStreamView;
|
||||||
- (void) setupOnScreenControls:(ControllerSupport*)controllerSupport swipeDelegate:(id<EdgeDetectionDelegate>)swipeDelegate;
|
- (void) setupOnScreenControls:(ControllerSupport*)controllerSupport swipeDelegate:(id<EdgeDetectionDelegate>)swipeDelegate;
|
||||||
- (void) setMouseDeltaFactors:(float)x y:(float)y;
|
- (void) setMouseDeltaFactors:(float)x y:(float)y;
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,11 @@
|
|||||||
float yDeltaFactor;
|
float yDeltaFactor;
|
||||||
float screenFactor;
|
float screenFactor;
|
||||||
|
|
||||||
|
#if TARGET_OS_TV
|
||||||
|
UIGestureRecognizer* remotePressRecognizer;
|
||||||
|
UIGestureRecognizer* remoteLongPressRecognizer;
|
||||||
|
#endif
|
||||||
|
|
||||||
NSDictionary<NSString *, NSNumber *> *dictCodes;
|
NSDictionary<NSString *, NSNumber *> *dictCodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,6 +41,19 @@
|
|||||||
screenFactor = [[UIScreen mainScreen] scale];
|
screenFactor = [[UIScreen mainScreen] scale];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setupStreamView {
|
||||||
|
#if TARGET_OS_TV
|
||||||
|
remotePressRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(remoteButtonPressed:)];
|
||||||
|
remotePressRecognizer.allowedPressTypes = @[@(UIPressTypeSelect)];
|
||||||
|
|
||||||
|
remoteLongPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(remoteButtonLongPressed:)];
|
||||||
|
remoteLongPressRecognizer.allowedPressTypes = @[@(UIPressTypeSelect)];
|
||||||
|
|
||||||
|
[self addGestureRecognizer:remotePressRecognizer];
|
||||||
|
[self addGestureRecognizer:remoteLongPressRecognizer];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
- (void) setupOnScreenControls:(ControllerSupport*)controllerSupport swipeDelegate:(id<EdgeDetectionDelegate>)swipeDelegate {
|
- (void) setupOnScreenControls:(ControllerSupport*)controllerSupport swipeDelegate:(id<EdgeDetectionDelegate>)swipeDelegate {
|
||||||
onScreenControls = [[OnScreenControls alloc] initWithView:self controllerSup:controllerSupport swipeDelegate:swipeDelegate];
|
onScreenControls = [[OnScreenControls alloc] initWithView:self controllerSup:controllerSupport swipeDelegate:swipeDelegate];
|
||||||
DataManager* dataMan = [[DataManager alloc] init];
|
DataManager* dataMan = [[DataManager alloc] init];
|
||||||
@@ -199,6 +217,30 @@
|
|||||||
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
|
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if TARGET_OS_TV
|
||||||
|
- (void)remoteButtonPressed:(id)sender {
|
||||||
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
||||||
|
Log(LOG_D, @"Sending left mouse button press");
|
||||||
|
|
||||||
|
// Mark this as touchMoved to avoid a duplicate press on touch up
|
||||||
|
self->touchMoved = true;
|
||||||
|
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT);
|
||||||
|
|
||||||
|
// Wait 100 ms to simulate a real button press
|
||||||
|
usleep(100 * 1000);
|
||||||
|
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
- (void)remoteButtonLongPressed:(id)sender {
|
||||||
|
Log(LOG_D, @"Holding left mouse button");
|
||||||
|
|
||||||
|
isDragging = true;
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
|
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
|
||||||
// Disable all gesture recognizers to prevent them from eating our touches.
|
// Disable all gesture recognizers to prevent them from eating our touches.
|
||||||
// This can happen on iOS 13 where the 3 finger tap gesture is taken over for
|
// This can happen on iOS 13 where the 3 finger tap gesture is taken over for
|
||||||
|
|||||||
@@ -50,6 +50,8 @@
|
|||||||
|
|
||||||
[self.navigationController setNavigationBarHidden:YES animated:YES];
|
[self.navigationController setNavigationBarHidden:YES animated:YES];
|
||||||
|
|
||||||
|
[(StreamView*)self.view setupStreamView];
|
||||||
|
|
||||||
[self.stageLabel setText:[NSString stringWithFormat:@"Starting %@...", self.streamConfig.appName]];
|
[self.stageLabel setText:[NSString stringWithFormat:@"Starting %@...", self.streamConfig.appName]];
|
||||||
[self.stageLabel sizeToFit];
|
[self.stageLabel sizeToFit];
|
||||||
self.stageLabel.textAlignment = NSTextAlignmentCenter;
|
self.stageLabel.textAlignment = NSTextAlignmentCenter;
|
||||||
|
|||||||
Reference in New Issue
Block a user