annotate src/video/uikit/SDL_uikitview.m @ 5026:0f36ef361705

Fixed building with the latest iOS SDK (4.2)
author Sam Lantinga <slouken@libsdl.org>
date Tue, 18 Jan 2011 16:55:03 -0800
parents c24ba2cc9583
children a69e36365766
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
99210400e8b9 Updated copyright date
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
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
4490
06c7423f8c60 Updated iPhone keyboard code (which builds and runs on the iPad and iPhone simulator now)
Sam Lantinga <slouken@libsdl.org>
parents: 4488
diff changeset
25 #include "../../events/SDL_keyboard_c.h"
06c7423f8c60 Updated iPhone keyboard code (which builds and runs on the iPad and iPhone simulator now)
Sam Lantinga <slouken@libsdl.org>
parents: 4488
diff changeset
26 #include "../../events/SDL_mouse_c.h"
4677
31607094315c Added Iphone project. Iphone multi-touch is now functional.
jimtla
parents: 4662
diff changeset
27 #include "../../events/SDL_touch_c.h"
4490
06c7423f8c60 Updated iPhone keyboard code (which builds and runs on the iPad and iPhone simulator now)
Sam Lantinga <slouken@libsdl.org>
parents: 4488
diff changeset
28
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 #if SDL_IPHONE_KEYBOARD
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 #import "keyinfotable.h"
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 #import "SDL_uikitappdelegate.h"
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 #import "SDL_uikitwindow.h"
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 #endif
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 @implementation SDL_uikitview
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 - (void)dealloc {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 #if SDL_IPHONE_KEYBOARD
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 [textField release];
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 #endif
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 [super dealloc];
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
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 - (id)initWithFrame:(CGRect)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 self = [super initWithFrame: frame];
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 #if SDL_IPHONE_KEYBOARD
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 [self initializeKeyboard];
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 #endif
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51
4677
31607094315c Added Iphone project. Iphone multi-touch is now functional.
jimtla
parents: 4662
diff changeset
52 #ifdef FIXED_MULTITOUCH
4660
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
53 SDL_Touch touch;
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
54 touch.id = 0; //TODO: Should be -1?
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
55
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
56 //touch.driverdata = SDL_malloc(sizeof(EventTouchData));
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
57 //EventTouchData* data = (EventTouchData*)(touch.driverdata);
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
58
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
59 touch.x_min = 0;
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
60 touch.x_max = frame.size.width;
4678
f8431f66613d Added SDL_TouchID, SDL_FingerID, SDL_GestureID types. Converted to integer cioordinates (<- not working).
jimtla
parents: 4677
diff changeset
61 touch.native_xres = touch.x_max - touch.x_min;
4660
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
62 touch.y_min = 0;
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
63 touch.y_max = frame.size.height;
4678
f8431f66613d Added SDL_TouchID, SDL_FingerID, SDL_GestureID types. Converted to integer cioordinates (<- not working).
jimtla
parents: 4677
diff changeset
64 touch.native_yres = touch.y_max - touch.y_min;
4660
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
65 touch.pressure_min = 0;
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
66 touch.pressure_max = 1;
4678
f8431f66613d Added SDL_TouchID, SDL_FingerID, SDL_GestureID types. Converted to integer cioordinates (<- not working).
jimtla
parents: 4677
diff changeset
67 touch.native_pressureres = touch.pressure_max - touch.pressure_min;
4660
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
68
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
69
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
70 touchId = SDL_AddTouch(&touch, "IPHONE SCREEN");
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
71 #endif
4661
03dcb795c583 Merged changes from the main SDL codebase
Sam Lantinga <slouken@libsdl.org>
parents: 4660 4490
diff changeset
72
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 return self;
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 }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 - (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
78
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 NSEnumerator *enumerator = [touches objectEnumerator];
4488
6dc6a2bdd55e Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
80 UITouch *touch = (UITouch*)[enumerator nextObject];
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81
4677
31607094315c Added Iphone project. Iphone multi-touch is now functional.
jimtla
parents: 4662
diff changeset
82 //NSLog("Click");
31607094315c Added Iphone project. Iphone multi-touch is now functional.
jimtla
parents: 4662
diff changeset
83
4488
6dc6a2bdd55e Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
84 if (touch) {
6dc6a2bdd55e Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
85 CGPoint locationInView = [touch locationInView: self];
6dc6a2bdd55e Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
86
6dc6a2bdd55e Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
87 /* send moved event */
6dc6a2bdd55e Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
88 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
89
6dc6a2bdd55e Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
90 /* send mouse down event */
6dc6a2bdd55e Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
91 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
92 }
4660
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
93
4677
31607094315c Added Iphone project. Iphone multi-touch is now functional.
jimtla
parents: 4662
diff changeset
94 #ifdef FIXED_MULTITOUCH
4660
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
95 while(touch) {
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
96 CGPoint locationInView = [touch locationInView: self];
4662
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
97
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
98
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
99 #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
100 //FIXME: TODO: Using touch as the fingerId is potentially dangerous
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
101 //It is also much more efficient than storing the UITouch pointer
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
102 //and comparing it to the incoming event.
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
103 SDL_SendFingerDown(touchId,(long)touch,
4660
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
104 SDL_TRUE,locationInView.x,locationInView.y,
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
105 1);
4662
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
106 #else
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
107 int i;
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
108 for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) {
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
109 if(finger[i] == NULL) {
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
110 finger[i] = touch;
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
111 SDL_SendFingerDown(touchId,i,
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
112 SDL_TRUE,locationInView.x,locationInView.y,
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
113 1);
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
114 break;
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
115 }
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
116 }
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
117 #endif
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
118
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
119
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
120
4660
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
121
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
122 touch = (UITouch*)[enumerator nextObject];
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
123 }
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
124 #endif
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 - (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
128
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 NSEnumerator *enumerator = [touches objectEnumerator];
4488
6dc6a2bdd55e Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
130 UITouch *touch = (UITouch*)[enumerator nextObject];
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131
4488
6dc6a2bdd55e Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
132 if (touch) {
6dc6a2bdd55e Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
133 /* send mouse up */
6dc6a2bdd55e Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
134 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
135 }
4661
03dcb795c583 Merged changes from the main SDL codebase
Sam Lantinga <slouken@libsdl.org>
parents: 4660 4490
diff changeset
136
4677
31607094315c Added Iphone project. Iphone multi-touch is now functional.
jimtla
parents: 4662
diff changeset
137 #ifdef FIXED_MULTITOUCH
4660
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
138 while(touch) {
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
139 CGPoint locationInView = [touch locationInView: self];
4662
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
140
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
141
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
142 #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
143 SDL_SendFingerDown(touchId,(long)touch,
4660
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
144 SDL_FALSE,locationInView.x,locationInView.y,
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
145 1);
4662
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
146 #else
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
147 int i;
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
148 for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) {
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
149 if(finger[i] == touch) {
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
150 SDL_SendFingerDown(touchId,i,
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
151 SDL_FALSE,locationInView.x,locationInView.y,
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
152 1);
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
153 break;
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
154 }
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
155 }
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
156 #endif
4660
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
157
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
158 touch = (UITouch*)[enumerator nextObject];
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
159 }
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
160 #endif
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 }
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 - (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
164 /*
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 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
166 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
167 all active touches are canceled.
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 [self touchesEnded: touches withEvent: event];
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 - (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
173
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 NSEnumerator *enumerator = [touches objectEnumerator];
4488
6dc6a2bdd55e Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
175 UITouch *touch = (UITouch*)[enumerator nextObject];
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176
4488
6dc6a2bdd55e Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
177 if (touch) {
6dc6a2bdd55e Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
178 CGPoint locationInView = [touch locationInView: self];
6dc6a2bdd55e Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
179
6dc6a2bdd55e Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
180 /* send moved event */
6dc6a2bdd55e Re-implemented single mouse touches on the iPhone/iPad
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
181 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
182 }
4660
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
183
4677
31607094315c Added Iphone project. Iphone multi-touch is now functional.
jimtla
parents: 4662
diff changeset
184 #ifdef FIXED_MULTITOUCH
4660
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
185 while(touch) {
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
186 CGPoint locationInView = [touch locationInView: self];
4662
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
187
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
188
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
189 #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
190 SDL_SendTouchMotion(touchId,(long)touch,
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
191 SDL_FALSE,locationInView.x,locationInView.y,
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
192 1);
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
193 #else
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
194 int i;
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
195 for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) {
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
196 if(finger[i] == touch) {
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
197 SDL_SendTouchMotion(touchId,i,
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
198 SDL_FALSE,locationInView.x,locationInView.y,
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
199 1);
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
200 break;
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
201 }
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
202 }
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4661
diff changeset
203 #endif
4660
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
204
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
205 touch = (UITouch*)[enumerator nextObject];
b15e7017409b Added Iphone support (untested)
Jim Grandpre <jim.tla@gmail.com>
parents: 3685
diff changeset
206 }
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
207 #endif
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 }
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 /*
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 ---- Keyboard related functionality below this line ----
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 #if SDL_IPHONE_KEYBOARD
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 /* 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
216 - (BOOL)keyboardVisible {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 return keyboardVisible;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 /* Set ourselves up as a UITextFieldDelegate */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 - (void)initializeKeyboard {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 textField = [[[UITextField alloc] initWithFrame: CGRectZero] autorelease];
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 textField.delegate = self;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 /* 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
226 textField.text = @" ";
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 /* set UITextInputTrait properties, mostly to defaults */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230 textField.autocorrectionType = UITextAutocorrectionTypeNo;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 textField.enablesReturnKeyAutomatically = NO;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 textField.keyboardAppearance = UIKeyboardAppearanceDefault;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 textField.keyboardType = UIKeyboardTypeDefault;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 textField.returnKeyType = UIReturnKeyDefault;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235 textField.secureTextEntry = NO;
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 textField.hidden = YES;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 keyboardVisible = NO;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 /* 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
240 [self addSubview: textField];
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 /* reveal onscreen virtual keyboard */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 - (void)showKeyboard {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 keyboardVisible = YES;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 [textField becomeFirstResponder];
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 }
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 /* hide onscreen virtual keyboard */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 - (void)hideKeyboard {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251 keyboardVisible = NO;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 [textField resignFirstResponder];
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
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 /* 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
256 - (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
257
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 if ([string length] == 0) {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 /* it wants to replace text with nothing, ie a delete */
4490
06c7423f8c60 Updated iPhone keyboard code (which builds and runs on the iPad and iPhone simulator now)
Sam Lantinga <slouken@libsdl.org>
parents: 4488
diff changeset
260 SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE);
06c7423f8c60 Updated iPhone keyboard code (which builds and runs on the iPad and iPhone simulator now)
Sam Lantinga <slouken@libsdl.org>
parents: 4488
diff changeset
261 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
262 }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263 else {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264 /* 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
265 and convert them to key presses */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266 int i;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267 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
268
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 unichar c = [string characterAtIndex: i];
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271 Uint16 mod = 0;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272 SDL_scancode code;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 if (c < 127) {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 /* 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
276 code = unicharToUIKeyInfoTable[c].code;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277 mod = unicharToUIKeyInfoTable[c].mod;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279 else {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 /* 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
281 code = SDL_SCANCODE_UNKNOWN;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 mod = 0;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283 }
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 if (mod & KMOD_SHIFT) {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
286 /* If character uses shift, press shift down */
4490
06c7423f8c60 Updated iPhone keyboard code (which builds and runs on the iPad and iPhone simulator now)
Sam Lantinga <slouken@libsdl.org>
parents: 4488
diff changeset
287 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
288 }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
289 /* send a keydown and keyup even for the character */
4490
06c7423f8c60 Updated iPhone keyboard code (which builds and runs on the iPad and iPhone simulator now)
Sam Lantinga <slouken@libsdl.org>
parents: 4488
diff changeset
290 SDL_SendKeyboardKey(SDL_PRESSED, code);
06c7423f8c60 Updated iPhone keyboard code (which builds and runs on the iPad and iPhone simulator now)
Sam Lantinga <slouken@libsdl.org>
parents: 4488
diff changeset
291 SDL_SendKeyboardKey(SDL_RELEASED, code);
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
292 if (mod & KMOD_SHIFT) {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293 /* If character uses shift, press shift back up */
4490
06c7423f8c60 Updated iPhone keyboard code (which builds and runs on the iPad and iPhone simulator now)
Sam Lantinga <slouken@libsdl.org>
parents: 4488
diff changeset
294 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
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 }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
298 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
299 }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
301 /* Terminates the editing session */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
302 - (BOOL)textFieldShouldReturn:(UITextField*)_textField {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
303 [self hideKeyboard];
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
304 return YES;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
305 }
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 #endif
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 @end
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 /* iPhone keyboard addition functions */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
312 #if SDL_IPHONE_KEYBOARD
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
313
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
314 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
315
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316 SDL_WindowData *data;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317 SDL_uikitview *view;
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 if (NULL == window) {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320 SDL_SetError("Window does not exist");
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 return -1;
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
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324 data = (SDL_WindowData *)window->driverdata;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 view = data->view;
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 if (nil == view) {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 SDL_SetError("Window has no view");
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 return -1;
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 else {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 [view showKeyboard];
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333 return 0;
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 }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336
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
337 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
338
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339 SDL_WindowData *data;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 SDL_uikitview *view;
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 if (NULL == window) {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343 SDL_SetError("Window does not exist");
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
344 return -1;
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 data = (SDL_WindowData *)window->driverdata;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348 view = data->view;
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 if (NULL == view) {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
351 SDL_SetError("Window has no view");
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352 return -1;
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 else {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
355 [view hideKeyboard];
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
356 return 0;
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 }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359
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
360 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
361
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
362 SDL_WindowData *data;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
363 SDL_uikitview *view;
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 if (NULL == window) {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
366 SDL_SetError("Window does not exist");
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
367 return -1;
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
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370 data = (SDL_WindowData *)window->driverdata;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
371 view = data->view;
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 if (NULL == view) {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374 SDL_SetError("Window has no view");
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
375 return 0;
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 else {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
378 return view.keyboardVisible;
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 }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
381
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
382 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
383
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
384 SDL_WindowData *data;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
385 SDL_uikitview *view;
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 if (NULL == window) {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
388 SDL_SetError("Window does not exist");
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
389 return -1;
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
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
392 data = (SDL_WindowData *)window->driverdata;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
393 view = data->view;
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 if (NULL == view) {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
396 SDL_SetError("Window has no view");
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
397 return -1;
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 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
401 SDL_iPhoneKeyboardHide(window);
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
402 }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
403 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
404 SDL_iPhoneKeyboardShow(window);
2765
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 return 0;
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 }
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 #else
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
411
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
412 /* 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
413
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
414 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
415 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
416 return -1;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
417 }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
418
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
419 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
420 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
421 return -1;
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 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
425 return 0;
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
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
428 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
429 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
430 return -1;
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
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
433
2859
99210400e8b9 Updated copyright date
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
434 #endif /* SDL_IPHONE_KEYBOARD */