Originally keyboard support was in the form of a category of the class SDL_uikitview. It turns out this can cause problems with compilation where the code is not actually included and doesn't fail until dynamic dispatch. This is just awful, so I've moved to the code into the SDL_uikitview class itself. gsoc2008_iphone
authorHolmes Futrell <hfutrell@umail.ucsb.edu>
Wed, 13 Aug 2008 23:14:36 +0000
branchgsoc2008_iphone
changeset 2419ab89ff6e97af
parent 2418 9aac7992ed85
child 2420 e759e6f98343
Originally keyboard support was in the form of a category of the class SDL_uikitview. It turns out this can cause problems with compilation where the code is not actually included and doesn't fail until dynamic dispatch. This is just awful, so I've moved to the code into the SDL_uikitview class itself.
src/video/uikit/SDL_uikitkeyboard.h
src/video/uikit/SDL_uikitkeyboard.m
src/video/uikit/SDL_uikitview.h
src/video/uikit/SDL_uikitview.m
     1.1 --- a/src/video/uikit/SDL_uikitkeyboard.h	Wed Aug 13 23:12:00 2008 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,47 +0,0 @@
     1.4 -/*
     1.5 - SDL - Simple DirectMedia Layer
     1.6 - Copyright (C) 1997-2006 Sam Lantinga
     1.7 - 
     1.8 - This library is free software; you can redistribute it and/or
     1.9 - modify it under the terms of the GNU Lesser General Public
    1.10 - License as published by the Free Software Foundation; either
    1.11 - version 2.1 of the License, or (at your option) any later version.
    1.12 - 
    1.13 - This library is distributed in the hope that it will be useful,
    1.14 - but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.16 - Lesser General Public License for more details.
    1.17 - 
    1.18 - You should have received a copy of the GNU Lesser General Public
    1.19 - License along with this library; if not, write to the Free Software
    1.20 - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1.21 - 
    1.22 - Sam Lantinga
    1.23 - slouken@libsdl.org
    1.24 - */
    1.25 -
    1.26 -#ifndef _SDL_uikitkeyboard_h
    1.27 -#define _SDL_uikitkeyboard_h
    1.28 -
    1.29 -#if SDL_IPHONE_KEYBOARD
    1.30 -
    1.31 -#import "SDL_uikitview.h"
    1.32 -
    1.33 -@interface SDL_uikitview (keyboardMethods)
    1.34 -
    1.35 -- (void)showKeyboard;
    1.36 -- (void)hideKeyboard;
    1.37 -- (void)initializeKeyboard;
    1.38 -
    1.39 -@property (readonly) BOOL keyboardVisible;
    1.40 -
    1.41 -@end
    1.42 -
    1.43 -#endif /* SDL_IPHONE_KEYBOARD */
    1.44 -
    1.45 -extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardShow(SDL_WindowID windowID);
    1.46 -extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardHide(SDL_WindowID windowID);
    1.47 -extern DECLSPEC SDL_bool SDLCALL SDL_iPhoneKeyboardIsShown(SDL_WindowID windowID);
    1.48 -extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardToggle(SDL_WindowID windowID);
    1.49 -
    1.50 -#endif /* _SDL_uikitkeyboard_h */
     2.1 --- a/src/video/uikit/SDL_uikitkeyboard.m	Wed Aug 13 23:12:00 2008 +0000
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,263 +0,0 @@
     2.4 -/*
     2.5 - SDL - Simple DirectMedia Layer
     2.6 - Copyright (C) 1997-2006 Sam Lantinga
     2.7 - 
     2.8 - This library is free software; you can redistribute it and/or
     2.9 - modify it under the terms of the GNU Lesser General Public
    2.10 - License as published by the Free Software Foundation; either
    2.11 - version 2.1 of the License, or (at your option) any later version.
    2.12 - 
    2.13 - This library is distributed in the hope that it will be useful,
    2.14 - but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.15 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    2.16 - Lesser General Public License for more details.
    2.17 - 
    2.18 - You should have received a copy of the GNU Lesser General Public
    2.19 - License along with this library; if not, write to the Free Software
    2.20 - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    2.21 - 
    2.22 - Sam Lantinga
    2.23 - slouken@libsdl.org
    2.24 - */
    2.25 -
    2.26 -#include "SDL_video.h"
    2.27 -
    2.28 -#if SDL_IPHONE_KEYBOARD
    2.29 -
    2.30 -#import "SDL_uikitkeyboard.h"
    2.31 -#import "SDL_uikitview.h"
    2.32 -#import "SDL_keyboard_c.h"
    2.33 -#import "keyinfotable.h"
    2.34 -#import "SDL_uikitappdelegate.h"
    2.35 -#import "SDL_uikitwindow.h"
    2.36 -
    2.37 -@implementation  SDL_uikitview (keyboardMethods)
    2.38 -
    2.39 -- (BOOL)keyboardVisible {
    2.40 -	return keyboardVisible;
    2.41 -}
    2.42 -
    2.43 -/* UITextFieldDelegate related methods */
    2.44 -- (void)initializeKeyboard {
    2.45 -	
    2.46 -	NSLog(@"Text field init");
    2.47 -	
    2.48 -	textField = [[UITextField alloc] initWithFrame: CGRectZero];
    2.49 -	textField.delegate = self;
    2.50 -	/* placeholder so there is something to delete! */
    2.51 -	textField.text = @" ";	
    2.52 -	
    2.53 -	/* set UITextInputTrait properties, mostly to defaults */
    2.54 -	textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
    2.55 -	textField.autocorrectionType = UITextAutocorrectionTypeNo;
    2.56 -	textField.enablesReturnKeyAutomatically = NO;
    2.57 -	textField.keyboardAppearance = UIKeyboardAppearanceDefault;
    2.58 -	textField.keyboardType = UIKeyboardTypeDefault;
    2.59 -	textField.returnKeyType = UIReturnKeyDefault;
    2.60 -	textField.secureTextEntry = NO;	
    2.61 -		
    2.62 -	textField.hidden = YES;
    2.63 -	keyboardVisible = NO;
    2.64 -	[self addSubview: textField];
    2.65 -	
    2.66 -	/*
    2.67 -	 SDL makes a copy of our keyboard.
    2.68 -	 */
    2.69 -	
    2.70 -	SDL_Keyboard keyboard;
    2.71 -	SDL_zero(keyboard);
    2.72 -	//data->keyboard = SDL_AddKeyboard(&keyboard, -1);
    2.73 -	/* 
    2.74 -	 We'll need to delete this keyboard ...
    2.75 -	 */
    2.76 -	SDL_AddKeyboard(&keyboard, 0);
    2.77 -	SDLKey keymap[SDL_NUM_SCANCODES];
    2.78 -	SDL_GetDefaultKeymap(keymap);
    2.79 -	SDL_SetKeymap(0, 0, keymap, SDL_NUM_SCANCODES);
    2.80 -	
    2.81 -}
    2.82 -
    2.83 -- (void)showKeyboard {
    2.84 -	keyboardVisible = YES;
    2.85 -	[textField becomeFirstResponder];
    2.86 -}
    2.87 -
    2.88 -- (void)hideKeyboard {
    2.89 -	keyboardVisible = NO;
    2.90 -	[textField resignFirstResponder];
    2.91 -}
    2.92 -
    2.93 -- (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    2.94 -	
    2.95 -	if ([string length] == 0) {
    2.96 -		/* it wants to replace text with nothing, ie a delete */
    2.97 -		SDL_SendKeyboardKey( 0, SDL_PRESSED, SDL_SCANCODE_DELETE);
    2.98 -		SDL_SendKeyboardKey( 0, SDL_RELEASED, SDL_SCANCODE_DELETE);
    2.99 -	}
   2.100 -	else {
   2.101 -		
   2.102 -		int i;
   2.103 -		for (i=0; i<[string length]; i++) {
   2.104 -			
   2.105 -			unichar c = [string characterAtIndex: i];
   2.106 -			
   2.107 -			Uint16 mod = 0;
   2.108 -			SDL_scancode code;
   2.109 -			
   2.110 -			if (0 <= c && c < 127) {
   2.111 -				code = unicharToUIKeyInfoTable[c].code;
   2.112 -				mod  = unicharToUIKeyInfoTable[c].mod;
   2.113 -			}
   2.114 -			else {
   2.115 -				code = SDL_SCANCODE_UNKNOWN;
   2.116 -				mod = 0;
   2.117 -			}
   2.118 -			
   2.119 -			if (mod & KMOD_SHIFT) {
   2.120 -				SDL_SendKeyboardKey( 0, SDL_PRESSED, SDL_SCANCODE_LSHIFT);
   2.121 -			}
   2.122 -			SDL_SendKeyboardKey( 0, SDL_PRESSED, code);
   2.123 -			SDL_SendKeyboardKey( 0, SDL_RELEASED, code);
   2.124 -			if (mod & KMOD_SHIFT) {
   2.125 -				SDL_SendKeyboardKey( 0, SDL_RELEASED, SDL_SCANCODE_LSHIFT);
   2.126 -			}			
   2.127 -			
   2.128 -		}
   2.129 -		
   2.130 -	}
   2.131 -	return NO; /* don't allow the edit(!) */
   2.132 -}
   2.133 -
   2.134 -/* Terminates the editing session */
   2.135 -- (BOOL)textFieldShouldReturn:(UITextField*)_textField {
   2.136 -	[self hideKeyboard];
   2.137 -	return YES;
   2.138 -}
   2.139 -
   2.140 -@end
   2.141 -
   2.142 -/* iPhone keyboard addition functions */
   2.143 -
   2.144 -int SDL_iPhoneKeyboardShow(SDL_WindowID windowID) {
   2.145 -
   2.146 -	SDL_Window *window = SDL_GetWindowFromID(windowID);
   2.147 -	SDL_WindowData *data;
   2.148 -	SDL_uikitview *view;
   2.149 -	
   2.150 -	if (NULL == window) {
   2.151 -		SDL_SetError("Window does not exist");
   2.152 -		return -1;
   2.153 -	}
   2.154 -	
   2.155 -	data = (SDL_WindowData *)window->driverdata;
   2.156 -	view = data->view;
   2.157 -		
   2.158 -	if (nil == view) {
   2.159 -		SDL_SetError("Window has no view");
   2.160 -		return -1;
   2.161 -	}
   2.162 -	else {
   2.163 -		[view showKeyboard];
   2.164 -		return 0;
   2.165 -	}
   2.166 -}
   2.167 -
   2.168 -int SDL_iPhoneKeyboardHide(SDL_WindowID windowID) {
   2.169 -	
   2.170 -	SDL_Window *window = SDL_GetWindowFromID(windowID);
   2.171 -	SDL_WindowData *data;
   2.172 -	SDL_uikitview *view;
   2.173 -	
   2.174 -	if (NULL == window) {
   2.175 -		SDL_SetError("Window does not exist");
   2.176 -		return -1;
   2.177 -	}	
   2.178 -	
   2.179 -	data = (SDL_WindowData *)window->driverdata;
   2.180 -	view = data->view;
   2.181 -
   2.182 -	if (NULL == view) {
   2.183 -		SDL_SetError("Window has no view");
   2.184 -		return -1;
   2.185 -	}
   2.186 -	else {
   2.187 -		[view hideKeyboard];
   2.188 -		return 0;
   2.189 -	}
   2.190 -}
   2.191 -
   2.192 -SDL_bool SDL_iPhoneKeyboardIsShown(SDL_WindowID windowID) {
   2.193 -	
   2.194 -	SDL_Window *window = SDL_GetWindowFromID(windowID);
   2.195 -	SDL_WindowData *data;
   2.196 -	SDL_uikitview *view;
   2.197 -
   2.198 -	if (NULL == window) {
   2.199 -		SDL_SetError("Window does not exist");
   2.200 -		return -1;
   2.201 -	}	
   2.202 -	
   2.203 -	data = (SDL_WindowData *)window->driverdata;
   2.204 -	view = data->view;
   2.205 -	
   2.206 -	if (NULL == view) {
   2.207 -		SDL_SetError("Window has no view");
   2.208 -		return 0;
   2.209 -	}
   2.210 -	else {
   2.211 -		return view.keyboardVisible;
   2.212 -	}
   2.213 -}
   2.214 -
   2.215 -int SDL_iPhoneKeyboardToggle(SDL_WindowID windowID) {
   2.216 -	
   2.217 -	SDL_Window *window = SDL_GetWindowFromID(windowID);
   2.218 -	SDL_WindowData *data;
   2.219 -	SDL_uikitview *view;
   2.220 -	
   2.221 -	if (NULL == window) {
   2.222 -		SDL_SetError("Window does not exist");
   2.223 -		return -1;
   2.224 -	}	
   2.225 -	
   2.226 -	data = (SDL_WindowData *)window->driverdata;
   2.227 -	view = data->view;
   2.228 -	
   2.229 -	if (NULL == view) {
   2.230 -		SDL_SetError("Window has no view");
   2.231 -		return -1;
   2.232 -	}
   2.233 -	else {
   2.234 -		if (SDL_iPhoneKeyboardIsShown(windowID)) {
   2.235 -			SDL_iPhoneKeyboardHide(windowID);
   2.236 -		}
   2.237 -		else {
   2.238 -			SDL_iPhoneKeyboardShow(windowID);
   2.239 -		}
   2.240 -		return 0;
   2.241 -	}
   2.242 -}
   2.243 -
   2.244 -#else
   2.245 -
   2.246 -int SDL_iPhoneKeyboardShow(SDL_WindowID windowID) {
   2.247 -	SDL_SetError("Not compiled with keyboard support");
   2.248 -	return -1;
   2.249 -}
   2.250 -
   2.251 -int SDL_iPhoneKeyboardHide(SDL_WindowID windowID) {
   2.252 -	SDL_SetError("Not compiled with keyboard support");
   2.253 -	return -1;
   2.254 -}
   2.255 -
   2.256 -SDL_bool SDL_iPhoneKeyboardIsShown(SDL_WindowID windowID) {
   2.257 -	return 0;
   2.258 -}
   2.259 -
   2.260 -int SDL_iPhoneKeyboardToggle(SDL_WindowID windowID) {
   2.261 -	SDL_SetError("Not compiled with keyboard support");
   2.262 -	return -1;
   2.263 -}
   2.264 -
   2.265 -
   2.266 -#endif /* SDL_IPHONE_KEYBOARD */
     3.1 --- a/src/video/uikit/SDL_uikitview.h	Wed Aug 13 23:12:00 2008 +0000
     3.2 +++ b/src/video/uikit/SDL_uikitview.h	Wed Aug 13 23:14:36 2008 +0000
     3.3 @@ -42,4 +42,18 @@
     3.4  - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
     3.5  - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
     3.6  
     3.7 +#if SDL_IPHONE_KEYBOARD
     3.8 +- (void)showKeyboard;
     3.9 +- (void)hideKeyboard;
    3.10 +- (void)initializeKeyboard;
    3.11 +@property (readonly) BOOL keyboardVisible;
    3.12 +#endif 
    3.13 +
    3.14  @end
    3.15 +
    3.16 +#if SDL_IPHONE_KEYBOARD
    3.17 +extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardShow(SDL_WindowID windowID);
    3.18 +extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardHide(SDL_WindowID windowID);
    3.19 +extern DECLSPEC SDL_bool SDLCALL SDL_iPhoneKeyboardIsShown(SDL_WindowID windowID);
    3.20 +extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardToggle(SDL_WindowID windowID);
    3.21 +#endif
     4.1 --- a/src/video/uikit/SDL_uikitview.m	Wed Aug 13 23:12:00 2008 +0000
     4.2 +++ b/src/video/uikit/SDL_uikitview.m	Wed Aug 13 23:14:36 2008 +0000
     4.3 @@ -21,7 +21,13 @@
     4.4   */
     4.5  
     4.6  #import "SDL_uikitview.h"
     4.7 -#import "SDL_uikitkeyboard.h"
     4.8 +
     4.9 +#if SDL_IPHONE_KEYBOARD
    4.10 +#import "SDL_keyboard_c.h"
    4.11 +#import "keyinfotable.h"
    4.12 +#import "SDL_uikitappdelegate.h"
    4.13 +#import "SDL_uikitwindow.h"
    4.14 +#endif
    4.15  
    4.16  @implementation SDL_uikitview
    4.17  
    4.18 @@ -127,6 +133,241 @@
    4.19  	}
    4.20  }
    4.21  
    4.22 +/*
    4.23 +	---- Keyboard related functionality below this line ----
    4.24 +*/
    4.25 +#if SDL_IPHONE_KEYBOARD
    4.26  
    4.27 +- (BOOL)keyboardVisible {
    4.28 +	return keyboardVisible;
    4.29 +}
    4.30 +
    4.31 +/* UITextFieldDelegate related methods */
    4.32 +- (void)initializeKeyboard {
    4.33 +	
    4.34 +	NSLog(@"Text field init");
    4.35 +	
    4.36 +	textField = [[UITextField alloc] initWithFrame: CGRectZero];
    4.37 +	textField.delegate = self;
    4.38 +	/* placeholder so there is something to delete! */
    4.39 +	textField.text = @" ";	
    4.40 +	
    4.41 +	/* set UITextInputTrait properties, mostly to defaults */
    4.42 +	textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
    4.43 +	textField.autocorrectionType = UITextAutocorrectionTypeNo;
    4.44 +	textField.enablesReturnKeyAutomatically = NO;
    4.45 +	textField.keyboardAppearance = UIKeyboardAppearanceDefault;
    4.46 +	textField.keyboardType = UIKeyboardTypeDefault;
    4.47 +	textField.returnKeyType = UIReturnKeyDefault;
    4.48 +	textField.secureTextEntry = NO;	
    4.49 +	
    4.50 +	textField.hidden = YES;
    4.51 +	keyboardVisible = NO;
    4.52 +	[self addSubview: textField];
    4.53 +	
    4.54 +	/*
    4.55 +	 SDL makes a copy of our keyboard.
    4.56 +	 */
    4.57 +	
    4.58 +	SDL_Keyboard keyboard;
    4.59 +	SDL_zero(keyboard);
    4.60 +	//data->keyboard = SDL_AddKeyboard(&keyboard, -1);
    4.61 +	/* 
    4.62 +	 We'll need to delete this keyboard ...
    4.63 +	 */
    4.64 +	SDL_AddKeyboard(&keyboard, 0);
    4.65 +	SDLKey keymap[SDL_NUM_SCANCODES];
    4.66 +	SDL_GetDefaultKeymap(keymap);
    4.67 +	SDL_SetKeymap(0, 0, keymap, SDL_NUM_SCANCODES);
    4.68 +	
    4.69 +}
    4.70 +
    4.71 +- (void)showKeyboard {
    4.72 +	keyboardVisible = YES;
    4.73 +	[textField becomeFirstResponder];
    4.74 +}
    4.75 +
    4.76 +- (void)hideKeyboard {
    4.77 +	keyboardVisible = NO;
    4.78 +	[textField resignFirstResponder];
    4.79 +}
    4.80 +
    4.81 +- (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    4.82 +	
    4.83 +	if ([string length] == 0) {
    4.84 +		/* it wants to replace text with nothing, ie a delete */
    4.85 +		SDL_SendKeyboardKey( 0, SDL_PRESSED, SDL_SCANCODE_DELETE);
    4.86 +		SDL_SendKeyboardKey( 0, SDL_RELEASED, SDL_SCANCODE_DELETE);
    4.87 +	}
    4.88 +	else {
    4.89 +		
    4.90 +		int i;
    4.91 +		for (i=0; i<[string length]; i++) {
    4.92 +			
    4.93 +			unichar c = [string characterAtIndex: i];
    4.94 +			
    4.95 +			Uint16 mod = 0;
    4.96 +			SDL_scancode code;
    4.97 +			
    4.98 +			if (c < 127) {
    4.99 +				code = unicharToUIKeyInfoTable[c].code;
   4.100 +				mod  = unicharToUIKeyInfoTable[c].mod;
   4.101 +			}
   4.102 +			else {
   4.103 +				code = SDL_SCANCODE_UNKNOWN;
   4.104 +				mod = 0;
   4.105 +			}
   4.106 +			
   4.107 +			if (mod & KMOD_SHIFT) {
   4.108 +				SDL_SendKeyboardKey( 0, SDL_PRESSED, SDL_SCANCODE_LSHIFT);
   4.109 +			}
   4.110 +			SDL_SendKeyboardKey( 0, SDL_PRESSED, code);
   4.111 +			SDL_SendKeyboardKey( 0, SDL_RELEASED, code);
   4.112 +			if (mod & KMOD_SHIFT) {
   4.113 +				SDL_SendKeyboardKey( 0, SDL_RELEASED, SDL_SCANCODE_LSHIFT);
   4.114 +			}			
   4.115 +			
   4.116 +		}
   4.117 +		
   4.118 +	}
   4.119 +	return NO; /* don't allow the edit(!) */
   4.120 +}
   4.121 +
   4.122 +/* Terminates the editing session */
   4.123 +- (BOOL)textFieldShouldReturn:(UITextField*)_textField {
   4.124 +	[self hideKeyboard];
   4.125 +	return YES;
   4.126 +}
   4.127 +
   4.128 +#endif
   4.129  
   4.130  @end
   4.131 +
   4.132 +
   4.133 +
   4.134 +/* iPhone keyboard addition functions */
   4.135 +#if SDL_IPHONE_KEYBOARD
   4.136 +
   4.137 +int SDL_iPhoneKeyboardShow(SDL_WindowID windowID) {
   4.138 +	
   4.139 +	SDL_Window *window = SDL_GetWindowFromID(windowID);
   4.140 +	SDL_WindowData *data;
   4.141 +	SDL_uikitview *view;
   4.142 +	
   4.143 +	if (NULL == window) {
   4.144 +		SDL_SetError("Window does not exist");
   4.145 +		return -1;
   4.146 +	}
   4.147 +	
   4.148 +	data = (SDL_WindowData *)window->driverdata;
   4.149 +	view = data->view;
   4.150 +	
   4.151 +	if (nil == view) {
   4.152 +		SDL_SetError("Window has no view");
   4.153 +		return -1;
   4.154 +	}
   4.155 +	else {
   4.156 +		[view showKeyboard];
   4.157 +		return 0;
   4.158 +	}
   4.159 +}
   4.160 +
   4.161 +int SDL_iPhoneKeyboardHide(SDL_WindowID windowID) {
   4.162 +	
   4.163 +	SDL_Window *window = SDL_GetWindowFromID(windowID);
   4.164 +	SDL_WindowData *data;
   4.165 +	SDL_uikitview *view;
   4.166 +	
   4.167 +	if (NULL == window) {
   4.168 +		SDL_SetError("Window does not exist");
   4.169 +		return -1;
   4.170 +	}	
   4.171 +	
   4.172 +	data = (SDL_WindowData *)window->driverdata;
   4.173 +	view = data->view;
   4.174 +	
   4.175 +	if (NULL == view) {
   4.176 +		SDL_SetError("Window has no view");
   4.177 +		return -1;
   4.178 +	}
   4.179 +	else {
   4.180 +		[view hideKeyboard];
   4.181 +		return 0;
   4.182 +	}
   4.183 +}
   4.184 +
   4.185 +SDL_bool SDL_iPhoneKeyboardIsShown(SDL_WindowID windowID) {
   4.186 +	
   4.187 +	SDL_Window *window = SDL_GetWindowFromID(windowID);
   4.188 +	SDL_WindowData *data;
   4.189 +	SDL_uikitview *view;
   4.190 +	
   4.191 +	if (NULL == window) {
   4.192 +		SDL_SetError("Window does not exist");
   4.193 +		return -1;
   4.194 +	}	
   4.195 +	
   4.196 +	data = (SDL_WindowData *)window->driverdata;
   4.197 +	view = data->view;
   4.198 +	
   4.199 +	if (NULL == view) {
   4.200 +		SDL_SetError("Window has no view");
   4.201 +		return 0;
   4.202 +	}
   4.203 +	else {
   4.204 +		return view.keyboardVisible;
   4.205 +	}
   4.206 +}
   4.207 +
   4.208 +int SDL_iPhoneKeyboardToggle(SDL_WindowID windowID) {
   4.209 +	
   4.210 +	SDL_Window *window = SDL_GetWindowFromID(windowID);
   4.211 +	SDL_WindowData *data;
   4.212 +	SDL_uikitview *view;
   4.213 +	
   4.214 +	if (NULL == window) {
   4.215 +		SDL_SetError("Window does not exist");
   4.216 +		return -1;
   4.217 +	}	
   4.218 +	
   4.219 +	data = (SDL_WindowData *)window->driverdata;
   4.220 +	view = data->view;
   4.221 +	
   4.222 +	if (NULL == view) {
   4.223 +		SDL_SetError("Window has no view");
   4.224 +		return -1;
   4.225 +	}
   4.226 +	else {
   4.227 +		if (SDL_iPhoneKeyboardIsShown(windowID)) {
   4.228 +			SDL_iPhoneKeyboardHide(windowID);
   4.229 +		}
   4.230 +		else {
   4.231 +			SDL_iPhoneKeyboardShow(windowID);
   4.232 +		}
   4.233 +		return 0;
   4.234 +	}
   4.235 +}
   4.236 +
   4.237 +#else
   4.238 +
   4.239 +int SDL_iPhoneKeyboardShow(SDL_WindowID windowID) {
   4.240 +	SDL_SetError("Not compiled with keyboard support");
   4.241 +	return -1;
   4.242 +}
   4.243 +
   4.244 +int SDL_iPhoneKeyboardHide(SDL_WindowID windowID) {
   4.245 +	SDL_SetError("Not compiled with keyboard support");
   4.246 +	return -1;
   4.247 +}
   4.248 +
   4.249 +SDL_bool SDL_iPhoneKeyboardIsShown(SDL_WindowID windowID) {
   4.250 +	return 0;
   4.251 +}
   4.252 +
   4.253 +int SDL_iPhoneKeyboardToggle(SDL_WindowID windowID) {
   4.254 +	SDL_SetError("Not compiled with keyboard support");
   4.255 +	return -1;
   4.256 +}
   4.257 +
   4.258 +
   4.259 +#endif /* SDL_IPHONE_KEYBOARD */
   4.260 \ No newline at end of file