Merged with latest official SDL code

This commit is contained in:
David Ludwig 2012-11-26 16:58:41 -05:00
commit 022b2a3cc4
39 changed files with 19900 additions and 10443 deletions

View file

@ -23,6 +23,10 @@ build
*.pbxuser
(^|/)build($|/)
.DS_Store
Xcode/SDL/SDL.xcodeproj/xcuserdata
Xcode/SDL/SDL.xcodeproj/project.xcworkspace/xcuserdata
Xcode/SDL/SDLTest.xcodeproj/xcuserdata
Xcode/SDL/SDLTest.xcodeproj/project.xcworkspace/xcuserdata
# for Visual C++
Debug

1176
CMakeLists.txt Normal file

File diff suppressed because it is too large Load diff

View file

@ -36,6 +36,9 @@ VERSION_OBJECTS = @VERSION_OBJECTS@
SDLMAIN_TARGET = libSDL2main.a
SDLMAIN_OBJECTS = @SDLMAIN_OBJECTS@
SDLTEST_TARGET = libSDL2_test.a
SDLTEST_OBJECTS = @SDLTEST_OBJECTS@
SRC_DIST = acinclude Android.mk autogen.sh BUGS build-scripts configure configure.in COPYING CREDITS include INSTALL Makefile.minimal Makefile.in README* sdl2-config.in sdl2.m4 sdl2.pc.in SDL2.spec.in src test TODO VisualC.html VisualC VisualCE WhatsNew Xcode Xcode-iOS
GEN_DIST = SDL2.spec
@ -89,13 +92,16 @@ HDRS = \
begin_code.h \
close_code.h
SDLTEST_HDRS = \
SDL_test.h
LT_AGE = @LT_AGE@
LT_CURRENT = @LT_CURRENT@
LT_RELEASE = @LT_RELEASE@
LT_REVISION = @LT_REVISION@
LT_LDFLAGS = -no-undefined -rpath $(DESTDIR)$(libdir) -release $(LT_RELEASE) -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
all: $(srcdir)/configure Makefile $(objects) $(objects)/$(TARGET) $(objects)/$(SDLMAIN_TARGET)
all: $(srcdir)/configure Makefile $(objects) $(objects)/$(TARGET) $(objects)/$(SDLMAIN_TARGET) $(objects)/$(SDLTEST_TARGET)
$(srcdir)/configure: $(srcdir)/configure.in
@echo "Warning, configure.in is out of date"
@ -122,13 +128,17 @@ $(objects)/$(SDLMAIN_TARGET): $(SDLMAIN_OBJECTS)
$(AR) cru $@ $(SDLMAIN_OBJECTS)
$(RANLIB) $@
$(objects)/$(SDLTEST_TARGET): $(SDLTEST_OBJECTS)
$(AR) cru $@ $(SDLTEST_OBJECTS)
$(RANLIB) $@
install: all install-bin install-hdrs install-lib install-data
install-bin:
$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(bindir)
$(INSTALL) -m 755 sdl2-config $(DESTDIR)$(bindir)/sdl2-config
install-hdrs: update-revision
$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(includedir)/SDL2
for file in $(HDRS); do \
for file in $(HDRS) $(SDLTEST_HDRS); do \
$(INSTALL) -m 644 $(srcdir)/include/$$file $(DESTDIR)$(includedir)/SDL2/$$file; \
done
$(INSTALL) -m 644 include/SDL_config.h $(DESTDIR)$(includedir)/SDL2/SDL_config.h
@ -138,11 +148,13 @@ install-hdrs: update-revision
$(INSTALL) -m 644 $(srcdir)/include/SDL_revision.h $(DESTDIR)$(includedir)/SDL2/SDL_revision.h; \
fi
install-lib: $(objects) $(objects)/$(TARGET) $(objects)/$(SDLMAIN_TARGET)
install-lib: $(objects) $(objects)/$(TARGET) $(objects)/$(SDLMAIN_TARGET) $(objects)/$(SDLTEST_TARGET)
$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(libdir)
$(LIBTOOL) --mode=install $(INSTALL) $(objects)/$(TARGET) $(DESTDIR)$(libdir)/$(TARGET)
$(INSTALL) -m 644 $(objects)/$(SDLMAIN_TARGET) $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET)
$(RANLIB) $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET)
$(INSTALL) -m 644 $(objects)/$(SDLTEST_TARGET) $(DESTDIR)$(libdir)/$(SDLTEST_TARGET)
$(RANLIB) $(DESTDIR)$(libdir)/$(SDLTEST_TARGET)
install-data:
$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(datadir)/aclocal
$(INSTALL) -m 644 $(srcdir)/sdl2.m4 $(DESTDIR)$(datadir)/aclocal/sdl2.m4
@ -153,7 +165,7 @@ uninstall: uninstall-bin uninstall-hdrs uninstall-lib uninstall-data
uninstall-bin:
rm -f $(DESTDIR)$(bindir)/sdl2-config
uninstall-hdrs:
for file in $(HDRS); do \
for file in $(HDRS) $(SDLTEST_HDRS); do \
rm -f $(DESTDIR)$(includedir)/SDL2/$$file; \
done
rm -f $(DESTDIR)$(includedir)/SDL2/SDL_config.h
@ -162,6 +174,7 @@ uninstall-hdrs:
uninstall-lib:
$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$(TARGET)
rm -f $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET)
rm -f $(DESTDIR)$(libdir)/$(SDLTEST_TARGET)
uninstall-data:
rm -f $(DESTDIR)$(datadir)/aclocal/sdl2.m4
rm -f $(DESTDIR)$(libdir)/pkgconfig/sdl2.pc

View file

