Commit 2bd415b4 authored by Kees Bakker's avatar Kees Bakker

Use a consistent source code format in src/video/uikit

For example:
* Opening bracket of a method/function on a new line at column 0
* space after "if", "while", etc
parent 4fa8ce73
...@@ -22,11 +22,11 @@ ...@@ -22,11 +22,11 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "SDL_uikitopenglview.h" #import "SDL_uikitopenglview.h"
@interface SDLUIKitDelegate:NSObject<UIApplicationDelegate> { @interface SDLUIKitDelegate : NSObject<UIApplicationDelegate> {
} }
+(SDLUIKitDelegate *)sharedAppDelegate; + (SDLUIKitDelegate *)sharedAppDelegate;
+(NSString *)getAppDelegateClassName; + (NSString *)getAppDelegateClassName;
@end @end
......
...@@ -37,15 +37,15 @@ extern int SDL_main(int argc, char *argv[]); ...@@ -37,15 +37,15 @@ extern int SDL_main(int argc, char *argv[]);
static int forward_argc; static int forward_argc;
static char **forward_argv; static char **forward_argv;
int main(int argc, char **argv) { int main(int argc, char **argv)
{
int i; int i;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
/* store arguments */ /* store arguments */
forward_argc = argc; forward_argc = argc;
forward_argv = (char **)malloc((argc+1) * sizeof(char *)); forward_argv = (char **)malloc((argc+1) * sizeof(char *));
for (i=0; i<argc; i++) { for (i = 0; i < argc; i++) {
forward_argv[i] = malloc( (strlen(argv[i])+1) * sizeof(char)); forward_argv[i] = malloc( (strlen(argv[i])+1) * sizeof(char));
strcpy(forward_argv[i], argv[i]); strcpy(forward_argv[i], argv[i]);
} }
...@@ -58,7 +58,8 @@ int main(int argc, char **argv) { ...@@ -58,7 +58,8 @@ int main(int argc, char **argv) {
return 0; return 0;
} }
static void SDL_IdleTimerDisabledChanged(const char *name, const char *oldValue, const char *newValue) { static void SDL_IdleTimerDisabledChanged(const char *name, const char *oldValue, const char *newValue)
{
SDL_assert(SDL_strcmp(name, SDL_HINT_IDLE_TIMER_DISABLED) == 0); SDL_assert(SDL_strcmp(name, SDL_HINT_IDLE_TIMER_DISABLED) == 0);
BOOL disable = (*newValue != '0'); BOOL disable = (*newValue != '0');
...@@ -68,24 +69,27 @@ static void SDL_IdleTimerDisabledChanged(const char *name, const char *oldValue, ...@@ -68,24 +69,27 @@ static void SDL_IdleTimerDisabledChanged(const char *name, const char *oldValue,
@implementation SDLUIKitDelegate @implementation SDLUIKitDelegate
/* convenience method */ /* convenience method */
+(SDLUIKitDelegate *)sharedAppDelegate { + (SDLUIKitDelegate *)sharedAppDelegate
{
/* the delegate is set in UIApplicationMain(), which is garaunteed to be called before this method */ /* the delegate is set in UIApplicationMain(), which is garaunteed to be called before this method */
return (SDLUIKitDelegate *)[[UIApplication sharedApplication] delegate]; return (SDLUIKitDelegate *)[[UIApplication sharedApplication] delegate];
} }
+(NSString *)getAppDelegateClassName { + (NSString *)getAppDelegateClassName
{
/* subclassing notice: when you subclass this appdelegate, make sure to add a category to override /* subclassing notice: when you subclass this appdelegate, make sure to add a category to override
this method and return the actual name of the delegate */ this method and return the actual name of the delegate */
return @"SDLUIKitDelegate"; return @"SDLUIKitDelegate";
} }
- (id)init { - (id)init
{
self = [super init]; self = [super init];
return self; return self;
} }
- (void)postFinishLaunch { - (void)postFinishLaunch
{
/* register a callback for the idletimer hint */ /* register a callback for the idletimer hint */
SDL_SetHint(SDL_HINT_IDLE_TIMER_DISABLED, "0"); SDL_SetHint(SDL_HINT_IDLE_TIMER_DISABLED, "0");
SDL_RegisterHintChangedCb(SDL_HINT_IDLE_TIMER_DISABLED, &SDL_IdleTimerDisabledChanged); SDL_RegisterHintChangedCb(SDL_HINT_IDLE_TIMER_DISABLED, &SDL_IdleTimerDisabledChanged);
...@@ -95,7 +99,7 @@ static void SDL_IdleTimerDisabledChanged(const char *name, const char *oldValue, ...@@ -95,7 +99,7 @@ static void SDL_IdleTimerDisabledChanged(const char *name, const char *oldValue,
/* free the memory we used to hold copies of argc and argv */ /* free the memory we used to hold copies of argc and argv */
int i; int i;
for (i=0; i<forward_argc; i++) { for (i = 0; i < forward_argc; i++) {
free(forward_argv[i]); free(forward_argv[i]);
} }
free(forward_argv); free(forward_argv);
...@@ -104,8 +108,8 @@ static void SDL_IdleTimerDisabledChanged(const char *name, const char *oldValue, ...@@ -104,8 +108,8 @@ static void SDL_IdleTimerDisabledChanged(const char *name, const char *oldValue,
exit(exit_status); exit(exit_status);
} }
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
/* Set working directory to resource path */ /* Set working directory to resource path */
[[NSFileManager defaultManager] changeCurrentDirectoryPath: [[NSBundle mainBundle] resourcePath]]; [[NSFileManager defaultManager] changeCurrentDirectoryPath: [[NSBundle mainBundle] resourcePath]];
...@@ -114,8 +118,8 @@ static void SDL_IdleTimerDisabledChanged(const char *name, const char *oldValue, ...@@ -114,8 +118,8 @@ static void SDL_IdleTimerDisabledChanged(const char *name, const char *oldValue,
return YES; return YES;
} }
- (void)applicationWillTerminate:(UIApplication *)application { - (void)applicationWillTerminate:(UIApplication *)application
{
SDL_SendQuit(); SDL_SendQuit();
/* hack to prevent automatic termination. See SDL_uikitevents.m for details */ /* hack to prevent automatic termination. See SDL_uikitevents.m for details */
longjmp(*(jump_env()), 1); longjmp(*(jump_env()), 1);
......
...@@ -47,7 +47,7 @@ UIKit_PumpEvents(_THIS) ...@@ -47,7 +47,7 @@ UIKit_PumpEvents(_THIS)
SInt32 result; SInt32 result;
do { do {
result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE); result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE);
} while(result == kCFRunLoopRunHandledSource); } while (result == kCFRunLoopRunHandledSource);
} }
} }
......
...@@ -47,7 +47,6 @@ UIKit_GL_GetProcAddress(_THIS, const char *proc) ...@@ -47,7 +47,6 @@ UIKit_GL_GetProcAddress(_THIS, const char *proc)
*/ */
int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
{ {
if (context) { if (context) {
SDL_WindowData *data = (SDL_WindowData *)window->driverdata; SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
[data->view setCurrentContext]; [data->view setCurrentContext];
...@@ -78,10 +77,10 @@ extern void SDL_UIKit_UpdateBatteryMonitoring(void); ...@@ -78,10 +77,10 @@ extern void SDL_UIKit_UpdateBatteryMonitoring(void);
void UIKit_GL_SwapWindow(_THIS, SDL_Window * window) void UIKit_GL_SwapWindow(_THIS, SDL_Window * window)
{ {
#ifdef SDL_POWER_UIKIT #ifdef SDL_POWER_UIKIT
// Check once a frame to see if we should turn off the battery monitor. // Check once a frame to see if we should turn off the battery monitor.
SDL_UIKit_UpdateBatteryMonitoring(); SDL_UIKit_UpdateBatteryMonitoring();
#endif #endif
SDL_WindowData *data = (SDL_WindowData *)window->driverdata; SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
...@@ -106,13 +105,13 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window) ...@@ -106,13 +105,13 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window)
UIWindow *uiwindow = data->uiwindow; UIWindow *uiwindow = data->uiwindow;
/* construct our view, passing in SDL's OpenGL configuration data */ /* construct our view, passing in SDL's OpenGL configuration data */
view = [[SDL_uikitopenglview alloc] initWithFrame: [uiwindow bounds] \ view = [[SDL_uikitopenglview alloc] initWithFrame: [uiwindow bounds]
retainBacking: _this->gl_config.retained_backing \ retainBacking: _this->gl_config.retained_backing
rBits: _this->gl_config.red_size \ rBits: _this->gl_config.red_size
gBits: _this->gl_config.green_size \ gBits: _this->gl_config.green_size
bBits: _this->gl_config.blue_size \ bBits: _this->gl_config.blue_size
aBits: _this->gl_config.alpha_size \ aBits: _this->gl_config.alpha_size
depthBits: _this->gl_config.depth_size \ depthBits: _this->gl_config.depth_size
majorVersion: _this->gl_config.major_version]; majorVersion: _this->gl_config.major_version];
data->view = view; data->view = view;
......
...@@ -54,12 +54,12 @@ ...@@ -54,12 +54,12 @@
- (void)setCurrentContext; - (void)setCurrentContext;
- (id)initWithFrame:(CGRect)frame - (id)initWithFrame:(CGRect)frame
retainBacking:(BOOL)retained \ retainBacking:(BOOL)retained
rBits:(int)rBits \ rBits:(int)rBits
gBits:(int)gBits \ gBits:(int)gBits
bBits:(int)bBits \ bBits:(int)bBits
aBits:(int)aBits \ aBits:(int)aBits
depthBits:(int)depthBits \ depthBits:(int)depthBits
majorVersion:(int)majorVersion; majorVersion:(int)majorVersion;
- (void)updateFrame; - (void)updateFrame;
......
...@@ -35,20 +35,21 @@ ...@@ -35,20 +35,21 @@
@synthesize context; @synthesize context;
+ (Class)layerClass { + (Class)layerClass
{
return [CAEAGLLayer class]; return [CAEAGLLayer class];
} }
- (id)initWithFrame:(CGRect)frame \ - (id)initWithFrame:(CGRect)frame
retainBacking:(BOOL)retained \ retainBacking:(BOOL)retained
rBits:(int)rBits \ rBits:(int)rBits
gBits:(int)gBits \ gBits:(int)gBits
bBits:(int)bBits \ bBits:(int)bBits
aBits:(int)aBits \ aBits:(int)aBits
depthBits:(int)depthBits \ depthBits:(int)depthBits
majorVersion:(int)majorVersion \ majorVersion:(int)majorVersion
{ {
NSString *colorFormat=nil; NSString *colorFormat = nil;
BOOL useDepthBuffer; BOOL useDepthBuffer;
if (rBits == 8 && gBits == 8 && bBits == 8) { if (rBits == 8 && gBits == 8 && bBits == 8) {
...@@ -116,7 +117,7 @@ ...@@ -116,7 +117,7 @@
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer); glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer);
} }
if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) {
return NO; return NO;
} }
/* end create buffers */ /* end create buffers */
...@@ -131,7 +132,8 @@ ...@@ -131,7 +132,8 @@
return self; return self;
} }
- (void)updateFrame { - (void)updateFrame
{
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, 0); glBindRenderbufferOES(GL_RENDERBUFFER_OES, 0);
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, 0); glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, 0);
...@@ -156,22 +158,26 @@ ...@@ -156,22 +158,26 @@
self.contentScaleFactor = [UIScreen mainScreen].scale; self.contentScaleFactor = [UIScreen mainScreen].scale;
} }
- (void)setCurrentContext { - (void)setCurrentContext
{
[EAGLContext setCurrentContext:context]; [EAGLContext setCurrentContext:context];
} }
- (void)swapBuffers { - (void)swapBuffers
{
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
[context presentRenderbuffer:GL_RENDERBUFFER_OES]; [context presentRenderbuffer:GL_RENDERBUFFER_OES];
} }
- (void)layoutSubviews { - (void)layoutSubviews
{
[EAGLContext setCurrentContext:context]; [EAGLContext setCurrentContext:context];
} }
- (void)destroyFramebuffer { - (void)destroyFramebuffer
{
glDeleteFramebuffersOES(1, &viewFramebuffer); glDeleteFramebuffersOES(1, &viewFramebuffer);
viewFramebuffer = 0; viewFramebuffer = 0;
glDeleteRenderbuffersOES(1, &viewRenderbuffer); glDeleteRenderbuffersOES(1, &viewRenderbuffer);
...@@ -184,7 +190,8 @@ ...@@ -184,7 +190,8 @@
} }
- (void)dealloc { - (void)dealloc
{
[self destroyFramebuffer]; [self destroyFramebuffer];
if ([EAGLContext currentContext] == context) { if ([EAGLContext currentContext] == context) {
[EAGLContext setCurrentContext:nil]; [EAGLContext setCurrentContext:nil];
......
...@@ -52,7 +52,7 @@ BOOL SDL_UIKit_supports_multiple_displays = NO; ...@@ -52,7 +52,7 @@ BOOL SDL_UIKit_supports_multiple_displays = NO;
static int static int
UIKit_Available(void) UIKit_Available(void)
{ {
return (1); return 1;
} }
static void UIKit_DeleteDevice(SDL_VideoDevice * device) static void UIKit_DeleteDevice(SDL_VideoDevice * device)
......
...@@ -33,12 +33,13 @@ ...@@ -33,12 +33,13 @@
@implementation SDL_uikitview @implementation SDL_uikitview
- (void)dealloc { - (void)dealloc
{
[super dealloc]; [super dealloc];
} }
- (id)initWithFrame:(CGRect)frame { - (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame: frame]; self = [super initWithFrame: frame];
#if SDL_IPHONE_KEYBOARD #if SDL_IPHONE_KEYBOARD
...@@ -72,8 +73,8 @@ ...@@ -72,8 +73,8 @@
} }
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSEnumerator *enumerator = [touches objectEnumerator]; NSEnumerator *enumerator = [touches objectEnumerator];
UITouch *touch = (UITouch*)[enumerator nextObject]; UITouch *touch = (UITouch*)[enumerator nextObject];
...@@ -89,36 +90,35 @@ ...@@ -89,36 +90,35 @@
#ifdef FIXED_MULTITOUCH #ifdef FIXED_MULTITOUCH
while(touch) { while(touch) {
CGPoint locationInView = [touch locationInView: self]; CGPoint locationInView = [touch locationInView: self];
#ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
//FIXME: TODO: Using touch as the fingerId is potentially dangerous //FIXME: TODO: Using touch as the fingerId is potentially dangerous
//It is also much more efficient than storing the UITouch pointer //It is also much more efficient than storing the UITouch pointer
//and comparing it to the incoming event. //and comparing it to the incoming event.
SDL_SendFingerDown(touchId,(long)touch, SDL_SendFingerDown(touchId, (long)touch,
SDL_TRUE,locationInView.x,locationInView.y, SDL_TRUE, locationInView.x, locationInView.y,
1); 1);
#else #else
int i; int i;
for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) { for(i = 0; i < MAX_SIMULTANEOUS_TOUCHES; i++) {
if(finger[i] == NULL) { if (finger[i] == NULL) {
finger[i] = touch; finger[i] = touch;
SDL_SendFingerDown(touchId,i, SDL_SendFingerDown(touchId, i,
SDL_TRUE,locationInView.x,locationInView.y, SDL_TRUE, locationInView.x, locationInView.y,
1); 1);
break; break;
}
} }
}
#endif #endif
touch = (UITouch*)[enumerator nextObject]; touch = (UITouch*)[enumerator nextObject];
} }
#endif #endif
} }
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
NSEnumerator *enumerator = [touches objectEnumerator]; NSEnumerator *enumerator = [touches objectEnumerator];
UITouch *touch = (UITouch*)[enumerator nextObject]; UITouch *touch = (UITouch*)[enumerator nextObject];
...@@ -129,32 +129,32 @@ ...@@ -129,32 +129,32 @@
#ifdef FIXED_MULTITOUCH #ifdef FIXED_MULTITOUCH
while(touch) { while(touch) {
CGPoint locationInView = [touch locationInView: self]; CGPoint locationInView = [touch locationInView: self];
#ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
SDL_SendFingerDown(touchId,(long)touch, SDL_SendFingerDown(touchId, (long)touch,
SDL_FALSE,locationInView.x,locationInView.y, SDL_FALSE, locationInView.x, locationInView.y,
1); 1);
#else #else
int i; int i;
for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) { for (i = 0; i < MAX_SIMULTANEOUS_TOUCHES; i++) {
if(finger[i] == touch) { if (finger[i] == touch) {
SDL_SendFingerDown(touchId,i, SDL_SendFingerDown(touchId, i,
SDL_FALSE,locationInView.x,locationInView.y, SDL_FALSE, locationInView.x, locationInView.y,
1); 1);
finger[i] = NULL; finger[i] = NULL;
break; break;
}
} }
}
#endif #endif
touch = (UITouch*)[enumerator nextObject]; touch = (UITouch*)[enumerator nextObject];
} }
#endif #endif
} }
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
/* /*
this can happen if the user puts more than 5 touches on the screen this can happen if the user puts more than 5 touches on the screen
at once, or perhaps in other circumstances. Usually (it seems) at once, or perhaps in other circumstances. Usually (it seems)
...@@ -163,8 +163,8 @@ ...@@ -163,8 +163,8 @@
[self touchesEnded: touches withEvent: event]; [self touchesEnded: touches withEvent: event];
} }
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
NSEnumerator *enumerator = [touches objectEnumerator]; NSEnumerator *enumerator = [touches objectEnumerator];
UITouch *touch = (UITouch*)[enumerator nextObject]; UITouch *touch = (UITouch*)[enumerator nextObject];
...@@ -177,26 +177,25 @@ ...@@ -177,26 +177,25 @@
#ifdef FIXED_MULTITOUCH #ifdef FIXED_MULTITOUCH
while(touch) { while(touch) {
CGPoint locationInView = [touch locationInView: self]; CGPoint locationInView = [touch locationInView: self];
#ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
SDL_SendTouchMotion(touchId,(long)touch, SDL_SendTouchMotion(touchId, (long)touch,
SDL_FALSE,locationInView.x,locationInView.y, SDL_FALSE, locationInView.x, locationInView.y,
1); 1);
#else #else
int i; int i;
for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) { for (i = 0; i < MAX_SIMULTANEOUS_TOUCHES; i++) {
if(finger[i] == touch) { if (finger[i] == touch) {
SDL_SendTouchMotion(touchId,i, SDL_SendTouchMotion(touchId, i,
SDL_FALSE,locationInView.x,locationInView.y, SDL_FALSE, locationInView.x, locationInView.y,
1); 1);
break; break;
}
} }
}
#endif #endif
touch = (UITouch*)[enumerator nextObject]; touch = (UITouch*)[enumerator nextObject];
} }
#endif #endif
} }
...@@ -207,13 +206,14 @@ ...@@ -207,13 +206,14 @@
#if SDL_IPHONE_KEYBOARD #if SDL_IPHONE_KEYBOARD
/* Is the iPhone virtual keyboard visible onscreen? */ /* Is the iPhone virtual keyboard visible onscreen? */
- (BOOL)keyboardVisible { - (BOOL)keyboardVisible
{
return keyboardVisible; return keyboardVisible;
} }
/* Set ourselves up as a UITextFieldDelegate */ /* Set ourselves up as a UITextFieldDelegate */
- (void)initializeKeyboard { - (void)initializeKeyboard
{
textField = [[UITextField alloc] initWithFrame: CGRectZero]; textField = [[UITextField alloc] initWithFrame: CGRectZero];
textField.delegate = self; textField.delegate = self;
/* placeholder so there is something to delete! */ /* placeholder so there is something to delete! */
...@@ -236,20 +236,22 @@ ...@@ -236,20 +236,22 @@
} }
/* reveal onscreen virtual keyboard */ /* reveal onscreen virtual keyboard */
- (void)showKeyboard { - (void)showKeyboard
{
keyboardVisible = YES; keyboardVisible = YES;
[textField becomeFirstResponder]; [textField becomeFirstResponder];
} }
/* hide onscreen virtual keyboard */ /* hide onscreen virtual keyboard */
- (void)hideKeyboard { - (void)hideKeyboard
{
keyboardVisible = NO; keyboardVisible = NO;
[textField resignFirstResponder]; [textField resignFirstResponder];
} }
/* UITextFieldDelegate method. Invoked when user types something. */ /* UITextFieldDelegate method. Invoked when user types something. */
- (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { - (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if ([string length] == 0) { if ([string length] == 0) {
/* it wants to replace text with nothing, ie a delete */ /* it wants to replace text with nothing, ie a delete */
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE); SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE);
...@@ -259,7 +261,7 @@ ...@@ -259,7 +261,7 @@
/* go through all the characters in the string we've been sent /* go through all the characters in the string we've been sent
and convert them to key presses */ and convert them to key presses */
int i; int i;
for (i=0; i<[string length]; i++) { for (i = 0; i < [string length]; i++) {
unichar c = [string characterAtIndex: i]; unichar c = [string characterAtIndex: i];
...@@ -295,7 +297,8 @@ ...@@ -295,7 +297,8 @@
} }
/* Terminates the editing session */ /* Terminates the editing session */
- (BOOL)textFieldShouldReturn:(UITextField*)_textField { - (BOOL)textFieldShouldReturn:(UITextField*)_textField
{
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RETURN); SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RETURN);
[self hideKeyboard]; [self hideKeyboard];
return YES; return YES;
...@@ -308,8 +311,8 @@ ...@@ -308,8 +311,8 @@
/* iPhone keyboard addition functions */ /* iPhone keyboard addition functions */
#if SDL_IPHONE_KEYBOARD #if SDL_IPHONE_KEYBOARD
int SDL_iPhoneKeyboardShow(SDL_Window * window) { int SDL_iPhoneKeyboardShow(SDL_Window * window)
{
SDL_WindowData *data; SDL_WindowData *data;
SDL_uikitview *view; SDL_uikitview *view;
...@@ -331,8 +334,8 @@ int SDL_iPhoneKeyboardShow(SDL_Window * window) { ...@@ -331,8 +334,8 @@ int SDL_iPhoneKeyboardShow(SDL_Window * window) {
} }
} }
int SDL_iPhoneKeyboardHide(SDL_Window * window) { int SDL_iPhoneKeyboardHide(SDL_Window * window)
{
SDL_WindowData *data; SDL_WindowData *data;
SDL_uikitview *view; SDL_uikitview *view;
...@@ -354,8 +357,8 @@ int SDL_iPhoneKeyboardHide(SDL_Window * window) { ...@@ -354,8 +357,8 @@ int SDL_iPhoneKeyboardHide(SDL_Window * window) {
} }
} }
SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) { SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window)
{
SDL_WindowData *data; SDL_WindowData *data;
SDL_uikitview *view; SDL_uikitview *view;
...@@ -376,8 +379,8 @@ SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) { ...@@ -376,8 +379,8 @@ SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) {
} }
} }
int SDL_iPhoneKeyboardToggle(SDL_Window * window) { int SDL_iPhoneKeyboardToggle(SDL_Window * window)
{
SDL_WindowData *data; SDL_WindowData *data;
SDL_uikitview *view; SDL_uikitview *view;
...@@ -408,21 +411,25 @@ int SDL_iPhoneKeyboardToggle(SDL_Window * window) { ...@@ -408,21 +411,25 @@ int SDL_iPhoneKeyboardToggle(SDL_Window * window) {
/* stubs, used if compiled without keyboard support */ /* stubs, used if compiled without keyboard support */
int SDL_iPhoneKeyboardShow(SDL_Window * window) { int SDL_iPhoneKeyboardShow(SDL_Window * window)
{
SDL_SetError("Not compiled with keyboard support"); SDL_SetError("Not compiled with keyboard support");
return -1; return -1;
} }
int SDL_iPhoneKeyboardHide(SDL_Window * window) { int SDL_iPhoneKeyboardHide(SDL_Window * window)
{
SDL_SetError("Not compiled with keyboard support"); SDL_SetError("Not compiled with keyboard support");
return -1; return -1;
} }
SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) { SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window)
{
return 0; return 0;
} }
int SDL_iPhoneKeyboardToggle(SDL_Window * window) { int SDL_iPhoneKeyboardToggle(SDL_Window * window)
{
SDL_SetError("Not compiled with keyboard support"); SDL_SetError("Not compiled with keyboard support");
return -1; return -1;
} }
......
...@@ -33,7 +33,8 @@ ...@@ -33,7 +33,8 @@
@implementation SDL_uikitviewcontroller @implementation SDL_uikitviewcontroller
- (id)initWithSDLWindow:(SDL_Window *)_window { - (id)initWithSDLWindow:(SDL_Window *)_window
{
if ((self = [self init]) == nil) { if ((self = [self init]) == nil) {
return nil; return nil;
} }
...@@ -41,7 +42,8 @@ ...@@ -41,7 +42,8 @@
return self; return self;
} }
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient { - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient
{
const char *orientationsCString; const char *orientationsCString;
if ((orientationsCString = SDL_GetHint(SDL_HINT_ORIENTATIONS)) != NULL) { if ((orientationsCString = SDL_GetHint(SDL_HINT_ORIENTATIONS)) != NULL) {
BOOL rotate = NO; BOOL rotate = NO;
...@@ -96,12 +98,14 @@ ...@@ -96,12 +98,14 @@
return NO; // Nothing else is acceptable. return NO; // Nothing else is acceptable.
} }
- (void)loadView { - (void)loadView
{
// do nothing. // do nothing.
} }
// Send a resized event when the orientation changes. // Send a resized event when the orientation changes.
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
if ((self->window->flags & SDL_WINDOW_RESIZABLE) == 0) { if ((self->window->flags & SDL_WINDOW_RESIZABLE) == 0) {
return; // don't care, we're just flipping over in this case. return; // don't care, we're just flipping over in this case.
} }
......
...@@ -183,7 +183,8 @@ UIKit_CreateWindow(_THIS, SDL_Window *window) ...@@ -183,7 +183,8 @@ UIKit_CreateWindow(_THIS, SDL_Window *window)
} }
void void
UIKit_DestroyWindow(_THIS, SDL_Window * window) { UIKit_DestroyWindow(_THIS, SDL_Window * window)
{
SDL_WindowData *data = (SDL_WindowData *)window->driverdata; SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
if (data) { if (data) {
[data->viewcontroller release]; [data->viewcontroller release];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment