summaryrefslogtreecommitdiff
path: root/sdl2-macos-ios.diff
blob: 62178f630bb946133fa05e6dba32e747fb68c784 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c
index a776bcca8..2d5e685e3 100644
--- a/src/events/SDL_mouse.c
+++ b/src/events/SDL_mouse.c
@@ -647,8 +647,8 @@ SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, float x, float y, S
         event.wheel.preciseX = x;
         event.wheel.preciseY = y;
 #endif
-        event.wheel.x = integral_x;
-        event.wheel.y = integral_y;
+        event.wheel.x = x; //integral_x;
+        event.wheel.y = y; //integral_y;
         event.wheel.direction = (Uint32)direction;
         posted = (SDL_PushEvent(&event) > 0);
     }
diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m
index e9d832d64..4cfa3624b 100644
--- a/src/video/cocoa/SDL_cocoamouse.m
+++ b/src/video/cocoa/SDL_cocoamouse.m
@@ -463,10 +463,16 @@ + (NSCursor *)invisibleCursor
     }
 
     SDL_MouseID mouseID = mouse->mouseID;
-    CGFloat x = -[event deltaX];
-    CGFloat y = [event deltaY];
+    CGFloat x = -[event scrollingDeltaX];
+    CGFloat y = [event scrollingDeltaY];
     SDL_MouseWheelDirection direction = SDL_MOUSEWHEEL_NORMAL;
 
+    /* HACK: Make a distinction between precise and imprecise scrolling.
+       Trackpad seems to be mouseID 0. */
+    if (![event hasPreciseScrollingDeltas]) {
+        mouseID = 1;
+    }
+
     if ([event respondsToSelector:@selector(isDirectionInvertedFromDevice)]) {
         if ([event isDirectionInvertedFromDevice] == YES) {
             direction = SDL_MOUSEWHEEL_FLIPPED;
diff --git a/src/video/cocoa/SDL_cocoawindow.h b/src/video/cocoa/SDL_cocoawindow.h
index 37bec665e..9b2f0510c 100644
--- a/src/video/cocoa/SDL_cocoawindow.h
+++ b/src/video/cocoa/SDL_cocoawindow.h
@@ -109,6 +109,8 @@ typedef enum
 /* Touch event handling */
 -(void) handleTouches:(NSTouchPhase) phase withEvent:(NSEvent*) theEvent;
 
+-(void) syncMouseButtonAndKeyboardModifierState;
+
 @end
 /* *INDENT-ON* */
 
diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
index 7a1446f09..a6da2f9d7 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -1073,6 +1073,21 @@ - (void)otherMouseDown:(NSEvent *)theEvent
     [self mouseDown:theEvent];
 }
 
+- (void)syncMouseButtonAndKeyboardModifierState {
+    SDL_Mouse *mouse = SDL_GetMouse();
+    if (mouse) {
+        mouse->buttonstate = SDL_GetGlobalMouseState(NULL, NULL);
+    }
+    SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LGUI);
+    SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RGUI);
+    SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
+    SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RSHIFT);
+    SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LCTRL);
+    SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RCTRL);
+    SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LALT);
+    SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RALT);
+}
+
 - (void)mouseUp:(NSEvent *)theEvent
 {
     const SDL_Mouse *mouse = SDL_GetMouse();
diff --git a/src/video/uikit/SDL_uikitviewcontroller.h b/src/video/uikit/SDL_uikitviewcontroller.h
index f7f4c9de6..50c72aad0 100644
--- a/src/video/uikit/SDL_uikitviewcontroller.h
+++ b/src/video/uikit/SDL_uikitviewcontroller.h
@@ -58,10 +58,13 @@
 #if !TARGET_OS_TV
 - (NSUInteger)supportedInterfaceOrientations;
 - (BOOL)prefersStatusBarHidden;
+- (void)setStatusStyle:(UIStatusBarStyle)style;
+- (UIStatusBarStyle)preferredStatusBarStyle;
 - (BOOL)prefersHomeIndicatorAutoHidden;
 - (UIRectEdge)preferredScreenEdgesDeferringSystemGestures;
 
 @property (nonatomic, assign) int homeIndicatorHidden;
+@property (nonatomic, assign) UIStatusBarStyle statusBarStyle;
 #endif
 
 #if SDL_IPHONE_KEYBOARD
diff --git a/src/video/uikit/SDL_uikitviewcontroller.m b/src/video/uikit/SDL_uikitviewcontroller.m
index c51d1aed2..cd8db9517 100644
--- a/src/video/uikit/SDL_uikitviewcontroller.m
+++ b/src/video/uikit/SDL_uikitviewcontroller.m
@@ -105,6 +105,7 @@ - (instancetype)initWithSDLWindow:(SDL_Window *)_window
 #endif
 
 #if !TARGET_OS_TV
+        self.statusBarStyle = UIStatusBarStyleDefault;
         SDL_AddHintCallback(SDL_HINT_IOS_HIDE_HOME_INDICATOR,
                             SDL_HideHomeIndicatorHintChanged,
                             (__bridge void *) self);
@@ -230,6 +231,17 @@ - (BOOL)prefersHomeIndicatorAutoHidden
     return hidden;
 }
 
+- (void)setStatusStyle:(UIStatusBarStyle)style
+{
+    self.statusBarStyle = style;
+    [self setNeedsStatusBarAppearanceUpdate];
+}
+
+- (UIStatusBarStyle)preferredStatusBarStyle
+{
+    return self.statusBarStyle;
+}
+
 - (UIRectEdge)preferredScreenEdgesDeferringSystemGestures
 {
     if (self.homeIndicatorHidden >= 0) {