Skip to content

Commit

Permalink
Merge branch 'SDL2' of https://github.com/libsdl-org/SDL into libsdl-…
Browse files Browse the repository at this point in the history
…org-SDL2
  • Loading branch information
capehill committed Nov 15, 2023
2 parents 05dcac2 + cc7c0a2 commit 6495038
Show file tree
Hide file tree
Showing 422 changed files with 3,468 additions and 2,804 deletions.
48 changes: 30 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,6 @@ if(SDL_LIBC)
string(REGEX REPLACE "[./]" "_" _HAVE_H ${_UPPER})
check_include_file("${_HEADER}" ${_HAVE_H})
endforeach()
check_include_file(linux/input.h HAVE_LINUX_INPUT_H)

set(STDC_HEADER_NAMES "stddef.h;stdarg.h;stdlib.h;string.h;stdio.h;wchar.h;float.h")
check_include_files("${STDC_HEADER_NAMES}" STDC_HEADERS)
Expand Down Expand Up @@ -1507,7 +1506,7 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU)
#ifndef EVIOCGNAME
#error EVIOCGNAME() ioctl not available
#endif
int main(int argc, char** argv) { return 0; }" HAVE_INPUT_EVENTS)
int main(int argc, char** argv) { return 0; }" HAVE_LINUX_INPUT_H)

if(LINUX)
check_c_source_compiles("
Expand Down Expand Up @@ -1543,11 +1542,11 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU)
}" HAVE_INPUT_WSCONS)
endif()

if(HAVE_INPUT_EVENTS)
if(HAVE_LINUX_INPUT_H)
set(SDL_INPUT_LINUXEV 1)
endif()

