84 + if ([self respondsToSelector:@selector(contentScaleFactor)]) |
84 + if ([self respondsToSelector:@selector(contentScaleFactor)]) |
85 + self.contentScaleFactor = [[UIScreen mainScreen] scale]; |
85 + self.contentScaleFactor = [[UIScreen mainScreen] scale]; |
86 } |
86 } |
87 |
87 |
88 - (void)setCurrentContext |
88 - (void)setCurrentContext |
|
89 diff -r 50560ca58f80 src/video/uikit/SDL_uikitvideo.m |
|
90 --- a/src/video/uikit/SDL_uikitvideo.m Mon Oct 24 23:18:53 2011 -0400 |
|
91 +++ b/src/video/uikit/SDL_uikitvideo.m Wed Nov 02 09:22:08 2011 +0100 |
|
92 @@ -178,7 +178,7 @@ |
|
93 |
|
94 // UIScreenMode showed up in 3.2 (the iPad and later). We're |
|
95 // misusing this supports_multiple_displays flag here for that. |
|
96 - if (!SDL_UIKit_supports_multiple_displays) { |
|
97 + if (SDL_UIKit_supports_multiple_displays) { |
|
98 UIScreenMode *uimode = [uiscreen currentMode]; |
|
99 [uimode retain]; // once for the desktop_mode |
|
100 [uimode retain]; // once for the current_mode |
|
101 @@ -200,10 +200,8 @@ |
|
102 { |
|
103 _this->gl_config.driver_loaded = 1; |
|
104 |
|
105 - NSString *reqSysVer = @"3.2"; |
|
106 - NSString *currSysVer = [[UIDevice currentDevice] systemVersion]; |
|
107 - if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending) |
|
108 - SDL_UIKit_supports_multiple_displays = YES; |
|
109 + // this tells us whether we are running on ios >= 3.2 |
|
110 + SDL_UIKit_supports_multiple_displays = [UIScreen instancesRespondToSelector:@selector(currentMode)]; |
|
111 |
|
112 // Add the main screen. |
|
113 UIScreen *uiscreen = [UIScreen mainScreen]; |
|
114 diff -r 50560ca58f80 src/video/uikit/SDL_uikitview.m |
|
115 --- a/src/video/uikit/SDL_uikitview.m Mon Oct 24 23:18:53 2011 -0400 |
|
116 +++ b/src/video/uikit/SDL_uikitview.m Wed Nov 02 09:22:08 2011 +0100 |
|
117 @@ -311,7 +311,7 @@ |
|
118 /* iPhone keyboard addition functions */ |
|
119 #if SDL_IPHONE_KEYBOARD |
|
120 |
|
121 -SDL_uikitview * getWindowView(SDL_Window * window) |
|
122 +SDL_uikitview *SDL_getUikitView(SDL_Window *window) |
|
123 { |
|
124 if (window == NULL) { |
|
125 SDL_SetError("Window does not exist"); |
|
126 @@ -328,9 +328,9 @@ |
|
127 return view; |
|
128 } |
|
129 |
|
130 -int SDL_iPhoneKeyboardShow(SDL_Window * window) |
|
131 +int SDL_iPhoneKeyboardShow(SDL_Window *window) |
|
132 { |
|
133 - SDL_uikitview *view = getWindowView(window); |
|
134 + SDL_uikitview *view = SDL_getUikitView(window); |
|
135 if (view == nil) { |
|
136 return -1; |
|
137 } |
|
138 @@ -339,9 +339,9 @@ |
|
139 return 0; |
|
140 } |
|
141 |
|
142 -int SDL_iPhoneKeyboardHide(SDL_Window * window) |
|
143 +int SDL_iPhoneKeyboardHide(SDL_Window *window) |
|
144 { |
|
145 - SDL_uikitview *view = getWindowView(window); |
|
146 + SDL_uikitview *view = SDL_getUikitView(window); |
|
147 if (view == nil) { |
|
148 return -1; |
|
149 } |
|
150 @@ -350,9 +350,9 @@ |
|
151 return 0; |
|
152 } |
|
153 |
|
154 -SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) |
|
155 +SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window *window) |
|
156 { |
|
157 - SDL_uikitview *view = getWindowView(window); |
|
158 + SDL_uikitview *view = SDL_getUikitView(window); |
|
159 if (view == nil) { |
|
160 return 0; |
|
161 } |
|
162 @@ -360,9 +360,9 @@ |
|
163 return view.keyboardVisible; |
|
164 } |
|
165 |
|
166 -int SDL_iPhoneKeyboardToggle(SDL_Window * window) |
|
167 +int SDL_iPhoneKeyboardToggle(SDL_Window *window) |
|
168 { |
|
169 - SDL_uikitview *view = getWindowView(window); |
|
170 + SDL_uikitview *view = SDL_getUikitView(window); |
|
171 if (view == nil) { |
|
172 return -1; |
|
173 } |
|
174 @@ -380,24 +380,24 @@ |
|
175 |
|
176 /* stubs, used if compiled without keyboard support */ |
|
177 |
|
178 -int SDL_iPhoneKeyboardShow(SDL_Window * window) |
|
179 +int SDL_iPhoneKeyboardShow(SDL_Window *window) |
|
180 { |
|
181 SDL_SetError("Not compiled with keyboard support"); |
|
182 return -1; |
|
183 } |
|
184 |
|
185 -int SDL_iPhoneKeyboardHide(SDL_Window * window) |
|
186 +int SDL_iPhoneKeyboardHide(SDL_Window *window) |
|
187 { |
|
188 SDL_SetError("Not compiled with keyboard support"); |
|
189 return -1; |
|
190 } |
|
191 |
|
192 -SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) |
|
193 +SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window *window) |
|
194 { |
|
195 return 0; |
|
196 } |
|
197 |
|
198 -int SDL_iPhoneKeyboardToggle(SDL_Window * window) |
|
199 +int SDL_iPhoneKeyboardToggle(SDL_Window *window) |
|
200 { |
|
201 SDL_SetError("Not compiled with keyboard support"); |
|
202 return -1; |
89 diff -r 50560ca58f80 src/video/uikit/SDL_uikitviewcontroller.m |
203 diff -r 50560ca58f80 src/video/uikit/SDL_uikitviewcontroller.m |
90 --- a/src/video/uikit/SDL_uikitviewcontroller.m Mon Oct 24 23:18:53 2011 -0400 |
204 --- a/src/video/uikit/SDL_uikitviewcontroller.m Mon Oct 24 23:18:53 2011 -0400 |
91 +++ b/src/video/uikit/SDL_uikitviewcontroller.m Tue Oct 25 22:13:19 2011 +0200 |
205 +++ b/src/video/uikit/SDL_uikitviewcontroller.m Wed Nov 02 09:22:08 2011 +0100 |
92 @@ -145,7 +145,7 @@ |
206 @@ -28,8 +28,8 @@ |
93 frame.origin.x = 0; |
207 |
94 frame.origin.y = 0; |
208 #include "SDL_uikitwindow.h" |
95 |
209 |
96 - [uiwindow setFrame:frame]; |
210 -#import "SDL_uikitviewcontroller.h" |
97 + [uiwindow setFrame:[[UIScreen mainScreen] bounds]]; |
211 - |
|
212 +#include "SDL_uikitviewcontroller.h" |
|
213 +#include "SDL_uikitvideo.h" |
|
214 |
|
215 @implementation SDL_uikitviewcontroller |
|
216 |
|
217 @@ -116,38 +116,17 @@ |
|
218 const UIInterfaceOrientation toInterfaceOrientation = [self interfaceOrientation]; |
|
219 SDL_WindowData *data = self->window->driverdata; |
|
220 UIWindow *uiwindow = data->uiwindow; |
|
221 - UIScreen *uiscreen = [uiwindow screen]; |
|
222 + UIScreen *uiscreen; |
|
223 + if (SDL_UIKit_supports_multiple_displays) |
|
224 + uiscreen = [uiwindow screen]; |
|
225 + else |
|
226 + uiscreen = [UIScreen mainScreen]; |
|
227 const int noborder = self->window->flags & SDL_WINDOW_BORDERLESS; |
|
228 CGRect frame = noborder ? [uiscreen bounds] : [uiscreen applicationFrame]; |
|
229 - const CGSize size = frame.size; |
|
230 - int w, h; |
|
231 - |
|
232 - switch (toInterfaceOrientation) { |
|
233 - case UIInterfaceOrientationPortrait: |
|
234 - case UIInterfaceOrientationPortraitUpsideDown: |
|
235 - w = (size.width < size.height) ? size.width : size.height; |
|
236 - h = (size.width > size.height) ? size.width : size.height; |
|
237 - break; |
|
238 - |
|
239 - case UIInterfaceOrientationLandscapeLeft: |
|
240 - case UIInterfaceOrientationLandscapeRight: |
|
241 - w = (size.width > size.height) ? size.width : size.height; |
|
242 - h = (size.width < size.height) ? size.width : size.height; |
|
243 - break; |
|
244 - |
|
245 - default: |
|
246 - SDL_assert(0 && "Unexpected interface orientation!"); |
|
247 - return; |
|
248 - } |
|
249 - |
|
250 - frame.size.width = w; |
|
251 - frame.size.height = h; |
|
252 - frame.origin.x = 0; |
|
253 - frame.origin.y = 0; |
|
254 |
|
255 [uiwindow setFrame:frame]; |
98 [data->view updateFrame]; |
256 [data->view updateFrame]; |
99 SDL_SendWindowEvent(self->window, SDL_WINDOWEVENT_RESIZED, w, h); |
257 - SDL_SendWindowEvent(self->window, SDL_WINDOWEVENT_RESIZED, w, h); |
100 } |
258 + SDL_SendWindowEvent(self->window, SDL_WINDOWEVENT_RESIZED, frame.size.width, frame.size.height); |
|
259 } |
|
260 |
|
261 @end |