Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
328 lines (274 loc) · 8.14 KB

SDL_pspvideo.c

File metadata and controls

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