if(SDL_HAPTIC AND HAVE_INPUT_EVENTS)
if(SDL_HAPTIC AND HAVE_LINUX_INPUT_H)
set(SDL_HAPTIC_LINUX 1)
file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/linux/*.c)
list(APPEND SOURCE_FILES ${HAPTIC_SOURCES})
Expand Down Expand Up @@ -1633,7 +1632,7 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU)
list(APPEND SOURCE_FILES "${SDL2_SOURCE_DIR}/src/core/linux/SDL_udev.c")
endif()

if(HAVE_INPUT_EVENTS)
if(HAVE_LINUX_INPUT_H)
list(APPEND SOURCE_FILES "${SDL2_SOURCE_DIR}/src/core/linux/SDL_evdev.c")
list(APPEND SOURCE_FILES "${SDL2_SOURCE_DIR}/src/core/linux/SDL_evdev_kbd.c")
endif()
Expand Down Expand Up @@ -1825,16 +1824,6 @@ elseif(WINDOWS)
#include <windows.h>
#include <xinput.h>
int main(int argc, char **argv) { return 0; }" HAVE_XINPUT_H)
check_c_source_compiles("
#include <windows.h>
#include <xinput.h>
XINPUT_GAMEPAD_EX x1;
int main(int argc, char **argv) { return 0; }" HAVE_XINPUT_GAMEPAD_EX)
check_c_source_compiles("
#include <windows.h>
#include <xinput.h>
XINPUT_STATE_EX s1;
int main(int argc, char **argv) { return 0; }" HAVE_XINPUT_STATE_EX)
check_c_source_compiles("
#define COBJMACROS
#include <windows.gaming.input.h>
Expand Down Expand Up @@ -3108,9 +3097,17 @@ else()
set(sdl_static_libname "SDL2")
endif()

set(prefix ${CMAKE_INSTALL_PREFIX})
# CMAKE_PREFIX_PATH and CMAKE_INSTALL_FULL_BINDIR can be a non-absolute path
# when a master-project does e.g. `set(CMAKE_INSTALL_PREFIX "libs/SDL2" CACHE PATH "prefix" FORCE)`.
if(NOT IS_ABSOLUTE "${CMAKE_INSTALL_PREFIX}")
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_PREFIX}")
endif()
if(NOT IS_ABSOLUTE "${CMAKE_INSTALL_FULL_BINDIR}")
set(CMAKE_INSTALL_FULL_BINDIR "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_FULL_BINDIR}")
endif()
file(RELATIVE_PATH bin_prefix_relpath "${CMAKE_INSTALL_FULL_BINDIR}" "${CMAKE_INSTALL_PREFIX}")

set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix "\${prefix}")
set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
set(bindir "\${exec_prefix}/${CMAKE_INSTALL_BINDIR}")
Expand Down Expand Up @@ -3354,6 +3351,12 @@ if(ANDROID)
endif()

if(APPLE)
cmake_push_check_state(RESET)
check_c_compiler_flag(-fobjc-arc COMPILER_SUPPORTS_FOBJC_ARC)
cmake_pop_check_state()
if(NOT COMPILER_SUPPORTS_FOBJC_ARC)
message(FATAL_ERROR "Compiler does not support -fobjc-arc: this is required on Apple platforms")
endif()
target_compile_options(sdl-build-options INTERFACE "-fobjc-arc")
endif()

Expand Down Expand Up @@ -3507,8 +3510,8 @@ if(NOT SDL2_DISABLE_INSTALL)
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
if(MSVC AND NOT CMAKE_VERSION VERSION_LESS "3.1")
install(FILES $<TARGET_PDB_FILE:SDL2> DESTINATION "${CMAKE_INSTALL_BINDIR}" OPTIONAL)
if(MSVC)
SDL_install_pdb(SDL2 "${CMAKE_INSTALL_BINDIR}")
endif()
endif()

Expand All @@ -3517,20 +3520,29 @@ if(NOT SDL2_DISABLE_INSTALL)
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
if(MSVC)
SDL_install_pdb(SDL2main "${CMAKE_INSTALL_LIBDIR}")
endif()
endif()

if(SDL_STATIC)
install(TARGETS SDL2-static EXPORT SDL2staticTargets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
if(MSVC)
SDL_install_pdb(SDL2-static "${CMAKE_INSTALL_LIBDIR}")
endif()
endif()

if(SDL_TEST)
install(TARGETS SDL2_test EXPORT SDL2testTargets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
if(MSVC)
SDL_install_pdb(SDL2_test "${CMAKE_INSTALL_LIBDIR}")
endif()
endif()

##### Export files #####
Expand Down
6 changes: 3 additions & 3 deletions VisualC-GDK/tests/testgdk/src/testgdk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ main(int argc, char *argv[])

/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO | SDL_INIT_AUDIO);
if (state == NULL) {
if (!state) {
return 1;
}

Expand Down Expand Up @@ -446,7 +446,7 @@ main(int argc, char *argv[])
/* Create the windows, initialize the renderers, and load the textures */
sprites =
(SDL_Texture **) SDL_malloc(state->num_windows * sizeof(*sprites));
if (sprites == NULL) {
if (!sprites) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
quit(2);
}
Expand All @@ -461,7 +461,7 @@ main(int argc, char *argv[])

soundname = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav");

if (soundname == NULL) {
if (!soundname) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
quit(1);
}
Expand Down
3 changes: 2 additions & 1 deletion VisualC/tests/testautomation/testautomation.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,12 @@
<ClCompile Include="..\..\..\test\testautomation_syswm.c" />
<ClCompile Include="..\..\..\test\testautomation_timer.c" />
<ClCompile Include="..\..\..\test\testautomation_video.c" />
<ClCompile Include="..\..\..\test\testautomation_subsystems.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\test\testautomation_suites.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
9 changes: 9 additions & 0 deletions WhatsNew.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@

This is a list of major changes in SDL's version history.

---------------------------------------------------------------------------
2.30.0:
---------------------------------------------------------------------------

Xbox:
* Added the function SDL_GDKGetDefaultUser()


