author | nemo |
Fri, 05 Feb 2010 11:47:57 +0000 | |
changeset 2757 | 8dbfe782218c |
parent 2754 | ad4f81fbfb76 |
child 2772 | 1965eba10be6 |
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 |
||
2689 | 35 |
// they have to be global variables to allow showControls() to use them |
36 |
UIButton *attackButton, *menuButton; |
|
37 |
||
2714
c85ffe57d971
update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents:
2705
diff
changeset
|
38 |
-(void) dealloc { |
2688 | 39 |
#if SDL_IPHONE_KEYBOARD |
40 |
SDL_DelKeyboard(0); |
|
41 |
[textField release]; |
|
42 |
#endif |
|
2689 | 43 |
[menuButton release]; |
44 |
[attackButton release]; |
|
2688 | 45 |
[super dealloc]; |
46 |
} |
|
47 |
||
48 |
- (id)initWithFrame:(CGRect)frame { |
|
2689 | 49 |
// the addTarget parameter for the buttons below is set like that because |
50 |
// this object is inherited by SDL_openglesview.m which is the one allocated by SDL. |
|
51 |
// We select this class with [self superclass] and call the selectors with "+" because |
|
52 |
// they are superclass methods |
|
2714
c85ffe57d971
update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents:
2705
diff
changeset
|
53 |
self = [super initWithFrame:frame]; |
2688 | 54 |
|
55 |
#if SDL_IPHONE_KEYBOARD |
|
56 |
[self initializeKeyboard]; |
|
57 |
#endif |
|
58 |
||
59 |
int i; |
|
60 |
for (i=0; i<MAX_SIMULTANEOUS_TOUCHES; i++) { |
|
61 |
mice[i].id = i; |
|
62 |
mice[i].driverdata = NULL; |
|
63 |
SDL_AddMouse(&mice[i], "Mouse", 0, 0, 1); |
|
64 |
} |
|
65 |
||
2724 | 66 |
self.multipleTouchEnabled = YES; |
67 |
||
68 |
// custom code |
|
2754
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
69 |
// the coordinate system is still like in Portrait even though everything is rotated |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
70 |
attackButton = [[UIButton alloc] initWithFrame:CGRectMake(30, 480, 260, 50)]; |
2688 | 71 |
[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
|
72 |
[attackButton setBackgroundImage:[UIImage imageNamed:@"Default.png"] forState:UIControlStateHighlighted]; |
2688 | 73 |
[attackButton addTarget:[self superclass] action:@selector(attackButtonPressed) forControlEvents:UIControlEventTouchDown]; |
2754
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
74 |
[attackButton addTarget:[self superclass] action:@selector(buttonsReleased) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
75 |
//[self addSubview:attackButton]; |
2689 | 76 |
|
2754
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
77 |
menuButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 480, 30, 50)]; |
2689 | 78 |
[menuButton setBackgroundImage:[UIImage imageNamed:@"Default.png"] forState:UIControlStateNormal]; |
79 |
[menuButton addTarget:[self superclass] action:@selector(attackButtonPressed) forControlEvents:UIControlEventTouchUpInside]; |
|
2754
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
80 |
[menuButton addTarget:[self superclass] action:@selector(buttonsReleased) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
81 |
//[self addSubview:menuButton]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
82 |
|
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
83 |
UIButton *walkLeftButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 320, 100)]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
84 |
[walkLeftButton addTarget:[self superclass] action:@selector(walkingLeft) forControlEvents:UIControlEventTouchDown]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
85 |
[walkLeftButton addTarget:[self superclass] action:@selector(buttonsReleased) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
86 |
[self insertSubview:walkLeftButton atIndex:0]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
87 |
[walkLeftButton release]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
88 |
|
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
89 |
UIButton *walkRightButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 380, 320, 100)]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
90 |
[walkRightButton addTarget:[self superclass] action:@selector(walkingRight) forControlEvents:UIControlEventTouchDown]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
91 |
[walkRightButton addTarget:[self superclass] action:@selector(buttonsReleased) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
92 |
[self insertSubview:walkRightButton atIndex:0]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
93 |
[walkRightButton release]; |
2688 | 94 |
|
2754
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
95 |
UIButton *moveDownButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 100, 70, 280)]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
96 |
[moveDownButton addTarget:[self superclass] action:@selector(movingDown) forControlEvents:UIControlEventTouchDown]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
97 |
[moveDownButton addTarget:[self superclass] action:@selector(buttonsReleased) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
98 |
[self insertSubview:moveDownButton atIndex:0]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
99 |
[moveDownButton release]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
100 |
|
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
101 |
UIButton *moveUpButton = [[UIButton alloc] initWithFrame:CGRectMake(250, 100, 70, 280)]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
102 |
[moveUpButton addTarget:[self superclass] action:@selector(movingUp) forControlEvents:UIControlEventTouchDown]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
103 |
[moveUpButton addTarget:[self superclass] action:@selector(buttonsReleased) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
104 |
[self insertSubview:moveUpButton atIndex:0]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
105 |
[moveUpButton release]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
106 |
|
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
107 |
//dummy button used to test chat |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
108 |
UIButton *chatButton = [[UIButton alloc] initWithFrame:CGRectMake(70, 100, 250, 280)]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
109 |
[chatButton addTarget:[self superclass] action:@selector(chatBegin) forControlEvents:UIControlEventTouchDown]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
110 |
[self insertSubview:chatButton atIndex:0]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
111 |
[chatButton release]; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
112 |
|
2688 | 113 |
return self; |
114 |
} |
|
115 |
||
116 |
#pragma mark - |
|
2690 | 117 |
#pragma mark Exported functions for FreePascal |
118 |
const char* IPH_getDocumentsPath() { |
|
2714
c85ffe57d971
update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents:
2705
diff
changeset
|
119 |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); |
c85ffe57d971
update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents:
2705
diff
changeset
|
120 |
NSString *documentsDirectory = [paths objectAtIndex: 0]; |
c85ffe57d971
update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents:
2705
diff
changeset
|
121 |
return [documentsDirectory UTF8String]; |
2690 | 122 |
} |
123 |
||
124 |
void IPH_showControls (void) { |
|
2689 | 125 |
NSLog(@"Showing controls"); |
2734 | 126 |
[UIView beginAnimations:nil context:NULL]; |
2689 | 127 |
[UIView setAnimationDuration:0.5]; |
128 |
attackButton.frame = CGRectMake(30, 430, 260, 50); |
|
129 |
menuButton.frame = CGRectMake(0, 430, 30, 50); |
|
130 |
[UIView commitAnimations]; |
|
2734 | 131 |
} |
2689 | 132 |
|
133 |
#pragma mark - |
|
2754
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
134 |
#pragma mark Superclass methods to call Pascal code |
2688 | 135 |
+(void) attackButtonPressed { |
136 |
HW_shoot(); |
|
137 |
} |
|
138 |
||
2754
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
139 |
+(void) buttonsReleased { |
2688 | 140 |
HW_allKeysUp(); |
141 |
} |
|
142 |
||
2754
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
143 |
+(void) walkingLeft { |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
144 |
HW_walkLeft(); |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
145 |
} |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
146 |
|
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
147 |
+(void) walkingRight { |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
148 |
HW_walkRight(); |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
149 |
} |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
150 |
|
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
151 |
+(void) movingUp { |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
152 |
HW_aimUp(); |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
153 |
} |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
154 |
|
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
155 |
+(void) movingDown { |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
156 |
HW_aimDown(); |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
157 |
} |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
158 |
|
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
159 |
+(void) chatBegin { |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
160 |
HW_chat(); |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
161 |
SDL_iPhoneKeyboardShow([SDLUIKitDelegate sharedAppDelegate].uiwindow); |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
162 |
} |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
163 |
|
2688 | 164 |
#pragma mark - |
165 |
#pragma mark Custom SDL_UIView input handling |
|
2754
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
166 |
#define kMinimumPinchDelta 50 |
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
167 |
#define kMinimumGestureLength 10 |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
168 |
#define kMaximumVariance 3 |
2688 | 169 |
|
170 |
// we override default touch input to implement our own gestures |
|
171 |
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { |
|
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
172 |
/* |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
173 |
NSEnumerator *enumerator = [touches objectEnumerator]; |
2688 | 174 |
UITouch *touch =(UITouch*)[enumerator nextObject]; |
175 |
||
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
176 |
// associate touches with mice, so long as we have slots |
2688 | 177 |
int i; |
178 |
int found = 0; |
|
179 |
for(i=0; touch && i < MAX_SIMULTANEOUS_TOUCHES; i++) { |
|
180 |
||
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
181 |
// check if this mouse is already tracking a touch |
2688 | 182 |
if (mice[i].driverdata != NULL) { |
183 |
continue; |
|
184 |
} |
|
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
185 |
|
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
186 |
// mouse not associated with anything right now, associate the touch with this mouse |
2688 | 187 |
found = 1; |
188 |
||
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
189 |
// save old mouse so we can switch back |
2688 | 190 |
int oldMouse = SDL_SelectMouse(-1); |
191 |
||
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
192 |
// select this slot's mouse |
2688 | 193 |
SDL_SelectMouse(i); |
194 |
CGPoint locationInView = [touch locationInView: self]; |
|
195 |
||
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
196 |
CGFloat oldX = locationInView.x; |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
197 |
locationInView.x = locationInView.y; |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
198 |
locationInView.y = 320 - oldX; |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
199 |
|
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
200 |
// set driver data to touch object, we'll use touch object later |
2688 | 201 |
mice[i].driverdata = [touch retain]; |
202 |
||
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
203 |
// send moved event |
2688 | 204 |
SDL_SendMouseMotion(i, 0, locationInView.x, locationInView.y, 0); |
205 |
||
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
206 |
// send mouse down event |
2688 | 207 |
SDL_SendMouseButton(i, SDL_PRESSED, SDL_BUTTON_LEFT); |
208 |
||
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
209 |
// re-calibrate relative mouse motion |
2688 | 210 |
SDL_GetRelativeMouseState(i, NULL, NULL); |
211 |
||
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
212 |
// grab next touch |
2688 | 213 |
touch = (UITouch*)[enumerator nextObject]; |
214 |
||
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
215 |
// switch back to our old mouse |
2688 | 216 |
SDL_SelectMouse(oldMouse); |
217 |
||
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
218 |
} |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
219 |
*/ |
2688 | 220 |
|
221 |
UITouch *touch = [touches anyObject]; |
|
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
222 |
|
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
223 |
switch ([touches count]) { |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
224 |
case 1: |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
225 |
gestureStartPoint = [touch locationInView:self]; |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
226 |
initialDistanceForPinching = 0; |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
227 |
switch ([touch tapCount]) { |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
228 |
case 1: |
2754
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2740
diff
changeset
|
229 |
NSLog(@"X:%d Y:%d", (int) gestureStartPoint.x, gestureStartPoint.y ); |
2734 | 230 |
SDL_WarpMouseInWindow([SDLUIKitDelegate sharedAppDelegate].window, |
231 |
(int)gestureStartPoint.y, 320 - (int)gestureStartPoint.x); |
|
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
232 |
HW_click(); |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
233 |
break; |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
234 |
case 2: |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
235 |
HW_ammoMenu(); |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
236 |
break; |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
237 |
default: |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
238 |
break; |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
239 |
} |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
240 |
break; |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
241 |
case 2: |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
242 |
if (2 == [touch tapCount]) { |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
243 |
HW_zoomReset(); |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
244 |
} |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
245 |
|
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
246 |
// pinching |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
247 |
NSArray *twoTouches = [touches allObjects]; |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
248 |
UITouch *first = [twoTouches objectAtIndex:0]; |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
249 |
UITouch *second = [twoTouches objectAtIndex:1]; |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
250 |
initialDistanceForPinching = distanceBetweenPoints([first locationInView:self], [second locationInView:self]); |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
251 |
break; |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
252 |
default: |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
253 |
break; |
2688 | 254 |
} |
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
255 |
|
2688 | 256 |
} |
257 |
||
258 |
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { |
|
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
259 |
initialDistanceForPinching = 0; |
2688 | 260 |
|
261 |
HW_allKeysUp(); |
|
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
262 |
/* |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
263 |
NSEnumerator *enumerator = [touches objectEnumerator]; |
2688 | 264 |
UITouch *touch=nil; |
265 |
||
266 |
while(touch = (UITouch *)[enumerator nextObject]) { |
|
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
267 |
// search for the mouse slot associated with this touch |
2688 | 268 |
int i, found = NO; |
269 |
for (i=0; i<MAX_SIMULTANEOUS_TOUCHES && !found; i++) { |
|
270 |
if (mice[i].driverdata == touch) { |
|
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
271 |
// found the mouse associate with the touch |
2688 | 272 |
[(UITouch*)(mice[i].driverdata) release]; |
273 |
mice[i].driverdata = NULL; |
|
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
274 |
// send mouse up |
2688 | 275 |
SDL_SendMouseButton(i, SDL_RELEASED, SDL_BUTTON_LEFT); |
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
276 |
// discontinue search for this touch |
2688 | 277 |
found = YES; |
278 |
} |
|
279 |
} |
|
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
280 |
} |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
281 |
*/ |
2688 | 282 |
} |
283 |
||
284 |
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { |
|
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
285 |
// this can happen if the user puts more than 5 touches on the screen |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
286 |
// at once, or perhaps in other circumstances. Usually (it seems) |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
287 |
// all active touches are canceled. |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
288 |
[self touchesEnded:touches withEvent:event]; |
2688 | 289 |
} |
290 |
||
291 |
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { |
|
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
292 |
NSArray *twoTouches; |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
293 |
CGPoint currentPosition; |
2688 | 294 |
UITouch *touch = [touches anyObject]; |
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
295 |
|
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
296 |
switch ([touches count]) { |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
297 |
case 1: |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
298 |
currentPosition = [touch locationInView:self]; |
2734 | 299 |
// panning |
300 |
SDL_WarpMouseInWindow([SDLUIKitDelegate sharedAppDelegate].window, |
|
301 |
(int)gestureStartPoint.y, 320 - (int)gestureStartPoint.x); |
|
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
302 |
// remember that we have x and y inverted |
2734 | 303 |
/* temporarily disabling hog movements for camera panning testing |
304 |
CGFloat vertDiff = gestureStartPoint.x - currentPosition.x; |
|
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
305 |
CGFloat horizDiff = gestureStartPoint.y - currentPosition.y; |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
306 |
CGFloat deltaX = fabsf(vertDiff); |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
307 |
CGFloat deltaY = fabsf(horizDiff); |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
308 |
|
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
309 |
if (deltaY >= kMinimumGestureLength && deltaX <= kMaximumVariance) { |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
310 |
NSLog(@"Horizontal swipe detected, begX:%f curX:%f", gestureStartPoint.x, currentPosition.x); |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
311 |
if (horizDiff > 0) HW_walkLeft(); |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
312 |
else HW_walkRight(); |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
313 |
} else if (deltaX >= kMinimumGestureLength && deltaY <= kMaximumVariance){ |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
314 |
NSLog(@"Vertical swipe detected, begY:%f curY:%f", gestureStartPoint.y, currentPosition.y); |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
315 |
if (vertDiff < 0) HW_aimUp(); |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
316 |
else HW_aimDown(); |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
317 |
} |
2734 | 318 |
*/ |
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
319 |
break; |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
320 |
case 2: |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
321 |
twoTouches = [touches allObjects]; |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
322 |
UITouch *first = [twoTouches objectAtIndex:0]; |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
323 |
UITouch *second = [twoTouches objectAtIndex:1]; |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
324 |
CGFloat currentDistanceOfPinching = distanceBetweenPoints([first locationInView:self], [second locationInView:self]); |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
325 |
|
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
326 |
if (0 == initialDistanceForPinching) |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
327 |
initialDistanceForPinching = currentDistanceOfPinching; |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
328 |
|
2738
bfccb2ec4334
new graphics from Tiy and frontend is loaded in landscape mode
koda
parents:
2734
diff
changeset
|
329 |
if (currentDistanceOfPinching < initialDistanceForPinching + kMinimumPinchDelta) |
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
330 |
HW_zoomOut(); |
2738
bfccb2ec4334
new graphics from Tiy and frontend is loaded in landscape mode
koda
parents:
2734
diff
changeset
|
331 |
else if (currentDistanceOfPinching > initialDistanceForPinching + kMinimumPinchDelta) |
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
332 |
HW_zoomIn(); |
2738
bfccb2ec4334
new graphics from Tiy and frontend is loaded in landscape mode
koda
parents:
2734
diff
changeset
|
333 |
|
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
334 |
currentDistanceOfPinching = initialDistanceForPinching; |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
335 |
break; |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
336 |
default: |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
337 |
break; |
2688 | 338 |
} |
339 |
||
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
340 |
/* |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
341 |
NSEnumerator *enumerator = [touches objectEnumerator]; |
2688 | 342 |
UITouch *touch=nil;while(touch = (UITouch *)[enumerator nextObject]) { |
343 |
// try to find the mouse associated with this touch |
|
344 |
int i, found = NO; |
|
345 |
for (i=0; i<MAX_SIMULTANEOUS_TOUCHES && !found; i++) { |
|
346 |
if (mice[i].driverdata == touch) { |
|
347 |
// found proper mouse |
|
348 |
CGPoint locationInView = [touch locationInView: self]; |
|
349 |
// send moved event |
|
350 |
SDL_SendMouseMotion(i, 0, locationInView.x, locationInView.y, 0); |
|
351 |
// discontinue search |
|
352 |
found = YES; |
|
353 |
} |
|
354 |
} |
|
2725
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
355 |
} |
89908847b155
input handling reworked, still a lot of bugs in mouse movement
koda
parents:
2724
diff
changeset
|
356 |
*/ |
2688 | 357 |
} |
358 |
||
359 |
#pragma mark - |
|
360 |
#pragma mark default routines |
|
361 |
/* |
|
362 |
---- Keyboard related functionality below this line ---- |
|
363 |
*/ |
|
364 |
#if SDL_IPHONE_KEYBOARD |
|
365 |
||
366 |
/* Is the iPhone virtual keyboard visible onscreen? */ |
|
367 |
- (BOOL)keyboardVisible { |
|
368 |
return keyboardVisible; |
|
369 |
} |
|
370 |
||
371 |
/* Set ourselves up as a UITextFieldDelegate */ |
|
372 |
- (void)initializeKeyboard { |
|
373 |
||
374 |
textField = [[[UITextField alloc] initWithFrame: CGRectZero] autorelease]; |
|
375 |
textField.delegate = self; |
|
376 |
/* placeholder so there is something to delete! */ |
|
377 |
textField.text = @" "; |
|
378 |
||
379 |
/* set UITextInputTrait properties, mostly to defaults */ |
|
380 |
textField.autocapitalizationType = UITextAutocapitalizationTypeNone; |
|
381 |
textField.autocorrectionType = UITextAutocorrectionTypeNo; |
|
382 |
textField.enablesReturnKeyAutomatically = NO; |
|
383 |
textField.keyboardAppearance = UIKeyboardAppearanceDefault; |
|
384 |
textField.keyboardType = UIKeyboardTypeDefault; |
|
385 |
textField.returnKeyType = UIReturnKeyDefault; |
|
386 |
textField.secureTextEntry = NO; |
|
387 |
||
388 |
textField.hidden = YES; |
|
389 |
keyboardVisible = NO; |
|
390 |
/* add the UITextField (hidden) to our view */ |
|
391 |
[self addSubview: textField]; |
|
392 |
||
393 |
/* create our SDL_Keyboard */ |
|
394 |
SDL_Keyboard keyboard; |
|
395 |
SDL_zero(keyboard); |
|
396 |
SDL_AddKeyboard(&keyboard, 0); |
|
397 |
SDLKey keymap[SDL_NUM_SCANCODES]; |
|
398 |
SDL_GetDefaultKeymap(keymap); |
|
399 |
SDL_SetKeymap(0, 0, keymap, SDL_NUM_SCANCODES); |
|
400 |
||
401 |
} |
|
402 |
||
403 |
/* reveal onscreen virtual keyboard */ |
|
404 |
- (void)showKeyboard { |
|
405 |
keyboardVisible = YES; |
|
406 |
[textField becomeFirstResponder]; |
|
407 |
} |
|
408 |
||
409 |
/* hide onscreen virtual keyboard */ |
|
410 |
- (void)hideKeyboard { |
|
411 |
keyboardVisible = NO; |
|
412 |
[textField resignFirstResponder]; |
|
413 |
} |
|
414 |
||
415 |
/* UITextFieldDelegate method. Invoked when user types something. */ |
|
416 |
- (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { |
|
417 |
||
418 |
if ([string length] == 0) { |
|
419 |
/* it wants to replace text with nothing, ie a delete */ |
|
420 |
SDL_SendKeyboardKey( 0, SDL_PRESSED, SDL_SCANCODE_DELETE); |
|
421 |
SDL_SendKeyboardKey( 0, SDL_RELEASED, SDL_SCANCODE_DELETE); |
|
422 |
} |
|
423 |
else { |
|
424 |
/* go through all the characters in the string we've been sent |
|
425 |
and convert them to key presses */ |
|
426 |
int i; |
|
427 |
for (i=0; i<[string length]; i++) { |
|
428 |
||
429 |
unichar c = [string characterAtIndex: i]; |
|
430 |
||
431 |
Uint16 mod = 0; |
|
432 |
SDL_scancode code; |
|
433 |
||
434 |
if (c < 127) { |
|
435 |
/* figure out the SDL_scancode and SDL_keymod for this unichar */ |
|
436 |
code = unicharToUIKeyInfoTable[c].code; |
|
437 |
mod = unicharToUIKeyInfoTable[c].mod; |
|
438 |
} |
|
439 |
else { |
|
440 |
/* we only deal with ASCII right now */ |
|
441 |
code = SDL_SCANCODE_UNKNOWN; |
|
442 |
mod = 0; |
|
443 |
} |
|
444 |
||
445 |
if (mod & KMOD_SHIFT) { |
|
446 |
/* If character uses shift, press shift down */ |
|
447 |
SDL_SendKeyboardKey( 0, SDL_PRESSED, SDL_SCANCODE_LSHIFT); |
|
448 |
} |
|
449 |
/* send a keydown and keyup even for the character */ |
|
450 |
SDL_SendKeyboardKey( 0, SDL_PRESSED, code); |
|
451 |
SDL_SendKeyboardKey( 0, SDL_RELEASED, code); |
|
452 |
if (mod & KMOD_SHIFT) { |
|
453 |
/* If character uses shift, press shift back up */ |
|
454 |
SDL_SendKeyboardKey( 0, SDL_RELEASED, SDL_SCANCODE_LSHIFT); |
|
455 |
} |
|
456 |
} |
|
457 |
} |
|
458 |
return NO; /* don't allow the edit! (keep placeholder text there) */ |
|
459 |
} |
|
460 |
||
461 |
/* Terminates the editing session */ |
|
462 |
- (BOOL)textFieldShouldReturn:(UITextField*)_textField { |
|
463 |
[self hideKeyboard]; |
|
464 |
return YES; |
|
465 |
} |
|
466 |
||
467 |
#endif |
|
468 |
||
469 |
@end |
|
470 |
||
471 |
/* iPhone keyboard addition functions */ |
|
472 |
#if SDL_IPHONE_KEYBOARD |
|
473 |
||
2714
c85ffe57d971
update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents:
2705
diff
changeset
|
474 |
int SDL_iPhoneKeyboardShow(SDL_Window *window) { |
2688 | 475 |
SDL_WindowData *data; |
476 |
SDL_uikitview *view; |
|
477 |
||
478 |
if (NULL == window) { |
|
479 |
SDL_SetError("Window does not exist"); |
|
480 |
return -1; |
|
481 |
} |
|
482 |
||
483 |
data = (SDL_WindowData *)window->driverdata; |
|
484 |
view = data->view; |
|
485 |
||
486 |
if (nil == view) { |
|
487 |
SDL_SetError("Window has no view"); |
|
488 |
return -1; |
|
489 |
} |
|
490 |
else { |
|
491 |
[view showKeyboard]; |
|
492 |
return 0; |
|
493 |
} |
|
494 |
} |
|
495 |
||
2714
c85ffe57d971
update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents:
2705
diff
changeset
|
496 |
int SDL_iPhoneKeyboardHide(SDL_Window *window) { |
2688 | 497 |
SDL_WindowData *data; |
498 |
SDL_uikitview *view; |
|
499 |
||
500 |
if (NULL == window) { |
|
501 |
SDL_SetError("Window does not exist"); |
|
502 |
return -1; |
|
503 |
} |
|
504 |
||
505 |
data = (SDL_WindowData *)window->driverdata; |
|
506 |
view = data->view; |
|
507 |
||
508 |
if (NULL == view) { |
|
509 |
SDL_SetError("Window has no view"); |
|
510 |
return -1; |
|
511 |
} |
|
512 |
else { |
|
513 |
[view hideKeyboard]; |
|
514 |
return 0; |
|
515 |
} |
|
516 |
} |
|
517 |
||
2714
c85ffe57d971
update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents:
2705
diff
changeset
|
518 |
SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window *window) { |
2688 | 519 |
SDL_WindowData *data; |
520 |
SDL_uikitview *view; |
|
521 |
||
522 |
if (NULL == window) { |
|
523 |
SDL_SetError("Window does not exist"); |
|
524 |
return -1; |
|
525 |
} |
|
526 |
||
527 |
data = (SDL_WindowData *)window->driverdata; |
|
528 |
view = data->view; |
|
529 |
||
530 |
if (NULL == view) { |
|
531 |
SDL_SetError("Window has no view"); |
|
532 |
return 0; |
|
533 |
} |
|
534 |
else { |
|
535 |
return view.keyboardVisible; |
|
536 |
} |
|
537 |
} |
|
538 |
||
2714
c85ffe57d971
update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents:
2705
diff
changeset
|
539 |
int SDL_iPhoneKeyboardToggle(SDL_Window *window) { |
2688 | 540 |
SDL_WindowData *data; |
541 |
SDL_uikitview *view; |
|
542 |
||
543 |
if (NULL == window) { |
|
544 |
SDL_SetError("Window does not exist"); |
|
545 |
return -1; |
|
546 |
} |
|
547 |
||
548 |
data = (SDL_WindowData *)window->driverdata; |
|
549 |
view = data->view; |
|
550 |
||
551 |
if (NULL == view) { |
|
552 |
SDL_SetError("Window has no view"); |
|
553 |
return -1; |
|
554 |
} |
|
555 |
else { |
|
2714
c85ffe57d971
update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents:
2705
diff
changeset
|
556 |
if (SDL_iPhoneKeyboardIsShown(window)) { |
c85ffe57d971
update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents:
2705
diff
changeset
|
557 |
SDL_iPhoneKeyboardHide(window); |
2688 | 558 |
} |
559 |
else { |
|
2714
c85ffe57d971
update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents:
2705
diff
changeset
|
560 |
SDL_iPhoneKeyboardShow(window); |
2688 | 561 |
} |
562 |
return 0; |
|
563 |
} |
|
564 |
} |
|
565 |
||
566 |
#else |
|
567 |
||
568 |
/* stubs, used if compiled without keyboard support */ |
|
569 |
||
2714
c85ffe57d971
update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents:
2705
diff
changeset
|
570 |
int SDL_iPhoneKeyboardShow(SDL_Window *window) { |
2688 | 571 |
SDL_SetError("Not compiled with keyboard support"); |
572 |
return -1; |
|
573 |
} |
|
574 |
||
2714
c85ffe57d971
update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents:
2705
diff
changeset
|
575 |
int SDL_iPhoneKeyboardHide(SDL_Window *window) { |
2688 | 576 |
SDL_SetError("Not compiled with keyboard support"); |
577 |
return -1; |
|
578 |
} |
|
579 |
||
2714
c85ffe57d971
update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents:
2705
diff
changeset
|
580 |
SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window *window) { |
2688 | 581 |
return 0; |
582 |
} |
|
583 |
||
2714
c85ffe57d971
update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents:
2705
diff
changeset
|
584 |
int SDL_iPhoneKeyboardToggle(SDL_Window *window) { |
2688 | 585 |
SDL_SetError("Not compiled with keyboard support"); |
586 |
return -1; |
|
587 |
} |
|
588 |
||
589 |
||
590 |
#endif /* SDL_IPHONE_KEYBOARD */ |