SDL  2.0
SDL_pspvideo.c
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2020 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 
46 static void
47 PSP_Destroy(SDL_VideoDevice * device)
48 {
49 /* SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; */
50 
51  if (device->driverdata != NULL) {
52  device->driverdata = NULL;
53  }
54 }
55 
56 static SDL_VideoDevice *
57 PSP_Create()
58 {
60  SDL_VideoData *phdata;
61  SDL_GLDriverData *gldata;
62 
63  /* Initialize SDL_VideoDevice structure */
65  if (device == NULL) {
67  return NULL;
68  }
69 
70  /* Initialize internal PSP specific data */
71  phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
72  if (phdata == NULL) {
75  return NULL;
76  }
77 
78  gldata = (SDL_GLDriverData *) SDL_calloc(1, sizeof(SDL_GLDriverData));
79  if (gldata == NULL) {
82  SDL_free(phdata);
83  return NULL;
84  }
85  device->gl_data = gldata;
86 
87  device->driverdata = phdata;
88 
89  phdata->egl_initialized = SDL_TRUE;
90 
91 
92  /* Setup amount of available displays */
93  device->num_displays = 0;
94 
95  /* Set device free function */
96  device->free = PSP_Destroy;
97 
98  /* Setup all functions which we can handle */
99  device->VideoInit = PSP_VideoInit;
100  device->VideoQuit = PSP_VideoQuit;
101  device->GetDisplayModes = PSP_GetDisplayModes;
102  device->SetDisplayMode = PSP_SetDisplayMode;
103  device->CreateSDLWindow = PSP_CreateWindow;
104  device->CreateSDLWindowFrom = PSP_CreateWindowFrom;
105  device->SetWindowTitle = PSP_SetWindowTitle;
106  device->SetWindowIcon = PSP_SetWindowIcon;
107  device->SetWindowPosition = PSP_SetWindowPosition;
108  device->SetWindowSize = PSP_SetWindowSize;
109  device->ShowWindow = PSP_ShowWindow;
110  device->HideWindow = PSP_HideWindow;
111  device->RaiseWindow = PSP_RaiseWindow;
112  device->MaximizeWindow = PSP_MaximizeWindow;
113  device->MinimizeWindow = PSP_MinimizeWindow;
114  device->RestoreWindow = PSP_RestoreWindow;
115  device->SetWindowGrab = PSP_SetWindowGrab;
116  device->DestroyWindow = PSP_DestroyWindow;
117 #if 0
118  device->GetWindowWMInfo = PSP_GetWindowWMInfo;
119 #endif
120  device->GL_LoadLibrary = PSP_GL_LoadLibrary;
121  device->GL_GetProcAddress = PSP_GL_GetProcAddress;
122  device->GL_UnloadLibrary = PSP_GL_UnloadLibrary;
123  device->GL_CreateContext = PSP_GL_CreateContext;
124  device->GL_MakeCurrent = PSP_GL_MakeCurrent;
125  device->GL_SetSwapInterval = PSP_GL_SetSwapInterval;
126  device->GL_GetSwapInterval = PSP_GL_GetSwapInterval;
127  device->GL_SwapWindow = PSP_GL_SwapWindow;
128  device->GL_DeleteContext = PSP_GL_DeleteContext;
129  device->HasScreenKeyboardSupport = PSP_HasScreenKeyboardSupport;
130  device->ShowScreenKeyboard = PSP_ShowScreenKeyboard;
131  device->HideScreenKeyboard = PSP_HideScreenKeyboard;
132  device->IsScreenKeyboardShown = PSP_IsScreenKeyboardShown;
133 
134  device->PumpEvents = PSP_PumpEvents;
135 
136  return device;
137 }
138 
140  "PSP",
141  "PSP Video Driver",
142  PSP_Create
143 };
144 
145 /*****************************************************************************/
146 /* SDL Video and Display initialization/handling functions */
147 /*****************************************************************************/
148 int
150 {
151  SDL_VideoDisplay display;
152  SDL_DisplayMode current_mode;
153 
154  SDL_zero(current_mode);
155 
156  current_mode.w = 480;
157  current_mode.h = 272;
158 
159  current_mode.refresh_rate = 60;
160  /* 32 bpp for default */
161  current_mode.format = SDL_PIXELFORMAT_ABGR8888;
162 
163  current_mode.driverdata = NULL;
164 
165  SDL_zero(display);
166  display.desktop_mode = current_mode;
167  display.current_mode = current_mode;
168  display.driverdata = NULL;
169 
170  SDL_AddVideoDisplay(&display, SDL_FALSE);
171 
172  return 1;
173 }
174 
175 void
177 {
178 
179 }
180 
181 void
183 {
184 
185 }
186 
187 int
189 {
190  return 0;
191 }
192 #define EGLCHK(stmt) \
193  do { \
194  EGLint err; \
195  \
196  stmt; \
197  err = eglGetError(); \
198  if (err != EGL_SUCCESS) { \
199  SDL_SetError("EGL error %d", err); \
200  return 0; \
201  } \
202  } while (0)
203 
204 int
206 {
207  SDL_WindowData *wdata;
208 
209  /* Allocate window internal data */
210  wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
211  if (wdata == NULL) {
212  return SDL_OutOfMemory();
213  }
214 
215  /* Setup driver data for this window */
216  window->driverdata = wdata;
217 
218 
219  /* Window has been successfully created */
220  return 0;
221 }
222 
223 int
225 {
226  return SDL_Unsupported();
227 }
228 
229 void
231 {
232 }
233 void
235 {
236 }
237 void
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 }
274 void
276 {
277 }
278 
279 /*****************************************************************************/
280 /* SDL Window Manager function */
281 /*****************************************************************************/
282 #if 0
283 SDL_bool
285 {
286  if (info->version.major <= SDL_MAJOR_VERSION) {
287  return SDL_TRUE;
288  } else {
289  SDL_SetError("Application not compiled with SDL %d.%d",
291  return SDL_FALSE;
292  }
293 
294  /* Failed to get window manager information */
295  return SDL_FALSE;
296 }
297 #endif
298 
299 
300 /* TO Write Me */
302 {
303  return SDL_FALSE;
304 }
306 {
307 }
309 {
310 }
312 {
313  return SDL_FALSE;
314 }
315 
316 
317 #endif /* SDL_VIDEO_DRIVER_PSP */
318 
319 /* vi: set ts=4 sw=4 expandtab: */
#define _THIS
#define SDL_SetError
#define SDL_free
#define SDL_calloc
#define SDL_OutOfMemory()
Definition: SDL_error.h:88
#define SDL_Unsupported()
Definition: SDL_error.h:89
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
GLenum mode
@ SDL_PIXELFORMAT_ABGR8888
Definition: SDL_pixels.h:263
void PSP_PumpEvents(_THIS)
int PSP_GL_LoadLibrary(_THIS, const char *path)
SDL_GLContext PSP_GL_CreateContext(_THIS, SDL_Window *window)
int PSP_GL_SwapWindow(_THIS, SDL_Window *window)
void * PSP_GL_GetProcAddress(_THIS, const char *proc)
void PSP_GL_UnloadLibrary(_THIS)
int PSP_GL_GetSwapInterval(_THIS)
int PSP_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
int PSP_GL_SetSwapInterval(_THIS, int interval)
void PSP_HideWindow(_THIS, SDL_Window *window)
void PSP_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
int PSP_VideoInit(_THIS)
int PSP_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
int PSP_CreateWindowFrom(_THIS, SDL_Window *window, const void *data)
void PSP_RestoreWindow(_THIS, SDL_Window *window)
int PSP_CreateWindow(_THIS, SDL_Window *window)
SDL_bool PSP_IsScreenKeyboardShown(_THIS, SDL_Window *window)
void PSP_ShowWindow(_THIS, SDL_Window *window)
void PSP_SetWindowPosition(_THIS, SDL_Window *window)
void PSP_GL_DeleteContext(_THIS, SDL_GLContext context)
SDL_bool PSP_HasScreenKeyboardSupport(_THIS)
void PSP_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
void PSP_VideoQuit(_THIS)
void PSP_HideScreenKeyboard(_THIS, SDL_Window *window)
void PSP_MaximizeWindow(_THIS, SDL_Window *window)
void PSP_SetWindowTitle(_THIS, SDL_Window *window)
void PSP_ShowScreenKeyboard(_THIS, SDL_Window *window)
void PSP_RaiseWindow(_THIS, SDL_Window *window)
void PSP_MinimizeWindow(_THIS, SDL_Window *window)
void PSP_SetWindowSize(_THIS, SDL_Window *window)
void PSP_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon)
void PSP_DestroyWindow(_THIS, SDL_Window *window)
SDL_bool PSP_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
#define SDL_zero(x)
Definition: SDL_stdinc.h:426
SDL_bool
Definition: SDL_stdinc.h:168
@ SDL_TRUE
Definition: SDL_stdinc.h:170
@ SDL_FALSE
Definition: SDL_stdinc.h:169
int SDL_AddVideoDisplay(const SDL_VideoDisplay *display, SDL_bool send_event)
Definition: SDL_video.c:607
VideoBootStrap PSP_bootstrap
#define SDL_MINOR_VERSION
Definition: SDL_version.h:61
#define SDL_MAJOR_VERSION
Definition: SDL_version.h:60
#define NULL
Definition: begin_code.h:163
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
static SDL_AudioDeviceID device
Definition: loopwave.c:37
The structure that defines a display mode.
Definition: SDL_video.h:54
void * driverdata
Definition: SDL_video.h:59
Uint32 format
Definition: SDL_video.h:55
A collection of pixels used in software blitting.
Definition: SDL_surface.h:71
SDL_version version
Definition: SDL_syswm.h:218
SDL_bool egl_initialized
Definition: SDL_pandora.h:32
SDL_DisplayMode desktop_mode
Definition: SDL_sysvideo.h:132
SDL_DisplayMode current_mode
Definition: SDL_sysvideo.h:133
The type used to identify a window.
Definition: SDL_sysvideo.h:75
Uint8 major
Definition: SDL_version.h:53