zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_uikitviewcontroller.m
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 #include "SDL_config.h"
22 
23 #if SDL_VIDEO_DRIVER_UIKIT
24 
25 #include "SDL_video.h"
26 #include "SDL_assert.h"
27 #include "SDL_hints.h"
28 #include "../SDL_sysvideo.h"
29 #include "../../events/SDL_events_c.h"
30 
32 #include "SDL_uikitvideo.h"
33 #include "SDL_uikitmodes.h"
34 #include "SDL_uikitwindow.h"
35 
36 
37 @implementation SDL_uikitviewcontroller
38 
39 @synthesize window;
40 
41 - (id)initWithSDLWindow:(SDL_Window *)_window
42 {
43  self = [self init];
44  if (self == nil) {
45  return nil;
46  }
47  self.window = _window;
48 
49  return self;
50 }
51 
52 - (void)loadView
53 {
54  /* do nothing. */
55 }
56 
58 {
59  if (self->window->flags & SDL_WINDOW_RESIZABLE) {
62  SDL_DisplayModeData *displaymodedata = (SDL_DisplayModeData *) display->current_mode.driverdata;
63  const CGSize size = data->view.bounds.size;
64  int w, h;
65 
66  w = (int)(size.width * displaymodedata->scale);
67  h = (int)(size.height * displaymodedata->scale);
68 
70  }
71 }
72 
74 {
75  NSUInteger orientationMask = 0;
76 
77  const char *orientationsCString;
78  if ((orientationsCString = SDL_GetHint(SDL_HINT_ORIENTATIONS)) != NULL) {
79  BOOL rotate = NO;
80  NSString *orientationsNSString = [NSString stringWithCString:orientationsCString
81  encoding:NSUTF8StringEncoding];
82  NSArray *orientations = [orientationsNSString componentsSeparatedByCharactersInSet:
83  [NSCharacterSet characterSetWithCharactersInString:@" "]];
84 
85  if ([orientations containsObject:@"LandscapeLeft"]) {
86  orientationMask |= UIInterfaceOrientationMaskLandscapeLeft;
87  }
88  if ([orientations containsObject:@"LandscapeRight"]) {
90  }
91  if ([orientations containsObject:@"Portrait"]) {
92  orientationMask |= UIInterfaceOrientationMaskPortrait;
93  }
94  if ([orientations containsObject:@"PortraitUpsideDown"]) {
96  }
97 
98  } else if (self->window->flags & SDL_WINDOW_RESIZABLE) {
99  orientationMask = UIInterfaceOrientationMaskAll; /* any orientation is okay. */
100  } else {
101  if (self->window->w >= self->window->h) {
102  orientationMask |= UIInterfaceOrientationMaskLandscape;
103  }
104  if (self->window->h >= self->window->w) {
106  }
107  }
108 
109  /* Don't allow upside-down orientation on the phone, so answering calls is in the natural orientation */
110  if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
112  }
113  return orientationMask;
114 }
115 
116 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient
117 {
118  NSUInteger orientationMask = [self supportedInterfaceOrientations];
119  return (orientationMask & (1 << orient));
120 }
121 
122 @end
123 
124 #endif /* SDL_VIDEO_DRIVER_UIKIT */
125 
126 /* vi: set ts=4 sw=4 expandtab: */
GLfloat GLfloat GLfloat GLfloat h
Definition: glew.h:7294
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
Definition: glew.h:1824
#define NULL
Definition: ftobjs.h:61
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
SDL_Window * window
char * display
Definition: visualinfo.c:85
GLuint id
Definition: gl2ext.h:1142
int
Definition: SDL_systhread.c:37
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl2ext.h:848
void * driverdata
Definition: SDL_video.h:59
SDL_DisplayMode current_mode
Definition: SDL_sysvideo.h:120
DECLSPEC const char *SDLCALL SDL_GetHint(const char *name)
Get a hint.
Definition: SDL_hints.c:104
#define SDL_HINT_ORIENTATIONS
A variable controlling which orientations are allowed on iOS.
Definition: SDL_hints.h:205
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:996
GLint GLint GLint GLint GLint w
Definition: gl2ext.h:1215
void * driverdata
Definition: SDL_sysvideo.h:99
SDL_uikitopenglview * view
NSUInteger supportedInterfaceOrientations()
typedef BOOL(WINAPI *PFNWGLSETSTEREOEMITTERSTATE3DLPROC)(HDC hDC
GLsizei size
Definition: gl2ext.h:1467