@ -38,7 +38,8 @@ src/main/android/SDL_android_main.cpp
================================================================================
Instructions:
1. Copy the android-project directory wherever you want to keep your projects and rename it to the name of your project.
1. Copy the android-project directory wherever you want to keep your projects
and rename it to the name of your project.
2. Move or symlink this SDL directory into the <project>/jni directory
3. Edit <project>/jni/src/Android.mk to include your source files
4. Run 'ndk-build' (a script provided by the NDK). This compiles the C source
@ -47,28 +48,38 @@ If you want to use the Eclipse IDE, skip to the Eclipse section below.
5. Edit <project>/local.properties to point to the Android SDK directory
6. Run 'ant debug' in android/project. This compiles the .java and eventually
creates a .apk with the native code embedded
creates a .apk with the native code embedded
7. 'ant debug install' will push the apk to the device or emulator (if connected)
Here's an explanation of the files in the Android project, so you can customize them:
android-project/
AndroidManifest.xml - package manifest, customize this for your app
AndroidManifest.xml - package manifest. Among others, it contains the class name
of the main activity.
build.properties - empty
build.xml - build description file, used by ant
default.properties - holds the ABI for the application, currently android-5 which corresponds to the Android 2.0 system image
build.xml - build description file, used by ant. The actual application name
is specified here.
default.properties - holds the target ABI for the application, can range between
android-5 and android-16
local.properties - holds the SDK path, you should change this to the path to your SDK
jni/ - directory holding native code
jni/Android.mk - Android makefile that includes all subdirectories
jni/SDL/ - directory holding the SDL library files
jni/Android.mk - Android makefile that can call recursively the Android.mk files
in all subdirectories
jni/SDL/ - (symlink to) directory holding the SDL library files
jni/SDL/Android.mk - Android makefile for creating the SDL shared library
jni/src/ - directory holding your C/C++ source
jni/src/Android.mk - Android makefile that you should customize to include your source code and any library references
jni/src/Android.mk - Android makefile that you should customize to include your
source code and any library references
res/ - directory holding resources for your application
res/drawable-* - directories holding icons for different phone hardware
res/layout/main.xml - place holder for the main screen layout, overridden by the SDL video output
res/values/strings.xml - strings used in your application, including the application name shown on the phone.
src/org/libsdl/app/SDLActivity.java - the Java class handling the initialization and binding to SDL. Be very careful changing this, as the SDL library relies on this implementation.
res/drawable-* - directories holding icons for different phone hardware. Could be
one dir called "drawable".
res/layout/main.xml - Usually contains a file main.xml, which declares the screen layout.
We don't need it because we use the SDL video output.
res/values/strings.xml - strings used in your application, including the application name
shown on the phone.
src/org/libsdl/app/SDLActivity.java - the Java class handling the initialization and binding
to SDL. Be very careful changing this, as the SDL library relies
on this implementation.
================================================================================
@ -87,21 +98,13 @@ Here's an example of a minimal class file:
package com.gamemaker.game;
import org.libsdl.app.SDLActivity;
import android.os.*;
/*
* A sample wrapper class that just calls SDLActivity
*/
public class MyGame extends SDLActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
public class MyGame extends SDLActivity { }
protected void onDestroy() {
super.onDestroy();
}
}
------------------------------------------
Then replace "SDLActivity" in AndroidManifest.xml with the name of your
@ -112,16 +115,12 @@ class, .e.g. "MyGame"
================================================================================
Conceptually changing your icon is just replacing the icon.png files in the
drawable directories under the res directory.
The easiest way to create a set of icons for your project is to remove all
the existing icon.png files, and then use the Eclipse IDE to create a dummy
project. During the process of doing this Eclipse will prompt you to create
an icon. Then just copy the drawable directories it creates over to your
res directory.
drawable directories under the res directory. There are 3 directories for
different screen sizes. These can be replaced with 1 dir called 'drawable',
containing an icon file 'icon.png' with dimensions 48x48 or 72x72.
You may need to change the name of your icon in AndroidManifest.xml to match
the filename used by Eclipse.
this icon filename.
================================================================================
Loading assets
@ -187,7 +186,8 @@ For more information check out CPLUSPLUS-SUPPORT.html in the NDK documentation.
Additional documentation
================================================================================
The documentation in the NDK docs directory is very helpful in understanding the build process and how to work with native code on the Android platform.
The documentation in the NDK docs directory is very helpful in understanding the
build process and how to work with native code on the Android platform.
The best place to start is with docs/OVERVIEW.TXT
@ -217,6 +217,8 @@ emulator here: http://developer.android.com/tools/devices/emulator.html
Especially useful is the info on setting up OpenGL ES 2.0 emulation.
Notice that this software emulator is incredibly slow and needs a lot of disk space.
Using a real device works better.
================================================================================
Troubleshooting
@ -243,14 +245,17 @@ You can see the files on the SD card with a shell command:
You can start a command shell on the default device with:
adb shell
You can do a clean build with the following commands:
You can remove the library files of your project (and not the SDL lib files) with:
ndk-build clean
You can do a build with the following command:
ndk-build
You can see the complete command line that ndk-build is using by passing V=1 on the command line:
ndk-build V=1
If your application crashes in native code, you can use addr2line to convert the addresses in the stack trace to lines in your code.
If your application crashes in native code, you can use addr2line to convert the
addresses in the stack trace to lines in your code.
For example, if your crash looks like this:
I/DEBUG ( 31): signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 400085d0
@ -263,7 +268,8 @@ I/DEBUG ( 31): #01 pc 0001ccf6 /system/lib/libc.so
I/DEBUG ( 31): #02 pc 000014bc /data/data/org.libsdl.app/lib/libmain.so
I/DEBUG ( 31): #03 pc 00001506 /data/data/org.libsdl.app/lib/libmain.so
You can see that there's a crash in the C library being called from the main code. I run addr2line with the debug version of my code:
You can see that there's a crash in the C library being called from the main code.
I run addr2line with the debug version of my code:
arm-eabi-addr2line -C -f -e obj/local/armeabi/libmain.so
and then paste in the number after "pc" in the call stack, from the line that I care about:
000014bc
@ -276,7 +282,8 @@ You can add logging to your code to help show what's happening:
__android_log_print(ANDROID_LOG_INFO, "foo", "Something happened! x = %d", x);
If you need to build without optimization turned on, you can create a file called "Application.mk" in the jni directory, with the following line in it:
If you need to build without optimization turned on, you can create a file called
"Application.mk" in the jni directory, with the following line in it:
APP_OPTIM := debug
@ -328,5 +335,4 @@ When you're done instrumenting with valgrind, you can disable the wrapper:
Known issues
================================================================================
- SDL audio (although it's mostly written, just not working properly yet)
- TODO. I'm sure there's a bunch more stuff I haven't thought of

31
README.cmake Normal file
View file

@ -0,0 +1,31 @@
================================================================================
CMake build system for SDL (www.cmake.org)
================================================================================
SDL's build system was traditionally based on autotools. Over time, this
approach has suffered from several issues across the different supported
platforms.
To solve these problems, a new build system based on CMake is under development.
It works in parallel to the legacy system, so users can experiment with it
without complication.
While still experimental, the build system should be usable on the following
platforms:
* FreeBSD
* Linux
* VS.NET 2010
* MinGW and Msys
* OS X with support for XCode
================================================================================
Usage
================================================================================
Assuming the source for SDL is located at ~/sdl
cd ~
mkdir build
cd build
cmake ../sdl
This will build the static and dynamic versions of SDL in the ~/build directory.

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL", "SDL\SDL_VS2012.vcxproj", "{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDLmain", "SDLmain\SDLmain_VS2012.vcxproj", "{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}"

View file

@ -29,19 +29,23 @@
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">

View file

@ -29,19 +29,23 @@
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">

65
cmake/macros.cmake Normal file
View file

@ -0,0 +1,65 @@
macro(SET_OPTION _NAME _DESC)
list(APPEND ALLOPTIONS ${_NAME})
if(${ARGC} EQUAL 3)
set(_DEFLT ${ARGV2})
else()
set(_DEFLT OFF)
endif()
option(${_NAME} ${_DESC} ${_DEFLT})
endmacro()
macro(DEP_OPTION _NAME _DESC _DEFLT _DEPTEST _FAILDFLT)
list(APPEND ALLOPTIONS ${_NAME})
cmake_dependent_option(${_NAME} ${_DESC} ${_DEFLT} ${_DEPTEST} ${_FAILDFLT})
endmacro()
macro(OPTION_STRING _NAME _DESC _VALUE)
list(APPEND ALLOPTIONS ${_NAME})
set(${_NAME} ${_VALUE} CACHE STRING "${_DESC}")
set(HAVE_${_NAME} ${_VALUE})
ENDMACRO()
# Message Output
macro(MESSAGE_WARN _TEXT)
message(STATUS "*** WARNING: ${_TEXT}")
endmacro()
macro(MESSAGE_ERROR _TEXT)
message(FATAL_ERROR "*** ERROR: ${_TEXT}")
endmacro()
macro(MESSAGE_BOOL_OPTION _NAME _VALUE)
if(${_VALUE})
message(STATUS " ${_NAME}:\tON")
else()
message(STATUS " ${_NAME}:\tOFF")
endif()
endmacro()
macro(MESSAGE_TESTED_OPTION _NAME)
set(_REQVALUE ${${_NAME}})
set(_PAD " ")
if(${ARGC} EQUAL 2)
set(_PAD ${ARGV1})
endif()
if(NOT HAVE_${_NAME})
set(HAVE_${_NAME} OFF)
elseif("${HAVE_${_NAME}}" MATCHES "1|TRUE|YES|Y")
set(HAVE_${_NAME} ON)
endif()
message(STATUS " ${_NAME}${_PAD}(Wanted: ${_REQVALUE}): ${HAVE_${_NAME}}")
endmacro()
macro(LISTTOSTR _LIST _OUTPUT)
if(${ARGC} EQUAL 3)
# prefix for each element
set(_LPREFIX ${ARGV2})
else()
set(_LPREFIX "")
endif()
# Do not use string(REPLACE ";" " ") here to avoid messing up list
# entries
foreach(_ITEM ${${_LIST}})
set(${_OUTPUT} "${_LPREFIX}${_ITEM} ${${_OUTPUT}}")
endforeach()
endmacro()

808
cmake/sdlchecks.cmake Normal file
View file

@ -0,0 +1,808 @@
macro(CheckDLOPEN)
check_function_exists(dlopen HAVE_DLOPEN)
if(NOT HAVE_DLOPEN)
foreach(_LIBNAME dl tdl)
check_library_exists("${_LIBNAME}" "dlopen" "" DLOPEN_LIB)
if(DLOPEN_LIB)
list(APPEND EXTRA_LIBS ${_LIBNAME})
set(_DLLIB ${_LIBNAME})
set(HAVE_DLOPEN TRUE)
break()
endif(DLOPEN_LIB)
endforeach()
endif()
if(HAVE_DLOPEN)
if(_DLLIB)
set(CMAKE_REQUIRED_LIBRARIES ${_DLLIB})
endif()
check_c_source_compiles("
#include <dlfcn.h>
#if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED <= 1020
#error Use dlcompat for Mac OS X 10.2 compatibility
#endif
int main(int argc, char **argv) {}" HAVE_DLOPEN)
set(CMAKE_REQUIRED_LIBRARIES)
endif()
if (HAVE_DLOPEN)
set(SDL_LOADSO_DLOPEN 1)
set(HAVE_SDL_DLOPEN TRUE)
file(GLOB DLOPEN_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/dlopen/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${DLOPEN_SOURCES})
set(HAVE_SDL_LOADSO TRUE)
endif()
endmacro(CheckDLOPEN)
# Requires:
# - n/a
macro(CheckOSS)
if(OSS)
set(OSS_HEADER_FILE "sys/soundcard.h")
check_c_source_compiles("
#include <sys/soundcard.h>
int main() { int arg = SNDCTL_DSP_SETFRAGMENT; }" OSS_FOUND)
if(NOT OSS_FOUND)
set(OSS_HEADER_FILE "soundcard.h")
check_c_source_compiles("
#include <soundcard.h>
int main() { int arg = SNDCTL_DSP_SETFRAGMENT; }" OSS_FOUND)
endif(NOT OSS_FOUND)
if(OSS_FOUND)
set(HAVE_OSS TRUE)
file(GLOB OSS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/dsp/*.c)
if(OSS_HEADER_FILE STREQUAL "soundcard.h")
set(SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H 1)
endif(OSS_HEADER_FILE STREQUAL "soundcard.h")
set(SDL_AUDIO_DRIVER_OSS 1)
set(SOURCE_FILES ${SOURCE_FILES} ${OSS_SOURCES})
if(NETBSD OR OPENBSD)
list(APPEND EXTRA_LIBS ossaudio)
endif(NETBSD OR OPENBSD)
set(HAVE_SDL_AUDIO TRUE)
endif(OSS_FOUND)
endif(OSS)
endmacro(CheckOSS)
# Requires:
# - n/a
# Optional:
# - ALSA_SHARED opt
# - HAVE_DLOPEN opt
macro(CheckALSA)
if(ALSA)
CHECK_INCLUDE_FILE(alsa/asoundlib.h HAVE_ASOUNDLIB_H)
if(HAVE_ASOUNDLIB_H)
CHECK_LIBRARY_EXISTS(asound snd_pcm_open "" HAVE_LIBASOUND)
set(HAVE_ALSA TRUE)
file(GLOB ALSA_SOURCES ${SDL2_SOURCE_DIR}/src/audio/alsa/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${ALSA_SOURCES})
set(SDL_AUDIO_DRIVER_ALSA 1)
if(ALSA_SHARED)
if(NOT HAVE_DLOPEN)
message_warn("You must have SDL_LoadObject() support for dynamic ALSA loading")
else()
find_library(_ALSA_LIB asound)
get_filename_component(F_ALSA_LIB ${_ALSA_LIB} NAME)
set(SDL_AUDIO_DRIVER_ALSA_DYNAMIC "\"${F_ALSA_LIB}\"")
set(HAVE_ALSA_SHARED TRUE)
endif(NOT HAVE_DLOPEN)
else(ALSA_SHARED)
list(APPEND EXTRA_LIBS asound)
endif(ALSA_SHARED)
set(HAVE_SDL_AUDIO TRUE)
endif(HAVE_ASOUNDLIB_H)
endif(ALSA)
endmacro(CheckALSA)
# Requires:
# - PkgCheckModules
# Optional:
# - PULSEAUDIO_SHARED opt
# - HAVE_DLOPEN opt
macro(CheckPulseAudio)
if(PULSEAUDIO)
pkg_check_modules(PKG_PULSEAUDIO libpulse-simple)
if(PKG_PULSEAUDIO_FOUND)
set(HAVE_PULSEAUDIO TRUE)
file(GLOB PULSEAUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/pulseaudio/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${PULSEAUDIO_SOURCES})
set(SDL_AUDIO_DRIVER_PULSEAUDIO 1)
list(APPEND EXTRA_CFLAGS ${PKG_PULSEAUDIO_CFLAGS})
if(PULSEAUDIO_SHARED)
if(NOT HAVE_DLOPEN)
message_warn("You must have SDL_LoadObject() support for dynamic PulseAudio loading")
else()
find_library(D_PULSE_LIB pulse-simple)
get_filename_component(F_PULSE_LIB ${D_PULSE_LIB} NAME)
set(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC "\"${F_PULSE_LIB}\"")
set(HAVE_PULSEAUDIO_SHARED TRUE)
endif(NOT HAVE_DLOPEN)
else(PULSEAUDIO_SHARED)
list(APPEND EXTRA_LDFLAGS ${PKG_PULSEAUDIO_LDFLAGS})
endif(PULSEAUDIO_SHARED)
set(HAVE_SDL_AUDIO TRUE)
endif(PKG_PULSEAUDIO_FOUND)
endif(PULSEAUDIO)
endmacro(CheckPulseAudio)
# Requires:
# - PkgCheckModules
# Optional:
# - ESD_SHARED opt
# - HAVE_DLOPEN opt
macro(CheckESD)
if(ESD)
pkg_check_modules(PKG_ESD esound)
if(PKG_ESD_FOUND)
set(HAVE_ESD TRUE)
file(GLOB ESD_SOURCES ${SDL2_SOURCE_DIR}/src/audio/esd/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${ESD_SOURCES})
set(SDL_AUDIO_DRIVER_ESD 1)
list(APPEND EXTRA_CFLAGS ${PKG_ESD_CFLAGS})
if(ESD_SHARED)
if(NOT HAVE_DLOPEN)
message_warn("You must have SDL_LoadObject() support for dynamic ESD loading")
else()
find_library(D_ESD_LIB esd)
get_filename_component(F_ESD_LIB ${D_ESD_LIB} NAME)
set(SDL_AUDIO_DRIVER_ESD_DYNAMIC "\"${F_ESD_LIB}\"")
set(HAVE_ESD_SHARED TRUE)
endif(NOT HAVE_DLOPEN)
else(ESD_SHARED)
list(APPEND EXTRA_LDFLAGS ${PKG_ESD_LDFLAGS})
endif(ESD_SHARED)
set(HAVE_SDL_AUDIO TRUE)
endif(PKG_ESD_FOUND)
endif(ESD)
endmacro(CheckESD)
# Requires:
# - n/a
# Optional:
# - ARTS_SHARED opt
# - HAVE_DLOPEN opt
macro(CheckARTS)
if(ARTS)
find_program(ARTS_CONFIG arts-config)
if(ARTS_CONFIG)
execute_process(CMD_ARTSCFLAGS ${ARTS_CONFIG} --cflags
OUTPUT_VARIABLE ARTS_CFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
list(APPEND EXTRA_CFLAGS ${ARTS_CFLAGS})
execute_process(CMD_ARTSLIBS ${ARTS_CONFIG} --libs
OUTPUT_VARIABLE ARTS_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE)
file(GLOB ARTS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/arts/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${ARTS_SOURCES})
set(SDL_AUDIO_DRIVER_ARTS 1)
set(HAVE_ARTS TRUE)
if(ARTS_SHARED)
if(NOT HAVE_DLOPEN)
message_warn("You must have SDL_LoadObject() support for dynamic ARTS loading")
else()
# TODO
find_library(D_ARTS_LIB artsc)
get_filename_component(F_ARTS_LIB ${D_ARTS_LIB} NAME)
set(SDL_AUDIO_DRIVER_ARTS_DYNAMIC "\"${F_ARTS_LIB}\"")
set(HAVE_ARTS_SHARED TRUE)
endif(NOT HAVE_DLOPEN)
else(ARTS_SHARED)
list(APPEND EXTRA_LDFLAGS ${ARTS_LIBS})
endif(ARTS_SHARED)
set(HAVE_SDL_AUDIO TRUE)
endif(ARTS_CONFIG)
endif(ARTS)
endmacro(CheckARTS)
# Requires:
# - n/a
# Optional:
# - NAS_SHARED opt
# - HAVE_DLOPEN opt
macro(CheckNAS)
if(NAS)
# TODO: set include paths properly, so the NAS headers are found
check_include_file(audio/audiolib.h HAVE_NAS_H)
find_library(D_NAS_LIB audio)
if(HAVE_NAS_H AND D_NAS_LIB)
set(HAVE_NAS TRUE)
file(GLOB NAS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/nas/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${NAS_SOURCES})
set(SDL_AUDIO_DRIVER_NAS 1)
if(NAS_SHARED)
if(NOT HAVE_DLOPEN)
message_warn("You must have SDL_LoadObject() support for dynamic NAS loading")
else()
get_filename_component(F_NAS_LIB ${D_NAS_LIB} NAME)
set(SDL_AUDIO_DRIVER_NAS_DYNAMIC "\"${F_NAS_LIB}\"")
set(HAVE_NAS_SHARED TRUE)
endif(NOT HAVE_DLOPEN)
else(NAS_SHARED)
list(APPEND EXTRA_LIBS ${D_NAS_LIB})
endif(NAS_SHARED)
set(HAVE_SDL_AUDIO TRUE)
endif(HAVE_NAS_H AND D_NAS_LIB)
endif(NAS)
endmacro(CheckNAS)
# Requires:
# - PkgCheckModules
# Optional:
# - FUSIONSOUND_SHARED opt
# - HAVE_DLOPEN opt
macro(CheckFusionSound)
if(FUSIONSOUND)
pkg_check_modules(PKG_FUSIONSOUND fusionsound>=1.0.0)
if(PKG_FUSIONSOUND_FOUND)
set(HAVE_FUSIONSOUND TRUE)
file(GLOB FUSIONSOUND_SOURCES ${SDL2_SOURCE_DIR}/src/audio/fusionsound/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${FUSIONSOUND_SOURCES})
set(SDL_AUDIO_DRIVER_FUSIONSOUND 1)
list(APPEND EXTRA_CFLAGS ${PKG_FUSIONSOUND_CFLAGS})
if(FUSIONSOUND_SHARED)
if(NOT HAVE_DLOPEN)
message_warn("You must have SDL_LoadObject() support for dynamic FusionSound loading")
else()
find_library(D_FUSIONSOUND_LIB fusionsound)
get_filename_component(F_FUSIONSOUND_LIB ${D_FUSIONSOUND_LIB} NAME)
set(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC "\"${F_FUSIONSOUND_LIB}\"")
set(HAVE_FUSIONSOUND_SHARED TRUE)
endif(NOT HAVE_DLOPEN)
else(FUSIONSOUND_SHARED)
list(APPEND EXTRA_LDFLAGS ${PKG_FUSIONSOUND_LDFLAGS})
endif(FUSIONSOUND_SHARED)
set(HAVE_SDL_AUDIO TRUE)
endif(PKG_FUSIONSOUND_FOUND)
endif(FUSIONSOUND)
endmacro(CheckFusionSound)
# Requires:
# - n/a
# Optional:
# - X11_SHARED opt
# - HAVE_DLOPEN opt
macro(CheckX11)
if(VIDEO_X11)
foreach(_LIB X11 Xext Xcursor Xinerama Xi Xrandr Xrender Xss Xxf86vm)
string(TOUPPER ${_LIB} _LNAME)
find_library(${_LNAME}_LIB ${_LIB})
if(${_LNAME}_LIB)
# reduce the library name for shared linking
get_filename_component(_TMP ${${_LNAME}_LIB} NAME)
set(${_LNAME}_LIB ${_TMP})
endif()
endforeach()
check_include_file(X11/Xcursor/Xcursor.h HAVE_XCURSOR_H)
check_include_file(X11/extensions/Xinerama.h HAVE_XINERAMA_H)
check_include_file(X11/extensions/XInput2.h HAVE_XINPUT_H)
check_include_file(X11/extensions/Xrandr.h HAVE_XRANDR_H)
check_include_file(X11/extensions/Xrender.h HAVE_XRENDER_H)
check_include_file(X11/extensions/scrnsaver.h HAVE_XSS_H)
check_include_file(X11/extensions/shape.h HAVE_XSHAPE_H)
check_include_files("X11/Xlib.h;X11/extensions/xf86vmode.h" HAVE_XF86VM_H)
if(X11_LIB)
set(HAVE_VIDEO_X11 TRUE)
set(HAVE_SDL_VIDEO TRUE)
file(GLOB X11_SOURCES ${SDL2_SOURCE_DIR}/src/video/x11/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${X11_SOURCES})
set(SDL_VIDEO_DRIVER_X11 1)
if(HAVE_GCC_FVISIBILITY)
set(X11_SYMBOLS_PRIVATE TRUE)
else()
set(X11_SYMBOLS_PRIVATE FALSE)
endif(HAVE_GCC_FVISIBILITY)
if(APPLE)
set(X11_SHARED OFF)
set(X11_SYMBOLS_PRIVATE TRUE)
endif(APPLE)
check_function_exists("shmat" HAVE_SHMAT)
if(NOT HAVE_SHMAT)
check_library_exists(ipc shmat "" HAVE_SHMAT)
if(HAVE_SHMAT)
list(APPEND EXTRA_LIBS ipc)
endif(HAVE_SHMAT)
if(NOT HAVE_SHMAT)
add_definitions(-DNO_SHARED_MEMORY)
endif(NOT HAVE_SHMAT)
endif(NOT HAVE_SHMAT)
if(X11_SHARED)
if(NOT HAVE_DLOPEN)
message_warn("You must have SDL_LoadObject() support for dynamic X11 loading")
set(HAVE_X11_SHARED FALSE)
if(X11_SYMBOLS_PRIVATE)
message_warn("You must have gcc4 (-fvisibility=hidden) for dynamic X11 loading")
set(HAVE_X11_SHARED TRUE)
endif(X11_SYMBOLS_PRIVATE)
else(NOT HAVE_DLOPEN)
set(HAVE_X11_SHARED TRUE)
endif()
if(HAVE_X11_SHARED)
set(SDL_VIDEO_DRIVER_X11_DYNAMIC "\"${X11_LIB}\"")
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "\"${XEXT_LIB}\"")
else(HAVE_X11_SHARED)
list(APPEND EXTRA_LIBS ${X11_LIB} ${XEXT_LIB})
endif(HAVE_X11_SHARED)
endif(X11_SHARED)
set(CMAKE_REQUIRED_LIBRARIES ${X11_LIB} ${X11_LIB})
check_c_source_compiles("
#include <X11/Xlib.h>
#include <X11/Xproto.h>
#include <X11/extensions/Xext.h>
#include <X11/extensions/extutil.h>
extern XExtDisplayInfo* XextAddDisplay(XExtensionInfo* a,Display* b,_Xconst char* c,XExtensionHooks* d,int e,XPointer f);
int main(int argc, char **argv) {}" HAVE_CONST_XEXT_ADDDISPLAY)
if(HAVE_CONST_XEXT_ADDDISPLAY)
set(SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY 1)
endif(HAVE_CONST_XEXT_ADDDISPLAY)
check_c_source_compiles("
#include <X11/Xlib.h>
int main(int argc, char **argv) {
Display *display;
XEvent event;
XGenericEventCookie *cookie = &event.xcookie;
XNextEvent(display, &event);
XGetEventData(display, cookie);
XFreeEventData(display, cookie); }" HAVE_XGENERICEVENT)
if(HAVE_XGENERICEVENT)
set(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1)
endif(HAVE_XGENERICEVENT)
check_function_exists(XkbKeycodeToKeysym SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM)
if(VIDEO_X11_XCURSOR AND HAVE_XCURSOR_H)
set(HAVE_VIDEO_X11_XCURSOR TRUE)
if(HAVE_X11_SHARED AND XCURSOR_LIB)
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR "\"${XCURSOR_LIB}\"")
else(HAVE_X11_SHARED AND XCURSOR_LIB)
list(APPEND EXTRA_LIBS ${XCURSOR_LIB})
endif(HAVE_X11_SHARED AND XCURSOR_LIB)
set(SDL_VIDEO_DRIVER_X11_XCURSOR 1)
endif(VIDEO_X11_XCURSOR AND HAVE_XCURSOR_H)
if(VIDEO_X11_XINERAMA AND HAVE_XINERAMA_H)
set(HAVE_VIDEO_X11_XINERAMA TRUE)
if(HAVE_X11_SHARED AND XINERAMA_LIB)
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "\"${XINERAMA_LIB}\"")
else(HAVE_X11_SHARED AND XINERAMA_LIB)
list(APPEND EXTRA_LIBS ${XINERAMA_LIB})
endif(HAVE_X11_SHARED AND XINERAMA_LIB)
set(SDL_VIDEO_DRIVER_X11_XINERAMA 1)
endif(VIDEO_X11_XINERAMA AND HAVE_XINERAMA_H)
if(VIDEO_X11_XINPUT AND HAVE_XINPUT_H)
set(HAVE_VIDEO_X11_XINPUT TRUE)
if(HAVE_X11_SHARED AND XI_LIB)
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "\"${XI_LIB}\"")
else(HAVE_X11_SHARED AND XI_LIB)
list(APPEND EXTRA_LIBS ${XI_LIB})
endif(HAVE_X11_SHARED AND XI_LIB)
set(SDL_VIDEO_DRIVER_X11_XINPUT2 1)
# Check for multitouch
check_c_source_compiles("
#include <X11/Xlib.h>
#include <X11/Xproto.h>
#include <X11/extensions/XInput2.h>
int event_type = XI_TouchBegin;
XITouchClassInfo *t;
Status XIAllowTouchEvents(Display *a,int b,unsigned int c,Window d,int f)
{
return (Status)0;
}
int main(int argc, char **argv) {}" HAVE_XINPUT2_MULTITOUCH)
if(HAVE_XINPUT2_MULTITOUCH)
set(SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH 1)
endif(HAVE_XINPUT2_MULTITOUCH)
endif(VIDEO_X11_XINPUT AND HAVE_XINPUT_H)
if(VIDEO_X11_XRANDR AND HAVE_XRANDR_H)
if(HAVE_X11_SHARED AND XRANDR_LIB)
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "\"${XRANDR_LIB}\"")
else(HAVE_X11_SHARED AND XRANDR_LIB)
list(APPEND EXTRA_LIBS ${XRANDR_LIB})
endif(HAVE_X11_SHARED AND XRANDR_LIB)
set(SDL_VIDEO_DRIVER_X11_XRANDR 1)
set(HAVE_VIDEO_X11_XRANDR TRUE)
endif(VIDEO_X11_XRANDR AND HAVE_XRANDR_H)
if(VIDEO_X11_XSCRNSAVER AND HAVE_XSS_H)
if(HAVE_X11_SHARED AND XSS_LIB)
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "\"${XSS_LIB}\"")
else(HAVE_X11_SHARED AND XSS_LIB)
list(APPEND EXTRA_LIBS ${XSS_LIB})
endif(HAVE_X11_SHARED AND XSS_LIB)
set(SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1)
set(HAVE_VIDEO_X11_XSCRNSAVER TRUE)
endif(VIDEO_X11_XSCRNSAVER AND HAVE_XSS_H)
if(VIDEO_X11_XSHAPE AND HAVE_XSHAPE_H)
set(SDL_VIDEO_DRIVER_X11_XSHAPE 1)
set(HAVE_VIDEO_X11_XSHAPE TRUE)
endif(VIDEO_X11_XSHAPE AND HAVE_XSHAPE_H)
if(VIDEO_X11_XVM AND HAVE_XF86VM_H)
if(HAVE_X11_SHARED AND XF86VMODE_LIB)
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "\"${XF86VMODE_LIB}\"")
else(HAVE_X11_SHARED AND XF86VMODE_LIB)
list(APPEND EXTRA_LIBS ${XF86VMODE_LIB})
endif(HAVE_X11_SHARED AND XF86VMODE_LIB)
set(SDL_VIDEO_DRIVER_X11_XVIDMODE 1)
set(HAVE_VIDEO_X11_XVM TRUE)
endif(VIDEO_X11_XVM AND HAVE_XF86VM_H)
set(CMAKE_REQUIRED_LIBRARIES)
endif(X11_LIB)
endif(VIDEO_X11)
endmacro(CheckX11)
# Requires:
# - n/a
#
macro(CheckCOCOA)
if(VIDEO_COCOA)
check_c_source_compiles("
#import <Cocoa/Cocoa.h>
int main (int argc, char** argv) {}" HAVE_VIDEO_COCOA)
if(HAVE_VIDEO_COCOA)
file(GLOB COCOA_SOURCES ${SDL2_SOURCE_DIR}/src/video/cocoa/*.m)
set(SOURCE_FILES ${SOURCE_FILES} ${COCOA_SOURCES})
set(SDL_VIDEO_DRIVER_COCOA 1)
set(HAVE_SDL_VIDEO TRUE)
endif(HAVE_VIDEO_COCOA)
endif(VIDEO_COCOA)
endmacro(CheckCOCOA)
# Requires:
# - PkgCheckModules
# Optional:
# - DIRECTFB_SHARED opt
# - HAVE_DLOPEN opt
macro(CheckDirectFB)
if(VIDEO_DIRECTFB)
pkg_check_modules(PKG_DIRECTFB directfb>=1.0.0)
if(PKG_DIRECTFB_FOUND)
set(HAVE_VIDEO_DIRECTFB TRUE)
file(GLOB DIRECTFB_SOURCES ${SDL2_SOURCE_DIR}/src/video/directfb/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${DIRECTFB_SOURCES})
set(SDL_VIDEO_DRIVER_DIRECTFB 1)
set(SDL_VIDEO_RENDER_DIRECTFB 1)
list(APPEND EXTRA_CFLAGS ${PKG_DIRECTFB_CFLAGS})
if(DIRECTFB_SHARED)
if(NOT HAVE_DLOPEN)
message_warn("You must have SDL_LoadObject() support for dynamic DirectFB loading")
else()
find_library(D_DIRECTFB_LIB directfb)
get_filename_component(F_DIRECTFB_LIB ${D_DIRECTFB_LIB} NAME)
set(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC "\"${F_DIRECTFB_LIB}\"")
set(HAVE_DIRECTFB_SHARED TRUE)
endif(NOT HAVE_DLOPEN)
else(DIRECTFB_SHARED)
list(APPEND EXTRA_LDFLAGS ${PKG_DIRECTFB_LDFLAGS})
endif(DIRECTFB_SHARED)
set(HAVE_SDL_VIDEO TRUE)
endif(PKG_DIRECTFB_FOUND)
endif(VIDEO_DIRECTFB)
endmacro(CheckDirectFB)
# Requires:
# - nada
macro(CheckOpenGLX11)
if(VIDEO_OPENGL)
check_c_source_compiles("
#include <GL/gl.h>
#include <GL/glx.h>
int main(int argc, char** argv) {}" HAVE_VIDEO_OPENGL)
if(HAVE_VIDEO_OPENGL)
set(HAVE_VIDEO_OPENGL TRUE)
set(SDL_VIDEO_OPENGL 1)
set(SDL_VIDEO_OPENGL_GLX 1)
set(SDL_VIDEO_RENDER_OGL 1)
list(APPEND EXTRA_LIBS GL)
endif(HAVE_VIDEO_OPENGL)
endif(VIDEO_OPENGL)
endmacro(CheckOpenGLX11)
# Requires:
# - nada
macro(CheckOpenGLESX11)
if(VIDEO_OPENGLES)
check_c_source_compiles("
#include <EGL/egl.h>
int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES)
if(HAVE_VIDEO_OPENGLES)
check_c_source_compiles("
#include <GLES/gl.h>
#include <GLES/glext.h>
int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES_V1)
if(HAVE_VIDEO_OPENGLES_V1)
set(SDL_VIDEO_OPENGL_ES 1)
set(SDL_VIDEO_RENDER_OGL_ES 1)
endif(HAVE_VIDEO_OPENGLES_V1)
check_c_source_compiles("
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES_V2)
if(HAVE_VIDEO_OPENGLES_V2)
set(SDL_VIDEO_OPENGL_ES2 1)
set(SDL_VIDEO_RENDER_OGL_ES2 1)
endif(HAVE_VIDEO_OPENGLES_V2)
endif(HAVE_VIDEO_OPENGLES)
endif(VIDEO_OPENGLES)
endmacro(CheckOpenGLESX11)
# Rquires:
# - nada
# Optional:
# - THREADS opt
# Sets:
# PTHREAD_CFLAGS
# PTHREAD_LIBS
macro(CheckPTHREAD)
if(PTHREADS)
if(LINUX)
set(PTHREAD_CFLAGS "-D_REENTRANT")
set(PTHREAD_LDFLAGS "-lpthread")
elseif(BSDI)
set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
set(PTHREAD_LDFLAGS "")
elseif(DARWIN)
set(PTHREAD_CFLAGS "-D_THREAD_SAFE")
# causes Carbon.p complaints?
# set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
set(PTHREAD_LDFLAGS "")
elseif(FREEBSD)
set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
set(PTHREAD_LDFLAGS "-pthread")
elseif(NETBSD)
set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
set(PTHREAD_LDFLAGS "-lpthread")
elseif(OPENBSD)
set(PTHREAD_CFLAGS "-D_REENTRANT")
set(PTHREAD_LDFLAGS "-pthread")
elseif(SOLARIS)
set(PTHREAD_CFLAGS "-D_REENTRANT")
set(PTHREAD_LDFLAGS "-pthread -lposix4")
elseif(SYSV5)
set(PTHREAD_CFLAGS "-D_REENTRANT -Kthread")
set(PTHREAD_LDFLAGS "")
elseif(AIX)
set(PTHREAD_CFLAGS "-D_REENTRANT -mthreads")
set(PTHREAD_LDFLAGS "-pthread")
elseif(HPUX)
set(PTHREAD_CFLAGS "-D_REENTRANT")
set(PTHREAD_LDFLAGS "-L/usr/lib -pthread")
else()
set(PTHREAD_CFLAGS "-D_REENTRANT")
set(PTHREAD_LDFLAGS "-lpthread")
endif(LINUX)
# Run some tests
set(CMAKE_REQUIRED_FLAGS "${PTHREAD_CFLAGS} ${PTHREAD_LDFLAGS}")
check_c_source_runs("
#include <pthread.h>
int main(int argc, char** argv) {
pthread_attr_t type;
pthread_attr_init(&type);
return 0;
}" HAVE_PTHREADS)
if(HAVE_PTHREADS)
set(SDL_THREAD_PTHREAD 1)
list(APPEND EXTRA_CFLAGS ${PTHREAD_CFLAGS})
list(APPEND EXTRA_LDFLAGS ${PTHREAD_LDFLAGS})
set(SDL_CFLAGS "${SDL_CFLAGS} ${PTHREAD_CFLAGS}")
list(APPEND SDL_LIBS ${PTHREAD_LDFLAGS})
check_c_source_compiles("
#include <pthread.h>
int main(int argc, char **argv) {
pthread_mutexattr_t attr;
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
}" HAVE_RECURSIVE_MUTEXES)
if(HAVE_RECURSIVE_MUTEXES)
set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1)
else(HAVE_RECURSIVE_MUTEXES)
check_c_source_compiles("
#include <pthread.h>
int main(int argc, char **argv) {
pthread_mutexattr_t attr;
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
}" HAVE_RECURSIVE_MUTEXES_NP)
if(HAVE_RECURSIVE_MUTEXES_NP)
set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1)
endif(HAVE_RECURSIVE_MUTEXES_NP)
endif(HAVE_RECURSIVE_MUTEXES)
if(PTHREADS_SEM)
check_c_source_compiles("#include <pthread.h>
#include <semaphore.h>" HAVE_PTHREADS_SEM)
if(HAVE_PTHREADS_SEM)
check_c_source_compiles("
#include <pthread.h>
#include <semaphore.h>
int main(int argc, char **argv) {
sem_timedwait(NULL, NULL);
return 0;
}" HAVE_SEM_TIMEDWAIT)
endif(HAVE_PTHREADS_SEM)
endif(PTHREADS_SEM)
check_c_source_compiles("
#include <pthread.h>
int main(int argc, char** argv) {
pthread_spin_trylock(NULL);
return 0;
}" HAVE_PTHREAD_SPINLOCK)
check_c_source_compiles("
#include <pthread.h>
#include <pthread_np.h>
int main(int argc, char** argv) { return 0; }" HAVE_PTHREAD_NP_H)
check_function_exists(pthread_setname_np HAVE_PTHREAD_setNAME_NP)
check_function_exists(pthread_set_name_np HAVE_PTHREAD_set_NAME_NP)
set(CMAKE_REQUIRED_FLAGS)
set(SOURCE_FILES ${SOURCE_FILES}
${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_systhread.c
${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_sysmutex.c # Can be faked, if necessary
${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_syscond.c # Can be faked, if necessary
)
if(HAVE_PTHREADS_SEM)
set(SOURCE_FILES ${SOURCE_FILES}
${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_syssem.c)
else(HAVE_PTHREADS_SEM)
set(SOURCE_FILES ${SOURCE_FILES}
${SDL2_SOURCE_DIR}/src/thread/generic/SDL_syssem.c)
endif(HAVE_PTHREADS_SEM)
set(HAVE_SDL_THREADS TRUE)
endif(HAVE_PTHREADS)
endif(PTHREADS)
endmacro(CheckPTHREAD)
# Requires
# - nada
# Optional:
# Sets:
# USB_LIBS
# USB_CFLAGS
macro(CheckUSBHID)
check_library_exists(usbhid hid_init "" LIBUSBHID)
if(LIBUSBHID)
check_include_file(usbhid.h HAVE_USBHID_H)
if(HAVE_USBHID_H)
set(USB_CFLAGS "-DHAVE_USBHID_H")
endif(HAVE_USBHID_H)
check_include_file(libusbhid.h HAVE_LIBUSBHID_H)
if(HAVE_LIBUSBHID_H)
set(USB_CFLAGS "${USB_CFLAGS} -DHAVE_LIBUSBHID_H")
endif(HAVE_LIBUSBHID_H)
set(USB_LIBS ${USB_LIBS} usbhid)
else(LIBUSBHID)
check_include_file(usb.h HAVE_USB_H)
if(HAVE_USB_H)
set(USB_CFLAGS "-DHAVE_USB_H")
endif(HAVE_USB_H)
check_include_file(libusb.h HAVE_LIBUSB_H)
if(HAVE_LIBUSB_H)
set(USB_CFLAGS "${USB_CFLAGS} -DHAVE_LIBUSB_H")
endif(HAVE_LIBUSB_H)
check_library_exists(usb hid_init "" LIBUSB)
if(LIBUSB)
set(USB_LIBS ${USB_LIBS} usb)
endif(LIBUSB)
endif(LIBUSBHID)
set(CMAKE_REQUIRED_FLAGS "${USB_CFLAGS}")
set(CMAKE_REQUIRED_LIBRARIES "${USB_LIBS}")
check_c_source_compiles("
#include <sys/types.h>
#if defined(HAVE_USB_H)
#include <usb.h>
#endif
#ifdef __DragonFly__
# include <bus/usb/usb.h>
# include <bus/usb/usbhid.h>
#else
# include <dev/usb/usb.h>
# include <dev/usb/usbhid.h>
#endif
#if defined(HAVE_USBHID_H)
#include <usbhid.h>
#elif defined(HAVE_LIBUSB_H)
#include <libusb.h>
#elif defined(HAVE_LIBUSBHID_H)
#include <libusbhid.h>
#endif
int main(int argc, char **argv) {
struct report_desc *repdesc;
struct usb_ctl_report *repbuf;
hid_kind_t hidkind;
return 0;
}" HAVE_USBHID)
if(HAVE_USBHID)
check_c_source_compiles("
#include <sys/types.h>
#if defined(HAVE_USB_H)
#include <usb.h>
#endif
#ifdef __DragonFly__
# include <bus/usb/usb.h>
# include <bus/usb/usbhid.h>
#else
# include <dev/usb/usb.h>
# include <dev/usb/usbhid.h>
#endif
#if defined(HAVE_USBHID_H)
#include <usbhid.h>
#elif defined(HAVE_LIBUSB_H)
#include <libusb.h>
#elif defined(HAVE_LIBUSBHID_H)
#include <libusbhid.h>
#endif
int main(int argc, char** argv) {
struct usb_ctl_report buf;
if (buf.ucr_data) { }
return 0;
}" HAVE_USBHID_UCR_DATA)
if(HAVE_USBHID_UCR_DATA)
set(USB_CFLAGS "${USB_CFLAGS} -DUSBHID_UCR_DATA")
endif(HAVE_USBHID_UCR_DATA)
check_c_source_compiles("
#include <sys/types.h>
#if defined(HAVE_USB_H)
#include <usb.h>
#endif
#ifdef __DragonFly__
#include <bus/usb/usb.h>
#include <bus/usb/usbhid.h>
#else
#include <dev/usb/usb.h>
#include <dev/usb/usbhid.h>
#endif
#if defined(HAVE_USBHID_H)
#include <usbhid.h>
#elif defined(HAVE_LIBUSB_H)
#include <libusb.h>
#elif defined(HAVE_LIBUSBHID_H)
#include <libusbhid.h>
#endif
int main(int argc, char **argv) {
report_desc_t d;
hid_start_parse(d, 1, 1);
return 0;
}" HAVE_USBHID_NEW)
if(HAVE_USBHID_NEW)
set(USB_CFLAGS "${USB_CFLAGS} -DUSBHID_NEW")
endif(HAVE_USBHID_NEW)
check_c_source_compiles("
#include <machine/joystick.h>
int main(int argc, char** argv) {
struct joystick t;
return 0;
}" HAVE_MACHINE_JOYSTICK)
if(HAVE_MACHINE_JOYSTICK)
set(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H 1)
endif(HAVE_MACHINE_JOYSTICK)
set(SDL_JOYSTICK_USBHID 1)
file(GLOB BSD_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/bsd/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${BSD_JOYSTICK_SOURCES})
list(APPEND EXTRA_CFLAGS ${USB_CFLAGS})
list(APPEND EXTRA_LIBS ${USB_LIBS})
set(HAVE_SDL_JOYSTICK TRUE)
set(CMAKE_REQUIRED_LIBRARIES)
set(CMAKE_REQUIRED_FLAGS)
endif(HAVE_USBHID)
endmacro(CheckUSBHID)

16921
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -2581,6 +2581,7 @@ fi
if test x$SDLMAIN_SOURCES = x; then
SDLMAIN_SOURCES="$srcdir/src/main/dummy/*.c"
fi
SDLTEST_SOURCES="$srcdir/src/test/*.c"
OBJECTS=`echo $SOURCES`
DEPENDS=`echo $SOURCES | tr ' ' '\n'`
@ -2605,6 +2606,13 @@ SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.
\\$(objects)/\\2.o: \\1/\\2.c\\\\
\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
SDLTEST_OBJECTS=`echo $SDLTEST_SOURCES`
SDLTEST_DEPENDS=`echo $SDLTEST_SOURCES`
SDLTEST_OBJECTS=`echo "$SDLTEST_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.o,g'`
SDLTEST_DEPENDS=`echo "$SDLTEST_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.c,\\\\
\\$(objects)/\\2.o: \\1/\\2.c\\\\
\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
# Set runtime shared library paths as needed
if test "x$enable_rpath" = "xyes"; then
@ -2650,6 +2658,7 @@ AC_SUBST(INCLUDE)
AC_SUBST(OBJECTS)
AC_SUBST(VERSION_OBJECTS)
AC_SUBST(SDLMAIN_OBJECTS)
AC_SUBST(SDLTEST_OBJECTS)
AC_SUBST(BUILD_CFLAGS)
AC_SUBST(EXTRA_CFLAGS)
AC_SUBST(BUILD_LDFLAGS)
@ -2666,6 +2675,7 @@ $srcdir/src/SDL.c: update-revision
$DEPENDS
$VERSION_DEPENDS
$SDLMAIN_DEPENDS
$SDLTEST_DEPENDS
__EOF__
AC_CONFIG_FILES([

364
include/SDL_config.h.cmake Normal file
View file

@ -0,0 +1,364 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2012 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
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef _SDL_config_h
#define _SDL_config_h
/**
* \file SDL_config.h.in
*
* This is a set of defines to configure the SDL features
*/
/* General platform specific identifiers */
#include "SDL_platform.h"
/* C language features */
#cmakedefine const @HAVE_CONST@
#cmakedefine inline @HAVE_INLINE@
#cmakedefine volatile @HAVE_VOLATILE@
/* C datatypes */
#cmakedefine SIZEOF_VOIDP @SIZEOF_VOIDP@
#cmakedefine HAVE_GCC_ATOMICS @HAVE_GCC_ATOMICS@
#cmakedefine HAVE_GCC_SYNC_LOCK_TEST_AND_SET @HAVE_GCC_SYNC_LOCK_TEST_AND_SET@
#cmakedefine HAVE_PTHREAD_SPINLOCK @HAVE_PTHREAD_SPINLOCK@
/* Comment this if you want to build without any C library requirements */
#cmakedefine HAVE_LIBC 1
#if HAVE_LIBC
/* Useful headers */
#cmakedefine HAVE_ALLOCA_H 1
#cmakedefine HAVE_SYS_TYPES_H 1
#cmakedefine HAVE_STDIO_H 1
#cmakedefine STDC_HEADERS 1
#cmakedefine HAVE_STDLIB_H 1
#cmakedefine HAVE_STDARG_H 1
#cmakedefine HAVE_MALLOC_H 1
#cmakedefine HAVE_MEMORY_H 1
#cmakedefine HAVE_STRING_H 1
#cmakedefine HAVE_STRINGS_H 1
#cmakedefine HAVE_INTTYPES_H 1
#cmakedefine HAVE_STDINT_H 1
#cmakedefine HAVE_CTYPE_H 1
#cmakedefine HAVE_MATH_H 1
#cmakedefine HAVE_ICONV_H 1
#cmakedefine HAVE_SIGNAL_H 1
#cmakedefine HAVE_ALTIVEC_H 1
#cmakedefine HAVE_PTHREAD_NP_H 1
/* C library functions */
#cmakedefine HAVE_MALLOC 1
#cmakedefine HAVE_CALLOC 1
#cmakedefine HAVE_REALLOC 1
#cmakedefine HAVE_FREE 1
#cmakedefine HAVE_ALLOCA 1
#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */
#cmakedefine HAVE_GETENV 1
#cmakedefine HAVE_SETENV 1
#cmakedefine HAVE_PUTENV 1
#cmakedefine HAVE_UNSETENV 1
#endif
#cmakedefine HAVE_QSORT 1
#cmakedefine HAVE_ABS 1
#cmakedefine HAVE_BCOPY 1
#cmakedefine HAVE_MEMSET 1
#cmakedefine HAVE_MEMCPY 1
#cmakedefine HAVE_MEMMOVE 1
#cmakedefine HAVE_MEMCMP 1
#cmakedefine HAVE_STRLEN 1
#cmakedefine HAVE_STRLCPY 1
#cmakedefine HAVE_STRLCAT 1
#cmakedefine HAVE_STRDUP 1
#cmakedefine HAVE__STRREV 1
#cmakedefine HAVE__STRUPR 1
#cmakedefine HAVE__STRLWR 1
#cmakedefine HAVE_INDEX 1
#cmakedefine HAVE_RINDEX 1
#cmakedefine HAVE_STRCHR 1
#cmakedefine HAVE_STRRCHR 1
#cmakedefine HAVE_STRSTR 1
#cmakedefine HAVE_ITOA 1
#cmakedefine HAVE__LTOA 1
#cmakedefine HAVE__UITOA 1
#cmakedefine HAVE__ULTOA 1
#cmakedefine HAVE_STRTOL 1
#cmakedefine HAVE_STRTOUL 1
#cmakedefine HAVE__I64TOA 1
#cmakedefine HAVE__UI64TOA 1
#cmakedefine HAVE_STRTOLL 1
#cmakedefine HAVE_STRTOULL 1
#cmakedefine HAVE_STRTOD 1
#cmakedefine HAVE_ATOI 1
#cmakedefine HAVE_ATOF 1
#cmakedefine HAVE_STRCMP 1
#cmakedefine HAVE_STRNCMP 1
#cmakedefine HAVE__STRICMP 1
#cmakedefine HAVE_STRCASECMP 1
#cmakedefine HAVE__STRNICMP 1
#cmakedefine HAVE_STRNCASECMP 1
#cmakedefine HAVE_SSCANF 1
#cmakedefine HAVE_SNPRINTF 1
#cmakedefine HAVE_VSNPRINTF 1
#cmakedefine HAVE_M_PI 1
#cmakedefine HAVE_ATAN 1
#cmakedefine HAVE_ATAN2 1
#cmakedefine HAVE_CEIL 1
#cmakedefine HAVE_COPYSIGN 1
#cmakedefine HAVE_COS 1
#cmakedefine HAVE_COSF 1
#cmakedefine HAVE_FABS 1
#cmakedefine HAVE_FLOOR 1
#cmakedefine HAVE_LOG 1
#cmakedefine HAVE_POW 1
#cmakedefine HAVE_SCALBN 1
#cmakedefine HAVE_SIN 1
#cmakedefine HAVE_SINF 1
#cmakedefine HAVE_SQRT 1
#cmakedefine HAVE_FSEEKO 1
#cmakedefine HAVE_FSEEKO64 1
#cmakedefine HAVE_SIGACTION 1
#cmakedefine HAVE_SA_SIGACTION 1
#cmakedefine HAVE_SETJMP 1
#cmakedefine HAVE_NANOSLEEP 1
#cmakedefine HAVE_SYSCONF 1
#cmakedefine HAVE_SYSCTLBYNAME 1
#cmakedefine HAVE_CLOCK_GETTIME 1
#cmakedefine HAVE_GETPAGESIZE 1
#cmakedefine HAVE_MPROTECT 1
#cmakedefine HAVE_ICONV 1
#cmakedefine HAVE_PTHREAD_SETNAME_NP 1
#cmakedefine HAVE_PTHREAD_SET_NAME_NP 1
#cmakedefine HAVE_SEM_TIMEDWAIT 1
#elif __WIN32__
#cmakedefine HAVE_STDARG_H 1
#cmakedefine HAVE_STDDEF_H 1
#else
/* We may need some replacement for stdarg.h here */
#include <stdarg.h>
#endif /* HAVE_LIBC */
/* SDL internal assertion support */
#cmakedefine SDL_DEFAULT_ASSERT_LEVEL @SDL_DEFAULT_ASSERT_LEVEL@
/* Allow disabling of core subsystems */
#cmakedefine SDL_ATOMIC_DISABLED @SDL_ATOMIC_DISABLED@
#cmakedefine SDL_AUDIO_DISABLED @SDL_AUDIO_DISABLED@
#cmakedefine SDL_CPUINFO_DISABLED @SDL_CPUINFO_DISABLED@
#cmakedefine SDL_EVENTS_DISABLED @SDL_EVENTS_DISABLED@
#cmakedefine SDL_FILE_DISABLED @SDL_FILE_DISABLED@
#cmakedefine SDL_JOYSTICK_DISABLED @SDL_JOYSTICK_DISABLED@
#cmakedefine SDL_HAPTIC_DISABLED @SDL_HAPTIC_DISABLED@
#cmakedefine SDL_LOADSO_DISABLED @SDL_LOADSO_DISABLED@
#cmakedefine SDL_RENDER_DISABLED @SDL_RENDER_DISABLED@
#cmakedefine SDL_THREADS_DISABLED @SDL_THREADS_DISABLED@
#cmakedefine SDL_TIMERS_DISABLED @SDL_TIMERS_DISABLED@
#cmakedefine SDL_VIDEO_DISABLED @SDL_VIDEO_DISABLED@
#cmakedefine SDL_POWER_DISABLED @SDL_POWER_DISABLED@
/* Enable various audio drivers */
#cmakedefine SDL_AUDIO_DRIVER_ALSA @SDL_AUDIO_DRIVER_ALSA@
#cmakedefine SDL_AUDIO_DRIVER_ALSA_DYNAMIC @SDL_AUDIO_DRIVER_ALSA_DYNAMIC@
#cmakedefine SDL_AUDIO_DRIVER_ARTS @SDL_AUDIO_DRIVER_ARTS@
#cmakedefine SDL_AUDIO_DRIVER_ARTS_DYNAMIC @SDL_AUDIO_DRIVER_ARTS_DYNAMIC@
#cmakedefine SDL_AUDIO_DRIVER_PULSEAUDIO @SDL_AUDIO_DRIVER_PULSEAUDIO@
#cmakedefine SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC @SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC@
#cmakedefine SDL_AUDIO_DRIVER_BEOSAUDIO @SDL_AUDIO_DRIVER_BEOSAUDIO@
#cmakedefine SDL_AUDIO_DRIVER_BSD @SDL_AUDIO_DRIVER_BSD@
#cmakedefine SDL_AUDIO_DRIVER_COREAUDIO @SDL_AUDIO_DRIVER_COREAUDIO@
#cmakedefine SDL_AUDIO_DRIVER_DISK @SDL_AUDIO_DRIVER_DISK@
#cmakedefine SDL_AUDIO_DRIVER_DUMMY @SDL_AUDIO_DRIVER_DUMMY@
#cmakedefine SDL_AUDIO_DRIVER_XAUDIO2 @SDL_AUDIO_DRIVER_XAUDIO2@
#cmakedefine SDL_AUDIO_DRIVER_DSOUND @SDL_AUDIO_DRIVER_DSOUND@
#cmakedefine SDL_AUDIO_DRIVER_ESD @SDL_AUDIO_DRIVER_ESD@
#cmakedefine SDL_AUDIO_DRIVER_ESD_DYNAMIC @SDL_AUDIO_DRIVER_ESD_DYNAMIC@
#cmakedefine SDL_AUDIO_DRIVER_NAS @SDL_AUDIO_DRIVER_NAS@
#cmakedefine SDL_AUDIO_DRIVER_NAS_DYNAMIC @SDL_AUDIO_DRIVER_NAS_DYNAMIC@
#cmakedefine SDL_AUDIO_DRIVER_NDS @SDL_AUDIO_DRIVER_NDS@
#cmakedefine SDL_AUDIO_DRIVER_OSS @SDL_AUDIO_DRIVER_OSS@
#cmakedefine SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H @SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H@
#cmakedefine SDL_AUDIO_DRIVER_PAUDIO @SDL_AUDIO_DRIVER_PAUDIO@
#cmakedefine SDL_AUDIO_DRIVER_QSA @SDL_AUDIO_DRIVER_QSA@
#cmakedefine SDL_AUDIO_DRIVER_SUNAUDIO @SDL_AUDIO_DRIVER_SUNAUDIO@
#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@
/* Enable various input drivers */
#cmakedefine SDL_INPUT_LINUXEV @SDL_INPUT_LINUXEV@
#cmakedefine SDL_INPUT_TSLIB @SDL_INPUT_TSLIB@
#cmakedefine SDL_JOYSTICK_BEOS @SDL_JOYSTICK_BEOS@
#cmakedefine SDL_JOYSTICK_DINPUT @SDL_JOYSTICK_DINPUT@
#cmakedefine SDL_JOYSTICK_DUMMY @SDL_JOYSTICK_DUMMY@
#cmakedefine SDL_JOYSTICK_IOKIT @SDL_JOYSTICK_IOKIT@
#cmakedefine SDL_JOYSTICK_LINUX @SDL_JOYSTICK_LINUX@
#cmakedefine SDL_JOYSTICK_NDS @SDL_JOYSTICK_NDS@
#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_HAPTIC_DUMMY @SDL_HAPTIC_DUMMY@
#cmakedefine SDL_HAPTIC_LINUX @SDL_HAPTIC_LINUX@
#cmakedefine SDL_HAPTIC_IOKIT @SDL_HAPTIC_IOKIT@
#cmakedefine SDL_HAPTIC_DINPUT @SDL_HAPTIC_DINPUT@
/* Enable various shared object loading systems */
#cmakedefine SDL_LOADSO_BEOS @SDL_LOADSO_BEOS@
#cmakedefine SDL_LOADSO_DLOPEN @SDL_LOADSO_DLOPEN@
#cmakedefine SDL_LOADSO_DUMMY @SDL_LOADSO_DUMMY@
#cmakedefine SDL_LOADSO_LDG @SDL_LOADSO_LDG@
#cmakedefine SDL_LOADSO_WINDOWS @SDL_LOADSO_WINDOWS@
/* Enable various threading systems */
#cmakedefine SDL_THREAD_BEOS @SDL_THREAD_BEOS@
#cmakedefine SDL_THREAD_NDS @SDL_THREAD_NDS@
#cmakedefine SDL_THREAD_PTHREAD @SDL_THREAD_PTHREAD@
#cmakedefine SDL_THREAD_PTHREAD_RECURSIVE_MUTEX @SDL_THREAD_PTHREAD_RECURSIVE_MUTEX@
#cmakedefine SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP @SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP@
#cmakedefine SDL_THREAD_WINDOWS @SDL_THREAD_WINDOWS@
/* Enable various timer systems */
#cmakedefine SDL_TIMER_BEOS @SDL_TIMER_BEOS@
#cmakedefine SDL_TIMER_DUMMY @SDL_TIMER_DUMMY@
#cmakedefine SDL_TIMER_NDS @SDL_TIMER_NDS@
#cmakedefine SDL_TIMER_UNIX @SDL_TIMER_UNIX@
#cmakedefine SDL_TIMER_WINDOWS @SDL_TIMER_WINDOWS@
#cmakedefine SDL_TIMER_WINCE @SDL_TIMER_WINCE@
/* Enable various video drivers */
#cmakedefine SDL_VIDEO_DRIVER_BWINDOW @SDL_VIDEO_DRIVER_BWINDOW@
#cmakedefine SDL_VIDEO_DRIVER_COCOA @SDL_VIDEO_DRIVER_COCOA@
#cmakedefine SDL_VIDEO_DRIVER_DIRECTFB @SDL_VIDEO_DRIVER_DIRECTFB@
#cmakedefine SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC @SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC@
#cmakedefine SDL_VIDEO_DRIVER_DUMMY @SDL_VIDEO_DRIVER_DUMMY@
#cmakedefine SDL_VIDEO_DRIVER_NDS @SDL_VIDEO_DRIVER_NDS@
#cmakedefine SDL_VIDEO_DRIVER_WINDOWS @SDL_VIDEO_DRIVER_WINDOWS@
#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@
#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR @SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR@
#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA @SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA@
#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 @SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2@
#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR @SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR@
#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS @SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS@
#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE @SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE@
#cmakedefine SDL_VIDEO_DRIVER_X11_XCURSOR @SDL_VIDEO_DRIVER_X11_XCURSOR@
#cmakedefine SDL_VIDEO_DRIVER_X11_XINERAMA @SDL_VIDEO_DRIVER_X11_XINERAMA@
#cmakedefine SDL_VIDEO_DRIVER_X11_XINPUT2 @SDL_VIDEO_DRIVER_X11_XINPUT2@
#cmakedefine SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH @SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH@
#cmakedefine SDL_VIDEO_DRIVER_X11_XRANDR @SDL_VIDEO_DRIVER_X11_XRANDR@
#cmakedefine SDL_VIDEO_DRIVER_X11_XSCRNSAVER @SDL_VIDEO_DRIVER_X11_XSCRNSAVER@
#cmakedefine SDL_VIDEO_DRIVER_X11_XSHAPE @SDL_VIDEO_DRIVER_X11_XSHAPE@
#cmakedefine SDL_VIDEO_DRIVER_X11_XVIDMODE @SDL_VIDEO_DRIVER_X11_XVIDMODE@
#cmakedefine SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS @SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS@
#cmakedefine SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY @SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY@
#cmakedefine SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM @SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM@
#cmakedefine SDL_VIDEO_RENDER_D3D @SDL_VIDEO_RENDER_D3D@
#cmakedefine SDL_VIDEO_RENDER_OGL @SDL_VIDEO_RENDER_OGL@
#cmakedefine SDL_VIDEO_RENDER_OGL_ES @SDL_VIDEO_RENDER_OGL_ES@
#cmakedefine SDL_VIDEO_RENDER_OGL_ES2 @SDL_VIDEO_RENDER_OGL_ES2@
#cmakedefine SDL_VIDEO_RENDER_DIRECTFB @SDL_VIDEO_RENDER_DIRECTFB@
/* Enable OpenGL support */
#cmakedefine SDL_VIDEO_OPENGL @SDL_VIDEO_OPENGL@
#cmakedefine SDL_VIDEO_OPENGL_ES @SDL_VIDEO_OPENGL_ES@
#cmakedefine SDL_VIDEO_OPENGL_BGL @SDL_VIDEO_OPENGL_BGL@
#cmakedefine SDL_VIDEO_OPENGL_CGL @SDL_VIDEO_OPENGL_CGL@
#cmakedefine SDL_VIDEO_OPENGL_GLX @SDL_VIDEO_OPENGL_GLX@
#cmakedefine SDL_VIDEO_OPENGL_WGL @SDL_VIDEO_OPENGL_WGL@
#cmakedefine SDL_VIDEO_OPENGL_OSMESA @SDL_VIDEO_OPENGL_OSMESA@
#cmakedefine SDL_VIDEO_OPENGL_OSMESA_DYNAMIC @SDL_VIDEO_OPENGL_OSMESA_DYNAMIC@
/* Enable system power support */
#cmakedefine SDL_POWER_LINUX @SDL_POWER_LINUX@
#cmakedefine SDL_POWER_WINDOWS @SDL_POWER_WINDOWS@
#cmakedefine SDL_POWER_MACOSX @SDL_POWER_MACOSX@
#cmakedefine SDL_POWER_BEOS @SDL_POWER_BEOS@
#cmakedefine SDL_POWER_NINTENDODS @SDL_POWER_NINTENDODS@
#cmakedefine SDL_POWER_HARDWIRED @SDL_POWER_HARDWIRED@
/* Enable assembly routines */
#cmakedefine SDL_ASSEMBLY_ROUTINES @SDL_ASSEMBLY_ROUTINES@
#cmakedefine SDL_ALTIVEC_BLITTERS @SDL_ALTIVEC_BLITTERS@
/* Platform specific definitions */
#if !defined(__WIN32__)
# if !defined(_STDINT_H_) && !defined(_STDINT_H) && !defined(HAVE_STDINT_H) && !defined(_HAVE_STDINT_H)
typedef unsigned int size_t;
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
typedef unsigned long uintptr_t;
# endif /* if (stdint.h isn't available) */
#else /* __WIN32__ */
# if !defined(_STDINT_H_) && !defined(HAVE_STDINT_H) && !defined(_HAVE_STDINT_H)
# if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__)
#define HAVE_STDINT_H 1
# elif defined(_MSC_VER)
typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef signed __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
# ifndef _UINTPTR_T_DEFINED
# ifdef _WIN64
typedef unsigned __int64 uintptr_t;
# else
typedef unsigned int uintptr_t;
# endif
#define _UINTPTR_T_DEFINED
# endif
/* Older Visual C++ headers don't have the Win64-compatible typedefs... */
# if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR)))
#define DWORD_PTR DWORD
# endif
# if ((_MSC_VER <= 1200) && (!defined(LONG_PTR)))
#define LONG_PTR LONG
# endif
# else /* !__GNUC__ && !_MSC_VER */
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
# ifndef _SIZE_T_DEFINED_
#define _SIZE_T_DEFINED_
typedef unsigned int size_t;
# endif
typedef unsigned int uintptr_t;
# endif /* __GNUC__ || _MSC_VER */
# endif /* !_STDINT_H_ && !HAVE_STDINT_H */
#endif /* __WIN32__ */
#endif /* _SDL_config_h */

View file

@ -40,7 +40,7 @@ typedef enum
{
SDL_MESSAGEBOX_ERROR = 0x00000010, /**< error dialog */
SDL_MESSAGEBOX_WARNING = 0x00000020, /**< warning dialog */
SDL_MESSAGEBOX_INFORMATION = 0x00000040, /**< informational dialog */
SDL_MESSAGEBOX_INFORMATION = 0x00000040 /**< informational dialog */
} SDL_MessageBoxFlags;
/**
@ -49,7 +49,7 @@ typedef enum
typedef enum
{
SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001, /**< Marks the default button when return is hit */
SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002, /**< Marks the default button when escape is hit */
SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002 /**< Marks the default button when escape is hit */
} SDL_MessageBoxButtonFlags;
/**
@ -72,12 +72,12 @@ typedef struct
typedef enum
{
SDL_MESSAGEBOX_COLOR_BACKGROUND,
SDL_MESSAGEBOX_COLOR_TEXT,
SDL_MESSAGEBOX_COLOR_BUTTON_BORDER,
SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND,
SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED,
SDL_MESSAGEBOX_COLOR_MAX
SDL_MESSAGEBOX_COLOR_BACKGROUND,
SDL_MESSAGEBOX_COLOR_TEXT,
SDL_MESSAGEBOX_COLOR_BUTTON_BORDER,
SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND,
SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED,
SDL_MESSAGEBOX_COLOR_MAX
} SDL_MessageBoxColorType;
/**

View file

@ -58,6 +58,25 @@ extern "C" {
typedef struct SDL_Cursor SDL_Cursor; /* Implementation dependent */
/**
* \brief Cursor types for SDL_CreateSystemCursor.
*/
typedef enum
{
SDL_SYSTEM_CURSOR_ARROW, // Arrow
SDL_SYSTEM_CURSOR_IBEAM, // I-beam
SDL_SYSTEM_CURSOR_WAIT, // Wait
SDL_SYSTEM_CURSOR_CROSSHAIR, // Crosshair
SDL_SYSTEM_CURSOR_WAITARROW, // Small wait cursor (or Wait if not available)
SDL_SYSTEM_CURSOR_SIZENWSE, // Double arrow pointing northwest and southeast
SDL_SYSTEM_CURSOR_SIZENESW, // Double arrow pointing northeast and southwest
SDL_SYSTEM_CURSOR_SIZEWE, // Double arrow pointing west and east
SDL_SYSTEM_CURSOR_SIZENS, // Double arrow pointing north and south
SDL_SYSTEM_CURSOR_SIZEALL, // Four pointed arrow pointing north, south, east, and west
SDL_SYSTEM_CURSOR_NO, // Slashed circle or crossbones
SDL_SYSTEM_CURSOR_HAND, // Hand
SDL_NUM_SYSTEM_CURSORS
} SDL_SystemCursor;
/* Function prototypes */
@ -74,7 +93,7 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void);
* mouse cursor position relative to the focus window for the currently
* selected mouse. You can pass NULL for either x or y.
*/
extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y);
extern DECLSPEC Uint32 SDLCALL SDL_GetMouseState(int *x, int *y);
/**
* \brief Retrieve the relative state of the mouse.
@ -83,7 +102,7 @@ extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y);
* be tested using the SDL_BUTTON(X) macros, and x and y are set to the
* mouse deltas since the last call to SDL_GetRelativeMouseState().
*/
extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
extern DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
/**
* \brief Moves the mouse to the given position within the window.
@ -154,6 +173,13 @@ extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface,
int hot_x,
int hot_y);
/**
* \brief Create a system cursor.
*
* \sa SDL_FreeCursor()
*/
extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id);
/**
* \brief Set the active cursor.
*/

View file

@ -114,9 +114,10 @@ enum
#define SDL_DEFINE_PIXELFOURCC(A, B, C, D) SDL_FOURCC(A, B, C, D)
#define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \
((1 << 31) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \
((1 << 28) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \
((bits) << 8) | ((bytes) << 0))
#define SDL_PIXELFLAG(X) (((X) >> 28) & 0x0F)
#define SDL_PIXELTYPE(X) (((X) >> 24) & 0x0F)
#define SDL_PIXELORDER(X) (((X) >> 20) & 0x0F)
#define SDL_PIXELLAYOUT(X) (((X) >> 16) & 0x0F)
@ -140,8 +141,9 @@ enum
(SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \
(SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA)))
/* The flag is set to 1 because 0x1? is not in the printable ASCII range */
#define SDL_ISPIXELFORMAT_FOURCC(format) \
((format) && !((format) & 0x80000000))
((format) && (SDL_PIXELFLAG(format) != 1))
/* Note: If you modify this list, update SDL_GetPixelFormatName() */
enum

View file

@ -30,7 +30,7 @@
#include "SDL_stdinc.h"
#if __IPHONEOS__
#if defined(__IPHONEOS__) && __IPHONEOS__
#include "SDL_video.h"
#include "SDL_keyboard.h"
#endif
@ -44,7 +44,7 @@ extern "C" {
#endif
/* Platform specific functions for iOS */
#if __IPHONEOS__
#if defined(__IPHONEOS__) && __IPHONEOS__
extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled);
@ -53,7 +53,7 @@ extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled);
/* Platform specific functions for Android */
#if __ANDROID__
#if defined(__ANDROID__) && __ANDROID__
/* Get the JNI environment for the current thread
This returns JNIEnv*, but the prototype is void* so we don't need jni.h

58
include/SDL_test.h Normal file
View file

@ -0,0 +1,58 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2012 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
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/**
* \file SDLTest.h
*
* Include file for SDL test framework.
*
* This code is a part of the SDL2_test library, not the main SDL library.
*/
#ifndef _SDLTest_h
#define _SDLTest_h
#include "SDL.h"
#include "SDL_test_font.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C" {
/* *INDENT-ON* */
#endif
/* Function prototypes */
/* ADD STUFF HERE */
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
}
/* *INDENT-ON* */
#endif
#include "close_code.h"
#endif /* _SDLTest_h */
/* vi: set ts=4 sw=4 expandtab: */

