Port to SDL3
Thanks to SRB2Classic for refernce!!!
This commit is contained in:
parent
47bcd68596
commit
656ad85a8f
12 changed files with 306 additions and 330 deletions
|
|
@ -89,9 +89,9 @@
|
|||
#include "deh_tables.h" // menunames
|
||||
|
||||
#if defined(HAVE_SDL)
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#if SDL_VERSION_ATLEAST(2,0,0)
|
||||
#include "sdl/sdlmain.h" // JOYSTICK_HOTPLUG
|
||||
#include <SDL3/SDL_main.h> // JOYSTICK_HOTPLUG
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@
|
|||
#include "SDL_image.h"
|
||||
#else
|
||||
// SDLCALL terms removed from original SDL_image declarations
|
||||
int IMG_isXPM(SDL_RWops *src);
|
||||
SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src);
|
||||
int IMG_isXPM(SDL_IOStream *src);
|
||||
SDL_Surface *IMG_LoadXPM_RW(SDL_IOStream *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_RWops *src)
|
||||
int IMG_isXPM(SDL_IOStream *src)
|
||||
{
|
||||
Sint64 start;
|
||||
int is_XPM;
|
||||
|
|
@ -64,14 +64,14 @@ int IMG_isXPM(SDL_RWops *src)
|
|||
|
||||
if ( !src )
|
||||
return 0;
|
||||
start = SDL_RWtell(src);
|
||||
start = SDL_TellIO(src);
|
||||
is_XPM = 0;
|
||||
if ( SDL_RWread(src, magic, sizeof(magic), 1) ) {
|
||||
if ( SDL_ReadIO(src, magic, sizeof(magic)) ) {
|
||||
if ( SDL_memcmp(magic, "/* XPM */", sizeof(magic)) == 0 ) {
|
||||
is_XPM = 1;
|
||||
}
|
||||
}
|
||||
SDL_RWseek(src, start, RW_SEEK_SET);
|
||||
SDL_SeekIO(src, start, SDL_IO_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_RWops *src, int len)
|
||||
static const char *get_next_line(const char ***lines, SDL_IOStream *src, int len)
|
||||
{
|
||||
char *linebufnew;
|
||||
|
||||
|
|
@ -943,7 +943,7 @@ static const char *get_next_line(const char ***lines, SDL_RWops *src, int len)
|
|||
char c;
|
||||
int n;
|
||||
do {
|
||||
if (SDL_RWread(src, &c, 1, 1) <= 0) {
|
||||
if (SDL_ReadIO(src, &c, 1) <= 0) {
|
||||
error = "Premature end of data";
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -960,7 +960,7 @@ static const char *get_next_line(const char ***lines, SDL_RWops *src, int len)
|
|||
}
|
||||
linebuf = linebufnew;
|
||||
}
|
||||
if (SDL_RWread(src, linebuf, len - 1, 1) <= 0) {
|
||||
if (SDL_ReadIO(src, linebuf, len - 1) <= 0) {
|
||||
error = "Premature end of data";
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -980,7 +980,7 @@ static const char *get_next_line(const char ***lines, SDL_RWops *src, int len)
|
|||
}
|
||||
linebuf = linebufnew;
|
||||
}
|
||||
if (SDL_RWread(src, linebuf + n, 1, 1) <= 0) {
|
||||
if (SDL_ReadIO(src, linebuf + n, 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_RWops *src)
|
||||
static SDL_Surface *load_xpm(const char **xpm, SDL_IOStream *src)
|
||||
{
|
||||
Sint64 start = 0;
|
||||
SDL_Surface *image = NULL;
|
||||
|
|
@ -1027,7 +1027,7 @@ static SDL_Surface *load_xpm(const char **xpm, SDL_RWops *src)
|
|||
buflen = 0;
|
||||
|
||||
if (src)
|
||||
start = SDL_RWtell(src);
|
||||
start = SDL_TellIO(src);
|
||||
|
||||
if (xpm)
|
||||
xpmlines = &xpm;
|
||||
|
|
@ -1065,14 +1065,15 @@ static SDL_Surface *load_xpm(const char **xpm, SDL_RWops *src)
|
|||
/* Create the new surface */
|
||||
if (ncolors <= 256) {
|
||||
indexed = 1;
|
||||
image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 8,
|
||||
0, 0, 0, 0);
|
||||
im_colors = image->format->palette->colors;
|
||||
image->format->palette->ncolors = ncolors;
|
||||
image = SDL_CreateSurface(w, h,
|
||||
SDL_PIXELFORMAT_INDEX8);
|
||||
SDL_Palette *palette = SDL_CreateSurfacePalette(image);
|
||||
im_colors = palette->colors;
|
||||
palette->ncolors = ncolors;
|
||||
} else {
|
||||
indexed = 0;
|
||||
image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32,
|
||||
0xff0000, 0x00ff00, 0x0000ff, 0);
|
||||
image = SDL_CreateSurface(w, h,
|
||||
SDL_GetPixelFormatForMasks(32, 0xff0000, 0x00ff00, 0x0000ff, 0));
|
||||
}
|
||||
if (!image) {
|
||||
/* Hmm, some SDL error (out of memory?) */
|
||||
|
|
@ -1128,7 +1129,7 @@ static SDL_Surface *load_xpm(const char **xpm, SDL_RWops *src)
|
|||
add_colorhash(colors, nextkey, cpp, pixel);
|
||||
nextkey += cpp;
|
||||
if (rgb == 0xffffffff)
|
||||
SDL_SetColorKey(image, SDL_TRUE, pixel);
|
||||
SDL_SetSurfaceColorKey(image, true, pixel);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1164,9 +1165,9 @@ static SDL_Surface *load_xpm(const char **xpm, SDL_RWops *src)
|
|||
done:
|
||||
if (error) {
|
||||
if ( src )
|
||||
SDL_RWseek(src, start, RW_SEEK_SET);
|
||||
SDL_SeekIO(src, start, SDL_IO_SEEK_SET);
|
||||
if ( image ) {
|
||||
SDL_FreeSurface(image);
|
||||
SDL_DestroySurface(image);
|
||||
image = NULL;
|
||||
}
|
||||
IMG_SetError("%s", error);
|
||||
|
|
@ -1180,7 +1181,7 @@ done:
|
|||
}
|
||||
|
||||
/* Load a XPM type image from an RWops datasource */
|
||||
SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src)
|
||||
SDL_Surface *IMG_LoadXPM_RW(SDL_IOStream *src)
|
||||
{
|
||||
if ( !src ) {
|
||||
/* The error message has been set in SDL_RWFromFile */
|
||||
|
|
@ -1201,14 +1202,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_RWops *src)
|
||||
int IMG_isXPM(SDL_IOStream *src)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/* Load a XPM type image from an SDL datasource */
|
||||
SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src)
|
||||
SDL_Surface *IMG_LoadXPM_RW(SDL_IOStream *src)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
#include <windows.h>
|
||||
|
||||
/* Include the SDL main definition header */
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include "SDL_main.h"
|
||||
|
||||
#ifdef main
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ typedef enum
|
|||
#include "../i_system.h" // I_Sleep
|
||||
#include "../fastcmp.h"
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
|
@ -1065,9 +1065,10 @@ static void do_fading_callback(void)
|
|||
fading_do_callback = true;
|
||||
}
|
||||
|
||||
static UINT32 music_fade(UINT32 interval, void *param)
|
||||
static UINT32 music_fade(void *userdata, SDL_TimerID timerID, Uint32 interval)
|
||||
{
|
||||
(void)param;
|
||||
(void)userdata;
|
||||
(void)timerID;
|
||||
|
||||
if (!is_fading
|
||||
|| fabs(internal_volume - fading_target) < FLOATEP // EQUALS I love floats I love floats
|
||||
|
|
|
|||
|
|
@ -27,10 +27,10 @@
|
|||
|
||||
#ifdef HAVE_SDL
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#ifndef NOLOADSO
|
||||
#include "SDL_loadso.h"
|
||||
#include <SDL3/SDL_loadso.h>
|
||||
#endif
|
||||
|
||||
#define _CREATE_DLL_ // necessary for Unix AND Windows
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
#ifdef HAVE_SDL
|
||||
|
||||
#ifdef HAVE_TTF
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include "i_ttf.h"
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
/// \file
|
||||
/// \brief SRB2 system stuff for SDL
|
||||
|
||||
#include <SDL3/SDL_gamepad.h>
|
||||
#include <SDL3/SDL_joystick.h>
|
||||
#include <thread>
|
||||
|
||||
#ifdef CMAKECONFIG
|
||||
|
|
@ -70,7 +72,7 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
|
|||
|
||||
#ifdef HAVE_SDL
|
||||
#define _MATH_DEFINES_DEFINED
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#ifdef HAVE_TTF
|
||||
#include "i_ttf.h"
|
||||
|
|
@ -219,12 +221,12 @@ static char returnWadPath[256];
|
|||
|
||||
static std::thread::id g_main_thread_id;
|
||||
|
||||
void I_StoreExJoystick(SDL_GameController *dev)
|
||||
void I_StoreExJoystick(SDL_Gamepad *dev)
|
||||
{
|
||||
// ExJoystick is a massive hack to avoid needing to completely
|
||||
// rewrite pretty much all of the controller support from scratch...
|
||||
|
||||
// Used in favor of most instances of SDL_GameControllerClose.
|
||||
// Used in favor of most instances of SDL_CloseGamepad.
|
||||
// If a joystick would've been discarded, then save it in an array,
|
||||
// because we want it have it for the joystick input screen.
|
||||
|
||||
|
|
@ -236,12 +238,12 @@ void I_StoreExJoystick(SDL_GameController *dev)
|
|||
return;
|
||||
}
|
||||
|
||||
index = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(dev));
|
||||
index = SDL_GetJoystickID(SDL_GetGamepadJoystick(dev));
|
||||
|
||||
if (index >= MAXGAMEPADS || index < 0)
|
||||
{
|
||||
// Not enough space to save this joystick, completely discard.
|
||||
SDL_GameControllerClose(dev);
|
||||
SDL_CloseGamepad(dev);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -254,7 +256,7 @@ void I_StoreExJoystick(SDL_GameController *dev)
|
|||
if (ExJoystick[index] != NULL)
|
||||
{
|
||||
// Discard joystick in the old slot.
|
||||
SDL_GameControllerClose(ExJoystick[index]);
|
||||
SDL_CloseGamepad(ExJoystick[index]);
|
||||
}
|
||||
|
||||
// Keep for safe-keeping.
|
||||
|
|
@ -287,10 +289,10 @@ static INT32 joystick_started[MAXSPLITSCREENPLAYERS] = {0,0,0,0};
|
|||
*/
|
||||
SDLJoyInfo_t JoyInfo[MAXSPLITSCREENPLAYERS];
|
||||
INT32 numcontrollers = 0;
|
||||
SDL_GameController *ExJoystick[MAXGAMEPADS];
|
||||
SDL_Gamepad *ExJoystick[MAXGAMEPADS];
|
||||
|
||||
SDL_bool consolevent = SDL_FALSE;
|
||||
SDL_bool framebuffer = SDL_FALSE;
|
||||
bool consolevent = false;
|
||||
bool framebuffer = false;
|
||||
|
||||
UINT8 keyboard_started = false;
|
||||
boolean g_in_exiting_signal_handler = false;
|
||||
|
|
@ -542,7 +544,7 @@ static void quit_handler(int num)
|
|||
|
||||
#ifdef HAVE_TERMIOS
|
||||
// TERMIOS console code from Quake3: thank you!
|
||||
SDL_bool stdin_active = SDL_TRUE;
|
||||
bool stdin_active = true;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
|
@ -648,7 +650,7 @@ static void I_ShutdownConsole(void)
|
|||
if (consolevent)
|
||||
{
|
||||
I_OutputMsg("Shutdown tty console\n");
|
||||
consolevent = SDL_FALSE;
|
||||
consolevent = false;
|
||||
tcsetattr (STDIN_FILENO, TCSADRAIN, &tty_tc);
|
||||
}
|
||||
}
|
||||
|
|
@ -663,18 +665,18 @@ static void I_StartupConsole(void)
|
|||
signal(SIGTTIN, SIG_IGN);
|
||||
signal(SIGTTOU, SIG_IGN);
|
||||
|
||||
consolevent = static_cast<SDL_bool>(!M_CheckParm("-noconsole"));
|
||||
framebuffer = static_cast<SDL_bool>(M_CheckParm("-framebuffer"));
|
||||
consolevent = static_cast<bool>(!M_CheckParm("-noconsole"));
|
||||
framebuffer = static_cast<bool>(M_CheckParm("-framebuffer"));
|
||||
|
||||
if (framebuffer)
|
||||
consolevent = SDL_FALSE;
|
||||
consolevent = false;
|
||||
|
||||
if (!consolevent) return;
|
||||
|
||||
if (isatty(STDIN_FILENO)!=1)
|
||||
{
|
||||
I_OutputMsg("stdin is not a tty, tty console mode failed\n");
|
||||
consolevent = SDL_FALSE;
|
||||
consolevent = false;
|
||||
return;
|
||||
}
|
||||
memset(&tty_con, 0x00, sizeof(tty_con));
|
||||
|
|
@ -852,7 +854,7 @@ static void I_StartupConsole(void)
|
|||
if (gotConsole)
|
||||
{
|
||||
SetConsoleTitleA("SRB2Kart Console");
|
||||
consolevent = SDL_TRUE;
|
||||
consolevent = true;
|
||||
}
|
||||
|
||||
//Let get the real console HANDLE, because Mingw's Bash is bad!
|
||||
|
|
@ -885,7 +887,7 @@ static inline void I_StartupConsole(void)
|
|||
framebuffer = M_CheckParm("-framebuffer");
|
||||
|
||||
if (framebuffer)
|
||||
consolevent = SDL_FALSE;
|
||||
consolevent = false;
|
||||
}
|
||||
static inline void I_ShutdownConsole(void){}
|
||||
#endif
|
||||
|
|
@ -1108,15 +1110,15 @@ void I_JoyScale4(void)
|
|||
}
|
||||
|
||||
// Cheat to get the device index for a game controller handle
|
||||
INT32 I_GetJoystickDeviceIndex(SDL_GameController *dev)
|
||||
INT32 I_GetJoystickDeviceIndex(SDL_Gamepad *dev)
|
||||
{
|
||||
SDL_Joystick *joystick = NULL;
|
||||
|
||||
joystick = SDL_GameControllerGetJoystick(dev);
|
||||
joystick = SDL_GetGamepadJoystick(dev);
|
||||
|
||||
if (joystick)
|
||||
{
|
||||
return SDL_JoystickInstanceID(joystick);
|
||||
return SDL_GetJoystickID(joystick);
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
|
@ -1126,11 +1128,11 @@ INT32 I_GetJoystickDeviceIndexForPlayer(UINT8 pnum)
|
|||
{
|
||||
SDL_Joystick *joystick = NULL;
|
||||
|
||||
joystick = SDL_GameControllerGetJoystick(JoyInfo[pnum].dev);
|
||||
joystick = SDL_GetGamepadJoystick(JoyInfo[pnum].dev);
|
||||
|
||||
if (joystick)
|
||||
{
|
||||
return SDL_JoystickInstanceID(joystick);
|
||||
return SDL_GetJoystickID(joystick);
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
|
@ -1240,7 +1242,7 @@ void I_ShutdownJoystick(UINT8 index)
|
|||
*/
|
||||
static int joy_open(int playerIndex, int joyIndex)
|
||||
{
|
||||
SDL_GameController *newdev = NULL;
|
||||
SDL_Gamepad *newdev = NULL;
|
||||
int num_joy = 0;
|
||||
|
||||
if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0)
|
||||
|
|
@ -1248,14 +1250,7 @@ static int joy_open(int playerIndex, int joyIndex)
|
|||
CONS_Printf(M_GetText("Joystick subsystem not started\n"));
|
||||
return -1;
|
||||
}
|
||||
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == 0)
|
||||
{
|
||||
CONS_Printf(M_GetText("Game Controller subsystem not started\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == 0)
|
||||
if (SDL_WasInit(SDL_INIT_GAMEPAD) == 0)
|
||||
{
|
||||
CONS_Printf(M_GetText("Game Controller subsystem not started\n"));
|
||||
return -1;
|
||||
|
|
@ -1264,7 +1259,7 @@ static int joy_open(int playerIndex, int joyIndex)
|
|||
if (joyIndex <= 0)
|
||||
return -1;
|
||||
|
||||
num_joy = SDL_NumJoysticks();
|
||||
SDL_GetJoysticks(&num_joy);
|
||||
|
||||
if (num_joy == 0)
|
||||
{
|
||||
|
|
@ -1272,7 +1267,7 @@ static int joy_open(int playerIndex, int joyIndex)
|
|||
return -1;
|
||||
}
|
||||
|
||||
newdev = SDL_GameControllerOpen(joyIndex-1);
|
||||
newdev = SDL_OpenGamepad(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.
|
||||
|
|
@ -1287,9 +1282,9 @@ 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_GameControllerGetAttached(JoyInfo[playerIndex].dev))) // we failed, but already have a working device
|
||||
|| (newdev == NULL && SDL_GamepadConnected(JoyInfo[playerIndex].dev))) // we failed, but already have a working device
|
||||
{
|
||||
return SDL_CONTROLLER_AXIS_MAX;
|
||||
return SDL_GAMEPAD_AXIS_COUNT;
|
||||
}
|
||||
|
||||
// Else, we're changing devices, so send neutral joy events
|
||||
|
|
@ -1306,10 +1301,10 @@ static int joy_open(int playerIndex, int joyIndex)
|
|||
}
|
||||
else
|
||||
{
|
||||
CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick%d: %s\n"), playerIndex+1, SDL_GameControllerName(JoyInfo[playerIndex].dev));
|
||||
CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick%d: %s\n"), playerIndex+1, SDL_GetGamepadName(JoyInfo[playerIndex].dev));
|
||||
|
||||
JoyInfo[playerIndex].axises = SDL_CONTROLLER_AXIS_MAX;
|
||||
JoyInfo[playerIndex].buttons = SDL_CONTROLLER_BUTTON_MAX;
|
||||
JoyInfo[playerIndex].axises = SDL_GAMEPAD_AXIS_COUNT;
|
||||
JoyInfo[playerIndex].buttons = SDL_GAMEPAD_BUTTON_COUNT;
|
||||
JoyInfo[playerIndex].hats = 1;
|
||||
JoyInfo[playerIndex].balls = 0;
|
||||
|
||||
|
|
@ -1324,7 +1319,7 @@ static int joy_open(int playerIndex, int joyIndex)
|
|||
//
|
||||
void I_InitJoystick(UINT8 index)
|
||||
{
|
||||
SDL_GameController *newcontroller = NULL;
|
||||
SDL_Gamepad *newcontroller = NULL;
|
||||
UINT8 i;
|
||||
|
||||
//I_ShutdownJoystick();
|
||||
|
|
@ -1335,13 +1330,13 @@ void I_InitJoystick(UINT8 index)
|
|||
{
|
||||
char dbpath[1024];
|
||||
sprintf(dbpath, "%s" PATHSEP "gamecontrollerdb.txt", srb2path);
|
||||
SDL_GameControllerAddMappingsFromFile(dbpath);
|
||||
SDL_AddGamepadMappingsFromFile(dbpath);
|
||||
}
|
||||
|
||||
{
|
||||
char dbpath[1024];
|
||||
sprintf(dbpath, "%s" PATHSEP "gamecontrollerdb_user.txt", srb2home);
|
||||
SDL_GameControllerAddMappingsFromFile(dbpath);
|
||||
SDL_AddGamepadMappingsFromFile(dbpath);
|
||||
}
|
||||
|
||||
if (M_CheckParm("-noxinput"))
|
||||
|
|
@ -1354,15 +1349,15 @@ void I_InitJoystick(UINT8 index)
|
|||
{
|
||||
CONS_Printf("I_InitJoystick()...\n");
|
||||
|
||||
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1)
|
||||
if (!SDL_InitSubSystem(SDL_INIT_JOYSTICK))
|
||||
{
|
||||
CONS_Printf(M_GetText("Couldn't initialize joystick: %s\n"), SDL_GetError());
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == 0)
|
||||
if (SDL_WasInit(SDL_INIT_GAMEPAD) == 0)
|
||||
{
|
||||
if (SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) == -1)
|
||||
if (!SDL_InitSubSystem(SDL_INIT_GAMEPAD))
|
||||
{
|
||||
CONS_Printf(M_GetText("Couldn't initialize gamepads: %s\n"), SDL_GetError());
|
||||
return;
|
||||
|
|
@ -1370,9 +1365,9 @@ void I_InitJoystick(UINT8 index)
|
|||
}
|
||||
|
||||
|
||||
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == 0)
|
||||
if (SDL_WasInit(SDL_INIT_GAMEPAD) == 0)
|
||||
{
|
||||
if (SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) == -1)
|
||||
if (!SDL_InitSubSystem(SDL_INIT_GAMEPAD))
|
||||
{
|
||||
CONS_Printf(M_GetText("Couldn't initialize gamepads: %s\n"), SDL_GetError());
|
||||
return;
|
||||
|
|
@ -1380,7 +1375,7 @@ void I_InitJoystick(UINT8 index)
|
|||
}
|
||||
|
||||
if (cv_usejoystick[index].value)
|
||||
newcontroller = SDL_GameControllerOpen(cv_usejoystick[index].value-1);
|
||||
newcontroller = SDL_OpenGamepad(cv_usejoystick[index].value-1);
|
||||
|
||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
{
|
||||
|
|
@ -1454,10 +1449,10 @@ static void I_ShutdownInput(void)
|
|||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
I_ShutdownJoystick(i);
|
||||
|
||||
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == SDL_INIT_GAMECONTROLLER)
|
||||
if (SDL_WasInit(SDL_INIT_GAMEPAD) == SDL_INIT_GAMEPAD)
|
||||
{
|
||||
CONS_Printf("Shutting down gamecontroller system\n");
|
||||
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
|
||||
SDL_QuitSubSystem(SDL_INIT_GAMEPAD);
|
||||
I_OutputMsg("I_Joystick: SDL's Game Controller system has been shutdown\n");
|
||||
}
|
||||
|
||||
|
|
@ -1471,10 +1466,10 @@ static void I_ShutdownInput(void)
|
|||
|
||||
INT32 I_NumJoys(void)
|
||||
{
|
||||
INT32 numjoy = 0;
|
||||
INT32 num_joy = 0;
|
||||
if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK)
|
||||
numjoy = SDL_NumJoysticks();
|
||||
return numjoy;
|
||||
SDL_GetJoysticks(&num_joy);
|
||||
return num_joy;
|
||||
}
|
||||
|
||||
static char joyname[255]; // joystick name is straight from the driver
|
||||
|
|
@ -1486,7 +1481,7 @@ const char *I_GetJoyName(INT32 joyindex)
|
|||
joyindex--; //SDL's Joystick System starts at 0, not 1
|
||||
if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK)
|
||||
{
|
||||
tempname = SDL_JoystickNameForIndex(joyindex);
|
||||
tempname = SDL_GetJoystickNameForID(joyindex);
|
||||
if (tempname)
|
||||
{
|
||||
strncpy(joyname, tempname, 254);
|
||||
|
|
@ -1504,14 +1499,14 @@ void I_GamepadRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength,
|
|||
(void)high_strength;
|
||||
(void)duration;
|
||||
#else
|
||||
SDL_GameController *controller = JoyInfo[playernum].dev;
|
||||
SDL_Gamepad *controller = JoyInfo[playernum].dev;
|
||||
|
||||
if (controller == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_GameControllerRumble(controller, low_strength, high_strength, duration);
|
||||
SDL_RumbleGamepad(controller, low_strength, high_strength, duration);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -1523,14 +1518,14 @@ void I_SetGamepadIndicatorColor(INT32 playernum, UINT8 red, UINT8 green, UINT8 b
|
|||
(void)green;
|
||||
(void)blue;
|
||||
#else
|
||||
SDL_GameController *controller = JoyInfo[playernum].dev;
|
||||
SDL_Gamepad *controller = JoyInfo[playernum].dev;
|
||||
|
||||
if (controller == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_GameControllerSetLED(controller, red, green, blue);
|
||||
SDL_SetGamepadLED(controller, red, green, blue);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -1927,10 +1922,7 @@ static void I_Fork(void)
|
|||
|
||||
INT32 I_StartupSystem(void)
|
||||
{
|
||||
SDL_version SDLcompiled;
|
||||
SDL_version SDLlinked;
|
||||
SDL_VERSION(&SDLcompiled)
|
||||
SDL_GetVersion(&SDLlinked);
|
||||
int SDLlinked = SDL_GetVersion();
|
||||
I_StartupConsole();
|
||||
#ifdef NEWSIGNALHANDLER
|
||||
// This is useful when debugging. It lets GDB attach to
|
||||
|
|
@ -1946,13 +1938,13 @@ INT32 I_StartupSystem(void)
|
|||
#endif
|
||||
I_RegisterSignals();
|
||||
I_OutputMsg("Compiled for SDL version: %d.%d.%d\n",
|
||||
SDLcompiled.major, SDLcompiled.minor, SDLcompiled.patch);
|
||||
SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION);
|
||||
I_OutputMsg("Linked with SDL version: %d.%d.%d\n",
|
||||
SDLlinked.major, SDLlinked.minor, SDLlinked.patch);
|
||||
SDL_VERSIONNUM_MAJOR(SDLlinked), SDL_VERSIONNUM_MINOR(SDLlinked), SDL_VERSIONNUM_MICRO(SDLlinked));
|
||||
#if SDL_VERSION_ATLEAST(2,0,22)
|
||||
SDL_SetHint(SDL_HINT_APP_NAME, "BlanKart");
|
||||
#endif
|
||||
if (SDL_Init(0) < 0)
|
||||
if (!SDL_Init(0))
|
||||
I_Error("SRB2Kart: SDL System Error: %s", SDL_GetError()); //Alam: Oh no....
|
||||
#ifndef NOMUMBLE
|
||||
I_SetupMumble();
|
||||
|
|
|
|||
|
|
@ -12,7 +12,9 @@
|
|||
#include "../doomdef.h"
|
||||
#include "../i_threads.h"
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_atomic.h>
|
||||
#include <SDL3/SDL_mutex.h>
|
||||
|
||||
typedef void * (*Create_fn)(void);
|
||||
|
||||
|
|
@ -45,7 +47,7 @@ static I_mutex i_thread_pool_mutex;
|
|||
static I_mutex i_mutex_pool_mutex;
|
||||
static I_mutex i_cond_pool_mutex;
|
||||
|
||||
static SDL_atomic_t i_threads_running = {1};
|
||||
static SDL_AtomicInt i_threads_running = {1};
|
||||
|
||||
static Link
|
||||
Insert_link (
|
||||
|
|
@ -103,13 +105,13 @@ Identity (
|
|||
){
|
||||
void * id;
|
||||
|
||||
id = SDL_AtomicGetPtr(anchor);
|
||||
id = SDL_GetAtomicPointer(anchor);
|
||||
|
||||
if (! id)
|
||||
{
|
||||
I_lock_mutex(&pool_mutex);
|
||||
{
|
||||
id = SDL_AtomicGetPtr(anchor);
|
||||
id = SDL_GetAtomicPointer(anchor);
|
||||
|
||||
if (! id)
|
||||
{
|
||||
|
|
@ -120,7 +122,7 @@ Identity (
|
|||
|
||||
Insert_link(pool_anchor, New_link(id));
|
||||
|
||||
SDL_AtomicSetPtr(anchor, id);
|
||||
SDL_SetAtomicPointer(anchor, id);
|
||||
}
|
||||
}
|
||||
I_unlock_mutex(pool_mutex);
|
||||
|
|
@ -139,11 +141,11 @@ Worker (
|
|||
|
||||
(*th->entry)(th->userdata);
|
||||
|
||||
if (SDL_AtomicGet(&i_threads_running))
|
||||
if (SDL_GetAtomicInt(&i_threads_running))
|
||||
{
|
||||
I_lock_mutex(&i_thread_pool_mutex);
|
||||
{
|
||||
if (SDL_AtomicGet(&i_threads_running))
|
||||
if (SDL_GetAtomicInt(&i_threads_running))
|
||||
{
|
||||
SDL_DetachThread(th->thread);
|
||||
Free_link(&i_thread_pool, link);
|
||||
|
|
@ -176,7 +178,7 @@ I_spawn_thread (
|
|||
{
|
||||
link = Insert_link(&i_thread_pool, New_link(th));
|
||||
|
||||
if (SDL_AtomicGet(&i_threads_running))
|
||||
if (SDL_GetAtomicInt(&i_threads_running))
|
||||
{
|
||||
th->thread = SDL_CreateThread(
|
||||
(SDL_ThreadFunction)Worker,
|
||||
|
|
@ -194,7 +196,7 @@ I_spawn_thread (
|
|||
int
|
||||
I_thread_is_stopped (void)
|
||||
{
|
||||
return ( ! SDL_AtomicGet(&i_threads_running) );
|
||||
return ( ! SDL_GetAtomicInt(&i_threads_running) );
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -220,13 +222,13 @@ I_stop_threads (void)
|
|||
Link next;
|
||||
|
||||
Thread th;
|
||||
SDL_mutex * mutex;
|
||||
SDL_cond * cond;
|
||||
SDL_Mutex * mutex;
|
||||
SDL_Condition * cond;
|
||||
|
||||
if (i_threads_running.value)
|
||||
{
|
||||
/* rely on the good will of thread-san */
|
||||
SDL_AtomicSet(&i_threads_running, 0);
|
||||
SDL_SetAtomicInt(&i_threads_running, 0);
|
||||
|
||||
I_lock_mutex(&i_thread_pool_mutex);
|
||||
{
|
||||
|
|
@ -267,7 +269,7 @@ I_stop_threads (void)
|
|||
next = link->next;
|
||||
cond = link->data;
|
||||
|
||||
SDL_DestroyCond(cond);
|
||||
SDL_DestroyCondition(cond);
|
||||
|
||||
free(link);
|
||||
}
|
||||
|
|
@ -282,7 +284,7 @@ void
|
|||
I_lock_mutex (
|
||||
I_mutex * anchor
|
||||
){
|
||||
SDL_mutex * mutex;
|
||||
SDL_Mutex * mutex;
|
||||
|
||||
mutex = Identity(
|
||||
&i_mutex_pool,
|
||||
|
|
@ -291,16 +293,14 @@ I_lock_mutex (
|
|||
(Create_fn)SDL_CreateMutex
|
||||
);
|
||||
|
||||
if (SDL_LockMutex(mutex) == -1)
|
||||
abort();
|
||||
SDL_LockMutex(mutex);
|
||||
}
|
||||
|
||||
void
|
||||
I_unlock_mutex (
|
||||
I_mutex id
|
||||
){
|
||||
if (SDL_UnlockMutex(id) == -1)
|
||||
abort();
|
||||
SDL_UnlockMutex(id);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -308,49 +308,46 @@ I_hold_cond (
|
|||
I_cond * cond_anchor,
|
||||
I_mutex mutex_id
|
||||
){
|
||||
SDL_cond * cond;
|
||||
SDL_Condition * cond;
|
||||
|
||||
cond = Identity(
|
||||
&i_cond_pool,
|
||||
i_cond_pool_mutex,
|
||||
cond_anchor,
|
||||
(Create_fn)SDL_CreateCond
|
||||
(Create_fn)SDL_CreateCondition
|
||||
);
|
||||
|
||||
if (SDL_CondWait(cond, mutex_id) == -1)
|
||||
abort();
|
||||
SDL_WaitCondition(cond, mutex_id);
|
||||
}
|
||||
|
||||
void
|
||||
I_wake_one_cond (
|
||||
I_cond * anchor
|
||||
){
|
||||
SDL_cond * cond;
|
||||
SDL_Condition * cond;
|
||||
|
||||
cond = Identity(
|
||||
&i_cond_pool,
|
||||
i_cond_pool_mutex,
|
||||
anchor,
|
||||
(Create_fn)SDL_CreateCond
|
||||
(Create_fn)SDL_CreateCondition
|
||||
);
|
||||
|
||||
if (SDL_CondSignal(cond) == -1)
|
||||
abort();
|
||||
SDL_SignalCondition(cond);
|
||||
}
|
||||
|
||||
void
|
||||
I_wake_all_cond (
|
||||
I_cond * anchor
|
||||
){
|
||||
SDL_cond * cond;
|
||||
SDL_Condition * cond;
|
||||
|
||||
cond = Identity(
|
||||
&i_cond_pool,
|
||||
i_cond_pool_mutex,
|
||||
anchor,
|
||||
(Create_fn)SDL_CreateCond
|
||||
(Create_fn)SDL_CreateCondition
|
||||
);
|
||||
|
||||
if (SDL_CondBroadcast(cond) == -1)
|
||||
abort();
|
||||
SDL_BroadcastCondition(cond);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
/// \brief SDL_ttf interface code. Necessary for platforms with no framebuffer console systems.
|
||||
|
||||
#if defined(HAVE_SDL) && defined(HAVE_TTF)
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include "SDL_ttf.h"
|
||||
#include "../doomdef.h"
|
||||
#include "../doomstat.h"
|
||||
|
|
@ -42,10 +42,10 @@
|
|||
SDL_Surface *TTFSurface = NULL;
|
||||
SDL_Surface *TTFRendSurface = NULL;
|
||||
// Text box.
|
||||
SDL_Rect TTFRect;
|
||||
SDL_FRect TTFRect;
|
||||
// Temporary storage for the new TTFRect, used to check for
|
||||
// line wrapping.
|
||||
SDL_Rect TTFRectCheck;
|
||||
SDL_FRect TTFRectCheck;
|
||||
// Text rendering resolution.
|
||||
videoResolution res;
|
||||
// Text storage buffer, the contents get printed to the SDL surface.
|
||||
|
|
@ -236,7 +236,7 @@ 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) < 0)
|
||||
if (!SDL_InitSubSystem(initflags))
|
||||
I_Error("Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
|
||||
TTFSurface = SDL_SetVideoMode(res.width, res.height, bitsperpixel, vidmodeflags);
|
||||
|
|
@ -324,7 +324,7 @@ void I_ShutdownTTF(void)
|
|||
TTF_Quit();
|
||||
|
||||
// Free TTF rendering surfaces.
|
||||
SDL_FreeSurface(TTFSurface);
|
||||
SDL_FreeSurface(TTFRendSurface);
|
||||
SDL_DestroySurface(TTFSurface);
|
||||
SDL_DestroySurface(TTFRendSurface);
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@
|
|||
/// \file i_video.cpp
|
||||
/// \brief SRB2 graphics stuff for SDL
|
||||
|
||||
#include <SDL3/SDL_events.h>
|
||||
#include <SDL3/SDL_gamepad.h>
|
||||
#include <SDL3/SDL_video.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
|
@ -26,7 +29,7 @@
|
|||
|
||||
#ifdef HAVE_SDL
|
||||
#define _MATH_DEFINES_DEFINED
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#ifdef HAVE_TTF
|
||||
#include "i_ttf.h"
|
||||
|
|
@ -108,11 +111,11 @@ UINT8 graphics_started = 0; // Is used in console.c and screen.c
|
|||
|
||||
// To disable fullscreen at startup; is set in VID_PrepareModeList
|
||||
boolean allow_fullscreen = false;
|
||||
static SDL_bool disable_fullscreen = SDL_FALSE;
|
||||
static bool disable_fullscreen = false;
|
||||
|
||||
#define USE_FULLSCREEN (disable_fullscreen||!allow_fullscreen)?static_cast<SDL_bool>(0):static_cast<SDL_bool>(cv_fullscreen.value == 1)
|
||||
#define USE_FULLSCREEN (disable_fullscreen||!allow_fullscreen)?static_cast<bool>(0):static_cast<bool>(cv_fullscreen.value == 1)
|
||||
|
||||
static SDL_bool disable_mouse = SDL_FALSE;
|
||||
static bool disable_mouse = false;
|
||||
#define USE_MOUSEINPUT (!disable_mouse && cv_usemouse.value && havefocus)
|
||||
#define MOUSE_MENU false //(!disable_mouse && cv_usemouse.value && menustack[0] && !USE_FULLSCREEN)
|
||||
#define MOUSEBUTTONS_MAX MOUSEBUTTONS
|
||||
|
|
@ -122,10 +125,10 @@ static INT32 mousemovex = 0, mousemovey = 0;
|
|||
|
||||
// SDL vars
|
||||
static UINT32 localPalette[256];
|
||||
static SDL_bool wrapmouseok = SDL_FALSE;
|
||||
static bool wrapmouseok = false;
|
||||
#define HalfWarpMouse(x,y) if (wrapmouseok) SDL_WarpMouseInWindow(window, (Uint16)(x/2),(Uint16)(y/2))
|
||||
static SDL_bool usesdl2soft = SDL_FALSE;
|
||||
static SDL_bool borderlesswindow = SDL_FALSE;
|
||||
static bool usesdl2soft = false;
|
||||
static bool borderlesswindow = false;
|
||||
|
||||
Uint16 realwidth = BASEVIDWIDTH;
|
||||
Uint16 realheight = BASEVIDHEIGHT;
|
||||
|
|
@ -133,13 +136,13 @@ Uint16 realheight = BASEVIDHEIGHT;
|
|||
SDL_Window *window = NULL;
|
||||
SDL_Renderer *renderer = NULL;
|
||||
static SDL_Texture *texture = NULL;
|
||||
static SDL_bool havefocus = SDL_TRUE;
|
||||
static bool havefocus = true;
|
||||
|
||||
static UINT32 refresh_rate;
|
||||
|
||||
static boolean video_init = false;
|
||||
|
||||
static SDL_bool Impl_CreateWindow(SDL_bool fullscreen);
|
||||
static bool Impl_CreateWindow(bool fullscreen);
|
||||
|
||||
static void Impl_VideoSetupSurfaces(int width, int height);
|
||||
|
||||
|
|
@ -195,37 +198,29 @@ static const char *fallback_resolution_name = "Fallback";
|
|||
CONS_Printf(str "\n", SDL_GetError()); \
|
||||
}
|
||||
|
||||
static SDL_bool Impl_RenderContextCreate(void)
|
||||
static bool Impl_RenderContextCreate(void)
|
||||
{
|
||||
if (rendermode != render_opengl)
|
||||
{
|
||||
int flags = 0; // Use this to set SDL_RENDERER_* flags now
|
||||
|
||||
if (usesdl2soft)
|
||||
flags |= SDL_RENDERER_SOFTWARE;
|
||||
else if (cv_vidwait.value)
|
||||
{
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 18)
|
||||
// If SDL is new enough, we can turn off vsync later.
|
||||
flags |= SDL_RENDERER_PRESENTVSYNC;
|
||||
#else
|
||||
// However, if it isn't, we should just silently turn vid_wait off
|
||||
// This is because the renderer will be created before the config
|
||||
// is read and vid_wait is set from the user's preferences, and thus
|
||||
// vid_wait will have no effect.
|
||||
CV_StealthSetValue(&cv_vidwait, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");
|
||||
|
||||
if (!renderer)
|
||||
renderer = SDL_CreateRenderer(window, -1, flags);
|
||||
{
|
||||
SDL_PropertiesID props = SDL_CreateProperties();
|
||||
if (props == 0)
|
||||
{
|
||||
VIDEO_INIT_ERROR("Couldn't create rendering properties: %s");
|
||||
return false;
|
||||
}
|
||||
if (usesdl2soft)
|
||||
SDL_SetStringProperty(props, SDL_PROP_RENDERER_CREATE_NAME_STRING, "SDL_SOFTWARE_RENDERER");
|
||||
SDL_SetNumberProperty(props, SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER, cv_vidwait.value);
|
||||
SDL_SetPointerProperty(props, SDL_PROP_RENDERER_CREATE_WINDOW_POINTER, window);
|
||||
renderer = SDL_CreateRendererWithProperties(props);
|
||||
}
|
||||
|
||||
if (renderer == NULL)
|
||||
{
|
||||
VIDEO_INIT_ERROR("Couldn't create rendering context: %s");
|
||||
return SDL_FALSE;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -239,16 +234,16 @@ static SDL_bool Impl_RenderContextCreate(void)
|
|||
if (sdlglcontext == NULL)
|
||||
{
|
||||
VIDEO_INIT_ERROR("Couldn't create OpenGL context: %s");
|
||||
return SDL_FALSE;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return SDL_TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
static SDL_bool Impl_RenderContextReset(void)
|
||||
static bool Impl_RenderContextReset(void)
|
||||
{
|
||||
if (renderer)
|
||||
{
|
||||
|
|
@ -261,14 +256,14 @@ static SDL_bool Impl_RenderContextReset(void)
|
|||
}
|
||||
renderer = NULL;
|
||||
|
||||
if (Impl_RenderContextCreate() == SDL_FALSE)
|
||||
return SDL_FALSE;
|
||||
if (Impl_RenderContextCreate() == false)
|
||||
return false;
|
||||
|
||||
#ifdef HWRENDER
|
||||
if (rendermode == render_opengl)
|
||||
{
|
||||
SDL_GL_MakeCurrent(window, sdlglcontext);
|
||||
SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0);
|
||||
SDL_GL_SetSwapInterval(cv_vidwait.value);
|
||||
|
||||
OglSdlSurface(realwidth, realheight);
|
||||
HWR_Startup();
|
||||
|
|
@ -277,11 +272,11 @@ static SDL_bool Impl_RenderContextReset(void)
|
|||
#endif
|
||||
{
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_RenderSetLogicalSize(renderer, realwidth, realheight);
|
||||
SDL_SetRenderLogicalPresentation(renderer, realwidth, realheight, SDL_LOGICAL_PRESENTATION_LETTERBOX);
|
||||
Impl_VideoSetupSurfaces(realwidth, realheight);
|
||||
}
|
||||
|
||||
return SDL_TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void Impl_SetSoftwareVsync(int vsync)
|
||||
|
|
@ -290,7 +285,7 @@ static void Impl_SetSoftwareVsync(int vsync)
|
|||
#if SDL_VERSION_ATLEAST(2,0,18)
|
||||
if (oldvsync != vsync)
|
||||
{
|
||||
SDL_RenderSetVSync(renderer, vsync);
|
||||
SDL_SetRenderVSync(renderer, vsync);
|
||||
}
|
||||
oldvsync = vsync;
|
||||
#endif
|
||||
|
|
@ -298,18 +293,16 @@ static void Impl_SetSoftwareVsync(int vsync)
|
|||
|
||||
static void Impl_VideoSetupSurfaces(int width, int height)
|
||||
{
|
||||
int sw_texture_format = SDL_PIXELFORMAT_ABGR8888;
|
||||
|
||||
if (texture == NULL)
|
||||
texture = SDL_CreateTexture(renderer, sw_texture_format, SDL_TEXTUREACCESS_STREAMING, width, height);
|
||||
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STREAMING, width, height);
|
||||
}
|
||||
|
||||
static SDL_Rect src_rect = { 0, 0, 0, 0 };
|
||||
static SDL_FRect src_rect = { 0, 0, 0, 0 };
|
||||
|
||||
static SDL_bool SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen, SDL_bool reposition)
|
||||
static bool SDLSetMode(INT32 width, INT32 height, bool fullscreen, bool reposition)
|
||||
{
|
||||
static SDL_bool wasfullscreen = SDL_FALSE;
|
||||
int fullscreen_type = SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||
static bool wasfullscreen = false;
|
||||
int fullscreen_type = SDL_WINDOW_FULLSCREEN;
|
||||
|
||||
src_rect.w = realwidth = width;
|
||||
src_rect.h = realheight = height;
|
||||
|
|
@ -318,7 +311,7 @@ static SDL_bool SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen, SDL_b
|
|||
{
|
||||
if (fullscreen)
|
||||
{
|
||||
wasfullscreen = SDL_TRUE;
|
||||
wasfullscreen = true;
|
||||
SDL_SetWindowFullscreen(window, fullscreen_type);
|
||||
I_SetBorderlessWindow();
|
||||
}
|
||||
|
|
@ -326,7 +319,7 @@ static SDL_bool SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen, SDL_b
|
|||
{
|
||||
if (wasfullscreen)
|
||||
{
|
||||
wasfullscreen = SDL_FALSE;
|
||||
wasfullscreen = false;
|
||||
SDL_SetWindowFullscreen(window, 0);
|
||||
}
|
||||
// Reposition window only in windowed mode
|
||||
|
|
@ -337,16 +330,16 @@ static SDL_bool SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen, SDL_b
|
|||
{
|
||||
// Reposition window only in windowed mode
|
||||
SDL_SetWindowPosition(window,
|
||||
SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)),
|
||||
SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window))
|
||||
SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetDisplayForWindow(window)),
|
||||
SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetDisplayForWindow(window))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Impl_CreateWindow(fullscreen) == SDL_FALSE)
|
||||
return SDL_FALSE;
|
||||
if (Impl_CreateWindow(fullscreen) == false)
|
||||
return false;
|
||||
|
||||
wasfullscreen = fullscreen;
|
||||
SDL_SetWindowSize(window, width, height);
|
||||
|
|
@ -354,16 +347,16 @@ static SDL_bool SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen, SDL_b
|
|||
SDL_SetWindowFullscreen(window, fullscreen_type);
|
||||
}
|
||||
|
||||
if (Impl_RenderContextReset() == SDL_FALSE)
|
||||
if (Impl_RenderContextReset() == false)
|
||||
I_Error("Couldn't create or reset rendering context");
|
||||
|
||||
return SDL_TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
static UINT32 VID_GetRefreshRate(void)
|
||||
{
|
||||
int index = SDL_GetWindowDisplayIndex(window);
|
||||
SDL_DisplayMode m;
|
||||
int index = SDL_GetDisplayForWindow(window);
|
||||
const SDL_DisplayMode *m;
|
||||
|
||||
if (SDL_WasInit(SDL_INIT_VIDEO) == 0)
|
||||
{
|
||||
|
|
@ -371,13 +364,14 @@ static UINT32 VID_GetRefreshRate(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (SDL_GetDesktopDisplayMode(index, &m) != 0)
|
||||
m = SDL_GetCurrentDisplayMode(index);
|
||||
if (m == NULL)
|
||||
{
|
||||
// Error has occurred.
|
||||
return 0;
|
||||
}
|
||||
|
||||
return m.refresh_rate;
|
||||
return m->refresh_rate;
|
||||
}
|
||||
|
||||
static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code)
|
||||
|
|
@ -471,11 +465,11 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code)
|
|||
}
|
||||
|
||||
// Get the equivalent ASCII (Unicode?) character for a keypress.
|
||||
static INT32 GetTypedChar(SDL_Keysym keysym)
|
||||
static INT32 GetTypedChar(SDL_KeyboardEvent *evt)
|
||||
{
|
||||
SDL_Event next_event;
|
||||
SDL_Keycode keycode = keysym.sym;
|
||||
SDL_Scancode scancode = keysym.scancode;
|
||||
SDL_Keycode keycode = evt->key;
|
||||
SDL_Scancode scancode = evt->scancode;
|
||||
const boolean Text_Input_Only = (chat_on || CON_Ready() || (menu_text_input && menustack[0])); // only use this this if on chat or console or the current menu wants inputs from us (except if its the control setup menu ig)
|
||||
|
||||
// Special cases, where we always return a fixed value.
|
||||
|
|
@ -489,7 +483,7 @@ static INT32 GetTypedChar(SDL_Keysym keysym)
|
|||
|
||||
if (Text_Input_Only)
|
||||
{
|
||||
if (SDL_PeepEvents(&next_event, 1, SDL_PEEKEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT) == 1 && next_event.type == SDL_TEXTINPUT)
|
||||
if (SDL_PeepEvents(&next_event, 1, SDL_PEEKEVENT, SDL_EVENT_FIRST, SDL_EVENT_LAST) == 1 && next_event.type == SDL_EVENT_TEXT_INPUT)
|
||||
{
|
||||
if (next_event.text.text[1] == '\0') // limit to ASCII
|
||||
return next_event.text.text[0];
|
||||
|
|
@ -518,20 +512,21 @@ static void SDLdoGrabMouse(void)
|
|||
if (disable_mouse)
|
||||
return;
|
||||
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
SDL_SetWindowGrab(window, SDL_TRUE);
|
||||
if (SDL_SetRelativeMouseMode(SDL_TRUE) == 0) // already warps mouse if successful
|
||||
wrapmouseok = SDL_TRUE; // TODO: is wrapmouseok or HalfWarpMouse needed anymore?
|
||||
SDL_HideCursor();
|
||||
SDL_SetWindowMouseGrab(window, true);
|
||||
if (SDL_SetWindowRelativeMouseMode(window, true)) // already warps mouse if successful
|
||||
wrapmouseok = true; // TODO: is wrapmouseok or HalfWarpMouse needed anymore?
|
||||
}
|
||||
|
||||
static void SDLdoUngrabMouse(void)
|
||||
{
|
||||
if (disable_mouse)
|
||||
return;
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
SDL_SetWindowGrab(window, SDL_FALSE);
|
||||
wrapmouseok = SDL_FALSE;
|
||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||
|
||||
SDL_ShowCursor();
|
||||
SDL_SetWindowMouseGrab(window, false);
|
||||
wrapmouseok = false;
|
||||
SDL_SetWindowRelativeMouseMode(window, false);
|
||||
}
|
||||
|
||||
void SDLforceUngrabMouse(void)
|
||||
|
|
@ -639,30 +634,32 @@ static INT32 SDLJoyAxis(const Sint16 axis, UINT8 pid)
|
|||
|
||||
static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
||||
{
|
||||
static SDL_bool firsttimeonmouse = SDL_TRUE;
|
||||
static SDL_bool mousefocus = SDL_TRUE;
|
||||
static SDL_bool kbfocus = SDL_TRUE;
|
||||
static bool firsttimeonmouse = true;
|
||||
static bool mousefocus = true;
|
||||
static bool kbfocus = true;
|
||||
|
||||
switch (evt.event)
|
||||
switch (evt.type)
|
||||
{
|
||||
case SDL_WINDOWEVENT_ENTER:
|
||||
mousefocus = SDL_TRUE;
|
||||
case SDL_EVENT_WINDOW_MOUSE_ENTER:
|
||||
mousefocus = true;
|
||||
break;
|
||||
case SDL_WINDOWEVENT_LEAVE:
|
||||
mousefocus = SDL_FALSE;
|
||||
case SDL_EVENT_WINDOW_MOUSE_LEAVE:
|
||||
mousefocus = false;
|
||||
break;
|
||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||
kbfocus = SDL_TRUE;
|
||||
mousefocus = SDL_TRUE;
|
||||
case SDL_EVENT_WINDOW_FOCUS_GAINED:
|
||||
kbfocus = true;
|
||||
mousefocus = true;
|
||||
break;
|
||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||
kbfocus = SDL_FALSE;
|
||||
mousefocus = SDL_FALSE;
|
||||
case SDL_EVENT_WINDOW_FOCUS_LOST:
|
||||
kbfocus = false;
|
||||
mousefocus = false;
|
||||
break;
|
||||
case SDL_WINDOWEVENT_MAXIMIZED:
|
||||
case SDL_EVENT_WINDOW_MAXIMIZED:
|
||||
break;
|
||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||
case SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED:
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (mousefocus && kbfocus)
|
||||
|
|
@ -695,11 +692,11 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type)
|
|||
|
||||
event.device = 0;
|
||||
|
||||
if (type == SDL_KEYUP)
|
||||
if (type == SDL_EVENT_KEY_UP)
|
||||
{
|
||||
event.type = ev_keyup;
|
||||
}
|
||||
else if (type == SDL_KEYDOWN)
|
||||
else if (type == SDL_EVENT_KEY_DOWN)
|
||||
{
|
||||
event.type = ev_keydown;
|
||||
}
|
||||
|
|
@ -711,10 +708,10 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type)
|
|||
switch (cv_keyboardlayout.value)
|
||||
{
|
||||
case 2: // "native"
|
||||
event.data1 = GetTypedChar(evt.keysym);
|
||||
event.data1 = GetTypedChar(&evt);
|
||||
break;
|
||||
default:
|
||||
event.data1 = Impl_SDL_Scancode_To_Keycode(evt.keysym.scancode);
|
||||
event.data1 = Impl_SDL_Scancode_To_Keycode(evt.scancode);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -736,13 +733,13 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
|
|||
|
||||
// If using relative mouse mode, don't post an event_t just now,
|
||||
// add on the offsets so we can make an overall event later.
|
||||
if (SDL_GetRelativeMouseMode())
|
||||
if (SDL_GetWindowRelativeMouseMode(window))
|
||||
{
|
||||
if (SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window)
|
||||
{
|
||||
mousemovex += evt.xrel;
|
||||
mousemovey += -evt.yrel;
|
||||
SDL_SetWindowGrab(window, SDL_TRUE);
|
||||
SDL_SetWindowMouseGrab(window, true);
|
||||
}
|
||||
firstmove = false;
|
||||
return;
|
||||
|
|
@ -750,7 +747,7 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
|
|||
|
||||
// If the event is from warping the pointer to middle
|
||||
// of the screen then ignore it.
|
||||
if ((evt.x == realwidth/2) && (evt.y == realheight/2))
|
||||
if (((int)evt.x == realwidth/2) && ((int)evt.y == realheight/2))
|
||||
{
|
||||
firstmove = false;
|
||||
return;
|
||||
|
|
@ -788,11 +785,11 @@ static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type)
|
|||
{
|
||||
event.device = 0;
|
||||
|
||||
if (type == SDL_MOUSEBUTTONUP)
|
||||
if (type == SDL_EVENT_MOUSE_BUTTON_UP)
|
||||
{
|
||||
event.type = ev_keyup;
|
||||
}
|
||||
else if (type == SDL_MOUSEBUTTONDOWN)
|
||||
else if (type == SDL_EVENT_MOUSE_BUTTON_DOWN)
|
||||
{
|
||||
event.type = ev_keydown;
|
||||
}
|
||||
|
|
@ -822,17 +819,18 @@ static void Impl_HandleMouseWheelEvent(SDL_MouseWheelEvent evt)
|
|||
|
||||
event.device = 0;
|
||||
|
||||
if (evt.y > 0)
|
||||
int y = evt.y;
|
||||
if (y > 0)
|
||||
{
|
||||
event.data1 = KEY_MOUSEWHEELUP;
|
||||
event.type = ev_keydown;
|
||||
}
|
||||
if (evt.y < 0)
|
||||
else if (y < 0)
|
||||
{
|
||||
event.data1 = KEY_MOUSEWHEELDOWN;
|
||||
event.type = ev_keydown;
|
||||
}
|
||||
if (evt.y == 0)
|
||||
else if (y == 0)
|
||||
{
|
||||
event.data1 = 0;
|
||||
event.type = ev_keyup;
|
||||
|
|
@ -843,7 +841,7 @@ static void Impl_HandleMouseWheelEvent(SDL_MouseWheelEvent evt)
|
|||
}
|
||||
}
|
||||
|
||||
static void Impl_HandleControllerAxisEvent(SDL_ControllerAxisEvent evt)
|
||||
static void Impl_HandleControllerAxisEvent(SDL_GamepadAxisEvent evt)
|
||||
{
|
||||
event_t event;
|
||||
|
||||
|
|
@ -860,22 +858,22 @@ static void Impl_HandleControllerAxisEvent(SDL_ControllerAxisEvent evt)
|
|||
//axis
|
||||
switch (evt.axis)
|
||||
{
|
||||
case SDL_CONTROLLER_AXIS_LEFTX:
|
||||
case SDL_GAMEPAD_AXIS_LEFTX:
|
||||
event.data1 = 0;
|
||||
break;
|
||||
case SDL_CONTROLLER_AXIS_LEFTY:
|
||||
case SDL_GAMEPAD_AXIS_LEFTY:
|
||||
event.data1 = 1;
|
||||
break;
|
||||
case SDL_CONTROLLER_AXIS_RIGHTX:
|
||||
case SDL_GAMEPAD_AXIS_RIGHTX:
|
||||
event.data1 = 2;
|
||||
break;
|
||||
case SDL_CONTROLLER_AXIS_RIGHTY:
|
||||
case SDL_GAMEPAD_AXIS_RIGHTY:
|
||||
event.data1 = 3;
|
||||
break;
|
||||
case SDL_CONTROLLER_AXIS_TRIGGERLEFT:
|
||||
case SDL_GAMEPAD_AXIS_LEFT_TRIGGER:
|
||||
event.data1 = 4;
|
||||
break;
|
||||
case SDL_CONTROLLER_AXIS_TRIGGERRIGHT:
|
||||
case SDL_GAMEPAD_AXIS_RIGHT_TRIGGER:
|
||||
event.data1 = 5;
|
||||
break;
|
||||
default:
|
||||
|
|
@ -888,7 +886,7 @@ static void Impl_HandleControllerAxisEvent(SDL_ControllerAxisEvent evt)
|
|||
D_PostEvent(&event);
|
||||
}
|
||||
|
||||
static void Impl_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint32 type)
|
||||
static void Impl_HandleControllerButtonEvent(SDL_GamepadButtonEvent evt, Uint32 type)
|
||||
{
|
||||
event_t event;
|
||||
|
||||
|
|
@ -901,11 +899,11 @@ static void Impl_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == SDL_CONTROLLERBUTTONUP)
|
||||
if (type == SDL_EVENT_GAMEPAD_BUTTON_UP)
|
||||
{
|
||||
event.type = ev_keyup;
|
||||
}
|
||||
else if (type == SDL_CONTROLLERBUTTONDOWN)
|
||||
else if (type == SDL_EVENT_GAMEPAD_BUTTON_DOWN)
|
||||
{
|
||||
event.type = ev_keydown;
|
||||
}
|
||||
|
|
@ -931,22 +929,10 @@ static void Impl_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint
|
|||
}
|
||||
}
|
||||
|
||||
static void Impl_HandleVideoEvent(SDL_Event *evt)
|
||||
{
|
||||
switch (evt->type)
|
||||
{
|
||||
case SDL_WINDOWEVENT:
|
||||
Impl_HandleWindowEvent(evt->window);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void I_GetEvent(void)
|
||||
{
|
||||
SDL_Event evt;
|
||||
char* dropped_filedir;
|
||||
const char* dropped_filedir;
|
||||
|
||||
UINT8 i;
|
||||
|
||||
|
|
@ -956,42 +942,39 @@ void I_GetEvent(void)
|
|||
{
|
||||
switch (evt.type)
|
||||
{
|
||||
default:
|
||||
Impl_HandleVideoEvent(&evt);
|
||||
break;
|
||||
// TODO: Move input code out of this file, desperately
|
||||
case SDL_KEYUP:
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_EVENT_KEY_UP:
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
Impl_HandleKeyboardEvent(evt.key, evt.type);
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
case SDL_EVENT_MOUSE_MOTION:
|
||||
//if (!mouseMotionOnce)
|
||||
Impl_HandleMouseMotionEvent(evt.motion);
|
||||
//mouseMotionOnce = 1;
|
||||
break;
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
case SDL_EVENT_MOUSE_BUTTON_UP:
|
||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||
Impl_HandleMouseButtonEvent(evt.button, evt.type);
|
||||
break;
|
||||
case SDL_MOUSEWHEEL:
|
||||
case SDL_EVENT_MOUSE_WHEEL:
|
||||
Impl_HandleMouseWheelEvent(evt.wheel);
|
||||
break;
|
||||
case SDL_CONTROLLERAXISMOTION:
|
||||
Impl_HandleControllerAxisEvent(evt.caxis);
|
||||
case SDL_EVENT_GAMEPAD_AXIS_MOTION:
|
||||
Impl_HandleControllerAxisEvent(evt.gaxis);
|
||||
break;
|
||||
case SDL_CONTROLLERBUTTONUP:
|
||||
case SDL_CONTROLLERBUTTONDOWN:
|
||||
Impl_HandleControllerButtonEvent(evt.cbutton, evt.type);
|
||||
case SDL_EVENT_GAMEPAD_BUTTON_UP:
|
||||
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
|
||||
Impl_HandleControllerButtonEvent(evt.gbutton, evt.type);
|
||||
break;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
case SDL_CONTROLLERDEVICEADDED:
|
||||
case SDL_EVENT_GAMEPAD_ADDED:
|
||||
{
|
||||
// OH BOY are you in for a good time! #abominationstation
|
||||
|
||||
SDL_GameController *newcontroller = SDL_GameControllerOpen(evt.cdevice.which);
|
||||
SDL_Gamepad *newcontroller = SDL_OpenGamepad(evt.cdevice.which);
|
||||
|
||||
CONS_Debug(DBG_GAMELOGIC, "Controller device index %d added\n", evt.cdevice.which + 1);
|
||||
|
||||
|
|
@ -1008,7 +991,7 @@ void I_GetEvent(void)
|
|||
|
||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
{
|
||||
if (newcontroller && (!JoyInfo[i].dev || !SDL_GameControllerGetAttached(JoyInfo[i].dev)))
|
||||
if (newcontroller && (!JoyInfo[i].dev || !SDL_GamepadConnected(JoyInfo[i].dev)))
|
||||
{
|
||||
UINT8 j;
|
||||
|
||||
|
|
@ -1080,10 +1063,10 @@ void I_GetEvent(void)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
case SDL_CONTROLLERDEVICEREMOVED:
|
||||
case SDL_EVENT_GAMEPAD_REMOVED:
|
||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
{
|
||||
if (JoyInfo[i].dev && !SDL_GameControllerGetAttached(JoyInfo[i].dev))
|
||||
if (JoyInfo[i].dev && !SDL_GamepadConnected(JoyInfo[i].dev))
|
||||
{
|
||||
CONS_Debug(DBG_GAMELOGIC, "Joystick%d removed, device index: %d\n", i+1, JoyInfo[i].oldjoy);
|
||||
I_ShutdownJoystick(i);
|
||||
|
|
@ -1128,15 +1111,17 @@ void I_GetEvent(void)
|
|||
MR_SetupJoystickMenu(0);
|
||||
numcontrollers = I_NumJoys();
|
||||
break;
|
||||
case SDL_DROPFILE:
|
||||
dropped_filedir = evt.drop.file;
|
||||
P_AddWadFile(dropped_filedir, WC_AUTO, false);
|
||||
SDL_free(dropped_filedir); // Free dropped_filedir memory
|
||||
case SDL_EVENT_DROP_FILE:
|
||||
dropped_filedir = evt.drop.data;
|
||||
COM_BufInsertText(va("addfile \"%s\"", dropped_filedir));
|
||||
break;
|
||||
case SDL_QUIT:
|
||||
case SDL_EVENT_QUIT:
|
||||
LUA_HookBool(true, HOOK(GameQuit));
|
||||
I_Quit();
|
||||
break;
|
||||
default:
|
||||
Impl_HandleWindowEvent(evt.window);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1165,9 +1150,9 @@ void I_GetEvent(void)
|
|||
|
||||
void I_StartupMouse(void)
|
||||
{
|
||||
static SDL_bool firsttimeonmouse = SDL_TRUE;
|
||||
static bool firsttimeonmouse = true;
|
||||
|
||||
disable_mouse = static_cast<SDL_bool>(M_CheckParm("-nomouse"));
|
||||
disable_mouse = static_cast<bool>(M_CheckParm("-nomouse"));
|
||||
|
||||
if (disable_mouse)
|
||||
{
|
||||
|
|
@ -1180,7 +1165,7 @@ void I_StartupMouse(void)
|
|||
HalfWarpMouse(realwidth, realheight); // warp to center
|
||||
}
|
||||
else
|
||||
firsttimeonmouse = SDL_FALSE;
|
||||
firsttimeonmouse = false;
|
||||
if (cv_usemouse.value && !IgnoreMouse())
|
||||
SDLdoGrabMouse();
|
||||
else
|
||||
|
|
@ -1197,8 +1182,8 @@ void I_OsPolling(void)
|
|||
if (consolevent)
|
||||
I_GetConsoleEvents();
|
||||
|
||||
if (SDL_WasInit(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) == (SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER))
|
||||
SDL_GameControllerUpdate();
|
||||
if (SDL_WasInit(SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD) == (SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD))
|
||||
SDL_UpdateGamepads();
|
||||
|
||||
I_GetEvent();
|
||||
|
||||
|
|
@ -1206,13 +1191,13 @@ void I_OsPolling(void)
|
|||
/* Handle here so that our state is always synched with the system. */
|
||||
shiftdown = ctrldown = altdown = 0;
|
||||
capslock = false;
|
||||
if (mod & KMOD_LSHIFT) shiftdown |= 1;
|
||||
if (mod & KMOD_RSHIFT) shiftdown |= 2;
|
||||
if (mod & KMOD_LCTRL) ctrldown |= 1;
|
||||
if (mod & KMOD_RCTRL) ctrldown |= 2;
|
||||
if (mod & KMOD_LALT) altdown |= 1;
|
||||
if (mod & KMOD_RALT) altdown |= 2;
|
||||
if (mod & KMOD_CAPS) capslock = true;
|
||||
if (mod & SDL_KMOD_LSHIFT) shiftdown |= 1;
|
||||
if (mod & SDL_KMOD_RSHIFT) shiftdown |= 2;
|
||||
if (mod & SDL_KMOD_LCTRL) ctrldown |= 1;
|
||||
if (mod & SDL_KMOD_RCTRL) ctrldown |= 2;
|
||||
if (mod & SDL_KMOD_LALT) altdown |= 1;
|
||||
if (mod & SDL_KMOD_RALT) altdown |= 2;
|
||||
if (mod & SDL_KMOD_CAPS) capslock = true;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -1328,7 +1313,7 @@ void I_FinishUpdate(void)
|
|||
SDL_UnlockTexture(texture);
|
||||
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_RenderCopy(renderer, texture, &src_rect, NULL);
|
||||
SDL_RenderTexture(renderer, texture, &src_rect, NULL);
|
||||
SDL_RenderPresent(renderer);
|
||||
Impl_SetSoftwareVsync(cv_vidwait.value);
|
||||
}
|
||||
|
|
@ -1497,9 +1482,9 @@ boolean VID_CheckRenderer(void)
|
|||
setrenderneeded = 0;
|
||||
}
|
||||
|
||||
SDL_bool center = setmodeneeded ? SDL_TRUE : SDL_FALSE;
|
||||
bool center = setmodeneeded ? true : false;
|
||||
|
||||
if (SDLSetMode(vid.width, vid.height, USE_FULLSCREEN, center) == SDL_FALSE)
|
||||
if (SDLSetMode(vid.width, vid.height, USE_FULLSCREEN, center) == false)
|
||||
{
|
||||
if (!graphics_started)
|
||||
{
|
||||
|
|
@ -1554,35 +1539,35 @@ INT32 VID_SetMode(INT32 modeNum)
|
|||
else
|
||||
{
|
||||
// just set the desktop resolution as a fallback
|
||||
SDL_DisplayMode mode;
|
||||
SDL_GetWindowDisplayMode(window, &mode);
|
||||
if (mode.w >= 2048)
|
||||
const SDL_DisplayMode *mode;
|
||||
mode = SDL_GetWindowFullscreenMode(window);
|
||||
if (mode->w >= 2048)
|
||||
{
|
||||
vid.width = 1920;
|
||||
vid.height = 1200;
|
||||
}
|
||||
else
|
||||
{
|
||||
vid.width = mode.w;
|
||||
vid.height = mode.h;
|
||||
vid.width = mode->w;
|
||||
vid.height = mode->h;
|
||||
}
|
||||
vid.modenum = -1;
|
||||
}
|
||||
|
||||
VID_CheckRenderer();
|
||||
|
||||
return SDL_TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
static SDL_bool Impl_CreateWindow(SDL_bool fullscreen)
|
||||
static bool Impl_CreateWindow(bool fullscreen)
|
||||
{
|
||||
int flags = 0;
|
||||
|
||||
if (window != NULL)
|
||||
return SDL_TRUE;
|
||||
return true;
|
||||
|
||||
if (fullscreen)
|
||||
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||
flags |= SDL_WINDOW_FULLSCREEN;
|
||||
|
||||
if (borderlesswindow)
|
||||
flags |= SDL_WINDOW_BORDERLESS;
|
||||
|
|
@ -1602,16 +1587,16 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen)
|
|||
char versionstring[256];
|
||||
sprintf(versionstring, "BlanKart Indev %s", comprevision);
|
||||
|
||||
window = SDL_CreateWindow(versionstring, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, realwidth, realheight, flags);
|
||||
window = SDL_CreateWindow(versionstring, realwidth, realheight, flags);
|
||||
}
|
||||
#else
|
||||
window = SDL_CreateWindow("BlanKart " VERSIONSTRING, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, realwidth, realheight, flags);
|
||||
window = SDL_CreateWindow("BlanKart " VERSIONSTRING, realwidth, realheight, flags);
|
||||
#endif
|
||||
|
||||
if (window == NULL)
|
||||
{
|
||||
VIDEO_INIT_ERROR("Couldn't create window: %s");
|
||||
return SDL_FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_SetWindowMinimumSize(window, BASEVIDWIDTH, BASEVIDHEIGHT);
|
||||
|
|
@ -1621,7 +1606,7 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen)
|
|||
Impl_SetWindowIcon();
|
||||
#endif
|
||||
|
||||
return SDL_TRUE;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1638,7 +1623,7 @@ static void Impl_InitVideoSubSystem(void)
|
|||
if (video_init)
|
||||
return;
|
||||
|
||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
|
||||
if (!SDL_InitSubSystem(SDL_INIT_VIDEO))
|
||||
{
|
||||
CONS_Printf(M_GetText("Couldn't initialize SDL's Video System: %s\n"), SDL_GetError());
|
||||
return;
|
||||
|
|
@ -1671,8 +1656,8 @@ void I_StartupGraphics(void)
|
|||
if (graphics_started)
|
||||
return;
|
||||
|
||||
disable_mouse = static_cast<SDL_bool>(M_CheckParm("-nomouse"));
|
||||
disable_fullscreen = M_CheckParm("-win") ? SDL_TRUE : SDL_FALSE;
|
||||
disable_mouse = static_cast<bool>(M_CheckParm("-nomouse"));
|
||||
disable_fullscreen = M_CheckParm("-win") ? true : false;
|
||||
|
||||
keyboard_started = true;
|
||||
|
||||
|
|
@ -1691,7 +1676,7 @@ void I_StartupGraphics(void)
|
|||
strncasecmp(vd, "wii", 4) == 0 ||
|
||||
strncasecmp(vd, "psl1ght", 8) == 0
|
||||
)
|
||||
framebuffer = SDL_TRUE;
|
||||
framebuffer = true;
|
||||
}
|
||||
|
||||
rendermode = render_soft;
|
||||
|
|
@ -1735,8 +1720,8 @@ void I_StartupGraphics(void)
|
|||
if (chosenrendermode != render_none)
|
||||
rendermode = chosenrendermode;
|
||||
|
||||
usesdl2soft = M_CheckParm("-softblit") ? SDL_TRUE : SDL_FALSE;
|
||||
borderlesswindow = M_CheckParm("-borderless") ? SDL_TRUE : SDL_FALSE;
|
||||
usesdl2soft = M_CheckParm("-softblit") ? true : false;
|
||||
borderlesswindow = M_CheckParm("-borderless") ? true : false;
|
||||
|
||||
#ifdef HWRENDER
|
||||
if (rendermode == render_opengl)
|
||||
|
|
@ -1798,7 +1783,7 @@ void I_ShutdownGraphics(void)
|
|||
{
|
||||
#ifdef USE_WINDOW_ICON
|
||||
if (icoSurface)
|
||||
SDL_FreeSurface(icoSurface);
|
||||
SDL_DestroySurface(icoSurface);
|
||||
icoSurface = NULL;
|
||||
#endif
|
||||
|
||||
|
|
@ -1818,12 +1803,12 @@ void I_ShutdownGraphics(void)
|
|||
#ifdef HWRENDER
|
||||
if (sdlglcontext)
|
||||
{
|
||||
SDL_GL_DeleteContext(sdlglcontext);
|
||||
SDL_GL_DestroyContext(sdlglcontext);
|
||||
}
|
||||
#endif
|
||||
if (SDL_WasInit(SDL_INIT_VIDEO) == SDL_INIT_VIDEO)
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
framebuffer = SDL_FALSE;
|
||||
framebuffer = false;
|
||||
}
|
||||
|
||||
UINT32 I_GetRefreshRate(void)
|
||||
|
|
@ -1838,7 +1823,7 @@ UINT32 I_GetRefreshRate(void)
|
|||
|
||||
void I_SetBorderlessWindow(void)
|
||||
{
|
||||
SDL_bool borderless = (cv_fullscreen.value == 2) ? SDL_FALSE : SDL_TRUE;
|
||||
bool borderless = (cv_fullscreen.value == 2) ? false : true;
|
||||
SDL_SetWindowBordered(window, borderless);
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
#ifdef HAVE_SDL
|
||||
#define _MATH_DEFINES_DEFINED
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include "sdlmain.h"
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ boolean LoadGL(void)
|
|||
if (M_CheckParm("-OGLlib") && M_IsNextParm())
|
||||
OGLLibname = M_GetNextParm();
|
||||
|
||||
if (SDL_GL_LoadLibrary(OGLLibname) != 0)
|
||||
if (!SDL_GL_LoadLibrary(OGLLibname))
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "Could not load OpenGL Library: %s\n"
|
||||
"Falling back to Software mode.\n", SDL_GetError());
|
||||
|
|
@ -153,7 +153,7 @@ boolean OglSdlSurface(INT32 w, INT32 h)
|
|||
|
||||
glanisotropicmode_cons_t[1].value = maximumAnisotropy;
|
||||
|
||||
SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0);
|
||||
SDL_GL_SetSwapInterval(cv_vidwait.value);
|
||||
|
||||
SetModelView(w, h);
|
||||
SetStates();
|
||||
|
|
@ -177,7 +177,7 @@ void OglSdlFinishUpdate(boolean waitvbl)
|
|||
int sdlw, sdlh;
|
||||
if (oldwaitvbl != waitvbl)
|
||||
{
|
||||
SDL_GL_SetSwapInterval(waitvbl ? 1 : 0);
|
||||
SDL_GL_SetSwapInterval(waitvbl);
|
||||
}
|
||||
|
||||
oldwaitvbl = waitvbl;
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@
|
|||
#ifndef __sdlmain__
|
||||
#define __sdlmain__
|
||||
|
||||
extern SDL_bool consolevent;
|
||||
extern SDL_bool framebuffer;
|
||||
extern bool consolevent;
|
||||
extern bool framebuffer;
|
||||
|
||||
#include "../m_fixed.h"
|
||||
#include "../doomdef.h"
|
||||
|
|
@ -29,8 +29,8 @@ extern SDL_bool framebuffer;
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
// SDL2 stub macro
|
||||
#define SDL2STUB() CONS_Printf("SDL2: stubbed: %s:%d\n", __func__, __LINE__)
|
||||
// SDL3 stub macro
|
||||
#define SDL3STUB() CONS_Printf("SDL3: stubbed: %s:%d\n", __func__, __LINE__)
|
||||
|
||||
// So m_menu knows whether to store cv_usejoystick value or string
|
||||
#define JOYSTICK_HOTPLUG
|
||||
|
|
@ -42,7 +42,7 @@ extern "C" {
|
|||
typedef struct SDLJoyInfo_s
|
||||
{
|
||||
/// Controller handle
|
||||
SDL_GameController *dev;
|
||||
SDL_Gamepad *dev;
|
||||
/// number of old joystick
|
||||
int oldjoy;
|
||||
/// number of axies
|
||||
|
|
@ -61,9 +61,9 @@ typedef struct SDLJoyInfo_s
|
|||
/** \brief SDL info about controllers
|
||||
*/
|
||||
extern SDLJoyInfo_t JoyInfo[MAXSPLITSCREENPLAYERS];
|
||||
extern SDL_GameController *ExJoystick[MAXGAMEPADS];
|
||||
extern SDL_Gamepad *ExJoystick[MAXGAMEPADS];
|
||||
|
||||
void I_StoreExJoystick(SDL_GameController *dev);
|
||||
void I_StoreExJoystick(SDL_Gamepad *dev);
|
||||
|
||||
/** \brief joystick axis deadzone
|
||||
*/
|
||||
|
|
@ -76,7 +76,7 @@ void I_GetConsoleEvents(void);
|
|||
void I_ShutdownJoystick(UINT8 index);
|
||||
|
||||
// Cheat to get the device index for a game controller handle
|
||||
INT32 I_GetJoystickDeviceIndex(SDL_GameController *dev);
|
||||
INT32 I_GetJoystickDeviceIndex(SDL_Gamepad *dev);
|
||||
|
||||
// Quick thing to make SDL_JOYDEVICEADDED events less of an abomination
|
||||
void I_UpdateJoystickDeviceIndex(UINT8 player);
|
||||
|
|
|
|||
Loading…
Reference in a new issue