mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-09-20 17:46:09 +08:00
resync'd overscan patch with SDL mainline.
This commit is contained in:
@@ -8,6 +8,9 @@ Makefile
|
||||
sdl-config
|
||||
SDL2.spec
|
||||
build
|
||||
Build
|
||||
*xcuserdata*
|
||||
*xcworkspacedata*
|
||||
|
||||
# for Xcode
|
||||
*.orig
|
||||
@@ -72,20 +75,26 @@ test/config.status
|
||||
test/Makefile
|
||||
test/SDL2.dll
|
||||
test/checkkeys
|
||||
test/controllermap
|
||||
test/loopwave
|
||||
test/loopwavequeue
|
||||
test/testatomic
|
||||
test/testaudiohotplug
|
||||
test/testaudioinfo
|
||||
test/testautomation
|
||||
test/testdraw2
|
||||
test/testdrawchessboard
|
||||
test/testdropfile
|
||||
test/testerror
|
||||
test/testfile
|
||||
test/testgamecontroller
|
||||
test/testgesture
|
||||
test/testgl2
|
||||
test/testgles
|
||||
test/testgles2
|
||||
test/testhaptic
|
||||
test/testhittesting
|
||||
test/testhotplug
|
||||
test/testiconv
|
||||
test/testime
|
||||
test/testintersections
|
||||
@@ -115,6 +124,7 @@ test/teststreaming
|
||||
test/testthread
|
||||
test/testtimer
|
||||
test/testver
|
||||
test/testviewport
|
||||
test/testwm2
|
||||
test/torturethread
|
||||
test/*.exe
|
||||
|
||||
+114
-33
@@ -2,7 +2,7 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
||||
message(FATAL_ERROR "Prevented in-tree built. Please create a build directory outside of the SDL source code and call cmake from there")
|
||||
endif()
|
||||
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
project(SDL2 C)
|
||||
include(CheckFunctionExists)
|
||||
include(CheckLibraryExists)
|
||||
@@ -117,6 +117,12 @@ else()
|
||||
set(UNIX_OR_MAC_SYS OFF)
|
||||
endif()
|
||||
|
||||
if (UNIX_OR_MAC_SYS AND NOT EMSCRIPTEN) # JavaScript does not yet have threading support, so disable pthreads when building for Emscripten.
|
||||
set(SDL_PTHREADS_ENABLED_BY_DEFAULT ON)
|
||||
else()
|
||||
set(SDL_PTHREADS_ENABLED_BY_DEFAULT OFF)
|
||||
endif()
|
||||
|
||||
# Default option knobs
|
||||
if(APPLE OR ARCH_64)
|
||||
set(OPT_DEF_SSEMATH ON)
|
||||
@@ -144,7 +150,7 @@ if("$ENV{CFLAGS}" STREQUAL "")
|
||||
if(USE_GCC OR USE_CLANG)
|
||||
set(CMAKE_C_FLAGS "-g -O3")
|
||||
endif()
|
||||
else("$ENV{CFLAGS}" STREQUAL "")
|
||||
else()
|
||||
set(CMAKE_C_FLAGS "$ENV{CFLAGS}")
|
||||
list(APPEND EXTRA_CFLAGS "$ENV{CFLAGS}")
|
||||
endif()
|
||||
@@ -161,7 +167,7 @@ if(MSVC)
|
||||
if(${flag_var} MATCHES "/MD")
|
||||
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
||||
endif()
|
||||
endforeach(flag_var)
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -170,13 +176,19 @@ endif()
|
||||
set(SDL_LIBS "-lSDL2")
|
||||
set(SDL_CFLAGS "")
|
||||
|
||||
# Emscripten toolchain has a nonempty default value for this, and the checks
|
||||
# in this file need to change that, so remember the original value, and
|
||||
# restore back to that afterwards. For check_function_exists() to work in
|
||||
# Emscripten, this value must be at its default value.
|
||||
set(ORIG_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
||||
|
||||
if(CYGWIN)
|
||||
# We build SDL on cygwin without the UNIX emulation layer
|
||||
include_directories("-I/usr/include/mingw")
|
||||
set(CMAKE_REQUIRED_FLAGS "-mno-cygwin")
|
||||
check_c_source_compiles("int main(int argc, char **argv) {}"
|
||||
HAVE_GCC_NO_CYGWIN)
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
|
||||
if(HAVE_GCC_NO_CYGWIN)
|
||||
list(APPEND EXTRA_LDFLAGS "-mno-cygwin")
|
||||
list(APPEND SDL_LIBS "-mno-cygwin")
|
||||
@@ -188,12 +200,31 @@ add_definitions(-DUSING_GENERATED_CONFIG_H)
|
||||
# General includes
|
||||
include_directories(${SDL2_BINARY_DIR}/include ${SDL2_SOURCE_DIR}/include)
|
||||
|
||||
# All these ENABLED_BY_DEFAULT vars will default to ON if not specified, so
|
||||
# you only need to have a platform override them if they are disabling.
|
||||
set(OPT_DEF_ASM TRUE)
|
||||
if(EMSCRIPTEN)
|
||||
# Set up default values for the currently supported set of subsystems:
|
||||
# Emscripten/Javascript does not have assembly support, a dynamic library
|
||||
# loading architecture, low-level CPU inspection or multithreading.
|
||||
set(OPT_DEF_ASM FALSE)
|
||||
set(SDL_SHARED_ENABLED_BY_DEFAULT OFF)
|
||||
set(SDL_ATOMIC_ENABLED_BY_DEFAULT OFF)
|
||||
set(SDL_THREADS_ENABLED_BY_DEFAULT OFF)
|
||||
set(SDL_LOADSO_ENABLED_BY_DEFAULT OFF)
|
||||
set(SDL_CPUINFO_ENABLED_BY_DEFAULT OFF)
|
||||
set(SDL_DLOPEN_ENABLED_BY_DEFAULT OFF)
|
||||
endif()
|
||||
|
||||
set(SDL_SUBSYSTEMS
|
||||
Atomic Audio Video Render Events Joystick Haptic Power Threads Timers
|
||||
File Loadso CPUinfo Filesystem)
|
||||
File Loadso CPUinfo Filesystem Dlopen)
|
||||
foreach(_SUB ${SDL_SUBSYSTEMS})
|
||||
string(TOUPPER ${_SUB} _OPT)
|
||||
option(SDL_${_OPT} "Enable the ${_SUB} subsystem" ON)
|
||||
if (NOT DEFINED SDL_${_OPT}_ENABLED_BY_DEFAULT)
|
||||
set(SDL_${_OPT}_ENABLED_BY_DEFAULT ON)
|
||||
endif()
|
||||
option(SDL_${_OPT} "Enable the ${_SUB} subsystem" ${SDL_${_OPT}_ENABLED_BY_DEFAULT})
|
||||
endforeach()
|
||||
|
||||
option_string(ASSERTIONS "Enable internal sanity checks (auto/disabled/release/enabled/paranoid)" "auto")
|
||||
@@ -212,13 +243,13 @@ set_option(DUMMYAUDIO "Support the dummy audio driver" ON)
|
||||
set_option(VIDEO_DIRECTFB "Use DirectFB video driver" OFF)
|
||||
dep_option(DIRECTFB_SHARED "Dynamically load directfb support" ON "VIDEO_DIRECTFB" OFF)
|
||||
set_option(FUSIONSOUND "Use FusionSound audio driver" OFF)
|
||||
dep_option(FUSIONSOUND_SHARED "Dynamically load fusionsound audio support" ON "FUSIONSOUND_SHARED" OFF)
|
||||
dep_option(FUSIONSOUND_SHARED "Dynamically load fusionsound audio support" ON "FUSIONSOUND" OFF)
|
||||
set_option(VIDEO_DUMMY "Use dummy video driver" ON)
|
||||
set_option(VIDEO_OPENGL "Include OpenGL support" ON)
|
||||
set_option(VIDEO_OPENGLES "Include OpenGL ES support" ON)
|
||||
set_option(PTHREADS "Use POSIX threads for multi-threading" ${UNIX_OR_MAC_SYS})
|
||||
set_option(PTHREADS "Use POSIX threads for multi-threading" ${SDL_PTHREADS_ENABLED_BY_DEFAULT})
|
||||
dep_option(PTHREADS_SEM "Use pthread semaphores" ON "PTHREADS" OFF)
|
||||
set_option(SDL_DLOPEN "Use dlopen for shared object loading" ON)
|
||||
set_option(SDL_DLOPEN "Use dlopen for shared object loading" ${SDL_DLOPEN_ENABLED_BY_DEFAULT})
|
||||
set_option(OSS "Support the OSS audio API" ${UNIX_SYS})
|
||||
set_option(ALSA "Support the ALSA audio API" ${UNIX_SYS})
|
||||
dep_option(ALSA_SHARED "Dynamically load ALSA audio support" ON "ALSA" OFF)
|
||||
@@ -236,7 +267,10 @@ set_option(CLOCK_GETTIME "Use clock_gettime() instead of gettimeofday()" O
|
||||
set_option(INPUT_TSLIB "Use the Touchscreen library for input" ${UNIX_SYS})
|
||||
set_option(VIDEO_X11 "Use X11 video driver" ${UNIX_SYS})
|
||||
set_option(VIDEO_WAYLAND "Use Wayland video driver" ${UNIX_SYS})
|
||||
dep_option(WAYLAND_SHARED "Dynamically load Wayland support" ON "VIDEO_WAYLAND" OFF)
|
||||
dep_option(VIDEO_WAYLAND_QT_TOUCH "QtWayland server support for Wayland video driver" ON "VIDEO_WAYLAND" OFF)
|
||||
set_option(VIDEO_MIR "Use Mir video driver" ${UNIX_SYS})
|
||||
dep_option(MIR_SHARED "Dynamically load Mir support" ON "VIDEO_MIR" OFF)
|
||||
set_option(VIDEO_RPI "Use Raspberry Pi video driver" ${UNIX_SYS})
|
||||
dep_option(X11_SHARED "Dynamically load X11 support" ON "VIDEO_X11" OFF)
|
||||
set(SDL_X11_OPTIONS Xcursor Xinerama XInput Xrandr Xscrnsaver XShape Xvm)
|
||||
@@ -251,7 +285,7 @@ set_option(VIDEO_VIVANTE "Use Vivante EGL video driver" ${UNIX_SYS})
|
||||
|
||||
# TODO: We should (should we?) respect cmake's ${BUILD_SHARED_LIBS} flag here
|
||||
# The options below are for compatibility to configure's default behaviour.
|
||||
set(SDL_SHARED ON CACHE BOOL "Build a shared version of the library")
|
||||
set(SDL_SHARED ${SDL_SHARED_ENABLED_BY_DEFAULT} CACHE BOOL "Build a shared version of the library")
|
||||
set(SDL_STATIC ON CACHE BOOL "Build a static version of the library")
|
||||
|
||||
# General source files
|
||||
@@ -317,7 +351,7 @@ if(USE_GCC OR USE_CLANG)
|
||||
set(CMAKE_REQUIRED_FLAGS "-mpreferred-stack-boundary=2")
|
||||
check_c_source_compiles("int x = 0; int main(int argc, char **argv) {}"
|
||||
HAVE_GCC_PREFERRED_STACK_BOUNDARY)
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
|
||||
|
||||
set(CMAKE_REQUIRED_FLAGS "-fvisibility=hidden -Werror")
|
||||
check_c_source_compiles("
|
||||
@@ -328,7 +362,7 @@ if(USE_GCC OR USE_CLANG)
|
||||
if(HAVE_GCC_FVISIBILITY)
|
||||
list(APPEND EXTRA_CFLAGS "-fvisibility=hidden")
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
|
||||
|
||||
check_c_compiler_flag(-Wall HAVE_GCC_WALL)
|
||||
if(HAVE_GCC_WALL)
|
||||
@@ -376,7 +410,7 @@ if(ASSEMBLY)
|
||||
if(HAVE_MMX)
|
||||
list(APPEND EXTRA_CFLAGS "-mmmx")
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
|
||||
endif()
|
||||
|
||||
if(3DNOW)
|
||||
@@ -393,7 +427,7 @@ if(ASSEMBLY)
|
||||
if(HAVE_3DNOW)
|
||||
list(APPEND EXTRA_CFLAGS "-m3dnow")
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
|
||||
endif()
|
||||
|
||||
if(SSE)
|
||||
@@ -416,7 +450,7 @@ if(ASSEMBLY)
|
||||
if(HAVE_SSE)
|
||||
list(APPEND EXTRA_CFLAGS "-msse")
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
|
||||
endif()
|
||||
|
||||
if(SSE2)
|
||||
@@ -439,7 +473,7 @@ if(ASSEMBLY)
|
||||
if(HAVE_SSE2)
|
||||
list(APPEND EXTRA_CFLAGS "-msse2")
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
|
||||
endif()
|
||||
|
||||
if(SSEMATH)
|
||||
@@ -464,7 +498,7 @@ if(ASSEMBLY)
|
||||
return vec_splat_u32(0);
|
||||
}
|
||||
int main(int argc, char **argv) { }" HAVE_ALTIVEC)
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
|
||||
if(HAVE_ALTIVEC OR HAVE_ALTIVEC_H_HDR)
|
||||
set(HAVE_ALTIVEC TRUE) # if only HAVE_ALTIVEC_H_HDR is set
|
||||
list(APPEND EXTRA_CFLAGS "-maltivec")
|
||||
@@ -486,7 +520,7 @@ if(ASSEMBLY)
|
||||
set(SDL_ASSEMBLY_ROUTINES 1)
|
||||
endif()
|
||||
# TODO:
|
||||
#else(ASSEMBLY)
|
||||
#else()
|
||||
# if(USE_GCC OR USE_CLANG)
|
||||
# list(APPEND EXTRA_CFLAGS "-mno-sse" "-mno-sse2" "-mno-mmx")
|
||||
# endif()
|
||||
@@ -518,7 +552,7 @@ if(LIBC)
|
||||
set(HAVE_M_PI 1)
|
||||
add_definitions(-D_USE_MATH_DEFINES) # needed for M_PI
|
||||
set(STDC_HEADERS 1)
|
||||
else(WINDOWS AND NOT MINGW)
|
||||
else()
|
||||
set(HAVE_LIBC TRUE)
|
||||
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
|
||||
foreach(_HEADER
|
||||
@@ -555,7 +589,7 @@ if(LIBC)
|
||||
set(CMAKE_REQUIRED_LIBRARIES m)
|
||||
foreach(_FN
|
||||
atan atan2 ceil copysign cos cosf fabs floor log pow scalbn sin
|
||||
sinf sqrt sqrtf tan tanf)
|
||||
sinf sqrt sqrtf tan tanf acos asin)
|
||||
string(TOUPPER ${_FN} _UPPER)
|
||||
set(_HAVEVAR "HAVE_${_UPPER}")
|
||||
check_function_exists("${_FN}" ${_HAVEVAR})
|
||||
@@ -567,11 +601,20 @@ if(LIBC)
|
||||
check_library_exists(iconv iconv_open "" HAVE_LIBICONV)
|
||||
if(HAVE_LIBICONV)
|
||||
list(APPEND EXTRA_LIBS iconv)
|
||||
set(HAVE_ICONV 1)
|
||||
endif()
|
||||
|
||||
if(NOT APPLE)
|
||||
check_include_file(alloca.h HAVE_ALLOCA_H)
|
||||
check_function_exists(alloca HAVE_ALLOCA)
|
||||
else()
|
||||
set(HAVE_ALLOCA_H 1)
|
||||
set(HAVE_ALLOCA 1)
|
||||
endif()
|
||||
|
||||
check_struct_has_member("struct sigaction" "sa_sigaction" "signal.h" HAVE_SA_SIGACTION)
|
||||
endif()
|
||||
else(LIBC)
|
||||
else()
|
||||
if(WINDOWS)
|
||||
set(HAVE_STDARG_H 1)
|
||||
set(HAVE_STDDEF_H 1)
|
||||
@@ -642,7 +685,49 @@ if(SDL_VIDEO)
|
||||
endif()
|
||||
|
||||
# Platform-specific options and settings
|
||||
if(UNIX AND NOT APPLE)
|
||||
if(EMSCRIPTEN)
|
||||
# Hide noisy warnings that intend to aid mostly during initial stages of porting a new
|
||||
# project. Uncomment at will for verbose cross-compiling -I/../ path info.
|
||||
add_definitions(-Wno-warn-absolute-paths)
|
||||
if(SDL_AUDIO)
|
||||
set(SDL_AUDIO_DRIVER_EMSCRIPTEN 1)
|
||||
file(GLOB EM_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/emscripten/*.c)
|
||||
set(SOURCE_FILES ${SOURCE_FILES} ${EM_AUDIO_SOURCES})
|
||||
set(HAVE_SDL_AUDIO TRUE)
|
||||
endif()
|
||||
if(SDL_FILESYSTEM)
|
||||
set(SDL_FILESYSTEM_EMSCRIPTEN 1)
|
||||
file(GLOB EM_FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/emscripten/*.c)
|
||||
set(SOURCE_FILES ${SOURCE_FILES} ${EM_FILESYSTEM_SOURCES})
|
||||
set(HAVE_SDL_FILESYSTEM TRUE)
|
||||
endif()
|
||||
if(SDL_JOYSTICK)
|
||||
set(SDL_JOYSTICK_EMSCRIPTEN 1)
|
||||
file(GLOB EM_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/emscripten/*.c)
|
||||
set(SOURCE_FILES ${SOURCE_FILES} ${EM_JOYSTICK_SOURCES})
|
||||
set(HAVE_SDL_JOYSTICK TRUE)
|
||||
endif()
|
||||
if(SDL_POWER)
|
||||
set(SDL_POWER_EMSCRIPTEN 1)
|
||||
file(GLOB EM_POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/emscripten/*.c)
|
||||
set(SOURCE_FILES ${SOURCE_FILES} ${EM_POWER_SOURCES})
|
||||
set(HAVE_SDL_POWER TRUE)
|
||||
endif()
|
||||
if(SDL_VIDEO)
|
||||
set(SDL_VIDEO_DRIVER_EMSCRIPTEN 1)
|
||||
file(GLOB EM_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/emscripten/*.c)
|
||||
set(SOURCE_FILES ${SOURCE_FILES} ${EM_VIDEO_SOURCES})
|
||||
set(HAVE_SDL_VIDEO TRUE)
|
||||
|
||||
#enable gles
|
||||
if(VIDEO_OPENGLES)
|
||||
set(SDL_VIDEO_OPENGL_EGL 1)
|
||||
set(HAVE_VIDEO_OPENGLES TRUE)
|
||||
set(SDL_VIDEO_OPENGL_ES2 1)
|
||||
set(SDL_VIDEO_RENDER_OGL_ES2 1)
|
||||
endif()
|
||||
endif()
|
||||
elseif(UNIX AND NOT APPLE)
|
||||
if(SDL_AUDIO)
|
||||
if(SYSV5 OR SOLARIS OR HPUX)
|
||||
set(SDL_AUDIO_DRIVER_SUNAUDIO 1)
|
||||
@@ -752,7 +837,7 @@ if(UNIX AND NOT APPLE)
|
||||
if(FOUND_CLOCK_GETTIME)
|
||||
list(APPEND EXTRA_LIBS rt)
|
||||
set(HAVE_CLOCK_GETTIME 1)
|
||||
else(FOUND_CLOCK_GETTIME)
|
||||
else()
|
||||
check_library_exists(c clock_gettime "" FOUND_CLOCK_GETTIME)
|
||||
if(FOUND_CLOCK_GETTIME)
|
||||
set(HAVE_CLOCK_GETTIME 1)
|
||||
@@ -829,7 +914,7 @@ elseif(WINDOWS)
|
||||
link_directories($ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH})
|
||||
include_directories($ENV{DXSDK_DIR}\\Include)
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
|
||||
endif()
|
||||
|
||||
if(SDL_AUDIO)
|
||||
@@ -978,7 +1063,7 @@ elseif(APPLE)
|
||||
endif()
|
||||
|
||||
if(SDL_AUDIO)
|
||||
set(MACOSX_COREAUDIO 1)
|
||||
set(SDL_AUDIO_DRIVER_COREAUDIO 1)
|
||||
file(GLOB AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/coreaudio/*.c)
|
||||
set(SOURCE_FILES ${SOURCE_FILES} ${AUDIO_SOURCES})
|
||||
set(HAVE_SDL_AUDIO TRUE)
|
||||
@@ -1068,10 +1153,6 @@ elseif(APPLE)
|
||||
set(SDL_VIDEO_OPENGL 1)
|
||||
set(SDL_VIDEO_OPENGL_CGL 1)
|
||||
set(SDL_VIDEO_RENDER_OGL 1)
|
||||
if(DARWIN)
|
||||
find_library(OpenGL_LIBRARY OpenGL)
|
||||
list(APPEND EXTRA_LIBRARIES ${OpenGL_LIBRARY})
|
||||
endif()
|
||||
set(HAVE_VIDEO_OPENGL TRUE)
|
||||
endif()
|
||||
endif()
|
||||
@@ -1193,14 +1274,14 @@ if(NOT WINDOWS OR CYGWIN)
|
||||
if(SDL_STATIC)
|
||||
set(ENABLE_STATIC_TRUE "")
|
||||
set(ENABLE_STATIC_FALSE "#")
|
||||
else(SDL_STATIC)
|
||||
else()
|
||||
set(ENABLE_STATIC_TRUE "#")
|
||||
set(ENABLE_STATIC_FALSE "")
|
||||
endif()
|
||||
if(SDL_SHARED)
|
||||
set(ENABLE_SHARED_TRUE "")
|
||||
set(ENABLE_SHARED_FALSE "#")
|
||||
else(SDL_SHARED)
|
||||
else()
|
||||
set(ENABLE_SHARED_TRUE "#")
|
||||
set(ENABLE_SHARED_FALSE "")
|
||||
endif()
|
||||
@@ -1281,7 +1362,7 @@ if(SDL_SHARED)
|
||||
VERSION ${LT_VERSION}
|
||||
SOVERSION ${LT_REVISION}
|
||||
OUTPUT_NAME "SDL2-${LT_RELEASE}")
|
||||
else(UNIX)
|
||||
else()
|
||||
set_target_properties(SDL2 PROPERTIES
|
||||
VERSION ${SDL_VERSION}
|
||||
SOVERSION ${LT_REVISION}
|
||||
@@ -1330,7 +1411,7 @@ if(NOT WINDOWS OR CYGWIN)
|
||||
if(FREEBSD)
|
||||
# FreeBSD uses ${PREFIX}/libdata/pkgconfig
|
||||
install(FILES ${SDL2_BINARY_DIR}/sdl2.pc DESTINATION "libdata/pkgconfig")
|
||||
else(FREEBSD)
|
||||
else()
|
||||
install(FILES ${SDL2_BINARY_DIR}/sdl2.pc
|
||||
DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
|
||||
endif()
|
||||
|
||||
+7
-4
@@ -1,7 +1,7 @@
|
||||
Summary: Simple DirectMedia Layer
|
||||
Name: SDL2
|
||||
Version: @SDL_VERSION@
|
||||
Release: 1
|
||||
Release: 2
|
||||
Source: http://www.libsdl.org/release/%{name}-%{version}.tar.gz
|
||||
URL: http://www.libsdl.org/
|
||||
License: zlib
|
||||
@@ -63,12 +63,12 @@ rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%files
|
||||
%{__defattr}
|
||||
%doc README-SDL.txt COPYING.txt CREDITS.txt BUGS.txt
|
||||
%doc README*.txt COPYING.txt CREDITS.txt BUGS.txt
|
||||
%{_libdir}/lib*.%{__soext}.*
|
||||
|
||||
%files devel
|
||||
%{__defattr}
|
||||
%doc README README-SDL.txt COPYING CREDITS BUGS WhatsNew
|
||||
%doc README*.txt COPYING.txt CREDITS.txt BUGS.txt WhatsNew.txt
|
||||
%{_bindir}/*-config
|
||||
%{_libdir}/lib*.a
|
||||
%{_libdir}/lib*.la
|
||||
@@ -78,13 +78,16 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%{_datadir}/aclocal/*
|
||||
|
||||
%changelog
|
||||
* Sun Dec 07 2014 Simone Contini <s.contini@oltrelinux.com>
|
||||
- Fixed changelog date issue and docs filenames
|
||||
|
||||
* Sun Jan 22 2012 Sam Lantinga <slouken@libsdl.org>
|
||||
- Updated for SDL 2.0
|
||||
|
||||
* Tue May 16 2006 Sam Lantinga <slouken@libsdl.org>
|
||||
- Removed support for Darwin, due to build problems on ps2linux
|
||||
|
||||
* Mon Jan 03 2004 Anders Bjorklund <afb@algonet.se>
|
||||
* Sat Jan 03 2004 Anders Bjorklund <afb@algonet.se>
|
||||
- Added support for Darwin, updated spec file
|
||||
|
||||
* Wed Jan 19 2000 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
@@ -387,6 +387,9 @@ main(int argc, char *argv[])
|
||||
SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 0);
|
||||
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
|
||||
|
||||
/* create main window and renderer */
|
||||
window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
|
||||
SDL_WINDOW_OPENGL |
|
||||
|
||||
@@ -1274,8 +1274,14 @@
|
||||
FD6526640DE8FCCB002AD96B /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
|
||||
GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = YES;
|
||||
GCC_WARN_STRICT_SELECTOR_MATCH = YES;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
PRODUCT_NAME = SDL2;
|
||||
SKIP_INSTALL = YES;
|
||||
};
|
||||
@@ -1284,8 +1290,14 @@
|
||||
FD6526650DE8FCCB002AD96B /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
|
||||
COPY_PHASE_STRIP = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
|
||||
GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = YES;
|
||||
GCC_WARN_STRICT_SELECTOR_MATCH = YES;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
PRODUCT_NAME = SDL2;
|
||||
SKIP_INSTALL = YES;
|
||||
};
|
||||
|
||||
@@ -8,6 +8,15 @@
|
||||
android:versionName="1.0"
|
||||
android:installLocation="auto">
|
||||
|
||||
<!-- Android 2.3.3 -->
|
||||
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="12" />
|
||||
|
||||
<!-- OpenGL ES 2.0 -->
|
||||
<uses-feature android:glEsVersion="0x00020000" />
|
||||
|
||||
<!-- Allow writing to external storage -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
<!-- Create a Java class extending SDLActivity and place it in a
|
||||
directory under src matching the package, e.g.
|
||||
src/com/gamemaker/game/MyGame.java
|
||||
@@ -33,12 +42,4 @@
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
<!-- Android 2.3.3 -->
|
||||
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="12" />
|
||||
|
||||
<!-- OpenGL ES 2.0 -->
|
||||
<uses-feature android:glEsVersion="0x00020000" />
|
||||
|
||||
<!-- Allow writing to external storage -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
</manifest>
|
||||
|
||||
@@ -41,6 +41,10 @@ public class SDLActivity extends Activity {
|
||||
/** If shared libraries (e.g. SDL or the native application) could not be loaded. */
|
||||
public static boolean mBrokenLibraries;
|
||||
|
||||
// If we want to separate mouse and touch events.
|
||||
// This is only toggled in native code when a hint is set!
|
||||
public static boolean mSeparateMouseAndTouch;
|
||||
|
||||
// Main components
|
||||
protected static SDLActivity mSingleton;
|
||||
protected static SDLSurface mSurface;
|
||||
@@ -81,7 +85,6 @@ public class SDLActivity extends Activity {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
* This method is called by SDL before starting the native application thread.
|
||||
* It can be overridden to provide the arguments after the application name.
|
||||
* The default implementation returns an empty array. It never returns null.
|
||||
@@ -111,6 +114,8 @@ public class SDLActivity extends Activity {
|
||||
// Setup
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Log.v("SDL", "Device: " + android.os.Build.DEVICE);
|
||||
Log.v("SDL", "Model: " + android.os.Build.MODEL);
|
||||
Log.v("SDL", "onCreate():" + mSingleton);
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
@@ -392,7 +397,7 @@ public class SDLActivity extends Activity {
|
||||
public static native void nativeQuit();
|
||||
public static native void nativePause();
|
||||
public static native void nativeResume();
|
||||
public static native void onNativeResize(int x, int y, int format);
|
||||
public static native void onNativeResize(int x, int y, int format, float rate);
|
||||
public static native int onNativePadDown(int device_id, int keycode);
|
||||
public static native int onNativePadUp(int device_id, int keycode);
|
||||
public static native void onNativeJoy(int device_id, int axis,
|
||||
@@ -402,6 +407,7 @@ public class SDLActivity extends Activity {
|
||||
public static native void onNativeKeyDown(int keycode);
|
||||
public static native void onNativeKeyUp(int keycode);
|
||||
public static native void onNativeKeyboardFocusLost();
|
||||
public static native void onNativeMouse(int button, int action, float x, float y);
|
||||
public static native void onNativeTouch(int touchDevId, int pointerFingerId,
|
||||
int action, float x,
|
||||
float y, float p);
|
||||
@@ -1041,7 +1047,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
||||
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
SDLActivity.onNativeResize(width, height, sdlFormat);
|
||||
SDLActivity.onNativeResize(width, height, sdlFormat, mDisplay.getRefreshRate());
|
||||
Log.v("SDL", "Window size:" + width + "x"+height);
|
||||
|
||||
// Set mIsSurfaceReady to 'true' *before* making a call to handleResume
|
||||
@@ -1088,8 +1094,8 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
||||
// Dispatch the different events depending on where they come from
|
||||
// Some SOURCE_DPAD or SOURCE_GAMEPAD are also SOURCE_KEYBOARD
|
||||
// So, we try to process them as DPAD or GAMEPAD events first, if that fails we try them as KEYBOARD
|
||||
|
||||
if ( (event.getSource() & 0x00000401) != 0 || /* API 12: SOURCE_GAMEPAD */
|
||||
|
||||
if ( (event.getSource() & InputDevice.SOURCE_GAMEPAD) != 0 ||
|
||||
(event.getSource() & InputDevice.SOURCE_DPAD) != 0 ) {
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
if (SDLActivity.onNativePadDown(event.getDeviceId(), keyCode) == 0) {
|
||||
@@ -1126,50 +1132,65 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
||||
final int pointerCount = event.getPointerCount();
|
||||
int action = event.getActionMasked();
|
||||
int pointerFingerId;
|
||||
int mouseButton;
|
||||
int i = -1;
|
||||
float x,y,p;
|
||||
|
||||
switch(action) {
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
for (i = 0; i < pointerCount; i++) {
|
||||
|
||||
// !!! FIXME: dump this SDK check after 2.0.4 ships and require API14.
|
||||
if (event.getSource() == InputDevice.SOURCE_MOUSE && SDLActivity.mSeparateMouseAndTouch) {
|
||||
if (Build.VERSION.SDK_INT < 14) {
|
||||
mouseButton = 1; // For Android==12 all mouse buttons are the left button
|
||||
} else {
|
||||
try {
|
||||
mouseButton = (Integer) event.getClass().getMethod("getButtonState").invoke(event);
|
||||
} catch(Exception e) {
|
||||
mouseButton = 1; // oh well.
|
||||
}
|
||||
}
|
||||
SDLActivity.onNativeMouse(mouseButton, action, event.getX(0), event.getY(0));
|
||||
} else {
|
||||
switch(action) {
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
for (i = 0; i < pointerCount; i++) {
|
||||
pointerFingerId = event.getPointerId(i);
|
||||
x = event.getX(i) / mWidth;
|
||||
y = event.getY(i) / mHeight;
|
||||
p = event.getPressure(i);
|
||||
SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p);
|
||||
}
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
// Primary pointer up/down, the index is always zero
|
||||
i = 0;
|
||||
case MotionEvent.ACTION_POINTER_UP:
|
||||
case MotionEvent.ACTION_POINTER_DOWN:
|
||||
// Non primary pointer up/down
|
||||
if (i == -1) {
|
||||
i = event.getActionIndex();
|
||||
}
|
||||
|
||||
pointerFingerId = event.getPointerId(i);
|
||||
x = event.getX(i) / mWidth;
|
||||
y = event.getY(i) / mHeight;
|
||||
p = event.getPressure(i);
|
||||
SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p);
|
||||
}
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
// Primary pointer up/down, the index is always zero
|
||||
i = 0;
|
||||
case MotionEvent.ACTION_POINTER_UP:
|
||||
case MotionEvent.ACTION_POINTER_DOWN:
|
||||
// Non primary pointer up/down
|
||||
if (i == -1) {
|
||||
i = event.getActionIndex();
|
||||
}
|
||||
break;
|
||||
|
||||
pointerFingerId = event.getPointerId(i);
|
||||
x = event.getX(i) / mWidth;
|
||||
y = event.getY(i) / mHeight;
|
||||
p = event.getPressure(i);
|
||||
SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p);
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
for (i = 0; i < pointerCount; i++) {
|
||||
pointerFingerId = event.getPointerId(i);
|
||||
x = event.getX(i) / mWidth;
|
||||
y = event.getY(i) / mHeight;
|
||||
p = event.getPressure(i);
|
||||
SDLActivity.onNativeTouch(touchDevId, pointerFingerId, MotionEvent.ACTION_UP, x, y, p);
|
||||
}
|
||||
break;
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
for (i = 0; i < pointerCount; i++) {
|
||||
pointerFingerId = event.getPointerId(i);
|
||||
x = event.getX(i) / mWidth;
|
||||
y = event.getY(i) / mHeight;
|
||||
p = event.getPressure(i);
|
||||
SDLActivity.onNativeTouch(touchDevId, pointerFingerId, MotionEvent.ACTION_UP, x, y, p);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -1500,9 +1521,44 @@ class SDLJoystickHandler_API12 extends SDLJoystickHandler {
|
||||
|
||||
class SDLGenericMotionListener_API12 implements View.OnGenericMotionListener {
|
||||
// Generic Motion (mouse hover, joystick...) events go here
|
||||
// We only have joysticks yet
|
||||
@Override
|
||||
public boolean onGenericMotion(View v, MotionEvent event) {
|
||||
return SDLActivity.handleJoystickMotionEvent(event);
|
||||
float x, y;
|
||||
int mouseButton;
|
||||
int action;
|
||||
|
||||
switch ( event.getSource() ) {
|
||||
case InputDevice.SOURCE_JOYSTICK:
|
||||
case InputDevice.SOURCE_GAMEPAD:
|
||||
case InputDevice.SOURCE_DPAD:
|
||||
SDLActivity.handleJoystickMotionEvent(event);
|
||||
return true;
|
||||
|
||||
case InputDevice.SOURCE_MOUSE:
|
||||
action = event.getActionMasked();
|
||||
switch (action) {
|
||||
case MotionEvent.ACTION_SCROLL:
|
||||
x = event.getAxisValue(MotionEvent.AXIS_HSCROLL, 0);
|
||||
y = event.getAxisValue(MotionEvent.AXIS_VSCROLL, 0);
|
||||
SDLActivity.onNativeMouse(0, action, x, y);
|
||||
return true;
|
||||
|
||||
case MotionEvent.ACTION_HOVER_MOVE:
|
||||
x = event.getX(0);
|
||||
y = event.getY(0);
|
||||
|
||||
SDLActivity.onNativeMouse(0, action, x, y);
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Event was not managed
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -898,6 +898,7 @@ EOF
|
||||
else
|
||||
case `sed -n '/^Hardware/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
|
||||
BCM2708) MANUFACTURER=raspberry;;
|
||||
BCM2709) MANUFACTURER=raspberry;;
|
||||
*) MANUFACTURER=unknown;;
|
||||
esac
|
||||
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
|
||||
|
||||
Vendored
+2
@@ -1534,6 +1534,8 @@ case $os in
|
||||
-pnacl*)
|
||||
os=-pnacl
|
||||
;;
|
||||
-emscripten*)
|
||||
;;
|
||||
-none)
|
||||
;;
|
||||
*)
|
||||
|
||||
Executable
+72
@@ -0,0 +1,72 @@
|
||||
#!/bin/bash
|
||||
|
||||
SDKDIR="/emsdk_portable"
|
||||
ENVSCRIPT="$SDKDIR/emsdk_env.sh"
|
||||
if [ ! -f "$ENVSCRIPT" ]; then
|
||||
echo "ERROR: This script expects the Emscripten SDK to be in '$SDKDIR'." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TARBALL="$1"
|
||||
if [ -z $1 ]; then
|
||||
TARBALL=sdl-emscripten.tar.xz
|
||||
fi
|
||||
|
||||
cd `dirname "$0"`
|
||||
cd ..
|
||||
SDLBASE=`pwd`
|
||||
|
||||
if [ -z "$MAKE" ]; then
|
||||
OSTYPE=`uname -s`
|
||||
if [ "$OSTYPE" == "Linux" ]; then
|
||||
NCPU=`cat /proc/cpuinfo |grep vendor_id |wc -l`
|
||||
let NCPU=$NCPU+1
|
||||
elif [ "$OSTYPE" = "Darwin" ]; then
|
||||
NCPU=`sysctl -n hw.ncpu`
|
||||
elif [ "$OSTYPE" = "SunOS" ]; then
|
||||
NCPU=`/usr/sbin/psrinfo |wc -l |sed -e 's/^ *//g;s/ *$//g'`
|
||||
else
|
||||
NCPU=1
|
||||
fi
|
||||
|
||||
if [ -z "$NCPU" ]; then
|
||||
NCPU=1
|
||||
elif [ "$NCPU" = "0" ]; then
|
||||
NCPU=1
|
||||
fi
|
||||
|
||||
MAKE="make -j$NCPU"
|
||||
fi
|
||||
|
||||
echo "\$MAKE is '$MAKE'"
|
||||
|
||||
echo "Setting up Emscripten SDK environment..."
|
||||
source "$ENVSCRIPT"
|
||||
|
||||
echo "Setting up..."
|
||||
set -x
|
||||
cd "$SDLBASE"
|
||||
rm -rf buildbot
|
||||
mkdir buildbot
|
||||
pushd buildbot
|
||||
|
||||
echo "Configuring..."
|
||||
emconfigure ../configure --host=asmjs-unknown-emscripten --disable-assembly --disable-threads --enable-cpuinfo=false CFLAGS="-O2 -Wno-warn-absolute-paths -Wdeclaration-after-statement -Werror=declaration-after-statement" --prefix="$PWD/emscripten-sdl2-installed"
|
||||
|
||||
echo "Building..."
|
||||
emmake $MAKE
|
||||
|
||||
echo "Moving things around..."
|
||||
emmake $MAKE install
|
||||
# Fix up a few things to a real install path
|
||||
perl -w -pi -e "s#$PWD/emscripten-sdl2-installed#/usr/local#g;" ./emscripten-sdl2-installed/lib/libSDL2.la ./emscripten-sdl2-installed/lib/pkgconfig/sdl2.pc ./emscripten-sdl2-installed/bin/sdl2-config
|
||||
mkdir -p ./usr
|
||||
mv ./emscripten-sdl2-installed ./usr/local
|
||||
popd
|
||||
tar -cJvvf $TARBALL -C buildbot usr
|
||||
rm -rf buildbot
|
||||
|
||||
exit 0
|
||||
|
||||
# end of emscripten-buildbot.sh ...
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
@echo off
|
||||
rem just a helper batch file for collecting up files and zipping them.
|
||||
rem usage: windows-buildbot-zipper.bat <zipfilename>
|
||||
rem must be run from root of SDL source tree.
|
||||
|
||||
IF EXIST VisualC\Win32\Release GOTO okaydir
|
||||
echo Please run from root of source tree after doing a Release build.
|
||||
GOTO done
|
||||
|
||||
:okaydir
|
||||
erase /q /f /s zipper
|
||||
IF EXIST zipper GOTO zippermade
|
||||
mkdir zipper
|
||||
:zippermade
|
||||
cd zipper
|
||||
mkdir SDL
|
||||
cd SDL
|
||||
mkdir include
|
||||
mkdir lib
|
||||
mkdir lib\win32
|
||||
copy ..\..\include\*.h include\
|
||||
copy ..\..\VisualC\Win32\Release\SDL2.dll lib\win32\
|
||||
copy ..\..\VisualC\Win32\Release\SDL2.lib lib\win32\
|
||||
copy ..\..\VisualC\Win32\Release\SDL2main.lib lib\win32\
|
||||
cd ..
|
||||
zip -9r ..\%1 SDL
|
||||
cd ..
|
||||
erase /q /f /s zipper
|
||||
|
||||
:done
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ endmacro()
|
||||
|
||||
macro(CHECK_OBJC_SOURCE_COMPILES SOURCE VAR)
|
||||
set(PREV_REQUIRED_DEFS "${CMAKE_REQUIRED_DEFINITIONS}")
|
||||
set(CMAKE_REQUIRED_DEFINITIONS "-ObjC ${PREV_REQUIRED_DEFS}")
|
||||
set(CMAKE_REQUIRED_DEFINITIONS "-x objective-c ${PREV_REQUIRED_DEFS}")
|
||||
CHECK_C_SOURCE_COMPILES(${SOURCE} ${VAR})
|
||||
set(CMAKE_REQUIRED_DEFINITIONS "${PREV_REQUIRED_DEFS}")
|
||||
endmacro()
|
||||
|
||||
+186
-139
File diff suppressed because it is too large
Load Diff
@@ -21385,6 +21385,78 @@ $as_echo "#define SDL_VIDEO_RENDER_OGL 1" >>confdefs.h
|
||||
fi
|
||||
}
|
||||
|
||||
CheckEmscriptenGLES()
|
||||
{
|
||||
if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for EGL support" >&5
|
||||
$as_echo_n "checking for EGL support... " >&6; }
|
||||
video_opengl_egl=no
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
#include <EGL/egl.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
|
||||
video_opengl_egl=yes
|
||||
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengl_egl" >&5
|
||||
$as_echo "$video_opengl_egl" >&6; }
|
||||
if test x$video_opengl_egl = xyes; then
|
||||
|
||||
$as_echo "#define SDL_VIDEO_OPENGL_EGL 1" >>confdefs.h
|
||||
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v2 headers" >&5
|
||||
$as_echo_n "checking for OpenGL ES v2 headers... " >&6; }
|
||||
video_opengles_v2=no
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
|
||||
video_opengles_v2=yes
|
||||
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v2" >&5
|
||||
$as_echo "$video_opengles_v2" >&6; }
|
||||
if test x$video_opengles_v2 = xyes; then
|
||||
|
||||
$as_echo "#define SDL_VIDEO_OPENGL_ES2 1" >>confdefs.h
|
||||
|
||||
|
||||
$as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h
|
||||
|
||||
SUMMARY_video="${SUMMARY_video} opengl_es2"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
CheckInputEvents()
|
||||
{
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Linux 2.4 unified input interface" >&5
|
||||
@@ -21844,6 +21916,7 @@ $as_echo_n "checking for recursive mutexes... " >&6; }
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
#define _GNU_SOURCE 1
|
||||
#include <pthread.h>
|
||||
|
||||
int
|
||||
@@ -21857,7 +21930,7 @@ main ()
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
if ac_fn_c_try_link "$LINENO"; then :
|
||||
|
||||
has_recursive_mutexes=yes
|
||||
|
||||
@@ -21865,12 +21938,14 @@ $as_echo "#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1" >>confdefs.h
|
||||
|
||||
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
rm -f core conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
fi
|
||||
if test x$has_recursive_mutexes = xno; then
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
#define _GNU_SOURCE 1
|
||||
#include <pthread.h>
|
||||
|
||||
int
|
||||
@@ -21884,7 +21959,7 @@ main ()
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
if ac_fn_c_try_link "$LINENO"; then :
|
||||
|
||||
has_recursive_mutexes=yes
|
||||
|
||||
@@ -21892,7 +21967,8 @@ $as_echo "#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1" >>confdefs.h
|
||||
|
||||
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
rm -f core conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $has_recursive_mutexes" >&5
|
||||
$as_echo "$has_recursive_mutexes" >&6; }
|
||||
@@ -22865,7 +22941,9 @@ case "$host" in
|
||||
|
||||
if test x$enable_video = xyes; then
|
||||
SOURCES="$SOURCES $srcdir/src/video/raspberry/*.c"
|
||||
# FIXME: confdefs? Not AC_DEFINE?
|
||||
$as_echo "#define SDL_VIDEO_DRIVER_RPI 1" >>confdefs.h
|
||||
SUMMARY_video="${SUMMARY_video} rpi"
|
||||
fi
|
||||
;;
|
||||
*-*-androideabi*)
|
||||
@@ -22879,6 +22957,7 @@ case "$host" in
|
||||
|
||||
if test x$enable_video = xyes; then
|
||||
SOURCES="$SOURCES $srcdir/src/core/android/*.c $srcdir/src/video/android/*.c"
|
||||
# FIXME: confdefs? Not AC_DEFINE?
|
||||
$as_echo "#define SDL_VIDEO_DRIVER_ANDROID 1" >>confdefs.h
|
||||
SUMMARY_video="${SUMMARY_video} android"
|
||||
fi
|
||||
@@ -23019,11 +23098,22 @@ $as_echo "#define SDL_POWER_ANDROID 1" >>confdefs.h
|
||||
fi
|
||||
# Set up files for the filesystem library
|
||||
if test x$enable_filesystem = xyes; then
|
||||
case $ARCH in
|
||||
android)
|
||||
|
||||
$as_echo "#define SDL_FILESYSTEM_ANDROID 1" >>confdefs.h
|
||||
|
||||
SOURCES="$SOURCES $srcdir/src/filesystem/android/*.c"
|
||||
have_filesystem=yes
|
||||
;;
|
||||
*)
|
||||
|
||||
$as_echo "#define SDL_FILESYSTEM_UNIX 1" >>confdefs.h
|
||||
|
||||
SOURCES="$SOURCES $srcdir/src/filesystem/unix/*.c"
|
||||
have_filesystem=yes
|
||||
SOURCES="$SOURCES $srcdir/src/filesystem/unix/*.c"
|
||||
have_filesystem=yes
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
# Set up files for the timer library
|
||||
if test x$enable_timers = xyes; then
|
||||
@@ -23483,7 +23573,68 @@ $as_echo "#define SDL_FILESYSTEM_NACL 1" >>confdefs.h
|
||||
SOURCES="$SOURCES $srcdir/src/filesystem/nacl/*.c"
|
||||
have_filesystem=yes
|
||||
fi
|
||||
;;
|
||||
*-*-emscripten* )
|
||||
if test x$enable_video = xyes; then
|
||||
|
||||
$as_echo "#define SDL_VIDEO_DRIVER_EMSCRIPTEN 1" >>confdefs.h
|
||||
|
||||
SOURCES="$SOURCES $srcdir/src/video/emscripten/*.c"
|
||||
have_video=yes
|
||||
SUMMARY_video="${SUMMARY_video} emscripten"
|
||||
fi
|
||||
|
||||
if test x$enable_audio = xyes; then
|
||||
|
||||
$as_echo "#define SDL_AUDIO_DRIVER_EMSCRIPTEN 1" >>confdefs.h
|
||||
|
||||
SOURCES="$SOURCES $srcdir/src/audio/emscripten/*.c"
|
||||
have_audio=yes
|
||||
SUMMARY_audio="${SUMMARY_audio} emscripten"
|
||||
fi
|
||||
|
||||
CheckVisibilityHidden
|
||||
CheckDummyVideo
|
||||
CheckDiskAudio
|
||||
CheckDummyAudio
|
||||
CheckDLOPEN
|
||||
CheckClockGettime
|
||||
CheckEmscriptenGLES
|
||||
|
||||
# Set up files for the power library
|
||||
if test x$enable_power = xyes; then
|
||||
|
||||
$as_echo "#define SDL_POWER_EMSCRIPTEN 1" >>confdefs.h
|
||||
|
||||
SOURCES="$SOURCES $srcdir/src/power/emscripten/*.c"
|
||||
have_power=yes
|
||||
fi
|
||||
|
||||
# Set up files for the power library
|
||||
if test x$enable_joystick = xyes; then
|
||||
|
||||
$as_echo "#define SDL_JOYSTICK_EMSCRIPTEN 1" >>confdefs.h
|
||||
|
||||
SOURCES="$SOURCES $srcdir/src/joystick/emscripten/*.c"
|
||||
have_joystick=yes
|
||||
fi
|
||||
|
||||
# Set up files for the filesystem library
|
||||
if test x$enable_filesystem = xyes; then
|
||||
|
||||
$as_echo "#define SDL_FILESYSTEM_EMSCRIPTEN 1" >>confdefs.h
|
||||
|
||||
SOURCES="$SOURCES $srcdir/src/filesystem/emscripten/*.c"
|
||||
have_filesystem=yes
|
||||
fi
|
||||
# Set up files for the timer library
|
||||
if test x$enable_timers = xyes; then
|
||||
|
||||
$as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h
|
||||
|
||||
SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
|
||||
have_timers=yes
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
as_fn_error $? "
|
||||
|
||||
+102
-5
@@ -2130,6 +2130,40 @@ CheckMacGL()
|
||||
fi
|
||||
}
|
||||
|
||||
CheckEmscriptenGLES()
|
||||
{
|
||||
if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then
|
||||
AC_MSG_CHECKING(for EGL support)
|
||||
video_opengl_egl=no
|
||||
AC_TRY_COMPILE([
|
||||
#include <EGL/egl.h>
|
||||
],[
|
||||
],[
|
||||
video_opengl_egl=yes
|
||||
])
|
||||
AC_MSG_RESULT($video_opengl_egl)
|
||||
if test x$video_opengl_egl = xyes; then
|
||||
AC_DEFINE(SDL_VIDEO_OPENGL_EGL, 1, [ ])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING(for OpenGL ES v2 headers)
|
||||
video_opengles_v2=no
|
||||
AC_TRY_COMPILE([
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
],[
|
||||
],[
|
||||
video_opengles_v2=yes
|
||||
])
|
||||
AC_MSG_RESULT($video_opengles_v2)
|
||||
if test x$video_opengles_v2 = xyes; then
|
||||
AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
|
||||
AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
|
||||
SUMMARY_video="${SUMMARY_video} opengl_es2"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
dnl See if we can use the new unified event interface in Linux 2.4
|
||||
CheckInputEvents()
|
||||
{
|
||||
@@ -2390,7 +2424,8 @@ AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]])
|
||||
AC_MSG_CHECKING(for recursive mutexes)
|
||||
has_recursive_mutexes=no
|
||||
if test x$has_recursive_mutexes = xno; then
|
||||
AC_TRY_COMPILE([
|
||||
AC_TRY_LINK([
|
||||
#define _GNU_SOURCE 1
|
||||
#include <pthread.h>
|
||||
],[
|
||||
pthread_mutexattr_t attr;
|
||||
@@ -2401,7 +2436,8 @@ AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]])
|
||||
])
|
||||
fi
|
||||
if test x$has_recursive_mutexes = xno; then
|
||||
AC_TRY_COMPILE([
|
||||
AC_TRY_LINK([
|
||||
#define _GNU_SOURCE 1
|
||||
#include <pthread.h>
|
||||
],[
|
||||
pthread_mutexattr_t attr;
|
||||
@@ -2801,7 +2837,9 @@ case "$host" in
|
||||
|
||||
if test x$enable_video = xyes; then
|
||||
SOURCES="$SOURCES $srcdir/src/video/raspberry/*.c"
|
||||
# FIXME: confdefs? Not AC_DEFINE?
|
||||
$as_echo "#define SDL_VIDEO_DRIVER_RPI 1" >>confdefs.h
|
||||
SUMMARY_video="${SUMMARY_video} rpi"
|
||||
fi
|
||||
;;
|
||||
*-*-androideabi*)
|
||||
@@ -2815,6 +2853,7 @@ case "$host" in
|
||||
|
||||
if test x$enable_video = xyes; then
|
||||
SOURCES="$SOURCES $srcdir/src/core/android/*.c $srcdir/src/video/android/*.c"
|
||||
# FIXME: confdefs? Not AC_DEFINE?
|
||||
$as_echo "#define SDL_VIDEO_DRIVER_ANDROID 1" >>confdefs.h
|
||||
SUMMARY_video="${SUMMARY_video} android"
|
||||
fi
|
||||
@@ -2937,9 +2976,18 @@ case "$host" in
|
||||
fi
|
||||
# Set up files for the filesystem library
|
||||
if test x$enable_filesystem = xyes; then
|
||||
AC_DEFINE(SDL_FILESYSTEM_UNIX, 1, [ ])
|
||||
SOURCES="$SOURCES $srcdir/src/filesystem/unix/*.c"
|
||||
have_filesystem=yes
|
||||
case $ARCH in
|
||||
android)
|
||||
AC_DEFINE(SDL_FILESYSTEM_ANDROID, 1, [ ])
|
||||
SOURCES="$SOURCES $srcdir/src/filesystem/android/*.c"
|
||||
have_filesystem=yes
|
||||
;;
|
||||
*)
|
||||
AC_DEFINE(SDL_FILESYSTEM_UNIX, 1, [ ])
|
||||
SOURCES="$SOURCES $srcdir/src/filesystem/unix/*.c"
|
||||
have_filesystem=yes
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
# Set up files for the timer library
|
||||
if test x$enable_timers = xyes; then
|
||||
@@ -3302,7 +3350,56 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
|
||||
SOURCES="$SOURCES $srcdir/src/filesystem/nacl/*.c"
|
||||
have_filesystem=yes
|
||||
fi
|
||||
;;
|
||||
*-*-emscripten* )
|
||||
if test x$enable_video = xyes; then
|
||||
AC_DEFINE(SDL_VIDEO_DRIVER_EMSCRIPTEN, 1, [ ])
|
||||
SOURCES="$SOURCES $srcdir/src/video/emscripten/*.c"
|
||||
have_video=yes
|
||||
SUMMARY_video="${SUMMARY_video} emscripten"
|
||||
fi
|
||||
|
||||
if test x$enable_audio = xyes; then
|
||||
AC_DEFINE(SDL_AUDIO_DRIVER_EMSCRIPTEN, 1, [ ])
|
||||
SOURCES="$SOURCES $srcdir/src/audio/emscripten/*.c"
|
||||
have_audio=yes
|
||||
SUMMARY_audio="${SUMMARY_audio} emscripten"
|
||||
fi
|
||||
|
||||
CheckVisibilityHidden
|
||||
CheckDummyVideo
|
||||
CheckDiskAudio
|
||||
CheckDummyAudio
|
||||
CheckDLOPEN
|
||||
CheckClockGettime
|
||||
CheckEmscriptenGLES
|
||||
|
||||
# Set up files for the power library
|
||||
if test x$enable_power = xyes; then
|
||||
AC_DEFINE(SDL_POWER_EMSCRIPTEN, 1, [ ])
|
||||
SOURCES="$SOURCES $srcdir/src/power/emscripten/*.c"
|
||||
have_power=yes
|
||||
fi
|
||||
|
||||
# Set up files for the power library
|
||||
if test x$enable_joystick = xyes; then
|
||||
AC_DEFINE(SDL_JOYSTICK_EMSCRIPTEN, 1, [ ])
|
||||
SOURCES="$SOURCES $srcdir/src/joystick/emscripten/*.c"
|
||||
have_joystick=yes
|
||||
fi
|
||||
|
||||
# Set up files for the filesystem library
|
||||
if test x$enable_filesystem = xyes; then
|
||||
AC_DEFINE(SDL_FILESYSTEM_EMSCRIPTEN, 1, [ ])
|
||||
SOURCES="$SOURCES $srcdir/src/filesystem/emscripten/*.c"
|
||||
have_filesystem=yes
|
||||
fi
|
||||
# Set up files for the timer library
|
||||
if test x$enable_timers = xyes; then
|
||||
AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
|
||||
SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
|
||||
have_timers=yes
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
AC_MSG_ERROR([
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
Emscripten
|
||||
================================================================================
|
||||
|
||||
Build:
|
||||
|
||||
$ emconfigure ./configure --host=asmjs-unknown-emscripten --disable-assembly --disable-threads --enable-cpuinfo=false CFLAGS="-O2"
|
||||
$ emmake make
|
||||
|
||||
Or with cmake:
|
||||
|
||||
$ emconfigure cmake ..
|
||||
$ make
|
||||
|
||||
To build one of the tests:
|
||||
|
||||
$ cd test/
|
||||
$ emcc -O2 --js-opts 0 -g4 testdraw2.c -I../include ../build/.libs/libSDL2.a ../build/libSDL2_test.a -o a.html
|
||||
|
||||
Uses GLES2 renderer or software
|
||||
|
||||
tests: https://dl.dropboxusercontent.com/u/17360362/SDL2-em/index.html
|
||||
|
||||
Some other SDL2 libraries can be easily built (assuming SDL2 is installed somewhere):
|
||||
|
||||
SDL_mixer (http://www.libsdl.org/projects/SDL_mixer/)
|
||||
|
||||
$ EMCONFIGURE_JS=1 emconfigure ../configure
|
||||
build as usual...
|
||||
|
||||
SDL_gfx (http://cms.ferzkopp.net/index.php/software/13-sdl-gfx):
|
||||
|
||||
$ EMCONFIGURE_JS=1 emconfigure ../configure --disable-mmx
|
||||
build as usual...
|
||||
@@ -1,6 +1,6 @@
|
||||
Dollar Gestures
|
||||
===========================================================================
|
||||
SDL Provides an implementation of the $1 gesture recognition system. This allows for recording, saving, loading, and performing single stroke gestures.
|
||||
SDL provides an implementation of the $1 gesture recognition system. This allows for recording, saving, loading, and performing single stroke gestures.
|
||||
|
||||
Gestures can be performed with any number of fingers (the centroid of the fingers must follow the path of the gesture), but the number of fingers must be constant (a finger cannot go down in the middle of a gesture). The path of a gesture is considered the path from the time when the final finger went down, to the first time any finger comes up.
|
||||
|
||||
|
||||
@@ -1,34 +1,8 @@
|
||||
Platforms
|
||||
=========
|
||||
|
||||
|
||||
This is a list of the platforms SDL supports, and who maintains them.
|
||||
|
||||
Officially supported platforms
|
||||
==============================
|
||||
(code compiles, and thoroughly tested for release)
|
||||
==============================
|
||||
* Windows XP/Vista/7/8
|
||||
* Mac OS X 10.5+
|
||||
* Linux 2.6+
|
||||
* iOS 5.1.1+
|
||||
* Android 2.3.3+
|
||||
|
||||
Unofficially supported platforms
|
||||
================================
|
||||
(code compiles, but not thoroughly tested)
|
||||
================================
|
||||
* FreeBSD
|
||||
* NetBSD
|
||||
* OpenBSD
|
||||
* Solaris
|
||||
|
||||
Platforms supported by volunteers
|
||||
=================================
|
||||
* Haiku - maintained by Axel Dörfler <axeld@pinc-software.de>
|
||||
* PSP - maintained by 527721088@qq.com
|
||||
* Pandora - maintained by Scott Smith <pickle136@sbcglobal.net>
|
||||
* NaCl - maintained by Gabriel Jacobo <gabomdq@gmail.com>
|
||||
|
||||
Platforms that need maintainers
|
||||
===============================
|
||||
We maintain the list of supported platforms on our wiki now, and how to
|
||||
build and install SDL for those platforms:
|
||||
|
||||
https://wiki.libsdl.org/Installation
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ There are two basic ways of building SDL at the moment:
|
||||
|
||||
If you have a GNUish system, then you might try this. Edit configure.in,
|
||||
take a look at the large section labelled:
|
||||
"Set up the configuration based on the target platform!"
|
||||
"Set up the configuration based on the host platform!"
|
||||
Add a section for your platform, and then re-run autogen.sh and build!
|
||||
|
||||
2. Using an IDE:
|
||||
|
||||
+11
-4
@@ -90,10 +90,12 @@ Here is a rough list of what works, and what doens't:
|
||||
* keyboard input. Most of WinRT's documented virtual keys are supported, as
|
||||
well as many keys with documented hardware scancodes.
|
||||
* OpenGL. Experimental support for OpenGL ES 2 is available via the ANGLE
|
||||
project, using either MS Open Technologies' repository, at
|
||||
https://github.com/msopentech/angle (both the "winrt" and "future-dev"
|
||||
branches are supported), or the official ANGLE repository, at
|
||||
https://chromium.googlesource.com/angle/angle
|
||||
project, using either:
|
||||
* MS Open Technologies' "ms-master" repository, at https://github.com/MSOpenTech/angle
|
||||
(for use with Windows 8.1+ or Windows Phone 8.1+)
|
||||
* MS Open Technologies' "angle-win8.0" repository, at https://github.com/MSOpenTech/angle-win8.0
|
||||
(for Windows 8.0 only!)
|
||||
* Google's main ANGLE repository, at https://chromium.googlesource.com/angle/angle
|
||||
* SDLmain. WinRT uses a different signature for each app's main() function.
|
||||
SDL-based apps that use this port must compile in SDL_winrt_main_NonXAML.cpp
|
||||
(in `SDL\src\main\winrt\`) directly in order for their C-style main()
|
||||
@@ -112,6 +114,11 @@ Here is a rough list of what works, and what doens't:
|
||||
supported by WinRT itself.
|
||||
* joysticks and game controllers that aren't supported by Microsoft's XInput
|
||||
API.
|
||||
* turning off VSync when rendering on Windows Phone. Attempts to turn VSync
|
||||
off on Windows Phone result either in Direct3D not drawing anything, or it
|
||||
forcing VSync back on. As such, SDL_RENDERER_PRESENTVSYNC will always get
|
||||
turned-on on Windows Phone. This limitation is not present in non-Phone
|
||||
WinRT (such as Windows 8.x), where turning off VSync appears to work.
|
||||
* probably anything else that's not listed as supported
|
||||
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ More documentation and FAQs are available online at [the wiki](http://wiki.libsd
|
||||
- [CMake](README-cmake.md)
|
||||
- [DirectFB](README-directfb.md)
|
||||
- [DynAPI](README-dynapi.md)
|
||||
- [Emscripten](README-emscripten.md)
|
||||
- [Gesture](README-gesture.md)
|
||||
- [Mercurial](README-hg.md)
|
||||
- [iOS](README-ios.md)
|
||||
|
||||
+21
-13
@@ -86,8 +86,10 @@ This also solves the problem of...
|
||||
disable assertions.
|
||||
*/
|
||||
|
||||
/* "while (0,0)" fools Microsoft's compiler's /W4 warning level into thinking
|
||||
this condition isn't constant. And looks like an owl's face! */
|
||||
#ifdef _MSC_VER /* stupid /W4 warnings. */
|
||||
#define SDL_NULL_WHILE_LOOP_CONDITION (-1 == __LINE__)
|
||||
#define SDL_NULL_WHILE_LOOP_CONDITION (0,0)
|
||||
#else
|
||||
#define SDL_NULL_WHILE_LOOP_CONDITION (0)
|
||||
#endif
|
||||
@@ -102,9 +104,9 @@ typedef enum
|
||||
SDL_ASSERTION_ABORT, /**< Terminate the program. */
|
||||
SDL_ASSERTION_IGNORE, /**< Ignore the assert. */
|
||||
SDL_ASSERTION_ALWAYS_IGNORE /**< Ignore the assert from now on. */
|
||||
} SDL_assert_state;
|
||||
} SDL_AssertState;
|
||||
|
||||
typedef struct SDL_assert_data
|
||||
typedef struct SDL_AssertData
|
||||
{
|
||||
int always_ignore;
|
||||
unsigned int trigger_count;
|
||||
@@ -112,13 +114,13 @@ typedef struct SDL_assert_data
|
||||
const char *filename;
|
||||
int linenum;
|
||||
const char *function;
|
||||
const struct SDL_assert_data *next;
|
||||
} SDL_assert_data;
|
||||
const struct SDL_AssertData *next;
|
||||
} SDL_AssertData;
|
||||
|
||||
#if (SDL_ASSERT_LEVEL > 0)
|
||||
|
||||
/* Never call this directly. Use the SDL_assert* macros. */
|
||||
extern DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *,
|
||||
extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
|
||||
const char *,
|
||||
const char *, int)
|
||||
#if defined(__clang__)
|
||||
@@ -141,10 +143,10 @@ extern DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *,
|
||||
#define SDL_enabled_assert(condition) \
|
||||
do { \
|
||||
while ( !(condition) ) { \
|
||||
static struct SDL_assert_data sdl_assert_data = { \
|
||||
static struct SDL_AssertData sdl_assert_data = { \
|
||||
0, 0, #condition, 0, 0, 0, 0 \
|
||||
}; \
|
||||
const SDL_assert_state sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \
|
||||
const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \
|
||||
if (sdl_assert_state == SDL_ASSERTION_RETRY) { \
|
||||
continue; /* go again. */ \
|
||||
} else if (sdl_assert_state == SDL_ASSERTION_BREAK) { \
|
||||
@@ -181,8 +183,8 @@ extern DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *,
|
||||
#define SDL_assert_always(condition) SDL_enabled_assert(condition)
|
||||
|
||||
|
||||
typedef SDL_assert_state (SDLCALL *SDL_AssertionHandler)(
|
||||
const SDL_assert_data* data, void* userdata);
|
||||
typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)(
|
||||
const SDL_AssertData* data, void* userdata);
|
||||
|
||||
/**
|
||||
* \brief Set an application-defined assertion handler.
|
||||
@@ -199,7 +201,7 @@ typedef SDL_assert_state (SDLCALL *SDL_AssertionHandler)(
|
||||
*
|
||||
* This callback is NOT reset to SDL's internal handler upon SDL_Quit()!
|
||||
*
|
||||
* \return SDL_assert_state value of how to handle the assertion failure.
|
||||
* \return SDL_AssertState value of how to handle the assertion failure.
|
||||
*
|
||||
* \param handler Callback function, called when an assertion fails.
|
||||
* \param userdata A pointer passed to the callback as-is.
|
||||
@@ -246,7 +248,7 @@ extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetAssertionHandler(void **puse
|
||||
* The proper way to examine this data looks something like this:
|
||||
*
|
||||
* <code>
|
||||
* const SDL_assert_data *item = SDL_GetAssertionReport();
|
||||
* const SDL_AssertData *item = SDL_GetAssertionReport();
|
||||
* while (item) {
|
||||
* printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n",
|
||||
* item->condition, item->function, item->filename,
|
||||
@@ -259,7 +261,7 @@ extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetAssertionHandler(void **puse
|
||||
* \return List of all assertions.
|
||||
* \sa SDL_ResetAssertionReport
|
||||
*/
|
||||
extern DECLSPEC const SDL_assert_data * SDLCALL SDL_GetAssertionReport(void);
|
||||
extern DECLSPEC const SDL_AssertData * SDLCALL SDL_GetAssertionReport(void);
|
||||
|
||||
/**
|
||||
* \brief Reset the list of all assertion failures.
|
||||
@@ -270,6 +272,12 @@ extern DECLSPEC const SDL_assert_data * SDLCALL SDL_GetAssertionReport(void);
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_ResetAssertionReport(void);
|
||||
|
||||
|
||||
/* these had wrong naming conventions until 2.0.4. Please update your app! */
|
||||
#define SDL_assert_state SDL_AssertState
|
||||
#define SDL_assert_data SDL_AssertData
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock);
|
||||
void _ReadWriteBarrier(void);
|
||||
#pragma intrinsic(_ReadWriteBarrier)
|
||||
#define SDL_CompilerBarrier() _ReadWriteBarrier()
|
||||
#elif defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120))
|
||||
#elif (defined(__GNUC__) && !defined(__EMSCRIPTEN__)) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120))
|
||||
/* This is correct for all CPUs when using GCC or Solaris Studio 12.1+. */
|
||||
#define SDL_CompilerBarrier() __asm__ __volatile__ ("" : : : "memory")
|
||||
#else
|
||||
|
||||
@@ -217,6 +217,7 @@
|
||||
#cmakedefine SDL_AUDIO_DRIVER_WINMM @SDL_AUDIO_DRIVER_WINMM@
|
||||
#cmakedefine SDL_AUDIO_DRIVER_FUSIONSOUND @SDL_AUDIO_DRIVER_FUSIONSOUND@
|
||||
#cmakedefine SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC @SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC@
|
||||
#cmakedefine SDL_AUDIO_DRIVER_EMSCRIPTEN @SDL_AUDIO_DRIVER_EMSCRIPTEN@
|
||||
|
||||
/* Enable various input drivers */
|
||||
#cmakedefine SDL_INPUT_LINUXEV @SDL_INPUT_LINUXEV@
|
||||
@@ -230,6 +231,7 @@
|
||||
#cmakedefine SDL_JOYSTICK_WINMM @SDL_JOYSTICK_WINMM@
|
||||
#cmakedefine SDL_JOYSTICK_USBHID @SDL_JOYSTICK_USBHID@
|
||||
#cmakedefine SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H @SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H@
|
||||
#cmakedefine SDL_JOYSTICK_EMSCRIPTEN @SDL_JOYSTICK_EMSCRIPTEN@
|
||||
#cmakedefine SDL_HAPTIC_DUMMY @SDL_HAPTIC_DUMMY@
|
||||
#cmakedefine SDL_HAPTIC_LINUX @SDL_HAPTIC_LINUX@
|
||||
#cmakedefine SDL_HAPTIC_IOKIT @SDL_HAPTIC_IOKIT@
|
||||
@@ -267,18 +269,16 @@
|
||||
#cmakedefine SDL_VIDEO_DRIVER_VIVANTE @SDL_VIDEO_DRIVER_VIVANTE@
|
||||
#cmakedefine SDL_VIDEO_DRIVER_VIVANTE_VDK @SDL_VIDEO_DRIVER_VIVANTE_VDK@
|
||||
|
||||
#if 0
|
||||
/* !!! FIXME: in configure script version, missing here: */
|
||||
#undef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
|
||||
#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC
|
||||
#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL
|
||||
#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR
|
||||
#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON
|
||||
#endif
|
||||
#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH @SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH@
|
||||
#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC@
|
||||
#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL@
|
||||
#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR@
|
||||
#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON@
|
||||
|
||||
#cmakedefine SDL_VIDEO_DRIVER_MIR @SDL_VIDEO_DRIVER_MIR@
|
||||
#cmakedefine SDL_VIDEO_DRIVER_MIR_DYNAMIC @SDL_VIDEO_DRIVER_MIR_DYNAMIC@
|
||||
#cmakedefine SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON @SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON@
|
||||
#cmakedefine SDL_VIDEO_DRIVER_EMSCRIPTEN @SDL_VIDEO_DRIVER_EMSCRIPTEN@
|
||||
#cmakedefine SDL_VIDEO_DRIVER_X11 @SDL_VIDEO_DRIVER_X11@
|
||||
#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC @SDL_VIDEO_DRIVER_X11_DYNAMIC@
|
||||
#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT @SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT@
|
||||
@@ -325,6 +325,7 @@
|
||||
#cmakedefine SDL_POWER_WINDOWS @SDL_POWER_WINDOWS@
|
||||
#cmakedefine SDL_POWER_MACOSX @SDL_POWER_MACOSX@
|
||||
#cmakedefine SDL_POWER_HAIKU @SDL_POWER_HAIKU@
|
||||
#cmakedefine SDL_POWER_EMSCRIPTEN @SDL_POWER_EMSCRIPTEN@
|
||||
#cmakedefine SDL_POWER_HARDWIRED @SDL_POWER_HARDWIRED@
|
||||
|
||||
/* Enable system filesystem support */
|
||||
@@ -333,6 +334,7 @@
|
||||
#cmakedefine SDL_FILESYSTEM_DUMMY @SDL_FILESYSTEM_DUMMY@
|
||||
#cmakedefine SDL_FILESYSTEM_UNIX @SDL_FILESYSTEM_UNIX@
|
||||
#cmakedefine SDL_FILESYSTEM_WINDOWS @SDL_FILESYSTEM_WINDOWS@
|
||||
#cmakedefine SDL_FILESYSTEM_EMSCRIPTEN @SDL_FILESYSTEM_EMSCRIPTEN@
|
||||
|
||||
/* Enable assembly routines */
|
||||
#cmakedefine SDL_ASSEMBLY_ROUTINES @SDL_ASSEMBLY_ROUTINES@
|
||||
|
||||
@@ -228,6 +228,7 @@
|
||||
#undef SDL_AUDIO_DRIVER_WINMM
|
||||
#undef SDL_AUDIO_DRIVER_FUSIONSOUND
|
||||
#undef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC
|
||||
#undef SDL_AUDIO_DRIVER_EMSCRIPTEN
|
||||
|
||||
/* Enable various input drivers */
|
||||
#undef SDL_INPUT_LINUXEV
|
||||
@@ -243,6 +244,7 @@
|
||||
#undef SDL_JOYSTICK_WINMM
|
||||
#undef SDL_JOYSTICK_USBHID
|
||||
#undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H
|
||||
#undef SDL_JOYSTICK_EMSCRIPTEN
|
||||
#undef SDL_HAPTIC_DUMMY
|
||||
#undef SDL_HAPTIC_LINUX
|
||||
#undef SDL_HAPTIC_IOKIT
|
||||
@@ -287,6 +289,7 @@
|
||||
#undef SDL_VIDEO_DRIVER_X11
|
||||
#undef SDL_VIDEO_DRIVER_RPI
|
||||
#undef SDL_VIDEO_DRIVER_ANDROID
|
||||
#undef SDL_VIDEO_DRIVER_EMSCRIPTEN
|
||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC
|
||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT
|
||||
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR
|
||||
@@ -336,6 +339,7 @@
|
||||
#undef SDL_POWER_MACOSX
|
||||
#undef SDL_POWER_HAIKU
|
||||
#undef SDL_POWER_ANDROID
|
||||
#undef SDL_POWER_EMSCRIPTEN
|
||||
#undef SDL_POWER_HARDWIRED
|
||||
|
||||
/* Enable system filesystem support */
|
||||
@@ -345,6 +349,8 @@
|
||||
#undef SDL_FILESYSTEM_UNIX
|
||||
#undef SDL_FILESYSTEM_WINDOWS
|
||||
#undef SDL_FILESYSTEM_NACL
|
||||
#undef SDL_FILESYSTEM_ANDROID
|
||||
#undef SDL_FILESYSTEM_EMSCRIPTEN
|
||||
|
||||
/* Enable assembly routines */
|
||||
#undef SDL_ASSEMBLY_ROUTINES
|
||||
|
||||
@@ -145,6 +145,9 @@
|
||||
/* enable iPhone keyboard support */
|
||||
#define SDL_IPHONE_KEYBOARD 1
|
||||
|
||||
/* enable iOS extended launch screen */
|
||||
#define SDL_IPHONE_LAUNCHSCREEN 1
|
||||
|
||||
/* enable joystick subsystem */
|
||||
#define SDL_JOYSTICK_DISABLED 0
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2014 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
|
||||
|
||||
+21
-1
@@ -134,6 +134,10 @@ typedef enum
|
||||
/* Drag and drop events */
|
||||
SDL_DROPFILE = 0x1000, /**< The system requests a file open */
|
||||
|
||||
/* Audio hotplug events */
|
||||
SDL_AUDIODEVICEADDED = 0x1100, /**< A new audio device is available */
|
||||
SDL_AUDIODEVICEREMOVED, /**< An audio device has been removed. */
|
||||
|
||||
/* Render events */
|
||||
SDL_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */
|
||||
SDL_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */
|
||||
@@ -260,6 +264,7 @@ typedef struct SDL_MouseWheelEvent
|
||||
Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
|
||||
Sint32 x; /**< The amount scrolled horizontally, positive to the right and negative to the left */
|
||||
Sint32 y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */
|
||||
Uint32 direction; /**< Set to one of the SDL_MOUSEWHEEL_* defines. When FLIPPED the values in X and Y will be opposite. Multiply by -1 to change them back */
|
||||
} SDL_MouseWheelEvent;
|
||||
|
||||
/**
|
||||
@@ -381,6 +386,20 @@ typedef struct SDL_ControllerDeviceEvent
|
||||
Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */
|
||||
} SDL_ControllerDeviceEvent;
|
||||
|
||||
/**
|
||||
* \brief Audio device event structure (event.adevice.*)
|
||||
*/
|
||||
typedef struct SDL_AudioDeviceEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_AUDIODEVICEADDED, or ::SDL_AUDIODEVICEREMOVED */
|
||||
Uint32 timestamp;
|
||||
Uint32 which; /**< The audio device index for the ADDED event (valid until next SDL_GetNumAudioDevices() call), SDL_AudioDeviceID for the REMOVED event */
|
||||
Uint8 iscapture; /**< zero if an output device, non-zero if a capture device. */
|
||||
Uint8 padding1;
|
||||
Uint8 padding2;
|
||||
Uint8 padding3;
|
||||
} SDL_AudioDeviceEvent;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Touch finger event structure (event.tfinger.*)
|
||||
@@ -421,7 +440,7 @@ typedef struct SDL_MultiGestureEvent
|
||||
*/
|
||||
typedef struct SDL_DollarGestureEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_DOLLARGESTURE */
|
||||
Uint32 type; /**< ::SDL_DOLLARGESTURE or ::SDL_DOLLARRECORD */
|
||||
Uint32 timestamp;
|
||||
SDL_TouchID touchId; /**< The touch device id */
|
||||
SDL_GestureID gestureId;
|
||||
@@ -515,6 +534,7 @@ typedef union SDL_Event
|
||||
SDL_ControllerAxisEvent caxis; /**< Game Controller axis event data */
|
||||
SDL_ControllerButtonEvent cbutton; /**< Game Controller button event data */
|
||||
SDL_ControllerDeviceEvent cdevice; /**< Game Controller device event data */
|
||||
SDL_AudioDeviceEvent adevice; /**< Audio device event data */
|
||||
SDL_QuitEvent quit; /**< Quit request event data */
|
||||
SDL_UserEvent user; /**< Custom event data */
|
||||
SDL_SysWMEvent syswm; /**< System dependent window event data */
|
||||
|
||||
@@ -241,7 +241,8 @@ SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller,
|
||||
/**
|
||||
* Get the current state of an axis control on a game controller.
|
||||
*
|
||||
* The state is a value ranging from -32768 to 32767.
|
||||
* The state is a value ranging from -32768 to 32767 (except for the triggers,
|
||||
* which range from 0 to 32767).
|
||||
*
|
||||
* The axis indices start at index 0.
|
||||
*/
|
||||
|
||||
+42
-3
@@ -272,8 +272,9 @@ extern "C" {
|
||||
#define SDL_HINT_ORIENTATIONS "SDL_IOS_ORIENTATIONS"
|
||||
|
||||
/**
|
||||
* \brief A variable controlling whether an Android built-in accelerometer should be
|
||||
* listed as a joystick device, rather than listing actual joysticks only.
|
||||
* \brief A variable controlling whether the Android / iOS built-in
|
||||
* accelerometer should be listed as a joystick device, rather than listing
|
||||
* actual joysticks only.
|
||||
*
|
||||
* This variable can be set to the following values:
|
||||
* "0" - List only real joysticks and accept input from them
|
||||
@@ -356,7 +357,7 @@ extern "C" {
|
||||
|
||||
|
||||
/**
|
||||
* \brief If set to 1, then do not allow high-DPI windows. ("Retina" on Mac)
|
||||
* \brief If set to 1, then do not allow high-DPI windows. ("Retina" on Mac and iOS)
|
||||
*/
|
||||
#define SDL_HINT_VIDEO_HIGHDPI_DISABLED "SDL_VIDEO_HIGHDPI_DISABLED"
|
||||
|
||||
@@ -543,6 +544,44 @@ extern "C" {
|
||||
*/
|
||||
#define SDL_HINT_IME_INTERNAL_EDITING "SDL_IME_INTERNAL_EDITING"
|
||||
|
||||
/**
|
||||
* \brief A variable to control whether mouse and touch events are to be treated together or separately
|
||||
*
|
||||
* The variable can be set to the following values:
|
||||
* "0" - Mouse events will be handled as touch events, and touch will raise fake mouse
|
||||
* events. This is the behaviour of SDL <= 2.0.3. (default)
|
||||
* "1" - Mouse events will be handled separately from pure touch events.
|
||||
*
|
||||
* The value of this hint is used at runtime, so it can be changed at any time.
|
||||
*/
|
||||
#define SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH "SDL_ANDROID_SEPARATE_MOUSE_AND_TOUCH"
|
||||
|
||||
/**
|
||||
* \brief override the binding element for keyboard inputs for Emscripten builds
|
||||
*
|
||||
* This hint only applies to the emscripten platform
|
||||
*
|
||||
* The variable can be one of
|
||||
* "#window" - The javascript window object (this is the default)
|
||||
* "#document" - The javascript document object
|
||||
* "#screen" - the javascript window.screen object
|
||||
* "#canvas" - the WebGL canvas element
|
||||
* any other string without a leading # sign applies to the element on the page with that ID.
|
||||
*/
|
||||
#define SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT "SDL_EMSCRIPTEN_KEYBOARD_ELEMENT"
|
||||
|
||||
/**
|
||||
* \brief Tell SDL not to catch the SIGINT or SIGTERM signals.
|
||||
*
|
||||
* This hint only applies to Unix-like platforms.
|
||||
*
|
||||
* The variable can be set to the following values:
|
||||
* "0" - SDL will install a SIGINT and SIGTERM handler, and when it
|
||||
* catches a signal, convert it into an SDL_QUIT event.
|
||||
* "1" - SDL will not install a signal handler at all.
|
||||
*/
|
||||
#define SDL_HINT_NO_SIGNAL_HANDLERS "SDL_NO_SIGNAL_HANDLERS"
|
||||
|
||||
/**
|
||||
* \brief An enumeration of hint priorities
|
||||
*/
|
||||
|
||||
+2
-5
@@ -142,14 +142,11 @@ extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
|
||||
* \brief Initializes and launches an SDL/WinRT application.
|
||||
*
|
||||
* \param mainFunction The SDL app's C-style main().
|
||||
* \param xamlBackgroundPanel An optional, XAML-based, background panel.
|
||||
* For Non-XAML apps, this value must be set to NULL. For XAML apps,
|
||||
* pass in a pointer to a SwapChainBackgroundPanel, casted to an
|
||||
* IInspectable (via reinterpret_cast).
|
||||
* \param reserved Reserved for future use; should be NULL
|
||||
* \ret 0 on success, -1 on failure. On failure, use SDL_GetError to retrieve more
|
||||
* information on the failure.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_WinRTRunApp(int (*mainFunction)(int, char **), void * xamlBackgroundPanel);
|
||||
extern DECLSPEC int SDLCALL SDL_WinRTRunApp(int (*mainFunction)(int, char **), void * reserved);
|
||||
|
||||
#endif /* __WINRT__ */
|
||||
|
||||
|
||||
@@ -60,6 +60,15 @@ typedef enum
|
||||
SDL_NUM_SYSTEM_CURSORS
|
||||
} SDL_SystemCursor;
|
||||
|
||||
/**
|
||||
* \brief Scroll direction types for the Scroll event
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SDL_MOUSEWHEEL_NORMAL, /**< The scroll direction is normal */
|
||||
SDL_MOUSEWHEEL_FLIPPED /**< The scroll direction is flipped / natural */
|
||||
} SDL_MouseWheelDirection;
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
|
||||
@@ -2988,6 +2988,11 @@ GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program);
|
||||
#define GL_ARB_framebuffer_sRGB 1
|
||||
#endif /* GL_ARB_framebuffer_sRGB */
|
||||
|
||||
#ifndef GL_KHR_context_flush_control
|
||||
#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82FB
|
||||
#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC
|
||||
#endif /* GL_KHR_context_flush_control */
|
||||
|
||||
#ifndef GL_ARB_geometry_shader4
|
||||
#define GL_ARB_geometry_shader4 1
|
||||
#define GL_LINES_ADJACENCY_ARB 0x000A
|
||||
|
||||
@@ -81,8 +81,8 @@ typedef struct SDL_RendererInfo
|
||||
Uint32 flags; /**< Supported ::SDL_RendererFlags */
|
||||
Uint32 num_texture_formats; /**< The number of available texture formats */
|
||||
Uint32 texture_formats[16]; /**< The available texture formats */
|
||||
int max_texture_width; /**< The maximimum texture width */
|
||||
int max_texture_height; /**< The maximimum texture height */
|
||||
int max_texture_width; /**< The maximum texture width */
|
||||
int max_texture_height; /**< The maximum texture height */
|
||||
} SDL_RendererInfo;
|
||||
|
||||
/**
|
||||
@@ -792,7 +792,7 @@ extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer,
|
||||
* \param dstrect A pointer to the destination rectangle, or NULL for the
|
||||
* entire rendering target.
|
||||
* \param angle An angle in degrees that indicates the rotation that will be applied to dstrect
|
||||
* \param center A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done aroud dstrect.w/2, dstrect.h/2)
|
||||
* \param center A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done around dstrect.w/2, dstrect.h/2).
|
||||
* \param flip An SDL_RendererFlip value stating which flipping actions should be performed on the texture
|
||||
*
|
||||
* \return 0 on success, or -1 on error
|
||||
|
||||
+61
-7
@@ -172,7 +172,9 @@ typedef uint64_t Uint64;
|
||||
#ifdef PRIs64
|
||||
#define SDL_PRIs64 PRIs64
|
||||
#elif defined(__WIN32__)
|
||||
#define SDL_PRIs64 "I64"
|
||||
#define SDL_PRIs64 "I64d"
|
||||
#elif defined(__LINUX__) && defined(__LP64__)
|
||||
#define SDL_PRIs64 "ld"
|
||||
#else
|
||||
#define SDL_PRIs64 "lld"
|
||||
#endif
|
||||
@@ -182,10 +184,34 @@ typedef uint64_t Uint64;
|
||||
#define SDL_PRIu64 PRIu64
|
||||
#elif defined(__WIN32__)
|
||||
#define SDL_PRIu64 "I64u"
|
||||
#elif defined(__LINUX__) && defined(__LP64__)
|
||||
#define SDL_PRIu64 "lu"
|
||||
#else
|
||||
#define SDL_PRIu64 "llu"
|
||||
#endif
|
||||
#endif
|
||||
#ifndef SDL_PRIx64
|
||||
#ifdef PRIx64
|
||||
#define SDL_PRIx64 PRIx64
|
||||
#elif defined(__WIN32__)
|
||||
#define SDL_PRIx64 "I64x"
|
||||
#elif defined(__LINUX__) && defined(__LP64__)
|
||||
#define SDL_PRIx64 "lx"
|
||||
#else
|
||||
#define SDL_PRIx64 "llx"
|
||||
#endif
|
||||
#endif
|
||||
#ifndef SDL_PRIX64
|
||||
#ifdef PRIX64
|
||||
#define SDL_PRIX64 PRIX64
|
||||
#elif defined(__WIN32__)
|
||||
#define SDL_PRIX64 "I64X"
|
||||
#elif defined(__LINUX__) && defined(__LP64__)
|
||||
#define SDL_PRIX64 "lX"
|
||||
#else
|
||||
#define SDL_PRIX64 "llX"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Annotations to help code analysis tools */
|
||||
#ifdef SDL_DISABLE_ANALYZE_MACROS
|
||||
@@ -200,7 +226,7 @@ typedef uint64_t Uint64;
|
||||
#define SDL_PRINTF_VARARG_FUNC( fmtargnumber )
|
||||
#define SDL_SCANF_VARARG_FUNC( fmtargnumber )
|
||||
#else
|
||||
#if _MSC_VER >= 1600 /* VS 2010 and above */
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1600) /* VS 2010 and above */
|
||||
#include <sal.h>
|
||||
|
||||
#define SDL_IN_BYTECAP(x) _In_bytecount_(x)
|
||||
@@ -361,11 +387,6 @@ SDL_FORCE_INLINE void SDL_memset4(void *dst, Uint32 val, size_t dwords)
|
||||
|
||||
extern DECLSPEC void *SDLCALL SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len);
|
||||
|
||||
SDL_FORCE_INLINE void *SDL_memcpy4(SDL_OUT_BYTECAP(dwords*4) void *dst, SDL_IN_BYTECAP(dwords*4) const void *src, size_t dwords)
|
||||
{
|
||||
return SDL_memcpy(dst, src, dwords * 4);
|
||||
}
|
||||
|
||||
extern DECLSPEC void *SDLCALL SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len);
|
||||
extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len);
|
||||
|
||||
@@ -462,6 +483,39 @@ extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode,
|
||||
#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", S, SDL_strlen(S)+1)
|
||||
#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4-INTERNAL", "UTF-8", S, SDL_strlen(S)+1)
|
||||
|
||||
/* force builds using Clang's static analysis tools to use literal C runtime
|
||||
here, since there are possibly tests that are ineffective otherwise. */
|
||||
#if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS)
|
||||
#define SDL_malloc malloc
|
||||
#define SDL_calloc calloc
|
||||
#define SDL_realloc realloc
|
||||
#define SDL_free free
|
||||
#define SDL_memset memset
|
||||
#define SDL_memcpy memcpy
|
||||
#define SDL_memmove memmove
|
||||
#define SDL_memcmp memcmp
|
||||
#define SDL_strlen strlen
|
||||
#define SDL_strlcpy strlcpy
|
||||
#define SDL_strlcat strlcat
|
||||
#define SDL_strdup strdup
|
||||
#define SDL_strchr strchr
|
||||
#define SDL_strrchr strrchr
|
||||
#define SDL_strstr strstr
|
||||
#define SDL_strcmp strcmp
|
||||
#define SDL_strncmp strncmp
|
||||
#define SDL_strcasecmp strcasecmp
|
||||
#define SDL_strncasecmp strncasecmp
|
||||
#define SDL_sscanf sscanf
|
||||
#define SDL_vsscanf vsscanf
|
||||
#define SDL_snprintf snprintf
|
||||
#define SDL_vsnprintf vsnprintf
|
||||
#endif
|
||||
|
||||
SDL_FORCE_INLINE void *SDL_memcpy4(SDL_OUT_BYTECAP(dwords*4) void *dst, SDL_IN_BYTECAP(dwords*4) const void *src, size_t dwords)
|
||||
{
|
||||
return SDL_memcpy(dst, src, dwords * 4);
|
||||
}
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+32
-12
@@ -43,19 +43,25 @@ extern "C" {
|
||||
/* Platform specific functions for Windows */
|
||||
#ifdef __WIN32__
|
||||
|
||||
/* Returns the D3D9 adapter index that matches the specified display index.
|
||||
/**
|
||||
\brief Returns the D3D9 adapter index that matches the specified display index.
|
||||
|
||||
This adapter index can be passed to IDirect3D9::CreateDevice and controls
|
||||
on which monitor a full screen application will appear.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex( int displayIndex );
|
||||
|
||||
/* Returns the D3D device associated with a renderer, or NULL if it's not a D3D renderer.
|
||||
typedef struct IDirect3DDevice9 IDirect3DDevice9;
|
||||
/**
|
||||
\brief Returns the D3D device associated with a renderer, or NULL if it's not a D3D renderer.
|
||||
|
||||
Once you are done using the device, you should release it to avoid a resource leak.
|
||||
*/
|
||||
typedef struct IDirect3DDevice9 IDirect3DDevice9;
|
||||
extern DECLSPEC IDirect3DDevice9* SDLCALL SDL_RenderGetD3D9Device(SDL_Renderer * renderer);
|
||||
|
||||
/* Returns the DXGI Adapter and Output indices for the specified display index.
|
||||
/**
|
||||
\brief Returns the DXGI Adapter and Output indices for the specified display index.
|
||||
|
||||
These can be passed to EnumAdapters and EnumOutputs respectively to get the objects
|
||||
required to create a DX10 or DX11 device and swap chain.
|
||||
*/
|
||||
@@ -67,7 +73,10 @@ extern DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo( int displayIndex, int *a
|
||||
/* Platform specific functions for iOS */
|
||||
#if defined(__IPHONEOS__) && __IPHONEOS__
|
||||
|
||||
#define SDL_iOSSetAnimationCallback(window, interval, callback, callbackParam) SDL_iPhoneSetAnimationCallback(window, interval, callback, callbackParam)
|
||||
extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
|
||||
|
||||
#define SDL_iOSSetEventPump(enabled) SDL_iPhoneSetEventPump(enabled)
|
||||
extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled);
|
||||
|
||||
#endif /* __IPHONEOS__ */
|
||||
@@ -76,12 +85,16 @@ extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled);
|
||||
/* Platform specific functions for Android */
|
||||
#if defined(__ANDROID__) && __ANDROID__
|
||||
|
||||
/* Get the JNI environment for the current thread
|
||||
/**
|
||||
\brief Get the JNI environment for the current thread
|
||||
|
||||
This returns JNIEnv*, but the prototype is void* so we don't need jni.h
|
||||
*/
|
||||
extern DECLSPEC void * SDLCALL SDL_AndroidGetJNIEnv();
|
||||
|
||||
/* Get the SDL Activity object for the application
|
||||
/**
|
||||
\brief Get the SDL Activity object for the application
|
||||
|
||||
This returns jobject, but the prototype is void* so we don't need jni.h
|
||||
The jobject returned by SDL_AndroidGetActivity is a local reference.
|
||||
It is the caller's responsibility to properly release it
|
||||
@@ -89,26 +102,33 @@ extern DECLSPEC void * SDLCALL SDL_AndroidGetJNIEnv();
|
||||
*/
|
||||
extern DECLSPEC void * SDLCALL SDL_AndroidGetActivity();
|
||||
|
||||
/* See the official Android developer guide for more information:
|
||||
/**
|
||||
See the official Android developer guide for more information:
|
||||
http://developer.android.com/guide/topics/data/data-storage.html
|
||||
*/
|
||||
#define SDL_ANDROID_EXTERNAL_STORAGE_READ 0x01
|
||||
#define SDL_ANDROID_EXTERNAL_STORAGE_WRITE 0x02
|
||||
|
||||
/* Get the path used for internal storage for this application.
|
||||
/**
|
||||
\brief Get the path used for internal storage for this application.
|
||||
|
||||
This path is unique to your application and cannot be written to
|
||||
by other applications.
|
||||
*/
|
||||
extern DECLSPEC const char * SDLCALL SDL_AndroidGetInternalStoragePath();
|
||||
|
||||
/* Get the current state of external storage, a bitmask of these values:
|
||||
/**
|
||||
\brief Get the current state of external storage, a bitmask of these values:
|
||||
SDL_ANDROID_EXTERNAL_STORAGE_READ
|
||||
SDL_ANDROID_EXTERNAL_STORAGE_WRITE
|
||||
|
||||
If external storage is currently unavailable, this will return 0.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_AndroidGetExternalStorageState();
|
||||
|
||||
/* Get the path used for external storage for this application.
|
||||
/**
|
||||
\brief Get the path used for external storage for this application.
|
||||
|
||||
This path is unique to your application, but is public and can be
|
||||
written to by other applications.
|
||||
*/
|
||||
@@ -151,7 +171,7 @@ typedef enum
|
||||
* http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
|
||||
*
|
||||
* \param pathType The type of path to retrieve.
|
||||
* \ret A UCS-2 string (16-bit, wide-char) containing the path, or NULL
|
||||
* \return A UCS-2 string (16-bit, wide-char) containing the path, or NULL
|
||||
* if the path is not available for any reason. Not all paths are
|
||||
* available on all versions of Windows. This is especially true on
|
||||
* Windows Phone. Check the documentation for the given
|
||||
@@ -168,7 +188,7 @@ extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path
|
||||
* http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
|
||||
*
|
||||
* \param pathType The type of path to retrieve.
|
||||
* \ret A UTF-8 string (8-bit, multi-byte) containing the path, or NULL
|
||||
* \return A UTF-8 string (8-bit, multi-byte) containing the path, or NULL
|
||||
* if the path is not available for any reason. Not all paths are
|
||||
* available on all versions of Windows. This is especially true on
|
||||
* Windows Phone. Check the documentation for the given
|
||||
|
||||
@@ -98,6 +98,7 @@ typedef struct _NSWindow NSWindow;
|
||||
typedef struct _UIWindow UIWindow;
|
||||
typedef struct _UIViewController UIViewController;
|
||||
#endif
|
||||
typedef Uint32 GLuint;
|
||||
#endif
|
||||
|
||||
#if defined(SDL_VIDEO_DRIVER_ANDROID)
|
||||
@@ -186,6 +187,7 @@ struct SDL_SysWMinfo
|
||||
struct
|
||||
{
|
||||
HWND window; /**< The window handle */
|
||||
HDC hdc; /**< The window device context */
|
||||
} win;
|
||||
#endif
|
||||
#if defined(SDL_VIDEO_DRIVER_WINRT)
|
||||
@@ -227,6 +229,8 @@ struct SDL_SysWMinfo
|
||||
#else
|
||||
UIWindow *window; /* The UIKit window */
|
||||
#endif
|
||||
GLuint framebuffer; /* The GL view's Framebuffer Object. It must be bound when rendering to the screen using GL. */
|
||||
GLuint colorbuffer; /* The GL view's color Renderbuffer Object. It must be bound when SDL_GL_SwapWindow is called. */
|
||||
} uikit;
|
||||
#endif
|
||||
#if defined(SDL_VIDEO_DRIVER_WAYLAND)
|
||||
|
||||
+20
-1
@@ -189,7 +189,8 @@ typedef enum
|
||||
SDL_GL_CONTEXT_FLAGS,
|
||||
SDL_GL_CONTEXT_PROFILE_MASK,
|
||||
SDL_GL_SHARE_WITH_CURRENT_CONTEXT,
|
||||
SDL_GL_FRAMEBUFFER_SRGB_CAPABLE
|
||||
SDL_GL_FRAMEBUFFER_SRGB_CAPABLE,
|
||||
SDL_GL_CONTEXT_RELEASE_BEHAVIOR
|
||||
} SDL_GLattr;
|
||||
|
||||
typedef enum
|
||||
@@ -207,6 +208,12 @@ typedef enum
|
||||
SDL_GL_CONTEXT_RESET_ISOLATION_FLAG = 0x0008
|
||||
} SDL_GLcontextFlag;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE = 0x0000,
|
||||
SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH = 0x0001
|
||||
} SDL_GLcontextReleaseFlag;
|
||||
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
@@ -715,6 +722,9 @@ extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window * window,
|
||||
* \param window The window for which the input grab mode should be set.
|
||||
* \param grabbed This is SDL_TRUE to grab input, and SDL_FALSE to release input.
|
||||
*
|
||||
* If the caller enables a grab while another window is currently grabbed,
|
||||
* the other window loses its grab in favor of the caller's window.
|
||||
*
|
||||
* \sa SDL_GetWindowGrab()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window * window,
|
||||
@@ -729,6 +739,15 @@ extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window * window,
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowGrab(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Get the window that currently has an input grab enabled.
|
||||
*
|
||||
* \return This returns the window if input is grabbed, and NULL otherwise.
|
||||
*
|
||||
* \sa SDL_SetWindowGrab()
|
||||
*/
|
||||
extern DECLSPEC SDL_Window * SDLCALL SDL_GetGrabbedWindow(void);
|
||||
|
||||
/**
|
||||
* \brief Set the brightness (gamma correction) for a window.
|
||||
*
|
||||
|
||||
@@ -126,6 +126,9 @@
|
||||
#ifndef SDL_IPHONE_KEYBOARD
|
||||
#define SDL_IPHONE_KEYBOARD 1
|
||||
#endif
|
||||
#ifndef SDL_IPHONE_LAUNCHSCREEN
|
||||
#define SDL_IPHONE_LAUNCHSCREEN 1
|
||||
#endif
|
||||
#ifndef SDL_POWER_UIKIT
|
||||
#define SDL_POWER_UIKIT 1
|
||||
#endif
|
||||
|
||||
@@ -405,6 +405,8 @@ SDL_GetPlatform()
|
||||
return "BSDI";
|
||||
#elif __DREAMCAST__
|
||||
return "Dreamcast";
|
||||
#elif __EMSCRIPTEN__
|
||||
return "Emscripten";
|
||||
#elif __FREEBSD__
|
||||
return "FreeBSD";
|
||||
#elif __HAIKU__
|
||||
|
||||
+27
-9
@@ -120,7 +120,7 @@ SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||
so that it supports internationalization and thread-safe errors.
|
||||
*/
|
||||
static char *
|
||||
SDL_GetErrorMsg(char *errstr, unsigned int maxlen)
|
||||
SDL_GetErrorMsg(char *errstr, int maxlen)
|
||||
{
|
||||
SDL_error *error;
|
||||
|
||||
@@ -163,37 +163,55 @@ SDL_GetErrorMsg(char *errstr, unsigned int maxlen)
|
||||
len =
|
||||
SDL_snprintf(msg, maxlen, tmp,
|
||||
error->args[argi++].value_i);
|
||||
msg += len;
|
||||
maxlen -= len;
|
||||
if (len > 0) {
|
||||
msg += len;
|
||||
maxlen -= len;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
len =
|
||||
SDL_snprintf(msg, maxlen, tmp,
|
||||
error->args[argi++].value_f);
|
||||
msg += len;
|
||||
maxlen -= len;
|
||||
if (len > 0) {
|
||||
msg += len;
|
||||
maxlen -= len;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
len =
|
||||
SDL_snprintf(msg, maxlen, tmp,
|
||||
error->args[argi++].value_ptr);
|
||||
msg += len;
|
||||
maxlen -= len;
|
||||
if (len > 0) {
|
||||
msg += len;
|
||||
maxlen -= len;
|
||||
}
|
||||
break;
|
||||
|
||||
case 's':
|
||||
len =
|
||||
SDL_snprintf(msg, maxlen, tmp,
|
||||
SDL_LookupString(error->args[argi++].
|
||||
buf));
|
||||
msg += len;
|
||||
maxlen -= len;
|
||||
if (len > 0) {
|
||||
msg += len;
|
||||
maxlen -= len;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
} else {
|
||||
*msg++ = *fmt++;
|
||||
maxlen -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* slide back if we've overshot the end of our buffer. */
|
||||
if (maxlen < 0) {
|
||||
msg -= (-maxlen) + 1;
|
||||
}
|
||||
|
||||
*msg = 0; /* NULL terminate the string */
|
||||
}
|
||||
return (errstr);
|
||||
|
||||
+321
-388
File diff suppressed because it is too large
Load Diff
+22
-12
@@ -46,18 +46,21 @@
|
||||
#define _PATH_DEV_AUDIO "/dev/audio"
|
||||
#endif
|
||||
|
||||
static SDL_INLINE void
|
||||
test_device(const char *fname, int flags, int (*test) (int fd),
|
||||
SDL_AddAudioDevice addfn)
|
||||
static void
|
||||
test_device(const int iscapture, const char *fname, int flags, int (*test) (int fd))
|
||||
{
|
||||
struct stat sb;
|
||||
if ((stat(fname, &sb) == 0) && (S_ISCHR(sb.st_mode))) {
|
||||
const int audio_fd = open(fname, flags, 0);
|
||||
if (audio_fd >= 0) {
|
||||
if (test(audio_fd)) {
|
||||
addfn(fname);
|
||||
}
|
||||
const int okay = test(audio_fd);
|
||||
close(audio_fd);
|
||||
if (okay) {
|
||||
static size_t dummyhandle = 0;
|
||||
dummyhandle++;
|
||||
SDL_assert(dummyhandle != 0);
|
||||
SDL_AddAudioDevice(iscapture, fname, (void *) dummyhandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,11 +71,10 @@ test_stub(int fd)
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_EnumUnixAudioDevices(int iscapture, int classic, int (*test)(int fd),
|
||||
SDL_AddAudioDevice addfn)
|
||||
static void
|
||||
SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int classic, int (*test)(int))
|
||||
{
|
||||
const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT);
|
||||
const int flags = iscapture ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT;
|
||||
const char *audiodev;
|
||||
char audiopath[1024];
|
||||
|
||||
@@ -97,17 +99,25 @@ SDL_EnumUnixAudioDevices(int iscapture, int classic, int (*test)(int fd),
|
||||
}
|
||||
}
|
||||
}
|
||||
test_device(audiodev, flags, test, addfn);
|
||||
test_device(iscapture, audiodev, flags, test);
|
||||
|
||||
if (SDL_strlen(audiodev) < (sizeof(audiopath) - 3)) {
|
||||
int instance = 0;
|
||||
while (instance++ <= 64) {
|
||||
SDL_snprintf(audiopath, SDL_arraysize(audiopath),
|
||||
"%s%d", audiodev, instance);
|
||||
test_device(audiopath, flags, test, addfn);
|
||||
test_device(iscapture, audiopath, flags, test);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_EnumUnixAudioDevices(const int classic, int (*test)(int))
|
||||
{
|
||||
SDL_EnumUnixAudioDevices_Internal(SDL_TRUE, classic, test);
|
||||
SDL_EnumUnixAudioDevices_Internal(SDL_FALSE, classic, test);
|
||||
}
|
||||
|
||||
#endif /* Audio driver selection */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#define OPEN_FLAGS_INPUT (O_RDONLY|O_NONBLOCK)
|
||||
#endif
|
||||
|
||||
void SDL_EnumUnixAudioDevices(int iscapture, int classic,
|
||||
int (*test) (int fd), SDL_AddAudioDevice addfn);
|
||||
extern void SDL_EnumUnixAudioDevices(const int classic, int (*test)(int));
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -30,8 +30,21 @@
|
||||
typedef struct SDL_AudioDevice SDL_AudioDevice;
|
||||
#define _THIS SDL_AudioDevice *_this
|
||||
|
||||
/* Used by audio targets during DetectDevices() */
|
||||
typedef void (*SDL_AddAudioDevice)(const char *name);
|
||||
/* Audio targets should call this as devices are added to the system (such as
|
||||
a USB headset being plugged in), and should also be called for
|
||||
for every device found during DetectDevices(). */
|
||||
extern void SDL_AddAudioDevice(const int iscapture, const char *name, void *handle);
|
||||
|
||||
/* Audio targets should call this as devices are removed, so SDL can update
|
||||
its list of available devices. */
|
||||
extern void SDL_RemoveAudioDevice(const int iscapture, void *handle);
|
||||
|
||||
/* Audio targets should call this if an opened audio device is lost while
|
||||
being used. This can happen due to i/o errors, or a device being unplugged,
|
||||
etc. If the device is totally gone, please also call SDL_RemoveAudioDevice()
|
||||
as appropriate so SDL's list of devices is accurate. */
|
||||
extern void SDL_OpenedAudioDeviceDisconnected(SDL_AudioDevice *device);
|
||||
|
||||
|
||||
/* This is the size of a packet when using SDL_QueueAudio(). We allocate
|
||||
these as necessary and pool them, under the assumption that we'll
|
||||
@@ -55,8 +68,8 @@ typedef struct SDL_AudioBufferQueue
|
||||
|
||||
typedef struct SDL_AudioDriverImpl
|
||||
{
|
||||
void (*DetectDevices) (int iscapture, SDL_AddAudioDevice addfn);
|
||||
int (*OpenDevice) (_THIS, const char *devname, int iscapture);
|
||||
void (*DetectDevices) (void);
|
||||
int (*OpenDevice) (_THIS, void *handle, const char *devname, int iscapture);
|
||||
void (*ThreadInit) (_THIS); /* Called by audio thread at start */
|
||||
void (*WaitDevice) (_THIS);
|
||||
void (*PlayDevice) (_THIS);
|
||||
@@ -66,19 +79,34 @@ typedef struct SDL_AudioDriverImpl
|
||||
void (*CloseDevice) (_THIS);
|
||||
void (*LockDevice) (_THIS);
|
||||
void (*UnlockDevice) (_THIS);
|
||||
void (*FreeDeviceHandle) (void *handle); /**< SDL is done with handle from SDL_AddAudioDevice() */
|
||||
void (*Deinitialize) (void);
|
||||
|
||||
/* !!! FIXME: add pause(), so we can optimize instead of mixing silence. */
|
||||
|
||||
/* Some flags to push duplicate code into the core and reduce #ifdefs. */
|
||||
/* !!! FIXME: these should be SDL_bool */
|
||||
int ProvidesOwnCallbackThread;
|
||||
int SkipMixerLock; /* !!! FIXME: do we need this anymore? */
|
||||
int HasCaptureSupport;
|
||||
int OnlyHasDefaultOutputDevice;
|
||||
int OnlyHasDefaultInputDevice;
|
||||
int AllowsArbitraryDeviceNames;
|
||||
} SDL_AudioDriverImpl;
|
||||
|
||||
|
||||
typedef struct SDL_AudioDeviceItem
|
||||
{
|
||||
void *handle;
|
||||
struct SDL_AudioDeviceItem *next;
|
||||
#if (defined(__GNUC__) && (__GNUC__ <= 2))
|
||||
char name[1]; /* actually variable length. */
|
||||
#else
|
||||
char name[];
|
||||
#endif
|
||||
} SDL_AudioDeviceItem;
|
||||
|
||||
|
||||
typedef struct SDL_AudioDriver
|
||||
{
|
||||
/* * * */
|
||||
@@ -91,11 +119,14 @@ typedef struct SDL_AudioDriver
|
||||
|
||||
SDL_AudioDriverImpl impl;
|
||||
|
||||
char **outputDevices;
|
||||
/* A mutex for device detection */
|
||||
SDL_mutex *detectionLock;
|
||||
SDL_bool captureDevicesRemoved;
|
||||
SDL_bool outputDevicesRemoved;
|
||||
int outputDeviceCount;
|
||||
|
||||
char **inputDevices;
|
||||
int inputDeviceCount;
|
||||
SDL_AudioDeviceItem *outputDevices;
|
||||
SDL_AudioDeviceItem *inputDevices;
|
||||
} SDL_AudioDriver;
|
||||
|
||||
|
||||
@@ -113,6 +144,7 @@ struct SDL_AudioDevice
|
||||
{
|
||||
/* * * */
|
||||
/* Data common to all devices */
|
||||
SDL_AudioDeviceID id;
|
||||
|
||||
/* The current audio specification (shared with audio thread) */
|
||||
SDL_AudioSpec spec;
|
||||
@@ -125,15 +157,17 @@ struct SDL_AudioDevice
|
||||
SDL_AudioStreamer streamer;
|
||||
|
||||
/* Current state flags */
|
||||
/* !!! FIXME: should be SDL_bool */
|
||||
int iscapture;
|
||||
int enabled;
|
||||
int enabled; /* true if device is functioning and connected. */
|
||||
int shutdown; /* true if we are signaling the play thread to end. */
|
||||
int paused;
|
||||
int opened;
|
||||
|
||||
/* Fake audio buffer for when the audio hardware is busy */
|
||||
Uint8 *fake_stream;
|
||||
|
||||
/* A semaphore for locking the mixing buffers */
|
||||
/* A mutex for locking the mixing buffers */
|
||||
SDL_mutex *mixer_lock;
|
||||
|
||||
/* A thread to feed the audio device */
|
||||
|
||||
@@ -320,7 +320,7 @@ ALSA_PlayDevice(_THIS)
|
||||
/* Hmm, not much we can do - abort */
|
||||
fprintf(stderr, "ALSA write failed (unrecoverable): %s\n",
|
||||
ALSA_snd_strerror(status));
|
||||
this->enabled = 0;
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
@@ -465,7 +465,7 @@ ALSA_set_buffer_size(_THIS, snd_pcm_hw_params_t *params, int override)
|
||||
}
|
||||
|
||||
static int
|
||||
ALSA_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
ALSA_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
int status = 0;
|
||||
snd_pcm_t *pcm_handle = NULL;
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
static SDL_AudioDevice* audioDevice = NULL;
|
||||
|
||||
static int
|
||||
AndroidAUD_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
AndroidAUD_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
SDL_AudioFormat test_format;
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ ARTS_WaitDevice(_THIS)
|
||||
/* Check every 10 loops */
|
||||
if (this->hidden->parent && (((++cnt) % 10) == 0)) {
|
||||
if (kill(this->hidden->parent, 0) < 0 && errno == ESRCH) {
|
||||
this->enabled = 0;
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,7 +179,7 @@ ARTS_PlayDevice(_THIS)
|
||||
|
||||
/* If we couldn't write, assume fatal error for now */
|
||||
if (written < 0) {
|
||||
this->enabled = 0;
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
}
|
||||
#ifdef DEBUG_AUDIO
|
||||
fprintf(stderr, "Wrote %d bytes of audio data\n", written);
|
||||
@@ -229,7 +229,7 @@ ARTS_Suspend(void)
|
||||
}
|
||||
|
||||
static int
|
||||
ARTS_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
ARTS_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
int rc = 0;
|
||||
int bits = 0, frag_spec = 0;
|
||||
|
||||
@@ -51,9 +51,9 @@
|
||||
|
||||
|
||||
static void
|
||||
BSDAUDIO_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
|
||||
BSDAUDIO_DetectDevices(void)
|
||||
{
|
||||
SDL_EnumUnixAudioDevices(iscapture, 0, NULL, addfn);
|
||||
SDL_EnumUnixAudioDevices(0, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ BSDAUDIO_WaitDevice(_THIS)
|
||||
the user know what happened.
|
||||
*/
|
||||
fprintf(stderr, "SDL: %s\n", message);
|
||||
this->enabled = 0;
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
/* Don't try to close - may hang */
|
||||
this->hidden->audio_fd = -1;
|
||||
#ifdef DEBUG_AUDIO
|
||||
@@ -195,7 +195,7 @@ BSDAUDIO_PlayDevice(_THIS)
|
||||
|
||||
/* If we couldn't write, assume fatal error for now */
|
||||
if (written < 0) {
|
||||
this->enabled = 0;
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
}
|
||||
#ifdef DEBUG_AUDIO
|
||||
fprintf(stderr, "Wrote %d bytes of audio data\n", written);
|
||||
@@ -224,7 +224,7 @@ BSDAUDIO_CloseDevice(_THIS)
|
||||
}
|
||||
|
||||
static int
|
||||
BSDAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
BSDAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT);
|
||||
SDL_AudioFormat format = 0;
|
||||
@@ -348,6 +348,8 @@ BSDAUDIO_Init(SDL_AudioDriverImpl * impl)
|
||||
impl->GetDeviceBuf = BSDAUDIO_GetDeviceBuf;
|
||||
impl->CloseDevice = BSDAUDIO_CloseDevice;
|
||||
|
||||
impl->AllowsArbitraryDeviceNames = 1;
|
||||
|
||||
return 1; /* this audio target is available. */
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_AUDIO_DRIVER_COREAUDIO
|
||||
|
||||
#include "SDL_audio.h"
|
||||
#include "../SDL_audio_c.h"
|
||||
#include "../SDL_sysaudio.h"
|
||||
@@ -37,31 +40,48 @@ static void COREAUDIO_CloseDevice(_THIS);
|
||||
}
|
||||
|
||||
#if MACOSX_COREAUDIO
|
||||
typedef void (*addDevFn)(const char *name, AudioDeviceID devId, void *data);
|
||||
static const AudioObjectPropertyAddress devlist_address = {
|
||||
kAudioHardwarePropertyDevices,
|
||||
kAudioObjectPropertyScopeGlobal,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
static void
|
||||
addToDevList(const char *name, AudioDeviceID devId, void *data)
|
||||
typedef void (*addDevFn)(const char *name, const int iscapture, AudioDeviceID devId, void *data);
|
||||
|
||||
typedef struct AudioDeviceList
|
||||
{
|
||||
SDL_AddAudioDevice addfn = (SDL_AddAudioDevice) data;
|
||||
addfn(name);
|
||||
AudioDeviceID devid;
|
||||
SDL_bool alive;
|
||||
struct AudioDeviceList *next;
|
||||
} AudioDeviceList;
|
||||
|
||||
static AudioDeviceList *output_devs = NULL;
|
||||
static AudioDeviceList *capture_devs = NULL;
|
||||
|
||||
static SDL_bool
|
||||
add_to_internal_dev_list(const int iscapture, AudioDeviceID devId)
|
||||
{
|
||||
AudioDeviceList *item = (AudioDeviceList *) SDL_malloc(sizeof (AudioDeviceList));
|
||||
if (item == NULL) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
item->devid = devId;
|
||||
item->alive = SDL_TRUE;
|
||||
item->next = iscapture ? capture_devs : output_devs;
|
||||
if (iscapture) {
|
||||
capture_devs = item;
|
||||
} else {
|
||||
output_devs = item;
|
||||
}
|
||||
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *findname;
|
||||
AudioDeviceID devId;
|
||||
int found;
|
||||
} FindDevIdData;
|
||||
|
||||
static void
|
||||
findDevId(const char *name, AudioDeviceID devId, void *_data)
|
||||
addToDevList(const char *name, const int iscapture, AudioDeviceID devId, void *data)
|
||||
{
|
||||
FindDevIdData *data = (FindDevIdData *) _data;
|
||||
if (!data->found) {
|
||||
if (SDL_strcmp(name, data->findname) == 0) {
|
||||
data->found = 1;
|
||||
data->devId = devId;
|
||||
}
|
||||
if (add_to_internal_dev_list(iscapture, devId)) {
|
||||
SDL_AddAudioDevice(iscapture, name, (void *) ((size_t) devId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,14 +94,8 @@ build_device_list(int iscapture, addDevFn addfn, void *addfndata)
|
||||
UInt32 i = 0;
|
||||
UInt32 max = 0;
|
||||
|
||||
AudioObjectPropertyAddress addr = {
|
||||
kAudioHardwarePropertyDevices,
|
||||
kAudioObjectPropertyScopeGlobal,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
result = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &addr,
|
||||
0, NULL, &size);
|
||||
result = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject,
|
||||
&devlist_address, 0, NULL, &size);
|
||||
if (result != kAudioHardwareNoError)
|
||||
return;
|
||||
|
||||
@@ -89,8 +103,8 @@ build_device_list(int iscapture, addDevFn addfn, void *addfndata)
|
||||
if (devs == NULL)
|
||||
return;
|
||||
|
||||
result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr,
|
||||
0, NULL, &size, devs);
|
||||
result = AudioObjectGetPropertyData(kAudioObjectSystemObject,
|
||||
&devlist_address, 0, NULL, &size, devs);
|
||||
if (result != kAudioHardwareNoError)
|
||||
return;
|
||||
|
||||
@@ -102,10 +116,17 @@ build_device_list(int iscapture, addDevFn addfn, void *addfndata)
|
||||
AudioBufferList *buflist = NULL;
|
||||
int usable = 0;
|
||||
CFIndex len = 0;
|
||||
const AudioObjectPropertyAddress addr = {
|
||||
kAudioDevicePropertyStreamConfiguration,
|
||||
iscapture ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
addr.mScope = iscapture ? kAudioDevicePropertyScopeInput :
|
||||
kAudioDevicePropertyScopeOutput;
|
||||
addr.mSelector = kAudioDevicePropertyStreamConfiguration;
|
||||
const AudioObjectPropertyAddress nameaddr = {
|
||||
kAudioObjectPropertyName,
|
||||
iscapture ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
result = AudioObjectGetPropertyDataSize(dev, &addr, 0, NULL, &size);
|
||||
if (result != noErr)
|
||||
@@ -133,9 +154,9 @@ build_device_list(int iscapture, addDevFn addfn, void *addfndata)
|
||||
if (!usable)
|
||||
continue;
|
||||
|
||||
addr.mSelector = kAudioObjectPropertyName;
|
||||
|
||||
size = sizeof (CFStringRef);
|
||||
result = AudioObjectGetPropertyData(dev, &addr, 0, NULL, &size, &cfstr);
|
||||
result = AudioObjectGetPropertyData(dev, &nameaddr, 0, NULL, &size, &cfstr);
|
||||
if (result != kAudioHardwareNoError)
|
||||
continue;
|
||||
|
||||
@@ -166,79 +187,84 @@ build_device_list(int iscapture, addDevFn addfn, void *addfndata)
|
||||
((iscapture) ? "capture" : "output"),
|
||||
(int) *devCount, ptr, (int) dev);
|
||||
#endif
|
||||
addfn(ptr, dev, addfndata);
|
||||
addfn(ptr, iscapture, dev, addfndata);
|
||||
}
|
||||
SDL_free(ptr); /* addfn() would have copied the string. */
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
COREAUDIO_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
|
||||
free_audio_device_list(AudioDeviceList **list)
|
||||
{
|
||||
build_device_list(iscapture, addToDevList, addfn);
|
||||
AudioDeviceList *item = *list;
|
||||
while (item) {
|
||||
AudioDeviceList *next = item->next;
|
||||
SDL_free(item);
|
||||
item = next;
|
||||
}
|
||||
*list = NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
find_device_by_name(_THIS, const char *devname, int iscapture)
|
||||
static void
|
||||
COREAUDIO_DetectDevices(void)
|
||||
{
|
||||
AudioDeviceID devid = 0;
|
||||
OSStatus result = noErr;
|
||||
UInt32 size = 0;
|
||||
UInt32 alive = 0;
|
||||
pid_t pid = 0;
|
||||
build_device_list(SDL_TRUE, addToDevList, NULL);
|
||||
build_device_list(SDL_FALSE, addToDevList, NULL);
|
||||
}
|
||||
|
||||
AudioObjectPropertyAddress addr = {
|
||||
0,
|
||||
kAudioObjectPropertyScopeGlobal,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
if (devname == NULL) {
|
||||
size = sizeof (AudioDeviceID);
|
||||
addr.mSelector =
|
||||
((iscapture) ? kAudioHardwarePropertyDefaultInputDevice :
|
||||
kAudioHardwarePropertyDefaultOutputDevice);
|
||||
result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr,
|
||||
0, NULL, &size, &devid);
|
||||
CHECK_RESULT("AudioHardwareGetProperty (default device)");
|
||||
} else {
|
||||
FindDevIdData data;
|
||||
SDL_zero(data);
|
||||
data.findname = devname;
|
||||
build_device_list(iscapture, findDevId, &data);
|
||||
if (!data.found) {
|
||||
SDL_SetError("CoreAudio: No such audio device.");
|
||||
return 0;
|
||||
static void
|
||||
build_device_change_list(const char *name, const int iscapture, AudioDeviceID devId, void *data)
|
||||
{
|
||||
AudioDeviceList **list = (AudioDeviceList **) data;
|
||||
AudioDeviceList *item;
|
||||
for (item = *list; item != NULL; item = item->next) {
|
||||
if (item->devid == devId) {
|
||||
item->alive = SDL_TRUE;
|
||||
return;
|
||||
}
|
||||
devid = data.devId;
|
||||
}
|
||||
|
||||
addr.mSelector = kAudioDevicePropertyDeviceIsAlive;
|
||||
addr.mScope = iscapture ? kAudioDevicePropertyScopeInput :
|
||||
kAudioDevicePropertyScopeOutput;
|
||||
add_to_internal_dev_list(iscapture, devId); /* new device, add it. */
|
||||
SDL_AddAudioDevice(iscapture, name, (void *) ((size_t) devId));
|
||||
}
|
||||
|
||||
size = sizeof (alive);
|
||||
result = AudioObjectGetPropertyData(devid, &addr, 0, NULL, &size, &alive);
|
||||
CHECK_RESULT
|
||||
("AudioDeviceGetProperty (kAudioDevicePropertyDeviceIsAlive)");
|
||||
|
||||
if (!alive) {
|
||||
SDL_SetError("CoreAudio: requested device exists, but isn't alive.");
|
||||
return 0;
|
||||
static void
|
||||
reprocess_device_list(const int iscapture, AudioDeviceList **list)
|
||||
{
|
||||
AudioDeviceList *item;
|
||||
AudioDeviceList *prev = NULL;
|
||||
for (item = *list; item != NULL; item = item->next) {
|
||||
item->alive = SDL_FALSE;
|
||||
}
|
||||
|
||||
addr.mSelector = kAudioDevicePropertyHogMode;
|
||||
size = sizeof (pid);
|
||||
result = AudioObjectGetPropertyData(devid, &addr, 0, NULL, &size, &pid);
|
||||
build_device_list(iscapture, build_device_change_list, list);
|
||||
|
||||
/* some devices don't support this property, so errors are fine here. */
|
||||
if ((result == noErr) && (pid != -1)) {
|
||||
SDL_SetError("CoreAudio: requested device is being hogged.");
|
||||
return 0;
|
||||
/* free items in the list that aren't still alive. */
|
||||
item = *list;
|
||||
while (item != NULL) {
|
||||
AudioDeviceList *next = item->next;
|
||||
if (item->alive) {
|
||||
prev = item;
|
||||
} else {
|
||||
SDL_RemoveAudioDevice(iscapture, (void *) ((size_t) item->devid));
|
||||
if (prev) {
|
||||
prev->next = item->next;
|
||||
} else {
|
||||
*list = item->next;
|
||||
}
|
||||
SDL_free(item);
|
||||
}
|
||||
item = next;
|
||||
}
|
||||
}
|
||||
|
||||
this->hidden->deviceID = devid;
|
||||
return 1;
|
||||
/* this is called when the system's list of available audio devices changes. */
|
||||
static OSStatus
|
||||
device_list_changed(AudioObjectID systemObj, UInt32 num_addr, const AudioObjectPropertyAddress *addrs, void *data)
|
||||
{
|
||||
reprocess_device_list(SDL_TRUE, &capture_devs);
|
||||
reprocess_device_list(SDL_FALSE, &output_devs);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -314,11 +340,54 @@ inputCallback(void *inRefCon,
|
||||
}
|
||||
|
||||
|
||||
#if MACOSX_COREAUDIO
|
||||
static const AudioObjectPropertyAddress alive_address =
|
||||
{
|
||||
kAudioDevicePropertyDeviceIsAlive,
|
||||
kAudioObjectPropertyScopeGlobal,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
static OSStatus
|
||||
device_unplugged(AudioObjectID devid, UInt32 num_addr, const AudioObjectPropertyAddress *addrs, void *data)
|
||||
{
|
||||
SDL_AudioDevice *this = (SDL_AudioDevice *) data;
|
||||
SDL_bool dead = SDL_FALSE;
|
||||
UInt32 isAlive = 1;
|
||||
UInt32 size = sizeof (isAlive);
|
||||
OSStatus error;
|
||||
|
||||
if (!this->enabled) {
|
||||
return 0; /* already known to be dead. */
|
||||
}
|
||||
|
||||
error = AudioObjectGetPropertyData(this->hidden->deviceID, &alive_address,
|
||||
0, NULL, &size, &isAlive);
|
||||
|
||||
if (error == kAudioHardwareBadDeviceError) {
|
||||
dead = SDL_TRUE; /* device was unplugged. */
|
||||
} else if ((error == kAudioHardwareNoError) && (!isAlive)) {
|
||||
dead = SDL_TRUE; /* device died in some other way. */
|
||||
}
|
||||
|
||||
if (dead) {
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
COREAUDIO_CloseDevice(_THIS)
|
||||
{
|
||||
if (this->hidden != NULL) {
|
||||
if (this->hidden->audioUnitOpened) {
|
||||
#if MACOSX_COREAUDIO
|
||||
/* Unregister our disconnect callback. */
|
||||
AudioObjectRemovePropertyListener(this->hidden->deviceID, &alive_address, device_unplugged, this);
|
||||
#endif
|
||||
|
||||
AURenderCallbackStruct callback;
|
||||
const AudioUnitElement output_bus = 0;
|
||||
const AudioUnitElement input_bus = 1;
|
||||
@@ -352,9 +421,63 @@ COREAUDIO_CloseDevice(_THIS)
|
||||
}
|
||||
}
|
||||
|
||||
#if MACOSX_COREAUDIO
|
||||
static int
|
||||
prepare_device(_THIS, void *handle, int iscapture)
|
||||
{
|
||||
AudioDeviceID devid = (AudioDeviceID) ((size_t) handle);
|
||||
OSStatus result = noErr;
|
||||
UInt32 size = 0;
|
||||
UInt32 alive = 0;
|
||||
pid_t pid = 0;
|
||||
|
||||
AudioObjectPropertyAddress addr = {
|
||||
0,
|
||||
kAudioObjectPropertyScopeGlobal,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
if (handle == NULL) {
|
||||
size = sizeof (AudioDeviceID);
|
||||
addr.mSelector =
|
||||
((iscapture) ? kAudioHardwarePropertyDefaultInputDevice :
|
||||
kAudioHardwarePropertyDefaultOutputDevice);
|
||||
result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr,
|
||||
0, NULL, &size, &devid);
|
||||
CHECK_RESULT("AudioHardwareGetProperty (default device)");
|
||||
}
|
||||
|
||||
addr.mSelector = kAudioDevicePropertyDeviceIsAlive;
|
||||
addr.mScope = iscapture ? kAudioDevicePropertyScopeInput :
|
||||
kAudioDevicePropertyScopeOutput;
|
||||
|
||||
size = sizeof (alive);
|
||||
result = AudioObjectGetPropertyData(devid, &addr, 0, NULL, &size, &alive);
|
||||
CHECK_RESULT
|
||||
("AudioDeviceGetProperty (kAudioDevicePropertyDeviceIsAlive)");
|
||||
|
||||
if (!alive) {
|
||||
SDL_SetError("CoreAudio: requested device exists, but isn't alive.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
addr.mSelector = kAudioDevicePropertyHogMode;
|
||||
size = sizeof (pid);
|
||||
result = AudioObjectGetPropertyData(devid, &addr, 0, NULL, &size, &pid);
|
||||
|
||||
/* some devices don't support this property, so errors are fine here. */
|
||||
if ((result == noErr) && (pid != -1)) {
|
||||
SDL_SetError("CoreAudio: requested device is being hogged.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
this->hidden->deviceID = devid;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
prepare_audiounit(_THIS, const char *devname, int iscapture,
|
||||
prepare_audiounit(_THIS, void *handle, int iscapture,
|
||||
const AudioStreamBasicDescription * strdesc)
|
||||
{
|
||||
OSStatus result = noErr;
|
||||
@@ -373,8 +496,7 @@ prepare_audiounit(_THIS, const char *devname, int iscapture,
|
||||
kAudioUnitScope_Input);
|
||||
|
||||
#if MACOSX_COREAUDIO
|
||||
if (!find_device_by_name(this, devname, iscapture)) {
|
||||
SDL_SetError("Couldn't find requested CoreAudio device");
|
||||
if (!prepare_device(this, handle, iscapture)) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -451,13 +573,18 @@ prepare_audiounit(_THIS, const char *devname, int iscapture,
|
||||
result = AudioOutputUnitStart(this->hidden->audioUnit);
|
||||
CHECK_RESULT("AudioOutputUnitStart");
|
||||
|
||||
#if MACOSX_COREAUDIO
|
||||
/* Fire a callback if the device stops being "alive" (disconnected, etc). */
|
||||
AudioObjectAddPropertyListener(this->hidden->deviceID, &alive_address, device_unplugged, this);
|
||||
#endif
|
||||
|
||||
/* We're running! */
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
COREAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
COREAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
AudioStreamBasicDescription strdesc;
|
||||
SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
|
||||
@@ -516,7 +643,7 @@ COREAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
strdesc.mBytesPerPacket =
|
||||
strdesc.mBytesPerFrame * strdesc.mFramesPerPacket;
|
||||
|
||||
if (!prepare_audiounit(this, devname, iscapture, &strdesc)) {
|
||||
if (!prepare_audiounit(this, handle, iscapture, &strdesc)) {
|
||||
COREAUDIO_CloseDevice(this);
|
||||
return -1; /* prepare_audiounit() will call SDL_SetError()... */
|
||||
}
|
||||
@@ -524,15 +651,27 @@ COREAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
return 0; /* good to go. */
|
||||
}
|
||||
|
||||
static void
|
||||
COREAUDIO_Deinitialize(void)
|
||||
{
|
||||
#if MACOSX_COREAUDIO
|
||||
AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &devlist_address, device_list_changed, NULL);
|
||||
free_audio_device_list(&capture_devs);
|
||||
free_audio_device_list(&output_devs);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
COREAUDIO_Init(SDL_AudioDriverImpl * impl)
|
||||
{
|
||||
/* Set the function pointers */
|
||||
impl->OpenDevice = COREAUDIO_OpenDevice;
|
||||
impl->CloseDevice = COREAUDIO_CloseDevice;
|
||||
impl->Deinitialize = COREAUDIO_Deinitialize;
|
||||
|
||||
#if MACOSX_COREAUDIO
|
||||
impl->DetectDevices = COREAUDIO_DetectDevices;
|
||||
AudioObjectAddPropertyListener(kAudioObjectSystemObject, &devlist_address, device_list_changed, NULL);
|
||||
#else
|
||||
impl->OnlyHasDefaultOutputDevice = 1;
|
||||
|
||||
@@ -554,4 +693,6 @@ AudioBootStrap COREAUDIO_bootstrap = {
|
||||
"coreaudio", "CoreAudio", COREAUDIO_Init, 0
|
||||
};
|
||||
|
||||
#endif /* SDL_AUDIO_DRIVER_COREAUDIO */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user