summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-12-25 06:36:48 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-12-25 06:36:48 +0200
commitf4650ecca043b630259470f34deed100b66929c6 (patch)
tree60b7ceb5b3a8c1fc71cc6c9fb2e94b289c39feb3
parent011cff2b2fbba3910bb9aeae527602749ec7a814 (diff)
SDL: Updated patch for 2.0.18
There were a few changes, particularly with the precise wheel XY now being available. Lagrange v1.10 will listen to Cocoa wheel events directly, though, so these can be removed later on.
-rw-r--r--sdl2.0.18-macos-ios.diff129
1 files changed, 129 insertions, 0 deletions
diff --git a/sdl2.0.18-macos-ios.diff b/sdl2.0.18-macos-ios.diff
new file mode 100644
index 00000000..8c143226
--- /dev/null
+++ b/sdl2.0.18-macos-ios.diff
@@ -0,0 +1,129 @@
1diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c
2index 539f17138..a5a5b00fd 100644
3--- a/src/events/SDL_mouse.c
4+++ b/src/events/SDL_mouse.c
5@@ -709,8 +709,8 @@ SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, float x, float y, S
6 event.type = SDL_MOUSEWHEEL;
7 event.wheel.windowID = mouse->focus ? mouse->focus->id : 0;
8 event.wheel.which = mouseID;
9- event.wheel.x = integral_x;
10- event.wheel.y = integral_y;
11+ event.wheel.x = x; //integral_x;
12+ event.wheel.y = y; //integral_y;
13 event.wheel.preciseX = x;
14 event.wheel.preciseY = y;
15 event.wheel.direction = (Uint32)direction;
16diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m
17index e9d832d64..4cfa3624b 100644
18--- a/src/video/cocoa/SDL_cocoamouse.m
19+++ b/src/video/cocoa/SDL_cocoamouse.m
20@@ -463,10 +463,16 @@ + (NSCursor *)invisibleCursor
21 }
22
23 SDL_MouseID mouseID = mouse->mouseID;
24- CGFloat x = -[event deltaX];
25- CGFloat y = [event deltaY];
26+ CGFloat x = -[event scrollingDeltaX];
27+ CGFloat y = [event scrollingDeltaY];
28 SDL_MouseWheelDirection direction = SDL_MOUSEWHEEL_NORMAL;
29
30+ /* HACK: Make a distinction between precise and imprecise scrolling.
31+ Trackpad seems to be mouseID 0. */
32+ if (![event hasPreciseScrollingDeltas]) {
33+ mouseID = 1;
34+ }
35+
36 if ([event respondsToSelector:@selector(isDirectionInvertedFromDevice)]) {
37 if ([event isDirectionInvertedFromDevice] == YES) {
38 direction = SDL_MOUSEWHEEL_FLIPPED;
39diff --git a/src/video/cocoa/SDL_cocoawindow.h b/src/video/cocoa/SDL_cocoawindow.h
40index 489db169f..79a41dd50 100644
41--- a/src/video/cocoa/SDL_cocoawindow.h
42+++ b/src/video/cocoa/SDL_cocoawindow.h
43@@ -110,6 +110,8 @@ typedef enum
44 /* Touch event handling */
45 -(void) handleTouches:(NSTouchPhase) phase withEvent:(NSEvent*) theEvent;
46
47+-(void) syncMouseButtonAndKeyboardModifierState;
48+
49 @end
50 /* *INDENT-ON* */
51
52diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
53index f09088c45..7379c2269 100644
54--- a/src/video/cocoa/SDL_cocoawindow.m
55+++ b/src/video/cocoa/SDL_cocoawindow.m
56@@ -1236,6 +1236,25 @@ - (void)otherMouseDown:(NSEvent *)theEvent
57 [self mouseDown:theEvent];
58 }
59
60+- (void)syncMouseButtonAndKeyboardModifierState {
61+ SDL_Mouse *mouse = SDL_GetMouse();
62+ if (mouse) {
63+ for (int i = 0; i < mouse->num_sources; i++) {
64+ if (mouse->sources[i].mouseID == mouse->mouseID) {
65+ mouse->sources[i].buttonstate = 0;
66+ }
67+ }
68+ }
69+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LGUI);
70+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RGUI);
71+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
72+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RSHIFT);
73+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LCTRL);
74+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RCTRL);
75+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LALT);
76+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RALT);
77+}
78+
79 - (void)mouseUp:(NSEvent *)theEvent
80 {
81 SDL_Mouse *mouse = SDL_GetMouse();
82diff --git a/src/video/uikit/SDL_uikitviewcontroller.h b/src/video/uikit/SDL_uikitviewcontroller.h
83index f7f4c9de6..50c72aad0 100644
84--- a/src/video/uikit/SDL_uikitviewcontroller.h
85+++ b/src/video/uikit/SDL_uikitviewcontroller.h
86@@ -58,10 +58,13 @@
87 #if !TARGET_OS_TV
88 - (NSUInteger)supportedInterfaceOrientations;
89 - (BOOL)prefersStatusBarHidden;
90+- (void)setStatusStyle:(UIStatusBarStyle)style;
91+- (UIStatusBarStyle)preferredStatusBarStyle;
92 - (BOOL)prefersHomeIndicatorAutoHidden;
93 - (UIRectEdge)preferredScreenEdgesDeferringSystemGestures;
94
95 @property (nonatomic, assign) int homeIndicatorHidden;
96+@property (nonatomic, assign) UIStatusBarStyle statusBarStyle;
97 #endif
98
99 #if SDL_IPHONE_KEYBOARD
100diff --git a/src/video/uikit/SDL_uikitviewcontroller.m b/src/video/uikit/SDL_uikitviewcontroller.m
101index b2db4037d..d39f8085c 100644
102--- a/src/video/uikit/SDL_uikitviewcontroller.m
103+++ b/src/video/uikit/SDL_uikitviewcontroller.m
104@@ -105,6 +105,7 @@ - (instancetype)initWithSDLWindow:(SDL_Window *)_window
105 #endif
106
107 #if !TARGET_OS_TV
108+ self.statusBarStyle = UIStatusBarStyleDefault;
109 SDL_AddHintCallback(SDL_HINT_IOS_HIDE_HOME_INDICATOR,
110 SDL_HideHomeIndicatorHintChanged,
111 (__bridge void *) self);
112@@ -230,6 +231,17 @@ - (BOOL)prefersHomeIndicatorAutoHidden
113 return hidden;
114 }
115
116+- (void)setStatusStyle:(UIStatusBarStyle)style
117+{
118+ self.statusBarStyle = style;
119+ [self setNeedsStatusBarAppearanceUpdate];
120+}
121+
122+- (UIStatusBarStyle)preferredStatusBarStyle
123+{
124+ return self.statusBarStyle;
125+}
126+
127 - (UIRectEdge)preferredScreenEdgesDeferringSystemGestures
128 {
129 if (self.homeIndicatorHidden >= 0) {