---------------------------------------------------------------------------
2.28.2:
---------------------------------------------------------------------------

General:
* Added the hint SDL_HINT_JOYSTICK_WGI to control whether to use Windows.Gaming.Input for controllers

Expand Down
10 changes: 5 additions & 5 deletions Xcode-iOS/Demos/src/accelerometer.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ initializeTextures(SDL_Renderer *renderer)

/* load the ship */
bmp_surface = SDL_LoadBMP("ship.bmp");
if (bmp_surface == NULL) {
if (!bmp_surface) {
fatalError("could not ship.bmp");
}
/* set blue to transparent on the ship */
Expand All @@ -127,7 +127,7 @@ initializeTextures(SDL_Renderer *renderer)

/* create ship texture from surface */
ship = SDL_CreateTextureFromSurface(renderer, bmp_surface);
if (ship == NULL) {
if (!ship) {
fatalError("could not create ship texture");
}
SDL_SetTextureBlendMode(ship, SDL_BLENDMODE_BLEND);
Expand All @@ -140,12 +140,12 @@ initializeTextures(SDL_Renderer *renderer)

/* load the space background */
bmp_surface = SDL_LoadBMP("space.bmp");
if (bmp_surface == NULL) {
if (!bmp_surface) {
fatalError("could not load space.bmp");
}
/* create space texture from surface */
space = SDL_CreateTextureFromSurface(renderer, bmp_surface);
if (space == NULL) {
if (!space) {
fatalError("could not create space texture");
}
SDL_FreeSurface(bmp_surface);
Expand Down Expand Up @@ -179,7 +179,7 @@ main(int argc, char *argv[])
printf("There are %d joysticks available\n", SDL_NumJoysticks());
printf("Default joystick (index 0) is %s\n", SDL_JoystickName(0));
accelerometer = SDL_JoystickOpen(0);
if (accelerometer == NULL) {
if (!accelerometer) {
fatalError("Could not open joystick (accelerometer)");
}
printf("joystick number of axis = %d\n",
Expand Down
2 changes: 1 addition & 1 deletion Xcode-iOS/Demos/src/fireworks.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ initializeTexture()
to format passed into OpenGL */

bmp_surface = SDL_LoadBMP("stroke.bmp");
if (bmp_surface == NULL) {
if (!bmp_surface) {
fatalError("could not load stroke.bmp");
}

Expand Down
4 changes: 2 additions & 2 deletions Xcode-iOS/Demos/src/happy.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ initializeTexture(SDL_Renderer *renderer)
SDL_Surface *bmp_surface;
/* load the bmp */
bmp_surface = SDL_LoadBMP("icon.bmp");
if (bmp_surface == NULL) {
if (!bmp_surface) {
fatalError("could not load bmp");
}
/* set white to transparent on the happyface */
Expand All @@ -117,7 +117,7 @@ initializeTexture(SDL_Renderer *renderer)

/* convert RGBA surface to texture */
texture = SDL_CreateTextureFromSurface(renderer, bmp_surface);
if (texture == NULL) {
if (!texture) {
fatalError("could not create texture");
}
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
Expand Down
4 changes: 2 additions & 2 deletions Xcode-iOS/Demos/src/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ loadFont(void)
{
SDL_Surface *surface = SDL_LoadBMP("kromasky_16x16.bmp");

if (surface == NULL) {
if (!surface) {
printf("Error loading bitmap: %s\n", SDL_GetError());
return 0;
} else {
Expand All @@ -183,7 +183,7 @@ loadFont(void)
SDL_BlitSurface(surface, NULL, converted, NULL);
/* create our texture */
texture = SDL_CreateTextureFromSurface(renderer, converted);
if (texture == NULL) {
if (!texture) {
printf("texture creation failed: %s\n", SDL_GetError());
} else {
/* set blend mode for our texture */
Expand Down
4 changes: 2 additions & 2 deletions Xcode-iOS/Demos/src/rectangles.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ main(int argc, char *argv[])

/* create window and renderer */
window = SDL_CreateWindow(NULL, 0, 0, 320, 480, SDL_WINDOW_ALLOW_HIGHDPI);
if (window == NULL) {
if (!window) {
fatalError("Could not initialize Window");
}
renderer = SDL_CreateRenderer(window, -1, 0);
if (renderer == NULL) {
if (!renderer) {
fatalError("Could not create renderer");
}

Expand Down
4 changes: 2 additions & 2 deletions Xcode-iOS/Demos/src/touch.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ initializeTexture(SDL_Renderer *renderer)
{
SDL_Surface *bmp_surface;
bmp_surface = SDL_LoadBMP("stroke.bmp");
if (bmp_surface == NULL) {
if (!bmp_surface) {
fatalError("could not load stroke.bmp");
}
brush =
SDL_CreateTextureFromSurface(renderer, bmp_surface);
SDL_FreeSurface(bmp_surface);
if (brush == NULL) {
if (!brush) {
fatalError("could not create brush texture");
}
/* additive blending -- laying strokes on top of eachother makes them brighter */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ private boolean isXboxOneController(UsbDevice usbDevice, UsbInterface usbInterfa
0x24c6, // PowerA
0x2dc8, // 8BitDo
0x2e24, // Hyperkin
0x3537, // GameSir
};

if (usbInterface.getId() == 0 &&
Expand Down
20 changes: 20 additions & 0 deletions cmake/macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,23 @@ if(CMAKE_VERSION VERSION_LESS 3.13.0)
link_directories(${ARGN})
endmacro()
endif()

# CMP0087: install(CODE) and install(SCRIPT) support generator expressions.
cmake_policy(SET CMP0087 NEW)
function(SDL_install_pdb TARGET DIRECTORY)
get_property(type TARGET ${TARGET} PROPERTY TYPE)
if(type MATCHES "^(SHARED_LIBRARY|EXECUTABLE)$")
if(NOT CMAKE_VERSION VERSION_LESS 3.1)
install(FILES $<TARGET_PDB_FILE:${TARGET}> DESTINATION "${DIRECTORY}" OPTIONAL)
endif()
elseif(type STREQUAL "STATIC_LIBRARY")
if(NOT CMAKE_VERSION VERSION_LESS 3.15)
# FIXME: Use $<TARGET_COMPILE_PDB_FILE:${TARGET} once it becomes available (https://gitlab.kitware.com/cmake/cmake/-/issues/25244)
if(CMAKE_GENERATOR MATCHES "^Visual Studio.*")
install(CODE "file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${DIRECTORY}\" TYPE FILE OPTIONAL FILES \"${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}/${TARGET}.pdb\")")
else()
install(CODE "file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${DIRECTORY}\" TYPE FILE OPTIONAL FILES \"${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TARGET}.dir/${TARGET}.pdb\")")
endif()
endif()
endif()
endfunction()
4 changes: 3 additions & 1 deletion cmake/sdlchecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,9 @@ macro(CheckX11)
list(APPEND SOURCE_FILES ${X11_SOURCES})
set(SDL_VIDEO_DRIVER_X11 1)

# !!! FIXME: why is this disabled for Apple?
# Note: Disabled on Apple because the dynamic mode backend for X11 doesn't
# work properly on Apple during several issues like inconsistent paths
# among platforms. See #6778 (https://github.com/libsdl-org/SDL/issues/6778)
if(APPLE)
set(SDL_X11_SHARED OFF)
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/test/main_gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int main(int argc, char *argv[]) {
640, 480,
SDL_WINDOW_SHOWN
);
if (window == NULL) {
if (!window) {
fprintf(stderr, "could not create window: %s\n", SDL_GetError());
return 1;
}
Expand Down
Loading

0 comments on commit 6495038

Please sign in to comment.