From c99ee24c6524fe3f3d3a5b13abbaa425eee688eb Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 15 Oct 2021 22:32:32 -0500 Subject: [PATCH] Restore GCMouse scroll handling for tvOS --- Limelight/Input/ControllerSupport.m | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Limelight/Input/ControllerSupport.m b/Limelight/Input/ControllerSupport.m index ca4a7faf..e8ab1e78 100644 --- a/Limelight/Input/ControllerSupport.m +++ b/Limelight/Input/ControllerSupport.m @@ -432,6 +432,24 @@ static const double MOUSE_SPEED_DIVISOR = 2.5; }; } } + + // We use UIPanGestureRecognizer on iPadOS because it allows us to distinguish + // between discrete and continuous scroll events and also works around a bug + // in iPadOS 15 where discrete scroll events are dropped. tvOS only supports + // GCMouse for mice, so we will have to just use it and hope for the best. +#if TARGET_OS_TV + mouse.mouseInput.scroll.yAxis.valueChangedHandler = ^(GCControllerAxisInput * _Nonnull axis, float value) { + self->accumulatedScrollY += -value; + + short truncatedScrollY = (short)self->accumulatedScrollY; + + if (truncatedScrollY != 0) { + LiSendHighResScrollEvent(truncatedScrollY); + + self->accumulatedScrollY -= truncatedScrollY; + } + }; +#endif } -(void) updateAutoOnScreenControlMode