66
include/SDL_test_font.h Normal file
View file

@ -0,0 +1,66 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2012 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
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/**
* \file SDL_test_font.h
*
* Include file for SDL test framework.
*
* This code is a part of the SDL2_test library, not the main SDL library.
*/
#ifndef _SDL_test_font_h
#define _SDL_test_font_h
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C" {
/* *INDENT-ON* */
#endif
/* Function prototypes */
/**
* \brief Draw a string in the currently set font.
*
* \param renderer The renderer to draw on.
* \param x The X coordinate of the upper left corner of the string.
* \param y The Y coordinate of the upper left corner of the string.
* \param s The string to draw.
*
* \returns Returns 0 on success, -1 on failure.
*/
int SDLTest_DrawString(SDL_Renderer * renderer, int x, int y, const char *s);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
}
/* *INDENT-ON* */
#endif
#include "close_code.h"
#endif /* _SDL_test_font_h */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -518,6 +518,25 @@ extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window * window, int w,
extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w,
int *h);
/**
* \brief Set the minimum size of a window's client area.
*
* \note You can't change the minimum size of a fullscreen window, it
* automatically matches the size of the display mode.
*
* \sa SDL_GetWindowMinimumSize()
*/
extern DECLSPEC void SDLCALL SDL_SetWindowMinimumSize(SDL_Window * window,
int min_w, int min_h);
/**
* \brief Get the minimum size of a window's client area.
*
* \sa SDL_SetWindowMinimumSize()
*/
extern DECLSPEC void SDLCALL SDL_GetWindowMinimumSize(SDL_Window * window,
int *w, int *h);
/**
* \brief Set the border state of a window.
*

View file

@ -118,7 +118,7 @@ SDL_SetMouseFocus(SDL_Window * window)
/* Check to see if we need to synthesize focus events */
static SDL_bool
SDL_UpdateMouseFocus(SDL_Window * window, int x, int y, Uint8 buttonstate)
SDL_UpdateMouseFocus(SDL_Window * window, int x, int y, Uint32 buttonstate)
{
SDL_Mouse *mouse = SDL_GetMouse();
int w, h;
@ -264,7 +264,7 @@ SDL_SendMouseButton(SDL_Window * window, Uint8 state, Uint8 button)
SDL_Mouse *mouse = SDL_GetMouse();
int posted;
Uint32 type;
Uint8 buttonstate = mouse->buttonstate;
Uint32 buttonstate = mouse->buttonstate;
/* Figure out which event to perform */
switch (state) {
@ -345,7 +345,7 @@ SDL_MouseQuit(void)
{
}
Uint8
Uint32
SDL_GetMouseState(int *x, int *y)
{
SDL_Mouse *mouse = SDL_GetMouse();
@ -359,7 +359,7 @@ SDL_GetMouseState(int *x, int *y)
return mouse->buttonstate;
}
Uint8
Uint32
SDL_GetRelativeMouseState(int *x, int *y)
{
SDL_Mouse *mouse = SDL_GetMouse();
@ -528,6 +528,26 @@ SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y)
return cursor;
}
SDL_Cursor *
SDL_CreateSystemCursor(SDL_SystemCursor id)
{
SDL_Mouse *mouse = SDL_GetMouse();
SDL_Cursor *cursor;
if (!mouse->CreateSystemCursor) {
SDL_SetError("CreateSystemCursor is not currently supported");
return NULL;
}
cursor = mouse->CreateSystemCursor(id);
if (cursor) {
cursor->next = mouse->cursors;
mouse->cursors = cursor;
}
return cursor;
}
/* SDL_SetCursor(NULL) can be used to force the cursor redraw,
if this is desired for any reason. This is used when setting
the video mode and when the SDL window gains the mouse focus.

View file

@ -36,6 +36,9 @@ typedef struct
/* Create a cursor from a surface */
SDL_Cursor *(*CreateCursor) (SDL_Surface * surface, int hot_x, int hot_y);
/* Create a system cursor */
SDL_Cursor *(*CreateSystemCursor) (SDL_SystemCursor id);
/* Show the specified cursor, or hide if cursor is NULL */
int (*ShowCursor) (SDL_Cursor * cursor);
@ -58,7 +61,7 @@ typedef struct
int xdelta;
int ydelta;
int last_x, last_y; /* the last reported x and y coordinates */
Uint8 buttonstate;
Uint32 buttonstate;
SDL_bool relative_mode;
/* the x and y coordinates when relative mode was activated */
int original_x, original_y;

3238
src/test/SDL_test_font.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -74,6 +74,7 @@ struct SDL_Window
char *title;
int x, y;
int w, h;
int min_w, min_h;
Uint32 flags;
/* Stored position and size for windowed mode */
@ -181,6 +182,7 @@ struct SDL_VideoDevice
void (*SetWindowIcon) (_THIS, SDL_Window * window, SDL_Surface * icon);
void (*SetWindowPosition) (_THIS, SDL_Window * window);
void (*SetWindowSize) (_THIS, SDL_Window * window);
void (*SetWindowMinimumSize) (_THIS, SDL_Window * window);
void (*ShowWindow) (_THIS, SDL_Window * window);
void (*HideWindow) (_THIS, SDL_Window * window);
void (*RaiseWindow) (_THIS, SDL_Window * window);

View file

@ -1566,19 +1566,47 @@ SDL_GetWindowSize(SDL_Window * window, int *w, int *h)
CHECK_WINDOW_MAGIC(window, );
if (_this && window && window->magic == &_this->window_magic) {
if (w) {
*w = window->w;
}
if (h) {
*h = window->h;
}
} else {
if (w) {
*w = 0;
}
if (h) {
*h = 0;
*w = window->w;
*h = window->h;
}
}
void
SDL_SetWindowMinimumSize(SDL_Window * window, int min_w, int min_h)
{
CHECK_WINDOW_MAGIC(window, );
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
window->min_w = min_w;
window->min_h = min_h;
if (_this->SetWindowMinimumSize) {
_this->SetWindowMinimumSize(_this, window);
}
/* Ensure that window is not smaller than minimal size */
SDL_SetWindowSize(window, SDL_max(window->w, window->min_w), SDL_max(window->h, window->min_h));
}
}
void
SDL_GetWindowMinimumSize(SDL_Window * window, int *min_w, int *min_h)
{
int dummy;
if (!min_w) {
min_w = &dummy;
}
if (!min_h) {
min_h = &dummy;
}
*min_w = 0;
*min_h = 0;
CHECK_WINDOW_MAGIC(window, );
if (_this && window && window->magic == &_this->window_magic) {
*min_w = window->min_w;
*min_h = window->min_h;
}
}

