SDL_pspvideo.c
Go to the documentation of this file.
/*
Simple DirectMedia Layer
Copyright (C) 1997-2016 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_internal.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)
{
/* SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; */
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 PSP 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 PSP specific data */
phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
if (phdata == NULL) {
SDL_OutOfMemory();
SDL_free(device);
return NULL;
}
gldata = (SDL_GLDriverData *) SDL_calloc(1, sizeof(SDL_GLDriverData));
if (gldata == NULL) {
SDL_OutOfMemory();
SDL_free(device);
return NULL;
}
device->gl_data = gldata;
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;
device->HasScreenKeyboardSupport = PSP_HasScreenKeyboardSupport;
device->ShowScreenKeyboard = PSP_ShowScreenKeyboard;
device->HideScreenKeyboard = PSP_HideScreenKeyboard;
device->IsScreenKeyboardShown = PSP_IsScreenKeyboardShown;
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);
current_mode.w = 480;
current_mode.h = 272;
current_mode.refresh_rate = 60;
/* 32 bpp for default */
current_mode.format = SDL_PIXELFORMAT_ABGR8888;
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;
}
#define EGLCHK(stmt) \
do { \
EGLint err; \
\
stmt; \
err = eglGetError(); \
if (err != EGL_SUCCESS) { \
SDL_SetError("EGL error %d", err); \
return 0; \
} \
} while (0)
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) {
return SDL_OutOfMemory();
}
/* 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 */
SDL_bool PSP_HasScreenKeyboardSupport(_THIS)
{
return SDL_FALSE;
}
void PSP_ShowScreenKeyboard(_THIS, SDL_Window *window)
{
}
void PSP_HideScreenKeyboard(_THIS, SDL_Window *window)
{
}
SDL_bool PSP_IsScreenKeyboardShown(_THIS, SDL_Window *window)
{
return SDL_FALSE;
}
#endif /* SDL_VIDEO_DRIVER_PSP */
/* vi: set ts=4 sw=4 expandtab: */
SDL_MINOR_VERSION
#define SDL_MINOR_VERSION
Definition: SDL_version.h:61
SDL_pspevents_c.h
SDL_VideoDevice::RestoreWindow
void(* RestoreWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:208
PSP_SetDisplayMode
int PSP_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
PSP_GL_UnloadLibrary
void PSP_GL_UnloadLibrary(_THIS)
SDL_DisplayMode::w
int w
Definition: SDL_video.h:56
PSP_GL_CreateContext
SDL_GLContext PSP_GL_CreateContext(_THIS, SDL_Window *window)
SDL_MAJOR_VERSION
#define SDL_MAJOR_VERSION
Definition: SDL_version.h:60
SDL_VideoDevice::IsScreenKeyboardShown
SDL_bool(* IsScreenKeyboardShown)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:263
SDL_VideoDevice::CreateWindowFrom
int(* CreateWindowFrom)(_THIS, SDL_Window *window, const void *data)
Definition: SDL_sysvideo.h:196
window
SDL_Window * window
Definition: testautomation_render.c:26
SDL_VideoDevice::free
void(* free)(_THIS)
Definition: SDL_sysvideo.h:345
SDL_Surface
A collection of pixels used in software blitting.
Definition: SDL_surface.h:69
SDL_VideoDevice::driverdata
void * driverdata
Definition: SDL_sysvideo.h:332
SDL_events.h
SDL_VideoDevice::GL_SetSwapInterval
int(* GL_SetSwapInterval)(_THIS, int interval)
Definition: SDL_sysvideo.h:240
data
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1967
SDL_VideoDevice::ShowWindow
void(* ShowWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:203
SDL_DisplayMode
The structure that defines a display mode.
Definition: SDL_video.h:53
SDL_SysWMinfo::version
SDL_version version
Definition: SDL_syswm.h:183
SDL_version::major
Uint8 major
Definition: SDL_version.h:53
SDL_VideoDevice::SetWindowSize
void(* SetWindowSize)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:200
SDL_DisplayMode::refresh_rate
int refresh_rate
Definition: SDL_video.h:58
SDL_VideoDevice::GL_SwapWindow
void(* GL_SwapWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:242
PSP_DestroyWindow
void PSP_DestroyWindow(_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)
PSP_GL_SwapWindow
void PSP_GL_SwapWindow(_THIS, SDL_Window *window)
PSP_MinimizeWindow
void PSP_MinimizeWindow(_THIS, SDL_Window *window)
PSP_VideoQuit
void PSP_VideoQuit(_THIS)
SDL_AddVideoDisplay
int SDL_AddVideoDisplay(const SDL_VideoDisplay *display)
Definition: SDL_video.c:593
SDL_VideoDevice::GL_LoadLibrary
int(* GL_LoadLibrary)(_THIS, const char *path)
Definition: SDL_sysvideo.h:234
PSP_GL_MakeCurrent
int PSP_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
PSP_GL_GetSwapInterval
int PSP_GL_GetSwapInterval(_THIS)
SDL_VideoDevice::gl_data
struct SDL_GLDriverData * gl_data
Definition: SDL_sysvideo.h:333
SDL_VideoDevice::SetDisplayMode
int(* SetDisplayMode)(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
Definition: SDL_sysvideo.h:189
SDL_WindowData
Definition: SDL_androidwindow.h:34
PSP_CreateWindow
int PSP_CreateWindow(_THIS, SDL_Window *window)
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:126
SDL_VideoDevice::HideWindow
void(* HideWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:204
PSP_PumpEvents
void PSP_PumpEvents(_THIS)
SDL_VideoDevice::RaiseWindow
void(* RaiseWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:205
SDL_calloc
void * SDL_calloc(size_t nmemb, size_t size)
SDL_VideoDevice::GetWindowWMInfo
SDL_bool(* GetWindowWMInfo)(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
Definition: SDL_sysvideo.h:227
SDL_VideoDevice::GL_CreateContext
SDL_GLContext(* GL_CreateContext)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:237
SDL_pspgl_c.h
SDL_SysWMinfo
Definition: SDL_syswm.h:181
PSP_HasScreenKeyboardSupport
SDL_bool PSP_HasScreenKeyboardSupport(_THIS)
PSP_SetWindowTitle
void PSP_SetWindowTitle(_THIS, SDL_Window *window)
SDL_PIXELFORMAT_ABGR8888
Definition: SDL_pixels.h:253
PSP_SetWindowSize
void PSP_SetWindowSize(_THIS, SDL_Window *window)
PSP_GL_DeleteContext
void PSP_GL_DeleteContext(_THIS, SDL_GLContext context)
_THIS
#define _THIS
Definition: SDL_alsa_audio.h:31
SDL_VideoDevice::GL_MakeCurrent
int(* GL_MakeCurrent)(_THIS, SDL_Window *window, SDL_GLContext context)
Definition: SDL_sysvideo.h:238
SDL_free
void SDL_free(void *mem)
SDL_pspvideo.h
SDL_DisplayMode::driverdata
void * driverdata
Definition: SDL_video.h:59
VideoBootStrap
Definition: SDL_sysvideo.h:348
PSP_ShowScreenKeyboard
void PSP_ShowScreenKeyboard(_THIS, SDL_Window *window)
SDL_VideoDevice::num_displays
int num_displays
Definition: SDL_sysvideo.h:279
PSP_GL_LoadLibrary
int PSP_GL_LoadLibrary(_THIS, const char *path)
PSP_GetWindowWMInfo
SDL_bool PSP_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
SDL_VideoDisplay::current_mode
SDL_DisplayMode current_mode
Definition: SDL_sysvideo.h:127
mode
GLenum mode
Definition: SDL_opengl_glext.h:1122
SDL_VideoDevice::DestroyWindow
void(* DestroyWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:214
SDL_zero
#define SDL_zero(x)
Definition: SDL_stdinc.h:357
SDL_DisplayMode::h
int h
Definition: SDL_video.h:57
SDL_VideoDevice::SetWindowIcon
void(* SetWindowIcon)(_THIS, SDL_Window *window, SDL_Surface *icon)
Definition: SDL_sysvideo.h:198
SDL_TRUE
Definition: SDL_stdinc.h:129
PSP_SetWindowPosition
void PSP_SetWindowPosition(_THIS, SDL_Window *window)
SDL_VideoDevice::HasScreenKeyboardSupport
SDL_bool(* HasScreenKeyboardSupport)(_THIS)
Definition: SDL_sysvideo.h:260
SDL_VideoDisplay
Definition: SDL_sysvideo.h:120
PSP_SetWindowIcon
void PSP_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon)
SDL_VideoDevice::GL_UnloadLibrary
void(* GL_UnloadLibrary)(_THIS)
Definition: SDL_sysvideo.h:236
PSP_GL_SetSwapInterval
int PSP_GL_SetSwapInterval(_THIS, int interval)
SDL_VideoDevice::GetDisplayModes
void(* GetDisplayModes)(_THIS, SDL_VideoDisplay *display)
Definition: SDL_sysvideo.h:181
NULL
#define NULL
Definition: begin_code.h:143
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
SDL_VideoDisplay::desktop_mode
SDL_DisplayMode desktop_mode
Definition: SDL_sysvideo.h:126
SDL_VideoDevice::VideoQuit
void(* VideoQuit)(_THIS)
Definition: SDL_sysvideo.h:161
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:36
SDL_loadso.h
PSP_CreateWindowFrom
int PSP_CreateWindowFrom(_THIS, SDL_Window *window, const void *data)
SDL_GLDriverData
Definition: SDL_pspgl_c.h:32
SDL_VideoDevice::SetWindowPosition
void(* SetWindowPosition)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:199
SDL_VideoDevice::ShowScreenKeyboard
void(* ShowScreenKeyboard)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:261
PSP_GetDisplayModes
void PSP_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
PSP_RaiseWindow
void PSP_RaiseWindow(_THIS, SDL_Window *window)
SDL_VideoDevice::CreateWindow
int(* CreateWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:195
SDL_Window
The type used to identify a window.
Definition: SDL_sysvideo.h:71
SDL_VideoDevice::MinimizeWindow
void(* MinimizeWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:207
PSP_GL_GetProcAddress
void * PSP_GL_GetProcAddress(_THIS, const char *proc)
SDL_FALSE
Definition: SDL_stdinc.h:128
SDL_VideoData::egl_initialized
SDL_bool egl_initialized
Definition: SDL_pandora.h:32
SDL_VideoDevice
Definition: SDL_sysvideo.h:142
PSP_IsScreenKeyboardShown
SDL_bool PSP_IsScreenKeyboardShown(_THIS, SDL_Window *window)
SDL_VideoData
Definition: SDL_androidvideo.h:35
SDL_VideoDevice::VideoInit
int(* VideoInit)(_THIS)
Definition: SDL_sysvideo.h:155
SDL_version.h
SDL_Window::driverdata
void * driverdata
Definition: SDL_sysvideo.h:106
SDL_VideoDevice::GL_DeleteContext
void(* GL_DeleteContext)(_THIS, SDL_GLContext context)
Definition: SDL_sysvideo.h:243
PSP_ShowWindow
void PSP_ShowWindow(_THIS, SDL_Window *window)
PSP_HideWindow
void PSP_HideWindow(_THIS, SDL_Window *window)
SDL_DisplayMode::format
Uint32 format
Definition: SDL_video.h:55
SDL_VideoDevice::SetWindowTitle
void(* SetWindowTitle)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:197
SDL_VideoDevice::GL_GetSwapInterval
int(* GL_GetSwapInterval)(_THIS)
Definition: SDL_sysvideo.h:241
SDL_VideoDevice::MaximizeWindow
void(* MaximizeWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:206
PSP_VideoInit
int PSP_VideoInit(_THIS)
PSP_MaximizeWindow
void PSP_MaximizeWindow(_THIS, SDL_Window *window)
PSP_HideScreenKeyboard
void PSP_HideScreenKeyboard(_THIS, SDL_Window *window)
SDL_VideoDevice::SetWindowGrab
void(* SetWindowGrab)(_THIS, SDL_Window *window, SDL_bool grabbed)
Definition: SDL_sysvideo.h:213
SDL_syswm.h
SDL_VideoDevice::GL_GetProcAddress
void *(* GL_GetProcAddress)(_THIS, const char *proc)
Definition: SDL_sysvideo.h:235
SDL_VideoDisplay::driverdata
void * driverdata
Definition: SDL_sysvideo.h:133
SDL_VideoDevice::PumpEvents
void(* PumpEvents)(_THIS)
Definition: SDL_sysvideo.h:249
SDL_VideoDevice::HideScreenKeyboard
void(* HideScreenKeyboard)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:262