mirror of https://github.com/encounter/SDL.git
More cleanup of the iOS Objective-C code.
This commit is contained in:
parent
6d552cae38
commit
ef0490a741
|
@ -75,17 +75,18 @@ SDL_IdleTimerDisabledChanged(void *userdata, const char *name, const char *oldVa
|
||||||
[UIApplication sharedApplication].idleTimerDisabled = disable;
|
[UIApplication sharedApplication].idleTimerDisabled = disable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@interface SDL_splashviewcontroller : UIViewController {
|
@interface SDL_splashviewcontroller : UIViewController
|
||||||
|
|
||||||
|
- (void)updateSplashImage:(UIInterfaceOrientation)interfaceOrientation;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation SDL_splashviewcontroller {
|
||||||
UIImageView *splash;
|
UIImageView *splash;
|
||||||
UIImage *splashPortrait;
|
UIImage *splashPortrait;
|
||||||
UIImage *splashLandscape;
|
UIImage *splashLandscape;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateSplashImage:(UIInterfaceOrientation)interfaceOrientation;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation SDL_splashviewcontroller
|
|
||||||
|
|
||||||
- (id)init
|
- (id)init
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
|
@ -30,17 +30,16 @@
|
||||||
|
|
||||||
static SDL_bool s_showingMessageBox = SDL_FALSE;
|
static SDL_bool s_showingMessageBox = SDL_FALSE;
|
||||||
|
|
||||||
@interface UIKit_UIAlertViewDelegate : NSObject <UIAlertViewDelegate> {
|
@interface UIKit_UIAlertViewDelegate : NSObject <UIAlertViewDelegate>
|
||||||
@private
|
|
||||||
int *clickedButtonIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id)initWithButtonIndex:(int *)_buttonIndex;
|
- (id)initWithButtonIndex:(int *)_buttonIndex;
|
||||||
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex;
|
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation UIKit_UIAlertViewDelegate
|
@implementation UIKit_UIAlertViewDelegate {
|
||||||
|
int *clickedButtonIndex;
|
||||||
|
}
|
||||||
|
|
||||||
- (id)initWithButtonIndex:(int *)buttonIndex
|
- (id)initWithButtonIndex:(int *)buttonIndex
|
||||||
{
|
{
|
||||||
|
@ -48,7 +47,8 @@ static SDL_bool s_showingMessageBox = SDL_FALSE;
|
||||||
if (self == nil) {
|
if (self == nil) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
self->clickedButtonIndex = buttonIndex;
|
|
||||||
|
clickedButtonIndex = buttonIndex;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,38 +29,7 @@
|
||||||
The view content is basically an EAGL surface you render your OpenGL scene into.
|
The view content is basically an EAGL surface you render your OpenGL scene into.
|
||||||
Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.
|
Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.
|
||||||
*/
|
*/
|
||||||
@interface SDL_uikitopenglview : SDL_uikitview {
|
@interface SDL_uikitopenglview : SDL_uikitview
|
||||||
|
|
||||||
@private
|
|
||||||
/* The pixel dimensions of the backbuffer */
|
|
||||||
GLint backingWidth;
|
|
||||||
GLint backingHeight;
|
|
||||||
|
|
||||||
EAGLContext *context;
|
|
||||||
|
|
||||||
/* OpenGL names for the renderbuffer and framebuffers used to render to this view */
|
|
||||||
GLuint viewRenderbuffer, viewFramebuffer;
|
|
||||||
|
|
||||||
/* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */
|
|
||||||
GLuint depthRenderbuffer;
|
|
||||||
|
|
||||||
/* format of depthRenderbuffer */
|
|
||||||
GLenum depthBufferFormat;
|
|
||||||
|
|
||||||
id displayLink;
|
|
||||||
int animationInterval;
|
|
||||||
void (*animationCallback)(void*);
|
|
||||||
void *animationCallbackParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
@property (nonatomic, retain, readonly) EAGLContext *context;
|
|
||||||
|
|
||||||
/* The width and height of the drawable in pixels (as opposed to points.) */
|
|
||||||
@property (nonatomic, readonly) int backingWidth;
|
|
||||||
@property (nonatomic, readonly) int backingHeight;
|
|
||||||
|
|
||||||
- (void)swapBuffers;
|
|
||||||
- (void)setCurrentContext;
|
|
||||||
|
|
||||||
- (id)initWithFrame:(CGRect)frame
|
- (id)initWithFrame:(CGRect)frame
|
||||||
scale:(CGFloat)scale
|
scale:(CGFloat)scale
|
||||||
|
@ -75,6 +44,15 @@
|
||||||
majorVersion:(int)majorVersion
|
majorVersion:(int)majorVersion
|
||||||
shareGroup:(EAGLSharegroup*)shareGroup;
|
shareGroup:(EAGLSharegroup*)shareGroup;
|
||||||
|
|
||||||
|
@property (nonatomic, retain, readonly) EAGLContext *context;
|
||||||
|
|
||||||
|
/* The width and height of the drawable in pixels (as opposed to points.) */
|
||||||
|
@property (nonatomic, readonly) int backingWidth;
|
||||||
|
@property (nonatomic, readonly) int backingHeight;
|
||||||
|
|
||||||
|
- (void)swapBuffers;
|
||||||
|
- (void)setCurrentContext;
|
||||||
|
|
||||||
- (void)updateFrame;
|
- (void)updateFrame;
|
||||||
|
|
||||||
- (void)setAnimationCallback:(int)interval
|
- (void)setAnimationCallback:(int)interval
|
||||||
|
|
|
@ -28,12 +28,28 @@
|
||||||
#include "SDL_uikitmessagebox.h"
|
#include "SDL_uikitmessagebox.h"
|
||||||
|
|
||||||
|
|
||||||
@implementation SDL_uikitopenglview
|
@implementation SDL_uikitopenglview {
|
||||||
|
|
||||||
|
/* OpenGL names for the renderbuffer and framebuffers used to render to this view */
|
||||||
|
GLuint viewRenderbuffer, viewFramebuffer;
|
||||||
|
|
||||||
|
/* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */
|
||||||
|
GLuint depthRenderbuffer;
|
||||||
|
|
||||||
|
/* format of depthRenderbuffer */
|
||||||
|
GLenum depthBufferFormat;
|
||||||
|
|
||||||
|
id displayLink;
|
||||||
|
int animationInterval;
|
||||||
|
void (*animationCallback)(void*);
|
||||||
|
void *animationCallbackParam;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@synthesize context;
|
@synthesize context;
|
||||||
|
|
||||||
@synthesize backingWidth = backingWidth;
|
@synthesize backingWidth;
|
||||||
@synthesize backingHeight = backingHeight;
|
@synthesize backingHeight;
|
||||||
|
|
||||||
+ (Class)layerClass
|
+ (Class)layerClass
|
||||||
{
|
{
|
||||||
|
@ -53,8 +69,6 @@
|
||||||
majorVersion:(int)majorVersion
|
majorVersion:(int)majorVersion
|
||||||
shareGroup:(EAGLSharegroup*)shareGroup
|
shareGroup:(EAGLSharegroup*)shareGroup
|
||||||
{
|
{
|
||||||
depthBufferFormat = 0;
|
|
||||||
|
|
||||||
if ((self = [super initWithFrame:frame])) {
|
if ((self = [super initWithFrame:frame])) {
|
||||||
const BOOL useStencilBuffer = (stencilBits != 0);
|
const BOOL useStencilBuffer = (stencilBits != 0);
|
||||||
const BOOL useDepthBuffer = (depthBits != 0);
|
const BOOL useDepthBuffer = (depthBits != 0);
|
||||||
|
|
|
@ -35,23 +35,10 @@
|
||||||
#else
|
#else
|
||||||
@interface SDL_uikitview : UIView {
|
@interface SDL_uikitview : UIView {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SDL_TouchID touchId;
|
|
||||||
UITouch *leftFingerDown;
|
|
||||||
#ifndef IPHONE_TOUCH_EFFICIENT_DANGEROUS
|
|
||||||
UITouch *finger[MAX_SIMULTANEOUS_TOUCHES];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if SDL_IPHONE_KEYBOARD
|
|
||||||
UITextField *textField;
|
|
||||||
BOOL keyboardVisible;
|
|
||||||
SDL_Rect textInputRect;
|
|
||||||
int keyboardHeight;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@public
|
@public
|
||||||
SDL_uikitviewcontroller *viewcontroller;
|
SDL_uikitviewcontroller *viewcontroller;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CGPoint)touchLocation:(UITouch *)touch shouldNormalize:(BOOL)normalize;
|
- (CGPoint)touchLocation:(UITouch *)touch shouldNormalize:(BOOL)normalize;
|
||||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
|
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
|
||||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
|
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
|
||||||
|
@ -61,7 +48,8 @@
|
||||||
- (void)showKeyboard;
|
- (void)showKeyboard;
|
||||||
- (void)hideKeyboard;
|
- (void)hideKeyboard;
|
||||||
- (void)initializeKeyboard;
|
- (void)initializeKeyboard;
|
||||||
@property (nonatomic, readonly) BOOL keyboardVisible;
|
|
||||||
|
@property (nonatomic, readonly, assign, getter=isKeyboardVisible) BOOL keyboardVisible;
|
||||||
@property (nonatomic, assign) SDL_Rect textInputRect;
|
@property (nonatomic, assign) SDL_Rect textInputRect;
|
||||||
@property (nonatomic, assign) int keyboardHeight;
|
@property (nonatomic, assign) int keyboardHeight;
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,19 @@
|
||||||
|
|
||||||
void _uikit_keyboard_init();
|
void _uikit_keyboard_init();
|
||||||
|
|
||||||
@implementation SDL_uikitview
|
@implementation SDL_uikitview {
|
||||||
|
|
||||||
|
SDL_TouchID touchId;
|
||||||
|
UITouch *leftFingerDown;
|
||||||
|
#ifndef IPHONE_TOUCH_EFFICIENT_DANGEROUS
|
||||||
|
UITouch *finger[MAX_SIMULTANEOUS_TOUCHES];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SDL_IPHONE_KEYBOARD
|
||||||
|
UITextField *textField;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
|
@ -66,7 +78,7 @@ void _uikit_keyboard_init();
|
||||||
CGPoint point = [touch locationInView: self];
|
CGPoint point = [touch locationInView: self];
|
||||||
|
|
||||||
if (normalize) {
|
if (normalize) {
|
||||||
CGRect bounds = [self bounds];
|
CGRect bounds = self.bounds;
|
||||||
point.x /= bounds.size.width;
|
point.x /= bounds.size.width;
|
||||||
point.y /= bounds.size.height;
|
point.y /= bounds.size.height;
|
||||||
}
|
}
|
||||||
|
@ -122,7 +134,7 @@ void _uikit_keyboard_init();
|
||||||
|
|
||||||
CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
|
CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
|
||||||
#ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
|
#ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
|
||||||
SDL_SendTouch(touchId, (long)touch,
|
SDL_SendTouch(touchId, (SDL_FingerID)((size_t)touch),
|
||||||
SDL_FALSE, locationInView.x, locationInView.y, 1.0f);
|
SDL_FALSE, locationInView.x, locationInView.y, 1.0f);
|
||||||
#else
|
#else
|
||||||
int i;
|
int i;
|
||||||
|
@ -160,7 +172,7 @@ void _uikit_keyboard_init();
|
||||||
|
|
||||||
CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
|
CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
|
||||||
#ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
|
#ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
|
||||||
SDL_SendTouchMotion(touchId, (long)touch,
|
SDL_SendTouchMotion(touchId, (SDL_FingerID)((size_t)touch),
|
||||||
locationInView.x, locationInView.y, 1.0f);
|
locationInView.x, locationInView.y, 1.0f);
|
||||||
#else
|
#else
|
||||||
int i;
|
int i;
|
||||||
|
@ -180,14 +192,9 @@ void _uikit_keyboard_init();
|
||||||
*/
|
*/
|
||||||
#if SDL_IPHONE_KEYBOARD
|
#if SDL_IPHONE_KEYBOARD
|
||||||
|
|
||||||
@synthesize textInputRect = textInputRect;
|
@synthesize textInputRect;
|
||||||
@synthesize keyboardHeight = keyboardHeight;
|
@synthesize keyboardHeight;
|
||||||
|
@synthesize keyboardVisible;
|
||||||
/* Is the iPhone virtual keyboard visible onscreen? */
|
|
||||||
- (BOOL)keyboardVisible
|
|
||||||
{
|
|
||||||
return keyboardVisible;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set ourselves up as a UITextFieldDelegate */
|
/* Set ourselves up as a UITextFieldDelegate */
|
||||||
- (void)initializeKeyboard
|
- (void)initializeKeyboard
|
||||||
|
@ -337,7 +344,7 @@ SDL_bool UIKit_IsScreenKeyboardShown(_THIS, SDL_Window *window)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return view.keyboardVisible;
|
return view.isKeyboardVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,12 +23,9 @@
|
||||||
|
|
||||||
#include "../SDL_sysvideo.h"
|
#include "../SDL_sysvideo.h"
|
||||||
|
|
||||||
@interface SDL_uikitviewcontroller : UIViewController {
|
@interface SDL_uikitviewcontroller : UIViewController
|
||||||
@private
|
|
||||||
SDL_Window *window;
|
|
||||||
}
|
|
||||||
|
|
||||||
@property (nonatomic, readwrite) SDL_Window *window;
|
@property (nonatomic, assign) SDL_Window *window;
|
||||||
|
|
||||||
- (id)initWithSDLWindow:(SDL_Window *)_window;
|
- (id)initWithSDLWindow:(SDL_Window *)_window;
|
||||||
- (void)loadView;
|
- (void)loadView;
|
||||||
|
|
|
@ -239,7 +239,6 @@ UIKit_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display
|
||||||
SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
|
SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
|
||||||
SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
|
SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
|
||||||
SDL_uikitviewcontroller *viewcontroller = windowdata->viewcontroller;
|
SDL_uikitviewcontroller *viewcontroller = windowdata->viewcontroller;
|
||||||
UIWindow *uiwindow = windowdata->uiwindow;
|
|
||||||
CGRect bounds;
|
CGRect bounds;
|
||||||
|
|
||||||
if (fullscreen || (window->flags & SDL_WINDOW_BORDERLESS)) {
|
if (fullscreen || (window->flags & SDL_WINDOW_BORDERLESS)) {
|
||||||
|
|
Loading…
Reference in New Issue