Skip to content

Commit

Permalink
Merge branch 'SDL2' into MorphOS-SDL-2
Browse files Browse the repository at this point in the history
  • Loading branch information
BeWorld2018 committed Mar 19, 2024
2 parents 4f3544a + 43f0ae1 commit 44e1650
Show file tree
Hide file tree
Showing 96 changed files with 1,042 additions and 490 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- { name: CMake, cmake: 1, android_abi: "arm64-v8a", android_platform: 23, arch: "aarch64" }

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: nttld/setup-ndk@v1
id: setup_ndk
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cpactions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ jobs:
name: FreeBSD
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Build
uses: cross-platform-actions/action@v0.19.1
uses: cross-platform-actions/action@v0.23.0
with:
operating_system: freebsd
version: '13.2'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/emscripten.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ jobs:
emscripten:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: mymindstorm/setup-emsdk@v12
- uses: actions/checkout@v4
- uses: mymindstorm/setup-emsdk@v14
with:
version: 3.1.35
- name: Install ninja
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ jobs:
- { name: tvOS, target: Static Library-tvOS, sdk: appletvos }

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Build
run: xcodebuild -project Xcode/SDL/SDL.xcodeproj -target '${{ matrix.platform.target }}' -configuration Release -sdk ${{ matrix.platform.sdk }} clean build
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
# Install oneAPI
sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Check that versioning is consistent
# We only need to run this once: arbitrarily use the Linux/CMake build
if: "runner.os == 'Linux' && ! matrix.platform.autotools"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/msvc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
project: VisualC-WinRT/SDL-UWP.sln, projectflags: '/p:Platform=x64 /p:WindowsTargetPlatformVersion=10.0.17763.0' }

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Create CMake project using SDL as a subproject
shell: python
run: |
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
- name: Add msbuild to PATH
if: ${{ matrix.platform.project != '' }}
uses: microsoft/setup-msbuild@v1.1.3
uses: microsoft/setup-msbuild@v2
- name: Build msbuild
if: ${{ matrix.platform.project != '' }}
run: msbuild ${{ matrix.platform.project }} /m /p:BuildInParallel=true /p:Configuration=Release ${{ matrix.platform.projectflags }}
2 changes: 1 addition & 1 deletion .github/workflows/n3ds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
container:
image: devkitpro/devkitarm:latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install build requirements
run: |
apt update
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ps2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
container: ps2dev/ps2dev:latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup dependencies
run: |
apk update
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/psp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
container: pspdev/pspdev:latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup dependencies
run: |
apk update
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/riscos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:
- name: Setup dependencies
run: apt-get update && apt-get install -y cmake ninja-build
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Configure (autotools)
if: ${{ contains(matrix.platform.name, 'autotools') }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/vita.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- { name: GLES (pib), os: windows-latest, pib: true }
- { name: GLES (PVR_PSP2 + gl4es4vita), os: windows-latest, pvr: true }
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install build requirements
run: |
apk update
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/watcom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- { name: OS/2, makefile: Makefile.os2 }

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: open-watcom/setup-watcom@v0
- name: Build SDL2
run: |
Expand Down
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ endif()
set(CMAKE_POLICY_DEFAULT_CMP0091 NEW)

cmake_minimum_required(VERSION 3.0.0...3.5)
project(SDL2 C CXX)
project(SDL2 C)

if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
set(SDL2_SUBPROJECT OFF)
Expand All @@ -15,6 +15,7 @@ else()
endif()

if (HAIKU)
enable_language(CXX)
set(LINKER_LANGUAGE CXX)
endif()

Expand Down Expand Up @@ -1107,6 +1108,8 @@ if(SDL_LIBC)
check_symbol_exists(getauxval "sys/auxv.h" HAVE_GETAUXVAL)
check_symbol_exists(elf_aux_info "sys/auxv.h" HAVE_ELF_AUX_INFO)
check_symbol_exists(poll "poll.h" HAVE_POLL)
check_symbol_exists(memfd_create "sys/mman.h" HAVE_MEMFD_CREATE)
check_symbol_exists(posix_fallocate "fcntl.h" HAVE_POSIX_FALLOCATE)

check_library_exists(m pow "" HAVE_LIBM)
if(HAVE_LIBM)
Expand Down Expand Up @@ -1787,6 +1790,7 @@ elseif(WINDOWS)
list(APPEND SOURCE_FILES ${CORE_SOURCES})

if(WINDOWS_STORE)
enable_language(CXX)
file(GLOB WINRT_SOURCE_FILES ${SDL2_SOURCE_DIR}/src/core/winrt/*.c ${SDL2_SOURCE_DIR}/src/core/winrt/*.cpp)
list(APPEND SOURCE_FILES ${WINRT_SOURCE_FILES})
endif()
Expand Down
3 changes: 2 additions & 1 deletion build-scripts/androidbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ do
cd $folder
done

ACTIVITY="${folder}Activity"
# Uppercase the first char in the activity class name because it's Java
ACTIVITY="$(echo $folder | awk '{$1=toupper(substr($1,0,1))substr($1,2)}1')Activity"
sed -i -e "s|\"SDLActivity\"|\"$ACTIVITY\"|g" $BUILDPATH/app/src/main/AndroidManifest.xml

# Fill in a default Activity
Expand Down
1 change: 1 addition & 0 deletions cmake/sdlchecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,7 @@ macro(CheckHIDAPI)

if(HAVE_HIDAPI)
if(ANDROID)
enable_language(CXX)
list(APPEND SOURCE_FILES ${SDL2_SOURCE_DIR}/src/hidapi/android/hid.cpp)
endif()
if(IOS OR TVOS)
Expand Down
12 changes: 12 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -19749,6 +19749,18 @@ if test "x$ac_cv_func_poll" = xyes
then :
printf "%s\n" "#define HAVE_POLL 1" >>confdefs.h

fi
ac_fn_c_check_func "$LINENO" "memfd_create" "ac_cv_func_memfd_create"
if test "x$ac_cv_func_memfd_create" = xyes
then :
printf "%s\n" "#define HAVE_MEMFD_CREATE 1" >>confdefs.h

fi
ac_fn_c_check_func "$LINENO" "posix_fallocate" "ac_cv_func_posix_fallocate"
if test "x$ac_cv_func_posix_fallocate" = xyes
then :
printf "%s\n" "#define HAVE_POSIX_FALLOCATE 1" >>confdefs.h

fi
ac_fn_c_check_func "$LINENO" "_Exit" "ac_cv_func__Exit"
if test "x$ac_cv_func__Exit" = xyes
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ dnl Checks for library functions.
AC_DEFINE(HAVE_MPROTECT, 1, [ ])
],[]),
)
AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv bsearch qsort abs bcopy memset memcmp memcpy memmove wcslen wcslcpy wcslcat _wcsdup wcsdup wcsstr wcscmp wcsncmp wcscasecmp _wcsicmp wcsncasecmp _wcsnicmp strlen strlcpy strlcat _strrev _strupr _strlwr index rindex strchr strrchr strstr strtok_r itoa _ltoa _uitoa _ultoa strtod strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp strcasestr vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval elf_aux_info poll _Exit)
AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv bsearch qsort abs bcopy memset memcmp memcpy memmove wcslen wcslcpy wcslcat _wcsdup wcsdup wcsstr wcscmp wcsncmp wcscasecmp _wcsicmp wcsncasecmp _wcsnicmp strlen strlcpy strlcat _strrev _strupr _strlwr index rindex strchr strrchr strstr strtok_r itoa _ltoa _uitoa _ultoa strtod strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp strcasestr vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval elf_aux_info poll memfd_create posix_fallocate _Exit)

AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"])
AC_CHECK_FUNCS(acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf copysign copysignf cos cosf exp expf fabs fabsf floor floorf trunc truncf fmod fmodf log logf log10 log10f lround lroundf pow powf round roundf scalbn scalbnf sin sinf sqrt sqrtf tan tanf)
Expand Down
2 changes: 2 additions & 0 deletions include/SDL_config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@
#cmakedefine HAVE_FOPEN64 1
#cmakedefine HAVE_FSEEKO 1
#cmakedefine HAVE_FSEEKO64 1
#cmakedefine HAVE_MEMFD_CREATE 1
#cmakedefine HAVE_POSIX_FALLOCATE 1
#cmakedefine HAVE_SIGACTION 1
#cmakedefine HAVE_SA_SIGACTION 1
#cmakedefine HAVE_SETJMP 1
Expand Down
2 changes: 2 additions & 0 deletions include/SDL_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@
#undef HAVE_GETAUXVAL
#undef HAVE_ELF_AUX_INFO
#undef HAVE_POLL
#undef HAVE_MEMFD_CREATE
#undef HAVE_POSIX_FALLOCATE
#undef HAVE__EXIT

#else
Expand Down
80 changes: 80 additions & 0 deletions src/SDL_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,86 @@
#define SDL_HAVE_YUV !SDL_LEAN_AND_MEAN
#endif

#ifndef SDL_RENDER_DISABLED
/* define the not defined ones as 0 */
#ifndef SDL_VIDEO_RENDER_D3D
#define SDL_VIDEO_RENDER_D3D 0
#endif
#ifndef SDL_VIDEO_RENDER_D3D11
#define SDL_VIDEO_RENDER_D3D11 0
#endif
#ifndef SDL_VIDEO_RENDER_D3D12
#define SDL_VIDEO_RENDER_D3D12 0
#endif
#ifndef SDL_VIDEO_RENDER_METAL
#define SDL_VIDEO_RENDER_METAL 0
#endif
#ifndef SDL_VIDEO_RENDER_OGL
#define SDL_VIDEO_RENDER_OGL 0
#endif
#ifndef SDL_VIDEO_RENDER_OGL_ES
#define SDL_VIDEO_RENDER_OGL_ES 0
#endif
#ifndef SDL_VIDEO_RENDER_OGL_ES2
#define SDL_VIDEO_RENDER_OGL_ES2 0
#endif
#ifndef SDL_VIDEO_RENDER_DIRECTFB
#define SDL_VIDEO_RENDER_DIRECTFB 0
#endif
#ifndef SDL_VIDEO_RENDER_PS2
#define SDL_VIDEO_RENDER_PS2 0
#endif
#ifndef SDL_VIDEO_RENDER_PSP
#define SDL_VIDEO_RENDER_PSP 0
#endif
#ifndef SDL_VIDEO_RENDER_VITA_GXM
#define SDL_VIDEO_RENDER_VITA_GXM 0
#endif
#else /* define all as 0 */
#undef SDL_VIDEO_RENDER_SW
#define SDL_VIDEO_RENDER_SW 0
#undef SDL_VIDEO_RENDER_D3D
#define SDL_VIDEO_RENDER_D3D 0
#undef SDL_VIDEO_RENDER_D3D11
#define SDL_VIDEO_RENDER_D3D11 0
#undef SDL_VIDEO_RENDER_D3D12
#define SDL_VIDEO_RENDER_D3D12 0
#undef SDL_VIDEO_RENDER_METAL
#define SDL_VIDEO_RENDER_METAL 0
#undef SDL_VIDEO_RENDER_OGL
#define SDL_VIDEO_RENDER_OGL 0
#undef SDL_VIDEO_RENDER_OGL_ES
#define SDL_VIDEO_RENDER_OGL_ES 0
#undef SDL_VIDEO_RENDER_OGL_ES2
#define SDL_VIDEO_RENDER_OGL_ES2 0
#undef SDL_VIDEO_RENDER_DIRECTFB
#define SDL_VIDEO_RENDER_DIRECTFB 0
#undef SDL_VIDEO_RENDER_PS2
#define SDL_VIDEO_RENDER_PS2 0
#undef SDL_VIDEO_RENDER_PSP
#define SDL_VIDEO_RENDER_PSP 0
#undef SDL_VIDEO_RENDER_VITA_GXM
#define SDL_VIDEO_RENDER_VITA_GXM 0
#endif /* SDL_RENDER_DISABLED */

#define SDL_HAS_RENDER_DRIVER \
(SDL_VIDEO_RENDER_SW | \
SDL_VIDEO_RENDER_D3D | \
SDL_VIDEO_RENDER_D3D11 | \
SDL_VIDEO_RENDER_D3D12 | \
SDL_VIDEO_RENDER_METAL | \
SDL_VIDEO_RENDER_OGL | \
SDL_VIDEO_RENDER_OGL_ES | \
SDL_VIDEO_RENDER_OGL_ES2 | \
SDL_VIDEO_RENDER_DIRECTFB | \
SDL_VIDEO_RENDER_PS2 | \
SDL_VIDEO_RENDER_PSP | \
SDL_VIDEO_RENDER_VITA_GXM)

#if !defined(SDL_RENDER_DISABLED) && !SDL_HAS_RENDER_DRIVER
#error SDL_RENDER enabled without any backend drivers.
#endif

#include "SDL_assert.h"
#include "SDL_log.h"

Expand Down
4 changes: 2 additions & 2 deletions src/audio/SDL_audiotypecvt.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static void SDLCALL SDL_Convert_U8_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFor

static void SDLCALL SDL_Convert_S16_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format)
{
const int num_samples = cvt->len_cvt;
const int num_samples = cvt->len_cvt / sizeof(Sint16);
const Sint16 *src = (const Sint16 *)cvt->buf;
float *dst = (float *)cvt->buf;
int i;
Expand Down Expand Up @@ -350,7 +350,7 @@ static void SDLCALL SDL_Convert_S8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioForma
i -= 16;

{
const __m128i bytes = _mm_xor_si128(_mm_loadu_si128((const __m128i *)&src[i-16]), flipper);
const __m128i bytes = _mm_xor_si128(_mm_loadu_si128((const __m128i *)&src[i]), flipper);

const __m128i shorts1 = _mm_unpacklo_epi8(bytes, zero);
const __m128i shorts2 = _mm_unpackhi_epi8(bytes, zero);
Expand Down
12 changes: 1 addition & 11 deletions src/core/windows/SDL_windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#endif
#undef WINVER
#undef _WIN32_WINNT
#if defined(SDL_VIDEO_RENDER_D3D12)
#if SDL_VIDEO_RENDER_D3D12
#define _WIN32_WINNT 0xA00 /* For D3D12, 0xA00 is required */
#elif defined(HAVE_SHELLSCALINGAPI_H)
#define _WIN32_WINNT 0x603 /* For DPI support */
Expand Down Expand Up @@ -92,16 +92,6 @@
#include <windows.h>
#include <basetyps.h> /* for REFIID with broken mingw.org headers */

/* Older Visual C++ headers don't have the Win64-compatible typedefs... */
#if defined(_MSC_VER) && (_MSC_VER <= 1200)
#ifndef DWORD_PTR
#define DWORD_PTR DWORD
#endif
#ifndef LONG_PTR
#define LONG_PTR LONG
#endif
#endif

#include "SDL_rect.h"

/* Routines to convert from UTF8 to native Windows text */
Expand Down
6 changes: 3 additions & 3 deletions src/core/windows/SDL_xinput.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,15 @@ typedef struct
#endif /* HAVE_XINPUT_H */

/* This struct is not defined in XInput headers. */
typedef struct _XINPUT_CAPABILITIES_EX
typedef struct
{
XINPUT_CAPABILITIES Capabilities;
WORD VendorId;
WORD ProductId;
WORD ProductVersion;
WORD unk1;
DWORD unk2;
} XINPUT_CAPABILITIES_EX, *PXINPUT_CAPABILITIES_EX;
} SDL_XINPUT_CAPABILITIES_EX;

/* Forward decl's for XInput API's we load dynamically and use if available */
typedef DWORD(WINAPI *XInputGetState_t)(
Expand All @@ -244,7 +244,7 @@ typedef DWORD(WINAPI *XInputGetCapabilitiesEx_t)(
DWORD dwReserved, /* [in] Must be 1 */
DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */
DWORD dwFlags, /* [in] Input flags that identify the device type */
XINPUT_CAPABILITIES_EX *pCapabilitiesEx /* [out] Receives the capabilities */
SDL_XINPUT_CAPABILITIES_EX *pCapabilitiesEx /* [out] Receives the capabilities */
);

typedef DWORD(WINAPI *XInputGetBatteryInformation_t)(
Expand Down
4 changes: 2 additions & 2 deletions src/core/winrt/SDL_winrtapp_direct3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ extern "C" {
#include "SDL_winrtapp_common.h"
#include "SDL_winrtapp_direct3d.h"

#if defined(SDL_VIDEO_RENDER_D3D11) && !defined(SDL_RENDER_DISABLED)
#if SDL_VIDEO_RENDER_D3D11
/* Calling IDXGIDevice3::Trim on the active Direct3D 11.x device is necessary
* when Windows 8.1 apps are about to get suspended.
*/
Expand Down Expand Up @@ -622,7 +622,7 @@ void SDL_WinRTApp::OnSuspending(Platform::Object ^ sender, SuspendingEventArgs ^
// Let the Direct3D 11 renderer prepare for the app to be backgrounded.
// This is necessary for Windows 8.1, possibly elsewhere in the future.
// More details at: http://msdn.microsoft.com/en-us/library/windows/apps/Hh994929.aspx
#if defined(SDL_VIDEO_RENDER_D3D11) && !defined(SDL_RENDER_DISABLED)
#if SDL_VIDEO_RENDER_D3D11
if (WINRT_GlobalSDLWindow) {
SDL_Renderer *renderer = SDL_GetRenderer(WINRT_GlobalSDLWindow);
if (renderer && (SDL_strcmp(renderer->info.name, "direct3d11") == 0)) {
Expand Down
Loading

0 comments on commit 44e1650

Please sign in to comment.