Skip to content

Commit

Permalink
VITASDK compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
isage authored and slouken committed Mar 8, 2021
1 parent 7d89f09 commit ca5e5d6
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Makefile.vita.dolce
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ PREFIX = arm-dolce-eabi
CC = $(PREFIX)-gcc
AR = $(PREFIX)-ar
CFLAGS = -g -Wl,-q -Wall -O3 -Iinclude \
-D__VITA__ -D__ARM_ARCH=7 -D__ARM_ARCH_7A__ \
-D__VITA__ -DDOLCEVITA -D__ARM_ARCH=7 -D__ARM_ARCH_7A__ \
-mfpu=neon -mcpu=cortex-a9 -mfloat-abi=hard
ASFLAGS = $(CFLAGS)

Expand Down
59 changes: 59 additions & 0 deletions Makefile.vita.vita
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Based on port by xerpi
# Makefile to build the SDL library

TARGET_LIB = libSDL2.a

SOURCES = \
src/*.c \
src/atomic/*.c \
src/audio/*.c \
src/audio/vita/*.c \
src/cpuinfo/*.c \
src/events/*.c \
src/file/*.c \
src/haptic/*.c \
src/haptic/dummy/*.c \
src/joystick/*.c \
src/joystick/vita/*.c \
src/loadso/dummy/*.c \
src/power/*.c \
src/power/vita/*.c \
src/filesystem/vita/*.c \
src/render/*.c \
src/render/software/*.c \
src/render/vitagxm/*.c \
src/sensor/*.c \
src/sensor/vita/*.c \
src/stdlib/*.c \
src/thread/*.c \
src/thread/generic/SDL_systls.c \
src/thread/vita/*.c \
src/timer/*.c \
src/timer/vita/*.c \
src/video/*.c \
src/video/vita/*.c \
src/video/yuv2rgb/*.c \
src/video/arm/*.S \

OBJS = $(shell echo $(SOURCES) | sed -e 's,\.c,\.o,g' | sed -e 's,\.S,\.o,g')

PREFIX = arm-vita-eabi
CC = $(PREFIX)-gcc
AR = $(PREFIX)-ar
CFLAGS = -g -Wl,-q -Wall -O3 -Iinclude \
-D__VITA__ -DSCE_OK=0 -D__ARM_ARCH=7 -D__ARM_ARCH_7A__ \
-mfpu=neon -mcpu=cortex-a9 -mfloat-abi=hard
ASFLAGS = $(CFLAGS)

$(TARGET_LIB): $(OBJS)
$(AR) rcs $@ $^

clean:
@rm -f $(TARGET_LIB) $(OBJS)

install: $(TARGET_LIB)
@mkdir -p "$(DESTDIR)$(VITASDK)/arm-vita-eabi/lib"
@cp $(TARGET_LIB) $(DESTDIR)$(VITASDK)/arm-vita-eabi/lib
@mkdir -p "$(DESTDIR)$(VITASDK)/arm-vita-eabi/include/SDL2"
@cp include/*.h "$(DESTDIR)$(VITASDK)/arm-vita-eabi/include/SDL2"
@echo "Installed!"
9 changes: 2 additions & 7 deletions include/SDL_config_vita.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,11 @@
#define SDL_FILESYSTEM_VITA 1
#define SDL_SENSOR_VITA 1

//#if defined(_VITA_GLES2_)
#if defined(DOLCEVITA)
#define SDL_VIDEO_RENDER_VITA_GLES2 1
//#else
#define SDL_VIDEO_RENDER_VITA_GXM 1
//#endif

#if defined(SDL_VIDEO_RENDER_VITA_GLES2) || defined(SDL_VIDEO_RENDER_VITA_GXM)
#define SDL_VIDEO_OPENGL_ES2 1
#endif

#define SDL_VIDEO_RENDER_VITA_GXM 1

/* VITA doesn't have haptic device (src/haptic/dummy/\*.c) */
#define SDL_HAPTIC_DISABLED 1
Expand Down
2 changes: 1 addition & 1 deletion include/SDL_stdinc.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);

/** \cond */
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
#if !defined(__ANDROID__)
#if !defined(__ANDROID__) && !defined(__VITA__)
/* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */
typedef enum
{
Expand Down
4 changes: 4 additions & 0 deletions src/filesystem/vita/SDL_sysfilesystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#if DOLCEVITA
#include <psp2/kernel/iofilemgr.h>
#else
#include <psp2/io/stat.h>
#endif
#include <sys/types.h>
#include <limits.h>
#include <fcntl.h>
Expand Down
6 changes: 6 additions & 0 deletions src/sensor/vita/SDL_vitasensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@
#include "SDL_vitasensor.h"
#include "../SDL_syssensor.h"
#include <psp2/motion.h>
#if DOLCEVITA
#include <psp2/error.h>
#endif

#if !defined(SCE_MOTION_MAX_NUM_STATES)
#define SCE_MOTION_MAX_NUM_STATES 64
#endif

typedef struct
{
Expand Down
2 changes: 1 addition & 1 deletion src/video/vita/SDL_vitagl.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"

#if SDL_VIDEO_DRIVER_VITA
#if SDL_VIDEO_DRIVER_VITA && SDL_VIDEO_OPENGL_ES2

#include <stdlib.h>
#include <string.h>
Expand Down
14 changes: 12 additions & 2 deletions src/video/vita/SDL_vitavideo.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
#include "SDL_vitatouch.h"
#include "SDL_vitakeyboard.h"
#include "SDL_vitamouse_c.h"
#if SDLVIDEO_OPENGL_ES2
#include "SDL_vitagl_c.h"

#endif
#include <psp2/ime_dialog.h>

SDL_Window *Vita_Window;
Expand Down Expand Up @@ -66,8 +67,9 @@ VITA_Create()
{
SDL_VideoDevice *device;
SDL_VideoData *phdata;
#if SDLVIDEO_OPENGL_ES2
SDL_GLDriverData *gldata;

#endif
/* Initialize SDL_VideoDevice structure */
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
if (device == NULL) {
Expand All @@ -82,6 +84,7 @@ VITA_Create()
SDL_free(device);
return NULL;
}
#if SDLVIDEO_OPENGL_ES2

gldata = (SDL_GLDriverData *) SDL_calloc(1, sizeof(SDL_GLDriverData));
if (gldata == NULL) {
Expand All @@ -92,6 +95,7 @@ VITA_Create()
}
device->gl_data = gldata;
phdata->egl_initialized = SDL_TRUE;
#endif
phdata->ime_active = SDL_FALSE;

device->driverdata = phdata;
Expand Down Expand Up @@ -123,6 +127,7 @@ VITA_Create()
device->DestroyWindow = VITA_DestroyWindow;
device->GetWindowWMInfo = VITA_GetWindowWMInfo;

#if SDL_VIDEO_OPENGL_ES2
device->GL_LoadLibrary = VITA_GL_LoadLibrary;
device->GL_GetProcAddress = VITA_GL_GetProcAddress;
device->GL_UnloadLibrary = VITA_GL_UnloadLibrary;
Expand All @@ -132,6 +137,7 @@ VITA_Create()
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;
Expand Down Expand Up @@ -321,6 +327,10 @@ 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;
Expand Down

0 comments on commit ca5e5d6

Please sign in to comment.