2 Simple DirectMedia Layer
3 Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
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.
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:
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.
22 #include "../../SDL_internal.h"
24 #if SDL_VIDEO_DRIVER_PSP
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"
37 /* PSP declarations */
38 #include "SDL_pspvideo.h"
39 #include "SDL_pspevents_c.h"
40 #include "SDL_pspgl_c.h"
43 static SDL_bool PSP_initialized = SDL_FALSE;
52 PSP_Destroy(SDL_VideoDevice * device)
54 /* SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; */
56 if (device->driverdata != NULL) {
57 device->driverdata = NULL;
61 static SDL_VideoDevice *
64 SDL_VideoDevice *device;
65 SDL_VideoData *phdata;
66 SDL_GLDriverData *gldata;
69 /* Check if PSP could be initialized */
70 status = PSP_Available();
72 /* PSP could not be used */
76 /* Initialize SDL_VideoDevice structure */
77 device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
83 /* Initialize internal PSP specific data */
84 phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
91 gldata = (SDL_GLDriverData *) SDL_calloc(1, sizeof(SDL_GLDriverData));
98 device->gl_data = gldata;
100 device->driverdata = phdata;
102 phdata->egl_initialized = SDL_TRUE;
105 /* Setup amount of available displays */
106 device->num_displays = 0;
108 /* Set device free function */
109 device->free = PSP_Destroy;
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;
131 device->GetWindowWMInfo = PSP_GetWindowWMInfo;
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;
147 device->PumpEvents = PSP_PumpEvents;
152 VideoBootStrap PSP_bootstrap = {
159 /*****************************************************************************/
160 /* SDL Video and Display initialization/handling functions */
161 /*****************************************************************************/
165 SDL_VideoDisplay display;
166 SDL_DisplayMode current_mode;
168 SDL_zero(current_mode);
170 current_mode.w = 480;
171 current_mode.h = 272;
173 current_mode.refresh_rate = 60;
174 /* 32 bpp for default */
175 current_mode.format = SDL_PIXELFORMAT_ABGR8888;
177 current_mode.driverdata = NULL;
180 display.desktop_mode = current_mode;
181 display.current_mode = current_mode;
182 display.driverdata = NULL;
184 SDL_AddVideoDisplay(&display);
196 PSP_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
202 PSP_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
206 #define EGLCHK(stmt) \
211 err = eglGetError(); \
212 if (err != EGL_SUCCESS) { \
213 SDL_SetError("EGL error %d", err); \
219 PSP_CreateWindow(_THIS, SDL_Window * window)
221 SDL_WindowData *wdata;
223 /* Allocate window internal data */
224 wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
226 return SDL_OutOfMemory();
229 /* Setup driver data for this window */
230 window->driverdata = wdata;
233 /* Window has been successfully created */
238 PSP_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
240 return SDL_Unsupported();
244 PSP_SetWindowTitle(_THIS, SDL_Window * window)
248 PSP_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
252 PSP_SetWindowPosition(_THIS, SDL_Window * window)
256 PSP_SetWindowSize(_THIS, SDL_Window * window)
260 PSP_ShowWindow(_THIS, SDL_Window * window)
264 PSP_HideWindow(_THIS, SDL_Window * window)
268 PSP_RaiseWindow(_THIS, SDL_Window * window)
272 PSP_MaximizeWindow(_THIS, SDL_Window * window)
276 PSP_MinimizeWindow(_THIS, SDL_Window * window)
280 PSP_RestoreWindow(_THIS, SDL_Window * window)
284 PSP_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
289 PSP_DestroyWindow(_THIS, SDL_Window * window)
293 /*****************************************************************************/
294 /* SDL Window Manager function */
295 /*****************************************************************************/
298 PSP_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
300 if (info->version.major <= SDL_MAJOR_VERSION) {
303 SDL_SetError("Application not compiled with SDL %d.%d",
304 SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
308 /* Failed to get window manager information */
315 SDL_bool PSP_HasScreenKeyboardSupport(_THIS)
319 void PSP_ShowScreenKeyboard(_THIS, SDL_Window *window)
322 void PSP_HideScreenKeyboard(_THIS, SDL_Window *window)
325 SDL_bool PSP_IsScreenKeyboardShown(_THIS, SDL_Window *window)
331 #endif /* SDL_VIDEO_DRIVER_PSP */
333 /* vi: set ts=4 sw=4 expandtab: */