Cleanup out trailing whitespace in src/video/uikit
This commit is contained in:
parent
90ff13a669
commit
7797271a96
12 changed files with 121 additions and 121 deletions
|
@ -41,7 +41,7 @@ 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 *));
|
||||||
|
@ -53,14 +53,14 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
/* Give over control to run loop, SDLUIKitDelegate will handle most things from here */
|
/* Give over control to run loop, SDLUIKitDelegate will handle most things from here */
|
||||||
UIApplicationMain(argc, argv, NULL, [SDLUIKitDelegate getAppDelegateClassName]);
|
UIApplicationMain(argc, argv, NULL, [SDLUIKitDelegate getAppDelegateClassName]);
|
||||||
|
|
||||||
[pool release];
|
[pool release];
|
||||||
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');
|
||||||
[UIApplication sharedApplication].idleTimerDisabled = disable;
|
[UIApplication sharedApplication].idleTimerDisabled = disable;
|
||||||
}
|
}
|
||||||
|
@ -85,37 +85,37 @@ static void SDL_IdleTimerDisabledChanged(const char *name, const char *oldValue,
|
||||||
}
|
}
|
||||||
|
|
||||||
- (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);
|
||||||
|
|
||||||
/* run the user's application, passing argc and argv */
|
/* run the user's application, passing argc and argv */
|
||||||
int exit_status = SDL_main(forward_argc, forward_argv);
|
int exit_status = SDL_main(forward_argc, forward_argv);
|
||||||
|
|
||||||
/* 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);
|
||||||
|
|
||||||
/* exit, passing the return status from the user's application */
|
/* exit, passing the return status from the user's application */
|
||||||
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]];
|
||||||
|
|
||||||
[self performSelector:@selector(postFinishLaunch) withObject:nil afterDelay:0.0];
|
[self performSelector:@selector(postFinishLaunch) withObject:nil afterDelay:0.0];
|
||||||
|
|
||||||
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);
|
||||||
|
@ -130,7 +130,7 @@ static void SDL_IdleTimerDisabledChanged(const char *name, const char *oldValue,
|
||||||
if (!_this) {
|
if (!_this) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Window *window;
|
SDL_Window *window;
|
||||||
for (window = _this->windows; window != nil; window = window->next) {
|
for (window = _this->windows; window != nil; window = window->next) {
|
||||||
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
|
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
|
||||||
|
@ -146,7 +146,7 @@ static void SDL_IdleTimerDisabledChanged(const char *name, const char *oldValue,
|
||||||
if (!_this) {
|
if (!_this) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Window *window;
|
SDL_Window *window;
|
||||||
for (window = _this->windows; window != nil; window = window->next) {
|
for (window = _this->windows; window != nil; window = window->next) {
|
||||||
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0);
|
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0);
|
||||||
|
|
|
@ -31,17 +31,17 @@
|
||||||
void
|
void
|
||||||
UIKit_PumpEvents(_THIS)
|
UIKit_PumpEvents(_THIS)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
When the user presses the 'home' button on the iPod
|
When the user presses the 'home' button on the iPod
|
||||||
the application exits -- immediatly.
|
the application exits -- immediatly.
|
||||||
|
|
||||||
Unlike in Mac OS X, it appears there is no way to cancel the termination.
|
Unlike in Mac OS X, it appears there is no way to cancel the termination.
|
||||||
|
|
||||||
This doesn't give the SDL user's application time to respond to an SDL_Quit event.
|
This doesn't give the SDL user's application time to respond to an SDL_Quit event.
|
||||||
So what we do is that in the UIApplicationDelegate class (SDLUIApplicationDelegate),
|
So what we do is that in the UIApplicationDelegate class (SDLUIApplicationDelegate),
|
||||||
when the delegate receives the ApplicationWillTerminate message, we execute
|
when the delegate receives the ApplicationWillTerminate message, we execute
|
||||||
a longjmp statement to get back here, preventing an immediate exit.
|
a longjmp statement to get back here, preventing an immediate exit.
|
||||||
*/
|
*/
|
||||||
if (setjmp(*jump_env()) == 0) {
|
if (setjmp(*jump_env()) == 0) {
|
||||||
/* if we're setting the jump, rather than jumping back */
|
/* if we're setting the jump, rather than jumping back */
|
||||||
SInt32 result;
|
SInt32 result;
|
||||||
|
|
|
@ -34,7 +34,7 @@ static int UIKit_GL_Initialize(_THIS);
|
||||||
|
|
||||||
void *
|
void *
|
||||||
UIKit_GL_GetProcAddress(_THIS, const char *proc)
|
UIKit_GL_GetProcAddress(_THIS, const char *proc)
|
||||||
{
|
{
|
||||||
/* Look through all SO's for the proc symbol. Here's why:
|
/* Look through all SO's for the proc symbol. Here's why:
|
||||||
-Looking for the path to the OpenGL Library seems not to work in the iPhone Simulator.
|
-Looking for the path to the OpenGL Library seems not to work in the iPhone Simulator.
|
||||||
-We don't know that the path won't change in the future.
|
-We don't know that the path won't change in the future.
|
||||||
|
@ -47,7 +47,7 @@ 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];
|
||||||
|
@ -55,15 +55,15 @@ int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
||||||
else {
|
else {
|
||||||
[EAGLContext setCurrentContext: nil];
|
[EAGLContext setCurrentContext: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
UIKit_GL_LoadLibrary(_THIS, const char *path)
|
UIKit_GL_LoadLibrary(_THIS, const char *path)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
shouldn't be passing a path into this function
|
shouldn't be passing a path into this function
|
||||||
why? Because we've already loaded the library
|
why? Because we've already loaded the library
|
||||||
and because the SDK forbids loading an external SO
|
and because the SDK forbids loading an external SO
|
||||||
*/
|
*/
|
||||||
|
@ -84,7 +84,7 @@ void UIKit_GL_SwapWindow(_THIS, SDL_Window * window)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
||||||
|
|
||||||
if (nil == data->view) {
|
if (nil == data->view) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ void UIKit_GL_SwapWindow(_THIS, SDL_Window * window)
|
||||||
|
|
||||||
/* we need to let the event cycle run, or the OS won't update the OpenGL view! */
|
/* we need to let the event cycle run, or the OS won't update the OpenGL view! */
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window)
|
SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window)
|
||||||
|
@ -114,7 +114,7 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window)
|
||||||
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;
|
||||||
view->viewcontroller = data->viewcontroller;
|
view->viewcontroller = data->viewcontroller;
|
||||||
if (view->viewcontroller != nil) {
|
if (view->viewcontroller != nil) {
|
||||||
|
|
|
@ -31,17 +31,17 @@
|
||||||
*/
|
*/
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
@interface SDL_uikitopenglview : SDL_uikitview {
|
@interface SDL_uikitopenglview : SDL_uikitview {
|
||||||
|
|
||||||
@private
|
@private
|
||||||
/* The pixel dimensions of the backbuffer */
|
/* The pixel dimensions of the backbuffer */
|
||||||
GLint backingWidth;
|
GLint backingWidth;
|
||||||
GLint backingHeight;
|
GLint backingHeight;
|
||||||
|
|
||||||
EAGLContext *context;
|
EAGLContext *context;
|
||||||
|
|
||||||
/* OpenGL names for the renderbuffer and framebuffers used to render to this view */
|
/* OpenGL names for the renderbuffer and framebuffers used to render to this view */
|
||||||
GLuint viewRenderbuffer, viewFramebuffer;
|
GLuint viewRenderbuffer, viewFramebuffer;
|
||||||
|
|
||||||
/* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */
|
/* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */
|
||||||
GLuint depthRenderbuffer;
|
GLuint depthRenderbuffer;
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
{
|
{
|
||||||
NSString *colorFormat=nil;
|
NSString *colorFormat=nil;
|
||||||
BOOL useDepthBuffer;
|
BOOL useDepthBuffer;
|
||||||
|
|
||||||
if (rBits == 8 && gBits == 8 && bBits == 8) {
|
if (rBits == 8 && gBits == 8 && bBits == 8) {
|
||||||
/* if user specifically requests rbg888 or some color format higher than 16bpp */
|
/* if user specifically requests rbg888 or some color format higher than 16bpp */
|
||||||
colorFormat = kEAGLColorFormatRGBA8;
|
colorFormat = kEAGLColorFormatRGBA8;
|
||||||
|
@ -59,7 +59,7 @@
|
||||||
/* default case (faster) */
|
/* default case (faster) */
|
||||||
colorFormat = kEAGLColorFormatRGB565;
|
colorFormat = kEAGLColorFormatRGB565;
|
||||||
}
|
}
|
||||||
|
|
||||||
depthBufferFormat = 0;
|
depthBufferFormat = 0;
|
||||||
|
|
||||||
if (depthBits == 24) {
|
if (depthBits == 24) {
|
||||||
|
@ -71,22 +71,22 @@
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* default case when depth buffer is not disabled */
|
/* default case when depth buffer is not disabled */
|
||||||
/*
|
/*
|
||||||
strange, even when we use this, we seem to get a 24 bit depth buffer on iPhone.
|
strange, even when we use this, we seem to get a 24 bit depth buffer on iPhone.
|
||||||
perhaps that's the only depth format iPhone actually supports
|
perhaps that's the only depth format iPhone actually supports
|
||||||
*/
|
*/
|
||||||
useDepthBuffer = YES;
|
useDepthBuffer = YES;
|
||||||
depthBufferFormat = GL_DEPTH_COMPONENT16_OES;
|
depthBufferFormat = GL_DEPTH_COMPONENT16_OES;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((self = [super initWithFrame:frame])) {
|
if ((self = [super initWithFrame:frame])) {
|
||||||
// Get the layer
|
// Get the layer
|
||||||
CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
|
CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
|
||||||
|
|
||||||
eaglLayer.opaque = YES;
|
eaglLayer.opaque = YES;
|
||||||
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
|
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
[NSNumber numberWithBool: retained], kEAGLDrawablePropertyRetainedBacking, colorFormat, kEAGLDrawablePropertyColorFormat, nil];
|
[NSNumber numberWithBool: retained], kEAGLDrawablePropertyRetainedBacking, colorFormat, kEAGLDrawablePropertyColorFormat, nil];
|
||||||
|
|
||||||
if (majorVersion > 1) {
|
if (majorVersion > 1) {
|
||||||
context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES2];
|
context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES2];
|
||||||
} else {
|
} else {
|
||||||
|
@ -96,16 +96,16 @@
|
||||||
[self release];
|
[self release];
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create the buffers */
|
/* create the buffers */
|
||||||
glGenFramebuffersOES(1, &viewFramebuffer);
|
glGenFramebuffersOES(1, &viewFramebuffer);
|
||||||
glGenRenderbuffersOES(1, &viewRenderbuffer);
|
glGenRenderbuffersOES(1, &viewRenderbuffer);
|
||||||
|
|
||||||
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
|
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
|
||||||
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
|
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
|
||||||
[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer];
|
[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer];
|
||||||
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer);
|
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer);
|
||||||
|
|
||||||
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
|
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
|
||||||
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
|
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@
|
||||||
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depthBufferFormat, backingWidth, backingHeight);
|
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depthBufferFormat, backingWidth, backingHeight);
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@
|
||||||
glGenRenderbuffersOES(1, &viewRenderbuffer);
|
glGenRenderbuffersOES(1, &viewRenderbuffer);
|
||||||
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
|
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
|
||||||
[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer];
|
[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer];
|
||||||
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer);
|
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer);
|
||||||
|
|
||||||
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
|
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
|
||||||
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
|
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
|
||||||
|
@ -149,7 +149,7 @@
|
||||||
glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);
|
glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);
|
||||||
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depthBufferFormat, backingWidth, backingHeight);
|
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depthBufferFormat, backingWidth, backingHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
// !!! FIXME: use the screen this is on!
|
// !!! FIXME: use the screen this is on!
|
||||||
/* Use the main screen scale (for retina display support) */
|
/* Use the main screen scale (for retina display support) */
|
||||||
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
|
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
|
||||||
|
@ -176,7 +176,7 @@
|
||||||
viewFramebuffer = 0;
|
viewFramebuffer = 0;
|
||||||
glDeleteRenderbuffersOES(1, &viewRenderbuffer);
|
glDeleteRenderbuffersOES(1, &viewRenderbuffer);
|
||||||
viewRenderbuffer = 0;
|
viewRenderbuffer = 0;
|
||||||
|
|
||||||
if (depthRenderbuffer) {
|
if (depthRenderbuffer) {
|
||||||
glDeleteRenderbuffersOES(1, &depthRenderbuffer);
|
glDeleteRenderbuffersOES(1, &depthRenderbuffer);
|
||||||
depthRenderbuffer = 0;
|
depthRenderbuffer = 0;
|
||||||
|
@ -189,7 +189,7 @@
|
||||||
if ([EAGLContext currentContext] == context) {
|
if ([EAGLContext currentContext] == context) {
|
||||||
[EAGLContext setCurrentContext:nil];
|
[EAGLContext setCurrentContext:nil];
|
||||||
}
|
}
|
||||||
[context release];
|
[context release];
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,8 +84,8 @@ UIKit_CreateDevice(int devindex)
|
||||||
device->CreateWindow = UIKit_CreateWindow;
|
device->CreateWindow = UIKit_CreateWindow;
|
||||||
device->DestroyWindow = UIKit_DestroyWindow;
|
device->DestroyWindow = UIKit_DestroyWindow;
|
||||||
device->GetWindowWMInfo = UIKit_GetWindowWMInfo;
|
device->GetWindowWMInfo = UIKit_GetWindowWMInfo;
|
||||||
|
|
||||||
|
|
||||||
/* OpenGL (ES) functions */
|
/* OpenGL (ES) functions */
|
||||||
device->GL_MakeCurrent = UIKit_GL_MakeCurrent;
|
device->GL_MakeCurrent = UIKit_GL_MakeCurrent;
|
||||||
device->GL_SwapWindow = UIKit_GL_SwapWindow;
|
device->GL_SwapWindow = UIKit_GL_SwapWindow;
|
||||||
|
@ -211,7 +211,7 @@ UIKit_AddDisplay(UIScreen *uiscreen, UIScreenMode *uimode, int w, int h)
|
||||||
mode.w = w;
|
mode.w = w;
|
||||||
mode.h = h;
|
mode.h = h;
|
||||||
mode.refresh_rate = 0;
|
mode.refresh_rate = 0;
|
||||||
|
|
||||||
[uimode retain];
|
[uimode retain];
|
||||||
mode.driverdata = uimode;
|
mode.driverdata = uimode;
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
#if SDL_IPHONE_KEYBOARD
|
#if SDL_IPHONE_KEYBOARD
|
||||||
UITextField *textField;
|
UITextField *textField;
|
||||||
BOOL keyboardVisible;
|
BOOL keyboardVisible;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@public
|
@public
|
||||||
SDL_uikitviewcontroller *viewcontroller;
|
SDL_uikitviewcontroller *viewcontroller;
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
- (void)hideKeyboard;
|
- (void)hideKeyboard;
|
||||||
- (void)initializeKeyboard;
|
- (void)initializeKeyboard;
|
||||||
@property (readonly) BOOL keyboardVisible;
|
@property (readonly) BOOL keyboardVisible;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@end
|
@end
|
||||||
/* *INDENT-ON* */
|
/* *INDENT-ON* */
|
||||||
|
|
|
@ -40,10 +40,10 @@
|
||||||
- (id)initWithFrame:(CGRect)frame {
|
- (id)initWithFrame:(CGRect)frame {
|
||||||
|
|
||||||
self = [super initWithFrame: frame];
|
self = [super initWithFrame: frame];
|
||||||
|
|
||||||
#if SDL_IPHONE_KEYBOARD
|
#if SDL_IPHONE_KEYBOARD
|
||||||
[self initializeKeyboard];
|
[self initializeKeyboard];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FIXED_MULTITOUCH
|
#ifdef FIXED_MULTITOUCH
|
||||||
self.multipleTouchEnabled = YES;
|
self.multipleTouchEnabled = YES;
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
|
|
||||||
//touch.driverdata = SDL_malloc(sizeof(EventTouchData));
|
//touch.driverdata = SDL_malloc(sizeof(EventTouchData));
|
||||||
//EventTouchData* data = (EventTouchData*)(touch.driverdata);
|
//EventTouchData* data = (EventTouchData*)(touch.driverdata);
|
||||||
|
|
||||||
touch.x_min = 0;
|
touch.x_min = 0;
|
||||||
touch.x_max = frame.size.width;
|
touch.x_max = frame.size.width;
|
||||||
touch.native_xres = touch.x_max - touch.x_min;
|
touch.native_xres = touch.x_max - touch.x_min;
|
||||||
|
@ -79,7 +79,7 @@
|
||||||
|
|
||||||
if (touch) {
|
if (touch) {
|
||||||
CGPoint locationInView = [touch locationInView: self];
|
CGPoint locationInView = [touch locationInView: self];
|
||||||
|
|
||||||
/* send moved event */
|
/* send moved event */
|
||||||
SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
|
SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
|
||||||
|
|
||||||
|
@ -112,16 +112,16 @@
|
||||||
}
|
}
|
||||||
#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];
|
||||||
|
|
||||||
if (touch) {
|
if (touch) {
|
||||||
/* send mouse up */
|
/* send mouse up */
|
||||||
SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT);
|
SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT);
|
||||||
|
@ -130,7 +130,7 @@
|
||||||
#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,
|
||||||
|
@ -149,7 +149,7 @@
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
touch = (UITouch*)[enumerator nextObject];
|
touch = (UITouch*)[enumerator nextObject];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -164,10 +164,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (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];
|
||||||
|
|
||||||
if (touch) {
|
if (touch) {
|
||||||
CGPoint locationInView = [touch locationInView: self];
|
CGPoint locationInView = [touch locationInView: self];
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@
|
||||||
#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,
|
||||||
|
@ -196,7 +196,7 @@
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
touch = (UITouch*)[enumerator nextObject];
|
touch = (UITouch*)[enumerator nextObject];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -213,12 +213,12 @@
|
||||||
|
|
||||||
/* 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! */
|
||||||
textField.text = @" ";
|
textField.text = @" ";
|
||||||
|
|
||||||
/* set UITextInputTrait properties, mostly to defaults */
|
/* set UITextInputTrait properties, mostly to defaults */
|
||||||
textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
|
textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
|
||||||
textField.autocorrectionType = UITextAutocorrectionTypeNo;
|
textField.autocorrectionType = UITextAutocorrectionTypeNo;
|
||||||
|
@ -226,8 +226,8 @@
|
||||||
textField.keyboardAppearance = UIKeyboardAppearanceDefault;
|
textField.keyboardAppearance = UIKeyboardAppearanceDefault;
|
||||||
textField.keyboardType = UIKeyboardTypeDefault;
|
textField.keyboardType = UIKeyboardTypeDefault;
|
||||||
textField.returnKeyType = UIReturnKeyDefault;
|
textField.returnKeyType = UIReturnKeyDefault;
|
||||||
textField.secureTextEntry = NO;
|
textField.secureTextEntry = NO;
|
||||||
|
|
||||||
textField.hidden = YES;
|
textField.hidden = YES;
|
||||||
keyboardVisible = NO;
|
keyboardVisible = NO;
|
||||||
/* add the UITextField (hidden) to our view */
|
/* add the UITextField (hidden) to our view */
|
||||||
|
@ -249,7 +249,7 @@
|
||||||
|
|
||||||
/* 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);
|
||||||
|
@ -260,12 +260,12 @@
|
||||||
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];
|
||||||
|
|
||||||
Uint16 mod = 0;
|
Uint16 mod = 0;
|
||||||
SDL_Scancode code;
|
SDL_Scancode code;
|
||||||
|
|
||||||
if (c < 127) {
|
if (c < 127) {
|
||||||
/* figure out the SDL_Scancode and SDL_keymod for this unichar */
|
/* figure out the SDL_Scancode and SDL_keymod for this unichar */
|
||||||
code = unicharToUIKeyInfoTable[c].code;
|
code = unicharToUIKeyInfoTable[c].code;
|
||||||
|
@ -276,7 +276,7 @@
|
||||||
code = SDL_SCANCODE_UNKNOWN;
|
code = SDL_SCANCODE_UNKNOWN;
|
||||||
mod = 0;
|
mod = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mod & KMOD_SHIFT) {
|
if (mod & KMOD_SHIFT) {
|
||||||
/* If character uses shift, press shift down */
|
/* If character uses shift, press shift down */
|
||||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT);
|
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT);
|
||||||
|
@ -287,7 +287,7 @@
|
||||||
if (mod & KMOD_SHIFT) {
|
if (mod & KMOD_SHIFT) {
|
||||||
/* If character uses shift, press shift back up */
|
/* If character uses shift, press shift back up */
|
||||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
|
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_SendKeyboardText([string UTF8String]);
|
SDL_SendKeyboardText([string UTF8String]);
|
||||||
}
|
}
|
||||||
|
@ -309,18 +309,18 @@
|
||||||
#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;
|
||||||
|
|
||||||
if (NULL == window) {
|
if (NULL == window) {
|
||||||
SDL_SetError("Window does not exist");
|
SDL_SetError("Window does not exist");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = (SDL_WindowData *)window->driverdata;
|
data = (SDL_WindowData *)window->driverdata;
|
||||||
view = data->view;
|
view = data->view;
|
||||||
|
|
||||||
if (nil == view) {
|
if (nil == view) {
|
||||||
SDL_SetError("Window has no view");
|
SDL_SetError("Window has no view");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -332,18 +332,18 @@ 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;
|
||||||
|
|
||||||
if (NULL == window) {
|
if (NULL == window) {
|
||||||
SDL_SetError("Window does not exist");
|
SDL_SetError("Window does not exist");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = (SDL_WindowData *)window->driverdata;
|
data = (SDL_WindowData *)window->driverdata;
|
||||||
view = data->view;
|
view = data->view;
|
||||||
|
|
||||||
if (NULL == view) {
|
if (NULL == view) {
|
||||||
SDL_SetError("Window has no view");
|
SDL_SetError("Window has no view");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -355,18 +355,18 @@ 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;
|
||||||
|
|
||||||
if (NULL == window) {
|
if (NULL == window) {
|
||||||
SDL_SetError("Window does not exist");
|
SDL_SetError("Window does not exist");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = (SDL_WindowData *)window->driverdata;
|
data = (SDL_WindowData *)window->driverdata;
|
||||||
view = data->view;
|
view = data->view;
|
||||||
|
|
||||||
if (NULL == view) {
|
if (NULL == view) {
|
||||||
SDL_SetError("Window has no view");
|
SDL_SetError("Window has no view");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -377,18 +377,18 @@ 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;
|
||||||
|
|
||||||
if (NULL == window) {
|
if (NULL == window) {
|
||||||
SDL_SetError("Window does not exist");
|
SDL_SetError("Window does not exist");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = (SDL_WindowData *)window->driverdata;
|
data = (SDL_WindowData *)window->driverdata;
|
||||||
view = data->view;
|
view = data->view;
|
||||||
|
|
||||||
if (NULL == view) {
|
if (NULL == view) {
|
||||||
SDL_SetError("Window has no view");
|
SDL_SetError("Window has no view");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
/*
|
/*
|
||||||
Simple DirectMedia Layer
|
Simple DirectMedia Layer
|
||||||
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
|
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
This software is provided 'as-is', without any express or implied
|
||||||
warranty. In no event will the authors be held liable for any damages
|
warranty. In no event will the authors be held liable for any damages
|
||||||
arising from the use of this software.
|
arising from the use of this software.
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it
|
including commercial applications, and to alter it and redistribute it
|
||||||
freely, subject to the following restrictions:
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
claim that you wrote the original software. If you use this software
|
claim that you wrote the original software. If you use this software
|
||||||
in a product, an acknowledgment in the product documentation would be
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
/*
|
/*
|
||||||
Simple DirectMedia Layer
|
Simple DirectMedia Layer
|
||||||
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
|
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
This software is provided 'as-is', without any express or implied
|
||||||
warranty. In no event will the authors be held liable for any damages
|
warranty. In no event will the authors be held liable for any damages
|
||||||
arising from the use of this software.
|
arising from the use of this software.
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it
|
including commercial applications, and to alter it and redistribute it
|
||||||
freely, subject to the following restrictions:
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
claim that you wrote the original software. If you use this software
|
claim that you wrote the original software. If you use this software
|
||||||
in a product, an acknowledgment in the product documentation would be
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
@ -49,34 +49,34 @@
|
||||||
encoding:NSUTF8StringEncoding];
|
encoding:NSUTF8StringEncoding];
|
||||||
NSArray *orientations = [orientationsNSString componentsSeparatedByCharactersInSet:
|
NSArray *orientations = [orientationsNSString componentsSeparatedByCharactersInSet:
|
||||||
[NSCharacterSet characterSetWithCharactersInString:@" "]];
|
[NSCharacterSet characterSetWithCharactersInString:@" "]];
|
||||||
|
|
||||||
switch (orient) {
|
switch (orient) {
|
||||||
case UIInterfaceOrientationLandscapeLeft:
|
case UIInterfaceOrientationLandscapeLeft:
|
||||||
rotate = [orientations containsObject:@"LandscapeLeft"];
|
rotate = [orientations containsObject:@"LandscapeLeft"];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UIInterfaceOrientationLandscapeRight:
|
case UIInterfaceOrientationLandscapeRight:
|
||||||
rotate = [orientations containsObject:@"LandscapeRight"];
|
rotate = [orientations containsObject:@"LandscapeRight"];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UIInterfaceOrientationPortrait:
|
case UIInterfaceOrientationPortrait:
|
||||||
rotate = [orientations containsObject:@"Portrait"];
|
rotate = [orientations containsObject:@"Portrait"];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UIInterfaceOrientationPortraitUpsideDown:
|
case UIInterfaceOrientationPortraitUpsideDown:
|
||||||
rotate = [orientations containsObject:@"PortraitUpsideDown"];
|
rotate = [orientations containsObject:@"PortraitUpsideDown"];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rotate;
|
return rotate;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->window->flags & SDL_WINDOW_RESIZABLE) {
|
if (self->window->flags & SDL_WINDOW_RESIZABLE) {
|
||||||
return YES; // any orientation is okay.
|
return YES; // any orientation is okay.
|
||||||
}
|
}
|
||||||
|
|
||||||
// If not resizable, allow device to orient to other matching sizes
|
// If not resizable, allow device to orient to other matching sizes
|
||||||
// (that is, let the user turn the device upside down...same screen
|
// (that is, let the user turn the device upside down...same screen
|
||||||
// dimensions, but it lets the user place the device where it's most
|
// dimensions, but it lets the user place the device where it's most
|
||||||
|
@ -85,14 +85,14 @@
|
||||||
case UIInterfaceOrientationLandscapeLeft:
|
case UIInterfaceOrientationLandscapeLeft:
|
||||||
case UIInterfaceOrientationLandscapeRight:
|
case UIInterfaceOrientationLandscapeRight:
|
||||||
return (self->window->w >= self->window->h);
|
return (self->window->w >= self->window->h);
|
||||||
|
|
||||||
case UIInterfaceOrientationPortrait:
|
case UIInterfaceOrientationPortrait:
|
||||||
case UIInterfaceOrientationPortraitUpsideDown:
|
case UIInterfaceOrientationPortraitUpsideDown:
|
||||||
return (self->window->h >= self->window->w);
|
return (self->window->h >= self->window->w);
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO; // Nothing else is acceptable.
|
return NO; // Nothing else is acceptable.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@
|
||||||
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.
|
||||||
}
|
}
|
||||||
|
|
||||||
const UIInterfaceOrientation toInterfaceOrientation = [self interfaceOrientation];
|
const UIInterfaceOrientation toInterfaceOrientation = [self interfaceOrientation];
|
||||||
SDL_WindowData *data = self->window->driverdata;
|
SDL_WindowData *data = self->window->driverdata;
|
||||||
UIWindow *uiwindow = data->uiwindow;
|
UIWindow *uiwindow = data->uiwindow;
|
||||||
|
@ -114,30 +114,30 @@
|
||||||
CGRect frame = noborder ? [uiscreen bounds] : [uiscreen applicationFrame];
|
CGRect frame = noborder ? [uiscreen bounds] : [uiscreen applicationFrame];
|
||||||
const CGSize size = frame.size;
|
const CGSize size = frame.size;
|
||||||
int w, h;
|
int w, h;
|
||||||
|
|
||||||
switch (toInterfaceOrientation) {
|
switch (toInterfaceOrientation) {
|
||||||
case UIInterfaceOrientationPortrait:
|
case UIInterfaceOrientationPortrait:
|
||||||
case UIInterfaceOrientationPortraitUpsideDown:
|
case UIInterfaceOrientationPortraitUpsideDown:
|
||||||
w = (size.width < size.height) ? size.width : size.height;
|
w = (size.width < size.height) ? size.width : size.height;
|
||||||
h = (size.width > size.height) ? size.width : size.height;
|
h = (size.width > size.height) ? size.width : size.height;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UIInterfaceOrientationLandscapeLeft:
|
case UIInterfaceOrientationLandscapeLeft:
|
||||||
case UIInterfaceOrientationLandscapeRight:
|
case UIInterfaceOrientationLandscapeRight:
|
||||||
w = (size.width > size.height) ? size.width : size.height;
|
w = (size.width > size.height) ? size.width : size.height;
|
||||||
h = (size.width < size.height) ? size.width : size.height;
|
h = (size.width < size.height) ? size.width : size.height;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
SDL_assert(0 && "Unexpected interface orientation!");
|
SDL_assert(0 && "Unexpected interface orientation!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
frame.size.width = w;
|
frame.size.width = w;
|
||||||
frame.size.height = h;
|
frame.size.height = h;
|
||||||
frame.origin.x = 0;
|
frame.origin.x = 0;
|
||||||
frame.origin.y = 0;
|
frame.origin.y = 0;
|
||||||
|
|
||||||
[uiwindow setFrame:frame];
|
[uiwindow setFrame:frame];
|
||||||
[data->view updateFrame];
|
[data->view updateFrame];
|
||||||
SDL_SendWindowEvent(self->window, SDL_WINDOWEVENT_RESIZED, w, h);
|
SDL_SendWindowEvent(self->window, SDL_WINDOWEVENT_RESIZED, w, h);
|
||||||
|
|
|
@ -46,7 +46,7 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
|
||||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||||
UIScreen *uiscreen = (UIScreen *) display->driverdata;
|
UIScreen *uiscreen = (UIScreen *) display->driverdata;
|
||||||
SDL_WindowData *data;
|
SDL_WindowData *data;
|
||||||
|
|
||||||
/* Allocate the window data */
|
/* Allocate the window data */
|
||||||
data = (SDL_WindowData *)SDL_malloc(sizeof(*data));
|
data = (SDL_WindowData *)SDL_malloc(sizeof(*data));
|
||||||
if (!data) {
|
if (!data) {
|
||||||
|
@ -64,7 +64,7 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
|
||||||
window->w = (int)uiwindow.frame.size.width;
|
window->w = (int)uiwindow.frame.size.width;
|
||||||
window->h = (int)uiwindow.frame.size.height;
|
window->h = (int)uiwindow.frame.size.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
window->driverdata = data;
|
window->driverdata = data;
|
||||||
|
|
||||||
// !!! FIXME: should we force this? Shouldn't specifying FULLSCREEN
|
// !!! FIXME: should we force this? Shouldn't specifying FULLSCREEN
|
||||||
|
@ -164,7 +164,7 @@ UIKit_CreateWindow(_THIS, SDL_Window *window)
|
||||||
uiwindow = [uiwindow initWithFrame:[uiscreen bounds]];
|
uiwindow = [uiwindow initWithFrame:[uiscreen bounds]];
|
||||||
else
|
else
|
||||||
uiwindow = [uiwindow initWithFrame:[uiscreen applicationFrame]];
|
uiwindow = [uiwindow initWithFrame:[uiscreen applicationFrame]];
|
||||||
|
|
||||||
// put the window on an external display if appropriate. This implicitly
|
// put the window on an external display if appropriate. This implicitly
|
||||||
// does [uiwindow setframe:[uiscreen bounds]], so don't do it on the
|
// does [uiwindow setframe:[uiscreen bounds]], so don't do it on the
|
||||||
// main display, where we land by default, as that would eat the
|
// main display, where we land by default, as that would eat the
|
||||||
|
@ -176,10 +176,10 @@ UIKit_CreateWindow(_THIS, SDL_Window *window)
|
||||||
if (SetupWindowData(_this, window, uiwindow, SDL_TRUE) < 0) {
|
if (SetupWindowData(_this, window, uiwindow, SDL_TRUE) < 0) {
|
||||||
[uiwindow release];
|
[uiwindow release];
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -88,7 +88,7 @@ static UIKitKeyInfo unicharToUIKeyInfoTable[] = {
|
||||||
/* 45 */ { SDL_SCANCODE_MINUS, 0 }, /* '-' */
|
/* 45 */ { SDL_SCANCODE_MINUS, 0 }, /* '-' */
|
||||||
/* 46 */ { SDL_SCANCODE_PERIOD, 0 }, /* '.' */
|
/* 46 */ { SDL_SCANCODE_PERIOD, 0 }, /* '.' */
|
||||||
/* 47 */ { SDL_SCANCODE_SLASH, 0 }, /* '/' */
|
/* 47 */ { SDL_SCANCODE_SLASH, 0 }, /* '/' */
|
||||||
/* 48 */ { SDL_SCANCODE_0, 0 },
|
/* 48 */ { SDL_SCANCODE_0, 0 },
|
||||||
/* 49 */ { SDL_SCANCODE_1, 0 },
|
/* 49 */ { SDL_SCANCODE_1, 0 },
|
||||||
/* 50 */ { SDL_SCANCODE_2, 0 },
|
/* 50 */ { SDL_SCANCODE_2, 0 },
|
||||||
/* 51 */ { SDL_SCANCODE_3, 0 },
|
/* 51 */ { SDL_SCANCODE_3, 0 },
|
||||||
|
@ -137,7 +137,7 @@ static UIKitKeyInfo unicharToUIKeyInfoTable[] = {
|
||||||
/* 94 */ { SDL_SCANCODE_6, KMOD_SHIFT }, /* plus shift modifier '^' */
|
/* 94 */ { SDL_SCANCODE_6, KMOD_SHIFT }, /* plus shift modifier '^' */
|
||||||
/* 95 */ { SDL_SCANCODE_MINUS, KMOD_SHIFT }, /* plus shift modifier '_' */
|
/* 95 */ { SDL_SCANCODE_MINUS, KMOD_SHIFT }, /* plus shift modifier '_' */
|
||||||
/* 96 */ { SDL_SCANCODE_GRAVE, KMOD_SHIFT }, /* '`' */
|
/* 96 */ { SDL_SCANCODE_GRAVE, KMOD_SHIFT }, /* '`' */
|
||||||
/* 97 */ { SDL_SCANCODE_A, 0 },
|
/* 97 */ { SDL_SCANCODE_A, 0 },
|
||||||
/* 98 */ { SDL_SCANCODE_B, 0 },
|
/* 98 */ { SDL_SCANCODE_B, 0 },
|
||||||
/* 99 */ { SDL_SCANCODE_C, 0 },
|
/* 99 */ { SDL_SCANCODE_C, 0 },
|
||||||
/* 100 */{ SDL_SCANCODE_D, 0 },
|
/* 100 */{ SDL_SCANCODE_D, 0 },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue