Fixed bug 1163 (SDL_TEXTINPUT not being received on iPhoneOS)
authorSam Lantinga <slouken@libsdl.org>
Wed, 09 Mar 2011 17:38:12 -0800
changeset 546194f742ce580a
parent 5460 43582fccdc0d
child 5462 6d43a04618fc
Fixed bug 1163 (SDL_TEXTINPUT not being received on iPhoneOS)
Xcode-iPhoneOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj
src/video/uikit/SDL_uikitview.m
test/checkkeys.c
     1.1 --- a/Xcode-iPhoneOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj	Wed Mar 09 15:51:51 2011 -0800
     1.2 +++ b/Xcode-iPhoneOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj	Wed Mar 09 17:38:12 2011 -0800
     1.3 @@ -17,6 +17,15 @@
     1.4  		046CEF8113254F23007AD51D /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89D0E2D111A00EA573E /* Foundation.framework */; };
     1.5  		046CEF8213254F23007AD51D /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89E0E2D111A00EA573E /* CoreAudio.framework */; };
     1.6  		046CEF8A13254F63007AD51D /* testgesture.c in Sources */ = {isa = PBXBuildFile; fileRef = 046CEF8913254F63007AD51D /* testgesture.c */; };
     1.7 +		047A63E213285C3200CD7973 /* libSDL.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FD1B48B80E3131CA007AB34E /* libSDL.a */; };
     1.8 +		047A63E313285C3200CD7973 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A8980E2D111A00EA573E /* AudioToolbox.framework */; };
     1.9 +		047A63E413285C3200CD7973 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A8990E2D111A00EA573E /* QuartzCore.framework */; };
    1.10 +		047A63E513285C3200CD7973 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89A0E2D111A00EA573E /* OpenGLES.framework */; };
    1.11 +		047A63E613285C3200CD7973 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89B0E2D111A00EA573E /* CoreGraphics.framework */; };
    1.12 +		047A63E713285C3200CD7973 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89C0E2D111A00EA573E /* UIKit.framework */; };
    1.13 +		047A63E813285C3200CD7973 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89D0E2D111A00EA573E /* Foundation.framework */; };
    1.14 +		047A63E913285C3200CD7973 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89E0E2D111A00EA573E /* CoreAudio.framework */; };
    1.15 +		047A63F113285CD100CD7973 /* checkkeys.c in Sources */ = {isa = PBXBuildFile; fileRef = 047A63F013285CD100CD7973 /* checkkeys.c */; };
    1.16  		56ED04FE118A8FE400A56AA6 /* icon.bmp in Resources */ = {isa = PBXBuildFile; fileRef = FDA8AAD90E2D33B000EA573E /* icon.bmp */; };
    1.17  		56ED0502118A8FE400A56AA6 /* libSDL.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FD1B48B80E3131CA007AB34E /* libSDL.a */; };
    1.18  		56ED0503118A8FE400A56AA6 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A8980E2D111A00EA573E /* AudioToolbox.framework */; };
    1.19 @@ -306,6 +315,8 @@
    1.20  /* Begin PBXFileReference section */
    1.21  		046CEF8613254F23007AD51D /* testgesture.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testgesture.app; sourceTree = BUILT_PRODUCTS_DIR; };
    1.22  		046CEF8913254F63007AD51D /* testgesture.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testgesture.c; path = ../../test/testgesture.c; sourceTree = SOURCE_ROOT; };
    1.23 +		047A63ED13285C3200CD7973 /* checkkeys.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = checkkeys.app; sourceTree = BUILT_PRODUCTS_DIR; };
    1.24 +		047A63F013285CD100CD7973 /* checkkeys.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = checkkeys.c; path = ../../test/checkkeys.c; sourceTree = SOURCE_ROOT; };
    1.25  		1D6058910D05DD3D006BFB54 /* testwm2.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testwm2.app; sourceTree = BUILT_PRODUCTS_DIR; };
    1.26  		56ED050D118A8FE400A56AA6 /* testpower.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testpower.app; sourceTree = BUILT_PRODUCTS_DIR; };
    1.27  		56ED0510118A904200A56AA6 /* testpower.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testpower.c; path = ../../test/testpower.c; sourceTree = SOURCE_ROOT; };
    1.28 @@ -342,7 +353,6 @@
    1.29  		FDA8A7840E2D0F1F00EA573E /* common.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = common.c; path = ../../test/common.c; sourceTree = SOURCE_ROOT; };
    1.30  		FDA8A7850E2D0F1F00EA573E /* common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = common.h; path = ../../test/common.h; sourceTree = SOURCE_ROOT; };
    1.31  		FDA8A7870E2D0F2700EA573E /* graywin.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = graywin.c; path = ../../test/graywin.c; sourceTree = SOURCE_ROOT; };
    1.32 -		FDA8A7890E2D0F2E00EA573E /* checkkeys.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = checkkeys.c; path = ../../test/checkkeys.c; sourceTree = SOURCE_ROOT; };
    1.33  		FDA8A78B0E2D0F3D00EA573E /* loopwave.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = loopwave.c; path = ../../test/loopwave.c; sourceTree = SOURCE_ROOT; };
    1.34  		FDA8A8980E2D111A00EA573E /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
    1.35  		FDA8A8990E2D111A00EA573E /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
    1.36 @@ -404,6 +414,21 @@
    1.37  			);
    1.38  			runOnlyForDeploymentPostprocessing = 0;
    1.39  		};
    1.40 +		047A63E113285C3200CD7973 /* Frameworks */ = {
    1.41 +			isa = PBXFrameworksBuildPhase;
    1.42 +			buildActionMask = 2147483647;
    1.43 +			files = (
    1.44 +				047A63E213285C3200CD7973 /* libSDL.a in Frameworks */,
    1.45 +				047A63E313285C3200CD7973 /* AudioToolbox.framework in Frameworks */,
    1.46 +				047A63E413285C3200CD7973 /* QuartzCore.framework in Frameworks */,
    1.47 +				047A63E513285C3200CD7973 /* OpenGLES.framework in Frameworks */,
    1.48 +				047A63E613285C3200CD7973 /* CoreGraphics.framework in Frameworks */,
    1.49 +				047A63E713285C3200CD7973 /* UIKit.framework in Frameworks */,
    1.50 +				047A63E813285C3200CD7973 /* Foundation.framework in Frameworks */,
    1.51 +				047A63E913285C3200CD7973 /* CoreAudio.framework in Frameworks */,
    1.52 +			);
    1.53 +			runOnlyForDeploymentPostprocessing = 0;
    1.54 +		};
    1.55  		1D60588F0D05DD3D006BFB54 /* Frameworks */ = {
    1.56  			isa = PBXFrameworksBuildPhase;
    1.57  			buildActionMask = 2147483647;
    1.58 @@ -858,6 +883,7 @@
    1.59  				FDC430000F0D866D009C87E1 /* torturethread.app */,
    1.60  				56ED050D118A8FE400A56AA6 /* testpower.app */,
    1.61  				046CEF8613254F23007AD51D /* testgesture.app */,
    1.62 +				047A63ED13285C3200CD7973 /* checkkeys.app */,
    1.63  			);
    1.64  			name = Products;
    1.65  			sourceTree = "<group>";
    1.66 @@ -888,9 +914,9 @@
    1.67  			children = (
    1.68  				FDA8A7840E2D0F1F00EA573E /* common.c */,
    1.69  				FDA8A7850E2D0F1F00EA573E /* common.h */,
    1.70 +				047A63F013285CD100CD7973 /* checkkeys.c */,
    1.71  				FDA8A7870E2D0F2700EA573E /* graywin.c */,
    1.72  				FDA8A78B0E2D0F3D00EA573E /* loopwave.c */,
    1.73 -				FDA8A7890E2D0F2E00EA573E /* checkkeys.c */,
    1.74  				FDA8A7400E2D0F1600EA573E /* testalpha.c */,
    1.75  				FDA8A7410E2D0F1600EA573E /* testaudioinfo.c */,
    1.76  				FDA8A7420E2D0F1600EA573E /* testbitmap.c */,
    1.77 @@ -976,6 +1002,23 @@
    1.78  			productReference = 046CEF8613254F23007AD51D /* testgesture.app */;
    1.79  			productType = "com.apple.product-type.application";
    1.80  		};
    1.81 +		047A63DD13285C3200CD7973 /* checkkeys */ = {
    1.82 +			isa = PBXNativeTarget;
    1.83 +			buildConfigurationList = 047A63EA13285C3200CD7973 /* Build configuration list for PBXNativeTarget "checkkeys" */;
    1.84 +			buildPhases = (
    1.85 +				047A63DE13285C3200CD7973 /* Resources */,
    1.86 +				047A63DF13285C3200CD7973 /* Sources */,
    1.87 +				047A63E113285C3200CD7973 /* Frameworks */,
    1.88 +			);
    1.89 +			buildRules = (
    1.90 +			);
    1.91 +			dependencies = (
    1.92 +			);
    1.93 +			name = checkkeys;
    1.94 +			productName = TestiPhoneOS;
    1.95 +			productReference = 047A63ED13285C3200CD7973 /* checkkeys.app */;
    1.96 +			productType = "com.apple.product-type.application";
    1.97 +		};
    1.98  		1D6058900D05DD3D006BFB54 /* testwm2 */ = {
    1.99  			isa = PBXNativeTarget;
   1.100  			buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "testwm2" */;
   1.101 @@ -1477,6 +1520,7 @@
   1.102  			);
   1.103  			projectRoot = "";
   1.104  			targets = (
   1.105 +				047A63DD13285C3200CD7973 /* checkkeys */,
   1.106  				FDA8A91D0E2D1C0B00EA573E /* graywin */,
   1.107  				FDAAC4300E2D4961001DB1D8 /* testbitmap */,
   1.108  				FDAAC5040E2D4FEB001DB1D8 /* testdyngles */,
   1.109 @@ -1536,6 +1580,13 @@
   1.110  			);
   1.111  			runOnlyForDeploymentPostprocessing = 0;
   1.112  		};
   1.113 +		047A63DE13285C3200CD7973 /* Resources */ = {
   1.114 +			isa = PBXResourcesBuildPhase;
   1.115 +			buildActionMask = 2147483647;
   1.116 +			files = (
   1.117 +			);
   1.118 +			runOnlyForDeploymentPostprocessing = 0;
   1.119 +		};
   1.120  		1D60588D0D05DD3D006BFB54 /* Resources */ = {
   1.121  			isa = PBXResourcesBuildPhase;
   1.122  			buildActionMask = 2147483647;
   1.123 @@ -1755,6 +1806,14 @@
   1.124  			);
   1.125  			runOnlyForDeploymentPostprocessing = 0;
   1.126  		};
   1.127 +		047A63DF13285C3200CD7973 /* Sources */ = {
   1.128 +			isa = PBXSourcesBuildPhase;
   1.129 +			buildActionMask = 2147483647;
   1.130 +			files = (
   1.131 +				047A63F113285CD100CD7973 /* checkkeys.c in Sources */,
   1.132 +			);
   1.133 +			runOnlyForDeploymentPostprocessing = 0;
   1.134 +		};
   1.135  		1D60588E0D05DD3D006BFB54 /* Sources */ = {
   1.136  			isa = PBXSourcesBuildPhase;
   1.137  			buildActionMask = 2147483647;
   1.138 @@ -2012,6 +2071,32 @@
   1.139  			};
   1.140  			name = Release;
   1.141  		};
   1.142 +		047A63EB13285C3200CD7973 /* Debug */ = {
   1.143 +			isa = XCBuildConfiguration;
   1.144 +			buildSettings = {
   1.145 +				ALWAYS_SEARCH_USER_PATHS = NO;
   1.146 +				COPY_PHASE_STRIP = NO;
   1.147 +				GCC_DYNAMIC_NO_PIC = NO;
   1.148 +				GCC_OPTIMIZATION_LEVEL = 0;
   1.149 +				GCC_PRECOMPILE_PREFIX_HEADER = YES;
   1.150 +				GCC_PREFIX_HEADER = "";
   1.151 +				INFOPLIST_FILE = Info.plist;
   1.152 +				PRODUCT_NAME = checkkeys;
   1.153 +			};
   1.154 +			name = Debug;
   1.155 +		};
   1.156 +		047A63EC13285C3200CD7973 /* Release */ = {
   1.157 +			isa = XCBuildConfiguration;
   1.158 +			buildSettings = {
   1.159 +				ALWAYS_SEARCH_USER_PATHS = NO;
   1.160 +				COPY_PHASE_STRIP = YES;
   1.161 +				GCC_PRECOMPILE_PREFIX_HEADER = YES;
   1.162 +				GCC_PREFIX_HEADER = "";
   1.163 +				INFOPLIST_FILE = Info.plist;
   1.164 +				PRODUCT_NAME = checkkeys;
   1.165 +			};
   1.166 +			name = Release;
   1.167 +		};
   1.168  		1D6058940D05DD3E006BFB54 /* Debug */ = {
   1.169  			isa = XCBuildConfiguration;
   1.170  			buildSettings = {
   1.171 @@ -2787,6 +2872,15 @@
   1.172  			defaultConfigurationIsVisible = 0;
   1.173  			defaultConfigurationName = Release;
   1.174  		};
   1.175 +		047A63EA13285C3200CD7973 /* Build configuration list for PBXNativeTarget "checkkeys" */ = {
   1.176 +			isa = XCConfigurationList;
   1.177 +			buildConfigurations = (
   1.178 +				047A63EB13285C3200CD7973 /* Debug */,
   1.179 +				047A63EC13285C3200CD7973 /* Release */,
   1.180 +			);
   1.181 +			defaultConfigurationIsVisible = 0;
   1.182 +			defaultConfigurationName = Release;
   1.183 +		};
   1.184  		1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "testwm2" */ = {
   1.185  			isa = XCConfigurationList;
   1.186  			buildConfigurations = (
     2.1 --- a/src/video/uikit/SDL_uikitview.m	Wed Mar 09 15:51:51 2011 -0800
     2.2 +++ b/src/video/uikit/SDL_uikitview.m	Wed Mar 09 17:38:12 2011 -0800
     2.3 @@ -290,6 +290,7 @@
     2.4                  SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
     2.5              }            
     2.6          }
     2.7 +        SDL_SendKeyboardText([string UTF8String]);
     2.8      }
     2.9      return NO; /* don't allow the edit! (keep placeholder text there) */
    2.10  }
     3.1 --- a/test/checkkeys.c	Wed Mar 09 15:51:51 2011 -0800
     3.2 +++ b/test/checkkeys.c	Wed Mar 09 17:38:12 2011 -0800
     3.3 @@ -19,92 +19,124 @@
     3.4  }
     3.5  
     3.6  static void
     3.7 -print_modifiers(void)
     3.8 +print_string(char **text, size_t *maxlen, const char *fmt, ...)
     3.9 +{
    3.10 +    int len;
    3.11 +    va_list ap;
    3.12 +
    3.13 +    va_start(ap, fmt);
    3.14 +    len = SDL_vsnprintf(*text, *maxlen, fmt, ap);
    3.15 +    if (len > 0) {
    3.16 +        *text += len;
    3.17 +        if (len < *maxlen) {
    3.18 +            *maxlen -= len;
    3.19 +        } else {
    3.20 +            *maxlen = 0;
    3.21 +        }
    3.22 +    }
    3.23 +    va_end(ap);
    3.24 +}
    3.25 +
    3.26 +static void
    3.27 +print_modifiers(char **text, size_t *maxlen)
    3.28  {
    3.29      int mod;
    3.30 -    printf(" modifiers:");
    3.31 +    print_string(text, maxlen, " modifiers:");
    3.32      mod = SDL_GetModState();
    3.33      if (!mod) {
    3.34 -        printf(" (none)");
    3.35 +        print_string(text, maxlen, " (none)");
    3.36          return;
    3.37      }
    3.38      if (mod & KMOD_LSHIFT)
    3.39 -        printf(" LSHIFT");
    3.40 +        print_string(text, maxlen, " LSHIFT");
    3.41      if (mod & KMOD_RSHIFT)
    3.42 -        printf(" RSHIFT");
    3.43 +        print_string(text, maxlen, " RSHIFT");
    3.44      if (mod & KMOD_LCTRL)
    3.45 -        printf(" LCTRL");
    3.46 +        print_string(text, maxlen, " LCTRL");
    3.47      if (mod & KMOD_RCTRL)
    3.48 -        printf(" RCTRL");
    3.49 +        print_string(text, maxlen, " RCTRL");
    3.50      if (mod & KMOD_LALT)
    3.51 -        printf(" LALT");
    3.52 +        print_string(text, maxlen, " LALT");
    3.53      if (mod & KMOD_RALT)
    3.54 -        printf(" RALT");
    3.55 +        print_string(text, maxlen, " RALT");
    3.56      if (mod & KMOD_LGUI)
    3.57 -        printf(" LGUI");
    3.58 +        print_string(text, maxlen, " LGUI");
    3.59      if (mod & KMOD_RGUI)
    3.60 -        printf(" RGUI");
    3.61 +        print_string(text, maxlen, " RGUI");
    3.62      if (mod & KMOD_NUM)
    3.63 -        printf(" NUM");
    3.64 +        print_string(text, maxlen, " NUM");
    3.65      if (mod & KMOD_CAPS)
    3.66 -        printf(" CAPS");
    3.67 +        print_string(text, maxlen, " CAPS");
    3.68      if (mod & KMOD_MODE)
    3.69 -        printf(" MODE");
    3.70 +        print_string(text, maxlen, " MODE");
    3.71  }
    3.72  
    3.73  static void
    3.74  PrintKey(SDL_Keysym * sym, SDL_bool pressed, SDL_bool repeat)
    3.75  {
    3.76 +    char message[512];
    3.77 +    char *spot;
    3.78 +    size_t left;
    3.79 +
    3.80 +    spot = message;
    3.81 +    left = sizeof(message);
    3.82 +
    3.83      /* Print the keycode, name and state */
    3.84      if (sym->sym) {
    3.85 -        printf("Key %s:  scancode %d = %s, keycode 0x%08X = %s ",
    3.86 -               pressed ? "pressed " : "released",
    3.87 -               sym->scancode,
    3.88 -               SDL_GetScancodeName(sym->scancode),
    3.89 -               sym->sym, SDL_GetKeyName(sym->sym));
    3.90 +        print_string(&spot, &left,
    3.91 +                "Key %s:  scancode %d = %s, keycode 0x%08X = %s ",
    3.92 +                pressed ? "pressed " : "released",
    3.93 +                sym->scancode,
    3.94 +                SDL_GetScancodeName(sym->scancode),
    3.95 +                sym->sym, SDL_GetKeyName(sym->sym));
    3.96      } else {
    3.97 -        printf("Unknown Key (scancode %d = %s) %s ",
    3.98 -               sym->scancode,
    3.99 -               SDL_GetScancodeName(sym->scancode),
   3.100 -               pressed ? "pressed" : "released");
   3.101 +        print_string(&spot, &left,
   3.102 +                "Unknown Key (scancode %d = %s) %s ",
   3.103 +                sym->scancode,
   3.104 +                SDL_GetScancodeName(sym->scancode),
   3.105 +                pressed ? "pressed" : "released");
   3.106      }
   3.107  
   3.108      /* Print the translated character, if one exists */
   3.109      if (sym->unicode) {
   3.110          /* Is it a control-character? */
   3.111          if (sym->unicode < ' ') {
   3.112 -            printf(" (^%c)", sym->unicode + '@');
   3.113 +            print_string(&spot, &left, " (^%c)", sym->unicode + '@');
   3.114          } else {
   3.115  #ifdef UNICODE
   3.116 -            printf(" (%c)", sym->unicode);
   3.117 +            print_string(&spot, &left, " (%c)", sym->unicode);
   3.118  #else
   3.119              /* This is a Latin-1 program, so only show 8-bits */
   3.120              if (!(sym->unicode & 0xFF00))
   3.121 -                printf(" (%c)", sym->unicode);
   3.122 +                print_string(&spot, &left, " (%c)", sym->unicode);
   3.123              else
   3.124 -                printf(" (0x%X)", sym->unicode);
   3.125 +                print_string(&spot, &left, " (0x%X)", sym->unicode);
   3.126  #endif
   3.127          }
   3.128      }
   3.129 -    print_modifiers();
   3.130 +    print_modifiers(&spot, &left);
   3.131      if (repeat) {
   3.132 -        printf(" (repeat)");
   3.133 +        print_string(&spot, &left, " (repeat)");
   3.134      }
   3.135 -    printf("\n");
   3.136 +    SDL_Log("%s", message);
   3.137  }
   3.138  
   3.139  static void
   3.140  PrintText(char *text)
   3.141  {
   3.142 -    printf("Text: %s\n", text);
   3.143 +    SDL_Log("Text: %s", text);
   3.144  }
   3.145  
   3.146 +#if __IPHONEOS__
   3.147 +extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardShow(SDL_Window * window);
   3.148 +#endif
   3.149 +
   3.150  int
   3.151  main(int argc, char *argv[])
   3.152  {
   3.153 +    SDL_Window *window;
   3.154      SDL_Event event;
   3.155      int done;
   3.156 -    Uint32 videoflags;
   3.157  
   3.158      /* Initialize SDL */
   3.159      if (SDL_Init(SDL_INIT_VIDEO) < 0) {
   3.160 @@ -112,24 +144,23 @@
   3.161          return (1);
   3.162      }
   3.163  
   3.164 -    videoflags = SDL_SWSURFACE;
   3.165 -    while (argc > 1) {
   3.166 -        --argc;
   3.167 -        if (argv[argc] && !strcmp(argv[argc], "-fullscreen")) {
   3.168 -            videoflags |= SDL_FULLSCREEN;
   3.169 -        } else {
   3.170 -            fprintf(stderr, "Usage: %s [-fullscreen]\n", argv[0]);
   3.171 -            quit(1);
   3.172 -        }
   3.173 -    }
   3.174 -
   3.175      /* Set 640x480 video mode */
   3.176 -    if (SDL_SetVideoMode(640, 480, 0, videoflags) == NULL) {
   3.177 -        fprintf(stderr, "Couldn't set 640x480 video mode: %s\n",
   3.178 +    window = SDL_CreateWindow("CheckKeys Test",
   3.179 +                              SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
   3.180 +                              640, 480, 0);
   3.181 +    if (!window) {
   3.182 +        fprintf(stderr, "Couldn't create 640x480 window: %s\n",
   3.183                  SDL_GetError());
   3.184          quit(2);
   3.185      }
   3.186  
   3.187 +#if __IPHONEOS__
   3.188 +    /* Creating the context creates the view, which we need to show keyboard */
   3.189 +    SDL_GL_CreateContext(window);
   3.190 +    SDL_iPhoneKeyboardShow(window);
   3.191 +#endif
   3.192 +    
   3.193 +
   3.194      /* Watch keystrokes */
   3.195      done = 0;
   3.196      while (!done) {
   3.197 @@ -156,3 +187,5 @@
   3.198      SDL_Quit();
   3.199      return (0);
   3.200  }
   3.201 +
   3.202 +/* vi: set ts=4 sw=4 expandtab: */