SDL  2.0
SDL_pspvideo.c
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2016 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_internal.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 PSP 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) {
80  return NULL;
81  }
82 
83  /* Initialize internal PSP specific data */
84  phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
85  if (phdata == NULL) {
87  SDL_free(device);
88  return NULL;
89  }
90 
91  gldata = (SDL_GLDriverData *) SDL_calloc(1, sizeof(SDL_GLDriverData));
92  if (gldata == NULL) {
94  SDL_free(device);
95  SDL_free(phdata);
96  return NULL;
97  }
98  device->gl_data = gldata;
99 
100  device->driverdata = phdata;
101 
102  phdata->egl_initialized = SDL_TRUE;
103 
104 
105  /* Setup amount of available displays */
106  device->num_displays = 0;
107 
108  /* Set device free function */
109  device->free = PSP_Destroy;
110 
111  /* Setup all functions which we can handle */
112  device->VideoInit = PSP_VideoInit;
113  device->VideoQuit = PSP_VideoQuit;
116  device->CreateWindow = PSP_CreateWindow;
122  device->ShowWindow = PSP_ShowWindow;
123  device->HideWindow = PSP_HideWindow;
124  device->RaiseWindow = PSP_RaiseWindow;
144 
145  device->PumpEvents = PSP_PumpEvents;
146 
147  return device;
148 }
149 
150 VideoBootStrap PSP_bootstrap = {
151  "PSP",
152  "PSP Video Driver",
153  PSP_Available,
154  PSP_Create
155 };
156 
157 /*****************************************************************************/
158 /* SDL Video and Display initialization/handling functions */
159 /*****************************************************************************/
160 int
162 {
163  SDL_VideoDisplay display;
164  SDL_DisplayMode current_mode;
165 
166  SDL_zero(current_mode);
167 
168  current_mode.w = 480;
169  current_mode.h = 272;
170 
171  current_mode.refresh_rate = 60;
172  /* 32 bpp for default */
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
189 {
190 
191 }
192 
193 void
195 {
196 
197 }
198 
199 int
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
218 {
219  SDL_WindowData *wdata;
220 
221  /* Allocate window internal data */
222  wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
223  if (wdata == NULL) {
224  return SDL_OutOfMemory();
225  }
226 
227  /* Setup driver data for this window */
228  window->driverdata = wdata;
229 
230 
231  /* Window has been successfully created */
232  return 0;
233 }
234 
235 int
236 PSP_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
237 {
238  return SDL_Unsupported();
239 }
240 
241 void
243 {
244 }
245 void
247 {
248 }
249 void
251 {
252 }
253 void
255 {
256 }
257 void
259 {
260 }
261 void
263 {
264 }
265 void
267 {
268 }
269 void
271 {
272 }
273 void
275 {
276 }
277 void
279 {
280 }
281 void
282 PSP_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
283 {
284 
285 }
286 void
288 {
289 }
290 
291 /*****************************************************************************/
292 /* SDL Window Manager function */
293 /*****************************************************************************/
294 SDL_bool
295 PSP_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
296 {
297  if (info->version.major <= SDL_MAJOR_VERSION) {
298  return SDL_TRUE;
299  } else {
300  SDL_SetError("application not compiled with SDL %d.%d\n",
302  return SDL_FALSE;
303  }
304 
305  /* Failed to get window manager information */
306  return SDL_FALSE;
307 }
308 
309 
310 /* TO Write Me */
312 {
313  return SDL_FALSE;
314 }
316 {
317 }
319 {
320 }
322 {
323  return SDL_FALSE;
324 }
325 
326 
327 #endif /* SDL_VIDEO_DRIVER_PSP */
328 
329 /* vi: set ts=4 sw=4 expandtab: */
void(* GetDisplayModes)(_THIS, SDL_VideoDisplay *display)
Definition: SDL_sysvideo.h:189
void(* MinimizeWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:219
#define SDL_MINOR_VERSION
Definition: SDL_version.h:61
SDL_bool(* GetWindowWMInfo)(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
Definition: SDL_sysvideo.h:240
SDL_bool(* IsScreenKeyboardShown)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:276
void(* RaiseWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:217
int PSP_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
void PSP_GL_UnloadLibrary(_THIS)
void(* HideWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:216
int(* GL_MakeCurrent)(_THIS, SDL_Window *window, SDL_GLContext context)
Definition: SDL_sysvideo.h:251
SDL_GLContext PSP_GL_CreateContext(_THIS, SDL_Window *window)
#define SDL_MAJOR_VERSION
Definition: SDL_version.h:60
static SDL_Window * window
A collection of pixels used in software blitting.
Definition: SDL_surface.h:69
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1967
void(* SetWindowGrab)(_THIS, SDL_Window *window, SDL_bool grabbed)
Definition: SDL_sysvideo.h:226
The structure that defines a display mode.
Definition: SDL_video.h:53
SDL_version version
Definition: SDL_syswm.h:195
Uint8 major
Definition: SDL_version.h:53
void(* SetWindowIcon)(_THIS, SDL_Window *window, SDL_Surface *icon)
Definition: SDL_sysvideo.h:206
SDL_bool(* HasScreenKeyboardSupport)(_THIS)
Definition: SDL_sysvideo.h:273
void PSP_DestroyWindow(_THIS, SDL_Window *window)
int(* CreateWindowFrom)(_THIS, SDL_Window *window, const void *data)
Definition: SDL_sysvideo.h:204
void PSP_RestoreWindow(_THIS, SDL_Window *window)
void PSP_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
void PSP_GL_SwapWindow(_THIS, SDL_Window *window)
void PSP_MinimizeWindow(_THIS, SDL_Window *window)
void PSP_VideoQuit(_THIS)
void(* HideScreenKeyboard)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:275
int SDL_AddVideoDisplay(const SDL_VideoDisplay *display)
Definition: SDL_video.c:591
void(* free)(_THIS)
Definition: SDL_sysvideo.h:358
int PSP_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
int PSP_GL_GetSwapInterval(_THIS)
struct SDL_GLDriverData * gl_data
Definition: SDL_sysvideo.h:346
int PSP_CreateWindow(_THIS, SDL_Window *window)
int(* GL_SetSwapInterval)(_THIS, int interval)
Definition: SDL_sysvideo.h:253
int(* CreateWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:203
void(* GL_UnloadLibrary)(_THIS)
Definition: SDL_sysvideo.h:249
void PSP_PumpEvents(_THIS)
void * SDL_calloc(size_t nmemb, size_t size)
SDL_bool PSP_HasScreenKeyboardSupport(_THIS)
void PSP_SetWindowTitle(_THIS, SDL_Window *window)
void PSP_SetWindowSize(_THIS, SDL_Window *window)
int(* VideoInit)(_THIS)
Definition: SDL_sysvideo.h:158
void PSP_GL_DeleteContext(_THIS, SDL_GLContext context)
#define _THIS
void SDL_free(void *mem)
void * driverdata
Definition: SDL_video.h:59
void PSP_ShowScreenKeyboard(_THIS, SDL_Window *window)
int PSP_GL_LoadLibrary(_THIS, const char *path)
SDL_bool PSP_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
SDL_DisplayMode current_mode
Definition: SDL_sysvideo.h:130
GLenum mode
#define SDL_zero(x)
Definition: SDL_stdinc.h:359
void(* SetWindowPosition)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:207
void(* PumpEvents)(_THIS)
Definition: SDL_sysvideo.h:262
void PSP_SetWindowPosition(_THIS, SDL_Window *window)
void PSP_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon)
int PSP_GL_SetSwapInterval(_THIS, int interval)
int(* GL_GetSwapInterval)(_THIS)
Definition: SDL_sysvideo.h:254
#define NULL
Definition: begin_code.h:143
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
SDL_bool
Definition: SDL_stdinc.h:130
SDL_DisplayMode desktop_mode
Definition: SDL_sysvideo.h:129
void(* GL_DeleteContext)(_THIS, SDL_GLContext context)
Definition: SDL_sysvideo.h:256
void(* MaximizeWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:218
#define SDL_SetError
void(* DestroyWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:227
int PSP_CreateWindowFrom(_THIS, SDL_Window *window, const void *data)
void(* SetWindowSize)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:208
int(* SetDisplayMode)(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
Definition: SDL_sysvideo.h:197
void PSP_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
void PSP_RaiseWindow(_THIS, SDL_Window *window)
The type used to identify a window.
Definition: SDL_sysvideo.h:71
void * PSP_GL_GetProcAddress(_THIS, const char *proc)
SDL_GLContext(* GL_CreateContext)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:250
int(* GL_LoadLibrary)(_THIS, const char *path)
Definition: SDL_sysvideo.h:247
SDL_bool egl_initialized
Definition: SDL_pandora.h:32
void(* GL_SwapWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:255
void(* VideoQuit)(_THIS)
Definition: SDL_sysvideo.h:164
void(* ShowWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:215
SDL_bool PSP_IsScreenKeyboardShown(_THIS, SDL_Window *window)
void * driverdata
Definition: SDL_sysvideo.h:109
void(* SetWindowTitle)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:205
void PSP_ShowWindow(_THIS, SDL_Window *window)
void PSP_HideWindow(_THIS, SDL_Window *window)
Uint32 format
Definition: SDL_video.h:55
int PSP_VideoInit(_THIS)
void PSP_MaximizeWindow(_THIS, SDL_Window *window)
void PSP_HideScreenKeyboard(_THIS, SDL_Window *window)
void *(* GL_GetProcAddress)(_THIS, const char *proc)
Definition: SDL_sysvideo.h:248
#define SDL_Unsupported()
Definition: SDL_error.h:53
void(* ShowScreenKeyboard)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:274
void(* RestoreWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:220