Mercurial > sdl-ios-xcode
annotate src/video/uikit/SDL_uikitview.m @ 4488:6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 06 Jul 2010 22:08:19 -0700 |
parents | 3e69e077cb95 |
children | 06c7423f8c60 |
rev | line source |
---|---|
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
2859 | 3 Copyright (C) 1997-2009 Sam Lantinga |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 #import "SDL_uikitview.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 #if SDL_IPHONE_KEYBOARD |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 #import "SDL_keyboard_c.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 #import "keyinfotable.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 #import "SDL_uikitappdelegate.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 #import "SDL_uikitwindow.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 #endif |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 @implementation SDL_uikitview |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 - (void)dealloc { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 #if SDL_IPHONE_KEYBOARD |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 SDL_DelKeyboard(0); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 [textField release]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 #endif |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 [super dealloc]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 - (id)initWithFrame:(CGRect)frame { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 self = [super initWithFrame: frame]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 #if SDL_IPHONE_KEYBOARD |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 [self initializeKeyboard]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 #endif |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 |
4465
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
3685
diff
changeset
|
50 #if FIXME_MULTITOUCH |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 int i; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 for (i=0; i<MAX_SIMULTANEOUS_TOUCHES; i++) { |
2940
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
53 mice[i].id = i; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 mice[i].driverdata = NULL; |
2940
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
55 SDL_AddMouse(&mice[i], "Mouse", 0, 0, 1); |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 self.multipleTouchEnabled = YES; |
4465
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
3685
diff
changeset
|
58 #endif |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 return self; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 NSEnumerator *enumerator = [touches objectEnumerator]; |
4488
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
67 UITouch *touch = (UITouch*)[enumerator nextObject]; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 |
4465
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
3685
diff
changeset
|
69 #if FIXME_MULTITOUCH |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 /* associate touches with mice, so long as we have slots */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 int i; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 int found = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 for(i=0; touch && i < MAX_SIMULTANEOUS_TOUCHES; i++) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 /* check if this mouse is already tracking a touch */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 if (mice[i].driverdata != NULL) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 continue; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 /* |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 mouse not associated with anything right now, |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 associate the touch with this mouse |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 found = 1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 /* save old mouse so we can switch back */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 int oldMouse = SDL_SelectMouse(-1); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 /* select this slot's mouse */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 SDL_SelectMouse(i); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 CGPoint locationInView = [touch locationInView: self]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 /* set driver data to touch object, we'll use touch object later */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 mice[i].driverdata = [touch retain]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 /* send moved event */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 SDL_SendMouseMotion(i, 0, locationInView.x, locationInView.y, 0); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 /* send mouse down event */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 SDL_SendMouseButton(i, SDL_PRESSED, SDL_BUTTON_LEFT); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 /* re-calibrate relative mouse motion */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 SDL_GetRelativeMouseState(i, NULL, NULL); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 /* switch back to our old mouse */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 SDL_SelectMouse(oldMouse); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 |
4488
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
107 /* grab next touch */ |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
108 touch = (UITouch*)[enumerator nextObject]; |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
109 } |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
110 #else |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
111 if (touch) { |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
112 CGPoint locationInView = [touch locationInView: self]; |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
113 |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
114 /* send moved event */ |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
115 SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y); |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
116 |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
117 /* send mouse down event */ |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
118 SDL_SendMouseButton(NULL, SDL_PRESSED, SDL_BUTTON_LEFT); |
4465
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
3685
diff
changeset
|
119 } |
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
3685
diff
changeset
|
120 #endif |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 NSEnumerator *enumerator = [touches objectEnumerator]; |
4488
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
126 UITouch *touch = (UITouch*)[enumerator nextObject]; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 |
4465
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
3685
diff
changeset
|
128 #if FIXME_MULTITOUCH |
4488
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
129 while(touch) { |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 /* search for the mouse slot associated with this touch */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 int i, found = NO; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 for (i=0; i<MAX_SIMULTANEOUS_TOUCHES && !found; i++) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 if (mice[i].driverdata == touch) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 /* found the mouse associate with the touch */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 [(UITouch*)(mice[i].driverdata) release]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 mice[i].driverdata = NULL; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 /* send mouse up */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 SDL_SendMouseButton(i, SDL_RELEASED, SDL_BUTTON_LEFT); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 /* discontinue search for this touch */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 found = YES; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 } |
4488
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
143 |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
144 /* grab next touch */ |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
145 touch = (UITouch*)[enumerator nextObject]; |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
146 } |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
147 #else |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
148 if (touch) { |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
149 /* send mouse up */ |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
150 SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT); |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 } |
4465
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
3685
diff
changeset
|
152 #endif |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 /* |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 this can happen if the user puts more than 5 touches on the screen |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 at once, or perhaps in other circumstances. Usually (it seems) |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 all active touches are canceled. |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 [self touchesEnded: touches withEvent: event]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 NSEnumerator *enumerator = [touches objectEnumerator]; |
4488
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
167 UITouch *touch = (UITouch*)[enumerator nextObject]; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 |
4465
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
3685
diff
changeset
|
169 #if FIXME_MULTITOUCH |
4488
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
170 while(touch) { |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 /* try to find the mouse associated with this touch */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 int i, found = NO; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 for (i=0; i<MAX_SIMULTANEOUS_TOUCHES && !found; i++) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 if (mice[i].driverdata == touch) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 /* found proper mouse */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 CGPoint locationInView = [touch locationInView: self]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 /* send moved event */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 SDL_SendMouseMotion(i, 0, locationInView.x, locationInView.y, 0); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 /* discontinue search */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 found = YES; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 } |
4488
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
183 |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
184 /* grab next touch */ |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
185 touch = (UITouch*)[enumerator nextObject]; |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
186 } |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
187 #else |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
188 if (touch) { |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
189 CGPoint locationInView = [touch locationInView: self]; |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
190 |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
191 /* send moved event */ |
6dc6a2bdd55e
Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
192 SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y); |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 } |
4465
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
3685
diff
changeset
|
194 #endif |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 /* |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 ---- Keyboard related functionality below this line ---- |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 #if SDL_IPHONE_KEYBOARD |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 /* Is the iPhone virtual keyboard visible onscreen? */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 - (BOOL)keyboardVisible { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 return keyboardVisible; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 /* Set ourselves up as a UITextFieldDelegate */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 - (void)initializeKeyboard { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 textField = [[[UITextField alloc] initWithFrame: CGRectZero] autorelease]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 textField.delegate = self; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 /* placeholder so there is something to delete! */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 textField.text = @" "; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 /* set UITextInputTrait properties, mostly to defaults */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 textField.autocapitalizationType = UITextAutocapitalizationTypeNone; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 textField.autocorrectionType = UITextAutocorrectionTypeNo; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 textField.enablesReturnKeyAutomatically = NO; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 textField.keyboardAppearance = UIKeyboardAppearanceDefault; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 textField.keyboardType = UIKeyboardTypeDefault; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 textField.returnKeyType = UIReturnKeyDefault; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 textField.secureTextEntry = NO; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 textField.hidden = YES; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
225 keyboardVisible = NO; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 /* add the UITextField (hidden) to our view */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 [self addSubview: textField]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 /* create our SDL_Keyboard */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 SDL_Keyboard keyboard; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 SDL_zero(keyboard); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 SDL_AddKeyboard(&keyboard, 0); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 SDLKey keymap[SDL_NUM_SCANCODES]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 SDL_GetDefaultKeymap(keymap); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 SDL_SetKeymap(0, 0, keymap, SDL_NUM_SCANCODES); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 /* reveal onscreen virtual keyboard */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 - (void)showKeyboard { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 keyboardVisible = YES; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 [textField becomeFirstResponder]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 /* hide onscreen virtual keyboard */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 - (void)hideKeyboard { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 keyboardVisible = NO; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 [textField resignFirstResponder]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 /* UITextFieldDelegate method. Invoked when user types something. */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 - (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 if ([string length] == 0) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 /* it wants to replace text with nothing, ie a delete */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 SDL_SendKeyboardKey( 0, SDL_PRESSED, SDL_SCANCODE_DELETE); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 SDL_SendKeyboardKey( 0, SDL_RELEASED, SDL_SCANCODE_DELETE); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 else { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 /* go through all the characters in the string we've been sent |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 and convert them to key presses */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 int i; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 for (i=0; i<[string length]; i++) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 unichar c = [string characterAtIndex: i]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 Uint16 mod = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 SDL_scancode code; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 if (c < 127) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 /* figure out the SDL_scancode and SDL_keymod for this unichar */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 code = unicharToUIKeyInfoTable[c].code; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 mod = unicharToUIKeyInfoTable[c].mod; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 else { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 /* we only deal with ASCII right now */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 code = SDL_SCANCODE_UNKNOWN; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 mod = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 if (mod & KMOD_SHIFT) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 /* If character uses shift, press shift down */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 SDL_SendKeyboardKey( 0, SDL_PRESSED, SDL_SCANCODE_LSHIFT); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 /* send a keydown and keyup even for the character */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 SDL_SendKeyboardKey( 0, SDL_PRESSED, code); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 SDL_SendKeyboardKey( 0, SDL_RELEASED, code); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 if (mod & KMOD_SHIFT) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 /* If character uses shift, press shift back up */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
290 SDL_SendKeyboardKey( 0, SDL_RELEASED, SDL_SCANCODE_LSHIFT); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 return NO; /* don't allow the edit! (keep placeholder text there) */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 /* Terminates the editing session */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 - (BOOL)textFieldShouldReturn:(UITextField*)_textField { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 [self hideKeyboard]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
300 return YES; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
301 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
302 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
303 #endif |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
304 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
305 @end |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
306 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 /* iPhone keyboard addition functions */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 #if SDL_IPHONE_KEYBOARD |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
2940
diff
changeset
|
310 int SDL_iPhoneKeyboardShow(SDL_Window * window) { |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 SDL_WindowData *data; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 SDL_uikitview *view; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
314 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 if (NULL == window) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
316 SDL_SetError("Window does not exist"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 return -1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 data = (SDL_WindowData *)window->driverdata; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 view = data->view; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 if (nil == view) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 SDL_SetError("Window has no view"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 return -1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 else { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 [view showKeyboard]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 return 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
2940
diff
changeset
|
333 int SDL_iPhoneKeyboardHide(SDL_Window * window) { |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
334 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
335 SDL_WindowData *data; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 SDL_uikitview *view; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
338 if (NULL == window) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 SDL_SetError("Window does not exist"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 return -1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 data = (SDL_WindowData *)window->driverdata; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 view = data->view; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
346 if (NULL == view) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 SDL_SetError("Window has no view"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 return -1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
350 else { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 [view hideKeyboard]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 return 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
354 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
355 |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
2940
diff
changeset
|
356 SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) { |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
357 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
358 SDL_WindowData *data; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
359 SDL_uikitview *view; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
360 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
361 if (NULL == window) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
362 SDL_SetError("Window does not exist"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
363 return -1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
364 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
365 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
366 data = (SDL_WindowData *)window->driverdata; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
367 view = data->view; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
368 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
369 if (NULL == view) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
370 SDL_SetError("Window has no view"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
371 return 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
372 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
373 else { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
374 return view.keyboardVisible; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
375 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
376 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
377 |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
2940
diff
changeset
|
378 int SDL_iPhoneKeyboardToggle(SDL_Window * window) { |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
379 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
380 SDL_WindowData *data; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
381 SDL_uikitview *view; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
382 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
383 if (NULL == window) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
384 SDL_SetError("Window does not exist"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
385 return -1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
386 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
387 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
388 data = (SDL_WindowData *)window->driverdata; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
389 view = data->view; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
390 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
391 if (NULL == view) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
392 SDL_SetError("Window has no view"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
393 return -1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
394 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
395 else { |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
2940
diff
changeset
|
396 if (SDL_iPhoneKeyboardIsShown(window)) { |
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
2940
diff
changeset
|
397 SDL_iPhoneKeyboardHide(window); |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
398 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
399 else { |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
2940
diff
changeset
|
400 SDL_iPhoneKeyboardShow(window); |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
401 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
402 return 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
403 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
404 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
405 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
406 #else |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
407 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
408 /* stubs, used if compiled without keyboard support */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
409 |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
2940
diff
changeset
|
410 int SDL_iPhoneKeyboardShow(SDL_Window * window) { |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
411 SDL_SetError("Not compiled with keyboard support"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
412 return -1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
413 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
414 |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
2940
diff
changeset
|
415 int SDL_iPhoneKeyboardHide(SDL_Window * window) { |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
416 SDL_SetError("Not compiled with keyboard support"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
417 return -1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
418 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
419 |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
2940
diff
changeset
|
420 SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) { |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
421 return 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
422 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
423 |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
2940
diff
changeset
|
424 int SDL_iPhoneKeyboardToggle(SDL_Window * window) { |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
425 SDL_SetError("Not compiled with keyboard support"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
426 return -1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
427 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
428 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
429 |
2859 | 430 #endif /* SDL_IPHONE_KEYBOARD */ |