SDL_pspvideo.c
Go to the documentation of this file.
/*
Simple DirectMedia Layer
Copyright (C) 1997-2018 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);
SDL_free(phdata);
return NULL;
}
device->gl_data = gldata;
device->driverdata = phdata;
phdata->egl_initialized = SDL_TRUE;
/* Setup amount of available displays */
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->CreateSDLWindow = PSP_CreateWindow;
device->CreateSDLWindowFrom = 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;
#if 0
device->GetWindowWMInfo = PSP_GetWindowWMInfo;
#endif
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 SDL_Unsupported();
}
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 */
/*****************************************************************************/
#if 0
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",
SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
return SDL_FALSE;
}
/* Failed to get window manager information */
return SDL_FALSE;
}
#endif
/* 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:227
PSP_SetDisplayMode
int PSP_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
SDL_TRUE
Definition: SDL_stdinc.h:142
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:294
SDL_VideoDevice::free
void(* free)(_THIS)
Definition: SDL_sysvideo.h:390
SDL_FALSE
Definition: SDL_stdinc.h:141
SDL_Surface
A collection of pixels used in software blitting.
Definition: SDL_surface.h:69
SDL_VideoDevice::driverdata
void * driverdata
Definition: SDL_sysvideo.h:377
SDL_events.h
SDL_VideoDevice::GL_SetSwapInterval
int(* GL_SetSwapInterval)(_THIS, int interval)
Definition: SDL_sysvideo.h:260
SDL_VideoDevice::ShowWindow
void(* ShowWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:222
SDL_DisplayMode
The structure that defines a display mode.
Definition: SDL_video.h:53
SDL_SysWMinfo::version
SDL_version version
Definition: SDL_syswm.h:196
SDL_version::major
Uint8 major
Definition: SDL_version.h:53
SDL_VideoDevice::SetWindowSize
void(* SetWindowSize)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:215
SDL_DisplayMode::refresh_rate
int refresh_rate
Definition: SDL_video.h:58
data
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
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_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:606
SDL_VideoDevice::GL_LoadLibrary
int(* GL_LoadLibrary)(_THIS, const char *path)
Definition: SDL_sysvideo.h:254
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:378
SDL_VideoDevice::SetDisplayMode
int(* SetDisplayMode)(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
Definition: SDL_sysvideo.h:204
SDL_WindowData
Definition: SDL_androidwindow.h:35
PSP_CreateWindow
int PSP_CreateWindow(_THIS, SDL_Window *window)
SDL_VideoDevice::HideWindow
void(* HideWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:223
device
static SDL_AudioDeviceID device
Definition: loopwave.c:37
PSP_PumpEvents
void PSP_PumpEvents(_THIS)
SDL_VideoDevice::RaiseWindow
void(* RaiseWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:224
SDL_VideoDevice::GetWindowWMInfo
SDL_bool(* GetWindowWMInfo)(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
Definition: SDL_sysvideo.h:247
SDL_VideoDevice::GL_CreateContext
SDL_GLContext(* GL_CreateContext)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:257
SDL_pspgl_c.h
SDL_SysWMinfo
Definition: SDL_syswm.h:194
PSP_HasScreenKeyboardSupport
SDL_bool PSP_HasScreenKeyboardSupport(_THIS)
PSP_SetWindowTitle
void PSP_SetWindowTitle(_THIS, SDL_Window *window)
SDL_PIXELFORMAT_ABGR8888
Definition: SDL_pixels.h:254
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:258
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
SDL_pspvideo.h
SDL_DisplayMode::driverdata
void * driverdata
Definition: SDL_video.h:59
VideoBootStrap
Definition: SDL_sysvideo.h:393
PSP_ShowScreenKeyboard
void PSP_ShowScreenKeyboard(_THIS, SDL_Window *window)
SDL_VideoDevice::num_displays
int num_displays
Definition: SDL_sysvideo.h:311
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:132
mode
GLenum mode
Definition: SDL_opengl_glext.h:1122
SDL_VideoDevice::DestroyWindow
void(* DestroyWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:234
SDL_zero
#define SDL_zero(x)
Definition: SDL_stdinc.h:416
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:213
PSP_SetWindowPosition
void PSP_SetWindowPosition(_THIS, SDL_Window *window)
SDL_VideoDevice::HasScreenKeyboardSupport
SDL_bool(* HasScreenKeyboardSupport)(_THIS)
Definition: SDL_sysvideo.h:291
PSP_bootstrap
VideoBootStrap PSP_bootstrap
SDL_VideoDisplay
Definition: SDL_sysvideo.h:125
PSP_SetWindowIcon
void PSP_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon)
SDL_VideoDevice::GL_UnloadLibrary
void(* GL_UnloadLibrary)(_THIS)
Definition: SDL_sysvideo.h:256
PSP_GL_SetSwapInterval
int PSP_GL_SetSwapInterval(_THIS, int interval)
SDL_VideoDevice::GetDisplayModes
void(* GetDisplayModes)(_THIS, SDL_VideoDisplay *display)
Definition: SDL_sysvideo.h:196
NULL
#define NULL
Definition: begin_code.h:164
SDL_VideoDevice::CreateSDLWindow
int(* CreateSDLWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:210
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:139
SDL_VideoDisplay::desktop_mode
SDL_DisplayMode desktop_mode
Definition: SDL_sysvideo.h:131
SDL_VideoDevice::VideoQuit
void(* VideoQuit)(_THIS)
Definition: SDL_sysvideo.h:166
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
SDL_loadso.h
PSP_CreateWindowFrom
int PSP_CreateWindowFrom(_THIS, SDL_Window *window, const void *data)
SDL_GLDriverData
Definition: SDL_pspgl_c.h:32
SDL_calloc
#define SDL_calloc
Definition: SDL_dynapi_overrides.h:375
window
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
SDL_VideoDevice::SetWindowPosition
void(* SetWindowPosition)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:214
SDL_VideoDevice::GL_SwapWindow
int(* GL_SwapWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:262
PSP_GL_SwapWindow
int PSP_GL_SwapWindow(_THIS, SDL_Window *window)
SDL_VideoDevice::ShowScreenKeyboard
void(* ShowScreenKeyboard)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:292
PSP_GetDisplayModes
void PSP_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
PSP_RaiseWindow
void PSP_RaiseWindow(_THIS, SDL_Window *window)
SDL_Window
The type used to identify a window.
Definition: SDL_sysvideo.h:73
SDL_VideoDevice::MinimizeWindow
void(* MinimizeWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:226
PSP_GL_GetProcAddress
void * PSP_GL_GetProcAddress(_THIS, const char *proc)
SDL_VideoData::egl_initialized
SDL_bool egl_initialized
Definition: SDL_pandora.h:32
SDL_VideoDevice
Definition: SDL_sysvideo.h:147
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:160
SDL_VideoDevice::CreateSDLWindowFrom
int(* CreateSDLWindowFrom)(_THIS, SDL_Window *window, const void *data)
Definition: SDL_sysvideo.h:211
SDL_version.h
SDL_Window::driverdata
void * driverdata
Definition: SDL_sysvideo.h:111
SDL_VideoDevice::GL_DeleteContext
void(* GL_DeleteContext)(_THIS, SDL_GLContext context)
Definition: SDL_sysvideo.h:263
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:212
SDL_VideoDevice::GL_GetSwapInterval
int(* GL_GetSwapInterval)(_THIS)
Definition: SDL_sysvideo.h:261
SDL_VideoDevice::MaximizeWindow
void(* MaximizeWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:225
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:233
SDL_syswm.h
SDL_Unsupported
#define SDL_Unsupported()
Definition: SDL_error.h:53
SDL_VideoDevice::GL_GetProcAddress
void *(* GL_GetProcAddress)(_THIS, const char *proc)
Definition: SDL_sysvideo.h:255
SDL_VideoDisplay::driverdata
void * driverdata
Definition: SDL_sysvideo.h:138
SDL_VideoDevice::PumpEvents
void(* PumpEvents)(_THIS)
Definition: SDL_sysvideo.h:280
SDL_VideoDevice::HideScreenKeyboard
void(* HideScreenKeyboard)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:293