This repository has been archived by the owner on Feb 11, 2021. It is now read-only.
/
SDL_uikitvideo.m
150 lines (119 loc) · 4.16 KB
1
2
/*
Simple DirectMedia Layer
3
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
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
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
21
#include "SDL_config.h"
22
23
#if SDL_VIDEO_DRIVER_UIKIT
24
25
#import <UIKit/UIKit.h>
26
27
28
29
30
31
32
33
34
#include "SDL_video.h"
#include "SDL_mouse.h"
#include "../SDL_sysvideo.h"
#include "../SDL_pixels_c.h"
#include "../../events/SDL_events_c.h"
#include "SDL_uikitvideo.h"
#include "SDL_uikitevents.h"
35
#include "SDL_uikitmodes.h"
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "SDL_uikitwindow.h"
#include "SDL_uikitopengles.h"
#define UIKITVID_DRIVER_NAME "uikit"
/* Initialization/Query functions */
static int UIKit_VideoInit(_THIS);
static void UIKit_VideoQuit(_THIS);
/* DUMMY driver bootstrap functions */
static int
UIKit_Available(void)
{
50
return 1;
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
}
static void UIKit_DeleteDevice(SDL_VideoDevice * device)
{
SDL_free(device);
}
static SDL_VideoDevice *
UIKit_CreateDevice(int devindex)
{
SDL_VideoDevice *device;
/* Initialize all variables that we clean on shutdown */
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
if (!device) {
SDL_OutOfMemory();
if (device) {
SDL_free(device);
}
return (0);
}
/* Set the function pointers */
device->VideoInit = UIKit_VideoInit;
device->VideoQuit = UIKit_VideoQuit;
device->GetDisplayModes = UIKit_GetDisplayModes;
device->SetDisplayMode = UIKit_SetDisplayMode;
device->PumpEvents = UIKit_PumpEvents;
device->CreateWindow = UIKit_CreateWindow;
80
81
device->ShowWindow = UIKit_ShowWindow;
device->HideWindow = UIKit_HideWindow;
82
device->RaiseWindow = UIKit_RaiseWindow;
83
device->SetWindowFullscreen = UIKit_SetWindowFullscreen;
84
85
device->DestroyWindow = UIKit_DestroyWindow;
device->GetWindowWMInfo = UIKit_GetWindowWMInfo;
86
87
88
/* !!! FIXME: implement SetWindowBordered */
89
90
91
92
93
device->SDL_HasScreenKeyboardSupport = UIKit_HasScreenKeyboardSupport;
device->SDL_ShowScreenKeyboard = UIKit_ShowScreenKeyboard;
device->SDL_HideScreenKeyboard = UIKit_HideScreenKeyboard;
device->SDL_ToggleScreenKeyboard = UIKit_ToggleScreenKeyboard;
device->SDL_IsScreenKeyboardShown = UIKit_IsScreenKeyboardShown;
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/* OpenGL (ES) functions */
device->GL_MakeCurrent = UIKit_GL_MakeCurrent;
device->GL_SwapWindow = UIKit_GL_SwapWindow;
device->GL_CreateContext = UIKit_GL_CreateContext;
device->GL_DeleteContext = UIKit_GL_DeleteContext;
device->GL_GetProcAddress = UIKit_GL_GetProcAddress;
device->GL_LoadLibrary = UIKit_GL_LoadLibrary;
device->free = UIKit_DeleteDevice;
device->gl_config.accelerated = 1;
return device;
}
VideoBootStrap UIKIT_bootstrap = {
UIKITVID_DRIVER_NAME, "SDL UIKit video driver",
UIKit_Available, UIKit_CreateDevice
};
int
UIKit_VideoInit(_THIS)
{
_this->gl_config.driver_loaded = 1;
120
if (UIKit_InitModes(_this) < 0) {
121
122
return -1;
}
123
124
125
126
127
128
return 0;
}
void
UIKit_VideoQuit(_THIS)
{
129
UIKit_QuitModes(_this);
130
131
}
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
* iOS log support.
*
* This doesn't really have aything to do with the interfaces of the SDL video
* subsystem, but we need to stuff this into an Objective-C source code file.
*/
void SDL_NSLog(const char *text)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSLog(@"%@", [[NSString alloc] initWithUTF8String:text]);
[pool release];
}
148
149
#endif /* SDL_VIDEO_DRIVER_UIKIT */
150
/* vi: set ts=4 sw=4 expandtab: */