SDL  2.0
SDL_pspvideo.c
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2019 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 {
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 */
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) {
88  return NULL;
89  }
90 
91  gldata = (SDL_GLDriverData *) SDL_calloc(1, sizeof(SDL_GLDriverData));
92  if (gldata == NULL) {
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;
114  device->GetDisplayModes = PSP_GetDisplayModes;
115  device->SetDisplayMode = PSP_SetDisplayMode;
116  device->CreateSDLWindow = PSP_CreateWindow;
117  device->CreateSDLWindowFrom = PSP_CreateWindowFrom;
118  device->SetWindowTitle = PSP_SetWindowTitle;
119  device->SetWindowIcon = PSP_SetWindowIcon;
120  device->SetWindowPosition = PSP_SetWindowPosition;
121  device->SetWindowSize = PSP_SetWindowSize;
122  device->ShowWindow = PSP_ShowWindow;
123  device->HideWindow = PSP_HideWindow;
124  device->RaiseWindow = PSP_RaiseWindow;
125  device->MaximizeWindow = PSP_MaximizeWindow;
126  device->MinimizeWindow = PSP_MinimizeWindow;
127  device->RestoreWindow = PSP_RestoreWindow;
128  device->SetWindowGrab = PSP_SetWindowGrab;
129  device->DestroyWindow = PSP_DestroyWindow;
130 #if 0
131  device->GetWindowWMInfo = PSP_GetWindowWMInfo;
132 #endif
133  device->GL_LoadLibrary = PSP_GL_LoadLibrary;
134  device->GL_GetProcAddress = PSP_GL_GetProcAddress;
135  device->GL_UnloadLibrary = PSP_GL_UnloadLibrary;
136  device->GL_CreateContext = PSP_GL_CreateContext;
137  device->GL_MakeCurrent = PSP_GL_MakeCurrent;
138  device->GL_SetSwapInterval = PSP_GL_SetSwapInterval;
139  device->GL_GetSwapInterval = PSP_GL_GetSwapInterval;
140  device->GL_SwapWindow = PSP_GL_SwapWindow;
141  device->GL_DeleteContext = PSP_GL_DeleteContext;
142  device->HasScreenKeyboardSupport = PSP_HasScreenKeyboardSupport;
143  device->ShowScreenKeyboard = PSP_ShowScreenKeyboard;
144  device->HideScreenKeyboard = PSP_HideScreenKeyboard;
145  device->IsScreenKeyboardShown = PSP_IsScreenKeyboardShown;
146 
147  device->PumpEvents = PSP_PumpEvents;
148 
149  return device;
150 }
151 
153  "PSP",
154  "PSP Video Driver",
155  PSP_Available,
156  PSP_Create
157 };
158 
159 /*****************************************************************************/
160 /* SDL Video and Display initialization/handling functions */
161 /*****************************************************************************/
162 int
164 {
165  SDL_VideoDisplay display;
166  SDL_DisplayMode current_mode;
167 
168  SDL_zero(current_mode);
169 
170  current_mode.w = 480;
171  current_mode.h = 272;
172 
173  current_mode.refresh_rate = 60;
174  /* 32 bpp for default */
175  current_mode.format = SDL_PIXELFORMAT_ABGR8888;
176 
177  current_mode.driverdata = NULL;
178 
179  SDL_zero(display);
180  display.desktop_mode = current_mode;
181  display.current_mode = current_mode;
182  display.driverdata = NULL;
183 
184  SDL_AddVideoDisplay(&display);
185 
186  return 1;
187 }
188 
189 void
191 {
192 
193 }
194 
195 void
197 {
198 
199 }
200 
201 int
203 {
204  return 0;
205 }
206 #define EGLCHK(stmt) \
207  do { \
208  EGLint err; \
209  \
210  stmt; \
211  err = eglGetError(); \
212  if (err != EGL_SUCCESS) { \
213  SDL_SetError("EGL error %d", err); \
214  return 0; \
215  } \
216  } while (0)
217 
218 int
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  return SDL_OutOfMemory();
227  }
228 
229  /* Setup driver data for this window */
230  window->driverdata = wdata;
231 
232 
233  /* Window has been successfully created */
234  return 0;
235 }
236 
237 int
239 {
240  return SDL_Unsupported();
241 }
242 
243 void
245 {
246 }
247 void
249 {
250 }
251 void
253 {
254 }
255 void
257 {
258 }
259 void
261 {
262 }
263 void
265 {
266 }
267 void
269 {
270 }
271 void
273 {
274 }
275 void
277 {
278 }
279 void
281 {
282 }
283 void
285 {
286 
287 }
288 void
290 {
291 }
292 
293 /*****************************************************************************/
294 /* SDL Window Manager function */
295 /*****************************************************************************/
296 #if 0
297 SDL_bool
299 {
300  if (info->version.major <= SDL_MAJOR_VERSION) {
301  return SDL_TRUE;
302  } else {
303  SDL_SetError("Application not compiled with SDL %d.%d",
305  return SDL_FALSE;
306  }
307 
308  /* Failed to get window manager information */
309  return SDL_FALSE;
310 }
311 #endif
312 
313 
314 /* TO Write Me */
316 {
317  return SDL_FALSE;
318 }
320 {
321 }
323 {
324 }
326 {
327  return SDL_FALSE;
328 }
329 
330 
331 #endif /* SDL_VIDEO_DRIVER_PSP */
332 
333 /* vi: set ts=4 sw=4 expandtab: */
SDL_zero
#define SDL_zero(x)
Definition: SDL_stdinc.h:416
PSP_GL_DeleteContext
void PSP_GL_DeleteContext(_THIS, SDL_GLContext context)
SDL_DisplayMode::format
Uint32 format
Definition: SDL_video.h:55
SDL_events.h
PSP_GL_CreateContext
SDL_GLContext PSP_GL_CreateContext(_THIS, SDL_Window *window)
SDL_Surface
A collection of pixels used in software blitting.
Definition: SDL_surface.h:70
PSP_SetWindowTitle
void PSP_SetWindowTitle(_THIS, SDL_Window *window)
PSP_SetWindowSize
void PSP_SetWindowSize(_THIS, SDL_Window *window)
NULL
#define NULL
Definition: begin_code.h:167
PSP_GL_GetProcAddress
void * PSP_GL_GetProcAddress(_THIS, const char *proc)
mode
GLenum mode
Definition: SDL_opengl_glext.h:1122
SDL_SysWMinfo
Definition: SDL_syswm.h:197
SDL_WindowData
Definition: SDL_androidwindow.h:38
PSP_GL_SetSwapInterval
int PSP_GL_SetSwapInterval(_THIS, int interval)
SDL_pspevents_c.h
PSP_ShowScreenKeyboard
void PSP_ShowScreenKeyboard(_THIS, SDL_Window *window)
PSP_SetWindowPosition
void PSP_SetWindowPosition(_THIS, SDL_Window *window)
PSP_RaiseWindow
void PSP_RaiseWindow(_THIS, SDL_Window *window)
PSP_GetWindowWMInfo
SDL_bool PSP_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
PSP_GL_MakeCurrent
int PSP_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
SDL_VideoData::egl_initialized
SDL_bool egl_initialized
Definition: SDL_pandora.h:32
SDL_VideoDisplay::desktop_mode
SDL_DisplayMode desktop_mode
Definition: SDL_sysvideo.h:131
PSP_VideoInit
int PSP_VideoInit(_THIS)
PSP_IsScreenKeyboardShown
SDL_bool PSP_IsScreenKeyboardShown(_THIS, SDL_Window *window)
SDL_DisplayMode::h
int h
Definition: SDL_video.h:57
data
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1973
SDL_Window
The type used to identify a window.
Definition: SDL_sysvideo.h:73
SDL_DisplayMode
The structure that defines a display mode.
Definition: SDL_video.h:53
PSP_SetDisplayMode
int PSP_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
PSP_CreateWindowFrom
int PSP_CreateWindowFrom(_THIS, SDL_Window *window, const void *data)
PSP_GL_LoadLibrary
int PSP_GL_LoadLibrary(_THIS, const char *path)
PSP_SetWindowIcon
void PSP_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon)
PSP_GetDisplayModes
void PSP_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
PSP_MaximizeWindow
void PSP_MaximizeWindow(_THIS, SDL_Window *window)
PSP_HideScreenKeyboard
void PSP_HideScreenKeyboard(_THIS, SDL_Window *window)
SDL_MINOR_VERSION
#define SDL_MINOR_VERSION
Definition: SDL_version.h:61
window
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
PSP_GL_SwapWindow
int PSP_GL_SwapWindow(_THIS, SDL_Window *window)
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
PSP_ShowWindow
void PSP_ShowWindow(_THIS, SDL_Window *window)
PSP_HideWindow
void PSP_HideWindow(_THIS, SDL_Window *window)
SDL_DisplayMode::refresh_rate
int refresh_rate
Definition: SDL_video.h:58
SDL_FALSE
Definition: SDL_stdinc.h:163
PSP_PumpEvents
void PSP_PumpEvents(_THIS)
SDL_GLDriverData
Definition: SDL_pspgl_c.h:32
_THIS
#define _THIS
Definition: SDL_alsa_audio.h:31
PSP_DestroyWindow
void PSP_DestroyWindow(_THIS, SDL_Window *window)
SDL_DisplayMode::w
int w
Definition: SDL_video.h:56
PSP_VideoQuit
void PSP_VideoQuit(_THIS)
SDL_AddVideoDisplay
int SDL_AddVideoDisplay(const SDL_VideoDisplay *display)
Definition: SDL_video.c:603
PSP_bootstrap
VideoBootStrap PSP_bootstrap
SDL_VideoDisplay::driverdata
void * driverdata
Definition: SDL_sysvideo.h:139
SDL_VideoDevice
Definition: SDL_sysvideo.h:148
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
PSP_CreateWindow
int PSP_CreateWindow(_THIS, SDL_Window *window)
PSP_RestoreWindow
void PSP_RestoreWindow(_THIS, SDL_Window *window)
PSP_SetWindowGrab
void PSP_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
SDL_calloc
#define SDL_calloc
Definition: SDL_dynapi_overrides.h:375
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:161
SDL_SysWMinfo::version
SDL_version version
Definition: SDL_syswm.h:199
SDL_VideoDisplay
Definition: SDL_sysvideo.h:125
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
SDL_TRUE
Definition: SDL_stdinc.h:164
SDL_pspvideo.h
PSP_GL_GetSwapInterval
int PSP_GL_GetSwapInterval(_THIS)
PSP_GL_UnloadLibrary
void PSP_GL_UnloadLibrary(_THIS)
SDL_pspgl_c.h
SDL_DisplayMode::driverdata
void * driverdata
Definition: SDL_video.h:59
SDL_Unsupported
#define SDL_Unsupported()
Definition: SDL_error.h:53
SDL_version.h
SDL_VideoDisplay::current_mode
SDL_DisplayMode current_mode
Definition: SDL_sysvideo.h:132
SDL_version::major
Uint8 major
Definition: SDL_version.h:53
VideoBootStrap
Definition: SDL_sysvideo.h:397
SDL_MAJOR_VERSION
#define SDL_MAJOR_VERSION
Definition: SDL_version.h:60
device
static SDL_AudioDeviceID device
Definition: loopwave.c:37
SDL_PIXELFORMAT_ABGR8888
Definition: SDL_pixels.h:254
SDL_loadso.h
PSP_MinimizeWindow
void PSP_MinimizeWindow(_THIS, SDL_Window *window)
SDL_VideoData
Definition: SDL_androidvideo.h:36
SDL_syswm.h
PSP_HasScreenKeyboardSupport
SDL_bool PSP_HasScreenKeyboardSupport(_THIS)