Merge commit 'dec0d4ec4153bf9fc2b78ae6c2df45b6ea8dde7a' as 'external/sdl/SDL'
This commit is contained in:
276
external/sdl/SDL/src/video/psp/SDL_pspevents.c
vendored
Normal file
276
external/sdl/SDL/src/video/psp/SDL_pspevents.c
vendored
Normal file
@@ -0,0 +1,276 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 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"
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_PSP
|
||||
|
||||
/* Being a null driver, there's no event stream. We just define stubs for
|
||||
most of the API. */
|
||||
|
||||
#include "../../events/SDL_events_c.h"
|
||||
#include "../../events/SDL_keyboard_c.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "SDL_pspvideo.h"
|
||||
#include "SDL_pspevents_c.h"
|
||||
#include "../../thread/SDL_systhread.h"
|
||||
#include <psphprm.h>
|
||||
#include <pspthreadman.h>
|
||||
|
||||
#ifdef PSPIRKEYB
|
||||
#include <pspirkeyb.h>
|
||||
#include <pspirkeyb_rawkeys.h>
|
||||
|
||||
#define IRKBD_CONFIG_FILE NULL /* this will take ms0:/seplugins/pspirkeyb.ini */
|
||||
|
||||
static int irkbd_ready = 0;
|
||||
static SDL_Keycode keymap[256];
|
||||
#endif
|
||||
|
||||
static enum PspHprmKeys hprm = 0;
|
||||
static SDL_Semaphore *event_sem = NULL;
|
||||
static SDL_Thread *thread = NULL;
|
||||
static int running = 0;
|
||||
static struct
|
||||
{
|
||||
enum PspHprmKeys id;
|
||||
SDL_Keycode sym;
|
||||
} keymap_psp[] = {
|
||||
{ PSP_HPRM_PLAYPAUSE, SDLK_F10 },
|
||||
{ PSP_HPRM_FORWARD, SDLK_F11 },
|
||||
{ PSP_HPRM_BACK, SDLK_F12 },
|
||||
{ PSP_HPRM_VOL_UP, SDLK_F13 },
|
||||
{ PSP_HPRM_VOL_DOWN, SDLK_F14 },
|
||||
{ PSP_HPRM_HOLD, SDLK_F15 }
|
||||
};
|
||||
|
||||
int EventUpdate(void *data)
|
||||
{
|
||||
while (running) {
|
||||
SDL_WaitSemaphore(event_sem);
|
||||
sceHprmPeekCurrentKey((u32 *)&hprm);
|
||||
SDL_PostSemaphore(event_sem);
|
||||
/* Delay 1/60th of a second */
|
||||
sceKernelDelayThread(1000000 / 60);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PSP_PumpEvents(SDL_VideoDevice *_this)
|
||||
{
|
||||
int i;
|
||||
enum PspHprmKeys keys;
|
||||
enum PspHprmKeys changed;
|
||||
static enum PspHprmKeys old_keys = 0;
|
||||
|
||||
SDL_WaitSemaphore(event_sem);
|
||||
keys = hprm;
|
||||
SDL_PostSemaphore(event_sem);
|
||||
|
||||
/* HPRM Keyboard */
|
||||
changed = old_keys ^ keys;
|
||||
old_keys = keys;
|
||||
if (changed) {
|
||||
for (i = 0; i < sizeof(keymap_psp) / sizeof(keymap_psp[0]); i++) {
|
||||
if (changed & keymap_psp[i].id) {
|
||||
SDL_SendKeyboardKey(0, (keys & keymap_psp[i].id) ? SDL_PRESSED : SDL_RELEASED, SDL_GetScancodeFromKey(keymap_psp[i].sym));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PSPIRKEYB
|
||||
if (irkbd_ready) {
|
||||
unsigned char buffer[255];
|
||||
int i, length, count;
|
||||
SIrKeybScanCodeData *scanData;
|
||||
|
||||
if (pspIrKeybReadinput(buffer, &length) >= 0) {
|
||||
if ((length % sizeof(SIrKeybScanCodeData)) == 0) {
|
||||
count = length / sizeof(SIrKeybScanCodeData);
|
||||
for (i = 0; i < count; i++) {
|
||||
unsigned char raw, pressed;
|
||||
scanData = (SIrKeybScanCodeData *)buffer + i;
|
||||
raw = scanData->raw;
|
||||
pressed = scanData->pressed;
|
||||
sym.scancode = raw;
|
||||
sym.sym = keymap[raw];
|
||||
/* not tested */
|
||||
/* SDL_PrivateKeyboard(pressed?SDL_PRESSED:SDL_RELEASED, &sym); */
|
||||
SDL_SendKeyboardKey(0, (keys & keymap_psp[i].id) ? SDL_PRESSED : SDL_RELEASED, SDL_GetScancodeFromKey(keymap[raw]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
sceKernelDelayThread(0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void PSP_InitOSKeymap(SDL_VideoDevice *_this)
|
||||
{
|
||||
#ifdef PSPIRKEYB
|
||||
int i;
|
||||
for (i = 0; i < SDL_TABLESIZE(keymap); ++i) {
|
||||
keymap[i] = SDLK_UNKNOWN;
|
||||
}
|
||||
|
||||
keymap[KEY_ESC] = SDLK_ESCAPE;
|
||||
|
||||
keymap[KEY_F1] = SDLK_F1;
|
||||
keymap[KEY_F2] = SDLK_F2;
|
||||
keymap[KEY_F3] = SDLK_F3;
|
||||
keymap[KEY_F4] = SDLK_F4;
|
||||
keymap[KEY_F5] = SDLK_F5;
|
||||
keymap[KEY_F6] = SDLK_F6;
|
||||
keymap[KEY_F7] = SDLK_F7;
|
||||
keymap[KEY_F8] = SDLK_F8;
|
||||
keymap[KEY_F9] = SDLK_F9;
|
||||
keymap[KEY_F10] = SDLK_F10;
|
||||
keymap[KEY_F11] = SDLK_F11;
|
||||
keymap[KEY_F12] = SDLK_F12;
|
||||
keymap[KEY_F13] = SDLK_PRINT;
|
||||
keymap[KEY_F14] = SDLK_PAUSE;
|
||||
|
||||
keymap[KEY_GRAVE] = SDLK_BACKQUOTE;
|
||||
keymap[KEY_1] = SDLK_1;
|
||||
keymap[KEY_2] = SDLK_2;
|
||||
keymap[KEY_3] = SDLK_3;
|
||||
keymap[KEY_4] = SDLK_4;
|
||||
keymap[KEY_5] = SDLK_5;
|
||||
keymap[KEY_6] = SDLK_6;
|
||||
keymap[KEY_7] = SDLK_7;
|
||||
keymap[KEY_8] = SDLK_8;
|
||||
keymap[KEY_9] = SDLK_9;
|
||||
keymap[KEY_0] = SDLK_0;
|
||||
keymap[KEY_MINUS] = SDLK_MINUS;
|
||||
keymap[KEY_EQUAL] = SDLK_EQUALS;
|
||||
keymap[KEY_BACKSPACE] = SDLK_BACKSPACE;
|
||||
|
||||
keymap[KEY_TAB] = SDLK_TAB;
|
||||
keymap[KEY_Q] = SDLK_q;
|
||||
keymap[KEY_W] = SDLK_w;
|
||||
keymap[KEY_E] = SDLK_e;
|
||||
keymap[KEY_R] = SDLK_r;
|
||||
keymap[KEY_T] = SDLK_t;
|
||||
keymap[KEY_Y] = SDLK_y;
|
||||
keymap[KEY_U] = SDLK_u;
|
||||
keymap[KEY_I] = SDLK_i;
|
||||
keymap[KEY_O] = SDLK_o;
|
||||
keymap[KEY_P] = SDLK_p;
|
||||
keymap[KEY_LEFTBRACE] = SDLK_LEFTBRACKET;
|
||||
keymap[KEY_RIGHTBRACE] = SDLK_RIGHTBRACKET;
|
||||
keymap[KEY_ENTER] = SDLK_RETURN;
|
||||
|
||||
keymap[KEY_CAPSLOCK] = SDLK_CAPSLOCK;
|
||||
keymap[KEY_A] = SDLK_a;
|
||||
keymap[KEY_S] = SDLK_s;
|
||||
keymap[KEY_D] = SDLK_d;
|
||||
keymap[KEY_F] = SDLK_f;
|
||||
keymap[KEY_G] = SDLK_g;
|
||||
keymap[KEY_H] = SDLK_h;
|
||||
keymap[KEY_J] = SDLK_j;
|
||||
keymap[KEY_K] = SDLK_k;
|
||||
keymap[KEY_L] = SDLK_l;
|
||||
keymap[KEY_SEMICOLON] = SDLK_SEMICOLON;
|
||||
keymap[KEY_APOSTROPHE] = SDLK_QUOTE;
|
||||
keymap[KEY_BACKSLASH] = SDLK_BACKSLASH;
|
||||
|
||||
keymap[KEY_Z] = SDLK_z;
|
||||
keymap[KEY_X] = SDLK_x;
|
||||
keymap[KEY_C] = SDLK_c;
|
||||
keymap[KEY_V] = SDLK_v;
|
||||
keymap[KEY_B] = SDLK_b;
|
||||
keymap[KEY_N] = SDLK_n;
|
||||
keymap[KEY_M] = SDLK_m;
|
||||
keymap[KEY_COMMA] = SDLK_COMMA;
|
||||
keymap[KEY_DOT] = SDLK_PERIOD;
|
||||
keymap[KEY_SLASH] = SDLK_SLASH;
|
||||
|
||||
keymap[KEY_SPACE] = SDLK_SPACE;
|
||||
|
||||
keymap[KEY_UP] = SDLK_UP;
|
||||
keymap[KEY_DOWN] = SDLK_DOWN;
|
||||
keymap[KEY_LEFT] = SDLK_LEFT;
|
||||
keymap[KEY_RIGHT] = SDLK_RIGHT;
|
||||
|
||||
keymap[KEY_HOME] = SDLK_HOME;
|
||||
keymap[KEY_END] = SDLK_END;
|
||||
keymap[KEY_INSERT] = SDLK_INSERT;
|
||||
keymap[KEY_DELETE] = SDLK_DELETE;
|
||||
|
||||
keymap[KEY_NUMLOCK] = SDLK_NUMLOCK;
|
||||
keymap[KEY_LEFTMETA] = SDLK_LSUPER;
|
||||
|
||||
keymap[KEY_KPSLASH] = SDLK_KP_DIVIDE;
|
||||
keymap[KEY_KPASTERISK] = SDLK_KP_MULTIPLY;
|
||||
keymap[KEY_KPMINUS] = SDLK_KP_MINUS;
|
||||
keymap[KEY_KPPLUS] = SDLK_KP_PLUS;
|
||||
keymap[KEY_KPDOT] = SDLK_KP_PERIOD;
|
||||
keymap[KEY_KPEQUAL] = SDLK_KP_EQUALS;
|
||||
|
||||
keymap[KEY_LEFTCTRL] = SDLK_LCTRL;
|
||||
keymap[KEY_RIGHTCTRL] = SDLK_RCTRL;
|
||||
keymap[KEY_LEFTALT] = SDLK_LALT;
|
||||
keymap[KEY_RIGHTALT] = SDLK_RALT;
|
||||
keymap[KEY_LEFTSHIFT] = SDLK_LSHIFT;
|
||||
keymap[KEY_RIGHTSHIFT] = SDLK_RSHIFT;
|
||||
#endif
|
||||
}
|
||||
|
||||
int PSP_EventInit(SDL_VideoDevice *_this)
|
||||
{
|
||||
#ifdef PSPIRKEYB
|
||||
int outputmode = PSP_IRKBD_OUTPUT_MODE_SCANCODE;
|
||||
int ret = pspIrKeybInit(IRKBD_CONFIG_FILE, 0);
|
||||
if (ret == PSP_IRKBD_RESULT_OK) {
|
||||
pspIrKeybOutputMode(outputmode);
|
||||
irkbd_ready = 1;
|
||||
} else {
|
||||
irkbd_ready = 0;
|
||||
}
|
||||
#endif
|
||||
/* Start thread to read data */
|
||||
if ((event_sem = SDL_CreateSemaphore(1)) == NULL) {
|
||||
return SDL_SetError("Can't create input semaphore");
|
||||
}
|
||||
running = 1;
|
||||
if ((thread = SDL_CreateThreadInternal(EventUpdate, "PSPInputThread", 4096, NULL)) == NULL) {
|
||||
return SDL_SetError("Can't create input thread");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PSP_EventQuit(SDL_VideoDevice *_this)
|
||||
{
|
||||
running = 0;
|
||||
SDL_WaitThread(thread, NULL);
|
||||
SDL_DestroySemaphore(event_sem);
|
||||
#ifdef PSPIRKEYB
|
||||
if (irkbd_ready) {
|
||||
pspIrKeybFinish();
|
||||
irkbd_ready = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* end of SDL_pspevents.c ... */
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_PSP */
|
27
external/sdl/SDL/src/video/psp/SDL_pspevents_c.h
vendored
Normal file
27
external/sdl/SDL/src/video/psp/SDL_pspevents_c.h
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 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_pspvideo.h"
|
||||
|
||||
extern void PSP_InitOSKeymap(SDL_VideoDevice *_this);
|
||||
extern void PSP_PumpEvents(SDL_VideoDevice *_this);
|
||||
|
||||
/* end of SDL_pspevents_c.h ... */
|
190
external/sdl/SDL/src/video/psp/SDL_pspgl.c
vendored
Normal file
190
external/sdl/SDL/src/video/psp/SDL_pspgl.c
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 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"
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_PSP
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "SDL_pspvideo.h"
|
||||
#include "SDL_pspgl_c.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* SDL OpenGL/OpenGL ES functions */
|
||||
/*****************************************************************************/
|
||||
#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_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* pspgl doesn't provide this call, so stub it out since SDL requires it.
|
||||
#define GLSTUB(func,params) void func params {}
|
||||
|
||||
GLSTUB(glOrtho,(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top,
|
||||
GLdouble zNear, GLdouble zFar))
|
||||
*/
|
||||
SDL_FunctionPointer PSP_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc)
|
||||
{
|
||||
return eglGetProcAddress(proc);
|
||||
}
|
||||
|
||||
void PSP_GL_UnloadLibrary(SDL_VideoDevice *_this)
|
||||
{
|
||||
eglTerminate(_this->gl_data->display);
|
||||
}
|
||||
|
||||
static EGLint width = 480;
|
||||
static EGLint height = 272;
|
||||
|
||||
SDL_GLContext PSP_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
|
||||
SDL_WindowData *wdata = window->driverdata;
|
||||
|
||||
EGLint attribs[32];
|
||||
EGLDisplay display;
|
||||
EGLContext context;
|
||||
EGLSurface surface;
|
||||
EGLConfig config;
|
||||
EGLint num_configs;
|
||||
int i;
|
||||
|
||||
/* EGL init taken from glutCreateWindow() in PSPGL's glut.c. */
|
||||
EGLCHK(display = eglGetDisplay(0));
|
||||
EGLCHK(eglInitialize(display, NULL, NULL));
|
||||
wdata->uses_gles = SDL_TRUE;
|
||||
window->flags |= SDL_WINDOW_FULLSCREEN;
|
||||
|
||||
/* Setup the config based on SDL's current values. */
|
||||
i = 0;
|
||||
attribs[i++] = EGL_RED_SIZE;
|
||||
attribs[i++] = _this->gl_config.red_size;
|
||||
attribs[i++] = EGL_GREEN_SIZE;
|
||||
attribs[i++] = _this->gl_config.green_size;
|
||||
attribs[i++] = EGL_BLUE_SIZE;
|
||||
attribs[i++] = _this->gl_config.blue_size;
|
||||
attribs[i++] = EGL_DEPTH_SIZE;
|
||||
attribs[i++] = _this->gl_config.depth_size;
|
||||
|
||||
if (_this->gl_config.alpha_size) {
|
||||
attribs[i++] = EGL_ALPHA_SIZE;
|
||||
attribs[i++] = _this->gl_config.alpha_size;
|
||||
}
|
||||
if (_this->gl_config.stencil_size) {
|
||||
attribs[i++] = EGL_STENCIL_SIZE;
|
||||
attribs[i++] = _this->gl_config.stencil_size;
|
||||
}
|
||||
|
||||
attribs[i++] = EGL_NONE;
|
||||
|
||||
EGLCHK(eglChooseConfig(display, attribs, &config, 1, &num_configs));
|
||||
|
||||
if (num_configs == 0) {
|
||||
SDL_SetError("No valid EGL configs for requested mode");
|
||||
return 0;
|
||||
}
|
||||
|
||||
EGLCHK(eglGetConfigAttrib(display, config, EGL_WIDTH, &width));
|
||||
EGLCHK(eglGetConfigAttrib(display, config, EGL_HEIGHT, &height));
|
||||
|
||||
EGLCHK(context = eglCreateContext(display, config, NULL, NULL));
|
||||
EGLCHK(surface = eglCreateWindowSurface(display, config, 0, NULL));
|
||||
EGLCHK(eglMakeCurrent(display, surface, surface, context));
|
||||
|
||||
_this->gl_data->display = display;
|
||||
_this->gl_data->context = context;
|
||||
_this->gl_data->surface = surface;
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
int PSP_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context)
|
||||
{
|
||||
if (!eglMakeCurrent(_this->gl_data->display, _this->gl_data->surface,
|
||||
_this->gl_data->surface, _this->gl_data->context)) {
|
||||
return SDL_SetError("Unable to make EGL context current");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PSP_GL_SetSwapInterval(SDL_VideoDevice *_this, int interval)
|
||||
{
|
||||
EGLBoolean status;
|
||||
status = eglSwapInterval(_this->gl_data->display, interval);
|
||||
if (status == EGL_TRUE) {
|
||||
/* Return success to upper level */
|
||||
_this->gl_data->swapinterval = interval;
|
||||
return 0;
|
||||
}
|
||||
/* Failed to set swap interval */
|
||||
return SDL_SetError("Unable to set the EGL swap interval");
|
||||
}
|
||||
|
||||
int PSP_GL_GetSwapInterval(SDL_VideoDevice *_this, int *interval)
|
||||
{
|
||||
*interval = _this->gl_data->swapinterval;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PSP_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
if (!eglSwapBuffers(_this->gl_data->display, _this->gl_data->surface)) {
|
||||
return SDL_SetError("eglSwapBuffers() failed");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PSP_GL_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context)
|
||||
{
|
||||
SDL_VideoData *phdata = _this->driverdata;
|
||||
EGLBoolean status;
|
||||
|
||||
if (phdata->egl_initialized != SDL_TRUE) {
|
||||
return SDL_SetError("PSP: GLES initialization failed, no OpenGL ES support");
|
||||
}
|
||||
|
||||
/* Check if OpenGL ES connection has been initialized */
|
||||
if (_this->gl_data->display != EGL_NO_DISPLAY) {
|
||||
if (context != EGL_NO_CONTEXT) {
|
||||
status = eglDestroyContext(_this->gl_data->display, context);
|
||||
if (status != EGL_TRUE) {
|
||||
/* Error during OpenGL ES context destroying */
|
||||
return SDL_SetError("PSP: OpenGL ES context destroy error");
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_PSP */
|
50
external/sdl/SDL/src/video/psp/SDL_pspgl_c.h
vendored
Normal file
50
external/sdl/SDL/src/video/psp/SDL_pspgl_c.h
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 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.
|
||||
*/
|
||||
|
||||
#ifndef SDL_pspgl_c_h_
|
||||
#define SDL_pspgl_c_h_
|
||||
|
||||
#include <GLES/egl.h>
|
||||
#include <GLES/gl.h>
|
||||
|
||||
#include "SDL_pspvideo.h"
|
||||
|
||||
typedef struct SDL_GLDriverData
|
||||
{
|
||||
EGLDisplay display;
|
||||
EGLContext context;
|
||||
EGLSurface surface;
|
||||
uint32_t swapinterval;
|
||||
} SDL_GLDriverData;
|
||||
|
||||
extern SDL_FunctionPointer PSP_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc);
|
||||
extern int PSP_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context);
|
||||
extern void PSP_GL_SwapBuffers(SDL_VideoDevice *_this);
|
||||
|
||||
extern int PSP_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern SDL_GLContext PSP_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
extern int PSP_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path);
|
||||
extern void PSP_GL_UnloadLibrary(SDL_VideoDevice *_this);
|
||||
extern int PSP_GL_SetSwapInterval(SDL_VideoDevice *_this, int interval);
|
||||
extern int PSP_GL_GetSwapInterval(SDL_VideoDevice *_this, int *interval);
|
||||
|
||||
#endif /* SDL_pspgl_c_h_ */
|
37
external/sdl/SDL/src/video/psp/SDL_pspmouse.c
vendored
Normal file
37
external/sdl/SDL/src/video/psp/SDL_pspmouse.c
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 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"
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_PSP
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../../events/SDL_events_c.h"
|
||||
|
||||
#include "SDL_pspmouse_c.h"
|
||||
|
||||
/* The implementation dependent data for the window manager cursor */
|
||||
struct WMcursor
|
||||
{
|
||||
int unused;
|
||||
};
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_PSP */
|
24
external/sdl/SDL/src/video/psp/SDL_pspmouse_c.h
vendored
Normal file
24
external/sdl/SDL/src/video/psp/SDL_pspmouse_c.h
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 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_pspvideo.h"
|
||||
|
||||
/* Functions to be exported */
|
263
external/sdl/SDL/src/video/psp/SDL_pspvideo.c
vendored
Normal file
263
external/sdl/SDL/src/video/psp/SDL_pspvideo.c
vendored
Normal file
@@ -0,0 +1,263 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 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"
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_PSP
|
||||
|
||||
/* SDL internals */
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
#include "../../events/SDL_keyboard_c.h"
|
||||
|
||||
#include <SDL3/SDL_syswm.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 void PSP_Destroy(SDL_VideoDevice *device)
|
||||
{
|
||||
SDL_free(device->driverdata);
|
||||
SDL_free(device);
|
||||
}
|
||||
|
||||
static SDL_VideoDevice *PSP_Create()
|
||||
{
|
||||
SDL_VideoDevice *device;
|
||||
SDL_VideoData *phdata;
|
||||
SDL_GLDriverData *gldata;
|
||||
|
||||
/* 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->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->DestroyWindow = PSP_DestroyWindow;
|
||||
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_Create
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* SDL Video and Display initialization/handling functions */
|
||||
/*****************************************************************************/
|
||||
int PSP_VideoInit(SDL_VideoDevice *_this)
|
||||
{
|
||||
SDL_DisplayMode mode;
|
||||
|
||||
SDL_zero(mode);
|
||||
mode.w = 480;
|
||||
mode.h = 272;
|
||||
mode.refresh_rate = 60.0f;
|
||||
|
||||
/* 32 bpp for default */
|
||||
mode.format = SDL_PIXELFORMAT_ABGR8888;
|
||||
|
||||
if (SDL_AddBasicVideoDisplay(&mode) == 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PSP_VideoQuit(SDL_VideoDevice *_this)
|
||||
{
|
||||
}
|
||||
|
||||
int PSP_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display)
|
||||
{
|
||||
SDL_DisplayMode mode;
|
||||
|
||||
SDL_zero(mode);
|
||||
mode.w = 480;
|
||||
mode.h = 272;
|
||||
mode.refresh_rate = 60.0f;
|
||||
|
||||
/* 32 bpp for default */
|
||||
mode.format = SDL_PIXELFORMAT_ABGR8888;
|
||||
SDL_AddFullscreenDisplayMode(display, &mode);
|
||||
|
||||
/* 16 bpp secondary mode */
|
||||
mode.format = SDL_PIXELFORMAT_BGR565;
|
||||
SDL_AddFullscreenDisplayMode(display, &mode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PSP_SetDisplayMode(SDL_VideoDevice *_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(SDL_VideoDevice *_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;
|
||||
|
||||
SDL_SetKeyboardFocus(window);
|
||||
|
||||
/* Window has been successfully created */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PSP_CreateWindowFrom(SDL_VideoDevice *_this, SDL_Window *window, const void *data)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
void PSP_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
}
|
||||
int PSP_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
void PSP_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
}
|
||||
void PSP_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
}
|
||||
void PSP_HideWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
}
|
||||
void PSP_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
}
|
||||
void PSP_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
}
|
||||
void PSP_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
}
|
||||
void PSP_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
}
|
||||
void PSP_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
}
|
||||
|
||||
/* TO Write Me */
|
||||
SDL_bool PSP_HasScreenKeyboardSupport(SDL_VideoDevice *_this)
|
||||
{
|
||||
return SDL_FALSE;
|
||||
}
|
||||
void PSP_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
}
|
||||
void PSP_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
}
|
||||
SDL_bool PSP_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_PSP */
|
82
external/sdl/SDL/src/video/psp/SDL_pspvideo.h
vendored
Normal file
82
external/sdl/SDL/src/video/psp/SDL_pspvideo.h
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 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.
|
||||
*/
|
||||
|
||||
#ifndef SDL_pspvideo_h_
|
||||
#define SDL_pspvideo_h_
|
||||
|
||||
#include <GLES/egl.h>
|
||||
|
||||
#include "SDL_internal.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
|
||||
struct SDL_VideoData
|
||||
{
|
||||
SDL_bool egl_initialized; /* OpenGL ES device initialization status */
|
||||
uint32_t egl_refcount; /* OpenGL ES reference count */
|
||||
|
||||
};
|
||||
|
||||
struct SDL_WindowData
|
||||
{
|
||||
SDL_bool uses_gles; /* if true window must support OpenGL ES */
|
||||
|
||||
};
|
||||
|
||||
/****************************************************************************/
|
||||
/* SDL_VideoDevice functions declaration */
|
||||
/****************************************************************************/
|
||||
|
||||
/* Display and window functions */
|
||||
int PSP_VideoInit(SDL_VideoDevice *_this);
|
||||
void PSP_VideoQuit(SDL_VideoDevice *_this);
|
||||
int PSP_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display);
|
||||
int PSP_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode);
|
||||
int PSP_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
int PSP_CreateWindowFrom(SDL_VideoDevice *_this, SDL_Window *window, const void *data);
|
||||
void PSP_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
int PSP_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
void PSP_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
void PSP_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
void PSP_HideWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
void PSP_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
void PSP_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
void PSP_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
void PSP_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
void PSP_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
/* OpenGL/OpenGL ES functions */
|
||||
int PSP_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path);
|
||||
SDL_FunctionPointer PSP_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc);
|
||||
void PSP_GL_UnloadLibrary(SDL_VideoDevice *_this);
|
||||
SDL_GLContext PSP_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
int PSP_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context);
|
||||
int PSP_GL_SetSwapInterval(SDL_VideoDevice *_this, int interval);
|
||||
int PSP_GL_GetSwapInterval(SDL_VideoDevice *_this, int *interval);
|
||||
int PSP_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
int PSP_GL_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context);
|
||||
|
||||
/* PSP on screen keyboard */
|
||||
SDL_bool PSP_HasScreenKeyboardSupport(SDL_VideoDevice *_this);
|
||||
void PSP_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
void PSP_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
SDL_bool PSP_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
#endif /* SDL_pspvideo_h_ */
|
Reference in New Issue
Block a user