1 parent
435d6af214
commit
8c1c80cf63
13 files changed
+338
-353
No files matched your search
+4
-10
@@ -29,8 +29,6 @@ ifndef NOHW
|
||||
sources+=sdl/ogl_sdl.c
|
||||
endif
|
||||
|
||||
NOMIXER=1
|
||||
|
||||
ifdef NOMIXER
|
||||
sources+=sdl/dummy_sound.c
|
||||
else
|
||||
@@ -48,16 +46,12 @@ sources+=sdl/i_threads.c
|
||||
endif
|
||||
|
||||
ifdef SDL_PKGCONFIG
|
||||
$(eval $(call Use_pkg_config,SDL3))
|
||||
$(eval $(call Use_pkg_config,SDL))
|
||||
else
|
||||
#FIXME: this is def not correct
|
||||
SDL_CFLAGS := -I/usr/local/include/SDL3
|
||||
SDL_LDFLAGS := -L/usr/local/lib -lSDL3
|
||||
#SDL_CONFIG?=$(call Prefix,sdl2-config)
|
||||
#SDL_CFLAGS?=$(shell $(SDL_CONFIG) --cflags)
|
||||
#SDL_LDFLAGS?=$(shell $(SDL_CONFIG) \
|
||||
SDL_CONFIG?=$(call Prefix,sdl2-config)
|
||||
SDL_CFLAGS?=$(shell $(SDL_CONFIG) --cflags)
|
||||
SDL_LDFLAGS?=$(shell $(SDL_CONFIG) \
|
||||
$(if $(STATIC),--static-libs,--libs))
|
||||
|
||||
$(eval $(call Propogate_flags,SDL))
|
||||
endif
|
||||
|
||||
|
||||
@@ -79,14 +79,14 @@ $(eval $(call _set,LIBOPENMPT))
|
||||
lib:=../libs/SDL2_mixer/$(mingw)
|
||||
|
||||
ifdef SDL
|
||||
mixer_opts:=-I$(lib)/include/SDL3
|
||||
mixer_opts:=-I$(lib)/include/SDL2
|
||||
mixer_libs:=-L$(lib)/lib
|
||||
|
||||
lib:=../libs/SDL2/$(mingw)
|
||||
SDL_opts:=-I$(lib)/include/SDL3\
|
||||
SDL_opts:=-I$(lib)/include/SDL2\
|
||||
$(mixer_opts) -Dmain=SDL_main
|
||||
SDL_libs:=-L$(lib)/lib $(mixer_libs)\
|
||||
-lmingw32 -lSDL3main -lSDL3 -mwindows
|
||||
-lmingw32 -lSDL2main -lSDL2 -mwindows
|
||||
$(eval $(call _set,SDL))
|
||||
endif
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ extern "C" {
|
||||
#ifdef HAVE_SDL
|
||||
#define _MATH_DEFINES_DEFINED
|
||||
|
||||
#include <SDL3/SDL_opengl.h> //Alam_GBC: Simple, yes?
|
||||
#include "SDL_opengl.h" //Alam_GBC: Simple, yes?
|
||||
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
|
||||
+2
-2
@@ -88,8 +88,8 @@
|
||||
#include "z_zone.h"
|
||||
#include "mserv.h"
|
||||
|
||||
#if defined (HAVE_SDL)
|
||||
#include <SDL3/SDL.h>
|
||||
#if defined(HAVE_SDL)
|
||||
#include "SDL.h"
|
||||
#if SDL_VERSION_ATLEAST(2,0,0)
|
||||
#include "sdl/sdlmain.h" // JOYSTICK_HOTPLUG
|
||||
#endif
|
||||
|
||||
+24
-25
@@ -46,8 +46,8 @@
|
||||
#include "SDL_image.h"
|
||||
#else
|
||||
// SDLCALL terms removed from original SDL_image declarations
|
||||
int IMG_isXPM(SDL_IOStream *src);
|
||||
SDL_Surface *IMG_LoadXPM_RW(SDL_IOStream *src);
|
||||
int IMG_isXPM(SDL_RWops *src);
|
||||
SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src);
|
||||
SDL_Surface *IMG_ReadXPMFromArray(const char **xpm);
|
||||
#define IMG_SetError SDL_SetError
|
||||
#define IMG_GetError SDL_GetError
|
||||
@@ -56,7 +56,7 @@ SDL_Surface *IMG_ReadXPMFromArray(const char **xpm);
|
||||
#ifdef LOAD_XPM
|
||||
|
||||
/* See if an image is contained in a data source */
|
||||
int IMG_isXPM(SDL_IOStream *src)
|
||||
int IMG_isXPM(SDL_RWops *src)
|
||||
{
|
||||
Sint64 start;
|
||||
int is_XPM;
|
||||
@@ -64,14 +64,14 @@ int IMG_isXPM(SDL_IOStream *src)
|
||||
|
||||
if ( !src )
|
||||
return 0;
|
||||
start = SDL_TellIO(src);
|
||||
start = SDL_RWtell(src);
|
||||
is_XPM = 0;
|
||||
if ( SDL_ReadIO(src, magic, sizeof(magic)) ) {
|
||||
if ( SDL_RWread(src, magic, sizeof(magic), 1) ) {
|
||||
if ( SDL_memcmp(magic, "/* XPM */", sizeof(magic)) == 0 ) {
|
||||
is_XPM = 1;
|
||||
}
|
||||
}
|
||||
SDL_SeekIO(src, start, SDL_IO_SEEK_SET);
|
||||
SDL_RWseek(src, start, RW_SEEK_SET);
|
||||
return(is_XPM);
|
||||
}
|
||||
|
||||
@@ -933,7 +933,7 @@ static const char *error;
|
||||
* If len > 0, it's assumed to be at least len chars (for efficiency).
|
||||
* Return NULL and set error upon EOF or parse error.
|
||||
*/
|
||||
static const char *get_next_line(const char ***lines, SDL_IOStream *src, int len)
|
||||
static const char *get_next_line(const char ***lines, SDL_RWops *src, int len)
|
||||
{
|
||||
char *linebufnew;
|
||||
|
||||
@@ -943,7 +943,7 @@ static const char *get_next_line(const char ***lines, SDL_IOStream *src, int len
|
||||
char c;
|
||||
int n;
|
||||
do {
|
||||
if (SDL_ReadIO(src, &c, 1) <= 0) {
|
||||
if (SDL_RWread(src, &c, 1, 1) <= 0) {
|
||||
error = "Premature end of data";
|
||||
return NULL;
|
||||
}
|
||||
@@ -960,7 +960,7 @@ static const char *get_next_line(const char ***lines, SDL_IOStream *src, int len
|
||||
}
|
||||
linebuf = linebufnew;
|
||||
}
|
||||
if (SDL_ReadIO(src, linebuf, len - 1) <= 0) {
|
||||
if (SDL_RWread(src, linebuf, len - 1, 1) <= 0) {
|
||||
error = "Premature end of data";
|
||||
return NULL;
|
||||
}
|
||||
@@ -980,7 +980,7 @@ static const char *get_next_line(const char ***lines, SDL_IOStream *src, int len
|
||||
}
|
||||
linebuf = linebufnew;
|
||||
}
|
||||
if (SDL_ReadIO(src, linebuf + n, 1) <= 0) {
|
||||
if (SDL_RWread(src, linebuf + n, 1, 1) <= 0) {
|
||||
error = "Premature end of data";
|
||||
return NULL;
|
||||
}
|
||||
@@ -1005,7 +1005,7 @@ do { \
|
||||
} while (0)
|
||||
|
||||
/* read XPM from either array or RWops */
|
||||
static SDL_Surface *load_xpm(const char **xpm, SDL_IOStream *src)
|
||||
static SDL_Surface *load_xpm(const char **xpm, SDL_RWops *src)
|
||||
{
|
||||
Sint64 start = 0;
|
||||
SDL_Surface *image = NULL;
|
||||
@@ -1027,7 +1027,7 @@ static SDL_Surface *load_xpm(const char **xpm, SDL_IOStream *src)
|
||||
buflen = 0;
|
||||
|
||||
if (src)
|
||||
start = SDL_TellIO(src);
|
||||
start = SDL_RWtell(src);
|
||||
|
||||
if (xpm)
|
||||
xpmlines = &xpm;
|
||||
@@ -1065,15 +1065,14 @@ static SDL_Surface *load_xpm(const char **xpm, SDL_IOStream *src)
|
||||
/* Create the new surface */
|
||||
if (ncolors <= 256) {
|
||||
indexed = 1;
|
||||
image = SDL_CreateSurface(w, h,
|
||||
SDL_PIXELFORMAT_INDEX8);
|
||||
SDL_Palette *palette = SDL_CreateSurfacePalette(image);
|
||||
im_colors = palette->colors;
|
||||
palette->ncolors = ncolors;
|
||||
image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 8,
|
||||
0, 0, 0, 0);
|
||||
im_colors = image->format->palette->colors;
|
||||
image->format->palette->ncolors = ncolors;
|
||||
} else {
|
||||
indexed = 0;
|
||||
image = SDL_CreateSurface(w, h,
|
||||
SDL_GetPixelFormatForMasks(32, 0xff0000, 0x00ff00, 0x0000ff, 0));
|
||||
image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32,
|
||||
0xff0000, 0x00ff00, 0x0000ff, 0);
|
||||
}
|
||||
if (!image) {
|
||||
/* Hmm, some SDL error (out of memory?) */
|
||||
@@ -1129,7 +1128,7 @@ static SDL_Surface *load_xpm(const char **xpm, SDL_IOStream *src)
|
||||
add_colorhash(colors, nextkey, cpp, pixel);
|
||||
nextkey += cpp;
|
||||
if (rgb == 0xffffffff)
|
||||
SDL_SetSurfaceColorKey(image, true, pixel);
|
||||
SDL_SetColorKey(image, SDL_TRUE, pixel);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1165,9 +1164,9 @@ static SDL_Surface *load_xpm(const char **xpm, SDL_IOStream *src)
|
||||
done:
|
||||
if (error) {
|
||||
if ( src )
|
||||
SDL_SeekIO(src, start, SDL_IO_SEEK_SET);
|
||||
SDL_RWseek(src, start, RW_SEEK_SET);
|
||||
if ( image ) {
|
||||
SDL_DestroySurface(image);
|
||||
SDL_FreeSurface(image);
|
||||
image = NULL;
|
||||
}
|
||||
IMG_SetError("%s", error);
|
||||
@@ -1181,7 +1180,7 @@ done:
|
||||
}
|
||||
|
||||
/* Load a XPM type image from an RWops datasource */
|
||||
SDL_Surface *IMG_LoadXPM_RW(SDL_IOStream *src)
|
||||
SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src)
|
||||
{
|
||||
if ( !src ) {
|
||||
/* The error message has been set in SDL_RWFromFile */
|
||||
@@ -1204,14 +1203,14 @@ SDL_Surface *IMG_ReadXPMFromArray(const char **xpm)
|
||||
#else /* not LOAD_XPM */
|
||||
|
||||
/* See if an image is contained in a data source */
|
||||
int IMG_isXPM(SDL_IOStream *src)
|
||||
int IMG_isXPM(SDL_RWops *src)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/* Load a XPM type image from an SDL datasource */
|
||||
SDL_Surface *IMG_LoadXPM_RW(SDL_IOStream *src)
|
||||
SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
+2
-2
@@ -27,10 +27,10 @@
|
||||
|
||||
#ifdef HAVE_SDL
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include "SDL.h"
|
||||
|
||||
#ifndef NOLOADSO
|
||||
#include <SDL3/SDL_loadso.h>
|
||||
#include "SDL_loadso.h"
|
||||
#endif
|
||||
|
||||
#define _CREATE_DLL_ // necessary for Unix AND Windows
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
#ifdef HAVE_SDL
|
||||
|
||||
#ifdef HAVE_TTF
|
||||
#include <SDL3/SDL.h>
|
||||
#include "SDL.h"
|
||||
#include "i_ttf.h"
|
||||
#endif
|
||||
|
||||
|
||||
+50
-52
@@ -73,15 +73,13 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
|
||||
|
||||
#ifdef HAVE_SDL
|
||||
#define _MATH_DEFINES_DEFINED
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_joystick.h>
|
||||
#include <SDL3/SDL_gamepad.h>
|
||||
#include "SDL.h"
|
||||
|
||||
#ifdef HAVE_TTF
|
||||
#include "i_ttf.h"
|
||||
#endif
|
||||
|
||||
#include <SDL3/SDL_cpuinfo.h>
|
||||
#include "SDL_cpuinfo.h"
|
||||
#define HAVE_SDLCPUINFO
|
||||
|
||||
#if defined (__unix__) || defined(__APPLE__) || (defined (UNIXCOMMON) && !defined (__HAIKU__))
|
||||
@@ -221,13 +219,13 @@ static char returnWadPath[256];
|
||||
#include "../byteptr.h"
|
||||
#endif
|
||||
|
||||
bool consolevent = false;
|
||||
bool framebuffer = false;
|
||||
SDL_bool consolevent = SDL_FALSE;
|
||||
SDL_bool framebuffer = SDL_FALSE;
|
||||
UINT8 keyboard_started = false;
|
||||
|
||||
#ifdef HAVE_TERMIOS
|
||||
// TERMIOS console code from Quake3: thank you!
|
||||
bool stdin_active = true;
|
||||
SDL_bool stdin_active = SDL_TRUE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -290,7 +288,7 @@ static void I_ShutdownConsole(void)
|
||||
if (consolevent)
|
||||
{
|
||||
I_OutputMsg("Shutdown tty console\n");
|
||||
consolevent = false;
|
||||
consolevent = SDL_FALSE;
|
||||
tcsetattr(STDIN_FILENO, TCSADRAIN, &tty_tc);
|
||||
}
|
||||
}
|
||||
@@ -305,11 +303,11 @@ static void I_StartupConsole(void)
|
||||
signal(SIGTTIN, SIG_IGN);
|
||||
signal(SIGTTOU, SIG_IGN);
|
||||
|
||||
consolevent = static_cast<bool>(!M_CheckParm("-noconsole"));
|
||||
framebuffer = static_cast<bool>( M_CheckParm("-framebuffer"));
|
||||
consolevent = static_cast<SDL_bool>(!M_CheckParm("-noconsole"));
|
||||
framebuffer = static_cast<SDL_bool>( M_CheckParm("-framebuffer"));
|
||||
|
||||
if (framebuffer)
|
||||
consolevent = false;
|
||||
consolevent = SDL_FALSE;
|
||||
|
||||
if (!consolevent)
|
||||
return;
|
||||
@@ -317,7 +315,7 @@ static void I_StartupConsole(void)
|
||||
if (isatty(STDIN_FILENO)!=1)
|
||||
{
|
||||
I_OutputMsg("stdin is not a tty, tty console mode failed\n");
|
||||
consolevent = false;
|
||||
consolevent = SDL_FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -519,7 +517,7 @@ static void I_StartupConsole(void)
|
||||
if (gotConsole)
|
||||
{
|
||||
SetConsoleTitleA("SRB2Kart Console");
|
||||
consolevent = true;
|
||||
consolevent = SDL_TRUE;
|
||||
}
|
||||
|
||||
//Let get the real console HANDLE, because Mingw's Bash is bad!
|
||||
@@ -552,7 +550,7 @@ static inline void I_StartupConsole(void)
|
||||
framebuffer = M_CheckParm("-framebuffer");
|
||||
|
||||
if (framebuffer)
|
||||
consolevent = false;
|
||||
consolevent = SDL_FALSE;
|
||||
}
|
||||
static inline void I_ShutdownConsole(void){}
|
||||
#endif
|
||||
@@ -701,7 +699,7 @@ void I_OutputMsg(const char *fmt, ...)
|
||||
//
|
||||
// I_GetKey
|
||||
//
|
||||
INT32 I_GetKey(void)
|
||||
INT32 I_GetKey (void)
|
||||
{
|
||||
// Warning: I_GetKey empties the event queue till next keypress
|
||||
event_t *ev;
|
||||
@@ -731,7 +729,7 @@ static void JoyReset(SDLJoyInfo_t *JoySet)
|
||||
{
|
||||
if (JoySet->dev)
|
||||
{
|
||||
SDL_CloseGamepad(JoySet->dev);
|
||||
SDL_GameControllerClose(JoySet->dev);
|
||||
}
|
||||
|
||||
JoySet->dev = NULL;
|
||||
@@ -773,15 +771,15 @@ void I_JoyScale4(void)
|
||||
}
|
||||
|
||||
// Cheat to get the device index for a joystick handle
|
||||
INT32 I_GetJoystickDeviceIndex(SDL_Gamepad *dev)
|
||||
INT32 I_GetJoystickDeviceIndex(SDL_GameController *dev)
|
||||
{
|
||||
SDL_Joystick *joystick = NULL;
|
||||
|
||||
joystick = SDL_GetGamepadJoystick(dev);
|
||||
joystick = SDL_GameControllerGetJoystick(dev);
|
||||
|
||||
if (joystick)
|
||||
{
|
||||
return SDL_GetJoystickID(joystick);
|
||||
return SDL_JoystickInstanceID(joystick);
|
||||
}
|
||||
|
||||
return -1;
|
||||
@@ -891,7 +889,7 @@ void I_ShutdownJoystick(UINT8 index)
|
||||
*/
|
||||
static int joy_open(int playerIndex, int joyIndex)
|
||||
{
|
||||
SDL_Gamepad *newdev = NULL;
|
||||
SDL_GameController *newdev = NULL;
|
||||
int num_joy = 0;
|
||||
|
||||
if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0)
|
||||
@@ -900,7 +898,7 @@ static int joy_open(int playerIndex, int joyIndex)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (SDL_WasInit(SDL_INIT_GAMEPAD) == 0)
|
||||
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == 0)
|
||||
{
|
||||
CONS_Printf(M_GetText("Game Controller subsystem not started\n"));
|
||||
return -1;
|
||||
@@ -909,7 +907,7 @@ static int joy_open(int playerIndex, int joyIndex)
|
||||
if (joyIndex <= 0)
|
||||
return -1;
|
||||
|
||||
SDL_GetJoysticks(&num_joy);
|
||||
num_joy = SDL_NumJoysticks();
|
||||
|
||||
if (num_joy == 0)
|
||||
{
|
||||
@@ -917,7 +915,7 @@ static int joy_open(int playerIndex, int joyIndex)
|
||||
return -1;
|
||||
}
|
||||
|
||||
newdev = SDL_OpenGamepad(joyIndex-1);
|
||||
newdev = SDL_GameControllerOpen(joyIndex-1);
|
||||
|
||||
// Handle the edge case where the device <-> joystick index assignment can change due to hotplugging
|
||||
// This indexing is SDL's responsibility and there's not much we can do about it.
|
||||
@@ -932,8 +930,8 @@ static int joy_open(int playerIndex, int joyIndex)
|
||||
if (JoyInfo[playerIndex].dev)
|
||||
{
|
||||
if (JoyInfo[playerIndex].dev == newdev // same device, nothing to do
|
||||
|| (newdev == NULL && SDL_GamepadConnected(JoyInfo[playerIndex].dev))) // we failed, but already have a working device
|
||||
return SDL_GAMEPAD_AXIS_COUNT;
|
||||
|| (newdev == NULL && SDL_GameControllerGetAttached(JoyInfo[playerIndex].dev))) // we failed, but already have a working device
|
||||
return SDL_CONTROLLER_AXIS_MAX;
|
||||
|
||||
// Else, we're changing devices, so send neutral joy events
|
||||
CONS_Debug(DBG_GAMELOGIC, "Joystick1 device is changing; resetting events...\n");
|
||||
@@ -950,13 +948,13 @@ static int joy_open(int playerIndex, int joyIndex)
|
||||
}
|
||||
else
|
||||
{
|
||||
CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: %s\n"), SDL_GetGamepadName(JoyInfo[playerIndex].dev));
|
||||
JoyInfo[playerIndex].axises = SDL_GAMEPAD_AXIS_COUNT;
|
||||
CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: %s\n"), SDL_GameControllerName(JoyInfo[playerIndex].dev));
|
||||
JoyInfo[playerIndex].axises = SDL_CONTROLLER_AXIS_MAX;
|
||||
|
||||
if (JoyInfo[playerIndex].axises > JOYAXISSET*2)
|
||||
JoyInfo[playerIndex].axises = JOYAXISSET*2;
|
||||
|
||||
JoyInfo[playerIndex].buttons = SDL_GAMEPAD_BUTTON_COUNT; // dpad is 4 buttons
|
||||
JoyInfo[playerIndex].buttons = SDL_CONTROLLER_BUTTON_MAX ; // dpad is 4 buttons
|
||||
if (JoyInfo[playerIndex].buttons > JOYBUTTONS)
|
||||
JoyInfo[playerIndex].buttons = JOYBUTTONS;
|
||||
|
||||
@@ -976,7 +974,7 @@ static int joy_open(int playerIndex, int joyIndex)
|
||||
void I_InitJoystick(UINT8 index)
|
||||
{
|
||||
UINT8 i;
|
||||
SDL_Gamepad *newcontroller = NULL;
|
||||
SDL_GameController *newcontroller = NULL;
|
||||
|
||||
// not sure if this is the best place to put this
|
||||
SDL_SetHint(SDL_HINT_AUTO_UPDATE_SENSORS, "0");
|
||||
@@ -994,16 +992,15 @@ void I_InitJoystick(UINT8 index)
|
||||
{
|
||||
CONS_Printf("I_InitJoystick()...\n");
|
||||
|
||||
if (!SDL_InitSubSystem(SDL_INIT_JOYSTICK))
|
||||
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1)
|
||||
{
|
||||
CONS_Printf(M_GetText("Couldn't initialize joystick: %s\n"), SDL_GetError());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (SDL_WasInit(SDL_INIT_GAMEPAD) == 0)
|
||||
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == 0)
|
||||
{
|
||||
if (!SDL_InitSubSystem(SDL_INIT_GAMEPAD))
|
||||
if (SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) == -1)
|
||||
{
|
||||
CONS_Printf(M_GetText("Couldn't initialize gamepads: %s\n"), SDL_GetError());
|
||||
return;
|
||||
@@ -1016,7 +1013,7 @@ void I_InitJoystick(UINT8 index)
|
||||
JoyInfo[index].axises = JoyInfo[index].buttons = JoyInfo[index].hats = JoyInfo[index].balls = 0;
|
||||
|
||||
if (cv_usejoystick[index].value)
|
||||
newcontroller = SDL_OpenGamepad(cv_usejoystick[index].value-1);
|
||||
newcontroller = SDL_GameControllerOpen(cv_usejoystick[index].value-1);
|
||||
|
||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
{
|
||||
@@ -1056,7 +1053,7 @@ void I_InitJoystick(UINT8 index)
|
||||
if (i == MAXSPLITSCREENPLAYERS)
|
||||
{
|
||||
// Joystick didn't end up being used
|
||||
SDL_CloseGamepad(newcontroller);
|
||||
SDL_GameControllerClose(newcontroller);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1091,10 +1088,10 @@ static void I_ShutdownInput(void)
|
||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
I_ShutdownJoystick(i);
|
||||
|
||||
if (SDL_WasInit(SDL_INIT_GAMEPAD) == SDL_INIT_GAMEPAD)
|
||||
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == SDL_INIT_GAMECONTROLLER)
|
||||
{
|
||||
CONS_Printf("Shutting down gamecontroller system\n");
|
||||
SDL_QuitSubSystem(SDL_INIT_GAMEPAD);
|
||||
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
|
||||
I_OutputMsg("I_Joystick: SDL's Game Controller system has been shutdown\n");
|
||||
}
|
||||
|
||||
@@ -1111,9 +1108,7 @@ INT32 I_NumJoys(void)
|
||||
INT32 numjoy = 0;
|
||||
|
||||
if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK)
|
||||
{
|
||||
SDL_GetJoysticks(&numjoy);
|
||||
}
|
||||
numjoy = SDL_NumJoysticks();
|
||||
|
||||
return numjoy;
|
||||
}
|
||||
@@ -1128,7 +1123,7 @@ const char *I_GetJoyName(INT32 joyindex)
|
||||
|
||||
if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK)
|
||||
{
|
||||
tempname = SDL_GetJoystickNameForID(joyindex);
|
||||
tempname = SDL_JoystickNameForIndex(joyindex);
|
||||
|
||||
if (tempname)
|
||||
{
|
||||
@@ -1148,14 +1143,14 @@ void I_GamepadRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength,
|
||||
(void)high_strength;
|
||||
(void)duration;
|
||||
#else
|
||||
SDL_Gamepad *controller = JoyInfo[playernum].dev;
|
||||
SDL_GameController *controller = JoyInfo[playernum].dev;
|
||||
|
||||
if (controller == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_RumbleGamepad(controller, low_strength, high_strength, duration);
|
||||
SDL_GameControllerRumble(controller, low_strength, high_strength, duration);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1167,14 +1162,14 @@ void I_SetGamepadIndicatorColor(INT32 playernum, UINT8 red, UINT8 green, UINT8 b
|
||||
(void)green;
|
||||
(void)blue;
|
||||
#else
|
||||
SDL_Gamepad *controller = JoyInfo[playernum].dev;
|
||||
SDL_GameController *controller = JoyInfo[playernum].dev;
|
||||
|
||||
if (controller == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_SetGamepadLED(controller, red, green, blue);
|
||||
SDL_GameControllerSetLED(controller, red, green, blue);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1827,7 +1822,10 @@ static void I_Fork(void)
|
||||
|
||||
INT32 I_StartupSystem(void)
|
||||
{
|
||||
int SDLlinked = SDL_GetVersion();
|
||||
SDL_version SDLcompiled;
|
||||
SDL_version SDLlinked;
|
||||
SDL_VERSION(&SDLcompiled)
|
||||
SDL_GetVersion(&SDLlinked);
|
||||
I_StartupConsole();
|
||||
#ifdef NEWSIGNALHANDLER
|
||||
// This is useful when debugging. It lets GDB attach to
|
||||
@@ -1843,15 +1841,15 @@ INT32 I_StartupSystem(void)
|
||||
#endif
|
||||
I_RegisterSignals();
|
||||
I_OutputMsg("Compiled for SDL version: %d.%d.%d\n",
|
||||
SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION);
|
||||
SDLcompiled.major, SDLcompiled.minor, SDLcompiled.patch);
|
||||
I_OutputMsg("Linked with SDL version: %d.%d.%d\n",
|
||||
SDL_VERSIONNUM_MAJOR(SDLlinked), SDL_VERSIONNUM_MINOR(SDLlinked), SDL_VERSIONNUM_MICRO(SDLlinked));
|
||||
SDLlinked.major, SDLlinked.minor, SDLlinked.patch);
|
||||
|
||||
#if (SDL_VERSION_ATLEAST(2, 0, 18))
|
||||
SDL_SetHint(SDL_HINT_APP_NAME, "SRB2Kart Saturn");
|
||||
#endif
|
||||
|
||||
if (!SDL_Init(0))
|
||||
if (SDL_Init(0) < 0)
|
||||
I_Error("SRB2: SDL System Error: %s", SDL_GetError()); //Alam: Oh no....
|
||||
#ifndef NOMUMBLE
|
||||
I_SetupMumble();
|
||||
@@ -1864,12 +1862,12 @@ INT32 I_StartupSystem(void)
|
||||
//
|
||||
FUNCNORETURN void ATTRNORETURN I_Quit(void)
|
||||
{
|
||||
static bool quiting = false;
|
||||
static SDL_bool quiting = SDL_FALSE;
|
||||
|
||||
/* prevent recursive I_Quit() */
|
||||
if (quiting) goto death;
|
||||
SDL_ShowCursor();
|
||||
quiting = false;
|
||||
SDL_ShowCursor(SDL_TRUE);
|
||||
quiting = SDL_FALSE;
|
||||
I_ShutdownConsole();
|
||||
M_SaveConfig(NULL); //save game config, cvars..
|
||||
D_SaveBan(); // save the ban list
|
||||
|
||||
+30
-25
@@ -12,7 +12,7 @@
|
||||
#include "../doomdef.h"
|
||||
#include "../i_threads.h"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL.h>
|
||||
|
||||
typedef void * (*Create_fn)(void);
|
||||
|
||||
@@ -45,7 +45,7 @@ static I_mutex i_thread_pool_mutex;
|
||||
static I_mutex i_mutex_pool_mutex;
|
||||
static I_mutex i_cond_pool_mutex;
|
||||
|
||||
static SDL_AtomicInt i_threads_running = {1};
|
||||
static SDL_atomic_t i_threads_running = {1};
|
||||
|
||||
static Link
|
||||
Insert_link (
|
||||
@@ -103,13 +103,13 @@ Identity (
|
||||
){
|
||||
void * id;
|
||||
|
||||
id = SDL_GetAtomicPointer(anchor);
|
||||
id = SDL_AtomicGetPtr(anchor);
|
||||
|
||||
if (! id)
|
||||
{
|
||||
I_lock_mutex(&pool_mutex);
|
||||
{
|
||||
id = SDL_GetAtomicPointer(anchor);
|
||||
id = SDL_AtomicGetPtr(anchor);
|
||||
|
||||
if (! id)
|
||||
{
|
||||
@@ -120,7 +120,7 @@ Identity (
|
||||
|
||||
Insert_link(pool_anchor, New_link(id));
|
||||
|
||||
SDL_SetAtomicPointer(anchor, id);
|
||||
SDL_AtomicSetPtr(anchor, id);
|
||||
}
|
||||
}
|
||||
I_unlock_mutex(pool_mutex);
|
||||
@@ -139,11 +139,11 @@ Worker (
|
||||
|
||||
(*th->entry)(th->userdata);
|
||||
|
||||
if (SDL_GetAtomicInt(&i_threads_running))
|
||||
if (SDL_AtomicGet(&i_threads_running))
|
||||
{
|
||||
I_lock_mutex(&i_thread_pool_mutex);
|
||||
{
|
||||
if (SDL_GetAtomicInt(&i_threads_running))
|
||||
if (SDL_AtomicGet(&i_threads_running))
|
||||
{
|
||||
SDL_DetachThread(th->thread);
|
||||
Free_link(&i_thread_pool, link);
|
||||
@@ -176,7 +176,7 @@ I_spawn_thread (
|
||||
{
|
||||
link = Insert_link(&i_thread_pool, New_link(th));
|
||||
|
||||
if (SDL_GetAtomicInt(&i_threads_running))
|
||||
if (SDL_AtomicGet(&i_threads_running))
|
||||
{
|
||||
th->thread = SDL_CreateThread(
|
||||
(SDL_ThreadFunction)Worker,
|
||||
@@ -194,7 +194,7 @@ I_spawn_thread (
|
||||
int
|
||||
I_thread_is_stopped (void)
|
||||
{
|
||||
return ( ! SDL_GetAtomicInt(&i_threads_running) );
|
||||
return ( ! SDL_AtomicGet(&i_threads_running) );
|
||||
}
|
||||
|
||||
void
|
||||
@@ -220,13 +220,13 @@ I_stop_threads (void)
|
||||
Link next;
|
||||
|
||||
Thread th;
|
||||
SDL_Mutex * mutex;
|
||||
SDL_Condition * cond;
|
||||
SDL_mutex * mutex;
|
||||
SDL_cond * cond;
|
||||
|
||||
if (i_threads_running.value)
|
||||
{
|
||||
/* rely on the good will of thread-san */
|
||||
SDL_SetAtomicInt(&i_threads_running, 0);
|
||||
SDL_AtomicSet(&i_threads_running, 0);
|
||||
|
||||
I_lock_mutex(&i_thread_pool_mutex);
|
||||
{
|
||||
@@ -267,7 +267,7 @@ I_stop_threads (void)
|
||||
next = link->next;
|
||||
cond = link->data;
|
||||
|
||||
SDL_DestroyCondition(cond);
|
||||
SDL_DestroyCond(cond);
|
||||
|
||||
free(link);
|
||||
}
|
||||
@@ -282,7 +282,7 @@ void
|
||||
I_lock_mutex (
|
||||
I_mutex * anchor
|
||||
){
|
||||
SDL_Mutex * mutex;
|
||||
SDL_mutex * mutex;
|
||||
|
||||
mutex = Identity(
|
||||
&i_mutex_pool,
|
||||
@@ -291,14 +291,16 @@ I_lock_mutex (
|
||||
(Create_fn)SDL_CreateMutex
|
||||
);
|
||||
|
||||
SDL_LockMutex(mutex);
|
||||
if (SDL_LockMutex(mutex) == -1)
|
||||
abort();
|
||||
}
|
||||
|
||||
void
|
||||
I_unlock_mutex (
|
||||
I_mutex id
|
||||
){
|
||||
SDL_UnlockMutex(id);
|
||||
if (SDL_UnlockMutex(id) == -1)
|
||||
abort();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -306,46 +308,49 @@ I_hold_cond (
|
||||
I_cond * cond_anchor,
|
||||
I_mutex mutex_id
|
||||
){
|
||||
SDL_Condition * cond;
|
||||
SDL_cond * cond;
|
||||
|
||||
cond = Identity(
|
||||
&i_cond_pool,
|
||||
i_cond_pool_mutex,
|
||||
cond_anchor,
|
||||
(Create_fn)SDL_CreateCondition
|
||||
(Create_fn)SDL_CreateCond
|
||||
);
|
||||
|
||||
SDL_WaitCondition(cond, mutex_id);
|
||||
if (SDL_CondWait(cond, mutex_id) == -1)
|
||||
abort();
|
||||
}
|
||||
|
||||
void
|
||||
I_wake_one_cond (
|
||||
I_cond * anchor
|
||||
){
|
||||
SDL_Condition * cond;
|
||||
SDL_cond * cond;
|
||||
|
||||
cond = Identity(
|
||||
&i_cond_pool,
|
||||
i_cond_pool_mutex,
|
||||
anchor,
|
||||
(Create_fn)SDL_CreateCondition
|
||||
(Create_fn)SDL_CreateCond
|
||||
);
|
||||
|
||||
SDL_SignalCondition(cond);
|
||||
if (SDL_CondSignal(cond) == -1)
|
||||
abort();
|
||||
}
|
||||
|
||||
void
|
||||
I_wake_all_cond (
|
||||
I_cond * anchor
|
||||
){
|
||||
SDL_Condition * cond;
|
||||
SDL_cond * cond;
|
||||
|
||||
cond = Identity(
|
||||
&i_cond_pool,
|
||||
i_cond_pool_mutex,
|
||||
anchor,
|
||||
(Create_fn)SDL_CreateCondition
|
||||
(Create_fn)SDL_CreateCond
|
||||
);
|
||||
|
||||
SDL_BroadcastCondition(cond);
|
||||
if (SDL_CondBroadcast(cond) == -1)
|
||||
abort();
|
||||
}
|
||||
+3
-3
@@ -16,7 +16,7 @@
|
||||
/// \file
|
||||
/// \brief SDL_ttf interface code. Necessary for platforms with no framebuffer console systems.
|
||||
|
||||
#if defined (HAVE_SDL) && defined (HAVE_TTF)
|
||||
#if defined(HAVE_SDL) && defined(HAVE_TTF)
|
||||
#include "SDL.h"
|
||||
#include "SDL_ttf.h"
|
||||
#include "../doomdef.h"
|
||||
@@ -236,14 +236,14 @@ void I_StartupTTF(UINT32 fontpointsize, Uint32 initflags, Uint32 vidmodeflags)
|
||||
|
||||
// what's the point of trying to display an error?
|
||||
// SDL_ttf is not started, can't display anything to screen (presumably)...
|
||||
if (!SDL_InitSubSystem(initflags))
|
||||
if (SDL_InitSubSystem(initflags) < 0)
|
||||
I_Error("Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
|
||||
TTFSurface = SDL_SetVideoMode(res.width, res.height, bitsperpixel, vidmodeflags);
|
||||
if (!TTFSurface)
|
||||
I_Error("Couldn't set SDL Video resolution: %s\n", SDL_GetError());
|
||||
|
||||
if (!TTF_Init())
|
||||
if (TTF_Init() < 0)
|
||||
I_Error("Couldn't start SDL_ttf: %s\n", TTF_GetError());
|
||||
|
||||
// look for default font in many directories
|
||||
|
||||
+211
-220
File diff suppressed because it is too large.
Load diff
+2
-2
@@ -20,7 +20,7 @@
|
||||
#ifdef HAVE_SDL
|
||||
#define _MATH_DEFINES_DEFINED
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include "SDL.h"
|
||||
|
||||
#include "sdlmain.h"
|
||||
|
||||
@@ -96,7 +96,7 @@ boolean VID_LoadOGLAPI(void)
|
||||
if (M_CheckParm("-OGLlib") && M_IsNextParm())
|
||||
OGLLibname = M_GetNextParm();
|
||||
|
||||
if (!SDL_GL_LoadLibrary(OGLLibname))
|
||||
if (SDL_GL_LoadLibrary(OGLLibname) != 0)
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "Could not load OpenGL Library: %s\n", SDL_GetError());
|
||||
if (!M_CheckParm("-OGLlib"))
|
||||
|
||||
+5
-7
@@ -23,16 +23,14 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern bool consolevent;
|
||||
extern bool framebuffer;
|
||||
extern SDL_bool consolevent;
|
||||
extern SDL_bool framebuffer;
|
||||
|
||||
#include "../m_fixed.h"
|
||||
|
||||
// SDL2 stub macro
|
||||
#define SDL2STUB() CONS_Printf("SDL2: stubbed: %s:%d\n", __func__, __LINE__)
|
||||
|
||||
#include <SDL3/SDL_gamepad.h>
|
||||
|
||||
// So m_menu knows whether to store cv_usejoystick value or string
|
||||
#define JOYSTICK_HOTPLUG
|
||||
|
||||
@@ -43,9 +41,9 @@ extern bool framebuffer;
|
||||
typedef struct SDLJoyInfo_s
|
||||
{
|
||||
/// Controller handle
|
||||
SDL_Gamepad *dev;
|
||||
SDL_GameController *dev;
|
||||
/// Controller index
|
||||
SDL_JoystickID id;
|
||||
INT32 id;
|
||||
/// number of old joystick
|
||||
int oldjoy;
|
||||
/// number of axies
|
||||
@@ -73,7 +71,7 @@ extern SDLJoyInfo_t JoyInfo[4]; //MAXSPLITSCREENPLAYERS
|
||||
void I_ShutdownJoystick(UINT8 index);
|
||||
|
||||
// Cheat to get the device index for a game controller handle
|
||||
INT32 I_GetJoystickDeviceIndex(SDL_Gamepad *dev);
|
||||
INT32 I_GetJoystickDeviceIndex(SDL_GameController *dev);
|
||||
|
||||
// Quick thing to make SDL_JOYDEVICEADDED events less of an abomination
|
||||
void I_UpdateJoystickDeviceIndex(UINT8 player);
|
||||
|
||||
Reference in new issue
Block a user