early-access version 2281
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -74,7 +74,7 @@ int VITA_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, vo
|
||||
&data->buffer_uid
|
||||
);
|
||||
|
||||
// memset the buffer to black
|
||||
// SDL_memset the buffer to black
|
||||
SDL_memset(data->buffer, 0x0, SCREEN_W*SCREEN_H*4);
|
||||
|
||||
SDL_memset(&framebuf, 0x00, sizeof(SceDisplayFrameBuf));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
||||
2
externals/SDL/src/video/vita/SDL_vitagl.c
vendored
2
externals/SDL/src/video/vita/SDL_vitagl.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
||||
2
externals/SDL/src/video/vita/SDL_vitagl_c.h
vendored
2
externals/SDL/src/video/vita/SDL_vitagl_c.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
||||
103
externals/SDL/src/video/vita/SDL_vitagl_pvr.c
vendored
Executable file
103
externals/SDL/src/video/vita/SDL_vitagl_pvr.c
vendored
Executable file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 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_VITA_PVR
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <psp2/kernel/modulemgr.h>
|
||||
#include <gpu_es4/psp2_pvr_hint.h>
|
||||
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_log.h"
|
||||
#include "SDL_vitavideo.h"
|
||||
#include "../SDL_egl_c.h"
|
||||
#include "SDL_vitagl_pvr_c.h"
|
||||
|
||||
#define MAX_PATH 256 // vita limits are somehow wrong
|
||||
|
||||
int
|
||||
VITA_GL_LoadLibrary(_THIS, const char *path)
|
||||
{
|
||||
PVRSRV_PSP2_APPHINT hint;
|
||||
char* override = SDL_getenv("VITA_MODULE_PATH");
|
||||
char* skip_init = SDL_getenv("VITA_PVR_SKIP_INIT");
|
||||
char* default_path = "app0:module";
|
||||
char target_path[MAX_PATH];
|
||||
|
||||
if (skip_init == NULL) // we don't care about actual value
|
||||
{
|
||||
if (override != NULL)
|
||||
{
|
||||
default_path = override;
|
||||
}
|
||||
|
||||
sceKernelLoadStartModule("vs0:sys/external/libfios2.suprx", 0, NULL, 0, NULL, NULL);
|
||||
sceKernelLoadStartModule("vs0:sys/external/libc.suprx", 0, NULL, 0, NULL, NULL);
|
||||
|
||||
SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libgpu_es4_ext.suprx");
|
||||
sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL);
|
||||
|
||||
SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libIMGEGL.suprx");
|
||||
sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL);
|
||||
|
||||
PVRSRVInitializeAppHint(&hint);
|
||||
|
||||
SDL_snprintf(hint.szGLES1, MAX_PATH, "%s/%s", default_path, "libGLESv1_CM.suprx");
|
||||
SDL_snprintf(hint.szGLES2, MAX_PATH, "%s/%s", default_path, "libGLESv2.suprx");
|
||||
SDL_snprintf(hint.szWindowSystem, MAX_PATH, "%s/%s", default_path, "libpvrPSP2_WSEGL.suprx");
|
||||
|
||||
PVRSRVCreateVirtualAppHint(&hint);
|
||||
}
|
||||
|
||||
return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType) 0, 0);
|
||||
}
|
||||
|
||||
SDL_GLContext
|
||||
VITA_GL_CreateContext(_THIS, SDL_Window * window)
|
||||
{
|
||||
return SDL_EGL_CreateContext(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
|
||||
}
|
||||
|
||||
int
|
||||
VITA_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
||||
{
|
||||
if (window && context) {
|
||||
return SDL_EGL_MakeCurrent(_this, ((SDL_WindowData *) window->driverdata)->egl_surface, context);
|
||||
} else {
|
||||
return SDL_EGL_MakeCurrent(_this, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
VITA_GL_SwapWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
|
||||
if (videodata->ime_active) {
|
||||
sceImeUpdate();
|
||||
}
|
||||
return SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
|
||||
}
|
||||
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_VITA && SDL_VIDEO_VITA_PVR */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
35
externals/SDL/src/video/vita/SDL_vitagl_pvr_c.h
vendored
Executable file
35
externals/SDL/src/video/vita/SDL_vitagl_pvr_c.h
vendored
Executable file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 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 "SDL_vitavideo.h"
|
||||
|
||||
extern int VITA_GL_MakeCurrent(_THIS,SDL_Window * window, SDL_GLContext context);
|
||||
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);
|
||||
|
||||
|
||||
#endif /* SDL_vitagl_c_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -42,6 +42,9 @@ Uint8 lock_key_down = 0;
|
||||
void
|
||||
VITA_InitKeyboard(void)
|
||||
{
|
||||
#if defined(SDL_VIDEO_VITA_PVR)
|
||||
sceSysmoduleLoadModule(SCE_SYSMODULE_IME); /** For PVR OSK Support **/
|
||||
#endif
|
||||
sceHidKeyboardEnumerate(&keyboard_hid_handle, 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
||||
2
externals/SDL/src/video/vita/SDL_vitamouse.c
vendored
2
externals/SDL/src/video/vita/SDL_vitamouse.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
||||
14
externals/SDL/src/video/vita/SDL_vitatouch.c
vendored
14
externals/SDL/src/video/vita/SDL_vitatouch.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -42,9 +42,15 @@ struct{
|
||||
float range;
|
||||
} force_info[SCE_TOUCH_PORT_MAX_NUM];
|
||||
|
||||
char* disableFrontPoll = NULL;
|
||||
char* disableBackPoll = NULL;
|
||||
|
||||
void
|
||||
VITA_InitTouch(void)
|
||||
{
|
||||
disableFrontPoll = SDL_getenv("VITA_DISABLE_TOUCH_FRONT");
|
||||
disableBackPoll = SDL_getenv("VITA_DISABLE_TOUCH_BACK");
|
||||
|
||||
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);
|
||||
@@ -84,9 +90,13 @@ VITA_PollTouch(void)
|
||||
if (Vita_Window == NULL)
|
||||
return;
|
||||
|
||||
memcpy(touch_old, touch, sizeof(touch_old));
|
||||
SDL_memcpy(touch_old, touch, sizeof(touch_old));
|
||||
|
||||
for(port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) {
|
||||
/** Skip polling of Touch Device if environment variable is set **/
|
||||
if (((port == 0) && disableFrontPoll) || ((port == 1) && disableBackPoll)) {
|
||||
continue;
|
||||
}
|
||||
sceTouchPeek(port, &touch[port], 1);
|
||||
if (touch[port].reportNum > 0) {
|
||||
for (int i = 0; i < touch[port].reportNum; i++)
|
||||
|
||||
2
externals/SDL/src/video/vita/SDL_vitatouch.h
vendored
2
externals/SDL/src/video/vita/SDL_vitatouch.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
||||
279
externals/SDL/src/video/vita/SDL_vitavideo.c
vendored
279
externals/SDL/src/video/vita/SDL_vitavideo.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2015 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -33,15 +33,24 @@
|
||||
#include "../../events/SDL_keyboard_c.h"
|
||||
|
||||
/* VITA declarations */
|
||||
#include <psp2/kernel/processmgr.h>
|
||||
#include "SDL_vitavideo.h"
|
||||
#include "SDL_vitatouch.h"
|
||||
#include "SDL_vitakeyboard.h"
|
||||
#include "SDL_vitamouse_c.h"
|
||||
#include "SDL_vitaframebuffer.h"
|
||||
#if SDL_VIDEO_VITA_PIB
|
||||
#include "SDL_vitagl_c.h"
|
||||
|
||||
#if defined(SDL_VIDEO_VITA_PIB)
|
||||
#include "SDL_vitagl_c.h"
|
||||
#elif defined(SDL_VIDEO_VITA_PVR)
|
||||
#include "SDL_vitagl_pvr_c.h"
|
||||
#include "../SDL_egl_c.h"
|
||||
#define VITA_GL_GetProcAddress SDL_EGL_GetProcAddress
|
||||
#define VITA_GL_UnloadLibrary SDL_EGL_UnloadLibrary
|
||||
#define VITA_GL_SetSwapInterval SDL_EGL_SetSwapInterval
|
||||
#define VITA_GL_GetSwapInterval SDL_EGL_GetSwapInterval
|
||||
#define VITA_GL_DeleteContext SDL_EGL_DeleteContext
|
||||
#endif
|
||||
#include <psp2/ime_dialog.h>
|
||||
|
||||
SDL_Window *Vita_Window;
|
||||
|
||||
@@ -130,7 +139,7 @@ VITA_Create()
|
||||
device->DestroyWindowFramebuffer = VITA_DestroyWindowFramebuffer;
|
||||
*/
|
||||
|
||||
#if SDL_VIDEO_VITA_PIB
|
||||
#if defined(SDL_VIDEO_VITA_PIB) || defined(SDL_VIDEO_VITA_PVR)
|
||||
device->GL_LoadLibrary = VITA_GL_LoadLibrary;
|
||||
device->GL_GetProcAddress = VITA_GL_GetProcAddress;
|
||||
device->GL_UnloadLibrary = VITA_GL_UnloadLibrary;
|
||||
@@ -166,11 +175,32 @@ VITA_VideoInit(_THIS)
|
||||
{
|
||||
SDL_VideoDisplay display;
|
||||
SDL_DisplayMode current_mode;
|
||||
|
||||
#if defined(SDL_VIDEO_VITA_PVR)
|
||||
char* res = SDL_getenv("VITA_RESOLUTION");
|
||||
#endif
|
||||
SDL_zero(current_mode);
|
||||
|
||||
current_mode.w = 960;
|
||||
current_mode.h = 544;
|
||||
#if defined(SDL_VIDEO_VITA_PVR)
|
||||
if (res) {
|
||||
/* 1088i for PSTV (Or Sharpscale) */
|
||||
if (!SDL_strncmp(res, "1080", 4)) {
|
||||
current_mode.w = 1920;
|
||||
current_mode.h = 1088;
|
||||
}
|
||||
/* 725p for PSTV (Or Sharpscale) */
|
||||
else if (!SDL_strncmp(res, "720", 3)) {
|
||||
current_mode.w = 1280;
|
||||
current_mode.h = 725;
|
||||
}
|
||||
}
|
||||
/* 544p */
|
||||
else {
|
||||
#endif
|
||||
current_mode.w = 960;
|
||||
current_mode.h = 544;
|
||||
#if defined(SDL_VIDEO_VITA_PVR)
|
||||
}
|
||||
#endif
|
||||
|
||||
current_mode.refresh_rate = 60;
|
||||
/* 32 bpp for default */
|
||||
@@ -213,6 +243,9 @@ int
|
||||
VITA_CreateWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_WindowData *wdata;
|
||||
#if defined(SDL_VIDEO_VITA_PVR)
|
||||
Psp2NativeWindow win;
|
||||
#endif
|
||||
|
||||
/* Allocate window internal data */
|
||||
wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
|
||||
@@ -232,6 +265,32 @@ VITA_CreateWindow(_THIS, SDL_Window * window)
|
||||
|
||||
Vita_Window = window;
|
||||
|
||||
#if defined(SDL_VIDEO_VITA_PVR)
|
||||
win.type = PSP2_DRAWABLE_TYPE_WINDOW;
|
||||
win.numFlipBuffers = 2;
|
||||
win.flipChainThrdAffinity = 0x20000;
|
||||
|
||||
/* 1088i for PSTV (Or Sharpscale) */
|
||||
if (window->w == 1920) {
|
||||
win.windowSize = PSP2_WINDOW_1920X1088;
|
||||
}
|
||||
/* 725p for PSTV (Or Sharpscale) */
|
||||
else if (window->w == 1280) {
|
||||
win.windowSize = PSP2_WINDOW_1280X725;
|
||||
}
|
||||
/* 544p */
|
||||
else {
|
||||
win.windowSize = PSP2_WINDOW_960X544;
|
||||
}
|
||||
if ((window->flags & SDL_WINDOW_OPENGL) != 0) {
|
||||
wdata->egl_surface = SDL_EGL_CreateSurface(_this, &win);
|
||||
|
||||
if (wdata->egl_surface == EGL_NO_SURFACE) {
|
||||
return SDL_SetError("Could not create GLES window surface");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// fix input, we need to find a better way
|
||||
SDL_SetKeyboardFocus(window);
|
||||
|
||||
@@ -288,8 +347,8 @@ VITA_RestoreWindow(_THIS, SDL_Window * window)
|
||||
void
|
||||
VITA_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
VITA_DestroyWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
@@ -333,63 +392,6 @@ SDL_bool VITA_HasScreenKeyboardSupport(_THIS)
|
||||
#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++) {
|
||||
@@ -414,15 +416,157 @@ static void utf16_to_utf8(const uint16_t *src, uint8_t *dst) {
|
||||
*dst = '\0';
|
||||
}
|
||||
|
||||
void VITA_PumpEvents(_THIS)
|
||||
#if defined (SDL_VIDEO_VITA_PVR)
|
||||
SceWChar16 libime_out[SCE_IME_MAX_PREEDIT_LENGTH + SCE_IME_MAX_TEXT_LENGTH + 1];
|
||||
char libime_initval[8] = { 1 };
|
||||
SceImeCaret caret_rev;
|
||||
|
||||
void VITA_ImeEventHandler(void *arg, const SceImeEventData *e)
|
||||
{
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)arg;
|
||||
SDL_Scancode scancode;
|
||||
uint8_t utf8_buffer[SCE_IME_MAX_TEXT_LENGTH];
|
||||
switch (e->id) {
|
||||
case SCE_IME_EVENT_UPDATE_TEXT:
|
||||
if (e->param.text.caretIndex == 0) {
|
||||
SDL_SendKeyboardKeyAutoRelease(SDL_SCANCODE_BACKSPACE);
|
||||
sceImeSetText((SceWChar16 *)libime_initval, 4);
|
||||
}
|
||||
else {
|
||||
scancode = SDL_GetScancodeFromKey(*(SceWChar16 *)&libime_out[1]);
|
||||
if (scancode == SDL_SCANCODE_SPACE) {
|
||||
SDL_SendKeyboardKeyAutoRelease(SDL_SCANCODE_SPACE);
|
||||
}
|
||||
else {
|
||||
utf16_to_utf8((SceWChar16 *)&libime_out[1], utf8_buffer);
|
||||
SDL_SendKeyboardText((const char*)utf8_buffer);
|
||||
}
|
||||
SDL_memset(&caret_rev, 0, sizeof(SceImeCaret));
|
||||
SDL_memset(libime_out, 0, ((SCE_IME_MAX_PREEDIT_LENGTH + SCE_IME_MAX_TEXT_LENGTH + 1) * sizeof(SceWChar16)));
|
||||
caret_rev.index = 1;
|
||||
sceImeSetCaret(&caret_rev);
|
||||
sceImeSetText((SceWChar16 *)libime_initval, 4);
|
||||
}
|
||||
break;
|
||||
case SCE_IME_EVENT_PRESS_ENTER:
|
||||
SDL_SendKeyboardKeyAutoRelease(SDL_SCANCODE_RETURN);
|
||||
case SCE_IME_EVENT_PRESS_CLOSE:
|
||||
sceImeClose();
|
||||
videodata->ime_active = SDL_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void VITA_ShowScreenKeyboard(_THIS, SDL_Window *window)
|
||||
{
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
|
||||
SceInt32 res;
|
||||
|
||||
#if defined(SDL_VIDEO_VITA_PVR)
|
||||
|
||||
SceUInt32 libime_work[SCE_IME_WORK_BUFFER_SIZE / sizeof(SceInt32)];
|
||||
SceImeParam param;
|
||||
|
||||
sceImeParamInit(¶m);
|
||||
|
||||
SDL_memset(libime_out, 0, ((SCE_IME_MAX_PREEDIT_LENGTH + SCE_IME_MAX_TEXT_LENGTH + 1) * sizeof(SceWChar16)));
|
||||
|
||||
param.supportedLanguages = SCE_IME_LANGUAGE_ENGLISH_US;
|
||||
param.languagesForced = SCE_FALSE;
|
||||
param.type = SCE_IME_TYPE_DEFAULT;
|
||||
param.option = SCE_IME_OPTION_NO_ASSISTANCE;
|
||||
param.inputTextBuffer = libime_out;
|
||||
param.maxTextLength = SCE_IME_MAX_TEXT_LENGTH;
|
||||
param.handler = VITA_ImeEventHandler;
|
||||
param.filter = NULL;
|
||||
param.initialText = (SceWChar16 *)libime_initval;
|
||||
param.arg = videodata;
|
||||
param.work = libime_work;
|
||||
|
||||
res = sceImeOpen(¶m);
|
||||
if (res < 0) {
|
||||
SDL_SetError("Failed to init IME");
|
||||
return;
|
||||
}
|
||||
|
||||
#else
|
||||
SceWChar16 *title = u"";
|
||||
SceWChar16 *text = u"";
|
||||
|
||||
SceImeDialogParam param;
|
||||
sceImeDialogParamInit(¶m);
|
||||
|
||||
param.supportedLanguages = 0;
|
||||
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;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
videodata->ime_active = SDL_TRUE;
|
||||
}
|
||||
|
||||
void VITA_HideScreenKeyboard(_THIS, SDL_Window *window)
|
||||
{
|
||||
#if !defined(SDL_VIDEO_VITA_PVR)
|
||||
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;
|
||||
#endif
|
||||
}
|
||||
|
||||
SDL_bool VITA_IsScreenKeyboardShown(_THIS, SDL_Window *window)
|
||||
{
|
||||
#if defined(SDL_VIDEO_VITA_PVR)
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
|
||||
return videodata->ime_active;
|
||||
#else
|
||||
SceCommonDialogStatus dialogStatus = sceImeDialogGetStatus();
|
||||
return (dialogStatus == SCE_COMMON_DIALOG_STATUS_RUNNING);
|
||||
#endif
|
||||
}
|
||||
|
||||
void VITA_PumpEvents(_THIS)
|
||||
{
|
||||
#if !defined(SDL_VIDEO_VITA_PVR)
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
|
||||
#endif
|
||||
|
||||
if (_this->suspend_screensaver) {
|
||||
// cancel all idle timers to prevent vita going to sleep
|
||||
sceKernelPowerTick(SCE_KERNEL_POWER_TICK_DEFAULT);
|
||||
}
|
||||
|
||||
VITA_PollTouch();
|
||||
VITA_PollKeyboard();
|
||||
VITA_PollMouse();
|
||||
|
||||
#if !defined(SDL_VIDEO_VITA_PVR)
|
||||
if (videodata->ime_active == SDL_TRUE) {
|
||||
// update IME status. Terminate, if finished
|
||||
SceCommonDialogStatus dialogStatus = sceImeDialogGetStatus();
|
||||
@@ -449,6 +593,7 @@ void VITA_PumpEvents(_THIS)
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_VITA */
|
||||
|
||||
10
externals/SDL/src/video/vita/SDL_vitavideo.h
vendored
10
externals/SDL/src/video/vita/SDL_vitavideo.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2015 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -24,10 +24,12 @@
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../SDL_egl_c.h"
|
||||
|
||||
#include <psp2/types.h>
|
||||
#include <psp2/display.h>
|
||||
#include <psp2/ime_dialog.h>
|
||||
#include <psp2/sysmodule.h>
|
||||
|
||||
typedef struct SDL_VideoData
|
||||
{
|
||||
@@ -36,7 +38,6 @@ typedef struct SDL_VideoData
|
||||
|
||||
SceWChar16 ime_buffer[SCE_IME_DIALOG_MAX_TEXT_LENGTH];
|
||||
SDL_bool ime_active;
|
||||
|
||||
} SDL_VideoData;
|
||||
|
||||
|
||||
@@ -51,7 +52,10 @@ typedef struct SDL_WindowData
|
||||
SDL_bool uses_gles;
|
||||
SceUID buffer_uid;
|
||||
void* buffer;
|
||||
|
||||
#if defined(SDL_VIDEO_VITA_PVR)
|
||||
EGLSurface egl_surface;
|
||||
EGLContext egl_context;
|
||||
#endif
|
||||
} SDL_WindowData;
|
||||
|
||||
extern SDL_Window * Vita_Window;
|
||||
|
||||
Reference in New Issue
Block a user