summaryrefslogtreecommitdiff
path: root/sdl2-macos-mouse-scrolling.diff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-11-10 12:17:54 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-11-10 12:17:54 +0200
commit8ec705003393f4a4b7430c81682541158e803816 (patch)
tree98f3130ad0d6315441fdd8bcc789b1f21103cc88 /sdl2-macos-mouse-scrolling.diff
parentf2df52c755e4211fea50afbecf552bd99a8d5fe5 (diff)
macOS: Improved scrolling using mouse wheel
This required further SDL hacking. The macOS SDL .diff was updated. IssueID #26
Diffstat (limited to 'sdl2-macos-mouse-scrolling.diff')
-rw-r--r--sdl2-macos-mouse-scrolling.diff36
1 files changed, 36 insertions, 0 deletions
diff --git a/sdl2-macos-mouse-scrolling.diff b/sdl2-macos-mouse-scrolling.diff
new file mode 100644
index 00000000..e2f30c24
--- /dev/null
+++ b/sdl2-macos-mouse-scrolling.diff
@@ -0,0 +1,36 @@
1diff -r 4f06c06b6d19 src/events/SDL_mouse.c
2--- a/src/events/SDL_mouse.c Wed Aug 05 15:28:51 2020 +0200
3+++ b/src/events/SDL_mouse.c Tue Nov 10 12:16:06 2020 +0200
4@@ -642,8 +642,8 @@
5 event.wheel.preciseX = x;
6 event.wheel.preciseY = y;
7 #endif
8- event.wheel.x = integral_x;
9- event.wheel.y = integral_y;
10+ event.wheel.x = x; //integral_x;
11+ event.wheel.y = y; //integral_y;
12 event.wheel.direction = (Uint32)direction;
13 posted = (SDL_PushEvent(&event) > 0);
14 }
15diff -r 4f06c06b6d19 src/video/cocoa/SDL_cocoamouse.m
16--- a/src/video/cocoa/SDL_cocoamouse.m Wed Aug 05 15:28:51 2020 +0200
17+++ b/src/video/cocoa/SDL_cocoamouse.m Tue Nov 10 12:16:06 2020 +0200
18@@ -424,10 +424,16 @@
19 }
20
21 SDL_MouseID mouseID = mouse->mouseID;
22- CGFloat x = -[event deltaX];
23- CGFloat y = [event deltaY];
24+ CGFloat x = -[event scrollingDeltaX];
25+ CGFloat y = [event scrollingDeltaY];
26 SDL_MouseWheelDirection direction = SDL_MOUSEWHEEL_NORMAL;
27
28+ /* HACK: Make a distinction between precise and imprecise scrolling.
29+ Trackpad seems to be mouseID 0. */
30+ if (![event hasPreciseScrollingDeltas]) {
31+ mouseID = 1;
32+ }
33+
34 if ([event respondsToSelector:@selector(isDirectionInvertedFromDevice)]) {
35 if ([event isDirectionInvertedFromDevice] == YES) {
36 direction = SDL_MOUSEWHEEL_FLIPPED;