From 0e40e4795a697bda7d8240d2767d7fb3f3a582bc Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 20 Feb 2023 16:00:03 -0600 Subject: [PATCH] Implement horizontal scrolling --- Limelight/Input/StreamView.m | 37 +++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/Limelight/Input/StreamView.m b/Limelight/Input/StreamView.m index 04b93a8e..a399858a 100644 --- a/Limelight/Input/StreamView.m +++ b/Limelight/Input/StreamView.m @@ -474,10 +474,22 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; } CGPoint currentScrollTranslation = [gesture translationInView:self]; - short translationDeltaY = ((currentScrollTranslation.y - lastScrollTranslation.y) / self.bounds.size.height) * 120; // WHEEL_DELTA - if (translationDeltaY != 0) { - LiSendHighResScrollEvent(translationDeltaY * 20); - lastScrollTranslation = currentScrollTranslation; + + { + short translationDeltaY = ((currentScrollTranslation.y - lastScrollTranslation.y) / self.bounds.size.height) * 120; // WHEEL_DELTA + if (translationDeltaY != 0) { + LiSendHighResScrollEvent(translationDeltaY * 20); + lastScrollTranslation = currentScrollTranslation; + } + } + + { + short translationDeltaX = ((currentScrollTranslation.x - lastScrollTranslation.x) / self.bounds.size.width) * 120; // WHEEL_DELTA + if (translationDeltaX != 0) { + // Direction is reversed from vertical scrolling + LiSendHighResHScrollEvent(-translationDeltaX * 20); + lastScrollTranslation = currentScrollTranslation; + } } } @@ -497,9 +509,20 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; // Using velocityInView is 0 for discrete scroll events // when scrolling very slowly, but translationInView does work. CGPoint currentScrollTranslation = [gesture translationInView:self]; - short translationDeltaY = currentScrollTranslation.y - lastScrollTranslation.y; - if (translationDeltaY != 0) { - LiSendScrollEvent(translationDeltaY > 0 ? 1 : -1); + + { + short translationDeltaY = currentScrollTranslation.y - lastScrollTranslation.y; + if (translationDeltaY != 0) { + LiSendScrollEvent(translationDeltaY > 0 ? 1 : -1); + } + } + + { + short translationDeltaX = currentScrollTranslation.x - lastScrollTranslation.x; + if (translationDeltaX != 0) { + // Direction is reversed from vertical scrolling + LiSendHScrollEvent(translationDeltaX < 0 ? 1 : -1); + } } lastScrollTranslation = currentScrollTranslation;