Updates SDL to 2.0.12

This commit is contained in:
Areloch 2020-08-12 11:56:18 -05:00
parent 3108a08650
commit a526029f2f
861 changed files with 25596 additions and 8904 deletions

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -228,7 +228,23 @@ private:
return;
}
win = GetSDLWindow(winID);
SDL_SendMouseMotion(win, 0, 0, x, y);
// Simple relative mode support for mouse.
if (SDL_GetMouse()->relative_mode) {
int winWidth, winHeight, winPosX, winPosY;
SDL_GetWindowSize(win, &winWidth, &winHeight);
SDL_GetWindowPosition(win, &winPosX, &winPosY);
int dx = x - (winWidth / 2);
int dy = y - (winHeight / 2);
SDL_SendMouseMotion(win, 0, SDL_GetMouse()->relative_mode, dx, dy);
set_mouse_position((winPosX + winWidth / 2), (winPosY + winHeight / 2));
if (!be_app->IsCursorHidden())
be_app->HideCursor();
} else {
SDL_SendMouseMotion(win, 0, 0, x, y);
if (SDL_ShowCursor(-1) && be_app->IsCursorHidden())
be_app->ShowCursor();
}
/* Tell the application that the mouse passed over, redraw needed */
HAIKU_UpdateWindowFramebuffer(NULL,win,NULL,-1);
@ -261,7 +277,7 @@ private:
return;
}
win = GetSDLWindow(winID);
SDL_SendMouseWheel(win, 0, xTicks, yTicks, SDL_MOUSEWHEEL_NORMAL);
SDL_SendMouseWheel(win, 0, xTicks, -yTicks, SDL_MOUSEWHEEL_NORMAL);
}
void _HandleKey(BMessage *msg) {
@ -285,7 +301,7 @@ private:
ssize_t count;
if (msg->FindData("key-utf8", B_INT8_TYPE, (const void**)&keyUtf8, &count) == B_OK) {
char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];
SDL_zero(text);
SDL_zeroa(text);
SDL_memcpy(text, keyUtf8, count);
SDL_SendKeyboardText(text);
}

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -48,13 +48,14 @@ extern "C" {
static int SDL_BeAppActive = 0;
static SDL_Thread *SDL_AppThread = NULL;
/* Default application signature */
const char *signature = "application/x-SDL-executable";
static int
StartBeApp(void *unused)
{
BApplication *App;
// default application signature
const char *signature = "application/x-SDL-executable";
// dig resources for correct signature
image_info info;
int32 cookie = 0;

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -31,6 +31,9 @@ extern int SDL_InitBeApp(void);
/* Quit the Be Application, if there's nothing left to do */
extern void SDL_QuitBeApp(void);
/* Be Application Signature*/
extern const char *signature;
/* vi: set ts=4 sw=4 expandtab: */
#ifdef __cplusplus

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View file

@ -9,6 +9,7 @@
/* Include this so we define UNICODE properly */
#include "../../core/windows/SDL_windows.h"
#include <shellapi.h> /* CommandLineToArgvW() */
/* Include the SDL main definition header */
#include "SDL.h"
@ -18,87 +19,7 @@
# undef main
#endif /* main */
static void
UnEscapeQuotes(char *arg)
{
char *last = NULL;
while (*arg) {
if (*arg == '"' && (last != NULL && *last == '\\')) {
char *c_curr = arg;
char *c_last = last;
while (*c_curr) {
*c_last = *c_curr;
c_last = c_curr;
c_curr++;
}
*c_last = '\0';
}
last = arg;
arg++;
}
}
/* Parse a command line buffer into arguments */
static int
ParseCommandLine(char *cmdline, char **argv)
{
char *bufp;
char *lastp = NULL;
int argc, last_argc;
argc = last_argc = 0;
for (bufp = cmdline; *bufp;) {
/* Skip leading whitespace */
while (*bufp == ' ' || *bufp == '\t') {
++bufp;
}
/* Skip over argument */
if (*bufp == '"') {
++bufp;
if (*bufp) {
if (argv) {
argv[argc] = bufp;
}
++argc;
}
/* Skip over word */
lastp = bufp;
while (*bufp && (*bufp != '"' || *lastp == '\\')) {
lastp = bufp;
++bufp;
}
} else {
if (*bufp) {
if (argv) {
argv[argc] = bufp;
}
++argc;
}
/* Skip over word */
while (*bufp && (*bufp != ' ' && *bufp != '\t')) {
++bufp;
}
}
if (*bufp) {
if (argv) {
*bufp = '\0';
}
++bufp;
}
/* Strip out \ from \" sequences */
if (argv && last_argc != argc) {
UnEscapeQuotes(argv[last_argc]);
}
last_argc = argc;
}
if (argv) {
argv[argc] = NULL;
}
return (argc);
}
#define WIN_WStringToUTF8(S) SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR))
/* Pop up an out of memory message, returns to Windows */
static BOOL
@ -119,65 +40,43 @@ OutOfMemory(void)
/* Gets the arguments with GetCommandLine, converts them to argc and argv
and calls SDL_main */
static int
main_getcmdline()
main_getcmdline(void)
{
LPWSTR *argvw;
char **argv;
int argc;
char *cmdline = NULL;
int retval = 0;
int cmdalloc = 0;
const TCHAR *text = GetCommandLine();
const TCHAR *ptr;
int argc_guess = 2; /* space for NULL and initial argument. */
int rc;
int i, argc, result;
/* make a rough guess of command line arguments. Overestimates if there
are quoted things. */
for (ptr = text; *ptr; ptr++) {
if ((*ptr == ' ') || (*ptr == '\t')) {
argc_guess++;
}
}
#if UNICODE
rc = WideCharToMultiByte(CP_UTF8, 0, text, -1, NULL, 0, NULL, NULL);
if (rc > 0) {
cmdalloc = rc + (sizeof (char *) * argc_guess);
argv = (char **) VirtualAlloc(NULL, cmdalloc, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
if (argv) {
int rc2;
cmdline = (char *) (argv + argc_guess);
rc2 = WideCharToMultiByte(CP_UTF8, 0, text, -1, cmdline, rc, NULL, NULL);
SDL_assert(rc2 == rc);
}
}
#else
/* !!! FIXME: are these in the system codepage? We need to convert to UTF-8. */
rc = ((int) SDL_strlen(text)) + 1;
cmdalloc = rc + (sizeof (char *) * argc_guess);
argv = (char **) VirtualAlloc(NULL, cmdalloc, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
if (argv) {
cmdline = (char *) (argv + argc_guess);
SDL_strcpy(cmdline, text);
}
#endif
if (cmdline == NULL) {
argvw = CommandLineToArgvW(GetCommandLineW(), &argc);
if (argvw == NULL) {
return OutOfMemory();
}
/* Parse it into argv and argc */
SDL_assert(ParseCommandLine(cmdline, NULL) <= argc_guess);
argc = ParseCommandLine(cmdline, argv);
argv = (char **)SDL_calloc(argc + 1, sizeof(*argv));
if (!argv) {
return OutOfMemory();
}
for (i = 0; i < argc; ++i) {
argv[i] = WIN_WStringToUTF8(argvw[i]);
if (!argv[i]) {
return OutOfMemory();
}
}
argv[i] = NULL;
LocalFree(argvw);
SDL_SetMainReady();
/* Run the application main() code */
retval = SDL_main(argc, argv);
result = SDL_main(argc, argv);
VirtualFree(argv, cmdalloc, MEM_DECOMMIT);
VirtualFree(argv, 0, MEM_RELEASE);
/* Free argv, to avoid memory leak */
for (i = 0; i < argc; ++i) {
SDL_free(argv[i]);
}
SDL_free(argv);
return retval;
return result;
}
/* This is where execution begins [console apps, ansi] */

View file

@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,0,10,0
PRODUCTVERSION 2,0,10,0
FILEVERSION 2,0,12,0
PRODUCTVERSION 2,0,12,0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x40004L
@ -23,12 +23,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "SDL\0"
VALUE "FileVersion", "2, 0, 10, 0\0"
VALUE "FileVersion", "2, 0, 12, 0\0"
VALUE "InternalName", "SDL\0"
VALUE "LegalCopyright", "Copyright © 2019 Sam Lantinga\0"
VALUE "LegalCopyright", "Copyright © 2020 Sam Lantinga\0"
VALUE "OriginalFilename", "SDL2.dll\0"
VALUE "ProductName", "Simple DirectMedia Layer\0"
VALUE "ProductVersion", "2, 0, 10, 0\0"
VALUE "ProductVersion", "2, 0, 12, 0\0"
END
END
BLOCK "VarFileInfo"