View file

@ -22,6 +22,7 @@
#if SDL_VIDEO_DRIVER_COCOA
#include "SDL_assert.h"
#include "SDL_events.h"
#include "SDL_cocoavideo.h"
@ -75,6 +76,68 @@ Cocoa_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
return cursor;
}
static SDL_Cursor *
Cocoa_CreateSystemCursor(SDL_SystemCursor id)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSCursor *nscursor = NULL;
SDL_Cursor *cursor = NULL;
switch(id)
{
case SDL_SYSTEM_CURSOR_ARROW:
nscursor = [NSCursor arrowCursor];
break;
case SDL_SYSTEM_CURSOR_IBEAM:
nscursor = [NSCursor IBeamCursor];
break;
case SDL_SYSTEM_CURSOR_WAIT:
nscursor = [NSCursor arrowCursor];
break;
case SDL_SYSTEM_CURSOR_CROSSHAIR:
nscursor = [NSCursor crosshairCursor];
break;
case SDL_SYSTEM_CURSOR_WAITARROW:
nscursor = [NSCursor arrowCursor];
break;
case SDL_SYSTEM_CURSOR_SIZENWSE:
case SDL_SYSTEM_CURSOR_SIZENESW:
nscursor = [NSCursor closedHandCursor];
break;
case SDL_SYSTEM_CURSOR_SIZEWE:
nscursor = [NSCursor resizeLeftRightCursor];
break;
case SDL_SYSTEM_CURSOR_SIZENS:
nscursor = [NSCursor resizeUpDownCursor];
break;
case SDL_SYSTEM_CURSOR_SIZEALL:
nscursor = [NSCursor closedHandCursor];
break;
case SDL_SYSTEM_CURSOR_NO:
nscursor = [NSCursor operationNotAllowedCursor];
break;
case SDL_SYSTEM_CURSOR_HAND:
nscursor = [NSCursor pointingHandCursor];
break;
default:
SDL_assert(!"Unknown system cursor");
return NULL;
}
if (nscursor) {
cursor = SDL_calloc(1, sizeof(*cursor));
if (cursor) {
// We'll free it later, so retain it here
[nscursor retain];
cursor->driverdata = nscursor;
}
}
[pool release];
return cursor;
}
static void
Cocoa_FreeCursor(SDL_Cursor * cursor)
{
@ -139,6 +202,7 @@ Cocoa_InitMouse(_THIS)
SDL_Mouse *mouse = SDL_GetMouse();
mouse->CreateCursor = Cocoa_CreateCursor;
mouse->CreateSystemCursor = Cocoa_CreateSystemCursor;
mouse->ShowCursor = Cocoa_ShowCursor;
mouse->FreeCursor = Cocoa_FreeCursor;
mouse->WarpMouse = Cocoa_WarpMouse;

View file

@ -95,6 +95,7 @@ Cocoa_CreateDevice(int devindex)
device->SetWindowIcon = Cocoa_SetWindowIcon;
device->SetWindowPosition = Cocoa_SetWindowPosition;
device->SetWindowSize = Cocoa_SetWindowSize;
device->SetWindowMinimumSize = Cocoa_SetWindowMinimumSize;
device->ShowWindow = Cocoa_ShowWindow;
device->HideWindow = Cocoa_HideWindow;
device->RaiseWindow = Cocoa_RaiseWindow;

View file

@ -94,6 +94,7 @@ extern void Cocoa_SetWindowTitle(_THIS, SDL_Window * window);
extern void Cocoa_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon);
extern void Cocoa_SetWindowPosition(_THIS, SDL_Window * window);
extern void Cocoa_SetWindowSize(_THIS, SDL_Window * window);
extern void Cocoa_SetWindowMinimumSize(_THIS, SDL_Window * window);
extern void Cocoa_ShowWindow(_THIS, SDL_Window * window);
extern void Cocoa_HideWindow(_THIS, SDL_Window * window);
extern void Cocoa_RaiseWindow(_THIS, SDL_Window * window);

