Mercurial > sdl-ios-xcode
annotate src/video/uikit/SDL_uikitview.m @ 4660:b15e7017409b
Added Iphone support (untested)
author | Jim Grandpre <jim.tla@gmail.com> |
---|---|
date | Mon, 12 Jul 2010 22:03:25 -0400 |
parents | 64ce267332c6 |
children | 03dcb795c583 |
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 |
4660
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
25 #include "../../events/SDL_keyboard_c.h" |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
26 #include "../../events/SDL_mouse_c.h" |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
27 |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 #if SDL_IPHONE_KEYBOARD |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 #import "keyinfotable.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 #import "SDL_uikitappdelegate.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 #import "SDL_uikitwindow.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 #endif |
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 @implementation SDL_uikitview |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 - (void)dealloc { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 #if SDL_IPHONE_KEYBOARD |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 [textField release]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 #endif |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 [super dealloc]; |
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 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 - (id)initWithFrame:(CGRect)frame { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 self = [super initWithFrame: frame]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 #if SDL_IPHONE_KEYBOARD |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 [self initializeKeyboard]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 #endif |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 |
4660
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
51 #if FIXME_MULTITOUCH |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 int i; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 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
|
54 mice[i].id = i; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 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
|
56 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
|
57 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 self.multipleTouchEnabled = YES; |
4660
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
59 #endif |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
60 #if FIXED_MULTITOUCH |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
61 SDL_Touch touch; |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
62 touch.id = 0; //TODO: Should be -1? |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
63 |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
64 //touch.driverdata = SDL_malloc(sizeof(EventTouchData)); |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
65 //EventTouchData* data = (EventTouchData*)(touch.driverdata); |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
66 |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
67 touch.x_min = 0; |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
68 touch.x_max = frame.size.width; |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
69 touch.xres = touch.x_max - touch.x_min; |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
70 touch.y_min = 0; |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
71 touch.y_max = frame.size.height; |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
72 touch.yres = touch.y_max - touch.y_min; |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
73 touch.pressure_min = 0; |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
74 touch.pressure_max = 1; |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
75 touch.pressureres = touch.pressure_max - touch.pressure_min; |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
76 |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
77 |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
78 touchId = SDL_AddTouch(&touch, "IPHONE SCREEN"); |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
79 #endif |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 return self; |
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 } |
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 - (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
|
86 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 NSEnumerator *enumerator = [touches objectEnumerator]; |
4660
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
88 UITouch *touch = (UITouch*)[enumerator nextObject]; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 |
4660
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
90 #if FIXME_MULTITOUCH |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 /* 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
|
92 int i; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 int found = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 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
|
95 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 /* 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
|
97 if (mice[i].driverdata != NULL) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 continue; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 } |
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 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
|
102 associate the touch with this mouse |
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 found = 1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 /* 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
|
107 int oldMouse = SDL_SelectMouse(-1); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 /* select this slot's mouse */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 SDL_SelectMouse(i); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 CGPoint locationInView = [touch locationInView: self]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 /* 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
|
114 mice[i].driverdata = [touch retain]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 /* send moved event */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 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
|
118 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 /* send mouse down event */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 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
|
121 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 /* re-calibrate relative mouse motion */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 SDL_GetRelativeMouseState(i, NULL, NULL); |
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 /* switch back to our old mouse */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 SDL_SelectMouse(oldMouse); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 |
4660
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
128 /* grab next touch */ |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
129 touch = (UITouch*)[enumerator nextObject]; |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
130 } |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
131 #else |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
132 if (touch) { |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
133 CGPoint locationInView = [touch locationInView: self]; |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
134 |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
135 /* send moved event */ |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
136 SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y); |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
137 |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
138 /* send mouse down event */ |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
139 SDL_SendMouseButton(NULL, SDL_PRESSED, SDL_BUTTON_LEFT); |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
140 } |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
141 #endif |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
142 |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
143 #if FIXED_MULTITOUCH |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
144 while(touch) { |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
145 CGPoint locationInView = [touch locationInView: self]; |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
146 SDL_SendFingerDown(touchId,(int)touch, |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
147 SDL_TRUE,locationInView.x,locationInView.y, |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
148 1); |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
149 |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
150 touch = (UITouch*)[enumerator nextObject]; |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
151 } |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
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)touchesEnded:(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 NSEnumerator *enumerator = [touches objectEnumerator]; |
4660
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
158 UITouch *touch = (UITouch*)[enumerator nextObject]; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 |
4660
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
160 #if FIXME_MULTITOUCH |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
161 while(touch) { |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 /* 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
|
163 int i, found = NO; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 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
|
165 if (mice[i].driverdata == touch) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 /* 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
|
167 [(UITouch*)(mice[i].driverdata) release]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 mice[i].driverdata = NULL; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 /* send mouse up */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 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
|
171 /* discontinue search for this touch */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 found = YES; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 } |
4660
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
175 |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
176 /* grab next touch */ |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
177 touch = (UITouch*)[enumerator nextObject]; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 } |
4660
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
179 #else |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
180 if (touch) { |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
181 /* send mouse up */ |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
182 SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT); |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
183 } |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
184 #endif |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
185 #if FIXED_MULTITOUCH |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
186 while(touch) { |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
187 CGPoint locationInView = [touch locationInView: self]; |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
188 SDL_SendFingerDown(touchId,(int)touch, |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
189 SDL_FALSE,locationInView.x,locationInView.y, |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
190 1); |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
191 |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
192 touch = (UITouch*)[enumerator nextObject]; |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
193 } |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
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 - (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
|
198 /* |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 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
|
200 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
|
201 all active touches are canceled. |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 [self touchesEnded: touches withEvent: event]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 } |
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 - (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
|
207 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 NSEnumerator *enumerator = [touches objectEnumerator]; |
4660
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
209 UITouch *touch = (UITouch*)[enumerator nextObject]; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 |
4660
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
211 #if FIXME_MULTITOUCH |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
212 while(touch) { |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 /* 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
|
214 int i, found = NO; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 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
|
216 if (mice[i].driverdata == touch) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 /* found proper mouse */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 CGPoint locationInView = [touch locationInView: self]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 /* send moved event */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 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
|
221 /* discontinue search */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 found = YES; |
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 } |
4660
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
225 |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
226 /* grab next touch */ |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
227 touch = (UITouch*)[enumerator nextObject]; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 } |
4660
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
229 #else |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
230 if (touch) { |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
231 CGPoint locationInView = [touch locationInView: self]; |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
232 |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
233 /* send moved event */ |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
234 SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y); |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
235 } |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
236 #endif |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
237 |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
238 #if FIXED_MULTITOUCH |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
239 while(touch) { |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
240 CGPoint locationInView = [touch locationInView: self]; |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
241 SDL_SendTouchMotion(touchId,(int)touch, |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
242 SDL_FALSE,locationInView.x,locationInView.y, |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
243 1); |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
244 |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
245 touch = (UITouch*)[enumerator nextObject]; |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
246 } |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
247 #endif |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 } |
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 ---- Keyboard related functionality below this line ---- |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 #if SDL_IPHONE_KEYBOARD |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 /* 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
|
256 - (BOOL)keyboardVisible { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 return keyboardVisible; |
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 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 /* Set ourselves up as a UITextFieldDelegate */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 - (void)initializeKeyboard { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 textField = [[[UITextField alloc] initWithFrame: CGRectZero] autorelease]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 textField.delegate = self; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 /* 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
|
266 textField.text = @" "; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 /* set UITextInputTrait properties, mostly to defaults */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 textField.autocapitalizationType = UITextAutocapitalizationTypeNone; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 textField.autocorrectionType = UITextAutocorrectionTypeNo; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 textField.enablesReturnKeyAutomatically = NO; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 textField.keyboardAppearance = UIKeyboardAppearanceDefault; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 textField.keyboardType = UIKeyboardTypeDefault; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 textField.returnKeyType = UIReturnKeyDefault; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 textField.secureTextEntry = NO; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 textField.hidden = YES; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 keyboardVisible = NO; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 /* 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
|
280 [self addSubview: textField]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 /* reveal onscreen virtual keyboard */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 - (void)showKeyboard { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 keyboardVisible = YES; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 [textField becomeFirstResponder]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 /* hide onscreen virtual keyboard */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
290 - (void)hideKeyboard { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 keyboardVisible = NO; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 [textField resignFirstResponder]; |
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 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 /* 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
|
296 - (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
|
297 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 if ([string length] == 0) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 /* it wants to replace text with nothing, ie a delete */ |
4660
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
300 SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE); |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
301 SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE); |
2765
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 else { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
304 /* 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
|
305 and convert them to key presses */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
306 int i; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 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
|
308 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 unichar c = [string characterAtIndex: i]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 Uint16 mod = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 SDL_scancode code; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
314 if (c < 127) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 /* 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
|
316 code = unicharToUIKeyInfoTable[c].code; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 mod = unicharToUIKeyInfoTable[c].mod; |
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 else { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 /* 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
|
321 code = SDL_SCANCODE_UNKNOWN; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 mod = 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 if (mod & KMOD_SHIFT) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 /* If character uses shift, press shift down */ |
4660
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
327 SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT); |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 /* send a keydown and keyup even for the character */ |
4660
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
330 SDL_SendKeyboardKey(SDL_PRESSED, code); |
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
331 SDL_SendKeyboardKey(SDL_RELEASED, code); |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 if (mod & KMOD_SHIFT) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
333 /* If character uses shift, press shift back up */ |
4660
b15e7017409b
Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents:
3685
diff
changeset
|
334 SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT); |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
335 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 } |
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 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
|
339 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 /* Terminates the editing session */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 - (BOOL)textFieldShouldReturn:(UITextField*)_textField { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 [self hideKeyboard]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 return YES; |
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 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 #endif |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 @end |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
350 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 /* iPhone keyboard addition functions */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 #if SDL_IPHONE_KEYBOARD |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 |
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
|
354 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
|
355 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
356 SDL_WindowData *data; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
357 SDL_uikitview *view; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
358 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
359 if (NULL == window) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
360 SDL_SetError("Window does not exist"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
361 return -1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
362 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
363 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
364 data = (SDL_WindowData *)window->driverdata; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
365 view = data->view; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
366 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
367 if (nil == view) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
368 SDL_SetError("Window has no view"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
369 return -1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
370 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
371 else { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
372 [view showKeyboard]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
373 return 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
374 } |
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 |
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
|
377 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
|
378 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
379 SDL_WindowData *data; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
380 SDL_uikitview *view; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
381 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
382 if (NULL == window) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
383 SDL_SetError("Window does not exist"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
384 return -1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
385 } |
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 data = (SDL_WindowData *)window->driverdata; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
388 view = data->view; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
389 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
390 if (NULL == view) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
391 SDL_SetError("Window has no view"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
392 return -1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
393 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
394 else { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
395 [view hideKeyboard]; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
396 return 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
397 } |
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 |
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_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
|
401 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
402 SDL_WindowData *data; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
403 SDL_uikitview *view; |
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 if (NULL == window) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
406 SDL_SetError("Window does not exist"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
407 return -1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
408 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
409 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
410 data = (SDL_WindowData *)window->driverdata; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
411 view = data->view; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
412 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
413 if (NULL == view) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
414 SDL_SetError("Window has no view"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
415 return 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
416 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
417 else { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
418 return view.keyboardVisible; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
419 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
420 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
421 |
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
|
422 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
|
423 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
424 SDL_WindowData *data; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
425 SDL_uikitview *view; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
426 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
427 if (NULL == window) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
428 SDL_SetError("Window does not exist"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
429 return -1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
430 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
431 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
432 data = (SDL_WindowData *)window->driverdata; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
433 view = data->view; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
434 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
435 if (NULL == view) { |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
436 SDL_SetError("Window has no view"); |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
437 return -1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
438 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
439 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
|
440 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
|
441 SDL_iPhoneKeyboardHide(window); |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
442 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
443 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
|
444 SDL_iPhoneKeyboardShow(window); |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
445 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
446 return 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
447 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
448 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
449 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
450 #else |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
451 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
452 /* 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
|
453 |
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
|
454 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
|
455 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
|
456 return -1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
457 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
458 |
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
|
459 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
|
460 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
|
461 return -1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
462 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
463 |
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
|
464 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
|
465 return 0; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
466 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
467 |
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
|
468 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
|
469 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
|
470 return -1; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
471 } |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
472 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
473 |
2859 | 474 #endif /* SDL_IPHONE_KEYBOARD */ |