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