mirror of
https://github.com/encounter/SDL.git
synced 2025-12-13 23:26:18 +00:00
Initial rebase of xerpi's port
This commit is contained in:
committed by
Sam Lantinga
parent
bd06538778
commit
2d64e37e41
@@ -428,6 +428,7 @@ extern VideoBootStrap PND_bootstrap;
|
||||
extern VideoBootStrap UIKIT_bootstrap;
|
||||
extern VideoBootStrap Android_bootstrap;
|
||||
extern VideoBootStrap PSP_bootstrap;
|
||||
extern VideoBootStrap VITA_bootstrap;
|
||||
extern VideoBootStrap RPI_bootstrap;
|
||||
extern VideoBootStrap KMSDRM_bootstrap;
|
||||
extern VideoBootStrap KMSDRM_LEGACY_bootstrap;
|
||||
|
||||
@@ -94,6 +94,9 @@ static VideoBootStrap *bootstrap[] = {
|
||||
#if SDL_VIDEO_DRIVER_PSP
|
||||
&PSP_bootstrap,
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_VITA
|
||||
&VITA_bootstrap,
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_KMSDRM
|
||||
&KMSDRM_bootstrap,
|
||||
#endif
|
||||
|
||||
221
src/video/vita/SDL_vitagl.c
Normal file
221
src/video/vita/SDL_vitagl.c
Normal file
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
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 <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "SDL_error.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);
|
||||
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;
|
||||
|
||||
|
||||
/* EGL init taken from glutCreateWindow() in VITAGL's glut.c. */
|
||||
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));
|
||||
|
||||
/* Setup the config based on SDL's current values. */
|
||||
i = 0;
|
||||
attribs[i++] = EGL_RED_SIZE;
|
||||
attribs[i++] = 8;//_this->gl_config.red_size;
|
||||
attribs[i++] = EGL_GREEN_SIZE;
|
||||
attribs[i++] = 8;//_this->gl_config.green_size;
|
||||
attribs[i++] = EGL_BLUE_SIZE;
|
||||
attribs[i++] = 8;//_this->gl_config.blue_size;
|
||||
attribs[i++] = EGL_DEPTH_SIZE;
|
||||
attribs[i++] = 32;//_this->gl_config.depth_size;
|
||||
|
||||
// if (_this->gl_config.alpha_size)
|
||||
{
|
||||
attribs[i++] = EGL_ALPHA_SIZE;
|
||||
attribs[i++] = 8;//_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_SURFACE_TYPE;
|
||||
attribs[i++] = 5;
|
||||
|
||||
attribs[i++] = EGL_RENDERABLE_TYPE;
|
||||
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;
|
||||
}
|
||||
|
||||
const EGLint contextAttribs[] = {
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
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
src/video/vita/SDL_vitagl_c.h
Normal file
56
src/video/vita/SDL_vitagl_c.h
Normal 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: */
|
||||
198
src/video/vita/SDL_vitakeyboard.c
Normal file
198
src/video/vita/SDL_vitakeyboard.c
Normal file
@@ -0,0 +1,198 @@
|
||||
/*
|
||||
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
src/video/vita/SDL_vitakeyboard.h
Normal file
33
src/video/vita/SDL_vitakeyboard.h
Normal 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: */
|
||||
94
src/video/vita/SDL_vitamouse.c
Normal file
94
src/video/vita/SDL_vitamouse.c
Normal 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
src/video/vita/SDL_vitamouse_c.h
Normal file
33
src/video/vita/SDL_vitamouse_c.h
Normal 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: */
|
||||
179
src/video/vita/SDL_vitatouch.c
Normal file
179
src/video/vita/SDL_vitatouch.c
Normal file
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
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];
|
||||
|
||||
SceTouchPanelInfo panelinfo[SCE_TOUCH_PORT_MAX_NUM];
|
||||
|
||||
float aAWidth[SCE_TOUCH_PORT_MAX_NUM];
|
||||
float aAHeight[SCE_TOUCH_PORT_MAX_NUM];
|
||||
float dispWidth[SCE_TOUCH_PORT_MAX_NUM];
|
||||
float dispHeight[SCE_TOUCH_PORT_MAX_NUM];
|
||||
float forcerange[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);
|
||||
|
||||
SceTouchPanelInfo panelinfo[SCE_TOUCH_PORT_MAX_NUM];
|
||||
for(int port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) {
|
||||
sceTouchGetPanelInfo(port, &panelinfo[port]);
|
||||
aAWidth[port] = (float)(panelinfo[port].maxAaX - panelinfo[port].minAaX);
|
||||
aAHeight[port] = (float)(panelinfo[port].maxAaY - panelinfo[port].minAaY);
|
||||
dispWidth[port] = (float)(panelinfo[port].maxDispX - panelinfo[port].minDispX);
|
||||
dispHeight[port] = (float)(panelinfo[port].maxDispY - panelinfo[port].minDispY);
|
||||
forcerange[port] = (float)(panelinfo[port].maxForce - panelinfo[port].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)
|
||||
{
|
||||
// We skip polling touch if no window is created
|
||||
if (Vita_Window == NULL)
|
||||
return;
|
||||
|
||||
SDL_FingerID finger_id = 0;
|
||||
int port;
|
||||
|
||||
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;
|
||||
VITA_ConvertTouchXYToSDLXY(&x, &y, touch[port].report[i].x, touch[port].report[i].y, port);
|
||||
float force = (touch[port].report[i].force - panelinfo[port].minForce) / forcerange[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;
|
||||
VITA_ConvertTouchXYToSDLXY(&x, &y, touch_old[port].report[i].x, touch_old[port].report[i].y, port);
|
||||
float force = (touch_old[port].report[i].force - panelinfo[port].minForce) / forcerange[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 = 0;
|
||||
float y = 0;
|
||||
if (port == SCE_TOUCH_PORT_FRONT) {
|
||||
x = (vita_x - panelinfo[port].minDispX) / dispWidth[port];
|
||||
y = (vita_y - panelinfo[port].minDispY) / dispHeight[port];
|
||||
} else {
|
||||
x = (vita_x - panelinfo[port].minAaX) / aAWidth[port];
|
||||
y = (vita_y - panelinfo[port].minAaY) / aAHeight[port];
|
||||
}
|
||||
if (x < 0.0) {
|
||||
x = 0.0;
|
||||
} else if (x > 1.0) {
|
||||
x = 1.0;
|
||||
}
|
||||
if (y < 0.0) {
|
||||
y = 0.0;
|
||||
} else if (y > 1.0) {
|
||||
y = 1.0;
|
||||
}
|
||||
*sdl_x = x;
|
||||
*sdl_y = y;
|
||||
}
|
||||
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_VITA */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
35
src/video/vita/SDL_vitatouch.h
Normal file
35
src/video/vita/SDL_vitatouch.h
Normal 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: */
|
||||
341
src/video/vita/SDL_vitavideo.c
Normal file
341
src/video/vita/SDL_vitavideo.c
Normal file
@@ -0,0 +1,341 @@
|
||||
/*
|
||||
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_vitagl_c.h"
|
||||
|
||||
SDL_Window *Vita_Window;
|
||||
|
||||
/* unused
|
||||
static SDL_bool VITA_initialized = SDL_FALSE;
|
||||
*/
|
||||
static int
|
||||
VITA_Available(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
VITA_Destroy(SDL_VideoDevice * device)
|
||||
{
|
||||
/* SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; */
|
||||
|
||||
if (device->driverdata != NULL) {
|
||||
device->driverdata = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_VideoDevice *
|
||||
VITA_Create()
|
||||
{
|
||||
SDL_VideoDevice *device;
|
||||
SDL_VideoData *phdata;
|
||||
SDL_GLDriverData *gldata;
|
||||
|
||||
int status;
|
||||
|
||||
/* Check if VITA could be initialized */
|
||||
status = VITA_Available();
|
||||
if (status == 0) {
|
||||
/* VITA could not be used */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Initialize SDL_VideoDevice structure */
|
||||
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
|
||||
if (device == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Initialize internal VITA 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;
|
||||
phdata->egl_initialized = SDL_TRUE;
|
||||
|
||||
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->SetWindowGrab = VITA_SetWindowGrab;
|
||||
device->DestroyWindow = VITA_DestroyWindow;
|
||||
device->GetWindowWMInfo = VITA_GetWindowWMInfo;
|
||||
|
||||
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;
|
||||
|
||||
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_Available,
|
||||
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);
|
||||
VITA_InitTouch();
|
||||
VITA_InitKeyboard();
|
||||
VITA_InitMouse();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
VITA_VideoQuit(_THIS)
|
||||
{
|
||||
VITA_QuitTouch();
|
||||
}
|
||||
|
||||
void
|
||||
VITA_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
// Replace this with something else
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
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 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;
|
||||
}
|
||||
|
||||
|
||||
/* TO Write Me */
|
||||
SDL_bool VITA_HasScreenKeyboardSupport(_THIS)
|
||||
{
|
||||
return SDL_FALSE;
|
||||
}
|
||||
void VITA_ShowScreenKeyboard(_THIS, SDL_Window *window)
|
||||
{
|
||||
}
|
||||
void VITA_HideScreenKeyboard(_THIS, SDL_Window *window)
|
||||
{
|
||||
}
|
||||
SDL_bool VITA_IsScreenKeyboardShown(_THIS, SDL_Window *window)
|
||||
{
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
void VITA_PumpEvents(_THIS)
|
||||
{
|
||||
VITA_PollTouch();
|
||||
VITA_PollKeyboard();
|
||||
VITA_PollMouse();
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_VITA */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
102
src/video/vita/SDL_vitavideo.h
Normal file
102
src/video/vita/SDL_vitavideo.h
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
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"
|
||||
|
||||
typedef struct SDL_VideoData
|
||||
{
|
||||
SDL_bool egl_initialized; /* OpenGL device initialization status */
|
||||
uint32_t egl_refcount; /* OpenGL reference count */
|
||||
|
||||
} SDL_VideoData;
|
||||
|
||||
|
||||
typedef struct SDL_DisplayData
|
||||
{
|
||||
|
||||
} SDL_DisplayData;
|
||||
|
||||
|
||||
typedef struct SDL_WindowData
|
||||
{
|
||||
SDL_bool uses_gles;
|
||||
|
||||
} 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