Mercurial > sdl-ios-xcode
comparison src/video/uikit/SDL_uikitview.m @ 5134:7b7da52e8775
Fixed spacing
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 01 Feb 2011 08:59:22 -0800 |
parents | 25d4feb7c127 |
children | 5f09cb749d75 |
comparison
equal
deleted
inserted
replaced
5133:ec13e48ee0d9 | 5134:7b7da52e8775 |
---|---|
33 #endif | 33 #endif |
34 | 34 |
35 @implementation SDL_uikitview | 35 @implementation SDL_uikitview |
36 | 36 |
37 - (void)dealloc { | 37 - (void)dealloc { |
38 [super dealloc]; | 38 [super dealloc]; |
39 } | 39 } |
40 | 40 |
41 - (id)initWithFrame:(CGRect)frame { | 41 - (id)initWithFrame:(CGRect)frame { |
42 | 42 |
43 self = [super initWithFrame: frame]; | 43 self = [super initWithFrame: frame]; |
44 | 44 |
45 #if SDL_IPHONE_KEYBOARD | 45 #if SDL_IPHONE_KEYBOARD |
46 [self initializeKeyboard]; | 46 [self initializeKeyboard]; |
47 #endif | 47 #endif |
48 | 48 |
49 #ifdef FIXED_MULTITOUCH | 49 #ifdef FIXED_MULTITOUCH |
50 SDL_Touch touch; | 50 SDL_Touch touch; |
51 touch.id = 0; //TODO: Should be -1? | 51 touch.id = 0; //TODO: Should be -1? |
52 | 52 |
53 //touch.driverdata = SDL_malloc(sizeof(EventTouchData)); | 53 //touch.driverdata = SDL_malloc(sizeof(EventTouchData)); |
54 //EventTouchData* data = (EventTouchData*)(touch.driverdata); | 54 //EventTouchData* data = (EventTouchData*)(touch.driverdata); |
55 | 55 |
56 touch.x_min = 0; | 56 touch.x_min = 0; |
57 touch.x_max = frame.size.width; | 57 touch.x_max = frame.size.width; |
58 touch.native_xres = touch.x_max - touch.x_min; | 58 touch.native_xres = touch.x_max - touch.x_min; |
59 touch.y_min = 0; | 59 touch.y_min = 0; |
60 touch.y_max = frame.size.height; | 60 touch.y_max = frame.size.height; |
61 touch.native_yres = touch.y_max - touch.y_min; | 61 touch.native_yres = touch.y_max - touch.y_min; |
62 touch.pressure_min = 0; | 62 touch.pressure_min = 0; |
63 touch.pressure_max = 1; | 63 touch.pressure_max = 1; |
64 touch.native_pressureres = touch.pressure_max - touch.pressure_min; | 64 touch.native_pressureres = touch.pressure_max - touch.pressure_min; |
65 | 65 |
66 | 66 |
67 touchId = SDL_AddTouch(&touch, "IPHONE SCREEN"); | 67 touchId = SDL_AddTouch(&touch, "IPHONE SCREEN"); |
68 #endif | 68 #endif |
69 | 69 |
70 return self; | 70 return self; |
71 | 71 |
72 } | 72 } |
73 | 73 |
74 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { | 74 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { |
75 | 75 |
76 NSEnumerator *enumerator = [touches objectEnumerator]; | 76 NSEnumerator *enumerator = [touches objectEnumerator]; |
77 UITouch *touch = (UITouch*)[enumerator nextObject]; | 77 UITouch *touch = (UITouch*)[enumerator nextObject]; |
78 | 78 |
79 //NSLog("Click"); | 79 //NSLog("Click"); |
80 | 80 |
81 if (touch) { | 81 if (touch) { |
82 CGPoint locationInView = [touch locationInView: self]; | 82 CGPoint locationInView = [touch locationInView: self]; |
83 | 83 |
84 /* send moved event */ | 84 /* send moved event */ |
85 SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y); | 85 SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y); |
86 | 86 |
87 /* send mouse down event */ | 87 /* send mouse down event */ |
88 SDL_SendMouseButton(NULL, SDL_PRESSED, SDL_BUTTON_LEFT); | 88 SDL_SendMouseButton(NULL, SDL_PRESSED, SDL_BUTTON_LEFT); |
89 } | 89 } |
90 | 90 |
91 #ifdef FIXED_MULTITOUCH | 91 #ifdef FIXED_MULTITOUCH |
92 while(touch) { | 92 while(touch) { |
93 CGPoint locationInView = [touch locationInView: self]; | 93 CGPoint locationInView = [touch locationInView: self]; |
94 | 94 |
95 | 95 |
96 #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS | 96 #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS |
97 //FIXME: TODO: Using touch as the fingerId is potentially dangerous | 97 //FIXME: TODO: Using touch as the fingerId is potentially dangerous |
98 //It is also much more efficient than storing the UITouch pointer | 98 //It is also much more efficient than storing the UITouch pointer |
99 //and comparing it to the incoming event. | 99 //and comparing it to the incoming event. |
100 SDL_SendFingerDown(touchId,(long)touch, | 100 SDL_SendFingerDown(touchId,(long)touch, |
101 SDL_TRUE,locationInView.x,locationInView.y, | 101 SDL_TRUE,locationInView.x,locationInView.y, |
102 1); | 102 1); |
103 #else | 103 #else |
104 int i; | 104 int i; |
105 for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) { | 105 for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) { |
106 if(finger[i] == NULL) { | 106 if(finger[i] == NULL) { |
107 finger[i] = touch; | 107 finger[i] = touch; |
108 SDL_SendFingerDown(touchId,i, | 108 SDL_SendFingerDown(touchId,i, |
109 SDL_TRUE,locationInView.x,locationInView.y, | 109 SDL_TRUE,locationInView.x,locationInView.y, |
110 1); | 110 1); |
111 break; | 111 break; |
112 } | 112 } |
113 } | 113 } |
114 #endif | 114 #endif |
115 | 115 |
116 | 116 |
117 | 117 |
118 | 118 |
119 touch = (UITouch*)[enumerator nextObject]; | 119 touch = (UITouch*)[enumerator nextObject]; |
120 } | 120 } |
121 #endif | 121 #endif |
122 } | 122 } |
123 | 123 |
124 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { | 124 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { |
125 | 125 |
126 NSEnumerator *enumerator = [touches objectEnumerator]; | 126 NSEnumerator *enumerator = [touches objectEnumerator]; |
127 UITouch *touch = (UITouch*)[enumerator nextObject]; | 127 UITouch *touch = (UITouch*)[enumerator nextObject]; |
128 | 128 |
129 if (touch) { | 129 if (touch) { |
130 /* send mouse up */ | 130 /* send mouse up */ |
131 SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT); | 131 SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT); |
132 } | 132 } |
133 | 133 |
134 #ifdef FIXED_MULTITOUCH | 134 #ifdef FIXED_MULTITOUCH |
135 while(touch) { | 135 while(touch) { |
136 CGPoint locationInView = [touch locationInView: self]; | 136 CGPoint locationInView = [touch locationInView: self]; |
137 | 137 |
138 | 138 |
139 #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS | 139 #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS |
140 SDL_SendFingerDown(touchId,(long)touch, | 140 SDL_SendFingerDown(touchId,(long)touch, |
141 SDL_FALSE,locationInView.x,locationInView.y, | 141 SDL_FALSE,locationInView.x,locationInView.y, |
142 1); | 142 1); |
143 #else | 143 #else |
144 int i; | 144 int i; |
145 for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) { | 145 for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) { |
146 if(finger[i] == touch) { | 146 if(finger[i] == touch) { |
147 SDL_SendFingerDown(touchId,i, | 147 SDL_SendFingerDown(touchId,i, |
148 SDL_FALSE,locationInView.x,locationInView.y, | 148 SDL_FALSE,locationInView.x,locationInView.y, |
149 1); | 149 1); |
150 break; | 150 break; |
151 } | 151 } |
152 } | 152 } |
153 #endif | 153 #endif |
154 | 154 |
155 touch = (UITouch*)[enumerator nextObject]; | 155 touch = (UITouch*)[enumerator nextObject]; |
156 } | 156 } |
157 #endif | 157 #endif |
158 } | 158 } |
159 | 159 |
160 - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { | 160 - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { |
161 /* | 161 /* |
162 this can happen if the user puts more than 5 touches on the screen | 162 this can happen if the user puts more than 5 touches on the screen |
163 at once, or perhaps in other circumstances. Usually (it seems) | 163 at once, or perhaps in other circumstances. Usually (it seems) |
164 all active touches are canceled. | 164 all active touches are canceled. |
165 */ | 165 */ |
166 [self touchesEnded: touches withEvent: event]; | 166 [self touchesEnded: touches withEvent: event]; |
167 } | 167 } |
168 | 168 |
169 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { | 169 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { |
170 | 170 |
171 NSEnumerator *enumerator = [touches objectEnumerator]; | 171 NSEnumerator *enumerator = [touches objectEnumerator]; |
172 UITouch *touch = (UITouch*)[enumerator nextObject]; | 172 UITouch *touch = (UITouch*)[enumerator nextObject]; |
173 | 173 |
174 if (touch) { | 174 if (touch) { |
175 CGPoint locationInView = [touch locationInView: self]; | 175 CGPoint locationInView = [touch locationInView: self]; |
176 | 176 |
177 /* send moved event */ | 177 /* send moved event */ |
178 SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y); | 178 SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y); |
179 } | 179 } |
180 | 180 |
181 #ifdef FIXED_MULTITOUCH | 181 #ifdef FIXED_MULTITOUCH |
182 while(touch) { | 182 while(touch) { |
183 CGPoint locationInView = [touch locationInView: self]; | 183 CGPoint locationInView = [touch locationInView: self]; |
184 | 184 |
185 | 185 |
186 #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS | 186 #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS |
187 SDL_SendTouchMotion(touchId,(long)touch, | 187 SDL_SendTouchMotion(touchId,(long)touch, |
188 SDL_FALSE,locationInView.x,locationInView.y, | 188 SDL_FALSE,locationInView.x,locationInView.y, |
189 1); | 189 1); |
190 #else | 190 #else |
191 int i; | 191 int i; |
192 for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) { | 192 for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) { |
193 if(finger[i] == touch) { | 193 if(finger[i] == touch) { |
194 SDL_SendTouchMotion(touchId,i, | 194 SDL_SendTouchMotion(touchId,i, |
195 SDL_FALSE,locationInView.x,locationInView.y, | 195 SDL_FALSE,locationInView.x,locationInView.y, |
196 1); | 196 1); |
197 break; | 197 break; |
198 } | 198 } |
199 } | 199 } |
200 #endif | 200 #endif |
201 | 201 |
202 touch = (UITouch*)[enumerator nextObject]; | 202 touch = (UITouch*)[enumerator nextObject]; |
203 } | 203 } |
204 #endif | 204 #endif |
205 } | 205 } |
206 | 206 |
207 /* | 207 /* |
208 ---- Keyboard related functionality below this line ---- | 208 ---- Keyboard related functionality below this line ---- |
209 */ | 209 */ |
210 #if SDL_IPHONE_KEYBOARD | 210 #if SDL_IPHONE_KEYBOARD |
211 | 211 |
212 /* Is the iPhone virtual keyboard visible onscreen? */ | 212 /* Is the iPhone virtual keyboard visible onscreen? */ |
213 - (BOOL)keyboardVisible { | 213 - (BOOL)keyboardVisible { |
214 return keyboardVisible; | 214 return keyboardVisible; |
215 } | 215 } |
216 | 216 |
217 /* Set ourselves up as a UITextFieldDelegate */ | 217 /* Set ourselves up as a UITextFieldDelegate */ |
218 - (void)initializeKeyboard { | 218 - (void)initializeKeyboard { |
219 | 219 |
220 textField = [[UITextField alloc] initWithFrame: CGRectZero]; | 220 textField = [[UITextField alloc] initWithFrame: CGRectZero]; |
221 textField.delegate = self; | 221 textField.delegate = self; |
222 /* placeholder so there is something to delete! */ | 222 /* placeholder so there is something to delete! */ |
223 textField.text = @" "; | 223 textField.text = @" "; |
224 | 224 |
225 /* set UITextInputTrait properties, mostly to defaults */ | 225 /* set UITextInputTrait properties, mostly to defaults */ |
226 textField.autocapitalizationType = UITextAutocapitalizationTypeNone; | 226 textField.autocapitalizationType = UITextAutocapitalizationTypeNone; |
227 textField.autocorrectionType = UITextAutocorrectionTypeNo; | 227 textField.autocorrectionType = UITextAutocorrectionTypeNo; |
228 textField.enablesReturnKeyAutomatically = NO; | 228 textField.enablesReturnKeyAutomatically = NO; |
229 textField.keyboardAppearance = UIKeyboardAppearanceDefault; | 229 textField.keyboardAppearance = UIKeyboardAppearanceDefault; |
230 textField.keyboardType = UIKeyboardTypeDefault; | 230 textField.keyboardType = UIKeyboardTypeDefault; |
231 textField.returnKeyType = UIReturnKeyDefault; | 231 textField.returnKeyType = UIReturnKeyDefault; |
232 textField.secureTextEntry = NO; | 232 textField.secureTextEntry = NO; |
233 | 233 |
234 textField.hidden = YES; | 234 textField.hidden = YES; |
235 keyboardVisible = NO; | 235 keyboardVisible = NO; |
236 /* add the UITextField (hidden) to our view */ | 236 /* add the UITextField (hidden) to our view */ |
237 [self addSubview: textField]; | 237 [self addSubview: textField]; |
238 [textField release]; | 238 [textField release]; |
239 } | 239 } |
240 | 240 |
241 /* reveal onscreen virtual keyboard */ | 241 /* reveal onscreen virtual keyboard */ |
242 - (void)showKeyboard { | 242 - (void)showKeyboard { |
243 keyboardVisible = YES; | 243 keyboardVisible = YES; |
244 [textField becomeFirstResponder]; | 244 [textField becomeFirstResponder]; |
245 } | 245 } |
246 | 246 |
247 /* hide onscreen virtual keyboard */ | 247 /* hide onscreen virtual keyboard */ |
248 - (void)hideKeyboard { | 248 - (void)hideKeyboard { |
249 keyboardVisible = NO; | 249 keyboardVisible = NO; |
250 [textField resignFirstResponder]; | 250 [textField resignFirstResponder]; |
251 } | 251 } |
252 | 252 |
253 /* UITextFieldDelegate method. Invoked when user types something. */ | 253 /* UITextFieldDelegate method. Invoked when user types something. */ |
254 - (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { | 254 - (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { |
255 | 255 |
256 if ([string length] == 0) { | 256 if ([string length] == 0) { |
257 /* it wants to replace text with nothing, ie a delete */ | 257 /* it wants to replace text with nothing, ie a delete */ |
258 SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE); | 258 SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE); |
259 SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE); | 259 SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE); |
260 } | 260 } |
261 else { | 261 else { |
262 /* go through all the characters in the string we've been sent | 262 /* go through all the characters in the string we've been sent |
263 and convert them to key presses */ | 263 and convert them to key presses */ |
264 int i; | 264 int i; |
265 for (i=0; i<[string length]; i++) { | 265 for (i=0; i<[string length]; i++) { |
266 | 266 |
267 unichar c = [string characterAtIndex: i]; | 267 unichar c = [string characterAtIndex: i]; |
268 | 268 |
269 Uint16 mod = 0; | 269 Uint16 mod = 0; |
270 SDL_ScanCode code; | 270 SDL_ScanCode code; |
271 | 271 |
272 if (c < 127) { | 272 if (c < 127) { |
273 /* figure out the SDL_ScanCode and SDL_keymod for this unichar */ | 273 /* figure out the SDL_ScanCode and SDL_keymod for this unichar */ |
274 code = unicharToUIKeyInfoTable[c].code; | 274 code = unicharToUIKeyInfoTable[c].code; |
275 mod = unicharToUIKeyInfoTable[c].mod; | 275 mod = unicharToUIKeyInfoTable[c].mod; |
276 } | 276 } |
277 else { | 277 else { |
278 /* we only deal with ASCII right now */ | 278 /* we only deal with ASCII right now */ |
279 code = SDL_SCANCODE_UNKNOWN; | 279 code = SDL_SCANCODE_UNKNOWN; |
280 mod = 0; | 280 mod = 0; |
281 } | 281 } |
282 | 282 |
283 if (mod & KMOD_SHIFT) { | 283 if (mod & KMOD_SHIFT) { |
284 /* If character uses shift, press shift down */ | 284 /* If character uses shift, press shift down */ |
285 SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT); | 285 SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT); |
286 } | 286 } |
287 /* send a keydown and keyup even for the character */ | 287 /* send a keydown and keyup even for the character */ |
288 SDL_SendKeyboardKey(SDL_PRESSED, code); | 288 SDL_SendKeyboardKey(SDL_PRESSED, code); |
289 SDL_SendKeyboardKey(SDL_RELEASED, code); | 289 SDL_SendKeyboardKey(SDL_RELEASED, code); |
290 if (mod & KMOD_SHIFT) { | 290 if (mod & KMOD_SHIFT) { |
291 /* If character uses shift, press shift back up */ | 291 /* If character uses shift, press shift back up */ |
292 SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT); | 292 SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT); |
293 } | 293 } |
294 } | 294 } |
295 } | 295 } |
296 return NO; /* don't allow the edit! (keep placeholder text there) */ | 296 return NO; /* don't allow the edit! (keep placeholder text there) */ |
297 } | 297 } |
298 | 298 |
299 /* Terminates the editing session */ | 299 /* Terminates the editing session */ |
300 - (BOOL)textFieldShouldReturn:(UITextField*)_textField { | 300 - (BOOL)textFieldShouldReturn:(UITextField*)_textField { |
301 [self hideKeyboard]; | 301 [self hideKeyboard]; |
302 return YES; | 302 return YES; |
303 } | 303 } |
304 | 304 |
305 #endif | 305 #endif |
306 | 306 |
307 @end | 307 @end |
308 | 308 |
309 /* iPhone keyboard addition functions */ | 309 /* iPhone keyboard addition functions */ |
310 #if SDL_IPHONE_KEYBOARD | 310 #if SDL_IPHONE_KEYBOARD |
311 | 311 |
312 int SDL_iPhoneKeyboardShow(SDL_Window * window) { | 312 int SDL_iPhoneKeyboardShow(SDL_Window * window) { |
313 | 313 |
314 SDL_WindowData *data; | 314 SDL_WindowData *data; |
315 SDL_uikitview *view; | 315 SDL_uikitview *view; |
316 | 316 |
317 if (NULL == window) { | 317 if (NULL == window) { |
318 SDL_SetError("Window does not exist"); | 318 SDL_SetError("Window does not exist"); |
319 return -1; | 319 return -1; |
320 } | 320 } |
321 | 321 |
322 data = (SDL_WindowData *)window->driverdata; | 322 data = (SDL_WindowData *)window->driverdata; |
323 view = data->view; | 323 view = data->view; |
324 | 324 |
325 if (nil == view) { | 325 if (nil == view) { |
326 SDL_SetError("Window has no view"); | 326 SDL_SetError("Window has no view"); |
327 return -1; | 327 return -1; |
328 } | 328 } |
329 else { | 329 else { |
330 [view showKeyboard]; | 330 [view showKeyboard]; |
331 return 0; | 331 return 0; |
332 } | 332 } |
333 } | 333 } |
334 | 334 |
335 int SDL_iPhoneKeyboardHide(SDL_Window * window) { | 335 int SDL_iPhoneKeyboardHide(SDL_Window * window) { |
336 | 336 |
337 SDL_WindowData *data; | 337 SDL_WindowData *data; |
338 SDL_uikitview *view; | 338 SDL_uikitview *view; |
339 | 339 |
340 if (NULL == window) { | 340 if (NULL == window) { |
341 SDL_SetError("Window does not exist"); | 341 SDL_SetError("Window does not exist"); |
342 return -1; | 342 return -1; |
343 } | 343 } |
344 | 344 |
345 data = (SDL_WindowData *)window->driverdata; | 345 data = (SDL_WindowData *)window->driverdata; |
346 view = data->view; | 346 view = data->view; |
347 | 347 |
348 if (NULL == view) { | 348 if (NULL == view) { |
349 SDL_SetError("Window has no view"); | 349 SDL_SetError("Window has no view"); |
350 return -1; | 350 return -1; |
351 } | 351 } |
352 else { | 352 else { |
353 [view hideKeyboard]; | 353 [view hideKeyboard]; |
354 return 0; | 354 return 0; |
355 } | 355 } |
356 } | 356 } |
357 | 357 |
358 SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) { | 358 SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) { |
359 | 359 |
360 SDL_WindowData *data; | 360 SDL_WindowData *data; |
361 SDL_uikitview *view; | 361 SDL_uikitview *view; |
362 | 362 |
363 if (NULL == window) { | 363 if (NULL == window) { |
364 SDL_SetError("Window does not exist"); | 364 SDL_SetError("Window does not exist"); |
365 return -1; | 365 return -1; |
366 } | 366 } |
367 | 367 |
368 data = (SDL_WindowData *)window->driverdata; | 368 data = (SDL_WindowData *)window->driverdata; |
369 view = data->view; | 369 view = data->view; |
370 | 370 |
371 if (NULL == view) { | 371 if (NULL == view) { |
372 SDL_SetError("Window has no view"); | 372 SDL_SetError("Window has no view"); |
373 return 0; | 373 return 0; |
374 } | 374 } |
375 else { | 375 else { |
376 return view.keyboardVisible; | 376 return view.keyboardVisible; |
377 } | 377 } |
378 } | 378 } |
379 | 379 |
380 int SDL_iPhoneKeyboardToggle(SDL_Window * window) { | 380 int SDL_iPhoneKeyboardToggle(SDL_Window * window) { |
381 | 381 |
382 SDL_WindowData *data; | 382 SDL_WindowData *data; |
383 SDL_uikitview *view; | 383 SDL_uikitview *view; |
384 | 384 |
385 if (NULL == window) { | 385 if (NULL == window) { |
386 SDL_SetError("Window does not exist"); | 386 SDL_SetError("Window does not exist"); |
387 return -1; | 387 return -1; |
388 } | 388 } |
389 | 389 |
390 data = (SDL_WindowData *)window->driverdata; | 390 data = (SDL_WindowData *)window->driverdata; |
391 view = data->view; | 391 view = data->view; |
392 | 392 |
393 if (NULL == view) { | 393 if (NULL == view) { |
394 SDL_SetError("Window has no view"); | 394 SDL_SetError("Window has no view"); |
395 return -1; | 395 return -1; |
396 } | 396 } |
397 else { | 397 else { |
398 if (SDL_iPhoneKeyboardIsShown(window)) { | 398 if (SDL_iPhoneKeyboardIsShown(window)) { |
399 SDL_iPhoneKeyboardHide(window); | 399 SDL_iPhoneKeyboardHide(window); |
400 } | 400 } |
401 else { | 401 else { |
402 SDL_iPhoneKeyboardShow(window); | 402 SDL_iPhoneKeyboardShow(window); |
403 } | 403 } |
404 return 0; | 404 return 0; |
405 } | 405 } |
406 } | 406 } |
407 | 407 |
408 #else | 408 #else |
409 | 409 |
410 /* stubs, used if compiled without keyboard support */ | 410 /* stubs, used if compiled without keyboard support */ |
411 | 411 |
412 int SDL_iPhoneKeyboardShow(SDL_Window * window) { | 412 int SDL_iPhoneKeyboardShow(SDL_Window * window) { |
413 SDL_SetError("Not compiled with keyboard support"); | 413 SDL_SetError("Not compiled with keyboard support"); |
414 return -1; | 414 return -1; |
415 } | 415 } |
416 | 416 |
417 int SDL_iPhoneKeyboardHide(SDL_Window * window) { | 417 int SDL_iPhoneKeyboardHide(SDL_Window * window) { |
418 SDL_SetError("Not compiled with keyboard support"); | 418 SDL_SetError("Not compiled with keyboard support"); |
419 return -1; | 419 return -1; |
420 } | 420 } |
421 | 421 |
422 SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) { | 422 SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) { |
423 return 0; | 423 return 0; |
424 } | 424 } |
425 | 425 |
426 int SDL_iPhoneKeyboardToggle(SDL_Window * window) { | 426 int SDL_iPhoneKeyboardToggle(SDL_Window * window) { |
427 SDL_SetError("Not compiled with keyboard support"); | 427 SDL_SetError("Not compiled with keyboard support"); |
428 return -1; | 428 return -1; |
429 } | 429 } |
430 | 430 |
431 | 431 |
432 #endif /* SDL_IPHONE_KEYBOARD */ | 432 #endif /* SDL_IPHONE_KEYBOARD */ |