author | koda |
Sun, 24 Jan 2010 13:37:03 +0000 | |
changeset 2705 | 2b5625c4ec16 |
parent 2701 | 3a8560c00f78 |
child 2714 | c85ffe57d971 |
permissions | -rw-r--r-- |
2688 | 1 |
/* |
2 |
SDL - Simple DirectMedia Layer |
|
3 |
Copyright (C) 1997-2009 Sam Lantinga |
|
4 |
||
5 |
This library is free software; you can redistribute it and/or |
|
6 |
modify it under the terms of the GNU Lesser General Public |
|
7 |
License as published by the Free Software Foundation; either |
|
8 |
version 2.1 of the License, or (at your option) any later version. |
|
9 |
||
10 |
This library is distributed in the hope that it will be useful, |
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 |
Lesser General Public License for more details. |
|
14 |
||
15 |
You should have received a copy of the GNU Lesser General Public |
|
16 |
License along with this library; if not, write to the Free Software |
|
17 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
18 |
||
19 |
Sam Lantinga, mods for Hedgewars by Vittorio Giovara |
|
20 |
slouken@libsdl.org, vittorio.giovara@gmail.com |
|
21 |
*/ |
|
22 |
||
23 |
#include "PascalImports.h" |
|
24 |
#import "SDL_uikitview.h" |
|
25 |
#import "SDL_uikitappdelegate.h" |
|
26 |
||
27 |
#if SDL_IPHONE_KEYBOARD |
|
28 |
#import "SDL_keyboard_c.h" |
|
29 |
#import "keyinfotable.h" |
|
30 |
#import "SDL_uikitwindow.h" |
|
31 |
#endif |
|
32 |
||
33 |
@implementation SDL_uikitview |
|
34 |
||
35 |
@synthesize initialDistance, gestureStartPoint; |
|
36 |
||
2689 | 37 |
// they have to be global variables to allow showControls() to use them |
38 |
UIButton *attackButton, *menuButton; |
|
39 |
||
2688 | 40 |
- (void)dealloc { |
41 |
#if SDL_IPHONE_KEYBOARD |
|
42 |
SDL_DelKeyboard(0); |
|
43 |
[textField release]; |
|
44 |
#endif |
|
2689 | 45 |
[menuButton release]; |
46 |
[attackButton release]; |
|
2688 | 47 |
[super dealloc]; |
48 |
} |
|
49 |
||
50 |
- (id)initWithFrame:(CGRect)frame { |
|
2689 | 51 |
// the addTarget parameter for the buttons below is set like that because |
52 |
// this object is inherited by SDL_openglesview.m which is the one allocated by SDL. |
|
53 |
// We select this class with [self superclass] and call the selectors with "+" because |
|
54 |
// they are superclass methods |
|
2688 | 55 |
self = [super initWithFrame: frame]; |
56 |
||
57 |
#if SDL_IPHONE_KEYBOARD |
|
58 |
[self initializeKeyboard]; |
|
59 |
#endif |
|
60 |
||
61 |
int i; |
|
62 |
for (i=0; i<MAX_SIMULTANEOUS_TOUCHES; i++) { |
|
63 |
mice[i].id = i; |
|
64 |
mice[i].driverdata = NULL; |
|
65 |
SDL_AddMouse(&mice[i], "Mouse", 0, 0, 1); |
|
66 |
} |
|
67 |
||
2689 | 68 |
attackButton = [[UIButton alloc] initWithFrame:CGRectMake(30, 480, 260,50)]; |
2688 | 69 |
[attackButton setBackgroundImage:[UIImage imageNamed:@"Default.png"] forState:UIControlStateNormal]; |
2705
2b5625c4ec16
fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents:
2701
diff
changeset
|
70 |
[attackButton setBackgroundImage:[UIImage imageNamed:@"Default.png"] forState:UIControlStateHighlighted]; |
2688 | 71 |
[attackButton addTarget:[self superclass] action:@selector(attackButtonPressed) forControlEvents:UIControlEventTouchDown]; |
72 |
[attackButton addTarget:[self superclass] action:@selector(attackButtonReleased) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside]; |
|
2689 | 73 |
[self addSubview:attackButton]; |
74 |
||
75 |
menuButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 480, 30,50)]; |
|
76 |
[menuButton setBackgroundImage:[UIImage imageNamed:@"Default.png"] forState:UIControlStateNormal]; |
|
77 |
[menuButton addTarget:[self superclass] action:@selector(attackButtonPressed) forControlEvents:UIControlEventTouchUpInside]; |
|
78 |
[self addSubview:menuButton]; |
|
2688 | 79 |
|
2694
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2690
diff
changeset
|
80 |
[[SDLUIKitDelegate sharedAppDelegate].window makeKeyAndVisible]; |
2688 | 81 |
self.multipleTouchEnabled = YES; |
2689 | 82 |
|
2688 | 83 |
return self; |
84 |
} |
|
85 |
||
86 |
#pragma mark - |
|
2690 | 87 |
#pragma mark Exported functions for FreePascal |
2689 | 88 |
|
2690 | 89 |
const char* IPH_getDocumentsPath() { |
90 |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); |
|
91 |
NSString *documentsDirectory = [paths objectAtIndex: 0]; |
|
92 |
return [documentsDirectory UTF8String]; |
|
93 |
} |
|
94 |
||
95 |
void IPH_showControls (void) { |
|
2689 | 96 |
NSLog(@"Showing controls"); |
97 |
[UIView beginAnimations:nil context:NULL]; |
|
98 |
[UIView setAnimationDuration:0.5]; |
|
99 |
attackButton.frame = CGRectMake(30, 430, 260, 50); |
|
100 |
menuButton.frame = CGRectMake(0, 430, 30, 50); |
|
101 |
[UIView commitAnimations]; |
|
102 |
} |
|
103 |
||
104 |
#pragma mark - |
|
2688 | 105 |
#pragma mark Superclass methods |
2689 | 106 |
|
2688 | 107 |
+(void) attackButtonPressed { |
108 |
HW_shoot(); |
|
109 |
} |
|
110 |
||
111 |
+(void) attackButtonReleased { |
|
112 |
HW_allKeysUp(); |
|
113 |
} |
|
114 |
||
115 |
#pragma mark - |
|
116 |
#pragma mark Custom SDL_UIView input handling |
|
117 |
||
118 |
// we override default touch input to implement our own gestures |
|
119 |
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { |
|
120 |
/*NSEnumerator *enumerator = [touches objectEnumerator]; |
|
121 |
UITouch *touch =(UITouch*)[enumerator nextObject]; |
|
122 |
||
123 |
/* associate touches with mice, so long as we have slots |
|
124 |
int i; |
|
125 |
int found = 0; |
|
126 |
for(i=0; touch && i < MAX_SIMULTANEOUS_TOUCHES; i++) { |
|
127 |
||
128 |
/* check if this mouse is already tracking a touch |
|
129 |
if (mice[i].driverdata != NULL) { |
|
130 |
continue; |
|
131 |
} |
|
132 |
/* |
|
133 |
mouse not associated with anything right now, |
|
134 |
associate the touch with this mouse |
|
135 |
||
136 |
found = 1; |
|
137 |
||
138 |
/* save old mouse so we can switch back |
|
139 |
int oldMouse = SDL_SelectMouse(-1); |
|
140 |
||
141 |
/* select this slot's mouse |
|
142 |
SDL_SelectMouse(i); |
|
143 |
CGPoint locationInView = [touch locationInView: self]; |
|
144 |
||
145 |
/* set driver data to touch object, we'll use touch object later |
|
146 |
mice[i].driverdata = [touch retain]; |
|
147 |
||
148 |
/* send moved event |
|
149 |
SDL_SendMouseMotion(i, 0, locationInView.x, locationInView.y, 0); |
|
150 |
||
151 |
/* send mouse down event |
|
152 |
SDL_SendMouseButton(i, SDL_PRESSED, SDL_BUTTON_LEFT); |
|
153 |
||
154 |
/* re-calibrate relative mouse motion |
|
155 |
SDL_GetRelativeMouseState(i, NULL, NULL); |
|
156 |
||
157 |
/* grab next touch |
|
158 |
touch = (UITouch*)[enumerator nextObject]; |
|
159 |
||
160 |
/* switch back to our old mouse |
|
161 |
SDL_SelectMouse(oldMouse); |
|
162 |
||
163 |
} */ |
|
164 |
||
165 |
UITouch *touch = [touches anyObject]; |
|
166 |
gestureStartPoint = [touch locationInView:self]; |
|
167 |
||
168 |
// one tap - single click |
|
169 |
if (1 == [touch tapCount] ) { |
|
2701
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2696
diff
changeset
|
170 |
//SDL_WarpMouseInWindow([SDLUIKitDelegate sharedAppDelegate].windowID, gestureStartPoint.x, gestureStartPoint.y); |
2688 | 171 |
HW_click(); |
172 |
} |
|
173 |
||
174 |
// two taps - right click |
|
175 |
if (2 == [touch tapCount] ) { |
|
176 |
HW_ammoMenu(); |
|
177 |
} |
|
178 |
||
179 |
// two taps with two fingers - middle click |
|
180 |
if (2 == [touch tapCount] && 2 == [touches count]) { |
|
181 |
HW_zoomReset(); |
|
182 |
} |
|
183 |
||
184 |
// two fingers - begin pinching |
|
185 |
if (2 == [touches count]) { |
|
186 |
NSArray *twoTouches = [touches allObjects]; |
|
187 |
UITouch *first = [twoTouches objectAtIndex:0]; |
|
188 |
UITouch *second = [twoTouches objectAtIndex:1]; |
|
189 |
initialDistance = distanceBetweenPoints([first locationInView:self], [second locationInView:self]); |
|
190 |
} |
|
191 |
} |
|
192 |
||
193 |
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { |
|
194 |
initialDistance = 0; |
|
195 |
// NSLog(@"touches ended, sigh"); |
|
196 |
||
197 |
HW_allKeysUp(); |
|
198 |
/*NSEnumerator *enumerator = [touches objectEnumerator]; |
|
199 |
UITouch *touch=nil; |
|
200 |
||
201 |
while(touch = (UITouch *)[enumerator nextObject]) { |
|
202 |
/* search for the mouse slot associated with this touch |
|
203 |
int i, found = NO; |
|
204 |
for (i=0; i<MAX_SIMULTANEOUS_TOUCHES && !found; i++) { |
|
205 |
if (mice[i].driverdata == touch) { |
|
206 |
/* found the mouse associate with the touch |
|
207 |
[(UITouch*)(mice[i].driverdata) release]; |
|
208 |
mice[i].driverdata = NULL; |
|
209 |
/* send mouse up |
|
210 |
SDL_SendMouseButton(i, SDL_RELEASED, SDL_BUTTON_LEFT); |
|
211 |
/* discontinue search for this touch |
|
212 |
found = YES; |
|
213 |
} |
|
214 |
} |
|
215 |
}*/ |
|
216 |
} |
|
217 |
||
218 |
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { |
|
219 |
/* |
|
220 |
this can happen if the user puts more than 5 touches on the screen |
|
221 |
at once, or perhaps in other circumstances. Usually (it seems) |
|
222 |
all active touches are canceled. |
|
223 |
*/ |
|
224 |
[self touchesEnded: touches withEvent: event]; |
|
225 |
} |
|
226 |
||
227 |
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { |
|
228 |
UITouch *touch = [touches anyObject]; |
|
229 |
CGPoint currentPosition = [touch locationInView:self]; |
|
230 |
||
231 |
CGFloat Xdiff = gestureStartPoint.x - currentPosition.x; |
|
232 |
CGFloat Ydiff = gestureStartPoint.y - currentPosition.y; |
|
233 |
CGFloat deltaX = fabsf(Xdiff); |
|
2701
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2696
diff
changeset
|
234 |
CGFloat deltaY = fabsf(Ydiff); |
2688 | 235 |
|
236 |
if (deltaX >= kMinimumGestureLength && deltaY <= kMaximumVariance) { |
|
237 |
NSLog(@"Horizontal swipe detected, begX:%f curX:%f", gestureStartPoint.x, currentPosition.x); |
|
238 |
if (Xdiff > 0) HW_walkLeft(); |
|
239 |
else HW_walkRight(); |
|
2701
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2696
diff
changeset
|
240 |
} |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2696
diff
changeset
|
241 |
else if (deltaY >= kMinimumGestureLength && deltaX <= kMaximumVariance){ |
2688 | 242 |
NSLog(@"Vertical swipe detected, begY:%f curY:%f", gestureStartPoint.y, currentPosition.y); |
243 |
if (Ydiff > 0) HW_aimUp(); |
|
244 |
else HW_aimDown(); |
|
245 |
} |
|
246 |
||
247 |
// end pinch detection |
|
248 |
if (2 == [touches count]) { |
|
249 |
NSArray *twoTouches = [touches allObjects]; |
|
250 |
UITouch *first = [twoTouches objectAtIndex:0]; |
|
251 |
UITouch *second = [twoTouches objectAtIndex:1]; |
|
252 |
CGFloat currentDistance = distanceBetweenPoints([first locationInView:self], [second locationInView:self]); |
|
2701
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2696
diff
changeset
|
253 |
|
2688 | 254 |
if (0 == initialDistance) |
255 |
initialDistance = currentDistance; |
|
256 |
else if (currentDistance - initialDistance > kMinimumPinchDelta) { |
|
257 |
NSLog(@"Outward pinch detected"); |
|
258 |
HW_zoomOut(); |
|
259 |
} |
|
260 |
else if (initialDistance - currentDistance > kMinimumPinchDelta) { |
|
261 |
NSLog(@"Inward pinch detected"); |
|
262 |
HW_zoomIn(); |
|
263 |
} |
|
264 |
} |
|
265 |
||
266 |
/*NSEnumerator *enumerator = [touches objectEnumerator]; |
|
267 |
UITouch *touch=nil;while(touch = (UITouch *)[enumerator nextObject]) { |
|
268 |
// try to find the mouse associated with this touch |
|
269 |
int i, found = NO; |
|
270 |
for (i=0; i<MAX_SIMULTANEOUS_TOUCHES && !found; i++) { |
|
271 |
if (mice[i].driverdata == touch) { |
|
272 |
// found proper mouse |
|
273 |
CGPoint locationInView = [touch locationInView: self]; |
|
274 |
// send moved event |
|
275 |
SDL_SendMouseMotion(i, 0, locationInView.x, locationInView.y, 0); |
|
276 |
// discontinue search |
|
277 |
found = YES; |
|
278 |
} |
|
279 |
} |
|
280 |
}*/ |
|
281 |
} |
|
282 |
||
283 |
#pragma mark - |
|
284 |
#pragma mark default routines |
|
285 |
/* |
|
286 |
---- Keyboard related functionality below this line ---- |
|
287 |
*/ |
|
288 |
#if SDL_IPHONE_KEYBOARD |
|
289 |
||
290 |
/* Is the iPhone virtual keyboard visible onscreen? */ |
|
291 |
- (BOOL)keyboardVisible { |
|
292 |
return keyboardVisible; |
|
293 |
} |
|
294 |
||
295 |
/* Set ourselves up as a UITextFieldDelegate */ |
|
296 |
- (void)initializeKeyboard { |
|
297 |
||
298 |
textField = [[[UITextField alloc] initWithFrame: CGRectZero] autorelease]; |
|
299 |
textField.delegate = self; |
|
300 |
/* placeholder so there is something to delete! */ |
|
301 |
textField.text = @" "; |
|
302 |
||
303 |
/* set UITextInputTrait properties, mostly to defaults */ |
|
304 |
textField.autocapitalizationType = UITextAutocapitalizationTypeNone; |
|
305 |
textField.autocorrectionType = UITextAutocorrectionTypeNo; |
|
306 |
textField.enablesReturnKeyAutomatically = NO; |
|
307 |
textField.keyboardAppearance = UIKeyboardAppearanceDefault; |
|
308 |
textField.keyboardType = UIKeyboardTypeDefault; |
|
309 |
textField.returnKeyType = UIReturnKeyDefault; |
|
310 |
textField.secureTextEntry = NO; |
|
311 |
||
312 |
textField.hidden = YES; |
|
313 |
keyboardVisible = NO; |
|
314 |
/* add the UITextField (hidden) to our view */ |
|
315 |
[self addSubview: textField]; |
|
316 |
||
317 |
/* create our SDL_Keyboard */ |
|
318 |
SDL_Keyboard keyboard; |
|
319 |
SDL_zero(keyboard); |
|
320 |
SDL_AddKeyboard(&keyboard, 0); |
|
321 |
SDLKey keymap[SDL_NUM_SCANCODES]; |
|
322 |
SDL_GetDefaultKeymap(keymap); |
|
323 |
SDL_SetKeymap(0, 0, keymap, SDL_NUM_SCANCODES); |
|
324 |
||
325 |
} |
|
326 |
||
327 |
/* reveal onscreen virtual keyboard */ |
|
328 |
- (void)showKeyboard { |
|
329 |
keyboardVisible = YES; |
|
330 |
[textField becomeFirstResponder]; |
|
331 |
} |
|
332 |
||
333 |
/* hide onscreen virtual keyboard */ |
|
334 |
- (void)hideKeyboard { |
|
335 |
keyboardVisible = NO; |
|
336 |
[textField resignFirstResponder]; |
|
337 |
} |
|
338 |
||
339 |
/* UITextFieldDelegate method. Invoked when user types something. */ |
|
340 |
- (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { |
|
341 |
||
342 |
if ([string length] == 0) { |
|
343 |
/* it wants to replace text with nothing, ie a delete */ |
|
344 |
SDL_SendKeyboardKey( 0, SDL_PRESSED, SDL_SCANCODE_DELETE); |
|
345 |
SDL_SendKeyboardKey( 0, SDL_RELEASED, SDL_SCANCODE_DELETE); |
|
346 |
} |
|
347 |
else { |
|
348 |
/* go through all the characters in the string we've been sent |
|
349 |
and convert them to key presses */ |
|
350 |
int i; |
|
351 |
for (i=0; i<[string length]; i++) { |
|
352 |
||
353 |
unichar c = [string characterAtIndex: i]; |
|
354 |
||
355 |
Uint16 mod = 0; |
|
356 |
SDL_scancode code; |
|
357 |
||
358 |
if (c < 127) { |
|
359 |
/* figure out the SDL_scancode and SDL_keymod for this unichar */ |
|
360 |
code = unicharToUIKeyInfoTable[c].code; |
|
361 |
mod = unicharToUIKeyInfoTable[c].mod; |
|
362 |
} |
|
363 |
else { |
|
364 |
/* we only deal with ASCII right now */ |
|
365 |
code = SDL_SCANCODE_UNKNOWN; |
|
366 |
mod = 0; |
|
367 |
} |
|
368 |
||
369 |
if (mod & KMOD_SHIFT) { |
|
370 |
/* If character uses shift, press shift down */ |
|
371 |
SDL_SendKeyboardKey( 0, SDL_PRESSED, SDL_SCANCODE_LSHIFT); |
|
372 |
} |
|
373 |
/* send a keydown and keyup even for the character */ |
|
374 |
SDL_SendKeyboardKey( 0, SDL_PRESSED, code); |
|
375 |
SDL_SendKeyboardKey( 0, SDL_RELEASED, code); |
|
376 |
if (mod & KMOD_SHIFT) { |
|
377 |
/* If character uses shift, press shift back up */ |
|
378 |
SDL_SendKeyboardKey( 0, SDL_RELEASED, SDL_SCANCODE_LSHIFT); |
|
379 |
} |
|
380 |
} |
|
381 |
} |
|
382 |
return NO; /* don't allow the edit! (keep placeholder text there) */ |
|
383 |
} |
|
384 |
||
385 |
/* Terminates the editing session */ |
|
386 |
- (BOOL)textFieldShouldReturn:(UITextField*)_textField { |
|
387 |
[self hideKeyboard]; |
|
388 |
return YES; |
|
389 |
} |
|
390 |
||
391 |
#endif |
|
392 |
||
393 |
@end |
|
394 |
||
395 |
/* iPhone keyboard addition functions */ |
|
396 |
#if SDL_IPHONE_KEYBOARD |
|
397 |
||
398 |
int SDL_iPhoneKeyboardShow(SDL_WindowID windowID) { |
|
399 |
||
400 |
SDL_Window *window = SDL_GetWindowFromID(windowID); |
|
401 |
SDL_WindowData *data; |
|
402 |
SDL_uikitview *view; |
|
403 |
||
404 |
if (NULL == window) { |
|
405 |
SDL_SetError("Window does not exist"); |
|
406 |
return -1; |
|
407 |
} |
|
408 |
||
409 |
data = (SDL_WindowData *)window->driverdata; |
|
410 |
view = data->view; |
|
411 |
||
412 |
if (nil == view) { |
|
413 |
SDL_SetError("Window has no view"); |
|
414 |
return -1; |
|
415 |
} |
|
416 |
else { |
|
417 |
[view showKeyboard]; |
|
418 |
return 0; |
|
419 |
} |
|
420 |
} |
|
421 |
||
422 |
int SDL_iPhoneKeyboardHide(SDL_WindowID windowID) { |
|
423 |
||
424 |
SDL_Window *window = SDL_GetWindowFromID(windowID); |
|
425 |
SDL_WindowData *data; |
|
426 |
SDL_uikitview *view; |
|
427 |
||
428 |
if (NULL == window) { |
|
429 |
SDL_SetError("Window does not exist"); |
|
430 |
return -1; |
|
431 |
} |
|
432 |
||
433 |
data = (SDL_WindowData *)window->driverdata; |
|
434 |
view = data->view; |
|
435 |
||
436 |
if (NULL == view) { |
|
437 |
SDL_SetError("Window has no view"); |
|
438 |
return -1; |
|
439 |
} |
|
440 |
else { |
|
441 |
[view hideKeyboard]; |
|
442 |
return 0; |
|
443 |
} |
|
444 |
} |
|
445 |
||
446 |
SDL_bool SDL_iPhoneKeyboardIsShown(SDL_WindowID windowID) { |
|
447 |
||
448 |
SDL_Window *window = SDL_GetWindowFromID(windowID); |
|
449 |
SDL_WindowData *data; |
|
450 |
SDL_uikitview *view; |
|
451 |
||
452 |
if (NULL == window) { |
|
453 |
SDL_SetError("Window does not exist"); |
|
454 |
return -1; |
|
455 |
} |
|
456 |
||
457 |
data = (SDL_WindowData *)window->driverdata; |
|
458 |
view = data->view; |
|
459 |
||
460 |
if (NULL == view) { |
|
461 |
SDL_SetError("Window has no view"); |
|
462 |
return 0; |
|
463 |
} |
|
464 |
else { |
|
465 |
return view.keyboardVisible; |
|
466 |
} |
|
467 |
} |
|
468 |
||
469 |
int SDL_iPhoneKeyboardToggle(SDL_WindowID windowID) { |
|
470 |
||
471 |
SDL_Window *window = SDL_GetWindowFromID(windowID); |
|
472 |
SDL_WindowData *data; |
|
473 |
SDL_uikitview *view; |
|
474 |
||
475 |
if (NULL == window) { |
|
476 |
SDL_SetError("Window does not exist"); |
|
477 |
return -1; |
|
478 |
} |
|
479 |
||
480 |
data = (SDL_WindowData *)window->driverdata; |
|
481 |
view = data->view; |
|
482 |
||
483 |
if (NULL == view) { |
|
484 |
SDL_SetError("Window has no view"); |
|
485 |
return -1; |
|
486 |
} |
|
487 |
else { |
|
488 |
if (SDL_iPhoneKeyboardIsShown(windowID)) { |
|
489 |
SDL_iPhoneKeyboardHide(windowID); |
|
490 |
} |
|
491 |
else { |
|
492 |
SDL_iPhoneKeyboardShow(windowID); |
|
493 |
} |
|
494 |
return 0; |
|
495 |
} |
|
496 |
} |
|
497 |
||
498 |
#else |
|
499 |
||
500 |
/* stubs, used if compiled without keyboard support */ |
|
501 |
||
502 |
int SDL_iPhoneKeyboardShow(SDL_WindowID windowID) { |
|
503 |
SDL_SetError("Not compiled with keyboard support"); |
|
504 |
return -1; |
|
505 |
} |
|
506 |
||
507 |
int SDL_iPhoneKeyboardHide(SDL_WindowID windowID) { |
|
508 |
SDL_SetError("Not compiled with keyboard support"); |
|
509 |
return -1; |
|
510 |
} |
|
511 |
||
512 |
SDL_bool SDL_iPhoneKeyboardIsShown(SDL_WindowID windowID) { |
|
513 |
return 0; |
|
514 |
} |
|
515 |
||
516 |
int SDL_iPhoneKeyboardToggle(SDL_WindowID windowID) { |
|
517 |
SDL_SetError("Not compiled with keyboard support"); |
|
518 |
return -1; |
|
519 |
} |
|
520 |
||
521 |
||
522 |
#endif /* SDL_IPHONE_KEYBOARD */ |