7009
|
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 |
|
|
22 |
#include "SDL_config.h"
|
|
23 |
|
|
24 |
#if SDL_VIDEO_DRIVER_PSP
|
|
25 |
|
|
26 |
/* SDL internals */
|
|
27 |
#include "../SDL_sysvideo.h"
|
|
28 |
#include "SDL_version.h"
|
|
29 |
#include "SDL_syswm.h"
|
|
30 |
#include "SDL_loadso.h"
|
|
31 |
#include "SDL_events.h"
|
|
32 |
#include "../../events/SDL_mouse_c.h"
|
|
33 |
#include "../../events/SDL_keyboard_c.h"
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
/* PSP declarations */
|
|
38 |
#include "SDL_pspvideo.h"
|
|
39 |
#include "SDL_pspevents_c.h"
|
|
40 |
#include "SDL_pspgl_c.h"
|
|
41 |
|
|
42 |
/* unused
|
|
43 |
static SDL_bool PSP_initialized = SDL_FALSE;
|
|
44 |
*/
|
|
45 |
static int
|
|
46 |
PSP_Available(void)
|
|
47 |
{
|
|
48 |
return 1;
|
|
49 |
}
|
|
50 |
|
|
51 |
static void
|
|
52 |
PSP_Destroy(SDL_VideoDevice * device)
|
|
53 |
{
|
|
54 |
// SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata;
|
|
55 |
|
|
56 |
if (device->driverdata != NULL) {
|
|
57 |
device->driverdata = NULL;
|
|
58 |
}
|
|
59 |
}
|
|
60 |
|
|
61 |
static SDL_VideoDevice *
|
|
62 |
PSP_Create()
|
|
63 |
{
|
|
64 |
SDL_VideoDevice *device;
|
|
65 |
SDL_VideoData *phdata;
|
|
66 |
SDL_GLDriverData *gldata;
|
|
67 |
int status;
|
|
68 |
|
|
69 |
/* Check if pandora could be initialized */
|
|
70 |
status = PSP_Available();
|
|
71 |
if (status == 0) {
|
|
72 |
/* PSP could not be used */
|
|
73 |
return NULL;
|
|
74 |
}
|
|
75 |
|
|
76 |
/* Initialize SDL_VideoDevice structure */
|
|
77 |
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
|
|
78 |
if (device == NULL) {
|
|
79 |
SDL_OutOfMemory();
|
|
80 |
return NULL;
|
|
81 |
}
|
|
82 |
|
|
83 |
/* Initialize internal Pandora specific data */
|
|
84 |
phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
|
|
85 |
if (phdata == NULL) {
|
|
86 |
SDL_OutOfMemory();
|
|
87 |
SDL_free(device);
|
|
88 |
return NULL;
|
|
89 |
}
|
|
90 |
|
|
91 |
gldata = (SDL_GLDriverData *) SDL_calloc(1, sizeof(SDL_GLDriverData));
|
|
92 |
if (gldata == NULL) {
|
|
93 |
SDL_OutOfMemory();
|
|
94 |
SDL_free(device);
|
|
95 |
return NULL;
|
|
96 |
}
|
|
97 |
device->gl_data = gldata;
|
|
98 |
|
|
99 |
device->driverdata = phdata;
|
|
100 |
|
|
101 |
phdata->egl_initialized = SDL_TRUE;
|
|
102 |
|
|
103 |
|
|
104 |
/* Setup amount of available displays and current display */
|
|
105 |
device->num_displays = 0;
|
|
106 |
|
|
107 |
/* Set device free function */
|
|
108 |
device->free = PSP_Destroy;
|
|
109 |
|
|
110 |
/* Setup all functions which we can handle */
|
|
111 |
device->VideoInit = PSP_VideoInit;
|
|
112 |
device->VideoQuit = PSP_VideoQuit;
|
|
113 |
device->GetDisplayModes = PSP_GetDisplayModes;
|
|
114 |
device->SetDisplayMode = PSP_SetDisplayMode;
|
|
115 |
device->CreateWindow = PSP_CreateWindow;
|
|
116 |
device->CreateWindowFrom = PSP_CreateWindowFrom;
|
|
117 |
device->SetWindowTitle = PSP_SetWindowTitle;
|
|
118 |
device->SetWindowIcon = PSP_SetWindowIcon;
|
|
119 |
device->SetWindowPosition = PSP_SetWindowPosition;
|
|
120 |
device->SetWindowSize = PSP_SetWindowSize;
|
|
121 |
device->ShowWindow = PSP_ShowWindow;
|
|
122 |
device->HideWindow = PSP_HideWindow;
|
|
123 |
device->RaiseWindow = PSP_RaiseWindow;
|
|
124 |
device->MaximizeWindow = PSP_MaximizeWindow;
|
|
125 |
device->MinimizeWindow = PSP_MinimizeWindow;
|
|
126 |
device->RestoreWindow = PSP_RestoreWindow;
|
|
127 |
device->SetWindowGrab = PSP_SetWindowGrab;
|
|
128 |
device->DestroyWindow = PSP_DestroyWindow;
|
|
129 |
device->GetWindowWMInfo = PSP_GetWindowWMInfo;
|
|
130 |
device->GL_LoadLibrary = PSP_GL_LoadLibrary;
|
|
131 |
device->GL_GetProcAddress = PSP_GL_GetProcAddress;
|
|
132 |
device->GL_UnloadLibrary = PSP_GL_UnloadLibrary;
|
|
133 |
device->GL_CreateContext = PSP_GL_CreateContext;
|
|
134 |
device->GL_MakeCurrent = PSP_GL_MakeCurrent;
|
|
135 |
device->GL_SetSwapInterval = PSP_GL_SetSwapInterval;
|
|
136 |
device->GL_GetSwapInterval = PSP_GL_GetSwapInterval;
|
|
137 |
device->GL_SwapWindow = PSP_GL_SwapWindow;
|
|
138 |
device->GL_DeleteContext = PSP_GL_DeleteContext;
|
|
139 |
device->SDL_HasScreenKeyboardSupport = PSP_SDL_HasScreenKeyboardSupport;
|
|
140 |
device->SDL_ShowScreenKeyboard = PSP_SDL_ShowScreenKeyboard;
|
|
141 |
device->SDL_HideScreenKeyboard = PSP_SDL_HideScreenKeyboard;
|
|
142 |
device->SDL_IsScreenKeyboardShown = PSP_SDL_IsScreenKeyboardShown;
|
|
143 |
|
|
144 |
device->PumpEvents = PSP_PumpEvents;
|
|
145 |
|
|
146 |
return device;
|
|
147 |
}
|
|
148 |
|
|
149 |
VideoBootStrap PSP_bootstrap = {
|
|
150 |
"PSP",
|
|
151 |
"PSP Video Driver",
|
|
152 |
PSP_Available,
|
|
153 |
PSP_Create
|
|
154 |
};
|
|
155 |
|
|
156 |
/*****************************************************************************/
|
|
157 |
/* SDL Video and Display initialization/handling functions */
|
|
158 |
/*****************************************************************************/
|
|
159 |
int
|
|
160 |
PSP_VideoInit(_THIS)
|
|
161 |
{
|
|
162 |
SDL_VideoDisplay display;
|
|
163 |
SDL_DisplayMode current_mode;
|
|
164 |
|
|
165 |
SDL_zero(current_mode);
|
|
166 |
|
|
167 |
current_mode.w = 480;
|
|
168 |
current_mode.h = 272;
|
|
169 |
|
|
170 |
current_mode.refresh_rate = 60;
|
|
171 |
// 32 bpp for default
|
|
172 |
// current_mode.format = SDL_PIXELFORMAT_RGBA8888;
|
|
173 |
current_mode.format = SDL_PIXELFORMAT_ABGR8888;
|
|
174 |
|
|
175 |
current_mode.driverdata = NULL;
|
|
176 |
|
|
177 |
SDL_zero(display);
|
|
178 |
display.desktop_mode = current_mode;
|
|
179 |
display.current_mode = current_mode;
|
|
180 |
display.driverdata = NULL;
|
|
181 |
|
|
182 |
SDL_AddVideoDisplay(&display);
|
|
183 |
|
|
184 |
return 1;
|
|
185 |
}
|
|
186 |
|
|
187 |
void
|
|
188 |
PSP_VideoQuit(_THIS)
|
|
189 |
{
|
|
190 |
|
|
191 |
}
|
|
192 |
|
|
193 |
void
|
|
194 |
PSP_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
|
|
195 |
{
|
|
196 |
|
|
197 |
}
|
|
198 |
|
|
199 |
int
|
|
200 |
PSP_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
|
201 |
{
|
|
202 |
return 0;
|
|
203 |
}
|
|
204 |
#define EGLCHK(stmt) \
|
|
205 |
do { \
|
|
206 |
EGLint err; \
|
|
207 |
\
|
|
208 |
stmt; \
|
|
209 |
err = eglGetError(); \
|
|
210 |
if (err != EGL_SUCCESS) { \
|
|
211 |
SDL_SetError("EGL error %d", err); \
|
|
212 |
return 0; \
|
|
213 |
} \
|
|
214 |
} while (0)
|
|
215 |
|
|
216 |
int
|
|
217 |
PSP_CreateWindow(_THIS, SDL_Window * window)
|
|
218 |
{
|
|
219 |
// SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
|
|
220 |
|
|
221 |
SDL_WindowData *wdata;
|
|
222 |
|
|
223 |
/* Allocate window internal data */
|
|
224 |
wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
|
|
225 |
if (wdata == NULL) {
|
|
226 |
SDL_OutOfMemory();
|
|
227 |
return -1;
|
|
228 |
}
|
|
229 |
|
|
230 |
/* Setup driver data for this window */
|
|
231 |
window->driverdata = wdata;
|
|
232 |
|
|
233 |
|
|
234 |
/* Window has been successfully created */
|
|
235 |
return 0;
|
|
236 |
}
|
|
237 |
|
|
238 |
int
|
|
239 |
PSP_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
|
|
240 |
{
|
|
241 |
return -1;
|
|
242 |
}
|
|
243 |
|
|
244 |
void
|
|
245 |
PSP_SetWindowTitle(_THIS, SDL_Window * window)
|
|
246 |
{
|
|
247 |
}
|
|
248 |
void
|
|
249 |
PSP_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
|
|
250 |
{
|
|
251 |
}
|
|
252 |
void
|
|
253 |
PSP_SetWindowPosition(_THIS, SDL_Window * window)
|
|
254 |
{
|
|
255 |
}
|
|
256 |
void
|
|
257 |
PSP_SetWindowSize(_THIS, SDL_Window * window)
|
|
258 |
{
|
|
259 |
}
|
|
260 |
void
|
|
261 |
PSP_ShowWindow(_THIS, SDL_Window * window)
|
|
262 |
{
|
|
263 |
}
|
|
264 |
void
|
|
265 |
PSP_HideWindow(_THIS, SDL_Window * window)
|
|
266 |
{
|
|
267 |
}
|
|
268 |
void
|
|
269 |
PSP_RaiseWindow(_THIS, SDL_Window * window)
|
|
270 |
{
|
|
271 |
}
|
|
272 |
void
|
|
273 |
PSP_MaximizeWindow(_THIS, SDL_Window * window)
|
|
274 |
{
|
|
275 |
}
|
|
276 |
void
|
|
277 |
PSP_MinimizeWindow(_THIS, SDL_Window * window)
|
|
278 |
{
|
|
279 |
}
|
|
280 |
void
|
|
281 |
PSP_RestoreWindow(_THIS, SDL_Window * window)
|
|
282 |
{
|
|
283 |
}
|
|
284 |
void
|
|
285 |
PSP_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
|
286 |
{
|
|
287 |
|
|
288 |
}
|
|
289 |
void
|
|
290 |
PSP_DestroyWindow(_THIS, SDL_Window * window)
|
|
291 |
{
|
|
292 |
|
|
293 |
// eglTerminate(_this->gl_data->display);
|
|
294 |
}
|
|
295 |
|
|
296 |
/*****************************************************************************/
|
|
297 |
/* SDL Window Manager function */
|
|
298 |
/*****************************************************************************/
|
|
299 |
SDL_bool
|
|
300 |
PSP_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
|
|
301 |
{
|
|
302 |
if (info->version.major <= SDL_MAJOR_VERSION) {
|
|
303 |
return SDL_TRUE;
|
|
304 |
} else {
|
|
305 |
SDL_SetError("application not compiled with SDL %d.%d\n",
|
|
306 |
SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
|
|
307 |
return SDL_FALSE;
|
|
308 |
}
|
|
309 |
|
|
310 |
/* Failed to get window manager information */
|
|
311 |
return SDL_FALSE;
|
|
312 |
}
|
|
313 |
|
|
314 |
|
|
315 |
/* TO Write Me*/
|
|
316 |
SDL_bool PSP_SDL_HasScreenKeyboardSupport(_THIS)
|
|
317 |
{
|
|
318 |
return SDL_TRUE;
|
|
319 |
}
|
|
320 |
void PSP_SDL_ShowScreenKeyboard(_THIS, SDL_Window *window)
|
|
321 |
{
|
|
322 |
}
|
|
323 |
void PSP_SDL_HideScreenKeyboard(_THIS, SDL_Window *window)
|
|
324 |
{
|
|
325 |
}
|
|
326 |
SDL_bool PSP_SDL_IsScreenKeyboardShown(_THIS, SDL_Window *window)
|
|
327 |
{
|
|
328 |
return SDL_FALSE;
|
|
329 |
}
|
|
330 |
|
|
331 |
|
|
332 |
#endif /* SDL_VIDEO_DRIVER_PSP */
|
|
333 |
|
|
334 |
/* vi: set ts=4 sw=4 expandtab: */
|