Implement horizontal scrolling

This commit is contained in:
Cameron Gutman
2023-02-20 16:00:03 -06:00
parent 5c844d3d1f
commit 0e40e4795a

View File

@@ -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;