View file

@ -730,6 +730,21 @@ Cocoa_SetWindowSize(_THIS, SDL_Window * window)
[pool release];
}
void
Cocoa_SetWindowMinimumSize(_THIS, SDL_Window * window)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
NSSize minSize;
minSize.width = window->min_w;
minSize.height = window->min_h;
[windata->nswindow setMinSize:minSize];
[pool release];
}
void
Cocoa_ShowWindow(_THIS, SDL_Window * window)
{

View file

@ -22,6 +22,8 @@
#if SDL_VIDEO_DRIVER_UIKIT
extern SDL_bool UIKit_ShowingMessageBox();
extern int UIKit_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);
#endif /* SDL_VIDEO_DRIVER_UIKIT */

View file

@ -28,6 +28,7 @@
/* Display a UIKit message box */
static SDL_bool s_showingMessageBox = SDL_FALSE;
@interface UIKit_UIAlertViewDelegate : NSObject <UIAlertViewDelegate> {
@private
@ -60,6 +61,12 @@
@end // UIKit_UIAlertViewDelegate
SDL_bool
UIKit_ShowingMessageBox()
{
return s_showingMessageBox;
}
int
UIKit_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
{
@ -86,9 +93,12 @@ UIKit_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
// Run the main event loop until the alert has finished
// Note that this needs to be done on the main thread
s_showingMessageBox = SDL_TRUE;
while (clicked == messageboxdata->numbuttons) {
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
}
s_showingMessageBox = SDL_FALSE;
*buttonid = messageboxdata->buttons[clicked].buttonid;
[pool release];

View file

@ -22,9 +22,10 @@
#if SDL_VIDEO_DRIVER_UIKIT
#import <QuartzCore/QuartzCore.h>
#import <OpenGLES/EAGLDrawable.h>
#import "SDL_uikitopenglview.h"
#include <QuartzCore/QuartzCore.h>
#include <OpenGLES/EAGLDrawable.h>
#include "SDL_uikitopenglview.h"
#include "SDL_uikitmessagebox.h"
@implementation SDL_uikitopenglview
@ -180,7 +181,10 @@
- (void)doLoop:(id)sender
{
animationCallback(animationCallbackParam);
// Don't run the game loop while a messagebox is up
if (!UIKit_ShowingMessageBox()) {
animationCallback(animationCallbackParam);
}
}
- (void)setCurrentContext

View file

@ -426,16 +426,13 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
RECT size;
int x, y;
int w, h;
int min_w, min_h;
int style;
BOOL menu;
/* If we allow resizing, let the resize happen naturally */
if(SDL_IsShapedWindow(data->window))
if (SDL_IsShapedWindow(data->window))
Win32_ResizeWindowShape(data->window);
if (SDL_GetWindowFlags(data->window) & SDL_WINDOW_RESIZABLE) {
returnCode = 0;
break;
}
/* Get the current position of our window */
GetWindowRect(hwnd, &size);
@ -444,12 +441,18 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
/* Calculate current size of our window */
SDL_GetWindowSize(data->window, &w, &h);
SDL_GetWindowMinimumSize(data->window, &min_w, &min_h);
/* Store in min_w and min_h difference between current size and minimal
size so we don't need to call AdjustWindowRectEx twice */
min_w -= w;
min_h -= h;
size.top = 0;
size.left = 0;
size.bottom = h;
size.right = w;
style = GetWindowLong(hwnd, GWL_STYLE);
/* DJM - according to the docs for GetMenu(), the
return value is undefined if hwnd is a child window.
@ -463,14 +466,19 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
/* Fix our size to the current size */
info = (MINMAXINFO *) lParam;
info->ptMaxSize.x = w;
info->ptMaxSize.y = h;
info->ptMaxPosition.x = x;
info->ptMaxPosition.y = y;
info->ptMinTrackSize.x = w;
info->ptMinTrackSize.y = h;
info->ptMaxTrackSize.x = w;
info->ptMaxTrackSize.y = h;
if (SDL_GetWindowFlags(data->window) & SDL_WINDOW_RESIZABLE) {
info->ptMinTrackSize.x = w + min_w;
info->ptMinTrackSize.y = h + min_h;
} else {
info->ptMaxSize.x = w;
info->ptMaxSize.y = h;
info->ptMaxPosition.x = x;
info->ptMaxPosition.y = y;
info->ptMinTrackSize.x = w;
info->ptMinTrackSize.y = h;
info->ptMaxTrackSize.x = w;
info->ptMaxTrackSize.y = h;
}
}
returnCode = 0;
break;

View file

@ -102,6 +102,45 @@ WIN_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
return cursor;
}
static SDL_Cursor *
WIN_CreateSystemCursor(SDL_SystemCursor id)
{
SDL_Cursor *cursor;
LPCTSTR name;
switch(id)
{
default:
SDL_assert(0);
return NULL;
case SDL_SYSTEM_CURSOR_ARROW: name = IDC_ARROW; break;
case SDL_SYSTEM_CURSOR_IBEAM: name = IDC_IBEAM; break;
case SDL_SYSTEM_CURSOR_WAIT: name = IDC_WAIT; break;
case SDL_SYSTEM_CURSOR_CROSSHAIR: name = IDC_CROSS; break;
case SDL_SYSTEM_CURSOR_WAITARROW: name = IDC_WAIT; break;
case SDL_SYSTEM_CURSOR_SIZENWSE: name = IDC_SIZENWSE; break;
case SDL_SYSTEM_CURSOR_SIZENESW: name = IDC_SIZENESW; break;
case SDL_SYSTEM_CURSOR_SIZEWE: name = IDC_SIZEWE; break;
case SDL_SYSTEM_CURSOR_SIZENS: name = IDC_SIZENS; break;
case SDL_SYSTEM_CURSOR_SIZEALL: name = IDC_SIZEALL; break;
case SDL_SYSTEM_CURSOR_NO: name = IDC_NO; break;
case SDL_SYSTEM_CURSOR_HAND: name = IDC_HAND; break;
}
cursor = SDL_calloc(1, sizeof(*cursor));
if (cursor) {
HICON hicon;
hicon = LoadCursor(NULL, name);
cursor->driverdata = hicon;
} else {
SDL_OutOfMemory();
}
return cursor;
}
static void
WIN_FreeCursor(SDL_Cursor * cursor)
{
@ -190,6 +229,7 @@ WIN_InitMouse(_THIS)
SDL_Mouse *mouse = SDL_GetMouse();
mouse->CreateCursor = WIN_CreateCursor;
mouse->CreateSystemCursor = WIN_CreateSystemCursor;
mouse->ShowCursor = WIN_ShowCursor;
mouse->FreeCursor = WIN_FreeCursor;
mouse->WarpMouse = WIN_WarpMouse;

View file

@ -22,6 +22,7 @@
#if SDL_VIDEO_DRIVER_X11
#include <X11/cursorfont.h>
#include "SDL_assert.h"
#include "SDL_x11video.h"
#include "SDL_x11mouse.h"
@ -218,6 +219,47 @@ X11_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
return cursor;
}
static SDL_Cursor *
X11_CreateSystemCursor(SDL_SystemCursor id)
{
SDL_Cursor *cursor;
unsigned int shape;
switch(id)
{
default:
SDL_assert(0);
return NULL;
// X Font Cursors reference:
// http://tronche.com/gui/x/xlib/appendix/b/
case SDL_SYSTEM_CURSOR_ARROW: shape = XC_arrow; break;
case SDL_SYSTEM_CURSOR_IBEAM: shape = XC_xterm; break;
case SDL_SYSTEM_CURSOR_WAIT: shape = XC_watch; break;
case SDL_SYSTEM_CURSOR_CROSSHAIR: shape = XC_tcross; break;
case SDL_SYSTEM_CURSOR_WAITARROW: shape = XC_watch; break;
case SDL_SYSTEM_CURSOR_SIZENWSE: shape = XC_fleur; break;
case SDL_SYSTEM_CURSOR_SIZENESW: shape = XC_fleur; break;
case SDL_SYSTEM_CURSOR_SIZEWE: shape = XC_sb_h_double_arrow; break;
case SDL_SYSTEM_CURSOR_SIZENS: shape = XC_sb_v_double_arrow; break;
case SDL_SYSTEM_CURSOR_SIZEALL: shape = XC_fleur; break;
case SDL_SYSTEM_CURSOR_NO: shape = XC_pirate; break;
case SDL_SYSTEM_CURSOR_HAND: shape = XC_hand2; break;
}
cursor = SDL_calloc(1, sizeof(*cursor));
if (cursor) {
Cursor x11_cursor;
x11_cursor = XCreateFontCursor(GetDisplay(), shape);
cursor->driverdata = (void*)x11_cursor;
} else {
SDL_OutOfMemory();
}
return cursor;
}
static void
X11_FreeCursor(SDL_Cursor * cursor)
{
@ -288,6 +330,7 @@ X11_InitMouse(_THIS)
SDL_Mouse *mouse = SDL_GetMouse();
mouse->CreateCursor = X11_CreateCursor;
mouse->CreateSystemCursor = X11_CreateSystemCursor;
mouse->ShowCursor = X11_ShowCursor;
mouse->FreeCursor = X11_FreeCursor;
mouse->WarpMouse = X11_WarpMouse;

View file

@ -36,6 +36,7 @@ SDL_X11_SYM(int,XConvertSelection,(Display* a,Atom b,Atom c,Atom d,Window e,Time
SDL_X11_SYM(Pixmap,XCreateBitmapFromData,(Display *dpy,Drawable d,_Xconst char *data,unsigned int width,unsigned int height),(dpy,d,data,width,height),return)
SDL_X11_SYM(Colormap,XCreateColormap,(Display* a,Window b,Visual* c,int d),(a,b,c,d),return)
SDL_X11_SYM(Cursor,XCreatePixmapCursor,(Display* a,Pixmap b,Pixmap c,XColor* d,XColor* e,unsigned int f,unsigned int g),(a,b,c,d,e,f,g),return)
SDL_X11_SYM(Cursor,XCreateFontCursor,(Display* a,unsigned int b),(a,b),return)
SDL_X11_SYM(GC,XCreateGC,(Display* a,Drawable b,unsigned long c,XGCValues* d),(a,b,c,d),return)
SDL_X11_SYM(XImage*,XCreateImage,(Display* a,Visual* b,unsigned int c,int d,int e,char* f,unsigned int g,unsigned int h,int i,int j),(a,b,c,d,e,f,g,h,i,j),return)
SDL_X11_SYM(Window,XCreateWindow,(Display* a,Window b,int c,int d,unsigned int e,unsigned int f,unsigned int g,int h,unsigned int i,Visual* j,unsigned long k,XSetWindowAttributes* l),(a,b,c,d,e,f,g,h,i,j,k,l),return)

3890
test/configure vendored

File diff suppressed because it is too large Load diff

View file

@ -28,8 +28,26 @@ quit(int rc)
int
main(int argc, char *argv[])
{
static const char *cursorNames[] = {
"arrow",
"ibeam",
"wait",
"crosshair",
"waitarrow",
"sizeNWSE",
"sizeNESW",
"sizeWE",
"sizeNS",
"sizeALL",
"NO",
"hand",
};
SDL_assert(SDL_arraysize(cursorNames) == SDL_NUM_SYSTEM_CURSORS);
int i, done;
SDL_Event event;
int system_cursor = -1;
SDL_Cursor *cursor = NULL;
/* Initialize test framework */
state = CommonCreateState(argv, SDL_INIT_VIDEO);
@ -73,8 +91,33 @@ main(int argc, char *argv[])
}
}
}
if (event.type == SDL_KEYUP) {
SDL_bool updateCursor = SDL_FALSE;
if (event.key.keysym.sym == SDLK_LEFT) {
--system_cursor;
if (system_cursor < 0) {
system_cursor = SDL_NUM_SYSTEM_CURSORS - 1;
}
updateCursor = SDL_TRUE;
} else if (event.key.keysym.sym == SDLK_RIGHT) {
++system_cursor;
if (system_cursor >= SDL_NUM_SYSTEM_CURSORS) {
system_cursor = 0;
}
updateCursor = SDL_TRUE;
}
if (updateCursor) {
SDL_Log("Changing cursor to \"%s\"", cursorNames[system_cursor]);
SDL_FreeCursor(cursor);
cursor = SDL_CreateSystemCursor((SDL_SystemCursor)system_cursor);
SDL_SetCursor(cursor);
}
}
}
}
SDL_FreeCursor(cursor);
quit(0);
// keep the compiler happy ...
return(0);