early-access version 1667
This commit is contained in:
116
externals/SDL/src/video/vita/SDL_vitaframebuffer.c
vendored
Executable file
116
externals/SDL/src/video/vita/SDL_vitaframebuffer.c
vendored
Executable file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 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_VITA
|
||||
|
||||
#include "SDL_vitavideo.h"
|
||||
|
||||
#include <psp2/kernel/sysmem.h>
|
||||
|
||||
#define SCREEN_W 960
|
||||
#define SCREEN_H 544
|
||||
#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
|
||||
#define DISPLAY_PIXEL_FORMAT SCE_DISPLAY_PIXELFORMAT_A8B8G8R8
|
||||
|
||||
void *vita_gpu_alloc(SceKernelMemBlockType type, unsigned int size, SceUID *uid)
|
||||
{
|
||||
void *mem;
|
||||
|
||||
if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW) {
|
||||
size = ALIGN(size, 256*1024);
|
||||
} else {
|
||||
size = ALIGN(size, 4*1024);
|
||||
}
|
||||
|
||||
*uid = sceKernelAllocMemBlock("gpu_mem", type, size, NULL);
|
||||
|
||||
if (*uid < 0)
|
||||
return NULL;
|
||||
|
||||
if (sceKernelGetMemBlockBase(*uid, &mem) < 0)
|
||||
return NULL;
|
||||
|
||||
return mem;
|
||||
}
|
||||
|
||||
void vita_gpu_free(SceUID uid)
|
||||
{
|
||||
void *mem = NULL;
|
||||
if (sceKernelGetMemBlockBase(uid, &mem) < 0)
|
||||
return;
|
||||
sceKernelFreeMemBlock(uid);
|
||||
}
|
||||
|
||||
int VITA_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
|
||||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
SceDisplayFrameBuf framebuf;
|
||||
|
||||
*format = SDL_PIXELFORMAT_ABGR8888;
|
||||
*pitch = SCREEN_W * 4;
|
||||
|
||||
data->buffer = vita_gpu_alloc(
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW,
|
||||
4 * SCREEN_W * SCREEN_H,
|
||||
&data->buffer_uid
|
||||
);
|
||||
|
||||
// memset the buffer to black
|
||||
SDL_memset(data->buffer, 0x0, SCREEN_W*SCREEN_H*4);
|
||||
|
||||
SDL_memset(&framebuf, 0x00, sizeof(SceDisplayFrameBuf));
|
||||
framebuf.size = sizeof(SceDisplayFrameBuf);
|
||||
framebuf.base = data->buffer;
|
||||
framebuf.pitch = SCREEN_W;
|
||||
framebuf.pixelformat = DISPLAY_PIXEL_FORMAT;
|
||||
framebuf.width = SCREEN_W;
|
||||
framebuf.height = SCREEN_H;
|
||||
sceDisplaySetFrameBuf(&framebuf, SCE_DISPLAY_SETBUF_NEXTFRAME);
|
||||
|
||||
*pixels = data->buffer;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VITA_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects)
|
||||
{
|
||||
// do nothing
|
||||
return 0;
|
||||
}
|
||||
|
||||
void VITA_DestroyWindowFramebuffer(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
|
||||
if (!data) {
|
||||
/* The window wasn't fully initialized */
|
||||
return;
|
||||
}
|
||||
|
||||
vita_gpu_free(data->buffer_uid);
|
||||
data->buffer = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_VITA */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
27
externals/SDL/src/video/vita/SDL_vitaframebuffer.h
vendored
Executable file
27
externals/SDL/src/video/vita/SDL_vitaframebuffer.h
vendored
Executable file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 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"
|
||||
|
||||
extern int VITA_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch);
|
||||
extern int VITA_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects);
|
||||
extern void VITA_DestroyWindowFramebuffer(_THIS, SDL_Window * window);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
215
externals/SDL/src/video/vita/SDL_vitagl.c
vendored
Executable file
215
externals/SDL/src/video/vita/SDL_vitagl.c
vendored
Executable file
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 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_VITA && SDL_VIDEO_OPENGL_ES2
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_log.h"
|
||||
#include "SDL_vitavideo.h"
|
||||
#include "SDL_vitagl_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
|
||||
VITA_GL_LoadLibrary(_THIS, const char *path)
|
||||
{
|
||||
pibInit(PIB_SHACCCG | PIB_GET_PROC_ADDR_CORE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *
|
||||
VITA_GL_GetProcAddress(_THIS, const char *proc)
|
||||
{
|
||||
return eglGetProcAddress(proc);
|
||||
}
|
||||
|
||||
void
|
||||
VITA_GL_UnloadLibrary(_THIS)
|
||||
{
|
||||
eglTerminate(_this->gl_data->display);
|
||||
}
|
||||
|
||||
static EGLint width = 960;
|
||||
static EGLint height = 544;
|
||||
|
||||
SDL_GLContext
|
||||
VITA_GL_CreateContext(_THIS, SDL_Window * window)
|
||||
{
|
||||
|
||||
SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
|
||||
|
||||
EGLint attribs[32];
|
||||
EGLDisplay display;
|
||||
EGLContext context;
|
||||
EGLSurface surface;
|
||||
EGLConfig config;
|
||||
EGLint num_configs;
|
||||
int i;
|
||||
|
||||
const EGLint contextAttribs[] = {
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
EGLCHK(display = eglGetDisplay(0));
|
||||
|
||||
EGLCHK(eglInitialize(display, NULL, NULL));
|
||||
wdata->uses_gles = SDL_TRUE;
|
||||
window->flags |= SDL_WINDOW_FULLSCREEN;
|
||||
|
||||
EGLCHK(eglBindAPI(EGL_OPENGL_ES_API));
|
||||
|
||||
i = 0;
|
||||
attribs[i++] = EGL_RED_SIZE;
|
||||
attribs[i++] = 8;
|
||||
attribs[i++] = EGL_GREEN_SIZE;
|
||||
attribs[i++] = 8;
|
||||
attribs[i++] = EGL_BLUE_SIZE;
|
||||
attribs[i++] = 8;
|
||||
attribs[i++] = EGL_DEPTH_SIZE;
|
||||
attribs[i++] = 0;
|
||||
attribs[i++] = EGL_ALPHA_SIZE;
|
||||
attribs[i++] = 8;
|
||||
attribs[i++] = EGL_STENCIL_SIZE;
|
||||
attribs[i++] = 0;
|
||||
|
||||
attribs[i++] = EGL_SURFACE_TYPE;
|
||||
attribs[i++] = 5;
|
||||
|
||||
attribs[i++] = EGL_RENDERABLE_TYPE;
|
||||
attribs[i++] = EGL_OPENGL_ES2_BIT;
|
||||
|
||||
attribs[i++] = EGL_CONFORMANT;
|
||||
attribs[i++] = EGL_OPENGL_ES2_BIT;
|
||||
|
||||
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(surface = eglCreateWindowSurface(display, config, VITA_WINDOW_960X544, NULL));
|
||||
|
||||
EGLCHK(context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs));
|
||||
|
||||
EGLCHK(eglMakeCurrent(display, surface, surface, context));
|
||||
|
||||
EGLCHK(eglQuerySurface(display, surface, EGL_WIDTH, &width));
|
||||
EGLCHK(eglQuerySurface(display, surface, EGL_HEIGHT, &height));
|
||||
|
||||
_this->gl_data->display = display;
|
||||
_this->gl_data->context = context;
|
||||
_this->gl_data->surface = surface;
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
int
|
||||
VITA_GL_MakeCurrent(_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
|
||||
VITA_GL_SetSwapInterval(_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
|
||||
VITA_GL_GetSwapInterval(_THIS)
|
||||
{
|
||||
return _this->gl_data->swapinterval;
|
||||
}
|
||||
|
||||
int
|
||||
VITA_GL_SwapWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
if (!eglSwapBuffers(_this->gl_data->display, _this->gl_data->surface)) {
|
||||
return SDL_SetError("eglSwapBuffers() failed");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
VITA_GL_DeleteContext(_THIS, SDL_GLContext context)
|
||||
{
|
||||
SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
|
||||
EGLBoolean status;
|
||||
|
||||
if (phdata->egl_initialized != SDL_TRUE) {
|
||||
SDL_SetError("VITA: GLES initialization failed, no OpenGL ES support");
|
||||
return;
|
||||
}
|
||||
|
||||
/* 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 */
|
||||
SDL_SetError("VITA: OpenGL ES context destroy error");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_VITA */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
56
externals/SDL/src/video/vita/SDL_vitagl_c.h
vendored
Executable file
56
externals/SDL/src/video/vita/SDL_vitagl_c.h
vendored
Executable file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 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_vitagl_c_h_
|
||||
#define SDL_vitagl_c_h_
|
||||
|
||||
|
||||
#include <pib.h>
|
||||
#include <EGL/egl.h>
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
|
||||
#include "SDL_vitavideo.h"
|
||||
|
||||
|
||||
typedef struct SDL_GLDriverData {
|
||||
EGLDisplay display;
|
||||
EGLContext context;
|
||||
EGLSurface surface;
|
||||
uint32_t swapinterval;
|
||||
}SDL_GLDriverData;
|
||||
|
||||
extern void * VITA_GL_GetProcAddress(_THIS, const char *proc);
|
||||
extern int VITA_GL_MakeCurrent(_THIS,SDL_Window * window, SDL_GLContext context);
|
||||
extern void VITA_GL_SwapBuffers(_THIS);
|
||||
|
||||
extern int VITA_GL_SwapWindow(_THIS, SDL_Window * window);
|
||||
extern SDL_GLContext VITA_GL_CreateContext(_THIS, SDL_Window * window);
|
||||
|
||||
extern int VITA_GL_LoadLibrary(_THIS, const char *path);
|
||||
extern void VITA_GL_UnloadLibrary(_THIS);
|
||||
extern int VITA_GL_SetSwapInterval(_THIS, int interval);
|
||||
extern int VITA_GL_GetSwapInterval(_THIS);
|
||||
|
||||
|
||||
#endif /* SDL_vitagl_c_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
200
externals/SDL/src/video/vita/SDL_vitakeyboard.c
vendored
Executable file
200
externals/SDL/src/video/vita/SDL_vitakeyboard.c
vendored
Executable file
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2017 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_VITA
|
||||
|
||||
#include <psp2/kernel/processmgr.h>
|
||||
#include <psp2/ctrl.h>
|
||||
#include <psp2/hid.h>
|
||||
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_log.h"
|
||||
#include "SDL_vitavideo.h"
|
||||
#include "SDL_vitakeyboard.h"
|
||||
#include "../../events/SDL_keyboard_c.h"
|
||||
|
||||
SceHidKeyboardReport k_reports[SCE_HID_MAX_REPORT];
|
||||
int keyboard_hid_handle = 0;
|
||||
Uint8 prev_keys[6] = {0};
|
||||
Uint8 prev_modifiers = 0;
|
||||
Uint8 locks = 0;
|
||||
Uint8 lock_key_down = 0;
|
||||
|
||||
void
|
||||
VITA_InitKeyboard(void)
|
||||
{
|
||||
sceHidKeyboardEnumerate(&keyboard_hid_handle, 1);
|
||||
}
|
||||
|
||||
void
|
||||
VITA_PollKeyboard(void)
|
||||
{
|
||||
// We skip polling keyboard if no window is created
|
||||
if (Vita_Window == NULL)
|
||||
return;
|
||||
|
||||
if (keyboard_hid_handle > 0)
|
||||
{
|
||||
int numReports = sceHidKeyboardRead(keyboard_hid_handle, (SceHidKeyboardReport**)&k_reports, SCE_HID_MAX_REPORT);
|
||||
|
||||
if (numReports < 0) {
|
||||
keyboard_hid_handle = 0;
|
||||
}
|
||||
else if (numReports) {
|
||||
// Numlock and Capslock state changes only on a SDL_PRESSED event
|
||||
// The k_report only reports the state of the LED
|
||||
if (k_reports[numReports - 1].modifiers[1] & 0x1) {
|
||||
if (!(locks & 0x1)) {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_NUMLOCKCLEAR);
|
||||
locks |= 0x1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (locks & 0x1) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_NUMLOCKCLEAR);
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_NUMLOCKCLEAR);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_NUMLOCKCLEAR);
|
||||
locks &= ~0x1;
|
||||
}
|
||||
}
|
||||
|
||||
if (k_reports[numReports - 1].modifiers[1] & 0x2) {
|
||||
if (!(locks & 0x2)) {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK);
|
||||
locks |= 0x2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (locks & 0x2) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK);
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK);
|
||||
locks &= ~0x2;
|
||||
}
|
||||
}
|
||||
|
||||
if (k_reports[numReports - 1].modifiers[1] & 0x4) {
|
||||
if (!(locks & 0x4)) {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_SCROLLLOCK);
|
||||
locks |= 0x4;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (locks & 0x4) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_SCROLLLOCK);
|
||||
locks &= ~0x4;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
Uint8 changed_modifiers = k_reports[numReports - 1].modifiers[0] ^ prev_modifiers;
|
||||
|
||||
if (changed_modifiers & 0x01) {
|
||||
if (prev_modifiers & 0x01) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LCTRL);
|
||||
}
|
||||
else {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LCTRL);
|
||||
}
|
||||
}
|
||||
if (changed_modifiers & 0x02) {
|
||||
if (prev_modifiers & 0x02) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
|
||||
}
|
||||
else {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT);
|
||||
}
|
||||
}
|
||||
if (changed_modifiers & 0x04) {
|
||||
if (prev_modifiers & 0x04) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LALT);
|
||||
}
|
||||
else {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LALT);
|
||||
}
|
||||
}
|
||||
if (changed_modifiers & 0x08) {
|
||||
if (prev_modifiers & 0x08) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LGUI);
|
||||
}
|
||||
else {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LGUI);
|
||||
}
|
||||
}
|
||||
if (changed_modifiers & 0x10) {
|
||||
if (prev_modifiers & 0x10) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RCTRL);
|
||||
}
|
||||
else {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RCTRL);
|
||||
}
|
||||
}
|
||||
if (changed_modifiers & 0x20) {
|
||||
if (prev_modifiers & 0x20) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RSHIFT);
|
||||
}
|
||||
else {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RSHIFT);
|
||||
}
|
||||
}
|
||||
if (changed_modifiers & 0x40) {
|
||||
if (prev_modifiers & 0x40) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RALT);
|
||||
}
|
||||
else {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RALT);
|
||||
}
|
||||
}
|
||||
if (changed_modifiers & 0x80) {
|
||||
if (prev_modifiers & 0x80) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RGUI);
|
||||
}
|
||||
else {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RGUI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prev_modifiers = k_reports[numReports - 1].modifiers[0];
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
|
||||
int keyCode = k_reports[numReports - 1].keycodes[i];
|
||||
|
||||
if (keyCode != prev_keys[i]) {
|
||||
|
||||
if (prev_keys[i]) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, prev_keys[i]);
|
||||
}
|
||||
if (keyCode) {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, keyCode);
|
||||
}
|
||||
prev_keys[i] = keyCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_VITA */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
33
externals/SDL/src/video/vita/SDL_vitakeyboard.h
vendored
Executable file
33
externals/SDL/src/video/vita/SDL_vitakeyboard.h
vendored
Executable file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2017 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_vitakeyboard_h
|
||||
#define _SDL_vitakeyboard_h
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
/* Keyboard functions */
|
||||
extern void VITA_InitKeyboard(void);
|
||||
extern void VITA_PollKeyboard(void);
|
||||
|
||||
#endif /* _SDL_vitakeyboard_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
147
externals/SDL/src/video/vita/SDL_vitamessagebox.c
vendored
Executable file
147
externals/SDL/src/video/vita/SDL_vitamessagebox.c
vendored
Executable file
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 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_VITA
|
||||
|
||||
#include "SDL_vitavideo.h"
|
||||
#include "SDL_vitamessagebox.h"
|
||||
#include <psp2/message_dialog.h>
|
||||
|
||||
#if SDL_VIDEO_RENDER_VITA_GXM
|
||||
#include "../../render/vitagxm/SDL_render_vita_gxm_tools.h"
|
||||
#endif /* SDL_VIDEO_RENDER_VITA_GXM */
|
||||
|
||||
int VITA_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
{
|
||||
#if SDL_VIDEO_RENDER_VITA_GXM
|
||||
SceCommonDialogConfigParam commonDialogConfigParam;
|
||||
SceMsgDialogParam param;
|
||||
SceMsgDialogUserMessageParam msgParam;
|
||||
SceMsgDialogButtonsParam buttonParam;
|
||||
SceDisplayFrameBuf dispparam;
|
||||
|
||||
SceMsgDialogResult dialog_result;
|
||||
SceCommonDialogErrorCode init_result;
|
||||
SDL_bool setup_minimal_gxm = SDL_FALSE;
|
||||
|
||||
if (messageboxdata->numbuttons > 3)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
SDL_zero(commonDialogConfigParam);
|
||||
sceCommonDialogSetConfigParam(&commonDialogConfigParam);
|
||||
SDL_zero(param);
|
||||
sceMsgDialogParamInit(¶m);
|
||||
param.mode = SCE_MSG_DIALOG_MODE_USER_MSG;
|
||||
SDL_zero(msgParam);
|
||||
msgParam.msg = (const SceChar8*)messageboxdata->message;
|
||||
SDL_zero(buttonParam);
|
||||
if (messageboxdata->numbuttons == 3)
|
||||
{
|
||||
msgParam.buttonType = SCE_MSG_DIALOG_BUTTON_TYPE_3BUTTONS;
|
||||
msgParam.buttonParam = &buttonParam;
|
||||
buttonParam.msg1 = messageboxdata->buttons[0].text;
|
||||
buttonParam.msg2 = messageboxdata->buttons[1].text;
|
||||
buttonParam.msg3 = messageboxdata->buttons[2].text;
|
||||
}
|
||||
else if (messageboxdata->numbuttons == 2)
|
||||
{
|
||||
msgParam.buttonType = SCE_MSG_DIALOG_BUTTON_TYPE_YESNO;
|
||||
}
|
||||
else if (messageboxdata->numbuttons == 1)
|
||||
{
|
||||
msgParam.buttonType = SCE_MSG_DIALOG_BUTTON_TYPE_OK;
|
||||
}
|
||||
param.userMsgParam = &msgParam;
|
||||
|
||||
dispparam.size = sizeof(dispparam);
|
||||
|
||||
init_result = sceMsgDialogInit(¶m);
|
||||
|
||||
// Setup display if it hasn't been initialized before
|
||||
if (init_result == SCE_COMMON_DIALOG_ERROR_GXM_IS_UNINITIALIZED)
|
||||
{
|
||||
gxm_minimal_init_for_common_dialog();
|
||||
init_result = sceMsgDialogInit(¶m);
|
||||
setup_minimal_gxm = SDL_TRUE;
|
||||
}
|
||||
|
||||
gxm_init_for_common_dialog();
|
||||
|
||||
if (init_result >= 0)
|
||||
{
|
||||
while (sceMsgDialogGetStatus() == SCE_COMMON_DIALOG_STATUS_RUNNING)
|
||||
{
|
||||
gxm_swap_for_common_dialog();
|
||||
}
|
||||
SDL_zero(dialog_result);
|
||||
sceMsgDialogGetResult(&dialog_result);
|
||||
|
||||
if (dialog_result.buttonId == SCE_MSG_DIALOG_BUTTON_ID_BUTTON1)
|
||||
{
|
||||
*buttonid = messageboxdata->buttons[0].buttonid;
|
||||
}
|
||||
else if (dialog_result.buttonId == SCE_MSG_DIALOG_BUTTON_ID_BUTTON2)
|
||||
{
|
||||
*buttonid = messageboxdata->buttons[1].buttonid;
|
||||
}
|
||||
else if (dialog_result.buttonId == SCE_MSG_DIALOG_BUTTON_ID_BUTTON3)
|
||||
{
|
||||
*buttonid = messageboxdata->buttons[2].buttonid;
|
||||
}
|
||||
else if (dialog_result.buttonId == SCE_MSG_DIALOG_BUTTON_ID_YES)
|
||||
{
|
||||
*buttonid = messageboxdata->buttons[0].buttonid;
|
||||
}
|
||||
else if (dialog_result.buttonId == SCE_MSG_DIALOG_BUTTON_ID_NO)
|
||||
{
|
||||
*buttonid = messageboxdata->buttons[1].buttonid;
|
||||
}
|
||||
else if (dialog_result.buttonId == SCE_MSG_DIALOG_BUTTON_ID_OK)
|
||||
{
|
||||
*buttonid = messageboxdata->buttons[0].buttonid;
|
||||
}
|
||||
sceMsgDialogTerm();
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
gxm_term_for_common_dialog();
|
||||
|
||||
if (setup_minimal_gxm)
|
||||
{
|
||||
gxm_minimal_term_for_common_dialog();
|
||||
}
|
||||
|
||||
return 0;
|
||||
#else
|
||||
(void)messageboxdata;
|
||||
(void)buttonid;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_VITA */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
33
externals/SDL/src/video/vita/SDL_vitamessagebox.h
vendored
Executable file
33
externals/SDL/src/video/vita/SDL_vitamessagebox.h
vendored
Executable file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 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_vitamessagebox_h_
|
||||
#define SDL_vitamessagebox_h_
|
||||
|
||||
#if SDL_VIDEO_DRIVER_VITA
|
||||
|
||||
extern int VITA_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_VITA */
|
||||
|
||||
#endif /* SDL_vitamessagebox_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
94
externals/SDL/src/video/vita/SDL_vitamouse.c
vendored
Executable file
94
externals/SDL/src/video/vita/SDL_vitamouse.c
vendored
Executable file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2017 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_VITA
|
||||
|
||||
#include <psp2/kernel/processmgr.h>
|
||||
#include <psp2/ctrl.h>
|
||||
#include <psp2/hid.h>
|
||||
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_log.h"
|
||||
#include "SDL_mouse.h"
|
||||
#include "SDL_vitavideo.h"
|
||||
#include "SDL_vitamouse_c.h"
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
|
||||
SceHidMouseReport m_reports[SCE_HID_MAX_REPORT];
|
||||
int mouse_hid_handle = 0;
|
||||
Uint8 prev_buttons = 0;
|
||||
|
||||
void
|
||||
VITA_InitMouse(void)
|
||||
{
|
||||
sceHidMouseEnumerate(&mouse_hid_handle, 1);
|
||||
}
|
||||
|
||||
void
|
||||
VITA_PollMouse(void)
|
||||
{
|
||||
// We skip polling mouse if no window is created
|
||||
if (Vita_Window == NULL)
|
||||
return;
|
||||
|
||||
if (mouse_hid_handle > 0)
|
||||
{
|
||||
int numReports = sceHidMouseRead(mouse_hid_handle, (SceHidMouseReport**)&m_reports, SCE_HID_MAX_REPORT);
|
||||
if (numReports > 0)
|
||||
{
|
||||
for (int i = 0; i <= numReports - 1; i++)
|
||||
{
|
||||
Uint8 changed_buttons = m_reports[i].buttons ^ prev_buttons;
|
||||
|
||||
if (changed_buttons & 0x1) {
|
||||
if (prev_buttons & 0x1)
|
||||
SDL_SendMouseButton(Vita_Window, 0, SDL_RELEASED, SDL_BUTTON_LEFT);
|
||||
else
|
||||
SDL_SendMouseButton(Vita_Window, 0, SDL_PRESSED, SDL_BUTTON_LEFT);
|
||||
}
|
||||
if (changed_buttons & 0x2) {
|
||||
if (prev_buttons & 0x2)
|
||||
SDL_SendMouseButton(Vita_Window, 0, SDL_RELEASED, SDL_BUTTON_RIGHT);
|
||||
else
|
||||
SDL_SendMouseButton(Vita_Window, 0, SDL_PRESSED, SDL_BUTTON_RIGHT);
|
||||
}
|
||||
if (changed_buttons & 0x4) {
|
||||
if (prev_buttons & 0x4)
|
||||
SDL_SendMouseButton(Vita_Window, 0, SDL_RELEASED, SDL_BUTTON_MIDDLE);
|
||||
else
|
||||
SDL_SendMouseButton(Vita_Window, 0, SDL_PRESSED, SDL_BUTTON_MIDDLE);
|
||||
}
|
||||
|
||||
prev_buttons = m_reports[i].buttons;
|
||||
|
||||
if (m_reports[i].rel_x || m_reports[i].rel_y)
|
||||
{
|
||||
SDL_SendMouseMotion(Vita_Window, 0, 1, m_reports[i].rel_x, m_reports[i].rel_y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_VITA */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
33
externals/SDL/src/video/vita/SDL_vitamouse_c.h
vendored
Executable file
33
externals/SDL/src/video/vita/SDL_vitamouse_c.h
vendored
Executable file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2017 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_vitamouse_h
|
||||
#define _SDL_vitamouse_h
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
/* mouse functions */
|
||||
extern void VITA_InitMouse(void);
|
||||
extern void VITA_PollMouse(void);
|
||||
|
||||
#endif /* _SDL_vitamouse_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
171
externals/SDL/src/video/vita/SDL_vitatouch.c
vendored
Executable file
171
externals/SDL/src/video/vita/SDL_vitatouch.c
vendored
Executable file
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2017 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_VITA
|
||||
|
||||
#include <psp2/kernel/processmgr.h>
|
||||
#include <psp2/touch.h>
|
||||
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_log.h"
|
||||
#include "SDL_vitavideo.h"
|
||||
#include "SDL_vitatouch.h"
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
#include "../../events/SDL_touch_c.h"
|
||||
|
||||
SceTouchData touch_old[SCE_TOUCH_PORT_MAX_NUM];
|
||||
SceTouchData touch[SCE_TOUCH_PORT_MAX_NUM];
|
||||
|
||||
SDL_FRect area_info[SCE_TOUCH_PORT_MAX_NUM];
|
||||
|
||||
struct{
|
||||
float min;
|
||||
float range;
|
||||
} force_info[SCE_TOUCH_PORT_MAX_NUM];
|
||||
|
||||
void
|
||||
VITA_InitTouch(void)
|
||||
{
|
||||
sceTouchSetSamplingState(SCE_TOUCH_PORT_FRONT, SCE_TOUCH_SAMPLING_STATE_START);
|
||||
sceTouchSetSamplingState(SCE_TOUCH_PORT_BACK, SCE_TOUCH_SAMPLING_STATE_START);
|
||||
sceTouchEnableTouchForce(SCE_TOUCH_PORT_FRONT);
|
||||
sceTouchEnableTouchForce(SCE_TOUCH_PORT_BACK);
|
||||
|
||||
for(int port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) {
|
||||
SceTouchPanelInfo panelinfo;
|
||||
sceTouchGetPanelInfo(port, &panelinfo);
|
||||
|
||||
area_info[port].x = (float)panelinfo.minAaX;
|
||||
area_info[port].y = (float)panelinfo.minAaY;
|
||||
area_info[port].w = (float)(panelinfo.maxAaX - panelinfo.minAaX);
|
||||
area_info[port].h = (float)(panelinfo.maxAaY - panelinfo.minAaY);
|
||||
|
||||
force_info[port].min = (float)panelinfo.minForce;
|
||||
force_info[port].range = (float)(panelinfo.maxForce - panelinfo.minForce);
|
||||
}
|
||||
|
||||
// Support passing both front and back touch devices in events
|
||||
SDL_AddTouch((SDL_TouchID)0, SDL_TOUCH_DEVICE_DIRECT, "Front");
|
||||
SDL_AddTouch((SDL_TouchID)1, SDL_TOUCH_DEVICE_DIRECT, "Back");
|
||||
}
|
||||
|
||||
void
|
||||
VITA_QuitTouch(void){
|
||||
sceTouchDisableTouchForce(SCE_TOUCH_PORT_FRONT);
|
||||
sceTouchDisableTouchForce(SCE_TOUCH_PORT_BACK);
|
||||
}
|
||||
|
||||
void
|
||||
VITA_PollTouch(void)
|
||||
{
|
||||
SDL_FingerID finger_id = 0;
|
||||
int port;
|
||||
|
||||
// We skip polling touch if no window is created
|
||||
if (Vita_Window == NULL)
|
||||
return;
|
||||
|
||||
memcpy(touch_old, touch, sizeof(touch_old));
|
||||
|
||||
for(port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) {
|
||||
sceTouchPeek(port, &touch[port], 1);
|
||||
if (touch[port].reportNum > 0) {
|
||||
for (int i = 0; i < touch[port].reportNum; i++)
|
||||
{
|
||||
// adjust coordinates and forces to return normalized values
|
||||
// for the front, screen area is used as a reference (for direct touch)
|
||||
// e.g. touch_x = 1.0 corresponds to screen_x = 960
|
||||
// for the back panel, the active touch area is used as reference
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
float force = (touch[port].report[i].force - force_info[port].min) / force_info[port].range;
|
||||
VITA_ConvertTouchXYToSDLXY(&x, &y, touch[port].report[i].x, touch[port].report[i].y, port);
|
||||
finger_id = (SDL_FingerID) touch[port].report[i].id;
|
||||
|
||||
// Send an initial touch
|
||||
SDL_SendTouch((SDL_TouchID)port,
|
||||
finger_id,
|
||||
Vita_Window,
|
||||
SDL_TRUE,
|
||||
x,
|
||||
y,
|
||||
force);
|
||||
|
||||
// Always send the motion
|
||||
SDL_SendTouchMotion((SDL_TouchID)port,
|
||||
finger_id,
|
||||
Vita_Window,
|
||||
x,
|
||||
y,
|
||||
force);
|
||||
}
|
||||
}
|
||||
|
||||
// some fingers might have been let go
|
||||
if (touch_old[port].reportNum > 0) {
|
||||
for (int i = 0; i < touch_old[port].reportNum; i++) {
|
||||
int finger_up = 1;
|
||||
if (touch[port].reportNum > 0) {
|
||||
for (int j = 0; j < touch[port].reportNum; j++) {
|
||||
if (touch[port].report[j].id == touch_old[port].report[i].id ) {
|
||||
finger_up = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (finger_up == 1) {
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
float force = (touch_old[port].report[i].force - force_info[port].min) / force_info[port].range;
|
||||
VITA_ConvertTouchXYToSDLXY(&x, &y, touch_old[port].report[i].x, touch_old[port].report[i].y, port);
|
||||
finger_id = (SDL_FingerID) touch_old[port].report[i].id;
|
||||
// Finger released from screen
|
||||
SDL_SendTouch((SDL_TouchID)port,
|
||||
finger_id,
|
||||
Vita_Window,
|
||||
SDL_FALSE,
|
||||
x,
|
||||
y,
|
||||
force);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VITA_ConvertTouchXYToSDLXY(float *sdl_x, float *sdl_y, int vita_x, int vita_y, int port) {
|
||||
float x = (vita_x - area_info[port].x) / area_info[port].w;
|
||||
float y = (vita_y - area_info[port].y) / area_info[port].h;
|
||||
|
||||
x = SDL_max(x, 0.0);
|
||||
x = SDL_min(x, 1.0);
|
||||
|
||||
y = SDL_max(y, 0.0);
|
||||
y = SDL_min(y, 1.0);
|
||||
|
||||
*sdl_x = x;
|
||||
*sdl_y = y;
|
||||
}
|
||||
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_VITA */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
35
externals/SDL/src/video/vita/SDL_vitatouch.h
vendored
Executable file
35
externals/SDL/src/video/vita/SDL_vitatouch.h
vendored
Executable file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2017 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_vitatouch_h
|
||||
#define _SDL_vitatouch_h
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
/* Touch functions */
|
||||
extern void VITA_InitTouch(void);
|
||||
extern void VITA_QuitTouch(void);
|
||||
extern void VITA_PollTouch(void);
|
||||
void VITA_ConvertTouchXYToSDLXY(float *sdl_x, float *sdl_y, int vita_x, int vita_y, int port);
|
||||
|
||||
#endif /* _SDL_vitatouch_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
451
externals/SDL/src/video/vita/SDL_vitavideo.c
vendored
Executable file
451
externals/SDL/src/video/vita/SDL_vitavideo.c
vendored
Executable file
@@ -0,0 +1,451 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2015 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_VITA
|
||||
|
||||
/* 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"
|
||||
|
||||
/* VITA declarations */
|
||||
#include "SDL_vitavideo.h"
|
||||
#include "SDL_vitatouch.h"
|
||||
#include "SDL_vitakeyboard.h"
|
||||
#include "SDL_vitamouse_c.h"
|
||||
#include "SDL_vitaframebuffer.h"
|
||||
#if SDL_VIDEO_OPENGL_ES2
|
||||
#include "SDL_vitagl_c.h"
|
||||
#endif
|
||||
#include <psp2/ime_dialog.h>
|
||||
|
||||
SDL_Window *Vita_Window;
|
||||
|
||||
static void
|
||||
VITA_Destroy(SDL_VideoDevice * device)
|
||||
{
|
||||
/* SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; */
|
||||
|
||||
SDL_free(device->driverdata);
|
||||
SDL_free(device);
|
||||
// if (device->driverdata != NULL) {
|
||||
// device->driverdata = NULL;
|
||||
// }
|
||||
}
|
||||
|
||||
static SDL_VideoDevice *
|
||||
VITA_Create()
|
||||
{
|
||||
SDL_VideoDevice *device;
|
||||
SDL_VideoData *phdata;
|
||||
#if SDL_VIDEO_OPENGL_ES2
|
||||
SDL_GLDriverData *gldata;
|
||||
#endif
|
||||
/* Initialize SDL_VideoDevice structure */
|
||||
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
|
||||
if (device == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Initialize internal VITA specific data */
|
||||
phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
|
||||
if (phdata == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
SDL_free(device);
|
||||
return NULL;
|
||||
}
|
||||
#if SDL_VIDEO_OPENGL_ES2
|
||||
|
||||
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;
|
||||
phdata->egl_initialized = SDL_TRUE;
|
||||
#endif
|
||||
phdata->ime_active = SDL_FALSE;
|
||||
|
||||
device->driverdata = phdata;
|
||||
|
||||
/* Setup amount of available displays and current display */
|
||||
device->num_displays = 0;
|
||||
|
||||
/* Set device free function */
|
||||
device->free = VITA_Destroy;
|
||||
|
||||
/* Setup all functions which we can handle */
|
||||
device->VideoInit = VITA_VideoInit;
|
||||
device->VideoQuit = VITA_VideoQuit;
|
||||
device->GetDisplayModes = VITA_GetDisplayModes;
|
||||
device->SetDisplayMode = VITA_SetDisplayMode;
|
||||
device->CreateSDLWindow = VITA_CreateWindow;
|
||||
device->CreateSDLWindowFrom = VITA_CreateWindowFrom;
|
||||
device->SetWindowTitle = VITA_SetWindowTitle;
|
||||
device->SetWindowIcon = VITA_SetWindowIcon;
|
||||
device->SetWindowPosition = VITA_SetWindowPosition;
|
||||
device->SetWindowSize = VITA_SetWindowSize;
|
||||
device->ShowWindow = VITA_ShowWindow;
|
||||
device->HideWindow = VITA_HideWindow;
|
||||
device->RaiseWindow = VITA_RaiseWindow;
|
||||
device->MaximizeWindow = VITA_MaximizeWindow;
|
||||
device->MinimizeWindow = VITA_MinimizeWindow;
|
||||
device->RestoreWindow = VITA_RestoreWindow;
|
||||
device->SetWindowMouseGrab = VITA_SetWindowGrab;
|
||||
device->SetWindowKeyboardGrab = VITA_SetWindowGrab;
|
||||
device->DestroyWindow = VITA_DestroyWindow;
|
||||
device->GetWindowWMInfo = VITA_GetWindowWMInfo;
|
||||
|
||||
/*
|
||||
// Disabled, causes issues on high-framerate updates. SDL still emulates this.
|
||||
device->CreateWindowFramebuffer = VITA_CreateWindowFramebuffer;
|
||||
device->UpdateWindowFramebuffer = VITA_UpdateWindowFramebuffer;
|
||||
device->DestroyWindowFramebuffer = VITA_DestroyWindowFramebuffer;
|
||||
*/
|
||||
|
||||
#if SDL_VIDEO_OPENGL_ES2
|
||||
device->GL_LoadLibrary = VITA_GL_LoadLibrary;
|
||||
device->GL_GetProcAddress = VITA_GL_GetProcAddress;
|
||||
device->GL_UnloadLibrary = VITA_GL_UnloadLibrary;
|
||||
device->GL_CreateContext = VITA_GL_CreateContext;
|
||||
device->GL_MakeCurrent = VITA_GL_MakeCurrent;
|
||||
device->GL_SetSwapInterval = VITA_GL_SetSwapInterval;
|
||||
device->GL_GetSwapInterval = VITA_GL_GetSwapInterval;
|
||||
device->GL_SwapWindow = VITA_GL_SwapWindow;
|
||||
device->GL_DeleteContext = VITA_GL_DeleteContext;
|
||||
#endif
|
||||
|
||||
device->HasScreenKeyboardSupport = VITA_HasScreenKeyboardSupport;
|
||||
device->ShowScreenKeyboard = VITA_ShowScreenKeyboard;
|
||||
device->HideScreenKeyboard = VITA_HideScreenKeyboard;
|
||||
device->IsScreenKeyboardShown = VITA_IsScreenKeyboardShown;
|
||||
|
||||
device->PumpEvents = VITA_PumpEvents;
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
VideoBootStrap VITA_bootstrap = {
|
||||
"VITA",
|
||||
"VITA Video Driver",
|
||||
VITA_Create
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* SDL Video and Display initialization/handling functions */
|
||||
/*****************************************************************************/
|
||||
int
|
||||
VITA_VideoInit(_THIS)
|
||||
{
|
||||
SDL_VideoDisplay display;
|
||||
SDL_DisplayMode current_mode;
|
||||
|
||||
SDL_zero(current_mode);
|
||||
|
||||
current_mode.w = 960;
|
||||
current_mode.h = 544;
|
||||
|
||||
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, SDL_FALSE);
|
||||
VITA_InitTouch();
|
||||
VITA_InitKeyboard();
|
||||
VITA_InitMouse();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
VITA_VideoQuit(_THIS)
|
||||
{
|
||||
VITA_QuitTouch();
|
||||
}
|
||||
|
||||
void
|
||||
VITA_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
|
||||
{
|
||||
SDL_AddDisplayMode(display, &display->current_mode);
|
||||
}
|
||||
|
||||
int
|
||||
VITA_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
VITA_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;
|
||||
|
||||
// Vita can only have one window
|
||||
if (Vita_Window != NULL)
|
||||
{
|
||||
SDL_SetError("Only one window supported");
|
||||
return -1;
|
||||
}
|
||||
|
||||
Vita_Window = window;
|
||||
|
||||
// fix input, we need to find a better way
|
||||
SDL_SetKeyboardFocus(window);
|
||||
|
||||
/* Window has been successfully created */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
VITA_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
VITA_SetWindowTitle(_THIS, SDL_Window * window)
|
||||
{
|
||||
}
|
||||
void
|
||||
VITA_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
|
||||
{
|
||||
}
|
||||
void
|
||||
VITA_SetWindowPosition(_THIS, SDL_Window * window)
|
||||
{
|
||||
}
|
||||
void
|
||||
VITA_SetWindowSize(_THIS, SDL_Window * window)
|
||||
{
|
||||
}
|
||||
void
|
||||
VITA_ShowWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
}
|
||||
void
|
||||
VITA_HideWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
}
|
||||
void
|
||||
VITA_RaiseWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
}
|
||||
void
|
||||
VITA_MaximizeWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
}
|
||||
void
|
||||
VITA_MinimizeWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
}
|
||||
void
|
||||
VITA_RestoreWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
}
|
||||
void
|
||||
VITA_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
||||
{
|
||||
|
||||
}
|
||||
void
|
||||
VITA_DestroyWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
// SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
|
||||
SDL_WindowData *data;
|
||||
|
||||
data = window->driverdata;
|
||||
if (data) {
|
||||
// TODO: should we destroy egl context? No one sane should recreate ogl window as non-ogl
|
||||
SDL_free(data);
|
||||
}
|
||||
|
||||
window->driverdata = NULL;
|
||||
Vita_Window = NULL;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* SDL Window Manager function */
|
||||
/*****************************************************************************/
|
||||
SDL_bool
|
||||
VITA_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;
|
||||
}
|
||||
|
||||
SDL_bool VITA_HasScreenKeyboardSupport(_THIS)
|
||||
{
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
#if !defined(SCE_IME_LANGUAGE_ENGLISH_US)
|
||||
#define SCE_IME_LANGUAGE_ENGLISH_US SCE_IME_LANGUAGE_ENGLISH
|
||||
#endif
|
||||
|
||||
void VITA_ShowScreenKeyboard(_THIS, SDL_Window *window)
|
||||
{
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
|
||||
|
||||
SceWChar16 *title = u"";
|
||||
SceWChar16 *text = u"";
|
||||
SceInt32 res;
|
||||
|
||||
SceImeDialogParam param;
|
||||
sceImeDialogParamInit(¶m);
|
||||
|
||||
param.supportedLanguages = SCE_IME_LANGUAGE_ENGLISH_US;
|
||||
param.languagesForced = SCE_FALSE;
|
||||
param.type = SCE_IME_TYPE_DEFAULT;
|
||||
param.option = 0;
|
||||
param.textBoxMode = SCE_IME_DIALOG_TEXTBOX_MODE_WITH_CLEAR;
|
||||
param.maxTextLength = SCE_IME_DIALOG_MAX_TEXT_LENGTH;
|
||||
|
||||
param.title = title;
|
||||
param.initialText = text;
|
||||
param.inputTextBuffer = videodata->ime_buffer;
|
||||
|
||||
res = sceImeDialogInit(¶m);
|
||||
if (res < 0) {
|
||||
SDL_SetError("Failed to init IME dialog");
|
||||
return;
|
||||
}
|
||||
|
||||
videodata->ime_active = SDL_TRUE;
|
||||
}
|
||||
|
||||
void VITA_HideScreenKeyboard(_THIS, SDL_Window *window)
|
||||
{
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
|
||||
|
||||
SceCommonDialogStatus dialogStatus = sceImeDialogGetStatus();
|
||||
|
||||
switch (dialogStatus) {
|
||||
default:
|
||||
case SCE_COMMON_DIALOG_STATUS_NONE:
|
||||
case SCE_COMMON_DIALOG_STATUS_RUNNING:
|
||||
break;
|
||||
case SCE_COMMON_DIALOG_STATUS_FINISHED:
|
||||
sceImeDialogTerm();
|
||||
break;
|
||||
}
|
||||
|
||||
videodata->ime_active = SDL_FALSE;
|
||||
}
|
||||
|
||||
SDL_bool VITA_IsScreenKeyboardShown(_THIS, SDL_Window *window)
|
||||
{
|
||||
SceCommonDialogStatus dialogStatus = sceImeDialogGetStatus();
|
||||
return (dialogStatus == SCE_COMMON_DIALOG_STATUS_RUNNING);
|
||||
}
|
||||
|
||||
|
||||
static void utf16_to_utf8(const uint16_t *src, uint8_t *dst) {
|
||||
int i;
|
||||
for (i = 0; src[i]; i++) {
|
||||
if ((src[i] & 0xFF80) == 0) {
|
||||
*(dst++) = src[i] & 0xFF;
|
||||
} else if((src[i] & 0xF800) == 0) {
|
||||
*(dst++) = ((src[i] >> 6) & 0xFF) | 0xC0;
|
||||
*(dst++) = (src[i] & 0x3F) | 0x80;
|
||||
} else if((src[i] & 0xFC00) == 0xD800 && (src[i + 1] & 0xFC00) == 0xDC00) {
|
||||
*(dst++) = (((src[i] + 64) >> 8) & 0x3) | 0xF0;
|
||||
*(dst++) = (((src[i] >> 2) + 16) & 0x3F) | 0x80;
|
||||
*(dst++) = ((src[i] >> 4) & 0x30) | 0x80 | ((src[i + 1] << 2) & 0xF);
|
||||
*(dst++) = (src[i + 1] & 0x3F) | 0x80;
|
||||
i += 1;
|
||||
} else {
|
||||
*(dst++) = ((src[i] >> 12) & 0xF) | 0xE0;
|
||||
*(dst++) = ((src[i] >> 6) & 0x3F) | 0x80;
|
||||
*(dst++) = (src[i] & 0x3F) | 0x80;
|
||||
}
|
||||
}
|
||||
|
||||
*dst = '\0';
|
||||
}
|
||||
|
||||
void VITA_PumpEvents(_THIS)
|
||||
{
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
|
||||
|
||||
VITA_PollTouch();
|
||||
VITA_PollKeyboard();
|
||||
VITA_PollMouse();
|
||||
|
||||
if (videodata->ime_active == SDL_TRUE) {
|
||||
// update IME status. Terminate, if finished
|
||||
SceCommonDialogStatus dialogStatus = sceImeDialogGetStatus();
|
||||
if (dialogStatus == SCE_COMMON_DIALOG_STATUS_FINISHED) {
|
||||
uint8_t utf8_buffer[SCE_IME_DIALOG_MAX_TEXT_LENGTH];
|
||||
|
||||
SceImeDialogResult result;
|
||||
SDL_memset(&result, 0, sizeof(SceImeDialogResult));
|
||||
sceImeDialogGetResult(&result);
|
||||
|
||||
// Convert UTF16 to UTF8
|
||||
utf16_to_utf8(videodata->ime_buffer, utf8_buffer);
|
||||
|
||||
// send sdl event
|
||||
SDL_SendKeyboardText((const char*)utf8_buffer);
|
||||
|
||||
sceImeDialogTerm();
|
||||
|
||||
videodata->ime_active = SDL_FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_VITA */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
111
externals/SDL/src/video/vita/SDL_vitavideo.h
vendored
Executable file
111
externals/SDL/src/video/vita/SDL_vitavideo.h
vendored
Executable file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2015 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_vitavideo_h
|
||||
#define _SDL_vitavideo_h
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
|
||||
#include <psp2/types.h>
|
||||
#include <psp2/display.h>
|
||||
#include <psp2/ime_dialog.h>
|
||||
|
||||
typedef struct SDL_VideoData
|
||||
{
|
||||
SDL_bool egl_initialized; /* OpenGL device initialization status */
|
||||
uint32_t egl_refcount; /* OpenGL reference count */
|
||||
|
||||
SceWChar16 ime_buffer[SCE_IME_DIALOG_MAX_TEXT_LENGTH];
|
||||
SDL_bool ime_active;
|
||||
|
||||
} SDL_VideoData;
|
||||
|
||||
|
||||
typedef struct SDL_DisplayData
|
||||
{
|
||||
|
||||
} SDL_DisplayData;
|
||||
|
||||
|
||||
typedef struct SDL_WindowData
|
||||
{
|
||||
SDL_bool uses_gles;
|
||||
SceUID buffer_uid;
|
||||
void* buffer;
|
||||
|
||||
} SDL_WindowData;
|
||||
|
||||
extern SDL_Window * Vita_Window;
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/* SDL_VideoDevice functions declaration */
|
||||
/****************************************************************************/
|
||||
|
||||
/* Display and window functions */
|
||||
int VITA_VideoInit(_THIS);
|
||||
void VITA_VideoQuit(_THIS);
|
||||
void VITA_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
|
||||
int VITA_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
|
||||
int VITA_CreateWindow(_THIS, SDL_Window * window);
|
||||
int VITA_CreateWindowFrom(_THIS, SDL_Window * window, const void *data);
|
||||
void VITA_SetWindowTitle(_THIS, SDL_Window * window);
|
||||
void VITA_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon);
|
||||
void VITA_SetWindowPosition(_THIS, SDL_Window * window);
|
||||
void VITA_SetWindowSize(_THIS, SDL_Window * window);
|
||||
void VITA_ShowWindow(_THIS, SDL_Window * window);
|
||||
void VITA_HideWindow(_THIS, SDL_Window * window);
|
||||
void VITA_RaiseWindow(_THIS, SDL_Window * window);
|
||||
void VITA_MaximizeWindow(_THIS, SDL_Window * window);
|
||||
void VITA_MinimizeWindow(_THIS, SDL_Window * window);
|
||||
void VITA_RestoreWindow(_THIS, SDL_Window * window);
|
||||
void VITA_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
|
||||
void VITA_DestroyWindow(_THIS, SDL_Window * window);
|
||||
|
||||
/* Window manager function */
|
||||
SDL_bool VITA_GetWindowWMInfo(_THIS, SDL_Window * window,
|
||||
struct SDL_SysWMinfo *info);
|
||||
|
||||
#if SDL_VIDEO_DRIVER_VITA
|
||||
/* OpenGL functions */
|
||||
int VITA_GL_LoadLibrary(_THIS, const char *path);
|
||||
void *VITA_GL_GetProcAddress(_THIS, const char *proc);
|
||||
void VITA_GL_UnloadLibrary(_THIS);
|
||||
SDL_GLContext VITA_GL_CreateContext(_THIS, SDL_Window * window);
|
||||
int VITA_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context);
|
||||
int VITA_GL_SetSwapInterval(_THIS, int interval);
|
||||
int VITA_GL_GetSwapInterval(_THIS);
|
||||
int VITA_GL_SwapWindow(_THIS, SDL_Window * window);
|
||||
void VITA_GL_DeleteContext(_THIS, SDL_GLContext context);
|
||||
#endif
|
||||
|
||||
/* VITA on screen keyboard */
|
||||
SDL_bool VITA_HasScreenKeyboardSupport(_THIS);
|
||||
void VITA_ShowScreenKeyboard(_THIS, SDL_Window *window);
|
||||
void VITA_HideScreenKeyboard(_THIS, SDL_Window *window);
|
||||
SDL_bool VITA_IsScreenKeyboardShown(_THIS, SDL_Window *window);
|
||||
|
||||
void VITA_PumpEvents(_THIS);
|
||||
|
||||
#endif /* _SDL_pspvideo_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
Reference in New Issue
Block a user