summaryrefslogtreecommitdiff
path: root/sdl2.0.18-macos-ios.diff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2022-01-04 08:58:15 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2022-01-04 08:58:15 +0200
commit81610dc712d004e81f9bbf1feaf6433a09f56e3a (patch)
treebfac086f50c317dce2cf611944f0de4461c3935f /sdl2.0.18-macos-ios.diff
parentec575faf05060617b7ade4d3787b6f0e88a116bf (diff)
SDL patch for macOS and iOS updated for 2.0.18
SDL has added multiple input sources for mice.
Diffstat (limited to 'sdl2.0.18-macos-ios.diff')
-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) {