diff --git a/.hgignore b/.hgignore index b6c427f82..c4b118779 100644 --- a/.hgignore +++ b/.hgignore @@ -76,6 +76,7 @@ test/testnative test/testoverlay2 test/testplatform test/testpower +test/testfilesystem test/testrelative test/testrendercopyex test/testrendertarget diff --git a/Android.mk b/Android.mk index 3230f9fea..c8e67da7b 100755 --- a/Android.mk +++ b/Android.mk @@ -33,6 +33,7 @@ LOCAL_SRC_FILES := \ $(wildcard $(LOCAL_PATH)/src/loadso/dlopen/*.c) \ $(wildcard $(LOCAL_PATH)/src/power/*.c) \ $(wildcard $(LOCAL_PATH)/src/power/android/*.c) \ + $(wildcard $(LOCAL_PATH)/src/filesystem/dummy/*.c) \ $(wildcard $(LOCAL_PATH)/src/render/*.c) \ $(wildcard $(LOCAL_PATH)/src/render/*/*.c) \ $(wildcard $(LOCAL_PATH)/src/stdlib/*.c) \ @@ -41,9 +42,27 @@ LOCAL_SRC_FILES := \ $(wildcard $(LOCAL_PATH)/src/timer/*.c) \ $(wildcard $(LOCAL_PATH)/src/timer/unix/*.c) \ $(wildcard $(LOCAL_PATH)/src/video/*.c) \ - $(wildcard $(LOCAL_PATH)/src/video/android/*.c)) + $(wildcard $(LOCAL_PATH)/src/video/android/*.c) \ + $(wildcard $(LOCAL_PATH)/src/test/*.c)) LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog +LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog -landroid include $(BUILD_SHARED_LIBRARY) + +########################### +# +# SDL static library +# +########################### + +LOCAL_MODULE := SDL2_static + +LOCAL_MODULE_FILENAME := libSDL2 + +LOCAL_SRC_FILES += $(LOCAL_PATH)/src/main/android/SDL_android_main.c + +LOCAL_LDLIBS := +LOCAL_EXPORT_LDLIBS := -Wl,--undefined=Java_org_libsdl_app_SDLActivity_nativeInit -ldl -lGLESv1_CM -lGLESv2 -llog -landroid + +include $(BUILD_STATIC_LIBRARY) diff --git a/CMakeLists.txt b/CMakeLists.txt index 925392ebb..1a1607fac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,9 +29,9 @@ include(${SDL2_SOURCE_DIR}/cmake/sdlchecks.cmake) # set SDL_BINARY_AGE and SDL_INTERFACE_AGE to 0. set(SDL_MAJOR_VERSION 2) set(SDL_MINOR_VERSION 0) -set(SDL_MICRO_VERSION 0) +set(SDL_MICRO_VERSION 1) set(SDL_INTERFACE_AGE 0) -set(SDL_BINARY_AGE 0) +set(SDL_BINARY_AGE 1) set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}") # Calculate a libtool-like version number @@ -172,7 +172,7 @@ include_directories(${SDL2_BINARY_DIR}/include ${SDL2_SOURCE_DIR}/include) set(SDL_SUBSYSTEMS Atomic Audio Video Render Events Joystick Haptic Power Threads Timers - File Loadso CPUinfo) + File Loadso CPUinfo Filesystem) foreach(_SUB ${SDL_SUBSYSTEMS}) string(TOUPPER ${_SUB} _OPT) option(SDL_${_OPT} "Enable the ${_SUB} subsystem" ON) @@ -714,6 +714,13 @@ if(UNIX AND NOT APPLE) endif(LINUX) endif(SDL_POWER) + if(SDL_FILESYSTEM) + set(SDL_FILESYSTEM_UNIX 1) + file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/unix/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES}) + set(HAVE_SDL_FILESYSTEM TRUE) + endif(SDL_FILESYSTEM) + if(SDL_TIMERS) set(SDL_TIMER_UNIX 1) file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c) @@ -814,6 +821,13 @@ elseif(WINDOWS) set(HAVE_SDL_POWER TRUE) endif(SDL_POWER) + if(SDL_FILESYSTEM) + set(SDL_FILESYSTEM_WINDOWS 1) + file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesytem/windows/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES}) + set(HAVE_SDL_FILESYSTEM TRUE) + endif(SDL_FILESYSTEM) + # Libraries for Win32 native and MinGW list(APPEND EXTRA_LIBS user32 gdi32 winmm imm32 ole32 oleaut32 version uuid) @@ -924,6 +938,13 @@ elseif(APPLE) set(SDL_FRAMEWORK_IOKIT 1) endif() + if(SDL_FILESYSTEM) + set(SDL_FILESYSTEM_COCOA 1) + file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/cocoa/*.m) + set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES}) + set(HAVE_SDL_FILESYSTEM TRUE) + endif() + # Actually load the frameworks at the end so we don't duplicate include. if(SDL_FRAMEWORK_COCOA) find_library(COCOA_LIBRARY Cocoa) @@ -973,6 +994,11 @@ elseif(BEOS) set(SOURCE_FILES ${SOURCE_FILES} ${BWINDOW_SOURCES}) set(HAVE_SDL_VIDEO TRUE) + set(SDL_FILESYSTEM_BEOS 1) + file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/beos/*.cc) + set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES}) + set(HAVE_SDL_FILESYSTEM TRUE) + if(VIDEO_OPENGL) # TODO: Use FIND_PACKAGE(OpenGL) instead set(SDL_VIDEO_OPENGL 1) @@ -1008,8 +1034,13 @@ endif(NOT HAVE_SDL_HAPTIC) if(NOT HAVE_SDL_LOADSO) set(SDL_LOADSO_DISABLED 1) file(GLOB LOADSO_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/dummy/*.c) - set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES}) + set(SOURCE_FILES ${SOURCE_FILES} ${LOADSO_SOURCES}) endif(NOT HAVE_SDL_LOADSO) +if(NOT HAVE_SDL_FILESYSTEM) + set(SDL_FILESYSTEM_DISABLED 1) + file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/dummy/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES}) +endif(NOT HAVE_SDL_FILESYSTEM) # We always need to have threads and timers around if(NOT HAVE_SDL_THREADS) diff --git a/CREDITS.txt b/CREDITS.txt index a1c2cdcb0..74163e824 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -21,6 +21,8 @@ Thanks to everyone who made this possible, including: * Pierre-Loup Griffais for his deep knowledge of OpenGL drivers. +* Julian Winter for the SDL 2.0 website. + * Sheena Smith for many months of great work on the SDL wiki creating the API documentation and style guides. * Paul Hunkin for his port of SDL to Android during the Google Summer of Code 2010. diff --git a/Makefile.in b/Makefile.in index ae6293e7d..da42661c5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -54,6 +54,7 @@ HDRS = \ SDL_endian.h \ SDL_error.h \ SDL_events.h \ + SDL_filesystem.h \ SDL_gamecontroller.h \ SDL_gesture.h \ SDL_haptic.h \ diff --git a/Makefile.minimal b/Makefile.minimal index a06083230..6ec1ce81c 100644 --- a/Makefile.minimal +++ b/Makefile.minimal @@ -19,6 +19,7 @@ SOURCES = \ src/joystick/dummy/*.c \ src/loadso/dummy/*.c \ src/power/*.c \ + src/filesystem/dummy/*.c \ src/render/*.c \ src/render/software/*.c \ src/stdlib/*.c \ diff --git a/Makefile.pandora b/Makefile.pandora index de15c846b..bb89d52a6 100644 --- a/Makefile.pandora +++ b/Makefile.pandora @@ -19,7 +19,7 @@ SOURCES = ./src/*.c ./src/audio/*.c ./src/cpuinfo/*.c ./src/events/*.c \ ./src/thread/pthread/SDL_systhread.c ./src/thread/pthread/SDL_syssem.c \ ./src/thread/pthread/SDL_sysmutex.c ./src/thread/pthread/SDL_syscond.c \ ./src/joystick/linux/*.c ./src/haptic/linux/*.c ./src/timer/unix/*.c \ - ./src/atomic/linux/*.c \ + ./src/atomic/linux/*.c ./src/filesystem/unix/*.c \ ./src/video/pandora/SDL_pandora.o ./src/video/pandora/SDL_pandora_events.o ./src/video/x11/*.c diff --git a/Makefile.psp b/Makefile.psp index 8bcdcb927..5e7dcd29a 100644 --- a/Makefile.psp +++ b/Makefile.psp @@ -31,6 +31,7 @@ OBJS= src/SDL.o \ src/joystick/psp/SDL_sysjoystick.o \ src/power/SDL_power.o \ src/power/psp/SDL_syspower.o \ + src/filesystem/dummy/SDL_sysfilesystem.o \ src/render/SDL_render.o \ src/render/SDL_yuv_sw.o \ src/render/psp/SDL_render_psp.o \ diff --git a/README-android.txt b/README-android.txt index ecd31ae1b..a161c8407 100644 --- a/README-android.txt +++ b/README-android.txt @@ -38,7 +38,33 @@ src/main/android/SDL_android_main.c Building an app ================================================================================ -Instructions: +For simple projects you can use the script located at build-scripts/androidbuild.sh + +There's two ways of using it: + +androidbuild.sh com.yourcompany.yourapp < sources.list +androidbuild.sh com.yourcompany.yourapp source1.c source2.c ...sourceN.c + +sources.list should be a text file with a source file name in each line +Filenames should be specified relative to the current directory, for example if +you are in the build-scripts directory and want to create the testgles.c test, you'll +run: + +./androidbuild.sh org.libsdl.testgles ../test/testgles.c + +One limitation of this script is that all sources provided will be aggregated into +a single directory, thus all your source files should have a unique name. + +Once the project is complete the script will tell you where the debug APK is located. +If you want to create a signed release APK, you can use the project created by this +utility to generate it. + +Finally, a word of caution: re running androidbuild.sh wipes any changes you may have +done in the build directory for the app! + + +For more complex projects, follow these instructions: + 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 /jni directory @@ -84,6 +110,28 @@ android-project/ on this implementation. +================================================================================ + Build an app with static linking of libSDL +================================================================================ + +This build uses the Android NDK module system. + +Instructions: +1. Copy the android-project directory wherever you want to keep your projects + and rename it to the name of your project. +2. Rename /jni/src/Android_static.mk to /jni/src/Android.mk + (overwrite the existing one) +3. Edit /jni/src/Android.mk to include your source files +4. create and export an environment variable named NDK_MODULE_PATH that points + to the parent directory of this SDL directory. e.g.: + + export NDK_MODULE_PATH="$PWD"/.. + +5. Edit /src/org/libsdl/app/SDLActivity.java and remove the call to + System.loadLibrary("SDL2") line 42. +6. Run 'ndk-build' (a script provided by the NDK). This compiles the C source + + ================================================================================ Customizing your application name ================================================================================ diff --git a/README-macosx.txt b/README-macosx.txt index c5cc89b5b..021b14021 100644 --- a/README-macosx.txt +++ b/README-macosx.txt @@ -29,6 +29,42 @@ gcc to make this easy is provided in test/gcc-fat.sh To use the library once it's built, you essential have two possibilities: use the traditional autoconf/automake/make method, or use Xcode. +============================================================================== +Caveats for using SDL with Mac OS X +============================================================================== + +Some things you have to be aware of when using SDL on Mac OS X: + +- If you register your own NSApplicationDelegate (using [NSApp setDelegate:]), + SDL will not register its own. This means that SDL will not terminate using + SDL_Quit if it receives a termination request, it will terminate like a + normal app, and it will not send a SDL_DROPFILE when you request to open a + file with the app. To solve these issues, put the following code in your + NSApplicationDelegate implementation: + + - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender + { + if (SDL_GetEventState(SDL_QUIT) == SDL_ENABLE) { + SDL_Event event; + event.type = SDL_QUIT; + SDL_PushEvent(&event); + } + + return NSTerminateCancel; + } + + - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename + { + if (SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) { + SDL_Event event; + event.type = SDL_DROPFILE; + event.drop.file = SDL_strdup([filename UTF8String]); + return (SDL_PushEvent(&event) > 0); + } + + return NO; + } + ============================================================================== Using the Simple DirectMedia Layer with a traditional Makefile ============================================================================== diff --git a/README-raspberrypi.txt b/README-raspberrypi.txt new file mode 100644 index 000000000..0724a8c90 --- /dev/null +++ b/README-raspberrypi.txt @@ -0,0 +1,155 @@ +================================================================================ +SDL2 for Raspberry Pi +================================================================================ + +Requirements: + +Raspbian (other Linux distros may work as well). + +================================================================================ + Features +================================================================================ + +* Works without X11 +* Hardware accelerated OpenGL ES 2.x +* Sound via ALSA +* Input (mouse/keyboard/joystick) via EVDEV +* Hotplugging of input devices via UDEV + +================================================================================ + Raspbian Build Dependencies +================================================================================ + +sudo apt-get install libudev-dev libasound2-dev libdbus-1-dev + +You also need the VideoCore binary stuff that ships in /opt/vc for EGL and +OpenGL ES 2.x, it usually comes pre installed, but in any case: + +sudo apt-get install libraspberrypi0 libraspberrypi-bin libraspberrypi-dev + +================================================================================ + Cross compiling from x86 Linux +================================================================================ + +To cross compile SDL for Raspbian from your desktop machine, you'll need a +Raspbian system root and the cross compilation tools. We'll assume these tools +will be placed in /opt/rpi-tools + + sudo git clone --depth 1 https://github.com/raspberrypi/tools /opt/rpi-tools + +You'll also need a Rasbian binary image. +Get it from: http://downloads.raspberrypi.org/raspbian_latest +After unzipping, you'll get file with a name like: -wheezy-raspbian.img +Let's assume the sysroot will be built in /opt/rpi-sysroot. + + export SYSROOT=/opt/rpi-sysroot + sudo kpartx -a -v .img + sudo mount -o loop /dev/mapper/loop0p2 /mnt + sudo cp -r /mnt $SYSROOT + sudo apt-get install qemu binfmt-support qemu-user-static + sudo cp /usr/bin/qemu-arm-static $SYSROOT/usr/bin + sudo mount --bind /dev $SYSROOT/dev + sudo mount --bind /proc $SYSROOT/proc + sudo mount --bind /sys $SYSROOT/sys + +Now, before chrooting into the ARM sysroot, you'll need to apply a workaround, +edit $SYSROOT/etc/ld.so.preload and comment out all lines in it. + + sudo chroot $SYSROOT + apt-get install libudev-dev libasound2-dev libdbus-1-dev libraspberrypi0 libraspberrypi-bin libraspberrypi-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxxf86vm-dev libxss-dev + exit + sudo umount $SYSROOT/dev + sudo umount $SYSROOT/proc + sudo umount $SYSROOT/sys + sudo umount /mnt + +The final step is compiling SDL itself. + + export CC="/opt/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc --sysroot=$SYSROOT -I$SYSROOT/opt/vc/include -I$SYSROOT/usr/include -I$SYSROOT/opt/vc/include/interface/vcos/pthreads -I$SYSROOT/opt/vc/include/interface/vmcs_host/linux" + cd + mkdir -p build;cd build + ../configure --with-sysroot=$SYSROOT --host=arm-raspberry-linux-gnueabihf --prefix=$PWD/rpi-sdl2-installed --disable-pulseaudio --disable-esd + make + make install + +To be able to deploy this to /usr/local in the Raspbian system you need to fix up a few paths: + + perl -w -pi -e "s#$PWD/rpi-sdl2-installed#/usr/local#g;" ./rpi-sdl2-installed/lib/libSDL2.la ./rpi-sdl2-installed/lib/pkgconfig/sdl2.pc ./rpi-sdl2-installed/bin/sdl2-config + +================================================================================ + Apps don't work or poor video/audio performance +================================================================================ + +If you get sound problems, buffer underruns, etc, run "sudo rpi-update" to +update the RPi's firmware. Note that doing so will fix these problems, but it +will also render the CMA - Dynamic Memory Split functionality useless. + +Also, by default the Raspbian distro configures the GPU RAM at 64MB, this is too +low in general, specially if a 1080p TV is hooked up. + +See here how to configure this setting: http://elinux.org/RPiconfig + +Using a fixed gpu_mem=128 is the best option (specially if you updated the +firmware, using CMA probably won't work, at least it's the current case). + +================================================================================ + No input +================================================================================ + +Make sure you belong to the "input" group. + + sudo usermod -aG input `whoami` + +================================================================================ + No HDMI Audio +================================================================================ + +If you notice that ALSA works but there's no audio over HDMI, try adding: + + hdmi_drive=2 + +to your config.txt file and reboot. + +Reference: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=5062 + +================================================================================ + Text Input API support +================================================================================ + +The Text Input API is supported, with translation of scan codes done via the +kernel symbol tables. For this to work, SDL needs access to a valid console. +If you notice there's no SDL_TEXTINPUT message being emmited, double check that +your app has read access to one of the following: + +* /proc/self/fd/0 +* /dev/tty +* /dev/tty[0...6] +* /dev/vc/0 +* /dev/console + +This is usually not a problem if you run from the physical terminal (as opposed +to running from a pseudo terminal, such as via SSH). If running from a PTS, a +quick workaround is to run your app as root or add yourself to the tty group, +then re login to the system. + + sudo usermod -aG tty `whoami` + +The keyboard layout used by SDL is the same as the one the kernel uses. +To configure the layout on Raspbian: + + sudo dpkg-reconfigure keyboard-configuration + +To configure the locale, which controls which keys are interpreted as letters, +this determining the CAPS LOCK behavior: + + sudo dpkg-reconfigure locales + +================================================================================ + Notes +================================================================================ + +* When launching apps remotely (via SSH), SDL can prevent local keystrokes from + leaking into the console only if it has root privileges. Launching apps locally + does not suffer from this issue. + + diff --git a/TODO.txt b/TODO.txt index 14c47d0eb..89637ebdb 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,15 +1,10 @@ Future work roadmap: * http://wiki.libsdl.org/moin.cgi/Roadmap - * See why windows are being rearranged. Is the shield window not up? - * Add __WINDOWS__ in addition to __WIN32__ - * Write test for fullscreen gamma to check X11 colormap handling - * Check 1.2 revisions: 3554 - Need to resolve semantics for locking keys on different platforms 4874 - Do we want screen rotation? At what level? 4974 - Windows file code needs to convert UTF-8 to Unicode, but we don't need to tap dance for Windows 95/98 - 4484, 4485 - Verify that SDL's Windows keyboard handling works correctly 4865 - See if this is still needed (mouse coordinate clamping) 4866 - See if this is still needed (blocking window repositioning) diff --git a/VisualC/SDL/SDL_VS2008.vcproj b/VisualC/SDL/SDL_VS2008.vcproj index 72eb2d4c9..1e7db21a3 100644 --- a/VisualC/SDL/SDL_VS2008.vcproj +++ b/VisualC/SDL/SDL_VS2008.vcproj @@ -427,6 +427,10 @@ RelativePath="..\..\include\SDL_events.h" > + + @@ -1088,6 +1092,10 @@ RelativePath="..\..\src\events\SDL_sysevents.h" > + + diff --git a/VisualC/SDL/SDL_VS2010.vcxproj b/VisualC/SDL/SDL_VS2010.vcxproj index 4fa9111d2..d9ca5aff7 100644 --- a/VisualC/SDL/SDL_VS2010.vcxproj +++ b/VisualC/SDL/SDL_VS2010.vcxproj @@ -1,464 +1,679 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - SDL2 - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} - SDL - - - - DynamicLibrary - false - - - DynamicLibrary - false - - - DynamicLibrary - false - - - DynamicLibrary - false - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Win32 - - - Disabled - ..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include"; - _DEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - false - - - Level3 - true - EditAndContinue - Default - false - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies) - true - true - Windows - false - $(DXSDK_DIR)\lib\x86 - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - X64 - - - Disabled - ..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include"; - _DEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - false - - - Level3 - EditAndContinue - false - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies) - true - true - Windows - false - $(DXSDK_DIR)\lib\x64 - - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - Win32 - - - OnlyExplicitInline - false - ..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include"; - NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - MultiThreadedDLL - false - true - - - Level3 - true - Default - false - ProgramDatabase - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies) - true - Windows - $(DXSDK_DIR)\lib\x86 - true - true - true - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - X64 - - - OnlyExplicitInline - false - ..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include"; - NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - MultiThreadedDLL - false - true - - - Level3 - false - ProgramDatabase - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies) - true - Windows - $(DXSDK_DIR)\lib\x64 - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug_static + Win32 + + + Debug_static + x64 + + + Debug + Win32 + + + Debug + x64 + + + Release_static + Win32 + + + Release_static + x64 + + + Release + Win32 + + + Release + x64 + + + + SDL2 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} + SDL + + + + DynamicLibrary + false + + + StaticLibrary + false + + + DynamicLibrary + false + + + StaticLibrary + false + + + DynamicLibrary + false + + + StaticLibrary + false + + + DynamicLibrary + false + MultiByte + + + StaticLibrary + false + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(ProjectName)_static + $(ProjectName)_static + $(ProjectName)_static + $(ProjectName)_static + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include"; + _DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + false + + + Level3 + true + EditAndContinue + Default + false + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies) + true + true + Windows + false + $(DXSDK_DIR)\lib\x86 + + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include"; + HAVE_LIBC;_CRT_SECURE_NO_WARNINGS;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreaded + false + + + Level3 + true + OldStyle + Default + false + true + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies) + true + true + Windows + false + $(DXSDK_DIR)\lib\x86 + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + X64 + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include"; + _DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + false + + + Level3 + EditAndContinue + false + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies) + true + true + Windows + false + $(DXSDK_DIR)\lib\x64 + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + X64 + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include"; + HAVE_LIBC;_CRT_SECURE_NO_WARNINGS;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreaded + false + + + Level3 + OldStyle + false + true + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies) + true + true + Windows + false + $(DXSDK_DIR)\lib\x64 + + + /MACHINE:X64 %(AdditionalOptions) + + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + + + OnlyExplicitInline + false + ..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include"; + NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreadedDLL + false + true + + + Level3 + true + Default + false + ProgramDatabase + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies) + true + Windows + $(DXSDK_DIR)\lib\x86 + true + true + true + + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + + + OnlyExplicitInline + false + ..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include"; + HAVE_LIBC;_CRT_SECURE_NO_WARNINGS;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreaded + false + true + + + Level3 + true + Default + false + OldStyle + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies) + true + Windows + $(DXSDK_DIR)\lib\x86 + true + true + true + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + + + OnlyExplicitInline + false + ..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include"; + NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreadedDLL + false + true + + + Level3 + false + ProgramDatabase + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies) + true + Windows + $(DXSDK_DIR)\lib\x64 + true + true + true + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + + + OnlyExplicitInline + false + ..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include"; + HAVE_LIBC;_CRT_SECURE_NO_WARNINGS;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreaded + false + true + + + Level3 + false + OldStyle + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + winmm.lib;imm32.lib;oleaut32.lib;version.lib;%(AdditionalDependencies) + true + Windows + $(DXSDK_DIR)\lib\x64 + true + true + true + + + /MACHINE:X64 %(AdditionalOptions) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/VisualC/SDL/SDL_VS2012.vcxproj b/VisualC/SDL/SDL_VS2012.vcxproj index 213c10cef..141bc6481 100644 --- a/VisualC/SDL/SDL_VS2012.vcxproj +++ b/VisualC/SDL/SDL_VS2012.vcxproj @@ -19,7 +19,7 @@ - SDL2 + SDL2 {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} SDL @@ -233,6 +233,7 @@ + @@ -433,6 +434,7 @@ + diff --git a/VisualC/SDL_VS2010.sln b/VisualC/SDL_VS2010.sln index fb5d873f2..3a493acd3 100644 --- a/VisualC/SDL_VS2010.sln +++ b/VisualC/SDL_VS2010.sln @@ -1,255 +1,417 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2", "SDL\SDL_VS2010.vcxproj", "{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2main", "SDLmain\SDLmain_VS2010.vcxproj", "{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{CE748C1F-3C21-4825-AA6A-F895A023F7E7}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "loopwave", "tests\loopwave\loopwave_VS2010.vcxproj", "{AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testplatform", "tests\testplatform\testplatform_VS2010.vcxproj", "{26932B24-EFC6-4E3A-B277-ED653DA37968}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testfile", "tests\testfile\testfile_VS2010.vcxproj", "{CAE4F1D0-314F-4B10-805B-0EFD670133A0}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testgl2", "tests\testgl2\testgl2_VS2010.vcxproj", "{8B5CFB38-CCBA-40A8-AD7A-89C57B070884}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "checkkeys", "tests\checkkeys\checkkeys_VS2010.vcxproj", "{26828762-C95D-4637-9CB1-7F0979523813}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testsprite2", "tests\testsprite2\testsprite2_VS2010.vcxproj", "{40FB7794-D3C3-4CFE-BCF4-A80C96635682}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testshape", "tests\testshape\testshape_VS2010.vcxproj", "{EDEA9D00-AF64-45DE-8F60-5957048F2F0F}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testdraw2", "tests\testdraw2\testdraw2_VS2010.vcxproj", "{8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testpower", "tests\testpower\testpower_VS2010.vcxproj", "{C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2test", "SDLtest\SDLtest_VS2010.vcxproj", "{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testautomation", "tests\testautomation\testautomation_vs2010.vcxproj", "{FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testatomic", "tests\testatomic\testatomic_VS2010.vcxproj", "{2271060E-98B4-4596-8172-A041E4B2EC7A}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testscale", "tests\testscale\testscale_VS2010.vcxproj", "{E7A6C41C-E059-4C9C-8CCC-73586A540B62}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testrendertarget", "tests\testrendertarget\testrendertarget_VS2010.vcxproj", "{43A06713-A52D-4008-AD7E-A69DF3FCFFA8}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testgamecontroller", "tests\testgamecontroller\testgamecontroller_VS2010.vcxproj", "{55812185-D13C-4022-9C81-32E0F4A08336}" - ProjectSection(ProjectDependencies) = postProject - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} - {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} - {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} = {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testgesture", "tests\testgesture\testgesture_VS2010.vcxproj", "{55812185-D13C-4022-9C81-32E0F4A08996}" - ProjectSection(ProjectDependencies) = postProject - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} - {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} - {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} = {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testjoystick", "tests\testjoystick\testjoystick_VS2010.vcxproj", "{55812185-D13C-4022-9C81-32E0F4A08BCC}" - ProjectSection(ProjectDependencies) = postProject - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} - {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} - {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} = {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testoverlay2", "tests\testoverlay2\testoverlay2_VS2010.vcxproj", "{55812185-D13C-4022-9C81-32E0F4A08AAD}" - ProjectSection(ProjectDependencies) = postProject - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} - {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} - {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} = {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|Win32.ActiveCfg = Debug|Win32 - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|Win32.Build.0 = Debug|Win32 - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|x64.ActiveCfg = Debug|x64 - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|x64.Build.0 = Debug|x64 - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|Win32.ActiveCfg = Release|Win32 - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|Win32.Build.0 = Release|Win32 - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|x64.ActiveCfg = Release|x64 - {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|x64.Build.0 = Release|x64 - {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug|Win32.ActiveCfg = Debug|Win32 - {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug|Win32.Build.0 = Debug|Win32 - {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug|x64.ActiveCfg = Debug|x64 - {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug|x64.Build.0 = Debug|x64 - {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|Win32.ActiveCfg = Release|Win32 - {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|Win32.Build.0 = Release|Win32 - {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|x64.ActiveCfg = Release|x64 - {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|x64.Build.0 = Release|x64 - {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Debug|Win32.ActiveCfg = Debug|Win32 - {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Debug|Win32.Build.0 = Debug|Win32 - {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Debug|x64.ActiveCfg = Debug|x64 - {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Debug|x64.Build.0 = Debug|x64 - {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Release|Win32.ActiveCfg = Release|Win32 - {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Release|Win32.Build.0 = Release|Win32 - {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Release|x64.ActiveCfg = Release|x64 - {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Release|x64.Build.0 = Release|x64 - {26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug|Win32.ActiveCfg = Debug|Win32 - {26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug|Win32.Build.0 = Debug|Win32 - {26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug|x64.ActiveCfg = Debug|x64 - {26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug|x64.Build.0 = Debug|x64 - {26932B24-EFC6-4E3A-B277-ED653DA37968}.Release|Win32.ActiveCfg = Release|Win32 - {26932B24-EFC6-4E3A-B277-ED653DA37968}.Release|Win32.Build.0 = Release|Win32 - {26932B24-EFC6-4E3A-B277-ED653DA37968}.Release|x64.ActiveCfg = Release|x64 - {26932B24-EFC6-4E3A-B277-ED653DA37968}.Release|x64.Build.0 = Release|x64 - {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Debug|Win32.ActiveCfg = Debug|Win32 - {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Debug|Win32.Build.0 = Debug|Win32 - {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Debug|x64.ActiveCfg = Debug|x64 - {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Debug|x64.Build.0 = Debug|x64 - {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Release|Win32.ActiveCfg = Release|Win32 - {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Release|Win32.Build.0 = Release|Win32 - {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Release|x64.ActiveCfg = Release|x64 - {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Release|x64.Build.0 = Release|x64 - {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Debug|Win32.ActiveCfg = Debug|Win32 - {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Debug|Win32.Build.0 = Debug|Win32 - {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Debug|x64.ActiveCfg = Debug|x64 - {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Debug|x64.Build.0 = Debug|x64 - {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release|Win32.ActiveCfg = Release|Win32 - {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release|Win32.Build.0 = Release|Win32 - {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release|x64.ActiveCfg = Release|x64 - {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release|x64.Build.0 = Release|x64 - {26828762-C95D-4637-9CB1-7F0979523813}.Debug|Win32.ActiveCfg = Debug|Win32 - {26828762-C95D-4637-9CB1-7F0979523813}.Debug|Win32.Build.0 = Debug|Win32 - {26828762-C95D-4637-9CB1-7F0979523813}.Debug|x64.ActiveCfg = Debug|x64 - {26828762-C95D-4637-9CB1-7F0979523813}.Debug|x64.Build.0 = Debug|x64 - {26828762-C95D-4637-9CB1-7F0979523813}.Release|Win32.ActiveCfg = Release|Win32 - {26828762-C95D-4637-9CB1-7F0979523813}.Release|Win32.Build.0 = Release|Win32 - {26828762-C95D-4637-9CB1-7F0979523813}.Release|x64.ActiveCfg = Release|x64 - {26828762-C95D-4637-9CB1-7F0979523813}.Release|x64.Build.0 = Release|x64 - {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|Win32.ActiveCfg = Debug|Win32 - {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|Win32.Build.0 = Debug|Win32 - {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|x64.ActiveCfg = Debug|x64 - {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|x64.Build.0 = Debug|x64 - {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|Win32.ActiveCfg = Release|Win32 - {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|Win32.Build.0 = Release|Win32 - {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|x64.ActiveCfg = Release|x64 - {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|x64.Build.0 = Release|x64 - {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Debug|Win32.ActiveCfg = Debug|Win32 - {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Debug|Win32.Build.0 = Debug|Win32 - {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Debug|x64.ActiveCfg = Debug|x64 - {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Debug|x64.Build.0 = Debug|x64 - {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Release|Win32.ActiveCfg = Release|Win32 - {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Release|Win32.Build.0 = Release|Win32 - {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Release|x64.ActiveCfg = Release|x64 - {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Release|x64.Build.0 = Release|x64 - {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Debug|Win32.ActiveCfg = Debug|Win32 - {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Debug|Win32.Build.0 = Debug|Win32 - {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Debug|x64.ActiveCfg = Debug|x64 - {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Debug|x64.Build.0 = Debug|x64 - {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Release|Win32.ActiveCfg = Release|Win32 - {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Release|Win32.Build.0 = Release|Win32 - {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Release|x64.ActiveCfg = Release|x64 - {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Release|x64.Build.0 = Release|x64 - {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Debug|Win32.ActiveCfg = Debug|Win32 - {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Debug|Win32.Build.0 = Debug|Win32 - {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Debug|x64.ActiveCfg = Debug|x64 - {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Debug|x64.Build.0 = Debug|x64 - {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|Win32.ActiveCfg = Release|Win32 - {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|Win32.Build.0 = Release|Win32 - {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|x64.ActiveCfg = Release|x64 - {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|x64.Build.0 = Release|x64 - {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|Win32.ActiveCfg = Debug|Win32 - {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|Win32.Build.0 = Debug|Win32 - {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|x64.ActiveCfg = Debug|x64 - {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|x64.Build.0 = Debug|x64 - {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|Win32.ActiveCfg = Release|Win32 - {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|Win32.Build.0 = Release|Win32 - {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|x64.ActiveCfg = Release|x64 - {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|x64.Build.0 = Release|x64 - {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Debug|Win32.ActiveCfg = Debug|Win32 - {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Debug|Win32.Build.0 = Debug|Win32 - {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Debug|x64.ActiveCfg = Debug|x64 - {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Debug|x64.Build.0 = Debug|x64 - {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Release|Win32.ActiveCfg = Release|Win32 - {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Release|Win32.Build.0 = Release|Win32 - {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Release|x64.ActiveCfg = Release|x64 - {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Release|x64.Build.0 = Release|x64 - {2271060E-98B4-4596-8172-A041E4B2EC7A}.Debug|Win32.ActiveCfg = Debug|Win32 - {2271060E-98B4-4596-8172-A041E4B2EC7A}.Debug|Win32.Build.0 = Debug|Win32 - {2271060E-98B4-4596-8172-A041E4B2EC7A}.Debug|x64.ActiveCfg = Debug|Win32 - {2271060E-98B4-4596-8172-A041E4B2EC7A}.Release|Win32.ActiveCfg = Release|Win32 - {2271060E-98B4-4596-8172-A041E4B2EC7A}.Release|Win32.Build.0 = Release|Win32 - {2271060E-98B4-4596-8172-A041E4B2EC7A}.Release|x64.ActiveCfg = Release|Win32 - {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Debug|Win32.ActiveCfg = Debug|Win32 - {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Debug|Win32.Build.0 = Debug|Win32 - {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Debug|x64.ActiveCfg = Debug|x64 - {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Debug|x64.Build.0 = Debug|x64 - {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Release|Win32.ActiveCfg = Release|Win32 - {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Release|Win32.Build.0 = Release|Win32 - {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Release|x64.ActiveCfg = Release|x64 - {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Release|x64.Build.0 = Release|x64 - {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Debug|Win32.ActiveCfg = Debug|Win32 - {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Debug|Win32.Build.0 = Debug|Win32 - {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Debug|x64.ActiveCfg = Debug|x64 - {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Debug|x64.Build.0 = Debug|x64 - {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Release|Win32.ActiveCfg = Release|Win32 - {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Release|Win32.Build.0 = Release|Win32 - {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Release|x64.ActiveCfg = Release|x64 - {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Release|x64.Build.0 = Release|x64 - {55812185-D13C-4022-9C81-32E0F4A08336}.Debug|Win32.ActiveCfg = Debug|Win32 - {55812185-D13C-4022-9C81-32E0F4A08336}.Debug|Win32.Build.0 = Debug|Win32 - {55812185-D13C-4022-9C81-32E0F4A08336}.Debug|x64.ActiveCfg = Debug|x64 - {55812185-D13C-4022-9C81-32E0F4A08336}.Debug|x64.Build.0 = Debug|x64 - {55812185-D13C-4022-9C81-32E0F4A08336}.Release|Win32.ActiveCfg = Release|Win32 - {55812185-D13C-4022-9C81-32E0F4A08336}.Release|Win32.Build.0 = Release|Win32 - {55812185-D13C-4022-9C81-32E0F4A08336}.Release|x64.ActiveCfg = Release|x64 - {55812185-D13C-4022-9C81-32E0F4A08336}.Release|x64.Build.0 = Release|x64 - {55812185-D13C-4022-9C81-32E0F4A08996}.Debug|Win32.ActiveCfg = Debug|Win32 - {55812185-D13C-4022-9C81-32E0F4A08996}.Debug|Win32.Build.0 = Debug|Win32 - {55812185-D13C-4022-9C81-32E0F4A08996}.Debug|x64.ActiveCfg = Debug|x64 - {55812185-D13C-4022-9C81-32E0F4A08996}.Debug|x64.Build.0 = Debug|x64 - {55812185-D13C-4022-9C81-32E0F4A08996}.Release|Win32.ActiveCfg = Release|Win32 - {55812185-D13C-4022-9C81-32E0F4A08996}.Release|Win32.Build.0 = Release|Win32 - {55812185-D13C-4022-9C81-32E0F4A08996}.Release|x64.ActiveCfg = Release|x64 - {55812185-D13C-4022-9C81-32E0F4A08996}.Release|x64.Build.0 = Release|x64 - {55812185-D13C-4022-9C81-32E0F4A08BCC}.Debug|Win32.ActiveCfg = Debug|Win32 - {55812185-D13C-4022-9C81-32E0F4A08BCC}.Debug|Win32.Build.0 = Debug|Win32 - {55812185-D13C-4022-9C81-32E0F4A08BCC}.Debug|x64.ActiveCfg = Debug|x64 - {55812185-D13C-4022-9C81-32E0F4A08BCC}.Debug|x64.Build.0 = Debug|x64 - {55812185-D13C-4022-9C81-32E0F4A08BCC}.Release|Win32.ActiveCfg = Release|Win32 - {55812185-D13C-4022-9C81-32E0F4A08BCC}.Release|Win32.Build.0 = Release|Win32 - {55812185-D13C-4022-9C81-32E0F4A08BCC}.Release|x64.ActiveCfg = Release|x64 - {55812185-D13C-4022-9C81-32E0F4A08BCC}.Release|x64.Build.0 = Release|x64 - {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug|Win32.ActiveCfg = Debug|Win32 - {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug|Win32.Build.0 = Debug|Win32 - {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug|x64.ActiveCfg = Debug|x64 - {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug|x64.Build.0 = Debug|x64 - {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release|Win32.ActiveCfg = Release|Win32 - {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release|Win32.Build.0 = Release|Win32 - {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release|x64.ActiveCfg = Release|x64 - {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {26932B24-EFC6-4E3A-B277-ED653DA37968} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {CAE4F1D0-314F-4B10-805B-0EFD670133A0} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {8B5CFB38-CCBA-40A8-AD7A-89C57B070884} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {26828762-C95D-4637-9CB1-7F0979523813} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {40FB7794-D3C3-4CFE-BCF4-A80C96635682} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {EDEA9D00-AF64-45DE-8F60-5957048F2F0F} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {2271060E-98B4-4596-8172-A041E4B2EC7A} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {E7A6C41C-E059-4C9C-8CCC-73586A540B62} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {43A06713-A52D-4008-AD7E-A69DF3FCFFA8} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {55812185-D13C-4022-9C81-32E0F4A08336} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {55812185-D13C-4022-9C81-32E0F4A08996} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {55812185-D13C-4022-9C81-32E0F4A08BCC} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - {55812185-D13C-4022-9C81-32E0F4A08AAD} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2", "SDL\SDL_VS2010.vcxproj", "{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2main", "SDLmain\SDLmain_VS2010.vcxproj", "{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{CE748C1F-3C21-4825-AA6A-F895A023F7E7}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "loopwave", "tests\loopwave\loopwave_VS2010.vcxproj", "{AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testplatform", "tests\testplatform\testplatform_VS2010.vcxproj", "{26932B24-EFC6-4E3A-B277-ED653DA37968}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testfile", "tests\testfile\testfile_VS2010.vcxproj", "{CAE4F1D0-314F-4B10-805B-0EFD670133A0}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testgl2", "tests\testgl2\testgl2_VS2010.vcxproj", "{8B5CFB38-CCBA-40A8-AD7A-89C57B070884}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "checkkeys", "tests\checkkeys\checkkeys_VS2010.vcxproj", "{26828762-C95D-4637-9CB1-7F0979523813}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testsprite2", "tests\testsprite2\testsprite2_VS2010.vcxproj", "{40FB7794-D3C3-4CFE-BCF4-A80C96635682}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testshape", "tests\testshape\testshape_VS2010.vcxproj", "{EDEA9D00-AF64-45DE-8F60-5957048F2F0F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testdraw2", "tests\testdraw2\testdraw2_VS2010.vcxproj", "{8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testpower", "tests\testpower\testpower_VS2010.vcxproj", "{C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2test", "SDLtest\SDLtest_VS2010.vcxproj", "{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testautomation", "tests\testautomation\testautomation_vs2010.vcxproj", "{FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testatomic", "tests\testatomic\testatomic_VS2010.vcxproj", "{2271060E-98B4-4596-8172-A041E4B2EC7A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testscale", "tests\testscale\testscale_VS2010.vcxproj", "{E7A6C41C-E059-4C9C-8CCC-73586A540B62}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testrendertarget", "tests\testrendertarget\testrendertarget_VS2010.vcxproj", "{43A06713-A52D-4008-AD7E-A69DF3FCFFA8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testgamecontroller", "tests\testgamecontroller\testgamecontroller_VS2010.vcxproj", "{55812185-D13C-4022-9C81-32E0F4A08336}" + ProjectSection(ProjectDependencies) = postProject + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} = {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testgesture", "tests\testgesture\testgesture_VS2010.vcxproj", "{55812185-D13C-4022-9C81-32E0F4A08996}" + ProjectSection(ProjectDependencies) = postProject + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} = {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testjoystick", "tests\testjoystick\testjoystick_VS2010.vcxproj", "{55812185-D13C-4022-9C81-32E0F4A08BCC}" + ProjectSection(ProjectDependencies) = postProject + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} = {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testoverlay2", "tests\testoverlay2\testoverlay2_VS2010.vcxproj", "{55812185-D13C-4022-9C81-32E0F4A08AAD}" + ProjectSection(ProjectDependencies) = postProject + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} = {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug_static|Win32 = Debug_static|Win32 + Debug_static|x64 = Debug_static|x64 + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release_static|Win32 = Release_static|Win32 + Release_static|x64 = Release_static|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug_static|Win32.ActiveCfg = Debug_static|Win32 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug_static|Win32.Build.0 = Debug_static|Win32 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug_static|x64.ActiveCfg = Debug_static|x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug_static|x64.Build.0 = Debug_static|x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|Win32.ActiveCfg = Debug|Win32 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|Win32.Build.0 = Debug|Win32 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|x64.ActiveCfg = Debug|x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Debug|x64.Build.0 = Debug|x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release_static|Win32.ActiveCfg = Release_static|Win32 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release_static|Win32.Build.0 = Release_static|Win32 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release_static|x64.ActiveCfg = Release|x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release_static|x64.Build.0 = Release|x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|Win32.ActiveCfg = Release|Win32 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|Win32.Build.0 = Release|Win32 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|x64.ActiveCfg = Release|x64 + {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}.Release|x64.Build.0 = Release|x64 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug_static|Win32.Build.0 = Debug|Win32 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug_static|x64.ActiveCfg = Debug|x64 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug_static|x64.Build.0 = Debug|x64 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug|Win32.ActiveCfg = Debug|Win32 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug|Win32.Build.0 = Debug|Win32 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug|x64.ActiveCfg = Debug|x64 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Debug|x64.Build.0 = Debug|x64 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release_static|Win32.ActiveCfg = Release|Win32 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release_static|Win32.Build.0 = Release|Win32 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release_static|x64.ActiveCfg = Release|x64 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release_static|x64.Build.0 = Release|x64 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|Win32.ActiveCfg = Release|Win32 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|Win32.Build.0 = Release|Win32 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|x64.ActiveCfg = Release|x64 + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|x64.Build.0 = Release|x64 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Debug_static|Win32.Build.0 = Debug|Win32 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Debug_static|x64.ActiveCfg = Debug|x64 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Debug_static|x64.Build.0 = Debug|x64 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Debug|Win32.ActiveCfg = Debug|Win32 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Debug|Win32.Build.0 = Debug|Win32 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Debug|x64.ActiveCfg = Debug|x64 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Debug|x64.Build.0 = Debug|x64 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Release_static|Win32.ActiveCfg = Release|Win32 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Release_static|Win32.Build.0 = Release|Win32 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Release_static|x64.ActiveCfg = Release|x64 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Release_static|x64.Build.0 = Release|x64 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Release|Win32.ActiveCfg = Release|Win32 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Release|Win32.Build.0 = Release|Win32 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Release|x64.ActiveCfg = Release|x64 + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB}.Release|x64.Build.0 = Release|x64 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug_static|Win32.Build.0 = Debug|Win32 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug_static|x64.ActiveCfg = Debug|x64 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug_static|x64.Build.0 = Debug|x64 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug|Win32.ActiveCfg = Debug|Win32 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug|Win32.Build.0 = Debug|Win32 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug|x64.ActiveCfg = Debug|x64 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug|x64.Build.0 = Debug|x64 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Release_static|Win32.ActiveCfg = Release|Win32 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Release_static|Win32.Build.0 = Release|Win32 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Release_static|x64.ActiveCfg = Release|x64 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Release_static|x64.Build.0 = Release|x64 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Release|Win32.ActiveCfg = Release|Win32 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Release|Win32.Build.0 = Release|Win32 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Release|x64.ActiveCfg = Release|x64 + {26932B24-EFC6-4E3A-B277-ED653DA37968}.Release|x64.Build.0 = Release|x64 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Debug_static|Win32.Build.0 = Debug|Win32 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Debug_static|x64.ActiveCfg = Debug|x64 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Debug_static|x64.Build.0 = Debug|x64 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Debug|Win32.ActiveCfg = Debug|Win32 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Debug|Win32.Build.0 = Debug|Win32 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Debug|x64.ActiveCfg = Debug|x64 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Debug|x64.Build.0 = Debug|x64 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Release_static|Win32.ActiveCfg = Release|Win32 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Release_static|Win32.Build.0 = Release|Win32 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Release_static|x64.ActiveCfg = Release|x64 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Release_static|x64.Build.0 = Release|x64 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Release|Win32.ActiveCfg = Release|Win32 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Release|Win32.Build.0 = Release|Win32 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Release|x64.ActiveCfg = Release|x64 + {CAE4F1D0-314F-4B10-805B-0EFD670133A0}.Release|x64.Build.0 = Release|x64 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Debug_static|Win32.Build.0 = Debug|Win32 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Debug_static|x64.ActiveCfg = Debug|x64 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Debug_static|x64.Build.0 = Debug|x64 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Debug|Win32.ActiveCfg = Debug|Win32 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Debug|Win32.Build.0 = Debug|Win32 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Debug|x64.ActiveCfg = Debug|x64 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Debug|x64.Build.0 = Debug|x64 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release_static|Win32.ActiveCfg = Release|Win32 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release_static|Win32.Build.0 = Release|Win32 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release_static|x64.ActiveCfg = Release|x64 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release_static|x64.Build.0 = Release|x64 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release|Win32.ActiveCfg = Release|Win32 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release|Win32.Build.0 = Release|Win32 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release|x64.ActiveCfg = Release|x64 + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884}.Release|x64.Build.0 = Release|x64 + {26828762-C95D-4637-9CB1-7F0979523813}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {26828762-C95D-4637-9CB1-7F0979523813}.Debug_static|Win32.Build.0 = Debug|Win32 + {26828762-C95D-4637-9CB1-7F0979523813}.Debug_static|x64.ActiveCfg = Debug|x64 + {26828762-C95D-4637-9CB1-7F0979523813}.Debug_static|x64.Build.0 = Debug|x64 + {26828762-C95D-4637-9CB1-7F0979523813}.Debug|Win32.ActiveCfg = Debug|Win32 + {26828762-C95D-4637-9CB1-7F0979523813}.Debug|Win32.Build.0 = Debug|Win32 + {26828762-C95D-4637-9CB1-7F0979523813}.Debug|x64.ActiveCfg = Debug|x64 + {26828762-C95D-4637-9CB1-7F0979523813}.Debug|x64.Build.0 = Debug|x64 + {26828762-C95D-4637-9CB1-7F0979523813}.Release_static|Win32.ActiveCfg = Release|Win32 + {26828762-C95D-4637-9CB1-7F0979523813}.Release_static|Win32.Build.0 = Release|Win32 + {26828762-C95D-4637-9CB1-7F0979523813}.Release_static|x64.ActiveCfg = Release|x64 + {26828762-C95D-4637-9CB1-7F0979523813}.Release_static|x64.Build.0 = Release|x64 + {26828762-C95D-4637-9CB1-7F0979523813}.Release|Win32.ActiveCfg = Release|Win32 + {26828762-C95D-4637-9CB1-7F0979523813}.Release|Win32.Build.0 = Release|Win32 + {26828762-C95D-4637-9CB1-7F0979523813}.Release|x64.ActiveCfg = Release|x64 + {26828762-C95D-4637-9CB1-7F0979523813}.Release|x64.Build.0 = Release|x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug_static|Win32.Build.0 = Debug|Win32 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug_static|x64.ActiveCfg = Debug|x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug_static|x64.Build.0 = Debug|x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|Win32.ActiveCfg = Debug|Win32 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|Win32.Build.0 = Debug|Win32 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|x64.ActiveCfg = Debug|x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|x64.Build.0 = Debug|x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release_static|Win32.ActiveCfg = Release|Win32 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release_static|Win32.Build.0 = Release|Win32 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release_static|x64.ActiveCfg = Release|x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release_static|x64.Build.0 = Release|x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|Win32.ActiveCfg = Release|Win32 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|Win32.Build.0 = Release|Win32 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|x64.ActiveCfg = Release|x64 + {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|x64.Build.0 = Release|x64 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Debug_static|Win32.Build.0 = Debug|Win32 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Debug_static|x64.ActiveCfg = Debug|x64 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Debug_static|x64.Build.0 = Debug|x64 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Debug|Win32.ActiveCfg = Debug|Win32 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Debug|Win32.Build.0 = Debug|Win32 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Debug|x64.ActiveCfg = Debug|x64 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Debug|x64.Build.0 = Debug|x64 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Release_static|Win32.ActiveCfg = Release|Win32 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Release_static|Win32.Build.0 = Release|Win32 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Release_static|x64.ActiveCfg = Release|x64 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Release_static|x64.Build.0 = Release|x64 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Release|Win32.ActiveCfg = Release|Win32 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Release|Win32.Build.0 = Release|Win32 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Release|x64.ActiveCfg = Release|x64 + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F}.Release|x64.Build.0 = Release|x64 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Debug_static|Win32.Build.0 = Debug|Win32 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Debug_static|x64.ActiveCfg = Debug|x64 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Debug_static|x64.Build.0 = Debug|x64 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Debug|Win32.ActiveCfg = Debug|Win32 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Debug|Win32.Build.0 = Debug|Win32 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Debug|x64.ActiveCfg = Debug|x64 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Debug|x64.Build.0 = Debug|x64 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Release_static|Win32.ActiveCfg = Release|Win32 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Release_static|Win32.Build.0 = Release|Win32 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Release_static|x64.ActiveCfg = Release|x64 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Release_static|x64.Build.0 = Release|x64 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Release|Win32.ActiveCfg = Release|Win32 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Release|Win32.Build.0 = Release|Win32 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Release|x64.ActiveCfg = Release|x64 + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF}.Release|x64.Build.0 = Release|x64 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Debug_static|Win32.Build.0 = Debug|Win32 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Debug_static|x64.ActiveCfg = Debug|x64 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Debug_static|x64.Build.0 = Debug|x64 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Debug|Win32.ActiveCfg = Debug|Win32 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Debug|Win32.Build.0 = Debug|Win32 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Debug|x64.ActiveCfg = Debug|x64 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Debug|x64.Build.0 = Debug|x64 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release_static|Win32.ActiveCfg = Release|Win32 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release_static|Win32.Build.0 = Release|Win32 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release_static|x64.ActiveCfg = Release|x64 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release_static|x64.Build.0 = Release|x64 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|Win32.ActiveCfg = Release|Win32 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|Win32.Build.0 = Release|Win32 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|x64.ActiveCfg = Release|x64 + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3}.Release|x64.Build.0 = Release|x64 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug_static|Win32.Build.0 = Debug|Win32 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug_static|x64.ActiveCfg = Debug|x64 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug_static|x64.Build.0 = Debug|x64 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|Win32.ActiveCfg = Debug|Win32 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|Win32.Build.0 = Debug|Win32 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|x64.ActiveCfg = Debug|x64 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Debug|x64.Build.0 = Debug|x64 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release_static|Win32.ActiveCfg = Release|Win32 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release_static|Win32.Build.0 = Release|Win32 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release_static|x64.ActiveCfg = Release|x64 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release_static|x64.Build.0 = Release|x64 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|Win32.ActiveCfg = Release|Win32 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|Win32.Build.0 = Release|Win32 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|x64.ActiveCfg = Release|x64 + {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}.Release|x64.Build.0 = Release|x64 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Debug_static|Win32.Build.0 = Debug|Win32 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Debug_static|x64.ActiveCfg = Debug|x64 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Debug_static|x64.Build.0 = Debug|x64 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Debug|Win32.ActiveCfg = Debug|Win32 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Debug|Win32.Build.0 = Debug|Win32 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Debug|x64.ActiveCfg = Debug|x64 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Debug|x64.Build.0 = Debug|x64 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Release_static|Win32.ActiveCfg = Release|Win32 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Release_static|Win32.Build.0 = Release|Win32 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Release_static|x64.ActiveCfg = Release|x64 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Release_static|x64.Build.0 = Release|x64 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Release|Win32.ActiveCfg = Release|Win32 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Release|Win32.Build.0 = Release|Win32 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Release|x64.ActiveCfg = Release|x64 + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0}.Release|x64.Build.0 = Release|x64 + {2271060E-98B4-4596-8172-A041E4B2EC7A}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {2271060E-98B4-4596-8172-A041E4B2EC7A}.Debug_static|Win32.Build.0 = Debug|Win32 + {2271060E-98B4-4596-8172-A041E4B2EC7A}.Debug_static|x64.ActiveCfg = Debug|Win32 + {2271060E-98B4-4596-8172-A041E4B2EC7A}.Debug|Win32.ActiveCfg = Debug|Win32 + {2271060E-98B4-4596-8172-A041E4B2EC7A}.Debug|Win32.Build.0 = Debug|Win32 + {2271060E-98B4-4596-8172-A041E4B2EC7A}.Debug|x64.ActiveCfg = Debug|Win32 + {2271060E-98B4-4596-8172-A041E4B2EC7A}.Release_static|Win32.ActiveCfg = Release|Win32 + {2271060E-98B4-4596-8172-A041E4B2EC7A}.Release_static|Win32.Build.0 = Release|Win32 + {2271060E-98B4-4596-8172-A041E4B2EC7A}.Release_static|x64.ActiveCfg = Release|Win32 + {2271060E-98B4-4596-8172-A041E4B2EC7A}.Release|Win32.ActiveCfg = Release|Win32 + {2271060E-98B4-4596-8172-A041E4B2EC7A}.Release|Win32.Build.0 = Release|Win32 + {2271060E-98B4-4596-8172-A041E4B2EC7A}.Release|x64.ActiveCfg = Release|Win32 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Debug_static|Win32.Build.0 = Debug|Win32 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Debug_static|x64.ActiveCfg = Debug|x64 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Debug_static|x64.Build.0 = Debug|x64 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Debug|Win32.ActiveCfg = Debug|Win32 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Debug|Win32.Build.0 = Debug|Win32 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Debug|x64.ActiveCfg = Debug|x64 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Debug|x64.Build.0 = Debug|x64 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Release_static|Win32.ActiveCfg = Release|Win32 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Release_static|Win32.Build.0 = Release|Win32 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Release_static|x64.ActiveCfg = Release|x64 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Release_static|x64.Build.0 = Release|x64 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Release|Win32.ActiveCfg = Release|Win32 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Release|Win32.Build.0 = Release|Win32 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Release|x64.ActiveCfg = Release|x64 + {E7A6C41C-E059-4C9C-8CCC-73586A540B62}.Release|x64.Build.0 = Release|x64 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Debug_static|Win32.Build.0 = Debug|Win32 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Debug_static|x64.ActiveCfg = Debug|x64 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Debug_static|x64.Build.0 = Debug|x64 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Debug|Win32.ActiveCfg = Debug|Win32 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Debug|Win32.Build.0 = Debug|Win32 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Debug|x64.ActiveCfg = Debug|x64 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Debug|x64.Build.0 = Debug|x64 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Release_static|Win32.ActiveCfg = Release|Win32 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Release_static|Win32.Build.0 = Release|Win32 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Release_static|x64.ActiveCfg = Release|x64 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Release_static|x64.Build.0 = Release|x64 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Release|Win32.ActiveCfg = Release|Win32 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Release|Win32.Build.0 = Release|Win32 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Release|x64.ActiveCfg = Release|x64 + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8}.Release|x64.Build.0 = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08336}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08336}.Debug_static|Win32.Build.0 = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08336}.Debug_static|x64.ActiveCfg = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08336}.Debug_static|x64.Build.0 = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08336}.Debug|Win32.ActiveCfg = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08336}.Debug|Win32.Build.0 = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08336}.Debug|x64.ActiveCfg = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08336}.Debug|x64.Build.0 = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08336}.Release_static|Win32.ActiveCfg = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08336}.Release_static|Win32.Build.0 = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08336}.Release_static|x64.ActiveCfg = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08336}.Release_static|x64.Build.0 = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08336}.Release|Win32.ActiveCfg = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08336}.Release|Win32.Build.0 = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08336}.Release|x64.ActiveCfg = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08336}.Release|x64.Build.0 = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08996}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08996}.Debug_static|Win32.Build.0 = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08996}.Debug_static|x64.ActiveCfg = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08996}.Debug_static|x64.Build.0 = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08996}.Debug|Win32.ActiveCfg = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08996}.Debug|Win32.Build.0 = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08996}.Debug|x64.ActiveCfg = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08996}.Debug|x64.Build.0 = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08996}.Release_static|Win32.ActiveCfg = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08996}.Release_static|Win32.Build.0 = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08996}.Release_static|x64.ActiveCfg = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08996}.Release_static|x64.Build.0 = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08996}.Release|Win32.ActiveCfg = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08996}.Release|Win32.Build.0 = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08996}.Release|x64.ActiveCfg = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08996}.Release|x64.Build.0 = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Debug_static|Win32.Build.0 = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Debug_static|x64.ActiveCfg = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Debug_static|x64.Build.0 = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Debug|Win32.ActiveCfg = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Debug|Win32.Build.0 = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Debug|x64.ActiveCfg = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Debug|x64.Build.0 = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Release_static|Win32.ActiveCfg = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Release_static|Win32.Build.0 = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Release_static|x64.ActiveCfg = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Release_static|x64.Build.0 = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Release|Win32.ActiveCfg = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Release|Win32.Build.0 = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Release|x64.ActiveCfg = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08BCC}.Release|x64.Build.0 = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug_static|Win32.ActiveCfg = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug_static|Win32.Build.0 = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug_static|x64.ActiveCfg = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug_static|x64.Build.0 = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug|Win32.ActiveCfg = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug|Win32.Build.0 = Debug|Win32 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug|x64.ActiveCfg = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug|x64.Build.0 = Debug|x64 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release_static|Win32.ActiveCfg = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release_static|Win32.Build.0 = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release_static|x64.ActiveCfg = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release_static|x64.Build.0 = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release|Win32.ActiveCfg = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release|Win32.Build.0 = Release|Win32 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release|x64.ActiveCfg = Release|x64 + {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {AAAD1CB5-7ADA-47AE-85A0-08A6EC48FAFB} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {26932B24-EFC6-4E3A-B277-ED653DA37968} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {CAE4F1D0-314F-4B10-805B-0EFD670133A0} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {8B5CFB38-CCBA-40A8-AD7A-89C57B070884} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {26828762-C95D-4637-9CB1-7F0979523813} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {40FB7794-D3C3-4CFE-BCF4-A80C96635682} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {EDEA9D00-AF64-45DE-8F60-5957048F2F0F} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {8682FE1E-0CF6-4EDD-9BB5-1733D8C8B4DF} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {FEE710DB-EC7B-4CCB-BD75-535D401A2FE0} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {2271060E-98B4-4596-8172-A041E4B2EC7A} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {E7A6C41C-E059-4C9C-8CCC-73586A540B62} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {43A06713-A52D-4008-AD7E-A69DF3FCFFA8} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {55812185-D13C-4022-9C81-32E0F4A08336} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {55812185-D13C-4022-9C81-32E0F4A08996} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {55812185-D13C-4022-9C81-32E0F4A08BCC} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + {55812185-D13C-4022-9C81-32E0F4A08AAD} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7} + EndGlobalSection +EndGlobal diff --git a/VisualC/tests/loopwave/loopwave_VS2010.vcxproj b/VisualC/tests/loopwave/loopwave_VS2010.vcxproj index 4ef300ad0..1fd518982 100644 --- a/VisualC/tests/loopwave/loopwave_VS2010.vcxproj +++ b/VisualC/tests/loopwave/loopwave_VS2010.vcxproj @@ -1,4 +1,4 @@ - + @@ -105,7 +105,8 @@ Windows - copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" + copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" +copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav" Copy SDL @@ -139,7 +140,8 @@ Windows - copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" + copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" +copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav" Copy SDL @@ -174,7 +176,8 @@ Windows - copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" + copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" +copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav" Copy SDL @@ -208,7 +211,8 @@ Windows - copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" + copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" +copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav" Copy SDL diff --git a/VisualC/tests/loopwave/loopwave_VS2012.vcxproj b/VisualC/tests/loopwave/loopwave_VS2012.vcxproj index 0a648593e..ea983c5d8 100644 --- a/VisualC/tests/loopwave/loopwave_VS2012.vcxproj +++ b/VisualC/tests/loopwave/loopwave_VS2012.vcxproj @@ -109,7 +109,8 @@ Windows - copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" + copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" +copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav" Copy SDL @@ -143,7 +144,8 @@ Windows - copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" + copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" +copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav" Copy SDL @@ -178,7 +180,8 @@ Windows - copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" + copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" +copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav" Copy SDL @@ -212,7 +215,8 @@ Windows - copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" + copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll" +copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav" Copy SDL diff --git a/WhatsNew.txt b/WhatsNew.txt index c3784deab..5ac78c513 100644 --- a/WhatsNew.txt +++ b/WhatsNew.txt @@ -1,3 +1,57 @@ -This is a list of API changes in SDL's version history. +This is a list of major changes in SDL's version history. +--------------------------------------------------------------------------- +2.0.1: +--------------------------------------------------------------------------- + +General: +* Added an API to get common filesystem paths in SDL_filesystem.h: + SDL_GetBasePath(), SDL_GetPrefPath() +* Added an API to do optimized YV12 and IYUV texture updates: + SDL_UpdateYUVTexture() +* Added an API to get the amount of RAM on the system: + SDL_GetSystemRAM() +* Added a macro to perform timestamp comparisons with SDL_GetTicks(): + SDL_TICKS_PASSED() +* Dramatically improved OpenGL ES 2.0 rendering performance +* Added OpenGL attribute SDL_GL_FRAMEBUFFER_SRGB_CAPABLE + +Windows: +* Created a static library configuration for the Visual Studio 2010 project +* Added a hint to create the Direct3D device with support for multi-threading: + SDL_HINT_RENDER_DIRECT3D_THREADSAFE +* Added a function to get the D3D9 adapter index for a display: + SDL_Direct3D9GetAdapterIndex() +* Added a function to get the D3D9 device for a D3D9 renderer: + SDL_RenderGetD3D9Device() +* Fixed building SDL with the mingw32 toolchain (mingw-w64 is preferred) +* Fixed crash when using two XInput controllers at the same time +* Fixed detecting a mixture of XInput and DirectInput controllers +* Fixed clearing a D3D render target larger than the window +* Improved support for format specifiers in SDL_snprintf() + +Mac OS X: +* Added support for retina displays: + Create your window with the SDL_WINDOW_ALLOW_HIGHDPI flag, and then use SDL_GL_GetDrawableSize() to find the actual drawable size. You are responsible for scaling mouse and drawing coordinates appropriately. +* Fixed mouse warping in fullscreen mode +* Right mouse click is emulated by holding the Ctrl key while left clicking + +Linux: +* Fixed float audio support with the PulseAudio driver +* Fixed missing line endpoints in the OpenGL renderer on some drivers +* X11 symbols are no longer defined to avoid collisions when linking statically + +iOS: +* Fixed status bar visibility on iOS 7 +* Flipped the accelerometer Y axis to match expected values + +Android: +IMPORTANT: You MUST get the updated SDLActivity.java to match C code +* Moved EGL initialization to native code +* Fixed the accelerometer axis rotation relative to the device rotation +* Fixed race conditions when handling the EGL context on pause/resume +* Touch devices are available for enumeration immediately after init + +Raspberry Pi: +* Added support for the Raspberry Pi, see README-raspberrypi.txt for details diff --git a/Xcode-iOS/Demos/src/accelerometer.c b/Xcode-iOS/Demos/src/accelerometer.c index 115de627f..3b7985faa 100644 --- a/Xcode-iOS/Demos/src/accelerometer.c +++ b/Xcode-iOS/Demos/src/accelerometer.c @@ -31,19 +31,19 @@ static SDL_Texture *ship = 0; /* texture for spaceship */ static SDL_Texture *space = 0; /* texture for space (background */ void -render(SDL_Renderer *renderer) +render(SDL_Renderer *renderer, int w, int h) { /* get joystick (accelerometer) axis values and normalize them */ float ax = SDL_JoystickGetAxis(accelerometer, 0); - float ay = -SDL_JoystickGetAxis(accelerometer, 1); + float ay = SDL_JoystickGetAxis(accelerometer, 1); /* ship screen constraints */ Uint32 minx = 0.0f; - Uint32 maxx = SCREEN_WIDTH - shipData.rect.w; + Uint32 maxx = w - shipData.rect.w; Uint32 miny = 0.0f; - Uint32 maxy = SCREEN_HEIGHT - shipData.rect.h; + Uint32 maxy = h - shipData.rect.h; #define SINT16_MAX ((float)(0x7FFF)) @@ -162,8 +162,9 @@ main(int argc, char *argv[]) SDL_Renderer *renderer; Uint32 startFrame; /* time frame began to process */ Uint32 endFrame; /* time frame ended processing */ - Uint32 delay; /* time to pause waiting to draw next frame */ + Sint32 delay; /* time to pause waiting to draw next frame */ int done; /* should we clean up and exit? */ + int w, h; /* initialize SDL */ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) { @@ -173,8 +174,10 @@ main(int argc, char *argv[]) /* create main window and renderer */ window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL | - SDL_WINDOW_BORDERLESS); + SDL_WINDOW_FULLSCREEN); renderer = SDL_CreateRenderer(window, 0, 0); + + SDL_GetWindowSize(window, &w, &h); /* print out some info about joysticks and try to open accelerometer for use */ printf("There are %d joysticks available\n", SDL_NumJoysticks()); @@ -196,8 +199,8 @@ main(int argc, char *argv[]) initializeTextures(renderer); /* setup ship */ - shipData.x = (SCREEN_WIDTH - shipData.rect.w) / 2; - shipData.y = (SCREEN_HEIGHT - shipData.rect.h) / 2; + shipData.x = (w - shipData.rect.w) / 2; + shipData.y = (h - shipData.rect.h) / 2; shipData.vx = 0.0f; shipData.vy = 0.0f; @@ -211,7 +214,7 @@ main(int argc, char *argv[]) done = 1; } } - render(renderer); + render(renderer, w, h); endFrame = SDL_GetTicks(); /* figure out how much time we have left, and then sleep */ diff --git a/Xcode-iOS/Demos/src/fireworks.c b/Xcode-iOS/Demos/src/fireworks.c index b2a4d095d..6c60dd125 100644 --- a/Xcode-iOS/Demos/src/fireworks.c +++ b/Xcode-iOS/Demos/src/fireworks.c @@ -196,7 +196,7 @@ explodeEmitter(struct particle *emitter) float speed = randomFloat(0.00, powf(0.17, exponent)); speed = powf(speed, 1.0f / exponent); - /*select the particle at the end of our array */ + /* select the particle at the end of our array */ struct particle *p = &particles[num_active_particles]; /* set the particles properties */ diff --git a/Xcode-iOS/Demos/src/keyboard.c b/Xcode-iOS/Demos/src/keyboard.c index fd903ff86..4fb45b94a 100644 --- a/Xcode-iOS/Demos/src/keyboard.c +++ b/Xcode-iOS/Demos/src/keyboard.c @@ -80,7 +80,7 @@ fontMapping map[TABLE_SIZE] = { {SDL_SCANCODE_7, 1, 0, 23}, /* 7 */ {SDL_SCANCODE_8, 1, 0, 24}, /* 8 */ {SDL_SCANCODE_9, 1, 0, 25}, /* 9 */ - {SDL_SCANCODE_SPACE, 1, 0, 0}, /*' ' */ + {SDL_SCANCODE_SPACE, 1, 0, 0}, /* ' ' */ {SDL_SCANCODE_1, 0, KMOD_SHIFT, 1}, /* ! */ {SDL_SCANCODE_SLASH, 0, KMOD_SHIFT, 31}, /* ? */ {SDL_SCANCODE_SLASH, 1, 0, 15}, /* / */ diff --git a/Xcode-iOS/Demos/src/rectangles.c b/Xcode-iOS/Demos/src/rectangles.c index 035e4f982..86fce49fe 100644 --- a/Xcode-iOS/Demos/src/rectangles.c +++ b/Xcode-iOS/Demos/src/rectangles.c @@ -37,7 +37,7 @@ render(SDL_Renderer *renderer) int main(int argc, char *argv[]) { - if (SDL_Init(SDL_INIT_VIDEO/* | SDL_INIT_AUDIO*/) < 0) + if (SDL_Init(SDL_INIT_VIDEO/* | SDL_INIT_AUDIO */) < 0) { printf("Unable to initialize SDL"); } diff --git a/Xcode-iOS/Demos/src/touch.c b/Xcode-iOS/Demos/src/touch.c index e811967b1..c81dcbc22 100644 --- a/Xcode-iOS/Demos/src/touch.c +++ b/Xcode-iOS/Demos/src/touch.c @@ -92,7 +92,7 @@ main(int argc, char *argv[]) SDL_WINDOW_BORDERLESS); renderer = SDL_CreateRenderer(window, 0, 0); - /*load brush texture */ + /* load brush texture */ initializeTexture(renderer); /* fill canvass initially with all black */ diff --git a/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj b/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj index 4d349d28a..350426c5d 100755 --- a/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj +++ b/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj @@ -67,6 +67,8 @@ 04F7808512FB753F00FC43C0 /* SDL_nullframebuffer.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F7808312FB753F00FC43C0 /* SDL_nullframebuffer.c */; }; 04FFAB8B12E23B8D00BA343D /* SDL_atomic.c in Sources */ = {isa = PBXBuildFile; fileRef = 04FFAB8912E23B8D00BA343D /* SDL_atomic.c */; }; 04FFAB8C12E23B8D00BA343D /* SDL_spinlock.c in Sources */ = {isa = PBXBuildFile; fileRef = 04FFAB8A12E23B8D00BA343D /* SDL_spinlock.c */; }; + 56C181DF17C44D5E00406AE3 /* SDL_filesystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 56C181DE17C44D5E00406AE3 /* SDL_filesystem.h */; }; + 56C181E217C44D7A00406AE3 /* SDL_sysfilesystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 56C181E117C44D7A00406AE3 /* SDL_sysfilesystem.m */; }; 56EA86FB13E9EC2B002E47EB /* SDL_coreaudio.c in Sources */ = {isa = PBXBuildFile; fileRef = 56EA86F913E9EC2B002E47EB /* SDL_coreaudio.c */; }; 56EA86FC13E9EC2B002E47EB /* SDL_coreaudio.h in Headers */ = {isa = PBXBuildFile; fileRef = 56EA86FA13E9EC2B002E47EB /* SDL_coreaudio.h */; }; 56ED04E1118A8EE200A56AA6 /* SDL_power.c in Sources */ = {isa = PBXBuildFile; fileRef = 56ED04E0118A8EE200A56AA6 /* SDL_power.c */; }; @@ -258,6 +260,8 @@ 04F7808312FB753F00FC43C0 /* SDL_nullframebuffer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_nullframebuffer.c; sourceTree = ""; }; 04FFAB8912E23B8D00BA343D /* SDL_atomic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_atomic.c; sourceTree = ""; }; 04FFAB8A12E23B8D00BA343D /* SDL_spinlock.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_spinlock.c; sourceTree = ""; }; + 56C181DE17C44D5E00406AE3 /* SDL_filesystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_filesystem.h; sourceTree = ""; }; + 56C181E117C44D7A00406AE3 /* SDL_sysfilesystem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDL_sysfilesystem.m; path = ../../src/filesystem/cocoa/SDL_sysfilesystem.m; sourceTree = ""; }; 56EA86F913E9EC2B002E47EB /* SDL_coreaudio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_coreaudio.c; path = coreaudio/SDL_coreaudio.c; sourceTree = ""; }; 56EA86FA13E9EC2B002E47EB /* SDL_coreaudio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_coreaudio.h; path = coreaudio/SDL_coreaudio.h; sourceTree = ""; }; 56ED04E0118A8EE200A56AA6 /* SDL_power.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_power.c; path = ../../src/power/SDL_power.c; sourceTree = SOURCE_ROOT; }; @@ -549,6 +553,14 @@ sourceTree = ""; usesTabs = 0; }; + 56C181E017C44D6900406AE3 /* filesystem */ = { + isa = PBXGroup; + children = ( + 56C181E117C44D7A00406AE3 /* SDL_sysfilesystem.m */, + ); + name = filesystem; + sourceTree = ""; + }; 56EA86F813E9EBF9002E47EB /* coreaudio */ = { isa = PBXGroup; children = ( @@ -677,6 +689,7 @@ AA7558701595D55500BBD41B /* SDL_endian.h */, AA7558711595D55500BBD41B /* SDL_error.h */, AA7558721595D55500BBD41B /* SDL_events.h */, + 56C181DE17C44D5E00406AE3 /* SDL_filesystem.h */, AA0AD06416647BD400CE5896 /* SDL_gamecontroller.h */, AA7558731595D55500BBD41B /* SDL_gesture.h */, AA7558741595D55500BBD41B /* SDL_haptic.h */, @@ -727,6 +740,7 @@ FD99B98A0DD52EDC00FB1D6B /* cpuinfo */, FD99B98C0DD52EDC00FB1D6B /* events */, FD99B99D0DD52EDC00FB1D6B /* file */, + 56C181E017C44D6900406AE3 /* filesystem */, 047677B60EA769DF008ABAF1 /* haptic */, FD5F9D080E0E08B3008E885B /* joystick */, FD8BD8150E27E25900B52CD5 /* loadso */, @@ -1019,6 +1033,7 @@ AABCC3941640643D00AB8930 /* SDL_uikitmessagebox.h in Headers */, AA0AD06516647BD400CE5896 /* SDL_gamecontroller.h in Headers */, AADA5B8F16CCAB7C00107CF7 /* SDL_bits.h in Headers */, + 56C181DF17C44D5E00406AE3 /* SDL_filesystem.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1184,6 +1199,7 @@ AABCC3951640643D00AB8930 /* SDL_uikitmessagebox.m in Sources */, AA0AD06216647BBB00CE5896 /* SDL_gamecontroller.c in Sources */, AA0F8495178D5F1A00823F9D /* SDL_systls.c in Sources */, + 56C181E217C44D7A00406AE3 /* SDL_sysfilesystem.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Xcode/SDL/Info-Framework.plist b/Xcode/SDL/Info-Framework.plist index 0ab4b25e3..696ef99d9 100644 --- a/Xcode/SDL/Info-Framework.plist +++ b/Xcode/SDL/Info-Framework.plist @@ -4,6 +4,8 @@ CFBundleDevelopmentRegion English + CFBundleExecutable + ${EXECUTABLE_NAME} CFBundleGetInfoString http://www.libsdl.org CFBundleIconFile @@ -17,12 +19,10 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.0.0 + 2.0.1 CFBundleSignature SDLX CFBundleVersion - 2.0.0 - CFBundleExecutable - ${EXECUTABLE_NAME} + 2.0.1 diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj index 3757efde0..9002cc656 100755 --- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj +++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj @@ -391,8 +391,10 @@ 04F7805F12FB74A200FC43C0 /* SDL_drawpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7804712FB74A200FC43C0 /* SDL_drawpoint.h */; }; 566CDE8F148F0AC200C5A9BB /* SDL_dropevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 566CDE8D148F0AC200C5A9BB /* SDL_dropevents_c.h */; }; 566CDE90148F0AC200C5A9BB /* SDL_dropevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 566CDE8E148F0AC200C5A9BB /* SDL_dropevents.c */; }; + 567E2F1C17C44BB2005F1892 /* SDL_sysfilesystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 567E2F1B17C44BB2005F1892 /* SDL_sysfilesystem.m */; }; + 567E2F2117C44C35005F1892 /* SDL_filesystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 567E2F2017C44C35005F1892 /* SDL_filesystem.h */; settings = {ATTRIBUTES = (Public, ); }; }; A77E6EB4167AB0A90010E40B /* SDL_gamecontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */; settings = {ATTRIBUTES = (Public, ); }; }; - A77E6EB5167AB0A90010E40B /* SDL_gamecontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */; }; + A77E6EB5167AB0A90010E40B /* SDL_gamecontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA0AD09D16648D1700CE5896 /* SDL_gamecontroller.c in Sources */ = {isa = PBXBuildFile; fileRef = BBFC088A164C6514003E6A99 /* SDL_gamecontroller.c */; }; AA0F8491178D5ECC00823F9D /* SDL_systls.c in Sources */ = {isa = PBXBuildFile; fileRef = AA0F8490178D5ECC00823F9D /* SDL_systls.c */; }; AA0F8492178D5ECC00823F9D /* SDL_systls.c in Sources */ = {isa = PBXBuildFile; fileRef = AA0F8490178D5ECC00823F9D /* SDL_systls.c */; }; @@ -407,105 +409,105 @@ AA628AD3159367F2005138DD /* SDL_x11xinput2.h in Headers */ = {isa = PBXBuildFile; fileRef = AA628AD0159367F2005138DD /* SDL_x11xinput2.h */; }; AA628AD4159367F2005138DD /* SDL_x11xinput2.h in Headers */ = {isa = PBXBuildFile; fileRef = AA628AD0159367F2005138DD /* SDL_x11xinput2.h */; }; AA7557FA1595D4D800BBD41B /* begin_code.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C71595D4D800BBD41B /* begin_code.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7557FB1595D4D800BBD41B /* begin_code.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C71595D4D800BBD41B /* begin_code.h */; }; + AA7557FB1595D4D800BBD41B /* begin_code.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C71595D4D800BBD41B /* begin_code.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7557FC1595D4D800BBD41B /* close_code.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C81595D4D800BBD41B /* close_code.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7557FD1595D4D800BBD41B /* close_code.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C81595D4D800BBD41B /* close_code.h */; }; + AA7557FD1595D4D800BBD41B /* close_code.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C81595D4D800BBD41B /* close_code.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7557FE1595D4D800BBD41B /* SDL_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C91595D4D800BBD41B /* SDL_assert.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7557FF1595D4D800BBD41B /* SDL_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C91595D4D800BBD41B /* SDL_assert.h */; }; + AA7557FF1595D4D800BBD41B /* SDL_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C91595D4D800BBD41B /* SDL_assert.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558001595D4D800BBD41B /* SDL_atomic.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CA1595D4D800BBD41B /* SDL_atomic.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558011595D4D800BBD41B /* SDL_atomic.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CA1595D4D800BBD41B /* SDL_atomic.h */; }; + AA7558011595D4D800BBD41B /* SDL_atomic.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CA1595D4D800BBD41B /* SDL_atomic.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558021595D4D800BBD41B /* SDL_audio.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CB1595D4D800BBD41B /* SDL_audio.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558031595D4D800BBD41B /* SDL_audio.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CB1595D4D800BBD41B /* SDL_audio.h */; }; + AA7558031595D4D800BBD41B /* SDL_audio.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CB1595D4D800BBD41B /* SDL_audio.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558041595D4D800BBD41B /* SDL_blendmode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CC1595D4D800BBD41B /* SDL_blendmode.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558051595D4D800BBD41B /* SDL_blendmode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CC1595D4D800BBD41B /* SDL_blendmode.h */; }; + AA7558051595D4D800BBD41B /* SDL_blendmode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CC1595D4D800BBD41B /* SDL_blendmode.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558061595D4D800BBD41B /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CD1595D4D800BBD41B /* SDL_clipboard.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558071595D4D800BBD41B /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CD1595D4D800BBD41B /* SDL_clipboard.h */; }; + AA7558071595D4D800BBD41B /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CD1595D4D800BBD41B /* SDL_clipboard.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558081595D4D800BBD41B /* SDL_config_macosx.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CE1595D4D800BBD41B /* SDL_config_macosx.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558091595D4D800BBD41B /* SDL_config_macosx.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CE1595D4D800BBD41B /* SDL_config_macosx.h */; }; + AA7558091595D4D800BBD41B /* SDL_config_macosx.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CE1595D4D800BBD41B /* SDL_config_macosx.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75580A1595D4D800BBD41B /* SDL_config.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CF1595D4D800BBD41B /* SDL_config.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75580B1595D4D800BBD41B /* SDL_config.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CF1595D4D800BBD41B /* SDL_config.h */; }; + AA75580B1595D4D800BBD41B /* SDL_config.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CF1595D4D800BBD41B /* SDL_config.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75580C1595D4D800BBD41B /* SDL_copying.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D01595D4D800BBD41B /* SDL_copying.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75580D1595D4D800BBD41B /* SDL_copying.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D01595D4D800BBD41B /* SDL_copying.h */; }; + AA75580D1595D4D800BBD41B /* SDL_copying.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D01595D4D800BBD41B /* SDL_copying.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75580E1595D4D800BBD41B /* SDL_cpuinfo.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D11595D4D800BBD41B /* SDL_cpuinfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75580F1595D4D800BBD41B /* SDL_cpuinfo.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D11595D4D800BBD41B /* SDL_cpuinfo.h */; }; + AA75580F1595D4D800BBD41B /* SDL_cpuinfo.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D11595D4D800BBD41B /* SDL_cpuinfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558101595D4D800BBD41B /* SDL_endian.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D21595D4D800BBD41B /* SDL_endian.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558111595D4D800BBD41B /* SDL_endian.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D21595D4D800BBD41B /* SDL_endian.h */; }; + AA7558111595D4D800BBD41B /* SDL_endian.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D21595D4D800BBD41B /* SDL_endian.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558121595D4D800BBD41B /* SDL_error.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D31595D4D800BBD41B /* SDL_error.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558131595D4D800BBD41B /* SDL_error.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D31595D4D800BBD41B /* SDL_error.h */; }; + AA7558131595D4D800BBD41B /* SDL_error.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D31595D4D800BBD41B /* SDL_error.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558141595D4D800BBD41B /* SDL_events.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D41595D4D800BBD41B /* SDL_events.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558151595D4D800BBD41B /* SDL_events.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D41595D4D800BBD41B /* SDL_events.h */; }; + AA7558151595D4D800BBD41B /* SDL_events.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D41595D4D800BBD41B /* SDL_events.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558161595D4D800BBD41B /* SDL_gesture.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D51595D4D800BBD41B /* SDL_gesture.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558171595D4D800BBD41B /* SDL_gesture.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D51595D4D800BBD41B /* SDL_gesture.h */; }; + AA7558171595D4D800BBD41B /* SDL_gesture.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D51595D4D800BBD41B /* SDL_gesture.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558181595D4D800BBD41B /* SDL_haptic.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D61595D4D800BBD41B /* SDL_haptic.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558191595D4D800BBD41B /* SDL_haptic.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D61595D4D800BBD41B /* SDL_haptic.h */; }; + AA7558191595D4D800BBD41B /* SDL_haptic.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D61595D4D800BBD41B /* SDL_haptic.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75581A1595D4D800BBD41B /* SDL_hints.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D71595D4D800BBD41B /* SDL_hints.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75581B1595D4D800BBD41B /* SDL_hints.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D71595D4D800BBD41B /* SDL_hints.h */; }; + AA75581B1595D4D800BBD41B /* SDL_hints.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D71595D4D800BBD41B /* SDL_hints.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75581E1595D4D800BBD41B /* SDL_joystick.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D91595D4D800BBD41B /* SDL_joystick.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75581F1595D4D800BBD41B /* SDL_joystick.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D91595D4D800BBD41B /* SDL_joystick.h */; }; + AA75581F1595D4D800BBD41B /* SDL_joystick.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D91595D4D800BBD41B /* SDL_joystick.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558201595D4D800BBD41B /* SDL_keyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DA1595D4D800BBD41B /* SDL_keyboard.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558211595D4D800BBD41B /* SDL_keyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DA1595D4D800BBD41B /* SDL_keyboard.h */; }; + AA7558211595D4D800BBD41B /* SDL_keyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DA1595D4D800BBD41B /* SDL_keyboard.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558221595D4D800BBD41B /* SDL_keycode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DB1595D4D800BBD41B /* SDL_keycode.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558231595D4D800BBD41B /* SDL_keycode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DB1595D4D800BBD41B /* SDL_keycode.h */; }; + AA7558231595D4D800BBD41B /* SDL_keycode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DB1595D4D800BBD41B /* SDL_keycode.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558241595D4D800BBD41B /* SDL_loadso.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DC1595D4D800BBD41B /* SDL_loadso.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558251595D4D800BBD41B /* SDL_loadso.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DC1595D4D800BBD41B /* SDL_loadso.h */; }; + AA7558251595D4D800BBD41B /* SDL_loadso.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DC1595D4D800BBD41B /* SDL_loadso.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558261595D4D800BBD41B /* SDL_log.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DD1595D4D800BBD41B /* SDL_log.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558271595D4D800BBD41B /* SDL_log.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DD1595D4D800BBD41B /* SDL_log.h */; }; + AA7558271595D4D800BBD41B /* SDL_log.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DD1595D4D800BBD41B /* SDL_log.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558281595D4D800BBD41B /* SDL_main.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DE1595D4D800BBD41B /* SDL_main.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558291595D4D800BBD41B /* SDL_main.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DE1595D4D800BBD41B /* SDL_main.h */; }; + AA7558291595D4D800BBD41B /* SDL_main.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DE1595D4D800BBD41B /* SDL_main.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75582A1595D4D800BBD41B /* SDL_mouse.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DF1595D4D800BBD41B /* SDL_mouse.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75582B1595D4D800BBD41B /* SDL_mouse.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DF1595D4D800BBD41B /* SDL_mouse.h */; }; + AA75582B1595D4D800BBD41B /* SDL_mouse.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DF1595D4D800BBD41B /* SDL_mouse.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75582C1595D4D800BBD41B /* SDL_mutex.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E01595D4D800BBD41B /* SDL_mutex.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75582D1595D4D800BBD41B /* SDL_mutex.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E01595D4D800BBD41B /* SDL_mutex.h */; }; + AA75582D1595D4D800BBD41B /* SDL_mutex.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E01595D4D800BBD41B /* SDL_mutex.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75582E1595D4D800BBD41B /* SDL_name.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E11595D4D800BBD41B /* SDL_name.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75582F1595D4D800BBD41B /* SDL_name.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E11595D4D800BBD41B /* SDL_name.h */; }; + AA75582F1595D4D800BBD41B /* SDL_name.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E11595D4D800BBD41B /* SDL_name.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558301595D4D800BBD41B /* SDL_opengl.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E21595D4D800BBD41B /* SDL_opengl.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558311595D4D800BBD41B /* SDL_opengl.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E21595D4D800BBD41B /* SDL_opengl.h */; }; + AA7558311595D4D800BBD41B /* SDL_opengl.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E21595D4D800BBD41B /* SDL_opengl.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558321595D4D800BBD41B /* SDL_opengles.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E31595D4D800BBD41B /* SDL_opengles.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558331595D4D800BBD41B /* SDL_opengles.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E31595D4D800BBD41B /* SDL_opengles.h */; }; + AA7558331595D4D800BBD41B /* SDL_opengles.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E31595D4D800BBD41B /* SDL_opengles.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558341595D4D800BBD41B /* SDL_opengles2.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E41595D4D800BBD41B /* SDL_opengles2.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558351595D4D800BBD41B /* SDL_opengles2.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E41595D4D800BBD41B /* SDL_opengles2.h */; }; + AA7558351595D4D800BBD41B /* SDL_opengles2.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E41595D4D800BBD41B /* SDL_opengles2.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558361595D4D800BBD41B /* SDL_pixels.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E51595D4D800BBD41B /* SDL_pixels.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558371595D4D800BBD41B /* SDL_pixels.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E51595D4D800BBD41B /* SDL_pixels.h */; }; + AA7558371595D4D800BBD41B /* SDL_pixels.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E51595D4D800BBD41B /* SDL_pixels.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558381595D4D800BBD41B /* SDL_platform.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E61595D4D800BBD41B /* SDL_platform.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558391595D4D800BBD41B /* SDL_platform.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E61595D4D800BBD41B /* SDL_platform.h */; }; + AA7558391595D4D800BBD41B /* SDL_platform.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E61595D4D800BBD41B /* SDL_platform.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75583A1595D4D800BBD41B /* SDL_power.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E71595D4D800BBD41B /* SDL_power.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75583B1595D4D800BBD41B /* SDL_power.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E71595D4D800BBD41B /* SDL_power.h */; }; + AA75583B1595D4D800BBD41B /* SDL_power.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E71595D4D800BBD41B /* SDL_power.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75583C1595D4D800BBD41B /* SDL_quit.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E81595D4D800BBD41B /* SDL_quit.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75583D1595D4D800BBD41B /* SDL_quit.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E81595D4D800BBD41B /* SDL_quit.h */; }; + AA75583D1595D4D800BBD41B /* SDL_quit.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E81595D4D800BBD41B /* SDL_quit.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75583E1595D4D800BBD41B /* SDL_rect.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E91595D4D800BBD41B /* SDL_rect.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75583F1595D4D800BBD41B /* SDL_rect.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E91595D4D800BBD41B /* SDL_rect.h */; }; + AA75583F1595D4D800BBD41B /* SDL_rect.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E91595D4D800BBD41B /* SDL_rect.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558401595D4D800BBD41B /* SDL_render.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EA1595D4D800BBD41B /* SDL_render.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558411595D4D800BBD41B /* SDL_render.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EA1595D4D800BBD41B /* SDL_render.h */; }; + AA7558411595D4D800BBD41B /* SDL_render.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EA1595D4D800BBD41B /* SDL_render.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558421595D4D800BBD41B /* SDL_revision.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EB1595D4D800BBD41B /* SDL_revision.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558431595D4D800BBD41B /* SDL_revision.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EB1595D4D800BBD41B /* SDL_revision.h */; }; + AA7558431595D4D800BBD41B /* SDL_revision.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EB1595D4D800BBD41B /* SDL_revision.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558441595D4D800BBD41B /* SDL_rwops.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EC1595D4D800BBD41B /* SDL_rwops.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558451595D4D800BBD41B /* SDL_rwops.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EC1595D4D800BBD41B /* SDL_rwops.h */; }; + AA7558451595D4D800BBD41B /* SDL_rwops.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EC1595D4D800BBD41B /* SDL_rwops.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558461595D4D800BBD41B /* SDL_scancode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557ED1595D4D800BBD41B /* SDL_scancode.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558471595D4D800BBD41B /* SDL_scancode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557ED1595D4D800BBD41B /* SDL_scancode.h */; }; + AA7558471595D4D800BBD41B /* SDL_scancode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557ED1595D4D800BBD41B /* SDL_scancode.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558481595D4D800BBD41B /* SDL_shape.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EE1595D4D800BBD41B /* SDL_shape.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558491595D4D800BBD41B /* SDL_shape.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EE1595D4D800BBD41B /* SDL_shape.h */; }; + AA7558491595D4D800BBD41B /* SDL_shape.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EE1595D4D800BBD41B /* SDL_shape.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75584A1595D4D800BBD41B /* SDL_stdinc.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EF1595D4D800BBD41B /* SDL_stdinc.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75584B1595D4D800BBD41B /* SDL_stdinc.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EF1595D4D800BBD41B /* SDL_stdinc.h */; }; + AA75584B1595D4D800BBD41B /* SDL_stdinc.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EF1595D4D800BBD41B /* SDL_stdinc.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75584C1595D4D800BBD41B /* SDL_surface.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F01595D4D800BBD41B /* SDL_surface.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75584D1595D4D800BBD41B /* SDL_surface.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F01595D4D800BBD41B /* SDL_surface.h */; }; + AA75584D1595D4D800BBD41B /* SDL_surface.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F01595D4D800BBD41B /* SDL_surface.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75584E1595D4D800BBD41B /* SDL_system.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F11595D4D800BBD41B /* SDL_system.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75584F1595D4D800BBD41B /* SDL_system.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F11595D4D800BBD41B /* SDL_system.h */; }; + AA75584F1595D4D800BBD41B /* SDL_system.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F11595D4D800BBD41B /* SDL_system.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558501595D4D800BBD41B /* SDL_syswm.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F21595D4D800BBD41B /* SDL_syswm.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558511595D4D800BBD41B /* SDL_syswm.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F21595D4D800BBD41B /* SDL_syswm.h */; }; + AA7558511595D4D800BBD41B /* SDL_syswm.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F21595D4D800BBD41B /* SDL_syswm.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558521595D4D800BBD41B /* SDL_thread.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F31595D4D800BBD41B /* SDL_thread.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558531595D4D800BBD41B /* SDL_thread.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F31595D4D800BBD41B /* SDL_thread.h */; }; + AA7558531595D4D800BBD41B /* SDL_thread.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F31595D4D800BBD41B /* SDL_thread.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558541595D4D800BBD41B /* SDL_timer.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F41595D4D800BBD41B /* SDL_timer.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558551595D4D800BBD41B /* SDL_timer.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F41595D4D800BBD41B /* SDL_timer.h */; }; + AA7558551595D4D800BBD41B /* SDL_timer.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F41595D4D800BBD41B /* SDL_timer.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558561595D4D800BBD41B /* SDL_touch.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F51595D4D800BBD41B /* SDL_touch.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558571595D4D800BBD41B /* SDL_touch.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F51595D4D800BBD41B /* SDL_touch.h */; }; + AA7558571595D4D800BBD41B /* SDL_touch.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F51595D4D800BBD41B /* SDL_touch.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA7558581595D4D800BBD41B /* SDL_types.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F61595D4D800BBD41B /* SDL_types.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA7558591595D4D800BBD41B /* SDL_types.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F61595D4D800BBD41B /* SDL_types.h */; }; + AA7558591595D4D800BBD41B /* SDL_types.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F61595D4D800BBD41B /* SDL_types.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75585A1595D4D800BBD41B /* SDL_version.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F71595D4D800BBD41B /* SDL_version.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75585B1595D4D800BBD41B /* SDL_version.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F71595D4D800BBD41B /* SDL_version.h */; }; + AA75585B1595D4D800BBD41B /* SDL_version.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F71595D4D800BBD41B /* SDL_version.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75585C1595D4D800BBD41B /* SDL_video.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F81595D4D800BBD41B /* SDL_video.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75585D1595D4D800BBD41B /* SDL_video.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F81595D4D800BBD41B /* SDL_video.h */; }; + AA75585D1595D4D800BBD41B /* SDL_video.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F81595D4D800BBD41B /* SDL_video.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA75585E1595D4D800BBD41B /* SDL.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F91595D4D800BBD41B /* SDL.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA75585F1595D4D800BBD41B /* SDL.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F91595D4D800BBD41B /* SDL.h */; }; + AA75585F1595D4D800BBD41B /* SDL.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F91595D4D800BBD41B /* SDL.h */; settings = {ATTRIBUTES = (Public, ); }; }; AA9E4093163BE51E007A2AD0 /* SDL_x11messagebox.c in Sources */ = {isa = PBXBuildFile; fileRef = AA9E4092163BE51E007A2AD0 /* SDL_x11messagebox.c */; }; AA9E4094163BE51E007A2AD0 /* SDL_x11messagebox.c in Sources */ = {isa = PBXBuildFile; fileRef = AA9E4092163BE51E007A2AD0 /* SDL_x11messagebox.c */; }; AA9FF95A1637CBF9000DF050 /* SDL_messagebox.h in Headers */ = {isa = PBXBuildFile; fileRef = AA9FF9591637CBF9000DF050 /* SDL_messagebox.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -513,8 +515,8 @@ AABCC38E164063D200AB8930 /* SDL_cocoamessagebox.h in Headers */ = {isa = PBXBuildFile; fileRef = AABCC38B164063D200AB8930 /* SDL_cocoamessagebox.h */; }; AABCC38F164063D200AB8930 /* SDL_cocoamessagebox.m in Sources */ = {isa = PBXBuildFile; fileRef = AABCC38C164063D200AB8930 /* SDL_cocoamessagebox.m */; }; AABCC390164063D200AB8930 /* SDL_cocoamessagebox.m in Sources */ = {isa = PBXBuildFile; fileRef = AABCC38C164063D200AB8930 /* SDL_cocoamessagebox.m */; }; - AADA5B8716CCAB3000107CF7 /* SDL_bits.h in Headers */ = {isa = PBXBuildFile; fileRef = AADA5B8616CCAB3000107CF7 /* SDL_bits.h */; }; - AADA5B8816CCAB3000107CF7 /* SDL_bits.h in Headers */ = {isa = PBXBuildFile; fileRef = AADA5B8616CCAB3000107CF7 /* SDL_bits.h */; }; + AADA5B8716CCAB3000107CF7 /* SDL_bits.h in Headers */ = {isa = PBXBuildFile; fileRef = AADA5B8616CCAB3000107CF7 /* SDL_bits.h */; settings = {ATTRIBUTES = (Public, ); }; }; + AADA5B8816CCAB3000107CF7 /* SDL_bits.h in Headers */ = {isa = PBXBuildFile; fileRef = AADA5B8616CCAB3000107CF7 /* SDL_bits.h */; settings = {ATTRIBUTES = (Public, ); }; }; BBFC088D164C6647003E6A99 /* SDL_gamecontroller.c in Sources */ = {isa = PBXBuildFile; fileRef = BBFC088A164C6514003E6A99 /* SDL_gamecontroller.c */; }; D55A1B81179F262300625D7C /* SDL_cocoamousetap.h in Headers */ = {isa = PBXBuildFile; fileRef = D55A1B7F179F262300625D7C /* SDL_cocoamousetap.h */; }; D55A1B82179F262300625D7C /* SDL_cocoamousetap.m in Sources */ = {isa = PBXBuildFile; fileRef = D55A1B80179F262300625D7C /* SDL_cocoamousetap.m */; }; @@ -522,6 +524,12 @@ D55A1B84179F263600625D7C /* SDL_cocoamousetap.m in Sources */ = {isa = PBXBuildFile; fileRef = D55A1B80179F262300625D7C /* SDL_cocoamousetap.m */; }; D55A1B85179F278E00625D7C /* SDL_cocoamousetap.h in Headers */ = {isa = PBXBuildFile; fileRef = D55A1B7F179F262300625D7C /* SDL_cocoamousetap.h */; }; D55A1B86179F278F00625D7C /* SDL_cocoamousetap.h in Headers */ = {isa = PBXBuildFile; fileRef = D55A1B7F179F262300625D7C /* SDL_cocoamousetap.h */; }; + DB0F489317C400E6008798C5 /* SDL_messagebox.h in Headers */ = {isa = PBXBuildFile; fileRef = AA9FF9591637CBF9000DF050 /* SDL_messagebox.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB0F489417C400ED008798C5 /* SDL_messagebox.h in Headers */ = {isa = PBXBuildFile; fileRef = AA9FF9591637CBF9000DF050 /* SDL_messagebox.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB0F490817CA5292008798C5 /* SDL_sysfilesystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 567E2F1B17C44BB2005F1892 /* SDL_sysfilesystem.m */; }; + DB0F490A17CA5293008798C5 /* SDL_sysfilesystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 567E2F1B17C44BB2005F1892 /* SDL_sysfilesystem.m */; }; + DB0F490B17CA57ED008798C5 /* SDL_filesystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 567E2F2017C44C35005F1892 /* SDL_filesystem.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB0F490C17CA57ED008798C5 /* SDL_filesystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 567E2F2017C44C35005F1892 /* SDL_filesystem.h */; settings = {ATTRIBUTES = (Public, ); }; }; DB313F7417554B71006C0E22 /* SDL_diskaudio.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFD8912E6671700899322 /* SDL_diskaudio.h */; }; DB313F7517554B71006C0E22 /* SDL_dummyaudio.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFD9512E6671700899322 /* SDL_dummyaudio.h */; }; DB313F7617554B71006C0E22 /* SDL_coreaudio.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDA112E6671700899322 /* SDL_coreaudio.h */; }; @@ -605,59 +613,59 @@ DB313FC517554B71006C0E22 /* SDL_shaders_gl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0435673D1303160F00BA5428 /* SDL_shaders_gl.h */; }; DB313FC617554B71006C0E22 /* SDL_rotate.h in Headers */ = {isa = PBXBuildFile; fileRef = AA628AC9159367B7005138DD /* SDL_rotate.h */; }; DB313FC717554B71006C0E22 /* SDL_x11xinput2.h in Headers */ = {isa = PBXBuildFile; fileRef = AA628AD0159367F2005138DD /* SDL_x11xinput2.h */; }; - DB313FC817554B71006C0E22 /* begin_code.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C71595D4D800BBD41B /* begin_code.h */; }; - DB313FC917554B71006C0E22 /* close_code.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C81595D4D800BBD41B /* close_code.h */; }; - DB313FCA17554B71006C0E22 /* SDL_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C91595D4D800BBD41B /* SDL_assert.h */; }; - DB313FCB17554B71006C0E22 /* SDL_atomic.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CA1595D4D800BBD41B /* SDL_atomic.h */; }; - DB313FCC17554B71006C0E22 /* SDL_audio.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CB1595D4D800BBD41B /* SDL_audio.h */; }; - DB313FCD17554B71006C0E22 /* SDL_blendmode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CC1595D4D800BBD41B /* SDL_blendmode.h */; }; - DB313FCE17554B71006C0E22 /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CD1595D4D800BBD41B /* SDL_clipboard.h */; }; - DB313FCF17554B71006C0E22 /* SDL_config_macosx.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CE1595D4D800BBD41B /* SDL_config_macosx.h */; }; - DB313FD017554B71006C0E22 /* SDL_config.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CF1595D4D800BBD41B /* SDL_config.h */; }; - DB313FD117554B71006C0E22 /* SDL_copying.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D01595D4D800BBD41B /* SDL_copying.h */; }; - DB313FD217554B71006C0E22 /* SDL_cpuinfo.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D11595D4D800BBD41B /* SDL_cpuinfo.h */; }; - DB313FD317554B71006C0E22 /* SDL_endian.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D21595D4D800BBD41B /* SDL_endian.h */; }; - DB313FD417554B71006C0E22 /* SDL_error.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D31595D4D800BBD41B /* SDL_error.h */; }; - DB313FD517554B71006C0E22 /* SDL_events.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D41595D4D800BBD41B /* SDL_events.h */; }; - DB313FD617554B71006C0E22 /* SDL_gesture.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D51595D4D800BBD41B /* SDL_gesture.h */; }; - DB313FD717554B71006C0E22 /* SDL_haptic.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D61595D4D800BBD41B /* SDL_haptic.h */; }; - DB313FD817554B71006C0E22 /* SDL_hints.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D71595D4D800BBD41B /* SDL_hints.h */; }; - DB313FD917554B71006C0E22 /* SDL_joystick.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D91595D4D800BBD41B /* SDL_joystick.h */; }; - DB313FDA17554B71006C0E22 /* SDL_keyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DA1595D4D800BBD41B /* SDL_keyboard.h */; }; - DB313FDB17554B71006C0E22 /* SDL_keycode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DB1595D4D800BBD41B /* SDL_keycode.h */; }; - DB313FDC17554B71006C0E22 /* SDL_loadso.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DC1595D4D800BBD41B /* SDL_loadso.h */; }; - DB313FDD17554B71006C0E22 /* SDL_log.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DD1595D4D800BBD41B /* SDL_log.h */; }; - DB313FDE17554B71006C0E22 /* SDL_main.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DE1595D4D800BBD41B /* SDL_main.h */; }; - DB313FDF17554B71006C0E22 /* SDL_mouse.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DF1595D4D800BBD41B /* SDL_mouse.h */; }; - DB313FE017554B71006C0E22 /* SDL_mutex.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E01595D4D800BBD41B /* SDL_mutex.h */; }; - DB313FE117554B71006C0E22 /* SDL_name.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E11595D4D800BBD41B /* SDL_name.h */; }; - DB313FE217554B71006C0E22 /* SDL_opengl.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E21595D4D800BBD41B /* SDL_opengl.h */; }; - DB313FE317554B71006C0E22 /* SDL_opengles.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E31595D4D800BBD41B /* SDL_opengles.h */; }; - DB313FE417554B71006C0E22 /* SDL_opengles2.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E41595D4D800BBD41B /* SDL_opengles2.h */; }; - DB313FE517554B71006C0E22 /* SDL_pixels.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E51595D4D800BBD41B /* SDL_pixels.h */; }; - DB313FE617554B71006C0E22 /* SDL_platform.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E61595D4D800BBD41B /* SDL_platform.h */; }; - DB313FE717554B71006C0E22 /* SDL_power.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E71595D4D800BBD41B /* SDL_power.h */; }; - DB313FE817554B71006C0E22 /* SDL_quit.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E81595D4D800BBD41B /* SDL_quit.h */; }; - DB313FE917554B71006C0E22 /* SDL_rect.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E91595D4D800BBD41B /* SDL_rect.h */; }; - DB313FEA17554B71006C0E22 /* SDL_render.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EA1595D4D800BBD41B /* SDL_render.h */; }; - DB313FEB17554B71006C0E22 /* SDL_revision.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EB1595D4D800BBD41B /* SDL_revision.h */; }; - DB313FEC17554B71006C0E22 /* SDL_rwops.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EC1595D4D800BBD41B /* SDL_rwops.h */; }; - DB313FED17554B71006C0E22 /* SDL_scancode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557ED1595D4D800BBD41B /* SDL_scancode.h */; }; - DB313FEE17554B71006C0E22 /* SDL_shape.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EE1595D4D800BBD41B /* SDL_shape.h */; }; - DB313FEF17554B71006C0E22 /* SDL_stdinc.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EF1595D4D800BBD41B /* SDL_stdinc.h */; }; - DB313FF017554B71006C0E22 /* SDL_surface.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F01595D4D800BBD41B /* SDL_surface.h */; }; - DB313FF117554B71006C0E22 /* SDL_system.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F11595D4D800BBD41B /* SDL_system.h */; }; - DB313FF217554B71006C0E22 /* SDL_syswm.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F21595D4D800BBD41B /* SDL_syswm.h */; }; - DB313FF317554B71006C0E22 /* SDL_thread.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F31595D4D800BBD41B /* SDL_thread.h */; }; - DB313FF417554B71006C0E22 /* SDL_timer.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F41595D4D800BBD41B /* SDL_timer.h */; }; - DB313FF517554B71006C0E22 /* SDL_touch.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F51595D4D800BBD41B /* SDL_touch.h */; }; - DB313FF617554B71006C0E22 /* SDL_types.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F61595D4D800BBD41B /* SDL_types.h */; }; - DB313FF717554B71006C0E22 /* SDL_version.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F71595D4D800BBD41B /* SDL_version.h */; }; - DB313FF817554B71006C0E22 /* SDL_video.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F81595D4D800BBD41B /* SDL_video.h */; }; - DB313FF917554B71006C0E22 /* SDL.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F91595D4D800BBD41B /* SDL.h */; }; + DB313FC817554B71006C0E22 /* begin_code.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C71595D4D800BBD41B /* begin_code.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FC917554B71006C0E22 /* close_code.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C81595D4D800BBD41B /* close_code.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FCA17554B71006C0E22 /* SDL_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557C91595D4D800BBD41B /* SDL_assert.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FCB17554B71006C0E22 /* SDL_atomic.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CA1595D4D800BBD41B /* SDL_atomic.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FCC17554B71006C0E22 /* SDL_audio.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CB1595D4D800BBD41B /* SDL_audio.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FCD17554B71006C0E22 /* SDL_blendmode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CC1595D4D800BBD41B /* SDL_blendmode.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FCE17554B71006C0E22 /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CD1595D4D800BBD41B /* SDL_clipboard.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FCF17554B71006C0E22 /* SDL_config_macosx.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CE1595D4D800BBD41B /* SDL_config_macosx.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FD017554B71006C0E22 /* SDL_config.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CF1595D4D800BBD41B /* SDL_config.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FD117554B71006C0E22 /* SDL_copying.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D01595D4D800BBD41B /* SDL_copying.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FD217554B71006C0E22 /* SDL_cpuinfo.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D11595D4D800BBD41B /* SDL_cpuinfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FD317554B71006C0E22 /* SDL_endian.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D21595D4D800BBD41B /* SDL_endian.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FD417554B71006C0E22 /* SDL_error.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D31595D4D800BBD41B /* SDL_error.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FD517554B71006C0E22 /* SDL_events.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D41595D4D800BBD41B /* SDL_events.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FD617554B71006C0E22 /* SDL_gesture.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D51595D4D800BBD41B /* SDL_gesture.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FD717554B71006C0E22 /* SDL_haptic.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D61595D4D800BBD41B /* SDL_haptic.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FD817554B71006C0E22 /* SDL_hints.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D71595D4D800BBD41B /* SDL_hints.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FD917554B71006C0E22 /* SDL_joystick.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557D91595D4D800BBD41B /* SDL_joystick.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FDA17554B71006C0E22 /* SDL_keyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DA1595D4D800BBD41B /* SDL_keyboard.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FDB17554B71006C0E22 /* SDL_keycode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DB1595D4D800BBD41B /* SDL_keycode.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FDC17554B71006C0E22 /* SDL_loadso.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DC1595D4D800BBD41B /* SDL_loadso.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FDD17554B71006C0E22 /* SDL_log.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DD1595D4D800BBD41B /* SDL_log.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FDE17554B71006C0E22 /* SDL_main.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DE1595D4D800BBD41B /* SDL_main.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FDF17554B71006C0E22 /* SDL_mouse.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DF1595D4D800BBD41B /* SDL_mouse.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FE017554B71006C0E22 /* SDL_mutex.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E01595D4D800BBD41B /* SDL_mutex.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FE117554B71006C0E22 /* SDL_name.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E11595D4D800BBD41B /* SDL_name.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FE217554B71006C0E22 /* SDL_opengl.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E21595D4D800BBD41B /* SDL_opengl.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FE317554B71006C0E22 /* SDL_opengles.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E31595D4D800BBD41B /* SDL_opengles.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FE417554B71006C0E22 /* SDL_opengles2.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E41595D4D800BBD41B /* SDL_opengles2.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FE517554B71006C0E22 /* SDL_pixels.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E51595D4D800BBD41B /* SDL_pixels.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FE617554B71006C0E22 /* SDL_platform.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E61595D4D800BBD41B /* SDL_platform.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FE717554B71006C0E22 /* SDL_power.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E71595D4D800BBD41B /* SDL_power.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FE817554B71006C0E22 /* SDL_quit.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E81595D4D800BBD41B /* SDL_quit.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FE917554B71006C0E22 /* SDL_rect.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E91595D4D800BBD41B /* SDL_rect.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FEA17554B71006C0E22 /* SDL_render.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EA1595D4D800BBD41B /* SDL_render.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FEB17554B71006C0E22 /* SDL_revision.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EB1595D4D800BBD41B /* SDL_revision.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FEC17554B71006C0E22 /* SDL_rwops.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EC1595D4D800BBD41B /* SDL_rwops.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FED17554B71006C0E22 /* SDL_scancode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557ED1595D4D800BBD41B /* SDL_scancode.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FEE17554B71006C0E22 /* SDL_shape.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EE1595D4D800BBD41B /* SDL_shape.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FEF17554B71006C0E22 /* SDL_stdinc.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557EF1595D4D800BBD41B /* SDL_stdinc.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FF017554B71006C0E22 /* SDL_surface.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F01595D4D800BBD41B /* SDL_surface.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FF117554B71006C0E22 /* SDL_system.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F11595D4D800BBD41B /* SDL_system.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FF217554B71006C0E22 /* SDL_syswm.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F21595D4D800BBD41B /* SDL_syswm.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FF317554B71006C0E22 /* SDL_thread.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F31595D4D800BBD41B /* SDL_thread.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FF417554B71006C0E22 /* SDL_timer.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F41595D4D800BBD41B /* SDL_timer.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FF517554B71006C0E22 /* SDL_touch.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F51595D4D800BBD41B /* SDL_touch.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FF617554B71006C0E22 /* SDL_types.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F61595D4D800BBD41B /* SDL_types.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FF717554B71006C0E22 /* SDL_version.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F71595D4D800BBD41B /* SDL_version.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FF817554B71006C0E22 /* SDL_video.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F81595D4D800BBD41B /* SDL_video.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FF917554B71006C0E22 /* SDL.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F91595D4D800BBD41B /* SDL.h */; settings = {ATTRIBUTES = (Public, ); }; }; DB313FFA17554B71006C0E22 /* SDL_cocoamessagebox.h in Headers */ = {isa = PBXBuildFile; fileRef = AABCC38B164063D200AB8930 /* SDL_cocoamessagebox.h */; }; - DB313FFB17554B71006C0E22 /* SDL_gamecontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */; }; - DB313FFC17554B71006C0E22 /* SDL_bits.h in Headers */ = {isa = PBXBuildFile; fileRef = AADA5B8616CCAB3000107CF7 /* SDL_bits.h */; }; + DB313FFB17554B71006C0E22 /* SDL_gamecontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB313FFC17554B71006C0E22 /* SDL_bits.h in Headers */ = {isa = PBXBuildFile; fileRef = AADA5B8616CCAB3000107CF7 /* SDL_bits.h */; settings = {ATTRIBUTES = (Public, ); }; }; DB313FFE17554B71006C0E22 /* SDL_atomic.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFD7412E6671700899322 /* SDL_atomic.c */; }; DB313FFF17554B71006C0E22 /* SDL_spinlock.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFD7512E6671700899322 /* SDL_spinlock.c */; }; DB31400017554B71006C0E22 /* SDL_diskaudio.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFD8812E6671700899322 /* SDL_diskaudio.c */; }; @@ -984,6 +992,8 @@ 04F7804712FB74A200FC43C0 /* SDL_drawpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_drawpoint.h; sourceTree = ""; }; 566CDE8D148F0AC200C5A9BB /* SDL_dropevents_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_dropevents_c.h; sourceTree = ""; }; 566CDE8E148F0AC200C5A9BB /* SDL_dropevents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_dropevents.c; sourceTree = ""; }; + 567E2F1B17C44BB2005F1892 /* SDL_sysfilesystem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDL_sysfilesystem.m; path = ../../src/filesystem/cocoa/SDL_sysfilesystem.m; sourceTree = ""; }; + 567E2F2017C44C35005F1892 /* SDL_filesystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_filesystem.h; sourceTree = ""; }; A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_gamecontroller.h; sourceTree = ""; }; AA0F8490178D5ECC00823F9D /* SDL_systls.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_systls.c; sourceTree = ""; }; AA628AC8159367B7005138DD /* SDL_rotate.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_rotate.c; sourceTree = ""; }; @@ -1133,6 +1143,7 @@ AA7557D21595D4D800BBD41B /* SDL_endian.h */, AA7557D31595D4D800BBD41B /* SDL_error.h */, AA7557D41595D4D800BBD41B /* SDL_events.h */, + 567E2F2017C44C35005F1892 /* SDL_filesystem.h */, A77E6EB3167AB0A90010E40B /* SDL_gamecontroller.h */, AA7557D51595D4D800BBD41B /* SDL_gesture.h */, AA7557D61595D4D800BBD41B /* SDL_haptic.h */, @@ -1641,6 +1652,7 @@ 04BDFD7612E6671700899322 /* audio */, 04BDFDD312E6671700899322 /* cpuinfo */, 04BDFDD512E6671700899322 /* events */, + 567E2F1F17C44BBB005F1892 /* filesystem */, 04BDFDEC12E6671700899322 /* file */, 04BDFDF112E6671700899322 /* haptic */, 04BDFDFF12E6671700899322 /* joystick */, @@ -1662,6 +1674,14 @@ name = "Library Source"; sourceTree = ""; }; + 567E2F1F17C44BBB005F1892 /* filesystem */ = { + isa = PBXGroup; + children = ( + 567E2F1B17C44BB2005F1892 /* SDL_sysfilesystem.m */, + ); + name = filesystem; + sourceTree = ""; + }; BEC562FE0761C0E800A33029 /* Linked Frameworks */ = { isa = PBXGroup; children = ( @@ -1722,6 +1742,7 @@ AA7557FE1595D4D800BBD41B /* SDL_assert.h in Headers */, AA7558001595D4D800BBD41B /* SDL_atomic.h in Headers */, AA7558021595D4D800BBD41B /* SDL_audio.h in Headers */, + AADA5B8716CCAB3000107CF7 /* SDL_bits.h in Headers */, AA7558041595D4D800BBD41B /* SDL_blendmode.h in Headers */, AA7558061595D4D800BBD41B /* SDL_clipboard.h in Headers */, AA7558081595D4D800BBD41B /* SDL_config_macosx.h in Headers */, @@ -1731,6 +1752,7 @@ AA7558101595D4D800BBD41B /* SDL_endian.h in Headers */, AA7558121595D4D800BBD41B /* SDL_error.h in Headers */, AA7558141595D4D800BBD41B /* SDL_events.h in Headers */, + 567E2F2117C44C35005F1892 /* SDL_filesystem.h in Headers */, A77E6EB4167AB0A90010E40B /* SDL_gamecontroller.h in Headers */, AA7558161595D4D800BBD41B /* SDL_gesture.h in Headers */, AA7558181595D4D800BBD41B /* SDL_haptic.h in Headers */, @@ -1854,7 +1876,6 @@ AA628ACC159367B7005138DD /* SDL_rotate.h in Headers */, AA628AD3159367F2005138DD /* SDL_x11xinput2.h in Headers */, AABCC38D164063D200AB8930 /* SDL_cocoamessagebox.h in Headers */, - AADA5B8716CCAB3000107CF7 /* SDL_bits.h in Headers */, D55A1B81179F262300625D7C /* SDL_cocoamousetap.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1863,6 +1884,60 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + DB0F490B17CA57ED008798C5 /* SDL_filesystem.h in Headers */, + AA7557FB1595D4D800BBD41B /* begin_code.h in Headers */, + AA7557FD1595D4D800BBD41B /* close_code.h in Headers */, + AA75585F1595D4D800BBD41B /* SDL.h in Headers */, + AA7557FF1595D4D800BBD41B /* SDL_assert.h in Headers */, + AA7558011595D4D800BBD41B /* SDL_atomic.h in Headers */, + AA7558031595D4D800BBD41B /* SDL_audio.h in Headers */, + AADA5B8816CCAB3000107CF7 /* SDL_bits.h in Headers */, + AA7558051595D4D800BBD41B /* SDL_blendmode.h in Headers */, + AA7558071595D4D800BBD41B /* SDL_clipboard.h in Headers */, + AA75580B1595D4D800BBD41B /* SDL_config.h in Headers */, + AA7558091595D4D800BBD41B /* SDL_config_macosx.h in Headers */, + AA75580D1595D4D800BBD41B /* SDL_copying.h in Headers */, + AA75580F1595D4D800BBD41B /* SDL_cpuinfo.h in Headers */, + AA7558111595D4D800BBD41B /* SDL_endian.h in Headers */, + AA7558131595D4D800BBD41B /* SDL_error.h in Headers */, + AA7558151595D4D800BBD41B /* SDL_events.h in Headers */, + A77E6EB5167AB0A90010E40B /* SDL_gamecontroller.h in Headers */, + AA7558171595D4D800BBD41B /* SDL_gesture.h in Headers */, + AA7558191595D4D800BBD41B /* SDL_haptic.h in Headers */, + AA75581B1595D4D800BBD41B /* SDL_hints.h in Headers */, + AA75581F1595D4D800BBD41B /* SDL_joystick.h in Headers */, + AA7558211595D4D800BBD41B /* SDL_keyboard.h in Headers */, + AA7558231595D4D800BBD41B /* SDL_keycode.h in Headers */, + AA7558251595D4D800BBD41B /* SDL_loadso.h in Headers */, + AA7558271595D4D800BBD41B /* SDL_log.h in Headers */, + AA7558291595D4D800BBD41B /* SDL_main.h in Headers */, + DB0F489417C400ED008798C5 /* SDL_messagebox.h in Headers */, + AA75582B1595D4D800BBD41B /* SDL_mouse.h in Headers */, + AA75582D1595D4D800BBD41B /* SDL_mutex.h in Headers */, + AA75582F1595D4D800BBD41B /* SDL_name.h in Headers */, + AA7558311595D4D800BBD41B /* SDL_opengl.h in Headers */, + AA7558331595D4D800BBD41B /* SDL_opengles.h in Headers */, + AA7558351595D4D800BBD41B /* SDL_opengles2.h in Headers */, + AA7558371595D4D800BBD41B /* SDL_pixels.h in Headers */, + AA7558391595D4D800BBD41B /* SDL_platform.h in Headers */, + AA75583B1595D4D800BBD41B /* SDL_power.h in Headers */, + AA75583D1595D4D800BBD41B /* SDL_quit.h in Headers */, + AA75583F1595D4D800BBD41B /* SDL_rect.h in Headers */, + AA7558411595D4D800BBD41B /* SDL_render.h in Headers */, + AA7558431595D4D800BBD41B /* SDL_revision.h in Headers */, + AA7558451595D4D800BBD41B /* SDL_rwops.h in Headers */, + AA7558471595D4D800BBD41B /* SDL_scancode.h in Headers */, + AA7558491595D4D800BBD41B /* SDL_shape.h in Headers */, + AA75584B1595D4D800BBD41B /* SDL_stdinc.h in Headers */, + AA75584D1595D4D800BBD41B /* SDL_surface.h in Headers */, + AA75584F1595D4D800BBD41B /* SDL_system.h in Headers */, + AA7558511595D4D800BBD41B /* SDL_syswm.h in Headers */, + AA7558531595D4D800BBD41B /* SDL_thread.h in Headers */, + AA7558551595D4D800BBD41B /* SDL_timer.h in Headers */, + AA7558571595D4D800BBD41B /* SDL_touch.h in Headers */, + AA7558591595D4D800BBD41B /* SDL_types.h in Headers */, + AA75585B1595D4D800BBD41B /* SDL_version.h in Headers */, + AA75585D1595D4D800BBD41B /* SDL_video.h in Headers */, 04BD022512E6671800899322 /* SDL_diskaudio.h in Headers */, 04BD022D12E6671800899322 /* SDL_dummyaudio.h in Headers */, 04BD023512E6671800899322 /* SDL_coreaudio.h in Headers */, @@ -1946,59 +2021,7 @@ 043567411303160F00BA5428 /* SDL_shaders_gl.h in Headers */, AA628ACD159367B7005138DD /* SDL_rotate.h in Headers */, AA628AD4159367F2005138DD /* SDL_x11xinput2.h in Headers */, - AA7557FB1595D4D800BBD41B /* begin_code.h in Headers */, - AA7557FD1595D4D800BBD41B /* close_code.h in Headers */, - AA7557FF1595D4D800BBD41B /* SDL_assert.h in Headers */, - AA7558011595D4D800BBD41B /* SDL_atomic.h in Headers */, - AA7558031595D4D800BBD41B /* SDL_audio.h in Headers */, - AA7558051595D4D800BBD41B /* SDL_blendmode.h in Headers */, - AA7558071595D4D800BBD41B /* SDL_clipboard.h in Headers */, - AA7558091595D4D800BBD41B /* SDL_config_macosx.h in Headers */, - AA75580B1595D4D800BBD41B /* SDL_config.h in Headers */, - AA75580D1595D4D800BBD41B /* SDL_copying.h in Headers */, - AA75580F1595D4D800BBD41B /* SDL_cpuinfo.h in Headers */, - AA7558111595D4D800BBD41B /* SDL_endian.h in Headers */, - AA7558131595D4D800BBD41B /* SDL_error.h in Headers */, - AA7558151595D4D800BBD41B /* SDL_events.h in Headers */, - AA7558171595D4D800BBD41B /* SDL_gesture.h in Headers */, - AA7558191595D4D800BBD41B /* SDL_haptic.h in Headers */, - AA75581B1595D4D800BBD41B /* SDL_hints.h in Headers */, - AA75581F1595D4D800BBD41B /* SDL_joystick.h in Headers */, - AA7558211595D4D800BBD41B /* SDL_keyboard.h in Headers */, - AA7558231595D4D800BBD41B /* SDL_keycode.h in Headers */, - AA7558251595D4D800BBD41B /* SDL_loadso.h in Headers */, - AA7558271595D4D800BBD41B /* SDL_log.h in Headers */, - AA7558291595D4D800BBD41B /* SDL_main.h in Headers */, - AA75582B1595D4D800BBD41B /* SDL_mouse.h in Headers */, - AA75582D1595D4D800BBD41B /* SDL_mutex.h in Headers */, - AA75582F1595D4D800BBD41B /* SDL_name.h in Headers */, - AA7558311595D4D800BBD41B /* SDL_opengl.h in Headers */, - AA7558331595D4D800BBD41B /* SDL_opengles.h in Headers */, - AA7558351595D4D800BBD41B /* SDL_opengles2.h in Headers */, - AA7558371595D4D800BBD41B /* SDL_pixels.h in Headers */, - AA7558391595D4D800BBD41B /* SDL_platform.h in Headers */, - AA75583B1595D4D800BBD41B /* SDL_power.h in Headers */, - AA75583D1595D4D800BBD41B /* SDL_quit.h in Headers */, - AA75583F1595D4D800BBD41B /* SDL_rect.h in Headers */, - AA7558411595D4D800BBD41B /* SDL_render.h in Headers */, - AA7558431595D4D800BBD41B /* SDL_revision.h in Headers */, - AA7558451595D4D800BBD41B /* SDL_rwops.h in Headers */, - AA7558471595D4D800BBD41B /* SDL_scancode.h in Headers */, - AA7558491595D4D800BBD41B /* SDL_shape.h in Headers */, - AA75584B1595D4D800BBD41B /* SDL_stdinc.h in Headers */, - AA75584D1595D4D800BBD41B /* SDL_surface.h in Headers */, - AA75584F1595D4D800BBD41B /* SDL_system.h in Headers */, - AA7558511595D4D800BBD41B /* SDL_syswm.h in Headers */, - AA7558531595D4D800BBD41B /* SDL_thread.h in Headers */, - AA7558551595D4D800BBD41B /* SDL_timer.h in Headers */, - AA7558571595D4D800BBD41B /* SDL_touch.h in Headers */, - AA7558591595D4D800BBD41B /* SDL_types.h in Headers */, - AA75585B1595D4D800BBD41B /* SDL_version.h in Headers */, - AA75585D1595D4D800BBD41B /* SDL_video.h in Headers */, - AA75585F1595D4D800BBD41B /* SDL.h in Headers */, AABCC38E164063D200AB8930 /* SDL_cocoamessagebox.h in Headers */, - A77E6EB5167AB0A90010E40B /* SDL_gamecontroller.h in Headers */, - AADA5B8816CCAB3000107CF7 /* SDL_bits.h in Headers */, D55A1B85179F278E00625D7C /* SDL_cocoamousetap.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2007,6 +2030,60 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + DB0F490C17CA57ED008798C5 /* SDL_filesystem.h in Headers */, + DB313FC817554B71006C0E22 /* begin_code.h in Headers */, + DB313FC917554B71006C0E22 /* close_code.h in Headers */, + DB313FF917554B71006C0E22 /* SDL.h in Headers */, + DB313FCA17554B71006C0E22 /* SDL_assert.h in Headers */, + DB313FCB17554B71006C0E22 /* SDL_atomic.h in Headers */, + DB313FCC17554B71006C0E22 /* SDL_audio.h in Headers */, + DB313FFC17554B71006C0E22 /* SDL_bits.h in Headers */, + DB313FCD17554B71006C0E22 /* SDL_blendmode.h in Headers */, + DB313FCE17554B71006C0E22 /* SDL_clipboard.h in Headers */, + DB313FD017554B71006C0E22 /* SDL_config.h in Headers */, + DB313FCF17554B71006C0E22 /* SDL_config_macosx.h in Headers */, + DB313FD117554B71006C0E22 /* SDL_copying.h in Headers */, + DB313FD217554B71006C0E22 /* SDL_cpuinfo.h in Headers */, + DB313FD317554B71006C0E22 /* SDL_endian.h in Headers */, + DB313FD417554B71006C0E22 /* SDL_error.h in Headers */, + DB313FD517554B71006C0E22 /* SDL_events.h in Headers */, + DB313FFB17554B71006C0E22 /* SDL_gamecontroller.h in Headers */, + DB313FD617554B71006C0E22 /* SDL_gesture.h in Headers */, + DB313FD717554B71006C0E22 /* SDL_haptic.h in Headers */, + DB313FD817554B71006C0E22 /* SDL_hints.h in Headers */, + DB313FD917554B71006C0E22 /* SDL_joystick.h in Headers */, + DB313FDA17554B71006C0E22 /* SDL_keyboard.h in Headers */, + DB313FDB17554B71006C0E22 /* SDL_keycode.h in Headers */, + DB313FDC17554B71006C0E22 /* SDL_loadso.h in Headers */, + DB313FDD17554B71006C0E22 /* SDL_log.h in Headers */, + DB313FDE17554B71006C0E22 /* SDL_main.h in Headers */, + DB0F489317C400E6008798C5 /* SDL_messagebox.h in Headers */, + DB313FDF17554B71006C0E22 /* SDL_mouse.h in Headers */, + DB313FE017554B71006C0E22 /* SDL_mutex.h in Headers */, + DB313FE117554B71006C0E22 /* SDL_name.h in Headers */, + DB313FE217554B71006C0E22 /* SDL_opengl.h in Headers */, + DB313FE317554B71006C0E22 /* SDL_opengles.h in Headers */, + DB313FE417554B71006C0E22 /* SDL_opengles2.h in Headers */, + DB313FE517554B71006C0E22 /* SDL_pixels.h in Headers */, + DB313FE617554B71006C0E22 /* SDL_platform.h in Headers */, + DB313FE717554B71006C0E22 /* SDL_power.h in Headers */, + DB313FE817554B71006C0E22 /* SDL_quit.h in Headers */, + DB313FE917554B71006C0E22 /* SDL_rect.h in Headers */, + DB313FEA17554B71006C0E22 /* SDL_render.h in Headers */, + DB313FEB17554B71006C0E22 /* SDL_revision.h in Headers */, + DB313FEC17554B71006C0E22 /* SDL_rwops.h in Headers */, + DB313FED17554B71006C0E22 /* SDL_scancode.h in Headers */, + DB313FEE17554B71006C0E22 /* SDL_shape.h in Headers */, + DB313FEF17554B71006C0E22 /* SDL_stdinc.h in Headers */, + DB313FF017554B71006C0E22 /* SDL_surface.h in Headers */, + DB313FF117554B71006C0E22 /* SDL_system.h in Headers */, + DB313FF217554B71006C0E22 /* SDL_syswm.h in Headers */, + DB313FF317554B71006C0E22 /* SDL_thread.h in Headers */, + DB313FF417554B71006C0E22 /* SDL_timer.h in Headers */, + DB313FF517554B71006C0E22 /* SDL_touch.h in Headers */, + DB313FF617554B71006C0E22 /* SDL_types.h in Headers */, + DB313FF717554B71006C0E22 /* SDL_version.h in Headers */, + DB313FF817554B71006C0E22 /* SDL_video.h in Headers */, DB313F7417554B71006C0E22 /* SDL_diskaudio.h in Headers */, DB313F7517554B71006C0E22 /* SDL_dummyaudio.h in Headers */, DB313F7617554B71006C0E22 /* SDL_coreaudio.h in Headers */, @@ -2090,59 +2167,7 @@ DB313FC517554B71006C0E22 /* SDL_shaders_gl.h in Headers */, DB313FC617554B71006C0E22 /* SDL_rotate.h in Headers */, DB313FC717554B71006C0E22 /* SDL_x11xinput2.h in Headers */, - DB313FC817554B71006C0E22 /* begin_code.h in Headers */, - DB313FC917554B71006C0E22 /* close_code.h in Headers */, - DB313FCA17554B71006C0E22 /* SDL_assert.h in Headers */, - DB313FCB17554B71006C0E22 /* SDL_atomic.h in Headers */, - DB313FCC17554B71006C0E22 /* SDL_audio.h in Headers */, - DB313FCD17554B71006C0E22 /* SDL_blendmode.h in Headers */, - DB313FCE17554B71006C0E22 /* SDL_clipboard.h in Headers */, - DB313FCF17554B71006C0E22 /* SDL_config_macosx.h in Headers */, - DB313FD017554B71006C0E22 /* SDL_config.h in Headers */, - DB313FD117554B71006C0E22 /* SDL_copying.h in Headers */, - DB313FD217554B71006C0E22 /* SDL_cpuinfo.h in Headers */, - DB313FD317554B71006C0E22 /* SDL_endian.h in Headers */, - DB313FD417554B71006C0E22 /* SDL_error.h in Headers */, - DB313FD517554B71006C0E22 /* SDL_events.h in Headers */, - DB313FD617554B71006C0E22 /* SDL_gesture.h in Headers */, - DB313FD717554B71006C0E22 /* SDL_haptic.h in Headers */, - DB313FD817554B71006C0E22 /* SDL_hints.h in Headers */, - DB313FD917554B71006C0E22 /* SDL_joystick.h in Headers */, - DB313FDA17554B71006C0E22 /* SDL_keyboard.h in Headers */, - DB313FDB17554B71006C0E22 /* SDL_keycode.h in Headers */, - DB313FDC17554B71006C0E22 /* SDL_loadso.h in Headers */, - DB313FDD17554B71006C0E22 /* SDL_log.h in Headers */, - DB313FDE17554B71006C0E22 /* SDL_main.h in Headers */, - DB313FDF17554B71006C0E22 /* SDL_mouse.h in Headers */, - DB313FE017554B71006C0E22 /* SDL_mutex.h in Headers */, - DB313FE117554B71006C0E22 /* SDL_name.h in Headers */, - DB313FE217554B71006C0E22 /* SDL_opengl.h in Headers */, - DB313FE317554B71006C0E22 /* SDL_opengles.h in Headers */, - DB313FE417554B71006C0E22 /* SDL_opengles2.h in Headers */, - DB313FE517554B71006C0E22 /* SDL_pixels.h in Headers */, - DB313FE617554B71006C0E22 /* SDL_platform.h in Headers */, - DB313FE717554B71006C0E22 /* SDL_power.h in Headers */, - DB313FE817554B71006C0E22 /* SDL_quit.h in Headers */, - DB313FE917554B71006C0E22 /* SDL_rect.h in Headers */, - DB313FEA17554B71006C0E22 /* SDL_render.h in Headers */, - DB313FEB17554B71006C0E22 /* SDL_revision.h in Headers */, - DB313FEC17554B71006C0E22 /* SDL_rwops.h in Headers */, - DB313FED17554B71006C0E22 /* SDL_scancode.h in Headers */, - DB313FEE17554B71006C0E22 /* SDL_shape.h in Headers */, - DB313FEF17554B71006C0E22 /* SDL_stdinc.h in Headers */, - DB313FF017554B71006C0E22 /* SDL_surface.h in Headers */, - DB313FF117554B71006C0E22 /* SDL_system.h in Headers */, - DB313FF217554B71006C0E22 /* SDL_syswm.h in Headers */, - DB313FF317554B71006C0E22 /* SDL_thread.h in Headers */, - DB313FF417554B71006C0E22 /* SDL_timer.h in Headers */, - DB313FF517554B71006C0E22 /* SDL_touch.h in Headers */, - DB313FF617554B71006C0E22 /* SDL_types.h in Headers */, - DB313FF717554B71006C0E22 /* SDL_version.h in Headers */, - DB313FF817554B71006C0E22 /* SDL_video.h in Headers */, - DB313FF917554B71006C0E22 /* SDL.h in Headers */, DB313FFA17554B71006C0E22 /* SDL_cocoamessagebox.h in Headers */, - DB313FFB17554B71006C0E22 /* SDL_gamecontroller.h in Headers */, - DB313FFC17554B71006C0E22 /* SDL_bits.h in Headers */, D55A1B86179F278F00625D7C /* SDL_cocoamousetap.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2427,6 +2452,7 @@ AA0AD09D16648D1700CE5896 /* SDL_gamecontroller.c in Sources */, AA0F8491178D5ECC00823F9D /* SDL_systls.c in Sources */, D55A1B82179F262300625D7C /* SDL_cocoamousetap.m in Sources */, + 567E2F1C17C44BB2005F1892 /* SDL_sysfilesystem.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2544,6 +2570,7 @@ AABCC390164063D200AB8930 /* SDL_cocoamessagebox.m in Sources */, AA0F8492178D5ECC00823F9D /* SDL_systls.c in Sources */, D55A1B84179F263600625D7C /* SDL_cocoamousetap.m in Sources */, + DB0F490817CA5292008798C5 /* SDL_sysfilesystem.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2661,6 +2688,7 @@ DB31406A17554B71006C0E22 /* SDL_cocoamessagebox.m in Sources */, AA0F8493178D5ECC00823F9D /* SDL_systls.c in Sources */, D55A1B83179F263500625D7C /* SDL_cocoamousetap.m in Sources */, + DB0F490A17CA5293008798C5 /* SDL_sysfilesystem.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj b/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj index bb4714de2..152c3d23c 100755 --- a/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj +++ b/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj @@ -13,6 +13,8 @@ buildPhases = ( ); dependencies = ( + DB0F490517CA5249008798C5 /* PBXTargetDependency */, + DB0F490717CA5249008798C5 /* PBXTargetDependency */, DB166E9816A1D7CF00A1396C /* PBXTargetDependency */, DB166E9616A1D7CD00A1396C /* PBXTargetDependency */, DB166E6C16A1D72000A1396C /* PBXTargetDependency */, @@ -397,6 +399,28 @@ BEC567930761D90500A33029 /* testtimer.c in Sources */ = {isa = PBXBuildFile; fileRef = 083E4880006D86A17F000001 /* testtimer.c */; }; BEC567AD0761D90500A33029 /* testver.c in Sources */ = {isa = PBXBuildFile; fileRef = 083E4882006D86A17F000001 /* testver.c */; }; BEC567F00761D90600A33029 /* torturethread.c in Sources */ = {isa = PBXBuildFile; fileRef = 083E4887006D86A17F000001 /* torturethread.c */; }; + DB0F48DD17CA51E5008798C5 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002F33A709CA188600EBEB88 /* Cocoa.framework */; }; + DB0F48DE17CA51E5008798C5 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A863B10730545007319AE /* CoreAudio.framework */; }; + DB0F48DF17CA51E5008798C5 /* ForceFeedback.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A863C10730545007319AE /* ForceFeedback.framework */; }; + DB0F48E017CA51E5008798C5 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A863D10730545007319AE /* IOKit.framework */; }; + DB0F48E117CA51E5008798C5 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A869F10730593007319AE /* AudioToolbox.framework */; }; + DB0F48E217CA51E5008798C5 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A86A010730593007319AE /* CoreFoundation.framework */; }; + DB0F48E317CA51E5008798C5 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A86F2107305CE007319AE /* OpenGL.framework */; }; + DB0F48E417CA51E5008798C5 /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A871410730623007319AE /* AudioUnit.framework */; }; + DB0F48E517CA51E5008798C5 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A873910730675007319AE /* Carbon.framework */; }; + DB0F48E617CA51E5008798C5 /* libSDL2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA645093FFD41000C53B3 /* libSDL2.a */; }; + DB0F48EE17CA51F8008798C5 /* testdrawchessboard.c in Sources */ = {isa = PBXBuildFile; fileRef = DB0F48D717CA51D2008798C5 /* testdrawchessboard.c */; }; + DB0F48F317CA5212008798C5 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002F33A709CA188600EBEB88 /* Cocoa.framework */; }; + DB0F48F417CA5212008798C5 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A863B10730545007319AE /* CoreAudio.framework */; }; + DB0F48F517CA5212008798C5 /* ForceFeedback.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A863C10730545007319AE /* ForceFeedback.framework */; }; + DB0F48F617CA5212008798C5 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A863D10730545007319AE /* IOKit.framework */; }; + DB0F48F717CA5212008798C5 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A869F10730593007319AE /* AudioToolbox.framework */; }; + DB0F48F817CA5212008798C5 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A86A010730593007319AE /* CoreFoundation.framework */; }; + DB0F48F917CA5212008798C5 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A86F2107305CE007319AE /* OpenGL.framework */; }; + DB0F48FA17CA5212008798C5 /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A871410730623007319AE /* AudioUnit.framework */; }; + DB0F48FB17CA5212008798C5 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A873910730675007319AE /* Carbon.framework */; }; + DB0F48FC17CA5212008798C5 /* libSDL2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA645093FFD41000C53B3 /* libSDL2.a */; }; + DB0F490317CA5225008798C5 /* testfilesystem.c in Sources */ = {isa = PBXBuildFile; fileRef = DB0F48D817CA51D2008798C5 /* testfilesystem.c */; }; DB166D7116A1CFB200A1396C /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A869F10730593007319AE /* AudioToolbox.framework */; }; DB166D7216A1CFB200A1396C /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A871410730623007319AE /* AudioUnit.framework */; }; DB166D7316A1CFB200A1396C /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A873910730675007319AE /* Carbon.framework */; }; @@ -780,6 +804,20 @@ remoteGlobalIDString = BECDF6BE0761BA81005FE872; remoteInfo = "Standard DMG"; }; + DB0F490417CA5249008798C5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; + proxyType = 1; + remoteGlobalIDString = DB0F48D917CA51E5008798C5; + remoteInfo = testdrawchessboard; + }; + DB0F490617CA5249008798C5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; + proxyType = 1; + remoteGlobalIDString = DB0F48EF17CA5212008798C5; + remoteInfo = testfilesystem; + }; DB166D6D16A1CEAA00A1396C /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; @@ -904,6 +942,24 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + DB0F48E717CA51E5008798C5 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 16; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + DB0F48FD17CA5212008798C5 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 16; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; DB166DDA16A1D40F00A1396C /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -1061,6 +1117,10 @@ BEC567980761D90500A33029 /* testtimer */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = testtimer; sourceTree = BUILT_PRODUCTS_DIR; }; BEC567B20761D90500A33029 /* testversion */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = testversion; sourceTree = BUILT_PRODUCTS_DIR; }; BEC567F50761D90600A33029 /* torturethread */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = torturethread; sourceTree = BUILT_PRODUCTS_DIR; }; + DB0F48D717CA51D2008798C5 /* testdrawchessboard.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testdrawchessboard.c; path = ../../test/testdrawchessboard.c; sourceTree = ""; }; + DB0F48D817CA51D2008798C5 /* testfilesystem.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testfilesystem.c; path = ../../test/testfilesystem.c; sourceTree = ""; }; + DB0F48EC17CA51E5008798C5 /* testdrawchessboard */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testdrawchessboard; sourceTree = BUILT_PRODUCTS_DIR; }; + DB0F490117CA5212008798C5 /* testfilesystem */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testfilesystem; sourceTree = BUILT_PRODUCTS_DIR; }; DB166CBB16A1C74100A1396C /* testgesture.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testgesture.c; path = ../../test/testgesture.c; sourceTree = ""; }; DB166CBC16A1C74100A1396C /* testgles.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testgles.c; path = ../../test/testgles.c; sourceTree = ""; }; DB166CBD16A1C74100A1396C /* testmessage.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testmessage.c; path = ../../test/testmessage.c; sourceTree = ""; }; @@ -1636,6 +1696,40 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + DB0F48DC17CA51E5008798C5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + DB0F48DD17CA51E5008798C5 /* Cocoa.framework in Frameworks */, + DB0F48DE17CA51E5008798C5 /* CoreAudio.framework in Frameworks */, + DB0F48DF17CA51E5008798C5 /* ForceFeedback.framework in Frameworks */, + DB0F48E017CA51E5008798C5 /* IOKit.framework in Frameworks */, + DB0F48E117CA51E5008798C5 /* AudioToolbox.framework in Frameworks */, + DB0F48E217CA51E5008798C5 /* CoreFoundation.framework in Frameworks */, + DB0F48E317CA51E5008798C5 /* OpenGL.framework in Frameworks */, + DB0F48E417CA51E5008798C5 /* AudioUnit.framework in Frameworks */, + DB0F48E517CA51E5008798C5 /* Carbon.framework in Frameworks */, + DB0F48E617CA51E5008798C5 /* libSDL2.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + DB0F48F217CA5212008798C5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + DB0F48F317CA5212008798C5 /* Cocoa.framework in Frameworks */, + DB0F48F417CA5212008798C5 /* CoreAudio.framework in Frameworks */, + DB0F48F517CA5212008798C5 /* ForceFeedback.framework in Frameworks */, + DB0F48F617CA5212008798C5 /* IOKit.framework in Frameworks */, + DB0F48F717CA5212008798C5 /* AudioToolbox.framework in Frameworks */, + DB0F48F817CA5212008798C5 /* CoreFoundation.framework in Frameworks */, + DB0F48F917CA5212008798C5 /* OpenGL.framework in Frameworks */, + DB0F48FA17CA5212008798C5 /* AudioUnit.framework in Frameworks */, + DB0F48FB17CA5212008798C5 /* Carbon.framework in Frameworks */, + DB0F48FC17CA5212008798C5 /* libSDL2.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; DB166D7C16A1D12400A1396C /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -1883,8 +1977,10 @@ 0017958F1074216E00F5D044 /* testatomic.c */, 001795B01074222D00F5D044 /* testaudioinfo.c */, 001797711074320D00F5D044 /* testdraw2.c */, + DB0F48D717CA51D2008798C5 /* testdrawchessboard.c */, 083E4878006D85357F000001 /* testerror.c */, 002F341709CA1C5B00EBEB88 /* testfile.c */, + DB0F48D817CA51D2008798C5 /* testfilesystem.c */, BBFC088E164C6820003E6A99 /* testgamecontroller.c */, DB166CBB16A1C74100A1396C /* testgesture.c */, 0017972710742FB900F5D044 /* testgl2.c */, @@ -1972,6 +2068,8 @@ DB166E6816A1D6F300A1396C /* testshader */, DB166E7E16A1D78400A1396C /* testspriteminimal */, DB166E9116A1D78C00A1396C /* teststreaming */, + DB0F48EC17CA51E5008798C5 /* testdrawchessboard */, + DB0F490117CA5212008798C5 /* testfilesystem */, ); name = Products; sourceTree = ""; @@ -2512,6 +2610,40 @@ productReference = BEC567F50761D90600A33029 /* torturethread */; productType = "com.apple.product-type.tool"; }; + DB0F48D917CA51E5008798C5 /* testdrawchessboard */ = { + isa = PBXNativeTarget; + buildConfigurationList = DB0F48E917CA51E5008798C5 /* Build configuration list for PBXNativeTarget "testdrawchessboard" */; + buildPhases = ( + DB0F48DA17CA51E5008798C5 /* Sources */, + DB0F48DC17CA51E5008798C5 /* Frameworks */, + DB0F48E717CA51E5008798C5 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = testdrawchessboard; + productName = testalpha; + productReference = DB0F48EC17CA51E5008798C5 /* testdrawchessboard */; + productType = "com.apple.product-type.tool"; + }; + DB0F48EF17CA5212008798C5 /* testfilesystem */ = { + isa = PBXNativeTarget; + buildConfigurationList = DB0F48FE17CA5212008798C5 /* Build configuration list for PBXNativeTarget "testfilesystem" */; + buildPhases = ( + DB0F48F017CA5212008798C5 /* Sources */, + DB0F48F217CA5212008798C5 /* Frameworks */, + DB0F48FD17CA5212008798C5 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = testfilesystem; + productName = testalpha; + productReference = DB0F490117CA5212008798C5 /* testfilesystem */; + productType = "com.apple.product-type.tool"; + }; DB166D7E16A1D12400A1396C /* SDL_test */ = { isa = PBXNativeTarget; buildConfigurationList = DB166D8016A1D12400A1396C /* Build configuration list for PBXNativeTarget "SDL_test" */; @@ -2730,8 +2862,10 @@ 0017957410741F7900F5D044 /* testatomic */, 00179595107421BF00F5D044 /* testaudioinfo */, 00179756107431B300F5D044 /* testdraw2 */, + DB0F48D917CA51E5008798C5 /* testdrawchessboard */, BEC566FB0761D90300A33029 /* testerror */, 002F340109CA1BFF00EBEB88 /* testfile */, + DB0F48EF17CA5212008798C5 /* testfilesystem */, BBFC08B7164C6862003E6A99 /* testgamecontroller */, DB166DAD16A1D2F600A1396C /* testgesture */, 0017970910742F3200F5D044 /* testgl2 */, @@ -3052,6 +3186,22 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + DB0F48DA17CA51E5008798C5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + DB0F48EE17CA51F8008798C5 /* testdrawchessboard.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + DB0F48F017CA5212008798C5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + DB0F490317CA5225008798C5 /* testfilesystem.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; DB166D7B16A1D12400A1396C /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -3302,6 +3452,16 @@ target = BEC567EA0761D90600A33029 /* torturethread */; targetProxy = 001799A11074403E00F5D044 /* PBXContainerItemProxy */; }; + DB0F490517CA5249008798C5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = DB0F48D917CA51E5008798C5 /* testdrawchessboard */; + targetProxy = DB0F490417CA5249008798C5 /* PBXContainerItemProxy */; + }; + DB0F490717CA5249008798C5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = DB0F48EF17CA5212008798C5 /* testfilesystem */; + targetProxy = DB0F490617CA5249008798C5 /* PBXContainerItemProxy */; + }; DB166D6E16A1CEAA00A1396C /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = BBFC08B7164C6862003E6A99 /* testgamecontroller */; @@ -3845,6 +4005,34 @@ }; name = Release; }; + DB0F48EA17CA51E5008798C5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = testdrawchessboard; + }; + name = Debug; + }; + DB0F48EB17CA51E5008798C5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = testdrawchessboard; + }; + name = Release; + }; + DB0F48FF17CA5212008798C5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = testfilesystem; + }; + name = Debug; + }; + DB0F490017CA5212008798C5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = testfilesystem; + }; + name = Release; + }; DB166D8116A1D12400A1396C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -4301,6 +4489,24 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; + DB0F48E917CA51E5008798C5 /* Build configuration list for PBXNativeTarget "testdrawchessboard" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + DB0F48EA17CA51E5008798C5 /* Debug */, + DB0F48EB17CA51E5008798C5 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; + DB0F48FE17CA5212008798C5 /* Build configuration list for PBXNativeTarget "testfilesystem" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + DB0F48FF17CA5212008798C5 /* Debug */, + DB0F490017CA5212008798C5 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; DB166D8016A1D12400A1396C /* Build configuration list for PBXNativeTarget "SDL_test" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/android-project/jni/src/Android_static.mk b/android-project/jni/src/Android_static.mk new file mode 100644 index 000000000..faed669c0 --- /dev/null +++ b/android-project/jni/src/Android_static.mk @@ -0,0 +1,12 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := main + +LOCAL_SRC_FILES := YourSourceHere.c + +LOCAL_STATIC_LIBRARIES := SDL2_static + +include $(BUILD_SHARED_LIBRARY) +$(call import-module,SDL)LOCAL_PATH := $(call my-dir) diff --git a/android-project/src/org/libsdl/app/SDLActivity.java b/android-project/src/org/libsdl/app/SDLActivity.java index ed6f4ef32..49b014ce1 100644 --- a/android-project/src/org/libsdl/app/SDLActivity.java +++ b/android-project/src/org/libsdl/app/SDLActivity.java @@ -1,10 +1,6 @@ package org.libsdl.app; -import javax.microedition.khronos.egl.EGL10; -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.egl.EGLContext; -import javax.microedition.khronos.egl.EGLDisplay; -import javax.microedition.khronos.egl.EGLSurface; +import java.util.Arrays; import android.app.*; import android.content.*; @@ -43,13 +39,6 @@ public class SDLActivity extends Activity { protected static Thread mAudioThread; protected static AudioTrack mAudioTrack; - // EGL objects - protected static EGLContext mEGLContext; - protected static EGLSurface mEGLSurface; - protected static EGLDisplay mEGLDisplay; - protected static EGLConfig mEGLConfig; - protected static int mGLMajor, mGLMinor; - // Load the .so static { System.loadLibrary("SDL2"); @@ -70,9 +59,7 @@ public class SDLActivity extends Activity { mSingleton = this; // Set up the surface - mEGLSurface = EGL10.EGL_NO_SURFACE; mSurface = new SDLSurface(getApplication()); - mEGLContext = EGL10.EGL_NO_CONTEXT; mLayout = new AbsoluteLayout(this); mLayout.addView(mSurface); @@ -137,9 +124,13 @@ public class SDLActivity extends Activity { @Override public boolean dispatchKeyEvent(KeyEvent event) { int keyCode = event.getKeyCode(); - // Ignore volume keys so they're handled by Android + // Ignore certain special keys so they're handled by Android if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || - keyCode == KeyEvent.KEYCODE_VOLUME_UP) { + keyCode == KeyEvent.KEYCODE_VOLUME_UP || + keyCode == KeyEvent.KEYCODE_CAMERA || + keyCode == 168 || /* API 11: KeyEvent.KEYCODE_ZOOM_IN */ + keyCode == 169 /* API 11: KeyEvent.KEYCODE_ZOOM_OUT */ + ) { return false; } return super.dispatchKeyEvent(event); @@ -252,29 +243,12 @@ public class SDLActivity extends Activity { int action, float x, float y, float p); public static native void onNativeAccel(float x, float y, float z); - - // Java functions called from C - - public static boolean createGLContext(int majorVersion, int minorVersion, int[] attribs) { - return initEGL(majorVersion, minorVersion, attribs); - } - - public static void deleteGLContext() { - if (SDLActivity.mEGLDisplay != null && SDLActivity.mEGLContext != EGL10.EGL_NO_CONTEXT) { - EGL10 egl = (EGL10)EGLContext.getEGL(); - egl.eglMakeCurrent(SDLActivity.mEGLDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT); - egl.eglDestroyContext(SDLActivity.mEGLDisplay, SDLActivity.mEGLContext); - SDLActivity.mEGLContext = EGL10.EGL_NO_CONTEXT; - - if (SDLActivity.mEGLSurface != EGL10.EGL_NO_SURFACE) { - egl.eglDestroySurface(SDLActivity.mEGLDisplay, SDLActivity.mEGLSurface); - SDLActivity.mEGLSurface = EGL10.EGL_NO_SURFACE; - } - } - } + public static native void onNativeSurfaceChanged(); + public static native void onNativeSurfaceDestroyed(); + public static native void nativeFlipBuffers(); public static void flipBuffers() { - flipEGL(); + SDLActivity.nativeFlipBuffers(); } public static boolean setActivityTitle(String title) { @@ -332,147 +306,9 @@ public class SDLActivity extends Activity { // Transfer the task to the main thread as a Runnable return mSingleton.commandHandler.post(new ShowTextInputTask(x, y, w, h)); } - - - // EGL functions - public static boolean initEGL(int majorVersion, int minorVersion, int[] attribs) { - try { - EGL10 egl = (EGL10)EGLContext.getEGL(); - if (SDLActivity.mEGLDisplay == null) { - SDLActivity.mEGLDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); - int[] version = new int[2]; - egl.eglInitialize(SDLActivity.mEGLDisplay, version); - } - - if (SDLActivity.mEGLDisplay != null && SDLActivity.mEGLContext == EGL10.EGL_NO_CONTEXT) { - // No current GL context exists, we will create a new one. - Log.v("SDL", "Starting up OpenGL ES " + majorVersion + "." + minorVersion); - EGLConfig[] configs = new EGLConfig[128]; - int[] num_config = new int[1]; - if (!egl.eglChooseConfig(SDLActivity.mEGLDisplay, attribs, configs, 1, num_config) || num_config[0] == 0) { - Log.e("SDL", "No EGL config available"); - return false; - } - EGLConfig config = null; - int bestdiff = -1, bitdiff; - int[] value = new int[1]; - - // eglChooseConfig returns a number of configurations that match or exceed the requested attribs. - // From those, we select the one that matches our requirements more closely - Log.v("SDL", "Got " + num_config[0] + " valid modes from egl"); - for(int i = 0; i < num_config[0]; i++) { - bitdiff = 0; - // Go through some of the attributes and compute the bit difference between what we want and what we get. - for (int j = 0; ; j += 2) { - if (attribs[j] == EGL10.EGL_NONE) - break; - - if (attribs[j+1] != EGL10.EGL_DONT_CARE && (attribs[j] == EGL10.EGL_RED_SIZE || - attribs[j] == EGL10.EGL_GREEN_SIZE || - attribs[j] == EGL10.EGL_BLUE_SIZE || - attribs[j] == EGL10.EGL_ALPHA_SIZE || - attribs[j] == EGL10.EGL_DEPTH_SIZE || - attribs[j] == EGL10.EGL_STENCIL_SIZE)) { - egl.eglGetConfigAttrib(SDLActivity.mEGLDisplay, configs[i], attribs[j], value); - bitdiff += value[0] - attribs[j + 1]; // value is always >= attrib - } - } - - if (bitdiff < bestdiff || bestdiff == -1) { - config = configs[i]; - bestdiff = bitdiff; - } - - if (bitdiff == 0) break; // we found an exact match! - } - - Log.d("SDL", "Selected mode with a total bit difference of " + bestdiff); - - SDLActivity.mEGLConfig = config; - SDLActivity.mGLMajor = majorVersion; - SDLActivity.mGLMinor = minorVersion; - } - - return SDLActivity.createEGLSurface(); - - } catch(Exception e) { - Log.v("SDL", e + ""); - for (StackTraceElement s : e.getStackTrace()) { - Log.v("SDL", s.toString()); - } - return false; - } - } - - public static boolean createEGLContext() { - EGL10 egl = (EGL10)EGLContext.getEGL(); - int EGL_CONTEXT_CLIENT_VERSION=0x3098; - int contextAttrs[] = new int[] { EGL_CONTEXT_CLIENT_VERSION, SDLActivity.mGLMajor, EGL10.EGL_NONE }; - SDLActivity.mEGLContext = egl.eglCreateContext(SDLActivity.mEGLDisplay, SDLActivity.mEGLConfig, EGL10.EGL_NO_CONTEXT, contextAttrs); - if (SDLActivity.mEGLContext == EGL10.EGL_NO_CONTEXT) { - Log.e("SDL", "Couldn't create context"); - return false; - } - return true; - } - - public static boolean createEGLSurface() { - if (SDLActivity.mEGLDisplay != null && SDLActivity.mEGLConfig != null) { - EGL10 egl = (EGL10)EGLContext.getEGL(); - if (SDLActivity.mEGLContext == EGL10.EGL_NO_CONTEXT) createEGLContext(); - - if (SDLActivity.mEGLSurface == EGL10.EGL_NO_SURFACE) { - Log.v("SDL", "Creating new EGL Surface"); - SDLActivity.mEGLSurface = egl.eglCreateWindowSurface(SDLActivity.mEGLDisplay, SDLActivity.mEGLConfig, SDLActivity.mSurface, null); - if (SDLActivity.mEGLSurface == EGL10.EGL_NO_SURFACE) { - Log.e("SDL", "Couldn't create surface"); - return false; - } - } - else Log.v("SDL", "EGL Surface remains valid"); - - if (egl.eglGetCurrentContext() != SDLActivity.mEGLContext) { - if (!egl.eglMakeCurrent(SDLActivity.mEGLDisplay, SDLActivity.mEGLSurface, SDLActivity.mEGLSurface, SDLActivity.mEGLContext)) { - Log.e("SDL", "Old EGL Context doesnt work, trying with a new one"); - // TODO: Notify the user via a message that the old context could not be restored, and that textures need to be manually restored. - createEGLContext(); - if (!egl.eglMakeCurrent(SDLActivity.mEGLDisplay, SDLActivity.mEGLSurface, SDLActivity.mEGLSurface, SDLActivity.mEGLContext)) { - Log.e("SDL", "Failed making EGL Context current"); - return false; - } - } - else Log.v("SDL", "EGL Context made current"); - } - else Log.v("SDL", "EGL Context remains current"); - - return true; - } else { - Log.e("SDL", "Surface creation failed, display = " + SDLActivity.mEGLDisplay + ", config = " + SDLActivity.mEGLConfig); - return false; - } - } - - // EGL buffer flip - public static void flipEGL() { - try { - EGL10 egl = (EGL10)EGLContext.getEGL(); - - egl.eglWaitNative(EGL10.EGL_CORE_NATIVE_ENGINE, null); - - // drawing here - - egl.eglWaitGL(); - - egl.eglSwapBuffers(SDLActivity.mEGLDisplay, SDLActivity.mEGLSurface); - - - } catch(Exception e) { - Log.v("SDL", "flipEGL(): " + e); - for (StackTraceElement s : e.getStackTrace()) { - Log.v("SDL", s.toString()); - } - } + public static Surface getNativeSurface() { + return SDLActivity.mSurface.getNativeSurface(); } // Audio @@ -552,6 +388,24 @@ public class SDLActivity extends Activity { mAudioTrack = null; } } + + // Input + + /** + * @return an array which may be empty but is never null. + */ + public static int[] inputGetInputDeviceIds(int sources) { + int[] ids = InputDevice.getDeviceIds(); + int[] filtered = new int[ids.length]; + int used = 0; + for (int i = 0; i < ids.length; ++i) { + InputDevice device = InputDevice.getDevice(ids[i]); + if ((device != null) && ((device.getSources() & sources) != 0)) { + filtered[used++] = device.getId(); + } + } + return Arrays.copyOf(filtered, used); + } } /** @@ -579,6 +433,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, // Sensors protected static SensorManager mSensorManager; + protected static Display mDisplay; // Keep track of the surface size to normalize touch events protected static float mWidth, mHeight; @@ -594,20 +449,23 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, setOnKeyListener(this); setOnTouchListener(this); + mDisplay = ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); mSensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE); // Some arbitrary defaults to avoid a potential division by zero mWidth = 1.0f; mHeight = 1.0f; } + + public Surface getNativeSurface() { + return getHolder().getSurface(); + } // Called when we have a valid drawing surface @Override public void surfaceCreated(SurfaceHolder holder) { Log.v("SDL", "surfaceCreated()"); holder.setType(SurfaceHolder.SURFACE_TYPE_GPU); - // Set mIsSurfaceReady to 'true' *before* any call to handleResume - SDLActivity.mIsSurfaceReady = true; } // Called when we lose the surface @@ -617,16 +475,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, // Call this *before* setting mIsSurfaceReady to 'false' SDLActivity.handlePause(); SDLActivity.mIsSurfaceReady = false; - - /* We have to clear the current context and destroy the egl surface here - * Otherwise there's BAD_NATIVE_WINDOW errors coming from eglCreateWindowSurface on resume - * Ref: http://stackoverflow.com/questions/8762589/eglcreatewindowsurface-on-ics-and-switching-from-2d-to-3d - */ - - EGL10 egl = (EGL10)EGLContext.getEGL(); - egl.eglMakeCurrent(SDLActivity.mEGLDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT); - egl.eglDestroySurface(SDLActivity.mEGLDisplay, SDLActivity.mEGLSurface); - SDLActivity.mEGLSurface = EGL10.EGL_NO_SURFACE; + SDLActivity.onNativeSurfaceDestroyed(); } // Called when the surface is resized @@ -687,6 +536,8 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, // Set mIsSurfaceReady to 'true' *before* making a call to handleResume SDLActivity.mIsSurfaceReady = true; + SDLActivity.onNativeSurfaceChanged(); + if (SDLActivity.mSDLThread == null) { // This is the entry point to the C app. @@ -695,11 +546,6 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, SDLActivity.mSDLThread = new Thread(new SDLMain(), "SDLThread"); enableSensor(Sensor.TYPE_ACCELEROMETER, true); SDLActivity.mSDLThread.start(); - } else { - // The app already exists, we resume via handleResume - // Multiple sequential calls to surfaceChanged are handled internally by handleResume - - SDLActivity.handleResume(); } } @@ -777,9 +623,28 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, @Override public void onSensorChanged(SensorEvent event) { if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { - SDLActivity.onNativeAccel(event.values[0] / SensorManager.GRAVITY_EARTH, - event.values[1] / SensorManager.GRAVITY_EARTH, - event.values[2] / SensorManager.GRAVITY_EARTH); + float x, y; + switch (mDisplay.getRotation()) { + case Surface.ROTATION_90: + x = -event.values[1]; + y = event.values[0]; + break; + case Surface.ROTATION_270: + x = event.values[1]; + y = -event.values[0]; + break; + case Surface.ROTATION_180: + x = -event.values[1]; + y = -event.values[0]; + break; + default: + x = event.values[0]; + y = event.values[1]; + break; + } + SDLActivity.onNativeAccel(-x / SensorManager.GRAVITY_EARTH, + y / SensorManager.GRAVITY_EARTH, + event.values[2] / SensorManager.GRAVITY_EARTH - 1); } } diff --git a/build-scripts/androidbuild.sh b/build-scripts/androidbuild.sh new file mode 100755 index 000000000..b4a83234c --- /dev/null +++ b/build-scripts/androidbuild.sh @@ -0,0 +1,114 @@ +#!/bin/bash + +SOURCES=() +MKSOURCES="" +CURDIR=`pwd -P` + +# Fetch sources +if [[ $# -ge 2 ]]; then + for src in ${@:2} + do + SOURCES+=($src) + MKSOURCES="$MKSOURCES $(basename $src)" + done +else + if [ -n "$1" ]; then + while read src + do + SOURCES+=($src) + MKSOURCES="$MKSOURCES $(basename $src)" + done + fi +fi + +if [ -z "$1" ] || [ -z "$SOURCES" ]; then + echo "Usage: androidbuild.sh com.yourcompany.yourapp < sources.list" + echo "Usage: androidbuild.sh com.yourcompany.yourapp source1.c source2.c ...sourceN.c" + exit 1 +fi + + + +SDLPATH="$( cd "$(dirname "$0")/.." ; pwd -P )" + +NDKBUILD=`which ndk-build` +if [ -z "$NDKBUILD" ];then + echo "Could not find the ndk-build utility, install Android's NDK and add it to the path" + exit 1 +fi + +ANDROID=`which android` +if [ -z "$ANDROID" ];then + echo "Could not find the android utility, install Android's SDK and add it to the path" + exit 1 +fi + +ANT=`which ant` + +if [ -z "$ANT" ];then + echo "Could not find the ant utility, install Android's SDK and add it to the path" + exit 1 +fi + +APP="$1" +APPARR=(${APP//./ }) +BUILDPATH="$SDLPATH/build/$APP" + +# Start Building + +rm -rf $BUILDPATH +mkdir -p $BUILDPATH + +cp -r $SDLPATH/android-project/* $BUILDPATH + +# Copy SDL sources +mkdir -p $BUILDPATH/jni/SDL +cp -r $SDLPATH/src $BUILDPATH/jni/SDL +cp -r $SDLPATH/include $BUILDPATH/jni/SDL +cp $SDLPATH/Android.mk $BUILDPATH/jni/SDL +sed -i "s|YourSourceHere.c|$MKSOURCES|g" $BUILDPATH/jni/src/Android.mk +sed -i "s|org\.libsdl\.app|$APP|g" $BUILDPATH/AndroidManifest.xml + +# Copy user sources +for src in "${SOURCES[@]}" +do + cp $src $BUILDPATH/jni/src +done + +# Create an inherited Activity +cd $BUILDPATH/src +for folder in "${APPARR[@]}" +do + mkdir -p $folder + cd $folder +done + +ACTIVITY="${folder}Activity" +sed -i "s|SDLActivity|$ACTIVITY|g" $BUILDPATH/AndroidManifest.xml +sed -i "s|SDLActivity|$APP|g" $BUILDPATH/build.xml + +# Fill in a default Activity +echo "package $APP;" > "$ACTIVITY.java" +echo "import org.libsdl.app.SDLActivity;" >> "$ACTIVITY.java" +echo "public class $ACTIVITY extends SDLActivity {}" >> "$ACTIVITY.java" + +# Update project and build +cd $BUILDPATH +android update project --path $BUILDPATH +$NDKBUILD +$ANT debug + +cd $CURDIR + +APK="$BUILDPATH/bin/$APP-debug.apk" + +if [ -f "$APK" ]; then + echo "Your APK is ready at $APK" + echo "To install to your device: " + echo "cd $BUILDPATH" + echo "ant debug install" + exit 0 +fi + +echo "There was an error building the APK" +exit 1 \ No newline at end of file diff --git a/build-scripts/config.guess b/build-scripts/config.guess index 137bedf2e..ddb36220a 100644 --- a/build-scripts/config.guess +++ b/build-scripts/config.guess @@ -896,12 +896,16 @@ EOF then echo ${UNAME_MACHINE}-unknown-linux-gnu else + case `sed -n '/^Hardware/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + BCM2708) MANUFACTURER=raspberry;; + *) MANUFACTURER=unknown;; + esac if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then - echo ${UNAME_MACHINE}-unknown-linux-gnueabi + echo ${UNAME_MACHINE}-${MANUFACTURER}-linux-gnueabi else - echo ${UNAME_MACHINE}-unknown-linux-gnueabihf + echo ${UNAME_MACHINE}-${MANUFACTURER}-linux-gnueabihf fi fi exit ;; diff --git a/build-scripts/raspberrypi-buildbot.sh b/build-scripts/raspberrypi-buildbot.sh new file mode 100755 index 000000000..4c746c014 --- /dev/null +++ b/build-scripts/raspberrypi-buildbot.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# This is the script buildbot.libsdl.org uses to cross-compile SDL2 from +# x86 Linux to Raspberry Pi. + +# The final tarball can be unpacked in the root directory of a RPi, +# so the SDL2 install lands in /usr/local. Run ldconfig, and then +# you should be able to build and run SDL2-based software on your +# Pi. Standard configure scripts should be able to find SDL and +# build against it, and sdl2-config should work correctly on the +# actual device. + +TARBALL="$1" +if [ -z $1 ]; then + TARBALL=sdl-raspberrypi.tar.bz2 +fi + +OSTYPE=`uname -s` +if [ "$OSTYPE" != "Linux" ]; then + # !!! FIXME + echo "This only works on x86 or x64-64 Linux at the moment." 1>&2 + exit 1 +fi + +if [ "x$MAKE" == "x" ]; then + NCPU=`cat /proc/cpuinfo |grep vendor_id |wc -l` + let NCPU=$NCPU+1 + MAKE="make -j$NCPU" +fi + +BUILDBOTDIR="raspberrypi-buildbot" +PARENTDIR="$PWD" + +set -e +set -x +rm -f $TARBALL +rm -rf $BUILDBOTDIR +mkdir -p $BUILDBOTDIR +pushd $BUILDBOTDIR + +SYSROOT="/opt/rpi-sysroot" +export CC="/opt/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc --sysroot=$SYSROOT -I$SYSROOT/opt/vc/include -I$SYSROOT/usr/include -I$SYSROOT/opt/vc/include/interface/vcos/pthreads -I$SYSROOT/opt/vc/include/interface/vmcs_host/linux" +# -L$SYSROOT/usr/lib/arm-linux-gnueabihf" +# !!! FIXME: shouldn't have to --disable-* things here. +../configure --with-sysroot=$SYSROOT --host=arm-raspberry-linux-gnueabihf --prefix=$PWD/rpi-sdl2-installed --disable-pulseaudio --disable-esd +$MAKE +$MAKE install +# Fix up a few things to a real install path on a real Raspberry Pi... +perl -w -pi -e "s#$PWD/rpi-sdl2-installed#/usr/local#g;" ./rpi-sdl2-installed/lib/libSDL2.la ./rpi-sdl2-installed/lib/pkgconfig/sdl2.pc ./rpi-sdl2-installed/bin/sdl2-config +mkdir -p ./usr +mv ./rpi-sdl2-installed ./usr/local + +popd +tar -cjvvf $TARBALL -C $BUILDBOTDIR usr +rm -rf $BUILDBOTDIR + +set +x +echo "All done. Final installable is in $TARBALL ..."; + + diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake index 14fb327b1..fe763785c 100644 --- a/cmake/sdlchecks.cmake +++ b/cmake/sdlchecks.cmake @@ -304,6 +304,11 @@ macro(CheckX11) endif() endforeach() + find_path(X_INCLUDEDIR X11/Xlib.h) + if(X_INCLUDEDIR) + set(X_CFLAGS "-I${X_INCLUDEDIR}") + endif() + 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) @@ -345,6 +350,7 @@ macro(CheckX11) endif(HAVE_SHMAT) if(NOT HAVE_SHMAT) add_definitions(-DNO_SHARED_MEMORY) + set(X_CFLAGS "${X_CFLAGS} -DNO_SHARED_MEMORY") endif(NOT HAVE_SHMAT) endif(NOT HAVE_SHMAT) @@ -367,6 +373,8 @@ macro(CheckX11) endif(HAVE_X11_SHARED) endif(X11_SHARED) + set(SDL_CFLAGS "${SDL_CFLAGS} ${X_CFLAGS}") + set(CMAKE_REQUIRED_LIBRARIES ${X11_LIB} ${X11_LIB}) check_c_source_compiles(" #include @@ -563,25 +571,29 @@ macro(CheckOpenGLESX11) if(VIDEO_OPENGLES) check_c_source_compiles(" #include - int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES) - if(HAVE_VIDEO_OPENGLES) - check_c_source_compiles(" - #include - #include - int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES_V1) - if(HAVE_VIDEO_OPENGLES_V1) + int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGL_EGL) + if(HAVE_VIDEO_OPENGL_EGL) + set(SDL_VIDEO_OPENGL_EGL 1) + endif(HAVE_VIDEO_OPENGL_EGL) + check_c_source_compiles(" + #include + #include + int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES_V1) + if(HAVE_VIDEO_OPENGLES_V1) + set(HAVE_VIDEO_OPENGLES TRUE) set(SDL_VIDEO_OPENGL_ES 1) set(SDL_VIDEO_RENDER_OGL_ES 1) - endif(HAVE_VIDEO_OPENGLES_V1) - check_c_source_compiles(" - #include - #include - int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES_V2) - if(HAVE_VIDEO_OPENGLES_V2) + endif(HAVE_VIDEO_OPENGLES_V1) + check_c_source_compiles(" + #include + #include + int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES_V2) + if(HAVE_VIDEO_OPENGLES_V2) + set(HAVE_VIDEO_OPENGLES TRUE) set(SDL_VIDEO_OPENGL_ES2 1) set(SDL_VIDEO_RENDER_OGL_ES2 1) - endif(HAVE_VIDEO_OPENGLES_V2) - endif(HAVE_VIDEO_OPENGLES) + endif(HAVE_VIDEO_OPENGLES_V2) + endif(VIDEO_OPENGLES) endmacro(CheckOpenGLESX11) diff --git a/configure b/configure index 38084c272..ba2489430 100755 --- a/configure +++ b/configure @@ -783,6 +783,7 @@ enable_events enable_joystick enable_haptic enable_power +enable_filesystem enable_threads enable_timers enable_file @@ -1496,6 +1497,7 @@ Optional Features: --enable-haptic Enable the haptic (force feedback) subsystem [[default=yes]] --enable-power Enable the power subsystem [[default=yes]] + --enable-filesystem Enable the filesystem subsystem [[default=yes]] --enable-threads Enable the threading subsystem [[default=yes]] --enable-timers Enable the timer subsystem [[default=yes]] --enable-file Enable the file subsystem [[default=yes]] @@ -2658,9 +2660,9 @@ orig_CFLAGS="$CFLAGS" # SDL_MAJOR_VERSION=2 SDL_MINOR_VERSION=0 -SDL_MICRO_VERSION=0 +SDL_MICRO_VERSION=1 SDL_INTERFACE_AGE=0 -SDL_BINARY_AGE=0 +SDL_BINARY_AGE=1 SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION @@ -16767,6 +16769,7 @@ SOURCES="$SOURCES $srcdir/src/haptic/*.c" SOURCES="$SOURCES $srcdir/src/joystick/*.c" SOURCES="$SOURCES $srcdir/src/libm/*.c" SOURCES="$SOURCES $srcdir/src/power/*.c" +#SOURCES="$SOURCES $srcdir/src/filesystem/*.c" SOURCES="$SOURCES $srcdir/src/render/*.c" SOURCES="$SOURCES $srcdir/src/render/*/*.c" SOURCES="$SOURCES $srcdir/src/stdlib/*.c" @@ -16870,6 +16873,18 @@ if test x$enable_power != xyes; then $as_echo "#define SDL_POWER_DISABLED 1" >>confdefs.h +fi +# Check whether --enable-filesystem was given. +if test "${enable_filesystem+set}" = set; then : + enableval=$enable_filesystem; +else + enable_filesystem=yes +fi + +if test x$enable_filesystem != xyes; then + +$as_echo "#define SDL_FILESYSTEM_DISABLED 1" >>confdefs.h + fi # Check whether --enable-threads was given. if test "${enable_threads+set}" = set; then : @@ -20547,9 +20562,9 @@ fi CheckOpenGLESX11() { if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES (EGL) support" >&5 -$as_echo_n "checking for OpenGL ES (EGL) support... " >&6; } - video_opengles=no + { $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. */ @@ -20566,21 +20581,26 @@ main () _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - video_opengles=yes + 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_opengles" >&5 -$as_echo "$video_opengles" >&6; } - if test x$video_opengles = xyes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v1 headers" >&5 + { $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 v1 headers" >&5 $as_echo_n "checking for OpenGL ES v1 headers... " >&6; } - video_opengles_v1=no - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + video_opengles_v1=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include - #include + #include + #include int main () @@ -20593,28 +20613,29 @@ main () _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - video_opengles_v1=yes + video_opengles_v1=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v1" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v1" >&5 $as_echo "$video_opengles_v1" >&6; } - if test x$video_opengles_v1 = xyes; then + if test x$video_opengles_v1 = xyes; then $as_echo "#define SDL_VIDEO_OPENGL_ES 1" >>confdefs.h $as_echo "#define SDL_VIDEO_RENDER_OGL_ES 1" >>confdefs.h - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v2 headers" >&5 + 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 + video_opengles_v2=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include - #include + #include + #include int main () @@ -20627,20 +20648,19 @@ main () _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - video_opengles_v2=yes + 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 "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v2" >&5 $as_echo "$video_opengles_v2" >&6; } - if test x$video_opengles_v2 = xyes; then + 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 - fi fi fi } @@ -20734,6 +20754,45 @@ $as_echo "#define SDL_INPUT_LINUXEV 1" >>confdefs.h fi } +CheckInputKD() +{ + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Linux kd.h" >&5 +$as_echo_n "checking for Linux kd.h... " >&6; } + use_input_kd=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + #include + +int +main () +{ + + struct kbentry kbe; + kbe.kb_table = KG_CTRL; + ioctl(0, KDGKBENT, &kbe); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + use_input_kd=yes + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $use_input_kd" >&5 +$as_echo "$use_input_kd" >&6; } + if test x$use_input_kd = xyes; then + +$as_echo "#define SDL_INPUT_LINUXKD 1" >>confdefs.h + + fi +} + CheckLibUDev() { # Check whether --enable-libudev was given. @@ -21575,8 +21634,10 @@ $as_echo "#define SDL_LOADSO_DLOPEN 1" >>confdefs.h CheckUSBHID() { - if test x$enable_joystick = xyes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for hid_init in -lusbhid" >&5 + case "$host" in + *-*-*bsd*) + if test x$enable_joystick = xyes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for hid_init in -lusbhid" >&5 $as_echo_n "checking for hid_init in -lusbhid... " >&6; } if ${ac_cv_lib_usbhid_hid_init+:} false; then : $as_echo_n "(cached) " >&6 @@ -21616,34 +21677,34 @@ if test "x$ac_cv_lib_usbhid_hid_init" = xyes; then : have_libusbhid=yes fi - if test x$have_libusbhid = xyes; then - ac_fn_c_check_header_mongrel "$LINENO" "usbhid.h" "ac_cv_header_usbhid_h" "$ac_includes_default" + if test x$have_libusbhid = xyes; then + ac_fn_c_check_header_mongrel "$LINENO" "usbhid.h" "ac_cv_header_usbhid_h" "$ac_includes_default" if test "x$ac_cv_header_usbhid_h" = xyes; then : USB_CFLAGS="-DHAVE_USBHID_H" fi - ac_fn_c_check_header_mongrel "$LINENO" "libusbhid.h" "ac_cv_header_libusbhid_h" "$ac_includes_default" + ac_fn_c_check_header_mongrel "$LINENO" "libusbhid.h" "ac_cv_header_libusbhid_h" "$ac_includes_default" if test "x$ac_cv_header_libusbhid_h" = xyes; then : USB_CFLAGS="-DHAVE_LIBUSBHID_H" fi - USB_LIBS="$USB_LIBS -lusbhid" - else - ac_fn_c_check_header_mongrel "$LINENO" "usb.h" "ac_cv_header_usb_h" "$ac_includes_default" + USB_LIBS="$USB_LIBS -lusbhid" + else + ac_fn_c_check_header_mongrel "$LINENO" "usb.h" "ac_cv_header_usb_h" "$ac_includes_default" if test "x$ac_cv_header_usb_h" = xyes; then : USB_CFLAGS="-DHAVE_USB_H" fi - ac_fn_c_check_header_mongrel "$LINENO" "libusb.h" "ac_cv_header_libusb_h" "$ac_includes_default" + ac_fn_c_check_header_mongrel "$LINENO" "libusb.h" "ac_cv_header_libusb_h" "$ac_includes_default" if test "x$ac_cv_header_libusb_h" = xyes; then : USB_CFLAGS="-DHAVE_LIBUSB_H" fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for hid_init in -lusb" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for hid_init in -lusb" >&5 $as_echo_n "checking for hid_init in -lusb... " >&6; } if ${ac_cv_lib_usb_hid_init+:} false; then : $as_echo_n "(cached) " >&6 @@ -21683,43 +21744,43 @@ if test "x$ac_cv_lib_usb_hid_init" = xyes; then : USB_LIBS="$USB_LIBS -lusb" fi - fi + fi - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $USB_CFLAGS" + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $USB_CFLAGS" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for usbhid" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for usbhid" >&5 $as_echo_n "checking for usbhid... " >&6; } - have_usbhid=no - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + have_usbhid=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include - #if defined(HAVE_USB_H) - #include - #endif - #ifdef __DragonFly__ - # include - # include - #else - # include - # include - #endif - #if defined(HAVE_USBHID_H) - #include - #elif defined(HAVE_LIBUSB_H) - #include - #elif defined(HAVE_LIBUSBHID_H) - #include - #endif + #include + #if defined(HAVE_USB_H) + #include + #endif + #ifdef __DragonFly__ + # include + # include + #else + # include + # include + #endif + #if defined(HAVE_USBHID_H) + #include + #elif defined(HAVE_LIBUSB_H) + #include + #elif defined(HAVE_LIBUSBHID_H) + #include + #endif int main () { - struct report_desc *repdesc; - struct usb_ctl_report *repbuf; - hid_kind_t hidkind; + struct report_desc *repdesc; + struct usb_ctl_report *repbuf; + hid_kind_t hidkind; ; return 0; @@ -21727,45 +21788,45 @@ main () _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - have_usbhid=yes + have_usbhid=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid" >&5 $as_echo "$have_usbhid" >&6; } - if test x$have_usbhid = xyes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ucr_data member of usb_ctl_report" >&5 + if test x$have_usbhid = xyes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ucr_data member of usb_ctl_report" >&5 $as_echo_n "checking for ucr_data member of usb_ctl_report... " >&6; } - have_usbhid_ucr_data=no - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + have_usbhid_ucr_data=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include - #if defined(HAVE_USB_H) - #include - #endif - #ifdef __DragonFly__ - # include - # include - #else - # include - # include - #endif - #if defined(HAVE_USBHID_H) - #include - #elif defined(HAVE_LIBUSB_H) - #include - #elif defined(HAVE_LIBUSBHID_H) - #include - #endif + #include + #if defined(HAVE_USB_H) + #include + #endif + #ifdef __DragonFly__ + # include + # include + #else + # include + # include + #endif + #if defined(HAVE_USBHID_H) + #include + #elif defined(HAVE_LIBUSB_H) + #include + #elif defined(HAVE_LIBUSBHID_H) + #include + #endif int main () { - struct usb_ctl_report buf; - if (buf.ucr_data) { } + struct usb_ctl_report buf; + if (buf.ucr_data) { } ; return 0; @@ -21773,47 +21834,47 @@ main () _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - have_usbhid_ucr_data=yes + have_usbhid_ucr_data=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - if test x$have_usbhid_ucr_data = xyes; then - USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA" - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid_ucr_data" >&5 + if test x$have_usbhid_ucr_data = xyes; then + USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid_ucr_data" >&5 $as_echo "$have_usbhid_ucr_data" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for new usbhid API" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for new usbhid API" >&5 $as_echo_n "checking for new usbhid API... " >&6; } - have_usbhid_new=no - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + have_usbhid_new=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include - #if defined(HAVE_USB_H) - #include - #endif - #ifdef __DragonFly__ - #include - #include - #else - #include - #include - #endif - #if defined(HAVE_USBHID_H) - #include - #elif defined(HAVE_LIBUSB_H) - #include - #elif defined(HAVE_LIBUSBHID_H) - #include - #endif + #include + #if defined(HAVE_USB_H) + #include + #endif + #ifdef __DragonFly__ + #include + #include + #else + #include + #include + #endif + #if defined(HAVE_USBHID_H) + #include + #elif defined(HAVE_LIBUSB_H) + #include + #elif defined(HAVE_LIBUSBHID_H) + #include + #endif int main () { - report_desc_t d; - hid_start_parse(d, 1, 1); + report_desc_t d; + hid_start_parse(d, 1, 1); ; return 0; @@ -21821,29 +21882,29 @@ main () _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - have_usbhid_new=yes + have_usbhid_new=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - if test x$have_usbhid_new = xyes; then - USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW" - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid_new" >&5 + if test x$have_usbhid_new = xyes; then + USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid_new" >&5 $as_echo "$have_usbhid_new" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct joystick in machine/joystick.h" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct joystick in machine/joystick.h" >&5 $as_echo_n "checking for struct joystick in machine/joystick.h... " >&6; } - have_machine_joystick=no - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + have_machine_joystick=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include + #include int main () { - struct joystick t; + struct joystick t; ; return 0; @@ -21851,28 +21912,30 @@ main () _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - have_machine_joystick=yes + have_machine_joystick=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - if test x$have_machine_joystick = xyes; then + if test x$have_machine_joystick = xyes; then $as_echo "#define SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H 1" >>confdefs.h - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_machine_joystick" >&5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_machine_joystick" >&5 $as_echo "$have_machine_joystick" >&6; } $as_echo "#define SDL_JOYSTICK_USBHID 1" >>confdefs.h - SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c" - EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS" - EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS" - have_joystick=yes - fi - CFLAGS="$save_CFLAGS" - fi + SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c" + EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS" + EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS" + have_joystick=yes + fi + CFLAGS="$save_CFLAGS" + fi + ;; + esac } CheckClockGettime() @@ -22008,6 +22071,21 @@ fi case "$host" in *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-aix*|*-*-minix*) case "$host" in + *-raspberry-linux*) + # Raspberry Pi + ARCH=linux + RPI_CFLAGS="-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux" + RPI_LDFLAGS="-L/opt/vc/lib -lbcm_host" + CFLAGS="$CFLAGS $RPI_CFLAGS" + SDL_CFLAGS="$SDL_CFLAGS $RPI_CFLAGS" + EXTRA_CFLAGS="$EXTRA_CFLAGS $RPI_CFLAGS" + SDL_LIBS="$SDL_LIBS $RPI_LDFLAGS" + + if test x$enable_video = xyes; then + SOURCES="$SOURCES $srcdir/src/video/raspberry/*.c" + $as_echo "#define SDL_VIDEO_DRIVER_RPI 1" >>confdefs.h + fi + ;; *-*-linux*) ARCH=linux ;; *-*-uclinux*) ARCH=linux ;; *-*-kfreebsd*-gnu) ARCH=kfreebsd-gnu ;; @@ -22045,6 +22123,7 @@ case "$host" in CheckLibUDev CheckDBus CheckInputEvents + CheckInputKD CheckTslib CheckUSBHID CheckPTHREAD @@ -22115,6 +22194,14 @@ $as_echo "#define SDL_POWER_LINUX 1" >>confdefs.h ;; esac fi + # Set up files for the filesystem library + if test x$enable_filesystem = xyes; then + +$as_echo "#define SDL_FILESYSTEM_UNIX 1" >>confdefs.h + + SOURCES="$SOURCES $srcdir/src/filesystem/unix/*.c" + have_filesystem=yes + fi # Set up files for the timer library if test x$enable_timers = xyes; then @@ -22123,6 +22210,14 @@ $as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/timer/unix/*.c" have_timers=yes fi + # Set up files for udev hotplugging support + if test x$enable_libudev = xyes && test x$have_libudev_h_hdr = xyes; then + SOURCES="$SOURCES $srcdir/src/core/linux/SDL_udev.c" + fi + # Set up files for evdev input + if test x$use_input_events = xyes; then + SOURCES="$SOURCES $srcdir/src/input/evdev/*.c" + fi ;; *-*-cygwin* | *-*-mingw32*) ARCH=win32 @@ -22217,6 +22312,13 @@ $as_echo "#define SDL_POWER_WINDOWS 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/power/windows/SDL_syspower.c" have_power=yes fi + if test x$enable_filesystem = xyes; then + +$as_echo "#define SDL_FILESYSTEM_WINDOWS 1" >>confdefs.h + + SOURCES="$SOURCES $srcdir/src/filesystem/windows/SDL_sysfilesystem.c" + have_filesystem=yes + fi # Set up files for the thread library if test x$enable_threads = xyes; then @@ -22350,6 +22452,14 @@ $as_echo "#define SDL_POWER_BEOS 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/power/beos/*.c" have_power=yes fi + # Set up files for the system filesystem library + if test x$enable_filesystem = xyes; then + +$as_echo "#define SDL_FILESYSTEM_BEOS 1" >>confdefs.h + + SOURCES="$SOURCES $srcdir/src/filesystem/beos/*.cc" + have_filesystem=yes + fi # The BeOS platform requires special setup. SOURCES="$srcdir/src/main/beos/*.cc $SOURCES" EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding" @@ -22389,6 +22499,11 @@ $as_echo "#define SDL_POWER_BEOS 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/power/uikit/*.m" have_power=yes fi + # Set up files for the filesystem library + if test x$enable_filesystem = xyes; then + SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m" + have_filesystem=yes + fi # Set up files for the timer library if test x$enable_timers = xyes; then SOURCES="$SOURCES $srcdir/src/timer/unix/*.c" @@ -22470,6 +22585,14 @@ $as_echo "#define SDL_POWER_MACOSX 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/power/macosx/*.c" have_power=yes fi + # Set up files for the filesystem library + if test x$enable_filesystem = xyes; then + +$as_echo "#define SDL_FILESYSTEM_COCOA 1" >>confdefs.h + + SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m" + have_filesystem=yes + fi # Set up files for the timer library if test x$enable_timers = xyes; then @@ -22536,6 +22659,14 @@ $as_echo "#define SDL_TIMERS_DISABLED 1" >>confdefs.h fi SOURCES="$SOURCES $srcdir/src/timer/dummy/*.c" fi +if test x$have_filesystem != xyes; then + if test x$enable_filesystem = xyes; then + +$as_echo "#define SDL_FILESYSTEM_DISABLED 1" >>confdefs.h + + fi + SOURCES="$SOURCES $srcdir/src/filesystem/dummy/*.c" +fi if test x$have_loadso != xyes; then if test x$enable_loadso = xyes; then diff --git a/configure.in b/configure.in index 252efe4be..5c56f0080 100644 --- a/configure.in +++ b/configure.in @@ -20,9 +20,9 @@ dnl Set various version strings - taken gratefully from the GTk sources # SDL_MAJOR_VERSION=2 SDL_MINOR_VERSION=0 -SDL_MICRO_VERSION=0 +SDL_MICRO_VERSION=1 SDL_INTERFACE_AGE=0 -SDL_BINARY_AGE=0 +SDL_BINARY_AGE=1 SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION AC_SUBST(SDL_MAJOR_VERSION) @@ -325,6 +325,7 @@ SOURCES="$SOURCES $srcdir/src/haptic/*.c" SOURCES="$SOURCES $srcdir/src/joystick/*.c" SOURCES="$SOURCES $srcdir/src/libm/*.c" SOURCES="$SOURCES $srcdir/src/power/*.c" +#SOURCES="$SOURCES $srcdir/src/filesystem/*.c" SOURCES="$SOURCES $srcdir/src/render/*.c" SOURCES="$SOURCES $srcdir/src/render/*/*.c" SOURCES="$SOURCES $srcdir/src/stdlib/*.c" @@ -382,6 +383,12 @@ AC_HELP_STRING([--enable-power], [Enable the power subsystem [[default=yes]]]), if test x$enable_power != xyes; then AC_DEFINE(SDL_POWER_DISABLED, 1, [ ]) fi +AC_ARG_ENABLE(filesystem, +AC_HELP_STRING([--enable-filesystem], [Enable the filesystem subsystem [[default=yes]]]), + , enable_filesystem=yes) +if test x$enable_filesystem != xyes; then + AC_DEFINE(SDL_FILESYSTEM_DISABLED, 1, [ ]) +fi AC_ARG_ENABLE(threads, AC_HELP_STRING([--enable-threads], [Enable the threading subsystem [[default=yes]]]), , enable_threads=yes) @@ -1681,44 +1688,47 @@ dnl Find OpenGL ES CheckOpenGLESX11() { if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then - AC_MSG_CHECKING(for OpenGL ES (EGL) support) - video_opengles=no + AC_MSG_CHECKING(for EGL support) + video_opengl_egl=no AC_TRY_COMPILE([ #include ],[ ],[ - video_opengles=yes + video_opengl_egl=yes ]) - AC_MSG_RESULT($video_opengles) - if test x$video_opengles = xyes; then - AC_MSG_CHECKING(for OpenGL ES v1 headers) - video_opengles_v1=no - AC_TRY_COMPILE([ - #include - #include - ],[ - ],[ - video_opengles_v1=yes - ]) - AC_MSG_RESULT($video_opengles_v1) - if test x$video_opengles_v1 = xyes; then - AC_DEFINE(SDL_VIDEO_OPENGL_ES, 1, [ ]) - AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES, 1, [ ]) - fi - AC_MSG_CHECKING(for OpenGL ES v2 headers) - video_opengles_v2=no - AC_TRY_COMPILE([ - #include - #include - ],[ - ],[ - 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, [ ]) - fi + 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 v1 headers) + video_opengles_v1=no + AC_TRY_COMPILE([ + #include + #include + ],[ + ],[ + video_opengles_v1=yes + ]) + AC_MSG_RESULT($video_opengles_v1) + if test x$video_opengles_v1 = xyes; then + AC_DEFINE(SDL_VIDEO_OPENGL_ES, 1, [ ]) + AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES, 1, [ ]) + fi + + AC_MSG_CHECKING(for OpenGL ES v2 headers) + video_opengles_v2=no + AC_TRY_COMPILE([ + #include + #include + ],[ + ],[ + 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, [ ]) fi fi } @@ -1781,6 +1791,28 @@ CheckInputEvents() fi } +dnl See if we can use the kernel kd.h header +CheckInputKD() +{ + + AC_MSG_CHECKING(for Linux kd.h) + use_input_kd=no + AC_TRY_COMPILE([ + #include + #include + ],[ + struct kbentry kbe; + kbe.kb_table = KG_CTRL; + ioctl(0, KDGKBENT, &kbe); + ],[ + use_input_kd=yes + ]) + AC_MSG_RESULT($use_input_kd) + if test x$use_input_kd = xyes; then + AC_DEFINE(SDL_INPUT_LINUXKD, 1, [ ]) + fi +} + dnl See if the platform offers libudev for device enumeration and hotplugging. CheckLibUDev() { @@ -2157,138 +2189,142 @@ AC_HELP_STRING([--enable-sdl-dlopen], [use dlopen for shared object loading [[de dnl Check for the usbhid(3) library on *BSD CheckUSBHID() { - if test x$enable_joystick = xyes; then - AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes) - if test x$have_libusbhid = xyes; then - AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"]) - AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"]) - USB_LIBS="$USB_LIBS -lusbhid" - else - AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"]) - AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"]) - AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"]) - fi - - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $USB_CFLAGS" + case "$host" in + *-*-*bsd*) + if test x$enable_joystick = xyes; then + AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes) + if test x$have_libusbhid = xyes; then + AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"]) + AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"]) + USB_LIBS="$USB_LIBS -lusbhid" + else + AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"]) + AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"]) + AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"]) + fi + + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $USB_CFLAGS" - AC_MSG_CHECKING(for usbhid) - have_usbhid=no - AC_TRY_COMPILE([ - #include - #if defined(HAVE_USB_H) - #include - #endif - #ifdef __DragonFly__ - # include - # include - #else - # include - # include - #endif - #if defined(HAVE_USBHID_H) - #include - #elif defined(HAVE_LIBUSB_H) - #include - #elif defined(HAVE_LIBUSBHID_H) - #include - #endif - ],[ - struct report_desc *repdesc; - struct usb_ctl_report *repbuf; - hid_kind_t hidkind; - ],[ - have_usbhid=yes - ]) - AC_MSG_RESULT($have_usbhid) + AC_MSG_CHECKING(for usbhid) + have_usbhid=no + AC_TRY_COMPILE([ + #include + #if defined(HAVE_USB_H) + #include + #endif + #ifdef __DragonFly__ + # include + # include + #else + # include + # include + #endif + #if defined(HAVE_USBHID_H) + #include + #elif defined(HAVE_LIBUSB_H) + #include + #elif defined(HAVE_LIBUSBHID_H) + #include + #endif + ],[ + struct report_desc *repdesc; + struct usb_ctl_report *repbuf; + hid_kind_t hidkind; + ],[ + have_usbhid=yes + ]) + AC_MSG_RESULT($have_usbhid) - if test x$have_usbhid = xyes; then - AC_MSG_CHECKING(for ucr_data member of usb_ctl_report) - have_usbhid_ucr_data=no - AC_TRY_COMPILE([ - #include - #if defined(HAVE_USB_H) - #include - #endif - #ifdef __DragonFly__ - # include - # include - #else - # include - # include - #endif - #if defined(HAVE_USBHID_H) - #include - #elif defined(HAVE_LIBUSB_H) - #include - #elif defined(HAVE_LIBUSBHID_H) - #include - #endif - ],[ - struct usb_ctl_report buf; - if (buf.ucr_data) { } - ],[ - have_usbhid_ucr_data=yes - ]) - if test x$have_usbhid_ucr_data = xyes; then - USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA" + if test x$have_usbhid = xyes; then + AC_MSG_CHECKING(for ucr_data member of usb_ctl_report) + have_usbhid_ucr_data=no + AC_TRY_COMPILE([ + #include + #if defined(HAVE_USB_H) + #include + #endif + #ifdef __DragonFly__ + # include + # include + #else + # include + # include + #endif + #if defined(HAVE_USBHID_H) + #include + #elif defined(HAVE_LIBUSB_H) + #include + #elif defined(HAVE_LIBUSBHID_H) + #include + #endif + ],[ + struct usb_ctl_report buf; + if (buf.ucr_data) { } + ],[ + have_usbhid_ucr_data=yes + ]) + if test x$have_usbhid_ucr_data = xyes; then + USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA" + fi + AC_MSG_RESULT($have_usbhid_ucr_data) + + AC_MSG_CHECKING(for new usbhid API) + have_usbhid_new=no + AC_TRY_COMPILE([ + #include + #if defined(HAVE_USB_H) + #include + #endif + #ifdef __DragonFly__ + #include + #include + #else + #include + #include + #endif + #if defined(HAVE_USBHID_H) + #include + #elif defined(HAVE_LIBUSB_H) + #include + #elif defined(HAVE_LIBUSBHID_H) + #include + #endif + ],[ + report_desc_t d; + hid_start_parse(d, 1, 1); + ],[ + have_usbhid_new=yes + ]) + if test x$have_usbhid_new = xyes; then + USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW" + fi + AC_MSG_RESULT($have_usbhid_new) + + AC_MSG_CHECKING(for struct joystick in machine/joystick.h) + have_machine_joystick=no + AC_TRY_COMPILE([ + #include + ],[ + struct joystick t; + ],[ + have_machine_joystick=yes + ]) + if test x$have_machine_joystick = xyes; then + AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H, 1, [ ]) + fi + AC_MSG_RESULT($have_machine_joystick) + + AC_DEFINE(SDL_JOYSTICK_USBHID, 1, [ ]) + SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c" + EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS" + EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS" + have_joystick=yes + fi + CFLAGS="$save_CFLAGS" fi - AC_MSG_RESULT($have_usbhid_ucr_data) - - AC_MSG_CHECKING(for new usbhid API) - have_usbhid_new=no - AC_TRY_COMPILE([ - #include - #if defined(HAVE_USB_H) - #include - #endif - #ifdef __DragonFly__ - #include - #include - #else - #include - #include - #endif - #if defined(HAVE_USBHID_H) - #include - #elif defined(HAVE_LIBUSB_H) - #include - #elif defined(HAVE_LIBUSBHID_H) - #include - #endif - ],[ - report_desc_t d; - hid_start_parse(d, 1, 1); - ],[ - have_usbhid_new=yes - ]) - if test x$have_usbhid_new = xyes; then - USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW" - fi - AC_MSG_RESULT($have_usbhid_new) - - AC_MSG_CHECKING(for struct joystick in machine/joystick.h) - have_machine_joystick=no - AC_TRY_COMPILE([ - #include - ],[ - struct joystick t; - ],[ - have_machine_joystick=yes - ]) - if test x$have_machine_joystick = xyes; then - AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H, 1, [ ]) - fi - AC_MSG_RESULT($have_machine_joystick) - - AC_DEFINE(SDL_JOYSTICK_USBHID, 1, [ ]) - SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c" - EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS" - EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS" - have_joystick=yes - fi - CFLAGS="$save_CFLAGS" - fi + ;; + esac } dnl Check for clock_gettime() @@ -2333,6 +2369,21 @@ dnl Set up the configuration based on the host platform! case "$host" in *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-aix*|*-*-minix*) case "$host" in + *-raspberry-linux*) + # Raspberry Pi + ARCH=linux + RPI_CFLAGS="-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux" + RPI_LDFLAGS="-L/opt/vc/lib -lbcm_host" + CFLAGS="$CFLAGS $RPI_CFLAGS" + SDL_CFLAGS="$SDL_CFLAGS $RPI_CFLAGS" + EXTRA_CFLAGS="$EXTRA_CFLAGS $RPI_CFLAGS" + SDL_LIBS="$SDL_LIBS $RPI_LDFLAGS" + + if test x$enable_video = xyes; then + SOURCES="$SOURCES $srcdir/src/video/raspberry/*.c" + $as_echo "#define SDL_VIDEO_DRIVER_RPI 1" >>confdefs.h + fi + ;; *-*-linux*) ARCH=linux ;; *-*-uclinux*) ARCH=linux ;; *-*-kfreebsd*-gnu) ARCH=kfreebsd-gnu ;; @@ -2370,6 +2421,7 @@ case "$host" in CheckLibUDev CheckDBus CheckInputEvents + CheckInputKD CheckTslib CheckUSBHID CheckPTHREAD @@ -2428,12 +2480,26 @@ case "$host" in ;; esac 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 + 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 + # Set up files for udev hotplugging support + if test x$enable_libudev = xyes && test x$have_libudev_h_hdr = xyes; then + SOURCES="$SOURCES $srcdir/src/core/linux/SDL_udev.c" + fi + # Set up files for evdev input + if test x$use_input_events = xyes; then + SOURCES="$SOURCES $srcdir/src/input/evdev/*.c" + fi ;; *-*-cygwin* | *-*-mingw32*) ARCH=win32 @@ -2506,6 +2572,11 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau SOURCES="$SOURCES $srcdir/src/power/windows/SDL_syspower.c" have_power=yes fi + if test x$enable_filesystem = xyes; then + AC_DEFINE(SDL_FILESYSTEM_WINDOWS, 1, [ ]) + SOURCES="$SOURCES $srcdir/src/filesystem/windows/SDL_sysfilesystem.c" + have_filesystem=yes + fi # Set up files for the thread library if test x$enable_threads = xyes; then AC_DEFINE(SDL_THREAD_WINDOWS, 1, [ ]) @@ -2588,6 +2659,12 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau SOURCES="$SOURCES $srcdir/src/power/beos/*.c" have_power=yes fi + # Set up files for the system filesystem library + if test x$enable_filesystem = xyes; then + AC_DEFINE(SDL_FILESYSTEM_BEOS, 1, [ ]) + SOURCES="$SOURCES $srcdir/src/filesystem/beos/*.cc" + have_filesystem=yes + fi # The BeOS platform requires special setup. SOURCES="$srcdir/src/main/beos/*.cc $SOURCES" EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding" @@ -2627,6 +2704,11 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau SOURCES="$SOURCES $srcdir/src/power/uikit/*.m" have_power=yes fi + # Set up files for the filesystem library + if test x$enable_filesystem = xyes; then + SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m" + have_filesystem=yes + fi # Set up files for the timer library if test x$enable_timers = xyes; then SOURCES="$SOURCES $srcdir/src/timer/unix/*.c" @@ -2700,6 +2782,12 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau SOURCES="$SOURCES $srcdir/src/power/macosx/*.c" have_power=yes fi + # Set up files for the filesystem library + if test x$enable_filesystem = xyes; then + AC_DEFINE(SDL_FILESYSTEM_COCOA, 1, [ ]) + SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m" + have_filesystem=yes + fi # Set up files for the timer library if test x$enable_timers = xyes; then AC_DEFINE(SDL_TIMER_UNIX, 1, [ ]) @@ -2757,6 +2845,12 @@ if test x$have_timers != xyes; then fi SOURCES="$SOURCES $srcdir/src/timer/dummy/*.c" fi +if test x$have_filesystem != xyes; then + if test x$enable_filesystem = xyes; then + AC_DEFINE(SDL_FILESYSTEM_DISABLED, 1, [ ]) + fi + SOURCES="$SOURCES $srcdir/src/filesystem/dummy/*.c" +fi if test x$have_loadso != xyes; then if test x$enable_loadso = xyes; then AC_DEFINE(SDL_LOADSO_DISABLED, 1, [ ]) diff --git a/debian/changelog b/debian/changelog index 1065a8a95..8e9dd49bc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +libsdl2 (2.0.1) UNRELEASED; urgency=low + + * Updated SDL to version 2.0.1 + + -- Sam Lantinga Wed, 23 Oct 2013 16:31:38 -0800 + libsdl2 (2.0.0) UNRELEASED; urgency=low * SDL is now a native debian package. diff --git a/include/SDL.h b/include/SDL.h index f2d760c2e..c0c067ca5 100644 --- a/include/SDL.h +++ b/include/SDL.h @@ -32,18 +32,20 @@ * * \section intro_sec Introduction * - * This is the Simple DirectMedia Layer, a general API that provides low - * level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, - * and 2D framebuffer across multiple platforms. + * Simple DirectMedia Layer is a cross-platform development library designed + * to provide low level access to audio, keyboard, mouse, joystick, and + * graphics hardware via OpenGL and Direct3D. It is used by video playback + * software, emulators, and popular games including Valve's award winning + * catalog and many Humble Bundle games. * - * SDL is written in C, but works with C++ natively, and has bindings to - * several other languages, including Ada, C#, Eiffel, Erlang, Euphoria, - * Guile, Haskell, Java, Lisp, Lua, ML, Objective C, Pascal, Perl, PHP, - * Pike, Pliant, Python, Ruby, and Smalltalk. + * SDL officially supports Windows, Mac OS X, Linux, iOS, and Android. + * Support for other platforms may be found in the source code. * - * This library is distributed under the zlib license, which can be - * found in the file "COPYING". This license allows you to use SDL - * freely for any purpose as long as you retain the copyright notice. + * SDL is written in C, works natively with C++, and there are bindings + * available for several other languages, including C# and Python. + * + * This library is distributed under the zlib license, which can be found + * in the file "COPYING.txt". * * The best way to learn how to use SDL is to check out the header files in * the "include" subdirectory and the programs in the "test" subdirectory. @@ -72,6 +74,7 @@ #include "SDL_endian.h" #include "SDL_error.h" #include "SDL_events.h" +#include "SDL_filesystem.h" #include "SDL_joystick.h" #include "SDL_gamecontroller.h" #include "SDL_haptic.h" @@ -103,7 +106,7 @@ extern "C" { * These are the flags which may be passed to SDL_Init(). You should * specify the subsystems which you will be using in your application. */ -/*@{*/ +/* @{ */ #define SDL_INIT_TIMER 0x00000001 #define SDL_INIT_AUDIO 0x00000010 #define SDL_INIT_VIDEO 0x00000020 /**< SDL_INIT_VIDEO implies SDL_INIT_EVENTS */ @@ -116,7 +119,7 @@ extern "C" { SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \ SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER \ ) -/*@}*/ +/* @} */ /** * This function initializes the subsystems specified by \c flags diff --git a/include/SDL_assert.h b/include/SDL_assert.h index 5a6afc5e2..432943406 100644 --- a/include/SDL_assert.h +++ b/include/SDL_assert.h @@ -86,8 +86,14 @@ This also solves the problem of... disable assertions. */ +#ifdef _MSC_VER /* stupid /W4 warnings. */ +#define SDL_NULL_WHILE_LOOP_CONDITION (-1 == __LINE__) +#else +#define SDL_NULL_WHILE_LOOP_CONDITION (0) +#endif + #define SDL_disabled_assert(condition) \ - do { (void) sizeof ((condition)); } while (0) + do { (void) sizeof ((condition)); } while (SDL_NULL_WHILE_LOOP_CONDITION) typedef enum { @@ -140,7 +146,7 @@ extern DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *, } \ break; /* not retrying. */ \ } \ - } while (0) + } while (SDL_NULL_WHILE_LOOP_CONDITION) #endif /* enabled assertions support code */ @@ -165,6 +171,9 @@ extern DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *, # error Unknown assertion level. #endif +/* this assertion is never disabled at any level. */ +#define SDL_assert_always(condition) SDL_enabled_assert(condition) + typedef SDL_assert_state (SDLCALL *SDL_AssertionHandler)( const SDL_assert_data* data, void* userdata); diff --git a/include/SDL_atomic.h b/include/SDL_atomic.h index 7bd669d1a..48b0053a0 100644 --- a/include/SDL_atomic.h +++ b/include/SDL_atomic.h @@ -91,7 +91,7 @@ extern "C" { * The spin lock functions and type are required and can not be * emulated because they are used in the atomic emulation code. */ -/*@{*/ +/* @{ */ typedef int SDL_SpinLock; @@ -118,7 +118,7 @@ extern DECLSPEC void SDLCALL SDL_AtomicLock(SDL_SpinLock *lock); */ extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock); -/*@}*//*SDL AtomicLock*/ +/* @} *//* SDL AtomicLock */ /** diff --git a/include/SDL_audio.h b/include/SDL_audio.h index 0b6f28af6..b9da236fc 100644 --- a/include/SDL_audio.h +++ b/include/SDL_audio.h @@ -66,7 +66,7 @@ typedef Uint16 SDL_AudioFormat; /** * \name Audio flags */ -/*@{*/ +/* @{ */ #define SDL_AUDIO_MASK_BITSIZE (0xFF) #define SDL_AUDIO_MASK_DATATYPE (1<<8) @@ -85,7 +85,7 @@ typedef Uint16 SDL_AudioFormat; * * Defaults to LSB byte order. */ -/*@{*/ +/* @{ */ #define AUDIO_U8 0x0008 /**< Unsigned 8-bit samples */ #define AUDIO_S8 0x8008 /**< Signed 8-bit samples */ #define AUDIO_U16LSB 0x0010 /**< Unsigned 16-bit samples */ @@ -94,30 +94,30 @@ typedef Uint16 SDL_AudioFormat; #define AUDIO_S16MSB 0x9010 /**< As above, but big-endian byte order */ #define AUDIO_U16 AUDIO_U16LSB #define AUDIO_S16 AUDIO_S16LSB -/*@}*/ +/* @} */ /** * \name int32 support */ -/*@{*/ +/* @{ */ #define AUDIO_S32LSB 0x8020 /**< 32-bit integer samples */ #define AUDIO_S32MSB 0x9020 /**< As above, but big-endian byte order */ #define AUDIO_S32 AUDIO_S32LSB -/*@}*/ +/* @} */ /** * \name float32 support */ -/*@{*/ +/* @{ */ #define AUDIO_F32LSB 0x8120 /**< 32-bit floating point samples */ #define AUDIO_F32MSB 0x9120 /**< As above, but big-endian byte order */ #define AUDIO_F32 AUDIO_F32LSB -/*@}*/ +/* @} */ /** * \name Native audio byte ordering */ -/*@{*/ +/* @{ */ #if SDL_BYTEORDER == SDL_LIL_ENDIAN #define AUDIO_U16SYS AUDIO_U16LSB #define AUDIO_S16SYS AUDIO_S16LSB @@ -129,21 +129,21 @@ typedef Uint16 SDL_AudioFormat; #define AUDIO_S32SYS AUDIO_S32MSB #define AUDIO_F32SYS AUDIO_F32MSB #endif -/*@}*/ +/* @} */ /** * \name Allow change flags * * Which audio format changes are allowed when opening a device. */ -/*@{*/ +/* @{ */ #define SDL_AUDIO_ALLOW_FREQUENCY_CHANGE 0x00000001 #define SDL_AUDIO_ALLOW_FORMAT_CHANGE 0x00000002 #define SDL_AUDIO_ALLOW_CHANNELS_CHANGE 0x00000004 #define SDL_AUDIO_ALLOW_ANY_CHANGE (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE|SDL_AUDIO_ALLOW_FORMAT_CHANGE|SDL_AUDIO_ALLOW_CHANNELS_CHANGE) -/*@}*/ +/* @} */ -/*@}*//*Audio flags*/ +/* @} *//* Audio flags */ /** * This function is called when the audio device needs more data. @@ -218,10 +218,10 @@ typedef struct SDL_AudioCVT * These functions return the list of built in audio drivers, in the * order that they are normally initialized by default. */ -/*@{*/ +/* @{ */ extern DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void); extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index); -/*@}*/ +/* @} */ /** * \name Initialization and cleanup @@ -230,10 +230,10 @@ extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index); * you have a specific need to specify the audio driver you want to * use. You should normally use SDL_Init() or SDL_InitSubSystem(). */ -/*@{*/ +/* @{ */ extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name); extern DECLSPEC void SDLCALL SDL_AudioQuit(void); -/*@}*/ +/* @} */ /** * This function returns the name of the current audio driver, or NULL @@ -359,7 +359,7 @@ extern DECLSPEC SDL_AudioDeviceID SDLCALL SDL_OpenAudioDevice(const char * * Get the current audio state. */ -/*@{*/ +/* @{ */ typedef enum { SDL_AUDIO_STOPPED = 0, @@ -370,7 +370,7 @@ extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioStatus(void); extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev); -/*@}*//*Audio State*/ +/* @} *//* Audio State */ /** * \name Pause audio functions @@ -381,11 +381,11 @@ SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev); * data for your callback function after opening the audio device. * Silence will be written to the audio device during the pause. */ -/*@{*/ +/* @{ */ extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on); extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev, int pause_on); -/*@}*//*Pause audio functions*/ +/* @} *//* Pause audio functions */ /** * This function loads a WAVE from the data source, automatically freeing @@ -482,12 +482,12 @@ extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst, * the callback function is not running. Do not call these from the callback * function or you will cause deadlock. */ -/*@{*/ +/* @{ */ extern DECLSPEC void SDLCALL SDL_LockAudio(void); extern DECLSPEC void SDLCALL SDL_LockAudioDevice(SDL_AudioDeviceID dev); extern DECLSPEC void SDLCALL SDL_UnlockAudio(void); extern DECLSPEC void SDLCALL SDL_UnlockAudioDevice(SDL_AudioDeviceID dev); -/*@}*//*Audio lock functions*/ +/* @} *//* Audio lock functions */ /** * This function shuts down audio processing and closes the audio device. diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake index 12c14fa24..66107e49e 100644 --- a/include/SDL_config.h.cmake +++ b/include/SDL_config.h.cmake @@ -182,6 +182,7 @@ #cmakedefine SDL_TIMERS_DISABLED @SDL_TIMERS_DISABLED@ #cmakedefine SDL_VIDEO_DISABLED @SDL_VIDEO_DISABLED@ #cmakedefine SDL_POWER_DISABLED @SDL_POWER_DISABLED@ +#cmakedefine SDL_FILESYSTEM_DISABLED @SDL_FILESYSTEM_DISABLED@ /* Enable various audio drivers */ #cmakedefine SDL_AUDIO_DRIVER_ALSA @SDL_AUDIO_DRIVER_ALSA@ @@ -287,10 +288,12 @@ /* Enable OpenGL support */ #cmakedefine SDL_VIDEO_OPENGL @SDL_VIDEO_OPENGL@ #cmakedefine SDL_VIDEO_OPENGL_ES @SDL_VIDEO_OPENGL_ES@ +#cmakedefine SDL_VIDEO_OPENGL_ES2 @SDL_VIDEO_OPENGL_ES2@ #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_EGL @SDL_VIDEO_OPENGL_EGL@ #cmakedefine SDL_VIDEO_OPENGL_OSMESA @SDL_VIDEO_OPENGL_OSMESA@ #cmakedefine SDL_VIDEO_OPENGL_OSMESA_DYNAMIC @SDL_VIDEO_OPENGL_OSMESA_DYNAMIC@ @@ -301,6 +304,13 @@ #cmakedefine SDL_POWER_BEOS @SDL_POWER_BEOS@ #cmakedefine SDL_POWER_HARDWIRED @SDL_POWER_HARDWIRED@ +/* Enable system filesystem support */ +#cmakedefine SDL_FILESYSTEM_BEOS @SDL_FILESYSTEM_BEOS@ +#cmakedefine SDL_FILESYSTEM_COCOA @SDL_FILESYSTEM_COCOA@ +#cmakedefine SDL_FILESYSTEM_DUMMY @SDL_FILESYSTEM_DUMMY@ +#cmakedefine SDL_FILESYSTEM_UNIX @SDL_FILESYSTEM_UNIX@ +#cmakedefine SDL_FILESYSTEM_WINDOWS @SDL_FILESYSTEM_WINDOWS@ + /* Enable assembly routines */ #cmakedefine SDL_ASSEMBLY_ROUTINES @SDL_ASSEMBLY_ROUTINES@ #cmakedefine SDL_ALTIVEC_BLITTERS @SDL_ALTIVEC_BLITTERS@ diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index 04ee11052..b2daf6fa3 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -184,6 +184,7 @@ #undef SDL_TIMERS_DISABLED #undef SDL_VIDEO_DISABLED #undef SDL_POWER_DISABLED +#undef SDL_FILESYSTEM_DISABLED /* Enable various audio drivers */ #undef SDL_AUDIO_DRIVER_ALSA @@ -216,6 +217,7 @@ /* Enable various input drivers */ #undef SDL_INPUT_LINUXEV +#undef SDL_INPUT_LINUXKD #undef SDL_INPUT_TSLIB #undef SDL_JOYSTICK_BEOS #undef SDL_JOYSTICK_DINPUT @@ -258,6 +260,7 @@ #undef SDL_VIDEO_DRIVER_DUMMY #undef SDL_VIDEO_DRIVER_WINDOWS #undef SDL_VIDEO_DRIVER_X11 +#undef SDL_VIDEO_DRIVER_RPI #undef SDL_VIDEO_DRIVER_X11_DYNAMIC #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR @@ -288,8 +291,10 @@ /* Enable OpenGL support */ #undef SDL_VIDEO_OPENGL #undef SDL_VIDEO_OPENGL_ES +#undef SDL_VIDEO_OPENGL_ES2 #undef SDL_VIDEO_OPENGL_BGL #undef SDL_VIDEO_OPENGL_CGL +#undef SDL_VIDEO_OPENGL_EGL #undef SDL_VIDEO_OPENGL_GLX #undef SDL_VIDEO_OPENGL_WGL #undef SDL_VIDEO_OPENGL_OSMESA @@ -302,6 +307,13 @@ #undef SDL_POWER_BEOS #undef SDL_POWER_HARDWIRED +/* Enable system filesystem support */ +#undef SDL_FILESYSTEM_BEOS +#undef SDL_FILESYSTEM_COCOA +#undef SDL_FILESYSTEM_DUMMY +#undef SDL_FILESYSTEM_UNIX +#undef SDL_FILESYSTEM_WINDOWS + /* Enable assembly routines */ #undef SDL_ASSEMBLY_ROUTINES #undef SDL_ALTIVEC_BLITTERS diff --git a/include/SDL_config_android.h b/include/SDL_config_android.h index e0c019f24..0826415c6 100644 --- a/include/SDL_config_android.h +++ b/include/SDL_config_android.h @@ -129,10 +129,14 @@ /* Enable OpenGL ES */ #define SDL_VIDEO_OPENGL_ES 1 +#define SDL_VIDEO_OPENGL_EGL 1 #define SDL_VIDEO_RENDER_OGL_ES 1 #define SDL_VIDEO_RENDER_OGL_ES2 1 /* Enable system power support */ #define SDL_POWER_ANDROID 1 +/* !!! FIXME: what does Android do for filesystem stuff? */ +#define SDL_FILESYSTEM_DUMMY 1 + #endif /* _SDL_config_android_h */ diff --git a/include/SDL_config_iphoneos.h b/include/SDL_config_iphoneos.h index b27b18973..ade296614 100644 --- a/include/SDL_config_iphoneos.h +++ b/include/SDL_config_iphoneos.h @@ -148,4 +148,7 @@ */ #define SDL_IPHONE_MAX_GFORCE 5.0 +/* enable filesystem support */ +#define SDL_FILESYSTEM_COCOA 1 + #endif /* _SDL_config_iphoneos_h */ diff --git a/include/SDL_config_macosx.h b/include/SDL_config_macosx.h index 68a0ebb9b..9f2f76e3f 100644 --- a/include/SDL_config_macosx.h +++ b/include/SDL_config_macosx.h @@ -171,6 +171,9 @@ /* Enable system power support */ #define SDL_POWER_MACOSX 1 +/* enable filesystem support */ +#define SDL_FILESYSTEM_COCOA 1 + /* Enable assembly routines */ #define SDL_ASSEMBLY_ROUTINES 1 #ifdef __ppc__ diff --git a/include/SDL_config_minimal.h b/include/SDL_config_minimal.h index fe3cebc7e..3248bdda1 100644 --- a/include/SDL_config_minimal.h +++ b/include/SDL_config_minimal.h @@ -75,4 +75,7 @@ typedef unsigned long uintptr_t; /* Enable the dummy video driver (src/video/dummy/\*.c) */ #define SDL_VIDEO_DRIVER_DUMMY 1 +/* Enable the dummy filesystem driver (src/filesystem/dummy/\*.c) */ +#define SDL_FILESYSTEM_DUMMY 1 + #endif /* _SDL_config_minimal_h */ diff --git a/include/SDL_config_pandora.h b/include/SDL_config_pandora.h index b93a1bc1a..4bfad4861 100644 --- a/include/SDL_config_pandora.h +++ b/include/SDL_config_pandora.h @@ -114,6 +114,7 @@ #define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1 #define SDL_TIMER_UNIX 1 +#define SDL_FILESYSTEM_UNIX 1 #define SDL_VIDEO_DRIVER_DUMMY 1 #define SDL_VIDEO_DRIVER_X11 1 diff --git a/include/SDL_config_psp.h b/include/SDL_config_psp.h index bf456f688..31ac2b2b7 100644 --- a/include/SDL_config_psp.h +++ b/include/SDL_config_psp.h @@ -99,8 +99,8 @@ #define HAVE_SQRT 1 #define HAVE_SETJMP 1 #define HAVE_NANOSLEEP 1 -//#define HAVE_SYSCONF 1 -//#define HAVE_SIGACTION 1 +/* #define HAVE_SYSCONF 1 */ +/* #define HAVE_SIGACTION 1 */ /* PSP isn't that sophisticated */ @@ -126,6 +126,9 @@ #define SDL_POWER_PSP 1 +/* !!! FIXME: what does PSP do for filesystem stuff? */ +#define SDL_FILESYSTEM_DUMMY 1 + /* PSP doesn't have haptic device (src/haptic/dummy/\*.c) */ #define SDL_HAPTIC_DISABLED 1 diff --git a/include/SDL_config_windows.h b/include/SDL_config_windows.h index 0b7621564..4d5c7c293 100644 --- a/include/SDL_config_windows.h +++ b/include/SDL_config_windows.h @@ -105,12 +105,10 @@ typedef unsigned int uintptr_t; #define HAVE_STRCHR 1 #define HAVE_STRRCHR 1 #define HAVE_STRSTR 1 -#define HAVE_ITOA 1 #define HAVE__LTOA 1 #define HAVE__ULTOA 1 #define HAVE_STRTOL 1 #define HAVE_STRTOUL 1 -#define HAVE_STRTOLL 1 #define HAVE_STRTOD 1 #define HAVE_ATOI 1 #define HAVE_ATOF 1 @@ -118,22 +116,27 @@ typedef unsigned int uintptr_t; #define HAVE_STRNCMP 1 #define HAVE__STRICMP 1 #define HAVE__STRNICMP 1 -#define HAVE_SSCANF 1 -#define HAVE_M_PI 1 #define HAVE_ATAN 1 #define HAVE_ATAN2 1 #define HAVE_CEIL 1 -#define HAVE_COPYSIGN 1 #define HAVE_COS 1 #define HAVE_COSF 1 #define HAVE_FABS 1 #define HAVE_FLOOR 1 #define HAVE_LOG 1 #define HAVE_POW 1 -#define HAVE_SCALBN 1 #define HAVE_SIN 1 #define HAVE_SINF 1 #define HAVE_SQRT 1 +#if _MSC_VER >= 1800 +#define HAVE_STRTOLL 1 +#define HAVE_SSCANF 1 +#define HAVE_COPYSIGN 1 +#define HAVE_SCALBN 1 +#endif +#if !defined(_MSC_VER) || defined(_USE_MATH_DEFINES) +#define HAVE_M_PI 1 +#endif #else #define HAVE_STDARG_H 1 #define HAVE_STDDEF_H 1 @@ -181,6 +184,9 @@ typedef unsigned int uintptr_t; /* Enable system power support */ #define SDL_POWER_WINDOWS 1 +/* Enable filesystem support */ +#define SDL_FILESYSTEM_WINDOWS 1 + /* Enable assembly routines (Win64 doesn't have inline asm) */ #ifndef _WIN64 #define SDL_ASSEMBLY_ROUTINES 1 diff --git a/include/SDL_cpuinfo.h b/include/SDL_cpuinfo.h index a722ee4d5..528a668ec 100644 --- a/include/SDL_cpuinfo.h +++ b/include/SDL_cpuinfo.h @@ -134,6 +134,11 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void); */ extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void); +/** + * This function returns the amount of RAM configured in the system, in MB. + */ +extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void); + /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/include/SDL_endian.h b/include/SDL_endian.h index c58edcca0..3450316c0 100644 --- a/include/SDL_endian.h +++ b/include/SDL_endian.h @@ -33,10 +33,10 @@ /** * \name The two types of endianness */ -/*@{*/ +/* @{ */ #define SDL_LIL_ENDIAN 1234 #define SDL_BIG_ENDIAN 4321 -/*@}*/ +/* @} */ #ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */ #ifdef __linux__ @@ -206,7 +206,7 @@ SDL_SwapFloat(float x) * \name Swap to native * Byteswap item from the specified endianness to the native endianness. */ -/*@{*/ +/* @{ */ #if SDL_BYTEORDER == SDL_LIL_ENDIAN #define SDL_SwapLE16(X) (X) #define SDL_SwapLE32(X) (X) @@ -226,7 +226,7 @@ SDL_SwapFloat(float x) #define SDL_SwapBE64(X) (X) #define SDL_SwapFloatBE(X) (X) #endif -/*@}*//*Swap to native*/ +/* @} *//* Swap to native */ /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/include/SDL_error.h b/include/SDL_error.h index 229b26802..2b8bb4165 100644 --- a/include/SDL_error.h +++ b/include/SDL_error.h @@ -48,7 +48,7 @@ extern DECLSPEC void SDLCALL SDL_ClearError(void); * \internal * Private error reporting function - used internally. */ -/*@{*/ +/* @{ */ #define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) #define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) #define SDL_InvalidParamError(param) SDL_SetError("Parameter '%s' is invalid", (param)) @@ -63,7 +63,7 @@ typedef enum } SDL_errorcode; /* SDL_Error() unconditionally returns -1. */ extern DECLSPEC int SDLCALL SDL_Error(SDL_errorcode code); -/*@}*//*Internal error functions*/ +/* @} *//* Internal error functions */ /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/include/SDL_events.h b/include/SDL_events.h index b997b5ec8..c08903073 100644 --- a/include/SDL_events.h +++ b/include/SDL_events.h @@ -541,7 +541,7 @@ typedef union SDL_Event */ extern DECLSPEC void SDLCALL SDL_PumpEvents(void); -/*@{*/ +/* @{ */ typedef enum { SDL_ADDEVENT, @@ -570,7 +570,7 @@ typedef enum extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action, Uint32 minType, Uint32 maxType); -/*@}*/ +/* @} */ /** * Checks to see if certain event types are in the event queue. @@ -681,7 +681,7 @@ extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter, extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter, void *userdata); -/*@{*/ +/* @{ */ #define SDL_QUERY -1 #define SDL_IGNORE 0 #define SDL_DISABLE 0 @@ -697,7 +697,7 @@ extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter, * current processing state of the specified event. */ extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state); -/*@}*/ +/* @} */ #define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY) /** diff --git a/include/SDL_filesystem.h b/include/SDL_filesystem.h new file mode 100644 index 000000000..ea8a1b56f --- /dev/null +++ b/include/SDL_filesystem.h @@ -0,0 +1,136 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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_filesystem.h + * + * \brief Include file for filesystem SDL API functions + */ + +#ifndef _SDL_filesystem_h +#define _SDL_filesystem_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" + +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Get the path where the application resides. + * + * Get the "base path". This is the directory where the application was run + * from, which is probably the installation directory, and may or may not + * be the process's current working directory. + * + * This returns an absolute path in UTF-8 encoding, and is guaranteed to + * end with a path separator ('\\' on Windows, '/' most other places). + * + * The pointer returned by this function is owned by you. Please call + * SDL_free() on the pointer when you are done with it, or it will be a + * memory leak. This is not necessarily a fast call, though, so you should + * call this once near startup and save the string if you need it. + * + * Some platforms can't determine the application's path, and on other + * platforms, this might be meaningless. In such cases, this function will + * return NULL. + * + * \return String of base dir in UTF-8 encoding, or NULL on error. + * + * \sa SDL_GetPrefPath + */ +extern DECLSPEC char *SDLCALL SDL_GetBasePath(void); + +/** + * \brief Get the user-and-app-specific path where files can be written. + * + * Get the "pref dir". This is meant to be where users can write personal + * files (preferences and save games, etc) that are specific to your + * application. This directory is unique per user, per application. + * + * This function will decide the appropriate location in the native filesystem, + * create the directory if necessary, and return a string of the absolute + * path to the directory in UTF-8 encoding. + * + * On Windows, the string might look like: + * "C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\" + * + * On Linux, the string might look like: + * "/home/bob/.local/share/My Program Name/" + * + * On Mac OS X, the string might look like: + * "/Users/bob/Library/Application Support/My Program Name/" + * + * (etc.) + * + * You specify the name of your organization (if it's not a real organization, + * your name or an Internet domain you own might do) and the name of your + * application. These should be untranslated proper names. + * + * Both the org and app strings may become part of a directory name, so + * please follow these rules: + * + * - Try to use the same org string (including case-sensitivity) for + * all your applications that use this function. + * - Always use a unique app string for each one, and make sure it never + * changes for an app once you've decided on it. + * - Unicode characters are legal, as long as it's UTF-8 encoded, but... + * - ...only use letters, numbers, and spaces. Avoid punctuation like + * "Game Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient. + * + * This returns an absolute path in UTF-8 encoding, and is guaranteed to + * end with a path separator ('\\' on Windows, '/' most other places). + * + * The pointer returned by this function is owned by you. Please call + * SDL_free() on the pointer when you are done with it, or it will be a + * memory leak. This is not necessarily a fast call, though, so you should + * call this once near startup and save the string if you need it. + * + * You should assume the path returned by this function is the only safe + * place to write files (and that SDL_GetBasePath(), while it might be + * writable, or even the parent of the returned path, aren't where you + * should be writing things). + * + * Some platforms can't determine the pref path, and on other + * platforms, this might be meaningless. In such cases, this function will + * return NULL. + * + * \param org The name of your organization. + * \param app The name of your application. + * \return UTF-8 string of user dir in platform-dependent notation. NULL + * if there's a problem (creating directory failed, etc). + * + * \sa SDL_GetBasePath + */ +extern DECLSPEC char *SDLCALL SDL_GetPrefPath(const char *org, const char *app); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_system_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/include/SDL_haptic.h b/include/SDL_haptic.h index da555c9c3..a029eb996 100644 --- a/include/SDL_haptic.h +++ b/include/SDL_haptic.h @@ -140,12 +140,12 @@ typedef struct _SDL_Haptic SDL_Haptic; * * Different haptic features a device can have. */ -/*@{*/ +/* @{ */ /** * \name Haptic effects */ -/*@{*/ +/* @{ */ /** * \brief Constant effect supported. @@ -177,7 +177,7 @@ typedef struct _SDL_Haptic SDL_Haptic; #define SDL_HAPTIC_LEFTRIGHT (1<<2) /* !!! FIXME: put this back when we have more bits in 2.1 */ -/*#define SDL_HAPTIC_SQUARE (1<<2)*/ +/* #define SDL_HAPTIC_SQUARE (1<<2) */ /** * \brief Triangle wave effect supported. @@ -262,7 +262,7 @@ typedef struct _SDL_Haptic SDL_Haptic; */ #define SDL_HAPTIC_CUSTOM (1<<11) -/*@}*//*Haptic effects*/ +/* @} *//* Haptic effects */ /* These last few are features the device has, not effects */ @@ -305,7 +305,7 @@ typedef struct _SDL_Haptic SDL_Haptic; /** * \name Direction encodings */ -/*@{*/ +/* @{ */ /** * \brief Uses polar coordinates for the direction. @@ -328,9 +328,9 @@ typedef struct _SDL_Haptic SDL_Haptic; */ #define SDL_HAPTIC_SPHERICAL 2 -/*@}*//*Direction encodings*/ +/* @} *//* Direction encodings */ -/*@}*//*Haptic features*/ +/* @} *//* Haptic features */ /* * Misc defines. diff --git a/include/SDL_hints.h b/include/SDL_hints.h index 6e2a78568..d195d9662 100644 --- a/include/SDL_hints.h +++ b/include/SDL_hints.h @@ -94,6 +94,17 @@ extern "C" { */ #define SDL_HINT_RENDER_OPENGL_SHADERS "SDL_RENDER_OPENGL_SHADERS" +/** + * \brief A variable controlling whether the Direct3D device is initialized for thread-safe operations. + * + * This variable can be set to the following values: + * "0" - Thread-safety is not enabled (faster) + * "1" - Thread-safety is enabled + * + * By default the Direct3D device is created with thread-safety disabled. + */ +#define SDL_HINT_RENDER_DIRECT3D_THREADSAFE "SDL_RENDER_DIRECT3D_THREADSAFE" + /** * \brief A variable controlling the scaling quality * @@ -271,6 +282,11 @@ extern "C" { #define SDL_HINT_TIMER_RESOLUTION "SDL_TIMER_RESOLUTION" +/** + * \brief If set to 1, then do not allow high-DPI windows. ("Retina" on Mac) + */ +#define SDL_HINT_VIDEO_HIGHDPI_DISABLED "SDL_VIDEO_HIGHDPI_DISABLED" + /** * \brief An enumeration of hint priorities diff --git a/include/SDL_joystick.h b/include/SDL_joystick.h index 266740348..b0e4b5dab 100644 --- a/include/SDL_joystick.h +++ b/include/SDL_joystick.h @@ -187,7 +187,7 @@ extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick, /** * \name Hat positions */ -/*@{*/ +/* @{ */ #define SDL_HAT_CENTERED 0x00 #define SDL_HAT_UP 0x01 #define SDL_HAT_RIGHT 0x02 @@ -197,7 +197,7 @@ extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick, #define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN) #define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP) #define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN) -/*@}*/ +/* @} */ /** * Get the current state of a POV hat on a joystick. diff --git a/include/SDL_main.h b/include/SDL_main.h index 8151b4a1a..c373f63e5 100644 --- a/include/SDL_main.h +++ b/include/SDL_main.h @@ -106,7 +106,7 @@ extern C_LINKAGE int SDL_main(int argc, char *argv[]); extern "C" { #endif -/* +/** * This is called by the real SDL main function to let the rest of the * library know that initialization was done properly. * diff --git a/include/SDL_mutex.h b/include/SDL_mutex.h index 3efc4a890..2b5df0ec3 100644 --- a/include/SDL_mutex.h +++ b/include/SDL_mutex.h @@ -52,9 +52,9 @@ extern "C" { /** * \name Mutex functions */ -/*@{*/ +/* @{ */ -/* The SDL mutex structure, defined in SDL_mutex.c */ +/* The SDL mutex structure, defined in SDL_sysmutex.c */ struct SDL_mutex; typedef struct SDL_mutex SDL_mutex; @@ -94,15 +94,15 @@ extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex); */ extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex * mutex); -/*@}*//*Mutex functions*/ +/* @} *//* Mutex functions */ /** * \name Semaphore functions */ -/*@{*/ +/* @{ */ -/* The SDL semaphore structure, defined in SDL_sem.c */ +/* The SDL semaphore structure, defined in SDL_syssem.c */ struct SDL_semaphore; typedef struct SDL_semaphore SDL_sem; @@ -154,15 +154,15 @@ extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem * sem); */ extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem * sem); -/*@}*//*Semaphore functions*/ +/* @} *//* Semaphore functions */ /** * \name Condition variable functions */ -/*@{*/ +/* @{ */ -/* The SDL condition variable structure, defined in SDL_cond.c */ +/* The SDL condition variable structure, defined in SDL_syscond.c */ struct SDL_cond; typedef struct SDL_cond SDL_cond; @@ -237,7 +237,7 @@ extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex); extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms); -/*@}*//*Condition variable functions*/ +/* @} *//* Condition variable functions */ /* Ends C function definitions when using C++ */ diff --git a/include/SDL_pixels.h b/include/SDL_pixels.h index 5e17cba53..99fcd9aac 100644 --- a/include/SDL_pixels.h +++ b/include/SDL_pixels.h @@ -39,10 +39,10 @@ extern "C" { * * These define alpha as the opacity of a surface. */ -/*@{*/ +/* @{ */ #define SDL_ALPHA_OPAQUE 255 #define SDL_ALPHA_TRANSPARENT 0 -/*@}*/ +/* @} */ /** Pixel type. */ enum diff --git a/include/SDL_platform.h b/include/SDL_platform.h index 419b6336c..8a7bc5615 100644 --- a/include/SDL_platform.h +++ b/include/SDL_platform.h @@ -1,168 +1,172 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - 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_platform.h - * - * Try to get a standard set of platform defines. - */ - -#ifndef _SDL_platform_h -#define _SDL_platform_h - -#if defined(_AIX) -#undef __AIX__ -#define __AIX__ 1 -#endif -#if defined(__BEOS__) -#undef __BEOS__ -#define __BEOS__ 1 -#endif -#if defined(__HAIKU__) -#undef __HAIKU__ -#define __HAIKU__ 1 -#endif -#if defined(bsdi) || defined(__bsdi) || defined(__bsdi__) -#undef __BSDI__ -#define __BSDI__ 1 -#endif -#if defined(_arch_dreamcast) -#undef __DREAMCAST__ -#define __DREAMCAST__ 1 -#endif -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) -#undef __FREEBSD__ -#define __FREEBSD__ 1 -#endif -#if defined(hpux) || defined(__hpux) || defined(__hpux__) -#undef __HPUX__ -#define __HPUX__ 1 -#endif -#if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE) -#undef __IRIX__ -#define __IRIX__ 1 -#endif -#if defined(linux) || defined(__linux) || defined(__linux__) -#undef __LINUX__ -#define __LINUX__ 1 -#endif -#if defined(ANDROID) -#undef __ANDROID__ -#undef __LINUX__ /*do we need to do this?*/ -#define __ANDROID__ 1 -#endif - -#if defined(__APPLE__) -/* lets us know what version of Mac OS X we're compiling on */ -#include "AvailabilityMacros.h" -#include "TargetConditionals.h" -#if TARGET_OS_IPHONE -/* if compiling for iPhone */ -#undef __IPHONEOS__ -#define __IPHONEOS__ 1 -#undef __MACOSX__ -#else -/* if not compiling for iPhone */ -#undef __MACOSX__ -#define __MACOSX__ 1 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050 -# error SDL for Mac OS X only supports deploying on 10.5 and above. -#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1050 */ -#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060 -# error SDL for Mac OS X must be built with a 10.6 SDK or above. -#endif /* MAC_OS_X_VERSION_MAX_ALLOWED < 1060 */ -#endif /* TARGET_OS_IPHONE */ -#endif /* defined(__APPLE__) */ - -#if defined(__NetBSD__) -#undef __NETBSD__ -#define __NETBSD__ 1 -#endif -#if defined(__OpenBSD__) -#undef __OPENBSD__ -#define __OPENBSD__ 1 -#endif -#if defined(__OS2__) -#undef __OS2__ -#define __OS2__ 1 -#endif -#if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE) -#undef __OSF__ -#define __OSF__ 1 -#endif -#if defined(__QNXNTO__) -#undef __QNXNTO__ -#define __QNXNTO__ 1 -#endif -#if defined(riscos) || defined(__riscos) || defined(__riscos__) -#undef __RISCOS__ -#define __RISCOS__ 1 -#endif -#if defined(__SVR4) -#undef __SOLARIS__ -#define __SOLARIS__ 1 -#endif - +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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_platform.h + * + * Try to get a standard set of platform defines. + */ + +#ifndef _SDL_platform_h +#define _SDL_platform_h + +#if defined(_AIX) +#undef __AIX__ +#define __AIX__ 1 +#endif +#if defined(__BEOS__) +#undef __BEOS__ +#define __BEOS__ 1 +#endif +#if defined(__HAIKU__) +#undef __HAIKU__ +#define __HAIKU__ 1 +#endif +#if defined(bsdi) || defined(__bsdi) || defined(__bsdi__) +#undef __BSDI__ +#define __BSDI__ 1 +#endif +#if defined(_arch_dreamcast) +#undef __DREAMCAST__ +#define __DREAMCAST__ 1 +#endif +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) +#undef __FREEBSD__ +#define __FREEBSD__ 1 +#endif +#if defined(hpux) || defined(__hpux) || defined(__hpux__) +#undef __HPUX__ +#define __HPUX__ 1 +#endif +#if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE) +#undef __IRIX__ +#define __IRIX__ 1 +#endif +#if defined(linux) || defined(__linux) || defined(__linux__) +#undef __LINUX__ +#define __LINUX__ 1 +#endif +#if defined(ANDROID) +#undef __ANDROID__ +#undef __LINUX__ /* do we need to do this? */ +#define __ANDROID__ 1 +#endif + +#if defined(__APPLE__) +/* lets us know what version of Mac OS X we're compiling on */ +#include "AvailabilityMacros.h" +#include "TargetConditionals.h" +#if TARGET_OS_IPHONE +/* if compiling for iPhone */ +#undef __IPHONEOS__ +#define __IPHONEOS__ 1 +#undef __MACOSX__ +#else +/* if not compiling for iPhone */ +#undef __MACOSX__ +#define __MACOSX__ 1 +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +# error SDL for Mac OS X only supports deploying on 10.5 and above. +#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1050 */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060 +# error SDL for Mac OS X must be built with a 10.6 SDK or above. +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED < 1060 */ +#endif /* TARGET_OS_IPHONE */ +#endif /* defined(__APPLE__) */ + +#if defined(__NetBSD__) +#undef __NETBSD__ +#define __NETBSD__ 1 +#endif +#if defined(__OpenBSD__) +#undef __OPENBSD__ +#define __OPENBSD__ 1 +#endif +#if defined(__OS2__) +#undef __OS2__ +#define __OS2__ 1 +#endif +#if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE) +#undef __OSF__ +#define __OSF__ 1 +#endif +#if defined(__QNXNTO__) +#undef __QNXNTO__ +#define __QNXNTO__ 1 +#endif +#if defined(riscos) || defined(__riscos) || defined(__riscos__) +#undef __RISCOS__ +#define __RISCOS__ 1 +#endif +#if defined(__SVR4) +#undef __SOLARIS__ +#define __SOLARIS__ 1 +#endif + #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) -/* Try to find out what version of Windows we are compiling for */ +/* Try to find out if we're compiling for WinRT or non-WinRT */ #if defined(_MSC_VER) && (_MSC_VER >= 1700) /* _MSC_VER==1700 for MSVC 2012 */ #include -#endif -/* Default to classic, Win32 / Desktop compilation either if: +#endif /* _MSC_VER >= 1700 */ +/* Default to classic, Win32/Win64/Desktop compilation either if: 1. the version of Windows is explicity set to a 'Desktop' (non-Metro) app 2. the version of Windows cannot be determined via winapifamily.h - If neither is true, see if we're compiling for WinRT. + If neither is true, then see if we're compiling for WinRT. */ #if ! defined(WINAPI_FAMILY_PARTITION) || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) -#undef __WIN32__ -#define __WIN32__ 1 +#undef __WINDOWS__ +#define __WINDOWS__ 1 /* See if we're compiling for WinRT: */ #elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) #undef __WINRT__ #define __WINRT__ 1 #endif /* ! defined(WINAPI_FAMILY_PARTITION) */ -#endif /* defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) */ - -#if defined(__PSP__) -#undef __PSP__ -#define __PSP__ 1 -#endif - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief Gets the name of the platform. - */ -extern DECLSPEC const char * SDLCALL SDL_GetPlatform (void); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_platform_h */ - -/* vi: set ts=4 sw=4 expandtab: */ +#endif /* defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) */ + +#if defined(__WINDOWS__) +#undef __WIN32__ +#define __WIN32__ 1 +#endif +#if defined(__PSP__) +#undef __PSP__ +#define __PSP__ 1 +#endif + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Gets the name of the platform. + */ +extern DECLSPEC const char * SDLCALL SDL_GetPlatform (void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_platform_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/include/SDL_rect.h b/include/SDL_rect.h index c8af7c197..7132e1b44 100644 --- a/include/SDL_rect.h +++ b/include/SDL_rect.h @@ -44,7 +44,7 @@ extern "C" { * * \sa SDL_EnclosePoints */ -typedef struct +typedef struct SDL_Point { int x; int y; diff --git a/include/SDL_render.h b/include/SDL_render.h index 1e24619f0..a765dc79f 100644 --- a/include/SDL_render.h +++ b/include/SDL_render.h @@ -381,6 +381,31 @@ extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect, const void *pixels, int pitch); +/** + * \brief Update a rectangle within a planar YV12 or IYUV texture with new pixel data. + * + * \param texture The texture to update + * \param rect A pointer to the rectangle of pixels to update, or NULL to + * update the entire texture. + * \param Yplane The raw pixel data for the Y plane. + * \param Ypitch The number of bytes between rows of pixel data for the Y plane. + * \param Uplane The raw pixel data for the U plane. + * \param Upitch The number of bytes between rows of pixel data for the U plane. + * \param Vplane The raw pixel data for the V plane. + * \param Vpitch The number of bytes between rows of pixel data for the V plane. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \note You can use SDL_UpdateTexture() as long as your pixel data is + * a contiguous block of Y and U/V planes in the proper order, but + * this function is available if your pixel data is not contiguous. + */ +extern DECLSPEC int SDLCALL SDL_UpdateYUVTexture(SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch); + /** * \brief Lock a portion of the texture for write-only pixel access. * diff --git a/include/SDL_rwops.h b/include/SDL_rwops.h index 0461ff782..d25744238 100644 --- a/include/SDL_rwops.h +++ b/include/SDL_rwops.h @@ -148,7 +148,7 @@ typedef struct SDL_RWops * * Functions to create SDL_RWops structures from various data streams. */ -/*@{*/ +/* @{ */ extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file, const char *mode); @@ -165,7 +165,7 @@ extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem(void *mem, int size); extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromConstMem(const void *mem, int size); -/*@}*//*RWFrom functions*/ +/* @} *//* RWFrom functions */ extern DECLSPEC SDL_RWops *SDLCALL SDL_AllocRW(void); @@ -180,14 +180,14 @@ extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area); * * Macros to easily read and write from an SDL_RWops structure. */ -/*@{*/ +/* @{ */ #define SDL_RWsize(ctx) (ctx)->size(ctx) #define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence) #define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR) #define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n) #define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n) #define SDL_RWclose(ctx) (ctx)->close(ctx) -/*@}*//*Read/write macros*/ +/* @} *//* Read/write macros */ /** @@ -195,7 +195,7 @@ extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area); * * Read an item of the specified endianness and return in native format. */ -/*@{*/ +/* @{ */ extern DECLSPEC Uint8 SDLCALL SDL_ReadU8(SDL_RWops * src); extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops * src); extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops * src); @@ -203,14 +203,14 @@ extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops * src); extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops * src); extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops * src); extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops * src); -/*@}*//*Read endian functions*/ +/* @} *//* Read endian functions */ /** * \name Write endian functions * * Write an item of native format to the specified endianness. */ -/*@{*/ +/* @{ */ extern DECLSPEC size_t SDLCALL SDL_WriteU8(SDL_RWops * dst, Uint8 value); extern DECLSPEC size_t SDLCALL SDL_WriteLE16(SDL_RWops * dst, Uint16 value); extern DECLSPEC size_t SDLCALL SDL_WriteBE16(SDL_RWops * dst, Uint16 value); @@ -218,7 +218,7 @@ extern DECLSPEC size_t SDLCALL SDL_WriteLE32(SDL_RWops * dst, Uint32 value); extern DECLSPEC size_t SDLCALL SDL_WriteBE32(SDL_RWops * dst, Uint32 value); extern DECLSPEC size_t SDLCALL SDL_WriteLE64(SDL_RWops * dst, Uint64 value); extern DECLSPEC size_t SDLCALL SDL_WriteBE64(SDL_RWops * dst, Uint64 value); -/*@}*//*Write endian functions*/ +/* @} *//* Write endian functions */ /* Ends C function definitions when using C++ */ diff --git a/include/SDL_scancode.h b/include/SDL_scancode.h index d3f874811..00b47a3b8 100644 --- a/include/SDL_scancode.h +++ b/include/SDL_scancode.h @@ -49,7 +49,7 @@ typedef enum * * These values are from usage page 0x07 (USB keyboard page). */ - /*@{*/ + /* @{ */ SDL_SCANCODE_A = 4, SDL_SCANCODE_B = 5, @@ -339,14 +339,14 @@ typedef enum * special KMOD_MODE for it I'm adding it here */ - /*@}*//*Usage page 0x07*/ + /* @} *//* Usage page 0x07 */ /** * \name Usage page 0x0C * * These values are mapped from usage page 0x0C (USB consumer page). */ - /*@{*/ + /* @{ */ SDL_SCANCODE_AUDIONEXT = 258, SDL_SCANCODE_AUDIOPREV = 259, @@ -366,14 +366,14 @@ typedef enum SDL_SCANCODE_AC_REFRESH = 273, SDL_SCANCODE_AC_BOOKMARKS = 274, - /*@}*//*Usage page 0x0C*/ + /* @} *//* Usage page 0x0C */ /** * \name Walther keys * * These are values that Christian Walther added (for mac keyboard?). */ - /*@{*/ + /* @{ */ SDL_SCANCODE_BRIGHTNESSDOWN = 275, SDL_SCANCODE_BRIGHTNESSUP = 276, @@ -388,7 +388,7 @@ typedef enum SDL_SCANCODE_APP1 = 283, SDL_SCANCODE_APP2 = 284, - /*@}*//*Walther keys*/ + /* @} *//* Walther keys */ /* Add any other keys here. */ diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h index e4a71d35c..7a6557a8e 100644 --- a/include/SDL_stdinc.h +++ b/include/SDL_stdinc.h @@ -99,7 +99,7 @@ * Use proper C++ casts when compiled as C++ to be compatible with the option * -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above). */ -/*@{*/ +/* @{ */ #ifdef __cplusplus #define SDL_reinterpret_cast(type, expression) reinterpret_cast(expression) #define SDL_static_cast(type, expression) static_cast(expression) @@ -109,7 +109,7 @@ #define SDL_static_cast(type, expression) ((type)(expression)) #define SDL_const_cast(type, expression) ((type)(expression)) #endif -/*@}*//*Cast operators*/ +/* @} *//* Cast operators */ /* Define a four character code as a Uint32 */ #define SDL_FOURCC(A, B, C, D) \ @@ -121,7 +121,7 @@ /** * \name Basic data types */ -/*@{*/ +/* @{ */ typedef enum { @@ -163,7 +163,7 @@ typedef int64_t Sint64; */ typedef uint64_t Uint64; -/*@}*//*Basic data types*/ +/* @} *//* Basic data types */ #define SDL_COMPILE_TIME_ASSERT(name, x) \ diff --git a/include/SDL_surface.h b/include/SDL_surface.h index fece79743..e18153a69 100644 --- a/include/SDL_surface.h +++ b/include/SDL_surface.h @@ -48,12 +48,12 @@ extern "C" { * \internal * Used internally (read-only). */ -/*@{*/ +/* @{ */ #define SDL_SWSURFACE 0 /**< Just here for compatibility */ #define SDL_PREALLOC 0x00000001 /**< Surface uses preallocated memory */ #define SDL_RLEACCEL 0x00000002 /**< Surface is RLE encoded */ #define SDL_DONTFREE 0x00000004 /**< Surface is referenced internally */ -/*@}*//*Surface flags*/ +/* @} *//* Surface flags */ /** * Evaluates to true if the surface needs to be locked before access. @@ -357,7 +357,7 @@ extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface, * surface. */ extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface - (SDL_Surface * src, SDL_PixelFormat * fmt, Uint32 flags); + (SDL_Surface * src, const SDL_PixelFormat * fmt, Uint32 flags); extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat (SDL_Surface * src, Uint32 pixel_format, Uint32 flags); diff --git a/include/SDL_system.h b/include/SDL_system.h index 056d07fcd..5dc64cc94 100644 --- a/include/SDL_system.h +++ b/include/SDL_system.h @@ -1,169 +1,185 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - 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_system.h - * - * Include file for platform specific SDL API functions - */ - -#ifndef _SDL_system_h -#define _SDL_system_h - -#include "SDL_stdinc.h" - -#if defined(__IPHONEOS__) && __IPHONEOS__ -#include "SDL_video.h" -#include "SDL_keyboard.h" -#endif - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* Platform specific functions for iOS */ -#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); - -#endif /* __IPHONEOS__ */ - - -/* Platform specific functions for 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 - */ -extern DECLSPEC void * SDLCALL SDL_AndroidGetJNIEnv(); - -/* 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 - (using env->Push/PopLocalFrame or manually with env->DeleteLocalRef) - */ -extern DECLSPEC void * SDLCALL SDL_AndroidGetActivity(); - -/* 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. - 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: - 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. - This path is unique to your application, but is public and can be - written to by other applications. - */ -extern DECLSPEC const char * SDLCALL SDL_AndroidGetExternalStoragePath(); - -#endif /* __ANDROID__ */ - - -/* Platform specific functions for WinRT */ -#if defined(__WINRT__) && __WINRT__ - -/** - * \brief WinRT / Windows Phone path types - */ -typedef enum -{ - /** \brief The installed app's root directory. - Files here are likely to be read-only. */ - SDL_WINRT_PATH_INSTALLED_LOCATION, - - /** \brief The app's local data store. Files may be written here */ - SDL_WINRT_PATH_LOCAL_FOLDER, - - /** \brief The app's roaming data store. Unsupported on Windows Phone. - Files written here may be copied to other machines via a network - connection. - */ - SDL_WINRT_PATH_ROAMING_FOLDER, - - /** \brief The app's temporary data store. Unsupported on Windows Phone. - Files written here may be deleted at any time. */ - SDL_WINRT_PATH_TEMP_FOLDER -} SDL_WinRT_Path; - - -/** - * \brief Retrieves a WinRT defined path on the local file system - * - * \note Documentation on most app-specific path types on WinRT - * can be found on MSDN, at the URL: - * 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 - * 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 - * SDL_WinRT_Path for more information on which path types are - * supported where. - */ -extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType); - -/** - * \brief Retrieves a WinRT defined path on the local file system - * - * \note Documentation on most app-specific path types on WinRT - * can be found on MSDN, at the URL: - * 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 - * 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 - * SDL_WinRT_Path for more information on which path types are - * supported where. - */ -extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType); - -#endif /* __WINRT__ */ - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_system_h */ - -/* vi: set ts=4 sw=4 expandtab: */ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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_system.h + * + * Include file for platform specific SDL API functions + */ + +#ifndef _SDL_system_h +#define _SDL_system_h + +#include "SDL_stdinc.h" +#include "SDL_keyboard.h" +#include "SDL_render.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + + +/* Platform specific functions for Windows */ +#ifdef __WIN32__ + +/* 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. + 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); + +#endif /* __WIN32__ */ + + +/* Platform specific functions for iOS */ +#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); + +#endif /* __IPHONEOS__ */ + + +/* Platform specific functions for 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 + */ +extern DECLSPEC void * SDLCALL SDL_AndroidGetJNIEnv(); + +/* 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 + (using env->Push/PopLocalFrame or manually with env->DeleteLocalRef) + */ +extern DECLSPEC void * SDLCALL SDL_AndroidGetActivity(); + +/* 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. + 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: + 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. + This path is unique to your application, but is public and can be + written to by other applications. + */ +extern DECLSPEC const char * SDLCALL SDL_AndroidGetExternalStoragePath(); + +#endif /* __ANDROID__ */ + +/* Platform specific functions for WinRT */ +#if defined(__WINRT__) && __WINRT__ + +/** + * \brief WinRT / Windows Phone path types + */ +typedef enum +{ + /** \brief The installed app's root directory. + Files here are likely to be read-only. */ + SDL_WINRT_PATH_INSTALLED_LOCATION, + + /** \brief The app's local data store. Files may be written here */ + SDL_WINRT_PATH_LOCAL_FOLDER, + + /** \brief The app's roaming data store. Unsupported on Windows Phone. + Files written here may be copied to other machines via a network + connection. + */ + SDL_WINRT_PATH_ROAMING_FOLDER, + + /** \brief The app's temporary data store. Unsupported on Windows Phone. + Files written here may be deleted at any time. */ + SDL_WINRT_PATH_TEMP_FOLDER +} SDL_WinRT_Path; + + +/** + * \brief Retrieves a WinRT defined path on the local file system + * + * \note Documentation on most app-specific path types on WinRT + * can be found on MSDN, at the URL: + * 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 + * 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 + * SDL_WinRT_Path for more information on which path types are + * supported where. + */ +extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType); + +/** + * \brief Retrieves a WinRT defined path on the local file system + * + * \note Documentation on most app-specific path types on WinRT + * can be found on MSDN, at the URL: + * 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 + * 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 + * SDL_WinRT_Path for more information on which path types are + * supported where. + */ +extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType); + +#endif /* __WINRT__ */ + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_system_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/include/SDL_test_common.h b/include/SDL_test_common.h index f07acf7c1..57f31146e 100644 --- a/include/SDL_test_common.h +++ b/include/SDL_test_common.h @@ -108,6 +108,7 @@ typedef struct int gl_major_version; int gl_minor_version; int gl_debug; + int gl_profile_mask; } SDLTest_CommonState; #include "begin_code.h" diff --git a/include/SDL_test_harness.h b/include/SDL_test_harness.h index d2da04f1e..935038e90 100644 --- a/include/SDL_test_harness.h +++ b/include/SDL_test_harness.h @@ -43,43 +43,43 @@ extern "C" { #endif -//! Definitions for test case structures +/* ! Definitions for test case structures */ #define TEST_ENABLED 1 #define TEST_DISABLED 0 -//! Definition of all the possible test return values of the test case method +/* ! Definition of all the possible test return values of the test case method */ #define TEST_ABORTED -1 #define TEST_STARTED 0 #define TEST_COMPLETED 1 #define TEST_SKIPPED 2 -//! Definition of all the possible test results for the harness +/* ! Definition of all the possible test results for the harness */ #define TEST_RESULT_PASSED 0 #define TEST_RESULT_FAILED 1 #define TEST_RESULT_NO_ASSERT 2 #define TEST_RESULT_SKIPPED 3 #define TEST_RESULT_SETUP_FAILURE 4 -//!< Function pointer to a test case setup function (run before every test) +/* !< Function pointer to a test case setup function (run before every test) */ typedef void (*SDLTest_TestCaseSetUpFp)(void *arg); -//!< Function pointer to a test case function +/* !< Function pointer to a test case function */ typedef int (*SDLTest_TestCaseFp)(void *arg); -//!< Function pointer to a test case teardown function (run after every test) +/* !< Function pointer to a test case teardown function (run after every test) */ typedef void (*SDLTest_TestCaseTearDownFp)(void *arg); /** * Holds information about a single test case. */ typedef struct SDLTest_TestCaseReference { - /*!< Func2Stress */ + /* !< Func2Stress */ SDLTest_TestCaseFp testCase; - /*!< Short name (or function name) "Func2Stress" */ + /* !< Short name (or function name) "Func2Stress" */ char *name; - /*!< Long name or full description "This test pushes func2() to the limit." */ + /* !< Long name or full description "This test pushes func2() to the limit." */ char *description; - /*!< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */ + /* !< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */ int enabled; } SDLTest_TestCaseReference; @@ -87,13 +87,13 @@ typedef struct SDLTest_TestCaseReference { * Holds information about a test suite (multiple test cases). */ typedef struct SDLTest_TestSuiteReference { - /*!< "PlatformSuite" */ + /* !< "PlatformSuite" */ char *name; - /*!< The function that is run before each test. NULL skips. */ + /* !< The function that is run before each test. NULL skips. */ SDLTest_TestCaseSetUpFp testSetUp; - /*!< The test cases that are run as part of the suite. Last item should be NULL. */ + /* !< The test cases that are run as part of the suite. Last item should be NULL. */ const SDLTest_TestCaseReference **testCases; - /*!< The function that is run after each test. NULL skips. */ + /* !< The function that is run after each test. NULL skips. */ SDLTest_TestCaseTearDownFp testTearDown; } SDLTest_TestSuiteReference; diff --git a/include/SDL_thread.h b/include/SDL_thread.h index c878c3ab9..f248c3d69 100644 --- a/include/SDL_thread.h +++ b/include/SDL_thread.h @@ -51,9 +51,10 @@ typedef unsigned long SDL_threadID; /* Thread local storage ID, 0 is the invalid ID */ typedef unsigned int SDL_TLSID; -/* The SDL thread priority +/** + * The SDL thread priority. * - * Note: On many systems you require special privileges to set high priority. + * \note On many systems you require special privileges to set high priority. */ typedef enum { SDL_THREAD_PRIORITY_LOW, @@ -61,8 +62,9 @@ typedef enum { SDL_THREAD_PRIORITY_HIGH } SDL_ThreadPriority; -/* The function passed to SDL_CreateThread() - It is passed a void* user context parameter and returns an int. +/** + * The function passed to SDL_CreateThread(). + * It is passed a void* user context parameter and returns an int. */ typedef int (SDLCALL * SDL_ThreadFunction) (void *data); diff --git a/include/SDL_timer.h b/include/SDL_timer.h index e065cf4f9..28ab415b4 100644 --- a/include/SDL_timer.h +++ b/include/SDL_timer.h @@ -44,6 +44,17 @@ extern "C" { */ extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); +/** + * \brief Compare SDL ticks values, and return true if A has passed B + * + * e.g. if you want to wait 100 ms, you could do this: + * Uint32 timeout = SDL_GetTicks() + 100; + * while (!SDL_TICKS_PASSED(SDL_GetTicks(), timeout)) { + * ... do work until timeout has elapsed + * } + */ +#define SDL_TICKS_PASSED(A, B) ((Sint32)((B) - (A)) <= 0) + /** * \brief Get the current value of the high resolution counter */ diff --git a/include/SDL_version.h b/include/SDL_version.h index a9ced804d..dc52c85c0 100644 --- a/include/SDL_version.h +++ b/include/SDL_version.h @@ -59,7 +59,7 @@ typedef struct SDL_version */ #define SDL_MAJOR_VERSION 2 #define SDL_MINOR_VERSION 0 -#define SDL_PATCHLEVEL 0 +#define SDL_PATCHLEVEL 1 /** * \brief Macro to determine SDL version program was compiled against. diff --git a/include/SDL_video.h b/include/SDL_video.h index f3a961977..4a53f9b34 100644 --- a/include/SDL_video.h +++ b/include/SDL_video.h @@ -107,7 +107,8 @@ typedef enum SDL_WINDOW_INPUT_FOCUS = 0x00000200, /**< window has input focus */ SDL_WINDOW_MOUSE_FOCUS = 0x00000400, /**< window has mouse focus */ SDL_WINDOW_FULLSCREEN_DESKTOP = ( SDL_WINDOW_FULLSCREEN | 0x00001000 ), - SDL_WINDOW_FOREIGN = 0x00000800 /**< window not created by SDL */ + SDL_WINDOW_FOREIGN = 0x00000800, /**< window not created by SDL */ + SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000 /**< window should be created in high-DPI mode if supported */ } SDL_WindowFlags; /** @@ -186,14 +187,15 @@ typedef enum SDL_GL_CONTEXT_EGL, SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_PROFILE_MASK, - SDL_GL_SHARE_WITH_CURRENT_CONTEXT + SDL_GL_SHARE_WITH_CURRENT_CONTEXT, + SDL_GL_FRAMEBUFFER_SRGB_CAPABLE } SDL_GLattr; typedef enum { SDL_GL_CONTEXT_PROFILE_CORE = 0x0001, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002, - SDL_GL_CONTEXT_PROFILE_ES = 0x0004 + SDL_GL_CONTEXT_PROFILE_ES = 0x0004 /* GLX_CONTEXT_ES2_PROFILE_BIT_EXT */ } SDL_GLprofile; typedef enum @@ -393,10 +395,11 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window * window); * \param w The width of the window. * \param h The height of the window. * \param flags The flags for the window, a mask of any of the following: - * ::SDL_WINDOW_FULLSCREEN, ::SDL_WINDOW_OPENGL, - * ::SDL_WINDOW_HIDDEN, ::SDL_WINDOW_BORDERLESS, - * ::SDL_WINDOW_RESIZABLE, ::SDL_WINDOW_MAXIMIZED, - * ::SDL_WINDOW_MINIMIZED, ::SDL_WINDOW_INPUT_GRABBED. + * ::SDL_WINDOW_FULLSCREEN, ::SDL_WINDOW_OPENGL, + * ::SDL_WINDOW_HIDDEN, ::SDL_WINDOW_BORDERLESS, + * ::SDL_WINDOW_RESIZABLE, ::SDL_WINDOW_MAXIMIZED, + * ::SDL_WINDOW_MINIMIZED, ::SDL_WINDOW_INPUT_GRABBED, + * ::SDL_WINDOW_ALLOW_HIGHDPI. * * \return The id of the window created, or zero if window creation failed. * @@ -821,7 +824,7 @@ extern DECLSPEC void SDLCALL SDL_DisableScreenSaver(void); /** * \name OpenGL support functions */ -/*@{*/ +/* @{ */ /** * \brief Dynamically load an OpenGL library. @@ -899,6 +902,24 @@ extern DECLSPEC SDL_Window* SDLCALL SDL_GL_GetCurrentWindow(void); */ extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_GetCurrentContext(void); +/** + * \brief Get the size of a window's underlying drawable (for use with glViewport). + * + * \param window Window from which the drawable size should be queried + * \param w Pointer to variable for storing the width, may be NULL + * \param h Pointer to variable for storing the height, may be NULL + * + * This may differ from SDL_GetWindowSize if we're rendering to a high-DPI + * drawable, i.e. the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a + * platform with high-DPI support (Apple calls this "Retina"), and not disabled + * by the SDL_HINT_VIDEO_HIGHDPI_DISABLED hint. + * + * \sa SDL_GetWindowSize() + * \sa SDL_CreateWindow() + */ +extern DECLSPEC void SDLCALL SDL_GL_GetDrawableSize(SDL_Window * window, int *w, + int *h); + /** * \brief Set the swap interval for the current OpenGL context. * @@ -939,7 +960,7 @@ extern DECLSPEC void SDLCALL SDL_GL_SwapWindow(SDL_Window * window); */ extern DECLSPEC void SDLCALL SDL_GL_DeleteContext(SDL_GLContext context); -/*@}*//*OpenGL support functions*/ +/* @} *//* OpenGL support functions */ /* Ends C function definitions when using C++ */ diff --git a/include/begin_code.h b/include/begin_code.h index 8997a7220..1a5aa31bd 100644 --- a/include/begin_code.h +++ b/include/begin_code.h @@ -1,150 +1,140 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - 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 begin_code.h - * - * This file sets things up for C dynamic library function definitions, - * static inlined functions, and structures aligned at 4-byte alignment. - * If you don't like ugly C preprocessor code, don't look at this file. :) - */ - -/* This shouldn't be nested -- included it around code only. */ -#ifdef _begin_code_h -#error Nested inclusion of begin_code.h -#endif -#define _begin_code_h - -/* Some compilers use a special export keyword */ -#ifndef DECLSPEC -# if defined(__BEOS__) || defined(__HAIKU__) -# if defined(__GNUC__) -# define DECLSPEC __declspec(dllexport) -# else -# define DECLSPEC __declspec(export) -# endif -# elif defined(__WIN32__) || defined(__WINRT__) -# ifdef __BORLANDC__ -# ifdef BUILD_SDL -# define DECLSPEC -# else -# define DECLSPEC __declspec(dllimport) -# endif -# else -# define DECLSPEC __declspec(dllexport) -# endif -# else -# if defined(__GNUC__) && __GNUC__ >= 4 -# define DECLSPEC __attribute__ ((visibility("default"))) -# else -# define DECLSPEC -# endif -# endif -#endif - -/* By default SDL uses the C calling convention */ -#ifndef SDLCALL -#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__) -#define SDLCALL __cdecl -#else -#define SDLCALL -#endif -#endif /* SDLCALL */ - -/* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */ -#ifdef __SYMBIAN32__ -#undef DECLSPEC -#define DECLSPEC -#endif /* __SYMBIAN32__ */ - -/* Force structure packing at 4 byte alignment. - This is necessary if the header is included in code which has structure - packing set to an alternate value, say for loading structures from disk. - The packing is reset to the previous value in close_code.h - */ -#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) -#ifdef _MSC_VER -#pragma warning(disable: 4103) -#endif -#ifdef __BORLANDC__ -#pragma nopackwarning -#endif -#ifdef _M_X64 -/* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */ -#pragma pack(push,8) -#else -#pragma pack(push,4) -#endif -#endif /* Compiler needs structure packing set */ - -/* Set up compiler-specific options for inlining functions */ -#ifndef SDL_INLINE_OKAY -#ifdef __GNUC__ -#define SDL_INLINE_OKAY -#else -/* Add any special compiler-specific cases here */ -#if defined(_MSC_VER) || defined(__BORLANDC__) || \ - defined(__DMC__) || defined(__SC__) || \ - defined(__WATCOMC__) || defined(__LCC__) || \ - defined(__DECC) -#ifndef __inline__ -#define __inline__ __inline -#endif -#define SDL_INLINE_OKAY -#else -#if !defined(__MRC__) && !defined(_SGI_SOURCE) -#ifndef __inline__ -#define __inline__ inline -#endif -#define SDL_INLINE_OKAY -#endif /* Not a funky compiler */ -#endif /* Visual C++ */ -#endif /* GNU C */ -#endif /* SDL_INLINE_OKAY */ - -/* If inlining isn't supported, remove "__inline__", turning static - inlined functions into static functions (resulting in code bloat - in all files which include the offending header files) -*/ -#ifndef SDL_INLINE_OKAY -#define __inline__ -#endif - -#ifndef SDL_FORCE_INLINE -#if defined(_MSC_VER) -#define SDL_FORCE_INLINE __forceinline -#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) -#define SDL_FORCE_INLINE __attribute__((always_inline)) static inline -#else -#define SDL_FORCE_INLINE static __inline__ -#endif -#endif - -/* Apparently this is needed by several Windows compilers */ -#if !defined(__MACH__) -#ifndef NULL -#ifdef __cplusplus -#define NULL 0 -#else -#define NULL ((void *)0) -#endif -#endif /* NULL */ -#endif /* ! Mac OS X - breaks precompiled headers */ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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 begin_code.h + * + * This file sets things up for C dynamic library function definitions, + * static inlined functions, and structures aligned at 4-byte alignment. + * If you don't like ugly C preprocessor code, don't look at this file. :) + */ + +/* This shouldn't be nested -- included it around code only. */ +#ifdef _begin_code_h +#error Nested inclusion of begin_code.h +#endif +#define _begin_code_h + +#ifndef SDL_DEPRECATED +# if (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */ +# define SDL_DEPRECATED __attribute__((deprecated)) +# else +# define SDL_DEPRECATED +# endif +#endif + +/* Some compilers use a special export keyword */ +#ifndef DECLSPEC +# if defined(__WIN32__) || defined(__WINRT__) +# ifdef __BORLANDC__ +# ifdef BUILD_SDL +# define DECLSPEC +# else +# define DECLSPEC __declspec(dllimport) +# endif +# else +# define DECLSPEC __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && __GNUC__ >= 4 +# define DECLSPEC __attribute__ ((visibility("default"))) +# elif defined(__GNUC__) && __GNUC__ >= 2 +# define DECLSPEC __declspec(dllexport) +# else +# define DECLSPEC +# endif +# endif +#endif + +/* By default SDL uses the C calling convention */ +#ifndef SDLCALL +#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__) +#define SDLCALL __cdecl +#else +#define SDLCALL +#endif +#endif /* SDLCALL */ + +/* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */ +#ifdef __SYMBIAN32__ +#undef DECLSPEC +#define DECLSPEC +#endif /* __SYMBIAN32__ */ + +/* Force structure packing at 4 byte alignment. + This is necessary if the header is included in code which has structure + packing set to an alternate value, say for loading structures from disk. + The packing is reset to the previous value in close_code.h + */ +#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) +#ifdef _MSC_VER +#pragma warning(disable: 4103) +#endif +#ifdef __BORLANDC__ +#pragma nopackwarning +#endif +#ifdef _M_X64 +/* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */ +#pragma pack(push,8) +#else +#pragma pack(push,4) +#endif +#endif /* Compiler needs structure packing set */ + +#ifndef SDL_INLINE +#if defined(__GNUC__) +#define SDL_INLINE __inline__ +#elif defined(_MSC_VER) || defined(__BORLANDC__) || \ + defined(__DMC__) || defined(__SC__) || \ + defined(__WATCOMC__) || defined(__LCC__) || \ + defined(__DECC) +#define SDL_INLINE __inline +#ifndef __inline__ +#define __inline__ __inline +#endif +#else +#define SDL_INLINE inline +#ifndef __inline__ +#define __inline__ inline +#endif +#endif +#endif /* SDL_INLINE not defined */ + +#ifndef SDL_FORCE_INLINE +#if defined(_MSC_VER) +#define SDL_FORCE_INLINE __forceinline +#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) +#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__ +#else +#define SDL_FORCE_INLINE static SDL_INLINE +#endif +#endif /* SDL_FORCE_INLINE not defined */ + +/* Apparently this is needed by several Windows compilers */ +#if !defined(__MACH__) +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 +#else +#define NULL ((void *)0) +#endif +#endif /* NULL */ +#endif /* ! Mac OS X - breaks precompiled headers */ diff --git a/src/SDL.c b/src/SDL.c index d8c05fb5b..0f6de9fe6 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -20,6 +20,10 @@ */ #include "SDL_config.h" +#if defined(__WIN32__) +#include "core/windows/SDL_windows.h" +#endif + /* Initialization code for SDL */ #include "SDL.h" @@ -441,7 +445,6 @@ SDL_GetPlatform() #if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL)) /* Need to include DllMain() on Watcom C for some reason.. */ -#include "core/windows/SDL_windows.h" BOOL APIENTRY _DllMainCRTStartup(HANDLE hModule, diff --git a/src/SDL_assert.c b/src/SDL_assert.c index 73ebfe5fc..5fa842408 100644 --- a/src/SDL_assert.c +++ b/src/SDL_assert.c @@ -20,6 +20,10 @@ */ #include "SDL_config.h" +#if defined(__WIN32__) +#include "core/windows/SDL_windows.h" +#endif + #include "SDL.h" #include "SDL_atomic.h" #include "SDL_messagebox.h" @@ -29,8 +33,6 @@ #include "video/SDL_sysvideo.h" #ifdef __WIN32__ -#include "core/windows/SDL_windows.h" - #ifndef WS_OVERLAPPEDWINDOW #define WS_OVERLAPPEDWINDOW 0 #endif diff --git a/src/SDL_hints.c b/src/SDL_hints.c index b00e961cc..a1eae9ffd 100644 --- a/src/SDL_hints.c +++ b/src/SDL_hints.c @@ -72,14 +72,8 @@ SDL_SetHintWithPriority(const char *name, const char *value, entry->callback(entry->userdata, name, hint->value, value); entry = next; } - if (hint->value) { - SDL_free(hint->value); - } - if (value) { - hint->value = SDL_strdup(value); - } else { - hint->value = NULL; - } + SDL_free(hint->value); + hint->value = value ? SDL_strdup(value) : NULL; } hint->priority = priority; return SDL_TRUE; @@ -210,9 +204,7 @@ void SDL_ClearHints(void) SDL_hints = hint->next; SDL_free(hint->name); - if (hint->value) { - SDL_free(hint->value); - } + SDL_free(hint->value); for (entry = hint->callbacks; entry; ) { SDL_HintWatch *freeable = entry; entry = entry->next; diff --git a/src/SDL_log.c b/src/SDL_log.c index 1bd8ae69d..4ad5c4273 100644 --- a/src/SDL_log.c +++ b/src/SDL_log.c @@ -1,436 +1,439 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - 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. -*/ -#include "SDL_config.h" - -/* Simple log messages in SDL */ - -#include "SDL_log.h" - -#if HAVE_STDIO_H -#include -#endif - -#if defined(__WIN32__) || defined(__WINRT__) -#include "core/windows/SDL_windows.h" -#elif defined(__ANDROID__) -#include -#endif - -#define DEFAULT_PRIORITY SDL_LOG_PRIORITY_CRITICAL -#define DEFAULT_ASSERT_PRIORITY SDL_LOG_PRIORITY_WARN -#define DEFAULT_APPLICATION_PRIORITY SDL_LOG_PRIORITY_INFO -#define DEFAULT_TEST_PRIORITY SDL_LOG_PRIORITY_VERBOSE - -/* Forward definition of error function */ -extern int SDL_SetError(const char *fmt, ...); - -typedef struct SDL_LogLevel -{ - int category; - SDL_LogPriority priority; - struct SDL_LogLevel *next; -} SDL_LogLevel; - -/* The default log output function */ -static void SDL_LogOutput(void *userdata, - int category, SDL_LogPriority priority, - const char *message); - -static SDL_LogLevel *SDL_loglevels; -static SDL_LogPriority SDL_default_priority = DEFAULT_PRIORITY; -static SDL_LogPriority SDL_assert_priority = DEFAULT_ASSERT_PRIORITY; -static SDL_LogPriority SDL_application_priority = DEFAULT_APPLICATION_PRIORITY; -static SDL_LogPriority SDL_test_priority = DEFAULT_TEST_PRIORITY; -static SDL_LogOutputFunction SDL_log_function = SDL_LogOutput; -static void *SDL_log_userdata = NULL; - -static const char *SDL_priority_prefixes[SDL_NUM_LOG_PRIORITIES] = { - NULL, - "VERBOSE", - "DEBUG", - "INFO", - "WARN", - "ERROR", - "CRITICAL" -}; - -#ifdef __ANDROID__ -static const char *SDL_category_prefixes[SDL_LOG_CATEGORY_RESERVED1] = { - "APP", - "ERROR", - "SYSTEM", - "AUDIO", - "VIDEO", - "RENDER", - "INPUT" -}; - -static int SDL_android_priority[SDL_NUM_LOG_PRIORITIES] = { - ANDROID_LOG_VERBOSE, - ANDROID_LOG_DEBUG, - ANDROID_LOG_INFO, - ANDROID_LOG_WARN, - ANDROID_LOG_ERROR, - ANDROID_LOG_FATAL -}; -#endif /* __ANDROID__ */ - - -void -SDL_LogSetAllPriority(SDL_LogPriority priority) -{ - SDL_LogLevel *entry; - - for (entry = SDL_loglevels; entry; entry = entry->next) { - entry->priority = priority; - } - SDL_default_priority = priority; - SDL_assert_priority = priority; - SDL_application_priority = priority; -} - -void -SDL_LogSetPriority(int category, SDL_LogPriority priority) -{ - SDL_LogLevel *entry; - - for (entry = SDL_loglevels; entry; entry = entry->next) { - if (entry->category == category) { - entry->priority = priority; - return; - } - } - - /* Create a new entry */ - entry = (SDL_LogLevel *)SDL_malloc(sizeof(*entry)); - if (entry) { - entry->category = category; - entry->priority = priority; - entry->next = SDL_loglevels; - SDL_loglevels = entry; - } -} - -SDL_LogPriority -SDL_LogGetPriority(int category) -{ - SDL_LogLevel *entry; - - for (entry = SDL_loglevels; entry; entry = entry->next) { - if (entry->category == category) { - return entry->priority; - } - } - - if (category == SDL_LOG_CATEGORY_TEST) { - return SDL_test_priority; - } else if (category == SDL_LOG_CATEGORY_APPLICATION) { - return SDL_application_priority; - } else if (category == SDL_LOG_CATEGORY_ASSERT) { - return SDL_assert_priority; - } else { - return SDL_default_priority; - } -} - -void -SDL_LogResetPriorities(void) -{ - SDL_LogLevel *entry; - - while (SDL_loglevels) { - entry = SDL_loglevels; - SDL_loglevels = entry->next; - SDL_free(entry); - } - - SDL_default_priority = DEFAULT_PRIORITY; - SDL_assert_priority = DEFAULT_ASSERT_PRIORITY; - SDL_application_priority = DEFAULT_APPLICATION_PRIORITY; - SDL_test_priority = DEFAULT_TEST_PRIORITY; -} - -void -SDL_Log(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, fmt, ap); - va_end(ap); -} - -void -SDL_LogVerbose(int category, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - SDL_LogMessageV(category, SDL_LOG_PRIORITY_VERBOSE, fmt, ap); - va_end(ap); -} - -void -SDL_LogDebug(int category, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - SDL_LogMessageV(category, SDL_LOG_PRIORITY_DEBUG, fmt, ap); - va_end(ap); -} - -void -SDL_LogInfo(int category, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - SDL_LogMessageV(category, SDL_LOG_PRIORITY_INFO, fmt, ap); - va_end(ap); -} - -void -SDL_LogWarn(int category, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - SDL_LogMessageV(category, SDL_LOG_PRIORITY_WARN, fmt, ap); - va_end(ap); -} - -void -SDL_LogError(int category, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - SDL_LogMessageV(category, SDL_LOG_PRIORITY_ERROR, fmt, ap); - va_end(ap); -} - -void -SDL_LogCritical(int category, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - SDL_LogMessageV(category, SDL_LOG_PRIORITY_CRITICAL, fmt, ap); - va_end(ap); -} - -void -SDL_LogMessage(int category, SDL_LogPriority priority, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - SDL_LogMessageV(category, priority, fmt, ap); - va_end(ap); -} - -#ifdef __ANDROID__ -static const char * -GetCategoryPrefix(int category) -{ - if (category < SDL_LOG_CATEGORY_RESERVED1) { - return SDL_category_prefixes[category]; - } - if (category < SDL_LOG_CATEGORY_CUSTOM) { - return "RESERVED"; - } - return "CUSTOM"; -} -#endif /* __ANDROID__ */ - -void -SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list ap) -{ - char *message; - size_t len; - - /* Nothing to do if we don't have an output function */ - if (!SDL_log_function) { - return; - } - - /* Make sure we don't exceed array bounds */ - if ((int)priority < 0 || priority >= SDL_NUM_LOG_PRIORITIES) { - return; - } - - /* See if we want to do anything with this message */ - if (priority < SDL_LogGetPriority(category)) { - return; - } - - message = SDL_stack_alloc(char, SDL_MAX_LOG_MESSAGE); - if (!message) { - return; - } - - SDL_vsnprintf(message, SDL_MAX_LOG_MESSAGE, fmt, ap); - - /* Chop off final endline. */ - len = SDL_strlen(message); - if ((len > 0) && (message[len-1] == '\n')) { - message[--len] = '\0'; - if ((len > 0) && (message[len-1] == '\r')) { /* catch "\r\n", too. */ - message[--len] = '\0'; - } - } - - SDL_log_function(SDL_log_userdata, category, priority, message); - SDL_stack_free(message); -} - -#if defined(__WIN32__) -/* Flag tracking the attachment of the console: 0=unattached, 1=attached, -1=error */ -static int consoleAttached = 0; - -/* Handle to stderr output of console. */ -static HANDLE stderrHandle = NULL; -#endif - -static void -SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, - const char *message) -{ -#if defined(__WIN32__) || defined(__WINRT__) - /* Way too many allocations here, urgh */ - /* Note: One can't call SDL_SetError here, since that function itself logs. */ - { - char *output; - size_t length; - LPTSTR tstr; - -#ifndef __WINRT__ - BOOL attachResult; - DWORD attachError; - unsigned long charsWritten; - - /* Maybe attach console and get stderr handle */ - if (consoleAttached == 0) { - attachResult = AttachConsole(ATTACH_PARENT_PROCESS); - if (!attachResult) { - attachError = GetLastError(); - if (attachError == ERROR_INVALID_HANDLE) { - OutputDebugString(TEXT("Parent process has no console")); - consoleAttached = -1; - } else if (attachError == ERROR_GEN_FAILURE) { - OutputDebugString(TEXT("Could not attach to console of parent process")); - consoleAttached = -1; - } else if (attachError == ERROR_ACCESS_DENIED) { - /* Already attached */ - consoleAttached = 1; - } else { - OutputDebugString(TEXT("Error attaching console")); - consoleAttached = -1; - } - } else { - /* Newly attached */ - consoleAttached = 1; - } - - if (consoleAttached == 1) { - stderrHandle = GetStdHandle(STD_ERROR_HANDLE); - } - } -#endif /* ifndef __WINRT__ */ - - length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1 + 1; - output = SDL_stack_alloc(char, length); - SDL_snprintf(output, length, "%s: %s\n", SDL_priority_prefixes[priority], message); - tstr = WIN_UTF8ToString(output); - - /* Output to debugger */ - OutputDebugString(tstr); - -#ifndef __WINRT__ - /* Screen output to stderr, if console was attached. */ - if (consoleAttached == 1) { - if (!WriteConsole(stderrHandle, tstr, lstrlen(tstr), &charsWritten, NULL)) { - OutputDebugString(TEXT("Error calling WriteConsole")); - } - if (charsWritten == ERROR_NOT_ENOUGH_MEMORY) { - OutputDebugString(TEXT("Insufficient heap memory to write message")); - } - } -#endif /* ifndef __WINRT__ */ - - SDL_free(tstr); - SDL_stack_free(output); - } -#elif defined(__ANDROID__) - { - char tag[32]; - - SDL_snprintf(tag, SDL_arraysize(tag), "SDL/%s", GetCategoryPrefix(category)); - __android_log_write(SDL_android_priority[priority], tag, message); - } -#elif defined(__APPLE__) && defined(SDL_VIDEO_DRIVER_COCOA) - /* Technically we don't need SDL_VIDEO_DRIVER_COCOA, but that's where this function is defined for now. - */ - extern void SDL_NSLog(const char *text); - { - char *text; - - text = SDL_stack_alloc(char, SDL_MAX_LOG_MESSAGE); - if (text) { - SDL_snprintf(text, SDL_MAX_LOG_MESSAGE, "%s: %s", SDL_priority_prefixes[priority], message); - SDL_NSLog(text); - SDL_stack_free(text); - return; - } - } -#elif defined(__PSP__) - { - FILE* pFile; - pFile = fopen ("SDL_Log.txt", "a"); - fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message); - fclose (pFile); - } -#endif -#if HAVE_STDIO_H - fprintf(stderr, "%s: %s\n", SDL_priority_prefixes[priority], message); -#endif -} - -void -SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata) -{ - if (callback) { - *callback = SDL_log_function; - } - if (userdata) { - *userdata = SDL_log_userdata; - } -} - -void -SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata) -{ - SDL_log_function = callback; - SDL_log_userdata = userdata; -} - -/* vi: set ts=4 sw=4 expandtab: */ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ +#include "SDL_config.h" + +#if defined(__WIN32__) +#include "core/windows/SDL_windows.h" +#endif + +/* Simple log messages in SDL */ + +#include "SDL_log.h" + +#if HAVE_STDIO_H +#include +#endif + +#if defined(__ANDROID__) +#include +#endif + +#define DEFAULT_PRIORITY SDL_LOG_PRIORITY_CRITICAL +#define DEFAULT_ASSERT_PRIORITY SDL_LOG_PRIORITY_WARN +#define DEFAULT_APPLICATION_PRIORITY SDL_LOG_PRIORITY_INFO +#define DEFAULT_TEST_PRIORITY SDL_LOG_PRIORITY_VERBOSE + +/* Forward definition of error function */ +extern int SDL_SetError(const char *fmt, ...); + +typedef struct SDL_LogLevel +{ + int category; + SDL_LogPriority priority; + struct SDL_LogLevel *next; +} SDL_LogLevel; + +/* The default log output function */ +static void SDL_LogOutput(void *userdata, + int category, SDL_LogPriority priority, + const char *message); + +static SDL_LogLevel *SDL_loglevels; +static SDL_LogPriority SDL_default_priority = DEFAULT_PRIORITY; +static SDL_LogPriority SDL_assert_priority = DEFAULT_ASSERT_PRIORITY; +static SDL_LogPriority SDL_application_priority = DEFAULT_APPLICATION_PRIORITY; +static SDL_LogPriority SDL_test_priority = DEFAULT_TEST_PRIORITY; +static SDL_LogOutputFunction SDL_log_function = SDL_LogOutput; +static void *SDL_log_userdata = NULL; + +static const char *SDL_priority_prefixes[SDL_NUM_LOG_PRIORITIES] = { + NULL, + "VERBOSE", + "DEBUG", + "INFO", + "WARN", + "ERROR", + "CRITICAL" +}; + +#ifdef __ANDROID__ +static const char *SDL_category_prefixes[SDL_LOG_CATEGORY_RESERVED1] = { + "APP", + "ERROR", + "SYSTEM", + "AUDIO", + "VIDEO", + "RENDER", + "INPUT" +}; + +static int SDL_android_priority[SDL_NUM_LOG_PRIORITIES] = { + ANDROID_LOG_UNKNOWN, + ANDROID_LOG_VERBOSE, + ANDROID_LOG_DEBUG, + ANDROID_LOG_INFO, + ANDROID_LOG_WARN, + ANDROID_LOG_ERROR, + ANDROID_LOG_FATAL +}; +#endif /* __ANDROID__ */ + + +void +SDL_LogSetAllPriority(SDL_LogPriority priority) +{ + SDL_LogLevel *entry; + + for (entry = SDL_loglevels; entry; entry = entry->next) { + entry->priority = priority; + } + SDL_default_priority = priority; + SDL_assert_priority = priority; + SDL_application_priority = priority; +} + +void +SDL_LogSetPriority(int category, SDL_LogPriority priority) +{ + SDL_LogLevel *entry; + + for (entry = SDL_loglevels; entry; entry = entry->next) { + if (entry->category == category) { + entry->priority = priority; + return; + } + } + + /* Create a new entry */ + entry = (SDL_LogLevel *)SDL_malloc(sizeof(*entry)); + if (entry) { + entry->category = category; + entry->priority = priority; + entry->next = SDL_loglevels; + SDL_loglevels = entry; + } +} + +SDL_LogPriority +SDL_LogGetPriority(int category) +{ + SDL_LogLevel *entry; + + for (entry = SDL_loglevels; entry; entry = entry->next) { + if (entry->category == category) { + return entry->priority; + } + } + + if (category == SDL_LOG_CATEGORY_TEST) { + return SDL_test_priority; + } else if (category == SDL_LOG_CATEGORY_APPLICATION) { + return SDL_application_priority; + } else if (category == SDL_LOG_CATEGORY_ASSERT) { + return SDL_assert_priority; + } else { + return SDL_default_priority; + } +} + +void +SDL_LogResetPriorities(void) +{ + SDL_LogLevel *entry; + + while (SDL_loglevels) { + entry = SDL_loglevels; + SDL_loglevels = entry->next; + SDL_free(entry); + } + + SDL_default_priority = DEFAULT_PRIORITY; + SDL_assert_priority = DEFAULT_ASSERT_PRIORITY; + SDL_application_priority = DEFAULT_APPLICATION_PRIORITY; + SDL_test_priority = DEFAULT_TEST_PRIORITY; +} + +void +SDL_Log(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, fmt, ap); + va_end(ap); +} + +void +SDL_LogVerbose(int category, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + SDL_LogMessageV(category, SDL_LOG_PRIORITY_VERBOSE, fmt, ap); + va_end(ap); +} + +void +SDL_LogDebug(int category, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + SDL_LogMessageV(category, SDL_LOG_PRIORITY_DEBUG, fmt, ap); + va_end(ap); +} + +void +SDL_LogInfo(int category, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + SDL_LogMessageV(category, SDL_LOG_PRIORITY_INFO, fmt, ap); + va_end(ap); +} + +void +SDL_LogWarn(int category, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + SDL_LogMessageV(category, SDL_LOG_PRIORITY_WARN, fmt, ap); + va_end(ap); +} + +void +SDL_LogError(int category, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + SDL_LogMessageV(category, SDL_LOG_PRIORITY_ERROR, fmt, ap); + va_end(ap); +} + +void +SDL_LogCritical(int category, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + SDL_LogMessageV(category, SDL_LOG_PRIORITY_CRITICAL, fmt, ap); + va_end(ap); +} + +void +SDL_LogMessage(int category, SDL_LogPriority priority, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + SDL_LogMessageV(category, priority, fmt, ap); + va_end(ap); +} + +#ifdef __ANDROID__ +static const char * +GetCategoryPrefix(int category) +{ + if (category < SDL_LOG_CATEGORY_RESERVED1) { + return SDL_category_prefixes[category]; + } + if (category < SDL_LOG_CATEGORY_CUSTOM) { + return "RESERVED"; + } + return "CUSTOM"; +} +#endif /* __ANDROID__ */ + +void +SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list ap) +{ + char *message; + size_t len; + + /* Nothing to do if we don't have an output function */ + if (!SDL_log_function) { + return; + } + + /* Make sure we don't exceed array bounds */ + if ((int)priority < 0 || priority >= SDL_NUM_LOG_PRIORITIES) { + return; + } + + /* See if we want to do anything with this message */ + if (priority < SDL_LogGetPriority(category)) { + return; + } + + message = SDL_stack_alloc(char, SDL_MAX_LOG_MESSAGE); + if (!message) { + return; + } + + SDL_vsnprintf(message, SDL_MAX_LOG_MESSAGE, fmt, ap); + + /* Chop off final endline. */ + len = SDL_strlen(message); + if ((len > 0) && (message[len-1] == '\n')) { + message[--len] = '\0'; + if ((len > 0) && (message[len-1] == '\r')) { /* catch "\r\n", too. */ + message[--len] = '\0'; + } + } + + SDL_log_function(SDL_log_userdata, category, priority, message); + SDL_stack_free(message); +} + +#if defined(__WIN32__) +/* Flag tracking the attachment of the console: 0=unattached, 1=attached, -1=error */ +static int consoleAttached = 0; + +/* Handle to stderr output of console. */ +static HANDLE stderrHandle = NULL; +#endif + +static void +SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, + const char *message) +{ +#if defined(__WIN32__) || defined(__WINRT__) + /* Way too many allocations here, urgh */ + /* Note: One can't call SDL_SetError here, since that function itself logs. */ + { + char *output; + size_t length; + LPTSTR tstr; + +#ifndef __WINRT__ + BOOL attachResult; + DWORD attachError; + unsigned long charsWritten; + + /* Maybe attach console and get stderr handle */ + if (consoleAttached == 0) { + attachResult = AttachConsole(ATTACH_PARENT_PROCESS); + if (!attachResult) { + attachError = GetLastError(); + if (attachError == ERROR_INVALID_HANDLE) { + OutputDebugString(TEXT("Parent process has no console\r\n")); + consoleAttached = -1; + } else if (attachError == ERROR_GEN_FAILURE) { + OutputDebugString(TEXT("Could not attach to console of parent process\r\n")); + consoleAttached = -1; + } else if (attachError == ERROR_ACCESS_DENIED) { + /* Already attached */ + consoleAttached = 1; + } else { + OutputDebugString(TEXT("Error attaching console\r\n")); + consoleAttached = -1; + } + } else { + /* Newly attached */ + consoleAttached = 1; + } + + if (consoleAttached == 1) { + stderrHandle = GetStdHandle(STD_ERROR_HANDLE); + } + } +#endif /* ifndef __WINRT__ */ + + length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1 + 1 + 1; + output = SDL_stack_alloc(char, length); + SDL_snprintf(output, length, "%s: %s\r\n", SDL_priority_prefixes[priority], message); + tstr = WIN_UTF8ToString(output); + + /* Output to debugger */ + OutputDebugString(tstr); + +#ifndef __WINRT__ + /* Screen output to stderr, if console was attached. */ + if (consoleAttached == 1) { + if (!WriteConsole(stderrHandle, tstr, lstrlen(tstr), &charsWritten, NULL)) { + OutputDebugString(TEXT("Error calling WriteConsole\r\n")); + } + if (charsWritten == ERROR_NOT_ENOUGH_MEMORY) { + OutputDebugString(TEXT("Insufficient heap memory to write message\r\n")); + } + } +#endif /* ifndef __WINRT__ */ + + SDL_free(tstr); + SDL_stack_free(output); + } +#elif defined(__ANDROID__) + { + char tag[32]; + + SDL_snprintf(tag, SDL_arraysize(tag), "SDL/%s", GetCategoryPrefix(category)); + __android_log_write(SDL_android_priority[priority], tag, message); + } +#elif defined(__APPLE__) && defined(SDL_VIDEO_DRIVER_COCOA) + /* Technically we don't need SDL_VIDEO_DRIVER_COCOA, but that's where this function is defined for now. + */ + extern void SDL_NSLog(const char *text); + { + char *text; + + text = SDL_stack_alloc(char, SDL_MAX_LOG_MESSAGE); + if (text) { + SDL_snprintf(text, SDL_MAX_LOG_MESSAGE, "%s: %s", SDL_priority_prefixes[priority], message); + SDL_NSLog(text); + SDL_stack_free(text); + return; + } + } +#elif defined(__PSP__) + { + FILE* pFile; + pFile = fopen ("SDL_Log.txt", "a"); + fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message); + fclose (pFile); + } +#endif +#if HAVE_STDIO_H + fprintf(stderr, "%s: %s\n", SDL_priority_prefixes[priority], message); +#endif +} + +void +SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata) +{ + if (callback) { + *callback = SDL_log_function; + } + if (userdata) { + *userdata = SDL_log_userdata; + } +} + +void +SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata) +{ + SDL_log_function = callback; + SDL_log_userdata = userdata; +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/atomic/SDL_atomic.c b/src/atomic/SDL_atomic.c index c747b12aa..e9b636f30 100644 --- a/src/atomic/SDL_atomic.c +++ b/src/atomic/SDL_atomic.c @@ -55,7 +55,7 @@ static SDL_SpinLock locks[32]; -static __inline__ void +static SDL_INLINE void enterLock(void *a) { uintptr_t index = ((((uintptr_t)a) >> 3) & 0x1f); @@ -63,7 +63,7 @@ enterLock(void *a) SDL_AtomicLock(&locks[index]); } -static __inline__ void +static SDL_INLINE void leaveLock(void *a) { uintptr_t index = ((((uintptr_t)a) >> 3) & 0x1f); diff --git a/src/atomic/SDL_spinlock.c b/src/atomic/SDL_spinlock.c index f90528c35..ac9b61e87 100644 --- a/src/atomic/SDL_spinlock.c +++ b/src/atomic/SDL_spinlock.c @@ -1,126 +1,126 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - 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. -*/ -#include "SDL_config.h" - -#include "SDL_atomic.h" -#include "SDL_mutex.h" -#include "SDL_timer.h" - -/* Don't do the check for Visual Studio 2005, it's safe here */ -#if defined(__WIN32__) || defined(__WINRT__) -#include "../core/windows/SDL_windows.h" -#endif - -/* This function is where all the magic happens... */ -SDL_bool -SDL_AtomicTryLock(SDL_SpinLock *lock) -{ -#if SDL_ATOMIC_DISABLED - /* Terrible terrible damage */ - static SDL_mutex *_spinlock_mutex; - - if (!_spinlock_mutex) { - /* Race condition on first lock... */ - _spinlock_mutex = SDL_CreateMutex(); - } - SDL_LockMutex(_spinlock_mutex); - if (*lock == 0) { - *lock = 1; - SDL_UnlockMutex(_spinlock_mutex); - return SDL_TRUE; - } else { - SDL_UnlockMutex(_spinlock_mutex); - return SDL_FALSE; - } - -#elif defined(_MSC_VER) - SDL_COMPILE_TIME_ASSERT(locksize, sizeof(*lock) == sizeof(long)); - return (InterlockedExchange((long*)lock, 1) == 0); - -#elif HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET - return (__sync_lock_test_and_set(lock, 1) == 0); - -#elif defined(__GNUC__) && defined(__arm__) && \ - (defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__) || \ - defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5TE__) || \ - defined(__ARM_ARCH_5TEJ__)) - int result; - __asm__ __volatile__ ( - "swp %0, %1, [%2]\n" - : "=&r,&r" (result) : "r,0" (1), "r,r" (lock) : "memory"); - return (result == 0); - -#elif defined(__GNUC__) && defined(__arm__) - int result; - __asm__ __volatile__ ( - "ldrex %0, [%2]\nteq %0, #0\nstrexeq %0, %1, [%2]" - : "=&r" (result) : "r" (1), "r" (lock) : "cc", "memory"); - return (result == 0); - -#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) - int result; - __asm__ __volatile__( - "lock ; xchgl %0, (%1)\n" - : "=r" (result) : "r" (lock), "0" (1) : "cc", "memory"); - return (result == 0); - -#elif defined(__MACOSX__) || defined(__IPHONEOS__) - /* Maybe used for PowerPC, but the Intel asm or gcc atomics are favored. */ - return OSAtomicCompareAndSwap32Barrier(0, 1, lock); - -#elif HAVE_PTHREAD_SPINLOCK - /* pthread instructions */ - return (pthread_spin_trylock(lock) == 0); - -#else -#error Please implement for your platform. - return SDL_FALSE; -#endif -} - -void -SDL_AtomicLock(SDL_SpinLock *lock) -{ - /* FIXME: Should we have an eventual timeout? */ - while (!SDL_AtomicTryLock(lock)) { - SDL_Delay(0); - } -} - -void -SDL_AtomicUnlock(SDL_SpinLock *lock) -{ -#if defined(_MSC_VER) - _ReadWriteBarrier(); - *lock = 0; - -#elif HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET - __sync_lock_release(lock); - -#elif HAVE_PTHREAD_SPINLOCK - pthread_spin_unlock(lock); - -#else - *lock = 0; -#endif -} - -/* vi: set ts=4 sw=4 expandtab: */ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ +#include "SDL_config.h" + +#ifdef __WIN32__ +#include "../core/windows/SDL_windows.h" +#endif + +#include "SDL_atomic.h" +#include "SDL_mutex.h" +#include "SDL_timer.h" + + +/* This function is where all the magic happens... */ +SDL_bool +SDL_AtomicTryLock(SDL_SpinLock *lock) +{ +#if SDL_ATOMIC_DISABLED + /* Terrible terrible damage */ + static SDL_mutex *_spinlock_mutex; + + if (!_spinlock_mutex) { + /* Race condition on first lock... */ + _spinlock_mutex = SDL_CreateMutex(); + } + SDL_LockMutex(_spinlock_mutex); + if (*lock == 0) { + *lock = 1; + SDL_UnlockMutex(_spinlock_mutex); + return SDL_TRUE; + } else { + SDL_UnlockMutex(_spinlock_mutex); + return SDL_FALSE; + } + +#elif defined(_MSC_VER) + SDL_COMPILE_TIME_ASSERT(locksize, sizeof(*lock) == sizeof(long)); + return (InterlockedExchange((long*)lock, 1) == 0); + +#elif HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET + return (__sync_lock_test_and_set(lock, 1) == 0); + +#elif defined(__GNUC__) && defined(__arm__) && \ + (defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__) || \ + defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5TE__) || \ + defined(__ARM_ARCH_5TEJ__)) + int result; + __asm__ __volatile__ ( + "swp %0, %1, [%2]\n" + : "=&r,&r" (result) : "r,0" (1), "r,r" (lock) : "memory"); + return (result == 0); + +#elif defined(__GNUC__) && defined(__arm__) + int result; + __asm__ __volatile__ ( + "ldrex %0, [%2]\nteq %0, #0\nstrexeq %0, %1, [%2]" + : "=&r" (result) : "r" (1), "r" (lock) : "cc", "memory"); + return (result == 0); + +#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) + int result; + __asm__ __volatile__( + "lock ; xchgl %0, (%1)\n" + : "=r" (result) : "r" (lock), "0" (1) : "cc", "memory"); + return (result == 0); + +#elif defined(__MACOSX__) || defined(__IPHONEOS__) + /* Maybe used for PowerPC, but the Intel asm or gcc atomics are favored. */ + return OSAtomicCompareAndSwap32Barrier(0, 1, lock); + +#elif HAVE_PTHREAD_SPINLOCK + /* pthread instructions */ + return (pthread_spin_trylock(lock) == 0); + +#else +#error Please implement for your platform. + return SDL_FALSE; +#endif +} + +void +SDL_AtomicLock(SDL_SpinLock *lock) +{ + /* FIXME: Should we have an eventual timeout? */ + while (!SDL_AtomicTryLock(lock)) { + SDL_Delay(0); + } +} + +void +SDL_AtomicUnlock(SDL_SpinLock *lock) +{ +#if defined(_MSC_VER) + _ReadWriteBarrier(); + *lock = 0; + +#elif HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET + __sync_lock_release(lock); + +#elif HAVE_PTHREAD_SPINLOCK + pthread_spin_unlock(lock); + +#else + *lock = 0; +#endif +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index 4d53e82b1..5631bb2fd 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -300,9 +300,7 @@ SDL_StreamInit(SDL_AudioStreamer * stream, int max_len, Uint8 silence) static void SDL_StreamDeinit(SDL_AudioStreamer * stream) { - if (stream->buffer != NULL) { - SDL_free(stream->buffer); - } + SDL_free(stream->buffer); } #if defined(ANDROID) @@ -419,7 +417,7 @@ SDL_RunAudio(void *devicep) if (istream == NULL) { istream = device->fake_stream; } - /*SDL_memcpy(istream, device->convert.buf, device->convert.len_cvt); */ + /* SDL_memcpy(istream, device->convert.buf, device->convert.len_cvt); */ SDL_StreamWrite(&device->streamer, device->convert.buf, device->convert.len_cvt); } else { @@ -632,9 +630,7 @@ free_device_list(char ***devices, int *devCount) } } - if (*devices != NULL) { - SDL_free(*devices); - } + SDL_free(*devices); *devices = NULL; *devCount = 0; @@ -761,9 +757,7 @@ close_audio_device(SDL_AudioDevice * device) if (device->mixer_lock != NULL) { SDL_DestroyMutex(device->mixer_lock); } - if (device->fake_stream != NULL) { - SDL_FreeAudioMem(device->fake_stream); - } + SDL_FreeAudioMem(device->fake_stream); if (device->convert.needed) { SDL_FreeAudioMem(device->convert.buf); } diff --git a/src/audio/SDL_audiodev.c b/src/audio/SDL_audiodev.c index 91b60c376..af45a8b90 100644 --- a/src/audio/SDL_audiodev.c +++ b/src/audio/SDL_audiodev.c @@ -46,7 +46,7 @@ #define _PATH_DEV_AUDIO "/dev/audio" #endif -static inline void +static SDL_INLINE void test_device(const char *fname, int flags, int (*test) (int fd), SDL_AddAudioDevice addfn) { diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c index 18fdcacd3..fac24cb3b 100644 --- a/src/audio/SDL_wave.c +++ b/src/audio/SDL_wave.c @@ -61,7 +61,7 @@ InitMS_ADPCM(WaveFMT * format) SDL_SwapLE16(format->bitspersample); rogue_feel = (Uint8 *) format + sizeof(*format); if (sizeof(*format) == 16) { - /*const Uint16 extra_info = ((rogue_feel[1] << 8) | rogue_feel[0]);*/ + /* const Uint16 extra_info = ((rogue_feel[1] << 8) | rogue_feel[0]); */ rogue_feel += sizeof(Uint16); } MS_ADPCM_state.wSamplesPerBlock = ((rogue_feel[1] << 8) | rogue_feel[0]); @@ -242,7 +242,7 @@ InitIMA_ADPCM(WaveFMT * format) SDL_SwapLE16(format->bitspersample); rogue_feel = (Uint8 *) format + sizeof(*format); if (sizeof(*format) == 16) { - /*const Uint16 extra_info = ((rogue_feel[1] << 8) | rogue_feel[0]);*/ + /* const Uint16 extra_info = ((rogue_feel[1] << 8) | rogue_feel[0]); */ rogue_feel += sizeof(Uint16); } IMA_ADPCM_state.wSamplesPerBlock = ((rogue_feel[1] << 8) | rogue_feel[0]); @@ -449,10 +449,8 @@ SDL_LoadWAV_RW(SDL_RWops * src, int freesrc, /* Read the audio data format chunk */ chunk.data = NULL; do { - if (chunk.data != NULL) { - SDL_free(chunk.data); - chunk.data = NULL; - } + SDL_free(chunk.data); + chunk.data = NULL; lenread = ReadChunk(src, &chunk); if (lenread < 0) { was_error = 1; @@ -549,10 +547,8 @@ SDL_LoadWAV_RW(SDL_RWops * src, int freesrc, /* Read the audio data chunk */ *audio_buf = NULL; do { - if (*audio_buf != NULL) { - SDL_free(*audio_buf); - *audio_buf = NULL; - } + SDL_free(*audio_buf); + *audio_buf = NULL; lenread = ReadChunk(src, &chunk); if (lenread < 0) { was_error = 1; @@ -583,9 +579,7 @@ SDL_LoadWAV_RW(SDL_RWops * src, int freesrc, *audio_len &= ~(samplesize - 1); done: - if (format != NULL) { - SDL_free(format); - } + SDL_free(format); if (src) { if (freesrc) { SDL_RWclose(src); @@ -606,9 +600,7 @@ SDL_LoadWAV_RW(SDL_RWops * src, int freesrc, void SDL_FreeWAV(Uint8 * audio_buf) { - if (audio_buf != NULL) { - SDL_free(audio_buf); - } + SDL_free(audio_buf); } static int diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index 13cc77bf6..5ff4cef4c 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -241,25 +241,25 @@ ALSA_WaitDevice(_THIS) tmp = ptr[3]; ptr[3] = ptr[5]; ptr[5] = tmp; \ } -static __inline__ void +static SDL_INLINE void swizzle_alsa_channels_6_64bit(_THIS) { SWIZ6(Uint64); } -static __inline__ void +static SDL_INLINE void swizzle_alsa_channels_6_32bit(_THIS) { SWIZ6(Uint32); } -static __inline__ void +static SDL_INLINE void swizzle_alsa_channels_6_16bit(_THIS) { SWIZ6(Uint16); } -static __inline__ void +static SDL_INLINE void swizzle_alsa_channels_6_8bit(_THIS) { SWIZ6(Uint8); @@ -272,7 +272,7 @@ swizzle_alsa_channels_6_8bit(_THIS) * Called right before feeding this->hidden->mixbuf to the hardware. Swizzle * channels from Windows/Mac order to the format alsalib will want. */ -static __inline__ void +static SDL_INLINE void swizzle_alsa_channels(_THIS) { if (this->spec.channels == 6) { @@ -304,7 +304,7 @@ ALSA_PlayDevice(_THIS) while ( frames_left > 0 && this->enabled ) { /* !!! FIXME: This works, but needs more testing before going live */ - /*ALSA_snd_pcm_wait(this->hidden->pcm_handle, -1);*/ + /* ALSA_snd_pcm_wait(this->hidden->pcm_handle, -1); */ status = ALSA_snd_pcm_writei(this->hidden->pcm_handle, sample_buf, frames_left); @@ -340,10 +340,8 @@ static void ALSA_CloseDevice(_THIS) { if (this->hidden != NULL) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; if (this->hidden->pcm_handle) { ALSA_snd_pcm_drain(this->hidden->pcm_handle); ALSA_snd_pcm_close(this->hidden->pcm_handle); diff --git a/src/audio/arts/SDL_artsaudio.c b/src/audio/arts/SDL_artsaudio.c index ac0bb9d5d..7e835c18a 100644 --- a/src/audio/arts/SDL_artsaudio.c +++ b/src/audio/arts/SDL_artsaudio.c @@ -204,10 +204,8 @@ static void ARTS_CloseDevice(_THIS) { if (this->hidden != NULL) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; if (this->hidden->stream) { SDL_NAME(arts_close_stream) (this->hidden->stream); this->hidden->stream = 0; @@ -222,7 +220,7 @@ static int ARTS_Suspend(void) { const Uint32 abortms = SDL_GetTicks() + 3000; /* give up after 3 secs */ - while ( (!SDL_NAME(arts_suspended)()) && (SDL_GetTicks() < abortms) ) { + while ( (!SDL_NAME(arts_suspended)()) && !SDL_TICKS_PASSED(SDL_GetTicks(), abortms) ) { if ( SDL_NAME(arts_suspend)() ) { break; } diff --git a/src/audio/bsd/SDL_bsdaudio.c b/src/audio/bsd/SDL_bsdaudio.c index b63c838ad..6694683bd 100644 --- a/src/audio/bsd/SDL_bsdaudio.c +++ b/src/audio/bsd/SDL_bsdaudio.c @@ -125,9 +125,7 @@ BSDAUDIO_WaitDevice(_THIS) /* Use timer for general audio synchronization */ Sint32 ticks; - ticks = - ((Sint32) (this->hidden->next_frame - SDL_GetTicks())) - - FUDGE_TICKS; + ticks = ((Sint32) (this->hidden->next_frame - SDL_GetTicks())) - FUDGE_TICKS; if (ticks > 0) { SDL_Delay(ticks); } @@ -214,10 +212,8 @@ static void BSDAUDIO_CloseDevice(_THIS) { if (this->hidden != NULL) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; if (this->hidden->audio_fd >= 0) { close(this->hidden->audio_fd); this->hidden->audio_fd = -1; diff --git a/src/audio/directsound/SDL_directsound.c b/src/audio/directsound/SDL_directsound.c index 686d46615..86563a62e 100644 --- a/src/audio/directsound/SDL_directsound.c +++ b/src/audio/directsound/SDL_directsound.c @@ -91,14 +91,6 @@ DSOUND_Load(void) return loaded; } -static __inline__ char * -utf16_to_utf8(const WCHAR *S) -{ - /* !!! FIXME: this should be UTF-16, not UCS-2! */ - return SDL_iconv_string("UTF-8", "UCS-2", (char *)(S), - (SDL_wcslen(S)+1)*sizeof(WCHAR)); -} - static int SetDSerror(const char *function, int code) { @@ -158,7 +150,7 @@ FindAllDevs(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID data) { SDL_AddAudioDevice addfn = (SDL_AddAudioDevice) data; if (guid != NULL) { /* skip default device */ - char *str = utf16_to_utf8(desc); + char *str = WIN_StringToUTF8(desc); if (str != NULL) { addfn(str); SDL_free(str); /* addfn() makes a copy of this string. */ @@ -439,7 +431,7 @@ FindDevGUID(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID _data) { if (guid != NULL) { /* skip the default device. */ FindDevGUIDData *data = (FindDevGUIDData *) _data; - char *str = utf16_to_utf8(desc); + char *str = WIN_StringToUTF8(desc); const int match = (SDL_strcmp(str, data->devname) == 0); SDL_free(str); if (match) { @@ -510,7 +502,7 @@ DSOUND_OpenDevice(_THIS, const char *devname, int iscapture) if (!valid_format) { DSOUND_CloseDevice(this); if (tried_format) { - return -1; // CreateSecondary() should have called SDL_SetError(). + return -1; /* CreateSecondary() should have called SDL_SetError(). */ } return SDL_SetError("DirectSound: Unsupported audio format"); } diff --git a/src/audio/disk/SDL_diskaudio.c b/src/audio/disk/SDL_diskaudio.c index 2286ba095..0dc650e12 100644 --- a/src/audio/disk/SDL_diskaudio.c +++ b/src/audio/disk/SDL_diskaudio.c @@ -88,10 +88,8 @@ static void DISKAUD_CloseDevice(_THIS) { if (this->hidden != NULL) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; if (this->hidden->output != NULL) { SDL_RWclose(this->hidden->output); this->hidden->output = NULL; diff --git a/src/audio/dsp/SDL_dspaudio.c b/src/audio/dsp/SDL_dspaudio.c index c62a22f8a..e3190170d 100644 --- a/src/audio/dsp/SDL_dspaudio.c +++ b/src/audio/dsp/SDL_dspaudio.c @@ -61,10 +61,8 @@ static void DSP_CloseDevice(_THIS) { if (this->hidden != NULL) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; if (this->hidden->audio_fd >= 0) { close(this->hidden->audio_fd); this->hidden->audio_fd = -1; diff --git a/src/audio/esd/SDL_esdaudio.c b/src/audio/esd/SDL_esdaudio.c index 92716f39b..8bba64098 100644 --- a/src/audio/esd/SDL_esdaudio.c +++ b/src/audio/esd/SDL_esdaudio.c @@ -135,8 +135,7 @@ ESD_WaitDevice(_THIS) } /* Use timer for general audio synchronization */ - ticks = - ((Sint32) (this->hidden->next_frame - SDL_GetTicks())) - FUDGE_TICKS; + ticks = ((Sint32) (this->hidden->next_frame - SDL_GetTicks())) - FUDGE_TICKS; if (ticks > 0) { SDL_Delay(ticks); } @@ -176,10 +175,8 @@ static void ESD_CloseDevice(_THIS) { if (this->hidden != NULL) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; if (this->hidden->audio_fd >= 0) { SDL_NAME(esd_close) (this->hidden->audio_fd); this->hidden->audio_fd = -1; diff --git a/src/audio/fusionsound/SDL_fsaudio.c b/src/audio/fusionsound/SDL_fsaudio.c index 2e468d5c6..49ad2c163 100644 --- a/src/audio/fusionsound/SDL_fsaudio.c +++ b/src/audio/fusionsound/SDL_fsaudio.c @@ -169,10 +169,8 @@ static void SDL_FS_CloseDevice(_THIS) { if (this->hidden != NULL) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; if (this->hidden->stream) { this->hidden->stream->Release(this->hidden->stream); this->hidden->stream = NULL; diff --git a/src/audio/nas/SDL_nasaudio.c b/src/audio/nas/SDL_nasaudio.c index 4e3dc0a13..c2bf67745 100644 --- a/src/audio/nas/SDL_nasaudio.c +++ b/src/audio/nas/SDL_nasaudio.c @@ -191,10 +191,8 @@ static void NAS_CloseDevice(_THIS) { if (this->hidden != NULL) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; if (this->hidden->aud) { NAS_AuCloseServer(this->hidden->aud); this->hidden->aud = 0; diff --git a/src/audio/paudio/SDL_paudio.c b/src/audio/paudio/SDL_paudio.c index 5a18b45e5..8a248af4e 100644 --- a/src/audio/paudio/SDL_paudio.c +++ b/src/audio/paudio/SDL_paudio.c @@ -133,9 +133,7 @@ PAUDIO_WaitDevice(_THIS) /* Use timer for general audio synchronization */ Sint32 ticks; - ticks = - ((Sint32) (this->hidden->next_frame - SDL_GetTicks())) - - FUDGE_TICKS; + ticks = ((Sint32) (this->hidden->next_frame - SDL_GetTicks())) - FUDGE_TICKS; if (ticks > 0) { SDL_Delay(ticks); } @@ -231,10 +229,8 @@ static void PAUDIO_CloseDevice(_THIS) { if (this->hidden != NULL) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; if (this->hidden->audio_fd >= 0) { close(this->hidden->audio_fd); this->hidden->audio_fd = -1; diff --git a/src/audio/psp/SDL_pspaudio.c b/src/audio/psp/SDL_pspaudio.c index 4b5534a3c..8576d95e1 100644 --- a/src/audio/psp/SDL_pspaudio.c +++ b/src/audio/psp/SDL_pspaudio.c @@ -63,7 +63,7 @@ PSPAUD_OpenDevice(_THIS, const char *devname, int iscapture) this->spec.freq = 44100; /* Update the fragment size as size in bytes. */ -// SDL_CalculateAudioSpec(this->spec); MOD +/* SDL_CalculateAudioSpec(this->spec); MOD */ switch (this->spec.format) { case AUDIO_U8: this->spec.silence = 0x80; @@ -76,7 +76,7 @@ PSPAUD_OpenDevice(_THIS, const char *devname, int iscapture) this->spec.size *= this->spec.channels; this->spec.size *= this->spec.samples; -//========================================== +/* ========================================== */ /* Allocate the mixing buffer. Its size and starting address must be a multiple of 64 bytes. Our sample count is already a multiple of @@ -162,7 +162,7 @@ static int PSPAUD_Init(SDL_AudioDriverImpl * impl) { - // Set the function pointers + /* Set the function pointers */ impl->OpenDevice = PSPAUD_OpenDevice; impl->PlayDevice = PSPAUD_PlayDevice; impl->WaitDevice = PSPAUD_WaitDevice; @@ -171,7 +171,7 @@ PSPAUD_Init(SDL_AudioDriverImpl * impl) impl->CloseDevice = PSPAUD_CloseDevice; impl->ThreadInit = PSPAUD_ThreadInit; - //PSP audio device + /* PSP audio device */ impl->OnlyHasDefaultOutputDevice = 1; /* impl->HasCaptureSupport = 1; @@ -189,7 +189,7 @@ AudioBootStrap PSPAUD_bootstrap = { "psp", "PSP audio driver", PSPAUD_Init, 0 }; - /* SDL_AUDI*/ + /* SDL_AUDI */ diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c index 46269d177..5923eaecc 100644 --- a/src/audio/pulseaudio/SDL_pulseaudio.c +++ b/src/audio/pulseaudio/SDL_pulseaudio.c @@ -49,7 +49,7 @@ #if (PA_API_VERSION < 12) /** Return non-zero if the passed state is one of the connected states */ -static __inline__ int PA_CONTEXT_IS_GOOD(pa_context_state_t x) { +static SDL_INLINE int PA_CONTEXT_IS_GOOD(pa_context_state_t x) { return x == PA_CONTEXT_CONNECTING || x == PA_CONTEXT_AUTHORIZING || @@ -57,7 +57,7 @@ static __inline__ int PA_CONTEXT_IS_GOOD(pa_context_state_t x) { x == PA_CONTEXT_READY; } /** Return non-zero if the passed state is one of the connected states */ -static __inline__ int PA_STREAM_IS_GOOD(pa_stream_state_t x) { +static SDL_INLINE int PA_STREAM_IS_GOOD(pa_stream_state_t x) { return x == PA_STREAM_CREATING || x == PA_STREAM_READY; @@ -300,10 +300,8 @@ static void PULSEAUDIO_CloseDevice(_THIS) { if (this->hidden != NULL) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; if (this->hidden->stream) { PULSEAUDIO_pa_stream_disconnect(this->hidden->stream); PULSEAUDIO_pa_stream_unref(this->hidden->stream); @@ -324,7 +322,7 @@ PULSEAUDIO_CloseDevice(_THIS) } -static __inline__ int +static SDL_INLINE int squashVersion(const int major, const int minor, const int patch) { return ((major & 0xFF) << 16) | ((minor & 0xFF) << 8) | (patch & 0xFF); diff --git a/src/audio/qsa/SDL_qsa_audio.c b/src/audio/qsa/SDL_qsa_audio.c index e3877b463..78f69c0d8 100644 --- a/src/audio/qsa/SDL_qsa_audio.c +++ b/src/audio/qsa/SDL_qsa_audio.c @@ -83,7 +83,7 @@ uint32_t qsa_playback_devices; QSA_Device qsa_capture_device[QSA_MAX_DEVICES]; uint32_t qsa_capture_devices; -static inline int +static SDL_INLINE int QSA_SetError(const char *fn, int status) { return SDL_SetError("QSA: %s() failed: %s", fn, snd_strerror(status)); @@ -328,10 +328,8 @@ QSA_CloseDevice(_THIS) this->hidden->audio_handle = NULL; } - if (this->hidden->pcm_buf != NULL) { - SDL_FreeAudioMem(this->hidden->pcm_buf); - this->hidden->pcm_buf = NULL; - } + SDL_FreeAudioMem(this->hidden->pcm_buf); + this->hidden->pcm_buf = NULL; SDL_free(this->hidden); this->hidden = NULL; diff --git a/src/audio/sndio/SDL_sndioaudio.c b/src/audio/sndio/SDL_sndioaudio.c index 16d0ec356..309472da0 100644 --- a/src/audio/sndio/SDL_sndioaudio.c +++ b/src/audio/sndio/SDL_sndioaudio.c @@ -181,10 +181,8 @@ static void SNDIO_CloseDevice(_THIS) { if (this->hidden != NULL) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; if ( this->hidden->dev != NULL ) { SNDIO_sio_close(this->hidden->dev); this->hidden->dev = NULL; diff --git a/src/audio/sun/SDL_sunaudio.c b/src/audio/sun/SDL_sunaudio.c index 950ba444c..98acf4446 100644 --- a/src/audio/sun/SDL_sunaudio.c +++ b/src/audio/sun/SDL_sunaudio.c @@ -184,14 +184,10 @@ static void SUNAUDIO_CloseDevice(_THIS) { if (this->hidden != NULL) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } - if (this->hidden->ulaw_buf != NULL) { - SDL_free(this->hidden->ulaw_buf); - this->hidden->ulaw_buf = NULL; - } + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; + SDL_free(this->hidden->ulaw_buf); + this->hidden->ulaw_buf = NULL; if (this->hidden->audio_fd >= 0) { close(this->hidden->audio_fd); this->hidden->audio_fd = -1; diff --git a/src/audio/winmm/SDL_winmm.c b/src/audio/winmm/SDL_winmm.c index 9c8da7ae2..4220afd41 100644 --- a/src/audio/winmm/SDL_winmm.c +++ b/src/audio/winmm/SDL_winmm.c @@ -176,11 +176,9 @@ WINMM_CloseDevice(_THIS) } } - if (this->hidden->mixbuf != NULL) { - /* Free raw mixing buffer */ - SDL_free(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } + /* Free raw mixing buffer */ + SDL_free(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; if (this->hidden->hin) { waveInClose(this->hidden->hin); diff --git a/src/audio/xaudio2/SDL_xaudio2.c b/src/audio/xaudio2/SDL_xaudio2.c index 88803e6d9..3335a8f0b 100644 --- a/src/audio/xaudio2/SDL_xaudio2.c +++ b/src/audio/xaudio2/SDL_xaudio2.c @@ -98,6 +98,18 @@ #include "SDL_xaudio2_winrthelpers.h" #endif +/* Fixes bug 1210 where some versions of gcc need named parameters */ +#ifdef __GNUC__ +#ifdef THIS +#undef THIS +#endif +#define THIS INTERFACE *p +#ifdef THIS_ +#undef THIS_ +#endif +#define THIS_ INTERFACE *p, +#endif + struct SDL_PrivateAudioData { IXAudio2 *ixa2; @@ -263,9 +275,7 @@ XAUDIO2_CloseDevice(_THIS) if (ixa2 != NULL) { IXAudio2_Release(ixa2); } - if (this->hidden->mixbuf != NULL) { - SDL_free(this->hidden->mixbuf); - } + SDL_free(this->hidden->mixbuf); if (this->hidden->semaphore != NULL) { SDL_DestroySemaphore(this->hidden->semaphore); } diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c index b7d1ff6d1..763715e68 100644 --- a/src/core/android/SDL_android.c +++ b/src/core/android/SDL_android.c @@ -33,19 +33,20 @@ #include "../../video/android/SDL_androidkeyboard.h" #include "../../video/android/SDL_androidtouch.h" #include "../../video/android/SDL_androidvideo.h" +#include "../../video/android/SDL_androidwindow.h" #include #include #include #include #define LOG_TAG "SDL_android" -//#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__) -//#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) +/* #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__) */ +/* #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) */ #define LOGI(...) do {} while (false) #define LOGE(...) do {} while (false) /* Uncomment this to log messages entering and exiting methods in this file */ -//#define DEBUG_JNI +/* #define DEBUG_JNI */ static void Android_JNI_ThreadDestroyed(void*); @@ -63,19 +64,18 @@ static void Android_JNI_ThreadDestroyed(void*); static pthread_key_t mThreadKey; static JavaVM* mJavaVM; -// Main activity +/* Main activity */ static jclass mActivityClass; -// method signatures -static jmethodID midCreateGLContext; -static jmethodID midDeleteGLContext; +/* method signatures */ +static jmethodID midGetNativeSurface; static jmethodID midFlipBuffers; static jmethodID midAudioInit; static jmethodID midAudioWriteShortBuffer; static jmethodID midAudioWriteByteBuffer; static jmethodID midAudioQuit; -// Accelerometer data storage +/* Accelerometer data storage */ static float fLastAccelerometer[3]; static bool bHasNewData; @@ -83,7 +83,7 @@ static bool bHasNewData; Functions called by JNI *******************************************************************************/ -// Library init +/* Library init */ jint JNI_OnLoad(JavaVM* vm, void* reserved) { JNIEnv *env; @@ -107,7 +107,7 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) return JNI_VERSION_1_4; } -// Called before SDL_main() to initialize JNI bindings +/* Called before SDL_main() to initialize JNI bindings */ void SDL_Android_Init(JNIEnv* mEnv, jclass cls) { __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_Android_Init()"); @@ -116,10 +116,8 @@ void SDL_Android_Init(JNIEnv* mEnv, jclass cls) mActivityClass = (jclass)((*mEnv)->NewGlobalRef(mEnv, cls)); - midCreateGLContext = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, - "createGLContext","(II[I)Z"); - midDeleteGLContext = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, - "deleteGLContext","()V"); + midGetNativeSurface = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, + "getNativeSurface","()Landroid/view/Surface;"); midFlipBuffers = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "flipBuffers","()V"); midAudioInit = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, @@ -133,14 +131,14 @@ void SDL_Android_Init(JNIEnv* mEnv, jclass cls) bHasNewData = false; - if(!midCreateGLContext || !midFlipBuffers || !midAudioInit || + if(!midGetNativeSurface || !midFlipBuffers || !midAudioInit || !midAudioWriteShortBuffer || !midAudioWriteByteBuffer || !midAudioQuit) { __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL: Couldn't locate Java callbacks, check that they're named and typed correctly"); } __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_Android_Init() finished!"); } -// Resize +/* Resize */ void Java_org_libsdl_app_SDLActivity_onNativeResize( JNIEnv* env, jclass jcls, jint width, jint height, jint format) @@ -148,21 +146,80 @@ void Java_org_libsdl_app_SDLActivity_onNativeResize( Android_SetScreenResolution(width, height, format); } -// Keydown + +/* Surface Created */ +void Java_org_libsdl_app_SDLActivity_onNativeSurfaceChanged(JNIEnv* env, jclass jcls) +{ + SDL_WindowData *data; + SDL_VideoDevice *_this; + + if (Android_Window == NULL || Android_Window->driverdata == NULL ) { + return; + } + + _this = SDL_GetVideoDevice(); + data = (SDL_WindowData *) Android_Window->driverdata; + + /* If the surface has been previously destroyed by onNativeSurfaceDestroyed, recreate it here */ + if (data->egl_surface == EGL_NO_SURFACE) { + if(data->native_window) { + ANativeWindow_release(data->native_window); + } + data->native_window = Android_JNI_GetNativeWindow(); + data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->native_window); + } + + /* GL Context handling is done in the event loop because this function is run from the Java thread */ + +} + +/* Surface Destroyed */ +void Java_org_libsdl_app_SDLActivity_onNativeSurfaceDestroyed(JNIEnv* env, jclass jcls) +{ + /* We have to clear the current context and destroy the egl surface here + * Otherwise there's BAD_NATIVE_WINDOW errors coming from eglCreateWindowSurface on resume + * Ref: http://stackoverflow.com/questions/8762589/eglcreatewindowsurface-on-ics-and-switching-from-2d-to-3d + */ + SDL_WindowData *data; + SDL_VideoDevice *_this; + + if (Android_Window == NULL || Android_Window->driverdata == NULL ) { + return; + } + + _this = SDL_GetVideoDevice(); + data = (SDL_WindowData *) Android_Window->driverdata; + + if (data->egl_surface != EGL_NO_SURFACE) { + SDL_EGL_MakeCurrent(_this, NULL, NULL); + SDL_EGL_DestroySurface(_this, data->egl_surface); + data->egl_surface = EGL_NO_SURFACE; + } + + /* GL Context handling is done in the event loop because this function is run from the Java thread */ + +} + +void Java_org_libsdl_app_SDLActivity_nativeFlipBuffers(JNIEnv* env, jclass jcls) +{ + SDL_GL_SwapWindow(Android_Window); +} + +/* Keydown */ void Java_org_libsdl_app_SDLActivity_onNativeKeyDown( JNIEnv* env, jclass jcls, jint keycode) { Android_OnKeyDown(keycode); } -// Keyup +/* Keyup */ void Java_org_libsdl_app_SDLActivity_onNativeKeyUp( JNIEnv* env, jclass jcls, jint keycode) { Android_OnKeyUp(keycode); } -// Keyboard Focus Lost +/* Keyboard Focus Lost */ void Java_org_libsdl_app_SDLActivity_onNativeKeyboardFocusLost( JNIEnv* env, jclass jcls) { @@ -171,7 +228,7 @@ void Java_org_libsdl_app_SDLActivity_onNativeKeyboardFocusLost( } -// Touch +/* Touch */ void Java_org_libsdl_app_SDLActivity_onNativeTouch( JNIEnv* env, jclass jcls, jint touch_device_id_in, jint pointer_finger_id_in, @@ -180,7 +237,7 @@ void Java_org_libsdl_app_SDLActivity_onNativeTouch( Android_OnTouch(touch_device_id_in, pointer_finger_id_in, action, x, y, p); } -// Accelerometer +/* Accelerometer */ void Java_org_libsdl_app_SDLActivity_onNativeAccel( JNIEnv* env, jclass jcls, jfloat x, jfloat y, jfloat z) @@ -191,23 +248,23 @@ void Java_org_libsdl_app_SDLActivity_onNativeAccel( bHasNewData = true; } -// Low memory +/* Low memory */ void Java_org_libsdl_app_SDLActivity_nativeLowMemory( JNIEnv* env, jclass cls) { SDL_SendAppEvent(SDL_APP_LOWMEMORY); } -// Quit +/* Quit */ void Java_org_libsdl_app_SDLActivity_nativeQuit( JNIEnv* env, jclass cls) { - // Inject a SDL_QUIT event + /* Inject a SDL_QUIT event */ SDL_SendQuit(); SDL_SendAppEvent(SDL_APP_TERMINATING); } -// Pause +/* Pause */ void Java_org_libsdl_app_SDLActivity_nativePause( JNIEnv* env, jclass cls) { @@ -223,7 +280,7 @@ void Java_org_libsdl_app_SDLActivity_nativePause( SDL_SendAppEvent(SDL_APP_DIDENTERBACKGROUND); } -// Resume +/* Resume */ void Java_org_libsdl_app_SDLActivity_nativeResume( JNIEnv* env, jclass cls) { @@ -317,47 +374,17 @@ static SDL_bool LocalReferenceHolder_IsActive() return s_active > 0; } - -SDL_bool Android_JNI_CreateContext(int majorVersion, int minorVersion, - int red, int green, int blue, int alpha, - int buffer, int depth, int stencil, - int buffers, int samples) +ANativeWindow* Android_JNI_GetNativeWindow(void) { + ANativeWindow* anw; + jobject s; JNIEnv *env = Android_JNI_GetEnv(); - jint attribs[] = { - EGL_RED_SIZE, red, - EGL_GREEN_SIZE, green, - EGL_BLUE_SIZE, blue, - EGL_ALPHA_SIZE, alpha, - EGL_BUFFER_SIZE, buffer, - EGL_DEPTH_SIZE, depth, - EGL_STENCIL_SIZE, stencil, - EGL_SAMPLE_BUFFERS, buffers, - EGL_SAMPLES, samples, - EGL_RENDERABLE_TYPE, (majorVersion == 1 ? EGL_OPENGL_ES_BIT : EGL_OPENGL_ES2_BIT), - EGL_NONE - }; - int len = SDL_arraysize(attribs); - - jintArray array; - - array = (*env)->NewIntArray(env, len); - (*env)->SetIntArrayRegion(env, array, 0, len, attribs); - - jboolean success = (*env)->CallStaticBooleanMethod(env, mActivityClass, midCreateGLContext, majorVersion, minorVersion, array); - - (*env)->DeleteLocalRef(env, array); - - return success ? SDL_TRUE : SDL_FALSE; -} - -SDL_bool Android_JNI_DeleteContext(void) -{ - /* There's only one context, so no parameter for now */ - JNIEnv *env = Android_JNI_GetEnv(); - (*env)->CallStaticVoidMethod(env, mActivityClass, midDeleteGLContext); - return SDL_TRUE; + s = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetNativeSurface); + anw = ANativeWindow_fromSurface(env, s); + (*env)->DeleteLocalRef(env, s); + + return anw; } void Android_JNI_SwapWindow() @@ -441,9 +468,9 @@ int Android_JNI_SetupThread(void) { return 1; } -// -// Audio support -// +/* + * Audio support + */ static jboolean audioBuffer16Bit = JNI_FALSE; static jboolean audioBufferStereo = JNI_FALSE; static jobject audioBuffer = NULL; @@ -541,8 +568,8 @@ void Android_JNI_CloseAudioDevice() } } -// Test for an exception and call SDL_SetError with its detail if one occurs -// If the parameter silent is truthy then SDL_SetError() will not be called. +/* Test for an exception and call SDL_SetError with its detail if one occurs */ +/* If the parameter silent is truthy then SDL_SetError() will not be called. */ static bool Android_JNI_ExceptionOccurred(bool silent) { SDL_assert(LocalReferenceHolder_IsActive()); @@ -552,7 +579,7 @@ static bool Android_JNI_ExceptionOccurred(bool silent) if (exception != NULL) { jmethodID mid; - // Until this happens most JNI operations have undefined behaviour + /* Until this happens most JNI operations have undefined behaviour */ (*mEnv)->ExceptionClear(mEnv); if (!silent) { @@ -608,13 +635,13 @@ static int Internal_Android_JNI_FileOpen(SDL_RWops* ctx) fileNameJString = (jstring)ctx->hidden.androidio.fileNameRef; ctx->hidden.androidio.position = 0; - // context = SDLActivity.getContext(); + /* context = SDLActivity.getContext(); */ mid = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "getContext","()Landroid/content/Context;"); context = (*mEnv)->CallStaticObjectMethod(mEnv, mActivityClass, mid); - // assetManager = context.getAssets(); + /* assetManager = context.getAssets(); */ mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, context), "getAssets", "()Landroid/content/res/AssetManager;"); assetManager = (*mEnv)->CallObjectMethod(mEnv, context, mid); @@ -647,34 +674,35 @@ static int Internal_Android_JNI_FileOpen(SDL_RWops* ctx) ctx->hidden.androidio.fd = (*mEnv)->GetIntField(mEnv, fd, descriptor); ctx->hidden.androidio.assetFileDescriptorRef = (*mEnv)->NewGlobalRef(mEnv, inputStream); - // Seek to the correct offset in the file. + /* Seek to the correct offset in the file. */ lseek(ctx->hidden.androidio.fd, (off_t)ctx->hidden.androidio.offset, SEEK_SET); if (false) { fallback: - // Disabled log message because of spam on the Nexus 7 - //__android_log_print(ANDROID_LOG_DEBUG, "SDL", "Falling back to legacy InputStream method for opening file"); + /* Disabled log message because of spam on the Nexus 7 */ + /* __android_log_print(ANDROID_LOG_DEBUG, "SDL", "Falling back to legacy InputStream method for opening file"); */ /* Try the old method using InputStream */ ctx->hidden.androidio.assetFileDescriptorRef = NULL; - // inputStream = assetManager.open(); + /* inputStream = assetManager.open(); */ mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, assetManager), "open", "(Ljava/lang/String;I)Ljava/io/InputStream;"); - inputStream = (*mEnv)->CallObjectMethod(mEnv, assetManager, mid, fileNameJString, 1 /*ACCESS_RANDOM*/); + inputStream = (*mEnv)->CallObjectMethod(mEnv, assetManager, mid, fileNameJString, 1 /* ACCESS_RANDOM */); if (Android_JNI_ExceptionOccurred(false)) { goto failure; } ctx->hidden.androidio.inputStreamRef = (*mEnv)->NewGlobalRef(mEnv, inputStream); - // Despite all the visible documentation on [Asset]InputStream claiming - // that the .available() method is not guaranteed to return the entire file - // size, comments in /samples//ApiDemos/src/com/example/ ... - // android/apis/content/ReadAsset.java imply that Android's - // AssetInputStream.available() /will/ always return the total file size - - // size = inputStream.available(); + /* Despite all the visible documentation on [Asset]InputStream claiming + * that the .available() method is not guaranteed to return the entire file + * size, comments in /samples//ApiDemos/src/com/example/ ... + * android/apis/content/ReadAsset.java imply that Android's + * AssetInputStream.available() /will/ always return the total file size + */ + + /* size = inputStream.available(); */ mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "available", "()I"); ctx->hidden.androidio.size = (long)(*mEnv)->CallIntMethod(mEnv, inputStream, mid); @@ -682,7 +710,7 @@ fallback: goto failure; } - // readableByteChannel = Channels.newChannel(inputStream); + /* readableByteChannel = Channels.newChannel(inputStream); */ channels = (*mEnv)->FindClass(mEnv, "java/nio/channels/Channels"); mid = (*mEnv)->GetStaticMethodID(mEnv, channels, "newChannel", @@ -696,7 +724,7 @@ fallback: ctx->hidden.androidio.readableByteChannelRef = (*mEnv)->NewGlobalRef(mEnv, readableByteChannel); - // Store .read id for reading purposes + /* Store .read id for reading purposes */ mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, readableByteChannel), "read", "(Ljava/nio/ByteBuffer;)I"); ctx->hidden.androidio.readMethod = mid; @@ -762,7 +790,7 @@ size_t Android_JNI_FileRead(SDL_RWops* ctx, void* buffer, if (ctx->hidden.androidio.assetFileDescriptorRef) { size_t bytesMax = size * maxnum; - if (ctx->hidden.androidio.size != -1 /*UNKNOWN_LENGTH*/ && ctx->hidden.androidio.position + bytesMax > ctx->hidden.androidio.size) { + if (ctx->hidden.androidio.size != -1 /* UNKNOWN_LENGTH */ && ctx->hidden.androidio.position + bytesMax > ctx->hidden.androidio.size) { bytesMax = ctx->hidden.androidio.size - ctx->hidden.androidio.position; } size_t result = read(ctx->hidden.androidio.fd, buffer, bytesMax ); @@ -792,7 +820,7 @@ size_t Android_JNI_FileRead(SDL_RWops* ctx, void* buffer, jobject byteBuffer = (*mEnv)->NewDirectByteBuffer(mEnv, buffer, bytesRemaining); while (bytesRemaining > 0) { - // result = readableByteChannel.read(...); + /* result = readableByteChannel.read(...); */ int result = (*mEnv)->CallIntMethod(mEnv, readableByteChannel, readMethod, byteBuffer); if (Android_JNI_ExceptionOccurred(false)) { @@ -850,7 +878,7 @@ static int Internal_Android_JNI_FileClose(SDL_RWops* ctx, bool release) else { jobject inputStream = (jobject)ctx->hidden.androidio.inputStreamRef; - // inputStream.close(); + /* inputStream.close(); */ jmethodID mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "close", "()V"); (*mEnv)->CallVoidMethod(mEnv, inputStream, mid); @@ -881,12 +909,12 @@ Sint64 Android_JNI_FileSeek(SDL_RWops* ctx, Sint64 offset, int whence) if (ctx->hidden.androidio.assetFileDescriptorRef) { switch (whence) { case RW_SEEK_SET: - if (ctx->hidden.androidio.size != -1 /*UNKNOWN_LENGTH*/ && offset > ctx->hidden.androidio.size) offset = ctx->hidden.androidio.size; + if (ctx->hidden.androidio.size != -1 /* UNKNOWN_LENGTH */ && offset > ctx->hidden.androidio.size) offset = ctx->hidden.androidio.size; offset += ctx->hidden.androidio.offset; break; case RW_SEEK_CUR: offset += ctx->hidden.androidio.position; - if (ctx->hidden.androidio.size != -1 /*UNKNOWN_LENGTH*/ && offset > ctx->hidden.androidio.size) offset = ctx->hidden.androidio.size; + if (ctx->hidden.androidio.size != -1 /* UNKNOWN_LENGTH */ && offset > ctx->hidden.androidio.size) offset = ctx->hidden.androidio.size; offset += ctx->hidden.androidio.offset; break; case RW_SEEK_END: @@ -929,7 +957,7 @@ Sint64 Android_JNI_FileSeek(SDL_RWops* ctx, Sint64 offset, int whence) if (movement > 0) { unsigned char buffer[4096]; - // The easy case where we're seeking forwards + /* The easy case where we're seeking forwards */ while (movement > 0) { Sint64 amount = sizeof (buffer); if (amount > movement) { @@ -937,7 +965,7 @@ Sint64 Android_JNI_FileSeek(SDL_RWops* ctx, Sint64 offset, int whence) } size_t result = Android_JNI_FileRead(ctx, buffer, 1, amount); if (result <= 0) { - // Failed to read/skip the required amount, so fail + /* Failed to read/skip the required amount, so fail */ return -1; } @@ -945,8 +973,8 @@ Sint64 Android_JNI_FileSeek(SDL_RWops* ctx, Sint64 offset, int whence) } } else if (movement < 0) { - // We can't seek backwards so we have to reopen the file and seek - // forwards which obviously isn't very efficient + /* We can't seek backwards so we have to reopen the file and seek */ + /* forwards which obviously isn't very efficient */ Internal_Android_JNI_FileClose(ctx, false); Internal_Android_JNI_FileOpen(ctx); Android_JNI_FileSeek(ctx, newPosition, RW_SEEK_SET); @@ -962,7 +990,7 @@ int Android_JNI_FileClose(SDL_RWops* ctx) return Internal_Android_JNI_FileClose(ctx, true); } -// returns a new global reference which needs to be released later +/* returns a new global reference which needs to be released later */ static jobject Android_JNI_GetSystemServiceObject(const char* name) { struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__); @@ -1062,9 +1090,10 @@ SDL_bool Android_JNI_HasClipboardText() } -// returns 0 on success or -1 on error (others undefined then) -// returns truthy or falsy value in plugged, charged and battery -// returns the value in seconds and percent or -1 if not available +/* returns 0 on success or -1 on error (others undefined then) + * returns truthy or falsy value in plugged, charged and battery + * returns the value in seconds and percent or -1 if not available + */ int Android_JNI_GetPowerInfo(int* plugged, int* charged, int* battery, int* seconds, int* percent) { struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__); @@ -1112,38 +1141,38 @@ int Android_JNI_GetPowerInfo(int* plugged, int* charged, int* battery, int* seco (*env)->DeleteLocalRef(env, bname); if (plugged) { - GET_INT_EXTRA(plug, "plugged") // == BatteryManager.EXTRA_PLUGGED (API 5) + GET_INT_EXTRA(plug, "plugged") /* == BatteryManager.EXTRA_PLUGGED (API 5) */ if (plug == -1) { LocalReferenceHolder_Cleanup(&refs); return -1; } - // 1 == BatteryManager.BATTERY_PLUGGED_AC - // 2 == BatteryManager.BATTERY_PLUGGED_USB + /* 1 == BatteryManager.BATTERY_PLUGGED_AC */ + /* 2 == BatteryManager.BATTERY_PLUGGED_USB */ *plugged = (0 < plug) ? 1 : 0; } if (charged) { - GET_INT_EXTRA(status, "status") // == BatteryManager.EXTRA_STATUS (API 5) + GET_INT_EXTRA(status, "status") /* == BatteryManager.EXTRA_STATUS (API 5) */ if (status == -1) { LocalReferenceHolder_Cleanup(&refs); return -1; } - // 5 == BatteryManager.BATTERY_STATUS_FULL + /* 5 == BatteryManager.BATTERY_STATUS_FULL */ *charged = (status == 5) ? 1 : 0; } if (battery) { - GET_BOOL_EXTRA(present, "present") // == BatteryManager.EXTRA_PRESENT (API 5) + GET_BOOL_EXTRA(present, "present") /* == BatteryManager.EXTRA_PRESENT (API 5) */ *battery = present ? 1 : 0; } if (seconds) { - *seconds = -1; // not possible + *seconds = -1; /* not possible */ } if (percent) { - GET_INT_EXTRA(level, "level") // == BatteryManager.EXTRA_LEVEL (API 5) - GET_INT_EXTRA(scale, "scale") // == BatteryManager.EXTRA_SCALE (API 5) + GET_INT_EXTRA(level, "level") /* == BatteryManager.EXTRA_LEVEL (API 5) */ + GET_INT_EXTRA(scale, "scale") /* == BatteryManager.EXTRA_SCALE (API 5) */ if ((level == -1) || (scale == -1)) { LocalReferenceHolder_Cleanup(&refs); return -1; @@ -1157,7 +1186,33 @@ int Android_JNI_GetPowerInfo(int* plugged, int* charged, int* battery, int* seco return 0; } -// sends message to be handled on the UI event dispatch thread +/* returns number of found touch devices as return value and ids in parameter ids */ +int Android_JNI_GetTouchDeviceIds(int **ids) { + JNIEnv *env = Android_JNI_GetEnv(); + jint sources = 4098; /* == InputDevice.SOURCE_TOUCHSCREEN */ + jmethodID mid = (*env)->GetStaticMethodID(env, mActivityClass, "inputGetInputDeviceIds", "(I)[I"); + jintArray array = (jintArray) (*env)->CallStaticObjectMethod(env, mActivityClass, mid, sources); + int number = 0; + *ids = NULL; + if (array) { + number = (int) (*env)->GetArrayLength(env, array); + if (0 < number) { + jint* elements = (*env)->GetIntArrayElements(env, array, NULL); + if (elements) { + int i; + *ids = SDL_malloc(number * sizeof (**ids)); + for (i = 0; i < number; ++i) { /* not assuming sizeof (jint) == sizeof (int) */ + (*ids)[i] = elements[i]; + } + (*env)->ReleaseIntArrayElements(env, array, elements, JNI_ABORT); + } + } + (*env)->DeleteLocalRef(env, array); + } + return number; +} + +/* sends message to be handled on the UI event dispatch thread */ int Android_JNI_SendMessage(int command, int param) { JNIEnv *env = Android_JNI_GetEnv(); @@ -1192,15 +1247,17 @@ void Android_JNI_ShowTextInput(SDL_Rect *inputRect) void Android_JNI_HideTextInput() { - // has to match Activity constant + /* has to match Activity constant */ const int COMMAND_TEXTEDIT_HIDE = 3; Android_JNI_SendMessage(COMMAND_TEXTEDIT_HIDE, 0); } +/* ////////////////////////////////////////////////////////////////////////////// // // Functions exposed to SDL applications in SDL_system.h -// +////////////////////////////////////////////////////////////////////////////// +*/ void *SDL_AndroidGetJNIEnv() { @@ -1220,7 +1277,7 @@ void *SDL_AndroidGetActivity() return NULL; } - // return SDLActivity.getContext(); + /* return SDLActivity.getContext(); */ mid = (*env)->GetStaticMethodID(env, mActivityClass, "getContext","()Landroid/content/Context;"); return (*env)->CallStaticObjectMethod(env, mActivityClass, mid); @@ -1244,12 +1301,12 @@ const char * SDL_AndroidGetInternalStoragePath() return NULL; } - // context = SDLActivity.getContext(); + /* context = SDLActivity.getContext(); */ mid = (*env)->GetStaticMethodID(env, mActivityClass, "getContext","()Landroid/content/Context;"); context = (*env)->CallStaticObjectMethod(env, mActivityClass, mid); - // fileObj = context.getFilesDir(); + /* fileObj = context.getFilesDir(); */ mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, context), "getFilesDir", "()Ljava/io/File;"); fileObject = (*env)->CallObjectMethod(env, context, mid); @@ -1259,7 +1316,7 @@ const char * SDL_AndroidGetInternalStoragePath() return NULL; } - // path = fileObject.getAbsolutePath(); + /* path = fileObject.getAbsolutePath(); */ mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, fileObject), "getAbsolutePath", "()Ljava/lang/String;"); pathString = (jstring)(*env)->CallObjectMethod(env, fileObject, mid); @@ -1295,7 +1352,7 @@ int SDL_AndroidGetExternalStorageState() state = (*env)->GetStringUTFChars(env, stateString, NULL); - // Print an info message so people debugging know the storage state + /* Print an info message so people debugging know the storage state */ __android_log_print(ANDROID_LOG_INFO, "SDL", "external storage state: %s", state); if (SDL_strcmp(state, "mounted") == 0) { @@ -1330,12 +1387,12 @@ const char * SDL_AndroidGetExternalStoragePath() return NULL; } - // context = SDLActivity.getContext(); + /* context = SDLActivity.getContext(); */ mid = (*env)->GetStaticMethodID(env, mActivityClass, "getContext","()Landroid/content/Context;"); context = (*env)->CallStaticObjectMethod(env, mActivityClass, mid); - // fileObj = context.getExternalFilesDir(); + /* fileObj = context.getExternalFilesDir(); */ mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, context), "getExternalFilesDir", "(Ljava/lang/String;)Ljava/io/File;"); fileObject = (*env)->CallObjectMethod(env, context, mid, NULL); @@ -1345,7 +1402,7 @@ const char * SDL_AndroidGetExternalStoragePath() return NULL; } - // path = fileObject.getAbsolutePath(); + /* path = fileObject.getAbsolutePath(); */ mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, fileObject), "getAbsolutePath", "()Ljava/lang/String;"); pathString = (jstring)(*env)->CallObjectMethod(env, fileObject, mid); diff --git a/src/core/android/SDL_android.h b/src/core/android/SDL_android.h index 973f5881f..6181a15db 100644 --- a/src/core/android/SDL_android.h +++ b/src/core/android/SDL_android.h @@ -27,16 +27,20 @@ extern "C" { /* *INDENT-ON* */ #endif +#include +#include + #include "SDL_rect.h" /* Interface from the SDL library into the Android Java activity */ -extern SDL_bool Android_JNI_CreateContext(int majorVersion, int minorVersion, int red, int green, int blue, int alpha, int buffer, int depth, int stencil, int buffers, int samples); -extern SDL_bool Android_JNI_DeleteContext(void); +/* extern SDL_bool Android_JNI_CreateContext(int majorVersion, int minorVersion, int red, int green, int blue, int alpha, int buffer, int depth, int stencil, int buffers, int samples); +extern SDL_bool Android_JNI_DeleteContext(void); */ extern void Android_JNI_SwapWindow(); extern void Android_JNI_SetActivityTitle(const char *title); extern SDL_bool Android_JNI_GetAccelerometerValues(float values[3]); extern void Android_JNI_ShowTextInput(SDL_Rect *inputRect); extern void Android_JNI_HideTextInput(); +extern ANativeWindow* Android_JNI_GetNativeWindow(void); /* Audio support */ extern int Android_JNI_OpenAudioDevice(int sampleRate, int is16Bit, int channelCount, int desiredBufferFrames); @@ -61,6 +65,9 @@ SDL_bool Android_JNI_HasClipboardText(); /* Power support */ int Android_JNI_GetPowerInfo(int* plugged, int* charged, int* battery, int* seconds, int* percent); +/* Touch support */ +int Android_JNI_GetTouchDeviceIds(int **ids); + /* Threads */ #include JNIEnv *Android_JNI_GetEnv(void); diff --git a/src/core/linux/SDL_udev.c b/src/core/linux/SDL_udev.c new file mode 100644 index 000000000..c08c287e8 --- /dev/null +++ b/src/core/linux/SDL_udev.c @@ -0,0 +1,398 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/* + * To list the properties of a device, try something like: + * udevadm info -a -n snd/hwC0D0 (for a sound card) + * udevadm info --query=all -n input/event3 (for a keyboard, mouse, etc) + * udevadm info --query=property -n input/event2 + */ + +#include "SDL_udev.h" + +#ifdef SDL_USE_LIBUDEV + +static char* SDL_UDEV_LIBS[] = { "libudev.so.1", "libudev.so.0" }; + +#define _THIS SDL_UDEV_PrivateData *_this +static _THIS = NULL; + +#include "SDL.h" + +static SDL_bool SDL_UDEV_load_sym(const char *fn, void **addr); +static int SDL_UDEV_load_syms(void); +static SDL_bool SDL_UDEV_hotplug_update_available(void); +static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev); + +static SDL_bool +SDL_UDEV_load_sym(const char *fn, void **addr) +{ + *addr = SDL_LoadFunction(_this->udev_handle, fn); + if (*addr == NULL) { + /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ + return SDL_FALSE; + } + + return SDL_TRUE; +} + +static int +SDL_UDEV_load_syms(void) +{ + /* cast funcs to char* first, to please GCC's strict aliasing rules. */ + #define SDL_UDEV_SYM(x) \ + if (!SDL_UDEV_load_sym(#x, (void **) (char *) & _this->x)) return -1 + + SDL_UDEV_SYM(udev_device_get_action); + SDL_UDEV_SYM(udev_device_get_devnode); + SDL_UDEV_SYM(udev_device_get_subsystem); + SDL_UDEV_SYM(udev_device_get_property_value); + SDL_UDEV_SYM(udev_device_new_from_syspath); + SDL_UDEV_SYM(udev_device_unref); + SDL_UDEV_SYM(udev_enumerate_add_match_property); + SDL_UDEV_SYM(udev_enumerate_add_match_subsystem); + SDL_UDEV_SYM(udev_enumerate_get_list_entry); + SDL_UDEV_SYM(udev_enumerate_new); + SDL_UDEV_SYM(udev_enumerate_scan_devices); + SDL_UDEV_SYM(udev_enumerate_unref); + SDL_UDEV_SYM(udev_list_entry_get_name); + SDL_UDEV_SYM(udev_list_entry_get_next); + SDL_UDEV_SYM(udev_monitor_enable_receiving); + SDL_UDEV_SYM(udev_monitor_filter_add_match_subsystem_devtype); + SDL_UDEV_SYM(udev_monitor_get_fd); + SDL_UDEV_SYM(udev_monitor_new_from_netlink); + SDL_UDEV_SYM(udev_monitor_receive_device); + SDL_UDEV_SYM(udev_monitor_unref); + SDL_UDEV_SYM(udev_new); + SDL_UDEV_SYM(udev_unref); + SDL_UDEV_SYM(udev_device_new_from_devnum); + SDL_UDEV_SYM(udev_device_get_devnum); + #undef SDL_UDEV_SYM + + return 0; +} + +static SDL_bool +SDL_UDEV_hotplug_update_available(void) +{ + if (_this->udev_mon != NULL) { + const int fd = _this->udev_monitor_get_fd(_this->udev_mon); + fd_set fds; + struct timeval tv; + + FD_ZERO(&fds); + FD_SET(fd, &fds); + tv.tv_sec = 0; + tv.tv_usec = 0; + if ((select(fd+1, &fds, NULL, NULL, &tv) > 0) && (FD_ISSET(fd, &fds))) { + return SDL_TRUE; + } + } + return SDL_FALSE; +} + + +int +SDL_UDEV_Init(void) +{ + int retval = 0; + + if (_this == NULL) { + _this = (SDL_UDEV_PrivateData *) SDL_calloc(1, sizeof(*_this)); + if(_this == NULL) { + return SDL_OutOfMemory(); + } + + retval = SDL_UDEV_LoadLibrary(); + if (retval < 0) { + SDL_UDEV_Quit(); + return retval; + } + + /* Set up udev monitoring + * Listen for input devices (mouse, keyboard, joystick, etc) and sound devices + */ + + _this->udev = _this->udev_new(); + if (_this->udev == NULL) { + SDL_UDEV_Quit(); + return SDL_SetError("udev_new() failed"); + } + + _this->udev_mon = _this->udev_monitor_new_from_netlink(_this->udev, "udev"); + if (_this->udev_mon == NULL) { + SDL_UDEV_Quit(); + return SDL_SetError("udev_monitor_new_from_netlink() failed"); + } + + _this->udev_monitor_filter_add_match_subsystem_devtype(_this->udev_mon, "input", NULL); + _this->udev_monitor_filter_add_match_subsystem_devtype(_this->udev_mon, "sound", NULL); + _this->udev_monitor_enable_receiving(_this->udev_mon); + + /* Do an initial scan of existing devices */ + SDL_UDEV_Scan(); + + } + + _this->ref_count += 1; + + return retval; +} + +void +SDL_UDEV_Quit(void) +{ + SDL_UDEV_CallbackList *item; + + if (_this == NULL) { + return; + } + + _this->ref_count -= 1; + + if (_this->ref_count < 1) { + + if (_this->udev_mon != NULL) { + _this->udev_monitor_unref(_this->udev_mon); + _this->udev_mon = NULL; + } + if (_this->udev != NULL) { + _this->udev_unref(_this->udev); + _this->udev = NULL; + } + + /* Remove existing devices */ + while (_this->first != NULL) { + item = _this->first; + _this->first = _this->first->next; + SDL_free(item); + } + + SDL_UDEV_UnloadLibrary(); + SDL_free(_this); + _this = NULL; + } +} + +void +SDL_UDEV_Scan(void) +{ + struct udev_enumerate *enumerate = NULL; + struct udev_list_entry *devs = NULL; + struct udev_list_entry *item = NULL; + + if (_this == NULL) { + return; + } + + enumerate = _this->udev_enumerate_new(_this->udev); + if (enumerate == NULL) { + SDL_UDEV_Quit(); + SDL_SetError("udev_monitor_new_from_netlink() failed"); + return; + } + + _this->udev_enumerate_add_match_subsystem(enumerate, "input"); + _this->udev_enumerate_add_match_subsystem(enumerate, "sound"); + + _this->udev_enumerate_scan_devices(enumerate); + devs = _this->udev_enumerate_get_list_entry(enumerate); + for (item = devs; item; item = _this->udev_list_entry_get_next(item)) { + const char *path = _this->udev_list_entry_get_name(item); + struct udev_device *dev = _this->udev_device_new_from_syspath(_this->udev, path); + if (dev != NULL) { + device_event(SDL_UDEV_DEVICEADDED, dev); + _this->udev_device_unref(dev); + } + } + + _this->udev_enumerate_unref(enumerate); +} + + +void +SDL_UDEV_UnloadLibrary(void) +{ + if (_this == NULL) { + return; + } + + if (_this->udev_handle != NULL) { + SDL_UnloadObject(_this->udev_handle); + _this->udev_handle = NULL; + } +} + +int +SDL_UDEV_LoadLibrary(void) +{ + int retval = 0, i; + + if (_this == NULL) { + return SDL_SetError("UDEV not initialized"); + } + + + if (_this->udev_handle == NULL) { + for( i = 0 ; i < SDL_arraysize(SDL_UDEV_LIBS); i++) { + _this->udev_handle = SDL_LoadObject(SDL_UDEV_LIBS[i]); + if (_this->udev_handle != NULL) { + retval = SDL_UDEV_load_syms(); + if (retval < 0) { + SDL_UDEV_UnloadLibrary(); + } + else { + break; + } + } + } + + if (_this->udev_handle == NULL) { + retval = -1; + /* Don't call SDL_SetError(): SDL_LoadObject already did. */ + } + } + + return retval; +} + +static void +device_event(SDL_UDEV_deviceevent type, struct udev_device *dev) +{ + const char *subsystem; + const char *val = NULL; + int devclass = 0; + const char *path; + SDL_UDEV_CallbackList *item; + + path = _this->udev_device_get_devnode(dev); + if (path == NULL) { + return; + } + + subsystem = _this->udev_device_get_subsystem(dev); + if (SDL_strcmp(subsystem, "sound") == 0) { + devclass = SDL_UDEV_DEVICE_SOUND; + } else if (SDL_strcmp(subsystem, "input") == 0) { + val = _this->udev_device_get_property_value(dev, "ID_INPUT_JOYSTICK"); + if (val != NULL && SDL_strcmp(val, "1") == 0 ) { + devclass |= SDL_UDEV_DEVICE_JOYSTICK; + } + + val = _this->udev_device_get_property_value(dev, "ID_INPUT_MOUSE"); + if (val != NULL && SDL_strcmp(val, "1") == 0 ) { + devclass |= SDL_UDEV_DEVICE_MOUSE; + } + + val = _this->udev_device_get_property_value(dev, "ID_INPUT_KEYBOARD"); + if (val != NULL && SDL_strcmp(val, "1") == 0 ) { + devclass |= SDL_UDEV_DEVICE_KEYBOARD; + } + + if (devclass == 0) { + return; + } + } else { + return; + } + + /* Process callbacks */ + for (item = _this->first; item != NULL; item = item->next) { + item->callback(type, devclass, path); + } +} + +void +SDL_UDEV_Poll(void) +{ + struct udev_device *dev = NULL; + const char *action = NULL; + + if (_this == NULL) { + return; + } + + while (SDL_UDEV_hotplug_update_available()) { + dev = _this->udev_monitor_receive_device(_this->udev_mon); + if (dev == NULL) { + break; + } + action = _this->udev_device_get_action(dev); + + if (SDL_strcmp(action, "add") == 0) { + device_event(SDL_UDEV_DEVICEADDED, dev); + } else if (SDL_strcmp(action, "remove") == 0) { + device_event(SDL_UDEV_DEVICEREMOVED, dev); + } + + _this->udev_device_unref(dev); + } +} + +int +SDL_UDEV_AddCallback(SDL_UDEV_Callback cb) +{ + SDL_UDEV_CallbackList *item; + item = (SDL_UDEV_CallbackList *) SDL_calloc(1, sizeof (SDL_UDEV_CallbackList)); + if (item == NULL) { + return SDL_OutOfMemory(); + } + + item->callback = cb; + + if (_this->last == NULL) { + _this->first = _this->last = item; + } else { + _this->last->next = item; + _this->last = item; + } + + return 1; +} + +void +SDL_UDEV_DelCallback(SDL_UDEV_Callback cb) +{ + SDL_UDEV_CallbackList *item; + SDL_UDEV_CallbackList *prev = NULL; + + for (item = _this->first; item != NULL; item = item->next) { + /* found it, remove it. */ + if (item->callback == cb) { + if (prev != NULL) { + prev->next = item->next; + } else { + SDL_assert(_this->first == item); + _this->first = item->next; + } + if (item == _this->last) { + _this->last = prev; + } + SDL_free(item); + return; + } + prev = item; + } + +} + + +#endif /* SDL_USE_LIBUDEV */ diff --git a/src/core/linux/SDL_udev.h b/src/core/linux/SDL_udev.h new file mode 100644 index 000000000..1c26f1104 --- /dev/null +++ b/src/core/linux/SDL_udev.h @@ -0,0 +1,115 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +#include "SDL_config.h" + +#ifndef _SDL_udev_h +#define _SDL_udev_h + +#if HAVE_LIBUDEV_H + +#ifndef SDL_USE_LIBUDEV +#define SDL_USE_LIBUDEV 1 +#endif + +#include "SDL_loadso.h" +#include "SDL_events.h" +#include +#include +#include + +/** + * \brief Device type + */ + +typedef enum +{ + SDL_UDEV_DEVICEADDED = 0x0001, + SDL_UDEV_DEVICEREMOVED +} SDL_UDEV_deviceevent; + +/* A device can be any combination of these classes */ +typedef enum +{ + SDL_UDEV_DEVICE_MOUSE = 0x0001, + SDL_UDEV_DEVICE_KEYBOARD = 0x0002, + SDL_UDEV_DEVICE_JOYSTICK = 0x0004, + SDL_UDEV_DEVICE_SOUND = 0x0008 +} SDL_UDEV_deviceclass; + +typedef void (*SDL_UDEV_Callback)(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath); + +typedef struct SDL_UDEV_CallbackList { + SDL_UDEV_Callback callback; + struct SDL_UDEV_CallbackList *next; +} SDL_UDEV_CallbackList; + +typedef struct SDL_UDEV_PrivateData +{ + const char *udev_library; + void *udev_handle; + struct udev *udev; + struct udev_monitor *udev_mon; + int ref_count; + SDL_UDEV_CallbackList *first, *last; + + /* Function pointers */ + const char *(*udev_device_get_action)(struct udev_device *); + const char *(*udev_device_get_devnode)(struct udev_device *); + const char *(*udev_device_get_subsystem)(struct udev_device *); + const char *(*udev_device_get_property_value)(struct udev_device *, const char *); + struct udev_device *(*udev_device_new_from_syspath)(struct udev *, const char *); + void (*udev_device_unref)(struct udev_device *); + int (*udev_enumerate_add_match_property)(struct udev_enumerate *, const char *, const char *); + int (*udev_enumerate_add_match_subsystem)(struct udev_enumerate *, const char *); + struct udev_list_entry *(*udev_enumerate_get_list_entry)(struct udev_enumerate *); + struct udev_enumerate *(*udev_enumerate_new)(struct udev *); + int (*udev_enumerate_scan_devices)(struct udev_enumerate *); + void (*udev_enumerate_unref)(struct udev_enumerate *); + const char *(*udev_list_entry_get_name)(struct udev_list_entry *); + struct udev_list_entry *(*udev_list_entry_get_next)(struct udev_list_entry *); + int (*udev_monitor_enable_receiving)(struct udev_monitor *); + int (*udev_monitor_filter_add_match_subsystem_devtype)(struct udev_monitor *, const char *, const char *); + int (*udev_monitor_get_fd)(struct udev_monitor *); + struct udev_monitor *(*udev_monitor_new_from_netlink)(struct udev *, const char *); + struct udev_device *(*udev_monitor_receive_device)(struct udev_monitor *); + void (*udev_monitor_unref)(struct udev_monitor *); + struct udev *(*udev_new)(void); + void (*udev_unref)(struct udev *); + struct udev_device * (*udev_device_new_from_devnum)(struct udev *udev, char type, dev_t devnum); + dev_t (*udev_device_get_devnum) (struct udev_device *udev_device); +} SDL_UDEV_PrivateData; + +extern int SDL_UDEV_Init(void); +extern void SDL_UDEV_Quit(void); +extern void SDL_UDEV_UnloadLibrary(void); +extern int SDL_UDEV_LoadLibrary(void); +extern void SDL_UDEV_Poll(void); +extern void SDL_UDEV_Scan(void); +extern int SDL_UDEV_AddCallback(SDL_UDEV_Callback cb); +extern void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb); + + + + +#endif /* HAVE_LIBUDEV_H */ + +#endif /* _SDL_udev_h */ diff --git a/src/core/windows/SDL_windows.c b/src/core/windows/SDL_windows.c index 2388f93fa..5df71407c 100644 --- a/src/core/windows/SDL_windows.c +++ b/src/core/windows/SDL_windows.c @@ -22,8 +22,8 @@ #if defined(__WIN32__) || defined(__WINRT__) -#include "SDL_error.h" #include "SDL_windows.h" +#include "SDL_error.h" #include "SDL_assert.h" #include /* for CoInitialize/CoUninitialize (Win32 only) */ diff --git a/src/core/windows/SDL_windows.h b/src/core/windows/SDL_windows.h index ce614a998..a9b34feb3 100644 --- a/src/core/windows/SDL_windows.h +++ b/src/core/windows/SDL_windows.h @@ -38,9 +38,10 @@ /* Routines to convert from UTF8 to native Windows text */ #if UNICODE -#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UCS-2-INTERNAL", (char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR)) -#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", (char *)(S), SDL_strlen(S)+1) +#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR)) +#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UTF-16LE", "UTF-8", (char *)(S), SDL_strlen(S)+1) #else +/* !!! FIXME: UTF8ToString() can just be a SDL_strdup() here. */ #define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)(S), (SDL_strlen(S)+1)) #define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)(S), SDL_strlen(S)+1) #endif diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index 30549852d..fcb600656 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -20,6 +20,10 @@ */ #include "SDL_config.h" +#if defined(__WIN32__) +#include "../core/windows/SDL_windows.h" +#endif + /* CPU feature detection for SDL */ #include "SDL_cpuinfo.h" @@ -41,9 +45,6 @@ #include #include #endif -#ifdef __WIN32__ -#include "../core/windows/SDL_windows.h" -#endif #define CPU_HAS_RDTSC 0x00000001 #define CPU_HAS_ALTIVEC 0x00000002 @@ -67,7 +68,7 @@ illegal_instruction(int sig) } #endif /* HAVE_SETJMP */ -static __inline__ int +static SDL_INLINE int CPU_haveCPUID(void) { int has_CPUID = 0; @@ -191,7 +192,7 @@ done: a = b = c = d = 0 #endif -static __inline__ int +static SDL_INLINE int CPU_getCPUIDFeatures(void) { int features = 0; @@ -205,7 +206,7 @@ CPU_getCPUIDFeatures(void) return features; } -static __inline__ int +static SDL_INLINE int CPU_haveRDTSC(void) { if (CPU_haveCPUID()) { @@ -214,7 +215,7 @@ CPU_haveRDTSC(void) return 0; } -static __inline__ int +static SDL_INLINE int CPU_haveAltiVec(void) { volatile int altivec = 0; @@ -241,7 +242,7 @@ CPU_haveAltiVec(void) return altivec; } -static __inline__ int +static SDL_INLINE int CPU_haveMMX(void) { if (CPU_haveCPUID()) { @@ -250,7 +251,7 @@ CPU_haveMMX(void) return 0; } -static __inline__ int +static SDL_INLINE int CPU_have3DNow(void) { if (CPU_haveCPUID()) { @@ -265,7 +266,7 @@ CPU_have3DNow(void) return 0; } -static __inline__ int +static SDL_INLINE int CPU_haveSSE(void) { if (CPU_haveCPUID()) { @@ -274,7 +275,7 @@ CPU_haveSSE(void) return 0; } -static __inline__ int +static SDL_INLINE int CPU_haveSSE2(void) { if (CPU_haveCPUID()) { @@ -283,7 +284,7 @@ CPU_haveSSE2(void) return 0; } -static __inline__ int +static SDL_INLINE int CPU_haveSSE3(void) { if (CPU_haveCPUID()) { @@ -298,7 +299,7 @@ CPU_haveSSE3(void) return 0; } -static __inline__ int +static SDL_INLINE int CPU_haveSSE41(void) { if (CPU_haveCPUID()) { @@ -313,7 +314,7 @@ CPU_haveSSE41(void) return 0; } -static __inline__ int +static SDL_INLINE int CPU_haveSSE42(void) { if (CPU_haveCPUID()) { @@ -607,6 +608,51 @@ SDL_HasSSE42(void) return SDL_FALSE; } +static int SDL_SystemRAM = 0; + +int +SDL_GetSystemRAM(void) +{ + if (!SDL_SystemRAM) { +#if defined(HAVE_SYSCONF) && defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE) + if (SDL_SystemRAM <= 0) { + SDL_SystemRAM = (int)((Sint64)sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGESIZE) / (1024*1024)); + } +#endif +#ifdef HAVE_SYSCTLBYNAME + if (SDL_SystemRAM <= 0) { +#ifdef __FreeBSD__ +#ifdef HW_REALMEM + int mib[2] = {CTL_HW, HW_REALMEM}; +#else + /* might only report up to 2 GiB */ + int mib[2] = {CTL_HW, HW_PHYSMEM}; +#endif /* HW_REALMEM */ +#else + int mib[2] = {CTL_HW, HW_MEMSIZE}; +#endif /* __FreeBSD__ */ + Uint64 memsize = 0; + size_t len = sizeof(memsize); + + if (sysctl(mib, 2, &memsize, &len, NULL, 0) == 0) { + SDL_SystemRAM = (int)(memsize / (1024*1024)); + } + } +#endif +#ifdef __WIN32__ + if (SDL_SystemRAM <= 0) { + MEMORYSTATUSEX stat; + stat.dwLength = sizeof(stat); + if (GlobalMemoryStatusEx(&stat)) { + SDL_SystemRAM = (int)(stat.ullTotalPhys / (1024 * 1024)); + } + } +#endif + } + return SDL_SystemRAM; +} + + #ifdef TEST_MAIN #include @@ -627,6 +673,7 @@ main() printf("SSE3: %d\n", SDL_HasSSE3()); printf("SSE4.1: %d\n", SDL_HasSSE41()); printf("SSE4.2: %d\n", SDL_HasSSE42()); + printf("RAM: %d MB\n", SDL_GetSystemRAM()); return 0; } diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c index 06cb0f2e7..99845034a 100644 --- a/src/events/SDL_events.c +++ b/src/events/SDL_events.c @@ -83,7 +83,7 @@ static struct } SDL_EventQ = { NULL, SDL_TRUE }; -static __inline__ SDL_bool +static SDL_INLINE SDL_bool SDL_ShouldPollJoystick() { #if !SDL_JOYSTICK_DISABLED @@ -141,10 +141,8 @@ SDL_StopEventLoop(void) /* Clear disabled event state */ for (i = 0; i < SDL_arraysize(SDL_disabled_events); ++i) { - if (SDL_disabled_events[i]) { - SDL_free(SDL_disabled_events[i]); - SDL_disabled_events[i] = NULL; - } + SDL_free(SDL_disabled_events[i]); + SDL_disabled_events[i] = NULL; } while (SDL_event_watchers) { @@ -445,7 +443,7 @@ SDL_WaitEventTimeout(SDL_Event * event, int timeout) /* Polling and no events, just return */ return 0; } - if (timeout > 0 && ((int) (SDL_GetTicks() - expiration) >= 0)) { + if (timeout > 0 && SDL_TICKS_PASSED(SDL_GetTicks(), expiration)) { /* Timeout expired and no events */ return 0; } diff --git a/src/events/SDL_gesture.c b/src/events/SDL_gesture.c index e987fcfbf..20ce57b57 100644 --- a/src/events/SDL_gesture.c +++ b/src/events/SDL_gesture.c @@ -121,8 +121,8 @@ static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops * src) if (src == NULL) return 0; - //No Longer storing the Hash, rehash on load - //if(SDL_RWops.write(src,&(templ->hash),sizeof(templ->hash),1) != 1) return 0; + /* No Longer storing the Hash, rehash on load */ + /* if(SDL_RWops.write(src,&(templ->hash),sizeof(templ->hash),1) != 1) return 0; */ if (SDL_RWwrite(src,templ->path, sizeof(templ->path[0]),DOLLARNPOINTS) != DOLLARNPOINTS) @@ -158,8 +158,8 @@ int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *src) return SDL_SetError("Unknown gestureId"); } -//path is an already sampled set of points -//Returns the index of the gesture on success, or -1 +/* path is an already sampled set of points +Returns the index of the gesture on success, or -1 */ static int SDL_AddDollarGesture_one(SDL_GestureTouch* inTouch, SDL_FloatPoint* path) { SDL_DollarTemplate* dollarTemplate; @@ -196,7 +196,7 @@ static int SDL_AddDollarGesture(SDL_GestureTouch* inTouch, SDL_FloatPoint* path) if (index < 0) return -1; } - // Use the index of the last one added. + /* Use the index of the last one added. */ return index; } else { return SDL_AddDollarGesture_one(inTouch, path); @@ -223,16 +223,16 @@ int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) DOLLARNPOINTS) break; if (touchId >= 0) { - //printf("Adding loaded gesture to 1 touch\n"); + /* printf("Adding loaded gesture to 1 touch\n"); */ if (SDL_AddDollarGesture(touch, templ.path) >= 0) loaded++; } else { - //printf("Adding to: %i touches\n",SDL_numGestureTouches); + /* printf("Adding to: %i touches\n",SDL_numGestureTouches); */ for (i = 0; i < SDL_numGestureTouches; i++) { touch = &SDL_gestureTouch[i]; - //printf("Adding loaded gesture to + touches\n"); - //TODO: What if this fails? + /* printf("Adding loaded gesture to + touches\n"); */ + /* TODO: What if this fails? */ SDL_AddDollarGesture(touch,templ.path); } loaded++; @@ -245,7 +245,7 @@ int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) static float dollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ,float ang) { - // SDL_FloatPoint p[DOLLARNPOINTS]; + /* SDL_FloatPoint p[DOLLARNPOINTS]; */ float dist = 0; SDL_FloatPoint p; int i; @@ -261,9 +261,10 @@ static float dollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ,float static float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ) { - //------------BEGIN DOLLAR BLACKBOX----------------// - //-TRANSLATED DIRECTLY FROM PSUDEO-CODE AVAILABLE AT-// - //-"http://depts.washington.edu/aimgroup/proj/dollar/"-// + /*------------BEGIN DOLLAR BLACKBOX------------------ + -TRANSLATED DIRECTLY FROM PSUDEO-CODE AVAILABLE AT- + -"http://depts.washington.edu/aimgroup/proj/dollar/" + */ double ta = -M_PI/4; double tb = M_PI/4; double dt = M_PI/90; @@ -296,7 +297,7 @@ static float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ) return SDL_min(f1,f2); } -//DollarPath contains raw points, plus (possibly) the calculated length +/* DollarPath contains raw points, plus (possibly) the calculated length */ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) { int i; @@ -309,7 +310,7 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) float w,h; float length = path->length; - //Calculate length if it hasn't already been done + /* Calculate length if it hasn't already been done */ if (length <= 0) { for (i=1;i < path->numPoints; i++) { float dx = path->p[i ].x - path->p[i-1].x; @@ -318,17 +319,17 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) } } - //Resample + /* Resample */ interval = length/(DOLLARNPOINTS - 1); dist = interval; centroid.x = 0;centroid.y = 0; - //printf("(%f,%f)\n",path->p[path->numPoints-1].x,path->p[path->numPoints-1].y); + /* printf("(%f,%f)\n",path->p[path->numPoints-1].x,path->p[path->numPoints-1].y); */ for (i = 1; i < path->numPoints; i++) { float d = (float)(SDL_sqrt((path->p[i-1].x-path->p[i].x)*(path->p[i-1].x-path->p[i].x)+ (path->p[i-1].y-path->p[i].y)*(path->p[i-1].y-path->p[i].y))); - //printf("d = %f dist = %f/%f\n",d,dist,interval); + /* printf("d = %f dist = %f/%f\n",d,dist,interval); */ while (dist + d > interval) { points[numPoints].x = path->p[i-1].x + ((interval-dist)/d)*(path->p[i].x-path->p[i-1].x); @@ -346,15 +347,15 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) SDL_SetError("ERROR: NumPoints = %i\n",numPoints); return 0; } - //copy the last point + /* copy the last point */ points[DOLLARNPOINTS-1] = path->p[path->numPoints-1]; numPoints = DOLLARNPOINTS; centroid.x /= numPoints; centroid.y /= numPoints; - //printf("Centroid (%f,%f)",centroid.x,centroid.y); - //Rotate Points so point 0 is left of centroid and solve for the bounding box + /* printf("Centroid (%f,%f)",centroid.x,centroid.y); */ + /* Rotate Points so point 0 is left of centroid and solve for the bounding box */ xmin = centroid.x; xmax = centroid.x; ymin = centroid.y; @@ -378,7 +379,7 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) if (points[i].y > ymax) ymax = points[i].y; } - //Scale points to DOLLARSIZE, and translate to the origin + /* Scale points to DOLLARSIZE, and translate to the origin */ w = xmax-xmin; h = ymax-ymin; @@ -399,7 +400,7 @@ static float dollarRecognize(const SDL_DollarPath *path,int *bestTempl,SDL_Gestu dollarNormalize(path,points); - //PrintPath(points); + /* PrintPath(points); */ *bestTempl = -1; for (i = 0; i < touch->numDollarTemplates; i++) { float diff = bestDollarDifference(points,touch->dollarTemplate[i].path); @@ -435,7 +436,7 @@ static SDL_GestureTouch * SDL_GetGestureTouch(SDL_TouchID id) { int i; for (i = 0; i < SDL_numGestureTouches; i++) { - //printf("%i ?= %i\n",SDL_gestureTouch[i].id,id); + /* printf("%i ?= %i\n",SDL_gestureTouch[i].id,id); */ if (SDL_gestureTouch[i].id == id) return &SDL_gestureTouch[i]; } @@ -465,7 +466,7 @@ static int SDL_SendGestureDollar(SDL_GestureTouch* touch, event.mgesture.y = touch->centroid.y; event.dgesture.gestureId = gestureId; event.dgesture.error = error; - //A finger came up to trigger this event. + /* A finger came up to trigger this event. */ event.dgesture.numFingers = touch->numDownFingers + 1; return SDL_PushEvent(&event) > 0; } @@ -500,13 +501,13 @@ void SDL_GestureProcessEvent(SDL_Event* event) event->type == SDL_FINGERUP) { SDL_GestureTouch* inTouch = SDL_GetGestureTouch(event->tfinger.touchId); - //Shouldn't be possible + /* Shouldn't be possible */ if (inTouch == NULL) return; x = event->tfinger.x; y = event->tfinger.y; - //Finger Up + /* Finger Up */ if (event->type == SDL_FINGERUP) { inTouch->numDownFingers--; @@ -514,7 +515,7 @@ void SDL_GestureProcessEvent(SDL_Event* event) if (inTouch->recording) { inTouch->recording = SDL_FALSE; dollarNormalize(&inTouch->dollarPath,path); - //PrintPath(path); + /* PrintPath(path); */ if (recordAll) { index = SDL_AddDollarGesture(NULL,path); for (i = 0; i < SDL_numGestureTouches; i++) @@ -537,14 +538,14 @@ void SDL_GestureProcessEvent(SDL_Event* event) error = dollarRecognize(&inTouch->dollarPath, &bestTempl,inTouch); if (bestTempl >= 0){ - //Send Event + /* Send Event */ unsigned long gestureId = inTouch->dollarTemplate[bestTempl].hash; SDL_SendGestureDollar(inTouch,gestureId,error); - //printf ("%s\n",);("Dollar error: %f\n",error); + /* printf ("%s\n",);("Dollar error: %f\n",error); */ } } #endif - //inTouch->gestureLast[j] = inTouch->gestureLast[inTouch->numDownFingers]; + /* inTouch->gestureLast[j] = inTouch->gestureLast[inTouch->numDownFingers]; */ if (inTouch->numDownFingers > 0) { inTouch->centroid.x = (inTouch->centroid.x*(inTouch->numDownFingers+1)- x)/inTouch->numDownFingers; @@ -574,22 +575,22 @@ void SDL_GestureProcessEvent(SDL_Event* event) inTouch->centroid.x += dx/inTouch->numDownFingers; inTouch->centroid.y += dy/inTouch->numDownFingers; - //printf("Centrid : (%f,%f)\n",inTouch->centroid.x,inTouch->centroid.y); + /* printf("Centrid : (%f,%f)\n",inTouch->centroid.x,inTouch->centroid.y); */ if (inTouch->numDownFingers > 1) { - SDL_FloatPoint lv; //Vector from centroid to last x,y position - SDL_FloatPoint v; //Vector from centroid to current x,y position - //lv = inTouch->gestureLast[j].cv; + SDL_FloatPoint lv; /* Vector from centroid to last x,y position */ + SDL_FloatPoint v; /* Vector from centroid to current x,y position */ + /* lv = inTouch->gestureLast[j].cv; */ lv.x = lastP.x - lastCentroid.x; lv.y = lastP.y - lastCentroid.y; lDist = (float)SDL_sqrt(lv.x*lv.x + lv.y*lv.y); - //printf("lDist = %f\n",lDist); + /* printf("lDist = %f\n",lDist); */ v.x = x - inTouch->centroid.x; v.y = y - inTouch->centroid.y; - //inTouch->gestureLast[j].cv = v; + /* inTouch->gestureLast[j].cv = v; */ Dist = (float)SDL_sqrt(v.x*v.x+v.y*v.y); - // SDL_cos(dTheta) = (v . lv)/(|v| * |lv|) + /* SDL_cos(dTheta) = (v . lv)/(|v| * |lv|) */ - //Normalize Vectors to simplify angle calculation + /* Normalize Vectors to simplify angle calculation */ lv.x/=lDist; lv.y/=lDist; v.x/=Dist; @@ -597,30 +598,30 @@ void SDL_GestureProcessEvent(SDL_Event* event) dtheta = (float)SDL_atan2(lv.x*v.y - lv.y*v.x,lv.x*v.x + lv.y*v.y); dDist = (Dist - lDist); - if (lDist == 0) {dDist = 0;dtheta = 0;} //To avoid impossible values + if (lDist == 0) {dDist = 0;dtheta = 0;} /* To avoid impossible values */ - //inTouch->gestureLast[j].dDist = dDist; - //inTouch->gestureLast[j].dtheta = dtheta; + /* inTouch->gestureLast[j].dDist = dDist; + inTouch->gestureLast[j].dtheta = dtheta; - //printf("dDist = %f, dTheta = %f\n",dDist,dtheta); - //gdtheta = gdtheta*.9 + dtheta*.1; - //gdDist = gdDist*.9 + dDist*.1 - //knob.r += dDist/numDownFingers; - //knob.ang += dtheta; - //printf("thetaSum = %f, distSum = %f\n",gdtheta,gdDist); - //printf("id: %i dTheta = %f, dDist = %f\n",j,dtheta,dDist); + printf("dDist = %f, dTheta = %f\n",dDist,dtheta); + gdtheta = gdtheta*.9 + dtheta*.1; + gdDist = gdDist*.9 + dDist*.1 + knob.r += dDist/numDownFingers; + knob.ang += dtheta; + printf("thetaSum = %f, distSum = %f\n",gdtheta,gdDist); + printf("id: %i dTheta = %f, dDist = %f\n",j,dtheta,dDist); */ SDL_SendGestureMulti(inTouch,dtheta,dDist); } else { - //inTouch->gestureLast[j].dDist = 0; - //inTouch->gestureLast[j].dtheta = 0; - //inTouch->gestureLast[j].cv.x = 0; - //inTouch->gestureLast[j].cv.y = 0; + /* inTouch->gestureLast[j].dDist = 0; + inTouch->gestureLast[j].dtheta = 0; + inTouch->gestureLast[j].cv.x = 0; + inTouch->gestureLast[j].cv.y = 0; */ } - //inTouch->gestureLast[j].f.p.x = x; - //inTouch->gestureLast[j].f.p.y = y; - //break; - //pressure? + /* inTouch->gestureLast[j].f.p.x = x; + inTouch->gestureLast[j].f.p.y = y; + break; + pressure? */ } if (event->type == SDL_FINGERDOWN) { @@ -630,8 +631,8 @@ void SDL_GestureProcessEvent(SDL_Event* event) x)/inTouch->numDownFingers; inTouch->centroid.y = (inTouch->centroid.y*(inTouch->numDownFingers - 1)+ y)/inTouch->numDownFingers; - //printf("Finger Down: (%f,%f). Centroid: (%f,%f\n",x,y, - // inTouch->centroid.x,inTouch->centroid.y); + /* printf("Finger Down: (%f,%f). Centroid: (%f,%f\n",x,y, + inTouch->centroid.x,inTouch->centroid.y); */ #ifdef ENABLE_DOLLAR inTouch->dollarPath.length = 0; diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c index a3ed16869..34d94d0ef 100644 --- a/src/events/SDL_keyboard.c +++ b/src/events/SDL_keyboard.c @@ -28,7 +28,7 @@ #include "../video/SDL_sysvideo.h" -/*#define DEBUG_KEYBOARD*/ +/* #define DEBUG_KEYBOARD */ /* Global keyboard information */ @@ -507,7 +507,7 @@ static const char *SDL_scancode_names[SDL_NUM_SCANCODES] = { }; /* Taken from SDL_iconv() */ -static char * +char * SDL_UCS4ToUTF8(Uint32 ch, char *dst) { Uint8 *p = (Uint8 *) dst; diff --git a/src/events/SDL_keyboard_c.h b/src/events/SDL_keyboard_c.h index 17203998b..cd9f1bb6b 100644 --- a/src/events/SDL_keyboard_c.h +++ b/src/events/SDL_keyboard_c.h @@ -59,6 +59,9 @@ extern int SDL_SendEditingText(const char *text, int start, int end); /* Shutdown the keyboard subsystem */ extern void SDL_KeyboardQuit(void); +/* Convert to UTF-8 */ +extern char *SDL_UCS4ToUTF8(Uint32 ch, char *dst); + #endif /* _SDL_keyboard_c_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index e9404f057..0886f54fa 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -28,7 +28,7 @@ #include "default_cursor.h" #include "../video/SDL_sysvideo.h" -/*#define DEBUG_MOUSE*/ +/* #define DEBUG_MOUSE */ /* The mouse state */ static SDL_Mouse SDL_mouse; @@ -246,13 +246,11 @@ SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relativ mouse->xdelta += xrel; mouse->ydelta += yrel; -#if 0 /* FIXME */ /* Move the mouse cursor, if needed */ if (mouse->cursor_shown && !mouse->relative_mode && mouse->MoveCursor && mouse->cur_cursor) { mouse->MoveCursor(mouse->cur_cursor); } -#endif /* Post the event, if desired */ posted = 0; @@ -571,9 +569,7 @@ SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y) mouse->cursors = cursor; } - if (temp) { - SDL_FreeSurface(temp); - } + SDL_FreeSurface(temp); return cursor; } diff --git a/src/events/SDL_touch.c b/src/events/SDL_touch.c index 3429b57d7..1874ba7f5 100644 --- a/src/events/SDL_touch.c +++ b/src/events/SDL_touch.c @@ -355,10 +355,8 @@ SDL_TouchQuit(void) } SDL_assert(SDL_num_touch == 0); - if (SDL_touchDevices) { - SDL_free(SDL_touchDevices); - SDL_touchDevices = NULL; - } + SDL_free(SDL_touchDevices); + SDL_touchDevices = NULL; } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/events/scancodes_windows.h b/src/events/scancodes_windows.h index 1034b1b57..3462e14ef 100644 --- a/src/events/scancodes_windows.h +++ b/src/events/scancodes_windows.h @@ -26,30 +26,30 @@ /* *INDENT-OFF* */ static const SDL_Scancode windows_scancode_table[] = { - // 0 1 2 3 4 5 6 7 - // 8 9 A B C D E F - SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_ESCAPE, SDL_SCANCODE_1, SDL_SCANCODE_2, SDL_SCANCODE_3, SDL_SCANCODE_4, SDL_SCANCODE_5, SDL_SCANCODE_6, // 0 - SDL_SCANCODE_7, SDL_SCANCODE_8, SDL_SCANCODE_9, SDL_SCANCODE_0, SDL_SCANCODE_MINUS, SDL_SCANCODE_EQUALS, SDL_SCANCODE_BACKSPACE, SDL_SCANCODE_TAB, // 0 + /* 0 1 2 3 4 5 6 7 */ + /* 8 9 A B C D E F */ + SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_ESCAPE, SDL_SCANCODE_1, SDL_SCANCODE_2, SDL_SCANCODE_3, SDL_SCANCODE_4, SDL_SCANCODE_5, SDL_SCANCODE_6, /* 0 */ + SDL_SCANCODE_7, SDL_SCANCODE_8, SDL_SCANCODE_9, SDL_SCANCODE_0, SDL_SCANCODE_MINUS, SDL_SCANCODE_EQUALS, SDL_SCANCODE_BACKSPACE, SDL_SCANCODE_TAB, /* 0 */ - SDL_SCANCODE_Q, SDL_SCANCODE_W, SDL_SCANCODE_E, SDL_SCANCODE_R, SDL_SCANCODE_T, SDL_SCANCODE_Y, SDL_SCANCODE_U, SDL_SCANCODE_I, // 1 - SDL_SCANCODE_O, SDL_SCANCODE_P, SDL_SCANCODE_LEFTBRACKET, SDL_SCANCODE_RIGHTBRACKET, SDL_SCANCODE_RETURN, SDL_SCANCODE_LCTRL, SDL_SCANCODE_A, SDL_SCANCODE_S, // 1 + SDL_SCANCODE_Q, SDL_SCANCODE_W, SDL_SCANCODE_E, SDL_SCANCODE_R, SDL_SCANCODE_T, SDL_SCANCODE_Y, SDL_SCANCODE_U, SDL_SCANCODE_I, /* 1 */ + SDL_SCANCODE_O, SDL_SCANCODE_P, SDL_SCANCODE_LEFTBRACKET, SDL_SCANCODE_RIGHTBRACKET, SDL_SCANCODE_RETURN, SDL_SCANCODE_LCTRL, SDL_SCANCODE_A, SDL_SCANCODE_S, /* 1 */ - SDL_SCANCODE_D, SDL_SCANCODE_F, SDL_SCANCODE_G, SDL_SCANCODE_H, SDL_SCANCODE_J, SDL_SCANCODE_K, SDL_SCANCODE_L, SDL_SCANCODE_SEMICOLON, // 2 - SDL_SCANCODE_APOSTROPHE, SDL_SCANCODE_GRAVE, SDL_SCANCODE_LSHIFT, SDL_SCANCODE_BACKSLASH, SDL_SCANCODE_Z, SDL_SCANCODE_X, SDL_SCANCODE_C, SDL_SCANCODE_V, // 2 + SDL_SCANCODE_D, SDL_SCANCODE_F, SDL_SCANCODE_G, SDL_SCANCODE_H, SDL_SCANCODE_J, SDL_SCANCODE_K, SDL_SCANCODE_L, SDL_SCANCODE_SEMICOLON, /* 2 */ + SDL_SCANCODE_APOSTROPHE, SDL_SCANCODE_GRAVE, SDL_SCANCODE_LSHIFT, SDL_SCANCODE_BACKSLASH, SDL_SCANCODE_Z, SDL_SCANCODE_X, SDL_SCANCODE_C, SDL_SCANCODE_V, /* 2 */ - SDL_SCANCODE_B, SDL_SCANCODE_N, SDL_SCANCODE_M, SDL_SCANCODE_COMMA, SDL_SCANCODE_PERIOD, SDL_SCANCODE_SLASH, SDL_SCANCODE_RSHIFT, SDL_SCANCODE_PRINTSCREEN,// 3 - SDL_SCANCODE_LALT, SDL_SCANCODE_SPACE, SDL_SCANCODE_CAPSLOCK, SDL_SCANCODE_F1, SDL_SCANCODE_F2, SDL_SCANCODE_F3, SDL_SCANCODE_F4, SDL_SCANCODE_F5, // 3 + SDL_SCANCODE_B, SDL_SCANCODE_N, SDL_SCANCODE_M, SDL_SCANCODE_COMMA, SDL_SCANCODE_PERIOD, SDL_SCANCODE_SLASH, SDL_SCANCODE_RSHIFT, SDL_SCANCODE_PRINTSCREEN,/* 3 */ + SDL_SCANCODE_LALT, SDL_SCANCODE_SPACE, SDL_SCANCODE_CAPSLOCK, SDL_SCANCODE_F1, SDL_SCANCODE_F2, SDL_SCANCODE_F3, SDL_SCANCODE_F4, SDL_SCANCODE_F5, /* 3 */ - SDL_SCANCODE_F6, SDL_SCANCODE_F7, SDL_SCANCODE_F8, SDL_SCANCODE_F9, SDL_SCANCODE_F10, SDL_SCANCODE_NUMLOCKCLEAR, SDL_SCANCODE_SCROLLLOCK, SDL_SCANCODE_HOME, // 4 - SDL_SCANCODE_UP, SDL_SCANCODE_PAGEUP, SDL_SCANCODE_KP_MINUS, SDL_SCANCODE_LEFT, SDL_SCANCODE_KP_5, SDL_SCANCODE_RIGHT, SDL_SCANCODE_KP_PLUS, SDL_SCANCODE_END, // 4 + SDL_SCANCODE_F6, SDL_SCANCODE_F7, SDL_SCANCODE_F8, SDL_SCANCODE_F9, SDL_SCANCODE_F10, SDL_SCANCODE_NUMLOCKCLEAR, SDL_SCANCODE_SCROLLLOCK, SDL_SCANCODE_HOME, /* 4 */ + SDL_SCANCODE_UP, SDL_SCANCODE_PAGEUP, SDL_SCANCODE_KP_MINUS, SDL_SCANCODE_LEFT, SDL_SCANCODE_KP_5, SDL_SCANCODE_RIGHT, SDL_SCANCODE_KP_PLUS, SDL_SCANCODE_END, /* 4 */ - SDL_SCANCODE_DOWN, SDL_SCANCODE_PAGEDOWN, SDL_SCANCODE_INSERT, SDL_SCANCODE_DELETE, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_NONUSBACKSLASH,SDL_SCANCODE_F11, // 5 - SDL_SCANCODE_F12, SDL_SCANCODE_PAUSE, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_LGUI, SDL_SCANCODE_RGUI, SDL_SCANCODE_APPLICATION, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, // 5 + SDL_SCANCODE_DOWN, SDL_SCANCODE_PAGEDOWN, SDL_SCANCODE_INSERT, SDL_SCANCODE_DELETE, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_NONUSBACKSLASH,SDL_SCANCODE_F11, /* 5 */ + SDL_SCANCODE_F12, SDL_SCANCODE_PAUSE, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_LGUI, SDL_SCANCODE_RGUI, SDL_SCANCODE_APPLICATION, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, /* 5 */ - SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_F13, SDL_SCANCODE_F14, SDL_SCANCODE_F15, SDL_SCANCODE_F16, // 6 - SDL_SCANCODE_F17, SDL_SCANCODE_F18, SDL_SCANCODE_F19, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, // 6 + SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_F13, SDL_SCANCODE_F14, SDL_SCANCODE_F15, SDL_SCANCODE_F16, /* 6 */ + SDL_SCANCODE_F17, SDL_SCANCODE_F18, SDL_SCANCODE_F19, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, /* 6 */ - SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, // 7 - SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN // 7 + SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, /* 7 */ + SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN /* 7 */ }; /* *INDENT-ON* */ diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c index 3a6f7db66..73e9846aa 100644 --- a/src/file/SDL_rwops.c +++ b/src/file/SDL_rwops.c @@ -22,6 +22,11 @@ #define _LARGEFILE64_SOURCE #include "SDL_config.h" +#if defined(__WIN32__) +#include "../core/windows/SDL_windows.h" +#endif + + /* This file provides a general interface for SDL to read and write data sources. It can easily be extended to files, memory, etc. */ @@ -42,8 +47,6 @@ /* Functions to read/write Win32 API file pointers */ -#include "../core/windows/SDL_windows.h" - #ifndef INVALID_SET_FILE_POINTER #define INVALID_SET_FILE_POINTER 0xFFFFFFFF #endif @@ -275,10 +278,8 @@ windows_file_close(SDL_RWops * context) CloseHandle(context->hidden.windowsio.h); context->hidden.windowsio.h = INVALID_HANDLE_VALUE; /* to be sure */ } - if (context->hidden.windowsio.buffer.data) { - SDL_free(context->hidden.windowsio.buffer.data); - context->hidden.windowsio.buffer.data = NULL; - } + SDL_free(context->hidden.windowsio.buffer.data); + context->hidden.windowsio.buffer.data = NULL; SDL_FreeRW(context); } return (0); diff --git a/src/filesystem/beos/SDL_sysfilesystem.cc b/src/filesystem/beos/SDL_sysfilesystem.cc new file mode 100644 index 000000000..dc7a97064 --- /dev/null +++ b/src/filesystem/beos/SDL_sysfilesystem.cc @@ -0,0 +1,93 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ +#include "SDL_config.h" + +#ifdef SDL_FILESYSTEM_BEOS + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* System dependent filesystem routines */ + +#include +#include +#include +#include + +#include "SDL_error.h" +#include "SDL_stdinc.h" +#include "SDL_assert.h" +#include "SDL_filesystem.h" + +char * +SDL_GetBasePath(void) +{ + image_info info; + int32 cookie = 0; + + while (get_next_image_info(0, &cookie, &info) == B_OK) { + if (info.type == B_APP_IMAGE) { + break; + } + } + + BEntry entry(info.name, true); + BPath path; + status_t rc = entry.GetPath(&path); /* (path) now has binary's path. */ + SDL_assert(rc == B_OK); + rc = path.GetParent(&path); /* chop filename, keep directory. */ + SDL_assert(rc == B_OK); + const char *str = path.Path(); + SDL_assert(str != NULL); + + const size_t len = SDL_strlen(str); + char *retval = (char *) SDL_malloc(len + 2); + if (!retval) { + SDL_OutOfMemory(); + return NULL; + } + + SDL_memcpy(retval, str, len); + retval[len] = '/'; + retval[len+1] = '\0'; + return retval; +} + + +char * +SDL_GetPrefPath(const char *org, const char *app) +{ + // !!! FIXME: is there a better way to do this? + const char *home = SDL_getenv("HOME"); + const char *append = "config/settings/"; + const size_t len = SDL_strlen(home) + SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3; + char *retval = (char *) SDL_malloc(len); + if (!retval) { + SDL_OutOfMemory(); + } else { + SDL_snprintf(retval, len, "%s%s%s/%s/", home, append, org, app); + create_directory(retval, 0700); // BeOS api: creates missing dirs + } + + return retval; +} + +#endif /* SDL_FILESYSTEM_BEOS */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/filesystem/cocoa/SDL_sysfilesystem.m b/src/filesystem/cocoa/SDL_sysfilesystem.m new file mode 100644 index 000000000..587c35cc0 --- /dev/null +++ b/src/filesystem/cocoa/SDL_sysfilesystem.m @@ -0,0 +1,105 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ +#include "SDL_config.h" + +#ifdef SDL_FILESYSTEM_COCOA + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* System dependent filesystem routines */ + +#include +#include +#include + +#include "SDL_error.h" +#include "SDL_stdinc.h" +#include "SDL_filesystem.h" + +char * +SDL_GetBasePath(void) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSBundle *bundle = [NSBundle mainBundle]; + const char* baseType = [[[bundle infoDictionary] objectForKey:@"SDL_FILESYSTEM_BASE_DIR_TYPE"] UTF8String]; + const char *base = NULL; + char *retval = NULL; + if (baseType == NULL) { + baseType = "resource"; + } + if (SDL_strcasecmp(baseType, "bundle")==0) { + base = [[bundle bundlePath] fileSystemRepresentation]; + } else if (SDL_strcasecmp(baseType, "parent")==0) { + base = [[[bundle bundlePath] stringByDeletingLastPathComponent] fileSystemRepresentation]; + } else { + /* this returns the exedir for non-bundled and the resourceDir for bundled apps */ + base = [[bundle resourcePath] fileSystemRepresentation]; + } + if (base) { + const size_t len = SDL_strlen(base) + 2; + retval = (char *) SDL_malloc(len); + if (retval == NULL) { + SDL_OutOfMemory(); + } else { + SDL_snprintf(retval, len, "%s/", base); + } + } + + [pool release]; + return retval; +} + +char * +SDL_GetPrefPath(const char *org, const char *app) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSArray *array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); + char *retval = NULL; + + if ([array count] > 0) { /* we only want the first item in the list. */ + NSString *str = [array objectAtIndex:0]; + const char *base = [str fileSystemRepresentation]; + if (base) { + const size_t len = SDL_strlen(base) + SDL_strlen(org) + SDL_strlen(app) + 4; + retval = (char *) SDL_malloc(len); + if (retval == NULL) { + SDL_OutOfMemory(); + } else { + char *ptr; + SDL_snprintf(retval, len, "%s/%s/%s/", base, org, app); + for (ptr = retval+1; *ptr; ptr++) { + if (*ptr == '/') { + *ptr = '\0'; + mkdir(retval, 0700); + *ptr = '/'; + } + } + mkdir(retval, 0700); + } + } + } + + [pool release]; + return retval; +} + +#endif /* SDL_FILESYSTEM_COCOA */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/filesystem/dummy/SDL_sysfilesystem.c b/src/filesystem/dummy/SDL_sysfilesystem.c new file mode 100644 index 000000000..a6bd57767 --- /dev/null +++ b/src/filesystem/dummy/SDL_sysfilesystem.c @@ -0,0 +1,47 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ +#include "SDL_config.h" + +#ifdef SDL_FILESYSTEM_DUMMY + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* System dependent filesystem routines */ + +#include "SDL_error.h" +#include "SDL_filesystem.h" + +char * +SDL_GetBasePath(void) +{ + SDL_Unsupported(); + return NULL; +} + +char * +SDL_GetPrefPath(const char *org, const char *app) +{ + SDL_Unsupported(); + return NULL; +} + +#endif /* SDL_FILESYSTEM_DUMMY */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c new file mode 100644 index 000000000..0f6e62e24 --- /dev/null +++ b/src/filesystem/unix/SDL_sysfilesystem.c @@ -0,0 +1,210 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ +#include "SDL_config.h" + +#ifdef SDL_FILESYSTEM_UNIX + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* System dependent filesystem routines */ + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __FREEBSD__ +#include +#endif + +#include "SDL_error.h" +#include "SDL_stdinc.h" +#include "SDL_filesystem.h" + +static char * +readSymLink(const char *path) +{ + char *retval = NULL; + ssize_t len = 64; + ssize_t rc = -1; + + while (1) + { + char *ptr = (char *) SDL_realloc(retval, (size_t) len); + if (ptr == NULL) { + SDL_OutOfMemory(); + break; + } + + retval = ptr; + + rc = readlink(path, retval, len); + if (rc == -1) { + break; /* not a symlink, i/o error, etc. */ + } else if (rc < len) { + retval[rc] = '\0'; /* readlink doesn't null-terminate. */ + return retval; /* we're good to go. */ + } + + len *= 2; /* grow buffer, try again. */ + } + + SDL_free(retval); + return NULL; +} + + +char * +SDL_GetBasePath(void) +{ + char *retval = NULL; + +#if defined(__FREEBSD__) + char fullpath[PATH_MAX]; + size_t buflen = sizeof (fullpath); + const int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; + if (sysctl(mib, SDL_arraysize(mib), fullpath, &buflen, NULL, 0) != -1) { + retval = SDL_strdup(fullpath); + if (!retval) { + SDL_OutOfMemory(); + return NULL; + } + } +#elif defined(__SOLARIS__) + const char *path = getexecname(); + if ((path != NULL) && (path[0] == '/')) { /* must be absolute path... */ + retval = SDL_strdup(path); + if (!retval) { + SDL_OutOfMemory(); + return NULL; + } + } +#endif + + /* is a Linux-style /proc filesystem available? */ + if (!retval && (access("/proc", F_OK) == 0)) { +#if defined(__FREEBSD__) + retval = readSymLink("/proc/curproc/file"); +#elif defined(__NETBSD__) + retval = readSymLink("/proc/curproc/exe"); +#else + retval = readSymLink("/proc/self/exe"); /* linux. */ +#endif + if (retval == NULL) { + /* older kernels don't have /proc/self ... try PID version... */ + char path[64]; + const int rc = (int) SDL_snprintf(path, sizeof(path), + "/proc/%llu/exe", + (unsigned long long) getpid()); + if ( (rc > 0) && (rc < sizeof(path)) ) { + retval = readSymLink(path); + } + } + } + + /* If we had access to argv[0] here, we could check it for a path, + or troll through $PATH looking for it, too. */ + + if (retval != NULL) { /* chop off filename. */ + char *ptr = SDL_strrchr(retval, '/'); + if (ptr != NULL) { + *(ptr+1) = '\0'; + } else { /* shouldn't happen, but just in case... */ + SDL_free(retval); + retval = NULL; + } + } + + if (retval != NULL) { + /* try to shrink buffer... */ + char *ptr = (char *) SDL_realloc(retval, strlen(retval) + 1); + if (ptr != NULL) + retval = ptr; /* oh well if it failed. */ + } + + return retval; +} + +char * +SDL_GetPrefPath(const char *org, const char *app) +{ + /* + * We use XDG's base directory spec, even if you're not on Linux. + * This isn't strictly correct, but the results are relatively sane + * in any case. + * + * http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html + */ + const char *envr = SDL_getenv("XDG_DATA_HOME"); + const char *append; + char *retval = NULL; + char *ptr = NULL; + size_t len = 0; + + if (!envr) { + /* You end up with "$HOME/.local/share/Game Name 2" */ + envr = SDL_getenv("HOME"); + if (!envr) { + /* we could take heroic measures with /etc/passwd, but oh well. */ + SDL_SetError("neither XDG_DATA_HOME nor HOME environment is set"); + return NULL; + } + append = "/.local/share/"; + } else { + append = "/"; + } + + len = SDL_strlen(envr); + if (envr[len - 1] == '/') + append += 1; + + len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3; + retval = (char *) SDL_malloc(len); + if (!retval) { + SDL_OutOfMemory(); + return NULL; + } + + SDL_snprintf(retval, len, "%s%s%s/%s/", envr, append, org, app); + + for (ptr = retval+1; *ptr; ptr++) { + if (*ptr == '/') { + *ptr = '\0'; + if (mkdir(retval, 0700) != 0 && errno != EEXIST) + goto error; + *ptr = '/'; + } + } + if (mkdir(retval, 0700) != 0 && errno != EEXIST) { +error: + SDL_SetError("Couldn't create directory '%s': ", retval, strerror(errno)); + SDL_free(retval); + return NULL; + } + + return retval; +} + +#endif /* SDL_FILESYSTEM_UNIX */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/filesystem/windows/SDL_sysfilesystem.c b/src/filesystem/windows/SDL_sysfilesystem.c new file mode 100644 index 000000000..7b101ffed --- /dev/null +++ b/src/filesystem/windows/SDL_sysfilesystem.c @@ -0,0 +1,99 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ +#include "SDL_config.h" + +#ifdef SDL_FILESYSTEM_WINDOWS + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* System dependent filesystem routines */ + +#include "../../core/windows/SDL_windows.h" +#include + +#include "SDL_assert.h" +#include "SDL_error.h" +#include "SDL_stdinc.h" +#include "SDL_filesystem.h" + +char * +SDL_GetBasePath(void) +{ + TCHAR path[MAX_PATH]; + const DWORD len = GetModuleFileName(NULL, path, SDL_arraysize(path)); + size_t i; + + SDL_assert(len < SDL_arraysize(path)); + + if (len == 0) { + WIN_SetError("Couldn't locate our .exe"); + return NULL; + } + + for (i = len-1; i > 0; i--) { + if (path[i] == '\\') { + break; + } + } + + SDL_assert(i > 0); /* Should have been an absolute path. */ + path[i+1] = '\0'; /* chop off filename. */ + return WIN_StringToUTF8(path); +} + +char * +SDL_GetPrefPath(const char *org, const char *app) +{ + /* + * Vista and later has a new API for this, but SHGetFolderPath works there, + * and apparently just wraps the new API. This is the new way to do it: + * + * SHGetKnownFolderPath(FOLDERID_RoamingAppData, KF_FLAG_CREATE, + * NULL, &wszPath); + */ + + TCHAR path[MAX_PATH]; + char *utf8 = NULL; + char *retval = NULL; + + if (!SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, path))) { + WIN_SetError("Couldn't locate our prefpath"); + return NULL; + } + + utf8 = WIN_StringToUTF8(path); + if (utf8) { + const size_t len = SDL_strlen(utf8) + SDL_strlen(org) + SDL_strlen(app) + 4; + retval = (char *) SDL_malloc(len); + if (!retval) { + SDL_free(utf8); + SDL_OutOfMemory(); + return NULL; + } + SDL_snprintf(retval, len, "%s\\%s\\%s\\", utf8, org, app); + SDL_free(utf8); + } + + return retval; +} + +#endif /* SDL_FILESYSTEM_WINDOWS */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/haptic/SDL_haptic.c b/src/haptic/SDL_haptic.c index d7e1c5062..33dd4277c 100644 --- a/src/haptic/SDL_haptic.c +++ b/src/haptic/SDL_haptic.c @@ -379,10 +379,8 @@ void SDL_HapticQuit(void) { SDL_SYS_HapticQuit(); - if (SDL_haptics != NULL) { - SDL_free(SDL_haptics); - SDL_haptics = NULL; - } + SDL_free(SDL_haptics); + SDL_haptics = NULL; SDL_numhaptics = 0; } diff --git a/src/haptic/darwin/SDL_syshaptic.c b/src/haptic/darwin/SDL_syshaptic.c index ec889041c..c999a77d3 100644 --- a/src/haptic/darwin/SDL_syshaptic.c +++ b/src/haptic/darwin/SDL_syshaptic.c @@ -93,7 +93,7 @@ FFStrError(HRESULT err) case FFERR_DEVICEFULL: return "device full"; /* This should be valid, but for some reason isn't defined... */ - /*case FFERR_DEVICENOTREG: + /* case FFERR_DEVICENOTREG: return "device not registered"; */ case FFERR_DEVICEPAUSED: return "device paused"; @@ -343,7 +343,7 @@ GetSupportedFeatures(SDL_Haptic * haptic) FF_TEST(FFCAP_ET_CONSTANTFORCE, SDL_HAPTIC_CONSTANT); FF_TEST(FFCAP_ET_RAMPFORCE, SDL_HAPTIC_RAMP); /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*FF_TEST(FFCAP_ET_SQUARE, SDL_HAPTIC_SQUARE);*/ + /* FF_TEST(FFCAP_ET_SQUARE, SDL_HAPTIC_SQUARE); */ FF_TEST(FFCAP_ET_SINE, SDL_HAPTIC_SINE); FF_TEST(FFCAP_ET_TRIANGLE, SDL_HAPTIC_TRIANGLE); FF_TEST(FFCAP_ET_SAWTOOTHUP, SDL_HAPTIC_SAWTOOTHUP); @@ -506,7 +506,7 @@ SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) /* - * Checks to see if the haptic device and joystick and in reality the same. + * Checks to see if the haptic device and joystick are in reality the same. */ int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) @@ -752,7 +752,7 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, case SDL_HAPTIC_SINE: /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*case SDL_HAPTIC_SQUARE:*/ + /* case SDL_HAPTIC_SQUARE: */ case SDL_HAPTIC_TRIANGLE: case SDL_HAPTIC_SAWTOOTHUP: case SDL_HAPTIC_SAWTOOTHDOWN: @@ -943,14 +943,10 @@ SDL_SYS_HapticFreeFFEFFECT(FFEFFECT * effect, int type) { FFCUSTOMFORCE *custom; - if (effect->lpEnvelope != NULL) { - SDL_free(effect->lpEnvelope); - effect->lpEnvelope = NULL; - } - if (effect->rgdwAxes != NULL) { - SDL_free(effect->rgdwAxes); - effect->rgdwAxes = NULL; - } + SDL_free(effect->lpEnvelope); + effect->lpEnvelope = NULL; + SDL_free(effect->rgdwAxes); + effect->rgdwAxes = NULL; if (effect->lpvTypeSpecificParams != NULL) { if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */ custom = (FFCUSTOMFORCE *) effect->lpvTypeSpecificParams; @@ -960,10 +956,8 @@ SDL_SYS_HapticFreeFFEFFECT(FFEFFECT * effect, int type) SDL_free(effect->lpvTypeSpecificParams); effect->lpvTypeSpecificParams = NULL; } - if (effect->rglDirection != NULL) { - SDL_free(effect->rglDirection); - effect->rglDirection = NULL; - } + SDL_free(effect->rglDirection); + effect->rglDirection = NULL; } @@ -981,8 +975,8 @@ SDL_SYS_HapticEffectType(Uint16 type) return kFFEffectType_RampForce_ID; /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*case SDL_HAPTIC_SQUARE: - return kFFEffectType_Square_ID;*/ + /* case SDL_HAPTIC_SQUARE: + return kFFEffectType_Square_ID; */ case SDL_HAPTIC_SINE: return kFFEffectType_Sine_ID; @@ -1061,10 +1055,8 @@ SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, err_effectdone: SDL_SYS_HapticFreeFFEFFECT(&effect->hweffect->effect, base->type); err_hweffect: - if (effect->hweffect != NULL) { - SDL_free(effect->hweffect); - effect->hweffect = NULL; - } + SDL_free(effect->hweffect); + effect->hweffect = NULL; return -1; } diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c index ad34fc27f..e209d0500 100644 --- a/src/haptic/linux/SDL_syshaptic.c +++ b/src/haptic/linux/SDL_syshaptic.c @@ -100,7 +100,7 @@ EV_IsHaptic(int fd) EV_TEST(FF_CONSTANT, SDL_HAPTIC_CONSTANT); EV_TEST(FF_SINE, SDL_HAPTIC_SINE); /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*EV_TEST(FF_SQUARE, SDL_HAPTIC_SQUARE);*/ + /* EV_TEST(FF_SQUARE, SDL_HAPTIC_SQUARE); */ EV_TEST(FF_TRIANGLE, SDL_HAPTIC_TRIANGLE); EV_TEST(FF_SAW_UP, SDL_HAPTIC_SAWTOOTHUP); EV_TEST(FF_SAW_DOWN, SDL_HAPTIC_SAWTOOTHDOWN); @@ -368,7 +368,7 @@ SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) /* - * Checks to see if the haptic device and joystick and in reality the same. + * Checks to see if the haptic device and joystick are in reality the same. */ int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) @@ -600,7 +600,7 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src) case SDL_HAPTIC_SINE: /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*case SDL_HAPTIC_SQUARE:*/ + /* case SDL_HAPTIC_SQUARE: */ case SDL_HAPTIC_TRIANGLE: case SDL_HAPTIC_SAWTOOTHUP: case SDL_HAPTIC_SAWTOOTHDOWN: @@ -625,8 +625,8 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src) if (periodic->type == SDL_HAPTIC_SINE) dest->u.periodic.waveform = FF_SINE; /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*else if (periodic->type == SDL_HAPTIC_SQUARE) - dest->u.periodic.waveform = FF_SQUARE;*/ + /* else if (periodic->type == SDL_HAPTIC_SQUARE) + dest->u.periodic.waveform = FF_SQUARE; */ else if (periodic->type == SDL_HAPTIC_TRIANGLE) dest->u.periodic.waveform = FF_TRIANGLE; else if (periodic->type == SDL_HAPTIC_SAWTOOTHUP) diff --git a/src/haptic/windows/SDL_syshaptic.c b/src/haptic/windows/SDL_syshaptic.c index 9b1349644..1506235e7 100644 --- a/src/haptic/windows/SDL_syshaptic.c +++ b/src/haptic/windows/SDL_syshaptic.c @@ -304,7 +304,7 @@ DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv) EFFECT_TEST(GUID_CustomForce, SDL_HAPTIC_CUSTOM); EFFECT_TEST(GUID_Sine, SDL_HAPTIC_SINE); /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*EFFECT_TEST(GUID_Square, SDL_HAPTIC_SQUARE);*/ + /* EFFECT_TEST(GUID_Square, SDL_HAPTIC_SQUARE); */ EFFECT_TEST(GUID_Triangle, SDL_HAPTIC_TRIANGLE); EFFECT_TEST(GUID_SawtoothUp, SDL_HAPTIC_SAWTOOTHUP); EFFECT_TEST(GUID_SawtoothDown, SDL_HAPTIC_SAWTOOTHDOWN); @@ -631,14 +631,16 @@ SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) /* - * Checks to see if the haptic device and joystick and in reality the same. + * Checks to see if the haptic device and joystick are in reality the same. */ int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) { - if ((joystick->hwdata->bXInputHaptic == haptic->hwdata->bXInputHaptic) && (haptic->hwdata->userid == joystick->hwdata->userid)) { - return 1; - } else { + if (joystick->hwdata->bXInputHaptic != haptic->hwdata->bXInputHaptic) { + return 0; /* one is XInput, one is not; not the same device. */ + } else if (joystick->hwdata->bXInputHaptic) { /* XInput */ + return (haptic->hwdata->userid == joystick->hwdata->userid); + } else { /* DirectInput */ HRESULT ret; DIDEVICEINSTANCE hap_instance, joy_instance; @@ -751,10 +753,8 @@ SDL_SYS_HapticQuit(void) } for (i = 0; i < SDL_arraysize(SDL_hapticlist); ++i) { - if (SDL_hapticlist[i].name) { - SDL_free(SDL_hapticlist[i].name); - SDL_hapticlist[i].name = NULL; - } + SDL_free(SDL_hapticlist[i].name); + SDL_hapticlist[i].name = NULL; } if (dinput != NULL) { @@ -936,7 +936,7 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, case SDL_HAPTIC_SINE: /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*case SDL_HAPTIC_SQUARE:*/ + /* case SDL_HAPTIC_SQUARE: */ case SDL_HAPTIC_TRIANGLE: case SDL_HAPTIC_SAWTOOTHUP: case SDL_HAPTIC_SAWTOOTHDOWN: @@ -1127,14 +1127,10 @@ SDL_SYS_HapticFreeDIEFFECT(DIEFFECT * effect, int type) { DICUSTOMFORCE *custom; - if (effect->lpEnvelope != NULL) { - SDL_free(effect->lpEnvelope); - effect->lpEnvelope = NULL; - } - if (effect->rgdwAxes != NULL) { - SDL_free(effect->rgdwAxes); - effect->rgdwAxes = NULL; - } + SDL_free(effect->lpEnvelope); + effect->lpEnvelope = NULL; + SDL_free(effect->rgdwAxes); + effect->rgdwAxes = NULL; if (effect->lpvTypeSpecificParams != NULL) { if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */ custom = (DICUSTOMFORCE *) effect->lpvTypeSpecificParams; @@ -1144,10 +1140,8 @@ SDL_SYS_HapticFreeDIEFFECT(DIEFFECT * effect, int type) SDL_free(effect->lpvTypeSpecificParams); effect->lpvTypeSpecificParams = NULL; } - if (effect->rglDirection != NULL) { - SDL_free(effect->rglDirection); - effect->rglDirection = NULL; - } + SDL_free(effect->rglDirection); + effect->rglDirection = NULL; } @@ -1165,8 +1159,8 @@ SDL_SYS_HapticEffectType(SDL_HapticEffect * effect) return &GUID_RampForce; /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*case SDL_HAPTIC_SQUARE: - return &GUID_Square;*/ + /* case SDL_HAPTIC_SQUARE: + return &GUID_Square; */ case SDL_HAPTIC_SINE: return &GUID_Sine; @@ -1196,7 +1190,6 @@ SDL_SYS_HapticEffectType(SDL_HapticEffect * effect) return &GUID_CustomForce; default: - SDL_SetError("Haptic: Unknown effect type."); return NULL; } } @@ -1213,6 +1206,7 @@ SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, REFGUID type = SDL_SYS_HapticEffectType(base); if ((type == NULL) && (!haptic->hwdata->bXInputHaptic)) { + SDL_SetError("Haptic: Unknown effect type."); goto err_hweffect; } @@ -1250,10 +1244,8 @@ SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, err_effectdone: SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect, base->type); err_hweffect: - if (effect->hweffect != NULL) { - SDL_free(effect->hweffect); - effect->hweffect = NULL; - } + SDL_free(effect->hweffect); + effect->hweffect = NULL; return -1; } @@ -1332,7 +1324,16 @@ SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, XINPUT_VIBRATION *vib = &effect->hweffect->vibration; SDL_assert(effect->effect.type == SDL_HAPTIC_LEFTRIGHT); /* should catch this at higher level */ SDL_LockMutex(haptic->hwdata->mutex); - haptic->hwdata->stopTicks = SDL_GetTicks() + (effect->effect.leftright.length * iterations); + if(effect->effect.leftright.length == SDL_HAPTIC_INFINITY || iterations == SDL_HAPTIC_INFINITY) { + haptic->hwdata->stopTicks = SDL_HAPTIC_INFINITY; + } else if ((!effect->effect.leftright.length) || (!iterations)) { + /* do nothing. Effect runs for zero milliseconds. */ + } else { + haptic->hwdata->stopTicks = SDL_GetTicks() + (effect->effect.leftright.length * iterations); + if ((haptic->hwdata->stopTicks == SDL_HAPTIC_INFINITY) || (haptic->hwdata->stopTicks == 0)) { + haptic->hwdata->stopTicks = 1; /* fix edge cases. */ + } + } SDL_UnlockMutex(haptic->hwdata->mutex); return (XINPUTSETSTATE(haptic->hwdata->userid, vib) == ERROR_SUCCESS) ? 0 : -1; } @@ -1565,10 +1566,12 @@ SDL_RunXInputHaptic(void *arg) SDL_Delay(50); SDL_LockMutex(hwdata->mutex); /* If we're currently running and need to stop... */ - if ((hwdata->stopTicks) && (hwdata->stopTicks < SDL_GetTicks())) { - XINPUT_VIBRATION vibration = { 0, 0 }; - hwdata->stopTicks = 0; - XINPUTSETSTATE(hwdata->userid, &vibration); + if (hwdata->stopTicks) { + if ((hwdata->stopTicks != SDL_HAPTIC_INFINITY) && SDL_TICKS_PASSED(SDL_GetTicks(), hwdata->stopTicks)) { + XINPUT_VIBRATION vibration = { 0, 0 }; + hwdata->stopTicks = 0; + XINPUTSETSTATE(hwdata->userid, &vibration); + } } SDL_UnlockMutex(hwdata->mutex); } diff --git a/src/input/evdev/SDL_evdev.c b/src/input/evdev/SDL_evdev.c new file mode 100644 index 000000000..92dc4fed7 --- /dev/null +++ b/src/input/evdev/SDL_evdev.c @@ -0,0 +1,805 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ +#include "SDL_config.h" + +#ifdef SDL_INPUT_LINUXEV + +/* This is based on the linux joystick driver */ +/* References: https://www.kernel.org/doc/Documentation/input/input.txt + * https://www.kernel.org/doc/Documentation/input/event-codes.txt + * /usr/include/linux/input.h + * The evtest application is also useful to debug the protocol + */ + + +#include "SDL_evdev.h" +#define _THIS SDL_EVDEV_PrivateData *_this +static _THIS = NULL; + +#include +#include +#include +#include +#include /* For the definition of PATH_MAX */ +#include +#ifdef SDL_INPUT_LINUXKD +#include +#include +#endif + + +/* We need this to prevent keystrokes from appear in the console */ +#ifndef KDSKBMUTE +#define KDSKBMUTE 0x4B51 +#endif +#ifndef KDSKBMODE +#define KDSKBMODE 0x4B45 +#endif +#ifndef K_OFF +#define K_OFF 0x04 +#endif + +#include "SDL.h" +#include "SDL_assert.h" +#include "SDL_endian.h" +#include "../../core/linux/SDL_udev.h" +#include "SDL_scancode.h" +#include "../../events/SDL_events_c.h" + +/* This isn't defined in older Linux kernel headers */ +#ifndef SYN_DROPPED +#define SYN_DROPPED 3 +#endif + +static SDL_Scancode SDL_EVDEV_translate_keycode(int keycode); +static void SDL_EVDEV_sync_device(SDL_evdevlist_item *item); +static int SDL_EVDEV_device_removed(const char *devpath); + +#if SDL_USE_LIBUDEV +static int SDL_EVDEV_device_added(const char *devpath); +void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath); +#endif /* SDL_USE_LIBUDEV */ + +static SDL_Scancode EVDEV_Keycodes[] = { + SDL_SCANCODE_UNKNOWN, /* KEY_RESERVED 0 */ + SDL_SCANCODE_ESCAPE, /* KEY_ESC 1 */ + SDL_SCANCODE_1, /* KEY_1 2 */ + SDL_SCANCODE_2, /* KEY_2 3 */ + SDL_SCANCODE_3, /* KEY_3 4 */ + SDL_SCANCODE_4, /* KEY_4 5 */ + SDL_SCANCODE_5, /* KEY_5 6 */ + SDL_SCANCODE_6, /* KEY_6 7 */ + SDL_SCANCODE_7, /* KEY_7 8 */ + SDL_SCANCODE_8, /* KEY_8 9 */ + SDL_SCANCODE_9, /* KEY_9 10 */ + SDL_SCANCODE_0, /* KEY_0 11 */ + SDL_SCANCODE_MINUS, /* KEY_MINUS 12 */ + SDL_SCANCODE_EQUALS, /* KEY_EQUAL 13 */ + SDL_SCANCODE_BACKSPACE, /* KEY_BACKSPACE 14 */ + SDL_SCANCODE_TAB, /* KEY_TAB 15 */ + SDL_SCANCODE_Q, /* KEY_Q 16 */ + SDL_SCANCODE_W, /* KEY_W 17 */ + SDL_SCANCODE_E, /* KEY_E 18 */ + SDL_SCANCODE_R, /* KEY_R 19 */ + SDL_SCANCODE_T, /* KEY_T 20 */ + SDL_SCANCODE_Y, /* KEY_Y 21 */ + SDL_SCANCODE_U, /* KEY_U 22 */ + SDL_SCANCODE_I, /* KEY_I 23 */ + SDL_SCANCODE_O, /* KEY_O 24 */ + SDL_SCANCODE_P, /* KEY_P 25 */ + SDL_SCANCODE_LEFTBRACKET, /* KEY_LEFTBRACE 26 */ + SDL_SCANCODE_RIGHTBRACKET, /* KEY_RIGHTBRACE 27 */ + SDL_SCANCODE_RETURN, /* KEY_ENTER 28 */ + SDL_SCANCODE_LCTRL, /* KEY_LEFTCTRL 29 */ + SDL_SCANCODE_A, /* KEY_A 30 */ + SDL_SCANCODE_S, /* KEY_S 31 */ + SDL_SCANCODE_D, /* KEY_D 32 */ + SDL_SCANCODE_F, /* KEY_F 33 */ + SDL_SCANCODE_G, /* KEY_G 34 */ + SDL_SCANCODE_H, /* KEY_H 35 */ + SDL_SCANCODE_J, /* KEY_J 36 */ + SDL_SCANCODE_K, /* KEY_K 37 */ + SDL_SCANCODE_L, /* KEY_L 38 */ + SDL_SCANCODE_SEMICOLON, /* KEY_SEMICOLON 39 */ + SDL_SCANCODE_APOSTROPHE, /* KEY_APOSTROPHE 40 */ + SDL_SCANCODE_GRAVE, /* KEY_GRAVE 41 */ + SDL_SCANCODE_LSHIFT, /* KEY_LEFTSHIFT 42 */ + SDL_SCANCODE_BACKSLASH, /* KEY_BACKSLASH 43 */ + SDL_SCANCODE_Z, /* KEY_Z 44 */ + SDL_SCANCODE_X, /* KEY_X 45 */ + SDL_SCANCODE_C, /* KEY_C 46 */ + SDL_SCANCODE_V, /* KEY_V 47 */ + SDL_SCANCODE_B, /* KEY_B 48 */ + SDL_SCANCODE_N, /* KEY_N 49 */ + SDL_SCANCODE_M, /* KEY_M 50 */ + SDL_SCANCODE_COMMA, /* KEY_COMMA 51 */ + SDL_SCANCODE_PERIOD, /* KEY_DOT 52 */ + SDL_SCANCODE_SLASH, /* KEY_SLASH 53 */ + SDL_SCANCODE_RSHIFT, /* KEY_RIGHTSHIFT 54 */ + SDL_SCANCODE_KP_MULTIPLY, /* KEY_KPASTERISK 55 */ + SDL_SCANCODE_LALT, /* KEY_LEFTALT 56 */ + SDL_SCANCODE_SPACE, /* KEY_SPACE 57 */ + SDL_SCANCODE_CAPSLOCK, /* KEY_CAPSLOCK 58 */ + SDL_SCANCODE_F1, /* KEY_F1 59 */ + SDL_SCANCODE_F2, /* KEY_F2 60 */ + SDL_SCANCODE_F3, /* KEY_F3 61 */ + SDL_SCANCODE_F4, /* KEY_F4 62 */ + SDL_SCANCODE_F5, /* KEY_F5 63 */ + SDL_SCANCODE_F6, /* KEY_F6 64 */ + SDL_SCANCODE_F7, /* KEY_F7 65 */ + SDL_SCANCODE_F8, /* KEY_F8 66 */ + SDL_SCANCODE_F9, /* KEY_F9 67 */ + SDL_SCANCODE_F10, /* KEY_F10 68 */ + SDL_SCANCODE_NUMLOCKCLEAR, /* KEY_NUMLOCK 69 */ + SDL_SCANCODE_SCROLLLOCK, /* KEY_SCROLLLOCK 70 */ + SDL_SCANCODE_KP_7, /* KEY_KP7 71 */ + SDL_SCANCODE_KP_8, /* KEY_KP8 72 */ + SDL_SCANCODE_KP_9, /* KEY_KP9 73 */ + SDL_SCANCODE_KP_MINUS, /* KEY_KPMINUS 74 */ + SDL_SCANCODE_KP_4, /* KEY_KP4 75 */ + SDL_SCANCODE_KP_5, /* KEY_KP5 76 */ + SDL_SCANCODE_KP_6, /* KEY_KP6 77 */ + SDL_SCANCODE_KP_PLUS, /* KEY_KPPLUS 78 */ + SDL_SCANCODE_KP_1, /* KEY_KP1 79 */ + SDL_SCANCODE_KP_2, /* KEY_KP2 80 */ + SDL_SCANCODE_KP_3, /* KEY_KP3 81 */ + SDL_SCANCODE_KP_0, /* KEY_KP0 82 */ + SDL_SCANCODE_KP_PERIOD, /* KEY_KPDOT 83 */ + SDL_SCANCODE_UNKNOWN, /* 84 */ + SDL_SCANCODE_LANG5, /* KEY_ZENKAKUHANKAKU 85 */ + SDL_SCANCODE_UNKNOWN, /* KEY_102ND 86 */ + SDL_SCANCODE_F11, /* KEY_F11 87 */ + SDL_SCANCODE_F12, /* KEY_F12 88 */ + SDL_SCANCODE_UNKNOWN, /* KEY_RO 89 */ + SDL_SCANCODE_LANG3, /* KEY_KATAKANA 90 */ + SDL_SCANCODE_LANG4, /* KEY_HIRAGANA 91 */ + SDL_SCANCODE_UNKNOWN, /* KEY_HENKAN 92 */ + SDL_SCANCODE_LANG3, /* KEY_KATAKANAHIRAGANA 93 */ + SDL_SCANCODE_UNKNOWN, /* KEY_MUHENKAN 94 */ + SDL_SCANCODE_KP_COMMA, /* KEY_KPJPCOMMA 95 */ + SDL_SCANCODE_KP_ENTER, /* KEY_KPENTER 96 */ + SDL_SCANCODE_RCTRL, /* KEY_RIGHTCTRL 97 */ + SDL_SCANCODE_KP_DIVIDE, /* KEY_KPSLASH 98 */ + SDL_SCANCODE_SYSREQ, /* KEY_SYSRQ 99 */ + SDL_SCANCODE_RALT, /* KEY_RIGHTALT 100 */ + SDL_SCANCODE_UNKNOWN, /* KEY_LINEFEED 101 */ + SDL_SCANCODE_HOME, /* KEY_HOME 102 */ + SDL_SCANCODE_UP, /* KEY_UP 103 */ + SDL_SCANCODE_PAGEUP, /* KEY_PAGEUP 104 */ + SDL_SCANCODE_LEFT, /* KEY_LEFT 105 */ + SDL_SCANCODE_RIGHT, /* KEY_RIGHT 106 */ + SDL_SCANCODE_END, /* KEY_END 107 */ + SDL_SCANCODE_DOWN, /* KEY_DOWN 108 */ + SDL_SCANCODE_PAGEDOWN, /* KEY_PAGEDOWN 109 */ + SDL_SCANCODE_INSERT, /* KEY_INSERT 110 */ + SDL_SCANCODE_DELETE, /* KEY_DELETE 111 */ + SDL_SCANCODE_UNKNOWN, /* KEY_MACRO 112 */ + SDL_SCANCODE_MUTE, /* KEY_MUTE 113 */ + SDL_SCANCODE_VOLUMEDOWN, /* KEY_VOLUMEDOWN 114 */ + SDL_SCANCODE_VOLUMEUP, /* KEY_VOLUMEUP 115 */ + SDL_SCANCODE_POWER, /* KEY_POWER 116 SC System Power Down */ + SDL_SCANCODE_KP_EQUALS, /* KEY_KPEQUAL 117 */ + SDL_SCANCODE_KP_MINUS, /* KEY_KPPLUSMINUS 118 */ + SDL_SCANCODE_PAUSE, /* KEY_PAUSE 119 */ + SDL_SCANCODE_UNKNOWN, /* KEY_SCALE 120 AL Compiz Scale (Expose) */ + SDL_SCANCODE_KP_COMMA, /* KEY_KPCOMMA 121 */ + SDL_SCANCODE_LANG1, /* KEY_HANGEUL,KEY_HANGUEL 122 */ + SDL_SCANCODE_LANG2, /* KEY_HANJA 123 */ + SDL_SCANCODE_INTERNATIONAL3,/* KEY_YEN 124 */ + SDL_SCANCODE_LGUI, /* KEY_LEFTMETA 125 */ + SDL_SCANCODE_RGUI, /* KEY_RIGHTMETA 126 */ + SDL_SCANCODE_APPLICATION, /* KEY_COMPOSE 127 */ + SDL_SCANCODE_STOP, /* KEY_STOP 128 AC Stop */ + SDL_SCANCODE_AGAIN, /* KEY_AGAIN 129 */ + SDL_SCANCODE_UNKNOWN, /* KEY_PROPS 130 AC Properties */ + SDL_SCANCODE_UNDO, /* KEY_UNDO 131 AC Undo */ + SDL_SCANCODE_UNKNOWN, /* KEY_FRONT 132 */ + SDL_SCANCODE_COPY, /* KEY_COPY 133 AC Copy */ + SDL_SCANCODE_UNKNOWN, /* KEY_OPEN 134 AC Open */ + SDL_SCANCODE_PASTE, /* KEY_PASTE 135 AC Paste */ + SDL_SCANCODE_FIND, /* KEY_FIND 136 AC Search */ + SDL_SCANCODE_CUT, /* KEY_CUT 137 AC Cut */ + SDL_SCANCODE_HELP, /* KEY_HELP 138 AL Integrated Help Center */ + SDL_SCANCODE_MENU, /* KEY_MENU 139 Menu (show menu) */ + SDL_SCANCODE_CALCULATOR, /* KEY_CALC 140 AL Calculator */ + SDL_SCANCODE_UNKNOWN, /* KEY_SETUP 141 */ + SDL_SCANCODE_SLEEP, /* KEY_SLEEP 142 SC System Sleep */ + SDL_SCANCODE_UNKNOWN, /* KEY_WAKEUP 143 System Wake Up */ + SDL_SCANCODE_UNKNOWN, /* KEY_FILE 144 AL Local Machine Browser */ + SDL_SCANCODE_UNKNOWN, /* KEY_SENDFILE 145 */ + SDL_SCANCODE_UNKNOWN, /* KEY_DELETEFILE 146 */ + SDL_SCANCODE_UNKNOWN, /* KEY_XFER 147 */ + SDL_SCANCODE_APP1, /* KEY_PROG1 148 */ + SDL_SCANCODE_APP1, /* KEY_PROG2 149 */ + SDL_SCANCODE_WWW, /* KEY_WWW 150 AL Internet Browser */ + SDL_SCANCODE_UNKNOWN, /* KEY_MSDOS 151 */ + SDL_SCANCODE_UNKNOWN, /* KEY_COFFEE,KEY_SCREENLOCK 152 AL Terminal Lock/Screensaver */ + SDL_SCANCODE_UNKNOWN, /* KEY_DIRECTION 153 */ + SDL_SCANCODE_UNKNOWN, /* KEY_CYCLEWINDOWS 154 */ + SDL_SCANCODE_MAIL, /* KEY_MAIL 155 */ + SDL_SCANCODE_AC_BOOKMARKS, /* KEY_BOOKMARKS 156 AC Bookmarks */ + SDL_SCANCODE_COMPUTER, /* KEY_COMPUTER 157 */ + SDL_SCANCODE_AC_BACK, /* KEY_BACK 158 AC Back */ + SDL_SCANCODE_AC_FORWARD, /* KEY_FORWARD 159 AC Forward */ + SDL_SCANCODE_UNKNOWN, /* KEY_CLOSECD 160 */ + SDL_SCANCODE_EJECT, /* KEY_EJECTCD 161 */ + SDL_SCANCODE_UNKNOWN, /* KEY_EJECTCLOSECD 162 */ + SDL_SCANCODE_AUDIONEXT, /* KEY_NEXTSONG 163 */ + SDL_SCANCODE_AUDIOPLAY, /* KEY_PLAYPAUSE 164 */ + SDL_SCANCODE_AUDIOPREV, /* KEY_PREVIOUSSONG 165 */ + SDL_SCANCODE_AUDIOSTOP, /* KEY_STOPCD 166 */ + SDL_SCANCODE_UNKNOWN, /* KEY_RECORD 167 */ + SDL_SCANCODE_UNKNOWN, /* KEY_REWIND 168 */ + SDL_SCANCODE_UNKNOWN, /* KEY_PHONE 169 Media Select Telephone */ + SDL_SCANCODE_UNKNOWN, /* KEY_ISO 170 */ + SDL_SCANCODE_UNKNOWN, /* KEY_CONFIG 171 AL Consumer Control Configuration */ + SDL_SCANCODE_AC_HOME, /* KEY_HOMEPAGE 172 AC Home */ + SDL_SCANCODE_AC_REFRESH, /* KEY_REFRESH 173 AC Refresh */ + SDL_SCANCODE_UNKNOWN, /* KEY_EXIT 174 AC Exit */ + SDL_SCANCODE_UNKNOWN, /* KEY_MOVE 175 */ + SDL_SCANCODE_UNKNOWN, /* KEY_EDIT 176 */ + SDL_SCANCODE_UNKNOWN, /* KEY_SCROLLUP 177 */ + SDL_SCANCODE_UNKNOWN, /* KEY_SCROLLDOWN 178 */ + SDL_SCANCODE_KP_LEFTPAREN, /* KEY_KPLEFTPAREN 179 */ + SDL_SCANCODE_KP_RIGHTPAREN, /* KEY_KPRIGHTPAREN 180 */ + SDL_SCANCODE_UNKNOWN, /* KEY_NEW 181 AC New */ + SDL_SCANCODE_AGAIN, /* KEY_REDO 182 AC Redo/Repeat */ + SDL_SCANCODE_F13, /* KEY_F13 183 */ + SDL_SCANCODE_F14, /* KEY_F14 184 */ + SDL_SCANCODE_F15, /* KEY_F15 185 */ + SDL_SCANCODE_F16, /* KEY_F16 186 */ + SDL_SCANCODE_F17, /* KEY_F17 187 */ + SDL_SCANCODE_F18, /* KEY_F18 188 */ + SDL_SCANCODE_F19, /* KEY_F19 189 */ + SDL_SCANCODE_F20, /* KEY_F20 190 */ + SDL_SCANCODE_F21, /* KEY_F21 191 */ + SDL_SCANCODE_F22, /* KEY_F22 192 */ + SDL_SCANCODE_F23, /* KEY_F23 193 */ + SDL_SCANCODE_F24, /* KEY_F24 194 */ + SDL_SCANCODE_UNKNOWN, /* 195 */ + SDL_SCANCODE_UNKNOWN, /* 196 */ + SDL_SCANCODE_UNKNOWN, /* 197 */ + SDL_SCANCODE_UNKNOWN, /* 198 */ + SDL_SCANCODE_UNKNOWN, /* 199 */ + SDL_SCANCODE_UNKNOWN, /* KEY_PLAYCD 200 */ + SDL_SCANCODE_UNKNOWN, /* KEY_PAUSECD 201 */ + SDL_SCANCODE_UNKNOWN, /* KEY_PROG3 202 */ + SDL_SCANCODE_UNKNOWN, /* KEY_PROG4 203 */ + SDL_SCANCODE_UNKNOWN, /* KEY_DASHBOARD 204 AL Dashboard */ + SDL_SCANCODE_UNKNOWN, /* KEY_SUSPEND 205 */ + SDL_SCANCODE_UNKNOWN, /* KEY_CLOSE 206 AC Close */ + SDL_SCANCODE_UNKNOWN, /* KEY_PLAY 207 */ + SDL_SCANCODE_UNKNOWN, /* KEY_FASTFORWARD 208 */ + SDL_SCANCODE_UNKNOWN, /* KEY_BASSBOOST 209 */ + SDL_SCANCODE_UNKNOWN, /* KEY_PRINT 210 AC Print */ + SDL_SCANCODE_UNKNOWN, /* KEY_HP 211 */ + SDL_SCANCODE_UNKNOWN, /* KEY_CAMERA 212 */ + SDL_SCANCODE_UNKNOWN, /* KEY_SOUND 213 */ + SDL_SCANCODE_UNKNOWN, /* KEY_QUESTION 214 */ + SDL_SCANCODE_UNKNOWN, /* KEY_EMAIL 215 */ + SDL_SCANCODE_UNKNOWN, /* KEY_CHAT 216 */ + SDL_SCANCODE_UNKNOWN, /* KEY_SEARCH 217 */ + SDL_SCANCODE_UNKNOWN, /* KEY_CONNECT 218 */ + SDL_SCANCODE_UNKNOWN, /* KEY_FINANCE 219 AL Checkbook/Finance */ + SDL_SCANCODE_UNKNOWN, /* KEY_SPORT 220 */ + SDL_SCANCODE_UNKNOWN, /* KEY_SHOP 221 */ + SDL_SCANCODE_UNKNOWN, /* KEY_ALTERASE 222 */ + SDL_SCANCODE_UNKNOWN, /* KEY_CANCEL 223 AC Cancel */ + SDL_SCANCODE_UNKNOWN, /* KEY_BRIGHTNESSDOWN 224 */ + SDL_SCANCODE_UNKNOWN, /* KEY_BRIGHTNESSUP 225 */ + SDL_SCANCODE_UNKNOWN, /* KEY_MEDIA 226 */ + SDL_SCANCODE_UNKNOWN, /* KEY_SWITCHVIDEOMODE 227 Cycle between available video outputs (Monitor/LCD/TV-out/etc) */ + SDL_SCANCODE_UNKNOWN, /* KEY_KBDILLUMTOGGLE 228 */ + SDL_SCANCODE_UNKNOWN, /* KEY_KBDILLUMDOWN 229 */ + SDL_SCANCODE_UNKNOWN, /* KEY_KBDILLUMUP 230 */ + SDL_SCANCODE_UNKNOWN, /* KEY_SEND 231 AC Send */ + SDL_SCANCODE_UNKNOWN, /* KEY_REPLY 232 AC Reply */ + SDL_SCANCODE_UNKNOWN, /* KEY_FORWARDMAIL 233 AC Forward Msg */ + SDL_SCANCODE_UNKNOWN, /* KEY_SAVE 234 AC Save */ + SDL_SCANCODE_UNKNOWN, /* KEY_DOCUMENTS 235 */ + SDL_SCANCODE_UNKNOWN, /* KEY_BATTERY 236 */ + SDL_SCANCODE_UNKNOWN, /* KEY_BLUETOOTH 237 */ + SDL_SCANCODE_UNKNOWN, /* KEY_WLAN 238 */ + SDL_SCANCODE_UNKNOWN, /* KEY_UWB 239 */ + SDL_SCANCODE_UNKNOWN, /* KEY_UNKNOWN 240 */ + SDL_SCANCODE_UNKNOWN, /* KEY_VIDEO_NEXT 241 drive next video source */ + SDL_SCANCODE_UNKNOWN, /* KEY_VIDEO_PREV 242 drive previous video source */ + SDL_SCANCODE_UNKNOWN, /* KEY_BRIGHTNESS_CYCLE 243 brightness up, after max is min */ + SDL_SCANCODE_UNKNOWN, /* KEY_BRIGHTNESS_ZERO 244 brightness off, use ambient */ + SDL_SCANCODE_UNKNOWN, /* KEY_DISPLAY_OFF 245 display device to off state */ + SDL_SCANCODE_UNKNOWN, /* KEY_WIMAX 246 */ + SDL_SCANCODE_UNKNOWN, /* KEY_RFKILL 247 Key that controls all radios */ + SDL_SCANCODE_UNKNOWN, /* KEY_MICMUTE 248 Mute / unmute the microphone */ +}; + +static Uint8 EVDEV_MouseButtons[] = { + SDL_BUTTON_LEFT, /* BTN_LEFT 0x110 */ + SDL_BUTTON_RIGHT, /* BTN_RIGHT 0x111 */ + SDL_BUTTON_MIDDLE, /* BTN_MIDDLE 0x112 */ + SDL_BUTTON_X1, /* BTN_SIDE 0x113 */ + SDL_BUTTON_X2, /* BTN_EXTRA 0x114 */ + SDL_BUTTON_X2 + 1, /* BTN_FORWARD 0x115 */ + SDL_BUTTON_X2 + 2, /* BTN_BACK 0x116 */ + SDL_BUTTON_X2 + 3 /* BTN_TASK 0x117 */ +}; + +static char* EVDEV_consoles[] = { + "/proc/self/fd/0", + "/dev/tty", + "/dev/tty0", + "/dev/tty1", + "/dev/tty2", + "/dev/tty3", + "/dev/tty4", + "/dev/tty5", + "/dev/tty6", + "/dev/vc/0", + "/dev/console" +}; + +#define IS_CONSOLE(fd) isatty (fd) && ioctl(fd, KDGKBTYPE, &arg) == 0 && ((arg == KB_101) || (arg == KB_84)) + +static int SDL_EVDEV_get_console_fd(void) +{ + int fd, i; + char arg = 0; + + /* Try a few consoles to see which one we have read access to */ + + for( i = 0; i < SDL_arraysize(EVDEV_consoles); i++) { + fd = open(EVDEV_consoles[i], O_RDONLY); + if (fd >= 0) { + if (IS_CONSOLE(fd)) return fd; + close(fd); + } + } + + /* Try stdin, stdout, stderr */ + + for( fd = 0; fd < 3; fd++) { + if (IS_CONSOLE(fd)) return fd; + } + + /* We won't be able to send SDL_TEXTINPUT events */ + return -1; +} + +/* Prevent keystrokes from reaching the tty */ +static int SDL_EVDEV_mute_keyboard(int tty, int *kb_mode) +{ + char arg; + + *kb_mode = 0; /* FIXME: Is this a sane default in case KDGKBMODE fails? */ + if (!IS_CONSOLE(tty)) { + return SDL_SetError("Tried to mute an invalid tty"); + } + ioctl(tty, KDGKBMODE, kb_mode); /* It's not fatal if this fails */ + if (ioctl(tty, KDSKBMUTE, 1) && ioctl(tty, KDSKBMODE, K_OFF)) { + return SDL_SetError("EVDEV: Failed muting keyboard"); + } + + return 0; +} + +/* Restore the keyboard mode for given tty */ +static void SDL_EVDEV_unmute_keyboard(int tty, int kb_mode) +{ + if (ioctl(tty, KDSKBMUTE, 0) && ioctl(tty, KDSKBMODE, kb_mode)) { + SDL_Log("EVDEV: Failed restoring keyboard mode"); + } +} + +/* Read /sys/class/tty/tty0/active and open the tty */ +static int SDL_EVDEV_get_active_tty() +{ + int fd, len; + char ttyname[NAME_MAX + 1]; + char ttypath[PATH_MAX+1] = "/dev/"; + char arg; + + fd = open("/sys/class/tty/tty0/active", O_RDONLY); + if (fd < 0) { + return SDL_SetError("Could not determine which tty is active"); + } + + len = read(fd, ttyname, NAME_MAX); + close(fd); + + if (len <= 0) { + return SDL_SetError("Could not read which tty is active"); + } + + if (ttyname[len-1] == '\n') { + ttyname[len-1] = '\0'; + } + else { + ttyname[len] = '\0'; + } + + SDL_strlcat(ttypath, ttyname, PATH_MAX); + fd = open(ttypath, O_RDWR | O_NOCTTY); + if (fd < 0) { + return SDL_SetError("Could not open tty: %s", ttypath); + } + + if (!IS_CONSOLE(fd)) { + close(fd); + return SDL_SetError("Invalid tty obtained: %s", ttypath); + } + + return fd; +} + +int +SDL_EVDEV_Init(void) +{ + int retval = 0; + + if (_this == NULL) { + + _this = (SDL_EVDEV_PrivateData *) SDL_calloc(1, sizeof(*_this)); + if(_this == NULL) { + return SDL_OutOfMemory(); + } + +#if SDL_USE_LIBUDEV + if (SDL_UDEV_Init() < 0) { + SDL_free(_this); + _this = NULL; + return -1; + } + + /* Set up the udev callback */ + if ( SDL_UDEV_AddCallback(SDL_EVDEV_udev_callback) < 0) { + SDL_EVDEV_Quit(); + return -1; + } + + /* Force a scan to build the initial device list */ + SDL_UDEV_Scan(); +#else + /* TODO: Scan the devices manually, like a caveman */ +#endif /* SDL_USE_LIBUDEV */ + + /* We need a physical terminal (not PTS) to be able to translate key code to symbols via the kernel tables */ + _this->console_fd = SDL_EVDEV_get_console_fd(); + + /* Mute the keyboard so keystrokes only generate evdev events and do not leak through to the console */ + _this->tty = STDIN_FILENO; + if (SDL_EVDEV_mute_keyboard(_this->tty, &_this->kb_mode) < 0) { + /* stdin is not a tty, probably we were launched remotely, so we try to disable the active tty */ + _this->tty = SDL_EVDEV_get_active_tty(); + if (_this->tty >= 0) { + if (SDL_EVDEV_mute_keyboard(_this->tty, &_this->kb_mode) < 0) { + close(_this->tty); + _this->tty = -1; + } + } + } + } + + _this->ref_count += 1; + + return retval; +} + +void +SDL_EVDEV_Quit(void) +{ + if (_this == NULL) { + return; + } + + _this->ref_count -= 1; + + if (_this->ref_count < 1) { + +#if SDL_USE_LIBUDEV + SDL_UDEV_DelCallback(SDL_EVDEV_udev_callback); + SDL_UDEV_Quit(); +#endif /* SDL_USE_LIBUDEV */ + + if (_this->console_fd >= 0) { + close(_this->console_fd); + } + + if (_this->tty >= 0) { + SDL_EVDEV_unmute_keyboard(_this->tty, _this->kb_mode); + close(_this->tty); + } + + /* Remove existing devices */ + while(_this->first != NULL) { + SDL_EVDEV_device_removed(_this->first->path); + } + + SDL_assert(_this->first == NULL); + SDL_assert(_this->last == NULL); + SDL_assert(_this->numdevices == 0); + + SDL_free(_this); + _this = NULL; + } +} + +#if SDL_USE_LIBUDEV +void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath) +{ + if (devpath == NULL) { + return; + } + + if (!(udev_class & (SDL_UDEV_DEVICE_MOUSE|SDL_UDEV_DEVICE_KEYBOARD))) { + return; + } + + switch( udev_type ) { + case SDL_UDEV_DEVICEADDED: + SDL_EVDEV_device_added(devpath); + break; + + case SDL_UDEV_DEVICEREMOVED: + SDL_EVDEV_device_removed(devpath); + break; + + default: + break; + } +} + +#endif /* SDL_USE_LIBUDEV */ + +void +SDL_EVDEV_Poll(void) +{ + struct input_event events[32]; + int i, len; + SDL_evdevlist_item *item; + SDL_Scancode scan_code; + int mouse_button; + SDL_Mouse *mouse; +#ifdef SDL_INPUT_LINUXKD + Uint16 modstate; + struct kbentry kbe; + static char keysym[8]; + char *end; + Uint32 kval; +#endif + +#if SDL_USE_LIBUDEV + SDL_UDEV_Poll(); +#endif + + mouse = SDL_GetMouse(); + + for (item = _this->first; item != NULL; item = item->next) { + while ((len = read(item->fd, events, (sizeof events))) > 0) { + len /= sizeof(events[0]); + for (i = 0; i < len; ++i) { + switch (events[i].type) { + case EV_KEY: + if (events[i].code >= BTN_MOUSE && events[i].code < BTN_MOUSE + SDL_arraysize(EVDEV_MouseButtons)) { + mouse_button = events[i].code - BTN_MOUSE; + if (events[i].value == 0) { + SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_RELEASED, EVDEV_MouseButtons[mouse_button]); + } else if (events[i].value == 1) { + SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_PRESSED, EVDEV_MouseButtons[mouse_button]); + } + break; + } + + /* Probably keyboard */ + scan_code = SDL_EVDEV_translate_keycode(events[i].code); + if (scan_code != SDL_SCANCODE_UNKNOWN) { + if (events[i].value == 0) { + SDL_SendKeyboardKey(SDL_RELEASED, scan_code); + } else if (events[i].value == 1 || events[i].value == 2 /* Key repeated */ ) { + SDL_SendKeyboardKey(SDL_PRESSED, scan_code); +#ifdef SDL_INPUT_LINUXKD + if (_this->console_fd >= 0) { + kbe.kb_index = events[i].code; + /* Convert the key to an UTF-8 char */ + /* Ref: http://www.linuxjournal.com/article/2783 */ + modstate = SDL_GetModState(); + kbe.kb_table = 0; + + /* Ref: http://graphics.stanford.edu/~seander/bithacks.html#ConditionalSetOrClearBitsWithoutBranching */ + kbe.kb_table |= -( (modstate & KMOD_LCTRL) != 0) & (1 << KG_CTRLL | 1 << KG_CTRL); + kbe.kb_table |= -( (modstate & KMOD_RCTRL) != 0) & (1 << KG_CTRLR | 1 << KG_CTRL); + kbe.kb_table |= -( (modstate & KMOD_LSHIFT) != 0) & (1 << KG_SHIFTL | 1 << KG_SHIFT); + kbe.kb_table |= -( (modstate & KMOD_RSHIFT) != 0) & (1 << KG_SHIFTR | 1 << KG_SHIFT); + kbe.kb_table |= -( (modstate & KMOD_LALT) != 0) & (1 << KG_ALT); + kbe.kb_table |= -( (modstate & KMOD_RALT) != 0) & (1 << KG_ALTGR); + + if (ioctl(_this->console_fd, KDGKBENT, (unsigned long)&kbe) == 0 && + ((KTYP(kbe.kb_value) == KT_LATIN) || (KTYP(kbe.kb_value) == KT_ASCII) || (KTYP(kbe.kb_value) == KT_LETTER))) + { + kval = KVAL(kbe.kb_value); + + /* While there's a KG_CAPSSHIFT symbol, it's not useful to build the table index with it + * because 1 << KG_CAPSSHIFT overflows the 8 bits of kb_table + * So, we do the CAPS LOCK logic here. Note that isalpha depends on the locale! + */ + if ( modstate & KMOD_CAPS && isalpha(kval) ) { + if ( isupper(kval) ) { + kval = tolower(kval); + } else { + kval = toupper(kval); + } + } + + /* Convert to UTF-8 and send */ + end = SDL_UCS4ToUTF8( kval, keysym); + *end = '\0'; + SDL_SendKeyboardText(keysym); + } + } +#endif /* SDL_INPUT_LINUXKD */ + } + } + break; + case EV_ABS: + switch(events[i].code) { + case ABS_X: + SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_FALSE, events[i].value, mouse->y); + break; + case ABS_Y: + SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_FALSE, mouse->x, events[i].value); + break; + default: + break; + } + break; + case EV_REL: + switch(events[i].code) { + case REL_X: + SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_TRUE, events[i].value, 0); + break; + case REL_Y: + SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_TRUE, 0, events[i].value); + break; + case REL_WHEEL: + SDL_SendMouseWheel(mouse->focus, mouse->mouseID, 0, events[i].value); + break; + case REL_HWHEEL: + SDL_SendMouseWheel(mouse->focus, mouse->mouseID, events[i].value, 0); + break; + default: + break; + } + break; + case EV_SYN: + switch (events[i].code) { + case SYN_DROPPED: + SDL_EVDEV_sync_device(item); + break; + default: + break; + } + break; + } + } + } + } +} + +static SDL_Scancode +SDL_EVDEV_translate_keycode(int keycode) +{ + SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN; + + if (keycode < SDL_arraysize(EVDEV_Keycodes)) { + scancode = EVDEV_Keycodes[keycode]; + } + if (scancode == SDL_SCANCODE_UNKNOWN) { + SDL_Log("The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL mailing list EVDEV KeyCode %d \n", keycode); + } + return scancode; +} + +static void +SDL_EVDEV_sync_device(SDL_evdevlist_item *item) +{ + /* TODO: get full state of device and report whatever is required */ +} + +#if SDL_USE_LIBUDEV +static int +SDL_EVDEV_device_added(const char *devpath) +{ + SDL_evdevlist_item *item; + + /* Check to make sure it's not already in list. */ + for (item = _this->first; item != NULL; item = item->next) { + if (strcmp(devpath, item->path) == 0) { + return -1; /* already have this one */ + } + } + + item = (SDL_evdevlist_item *) SDL_calloc(1, sizeof (SDL_evdevlist_item)); + if (item == NULL) { + return SDL_OutOfMemory(); + } + + item->fd = open(devpath, O_RDONLY, 0); + if (item->fd < 0) { + SDL_free(item); + return SDL_SetError("Unable to open %s", devpath); + } + + item->path = SDL_strdup(devpath); + if (item->path == NULL) { + close(item->fd); + SDL_free(item); + return SDL_OutOfMemory(); + } + + /* Non blocking read mode */ + fcntl(item->fd, F_SETFL, O_NONBLOCK); + + if (_this->last == NULL) { + _this->first = _this->last = item; + } else { + _this->last->next = item; + _this->last = item; + } + + SDL_EVDEV_sync_device(item); + + return _this->numdevices++; +} +#endif /* SDL_USE_LIBUDEV */ + +static int +SDL_EVDEV_device_removed(const char *devpath) +{ + SDL_evdevlist_item *item; + SDL_evdevlist_item *prev = NULL; + + for (item = _this->first; item != NULL; item = item->next) { + /* found it, remove it. */ + if ( strcmp(devpath, item->path) ==0 ) { + if (prev != NULL) { + prev->next = item->next; + } else { + SDL_assert(_this->first == item); + _this->first = item->next; + } + if (item == _this->last) { + _this->last = prev; + } + close(item->fd); + SDL_free(item->path); + SDL_free(item); + _this->numdevices--; + return 0; + } + prev = item; + } + + return -1; +} + + +#endif /* SDL_INPUT_LINUXEV */ + +/* vi: set ts=4 sw=4 expandtab: */ + diff --git a/src/input/evdev/SDL_evdev.h b/src/input/evdev/SDL_evdev.h new file mode 100644 index 000000000..b9311d4f3 --- /dev/null +++ b/src/input/evdev/SDL_evdev.h @@ -0,0 +1,59 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +#include "SDL_config.h" + +#ifndef _SDL_evdev_h +#define _SDL_evdev_h + +#ifdef SDL_INPUT_LINUXEV + +#include "SDL_events.h" +#include + +typedef struct SDL_evdevlist_item +{ + char *path; + int fd; + struct SDL_evdevlist_item *next; +} SDL_evdevlist_item; + +typedef struct SDL_EVDEV_PrivateData +{ + SDL_evdevlist_item *first; + SDL_evdevlist_item *last; + int numdevices; + int ref_count; + int console_fd; + int kb_mode; + int tty; +} SDL_EVDEV_PrivateData; + +extern int SDL_EVDEV_Init(void); +extern void SDL_EVDEV_Quit(void); +extern void SDL_EVDEV_Poll(void); + + +#endif /* SDL_INPUT_LINUXEV */ + +#endif /* _SDL_evdev_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c index 414e59135..1ffa5b56c 100644 --- a/src/joystick/SDL_gamecontroller.c +++ b/src/joystick/SDL_gamecontroller.c @@ -52,7 +52,7 @@ struct _SDL_HatMapping */ #define k_nMaxHatEntries 0x3f + 1 -/* our in memory mapping db between joystick objects and controller mappings*/ +/* our in memory mapping db between joystick objects and controller mappings */ struct _SDL_ControllerMapping { SDL_JoystickGUID guid; @@ -758,7 +758,7 @@ SDL_GameControllerLoadHints() { const char *hint = SDL_GetHint(SDL_HINT_GAMECONTROLLERCONFIG); if ( hint && hint[0] ) { - int nchHints = SDL_strlen( hint ); + size_t nchHints = SDL_strlen( hint ); char *pUserMappings = SDL_malloc( nchHints + 1 ); char *pTempMappings = pUserMappings; SDL_memcpy( pUserMappings, hint, nchHints ); diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index bb8652f4d..3906ec2b9 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -437,22 +437,13 @@ SDL_JoystickClose(SDL_Joystick * joystick) joysticklist = joysticklist->next; } - if (joystick->name) - SDL_free(joystick->name); + SDL_free(joystick->name); /* Free the data associated with this joystick */ - if (joystick->axes) { - SDL_free(joystick->axes); - } - if (joystick->hats) { - SDL_free(joystick->hats); - } - if (joystick->balls) { - SDL_free(joystick->balls); - } - if (joystick->buttons) { - SDL_free(joystick->buttons); - } + SDL_free(joystick->axes); + SDL_free(joystick->hats); + SDL_free(joystick->balls); + SDL_free(joystick->buttons); SDL_free(joystick); } @@ -488,14 +479,14 @@ SDL_PrivateJoystickShouldIgnoreEvent() if (SDL_WasInit(SDL_INIT_VIDEO)) { if (SDL_GetKeyboardFocus() == NULL) { - // Video is initialized and we don't have focus, ignore the event. + /* Video is initialized and we don't have focus, ignore the event. */ return SDL_TRUE; } else { return SDL_FALSE; } } - // Video subsystem wasn't initialized, always allow the event + /* Video subsystem wasn't initialized, always allow the event */ return SDL_FALSE; } @@ -772,6 +763,11 @@ SDL_JoystickGUID SDL_JoystickGetDeviceGUID(int device_index) /* return the guid for this opened device */ SDL_JoystickGUID SDL_JoystickGetGUID(SDL_Joystick * joystick) { + if (!SDL_PrivateJoystickValid(joystick)) { + SDL_JoystickGUID emptyGUID; + SDL_zero( emptyGUID ); + return emptyGUID; + } return SDL_SYS_JoystickGetGUID( joystick ); } @@ -785,7 +781,7 @@ void SDL_JoystickGetGUIDString( SDL_JoystickGUID guid, char *pszGUID, int cbGUID return; } - for ( i = 0; i < sizeof(guid.data) && i < (cbGUID-1); i++ ) + for ( i = 0; i < sizeof(guid.data) && i < (cbGUID-1)/2; i++ ) { /* each input byte writes 2 ascii chars, and might write a null byte. */ /* If we don't have room for next input byte, stop */ @@ -834,7 +830,7 @@ SDL_JoystickGUID SDL_JoystickGetGUIDFromString(const char *pchGUID) { SDL_JoystickGUID guid; int maxoutputbytes= sizeof(guid); - int len = SDL_strlen( pchGUID ); + size_t len = SDL_strlen( pchGUID ); Uint8 *p; int i; diff --git a/src/joystick/SDL_sysjoystick.h b/src/joystick/SDL_sysjoystick.h index f75aabc07..1b515be65 100644 --- a/src/joystick/SDL_sysjoystick.h +++ b/src/joystick/SDL_sysjoystick.h @@ -111,6 +111,7 @@ extern SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick); #if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT) /* Function to get the current instance id of the joystick located at device_index */ extern SDL_bool SDL_SYS_IsXInputDeviceIndex( int device_index ); +extern SDL_bool SDL_SYS_IsXInputJoystick(SDL_Joystick * joystick); #endif /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/joystick/beos/SDL_bejoystick.cc b/src/joystick/beos/SDL_bejoystick.cc index 4e342ed41..c32458134 100644 --- a/src/joystick/beos/SDL_bejoystick.cc +++ b/src/joystick/beos/SDL_bejoystick.cc @@ -231,12 +231,8 @@ extern "C" if (joystick->hwdata) { joystick->hwdata->stick->Close(); delete joystick->hwdata->stick; - if (joystick->hwdata->new_hats) { - SDL_free(joystick->hwdata->new_hats); - } - if (joystick->hwdata->new_axes) { - SDL_free(joystick->hwdata->new_axes); - } + SDL_free(joystick->hwdata->new_hats); + SDL_free(joystick->hwdata->new_axes); SDL_free(joystick->hwdata); joystick->hwdata = NULL; } diff --git a/src/joystick/bsd/SDL_sysjoystick.c b/src/joystick/bsd/SDL_sysjoystick.c index 6d35d91b5..41a8693d6 100644 --- a/src/joystick/bsd/SDL_sysjoystick.c +++ b/src/joystick/bsd/SDL_sysjoystick.c @@ -446,48 +446,47 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joy) static int x, y, xmin = 0xffff, ymin = 0xffff, xmax = 0, ymax = 0; if (joy->hwdata->type == BSDJOY_JOY) { - if (read(joy->hwdata->fd, &gameport, sizeof gameport) != - sizeof gameport) - return; - if (abs(x - gameport.x) > 8) { - x = gameport.x; - if (x < xmin) { - xmin = x; + while (read(joy->hwdata->fd, &gameport, sizeof gameport) == sizeof gameport) { + if (abs(x - gameport.x) > 8) { + x = gameport.x; + if (x < xmin) { + xmin = x; + } + if (x > xmax) { + xmax = x; + } + if (xmin == xmax) { + xmin--; + xmax++; + } + v = (Sint32) x; + v -= (xmax + xmin + 1) / 2; + v *= 32768 / ((xmax - xmin + 1) / 2); + SDL_PrivateJoystickAxis(joy, 0, v); } - if (x > xmax) { - xmax = x; + if (abs(y - gameport.y) > 8) { + y = gameport.y; + if (y < ymin) { + ymin = y; + } + if (y > ymax) { + ymax = y; + } + if (ymin == ymax) { + ymin--; + ymax++; + } + v = (Sint32) y; + v -= (ymax + ymin + 1) / 2; + v *= 32768 / ((ymax - ymin + 1) / 2); + SDL_PrivateJoystickAxis(joy, 1, v); } - if (xmin == xmax) { - xmin--; - xmax++; + if (gameport.b1 != joy->buttons[0]) { + SDL_PrivateJoystickButton(joy, 0, gameport.b1); } - v = (Sint32) x; - v -= (xmax + xmin + 1) / 2; - v *= 32768 / ((xmax - xmin + 1) / 2); - SDL_PrivateJoystickAxis(joy, 0, v); - } - if (abs(y - gameport.y) > 8) { - y = gameport.y; - if (y < ymin) { - ymin = y; + if (gameport.b2 != joy->buttons[1]) { + SDL_PrivateJoystickButton(joy, 1, gameport.b2); } - if (y > ymax) { - ymax = y; - } - if (ymin == ymax) { - ymin--; - ymax++; - } - v = (Sint32) y; - v -= (ymax + ymin + 1) / 2; - v *= 32768 / ((ymax - ymin + 1) / 2); - SDL_PrivateJoystickAxis(joy, 1, v); - } - if (gameport.b1 != joy->buttons[0]) { - SDL_PrivateJoystickButton(joy, 0, gameport.b1); - } - if (gameport.b2 != joy->buttons[1]) { - SDL_PrivateJoystickButton(joy, 1, gameport.b2); } return; } @@ -495,65 +494,62 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joy) rep = &joy->hwdata->inreport; - if (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) != rep->size) { - return; - } + while (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) == rep->size) { #if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) || defined(__FreeBSD_kernel__) - hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input, rep->rid); + hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input, rep->rid); #else - hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input); + hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input); #endif - if (hdata == NULL) { - fprintf(stderr, "%s: Cannot start HID parser\n", joy->hwdata->path); - return; - } + if (hdata == NULL) { + /*fprintf(stderr, "%s: Cannot start HID parser\n", joy->hwdata->path);*/ + continue; + } - for (nbutton = 0; hid_get_item(hdata, &hitem) > 0;) { - switch (hitem.kind) { - case hid_input: - switch (HID_PAGE(hitem.usage)) { - case HUP_GENERIC_DESKTOP: - { - unsigned usage = HID_USAGE(hitem.usage); - int joyaxe = usage_to_joyaxe(usage); - if (joyaxe >= 0) { - naxe = joy->hwdata->axis_map[joyaxe]; - /* scaleaxe */ - v = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); - v -= (hitem.logical_maximum + - hitem.logical_minimum + 1) / 2; - v *= 32768 / - ((hitem.logical_maximum - - hitem.logical_minimum + 1) / 2); - if (v != joy->axes[naxe]) { - SDL_PrivateJoystickAxis(joy, naxe, v); + for (nbutton = 0; hid_get_item(hdata, &hitem) > 0;) { + switch (hitem.kind) { + case hid_input: + switch (HID_PAGE(hitem.usage)) { + case HUP_GENERIC_DESKTOP: + { + unsigned usage = HID_USAGE(hitem.usage); + int joyaxe = usage_to_joyaxe(usage); + if (joyaxe >= 0) { + naxe = joy->hwdata->axis_map[joyaxe]; + /* scaleaxe */ + v = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); + v -= (hitem.logical_maximum + + hitem.logical_minimum + 1) / 2; + v *= 32768 / + ((hitem.logical_maximum - + hitem.logical_minimum + 1) / 2); + if (v != joy->axes[naxe]) { + SDL_PrivateJoystickAxis(joy, naxe, v); + } + } else if (usage == HUG_HAT_SWITCH) { + v = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); + SDL_PrivateJoystickHat(joy, 0, + hatval_to_sdl(v) - + hitem.logical_minimum); } - } else if (usage == HUG_HAT_SWITCH) { - v = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); - SDL_PrivateJoystickHat(joy, 0, - hatval_to_sdl(v) - - hitem.logical_minimum); + break; } + case HUP_BUTTON: + v = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); + if (joy->buttons[nbutton] != v) { + SDL_PrivateJoystickButton(joy, nbutton, v); + } + nbutton++; break; + default: + continue; } - case HUP_BUTTON: - v = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); - if (joy->buttons[nbutton] != v) { - SDL_PrivateJoystickButton(joy, nbutton, v); - } - nbutton++; break; default: - continue; + break; } - break; - default: - break; } + hid_end_parse(hdata); } - hid_end_parse(hdata); - - return; } /* Function to close a joystick after use */ @@ -577,10 +573,8 @@ SDL_SYS_JoystickQuit(void) int i; for (i = 0; i < MAX_JOYS; i++) { - if (joynames[i] != NULL) - SDL_free(joynames[i]); - if (joydevnames[i] != NULL) - SDL_free(joydevnames[i]); + SDL_free(joynames[i]); + SDL_free(joydevnames[i]); } return; @@ -657,9 +651,7 @@ report_alloc(struct report *r, struct report_desc *rd, int repind) static void report_free(struct report *r) { - if (r->buf != NULL) { - SDL_free(r->buf); - } + SDL_free(r->buf); r->status = SREPORT_UNINIT; } diff --git a/src/joystick/darwin/SDL_sysjoystick.c b/src/joystick/darwin/SDL_sysjoystick.c index 4e50e4dd6..55ec41ed8 100644 --- a/src/joystick/darwin/SDL_sysjoystick.c +++ b/src/joystick/darwin/SDL_sysjoystick.c @@ -589,7 +589,6 @@ HIDBuildDevice(io_object_t hidDevice) if (kIOReturnSuccess == result) { HIDGetDeviceInfo(hidDevice, hidProperties, pDevice); /* hidDevice used to find parents in registry tree */ HIDGetCollectionElements(hidProperties, pDevice); - pDevice->instance_id = ++s_joystick_instance_id; } else { DisposePtr((Ptr) pDevice); pDevice = NULL; @@ -678,6 +677,9 @@ AddDeviceHelper( io_object_t ioHIDDeviceObject ) return 0; } + /* Allocate an instance ID for this device */ + device->instance_id = ++s_joystick_instance_id; + /* We have to do some storage of the io_service_t for * SDL_HapticOpenFromJoystick */ if (FFIsForceFeedback(ioHIDDeviceObject) == FF_OK) { @@ -771,7 +773,7 @@ SDL_SYS_JoystickInit(void) ("Joystick: Failed to get HID CFMutableDictionaryRef via IOServiceMatching."); } - /*/ Now search I/O Registry for matching devices. */ + /* Now search I/O Registry for matching devices. */ result = IOServiceGetMatchingServices(masterPort, hidMatchDictionary, &hidObjectIterator); diff --git a/src/joystick/iphoneos/SDL_sysjoystick.m b/src/joystick/iphoneos/SDL_sysjoystick.m index 231c851cf..6082389ff 100644 --- a/src/joystick/iphoneos/SDL_sysjoystick.m +++ b/src/joystick/iphoneos/SDL_sysjoystick.m @@ -106,7 +106,7 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) [[SDLUIAccelerationDelegate sharedDelegate] setHasNewData: NO]; SDL_PrivateJoystickAxis(joystick, 0, orientation[0]); - SDL_PrivateJoystickAxis(joystick, 1, orientation[1]); + SDL_PrivateJoystickAxis(joystick, 1, -orientation[1]); SDL_PrivateJoystickAxis(joystick, 2, orientation[2]); } diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c index 8582838a7..72fa52cad 100644 --- a/src/joystick/linux/SDL_sysjoystick.c +++ b/src/joystick/linux/SDL_sysjoystick.c @@ -52,124 +52,13 @@ #define SYN_DROPPED 3 #endif -/* - * !!! FIXME: move all the udev stuff to src/core/linux, so I can reuse it - * !!! FIXME: for audio hardware disconnects. - */ -#ifdef HAVE_LIBUDEV_H -#define SDL_USE_LIBUDEV 1 -#include "SDL_loadso.h" -#include -#include -#include +#include "../../core/linux/SDL_udev.h" -/* we never link directly to libudev. */ -/* !!! FIXME: can we generalize this? ALSA, etc, do the same things. */ -static const char *udev_library = "libudev.so.0"; -static void *udev_handle = NULL; - -/* !!! FIXME: this is kinda ugly. */ -static SDL_bool -load_udev_sym(const char *fn, void **addr) -{ - *addr = SDL_LoadFunction(udev_handle, fn); - if (*addr == NULL) { - /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ - return SDL_FALSE; - } - - return SDL_TRUE; -} - -/* libudev entry points... */ -static const char *(*UDEV_udev_device_get_action)(struct udev_device *) = NULL; -static const char *(*UDEV_udev_device_get_devnode)(struct udev_device *) = NULL; -static const char *(*UDEV_udev_device_get_property_value)(struct udev_device *, const char *) = NULL; -static struct udev_device *(*UDEV_udev_device_new_from_syspath)(struct udev *, const char *) = NULL; -static void (*UDEV_udev_device_unref)(struct udev_device *) = NULL; -static int (*UDEV_udev_enumerate_add_match_property)(struct udev_enumerate *, const char *, const char *) = NULL; -static int (*UDEV_udev_enumerate_add_match_subsystem)(struct udev_enumerate *, const char *) = NULL; -static struct udev_list_entry *(*UDEV_udev_enumerate_get_list_entry)(struct udev_enumerate *) = NULL; -static struct udev_enumerate *(*UDEV_udev_enumerate_new)(struct udev *) = NULL; -static int (*UDEV_udev_enumerate_scan_devices)(struct udev_enumerate *) = NULL; -static void (*UDEV_udev_enumerate_unref)(struct udev_enumerate *) = NULL; -static const char *(*UDEV_udev_list_entry_get_name)(struct udev_list_entry *) = NULL; -static struct udev_list_entry *(*UDEV_udev_list_entry_get_next)(struct udev_list_entry *) = NULL; -static int (*UDEV_udev_monitor_enable_receiving)(struct udev_monitor *) = NULL; -static int (*UDEV_udev_monitor_filter_add_match_subsystem_devtype)(struct udev_monitor *, const char *, const char *) = NULL; -static int (*UDEV_udev_monitor_get_fd)(struct udev_monitor *) = NULL; -static struct udev_monitor *(*UDEV_udev_monitor_new_from_netlink)(struct udev *, const char *) = NULL; -static struct udev_device *(*UDEV_udev_monitor_receive_device)(struct udev_monitor *) = NULL; -static void (*UDEV_udev_monitor_unref)(struct udev_monitor *) = NULL; -static struct udev *(*UDEV_udev_new)(void) = NULL; -static void (*UDEV_udev_unref)(struct udev *) = NULL; - -static int -load_udev_syms(void) -{ - /* cast funcs to char* first, to please GCC's strict aliasing rules. */ - #define SDL_UDEV_SYM(x) \ - if (!load_udev_sym(#x, (void **) (char *) &UDEV_##x)) return -1 - - SDL_UDEV_SYM(udev_device_get_action); - SDL_UDEV_SYM(udev_device_get_devnode); - SDL_UDEV_SYM(udev_device_get_property_value); - SDL_UDEV_SYM(udev_device_new_from_syspath); - SDL_UDEV_SYM(udev_device_unref); - SDL_UDEV_SYM(udev_enumerate_add_match_property); - SDL_UDEV_SYM(udev_enumerate_add_match_subsystem); - SDL_UDEV_SYM(udev_enumerate_get_list_entry); - SDL_UDEV_SYM(udev_enumerate_new); - SDL_UDEV_SYM(udev_enumerate_scan_devices); - SDL_UDEV_SYM(udev_enumerate_unref); - SDL_UDEV_SYM(udev_list_entry_get_name); - SDL_UDEV_SYM(udev_list_entry_get_next); - SDL_UDEV_SYM(udev_monitor_enable_receiving); - SDL_UDEV_SYM(udev_monitor_filter_add_match_subsystem_devtype); - SDL_UDEV_SYM(udev_monitor_get_fd); - SDL_UDEV_SYM(udev_monitor_new_from_netlink); - SDL_UDEV_SYM(udev_monitor_receive_device); - SDL_UDEV_SYM(udev_monitor_unref); - SDL_UDEV_SYM(udev_new); - SDL_UDEV_SYM(udev_unref); - - #undef SDL_UDEV_SYM - - return 0; -} - -static void -UnloadUDEVLibrary(void) -{ - if (udev_handle != NULL) { - SDL_UnloadObject(udev_handle); - udev_handle = NULL; - } -} - -static int -LoadUDEVLibrary(void) -{ - int retval = 0; - if (udev_handle == NULL) { - udev_handle = SDL_LoadObject(udev_library); - if (udev_handle == NULL) { - retval = -1; - /* Don't call SDL_SetError(): SDL_LoadObject already did. */ - } else { - retval = load_udev_syms(); - if (retval < 0) { - UnloadUDEVLibrary(); - } - } - } - - return retval; -} - -static struct udev *udev = NULL; -static struct udev_monitor *udev_mon = NULL; -#endif +static int MaybeAddDevice(const char *path); +#if SDL_USE_LIBUDEV +static int MaybeRemoveDevice(const char *path); +void joystick_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath); +#endif /* SDL_USE_LIBUDEV */ /* A linked list of available joysticks */ @@ -246,6 +135,30 @@ IsJoystick(int fd, char *namebuf, const size_t namebuflen, SDL_JoystickGUID *gui return 1; } +#if SDL_USE_LIBUDEV +void joystick_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath) +{ + if (devpath == NULL || !(udev_class & SDL_UDEV_DEVICE_JOYSTICK)) { + return; + } + + switch( udev_type ) + { + case SDL_UDEV_DEVICEADDED: + MaybeAddDevice(devpath); + break; + + case SDL_UDEV_DEVICEREMOVED: + MaybeRemoveDevice(devpath); + break; + + default: + break; + } + +} +#endif /* SDL_USE_LIBUDEV */ + /* !!! FIXME: I would love to dump this code and use libudev instead. */ static int @@ -257,6 +170,9 @@ MaybeAddDevice(const char *path) char namebuf[128]; SDL_JoystickGUID guid; SDL_joylist_item *item; +#if !SDL_EVENTS_DISABLED + SDL_Event event; +#endif if (path == NULL) { return -1; @@ -314,6 +230,19 @@ MaybeAddDevice(const char *path) SDL_joylist_tail = item; } + /* !!! FIXME: Move this to an SDL_PrivateJoyDeviceAdded() function? */ +#if !SDL_EVENTS_DISABLED + event.type = SDL_JOYDEVICEADDED; + + if (SDL_GetEventState(event.type) == SDL_ENABLE) { + event.jdevice.which = numjoysticks; + if ( (SDL_EventOK == NULL) || + (*SDL_EventOK) (SDL_EventOKParam, &event) ) { + SDL_PushEvent(&event); + } + } +#endif /* !SDL_EVENTS_DISABLED */ + return numjoysticks++; } @@ -324,6 +253,9 @@ MaybeRemoveDevice(const char *path) { SDL_joylist_item *item; SDL_joylist_item *prev = NULL; +#if !SDL_EVENTS_DISABLED + SDL_Event event; +#endif if (path == NULL) { return -1; @@ -345,6 +277,20 @@ MaybeRemoveDevice(const char *path) if (item == SDL_joylist_tail) { SDL_joylist_tail = prev; } + + /* !!! FIXME: Move this to an SDL_PrivateJoyDeviceRemoved() function? */ +#if !SDL_EVENTS_DISABLED + event.type = SDL_JOYDEVICEREMOVED; + + if (SDL_GetEventState(event.type) == SDL_ENABLE) { + event.jdevice.which = item->device_instance; + if ( (SDL_EventOK == NULL) || + (*SDL_EventOK) (SDL_EventOKParam, &event) ) { + SDL_PushEvent(&event); + } + } +#endif /* !SDL_EVENTS_DISABLED */ + SDL_free(item->path); SDL_free(item->name); SDL_free(item); @@ -380,40 +326,19 @@ JoystickInitWithoutUdev(void) static int JoystickInitWithUdev(void) { - struct udev_enumerate *enumerate = NULL; - struct udev_list_entry *devs = NULL; - struct udev_list_entry *item = NULL; - SDL_assert(udev == NULL); - udev = UDEV_udev_new(); - if (udev == NULL) { - return SDL_SetError("udev_new() failed"); + if (SDL_UDEV_Init() < 0) { + return SDL_SetError("Could not initialize UDEV"); } - udev_mon = UDEV_udev_monitor_new_from_netlink(udev, "udev"); - if (udev_mon != NULL) { /* okay if it's NULL, we just lose hotplugging. */ - UDEV_udev_monitor_filter_add_match_subsystem_devtype(udev_mon, - "input", NULL); - UDEV_udev_monitor_enable_receiving(udev_mon); + /* Set up the udev callback */ + if ( SDL_UDEV_AddCallback(joystick_udev_callback) < 0) { + SDL_UDEV_Quit(); + return SDL_SetError("Could not set up joystick <-> udev callback"); } - - enumerate = UDEV_udev_enumerate_new(udev); - if (enumerate == NULL) { - return SDL_SetError("udev_enumerate_new() failed"); - } - - UDEV_udev_enumerate_add_match_subsystem(enumerate, "input"); - UDEV_udev_enumerate_add_match_property(enumerate, "ID_INPUT_JOYSTICK", "1"); - UDEV_udev_enumerate_scan_devices(enumerate); - devs = UDEV_udev_enumerate_get_list_entry(enumerate); - for (item = devs; item; item = UDEV_udev_list_entry_get_next(item)) { - const char *path = UDEV_udev_list_entry_get_name(item); - struct udev_device *dev = UDEV_udev_device_new_from_syspath(udev, path); - MaybeAddDevice(UDEV_udev_device_get_devnode(dev)); - UDEV_udev_device_unref(dev); - } - - UDEV_udev_enumerate_unref(enumerate); + + /* Force a scan to build the initial device list */ + SDL_UDEV_Scan(); return numjoysticks; } @@ -439,9 +364,7 @@ SDL_SYS_JoystickInit(void) } #if SDL_USE_LIBUDEV - if (LoadUDEVLibrary() == 0) { /* okay if this fails, FOR NOW. */ - return JoystickInitWithUdev(); - } + return JoystickInitWithUdev(); #endif return JoystickInitWithoutUdev(); @@ -452,99 +375,21 @@ int SDL_SYS_NumJoysticks() return numjoysticks; } -static SDL_bool -HotplugUpdateAvailable(void) -{ -#if SDL_USE_LIBUDEV - if (udev_mon != NULL) { - const int fd = UDEV_udev_monitor_get_fd(udev_mon); - fd_set fds; - struct timeval tv; - - FD_ZERO(&fds); - FD_SET(fd, &fds); - tv.tv_sec = 0; - tv.tv_usec = 0; - if ((select(fd+1, &fds, NULL, NULL, &tv) > 0) && (FD_ISSET(fd, &fds))) { - return SDL_TRUE; - } - } -#endif - - return SDL_FALSE; -} - void SDL_SYS_JoystickDetect() { #if SDL_USE_LIBUDEV - struct udev_device *dev = NULL; - const char *devnode = NULL; - const char *action = NULL; - const char *val = NULL; - - while (HotplugUpdateAvailable()) { - dev = UDEV_udev_monitor_receive_device(udev_mon); - if (dev == NULL) { - break; - } - val = UDEV_udev_device_get_property_value(dev, "ID_INPUT_JOYSTICK"); - if ((!val) || (SDL_strcmp(val, "1") != 0)) { - continue; - } - - action = UDEV_udev_device_get_action(dev); - devnode = UDEV_udev_device_get_devnode(dev); - - if (SDL_strcmp(action, "add") == 0) { - const int device_index = MaybeAddDevice(devnode); - if (device_index != -1) { - /* !!! FIXME: Move this to an SDL_PrivateJoyDeviceAdded() function? */ - #if !SDL_EVENTS_DISABLED - SDL_Event event; - event.type = SDL_JOYDEVICEADDED; - - if (SDL_GetEventState(event.type) == SDL_ENABLE) { - event.jdevice.which = device_index; - if ( (SDL_EventOK == NULL) || - (*SDL_EventOK) (SDL_EventOKParam, &event) ) { - SDL_PushEvent(&event); - } - } - #endif /* !SDL_EVENTS_DISABLED */ - } - } else if (SDL_strcmp(action, "remove") == 0) { - const int inst = MaybeRemoveDevice(devnode); - if (inst != -1) { - /* !!! FIXME: Move this to an SDL_PrivateJoyDeviceRemoved() function? */ - #if !SDL_EVENTS_DISABLED - SDL_Event event; - event.type = SDL_JOYDEVICEREMOVED; - - if (SDL_GetEventState(event.type) == SDL_ENABLE) { - event.jdevice.which = inst; - if ( (SDL_EventOK == NULL) || - (*SDL_EventOK) (SDL_EventOKParam, &event) ) { - SDL_PushEvent(&event); - } - } - #endif /* !SDL_EVENTS_DISABLED */ - } - } - UDEV_udev_device_unref(dev); - } + SDL_UDEV_Poll(); #endif + } SDL_bool SDL_SYS_JoystickNeedsPolling() { - /* - * This results in a select() call, so technically we're polling to - * decide if we should poll, but I think this function is here because - * Windows has to do an enormous amount of work to detect new sticks, - * whereas libudev just needs to see if there's more data available on - * a socket...so this should be acceptable, I hope. - */ - return HotplugUpdateAvailable(); +#if SDL_USE_LIBUDEV + return SDL_TRUE; +#endif + + return SDL_FALSE; } static SDL_joylist_item * @@ -772,7 +617,7 @@ SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick) return !joystick->closed && (joystick->hwdata->item != NULL); } -static __inline__ void +static SDL_INLINE void HandleHat(SDL_Joystick * stick, Uint8 hat, int axis, int value) { struct hwdata_hat *the_hat; @@ -798,14 +643,14 @@ HandleHat(SDL_Joystick * stick, Uint8 hat, int axis, int value) } } -static __inline__ void +static SDL_INLINE void HandleBall(SDL_Joystick * stick, Uint8 ball, int axis, int value) { stick->hwdata->balls[ball].axis[axis] += value; } -static __inline__ int +static SDL_INLINE int AxisCorrect(SDL_Joystick * joystick, int which, int value) { struct axis_correct *correct; @@ -834,7 +679,7 @@ AxisCorrect(SDL_Joystick * joystick, int which, int value) return value; } -static __inline__ void +static SDL_INLINE void PollAllValues(SDL_Joystick * joystick) { struct input_absinfo absinfo; @@ -872,7 +717,7 @@ PollAllValues(SDL_Joystick * joystick) } } -static __inline__ void +static SDL_INLINE void HandleInputEvents(SDL_Joystick * joystick) { struct input_event events[32]; @@ -1011,15 +856,8 @@ SDL_SYS_JoystickQuit(void) instance_counter = 0; #if SDL_USE_LIBUDEV - if (udev_mon != NULL) { - UDEV_udev_monitor_unref(udev_mon); - udev_mon = NULL; - } - if (udev != NULL) { - UDEV_udev_unref(udev); - udev = NULL; - } - UnloadUDEVLibrary(); + SDL_UDEV_DelCallback(joystick_udev_callback); + SDL_UDEV_Quit(); #endif } diff --git a/src/joystick/psp/SDL_sysjoystick.c b/src/joystick/psp/SDL_sysjoystick.c index d6ca6989e..b953372d6 100644 --- a/src/joystick/psp/SDL_sysjoystick.c +++ b/src/joystick/psp/SDL_sysjoystick.c @@ -60,7 +60,7 @@ static point c = { 78, 32767 }; static point d = { 128, 32767 }; /* simple linear interpolation between two points */ -static __inline__ void lerp (point *dest, point *a, point *b, float t) +static SDL_INLINE void lerp (point *dest, point *a, point *b, float t) { dest->x = a->x + (b->x - a->x)*t; dest->y = a->y + (b->y - a->y)*t; diff --git a/src/joystick/windows/SDL_dxjoystick.c b/src/joystick/windows/SDL_dxjoystick.c index 5a832abd8..d8149a301 100644 --- a/src/joystick/windows/SDL_dxjoystick.c +++ b/src/joystick/windows/SDL_dxjoystick.c @@ -46,40 +46,17 @@ #include "../../events/SDL_events_c.h" #endif -/* The latest version of mingw-w64 defines IID_IWbemLocator in wbemcli.h - instead of declaring it like Visual Studio and other mingw32 compilers. - So, we need to take care of this here before we define INITGUID. -*/ -#ifdef __MINGW32__ -#define __IWbemLocator_INTERFACE_DEFINED__ -#endif /* __MINGW32__ */ - #define INITGUID /* Only set here, if set twice will cause mingw32 to break. */ #include "SDL_dxjoystick_c.h" -#ifdef __MINGW32__ -/* And now that we've included wbemcli.h we need to declare these interfaces */ -typedef struct IWbemLocatorVtbl { - BEGIN_INTERFACE - HRESULT (WINAPI *QueryInterface)(IWbemLocator *This,REFIID riid,void **ppvObject); - ULONG (WINAPI *AddRef)(IWbemLocator *This); - ULONG (WINAPI *Release)(IWbemLocator *This); - HRESULT (WINAPI *ConnectServer)(IWbemLocator *This,const BSTR strNetworkResource,const BSTR strUser,const BSTR strPassword,const BSTR strLocale,LONG lSecurityFlags,const BSTR strAuthority,IWbemContext *pCtx,IWbemServices **ppNamespace); - END_INTERFACE -} IWbemLocatorVtbl; -struct IWbemLocator { - CONST_VTBL struct IWbemLocatorVtbl *lpVtbl; -}; -#define IWbemLocator_ConnectServer(This,strNetworkResource,strUser,strPassword,strLocale,lSecurityFlags,strAuthority,pCtx,ppNamespace) (This)->lpVtbl->ConnectServer(This,strNetworkResource,strUser,strPassword,strLocale,lSecurityFlags,strAuthority,pCtx,ppNamespace) -#endif /* __MINGW32__ */ - #ifndef DIDFT_OPTIONAL #define DIDFT_OPTIONAL 0x80000000 #endif +DEFINE_GUID(GUID_DEVINTERFACE_HID, 0x4D1E55B2L, 0xF16F, 0x11CF, 0x88, 0xCB, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30); + #define INPUT_QSIZE 32 /* Buffer up to 32 input messages */ -#define MAX_JOYSTICKS 8 #define AXIS_MIN -32768 /* minimum value for axis coordinate */ #define AXIS_MAX 32767 /* maximum value for axis coordinate */ #define JOY_AXIS_THRESHOLD (((AXIS_MAX)-(AXIS_MIN))/100) /* 1% motion */ @@ -94,7 +71,6 @@ static LPDIRECTINPUT8 dinput = NULL; static SDL_bool s_bDeviceAdded = SDL_FALSE; static SDL_bool s_bDeviceRemoved = SDL_FALSE; static SDL_JoystickID s_nInstanceID = -1; -static GUID *s_pKnownJoystickGUIDs = NULL; static SDL_cond *s_condJoystickThread = NULL; static SDL_mutex *s_mutexJoyStickEnum = NULL; static SDL_Thread *s_threadJoystick = NULL; @@ -396,156 +372,74 @@ SetDIerror(const char *function, HRESULT code) } \ } -DEFINE_GUID(CLSID_WbemLocator, 0x4590f811,0x1d3a,0x11d0,0x89,0x1F,0x00,0xaa,0x00,0x4b,0x2e,0x24); -DEFINE_GUID(IID_IWbemLocator, 0xdc12a687,0x737f,0x11cf,0x88,0x4d,0x00,0xaa,0x00,0x4b,0x2e,0x24); - DEFINE_GUID(IID_ValveStreamingGamepad, MAKELONG( 0x28DE, 0x11FF ),0x0000,0x0000,0x00,0x00,0x50,0x49,0x44,0x56,0x49,0x44); +DEFINE_GUID(IID_X360WiredGamepad, MAKELONG( 0x045E, 0x02A1 ),0x0000,0x0000,0x00,0x00,0x50,0x49,0x44,0x56,0x49,0x44); +DEFINE_GUID(IID_X360WirelessGamepad, MAKELONG( 0x045E, 0x028E ),0x0000,0x0000,0x00,0x00,0x50,0x49,0x44,0x56,0x49,0x44); -/*----------------------------------------------------------------------------- - * - * code from MSDN: http://msdn.microsoft.com/en-us/library/windows/desktop/ee417014(v=vs.85).aspx - * - * Enum each PNP device using WMI and check each device ID to see if it contains - * "IG_" (ex. "VID_045E&PID_028E&IG_00"). If it does, then it's an XInput device - * Unfortunately this information can not be found by just using DirectInput - *-----------------------------------------------------------------------------*/ -BOOL IsXInputDevice( const GUID* pGuidProductFromDirectInput ) +static PRAWINPUTDEVICELIST SDL_RawDevList = NULL; +static UINT SDL_RawDevListCount = 0; + +static SDL_bool +SDL_IsXInputDevice( const GUID* pGuidProductFromDirectInput ) { static const GUID *s_XInputProductGUID[] = { - &IID_ValveStreamingGamepad + &IID_ValveStreamingGamepad, + &IID_X360WiredGamepad, /* Microsoft's wired X360 controller for Windows. */ + &IID_X360WirelessGamepad /* Microsoft's wireless X360 controller for Windows. */ }; - IWbemLocator* pIWbemLocator = NULL; - IEnumWbemClassObject* pEnumDevices = NULL; - IWbemClassObject* pDevices[20]; - IWbemServices* pIWbemServices = NULL; - DWORD uReturned = 0; - BSTR bstrNamespace = NULL; - BSTR bstrDeviceID = NULL; - BSTR bstrClassName = NULL; - SDL_bool bIsXinputDevice= SDL_FALSE; - UINT iDevice = 0; - VARIANT var; - HRESULT hr; - DWORD bCleanupCOM; - if (!s_bXInputEnabled) - { + size_t iDevice; + UINT i; + + if (!s_bXInputEnabled) { return SDL_FALSE; } - // Check for well known XInput device GUIDs - // We need to do this for the Valve Streaming Gamepad because it's virtualized and doesn't show up in the device list. + /* Check for well known XInput device GUIDs */ + /* This lets us skip RAWINPUT for popular devices. Also, we need to do this for the Valve Streaming Gamepad because it's virtualized and doesn't show up in the device list. */ for ( iDevice = 0; iDevice < SDL_arraysize(s_XInputProductGUID); ++iDevice ) { if (SDL_memcmp(pGuidProductFromDirectInput, s_XInputProductGUID[iDevice], sizeof(GUID)) == 0) { return SDL_TRUE; } } - SDL_memset( pDevices, 0x0, sizeof(pDevices) ); + /* Go through RAWINPUT (WinXP and later) to find HID devices. */ + /* Cache this if we end up using it. */ + if (SDL_RawDevList == NULL) { + if ((GetRawInputDeviceList(NULL, &SDL_RawDevListCount, sizeof (RAWINPUTDEVICELIST)) == -1) || (!SDL_RawDevListCount)) { + return SDL_FALSE; /* oh well. */ + } - /* CoInit if needed */ - hr = CoInitialize(NULL); - bCleanupCOM = SUCCEEDED(hr); + SDL_RawDevList = (PRAWINPUTDEVICELIST) SDL_malloc(sizeof (RAWINPUTDEVICELIST) * SDL_RawDevListCount); + if (SDL_RawDevList == NULL) { + SDL_OutOfMemory(); + return SDL_FALSE; + } - /* Create WMI */ - hr = CoCreateInstance( &CLSID_WbemLocator, - NULL, - CLSCTX_INPROC_SERVER, - &IID_IWbemLocator, - (LPVOID*) &pIWbemLocator); - if( FAILED(hr) || pIWbemLocator == NULL ) - goto LCleanup; - - bstrNamespace = SysAllocString( L"\\\\.\\root\\cimv2" );if( bstrNamespace == NULL ) goto LCleanup; - bstrClassName = SysAllocString( L"Win32_PNPEntity" ); if( bstrClassName == NULL ) goto LCleanup; - bstrDeviceID = SysAllocString( L"DeviceID" ); if( bstrDeviceID == NULL ) goto LCleanup; - - /* Connect to WMI */ - hr = IWbemLocator_ConnectServer( pIWbemLocator, bstrNamespace, NULL, NULL, 0L, - 0L, NULL, NULL, &pIWbemServices ); - if( FAILED(hr) || pIWbemServices == NULL ) - goto LCleanup; - - /* Switch security level to IMPERSONATE. */ - CoSetProxyBlanket( (IUnknown *)pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, - RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE ); - - hr = IWbemServices_CreateInstanceEnum( pIWbemServices, bstrClassName, 0, NULL, &pEnumDevices ); - if( FAILED(hr) || pEnumDevices == NULL ) - goto LCleanup; - - /* Loop over all devices */ - for( ;; ) - { - /* Get 20 at a time */ - hr = IEnumWbemClassObject_Next( pEnumDevices, 10000, 20, pDevices, &uReturned ); - if( FAILED(hr) ) - goto LCleanup; - if( uReturned == 0 ) - break; - - for( iDevice=0; iDeviceData1 ) - { - bIsXinputDevice = SDL_TRUE; - } - } - if ( pDeviceString ) - SDL_free( pDeviceString ); - - if ( bIsXinputDevice ) - break; - } - SAFE_RELEASE( pDevices[iDevice] ); + if (GetRawInputDeviceList(SDL_RawDevList, &SDL_RawDevListCount, sizeof (RAWINPUTDEVICELIST)) == -1) { + SDL_free(SDL_RawDevList); + SDL_RawDevList = NULL; + return SDL_FALSE; /* oh well. */ } } -LCleanup: + for (i = 0; i < SDL_RawDevListCount; i++) { + RID_DEVICE_INFO rdi; + char devName[128]; + UINT rdiSize = sizeof (rdi); + UINT nameSize = SDL_arraysize(devName); - for( iDevice=0; iDevice<20; iDevice++ ) - SAFE_RELEASE( pDevices[iDevice] ); - SAFE_RELEASE( pEnumDevices ); - SAFE_RELEASE( pIWbemLocator ); - SAFE_RELEASE( pIWbemServices ); + rdi.cbSize = sizeof (rdi); + if ( (SDL_RawDevList[i].dwType == RIM_TYPEHID) && + (GetRawInputDeviceInfoA(SDL_RawDevList[i].hDevice, RIDI_DEVICEINFO, &rdi, &rdiSize) != ((UINT)-1)) && + (MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) == ((LONG)pGuidProductFromDirectInput->Data1)) && + (GetRawInputDeviceInfoA(SDL_RawDevList[i].hDevice, RIDI_DEVICENAME, devName, &nameSize) != ((UINT)-1)) && + (SDL_strstr(devName, "IG_") != NULL) ) { + return SDL_TRUE; + } + } - if ( bstrNamespace ) - SysFreeString( bstrNamespace ); - if ( bstrClassName ) - SysFreeString( bstrClassName ); - if ( bstrDeviceID ) - SysFreeString( bstrDeviceID ); - - if( bCleanupCOM ) - CoUninitialize(); - - return bIsXinputDevice; + return SDL_FALSE; } @@ -586,10 +480,10 @@ SDL_JoystickThread(void *_data) HWND messageWindow = 0; HDEVNOTIFY hNotify = 0; DEV_BROADCAST_DEVICEINTERFACE dbh; - SDL_bool bOpenedXInputDevices[4]; + SDL_bool bOpenedXInputDevices[SDL_XINPUT_MAX_DEVICES]; WNDCLASSEX wincl; - SDL_memset( bOpenedXInputDevices, 0x0, sizeof(bOpenedXInputDevices) ); + SDL_zero(bOpenedXInputDevices); WIN_CoInitialize(); @@ -610,11 +504,11 @@ SDL_JoystickThread(void *_data) return SDL_SetError("Failed to create message window for joystick autodetect.", GetLastError()); } - SDL_memset(&dbh, 0x0, sizeof(dbh)); + SDL_zero(dbh); dbh.dbcc_size = sizeof(dbh); dbh.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; - dbh.dbcc_classguid = GUID_DEVINTERFACE_USB_DEVICE; + dbh.dbcc_classguid = GUID_DEVINTERFACE_HID; hNotify = RegisterDeviceNotification( messageWindow, &dbh, DEVICE_NOTIFY_WINDOW_HANDLE ); if ( !hNotify ) @@ -626,9 +520,8 @@ SDL_JoystickThread(void *_data) while ( s_bJoystickThreadQuit == SDL_FALSE ) { MSG messages; - Uint8 userId; - int nCurrentOpenedXInputDevices = 0; - int nNewOpenedXInputDevices = 0; + SDL_bool bXInputChanged = SDL_FALSE; + SDL_CondWaitTimeout( s_condJoystickThread, s_mutexJoyStickEnum, 300 ); while ( s_bJoystickThreadQuit == SDL_FALSE && PeekMessage(&messages, messageWindow, 0, 0, PM_NOREMOVE) ) @@ -639,33 +532,24 @@ SDL_JoystickThread(void *_data) } } - if ( s_bXInputEnabled && XINPUTGETCAPABILITIES ) - { + if ( s_bXInputEnabled && XINPUTGETCAPABILITIES ) { /* scan for any change in XInput devices */ - for ( userId = 0; userId < 4; userId++ ) - { + Uint8 userId; + for (userId = 0; userId < SDL_XINPUT_MAX_DEVICES; userId++) { XINPUT_CAPABILITIES capabilities; - DWORD result; - - if ( bOpenedXInputDevices[userId] == SDL_TRUE ) - nCurrentOpenedXInputDevices++; - - result = XINPUTGETCAPABILITIES( userId, XINPUT_FLAG_GAMEPAD, &capabilities ); - if ( result == ERROR_SUCCESS ) - { - bOpenedXInputDevices[userId] = SDL_TRUE; - nNewOpenedXInputDevices++; - } - else - { - bOpenedXInputDevices[userId] = SDL_FALSE; + const DWORD result = XINPUTGETCAPABILITIES( userId, XINPUT_FLAG_GAMEPAD, &capabilities ); + const SDL_bool available = (result == ERROR_SUCCESS); + if (bOpenedXInputDevices[userId] != available) { + bXInputChanged = SDL_TRUE; + bOpenedXInputDevices[userId] = available; } } } - if ( s_pKnownJoystickGUIDs && ( s_bWindowsDeviceChanged || nNewOpenedXInputDevices != nCurrentOpenedXInputDevices ) ) - { + if (s_bWindowsDeviceChanged || bXInputChanged) { + SDL_UnlockMutex( s_mutexJoyStickEnum ); /* let main thread go while we SDL_Delay(). */ SDL_Delay( 300 ); /* wait for direct input to find out about this device */ + SDL_LockMutex( s_mutexJoyStickEnum ); s_bDeviceRemoved = SDL_TRUE; s_bDeviceAdded = SDL_TRUE; @@ -730,15 +614,16 @@ SDL_SYS_JoystickInit(void) return SetDIerror("IDirectInput::Initialize", result); } - s_mutexJoyStickEnum = SDL_CreateMutex(); - s_condJoystickThread = SDL_CreateCond(); - s_bDeviceAdded = SDL_TRUE; /* force a scan of the system for joysticks this first time */ - SDL_SYS_JoystickDetect(); - if ((s_bXInputEnabled) && (WIN_LoadXInputDLL() == -1)) { s_bXInputEnabled = SDL_FALSE; /* oh well. */ } + s_mutexJoyStickEnum = SDL_CreateMutex(); + s_condJoystickThread = SDL_CreateCond(); + s_bDeviceAdded = SDL_TRUE; /* force a scan of the system for joysticks this first time */ + + SDL_SYS_JoystickDetect(); + if ( !s_threadJoystick ) { s_bJoystickThreadQuit = SDL_FALSE; @@ -767,15 +652,17 @@ int SDL_SYS_NumJoysticks() return nJoysticks; } -static int s_iNewGUID = 0; - /* helper function for direct input, gets called for each connected joystick */ static BOOL CALLBACK EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext) { JoyStick_DeviceData *pNewJoystick; JoyStick_DeviceData *pPrevJoystick = NULL; - SDL_bool bXInputDevice; + + if (SDL_IsXInputDevice( &pdidInstance->guidProduct )) { + return DIENUM_CONTINUE; /* ignore XInput devices here, keep going. */ + } + pNewJoystick = *(JoyStick_DeviceData **)pContext; while ( pNewJoystick ) { @@ -794,58 +681,109 @@ static BOOL CALLBACK pNewJoystick->pNext = SYS_Joystick; SYS_Joystick = pNewJoystick; - s_pKnownJoystickGUIDs[ s_iNewGUID ] = pdidInstance->guidInstance; - s_iNewGUID++; - if ( s_iNewGUID < MAX_JOYSTICKS ) - return DIENUM_CONTINUE; /* already have this joystick loaded, just keep going */ - else - return DIENUM_STOP; + return DIENUM_CONTINUE; /* already have this joystick loaded, just keep going */ } pPrevJoystick = pNewJoystick; pNewJoystick = pNewJoystick->pNext; } - s_bDeviceAdded = SDL_TRUE; - - bXInputDevice = IsXInputDevice( &pdidInstance->guidProduct ); - pNewJoystick = (JoyStick_DeviceData *)SDL_malloc( sizeof(JoyStick_DeviceData) ); - - if ( bXInputDevice ) - { - pNewJoystick->bXInputDevice = SDL_TRUE; - pNewJoystick->XInputUserId = INVALID_XINPUT_USERID; + if (!pNewJoystick) { + return DIENUM_CONTINUE; /* better luck next time? */ } - else - { - pNewJoystick->bXInputDevice = SDL_FALSE; + + SDL_zerop(pNewJoystick); + pNewJoystick->joystickname = WIN_StringToUTF8(pdidInstance->tszProductName); + if (!pNewJoystick->joystickname) { + SDL_free(pNewJoystick); + return DIENUM_CONTINUE; /* better luck next time? */ } SDL_memcpy(&(pNewJoystick->dxdevice), pdidInstance, sizeof(DIDEVICEINSTANCE)); - pNewJoystick->joystickname = WIN_StringToUTF8(pdidInstance->tszProductName); + pNewJoystick->XInputUserId = INVALID_XINPUT_USERID; pNewJoystick->send_add_event = 1; pNewJoystick->nInstanceID = ++s_nInstanceID; SDL_memcpy( &pNewJoystick->guid, &pdidInstance->guidProduct, sizeof(pNewJoystick->guid) ); - pNewJoystick->pNext = NULL; - - if ( SYS_Joystick ) - { - pNewJoystick->pNext = SYS_Joystick; - } + pNewJoystick->pNext = SYS_Joystick; SYS_Joystick = pNewJoystick; - s_pKnownJoystickGUIDs[ s_iNewGUID ] = pdidInstance->guidInstance; - s_iNewGUID++; + s_bDeviceAdded = SDL_TRUE; - if ( s_iNewGUID < MAX_JOYSTICKS ) - return DIENUM_CONTINUE; /* already have this joystick loaded, just keep going */ - else - return DIENUM_STOP; + return DIENUM_CONTINUE; /* get next device, please */ } +static void +AddXInputDevice(const Uint8 userid, JoyStick_DeviceData **pContext) +{ + char name[32]; + JoyStick_DeviceData *pPrevJoystick = NULL; + JoyStick_DeviceData *pNewJoystick = *pContext; + + while (pNewJoystick) { + if ((pNewJoystick->bXInputDevice) && (pNewJoystick->XInputUserId == userid)) { + /* if we are replacing the front of the list then update it */ + if (pNewJoystick == *pContext) { + *pContext = pNewJoystick->pNext; + } else if (pPrevJoystick) { + pPrevJoystick->pNext = pNewJoystick->pNext; + } + + pNewJoystick->pNext = SYS_Joystick; + SYS_Joystick = pNewJoystick; + return; /* already in the list. */ + } + + pPrevJoystick = pNewJoystick; + pNewJoystick = pNewJoystick->pNext; + } + + pNewJoystick = (JoyStick_DeviceData *) SDL_malloc(sizeof (JoyStick_DeviceData)); + if (!pNewJoystick) { + return; /* better luck next time? */ + } + SDL_zerop(pNewJoystick); + + SDL_snprintf(name, sizeof (name), "XInput Controller #%u", ((unsigned int) userid) + 1); + pNewJoystick->joystickname = SDL_strdup(name); + if (!pNewJoystick->joystickname) { + SDL_free(pNewJoystick); + return; /* better luck next time? */ + } + + pNewJoystick->bXInputDevice = SDL_TRUE; + pNewJoystick->XInputUserId = userid; + pNewJoystick->send_add_event = 1; + pNewJoystick->nInstanceID = ++s_nInstanceID; + pNewJoystick->pNext = SYS_Joystick; + SYS_Joystick = pNewJoystick; + + s_bDeviceAdded = SDL_TRUE; +} + +static void +EnumXInputDevices(JoyStick_DeviceData **pContext) +{ + if (s_bXInputEnabled) { + int iuserid; + /* iterate in reverse, so these are in the final list in ascending numeric order. */ + for (iuserid = SDL_XINPUT_MAX_DEVICES-1; iuserid >= 0; iuserid--) { + const Uint8 userid = (Uint8) iuserid; + XINPUT_CAPABILITIES capabilities; + if (XINPUTGETCAPABILITIES(userid, XINPUT_FLAG_GAMEPAD, &capabilities) == ERROR_SUCCESS) { + /* Current version of XInput mistakenly returns 0 as the Type. Ignore it and ensure the subtype is a gamepad. */ + /* !!! FIXME: we might want to support steering wheels or guitars or whatever laster. */ + if (capabilities.SubType == XINPUT_DEVSUBTYPE_GAMEPAD) { + AddXInputDevice(userid, pContext); + } + } + } + } +} + + /* detect any new joysticks being inserted into the system */ void SDL_SYS_JoystickDetect() { @@ -853,25 +791,27 @@ void SDL_SYS_JoystickDetect() /* only enum the devices if the joystick thread told us something changed */ if ( s_bDeviceAdded || s_bDeviceRemoved ) { + SDL_LockMutex( s_mutexJoyStickEnum ); + s_bDeviceAdded = SDL_FALSE; s_bDeviceRemoved = SDL_FALSE; pCurList = SYS_Joystick; SYS_Joystick = NULL; - s_iNewGUID = 0; - SDL_LockMutex( s_mutexJoyStickEnum ); - if ( !s_pKnownJoystickGUIDs ) - s_pKnownJoystickGUIDs = SDL_malloc( sizeof(GUID)*MAX_JOYSTICKS ); - - SDL_memset( s_pKnownJoystickGUIDs, 0x0, sizeof(GUID)*MAX_JOYSTICKS ); - - /* Look for joysticks, wheels, head trackers, gamepads, etc.. */ + /* Look for DirectInput joysticks, wheels, head trackers, gamepads, etc.. */ IDirectInput8_EnumDevices(dinput, DI8DEVCLASS_GAMECTRL, EnumJoysticksCallback, &pCurList, DIEDFL_ATTACHEDONLY); + SDL_free(SDL_RawDevList); /* in case we used this in DirectInput enumerator. */ + SDL_RawDevList = NULL; + SDL_RawDevListCount = 0; + + /* Look for XInput devices. Do this last, so they're first in the final list. */ + EnumXInputDevices(&pCurList); + SDL_UnlockMutex( s_mutexJoyStickEnum ); } @@ -895,7 +835,7 @@ void SDL_SYS_JoystickDetect() pListNext = pCurList->pNext; SDL_free(pCurList->joystickname); - SDL_free( pCurList ); + SDL_free(pCurList); pCurList = pListNext; } @@ -974,17 +914,11 @@ int SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index) { HRESULT result; - LPDIRECTINPUTDEVICE8 device; - DIPROPDWORD dipdw; JoyStick_DeviceData *joystickdevice = SYS_Joystick; for (; device_index > 0; device_index--) joystickdevice = joystickdevice->pNext; - SDL_memset(&dipdw, 0, sizeof(DIPROPDWORD)); - dipdw.diph.dwSize = sizeof(DIPROPDWORD); - dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); - /* allocate memory for system specific hardware data */ joystick->instance_id = joystickdevice->nInstanceID; joystick->closed = 0; @@ -993,71 +927,50 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index) if (joystick->hwdata == NULL) { return SDL_OutOfMemory(); } - SDL_memset(joystick->hwdata, 0, sizeof(struct joystick_hwdata)); - joystick->hwdata->buffered = 1; - joystick->hwdata->removed = 0; - joystick->hwdata->Capabilities.dwSize = sizeof(DIDEVCAPS); - joystick->hwdata->guid = joystickdevice->guid; + SDL_zerop(joystick->hwdata); - if ( joystickdevice->bXInputDevice ) - { + if (joystickdevice->bXInputDevice) { + const SDL_bool bIs14OrLater = (SDL_XInputVersion >= ((1<<16)|4)); + const Uint8 userId = joystickdevice->XInputUserId; XINPUT_CAPABILITIES capabilities; - Uint8 userId = 0; - DWORD result; - JoyStick_DeviceData *joysticklist = SYS_Joystick; - /* scan the opened joysticks and pick the next free xinput userid for this one */ - for( ; joysticklist; joysticklist = joysticklist->pNext) - { - if ( joysticklist->bXInputDevice && joysticklist->XInputUserId == userId ) - userId++; - } - if ( s_bXInputEnabled && XINPUTGETCAPABILITIES ) - { - result = XINPUTGETCAPABILITIES( userId, XINPUT_FLAG_GAMEPAD, &capabilities ); - if ( result == ERROR_SUCCESS ) - { - const SDL_bool bIs14OrLater = (SDL_XInputVersion >= ((1<<16)|4)); - SDL_bool bIsSupported = SDL_FALSE; - /* Current version of XInput mistakenly returns 0 as the Type. Ignore it and ensure the subtype is a gamepad. */ - bIsSupported = ( capabilities.SubType == XINPUT_DEVSUBTYPE_GAMEPAD ); + SDL_assert(s_bXInputEnabled); + SDL_assert(XINPUTGETCAPABILITIES); + SDL_assert(userId >= 0); + SDL_assert(userId < SDL_XINPUT_MAX_DEVICES); - if ( !bIsSupported ) - { - joystickdevice->bXInputDevice = SDL_FALSE; - } - else - { - /* valid */ - joystick->hwdata->bXInputDevice = SDL_TRUE; - if ((!bIs14OrLater) || (capabilities.Flags & XINPUT_CAPS_FFB_SUPPORTED)) { - joystick->hwdata->bXInputHaptic = SDL_TRUE; - } - SDL_memset( joystick->hwdata->XInputState, 0x0, sizeof(joystick->hwdata->XInputState) ); - joystickdevice->XInputUserId = userId; - joystick->hwdata->userid = userId; - joystick->hwdata->currentXInputSlot = 0; - /* The XInput API has a hard coded button/axis mapping, so we just match it */ - joystick->naxes = 6; - joystick->nbuttons = 15; - joystick->nballs = 0; - joystick->nhats = 0; - } + joystick->hwdata->bXInputDevice = SDL_TRUE; + + if (XINPUTGETCAPABILITIES(userId, XINPUT_FLAG_GAMEPAD, &capabilities) != ERROR_SUCCESS) { + SDL_free(joystick->hwdata); + joystick->hwdata = NULL; + return SDL_SetError("Failed to obtain XInput device capabilities. Device disconnected?"); + } else { + /* Current version of XInput mistakenly returns 0 as the Type. Ignore it and ensure the subtype is a gamepad. */ + SDL_assert(capabilities.SubType == XINPUT_DEVSUBTYPE_GAMEPAD); + if ((!bIs14OrLater) || (capabilities.Flags & XINPUT_CAPS_FFB_SUPPORTED)) { + joystick->hwdata->bXInputHaptic = SDL_TRUE; } - else - { - joystickdevice->bXInputDevice = SDL_FALSE; - } - } - else - { - joystickdevice->bXInputDevice = SDL_FALSE; - } - } + joystick->hwdata->userid = userId; - if ( joystickdevice->bXInputDevice == SDL_FALSE ) - { - joystick->hwdata->bXInputDevice = SDL_FALSE; + /* The XInput API has a hard coded button/axis mapping, so we just match it */ + joystick->naxes = 6; + joystick->nbuttons = 15; + joystick->nballs = 0; + joystick->nhats = 0; + } + } else { /* use DirectInput, not XInput. */ + LPDIRECTINPUTDEVICE8 device; + DIPROPDWORD dipdw; + + joystick->hwdata->buffered = 1; + joystick->hwdata->removed = 0; + joystick->hwdata->Capabilities.dwSize = sizeof(DIDEVCAPS); + joystick->hwdata->guid = joystickdevice->guid; + + SDL_zero(dipdw); + dipdw.diph.dwSize = sizeof(DIPROPDWORD); + dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); result = IDirectInput8_CreateDevice(dinput, @@ -1642,29 +1555,13 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) void SDL_SYS_JoystickClose(SDL_Joystick * joystick) { - if ( joystick->hwdata->bXInputDevice ) - { - JoyStick_DeviceData *joysticklist = SYS_Joystick; - /* scan the opened joysticks and clear the userid for this instance */ - for( ; joysticklist; joysticklist = joysticklist->pNext) - { - if ( joysticklist->bXInputDevice && joysticklist->nInstanceID == joystick->instance_id ) - { - joysticklist->XInputUserId = INVALID_XINPUT_USERID; - } - } - - } - else - { + if (!joystick->hwdata->bXInputDevice) { IDirectInputDevice8_Unacquire(joystick->hwdata->InputDevice); IDirectInputDevice8_Release(joystick->hwdata->InputDevice); } - if (joystick->hwdata != NULL) { - /* free system specific hardware data */ - SDL_free(joystick->hwdata); - } + /* free system specific hardware data */ + SDL_free(joystick->hwdata); joystick->closed = 1; } @@ -1709,18 +1606,11 @@ SDL_SYS_JoystickQuit(void) coinitialized = SDL_FALSE; } - if ( s_pKnownJoystickGUIDs ) - { - SDL_free( s_pKnownJoystickGUIDs ); - s_pKnownJoystickGUIDs = NULL; - } - if (s_bXInputEnabled) { WIN_UnloadXInputDLL(); } } - /* return the stable device guid for this device index */ SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index ) { @@ -1750,6 +1640,12 @@ SDL_bool SDL_SYS_IsXInputDeviceIndex(int device_index) return device->bXInputDevice; } +/* return SDL_TRUE if this device was opened with XInput */ +SDL_bool SDL_SYS_IsXInputJoystick(SDL_Joystick * joystick) +{ + return joystick->hwdata->bXInputDevice; +} + #endif /* SDL_JOYSTICK_DINPUT */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/joystick/windows/SDL_dxjoystick_c.h b/src/joystick/windows/SDL_dxjoystick_c.h index 01cfca970..1a4703e5e 100644 --- a/src/joystick/windows/SDL_dxjoystick_c.h +++ b/src/joystick/windows/SDL_dxjoystick_c.h @@ -42,7 +42,18 @@ #include #include #include -#include + + +#ifndef XUSER_MAX_COUNT +#define XUSER_MAX_COUNT 4 +#endif +#ifndef XUSER_INDEX_ANY +#define XUSER_INDEX_ANY 0x000000FF +#endif +#ifndef XINPUT_CAPS_FFB_SUPPORTED +#define XINPUT_CAPS_FFB_SUPPORTED 0x0001 +#endif + /* typedef's for XInput structs we use */ typedef struct @@ -94,13 +105,8 @@ extern DWORD SDL_XInputVersion; /* ((major << 16) & 0xFF00) | (minor & 0xFF) */ #define XINPUTGETSTATE SDL_XInputGetState #define XINPUTSETSTATE SDL_XInputSetState #define XINPUTGETCAPABILITIES SDL_XInputGetCapabilities -#define INVALID_XINPUT_USERID 255 -#define SDL_XINPUT_MAX_DEVICES 4 - -#ifndef XINPUT_CAPS_FFB_SUPPORTED -#define XINPUT_CAPS_FFB_SUPPORTED 0x0001 -#endif - +#define INVALID_XINPUT_USERID XUSER_INDEX_ANY +#define SDL_XINPUT_MAX_DEVICES XUSER_MAX_COUNT #define MAX_INPUTS 256 /* each joystick can have up to 256 inputs */ diff --git a/src/joystick/windows/SDL_mmjoystick.c b/src/joystick/windows/SDL_mmjoystick.c index 413053f14..e012d4466 100644 --- a/src/joystick/windows/SDL_mmjoystick.c +++ b/src/joystick/windows/SDL_mmjoystick.c @@ -33,6 +33,11 @@ #include "../SDL_sysjoystick.h" #include "../SDL_joystick_c.h" +#ifdef REGSTR_VAL_JOYOEMNAME +#undef REGSTR_VAL_JOYOEMNAME +#endif +#define REGSTR_VAL_JOYOEMNAME "OEMName" + #define MAX_JOYSTICKS 16 #define MAX_AXES 6 /* each joystick can have up to 6 axes */ #define MAX_BUTTONS 32 /* and 32 buttons */ @@ -45,7 +50,7 @@ /* array to hold joystick ID values */ static UINT SYS_JoystickID[MAX_JOYSTICKS]; -static JOYCAPS SYS_Joystick[MAX_JOYSTICKS]; +static JOYCAPSA SYS_Joystick[MAX_JOYSTICKS]; static char *SYS_JoystickName[MAX_JOYSTICKS]; /* The private structure used to keep track of a joystick */ @@ -148,7 +153,7 @@ SDL_SYS_JoystickInit(void) int i; int maxdevs; JOYINFOEX joyinfo; - JOYCAPS joycaps; + JOYCAPSA joycaps; MMRESULT result; /* Reset the joystick ID & name mapping tables */ @@ -166,7 +171,7 @@ SDL_SYS_JoystickInit(void) joyinfo.dwFlags = JOY_RETURNALL; result = joyGetPosEx(i, &joyinfo); if (result == JOYERR_NOERROR) { - result = joyGetDevCaps(i, &joycaps, sizeof(joycaps)); + result = joyGetDevCapsA(i, &joycaps, sizeof(joycaps)); if (result == JOYERR_NOERROR) { SYS_JoystickID[SDL_SYS_numjoysticks] = i; SYS_Joystick[SDL_SYS_numjoysticks] = joycaps; @@ -384,11 +389,9 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) void SDL_SYS_JoystickClose(SDL_Joystick * joystick) { - if (joystick->hwdata != NULL) { - /* free system specific hardware data */ - SDL_free(joystick->hwdata); - joystick->hwdata = NULL; - } + /* free system specific hardware data */ + SDL_free(joystick->hwdata); + joystick->hwdata = NULL; } /* Function to perform any system-specific joystick related cleanup */ @@ -397,10 +400,8 @@ SDL_SYS_JoystickQuit(void) { int i; for (i = 0; i < MAX_JOYSTICKS; i++) { - if (SYS_JoystickName[i] != NULL) { - SDL_free(SYS_JoystickName[i]); - SYS_JoystickName[i] = NULL; - } + SDL_free(SYS_JoystickName[i]); + SYS_JoystickName[i] = NULL; } } diff --git a/src/libm/e_atan2.c b/src/libm/e_atan2.c index 3f1ee5771..f7b91a3e1 100644 --- a/src/libm/e_atan2.c +++ b/src/libm/e_atan2.c @@ -81,8 +81,8 @@ double attribute_hidden __ieee754_atan2(double y, double x) switch(m) { case 0: return pi_o_4+tiny;/* atan(+INF,+INF) */ case 1: return -pi_o_4-tiny;/* atan(-INF,+INF) */ - case 2: return 3.0*pi_o_4+tiny;/*atan(+INF,-INF)*/ - case 3: return -3.0*pi_o_4-tiny;/*atan(-INF,-INF)*/ + case 2: return 3.0*pi_o_4+tiny;/* atan(+INF,-INF) */ + case 3: return -3.0*pi_o_4-tiny;/* atan(-INF,-INF) */ } } else { switch(m) { diff --git a/src/libm/e_pow.c b/src/libm/e_pow.c index 9145c4b57..686da2e55 100644 --- a/src/libm/e_pow.c +++ b/src/libm/e_pow.c @@ -178,7 +178,7 @@ libm_hidden_proto(scalbn) /* special value of x */ if (lx == 0) { if (ix == 0x7ff00000 || ix == 0 || ix == 0x3ff00000) { - z = ax; /*x is +-0,+-inf,+-1 */ + z = ax; /* x is +-0,+-inf,+-1 */ if (hy < 0) z = one / z; /* z = (1/|x|) */ if (hx < 0) { diff --git a/src/libm/math_private.h b/src/libm/math_private.h index c5ab63d7c..6ab0f35fd 100644 --- a/src/libm/math_private.h +++ b/src/libm/math_private.h @@ -17,9 +17,9 @@ #ifndef _MATH_PRIVATE_H_ #define _MATH_PRIVATE_H_ -/*#include */ +/* #include */ #include "SDL_endian.h" -/*#include */ +/* #include */ #define attribute_hidden #define libm_hidden_proto(x) diff --git a/src/libm/s_scalbn.c b/src/libm/s_scalbn.c index 74b979445..f824e926d 100644 --- a/src/libm/s_scalbn.c +++ b/src/libm/s_scalbn.c @@ -54,7 +54,7 @@ libm_hidden_proto(scalbn) GET_HIGH_WORD(hx, x); k = ((hx & 0x7ff00000) >> 20) - 54; if (n < -50000) - return tiny * x; /*underflow */ + return tiny * x; /* underflow */ } if (k == 0x7ff) return x + x; /* NaN or Inf */ @@ -67,9 +67,9 @@ libm_hidden_proto(scalbn) } if (k <= -54) { if (n > 50000) /* in case integer overflow in n+k */ - return huge_val * copysign(huge_val, x); /*overflow */ + return huge_val * copysign(huge_val, x); /* overflow */ else - return tiny * copysign(tiny, x); /*underflow */ + return tiny * copysign(tiny, x); /* underflow */ } k += 54; /* subnormal result */ SET_HIGH_WORD(x, (hx & 0x800fffff) | (k << 20)); diff --git a/src/main/android/SDL_android_main.c b/src/main/android/SDL_android_main.c index 0622a12c4..8f00f39d9 100644 --- a/src/main/android/SDL_android_main.c +++ b/src/main/android/SDL_android_main.c @@ -11,10 +11,10 @@ *******************************************************************************/ #include -// Called before SDL_main() to initialize JNI bindings in SDL library +/* Called before SDL_main() to initialize JNI bindings in SDL library */ extern void SDL_Android_Init(JNIEnv* env, jclass cls); -// Start up the SDL app +/* Start up the SDL app */ void Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject obj) { /* This interface could expand with ABI negotiation, calbacks, etc. */ @@ -30,7 +30,7 @@ void Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject status = SDL_main(1, argv); /* Do not issue an exit or the whole application will terminate instead of just the SDL thread */ - //exit(status); + /* exit(status); */ } #endif /* __ANDROID__ */ diff --git a/src/main/beos/SDL_BApp.h b/src/main/beos/SDL_BApp.h index 2a64455b6..9b731e3e7 100644 --- a/src/main/beos/SDL_BApp.h +++ b/src/main/beos/SDL_BApp.h @@ -371,7 +371,7 @@ private: /* Members */ - vector _window_map; /* Keeps track of SDL_Windows by index-id*/ + std::vector _window_map; /* Keeps track of SDL_Windows by index-id */ display_mode *_saved_mode; BGLView *_current_context; diff --git a/src/main/windows/SDL_windows_main.c b/src/main/windows/SDL_windows_main.c index 519ce14b8..4e8e3f2f4 100644 --- a/src/main/windows/SDL_windows_main.c +++ b/src/main/windows/SDL_windows_main.c @@ -7,12 +7,12 @@ #ifdef __WIN32__ +/* Include this so we define UNICODE properly */ +#include "../../core/windows/SDL_windows.h" + #include #include -#define WIN32_LEAN_AND_MEAN -#include - /* Include the SDL main definition header */ #include "SDL.h" #include "SDL_main.h" diff --git a/src/main/windows/version.rc b/src/main/windows/version.rc index 129a1f5dd..b096a9149 100644 --- a/src/main/windows/version.rc +++ b/src/main/windows/version.rc @@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,0,0,0 - PRODUCTVERSION 2,0,0,0 + FILEVERSION 2,0,1,0 + PRODUCTVERSION 2,0,1,0 FILEFLAGSMASK 0x3fL FILEFLAGS 0x0L FILEOS 0x40004L @@ -23,12 +23,12 @@ BEGIN BEGIN VALUE "CompanyName", "\0" VALUE "FileDescription", "SDL\0" - VALUE "FileVersion", "2, 0, 0, 0\0" + VALUE "FileVersion", "2, 0, 1, 0\0" VALUE "InternalName", "SDL\0" VALUE "LegalCopyright", "Copyright 2013 Sam Lantinga\0" - VALUE "OriginalFilename", "SDL.dll\0" + VALUE "OriginalFilename", "SDL2.dll\0" VALUE "ProductName", "Simple DirectMedia Layer\0" - VALUE "ProductVersion", "2, 0, 0, 0\0" + VALUE "ProductVersion", "2, 0, 1, 0\0" END END BLOCK "VarFileInfo" diff --git a/src/power/uikit/SDL_syspower.m b/src/power/uikit/SDL_syspower.m index 3364da56e..f870ea2a9 100644 --- a/src/power/uikit/SDL_syspower.m +++ b/src/power/uikit/SDL_syspower.m @@ -38,11 +38,7 @@ void SDL_UIKit_UpdateBatteryMonitoring(void) { if (SDL_UIKitLastPowerInfoQuery) { - const Uint32 prev = SDL_UIKitLastPowerInfoQuery; - const UInt32 now = SDL_GetTicks(); - const UInt32 ticks = now - prev; - /* if timer wrapped (now < prev), shut down, too. */ - if ((now < prev) || (ticks >= BATTERY_MONITORING_TIMEOUT)) { + if (SDL_TICKS_PASSED(SDL_GetTicks(), SDL_UIKitLastPowerInfoQuery + BATTERY_MONITORING_TIMEOUT)) { UIDevice *uidev = [UIDevice currentDevice]; SDL_assert([uidev isBatteryMonitoringEnabled] == YES); [uidev setBatteryMonitoringEnabled:NO]; diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 5827a55e1..e2ca09b2e 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -22,6 +22,7 @@ /* The SDL 2D rendering system */ +#include "SDL_assert.h" #include "SDL_hints.h" #include "SDL_log.h" #include "SDL_render.h" @@ -120,7 +121,12 @@ SDL_RendererEventWatch(void *userdata, SDL_Event *event) /* Window was resized, reset viewport */ int w, h; - SDL_GetWindowSize(window, &w, &h); + if (renderer->GetOutputSize) { + renderer->GetOutputSize(renderer, &w, &h); + } else { + SDL_GetWindowSize(renderer->window, &w, &h); + } + if (renderer->target) { renderer->viewport_backup.x = 0; renderer->viewport_backup.y = 0; @@ -338,11 +344,11 @@ SDL_GetRendererOutputSize(SDL_Renderer * renderer, int *w, int *h) if (renderer->target) { return SDL_QueryTexture(renderer->target, NULL, NULL, w, h); + } else if (renderer->GetOutputSize) { + return renderer->GetOutputSize(renderer, w, h); } else if (renderer->window) { SDL_GetWindowSize(renderer->window, w, h); return 0; - } else if (renderer->GetOutputSize) { - return renderer->GetOutputSize(renderer, w, h); } else { /* This should never happen */ SDL_SetError("Renderer doesn't support querying output size"); @@ -407,6 +413,11 @@ SDL_CreateTexture(SDL_Renderer * renderer, Uint32 format, int access, int w, int SDL_SetError("Texture dimensions can't be 0"); return NULL; } + if ((renderer->info.max_texture_width && w > renderer->info.max_texture_width) || + (renderer->info.max_texture_height && h > renderer->info.max_texture_height)) { + SDL_SetError("Texture dimensions are limited to %dx%d", renderer->info.max_texture_width, renderer->info.max_texture_height); + return NULL; + } texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture)); if (!texture) { SDL_OutOfMemory(); @@ -802,6 +813,110 @@ SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect, } } +static int +SDL_UpdateTextureYUVPlanar(SDL_Texture * texture, const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) +{ + SDL_Texture *native = texture->native; + SDL_Rect full_rect; + + if (SDL_SW_UpdateYUVTexturePlanar(texture->yuv, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch) < 0) { + return -1; + } + + full_rect.x = 0; + full_rect.y = 0; + full_rect.w = texture->w; + full_rect.h = texture->h; + rect = &full_rect; + + if (texture->access == SDL_TEXTUREACCESS_STREAMING) { + /* We can lock the texture and copy to it */ + void *native_pixels; + int native_pitch; + + if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) { + return -1; + } + SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format, + rect->w, rect->h, native_pixels, native_pitch); + SDL_UnlockTexture(native); + } else { + /* Use a temporary buffer for updating */ + void *temp_pixels; + int temp_pitch; + + temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3); + temp_pixels = SDL_malloc(rect->h * temp_pitch); + if (!temp_pixels) { + return SDL_OutOfMemory(); + } + SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format, + rect->w, rect->h, temp_pixels, temp_pitch); + SDL_UpdateTexture(native, rect, temp_pixels, temp_pitch); + SDL_free(temp_pixels); + } + return 0; +} + +int SDL_UpdateYUVTexture(SDL_Texture * texture, const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) +{ + SDL_Renderer *renderer; + SDL_Rect full_rect; + + CHECK_TEXTURE_MAGIC(texture, -1); + + if (!Yplane) { + return SDL_InvalidParamError("Yplane"); + } + if (!Ypitch) { + return SDL_InvalidParamError("Ypitch"); + } + if (!Uplane) { + return SDL_InvalidParamError("Uplane"); + } + if (!Upitch) { + return SDL_InvalidParamError("Upitch"); + } + if (!Vplane) { + return SDL_InvalidParamError("Vplane"); + } + if (!Vpitch) { + return SDL_InvalidParamError("Vpitch"); + } + + if (texture->format != SDL_PIXELFORMAT_YV12 && + texture->format != SDL_PIXELFORMAT_IYUV) { + return SDL_SetError("Texture format must by YV12 or IYUV"); + } + + if (!rect) { + full_rect.x = 0; + full_rect.y = 0; + full_rect.w = texture->w; + full_rect.h = texture->h; + rect = &full_rect; + } + + if (texture->yuv) { + return SDL_UpdateTextureYUVPlanar(texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch); + } else { + SDL_assert(!texture->native); + renderer = texture->renderer; + SDL_assert(renderer->UpdateTextureYUV); + if (renderer->UpdateTextureYUV) { + return renderer->UpdateTextureYUV(renderer, texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch); + } else { + return SDL_Unsupported(); + } + } +} + static int SDL_LockTextureYUV(SDL_Texture * texture, const SDL_Rect * rect, void **pixels, int *pitch) @@ -1715,9 +1830,7 @@ SDL_DestroyTexture(SDL_Texture * texture) if (texture->yuv) { SDL_SW_DestroyYUVTexture(texture->yuv); } - if (texture->pixels) { - SDL_free(texture->pixels); - } + SDL_free(texture->pixels); renderer->DestroyTexture(renderer, texture); SDL_free(texture); diff --git a/src/render/SDL_sysrender.h b/src/render/SDL_sysrender.h index 10504654f..b1b691513 100644 --- a/src/render/SDL_sysrender.h +++ b/src/render/SDL_sysrender.h @@ -89,6 +89,11 @@ struct SDL_Renderer int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, const void *pixels, int pitch); + int (*UpdateTextureYUV) (SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch); int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, void **pixels, int *pitch); void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture); diff --git a/src/render/SDL_yuv_sw.c b/src/render/SDL_yuv_sw.c index bb235b0a2..14b825d9c 100644 --- a/src/render/SDL_yuv_sw.c +++ b/src/render/SDL_yuv_sw.c @@ -958,10 +958,10 @@ SDL_SW_SetupYUVDisplay(SDL_SW_YUVTexture * swdata, Uint32 target_format) if (SDL_HasMMX() && (Rmask == 0xF800) && (Gmask == 0x07E0) && (Bmask == 0x001F) && (swdata->w & 15) == 0) { -/*printf("Using MMX 16-bit 565 dither\n");*/ +/* printf("Using MMX 16-bit 565 dither\n"); */ swdata->Display1X = Color565DitherYV12MMX1X; } else { -/*printf("Using C 16-bit dither\n");*/ +/* printf("Using C 16-bit dither\n"); */ swdata->Display1X = Color16DitherYV12Mod1X; } #else @@ -979,10 +979,10 @@ SDL_SW_SetupYUVDisplay(SDL_SW_YUVTexture * swdata, Uint32 target_format) if (SDL_HasMMX() && (Rmask == 0x00FF0000) && (Gmask == 0x0000FF00) && (Bmask == 0x000000FF) && (swdata->w & 15) == 0) { -/*printf("Using MMX 32-bit dither\n");*/ +/* printf("Using MMX 32-bit dither\n"); */ swdata->Display1X = ColorRGBDitherYV12MMX1X; } else { -/*printf("Using C 32-bit dither\n");*/ +/* printf("Using C 32-bit dither\n"); */ swdata->Display1X = Color32DitherYV12Mod1X; } #else @@ -1012,10 +1012,8 @@ SDL_SW_SetupYUVDisplay(SDL_SW_YUVTexture * swdata, Uint32 target_format) break; } - if (swdata->display) { - SDL_FreeSurface(swdata->display); - swdata->display = NULL; - } + SDL_FreeSurface(swdata->display); + swdata->display = NULL; return 0; } @@ -1186,6 +1184,61 @@ SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, return 0; } +int +SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) +{ + const Uint8 *src; + Uint8 *dst; + int row; + size_t length; + + /* Copy the Y plane */ + src = Yplane; + dst = swdata->pixels + rect->y * swdata->w + rect->x; + length = rect->w; + for (row = 0; row < rect->h; ++row) { + SDL_memcpy(dst, src, length); + src += Ypitch; + dst += swdata->w; + } + + /* Copy the U plane */ + src = Uplane; + if (swdata->format == SDL_PIXELFORMAT_IYUV) { + dst = swdata->pixels + swdata->h * swdata->w; + } else { + dst = swdata->pixels + swdata->h * swdata->w + + (swdata->h * swdata->w) / 4; + } + dst += rect->y/2 * swdata->w/2 + rect->x/2; + length = rect->w / 2; + for (row = 0; row < rect->h/2; ++row) { + SDL_memcpy(dst, src, length); + src += Upitch; + dst += swdata->w/2; + } + + /* Copy the V plane */ + src = Vplane; + if (swdata->format == SDL_PIXELFORMAT_YV12) { + dst = swdata->pixels + swdata->h * swdata->w; + } else { + dst = swdata->pixels + swdata->h * swdata->w + + (swdata->h * swdata->w) / 4; + } + dst += rect->y/2 * swdata->w/2 + rect->x/2; + length = rect->w / 2; + for (row = 0; row < rect->h/2; ++row) { + SDL_memcpy(dst, src, length); + src += Vpitch; + dst += swdata->w/2; + } + return 0; +} + int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, void **pixels, int *pitch) @@ -1335,21 +1388,11 @@ void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata) { if (swdata) { - if (swdata->pixels) { - SDL_free(swdata->pixels); - } - if (swdata->colortab) { - SDL_free(swdata->colortab); - } - if (swdata->rgb_2_pix) { - SDL_free(swdata->rgb_2_pix); - } - if (swdata->stretch) { - SDL_FreeSurface(swdata->stretch); - } - if (swdata->display) { - SDL_FreeSurface(swdata->display); - } + SDL_free(swdata->pixels); + SDL_free(swdata->colortab); + SDL_free(swdata->rgb_2_pix); + SDL_FreeSurface(swdata->stretch); + SDL_FreeSurface(swdata->display); SDL_free(swdata); } } diff --git a/src/render/SDL_yuv_sw_c.h b/src/render/SDL_yuv_sw_c.h index 9debacbcf..f1280417f 100644 --- a/src/render/SDL_yuv_sw_c.h +++ b/src/render/SDL_yuv_sw_c.h @@ -57,6 +57,10 @@ int SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture * swdata, void **pixels, int *pitch); int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, const void *pixels, int pitch); +int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch); int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, void **pixels, int *pitch); void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture * swdata); diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index e9fc0ce04..a4c602757 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -22,14 +22,14 @@ #if SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED - #include "../../core/windows/SDL_windows.h" #include "SDL_hints.h" #include "SDL_loadso.h" #include "SDL_syswm.h" +#include "SDL_system.h" #include "../SDL_sysrender.h" -#include +#include "../../video/windows/SDL_windowsvideo.h" #if SDL_VIDEO_RENDER_D3D #define D3D_DEBUG_INFO @@ -207,6 +207,11 @@ static int D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); static int D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, const void *pixels, int pitch); +static int D3D_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch); static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, void **pixels, int *pitch); static void D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); @@ -395,6 +400,73 @@ D3DFMTToPixelFormat(D3DFORMAT format) } } +static void +D3D_InitRenderState(D3D_RenderData *data) +{ + D3DMATRIX matrix; + + IDirect3DDevice9 *device = data->device; + + IDirect3DDevice9_SetVertexShader(device, NULL); + IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1); + IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE); + IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE); + IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE); + + /* Enable color modulation by diffuse color */ + IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, + D3DTOP_MODULATE); + IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, + D3DTA_TEXTURE); + IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG2, + D3DTA_DIFFUSE); + + /* Enable alpha modulation by diffuse alpha */ + IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAOP, + D3DTOP_MODULATE); + IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAARG1, + D3DTA_TEXTURE); + IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAARG2, + D3DTA_DIFFUSE); + + /* Enable separate alpha blend function, if possible */ + if (data->enableSeparateAlphaBlend) { + IDirect3DDevice9_SetRenderState(device, D3DRS_SEPARATEALPHABLENDENABLE, TRUE); + } + + /* Disable second texture stage, since we're done */ + IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLOROP, + D3DTOP_DISABLE); + IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_ALPHAOP, + D3DTOP_DISABLE); + + /* Set an identity world and view matrix */ + matrix.m[0][0] = 1.0f; + matrix.m[0][1] = 0.0f; + matrix.m[0][2] = 0.0f; + matrix.m[0][3] = 0.0f; + matrix.m[1][0] = 0.0f; + matrix.m[1][1] = 1.0f; + matrix.m[1][2] = 0.0f; + matrix.m[1][3] = 0.0f; + matrix.m[2][0] = 0.0f; + matrix.m[2][1] = 0.0f; + matrix.m[2][2] = 1.0f; + matrix.m[2][3] = 0.0f; + matrix.m[3][0] = 0.0f; + matrix.m[3][1] = 0.0f; + matrix.m[3][2] = 0.0f; + matrix.m[3][3] = 1.0f; + IDirect3DDevice9_SetTransform(device, D3DTS_WORLD, &matrix); + IDirect3DDevice9_SetTransform(device, D3DTS_VIEW, &matrix); + + /* Reset our current scale mode */ + SDL_memset(data->scaleMode, 0xFF, sizeof(data->scaleMode)); + + /* Start the render with beginScene */ + data->beginScene = SDL_TRUE; +} + static int D3D_Reset(SDL_Renderer * renderer) { @@ -416,14 +488,9 @@ D3D_Reset(SDL_Renderer * renderer) return D3D_SetError("Reset()", result); } } - IDirect3DDevice9_SetVertexShader(data->device, NULL); - IDirect3DDevice9_SetFVF(data->device, - D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1); - IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE, - D3DCULL_NONE); - IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE); + IDirect3DDevice9_GetRenderTarget(data->device, 0, &data->defaultRenderTarget); - SDL_memset(data->scaleMode, 0xFF, sizeof(data->scaleMode)); + D3D_InitRenderState(data); D3D_UpdateViewport(renderer); return 0; } @@ -476,15 +543,17 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) D3D_RenderData *data; SDL_SysWMinfo windowinfo; HRESULT result; + const char *hint; D3DPRESENT_PARAMETERS pparams; IDirect3DSwapChain9 *chain; D3DCAPS9 caps; + DWORD device_flags; Uint32 window_flags; int w, h; SDL_DisplayMode fullscreen_mode; - D3DMATRIX matrix; int d3dxVersion; char d3dxDLLFile[50]; + int displayIndex; renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); if (!renderer) { @@ -499,21 +568,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) return NULL; } - data->d3dDLL = SDL_LoadObject("D3D9.DLL"); - if (data->d3dDLL) { - IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion); - - D3DCreate = - (IDirect3D9 * (WINAPI *) (UINT)) SDL_LoadFunction(data->d3dDLL, - "Direct3DCreate9"); - if (D3DCreate) { - data->d3d = D3DCreate(D3D_SDK_VERSION); - } - if (!data->d3d) { - SDL_UnloadObject(data->d3dDLL); - data->d3dDLL = NULL; - } - + if( D3D_LoadDLL( &data->d3dDLL, &data->d3d ) ) { for (d3dxVersion=50;d3dxVersion>0;d3dxVersion--) { LPTSTR dllName; SDL_snprintf(d3dxDLLFile, sizeof(d3dxDLLFile), "D3DX9_%02d.dll", d3dxVersion); @@ -535,8 +590,6 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) } } - - if (!data->d3d || !data->matrixStack) { SDL_free(renderer); SDL_free(data); @@ -547,6 +600,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->WindowEvent = D3D_WindowEvent; renderer->CreateTexture = D3D_CreateTexture; renderer->UpdateTexture = D3D_UpdateTexture; + renderer->UpdateTextureYUV = D3D_UpdateTextureYUV; renderer->LockTexture = D3D_LockTexture; renderer->UnlockTexture = D3D_UnlockTexture; renderer->SetRenderTarget = D3D_SetRenderTarget; @@ -606,26 +660,34 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) pparams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; } - /* FIXME: Which adapter? */ - data->adapter = D3DADAPTER_DEFAULT; + /* Get the adapter for the display that the window is on */ + displayIndex = SDL_GetWindowDisplayIndex( window ); + data->adapter = SDL_Direct3D9GetAdapterIndex( displayIndex ); + IDirect3D9_GetDeviceCaps(data->d3d, data->adapter, D3DDEVTYPE_HAL, &caps); + device_flags = D3DCREATE_FPU_PRESERVE; + if (caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) { + device_flags |= D3DCREATE_HARDWARE_VERTEXPROCESSING; + } else { + device_flags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING; + } + + hint = SDL_GetHint(SDL_HINT_RENDER_DIRECT3D_THREADSAFE); + if (hint && SDL_atoi(hint)) { + device_flags |= D3DCREATE_MULTITHREADED; + } + result = IDirect3D9_CreateDevice(data->d3d, data->adapter, D3DDEVTYPE_HAL, pparams.hDeviceWindow, - D3DCREATE_FPU_PRESERVE | ((caps. - DevCaps & - D3DDEVCAPS_HWTRANSFORMANDLIGHT) ? - D3DCREATE_HARDWARE_VERTEXPROCESSING : - D3DCREATE_SOFTWARE_VERTEXPROCESSING), + device_flags, &pparams, &data->device); if (FAILED(result)) { D3D_DestroyRenderer(renderer); D3D_SetError("CreateDevice()", result); return NULL; } - data->beginScene = SDL_TRUE; - SDL_memset(data->scaleMode, 0xFF, sizeof(data->scaleMode)); /* Get presentation parameters to fill info */ result = IDirect3DDevice9_GetSwapChain(data->device, 0, &chain); @@ -658,61 +720,12 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) data->enableSeparateAlphaBlend = SDL_TRUE; } - /* Set up parameters for rendering */ - IDirect3DDevice9_SetVertexShader(data->device, NULL); - IDirect3DDevice9_SetFVF(data->device, - D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1); - IDirect3DDevice9_SetRenderState(data->device, D3DRS_ZENABLE, D3DZB_FALSE); - IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE, - D3DCULL_NONE); - IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE); - /* Enable color modulation by diffuse color */ - IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLOROP, - D3DTOP_MODULATE); - IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLORARG1, - D3DTA_TEXTURE); - IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLORARG2, - D3DTA_DIFFUSE); - /* Enable alpha modulation by diffuse alpha */ - IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAOP, - D3DTOP_MODULATE); - IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAARG1, - D3DTA_TEXTURE); - IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAARG2, - D3DTA_DIFFUSE); - /* Enable separate alpha blend function, if possible */ - if (data->enableSeparateAlphaBlend) { - IDirect3DDevice9_SetRenderState(data->device, D3DRS_SEPARATEALPHABLENDENABLE, TRUE); - } - /* Disable second texture stage, since we're done */ - IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_COLOROP, - D3DTOP_DISABLE); - IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_ALPHAOP, - D3DTOP_DISABLE); - /* Store the default render target */ IDirect3DDevice9_GetRenderTarget(data->device, 0, &data->defaultRenderTarget ); data->currentRenderTarget = NULL; - /* Set an identity world and view matrix */ - matrix.m[0][0] = 1.0f; - matrix.m[0][1] = 0.0f; - matrix.m[0][2] = 0.0f; - matrix.m[0][3] = 0.0f; - matrix.m[1][0] = 0.0f; - matrix.m[1][1] = 1.0f; - matrix.m[1][2] = 0.0f; - matrix.m[1][3] = 0.0f; - matrix.m[2][0] = 0.0f; - matrix.m[2][1] = 0.0f; - matrix.m[2][2] = 1.0f; - matrix.m[2][3] = 0.0f; - matrix.m[3][0] = 0.0f; - matrix.m[3][1] = 0.0f; - matrix.m[3][2] = 0.0f; - matrix.m[3][3] = 1.0f; - IDirect3DDevice9_SetTransform(data->device, D3DTS_WORLD, &matrix); - IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, &matrix); + /* Set up parameters for rendering */ + D3D_InitRenderState(data); if (caps.MaxSimultaneousTextures >= 3) { @@ -864,7 +877,7 @@ GetScaleQuality(void) if (!hint || *hint == '0' || SDL_strcasecmp(hint, "nearest") == 0) { return D3DTEXF_POINT; - } else /*if (*hint == '1' || SDL_strcasecmp(hint, "linear") == 0)*/ { + } else /* if (*hint == '1' || SDL_strcasecmp(hint, "linear") == 0) */ { return D3DTEXF_LINEAR; } } @@ -1013,6 +1026,36 @@ D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, return 0; } +static int +D3D_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) +{ + D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; + SDL_bool full_texture = SDL_FALSE; + +#ifdef USE_DYNAMIC_TEXTURE + if (texture->access == SDL_TEXTUREACCESS_STREAMING && + rect->x == 0 && rect->y == 0 && + rect->w == texture->w && rect->h == texture->h) { + full_texture = SDL_TRUE; + } +#endif + + if (D3D_UpdateTextureInternal(data->texture, texture->format, full_texture, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch) < 0) { + return -1; + } + if (D3D_UpdateTextureInternal(data->utexture, texture->format, full_texture, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Uplane, Upitch) < 0) { + return -1; + } + if (D3D_UpdateTextureInternal(data->vtexture, texture->format, full_texture, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Vplane, Vpitch) < 0) { + return -1; + } + return 0; +} + static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, void **pixels, int *pitch) @@ -1023,7 +1066,7 @@ D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, HRESULT result; if (data->yuv) { - // It's more efficient to upload directly... + /* It's more efficient to upload directly... */ if (!data->pixels) { data->pitch = texture->w; data->pixels = (Uint8 *)SDL_malloc((texture->h * data->pitch * 3) / 2); @@ -1173,6 +1216,7 @@ D3D_RenderClear(SDL_Renderer * renderer) D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; DWORD color; HRESULT result; + int BackBufferWidth, BackBufferHeight; if (D3D_ActivateRenderer(renderer) < 0) { return -1; @@ -1180,10 +1224,18 @@ D3D_RenderClear(SDL_Renderer * renderer) color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b); + if (renderer->target) { + BackBufferWidth = renderer->target->w; + BackBufferHeight = renderer->target->h; + } else { + BackBufferWidth = data->pparams.BackBufferWidth; + BackBufferHeight = data->pparams.BackBufferHeight; + } + /* Don't reset the viewport if we don't have to! */ if (!renderer->viewport.x && !renderer->viewport.y && - renderer->viewport.w == data->pparams.BackBufferWidth && - renderer->viewport.h == data->pparams.BackBufferHeight) { + renderer->viewport.w == BackBufferWidth && + renderer->viewport.h == BackBufferHeight) { result = IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0); } else { D3DVIEWPORT9 viewport; @@ -1191,8 +1243,8 @@ D3D_RenderClear(SDL_Renderer * renderer) /* Clear is defined to clear the entire render target */ viewport.X = 0; viewport.Y = 0; - viewport.Width = data->pparams.BackBufferWidth; - viewport.Height = data->pparams.BackBufferHeight; + viewport.Width = BackBufferWidth; + viewport.Height = BackBufferHeight; viewport.MinZ = 0.0f; viewport.MaxZ = 1.0f; IDirect3DDevice9_SetViewport(data->device, &viewport); @@ -1803,9 +1855,7 @@ D3D_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) if (data->vtexture) { IDirect3DTexture9_Release(data->vtexture); } - if (data->pixels) { - SDL_free(data->pixels); - } + SDL_free(data->pixels); SDL_free(data); texture->driverdata = NULL; } @@ -1825,7 +1875,9 @@ D3D_DestroyRenderer(SDL_Renderer * renderer) IDirect3DSurface9_Release(data->currentRenderTarget); data->currentRenderTarget = NULL; } - + if (data->ps_yuv) { + IDirect3DPixelShader9_Release(data->ps_yuv); + } if (data->device) { IDirect3DDevice9_Release(data->device); } @@ -1839,6 +1891,25 @@ D3D_DestroyRenderer(SDL_Renderer * renderer) SDL_free(renderer); } +IDirect3DDevice9 * +SDL_RenderGetD3D9Device(SDL_Renderer * renderer) +{ + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + IDirect3DDevice9 *device; + + // Make sure that this is a D3D renderer + if (renderer->DestroyRenderer != D3D_DestroyRenderer) { + SDL_SetError("Renderer is not a D3D renderer"); + return NULL; + } + + device = data->device; + if (device) { + IDirect3DDevice9_AddRef( device ); + } + return device; +} + #endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/render/opengl/SDL_glfuncs.h b/src/render/opengl/SDL_glfuncs.h index 7544929fc..4915c64bc 100644 --- a/src/render/opengl/SDL_glfuncs.h +++ b/src/render/opengl/SDL_glfuncs.h @@ -89,8 +89,8 @@ SDL_PROC_UNUSED(void, glDepthFunc, (GLenum func)) SDL_PROC_UNUSED(void, glDepthMask, (GLboolean flag)) SDL_PROC_UNUSED(void, glDepthRange, (GLclampd zNear, GLclampd zFar)) SDL_PROC(void, glDisable, (GLenum cap)) -SDL_PROC_UNUSED(void, glDisableClientState, (GLenum array)) -SDL_PROC_UNUSED(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count)) +SDL_PROC(void, glDisableClientState, (GLenum array)) +SDL_PROC(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count)) SDL_PROC_UNUSED(void, glDrawBuffer, (GLenum mode)) SDL_PROC_UNUSED(void, glDrawElements, (GLenum mode, GLsizei count, GLenum type, @@ -103,7 +103,7 @@ SDL_PROC_UNUSED(void, glEdgeFlagPointer, (GLsizei stride, const GLvoid * pointer)) SDL_PROC_UNUSED(void, glEdgeFlagv, (const GLboolean * flag)) SDL_PROC(void, glEnable, (GLenum cap)) -SDL_PROC_UNUSED(void, glEnableClientState, (GLenum array)) +SDL_PROC(void, glEnableClientState, (GLenum array)) SDL_PROC(void, glEnd, (void)) SDL_PROC_UNUSED(void, glEndList, (void)) SDL_PROC_UNUSED(void, glEvalCoord1d, (GLdouble u)) @@ -448,7 +448,7 @@ SDL_PROC_UNUSED(void, glVertex4iv, (const GLint * v)) SDL_PROC_UNUSED(void, glVertex4s, (GLshort x, GLshort y, GLshort z, GLshort w)) SDL_PROC_UNUSED(void, glVertex4sv, (const GLshort * v)) -SDL_PROC_UNUSED(void, glVertexPointer, +SDL_PROC(void, glVertexPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer)) SDL_PROC(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height)) diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index 697a974c5..51fc9ad73 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -47,10 +47,16 @@ static const float inv255f = 1.0f / 255.0f; static SDL_Renderer *GL_CreateRenderer(SDL_Window * window, Uint32 flags); static void GL_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event); +static int GL_GetOutputSize(SDL_Renderer * renderer, int *w, int *h); static int GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); static int GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, const void *pixels, int pitch); +static int GL_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch); static int GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, void **pixels, int *pitch); static void GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); @@ -310,7 +316,7 @@ GL_ResetState(SDL_Renderer *renderer) data->glDisable(GL_DEPTH_TEST); data->glDisable(GL_CULL_FACE); /* This ended up causing video discrepancies between OpenGL and Direct3D */ - /*data->glEnable(GL_LINE_SMOOTH);*/ + /* data->glEnable(GL_LINE_SMOOTH); */ data->glMatrixMode(GL_MODELVIEW); data->glLoadIdentity(); @@ -399,8 +405,10 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) } renderer->WindowEvent = GL_WindowEvent; + renderer->GetOutputSize = GL_GetOutputSize; renderer->CreateTexture = GL_CreateTexture; renderer->UpdateTexture = GL_UpdateTexture; + renderer->UpdateTextureYUV = GL_UpdateTextureYUV; renderer->LockTexture = GL_LockTexture; renderer->UnlockTexture = GL_UnlockTexture; renderer->SetRenderTarget = GL_SetRenderTarget; @@ -506,6 +514,10 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_IYUV; } +#ifdef __MACOSX__ + renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_UYVY; +#endif + if (SDL_GL_ExtensionSupported("GL_EXT_framebuffer_object")) { data->GL_EXT_framebuffer_object_supported = SDL_TRUE; data->glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) @@ -539,6 +551,14 @@ GL_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) } } +static int +GL_GetOutputSize(SDL_Renderer * renderer, int *w, int *h) +{ + SDL_GL_GetDrawableSize(renderer->window, w, h); + + return 0; +} + SDL_FORCE_INLINE int power_of_2(int input) { @@ -566,6 +586,13 @@ convert_format(GL_RenderData *renderdata, Uint32 pixel_format, *format = GL_LUMINANCE; *type = GL_UNSIGNED_BYTE; break; +#ifdef __MACOSX__ + case SDL_PIXELFORMAT_UYVY: + *internalFormat = GL_RGB8; + *format = GL_YCBCR_422_APPLE; + *type = GL_UNSIGNED_SHORT_8_8_APPLE; + break; +#endif default: return SDL_FALSE; } @@ -623,8 +650,6 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) } } - texture->driverdata = data; - if (texture->access == SDL_TEXTUREACCESS_TARGET) { data->fbo = GL_GetFBO(renderdata, texture->w, texture->h); } else { @@ -637,8 +662,10 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) SDL_free(data); return -1; } + texture->driverdata = data; + if ((renderdata->GL_ARB_texture_rectangle_supported) - /*&& texture->access != SDL_TEXTUREACCESS_TARGET*/){ + /* && texture->access != SDL_TEXTUREACCESS_TARGET */){ data->type = GL_TEXTURE_RECTANGLE_ARB; texture_w = texture->w; texture_h = texture->h; @@ -788,6 +815,43 @@ GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, data->format, data->formattype, pixels); } renderdata->glDisable(data->type); + + return GL_CheckError("glTexSubImage2D()", renderer); +} + +static int +GL_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) +{ + GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata; + GL_TextureData *data = (GL_TextureData *) texture->driverdata; + + GL_ActivateRenderer(renderer); + + renderdata->glEnable(data->type); + renderdata->glBindTexture(data->type, data->texture); + renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, Ypitch); + renderdata->glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w, + rect->h, data->format, data->formattype, + Yplane); + + renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, Upitch); + renderdata->glBindTexture(data->type, data->utexture); + renderdata->glTexSubImage2D(data->type, 0, rect->x/2, rect->y/2, + rect->w/2, rect->h/2, + data->format, data->formattype, Uplane); + + renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, Vpitch); + renderdata->glBindTexture(data->type, data->vtexture); + renderdata->glTexSubImage2D(data->type, 0, rect->x/2, rect->y/2, + rect->w/2, rect->h/2, + data->format, data->formattype, Vplane); + renderdata->glDisable(data->type); + return GL_CheckError("glTexSubImage2D()", renderer); } @@ -984,15 +1048,17 @@ GL_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points, int count) { GL_RenderData *data = (GL_RenderData *) renderer->driverdata; - int i; GL_SetDrawingState(renderer); - data->glBegin(GL_POINTS); - for (i = 0; i < count; ++i) { - data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y); - } - data->glEnd(); + data->glTranslatef(0.5f, 0.5f, 0.0f); + data->glVertexPointer(2, GL_FLOAT, 0, points); + data->glEnableClientState(GL_VERTEX_ARRAY); + + data->glDrawArrays(GL_POINTS, 0, count); + + data->glDisableClientState(GL_VERTEX_ARRAY); + data->glTranslatef(-0.5f, -0.5f, 0.0f); return 0; } @@ -1002,61 +1068,28 @@ GL_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points, int count) { GL_RenderData *data = (GL_RenderData *) renderer->driverdata; - int i; GL_SetDrawingState(renderer); + data->glTranslatef(0.5f, 0.5f, 0.0f); + data->glVertexPointer(2, GL_FLOAT, 0, points); + data->glEnableClientState(GL_VERTEX_ARRAY); + if (count > 2 && points[0].x == points[count-1].x && points[0].y == points[count-1].y) { - data->glBegin(GL_LINE_LOOP); /* GL_LINE_LOOP takes care of the final segment */ - --count; - for (i = 0; i < count; ++i) { - data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y); - } - data->glEnd(); + data->glDrawArrays(GL_LINE_LOOP, 0, count-1); } else { -#if defined(__APPLE__) || defined(__WIN32__) -#else - int x1, y1, x2, y2; -#endif - - data->glBegin(GL_LINE_STRIP); - for (i = 0; i < count; ++i) { - data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y); - } - data->glEnd(); - - /* The line is half open, so we need one more point to complete it. - * http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node47.html - * If we have to, we can use vertical line and horizontal line textures - * for vertical and horizontal lines, and then create custom textures - * for diagonal lines and software render those. It's terrible, but at - * least it would be pixel perfect. - */ - data->glBegin(GL_POINTS); -#if defined(__APPLE__) || defined(__WIN32__) - /* Mac OS X and Windows seem to always leave the second point open */ - data->glVertex2f(0.5f + points[count-1].x, 0.5f + points[count-1].y); -#else - /* Linux seems to leave the right-most or bottom-most point open */ - x1 = points[0].x; - y1 = points[0].y; - x2 = points[count-1].x; - y2 = points[count-1].y; - - if (x1 > x2) { - data->glVertex2f(0.5f + x1, 0.5f + y1); - } else if (x2 > x1) { - data->glVertex2f(0.5f + x2, 0.5f + y2); - } else if (y1 > y2) { - data->glVertex2f(0.5f + x1, 0.5f + y1); - } else if (y2 > y1) { - data->glVertex2f(0.5f + x2, 0.5f + y2); - } -#endif - data->glEnd(); + data->glDrawArrays(GL_LINE_STRIP, 0, count); } + /* Make sure all the line endpoints are closed. + * http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node47.html + * Which points need to be drawn varies by driver, so just draw all of them. + */ + data->glDrawArrays(GL_POINTS, 0, count); + data->glDisableClientState(GL_VERTEX_ARRAY); + data->glTranslatef(-0.5f, -0.5f, 0.0f); + return GL_CheckError("", renderer); } @@ -1267,7 +1300,9 @@ GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, data->glReadPixels(rect->x, (h-rect->y)-rect->h, rect->w, rect->h, format, type, temp_pixels); - GL_CheckError("", renderer); + if (GL_CheckError("glReadPixels()", renderer) < 0) { + return -1; + } /* Flip the rows to be top-down */ length = rect->w * SDL_BYTESPERPIXEL(temp_format); @@ -1318,9 +1353,7 @@ GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) renderdata->glDeleteTextures(1, &data->utexture); renderdata->glDeleteTextures(1, &data->vtexture); } - if (data->pixels) { - SDL_free(data->pixels); - } + SDL_free(data->pixels); SDL_free(data); texture->driverdata = NULL; } diff --git a/src/render/opengl/SDL_shaders_gl.c b/src/render/opengl/SDL_shaders_gl.c index 1e6262191..ebf641bb2 100644 --- a/src/render/opengl/SDL_shaders_gl.c +++ b/src/render/opengl/SDL_shaders_gl.c @@ -30,7 +30,7 @@ /* OpenGL shader implementation */ -/*#define DEBUG_SHADERS*/ +/* #define DEBUG_SHADERS */ typedef struct { diff --git a/src/render/opengles/SDL_glesfuncs.h b/src/render/opengles/SDL_glesfuncs.h index 4a6384da6..ff5ce76be 100644 --- a/src/render/opengles/SDL_glesfuncs.h +++ b/src/render/opengles/SDL_glesfuncs.h @@ -1,6 +1,6 @@ SDL_PROC(void, glBindTexture, (GLenum, GLuint)) SDL_PROC(void, glBlendFunc, (GLenum, GLenum)) -SDL_PROC(void, glBlendFuncSeparateOES, (GLenum, GLenum, GLenum, GLenum)) +SDL_PROC_OES(void, glBlendFuncSeparateOES, (GLenum, GLenum, GLenum, GLenum)) SDL_PROC(void, glClear, (GLbitfield)) SDL_PROC(void, glClearColor, (GLclampf, GLclampf, GLclampf, GLclampf)) SDL_PROC(void, glColor4f, (GLfloat, GLfloat, GLfloat, GLfloat)) @@ -8,11 +8,11 @@ SDL_PROC(void, glDeleteTextures, (GLsizei, const GLuint *)) SDL_PROC(void, glDisable, (GLenum)) SDL_PROC(void, glDisableClientState, (GLenum array)) SDL_PROC(void, glDrawArrays, (GLenum, GLint, GLsizei)) -SDL_PROC(void, glDrawTexfOES, (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat)) +SDL_PROC_OES(void, glDrawTexfOES, (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat)) SDL_PROC(void, glEnable, (GLenum)) SDL_PROC(void, glEnableClientState, (GLenum)) SDL_PROC(void, glFinish, (void)) -SDL_PROC(void, glGenFramebuffersOES, (GLsizei, GLuint *)) +SDL_PROC_OES(void, glGenFramebuffersOES, (GLsizei, GLuint *)) SDL_PROC(void, glGenTextures, (GLsizei, GLuint *)) SDL_PROC(GLenum, glGetError, (void)) SDL_PROC(void, glGetIntegerv, (GLenum, GLint *)) @@ -30,13 +30,13 @@ SDL_PROC(void, glTexParameteriv, (GLenum, GLenum, const GLint *)) SDL_PROC(void, glTexSubImage2D, (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *)) SDL_PROC(void, glVertexPointer, (GLint, GLenum, GLsizei, const GLvoid *)) SDL_PROC(void, glViewport, (GLint, GLint, GLsizei, GLsizei)) -SDL_PROC(void, glBindFramebufferOES, (GLenum, GLuint)) -SDL_PROC(void, glFramebufferTexture2DOES, (GLenum, GLenum, GLenum, GLuint, GLint)) -SDL_PROC(GLenum, glCheckFramebufferStatusOES, (GLenum)) +SDL_PROC_OES(void, glBindFramebufferOES, (GLenum, GLuint)) +SDL_PROC_OES(void, glFramebufferTexture2DOES, (GLenum, GLenum, GLenum, GLuint, GLint)) +SDL_PROC_OES(GLenum, glCheckFramebufferStatusOES, (GLenum)) SDL_PROC(void, glPushMatrix, (void)) SDL_PROC(void, glTranslatef, (GLfloat, GLfloat, GLfloat)) SDL_PROC(void, glRotatef, (GLfloat, GLfloat, GLfloat, GLfloat)) SDL_PROC(void, glPopMatrix, (void)) -SDL_PROC(void, glDeleteFramebuffersOES, (GLsizei, const GLuint*)) +SDL_PROC_OES(void, glDeleteFramebuffersOES, (GLsizei, const GLuint*)) /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c index ab0f01d4e..3be1998d8 100644 --- a/src/render/opengles/SDL_render_gles.c +++ b/src/render/opengles/SDL_render_gles.c @@ -96,7 +96,7 @@ SDL_RenderDriver GLES_RenderDriver = { GLES_CreateRenderer, { "opengles", - (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE), + (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC ), 1, {SDL_PIXELFORMAT_ABGR8888}, 0, @@ -113,8 +113,10 @@ typedef struct } current; #define SDL_PROC(ret,func,params) ret (APIENTRY *func) params; +#define SDL_PROC_OES SDL_PROC #include "SDL_glesfuncs.h" #undef SDL_PROC +#undef SDL_PROC_OES SDL_bool GL_OES_framebuffer_object_supported; GLES_FBOList *framebuffers; GLuint window_framebuffer; @@ -183,6 +185,7 @@ static int GLES_LoadFunctions(GLES_RenderData * data) #ifdef __SDL_NOGETPROCADDR__ #define SDL_PROC(ret,func,params) data->func=func; +#define SDL_PROC_OES(ret,func,params) data->func=func; #else #define SDL_PROC(ret,func,params) \ do { \ @@ -191,10 +194,15 @@ static int GLES_LoadFunctions(GLES_RenderData * data) return SDL_SetError("Couldn't load GLES function %s: %s\n", #func, SDL_GetError()); \ } \ } while ( 0 ); +#define SDL_PROC_OES(ret,func,params) \ + do { \ + data->func = SDL_GL_GetProcAddress(#func); \ + } while ( 0 ); #endif /* _SDL_NOGETPROCADDR_ */ #include "SDL_glesfuncs.h" #undef SDL_PROC +#undef SDL_PROC_OES return 0; } @@ -272,7 +280,7 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags) GLint value; Uint32 windowFlags; - SDL_GL_SetAttribute(SDL_GL_CONTEXT_EGL, 1); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); @@ -367,7 +375,8 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags) data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); renderer->info.max_texture_height = value; - if (SDL_GL_ExtensionSupported("GL_OES_framebuffer_object")) { + /* Android does not report GL_OES_framebuffer_object but the functionality seems to be there anyway */ + if (SDL_GL_ExtensionSupported("GL_OES_framebuffer_object") || data->glGenFramebuffersOES) { data->GL_OES_framebuffer_object_supported = SDL_TRUE; renderer->info.flags |= SDL_RENDERER_TARGETTEXTURE; @@ -405,7 +414,7 @@ GLES_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) } } -static __inline__ int +static SDL_INLINE int power_of_2(int input) { int value = 1; @@ -465,12 +474,17 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) } } - texture->driverdata = data; + if (texture->access == SDL_TEXTUREACCESS_TARGET) { - data->fbo = GLES_GetFBO(renderer->driverdata, texture->w, texture->h); + if (!renderdata->GL_OES_framebuffer_object_supported) { + SDL_free(data); + return SDL_SetError("GL_OES_framebuffer_object not supported"); + } + data->fbo = GLES_GetFBO(renderer->driverdata, texture->w, texture->h); } else { - data->fbo = NULL; + data->fbo = NULL; } + renderdata->glGetError(); renderdata->glEnable(GL_TEXTURE_2D); @@ -503,8 +517,11 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) result = renderdata->glGetError(); if (result != GL_NO_ERROR) { + SDL_free(data); return GLES_SetError("glTexImage2D()", result); } + + texture->driverdata = data; return 0; } @@ -556,9 +573,7 @@ GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, data->format, data->formattype, src); - if (blob) { - SDL_free(blob); - } + SDL_free(blob); if (renderdata->glGetError() != GL_NO_ERROR) { @@ -602,6 +617,10 @@ GLES_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) GLenum status; GLES_ActivateRenderer(renderer); + + if (!data->GL_OES_framebuffer_object_supported) { + return SDL_SetError("Can't enable render target support in this renderer"); + } if (texture == NULL) { data->glBindFramebufferOES(GL_FRAMEBUFFER_OES, data->window_framebuffer); @@ -843,6 +862,8 @@ GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata; GLfloat minx, miny, maxx, maxy; GLfloat minu, maxu, minv, maxv; + GLfloat vertices[8]; + GLfloat texCoords[8]; GLES_ActivateRenderer(renderer); @@ -903,9 +924,6 @@ GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h; maxv *= texturedata->texh; - GLfloat vertices[8]; - GLfloat texCoords[8]; - vertices[0] = minx; vertices[1] = miny; vertices[2] = maxx; @@ -944,6 +962,9 @@ GLES_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, GLfloat minx, miny, maxx, maxy; GLfloat minu, maxu, minv, maxv; GLfloat centerx, centery; + GLfloat vertices[8]; + GLfloat texCoords[8]; + GLES_ActivateRenderer(renderer); @@ -994,9 +1015,6 @@ GLES_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h; maxv *= texturedata->texh; - GLfloat vertices[8]; - GLfloat texCoords[8]; - vertices[0] = minx; vertices[1] = miny; vertices[2] = maxx; @@ -1096,9 +1114,7 @@ GLES_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) if (data->texture) { renderdata->glDeleteTextures(1, &data->texture); } - if (data->pixels) { - SDL_free(data->pixels); - } + SDL_free(data->pixels); SDL_free(data); texture->driverdata = NULL; } diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index a0ab94365..31a1598c0 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -25,6 +25,7 @@ #include "SDL_hints.h" #include "SDL_opengles2.h" #include "../SDL_sysrender.h" +#include "../../video/SDL_blit.h" #include "SDL_shaders_gles2.h" /* Used to re-create the window with OpenGL ES capability */ @@ -81,6 +82,7 @@ typedef struct GLES2_ShaderCacheEntry GLES2_ShaderType type; const GLES2_ShaderInstance *instance; int references; + Uint8 modulation_r, modulation_g, modulation_b, modulation_a; struct GLES2_ShaderCacheEntry *prev; struct GLES2_ShaderCacheEntry *next; } GLES2_ShaderCacheEntry; @@ -98,6 +100,9 @@ typedef struct GLES2_ProgramCacheEntry GLES2_ShaderCacheEntry *vertex_shader; GLES2_ShaderCacheEntry *fragment_shader; GLuint uniform_locations[16]; + Uint8 color_r, color_g, color_b, color_a; + Uint8 modulation_r, modulation_g, modulation_b, modulation_a; + GLfloat projection[4][4]; struct GLES2_ProgramCacheEntry *prev; struct GLES2_ProgramCacheEntry *next; } GLES2_ProgramCacheEntry; @@ -122,8 +127,7 @@ typedef enum GLES2_UNIFORM_PROJECTION, GLES2_UNIFORM_TEXTURE, GLES2_UNIFORM_MODULATION, - GLES2_UNIFORM_COLOR, - GLES2_UNIFORM_COLORTABLE + GLES2_UNIFORM_COLOR } GLES2_Uniform; typedef enum @@ -138,6 +142,9 @@ typedef enum typedef struct GLES2_DriverContext { SDL_GLContext *context; + + SDL_bool debug_enabled; + struct { int blendMode; SDL_bool tex_coords; @@ -154,10 +161,77 @@ typedef struct GLES2_DriverContext GLES2_ShaderCache shader_cache; GLES2_ProgramCache program_cache; GLES2_ProgramCacheEntry *current_program; + Uint8 clear_r, clear_g, clear_b, clear_a; } GLES2_DriverContext; #define GLES2_MAX_CACHED_PROGRAMS 8 + +SDL_FORCE_INLINE const char* +GL_TranslateError (GLenum error) +{ +#define GL_ERROR_TRANSLATE(e) case e: return #e; + switch (error) { + GL_ERROR_TRANSLATE(GL_INVALID_ENUM) + GL_ERROR_TRANSLATE(GL_INVALID_VALUE) + GL_ERROR_TRANSLATE(GL_INVALID_OPERATION) + GL_ERROR_TRANSLATE(GL_OUT_OF_MEMORY) + GL_ERROR_TRANSLATE(GL_NO_ERROR) + default: + return "UNKNOWN"; +} +#undef GL_ERROR_TRANSLATE +} + +SDL_FORCE_INLINE void +GL_ClearErrors(SDL_Renderer *renderer) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *) renderer->driverdata; + + if (!data->debug_enabled) + { + return; + } + while (data->glGetError() != GL_NO_ERROR) { + continue; + } +} + +SDL_FORCE_INLINE int +GL_CheckAllErrors (const char *prefix, SDL_Renderer *renderer, const char *file, int line, const char *function) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *) renderer->driverdata; + int ret = 0; + + if (!data->debug_enabled) + { + return 0; + } + /* check gl errors (can return multiple errors) */ + for (;;) { + GLenum error = data->glGetError(); + if (error != GL_NO_ERROR) { + if (prefix == NULL || prefix[0] == '\0') { + prefix = "generic"; + } + SDL_SetError("%s: %s (%d): %s %s (0x%X)", prefix, file, line, function, GL_TranslateError(error), error); + ret = -1; + } else { + break; + } + } + return ret; +} + +#if 0 +#define GL_CheckError(prefix, renderer) +#elif defined(_MSC_VER) +#define GL_CheckError(prefix, renderer) GL_CheckAllErrors(prefix, renderer, __FILE__, __LINE__, __FUNCTION__) +#else +#define GL_CheckError(prefix, renderer) GL_CheckAllErrors(prefix, renderer, __FILE__, __LINE__, __PRETTY_FUNCTION__) +#endif + + /************************************************************************************************* * Renderer state APIs * *************************************************************************************************/ @@ -222,26 +296,29 @@ GLES2_GetFBO(GLES2_DriverContext *data, Uint32 w, Uint32 h) static int GLES2_ActivateRenderer(SDL_Renderer * renderer) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; - if (SDL_CurrentContext != rdata->context) { + if (SDL_CurrentContext != data->context) { /* Null out the current program to ensure we set it again */ - rdata->current_program = NULL; + data->current_program = NULL; - if (SDL_GL_MakeCurrent(renderer->window, rdata->context) < 0) { + if (SDL_GL_MakeCurrent(renderer->window, data->context) < 0) { return -1; } - SDL_CurrentContext = rdata->context; + SDL_CurrentContext = data->context; GLES2_UpdateViewport(renderer); } + + GL_ClearErrors(renderer); + return 0; } static void GLES2_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED || event->event == SDL_WINDOWEVENT_SHOWN || @@ -252,45 +329,45 @@ GLES2_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) if (event->event == SDL_WINDOWEVENT_MINIMIZED) { /* According to Apple documentation, we need to finish drawing NOW! */ - rdata->glFinish(); + data->glFinish(); } } static int GLES2_UpdateViewport(SDL_Renderer * renderer) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; - if (SDL_CurrentContext != rdata->context) { + if (SDL_CurrentContext != data->context) { /* We'll update the viewport after we rebind the context */ return 0; } - rdata->glViewport(renderer->viewport.x, renderer->viewport.y, + data->glViewport(renderer->viewport.x, renderer->viewport.y, renderer->viewport.w, renderer->viewport.h); - if (rdata->current_program) { + if (data->current_program) { GLES2_SetOrthographicProjection(renderer); } - return 0; + return GL_CheckError("", renderer); } static int GLES2_UpdateClipRect(SDL_Renderer * renderer) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; const SDL_Rect *rect = &renderer->clip_rect; - if (SDL_CurrentContext != rdata->context) { + if (SDL_CurrentContext != data->context) { /* We'll update the clip rect after we rebind the context */ return 0; } if (!SDL_RectEmpty(rect)) { - rdata->glEnable(GL_SCISSOR_TEST); - rdata->glScissor(rect->x, renderer->viewport.h - rect->y - rect->h, rect->w, rect->h); + data->glEnable(GL_SCISSOR_TEST); + data->glScissor(rect->x, renderer->viewport.h - rect->y - rect->h, rect->w, rect->h); } else { - rdata->glDisable(GL_SCISSOR_TEST); + data->glDisable(GL_SCISSOR_TEST); } return 0; } @@ -298,19 +375,19 @@ GLES2_UpdateClipRect(SDL_Renderer * renderer) static void GLES2_DestroyRenderer(SDL_Renderer *renderer) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; /* Deallocate everything */ - if (rdata) { + if (data) { GLES2_ActivateRenderer(renderer); { GLES2_ShaderCacheEntry *entry; GLES2_ShaderCacheEntry *next; - entry = rdata->shader_cache.head; + entry = data->shader_cache.head; while (entry) { - rdata->glDeleteShader(entry->id); + data->glDeleteShader(entry->id); next = entry->next; SDL_free(entry); entry = next; @@ -319,27 +396,26 @@ GLES2_DestroyRenderer(SDL_Renderer *renderer) { GLES2_ProgramCacheEntry *entry; GLES2_ProgramCacheEntry *next; - entry = rdata->program_cache.head; + entry = data->program_cache.head; while (entry) { - rdata->glDeleteProgram(entry->id); + data->glDeleteProgram(entry->id); next = entry->next; SDL_free(entry); entry = next; } } - if (rdata->context) { - while (rdata->framebuffers) { - GLES2_FBOList *nextnode = rdata->framebuffers->next; - rdata->glDeleteFramebuffers(1, &rdata->framebuffers->FBO); - SDL_free(rdata->framebuffers); - rdata->framebuffers = nextnode; + if (data->context) { + while (data->framebuffers) { + GLES2_FBOList *nextnode = data->framebuffers->next; + data->glDeleteFramebuffers(1, &data->framebuffers->FBO); + GL_CheckError("", renderer); + SDL_free(data->framebuffers); + data->framebuffers = nextnode; } - SDL_GL_DeleteContext(rdata->context); + SDL_GL_DeleteContext(data->context); } - if (rdata->shader_formats) { - SDL_free(rdata->shader_formats); - } - SDL_free(rdata); + SDL_free(data->shader_formats); + SDL_free(data); } SDL_free(renderer); } @@ -349,13 +425,13 @@ GLES2_DestroyRenderer(SDL_Renderer *renderer) *************************************************************************************************/ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture); -static void GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture); +static int GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, + const void *pixels, int pitch); static int GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch); static void GLES2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture); -static int GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, - const void *pixels, int pitch); static int GLES2_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture); +static void GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture); static GLenum GetScaleQuality(void) @@ -372,8 +448,8 @@ GetScaleQuality(void) static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; - GLES2_TextureData *tdata; + GLES2_DriverContext *renderdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_TextureData *data; GLenum format; GLenum type; GLenum scaleMode; @@ -395,72 +471,101 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) } /* Allocate a texture struct */ - tdata = (GLES2_TextureData *)SDL_calloc(1, sizeof(GLES2_TextureData)); - if (!tdata) { + data = (GLES2_TextureData *)SDL_calloc(1, sizeof(GLES2_TextureData)); + if (!data) { return SDL_OutOfMemory(); } - tdata->texture = 0; - tdata->texture_type = GL_TEXTURE_2D; - tdata->pixel_format = format; - tdata->pixel_type = type; + data->texture = 0; + data->texture_type = GL_TEXTURE_2D; + data->pixel_format = format; + data->pixel_type = type; scaleMode = GetScaleQuality(); - /* Allocate a blob for image data */ + /* Allocate a blob for image renderdata */ if (texture->access == SDL_TEXTUREACCESS_STREAMING) { - tdata->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format); - tdata->pixel_data = SDL_calloc(1, tdata->pitch * texture->h); - if (!tdata->pixel_data) { - SDL_free(tdata); + data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format); + data->pixel_data = SDL_calloc(1, data->pitch * texture->h); + if (!data->pixel_data) { + SDL_free(data); return SDL_OutOfMemory(); } } /* Allocate the texture */ - rdata->glGetError(); - rdata->glGenTextures(1, &tdata->texture); - if (rdata->glGetError() != GL_NO_ERROR) { - SDL_free(tdata); - return SDL_SetError("Texture creation failed in glGenTextures()"); + GL_CheckError("", renderer); + renderdata->glGenTextures(1, &data->texture); + if (GL_CheckError("glGenTexures()", renderer) < 0) { + return -1; } - rdata->glActiveTexture(GL_TEXTURE0); - rdata->glBindTexture(tdata->texture_type, tdata->texture); - rdata->glTexParameteri(tdata->texture_type, GL_TEXTURE_MIN_FILTER, scaleMode); - rdata->glTexParameteri(tdata->texture_type, GL_TEXTURE_MAG_FILTER, scaleMode); - rdata->glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - rdata->glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - rdata->glTexImage2D(tdata->texture_type, 0, format, texture->w, texture->h, 0, format, type, NULL); - if (rdata->glGetError() != GL_NO_ERROR) { - rdata->glDeleteTextures(1, &tdata->texture); - SDL_free(tdata); - return SDL_SetError("Texture creation failed"); + texture->driverdata = data; + renderdata->glBindTexture(data->texture_type, data->texture); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MIN_FILTER, scaleMode); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, scaleMode); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + renderdata->glTexImage2D(data->texture_type, 0, format, texture->w, texture->h, 0, format, type, NULL); + if (GL_CheckError("glTexImage2D()", renderer) < 0) { + return -1; } - texture->driverdata = tdata; if (texture->access == SDL_TEXTUREACCESS_TARGET) { - tdata->fbo = GLES2_GetFBO(renderer->driverdata, texture->w, texture->h); + data->fbo = GLES2_GetFBO(renderer->driverdata, texture->w, texture->h); } else { - tdata->fbo = NULL; + data->fbo = NULL; } - return 0; + return GL_CheckError("", renderer); } -static void -GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) +static int +GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, + const void *pixels, int pitch) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; + Uint8 *blob = NULL; + Uint8 *src; + int srcPitch; + int y; GLES2_ActivateRenderer(renderer); - /* Destroy the texture */ - if (tdata) - { - rdata->glDeleteTextures(1, &tdata->texture); - SDL_free(tdata->pixel_data); - SDL_free(tdata); - texture->driverdata = NULL; + /* Bail out if we're supposed to update an empty rectangle */ + if (rect->w <= 0 || rect->h <= 0) + return 0; + + /* Reformat the texture data into a tightly packed array */ + srcPitch = rect->w * SDL_BYTESPERPIXEL(texture->format); + src = (Uint8 *)pixels; + if (pitch != srcPitch) { + blob = (Uint8 *)SDL_malloc(srcPitch * rect->h); + if (!blob) { + return SDL_OutOfMemory(); + } + src = blob; + for (y = 0; y < rect->h; ++y) + { + SDL_memcpy(src, pixels, srcPitch); + src += srcPitch; + pixels = (Uint8 *)pixels + pitch; + } + src = blob; } + + /* Create a texture subimage with the supplied data */ + data->glBindTexture(tdata->texture_type, tdata->texture); + data->glTexSubImage2D(tdata->texture_type, + 0, + rect->x, + rect->y, + rect->w, + rect->h, + tdata->pixel_format, + tdata->pixel_type, + src); + SDL_free(blob); + + return GL_CheckError("glTexSubImage2D()", renderer); } static int @@ -492,65 +597,6 @@ GLES2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) GLES2_UpdateTexture(renderer, texture, &rect, tdata->pixel_data, tdata->pitch); } -static int -GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, - const void *pixels, int pitch) -{ - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; - GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; - Uint8 *blob = NULL; - Uint8 *src; - int srcPitch; - int y; - - GLES2_ActivateRenderer(renderer); - - /* Bail out if we're supposed to update an empty rectangle */ - if (rect->w <= 0 || rect->h <= 0) - return 0; - - /* Reformat the texture data into a tightly packed array */ - srcPitch = rect->w * SDL_BYTESPERPIXEL(texture->format); - src = (Uint8 *)pixels; - if (pitch != srcPitch) { - blob = (Uint8 *)SDL_malloc(srcPitch * rect->h); - if (!blob) { - return SDL_OutOfMemory(); - } - src = blob; - for (y = 0; y < rect->h; ++y) - { - SDL_memcpy(src, pixels, srcPitch); - src += srcPitch; - pixels = (Uint8 *)pixels + pitch; - } - src = blob; - } - - /* Create a texture subimage with the supplied data */ - rdata->glGetError(); - rdata->glActiveTexture(GL_TEXTURE0); - rdata->glBindTexture(tdata->texture_type, tdata->texture); - rdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - rdata->glTexSubImage2D(tdata->texture_type, - 0, - rect->x, - rect->y, - rect->w, - rect->h, - tdata->pixel_format, - tdata->pixel_type, - src); - if (blob) { - SDL_free(blob); - } - - if (rdata->glGetError() != GL_NO_ERROR) { - return SDL_SetError("Failed to update texture"); - } - return 0; -} - static int GLES2_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) { @@ -574,6 +620,24 @@ GLES2_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) return 0; } +static void +GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; + + GLES2_ActivateRenderer(renderer); + + /* Destroy the texture */ + if (tdata) + { + data->glDeleteTextures(1, &tdata->texture); + SDL_free(tdata->pixel_data); + SDL_free(tdata); + texture->driverdata = NULL; + } +} + /************************************************************************************************* * Shader management functions * *************************************************************************************************/ @@ -592,13 +656,13 @@ static GLES2_ProgramCacheEntry * GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex, GLES2_ShaderCacheEntry *fragment, SDL_BlendMode blendMode) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLES2_ProgramCacheEntry *entry; GLES2_ShaderCacheEntry *shaderEntry; GLint linkSuccessful; /* Check if we've already cached this program */ - entry = rdata->program_cache.head; + entry = data->program_cache.head; while (entry) { if (entry->vertex_shader == vertex && entry->fragment_shader == fragment) @@ -607,16 +671,16 @@ GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex, } if (entry) { - if (rdata->program_cache.head != entry) + if (data->program_cache.head != entry) { if (entry->next) entry->next->prev = entry->prev; if (entry->prev) entry->prev->next = entry->next; entry->prev = NULL; - entry->next = rdata->program_cache.head; - rdata->program_cache.head->prev = entry; - rdata->program_cache.head = entry; + entry->next = data->program_cache.head; + data->program_cache.head->prev = entry; + data->program_cache.head = entry; } return entry; } @@ -633,19 +697,18 @@ GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex, entry->blend_mode = blendMode; /* Create the program and link it */ - rdata->glGetError(); - entry->id = rdata->glCreateProgram(); - rdata->glAttachShader(entry->id, vertex->id); - rdata->glAttachShader(entry->id, fragment->id); - rdata->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_POSITION, "a_position"); - rdata->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_TEXCOORD, "a_texCoord"); - rdata->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_ANGLE, "a_angle"); - rdata->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_CENTER, "a_center"); - rdata->glLinkProgram(entry->id); - rdata->glGetProgramiv(entry->id, GL_LINK_STATUS, &linkSuccessful); - if (rdata->glGetError() != GL_NO_ERROR || !linkSuccessful) + entry->id = data->glCreateProgram(); + data->glAttachShader(entry->id, vertex->id); + data->glAttachShader(entry->id, fragment->id); + data->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_POSITION, "a_position"); + data->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_TEXCOORD, "a_texCoord"); + data->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_ANGLE, "a_angle"); + data->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_CENTER, "a_center"); + data->glLinkProgram(entry->id); + data->glGetProgramiv(entry->id, GL_LINK_STATUS, &linkSuccessful); + if (!linkSuccessful) { - rdata->glDeleteProgram(entry->id); + data->glDeleteProgram(entry->id); SDL_free(entry); SDL_SetError("Failed to link shader program"); return NULL; @@ -653,47 +716,54 @@ GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex, /* Predetermine locations of uniform variables */ entry->uniform_locations[GLES2_UNIFORM_PROJECTION] = - rdata->glGetUniformLocation(entry->id, "u_projection"); + data->glGetUniformLocation(entry->id, "u_projection"); entry->uniform_locations[GLES2_UNIFORM_TEXTURE] = - rdata->glGetUniformLocation(entry->id, "u_texture"); + data->glGetUniformLocation(entry->id, "u_texture"); entry->uniform_locations[GLES2_UNIFORM_MODULATION] = - rdata->glGetUniformLocation(entry->id, "u_modulation"); + data->glGetUniformLocation(entry->id, "u_modulation"); entry->uniform_locations[GLES2_UNIFORM_COLOR] = - rdata->glGetUniformLocation(entry->id, "u_color"); - entry->uniform_locations[GLES2_UNIFORM_COLORTABLE] = - rdata->glGetUniformLocation(entry->id, "u_colorTable"); + data->glGetUniformLocation(entry->id, "u_color"); + + entry->modulation_r = entry->modulation_g = entry->modulation_b = entry->modulation_a = 1.0f; + entry->color_r = entry->color_g = entry->color_b = entry->color_a = 1.0f; + + data->glUseProgram(entry->id); + data->glUniformMatrix4fv(entry->uniform_locations[GLES2_UNIFORM_PROJECTION], 1, GL_FALSE, (GLfloat *)entry->projection); + data->glUniform1i(entry->uniform_locations[GLES2_UNIFORM_TEXTURE], 0); /* always texture unit 0. */ + data->glUniform4f(entry->uniform_locations[GLES2_UNIFORM_MODULATION], 1.0f, 1.0f, 1.0f, 1.0f); + data->glUniform4f(entry->uniform_locations[GLES2_UNIFORM_COLOR], 1.0f, 1.0f, 1.0f, 1.0f); /* Cache the linked program */ - if (rdata->program_cache.head) + if (data->program_cache.head) { - entry->next = rdata->program_cache.head; - rdata->program_cache.head->prev = entry; + entry->next = data->program_cache.head; + data->program_cache.head->prev = entry; } else { - rdata->program_cache.tail = entry; + data->program_cache.tail = entry; } - rdata->program_cache.head = entry; - ++rdata->program_cache.count; + data->program_cache.head = entry; + ++data->program_cache.count; /* Increment the refcount of the shaders we're using */ ++vertex->references; ++fragment->references; /* Evict the last entry from the cache if we exceed the limit */ - if (rdata->program_cache.count > GLES2_MAX_CACHED_PROGRAMS) + if (data->program_cache.count > GLES2_MAX_CACHED_PROGRAMS) { - shaderEntry = rdata->program_cache.tail->vertex_shader; + shaderEntry = data->program_cache.tail->vertex_shader; if (--shaderEntry->references <= 0) GLES2_EvictShader(renderer, shaderEntry); - shaderEntry = rdata->program_cache.tail->fragment_shader; + shaderEntry = data->program_cache.tail->fragment_shader; if (--shaderEntry->references <= 0) GLES2_EvictShader(renderer, shaderEntry); - rdata->glDeleteProgram(rdata->program_cache.tail->id); - rdata->program_cache.tail = rdata->program_cache.tail->prev; - SDL_free(rdata->program_cache.tail->next); - rdata->program_cache.tail->next = NULL; - --rdata->program_cache.count; + data->glDeleteProgram(data->program_cache.tail->id); + data->program_cache.tail = data->program_cache.tail->prev; + SDL_free(data->program_cache.tail->next); + data->program_cache.tail->next = NULL; + --data->program_cache.count; } return entry; } @@ -701,7 +771,7 @@ GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex, static GLES2_ShaderCacheEntry * GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type, SDL_BlendMode blendMode) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; const GLES2_Shader *shader; const GLES2_ShaderInstance *instance = NULL; GLES2_ShaderCacheEntry *entry = NULL; @@ -719,13 +789,13 @@ GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type, SDL_BlendMode b /* Find a matching shader instance that's supported on this hardware */ for (i = 0; i < shader->instance_count && !instance; ++i) { - for (j = 0; j < rdata->shader_format_count && !instance; ++j) + for (j = 0; j < data->shader_format_count && !instance; ++j) { if (!shader->instances) continue; if (!shader->instances[i]) continue; - if (shader->instances[i]->format != rdata->shader_formats[j]) + if (shader->instances[i]->format != data->shader_formats[j]) continue; instance = shader->instances[i]; } @@ -737,7 +807,7 @@ GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type, SDL_BlendMode b } /* Check if we've already cached this shader */ - entry = rdata->shader_cache.head; + entry = data->shader_cache.head; while (entry) { if (entry->instance == instance) @@ -758,29 +828,28 @@ GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type, SDL_BlendMode b entry->instance = instance; /* Compile or load the selected shader instance */ - rdata->glGetError(); - entry->id = rdata->glCreateShader(instance->type); + entry->id = data->glCreateShader(instance->type); if (instance->format == (GLenum)-1) { - rdata->glShaderSource(entry->id, 1, (const char **)&instance->data, NULL); - rdata->glCompileShader(entry->id); - rdata->glGetShaderiv(entry->id, GL_COMPILE_STATUS, &compileSuccessful); + data->glShaderSource(entry->id, 1, (const char **)&instance->data, NULL); + data->glCompileShader(entry->id); + data->glGetShaderiv(entry->id, GL_COMPILE_STATUS, &compileSuccessful); } else { - rdata->glShaderBinary(1, &entry->id, instance->format, instance->data, instance->length); + data->glShaderBinary(1, &entry->id, instance->format, instance->data, instance->length); compileSuccessful = GL_TRUE; } - if (rdata->glGetError() != GL_NO_ERROR || !compileSuccessful) + if (!compileSuccessful) { char *info = NULL; int length = 0; - rdata->glGetShaderiv(entry->id, GL_INFO_LOG_LENGTH, &length); + data->glGetShaderiv(entry->id, GL_INFO_LOG_LENGTH, &length); if (length > 0) { info = SDL_stack_alloc(char, length); if (info) { - rdata->glGetShaderInfoLog(entry->id, length, &length, info); + data->glGetShaderInfoLog(entry->id, length, &length, info); } } if (info) { @@ -789,45 +858,45 @@ GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type, SDL_BlendMode b } else { SDL_SetError("Failed to load the shader"); } - rdata->glDeleteShader(entry->id); + data->glDeleteShader(entry->id); SDL_free(entry); return NULL; } /* Link the shader entry in at the front of the cache */ - if (rdata->shader_cache.head) + if (data->shader_cache.head) { - entry->next = rdata->shader_cache.head; - rdata->shader_cache.head->prev = entry; + entry->next = data->shader_cache.head; + data->shader_cache.head->prev = entry; } - rdata->shader_cache.head = entry; - ++rdata->shader_cache.count; + data->shader_cache.head = entry; + ++data->shader_cache.count; return entry; } static void GLES2_EvictShader(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *entry) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; /* Unlink the shader from the cache */ if (entry->next) entry->next->prev = entry->prev; if (entry->prev) entry->prev->next = entry->next; - if (rdata->shader_cache.head == entry) - rdata->shader_cache.head = entry->next; - --rdata->shader_cache.count; + if (data->shader_cache.head == entry) + data->shader_cache.head = entry->next; + --data->shader_cache.count; /* Deallocate the shader */ - rdata->glDeleteShader(entry->id); + data->glDeleteShader(entry->id); SDL_free(entry); } static int GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source, SDL_BlendMode blendMode) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLES2_ShaderCacheEntry *vertex = NULL; GLES2_ShaderCacheEntry *fragment = NULL; GLES2_ShaderType vtype, ftype; @@ -865,9 +934,9 @@ GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source, SDL_BlendM goto fault; /* Check if we need to change programs at all */ - if (rdata->current_program && - rdata->current_program->vertex_shader == vertex && - rdata->current_program->fragment_shader == fragment) + if (data->current_program && + data->current_program->vertex_shader == vertex && + data->current_program->fragment_shader == fragment) return 0; /* Generate a matching program */ @@ -876,16 +945,10 @@ GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source, SDL_BlendM goto fault; /* Select that program in OpenGL */ - rdata->glGetError(); - rdata->glUseProgram(program->id); - if (rdata->glGetError() != GL_NO_ERROR) - { - SDL_SetError("Failed to select program"); - goto fault; - } + data->glUseProgram(program->id); /* Set the current program */ - rdata->current_program = program; + data->current_program = program; /* Activate an orthographic projection */ if (GLES2_SetOrthographicProjection(renderer) < 0) @@ -898,16 +961,15 @@ fault: GLES2_EvictShader(renderer, vertex); if (fragment && fragment->references <= 0) GLES2_EvictShader(renderer, fragment); - rdata->current_program = NULL; + data->current_program = NULL; return -1; } static int GLES2_SetOrthographicProjection(SDL_Renderer *renderer) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLfloat projection[4][4]; - GLuint locProjection; if (!renderer->viewport.w || !renderer->viewport.h) { return 0; @@ -940,12 +1002,12 @@ GLES2_SetOrthographicProjection(SDL_Renderer *renderer) projection[3][3] = 1.0f; /* Set the projection matrix */ - locProjection = rdata->current_program->uniform_locations[GLES2_UNIFORM_PROJECTION]; - rdata->glGetError(); - rdata->glUniformMatrix4fv(locProjection, 1, GL_FALSE, (GLfloat *)projection); - if (rdata->glGetError() != GL_NO_ERROR) { - return SDL_SetError("Failed to set orthographic projection"); + if (SDL_memcmp(data->current_program->projection, projection, sizeof (projection)) != 0) { + const GLuint locProjection = data->current_program->uniform_locations[GLES2_UNIFORM_PROJECTION]; + data->glUniformMatrix4fv(locProjection, 1, GL_FALSE, (GLfloat *)projection); + SDL_memcpy(data->current_program->projection, projection, sizeof (projection)); } + return 0; } @@ -968,106 +1030,129 @@ static int GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect Uint32 pixel_format, void * pixels, int pitch); static void GLES2_RenderPresent(SDL_Renderer *renderer); +static SDL_bool +CompareColors(Uint8 r1, Uint8 g1, Uint8 b1, Uint8 a1, + Uint8 r2, Uint8 g2, Uint8 b2, Uint8 a2) +{ + Uint32 Pixel1, Pixel2; + RGBA8888_FROM_RGBA(Pixel1, r1, g1, b1, a1); + RGBA8888_FROM_RGBA(Pixel2, r2, g2, b2, a2); + return (Pixel1 == Pixel2); +} static int GLES2_RenderClear(SDL_Renderer * renderer) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLES2_ActivateRenderer(renderer); - rdata->glClearColor((GLfloat) renderer->r * inv255f, - (GLfloat) renderer->g * inv255f, - (GLfloat) renderer->b * inv255f, - (GLfloat) renderer->a * inv255f); + if (!CompareColors(data->clear_r, data->clear_g, data->clear_b, data->clear_a, + renderer->r, renderer->g, renderer->b, renderer->a)) { + data->glClearColor((GLfloat) renderer->r * inv255f, + (GLfloat) renderer->g * inv255f, + (GLfloat) renderer->b * inv255f, + (GLfloat) renderer->a * inv255f); + data->clear_r = renderer->r; + data->clear_g = renderer->g; + data->clear_b = renderer->b; + data->clear_a = renderer->a; + } - rdata->glClear(GL_COLOR_BUFFER_BIT); + data->glClear(GL_COLOR_BUFFER_BIT); return 0; } static void -GLES2_SetBlendMode(GLES2_DriverContext *rdata, int blendMode) +GLES2_SetBlendMode(GLES2_DriverContext *data, int blendMode) { - if (blendMode != rdata->current.blendMode) { + if (blendMode != data->current.blendMode) { switch (blendMode) { default: case SDL_BLENDMODE_NONE: - rdata->glDisable(GL_BLEND); + data->glDisable(GL_BLEND); break; case SDL_BLENDMODE_BLEND: - rdata->glEnable(GL_BLEND); - rdata->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + data->glEnable(GL_BLEND); + data->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); break; case SDL_BLENDMODE_ADD: - rdata->glEnable(GL_BLEND); - rdata->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ZERO, GL_ONE); + data->glEnable(GL_BLEND); + data->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ZERO, GL_ONE); break; case SDL_BLENDMODE_MOD: - rdata->glEnable(GL_BLEND); - rdata->glBlendFuncSeparate(GL_ZERO, GL_SRC_COLOR, GL_ZERO, GL_ONE); + data->glEnable(GL_BLEND); + data->glBlendFuncSeparate(GL_ZERO, GL_SRC_COLOR, GL_ZERO, GL_ONE); break; } - rdata->current.blendMode = blendMode; + data->current.blendMode = blendMode; } } static void -GLES2_SetTexCoords(GLES2_DriverContext * rdata, SDL_bool enabled) +GLES2_SetTexCoords(GLES2_DriverContext * data, SDL_bool enabled) { - if (enabled != rdata->current.tex_coords) { + if (enabled != data->current.tex_coords) { if (enabled) { - rdata->glEnableVertexAttribArray(GLES2_ATTRIBUTE_TEXCOORD); + data->glEnableVertexAttribArray(GLES2_ATTRIBUTE_TEXCOORD); } else { - rdata->glDisableVertexAttribArray(GLES2_ATTRIBUTE_TEXCOORD); + data->glDisableVertexAttribArray(GLES2_ATTRIBUTE_TEXCOORD); } - rdata->current.tex_coords = enabled; + data->current.tex_coords = enabled; } } static int GLES2_SetDrawingState(SDL_Renderer * renderer) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; - int blendMode = renderer->blendMode; - GLuint locColor; - - rdata->glGetError(); + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + const int blendMode = renderer->blendMode; + GLES2_ProgramCacheEntry *program; + Uint8 r, g, b, a; GLES2_ActivateRenderer(renderer); - GLES2_SetBlendMode(rdata, blendMode); + GLES2_SetBlendMode(data, blendMode); - GLES2_SetTexCoords(rdata, SDL_FALSE); + GLES2_SetTexCoords(data, SDL_FALSE); /* Activate an appropriate shader and set the projection matrix */ - if (GLES2_SelectProgram(renderer, GLES2_IMAGESOURCE_SOLID, blendMode) < 0) + if (GLES2_SelectProgram(renderer, GLES2_IMAGESOURCE_SOLID, blendMode) < 0) { return -1; + } /* Select the color to draw with */ - locColor = rdata->current_program->uniform_locations[GLES2_UNIFORM_COLOR]; + g = renderer->g; + a = renderer->a; + if (renderer->target && - (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || + (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || renderer->target->format == SDL_PIXELFORMAT_RGB888)) { - rdata->glUniform4f(locColor, - renderer->b * inv255f, - renderer->g * inv255f, - renderer->r * inv255f, - renderer->a * inv255f); - } else { - rdata->glUniform4f(locColor, - renderer->r * inv255f, - renderer->g * inv255f, - renderer->b * inv255f, - renderer->a * inv255f); + r = renderer->b; + b = renderer->r; + } else { + r = renderer->r; + b = renderer->b; + } + + program = data->current_program; + if (!CompareColors(program->color_r, program->color_g, program->color_b, program->color_a, r, g, b, a)) { + /* Select the color to draw with */ + data->glUniform4f(program->uniform_locations[GLES2_UNIFORM_COLOR], r * inv255f, g * inv255f, b * inv255f, a * inv255f); + program->color_r = r; + program->color_g = g; + program->color_b = b; + program->color_a = a; } + return 0; } static int GLES2_RenderDrawPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int count) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLfloat *vertices; int idx; @@ -1084,20 +1169,16 @@ GLES2_RenderDrawPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int cou vertices[idx * 2] = x; vertices[(idx * 2) + 1] = y; } - rdata->glGetError(); - rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); - rdata->glDrawArrays(GL_POINTS, 0, count); + data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); + data->glDrawArrays(GL_POINTS, 0, count); SDL_stack_free(vertices); - if (rdata->glGetError() != GL_NO_ERROR) { - return SDL_SetError("Failed to render points"); - } return 0; } static int GLES2_RenderDrawLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLfloat *vertices; int idx; @@ -1114,26 +1195,23 @@ GLES2_RenderDrawLines(SDL_Renderer *renderer, const SDL_FPoint *points, int coun vertices[idx * 2] = x; vertices[(idx * 2) + 1] = y; } - rdata->glGetError(); - rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); - rdata->glDrawArrays(GL_LINE_STRIP, 0, count); + data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); + data->glDrawArrays(GL_LINE_STRIP, 0, count); /* We need to close the endpoint of the line */ if (count == 2 || points[0].x != points[count-1].x || points[0].y != points[count-1].y) { - rdata->glDrawArrays(GL_POINTS, count-1, 1); + data->glDrawArrays(GL_POINTS, count-1, 1); } SDL_stack_free(vertices); - if (rdata->glGetError() != GL_NO_ERROR) { - return SDL_SetError("Failed to render lines"); - } - return 0; + + return GL_CheckError("", renderer); } static int GLES2_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLfloat vertices[8]; int idx; @@ -1142,7 +1220,6 @@ GLES2_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count) } /* Emit a line loop for each rectangle */ - rdata->glGetError(); for (idx = 0; idx < count; ++idx) { const SDL_FRect *rect = &rects[idx]; @@ -1159,27 +1236,24 @@ GLES2_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count) vertices[5] = yMax; vertices[6] = xMax; vertices[7] = yMax; - rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); - rdata->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); + data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } - if (rdata->glGetError() != GL_NO_ERROR) { - return SDL_SetError("Failed to render filled rects"); - } - return 0; + return GL_CheckError("", renderer); } static int GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; - GLES2_ImageSource sourceType; + GLES2_ImageSource sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; SDL_BlendMode blendMode; GLfloat vertices[8]; GLfloat texCoords[8]; - GLuint locTexture; - GLuint locModulation; + GLES2_ProgramCacheEntry *program; + Uint8 r, g, b, a; GLES2_ActivateRenderer(renderer); @@ -1265,38 +1339,42 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s return -1; } } - if (GLES2_SelectProgram(renderer, sourceType, blendMode) < 0) + + if (GLES2_SelectProgram(renderer, sourceType, blendMode) < 0) { return -1; + } /* Select the target texture */ - locTexture = rdata->current_program->uniform_locations[GLES2_UNIFORM_TEXTURE]; - rdata->glGetError(); - rdata->glActiveTexture(GL_TEXTURE0); - rdata->glBindTexture(tdata->texture_type, tdata->texture); - rdata->glUniform1i(locTexture, 0); + data->glBindTexture(tdata->texture_type, tdata->texture); /* Configure color modulation */ - locModulation = rdata->current_program->uniform_locations[GLES2_UNIFORM_MODULATION]; + g = texture->g; + a = texture->a; + if (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || renderer->target->format == SDL_PIXELFORMAT_RGB888)) { - rdata->glUniform4f(locModulation, - texture->b * inv255f, - texture->g * inv255f, - texture->r * inv255f, - texture->a * inv255f); + r = texture->b; + b = texture->r; } else { - rdata->glUniform4f(locModulation, - texture->r * inv255f, - texture->g * inv255f, - texture->b * inv255f, - texture->a * inv255f); + r = texture->r; + b = texture->b; + } + + program = data->current_program; + + if (!CompareColors(program->modulation_r, program->modulation_g, program->modulation_b, program->modulation_a, r, g, b, a)) { + data->glUniform4f(program->uniform_locations[GLES2_UNIFORM_MODULATION], r * inv255f, g * inv255f, b * inv255f, a * inv255f); + program->modulation_r = r; + program->modulation_g = g; + program->modulation_b = b; + program->modulation_a = a; } /* Configure texture blending */ - GLES2_SetBlendMode(rdata, blendMode); + GLES2_SetBlendMode(data, blendMode); - GLES2_SetTexCoords(rdata, SDL_TRUE); + GLES2_SetTexCoords(data, SDL_TRUE); /* Emit the textured quad */ vertices[0] = dstrect->x; @@ -1307,7 +1385,7 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s vertices[5] = (dstrect->y + dstrect->h); vertices[6] = (dstrect->x + dstrect->w); vertices[7] = (dstrect->y + dstrect->h); - rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); + data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); texCoords[0] = srcrect->x / (GLfloat)texture->w; texCoords[1] = srcrect->y / (GLfloat)texture->h; texCoords[2] = (srcrect->x + srcrect->w) / (GLfloat)texture->w; @@ -1316,34 +1394,32 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s texCoords[5] = (srcrect->y + srcrect->h) / (GLfloat)texture->h; texCoords[6] = (srcrect->x + srcrect->w) / (GLfloat)texture->w; texCoords[7] = (srcrect->y + srcrect->h) / (GLfloat)texture->h; - rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, texCoords); - rdata->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - if (rdata->glGetError() != GL_NO_ERROR) { - return SDL_SetError("Failed to render texture"); - } - return 0; + data->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, texCoords); + data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + return GL_CheckError("", renderer); } static int GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect, const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; - GLES2_ImageSource sourceType; + GLES2_ImageSource sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; + GLES2_ProgramCacheEntry *program; + Uint8 r, g, b, a; SDL_BlendMode blendMode; GLfloat vertices[8]; GLfloat texCoords[8]; - GLuint locTexture; - GLuint locModulation; GLfloat translate[8]; GLfloat fAngle[4]; GLfloat tmp; GLES2_ActivateRenderer(renderer); - rdata->glEnableVertexAttribArray(GLES2_ATTRIBUTE_CENTER); - rdata->glEnableVertexAttribArray(GLES2_ATTRIBUTE_ANGLE); + data->glEnableVertexAttribArray(GLES2_ATTRIBUTE_CENTER); + data->glEnableVertexAttribArray(GLES2_ATTRIBUTE_ANGLE); fAngle[0] = fAngle[1] = fAngle[2] = fAngle[3] = (GLfloat)(360.0f - angle); /* Calculate the center of rotation */ translate[0] = translate[2] = translate[4] = translate[6] = (center->x + dstrect->x); @@ -1435,34 +1511,37 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect return -1; /* Select the target texture */ - locTexture = rdata->current_program->uniform_locations[GLES2_UNIFORM_TEXTURE]; - rdata->glGetError(); - rdata->glActiveTexture(GL_TEXTURE0); - rdata->glBindTexture(tdata->texture_type, tdata->texture); - rdata->glUniform1i(locTexture, 0); + data->glBindTexture(tdata->texture_type, tdata->texture); /* Configure color modulation */ - locModulation = rdata->current_program->uniform_locations[GLES2_UNIFORM_MODULATION]; + /* !!! FIXME: grep for glUniform4f(), move that stuff to a subroutine, it's a lot of copy/paste. */ + g = texture->g; + a = texture->a; + if (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || renderer->target->format == SDL_PIXELFORMAT_RGB888)) { - rdata->glUniform4f(locModulation, - texture->b * inv255f, - texture->g * inv255f, - texture->r * inv255f, - texture->a * inv255f); + r = texture->b; + b = texture->r; } else { - rdata->glUniform4f(locModulation, - texture->r * inv255f, - texture->g * inv255f, - texture->b * inv255f, - texture->a * inv255f); + r = texture->r; + b = texture->b; + } + + program = data->current_program; + + if (!CompareColors(program->modulation_r, program->modulation_g, program->modulation_b, program->modulation_a, r, g, b, a)) { + data->glUniform4f(program->uniform_locations[GLES2_UNIFORM_MODULATION], r * inv255f, g * inv255f, b * inv255f, a * inv255f); + program->modulation_r = r; + program->modulation_g = g; + program->modulation_b = b; + program->modulation_a = a; } /* Configure texture blending */ - GLES2_SetBlendMode(rdata, blendMode); + GLES2_SetBlendMode(data, blendMode); - GLES2_SetTexCoords(rdata, SDL_TRUE); + GLES2_SetTexCoords(data, SDL_TRUE); /* Emit the textured quad */ vertices[0] = dstrect->x; @@ -1484,9 +1563,9 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect vertices[5] = vertices[7] = tmp; } - rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_ANGLE, 1, GL_FLOAT, GL_FALSE, 0, &fAngle); - rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_CENTER, 2, GL_FLOAT, GL_FALSE, 0, translate); - rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); + data->glVertexAttribPointer(GLES2_ATTRIBUTE_ANGLE, 1, GL_FLOAT, GL_FALSE, 0, &fAngle); + data->glVertexAttribPointer(GLES2_ATTRIBUTE_CENTER, 2, GL_FLOAT, GL_FALSE, 0, translate); + data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); texCoords[0] = srcrect->x / (GLfloat)texture->w; texCoords[1] = srcrect->y / (GLfloat)texture->h; @@ -1496,21 +1575,19 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect texCoords[5] = (srcrect->y + srcrect->h) / (GLfloat)texture->h; texCoords[6] = (srcrect->x + srcrect->w) / (GLfloat)texture->w; texCoords[7] = (srcrect->y + srcrect->h) / (GLfloat)texture->h; - rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, texCoords); - rdata->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - rdata->glDisableVertexAttribArray(GLES2_ATTRIBUTE_CENTER); - rdata->glDisableVertexAttribArray(GLES2_ATTRIBUTE_ANGLE); - if (rdata->glGetError() != GL_NO_ERROR) { - return SDL_SetError("Failed to render texture"); - } - return 0; + data->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, texCoords); + data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + data->glDisableVertexAttribArray(GLES2_ATTRIBUTE_CENTER); + data->glDisableVertexAttribArray(GLES2_ATTRIBUTE_ANGLE); + + return GL_CheckError("", renderer); } static int GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, Uint32 pixel_format, void * pixels, int pitch) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; Uint32 temp_format = SDL_PIXELFORMAT_ABGR8888; void *temp_pixels; int temp_pitch; @@ -1528,10 +1605,11 @@ GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, SDL_GetRendererOutputSize(renderer, &w, &h); - rdata->glPixelStorei(GL_PACK_ALIGNMENT, 1); - - rdata->glReadPixels(rect->x, (h-rect->y)-rect->h, rect->w, rect->h, + data->glReadPixels(rect->x, (h-rect->y)-rect->h, rect->w, rect->h, GL_RGBA, GL_UNSIGNED_BYTE, temp_pixels); + if (GL_CheckError("glReadPixels()", renderer) < 0) { + return -1; + } /* Flip the rows to be top-down */ length = rect->w * SDL_BYTESPERPIXEL(temp_format); @@ -1572,7 +1650,8 @@ GLES2_RenderPresent(SDL_Renderer *renderer) static int GLES2_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh); static int GLES2_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture); -static int GLES2_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh) { +static int GLES2_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh) +{ GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLES2_TextureData *texturedata = (GLES2_TextureData *)texture->driverdata; GLES2_ActivateRenderer(renderer); @@ -1585,7 +1664,8 @@ static int GLES2_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, flo return 0; } -static int GLES2_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture) { +static int GLES2_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture) +{ GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLES2_TextureData *texturedata = (GLES2_TextureData *)texture->driverdata; GLES2_ActivateRenderer(renderer); @@ -1605,34 +1685,46 @@ static int GLES2_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture) { static void GLES2_ResetState(SDL_Renderer *renderer) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *) renderer->driverdata; + GLES2_DriverContext *data = (GLES2_DriverContext *) renderer->driverdata; - if (SDL_CurrentContext == rdata->context) { + if (SDL_CurrentContext == data->context) { GLES2_UpdateViewport(renderer); } else { GLES2_ActivateRenderer(renderer); } - rdata->current.blendMode = -1; - rdata->current.tex_coords = SDL_FALSE; + data->current.blendMode = -1; + data->current.tex_coords = SDL_FALSE; - rdata->glEnableVertexAttribArray(GLES2_ATTRIBUTE_POSITION); - rdata->glDisableVertexAttribArray(GLES2_ATTRIBUTE_TEXCOORD); + data->glActiveTexture(GL_TEXTURE0); + data->glPixelStorei(GL_PACK_ALIGNMENT, 1); + data->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + data->glClearColor((GLfloat) data->clear_r * inv255f, + (GLfloat) data->clear_g * inv255f, + (GLfloat) data->clear_b * inv255f, + (GLfloat) data->clear_a * inv255f); + + data->glEnableVertexAttribArray(GLES2_ATTRIBUTE_POSITION); + data->glDisableVertexAttribArray(GLES2_ATTRIBUTE_TEXCOORD); + + GL_CheckError("", renderer); } static SDL_Renderer * GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) { SDL_Renderer *renderer; - GLES2_DriverContext *rdata; + GLES2_DriverContext *data; GLint nFormats; #ifndef ZUNE_HD GLboolean hasCompiler; #endif Uint32 windowFlags; GLint window_framebuffer; + GLint value; - SDL_GL_SetAttribute(SDL_GL_CONTEXT_EGL, 1); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); @@ -1652,30 +1744,30 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) return NULL; } - rdata = (GLES2_DriverContext *)SDL_calloc(1, sizeof(GLES2_DriverContext)); - if (!rdata) { + data = (GLES2_DriverContext *)SDL_calloc(1, sizeof(GLES2_DriverContext)); + if (!data) { GLES2_DestroyRenderer(renderer); SDL_OutOfMemory(); return NULL; } renderer->info = GLES2_RenderDriver.info; renderer->info.flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE; - renderer->driverdata = rdata; + renderer->driverdata = data; renderer->window = window; /* Create an OpenGL ES 2.0 context */ - rdata->context = SDL_GL_CreateContext(window); - if (!rdata->context) + data->context = SDL_GL_CreateContext(window); + if (!data->context) { GLES2_DestroyRenderer(renderer); return NULL; } - if (SDL_GL_MakeCurrent(window, rdata->context) < 0) { + if (SDL_GL_MakeCurrent(window, data->context) < 0) { GLES2_DestroyRenderer(renderer); return NULL; } - if (GLES2_LoadFunctions(rdata) < 0) { + if (GLES2_LoadFunctions(data) < 0) { GLES2_DestroyRenderer(renderer); return NULL; } @@ -1689,42 +1781,48 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; } + /* Check for debug output support */ + if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_FLAGS, &value) == 0 && + (value & SDL_GL_CONTEXT_DEBUG_FLAG)) { + data->debug_enabled = SDL_TRUE; + } + + value = 0; + data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); + renderer->info.max_texture_width = value; + value = 0; + data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); + renderer->info.max_texture_height = value; + /* Determine supported shader formats */ /* HACK: glGetInteger is broken on the Zune HD's compositor, so we just hardcode this */ - rdata->glGetError(); #ifdef ZUNE_HD nFormats = 1; #else /* !ZUNE_HD */ - rdata->glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &nFormats); - rdata->glGetBooleanv(GL_SHADER_COMPILER, &hasCompiler); + data->glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &nFormats); + data->glGetBooleanv(GL_SHADER_COMPILER, &hasCompiler); if (hasCompiler) ++nFormats; #endif /* ZUNE_HD */ - rdata->shader_formats = (GLenum *)SDL_calloc(nFormats, sizeof(GLenum)); - if (!rdata->shader_formats) + data->shader_formats = (GLenum *)SDL_calloc(nFormats, sizeof(GLenum)); + if (!data->shader_formats) { GLES2_DestroyRenderer(renderer); SDL_OutOfMemory(); return NULL; } - rdata->shader_format_count = nFormats; + data->shader_format_count = nFormats; #ifdef ZUNE_HD - rdata->shader_formats[0] = GL_NVIDIA_PLATFORM_BINARY_NV; + data->shader_formats[0] = GL_NVIDIA_PLATFORM_BINARY_NV; #else /* !ZUNE_HD */ - rdata->glGetIntegerv(GL_SHADER_BINARY_FORMATS, (GLint *)rdata->shader_formats); - if (rdata->glGetError() != GL_NO_ERROR) - { - GLES2_DestroyRenderer(renderer); - SDL_SetError("Failed to query supported shader formats"); - return NULL; - } + data->glGetIntegerv(GL_SHADER_BINARY_FORMATS, (GLint *)data->shader_formats); if (hasCompiler) - rdata->shader_formats[nFormats - 1] = (GLenum)-1; + data->shader_formats[nFormats - 1] = (GLenum)-1; #endif /* ZUNE_HD */ - rdata->framebuffers = NULL; - rdata->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &window_framebuffer); - rdata->window_framebuffer = (GLuint)window_framebuffer; + data->framebuffers = NULL; + data->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &window_framebuffer); + data->window_framebuffer = (GLuint)window_framebuffer; /* Populate the function pointers for the module */ renderer->WindowEvent = &GLES2_WindowEvent; diff --git a/src/render/psp/SDL_render_psp.c b/src/render/psp/SDL_render_psp.c index 7ea536d14..b8cd265de 100644 --- a/src/render/psp/SDL_render_psp.c +++ b/src/render/psp/SDL_render_psp.c @@ -458,7 +458,7 @@ PSP_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) static int PSP_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) { -// PSP_RenderData *renderdata = (PSP_RenderData *) renderer->driverdata; +/* PSP_RenderData *renderdata = (PSP_RenderData *) renderer->driverdata; */ PSP_TextureData* psp_texture = (PSP_TextureData*) SDL_calloc(1, sizeof(*psp_texture));; if(!psp_texture) @@ -528,7 +528,7 @@ static int PSP_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, const void *pixels, int pitch) { -// PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; +/* PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; */ const Uint8 *src; Uint8 *dst; int row, length,dpitch; @@ -895,8 +895,8 @@ PSP_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, sceGuColor(0xFFFFFFFF); } -// x += width * 0.5f; -// y += height * 0.5f; +/* x += width * 0.5f; */ +/* y += height * 0.5f; */ x += centerx; y += centery; @@ -904,8 +904,8 @@ PSP_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, MathSincos(degToRad(angle), &s, &c); -// width *= 0.5f; -// height *= 0.5f; +/* width *= 0.5f; */ +/* height *= 0.5f; */ width -= centerx; height -= centery; @@ -968,7 +968,7 @@ PSP_RenderPresent(SDL_Renderer * renderer) sceGuFinish(); sceGuSync(0,0); -// if(data->vsync) +/* if(data->vsync) */ sceDisplayWaitVblankStart(); data->backbuffer = data->frontbuffer; @@ -988,10 +988,7 @@ PSP_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) if(psp_texture == 0) return; - if(psp_texture->data != 0) - { - SDL_free(psp_texture->data); - } + SDL_free(psp_texture->data); SDL_free(psp_texture); texture->driverdata = NULL; } @@ -1007,8 +1004,8 @@ PSP_DestroyRenderer(SDL_Renderer * renderer) StartDrawing(renderer); sceGuTerm(); -// vfree(data->backbuffer); -// vfree(data->frontbuffer); +/* vfree(data->backbuffer); */ +/* vfree(data->frontbuffer); */ data->initialized = SDL_FALSE; data->displayListAvail = SDL_FALSE; diff --git a/src/render/software/SDL_render_sw.c b/src/render/software/SDL_render_sw.c index 78f6ca1e9..29aab8c8f 100644 --- a/src/render/software/SDL_render_sw.c +++ b/src/render/software/SDL_render_sw.c @@ -609,8 +609,8 @@ SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, retval = SDL_BlitScaled(src, srcrect, surface_scaled, &tmp_rect); if (!retval) { - _rotozoomSurfaceSizeTrig(tmp_rect.w, tmp_rect.h, -angle, &dstwidth, &dstheight, &cangle, &sangle); - surface_rotated = _rotateSurface(surface_scaled, -angle, dstwidth/2, dstheight/2, GetScaleQuality(), flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL, dstwidth, dstheight, cangle, sangle); + SDLgfx_rotozoomSurfaceSizeTrig(tmp_rect.w, tmp_rect.h, -angle, &dstwidth, &dstheight, &cangle, &sangle); + surface_rotated = SDLgfx_rotateSurface(surface_scaled, -angle, dstwidth/2, dstheight/2, GetScaleQuality(), flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL, dstwidth, dstheight, cangle, sangle); if(surface_rotated) { /* Find out where the new origin is by rotating the four final_rect points around the center and then taking the extremes */ abscenterx = final_rect.x + (int)center->x; @@ -718,9 +718,7 @@ SW_DestroyRenderer(SDL_Renderer * renderer) { SW_RenderData *data = (SW_RenderData *) renderer->driverdata; - if (data) { - SDL_free(data); - } + SDL_free(data); SDL_free(renderer); } diff --git a/src/render/software/SDL_rotate.c b/src/render/software/SDL_rotate.c index b31553587..3006eda62 100644 --- a/src/render/software/SDL_rotate.c +++ b/src/render/software/SDL_rotate.c @@ -30,8 +30,8 @@ Andreas Schiffler -- aschiffler at ferzkopp dot net */ #include "SDL_config.h" -#ifdef WIN32 -#include +#if defined(__WIN32__) +#include "../../core/windows/SDL_windows.h" #endif #include @@ -42,7 +42,7 @@ Andreas Schiffler -- aschiffler at ferzkopp dot net /* ---- Internally used structures */ -/*! +/* ! \brief A 32 bit RGBA pixel. */ typedef struct tColorRGBA { @@ -52,19 +52,19 @@ typedef struct tColorRGBA { Uint8 a; } tColorRGBA; -/*! +/* ! \brief A 8bit Y/palette pixel. */ typedef struct tColorY { Uint8 y; } tColorY; -/*! +/* ! \brief Returns maximum of two numbers a and b. */ #define MAX(a,b) (((a) > (b)) ? (a) : (b)) -/*! +/* ! \brief Number of guard rows added to destination surfaces. This is a simple but effective workaround for observed issues. @@ -76,15 +76,16 @@ to a situation where the program can segfault. */ #define GUARD_ROWS (2) -/*! +/* ! \brief Lower limit of absolute zoom factor or rotation degrees. */ #define VALUE_LIMIT 0.001 -/*! +/* ! \brief Returns colorkey info for a surface */ -Uint32 _colorkey(SDL_Surface *src) +static Uint32 +_colorkey(SDL_Surface *src) { Uint32 key = 0; SDL_GetColorKey(src, &key); @@ -92,7 +93,7 @@ Uint32 _colorkey(SDL_Surface *src) } -/*! +/* ! \brief Internal target surface sizing function for rotations with trig result return. \param width The source surface width. @@ -104,9 +105,10 @@ Uint32 _colorkey(SDL_Surface *src) \param sangle The cosine of the angle */ -void _rotozoomSurfaceSizeTrig(int width, int height, double angle, - int *dstwidth, int *dstheight, - double *cangle, double *sangle) +void +SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, + int *dstwidth, int *dstheight, + double *cangle, double *sangle) { double x, y, cx, cy, sx, sy; double radangle; @@ -134,7 +136,7 @@ void _rotozoomSurfaceSizeTrig(int width, int height, double angle, } -/*! +/* ! \brief Internal 32 bit rotozoomer with optional anti-aliasing. Rotates and zooms 32 bit RGBA/ABGR 'src' surface to 'dst' surface based on the control @@ -153,7 +155,8 @@ Assumes dst surface was allocated with the correct dimensions. \param flipy Flag indicating vertical mirroring should be applied. \param smooth Flag indicating anti-aliasing should be used. */ -void _transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin, int icos, int flipx, int flipy, int smooth) +static void +_transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin, int icos, int flipx, int flipy, int smooth) { int x, y, t1, t2, dx, dy, xd, yd, sdx, sdy, ax, ay, ex, ey, sw, sh; tColorRGBA c00, c01, c10, c11, cswap; @@ -252,7 +255,7 @@ void _transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, } } -/*! +/* ! \brief Rotates and zooms 8 bit palette/Y 'src' surface to 'dst' surface without smoothing. @@ -270,7 +273,8 @@ Assumes dst surface was allocated with the correct dimensions. \param flipx Flag indicating horizontal mirroring should be applied. \param flipy Flag indicating vertical mirroring should be applied. */ -void transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin, int icos, int flipx, int flipy) +static void +transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin, int icos, int flipx, int flipy) { int x, y, dx, dy, xd, yd, sdx, sdy, ax, ay; tColorY *pc, *sp; @@ -315,9 +319,7 @@ void transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int } - - -/*! +/* ! \brief Rotates and zooms a surface with different horizontal and vertival scaling factors and optional anti-aliasing. Rotates a 32bit or 8bit 'src' surface to newly created 'dst' surface. @@ -340,7 +342,8 @@ or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly. */ -SDL_Surface *_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery, int smooth, int flipx, int flipy, int dstwidth, int dstheight, double cangle, double sangle) +SDL_Surface * +SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery, int smooth, int flipx, int flipy, int dstwidth, int dstheight, double cangle, double sangle) { SDL_Surface *rz_src; SDL_Surface *rz_dst; @@ -357,7 +360,7 @@ SDL_Surface *_rotateSurface(SDL_Surface * src, double angle, int centerx, int ce if (src == NULL) return (NULL); - if (src->flags & SDL_TRUE/*SDL_SRCCOLORKEY*/) + if (src->flags & SDL_TRUE/* SDL_SRCCOLORKEY */) { colorkey = _colorkey(src); SDL_GetRGB(colorkey, src->format, &r, &g, &b); @@ -391,14 +394,14 @@ SDL_Surface *_rotateSurface(SDL_Surface * src, double angle, int centerx, int ce SDL_BlitSurface(src, NULL, rz_src, NULL); if(colorKeyAvailable) - SDL_SetColorKey(src, SDL_TRUE /*SDL_SRCCOLORKEY*/, colorkey); + SDL_SetColorKey(src, SDL_TRUE /* SDL_SRCCOLORKEY */, colorkey); src_converted = 1; is32bit = 1; } /* Determine target size */ - /*_rotozoomSurfaceSizeTrig(rz_src->w, rz_src->h, angle, &dstwidth, &dstheight, &cangle, &sangle); */ + /* _rotozoomSurfaceSizeTrig(rz_src->w, rz_src->h, angle, &dstwidth, &dstheight, &cangle, &sangle); */ /* * Calculate target factors from sin/cos and zoom @@ -459,8 +462,8 @@ SDL_Surface *_rotateSurface(SDL_Surface * src, double angle, int centerx, int ce /* * Turn on source-alpha support */ - /*SDL_SetAlpha(rz_dst, SDL_SRCALPHA, 255);*/ - SDL_SetColorKey(rz_dst, /*SDL_SRCCOLORKEY*/ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src)); + /* SDL_SetAlpha(rz_dst, SDL_SRCALPHA, 255); */ + SDL_SetColorKey(rz_dst, /* SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src)); } else { /* * Copy palette and colorkey info @@ -475,7 +478,7 @@ SDL_Surface *_rotateSurface(SDL_Surface * src, double angle, int centerx, int ce transformSurfaceY(rz_src, rz_dst, centerx, centery, (int) (sangleinv), (int) (cangleinv), flipx, flipy); - SDL_SetColorKey(rz_dst, /*SDL_SRCCOLORKEY*/ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src)); + SDL_SetColorKey(rz_dst, /* SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src)); } /* * Unlock source surface @@ -496,4 +499,3 @@ SDL_Surface *_rotateSurface(SDL_Surface * src, double angle, int centerx, int ce */ return (rz_dst); } - diff --git a/src/render/software/SDL_rotate.h b/src/render/software/SDL_rotate.h index 26bb8ad1c..31d12a48f 100644 --- a/src/render/software/SDL_rotate.h +++ b/src/render/software/SDL_rotate.h @@ -2,6 +2,6 @@ #define MIN(a,b) (((a) < (b)) ? (a) : (b)) #endif -extern SDL_Surface *_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery, int smooth, int flipx, int flipy, int dstwidth, int dstheight, double cangle, double sangle); -extern void _rotozoomSurfaceSizeTrig(int width, int height, double angle, int *dstwidth, int *dstheight, double *cangle, double *sangle); +extern SDL_Surface *SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery, int smooth, int flipx, int flipy, int dstwidth, int dstheight, double cangle, double sangle); +extern void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, int *dstwidth, int *dstheight, double *cangle, double *sangle); diff --git a/src/stdlib/SDL_getenv.c b/src/stdlib/SDL_getenv.c index 0cd440549..10fa7c5c1 100644 --- a/src/stdlib/SDL_getenv.c +++ b/src/stdlib/SDL_getenv.c @@ -20,10 +20,13 @@ */ #include "SDL_config.h" +#if defined(__WIN32__) +#include "../core/windows/SDL_windows.h" +#endif + #include "SDL_stdinc.h" #if !defined(SDL_setenv) && defined(__WIN32__) -#include "../core/windows/SDL_windows.h" /* Note this isn't thread-safe! */ static char *SDL_envmem = NULL; /* Ugh, memory leak */ static size_t SDL_envmemlen = 0; diff --git a/src/stdlib/SDL_iconv.c b/src/stdlib/SDL_iconv.c index 109e03ed6..4de2ebe3f 100644 --- a/src/stdlib/SDL_iconv.c +++ b/src/stdlib/SDL_iconv.c @@ -843,7 +843,7 @@ SDL_iconv(SDL_iconv_t cd, int SDL_iconv_close(SDL_iconv_t cd) { - if (cd && cd != (SDL_iconv_t) - 1) { + if (cd != (SDL_iconv_t)-1) { SDL_free(cd); } return 0; diff --git a/src/stdlib/SDL_string.c b/src/stdlib/SDL_string.c index 89f5f358e..980f025ae 100644 --- a/src/stdlib/SDL_string.c +++ b/src/stdlib/SDL_string.c @@ -1293,13 +1293,20 @@ int SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap) } #else /* FIXME: implement more of the format specifiers */ +typedef enum +{ + SDL_CASE_NOCHANGE, + SDL_CASE_LOWER, + SDL_CASE_UPPER +} SDL_letter_case; + typedef struct { SDL_bool left_justify; SDL_bool force_sign; SDL_bool force_type; SDL_bool pad_zeroes; - SDL_bool do_lowercase; + SDL_letter_case force_case; int width; int radix; int precision; @@ -1322,8 +1329,12 @@ SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *str length += SDL_strlcpy(text, string, maxlen); - if (info && info->do_lowercase) { - SDL_strlwr(text); + if (info) { + if (info->force_case == SDL_CASE_LOWER) { + SDL_strlwr(text); + } else if (info->force_case == SDL_CASE_UPPER) { + SDL_strupr(text); + } } return length; } @@ -1573,9 +1584,12 @@ SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap) break; case 'p': case 'x': - info.do_lowercase = SDL_TRUE; + info.force_case = SDL_CASE_LOWER; /* Fall through to 'X' handling */ case 'X': + if (info.force_case == SDL_CASE_NOCHANGE) { + info.force_case = SDL_CASE_UPPER; + } if (info.radix == 10) { info.radix = 16; } diff --git a/src/test/SDL_test_assert.c b/src/test/SDL_test_assert.c index 41a3df68f..6f08d1f5b 100644 --- a/src/test/SDL_test_assert.c +++ b/src/test/SDL_test_assert.c @@ -35,10 +35,10 @@ const char *SDLTest_AssertCheckFormat = "Assert '%s': %s"; /* Assert summary message format */ const char *SDLTest_AssertSummaryFormat = "Assert Summary: Total=%d Passed=%d Failed=%d"; -/*! \brief counts the failed asserts */ +/* ! \brief counts the failed asserts */ static Uint32 SDLTest_AssertsFailed = 0; -/*! \brief counts the passed asserts */ +/* ! \brief counts the passed asserts */ static Uint32 SDLTest_AssertsPassed = 0; /* diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c index 14add55b2..c117a93a9 100644 --- a/src/test/SDL_test_common.c +++ b/src/test/SDL_test_common.c @@ -27,7 +27,7 @@ #include #define VIDEO_USAGE \ -"[--video driver] [--renderer driver] [--gldebug] [--info all|video|modes|render|event] [--log all|error|system|audio|video|render|input] [--display N] [--fullscreen | --fullscreen-desktop | --windows N] [--title title] [--icon icon.bmp] [--center | --position X,Y] [--geometry WxH] [--min-geometry WxH] [--max-geometry WxH] [--logical WxH] [--scale N] [--depth N] [--refresh R] [--vsync] [--noframe] [--resize] [--minimize] [--maximize] [--grab]" +"[--video driver] [--renderer driver] [--gldebug] [--info all|video|modes|render|event] [--log all|error|system|audio|video|render|input] [--display N] [--fullscreen | --fullscreen-desktop | --windows N] [--title title] [--icon icon.bmp] [--center | --position X,Y] [--geometry WxH] [--min-geometry WxH] [--max-geometry WxH] [--logical WxH] [--scale N] [--depth N] [--refresh R] [--vsync] [--noframe] [--resize] [--minimize] [--maximize] [--grab] [--allow-hidpi]" #define AUDIO_USAGE \ "[--rate N] [--format U8|S8|U16|U16LE|U16BE|S16|S16LE|S16BE] [--channels N] [--samples N]" @@ -194,6 +194,10 @@ SDLTest_CommonArg(SDLTest_CommonState * state, int index) state->num_windows = 1; return 1; } + if (SDL_strcasecmp(argv[index], "--allow-highdpi") == 0) { + state->window_flags |= SDL_WINDOW_ALLOW_HIGHDPI; + return 1; + } if (SDL_strcasecmp(argv[index], "--windows") == 0) { ++index; if (!argv[index] || !SDL_isdigit(*argv[index])) { @@ -691,13 +695,18 @@ SDLTest_CommonInit(SDLTest_CommonState * state) if (state->gl_debug) { SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG); } + if (state->gl_profile_mask) { + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, state->gl_profile_mask); + } if (state->verbose & VERBOSE_MODES) { SDL_Rect bounds; SDL_DisplayMode mode; int bpp; Uint32 Rmask, Gmask, Bmask, Amask; - +#if SDL_VIDEO_DRIVER_WINDOWS + int adapterIndex = 0; +#endif n = SDL_GetNumVideoDisplays(); fprintf(stderr, "Number of displays: %d\n", n); for (i = 0; i < n; ++i) { @@ -750,6 +759,12 @@ SDLTest_CommonInit(SDLTest_CommonState * state) } } } + +#if SDL_VIDEO_DRIVER_WINDOWS + /* Print the adapter index */ + adapterIndex = SDL_Direct3D9GetAdapterIndex( i ); + fprintf( stderr, "Adapter Index: %d", adapterIndex ); +#endif } } @@ -1092,10 +1107,10 @@ SDLTest_PrintEvent(SDL_Event * event) case SDL_FINGERDOWN: case SDL_FINGERUP: - fprintf(stderr, "Finger: %s touch=%lld, finger=%lld, x=%f, y=%f, dx=%f, dy=%f, pressure=%f", + fprintf(stderr, "Finger: %s touch=%ld, finger=%ld, x=%f, y=%f, dx=%f, dy=%f, pressure=%f", (event->type == SDL_FINGERDOWN) ? "down" : "up", - (long long) event->tfinger.touchId, - (long long) event->tfinger.fingerId, + (long) event->tfinger.touchId, + (long) event->tfinger.fingerId, event->tfinger.x, event->tfinger.y, event->tfinger.dx, event->tfinger.dy, event->tfinger.pressure); break; @@ -1139,11 +1154,13 @@ SDLTest_ScreenShot(SDL_Renderer *renderer) if (SDL_RenderReadPixels(renderer, NULL, surface->format->format, surface->pixels, surface->pitch) < 0) { fprintf(stderr, "Couldn't read screen: %s\n", SDL_GetError()); + SDL_free(surface); return; } if (SDL_SaveBMP(surface, "screenshot.bmp") < 0) { fprintf(stderr, "Couldn't save screenshot.bmp: %s\n", SDL_GetError()); + SDL_free(surface); return; } } @@ -1188,6 +1205,12 @@ SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done) SDL_Window *window = SDL_GetWindowFromID(event->window.windowID); if (window) { SDL_DestroyWindow(window); + for (i = 0; i < state->num_windows; ++i) { + if (window == state->windows[i]) { + state->windows[i] = NULL; + break; + } + } } } break; @@ -1388,9 +1411,7 @@ SDLTest_CommonQuit(SDLTest_CommonState * state) { int i; - if (state->windows) { - SDL_free(state->windows); - } + SDL_free(state->windows); if (state->renderers) { for (i = 0; i < state->num_windows; ++i) { if (state->renderers[i]) { diff --git a/src/test/SDL_test_font.c b/src/test/SDL_test_font.c index 144bcad02..b7d2caa2d 100644 --- a/src/test/SDL_test_font.c +++ b/src/test/SDL_test_font.c @@ -1569,7 +1569,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 128 0x80 '' + * 128 0x80 '�' */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ @@ -1581,7 +1581,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x78, /* 01111000 */ /* - * 129 0x81 '' + * 129 0x81 '�' */ 0xcc, /* 11001100 */ 0x00, /* 00000000 */ @@ -1593,7 +1593,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 130 0x82 '' + * 130 0x82 '�' */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ @@ -1605,7 +1605,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 131 0x83 '' + * 131 0x83 '�' */ 0x7c, /* 01111100 */ 0x82, /* 10000010 */ @@ -1617,7 +1617,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 132 0x84 '' + * 132 0x84 '�' */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ @@ -1629,7 +1629,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 133 0x85 '' + * 133 0x85 '�' */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ @@ -1641,7 +1641,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 134 0x86 '' + * 134 0x86 '�' */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ @@ -1653,7 +1653,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 135 0x87 '' + * 135 0x87 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -1665,7 +1665,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x38, /* 00111000 */ /* - * 136 0x88 '' + * 136 0x88 '�' */ 0x7c, /* 01111100 */ 0x82, /* 10000010 */ @@ -1677,7 +1677,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 137 0x89 '' + * 137 0x89 '�' */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ @@ -1689,7 +1689,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 138 0x8a '' + * 138 0x8a '�' */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ @@ -1701,7 +1701,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 139 0x8b '' + * 139 0x8b '�' */ 0x66, /* 01100110 */ 0x00, /* 00000000 */ @@ -1713,7 +1713,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 140 0x8c '' + * 140 0x8c '�' */ 0x7c, /* 01111100 */ 0x82, /* 10000010 */ @@ -1725,7 +1725,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 141 0x8d '' + * 141 0x8d '�' */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ @@ -1737,7 +1737,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 142 0x8e '' + * 142 0x8e '�' */ 0xc6, /* 11000110 */ 0x38, /* 00111000 */ @@ -1749,7 +1749,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 143 0x8f '' + * 143 0x8f '�' */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ @@ -1761,7 +1761,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 144 0x90 '' + * 144 0x90 '�' */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ @@ -1773,7 +1773,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 145 0x91 '' + * 145 0x91 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -1785,7 +1785,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 146 0x92 '' + * 146 0x92 '�' */ 0x3e, /* 00111110 */ 0x6c, /* 01101100 */ @@ -1797,7 +1797,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 147 0x93 '' + * 147 0x93 '�' */ 0x7c, /* 01111100 */ 0x82, /* 10000010 */ @@ -1809,7 +1809,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 148 0x94 '' + * 148 0x94 '�' */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ @@ -1821,7 +1821,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 149 0x95 '' + * 149 0x95 '�' */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ @@ -1833,7 +1833,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 150 0x96 '' + * 150 0x96 '�' */ 0x78, /* 01111000 */ 0x84, /* 10000100 */ @@ -1845,7 +1845,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 151 0x97 '' + * 151 0x97 '�' */ 0x60, /* 01100000 */ 0x30, /* 00110000 */ @@ -1857,7 +1857,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 152 0x98 '' + * 152 0x98 '�' */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ @@ -1869,7 +1869,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xfc, /* 11111100 */ /* - * 153 0x99 '' + * 153 0x99 '�' */ 0xc6, /* 11000110 */ 0x38, /* 00111000 */ @@ -1881,7 +1881,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 154 0x9a '' + * 154 0x9a '�' */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ @@ -1893,7 +1893,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 155 0x9b '' + * 155 0x9b '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -1905,7 +1905,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 156 0x9c '' + * 156 0x9c '�' */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ @@ -1917,7 +1917,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 157 0x9d '' + * 157 0x9d '�' */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ @@ -1929,7 +1929,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 158 0x9e '' + * 158 0x9e '�' */ 0xf8, /* 11111000 */ 0xcc, /* 11001100 */ @@ -1941,7 +1941,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xc7, /* 11000111 */ /* - * 159 0x9f '' + * 159 0x9f '�' */ 0x0e, /* 00001110 */ 0x1b, /* 00011011 */ @@ -1953,7 +1953,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 160 0xa0 '' + * 160 0xa0 '�' */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ @@ -1965,7 +1965,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 161 0xa1 '' + * 161 0xa1 '�' */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ @@ -1977,7 +1977,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 162 0xa2 '' + * 162 0xa2 '�' */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ @@ -1989,7 +1989,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 163 0xa3 '' + * 163 0xa3 '�' */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ @@ -2001,7 +2001,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 164 0xa4 '' + * 164 0xa4 '�' */ 0x76, /* 01110110 */ 0xdc, /* 11011100 */ @@ -2013,7 +2013,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 165 0xa5 '' + * 165 0xa5 '�' */ 0x76, /* 01110110 */ 0xdc, /* 11011100 */ @@ -2025,7 +2025,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 166 0xa6 '' + * 166 0xa6 '�' */ 0x3c, /* 00111100 */ 0x6c, /* 01101100 */ @@ -2037,7 +2037,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 167 0xa7 '' + * 167 0xa7 '�' */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ @@ -2049,7 +2049,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 168 0xa8 '' + * 168 0xa8 '�' */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ @@ -2061,7 +2061,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 169 0xa9 '' + * 169 0xa9 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2073,7 +2073,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 170 0xaa '' + * 170 0xaa '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2085,7 +2085,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 171 0xab '' + * 171 0xab '�' */ 0x63, /* 01100011 */ 0xe6, /* 11100110 */ @@ -2097,7 +2097,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x0f, /* 00001111 */ /* - * 172 0xac '' + * 172 0xac '�' */ 0x63, /* 01100011 */ 0xe6, /* 11100110 */ @@ -2109,7 +2109,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x06, /* 00000110 */ /* - * 173 0xad '' + * 173 0xad '�' */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ @@ -2121,7 +2121,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 174 0xae '' + * 174 0xae '�' */ 0x00, /* 00000000 */ 0x33, /* 00110011 */ @@ -2133,7 +2133,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 175 0xaf '' + * 175 0xaf '�' */ 0x00, /* 00000000 */ 0xcc, /* 11001100 */ @@ -2145,7 +2145,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 176 0xb0 '' + * 176 0xb0 '�' */ 0x22, /* 00100010 */ 0x88, /* 10001000 */ @@ -2157,7 +2157,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x88, /* 10001000 */ /* - * 177 0xb1 '' + * 177 0xb1 '�' */ 0x55, /* 01010101 */ 0xaa, /* 10101010 */ @@ -2169,7 +2169,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xaa, /* 10101010 */ /* - * 178 0xb2 '' + * 178 0xb2 '�' */ 0x77, /* 01110111 */ 0xdd, /* 11011101 */ @@ -2181,7 +2181,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xdd, /* 11011101 */ /* - * 179 0xb3 '' + * 179 0xb3 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2193,7 +2193,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 180 0xb4 '' + * 180 0xb4 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2205,7 +2205,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 181 0xb5 '' + * 181 0xb5 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2217,7 +2217,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 182 0xb6 '' + * 182 0xb6 '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2229,7 +2229,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 183 0xb7 '' + * 183 0xb7 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2241,7 +2241,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 184 0xb8 '' + * 184 0xb8 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2253,7 +2253,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 185 0xb9 '' + * 185 0xb9 '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2265,7 +2265,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 186 0xba '' + * 186 0xba '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2277,7 +2277,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 187 0xbb '' + * 187 0xbb '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2289,7 +2289,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 188 0xbc '' + * 188 0xbc '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2301,7 +2301,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 189 0xbd '' + * 189 0xbd '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2313,7 +2313,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 190 0xbe '' + * 190 0xbe '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2325,7 +2325,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 191 0xbf '' + * 191 0xbf '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2337,7 +2337,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 192 0xc0 '' + * 192 0xc0 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2349,7 +2349,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 193 0xc1 '' + * 193 0xc1 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2361,7 +2361,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 194 0xc2 '' + * 194 0xc2 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2373,7 +2373,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 195 0xc3 '' + * 195 0xc3 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2385,7 +2385,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 196 0xc4 '' + * 196 0xc4 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2397,7 +2397,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 197 0xc5 '' + * 197 0xc5 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2409,7 +2409,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 198 0xc6 '' + * 198 0xc6 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2421,7 +2421,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 199 0xc7 '' + * 199 0xc7 '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2433,7 +2433,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 200 0xc8 '' + * 200 0xc8 '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2445,7 +2445,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 201 0xc9 '' + * 201 0xc9 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2457,7 +2457,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 202 0xca '' + * 202 0xca '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2469,7 +2469,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 203 0xcb '' + * 203 0xcb '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2481,7 +2481,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 204 0xcc '' + * 204 0xcc '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2493,7 +2493,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 205 0xcd '' + * 205 0xcd '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2505,7 +2505,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 206 0xce '' + * 206 0xce '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2517,7 +2517,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 207 0xcf '' + * 207 0xcf '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2529,7 +2529,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 208 0xd0 '' + * 208 0xd0 '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2541,7 +2541,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 209 0xd1 '' + * 209 0xd1 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2553,7 +2553,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 210 0xd2 '' + * 210 0xd2 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2565,7 +2565,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 211 0xd3 '' + * 211 0xd3 '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2577,7 +2577,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 212 0xd4 '' + * 212 0xd4 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2589,7 +2589,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 213 0xd5 '' + * 213 0xd5 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2601,7 +2601,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 214 0xd6 '' + * 214 0xd6 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2613,7 +2613,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 215 0xd7 '' + * 215 0xd7 '�' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2625,7 +2625,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 216 0xd8 '' + * 216 0xd8 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2637,7 +2637,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 217 0xd9 '' + * 217 0xd9 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2649,7 +2649,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 218 0xda '' + * 218 0xda '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2661,7 +2661,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 219 0xdb '' + * 219 0xdb '�' */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ @@ -2673,7 +2673,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xff, /* 11111111 */ /* - * 220 0xdc '' + * 220 0xdc '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2685,7 +2685,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xff, /* 11111111 */ /* - * 221 0xdd '' + * 221 0xdd '�' */ 0xf0, /* 11110000 */ 0xf0, /* 11110000 */ @@ -2697,7 +2697,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xf0, /* 11110000 */ /* - * 222 0xde '' + * 222 0xde '�' */ 0x0f, /* 00001111 */ 0x0f, /* 00001111 */ @@ -2709,7 +2709,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x0f, /* 00001111 */ /* - * 223 0xdf '' + * 223 0xdf '�' */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ @@ -2721,7 +2721,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 224 0xe0 '' + * 224 0xe0 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2733,7 +2733,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 225 0xe1 '' + * 225 0xe1 '�' */ 0x78, /* 01111000 */ 0xcc, /* 11001100 */ @@ -2745,7 +2745,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 226 0xe2 '' + * 226 0xe2 '�' */ 0xfe, /* 11111110 */ 0xc6, /* 11000110 */ @@ -2757,7 +2757,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 227 0xe3 '' + * 227 0xe3 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2769,7 +2769,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 228 0xe4 '' + * 228 0xe4 '�' */ 0xfe, /* 11111110 */ 0xc6, /* 11000110 */ @@ -2781,7 +2781,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 229 0xe5 '' + * 229 0xe5 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2793,7 +2793,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 230 0xe6 '' + * 230 0xe6 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2805,7 +2805,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xc0, /* 11000000 */ /* - * 231 0xe7 '' + * 231 0xe7 '�' */ 0x00, /* 00000000 */ 0x76, /* 01110110 */ @@ -2817,7 +2817,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 232 0xe8 '' + * 232 0xe8 '�' */ 0x7e, /* 01111110 */ 0x18, /* 00011000 */ @@ -2829,7 +2829,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x7e, /* 01111110 */ /* - * 233 0xe9 '' + * 233 0xe9 '�' */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ @@ -2841,7 +2841,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 234 0xea '' + * 234 0xea '�' */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ @@ -2853,7 +2853,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 235 0xeb '' + * 235 0xeb '�' */ 0x0e, /* 00001110 */ 0x18, /* 00011000 */ @@ -2865,7 +2865,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 236 0xec '' + * 236 0xec '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2877,7 +2877,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 237 0xed '' + * 237 0xed '�' */ 0x06, /* 00000110 */ 0x0c, /* 00001100 */ @@ -2889,7 +2889,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xc0, /* 11000000 */ /* - * 238 0xee '' + * 238 0xee '�' */ 0x1e, /* 00011110 */ 0x30, /* 00110000 */ @@ -2901,7 +2901,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 239 0xef '' + * 239 0xef '�' */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ @@ -2913,7 +2913,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 240 0xf0 '' + * 240 0xf0 '�' */ 0x00, /* 00000000 */ 0xfe, /* 11111110 */ @@ -2925,7 +2925,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 241 0xf1 '' + * 241 0xf1 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2937,7 +2937,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 242 0xf2 '' + * 242 0xf2 '�' */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ @@ -2949,7 +2949,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 243 0xf3 '' + * 243 0xf3 '�' */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ @@ -2961,7 +2961,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 244 0xf4 '' + * 244 0xf4 '�' */ 0x0e, /* 00001110 */ 0x1b, /* 00011011 */ @@ -2973,7 +2973,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 245 0xf5 '' + * 245 0xf5 '�' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2985,7 +2985,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x70, /* 01110000 */ /* - * 246 0xf6 '' + * 246 0xf6 '�' */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ @@ -2997,7 +2997,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 247 0xf7 '' + * 247 0xf7 '�' */ 0x00, /* 00000000 */ 0x76, /* 01110110 */ @@ -3009,7 +3009,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 248 0xf8 '' + * 248 0xf8 '�' */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ @@ -3021,7 +3021,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 249 0xf9 '' + * 249 0xf9 '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -3033,7 +3033,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 250 0xfa '' + * 250 0xfa '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -3045,7 +3045,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 251 0xfb '' + * 251 0xfb '�' */ 0x0f, /* 00001111 */ 0x0c, /* 00001100 */ @@ -3057,7 +3057,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x1c, /* 00011100 */ /* - * 252 0xfc '' + * 252 0xfc '�' */ 0x6c, /* 01101100 */ 0x36, /* 00110110 */ @@ -3069,7 +3069,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 253 0xfd '' + * 253 0xfd '�' */ 0x78, /* 01111000 */ 0x0c, /* 00001100 */ @@ -3081,7 +3081,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 254 0xfe '' + * 254 0xfe '�' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -3109,7 +3109,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { /* ---- Character */ -/*! +/* ! \brief Global cache for 8x8 pixel font textures created at runtime. */ static SDL_Texture *SDLTest_CharTextureCache[256]; diff --git a/src/test/SDL_test_fuzzer.c b/src/test/SDL_test_fuzzer.c index 8a27fd011..d090c150c 100644 --- a/src/test/SDL_test_fuzzer.c +++ b/src/test/SDL_test_fuzzer.c @@ -173,7 +173,7 @@ SDLTest_RandomIntegerInRange(Sint32 pMin, Sint32 pMax) return (Sint32)((number % ((max + 1) - min)) + min); } -/*! +/* ! * Generates a unsigned boundary value between the given boundaries. * Boundary values are inclusive. See the examples below. * If boundary2 < boundary1, the values are swapped. @@ -303,7 +303,7 @@ SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool v validDomain); } -/*! +/* ! * Generates a signed boundary value between the given boundaries. * Boundary values are inclusive. See the examples below. * If boundary2 < boundary1, the values are swapped. diff --git a/src/test/SDL_test_harness.c b/src/test/SDL_test_harness.c index 291874566..1bfe9c281 100644 --- a/src/test/SDL_test_harness.c +++ b/src/test/SDL_test_harness.c @@ -37,7 +37,7 @@ const char *SDLTest_LogSummaryFormat = "%s Summary: Total=%d Passed=%d Failed=%d /* Final result message format */ const char *SDLTest_FinalResultFormat = ">>> %s '%s': %s\n"; -/*! \brief Timeout for single test case execution */ +/* ! \brief Timeout for single test case execution */ static Uint32 SDLTest_TestCaseTimeout = 3600; /** @@ -109,17 +109,17 @@ SDLTest_GenerateExecKey(char *runSeed, char *suiteName, char *testName, int iter Uint32 entireStringLength; char *buffer; - if (runSeed == NULL || SDL_strlen(runSeed)==0) { + if (runSeed == NULL || runSeed[0] == '\0') { SDLTest_LogError("Invalid runSeed string."); return -1; } - if (suiteName == NULL || SDL_strlen(suiteName)==0) { + if (suiteName == NULL || suiteName[0] == '\0') { SDLTest_LogError("Invalid suiteName string."); return -1; } - if (testName == NULL || SDL_strlen(testName)==0) { + if (testName == NULL || testName[0] == '\0') { SDLTest_LogError("Invalid testName string."); return -1; } @@ -399,7 +399,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user } /* Generate run see if we don't have one already */ - if (userRunSeed == NULL || SDL_strlen(userRunSeed) == 0) { + if (userRunSeed == NULL || userRunSeed[0] == '\0') { runSeed = SDLTest_GenerateRunSeed(16); if (runSeed == NULL) { SDLTest_LogError("Generating a random seed failed"); @@ -422,7 +422,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user SDLTest_Log("::::: Test Run /w seed '%s' started\n", runSeed); /* Initialize filtering */ - if (filter != NULL && SDL_strlen(filter) > 0) { + if (filter != NULL && filter[0] != '\0') { /* Loop over all suites to check if we have a filter match */ suiteCounter = 0; while (testSuites[suiteCounter] && suiteFilter == 0) { @@ -521,7 +521,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user suiteCounter, testCounter, currentTestName); - if (testCase->description != NULL && SDL_strlen(testCase->description)>0) { + if (testCase->description != NULL && testCase->description[0] != '\0') { SDLTest_Log("Test Description: '%s'", (testCase->description) ? testCase->description : SDLTest_InvalidNameFormat); } diff --git a/src/test/SDL_test_log.c b/src/test/SDL_test_log.c index c854c0f7d..caf3ddde4 100644 --- a/src/test/SDL_test_log.c +++ b/src/test/SDL_test_log.c @@ -39,7 +39,7 @@ #include "SDL_test.h" -/*! +/* ! * Converts unix timestamp to its ascii representation in localtime * * Note: Uses a static buffer internally, so the return value diff --git a/src/thread/SDL_systhread.h b/src/thread/SDL_systhread.h index 738ea27b0..36898f389 100644 --- a/src/thread/SDL_systhread.h +++ b/src/thread/SDL_systhread.h @@ -26,6 +26,7 @@ #define _SDL_systhread_h #include "SDL_thread.h" +#include "SDL_thread_c.h" /* This function creates a thread, passing args to SDL_RunThread(), saves a system-dependent thread id in thread->id, and returns 0 diff --git a/src/thread/SDL_thread.c b/src/thread/SDL_thread.c index 5eaed0c0c..4b070dadc 100644 --- a/src/thread/SDL_thread.c +++ b/src/thread/SDL_thread.c @@ -125,6 +125,7 @@ SDL_Generic_GetTLSData() SDL_TLSEntry *entry; SDL_TLSData *storage = NULL; +#if !SDL_THREADS_DISABLED if (!SDL_generic_TLS_mutex) { static SDL_SpinLock tls_lock; SDL_AtomicLock(&tls_lock); @@ -139,6 +140,7 @@ SDL_Generic_GetTLSData() } SDL_AtomicUnlock(&tls_lock); } +#endif /* SDL_THREADS_DISABLED */ SDL_MemoryBarrierAcquire(); SDL_LockMutex(SDL_generic_TLS_mutex); @@ -148,7 +150,9 @@ SDL_Generic_GetTLSData() break; } } +#if !SDL_THREADS_DISABLED SDL_UnlockMutex(SDL_generic_TLS_mutex); +#endif return storage; } diff --git a/src/thread/SDL_thread_c.h b/src/thread/SDL_thread_c.h index 90d9b57ca..2a20b4d59 100644 --- a/src/thread/SDL_thread_c.h +++ b/src/thread/SDL_thread_c.h @@ -23,6 +23,8 @@ #ifndef _SDL_thread_c_h #define _SDL_thread_c_h +#include "SDL_thread.h" + /* Need the definitions of SYS_ThreadHandle */ #if SDL_THREADS_DISABLED #include "generic/SDL_systhread_c.h" diff --git a/src/thread/pthread/SDL_syssem.c b/src/thread/pthread/SDL_syssem.c index 4acd6bfb5..e1613fc30 100644 --- a/src/thread/pthread/SDL_syssem.c +++ b/src/thread/pthread/SDL_syssem.c @@ -156,10 +156,10 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) #else end = SDL_GetTicks() + timeout; while ((retval = SDL_SemTryWait(sem)) == SDL_MUTEX_TIMEDOUT) { - if ((SDL_GetTicks() - end) >= 0) { + if (SDL_TICKS_PASSED(SDL_GetTicks(), end)) { break; } - SDL_Delay(0); + SDL_Delay(1); } #endif /* HAVE_SEM_TIMEDWAIT */ diff --git a/src/thread/windows/SDL_systhread.c b/src/thread/windows/SDL_systhread.c index 6cf826ec7..06e23abd0 100644 --- a/src/thread/windows/SDL_systhread.c +++ b/src/thread/windows/SDL_systhread.c @@ -116,8 +116,8 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args) int SDL_SYS_CreateThread(SDL_Thread * thread, void *args) { - pfnSDL_CurrentBeginThread pfnBeginThread = _beginthreadex; - pfnSDL_CurrentEndThread pfnEndThread = _endthreadex; + pfnSDL_CurrentBeginThread pfnBeginThread = (pfnSDL_CurrentBeginThread)_beginthreadex; + pfnSDL_CurrentEndThread pfnEndThread = (pfnSDL_CurrentEndThread)_endthreadex; #endif /* SDL_PASSED_BEGINTHREAD_ENDTHREAD */ pThreadStartParms pThreadParms = (pThreadStartParms) SDL_malloc(sizeof(tThreadStartParms)); @@ -145,7 +145,9 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args) return 0; } +#if 0 /* !!! FIXME: revisit this later. See https://bugzilla.libsdl.org/show_bug.cgi?id=2089 */ #ifdef _MSC_VER +#pragma warning(disable : 4733) #pragma pack(push,8) typedef struct tagTHREADNAME_INFO { @@ -155,28 +157,46 @@ typedef struct tagTHREADNAME_INFO DWORD dwFlags; /* reserved for future use, must be zero */ } THREADNAME_INFO; #pragma pack(pop) + +static EXCEPTION_DISPOSITION +ignore_exception(void *a, void *b, void *c, void *d) +{ + return ExceptionContinueExecution; +} +#endif #endif void SDL_SYS_SetupThread(const char *name) { if (name != NULL) { - #if 0 /* !!! FIXME: __except needs C runtime, which we don't link against. */ - #ifdef _MSC_VER /* !!! FIXME: can we do SEH on other compilers yet? */ - /* This magic tells the debugger to name a thread if it's listening. */ + #if 0 /* !!! FIXME: revisit this later. See https://bugzilla.libsdl.org/show_bug.cgi?id=2089 */ + #if (defined(_MSC_VER) && defined(_M_IX86)) + /* This magic tells the debugger to name a thread if it's listening. + The inline asm sets up SEH (__try/__except) without C runtime + support. See Microsoft Systems Journal, January 1997: + http://www.microsoft.com/msj/0197/exception/exception.aspx */ + INT_PTR handler = (INT_PTR) ignore_exception; THREADNAME_INFO inf; + inf.dwType = 0x1000; inf.szName = name; inf.dwThreadID = (DWORD) -1; inf.dwFlags = 0; - __try - { - RaiseException(0x406D1388, 0, sizeof(inf)/sizeof(DWORD), (DWORD*)&inf); + __asm { /* set up SEH */ + push handler + push fs:[0] + mov fs:[0],esp } - __except(EXCEPTION_CONTINUE_EXECUTION) - { - /* The program itself should ignore this bogus exception. */ + + /* The program itself should ignore this bogus exception. */ + RaiseException(0x406D1388, 0, sizeof(inf)/sizeof(DWORD), (DWORD*)&inf); + + __asm { /* tear down SEH. */ + mov eax,[esp] + mov fs:[0], eax + add esp, 8 } #endif #endif diff --git a/src/thread/windows/SDL_systls.c b/src/thread/windows/SDL_systls.c index 0ece77dd0..90941ee62 100644 --- a/src/thread/windows/SDL_systls.c +++ b/src/thread/windows/SDL_systls.c @@ -20,13 +20,13 @@ */ #include "SDL_config.h" -#include "SDL_thread.h" -#include "../SDL_thread_c.h" #if SDL_THREAD_WINDOWS #include "../../core/windows/SDL_windows.h" +#include "SDL_thread.h" +#include "../SDL_thread_c.h" static DWORD thread_local_storage = TLS_OUT_OF_INDEXES; static SDL_bool generic_local_storage = SDL_FALSE; diff --git a/src/timer/SDL_timer.c b/src/timer/SDL_timer.c index 5b6550c1c..2980f4dc7 100644 --- a/src/timer/SDL_timer.c +++ b/src/timer/SDL_timer.c @@ -26,8 +26,6 @@ #include "SDL_cpuinfo.h" #include "SDL_thread.h" -extern void SDL_StartTicks(void); - /* #define DEBUG_TIMERS */ typedef struct _SDL_Timer @@ -72,17 +70,6 @@ typedef struct { static SDL_TimerData SDL_timer_data; -static Uint32 ticks_started = 0; - -void -SDL_InitTicks(void) -{ - if (!ticks_started) { - SDL_StartTicks(); - ticks_started = 1; - } -} - /* The idea here is that any thread might add a timer, but a single * thread manages the active timer queue, sorted by scheduling time. * diff --git a/src/timer/beos/SDL_systimer.c b/src/timer/beos/SDL_systimer.c index edaf27501..fd22e4412 100644 --- a/src/timer/beos/SDL_systimer.c +++ b/src/timer/beos/SDL_systimer.c @@ -27,10 +27,16 @@ #include "SDL_timer.h" static bigtime_t start; +static SDL_bool ticks_started = SDL_FALSE; void -SDL_StartTicks(void) +SDL_InitTicks(void) { + if (ticks_started) { + return; + } + ticks_started = SDL_TRUE; + /* Set first ticks value */ start = system_time(); } @@ -38,6 +44,10 @@ SDL_StartTicks(void) Uint32 SDL_GetTicks(void) { + if (!ticks_started) { + SDL_InitTicks(); + } + return ((system_time() - start) / 1000); } diff --git a/src/timer/dummy/SDL_systimer.c b/src/timer/dummy/SDL_systimer.c index 2b5a9f8e3..387675db1 100644 --- a/src/timer/dummy/SDL_systimer.c +++ b/src/timer/dummy/SDL_systimer.c @@ -24,14 +24,24 @@ #include "SDL_timer.h" +static SDL_bool ticks_started = SDL_FALSE; + void -SDL_StartTicks(void) +SDL_InitTicks(void) { + if (ticks_started) { + return; + } + ticks_started = SDL_TRUE; } Uint32 SDL_GetTicks(void) { + if (!ticks_started) { + SDL_InitTicks(); + } + SDL_Unsupported(); return 0; } diff --git a/src/timer/psp/SDL_systimer.c b/src/timer/psp/SDL_systimer.c index 59bb4df1c..61c4690aa 100644 --- a/src/timer/psp/SDL_systimer.c +++ b/src/timer/psp/SDL_systimer.c @@ -29,14 +29,24 @@ #include static struct timeval start; +static SDL_bool ticks_started = SDL_FALSE; -void SDL_StartTicks(void) +void SDL_InitTicks(void) { + if (ticks_started) { + return; + } + ticks_started = SDL_TRUE; + gettimeofday(&start, NULL); } Uint32 SDL_GetTicks(void) { + if (!ticks_started) { + SDL_InitTicks(); + } + struct timeval now; Uint32 ticks; diff --git a/src/timer/unix/SDL_systimer.c b/src/timer/unix/SDL_systimer.c index 596d749ab..88a40ba51 100644 --- a/src/timer/unix/SDL_systimer.c +++ b/src/timer/unix/SDL_systimer.c @@ -56,10 +56,16 @@ mach_timebase_info_data_t mach_base_info; #endif static SDL_bool has_monotonic_time = SDL_FALSE; static struct timeval start_tv; +static SDL_bool ticks_started = SDL_FALSE; void -SDL_StartTicks(void) +SDL_InitTicks(void) { + if (ticks_started) { + return; + } + ticks_started = SDL_TRUE; + /* Set first ticks value */ #if HAVE_CLOCK_GETTIME if (clock_gettime(CLOCK_MONOTONIC, &start_ts) == 0) { @@ -81,6 +87,10 @@ Uint32 SDL_GetTicks(void) { Uint32 ticks; + if (!ticks_started) { + SDL_InitTicks(); + } + if (has_monotonic_time) { #if HAVE_CLOCK_GETTIME struct timespec now; @@ -106,6 +116,10 @@ Uint64 SDL_GetPerformanceCounter(void) { Uint64 ticks; + if (!ticks_started) { + SDL_InitTicks(); + } + if (has_monotonic_time) { #if HAVE_CLOCK_GETTIME struct timespec now; @@ -131,6 +145,10 @@ SDL_GetPerformanceCounter(void) Uint64 SDL_GetPerformanceFrequency(void) { + if (!ticks_started) { + SDL_InitTicks(); + } + if (has_monotonic_time) { #if HAVE_CLOCK_GETTIME return 1000000000; @@ -140,9 +158,9 @@ SDL_GetPerformanceFrequency(void) freq /= mach_base_info.numer; return freq; #endif - } else { - return 1000000; - } + } + + return 1000000; } void diff --git a/src/timer/windows/SDL_systimer.c b/src/timer/windows/SDL_systimer.c index f71aecf35..a3055218c 100644 --- a/src/timer/windows/SDL_systimer.c +++ b/src/timer/windows/SDL_systimer.c @@ -31,6 +31,7 @@ /* The first (low-resolution) ticks value of the application */ static DWORD start; +static BOOL ticks_started = FALSE; #ifndef USE_GETTICKCOUNT /* Store if a high-resolution performance counter exists on the system */ @@ -78,8 +79,13 @@ SDL_TimerResolutionChanged(void *userdata, const char *name, const char *oldValu #endif /* ifndef __WINRT__ */ void -SDL_StartTicks(void) +SDL_InitTicks(void) { + if (ticks_started) { + return; + } + ticks_started = TRUE; + /* Set first ticks value */ #ifdef USE_GETTICKCOUNT start = GetTickCount(); @@ -115,6 +121,10 @@ SDL_GetTicks(void) LARGE_INTEGER hires_now; #endif + if (!ticks_started) { + SDL_InitTicks(); + } + #ifdef USE_GETTICKCOUNT now = GetTickCount(); #else diff --git a/src/video/SDL_RLEaccel.c b/src/video/SDL_RLEaccel.c index 25ecd4556..6db43b092 100644 --- a/src/video/SDL_RLEaccel.c +++ b/src/video/SDL_RLEaccel.c @@ -1558,10 +1558,8 @@ SDL_UnRLESurface(SDL_Surface * surface, int recode) surface->map->info.flags &= ~(SDL_COPY_RLE_COLORKEY | SDL_COPY_RLE_ALPHAKEY); - if (surface->map->data) { - SDL_free(surface->map->data); - surface->map->data = NULL; - } + SDL_free(surface->map->data); + surface->map->data = NULL; } } diff --git a/src/video/SDL_blit_A.c b/src/video/SDL_blit_A.c index 3fb89c061..46d46136f 100644 --- a/src/video/SDL_blit_A.c +++ b/src/video/SDL_blit_A.c @@ -334,18 +334,16 @@ BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info) Uint32 *dstp = (Uint32 *) info->dst; int dstskip = info->dst_skip >> 2; SDL_PixelFormat *sf = info->src_fmt; - Uint32 chanmask = sf->Rmask | sf->Gmask | sf->Bmask; Uint32 amask = sf->Amask; Uint32 ashift = sf->Ashift; - Uint64 multmask; + Uint64 multmask, multmask2; - __m64 src1, dst1, mm_alpha, mm_zero, dmask; + __m64 src1, dst1, mm_alpha, mm_zero, mm_alpha2; mm_zero = _mm_setzero_si64(); /* 0 -> mm_zero */ - multmask = 0xFFFF; - multmask <<= (ashift * 2); - multmask = ~multmask; - dmask = *(__m64 *) & multmask; /* dst alpha mask -> dmask */ + multmask = 0x00FF; + multmask <<= (ashift * 2); + multmask2 = 0x00FF00FF00FF00FF; while (height--) { /* *INDENT-OFF* */ @@ -354,27 +352,28 @@ BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info) if (alpha == 0) { /* do nothing */ } else if (alpha == amask) { - /* opaque alpha -- copy RGB, keep dst alpha */ - *dstp = (*srcp & chanmask) | (*dstp & ~chanmask); + *dstp = *srcp; } else { - src1 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src1 (0000ARGB)*/ + src1 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src1 (0000ARGB) */ src1 = _mm_unpacklo_pi8(src1, mm_zero); /* 0A0R0G0B -> src1 */ - dst1 = _mm_cvtsi32_si64(*dstp); /* dst(ARGB) -> dst1 (0000ARGB)*/ + dst1 = _mm_cvtsi32_si64(*dstp); /* dst(ARGB) -> dst1 (0000ARGB) */ dst1 = _mm_unpacklo_pi8(dst1, mm_zero); /* 0A0R0G0B -> dst1 */ mm_alpha = _mm_cvtsi32_si64(alpha); /* alpha -> mm_alpha (0000000A) */ mm_alpha = _mm_srli_si64(mm_alpha, ashift); /* mm_alpha >> ashift -> mm_alpha(0000000A) */ mm_alpha = _mm_unpacklo_pi16(mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */ - mm_alpha = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha */ - mm_alpha = _mm_and_si64(mm_alpha, dmask); /* 000A0A0A -> mm_alpha, preserve dst alpha on add */ + mm_alpha2 = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha2 */ + mm_alpha = _mm_or_si64(mm_alpha2, *(__m64 *) & multmask); /* 0F0A0A0A -> mm_alpha */ + mm_alpha2 = _mm_xor_si64(mm_alpha2, *(__m64 *) & multmask2); /* 255 - mm_alpha -> mm_alpha */ /* blend */ - src1 = _mm_sub_pi16(src1, dst1);/* src1 - dst1 -> src1 */ - src1 = _mm_mullo_pi16(src1, mm_alpha); /* (src1 - dst1) * alpha -> src1 */ - src1 = _mm_srli_pi16(src1, 8); /* src1 >> 8 -> src1(000R0G0B) */ - dst1 = _mm_add_pi8(src1, dst1); /* src1 + dst1 -> dst1(0A0R0G0B) */ - dst1 = _mm_packs_pu16(dst1, mm_zero); /* 0000ARGB -> dst1 */ + src1 = _mm_mullo_pi16(src1, mm_alpha); + src1 = _mm_srli_pi16(src1, 8); + dst1 = _mm_mullo_pi16(dst1, mm_alpha2); + dst1 = _mm_srli_pi16(dst1, 8); + dst1 = _mm_add_pi16(src1, dst1); + dst1 = _mm_packs_pu16(dst1, mm_zero); *dstp = _mm_cvtsi64_si32(dst1); /* dst1 -> pixel */ } @@ -481,23 +480,24 @@ BlitRGBtoRGBPixelAlpha(SDL_BlitInfo * info) compositioning used (>>8 instead of /255) doesn't handle it correctly. Also special-case alpha=0 for speed? Benchmark this! */ - if(alpha) { - if(alpha == SDL_ALPHA_OPAQUE) { - *dstp = (s & 0x00ffffff) | (*dstp & 0xff000000); + if (alpha) { + if (alpha == SDL_ALPHA_OPAQUE) { + *dstp = *srcp; } else { /* * take out the middle component (green), and process * the other two in parallel. One multiply less. */ d = *dstp; - dalpha = d & 0xff000000; + dalpha = d >> 24; s1 = s & 0xff00ff; d1 = d & 0xff00ff; d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff; s &= 0xff00; d &= 0xff00; d = (d + ((s - d) * alpha >> 8)) & 0xff00; - *dstp = d1 | d | dalpha; + dalpha = alpha + (dalpha * (alpha ^ 0xFF) >> 8); + *dstp = d1 | d | (dalpha << 24); } } ++srcp; @@ -521,18 +521,16 @@ BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info) Uint32 *dstp = (Uint32 *) info->dst; int dstskip = info->dst_skip >> 2; SDL_PixelFormat *sf = info->src_fmt; - Uint32 chanmask = sf->Rmask | sf->Gmask | sf->Bmask; Uint32 amask = sf->Amask; Uint32 ashift = sf->Ashift; - Uint64 multmask; + Uint64 multmask, multmask2; - __m64 src1, dst1, mm_alpha, mm_zero, dmask; + __m64 src1, dst1, mm_alpha, mm_zero, mm_alpha2; mm_zero = _mm_setzero_si64(); /* 0 -> mm_zero */ - multmask = 0xFFFF; + multmask = 0x00FF; multmask <<= (ashift * 2); - multmask = ~multmask; - dmask = *(__m64 *) & multmask; /* dst alpha mask -> dmask */ + multmask2 = 0x00FF00FF00FF00FF; while (height--) { /* *INDENT-OFF* */ @@ -546,27 +544,29 @@ BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info) if (alpha == 0) { /* do nothing */ } else if (alpha == amask) { - /* copy RGB, keep dst alpha */ - *dstp = (*srcp & chanmask) | (*dstp & ~chanmask); + *dstp = *srcp; } else { - src1 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src1 (0000ARGB)*/ + src1 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src1 (0000ARGB) */ src1 = _mm_unpacklo_pi8(src1, mm_zero); /* 0A0R0G0B -> src1 */ - dst1 = _mm_cvtsi32_si64(*dstp); /* dst(ARGB) -> dst1 (0000ARGB)*/ + dst1 = _mm_cvtsi32_si64(*dstp); /* dst(ARGB) -> dst1 (0000ARGB) */ dst1 = _mm_unpacklo_pi8(dst1, mm_zero); /* 0A0R0G0B -> dst1 */ mm_alpha = _mm_cvtsi32_si64(alpha); /* alpha -> mm_alpha (0000000A) */ mm_alpha = _mm_srli_si64(mm_alpha, ashift); /* mm_alpha >> ashift -> mm_alpha(0000000A) */ mm_alpha = _mm_unpacklo_pi16(mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */ - mm_alpha = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha */ - mm_alpha = _mm_and_si64(mm_alpha, dmask); /* 000A0A0A -> mm_alpha, preserve dst alpha on add */ + mm_alpha2 = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha2 */ + mm_alpha = _mm_or_si64(mm_alpha2, *(__m64 *) & multmask); /* 0F0A0A0A -> mm_alpha */ + mm_alpha2 = _mm_xor_si64(mm_alpha2, *(__m64 *) & multmask2); /* 255 - mm_alpha -> mm_alpha */ + /* blend */ - src1 = _mm_sub_pi16(src1, dst1);/* src - dst -> src1 */ - src1 = _mm_mullo_pi16(src1, mm_alpha); /* (src - dst) * alpha -> src1 */ - src1 = _mm_srli_pi16(src1, 8); /* src1 >> 8 -> src1(000R0G0B) */ - dst1 = _mm_add_pi8(src1, dst1); /* src1 + dst1(dst) -> dst1(0A0R0G0B) */ - dst1 = _mm_packs_pu16(dst1, mm_zero); /* 0000ARGB -> dst1 */ + src1 = _mm_mullo_pi16(src1, mm_alpha); + src1 = _mm_srli_pi16(src1, 8); + dst1 = _mm_mullo_pi16(dst1, mm_alpha2); + dst1 = _mm_srli_pi16(dst1, 8); + dst1 = _mm_add_pi16(src1, dst1); + dst1 = _mm_packs_pu16(dst1, mm_zero); *dstp = _mm_cvtsi64_si32(dst1); /* dst1 -> pixel */ } diff --git a/src/video/SDL_blit_copy.c b/src/video/SDL_blit_copy.c index 6d286c31f..80519e099 100644 --- a/src/video/SDL_blit_copy.c +++ b/src/video/SDL_blit_copy.c @@ -27,7 +27,7 @@ #ifdef __SSE__ /* This assumes 16-byte aligned src and dst */ -static __inline__ void +static SDL_INLINE void SDL_memcpySSE(Uint8 * dst, const Uint8 * src, int len) { int i; @@ -56,7 +56,7 @@ SDL_memcpySSE(Uint8 * dst, const Uint8 * src, int len) #ifdef _MSC_VER #pragma warning(disable:4799) #endif -static __inline__ void +static SDL_INLINE void SDL_memcpyMMX(Uint8 * dst, const Uint8 * src, int len) { const int remain = (len & 63); diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c index df43ed0ce..9244b28db 100644 --- a/src/video/SDL_bmp.c +++ b/src/video/SDL_bmp.c @@ -97,23 +97,23 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) /* The Win32 BMP file header (14 bytes) */ char magic[2]; - /*Uint32 bfSize = 0;*/ - /*Uint16 bfReserved1 = 0;*/ - /*Uint16 bfReserved2 = 0;*/ + /* Uint32 bfSize = 0; */ + /* Uint16 bfReserved1 = 0; */ + /* Uint16 bfReserved2 = 0; */ Uint32 bfOffBits = 0; /* The Win32 BITMAPINFOHEADER struct (40 bytes) */ Uint32 biSize = 0; Sint32 biWidth = 0; Sint32 biHeight = 0; - /*Uint16 biPlanes = 0;*/ + /* Uint16 biPlanes = 0; */ Uint16 biBitCount = 0; Uint32 biCompression = 0; - /*Uint32 biSizeImage = 0;*/ - /*Sint32 biXPelsPerMeter = 0;*/ - /*Sint32 biYPelsPerMeter = 0;*/ + /* Uint32 biSizeImage = 0; */ + /* Sint32 biXPelsPerMeter = 0; */ + /* Sint32 biYPelsPerMeter = 0; */ Uint32 biClrUsed = 0; - /*Uint32 biClrImportant = 0;*/ + /* Uint32 biClrImportant = 0; */ /* Make sure we are passed a valid data source */ surface = NULL; @@ -136,9 +136,9 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) was_error = SDL_TRUE; goto done; } - /*bfSize =*/ SDL_ReadLE32(src); - /*bfReserved1 =*/ SDL_ReadLE16(src); - /*bfReserved2 =*/ SDL_ReadLE16(src); + /* bfSize = */ SDL_ReadLE32(src); + /* bfReserved1 = */ SDL_ReadLE16(src); + /* bfReserved2 = */ SDL_ReadLE16(src); bfOffBits = SDL_ReadLE32(src); /* Read the Win32 BITMAPINFOHEADER */ @@ -146,20 +146,20 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) if (biSize == 12) { biWidth = (Uint32) SDL_ReadLE16(src); biHeight = (Uint32) SDL_ReadLE16(src); - /*biPlanes =*/ SDL_ReadLE16(src); + /* biPlanes = */ SDL_ReadLE16(src); biBitCount = SDL_ReadLE16(src); biCompression = BI_RGB; } else { biWidth = SDL_ReadLE32(src); biHeight = SDL_ReadLE32(src); - /*biPlanes =*/ SDL_ReadLE16(src); + /* biPlanes = */ SDL_ReadLE16(src); biBitCount = SDL_ReadLE16(src); biCompression = SDL_ReadLE32(src); - /*biSizeImage =*/ SDL_ReadLE32(src); - /*biXPelsPerMeter =*/ SDL_ReadLE32(src); - /*biYPelsPerMeter =*/ SDL_ReadLE32(src); + /* biSizeImage = */ SDL_ReadLE32(src); + /* biXPelsPerMeter = */ SDL_ReadLE32(src); + /* biYPelsPerMeter = */ SDL_ReadLE32(src); biClrUsed = SDL_ReadLE32(src); - /*biClrImportant =*/ SDL_ReadLE32(src); + /* biClrImportant = */ SDL_ReadLE32(src); } if (biHeight < 0) { topDown = SDL_TRUE; @@ -398,9 +398,7 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) if (src) { SDL_RWseek(src, fp_offset, RW_SEEK_SET); } - if (surface) { - SDL_FreeSurface(surface); - } + SDL_FreeSurface(surface); surface = NULL; } if (freesrc && src) { diff --git a/src/video/SDL_clipboard.c b/src/video/SDL_clipboard.c index 83c2e346e..8c0626ef2 100644 --- a/src/video/SDL_clipboard.c +++ b/src/video/SDL_clipboard.c @@ -35,9 +35,7 @@ SDL_SetClipboardText(const char *text) if (_this->SetClipboardText) { return _this->SetClipboardText(_this, text); } else { - if (_this->clipboard_text) { - SDL_free(_this->clipboard_text); - } + SDL_free(_this->clipboard_text); _this->clipboard_text = SDL_strdup(text); return 0; } @@ -67,7 +65,7 @@ SDL_HasClipboardText(void) if (_this->HasClipboardText) { return _this->HasClipboardText(_this); } else { - if ((_this->clipboard_text) && (SDL_strlen(_this->clipboard_text)>0)) { + if (_this->clipboard_text && _this->clipboard_text[0] != '\0') { return SDL_TRUE; } else { return SDL_FALSE; diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c new file mode 100644 index 000000000..ccfb92e18 --- /dev/null +++ b/src/video/SDL_egl.c @@ -0,0 +1,431 @@ +/* + * Simple DirectMedia Layer + * Copyright (C) 1997-2013 Sam Lantinga + * + * 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. + */ +#include "SDL_config.h" + +#if SDL_VIDEO_OPENGL_EGL + +#include "SDL_sysvideo.h" +#include "SDL_egl.h" + + +#if SDL_VIDEO_DRIVER_RPI +/* Raspbian places the OpenGL ES/EGL binaries in a non standard path */ +#define DEFAULT_EGL "/opt/vc/lib/libEGL.so" +#define DEFAULT_OGL_ES2 "/opt/vc/lib/libGLESv2.so" +#define DEFAULT_OGL_ES_PVR "/opt/vc/lib/libGLES_CM.so" +#define DEFAULT_OGL_ES "/opt/vc/lib/libGLESv1_CM.so" + +#elif SDL_VIDEO_DRIVER_ANDROID +/* Android */ +#define DEFAULT_EGL "libEGL.so" +#define DEFAULT_OGL_ES2 "libGLESv2.so" +#define DEFAULT_OGL_ES_PVR "libGLES_CM.so" +#define DEFAULT_OGL_ES "libGLESv1_CM.so" + +#else +/* Desktop Linux */ +#define DEFAULT_EGL "libEGL.so.1" +#define DEFAULT_OGL_ES2 "libGLESv2.so.2" +#define DEFAULT_OGL_ES_PVR "libGLES_CM.so.1" +#define DEFAULT_OGL_ES "libGLESv1_CM.so.1" +#endif /* SDL_VIDEO_DRIVER_RPI */ + +#define LOAD_FUNC(NAME) \ +*((void**)&_this->egl_data->NAME) = dlsym(dll_handle, #NAME); \ +if (!_this->egl_data->NAME) \ +{ \ + return SDL_SetError("Could not retrieve EGL function " #NAME); \ +} + +/* EGL implementation of SDL OpenGL ES support */ + +void * +SDL_EGL_GetProcAddress(_THIS, const char *proc) +{ + static char procname[1024]; + void *handle; + void *retval; + + /* eglGetProcAddress is busted on Android http://code.google.com/p/android/issues/detail?id=7681 */ +#if !defined(SDL_VIDEO_DRIVER_ANDROID) + handle = _this->egl_data->egl_dll_handle; + if (_this->egl_data->eglGetProcAddress) { + retval = _this->egl_data->eglGetProcAddress(proc); + if (retval) { + return retval; + } + } +#endif + + handle = _this->gl_config.dll_handle; + #if defined(__OpenBSD__) && !defined(__ELF__) + #undef dlsym(x,y); + #endif + retval = dlsym(handle, proc); + if (!retval && strlen(proc) <= 1022) { + procname[0] = '_'; + strcpy(procname + 1, proc); + retval = dlsym(handle, procname); + } + return retval; +} + +void +SDL_EGL_UnloadLibrary(_THIS) +{ + if (_this->egl_data) { + if (_this->egl_data->egl_display) { + _this->egl_data->eglTerminate(_this->egl_data->egl_display); + _this->egl_data->egl_display = NULL; + } + + if (_this->gl_config.dll_handle) { + dlclose(_this->gl_config.dll_handle); + _this->gl_config.dll_handle = NULL; + } + if (_this->egl_data->egl_dll_handle) { + dlclose(_this->egl_data->egl_dll_handle); + _this->egl_data->egl_dll_handle = NULL; + } + + SDL_free(_this->egl_data); + _this->egl_data = NULL; + } +} + +int +SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_display) +{ + void *dll_handle, *egl_dll_handle; /* The naming is counter intuitive, but hey, I just work here -- Gabriel */ + char *path; + int dlopen_flags; + + if (_this->egl_data) { + return SDL_SetError("OpenGL ES context already created"); + } + + _this->egl_data = (struct SDL_EGL_VideoData *) SDL_calloc(1, sizeof(SDL_EGL_VideoData)); + if (!_this->egl_data) { + return SDL_OutOfMemory(); + } + +#ifdef RTLD_GLOBAL + dlopen_flags = RTLD_LAZY | RTLD_GLOBAL; +#else + dlopen_flags = RTLD_LAZY; +#endif + + /* A funny thing, loading EGL.so first does not work on the Raspberry, so we load libGL* first */ + path = getenv("SDL_VIDEO_GL_DRIVER"); + egl_dll_handle = dlopen(path, dlopen_flags); + if ((path == NULL) | (egl_dll_handle == NULL)) { + if (_this->gl_config.major_version > 1) { + path = DEFAULT_OGL_ES2; + egl_dll_handle = dlopen(path, dlopen_flags); + } else { + path = DEFAULT_OGL_ES; + egl_dll_handle = dlopen(path, dlopen_flags); + if (egl_dll_handle == NULL) { + path = DEFAULT_OGL_ES_PVR; + egl_dll_handle = dlopen(path, dlopen_flags); + } + } + } + _this->egl_data->egl_dll_handle = egl_dll_handle; + + if (egl_dll_handle == NULL) { + return SDL_SetError("Could not initialize OpenGL ES library: %s", dlerror()); + } + + /* Loading libGL* in the previous step took care of loading libEGL.so, but we future proof by double checking */ + dll_handle = dlopen(egl_path, dlopen_flags); + /* Catch the case where the application isn't linked with EGL */ + if ((dlsym(dll_handle, "eglChooseConfig") == NULL) && (egl_path == NULL)) { + dlclose(dll_handle); + path = getenv("SDL_VIDEO_EGL_DRIVER"); + if (path == NULL) { + path = DEFAULT_EGL; + } + dll_handle = dlopen(path, dlopen_flags); + } + _this->gl_config.dll_handle = dll_handle; + + if (dll_handle == NULL) { + return SDL_SetError("Could not load EGL library: %s", dlerror()); + } + + /* Load new function pointers */ + LOAD_FUNC(eglGetDisplay); + LOAD_FUNC(eglInitialize); + LOAD_FUNC(eglTerminate); + LOAD_FUNC(eglGetProcAddress); + LOAD_FUNC(eglChooseConfig); + LOAD_FUNC(eglGetConfigAttrib); + LOAD_FUNC(eglCreateContext); + LOAD_FUNC(eglDestroyContext); + LOAD_FUNC(eglCreateWindowSurface); + LOAD_FUNC(eglDestroySurface); + LOAD_FUNC(eglMakeCurrent); + LOAD_FUNC(eglSwapBuffers); + LOAD_FUNC(eglSwapInterval); + LOAD_FUNC(eglWaitNative); + LOAD_FUNC(eglWaitGL); + + _this->egl_data->egl_display = _this->egl_data->eglGetDisplay(native_display); + if (!_this->egl_data->egl_display) { + return SDL_SetError("Could not get EGL display"); + } + + if (_this->egl_data->eglInitialize(_this->egl_data->egl_display, NULL, NULL) != EGL_TRUE) { + return SDL_SetError("Could not initialize EGL"); + } + + _this->gl_config.dll_handle = dll_handle; + _this->egl_data->egl_dll_handle = egl_dll_handle; + _this->gl_config.driver_loaded = 1; + + if (path) { + strncpy(_this->gl_config.driver_path, path, sizeof(_this->gl_config.driver_path) - 1); + } else { + strcpy(_this->gl_config.driver_path, ""); + } + + /* We need to select a config here to satisfy some video backends such as X11 */ + SDL_EGL_ChooseConfig(_this); + + return 0; +} + +int +SDL_EGL_ChooseConfig(_THIS) +{ + /* 64 seems nice. */ + EGLint attribs[64]; + EGLint found_configs = 0; + int i; + + if (!_this->egl_data) { + /* The EGL library wasn't loaded, SDL_GetError() should have info */ + return -1; + } + + /* Get a valid EGL configuration */ + i = 0; + attribs[i++] = EGL_RED_SIZE; + attribs[i++] = _this->gl_config.red_size; + attribs[i++] = EGL_GREEN_SIZE; + attribs[i++] = _this->gl_config.green_size; + attribs[i++] = EGL_BLUE_SIZE; + attribs[i++] = _this->gl_config.blue_size; + + if (_this->gl_config.alpha_size) { + attribs[i++] = EGL_ALPHA_SIZE; + attribs[i++] = _this->gl_config.alpha_size; + } + + if (_this->gl_config.buffer_size) { + attribs[i++] = EGL_BUFFER_SIZE; + attribs[i++] = _this->gl_config.buffer_size; + } + + attribs[i++] = EGL_DEPTH_SIZE; + attribs[i++] = _this->gl_config.depth_size; + + if (_this->gl_config.stencil_size) { + attribs[i++] = EGL_STENCIL_SIZE; + attribs[i++] = _this->gl_config.stencil_size; + } + + if (_this->gl_config.multisamplebuffers) { + attribs[i++] = EGL_SAMPLE_BUFFERS; + attribs[i++] = _this->gl_config.multisamplebuffers; + } + + if (_this->gl_config.multisamplesamples) { + attribs[i++] = EGL_SAMPLES; + attribs[i++] = _this->gl_config.multisamplesamples; + } + + attribs[i++] = EGL_RENDERABLE_TYPE; + if (_this->gl_config.major_version == 2) { + attribs[i++] = EGL_OPENGL_ES2_BIT; + } else { + attribs[i++] = EGL_OPENGL_ES_BIT; + } + + attribs[i++] = EGL_NONE; + + if (_this->egl_data->eglChooseConfig(_this->egl_data->egl_display, + attribs, + &_this->egl_data->egl_config, 1, + &found_configs) == EGL_FALSE || + found_configs == 0) { + return SDL_SetError("Couldn't find matching EGL config"); + } + + return 0; +} + +SDL_GLContext +SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface) +{ + EGLint context_attrib_list[] = { + EGL_CONTEXT_CLIENT_VERSION, + 1, + EGL_NONE + }; + + EGLContext egl_context; + + if (!_this->egl_data) { + /* The EGL library wasn't loaded, SDL_GetError() should have info */ + return NULL; + } + + if (_this->gl_config.major_version) { + context_attrib_list[1] = _this->gl_config.major_version; + } + + egl_context = + _this->egl_data->eglCreateContext(_this->egl_data->egl_display, + _this->egl_data->egl_config, + EGL_NO_CONTEXT, context_attrib_list); + + if (egl_context == EGL_NO_CONTEXT) { + SDL_SetError("Could not create EGL context"); + return NULL; + } + + _this->egl_data->egl_swapinterval = 0; + + if (SDL_EGL_MakeCurrent(_this, egl_surface, egl_context) < 0) { + SDL_EGL_DeleteContext(_this, egl_context); + SDL_SetError("Could not make EGL context current"); + return NULL; + } + + return (SDL_GLContext) egl_context; +} + +int +SDL_EGL_MakeCurrent(_THIS, EGLSurface egl_surface, SDL_GLContext context) +{ + EGLContext egl_context = (EGLContext) context; + + if (!_this->egl_data) { + return SDL_SetError("OpenGL not initialized"); + } + + /* The android emulator crashes badly if you try to eglMakeCurrent + * with a valid context and invalid surface, so we have to check for both here. + */ + if (!egl_context || !egl_surface) { + _this->egl_data->eglMakeCurrent(_this->egl_data->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + } + else { + if (!_this->egl_data->eglMakeCurrent(_this->egl_data->egl_display, + egl_surface, egl_surface, egl_context)) { + return SDL_SetError("Unable to make EGL context current"); + } + } + + return 0; +} + +int +SDL_EGL_SetSwapInterval(_THIS, int interval) +{ + EGLBoolean status; + + if (!_this->egl_data) { + return SDL_SetError("EGL not initialized"); + } + + status = _this->egl_data->eglSwapInterval(_this->egl_data->egl_display, interval); + if (status == EGL_TRUE) { + _this->egl_data->egl_swapinterval = interval; + return 0; + } + + return SDL_SetError("Unable to set the EGL swap interval"); +} + +int +SDL_EGL_GetSwapInterval(_THIS) +{ + if (!_this->egl_data) { + return SDL_SetError("EGL not initialized"); + } + + return _this->egl_data->egl_swapinterval; +} + +void +SDL_EGL_SwapBuffers(_THIS, EGLSurface egl_surface) +{ + _this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, egl_surface); +} + +void +SDL_EGL_DeleteContext(_THIS, SDL_GLContext context) +{ + EGLContext egl_context = (EGLContext) context; + + /* Clean up GLES and EGL */ + if (!_this->egl_data) { + return; + } + + if (!egl_context && egl_context != EGL_NO_CONTEXT) { + SDL_EGL_MakeCurrent(_this, NULL, NULL); + _this->egl_data->eglDestroyContext(_this->egl_data->egl_display, egl_context); + } + + /* FIXME: This "crappy fix" comes from the X11 code, + * it's required so you can create a GLX context, destroy it and create a EGL one */ + SDL_EGL_UnloadLibrary(_this); +} + +EGLSurface * +SDL_EGL_CreateSurface(_THIS, NativeWindowType nw) +{ + return _this->egl_data->eglCreateWindowSurface( + _this->egl_data->egl_display, + _this->egl_data->egl_config, + nw, NULL); +} + +void +SDL_EGL_DestroySurface(_THIS, EGLSurface egl_surface) +{ + if (!_this->egl_data) { + return; + } + + if (egl_surface != EGL_NO_SURFACE) { + _this->egl_data->eglDestroySurface(_this->egl_data->egl_display, egl_surface); + } +} + +#endif /* SDL_VIDEO_OPENGL_EGL */ + +/* vi: set ts=4 sw=4 expandtab: */ + diff --git a/src/video/SDL_egl.h b/src/video/SDL_egl.h new file mode 100644 index 000000000..d6139058d --- /dev/null +++ b/src/video/SDL_egl.h @@ -0,0 +1,132 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ +#include "SDL_config.h" + +#ifndef _SDL_egl_h +#define _SDL_egl_h + +#if SDL_VIDEO_OPENGL_EGL + +#include + +#include +#if defined(__OpenBSD__) && !defined(__ELF__) +#define dlsym(x,y) dlsym(x, "_" y) +#endif + +#include "SDL_sysvideo.h" + +typedef struct SDL_EGL_VideoData +{ + void *egl_dll_handle; + EGLDisplay egl_display; + EGLConfig egl_config; + int egl_swapinterval; + + EGLDisplay(*eglGetDisplay) (NativeDisplayType display); + EGLBoolean(*eglInitialize) (EGLDisplay dpy, EGLint * major, + EGLint * minor); + EGLBoolean(*eglTerminate) (EGLDisplay dpy); + + void *(*eglGetProcAddress) (const char * procName); + + EGLBoolean(*eglChooseConfig) (EGLDisplay dpy, + const EGLint * attrib_list, + EGLConfig * configs, + EGLint config_size, EGLint * num_config); + + EGLContext(*eglCreateContext) (EGLDisplay dpy, + EGLConfig config, + EGLContext share_list, + const EGLint * attrib_list); + + EGLBoolean(*eglDestroyContext) (EGLDisplay dpy, EGLContext ctx); + + EGLSurface(*eglCreateWindowSurface) (EGLDisplay dpy, + EGLConfig config, + NativeWindowType window, + const EGLint * attrib_list); + EGLBoolean(*eglDestroySurface) (EGLDisplay dpy, EGLSurface surface); + + EGLBoolean(*eglMakeCurrent) (EGLDisplay dpy, EGLSurface draw, + EGLSurface read, EGLContext ctx); + + EGLBoolean(*eglSwapBuffers) (EGLDisplay dpy, EGLSurface draw); + + EGLBoolean(*eglSwapInterval) (EGLDisplay dpy, EGLint interval); + + const char *(*eglQueryString) (EGLDisplay dpy, EGLint name); + + EGLBoolean(*eglGetConfigAttrib) (EGLDisplay dpy, EGLConfig config, + EGLint attribute, EGLint * value); + + EGLBoolean(*eglWaitNative) (EGLint engine); + + EGLBoolean(*eglWaitGL)(void); +} SDL_EGL_VideoData; + +/* OpenGLES functions */ +extern int SDL_EGL_GetAttribute(_THIS, SDL_GLattr attrib, int *value); +extern int SDL_EGL_LoadLibrary(_THIS, const char *path, NativeDisplayType native_display); +extern void *SDL_EGL_GetProcAddress(_THIS, const char *proc); +extern void SDL_EGL_UnloadLibrary(_THIS); +extern int SDL_EGL_ChooseConfig(_THIS); +extern int SDL_EGL_SetSwapInterval(_THIS, int interval); +extern int SDL_EGL_GetSwapInterval(_THIS); +extern void SDL_EGL_DeleteContext(_THIS, SDL_GLContext context); +extern EGLSurface *SDL_EGL_CreateSurface(_THIS, NativeWindowType nw); +extern void SDL_EGL_DestroySurface(_THIS, EGLSurface egl_surface); + +/* These need to be wrapped to get the surface for the window by the platform GLES implementation */ +extern SDL_GLContext SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface); +extern int SDL_EGL_MakeCurrent(_THIS, EGLSurface egl_surface, SDL_GLContext context); +extern void SDL_EGL_SwapBuffers(_THIS, EGLSurface egl_surface); + +/* A few of useful macros */ + +#define SDL_EGL_SwapWindow_impl(BACKEND) void \ +BACKEND ## _GLES_SwapWindow(_THIS, SDL_Window * window) \ +{\ + SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);\ +} + +#define SDL_EGL_MakeCurrent_impl(BACKEND) int \ +BACKEND ## _GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) \ +{\ + if (window && context) { \ + return SDL_EGL_MakeCurrent(_this, ((SDL_WindowData *) window->driverdata)->egl_surface, context); \ + }\ + else {\ + return SDL_EGL_MakeCurrent(_this, NULL, NULL);\ + }\ +} + +#define SDL_EGL_CreateContext_impl(BACKEND) SDL_GLContext \ +BACKEND ## _GLES_CreateContext(_THIS, SDL_Window * window) \ +{\ + return SDL_EGL_CreateContext(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);\ +} + +#endif /* SDL_VIDEO_OPENGL_EGL */ + +#endif /* _SDL_egl_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/SDL_fillrect.c b/src/video/SDL_fillrect.c index a99371e05..d891e4e9d 100644 --- a/src/video/SDL_fillrect.c +++ b/src/video/SDL_fillrect.c @@ -36,12 +36,13 @@ c128.m128_u32[3] = color; #else #define SSE_BEGIN \ + __m128 c128; \ DECLARE_ALIGNED(Uint32, cccc[4], 16); \ cccc[0] = color; \ cccc[1] = color; \ cccc[2] = color; \ cccc[3] = color; \ - __m128 c128 = *(__m128 *)cccc; + c128 = *(__m128 *)cccc; #endif #define SSE_WORK \ @@ -59,11 +60,14 @@ static void \ SDL_FillRect##bpp##SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \ { \ + int i, n; \ + Uint8 *p = NULL; \ + \ SSE_BEGIN; \ \ while (h--) { \ - int i, n = w * bpp; \ - Uint8 *p = pixels; \ + n = w * bpp; \ + p = pixels; \ \ if (n > 63) { \ int adjust = 16 - ((uintptr_t)p & 15); \ @@ -94,11 +98,13 @@ SDL_FillRect##bpp##SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \ static void SDL_FillRect1SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) { + int i, n; + Uint8 *p = NULL; + SSE_BEGIN; - while (h--) { - int i, n = w; - Uint8 *p = pixels; + n = w; + p = pixels; if (n > 63) { int adjust = 16 - ((uintptr_t)p & 15); @@ -119,7 +125,7 @@ SDL_FillRect1SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) SSE_END; } -/*DEFINE_SSE_FILLRECT(1, Uint8)*/ +/* DEFINE_SSE_FILLRECT(1, Uint8) */ DEFINE_SSE_FILLRECT(2, Uint16) DEFINE_SSE_FILLRECT(4, Uint32) @@ -152,11 +158,14 @@ DEFINE_SSE_FILLRECT(4, Uint32) static void \ SDL_FillRect##bpp##MMX(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \ { \ + int i, n; \ + Uint8 *p = NULL; \ + \ MMX_BEGIN; \ \ while (h--) { \ - int i, n = w * bpp; \ - Uint8 *p = pixels; \ + n = w * bpp; \ + p = pixels; \ \ if (n > 63) { \ int adjust = 8 - ((uintptr_t)p & 7); \ @@ -187,11 +196,14 @@ SDL_FillRect##bpp##MMX(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \ static void SDL_FillRect1MMX(Uint8 *pixels, int pitch, Uint32 color, int w, int h) { + int i, n; + Uint8 *p = NULL; + MMX_BEGIN; while (h--) { - int i, n = w; - Uint8 *p = pixels; + n = w; + p = pixels; if (n > 63) { int adjust = 8 - ((uintptr_t)p & 7); @@ -212,7 +224,7 @@ SDL_FillRect1MMX(Uint8 *pixels, int pitch, Uint32 color, int w, int h) MMX_END; } -/*DEFINE_MMX_FILLRECT(1, Uint8)*/ +/* DEFINE_MMX_FILLRECT(1, Uint8) */ DEFINE_MMX_FILLRECT(2, Uint16) DEFINE_MMX_FILLRECT(4, Uint32) @@ -222,9 +234,12 @@ DEFINE_MMX_FILLRECT(4, Uint32) static void SDL_FillRect1(Uint8 * pixels, int pitch, Uint32 color, int w, int h) { + int n; + Uint8 *p = NULL; + while (h--) { - int n = w; - Uint8 *p = pixels; + n = w; + p = pixels; if (n > 3) { switch ((uintptr_t) p & 3) { @@ -258,9 +273,12 @@ SDL_FillRect1(Uint8 * pixels, int pitch, Uint32 color, int w, int h) static void SDL_FillRect2(Uint8 * pixels, int pitch, Uint32 color, int w, int h) { + int n; + Uint16 *p = NULL; + while (h--) { - int n = w; - Uint16 *p = (Uint16 *) pixels; + n = w; + p = (Uint16 *) pixels; if (n > 1) { if ((uintptr_t) p & 2) { @@ -282,10 +300,12 @@ SDL_FillRect3(Uint8 * pixels, int pitch, Uint32 color, int w, int h) Uint8 r = (Uint8) ((color >> 16) & 0xFF); Uint8 g = (Uint8) ((color >> 8) & 0xFF); Uint8 b = (Uint8) (color & 0xFF); + int n; + Uint8 *p = NULL; while (h--) { - int n = w; - Uint8 *p = pixels; + n = w; + p = pixels; while (n--) { *p++ = r; diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c index c472c38b5..0300155fc 100644 --- a/src/video/SDL_pixels.c +++ b/src/video/SDL_pixels.c @@ -707,9 +707,7 @@ SDL_FreePalette(SDL_Palette * palette) if (--palette->refcount > 0) { return; } - if (palette->colors) { - SDL_free(palette->colors); - } + SDL_free(palette->colors); SDL_free(palette); } @@ -985,10 +983,8 @@ SDL_InvalidateMap(SDL_BlitMap * map) map->dst = NULL; map->src_palette_version = 0; map->dst_palette_version = 0; - if (map->info.table) { - SDL_free(map->info.table); - map->info.table = NULL; - } + SDL_free(map->info.table); + map->info.table = NULL; } int diff --git a/src/video/SDL_rect.c b/src/video/SDL_rect.c index 8dcb5b651..b6393fb2d 100644 --- a/src/video/SDL_rect.c +++ b/src/video/SDL_rect.c @@ -296,15 +296,16 @@ SDL_EnclosePoints(const SDL_Point * points, int count, const SDL_Rect * clip, #define CODE_LEFT 4 #define CODE_RIGHT 8 -static int ComputeOutCode(const SDL_Rect * rect, int x, int y) +static int +ComputeOutCode(const SDL_Rect * rect, int x, int y) { int code = 0; - if (y < 0) { + if (y < rect->y) { code |= CODE_TOP; } else if (y >= rect->y + rect->h) { code |= CODE_BOTTOM; } - if (x < 0) { + if (x < rect->x) { code |= CODE_LEFT; } else if (x >= rect->x + rect->w) { code |= CODE_RIGHT; diff --git a/src/video/SDL_shape.c b/src/video/SDL_shape.c index e9876e410..308fefce5 100644 --- a/src/video/SDL_shape.c +++ b/src/video/SDL_shape.c @@ -33,7 +33,7 @@ SDL_Window* SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) { SDL_Window *result = NULL; - result = SDL_CreateWindow(title,-1000,-1000,w,h,(flags | SDL_WINDOW_BORDERLESS) & (~SDL_WINDOW_FULLSCREEN) & (~SDL_WINDOW_RESIZABLE) /*& (~SDL_WINDOW_SHOWN)*/); + result = SDL_CreateWindow(title,-1000,-1000,w,h,(flags | SDL_WINDOW_BORDERLESS) & (~SDL_WINDOW_FULLSCREEN) & (~SDL_WINDOW_RESIZABLE) /* & (~SDL_WINDOW_SHOWN) */); if(result != NULL) { result->shaper = SDL_GetVideoDevice()->shape_driver.CreateShaper(result); if(result->shaper != NULL) { diff --git a/src/video/SDL_stretch.c b/src/video/SDL_stretch.c index 69980d076..3eafc2055 100644 --- a/src/video/SDL_stretch.c +++ b/src/video/SDL_stretch.c @@ -38,7 +38,7 @@ (defined(__GNUC__) && defined(__i386__))) && SDL_ASSEMBLY_ROUTINES /* There's a bug with gcc 4.4.1 and -O2 where srcp doesn't get the correct * value after the first scanline. FIXME? */ -/*#define USE_ASM_STRETCH*/ +/* #define USE_ASM_STRETCH */ #endif #ifdef USE_ASM_STRETCH diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index 460d53bc3..d4c852a16 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -596,6 +596,12 @@ SDL_UpperBlit(SDL_Surface * src, const SDL_Rect * srcrect, h -= dy; } + /* Switch back to a fast blit if we were previously stretching */ + if (src->map->info.flags & SDL_COPY_NEAREST) { + src->map->info.flags &= ~SDL_COPY_NEAREST; + SDL_InvalidateMap(src->map); + } + if (w > 0 && h > 0) { SDL_Rect sr; sr.x = srcx; @@ -747,7 +753,10 @@ SDL_LowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect, return 0; } - src->map->info.flags |= SDL_COPY_NEAREST; + if (!(src->map->info.flags & SDL_COPY_NEAREST)) { + src->map->info.flags |= SDL_COPY_NEAREST; + SDL_InvalidateMap(src->map); + } if ( !(src->map->info.flags & complex_copy_flags) && src->format->format == dst->format->format && @@ -801,7 +810,7 @@ SDL_UnlockSurface(SDL_Surface * surface) * Convert a surface into the specified pixel format. */ SDL_Surface * -SDL_ConvertSurface(SDL_Surface * surface, SDL_PixelFormat * format, +SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format, Uint32 flags) { SDL_Surface *convert; @@ -942,7 +951,7 @@ SDL_ConvertSurfaceFormat(SDL_Surface * surface, Uint32 pixel_format, /* * Create a surface on the stack for quick blit operations */ -static __inline__ SDL_bool +static SDL_INLINE SDL_bool SDL_CreateSurfaceOnStack(int width, int height, Uint32 pixel_format, void * pixels, int pitch, SDL_Surface * surface, SDL_PixelFormat * format, SDL_BlitMap * blitmap) @@ -963,7 +972,7 @@ SDL_CreateSurfaceOnStack(int width, int height, Uint32 pixel_format, surface->h = height; surface->pitch = pitch; /* We don't actually need to set up the clip rect for our purposes */ - /*SDL_SetClipRect(surface, NULL);*/ + /* SDL_SetClipRect(surface, NULL); */ /* Allocate an empty mapping */ SDL_zerop(blitmap); @@ -1076,7 +1085,7 @@ SDL_FreeSurface(SDL_Surface * surface) SDL_FreeBlitMap(surface->map); surface->map = NULL; } - if (surface->pixels && ((surface->flags & SDL_PREALLOC) != SDL_PREALLOC)) { + if (!(surface->flags & SDL_PREALLOC)) { SDL_free(surface->pixels); } SDL_free(surface); diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index e149b8a18..f3113a7e8 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -224,6 +224,7 @@ struct SDL_VideoDevice void (*GL_UnloadLibrary) (_THIS); SDL_GLContext(*GL_CreateContext) (_THIS, SDL_Window * window); int (*GL_MakeCurrent) (_THIS, SDL_Window * window, SDL_GLContext context); + void (*GL_GetDrawableSize) (_THIS, SDL_Window * window, int *w, int *h); int (*GL_SetSwapInterval) (_THIS, int interval); int (*GL_GetSwapInterval) (_THIS); void (*GL_SwapWindow) (_THIS, SDL_Window * window); @@ -291,8 +292,8 @@ struct SDL_VideoDevice int minor_version; int flags; int profile_mask; - int use_egl; int share_with_current_context; + int framebuffer_srgb_capable; int retained_backing; int driver_loaded; char driver_path[256]; @@ -313,7 +314,11 @@ struct SDL_VideoDevice /* Data private to this driver */ void *driverdata; struct SDL_GLDriverData *gl_data; - + +#if SDL_VIDEO_OPENGL_EGL + struct SDL_EGL_VideoData *egl_data; +#endif + #if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 struct SDL_PrivateGLESData *gles_data; #endif @@ -361,6 +366,9 @@ extern VideoBootStrap Android_bootstrap; #if SDL_VIDEO_DRIVER_PSP extern VideoBootStrap PSP_bootstrap; #endif +#if SDL_VIDEO_DRIVER_RPI +extern VideoBootStrap RPI_bootstrap; +#endif #if SDL_VIDEO_DRIVER_DUMMY extern VideoBootStrap DUMMY_bootstrap; #endif @@ -370,6 +378,7 @@ extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode); extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display); extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode * mode); extern SDL_VideoDisplay *SDL_GetDisplayForWindow(SDL_Window *window); +extern void *SDL_GetDisplayDriverData( int displayIndex ); extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags); diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 1404ba0e8..5c1c6d3f7 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -39,9 +39,10 @@ #include "SDL_opengles.h" #endif /* SDL_VIDEO_OPENGL_ES */ -#if SDL_VIDEO_OPENGL_ES2 +/* GL and GLES2 headers conflict on Linux 32 bits */ +#if SDL_VIDEO_OPENGL_ES2 && !SDL_VIDEO_OPENGL #include "SDL_opengles2.h" -#endif /* SDL_VIDEO_OPENGL_ES2 */ +#endif /* SDL_VIDEO_OPENGL_ES2 && !SDL_VIDEO_OPENGL */ #include "SDL_syswm.h" @@ -82,6 +83,9 @@ static VideoBootStrap *bootstrap[] = { #if SDL_VIDEO_DRIVER_PSP &PSP_bootstrap, #endif +#if SDL_VIDEO_DRIVER_RPI + &RPI_bootstrap, +#endif #if SDL_VIDEO_DRIVER_DUMMY &DUMMY_bootstrap, #endif @@ -265,10 +269,8 @@ SDL_CreateWindowTexture(_THIS, SDL_Window * window, Uint32 * format, void ** pix SDL_DestroyTexture(data->texture); data->texture = NULL; } - if (data->pixels) { - SDL_free(data->pixels); - data->pixels = NULL; - } + SDL_free(data->pixels); + data->pixels = NULL; if (SDL_GetRendererInfo(data->renderer, &info) < 0) { return -1; @@ -353,9 +355,7 @@ SDL_DestroyWindowTexture(_THIS, SDL_Window * window) if (data->renderer) { SDL_DestroyRenderer(data->renderer); } - if (data->pixels) { - SDL_free(data->pixels); - } + SDL_free(data->pixels); SDL_free(data); } @@ -483,21 +483,21 @@ SDL_VideoInit(const char *driver_name) _this->gl_config.multisamplesamples = 0; _this->gl_config.retained_backing = 1; _this->gl_config.accelerated = -1; /* accelerated or not, both are fine */ + _this->gl_config.profile_mask = 0; #if SDL_VIDEO_OPENGL _this->gl_config.major_version = 2; _this->gl_config.minor_version = 1; - _this->gl_config.use_egl = 0; -#elif SDL_VIDEO_OPENGL_ES - _this->gl_config.major_version = 1; - _this->gl_config.minor_version = 1; - _this->gl_config.use_egl = 1; #elif SDL_VIDEO_OPENGL_ES2 _this->gl_config.major_version = 2; _this->gl_config.minor_version = 0; - _this->gl_config.use_egl = 1; + _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; +#elif SDL_VIDEO_OPENGL_ES + _this->gl_config.major_version = 1; + _this->gl_config.minor_version = 1; + _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; #endif _this->gl_config.flags = 0; - _this->gl_config.profile_mask = 0; + _this->gl_config.share_with_current_context = 0; _this->current_glwin_tls = SDL_TLSCreate(); @@ -621,6 +621,14 @@ SDL_GetIndexOfDisplay(SDL_VideoDisplay *display) return 0; } +void * +SDL_GetDisplayDriverData( int displayIndex ) +{ + CHECK_DISPLAY_INDEX( displayIndex, NULL ); + + return _this->displays[displayIndex].driverdata; +} + const char * SDL_GetDisplayName(int displayIndex) { @@ -1185,6 +1193,7 @@ SDL_Window * SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) { SDL_Window *window; + const char *hint; if (!_this) { /* Initialize the video system if needed */ @@ -1243,6 +1252,17 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN); window->brightness = 1.0f; window->next = _this->windows; + + /* Unless the user has specified the high-DPI disabling hint, respect the + * SDL_WINDOW_ALLOW_HIGHDPI flag. + */ + hint = SDL_GetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED); + if (!hint || *hint != '1') { + if ((flags & SDL_WINDOW_ALLOW_HIGHDPI)) { + window->flags |= SDL_WINDOW_ALLOW_HIGHDPI; + } + } + if (_this->windows) { _this->windows->prev = window; } @@ -1404,9 +1424,7 @@ SDL_SetWindowTitle(SDL_Window * window, const char *title) if (title == window->title) { return; } - if (window->title) { - SDL_free(window->title); - } + SDL_free(window->title); if (title && *title) { window->title = SDL_strdup(title); } else { @@ -1435,9 +1453,7 @@ SDL_SetWindowIcon(SDL_Window * window, SDL_Surface * icon) return; } - if (window->icon) { - SDL_FreeSurface(window->icon); - } + SDL_FreeSurface(window->icon); /* Convert the icon into ARGB8888 */ window->icon = SDL_ConvertSurfaceFormat(icon, SDL_PIXELFORMAT_ARGB8888, 0); @@ -1458,7 +1474,7 @@ SDL_SetWindowData(SDL_Window * window, const char *name, void *userdata) CHECK_WINDOW_MAGIC(window, NULL); /* Input validation */ - if (name == NULL || SDL_strlen(name) == 0) { + if (name == NULL || name[0] == '\0') { SDL_InvalidParamError("name"); return NULL; } @@ -1505,7 +1521,7 @@ SDL_GetWindowData(SDL_Window * window, const char *name) CHECK_WINDOW_MAGIC(window, NULL); /* Input validation */ - if (name == NULL || SDL_strlen(name) == 0) { + if (name == NULL || name[0] == '\0') { SDL_InvalidParamError("name"); return NULL; } @@ -1538,14 +1554,21 @@ SDL_SetWindowPosition(SDL_Window * window, int x, int y) } } - if (!SDL_WINDOWPOS_ISUNDEFINED(x)) { - window->x = x; - } - if (!SDL_WINDOWPOS_ISUNDEFINED(y)) { - window->y = y; - } + if ((window->flags & SDL_WINDOW_FULLSCREEN)) { + if (!SDL_WINDOWPOS_ISUNDEFINED(x)) { + window->windowed.x = x; + } + if (!SDL_WINDOWPOS_ISUNDEFINED(y)) { + window->windowed.y = y; + } + } else { + if (!SDL_WINDOWPOS_ISUNDEFINED(x)) { + window->x = x; + } + if (!SDL_WINDOWPOS_ISUNDEFINED(y)) { + window->y = y; + } - if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { if (_this->SetWindowPosition) { _this->SetWindowPosition(_this, window); } @@ -1759,7 +1782,7 @@ SDL_MaximizeWindow(SDL_Window * window) return; } - // !!! FIXME: should this check if the window is resizable? + /* !!! FIXME: should this check if the window is resizable? */ if (_this->MaximizeWindow) { _this->MaximizeWindow(_this, window); @@ -2185,15 +2208,9 @@ SDL_DestroyWindow(SDL_Window * window) window->magic = NULL; /* Free memory associated with the window */ - if (window->title) { - SDL_free(window->title); - } - if (window->icon) { - SDL_FreeSurface(window->icon); - } - if (window->gamma) { - SDL_free(window->gamma); - } + SDL_free(window->title); + SDL_FreeSurface(window->icon); + SDL_free(window->gamma); while (window->data) { SDL_WindowUserData *data = window->data; @@ -2280,23 +2297,15 @@ SDL_VideoQuit(void) for (i = 0; i < _this->num_displays; ++i) { SDL_VideoDisplay *display = &_this->displays[i]; for (j = display->num_display_modes; j--;) { - if (display->display_modes[j].driverdata) { - SDL_free(display->display_modes[j].driverdata); - display->display_modes[j].driverdata = NULL; - } - } - if (display->display_modes) { - SDL_free(display->display_modes); - display->display_modes = NULL; - } - if (display->desktop_mode.driverdata) { - SDL_free(display->desktop_mode.driverdata); - display->desktop_mode.driverdata = NULL; - } - if (display->driverdata) { - SDL_free(display->driverdata); - display->driverdata = NULL; + SDL_free(display->display_modes[j].driverdata); + display->display_modes[j].driverdata = NULL; } + SDL_free(display->display_modes); + display->display_modes = NULL; + SDL_free(display->desktop_mode.driverdata); + display->desktop_mode.driverdata = NULL; + SDL_free(display->driverdata); + display->driverdata = NULL; } if (_this->displays) { for (i = 0; i < _this->num_displays; ++i) { @@ -2306,10 +2315,8 @@ SDL_VideoQuit(void) _this->displays = NULL; _this->num_displays = 0; } - if (_this->clipboard_text) { - SDL_free(_this->clipboard_text); - _this->clipboard_text = NULL; - } + SDL_free(_this->clipboard_text); + _this->clipboard_text = NULL; _this->free(_this); _this = NULL; } @@ -2329,12 +2336,16 @@ SDL_GL_LoadLibrary(const char *path) retval = 0; } else { if (!_this->GL_LoadLibrary) { - return SDL_SetError("No dynamic GL support in video driver"); + return SDL_SetError("No dynamic GL support in video driver"); } retval = _this->GL_LoadLibrary(_this, path); } if (retval == 0) { ++_this->gl_config.driver_loaded; + } else { + if (_this->GL_UnloadLibrary) { + _this->GL_UnloadLibrary(_this); + } } return (retval); } @@ -2378,7 +2389,7 @@ SDL_GL_UnloadLibrary(void) } } -static __inline__ SDL_bool +static SDL_INLINE SDL_bool isAtLeastGL3(const char *verstr) { return ( verstr && (SDL_atoi(verstr) >= 3) ); @@ -2537,7 +2548,12 @@ SDL_GL_SetAttribute(SDL_GLattr attr, int value) _this->gl_config.minor_version = value; break; case SDL_GL_CONTEXT_EGL: - _this->gl_config.use_egl = value; + /* FIXME: SDL_GL_CONTEXT_EGL to be deprecated in SDL 2.1 */ + if (value != 0) { + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); + } else { + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, 0); + }; break; case SDL_GL_CONTEXT_FLAGS: if( value & ~(SDL_GL_CONTEXT_DEBUG_FLAG | @@ -2561,7 +2577,10 @@ SDL_GL_SetAttribute(SDL_GLattr attr, int value) break; case SDL_GL_SHARE_WITH_CURRENT_CONTEXT: _this->gl_config.share_with_current_context = value; - break; + break; + case SDL_GL_FRAMEBUFFER_SRGB_CAPABLE: + _this->gl_config.framebuffer_srgb_capable = value; + break; default: retval = SDL_SetError("Unknown OpenGL attribute"); break; @@ -2707,8 +2726,14 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value) return 0; } case SDL_GL_CONTEXT_EGL: + /* FIXME: SDL_GL_CONTEXT_EGL to be deprecated in SDL 2.1 */ { - *value = _this->gl_config.use_egl; + if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) { + *value = 1; + } + else { + *value = 0; + } return 0; } case SDL_GL_CONTEXT_FLAGS: @@ -2726,6 +2751,11 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value) *value = _this->gl_config.share_with_current_context; return 0; } + case SDL_GL_FRAMEBUFFER_SRGB_CAPABLE: + { + *value = _this->gl_config.framebuffer_srgb_capable; + return 0; + } default: return SDL_SetError("Unknown OpenGL attribute"); } @@ -2820,6 +2850,17 @@ SDL_GL_GetCurrentContext(void) return (SDL_GLContext)SDL_TLSGet(_this->current_glctx_tls); } +void SDL_GL_GetDrawableSize(SDL_Window * window, int *w, int *h) +{ + CHECK_WINDOW_MAGIC(window, ); + + if (_this->GL_GetDrawableSize) { + _this->GL_GetDrawableSize(_this, window, w, h); + } else { + SDL_GetWindowSize(window, w, h); + } +} + int SDL_GL_SetSwapInterval(int interval) { diff --git a/src/video/android/SDL_androidevents.c b/src/video/android/SDL_androidevents.c index 528fce5c6..9be49cf4f 100644 --- a/src/video/android/SDL_androidevents.c +++ b/src/video/android/SDL_androidevents.c @@ -27,6 +27,32 @@ #include "SDL_androidevents.h" #include "SDL_events.h" +#include "SDL_androidwindow.h" + +void android_egl_context_backup(); +void android_egl_context_restore(); + +void +android_egl_context_restore() +{ + SDL_WindowData *data = (SDL_WindowData *) Android_Window->driverdata; + if (SDL_GL_MakeCurrent(Android_Window, (SDL_GLContext) data->egl_context) < 0) { + /* The context is no longer valid, create a new one */ + /* FIXME: Notify the user that the context changed and textures need to be re created */ + data->egl_context = (EGLContext) SDL_GL_CreateContext(Android_Window); + SDL_GL_MakeCurrent(Android_Window, (SDL_GLContext) data->egl_context); + } +} + +void +android_egl_context_backup() +{ + /* Keep a copy of the EGL Context so we can try to restore it when we resume */ + SDL_WindowData *data = (SDL_WindowData *) Android_Window->driverdata; + data->egl_context = SDL_GL_GetCurrentContext(); + /* We need to do this so the EGLSurface can be freed */ + SDL_GL_MakeCurrent(Android_Window, NULL); +} void Android_PumpEvents(_THIS) @@ -46,27 +72,25 @@ Android_PumpEvents(_THIS) #if SDL_ANDROID_BLOCK_ON_PAUSE if (isPaused && !isPausing) { + /* Make sure this is the last thing we do before pausing */ + android_egl_context_backup(); if(SDL_SemWait(Android_ResumeSem) == 0) { #else if (isPaused) { if(SDL_SemTryWait(Android_ResumeSem) == 0) { #endif isPaused = 0; - /* TODO: Should we double check if we are on the same thread as the one that made the original GL context? - * This call will go through the following chain of calls in Java: - * SDLActivity::createGLContext -> SDLActivity:: initEGL -> SDLActivity::createEGLSurface -> SDLActivity::createEGLContext - * SDLActivity::createEGLContext will attempt to restore the GL context first, and if that fails it will create a new one - * If a new GL context is created, the user needs to restore the textures manually (TODO: notify the user that this happened with a message) - */ - SDL_GL_CreateContext(Android_Window); + + /* Restore the GL Context from here, as this operation is thread dependent */ + android_egl_context_restore(); } } else { #if SDL_ANDROID_BLOCK_ON_PAUSE if( isPausing || SDL_SemTryWait(Android_PauseSem) == 0 ) { - /* We've been signaled to pause, but before we block ourselves, we need to make sure that - SDL_WINDOWEVENT_FOCUS_LOST and SDL_WINDOWEVENT_MINIMIZED have reached the app */ - if (SDL_HasEvent(SDL_WINDOWEVENT)) { + /* We've been signaled to pause, but before we block ourselves, + we need to make sure that certain key events have reached the app */ + if (SDL_HasEvent(SDL_WINDOWEVENT) || SDL_HasEvent(SDL_APP_WILLENTERBACKGROUND) || SDL_HasEvent(SDL_APP_DIDENTERBACKGROUND) ) { isPausing = 1; } else { @@ -76,7 +100,7 @@ Android_PumpEvents(_THIS) } #else if(SDL_SemTryWait(Android_PauseSem) == 0) { - /* If we fall in here, the system is/was paused */ + android_egl_context_backup(); isPaused = 1; } #endif diff --git a/src/video/android/SDL_androidgl.c b/src/video/android/SDL_androidgl.c index 6902bc1d0..691fbf7fb 100644 --- a/src/video/android/SDL_androidgl.c +++ b/src/video/android/SDL_androidgl.c @@ -25,6 +25,8 @@ /* Android SDL video driver implementation */ #include "SDL_video.h" +#include "../SDL_egl.h" +#include "SDL_androidwindow.h" #include "SDL_androidvideo.h" #include "../../core/android/SDL_android.h" @@ -33,95 +35,21 @@ #include -static void* Android_GLHandle = NULL; - -/* GL functions */ -int -Android_GL_LoadLibrary(_THIS, const char *path) -{ - if (!Android_GLHandle) { - Android_GLHandle = dlopen("libGLESv1_CM.so",RTLD_GLOBAL); - if (!Android_GLHandle) { - return SDL_SetError("Could not initialize GL ES library\n"); - } - } - return 0; -} - -void * -Android_GL_GetProcAddress(_THIS, const char *proc) -{ - /* - !!! FIXME: this _should_ use eglGetProcAddress(), but it appears to be - !!! FIXME: busted on Android at the moment... - !!! FIXME: http://code.google.com/p/android/issues/detail?id=7681 - !!! FIXME: ...so revisit this later. --ryan. - */ - return dlsym(Android_GLHandle, proc); -} +SDL_EGL_CreateContext_impl(Android) +SDL_EGL_MakeCurrent_impl(Android) void -Android_GL_UnloadLibrary(_THIS) +Android_GLES_SwapWindow(_THIS, SDL_Window * window) { - if(Android_GLHandle) { - dlclose(Android_GLHandle); - Android_GLHandle = NULL; - } -} - -SDL_GLContext -Android_GL_CreateContext(_THIS, SDL_Window * window) -{ - if (!Android_JNI_CreateContext(_this->gl_config.major_version, - _this->gl_config.minor_version, - _this->gl_config.red_size, - _this->gl_config.green_size, - _this->gl_config.blue_size, - _this->gl_config.alpha_size, - _this->gl_config.buffer_size, - _this->gl_config.depth_size, - _this->gl_config.stencil_size, - _this->gl_config.multisamplebuffers, - _this->gl_config.multisamplesamples)) { - SDL_SetError("Couldn't create OpenGL context - see Android log for details"); - return NULL; - } - return (SDL_GLContext)1; + /* FIXME: These two functions were in the Java code, do we really need them? */ + _this->egl_data->eglWaitNative(EGL_CORE_NATIVE_ENGINE); + _this->egl_data->eglWaitGL(); + SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface); } int -Android_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) -{ - /* There's only one context, nothing to do... */ - return 0; -} - -int -Android_GL_SetSwapInterval(_THIS, int interval) -{ - __android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_SetSwapInterval\n"); - return 0; -} - -int -Android_GL_GetSwapInterval(_THIS) -{ - __android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_GetSwapInterval\n"); - return 0; -} - -void -Android_GL_SwapWindow(_THIS, SDL_Window * window) -{ - Android_JNI_SwapWindow(); -} - -void -Android_GL_DeleteContext(_THIS, SDL_GLContext context) -{ - if (context) { - Android_JNI_DeleteContext(); - } +Android_GLES_LoadLibrary(_THIS, const char *path) { + return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType) 0); } #endif /* SDL_VIDEO_DRIVER_ANDROID */ diff --git a/src/video/android/SDL_androidtouch.c b/src/video/android/SDL_androidtouch.c index 3265b54eb..6ad26e2c9 100644 --- a/src/video/android/SDL_androidtouch.c +++ b/src/video/android/SDL_androidtouch.c @@ -31,6 +31,7 @@ #include "SDL_androidtouch.h" +#include "../../core/android/SDL_android.h" #define ACTION_DOWN 0 #define ACTION_UP 1 @@ -53,6 +54,19 @@ static void Android_GetWindowCoordinates(float x, float y, *window_y = (int)(y * window_h); } +void Android_InitTouch(void) +{ + int i; + int* ids; + int number = Android_JNI_GetTouchDeviceIds(&ids); + if (0 < number) { + for (i = 0; i < number; ++i) { + SDL_AddTouch((SDL_TouchID) ids[i], ""); /* no error handling */ + } + SDL_free(ids); + } +} + void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p) { SDL_TouchID touchDeviceId = 0; diff --git a/src/video/android/SDL_androidtouch.h b/src/video/android/SDL_androidtouch.h index 50a3ebdc8..346d73a66 100644 --- a/src/video/android/SDL_androidtouch.h +++ b/src/video/android/SDL_androidtouch.h @@ -22,6 +22,7 @@ #include "SDL_androidvideo.h" +extern void Android_InitTouch(void); extern void Android_OnTouch( int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p); /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/android/SDL_androidvideo.c b/src/video/android/SDL_androidvideo.c index 6dcb81e70..fc766ece7 100644 --- a/src/video/android/SDL_androidvideo.c +++ b/src/video/android/SDL_androidvideo.c @@ -36,6 +36,7 @@ #include "SDL_androidclipboard.h" #include "SDL_androidevents.h" #include "SDL_androidkeyboard.h" +#include "SDL_androidtouch.h" #include "SDL_androidwindow.h" #define ANDROID_VID_DRIVER_NAME "Android" @@ -44,17 +45,17 @@ static int Android_VideoInit(_THIS); static void Android_VideoQuit(_THIS); +#include "../SDL_egl.h" /* GL functions (SDL_androidgl.c) */ -extern int Android_GL_LoadLibrary(_THIS, const char *path); -extern void *Android_GL_GetProcAddress(_THIS, const char *proc); -extern void Android_GL_UnloadLibrary(_THIS); -extern SDL_GLContext Android_GL_CreateContext(_THIS, SDL_Window * window); -extern int Android_GL_MakeCurrent(_THIS, SDL_Window * window, - SDL_GLContext context); -extern int Android_GL_SetSwapInterval(_THIS, int interval); -extern int Android_GL_GetSwapInterval(_THIS); -extern void Android_GL_SwapWindow(_THIS, SDL_Window * window); -extern void Android_GL_DeleteContext(_THIS, SDL_GLContext context); +extern SDL_GLContext Android_GLES_CreateContext(_THIS, SDL_Window * window); +extern int Android_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); +extern void Android_GLES_SwapWindow(_THIS, SDL_Window * window); +extern int Android_GLES_LoadLibrary(_THIS, const char *path); +#define Android_GLES_GetProcAddress SDL_EGL_GetProcAddress +#define Android_GLES_UnloadLibrary SDL_EGL_UnloadLibrary +#define Android_GLES_SetSwapInterval SDL_EGL_SetSwapInterval +#define Android_GLES_GetSwapInterval SDL_EGL_GetSwapInterval +#define Android_GLES_DeleteContext SDL_EGL_DeleteContext /* Android driver bootstrap functions */ @@ -114,15 +115,15 @@ Android_CreateDevice(int devindex) device->free = Android_DeleteDevice; /* GL pointers */ - device->GL_LoadLibrary = Android_GL_LoadLibrary; - device->GL_GetProcAddress = Android_GL_GetProcAddress; - device->GL_UnloadLibrary = Android_GL_UnloadLibrary; - device->GL_CreateContext = Android_GL_CreateContext; - device->GL_MakeCurrent = Android_GL_MakeCurrent; - device->GL_SetSwapInterval = Android_GL_SetSwapInterval; - device->GL_GetSwapInterval = Android_GL_GetSwapInterval; - device->GL_SwapWindow = Android_GL_SwapWindow; - device->GL_DeleteContext = Android_GL_DeleteContext; + device->GL_LoadLibrary = Android_GLES_LoadLibrary; + device->GL_GetProcAddress = Android_GLES_GetProcAddress; + device->GL_UnloadLibrary = Android_GLES_UnloadLibrary; + device->GL_CreateContext = Android_GLES_CreateContext; + device->GL_MakeCurrent = Android_GLES_MakeCurrent; + device->GL_SetSwapInterval = Android_GLES_SetSwapInterval; + device->GL_GetSwapInterval = Android_GLES_GetSwapInterval; + device->GL_SwapWindow = Android_GLES_SwapWindow; + device->GL_DeleteContext = Android_GLES_DeleteContext; /* Text input */ device->StartTextInput = Android_StartTextInput; @@ -165,6 +166,8 @@ Android_VideoInit(_THIS) Android_InitKeyboard(); + Android_InitTouch(); + /* We're done! */ return 0; } diff --git a/src/video/android/SDL_androidwindow.c b/src/video/android/SDL_androidwindow.c index 70e244e1a..acc40dbee 100644 --- a/src/video/android/SDL_androidwindow.c +++ b/src/video/android/SDL_androidwindow.c @@ -29,15 +29,15 @@ #include "SDL_androidvideo.h" #include "SDL_androidwindow.h" -#include "../../core/android/SDL_android.h" - int Android_CreateWindow(_THIS, SDL_Window * window) { + SDL_WindowData *data; + if (Android_Window) { return SDL_SetError("Android only supports one window"); } - Android_Window = window; + Android_PauseSem = SDL_CreateSemaphore(0); Android_ResumeSem = SDL_CreateSemaphore(0); @@ -56,7 +56,29 @@ Android_CreateWindow(_THIS, SDL_Window * window) /* One window, it always has focus */ SDL_SetMouseFocus(window); SDL_SetKeyboardFocus(window); + + data = (SDL_WindowData *) SDL_calloc(1, sizeof(*data)); + if (!data) { + return SDL_OutOfMemory(); + } + + data->native_window = Android_JNI_GetNativeWindow(); + + if (!data->native_window) { + SDL_free(data); + return SDL_SetError("Could not fetch native window"); + } + + data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->native_window); + if (data->egl_surface == EGL_NO_SURFACE) { + SDL_free(data); + return SDL_SetError("Could not create GLES window surface"); + } + + window->driverdata = data; + Android_Window = window; + return 0; } @@ -69,12 +91,23 @@ Android_SetWindowTitle(_THIS, SDL_Window * window) void Android_DestroyWindow(_THIS, SDL_Window * window) { + SDL_WindowData *data; + if (window == Android_Window) { Android_Window = NULL; if (Android_PauseSem) SDL_DestroySemaphore(Android_PauseSem); if (Android_ResumeSem) SDL_DestroySemaphore(Android_ResumeSem); Android_PauseSem = NULL; Android_ResumeSem = NULL; + + if(window->driverdata) { + data = (SDL_WindowData *) window->driverdata; + if(data->native_window) { + ANativeWindow_release(data->native_window); + } + SDL_free(window->driverdata); + window->driverdata = NULL; + } } } diff --git a/src/video/android/SDL_androidwindow.h b/src/video/android/SDL_androidwindow.h index c0ef93bb0..4365cd414 100644 --- a/src/video/android/SDL_androidwindow.h +++ b/src/video/android/SDL_androidwindow.h @@ -23,10 +23,21 @@ #ifndef _SDL_androidwindow_h #define _SDL_androidwindow_h +#include "../../core/android/SDL_android.h" +#include "../SDL_egl.h" + extern int Android_CreateWindow(_THIS, SDL_Window * window); extern void Android_SetWindowTitle(_THIS, SDL_Window * window); extern void Android_DestroyWindow(_THIS, SDL_Window * window); +typedef struct +{ + EGLSurface egl_surface; + EGLContext egl_context; /* We use this to preserve the context when losing focus */ + ANativeWindow* native_window; + +} SDL_WindowData; + #endif /* _SDL_androidwindow_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/bwindow/SDL_BWin.h b/src/video/bwindow/SDL_BWin.h index fb576da68..6b6a71e41 100644 --- a/src/video/bwindow/SDL_BWin.h +++ b/src/video/bwindow/SDL_BWin.h @@ -353,7 +353,7 @@ class SDL_BWin:public BDirectWindow - CTRL+Q to close window (and other shortcuts) - PrintScreen to make screenshot into /boot/home - etc.. */ - //BDirectWindow::DispatchMessage(msg, target); + /* BDirectWindow::DispatchMessage(msg, target); */ break; } @@ -461,9 +461,9 @@ private: msg.AddBool("focusGained", focusGained); _PostWindowEvent(msg); -//FIXME: Why were these here? -// if false: be_app->SetCursor(B_HAND_CURSOR); -// if true: SDL_SetCursor(NULL); +/* FIXME: Why were these here? + if false: be_app->SetCursor(B_HAND_CURSOR); + if true: SDL_SetCursor(NULL); */ } void _MouseButtonEvent(int32 buttons) { diff --git a/src/video/bwindow/SDL_bclipboard.cc b/src/video/bwindow/SDL_bclipboard.cc index 4801483c4..2ec80c6ba 100644 --- a/src/video/bwindow/SDL_bclipboard.cc +++ b/src/video/bwindow/SDL_bclipboard.cc @@ -82,14 +82,14 @@ SDL_bool BE_HasClipboardText(_THIS) { SDL_bool result = SDL_FALSE; char *text = BE_GetClipboardText(_this); if (text) { - result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE; + result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE; SDL_free(text); } return result; } #ifdef __cplusplus -} /* Extern C */ +} #endif #endif /* SDL_VIDEO_DRIVER_BWINDOW */ diff --git a/src/video/bwindow/SDL_bframebuffer.cc b/src/video/bwindow/SDL_bframebuffer.cc index 6e7f8c3f2..69f4a43a1 100644 --- a/src/video/bwindow/SDL_bframebuffer.cc +++ b/src/video/bwindow/SDL_bframebuffer.cc @@ -37,11 +37,11 @@ extern "C" { int32 BE_UpdateOnce(SDL_Window *window); -static inline SDL_BWin *_ToBeWin(SDL_Window *window) { +static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) { return ((SDL_BWin*)(window->driverdata)); } -static inline SDL_BApp *_GetBeApp() { +static SDL_INLINE SDL_BApp *_GetBeApp() { return ((SDL_BApp*)be_app); } diff --git a/src/video/bwindow/SDL_bmodes.cc b/src/video/bwindow/SDL_bmodes.cc index 41894fb78..44e19dc7e 100644 --- a/src/video/bwindow/SDL_bmodes.cc +++ b/src/video/bwindow/SDL_bmodes.cc @@ -48,15 +48,15 @@ typedef struct SDL_DisplayModeData { }; #endif -static inline SDL_BWin *_ToBeWin(SDL_Window *window) { +static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) { return ((SDL_BWin*)(window->driverdata)); } -static inline SDL_BApp *_GetBeApp() { +static SDL_INLINE SDL_BApp *_GetBeApp() { return ((SDL_BApp*)be_app); } -static inline display_mode * _ExtractBMode(SDL_DisplayMode *mode) { +static SDL_INLINE display_mode * _ExtractBMode(SDL_DisplayMode *mode) { #if WRAP_BMODE return ((SDL_DisplayModeData*)mode->driverdata)->bmode; #else diff --git a/src/video/bwindow/SDL_bopengl.cc b/src/video/bwindow/SDL_bopengl.cc index 5acefe2cd..13b90ad97 100644 --- a/src/video/bwindow/SDL_bopengl.cc +++ b/src/video/bwindow/SDL_bopengl.cc @@ -37,11 +37,11 @@ extern "C" { #define BGL_FLAGS BGL_RGB | BGL_DOUBLE -static inline SDL_BWin *_ToBeWin(SDL_Window *window) { +static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) { return ((SDL_BWin*)(window->driverdata)); } -static inline SDL_BApp *_GetBeApp() { +static SDL_INLINE SDL_BApp *_GetBeApp() { return ((SDL_BApp*)be_app); } diff --git a/src/video/bwindow/SDL_bopengl.h b/src/video/bwindow/SDL_bopengl.h index f0279ba66..9ec972eef 100644 --- a/src/video/bwindow/SDL_bopengl.h +++ b/src/video/bwindow/SDL_bopengl.h @@ -29,13 +29,13 @@ extern "C" { #include "../SDL_sysvideo.h" -extern int BE_GL_LoadLibrary(_THIS, const char *path); //FIXME -extern void *BE_GL_GetProcAddress(_THIS, const char *proc); //FIXME -extern void BE_GL_UnloadLibrary(_THIS); //TODO +extern int BE_GL_LoadLibrary(_THIS, const char *path); /* FIXME */ +extern void *BE_GL_GetProcAddress(_THIS, const char *proc); /* FIXME */ +extern void BE_GL_UnloadLibrary(_THIS); /* TODO */ extern int BE_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); -extern int BE_GL_SetSwapInterval(_THIS, int interval); //TODO -extern int BE_GL_GetSwapInterval(_THIS); //TODO +extern int BE_GL_SetSwapInterval(_THIS, int interval); /* TODO */ +extern int BE_GL_GetSwapInterval(_THIS); /* TODO */ extern void BE_GL_SwapWindow(_THIS, SDL_Window * window); extern SDL_GLContext BE_GL_CreateContext(_THIS, SDL_Window * window); extern void BE_GL_DeleteContext(_THIS, SDL_GLContext context); diff --git a/src/video/bwindow/SDL_bwindow.cc b/src/video/bwindow/SDL_bwindow.cc index c6eb3aa1a..c898be6ba 100644 --- a/src/video/bwindow/SDL_bwindow.cc +++ b/src/video/bwindow/SDL_bwindow.cc @@ -31,11 +31,11 @@ extern "C" { #endif -static inline SDL_BWin *_ToBeWin(SDL_Window *window) { +static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) { return ((SDL_BWin*)(window->driverdata)); } -static inline SDL_BApp *_GetBeApp() { +static SDL_INLINE SDL_BApp *_GetBeApp() { return ((SDL_BApp*)be_app); } diff --git a/src/video/cocoa/SDL_cocoaclipboard.m b/src/video/cocoa/SDL_cocoaclipboard.m index ab31031b4..62c34b53f 100644 --- a/src/video/cocoa/SDL_cocoaclipboard.m +++ b/src/video/cocoa/SDL_cocoaclipboard.m @@ -95,7 +95,7 @@ Cocoa_HasClipboardText(_THIS) SDL_bool result = SDL_FALSE; char *text = Cocoa_GetClipboardText(_this); if (text) { - result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE; + result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE; SDL_free(text); } return result; diff --git a/src/video/cocoa/SDL_cocoaevents.m b/src/video/cocoa/SDL_cocoaevents.m index f0a65e322..e6b292b0b 100644 --- a/src/video/cocoa/SDL_cocoaevents.m +++ b/src/video/cocoa/SDL_cocoaevents.m @@ -42,12 +42,11 @@ @end @interface SDLAppDelegate : NSObject { +@public BOOL seenFirstActivate; } - (id)init; -- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; -- (void)applicationDidBecomeActive:(NSNotification *)aNotification; @end @implementation SDLAppDelegate : NSObject @@ -57,18 +56,28 @@ if (self) { seenFirstActivate = NO; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(focusSomeWindow:) + name:NSApplicationDidBecomeActiveNotification + object:nil]; } return self; } +- (void)dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver:self]; + [super dealloc]; +} + - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { SDL_SendQuit(); return NSTerminateCancel; } -- (void)applicationDidBecomeActive:(NSNotification *)aNotification +- (void)focusSomeWindow:(NSNotification *)aNotification { /* HACK: Ignore the first call. The application gets a * applicationDidBecomeActive: a little bit after the first window is @@ -111,6 +120,8 @@ } @end +static SDLAppDelegate *appDelegate = nil; + static NSString * GetApplicationName(void) { @@ -231,9 +242,21 @@ Cocoa_RegisterApp(void) CreateApplicationMenus(); } [NSApp finishLaunching]; + NSDictionary *appDefaults = [NSDictionary dictionaryWithObject:@"NO" forKey:@"AppleMomentumScrollSupported"]; + [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults]; + } - if (NSApp && ![NSApp delegate]) { - [NSApp setDelegate:[[SDLAppDelegate alloc] init]]; + if (NSApp && !appDelegate) { + appDelegate = [[SDLAppDelegate alloc] init]; + + /* If someone else has an app delegate, it means we can't turn a + * termination into SDL_Quit, and we can't handle application:openFile: + */ + if (![NSApp delegate]) { + [NSApp setDelegate:appDelegate]; + } else { + appDelegate->seenFirstActivate = YES; + } } [pool release]; } @@ -248,7 +271,7 @@ Cocoa_PumpEvents(_THIS) SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; Uint32 now = SDL_GetTicks(); if (!data->screensaver_activity || - (int)(now-data->screensaver_activity) >= 30000) { + SDL_TICKS_PASSED(now, data->screensaver_activity + 30000)) { UpdateSystemActivity(UsrActivity); data->screensaver_activity = now; } diff --git a/src/video/cocoa/SDL_cocoamodes.m b/src/video/cocoa/SDL_cocoamodes.m index f10e7ee20..501684fc9 100644 --- a/src/video/cocoa/SDL_cocoamodes.m +++ b/src/video/cocoa/SDL_cocoamodes.m @@ -33,7 +33,9 @@ /* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */ #include -static inline void Cocoa_ToggleMenuBar(const BOOL show) + +static void +Cocoa_ToggleMenuBar(const BOOL show) { /* !!! FIXME: keep an eye on this. * ShowMenuBar/HideMenuBar is officially unavailable for 64-bit binaries. @@ -57,7 +59,7 @@ static inline void Cocoa_ToggleMenuBar(const BOOL show) #define MAC_OS_X_VERSION_MIN_REQUIRED 1050 #endif -static inline BOOL +static BOOL IS_SNOW_LEOPARD_OR_LATER(_THIS) { #if FORCE_OLD_API @@ -179,7 +181,7 @@ GetDisplayMode(_THIS, const void *moderef, SDL_DisplayMode *mode) return SDL_TRUE; } -static inline void +static void Cocoa_ReleaseDisplayMode(_THIS, const void *moderef) { if (IS_SNOW_LEOPARD_OR_LATER(_this)) { @@ -187,7 +189,7 @@ Cocoa_ReleaseDisplayMode(_THIS, const void *moderef) } } -static inline void +static void Cocoa_ReleaseDisplayModeList(_THIS, CFArrayRef modelist) { if (IS_SNOW_LEOPARD_OR_LATER(_this)) { @@ -281,7 +283,7 @@ Cocoa_InitModes(_THIS) display.name = (char *)Cocoa_GetDisplayName(displays[i]); if (!GetDisplayMode (_this, moderef, &mode)) { Cocoa_ReleaseDisplayMode(_this, moderef); - if (display.name) SDL_free(display.name); + SDL_free(display.name); SDL_free(displaydata); continue; } @@ -290,7 +292,7 @@ Cocoa_InitModes(_THIS) display.current_mode = mode; display.driverdata = displaydata; SDL_AddVideoDisplay(&display); - if (display.name) SDL_free(display.name); + SDL_free(display.name); } } SDL_stack_free(displays); diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m index faba9618e..e83442346 100644 --- a/src/video/cocoa/SDL_cocoamouse.m +++ b/src/video/cocoa/SDL_cocoamouse.m @@ -204,13 +204,7 @@ static void Cocoa_WarpMouse(SDL_Window * window, int x, int y) { SDL_Mouse *mouse = SDL_GetMouse(); - CGPoint point = CGPointMake(x, y); - - if (!(window->flags & SDL_WINDOW_FULLSCREEN)) - { - point.x += window->x; - point.y += window->y; - } + CGPoint point = CGPointMake(x + (float)window->x, y + (float)window->y); { /* This makes Cocoa_HandleMouseEvent ignore this delta in the next diff --git a/src/video/cocoa/SDL_cocoaopengl.h b/src/video/cocoa/SDL_cocoaopengl.h index 2d06700b6..e7ef1f66c 100644 --- a/src/video/cocoa/SDL_cocoaopengl.h +++ b/src/video/cocoa/SDL_cocoaopengl.h @@ -54,6 +54,8 @@ extern void Cocoa_GL_UnloadLibrary(_THIS); extern SDL_GLContext Cocoa_GL_CreateContext(_THIS, SDL_Window * window); extern int Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); +extern void Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, + int * w, int * h); extern int Cocoa_GL_SetSwapInterval(_THIS, int interval); extern int Cocoa_GL_GetSwapInterval(_THIS); extern void Cocoa_GL_SwapWindow(_THIS, SDL_Window * window); diff --git a/src/video/cocoa/SDL_cocoaopengl.m b/src/video/cocoa/SDL_cocoaopengl.m index 0d49ba0cc..13c7777b1 100644 --- a/src/video/cocoa/SDL_cocoaopengl.m +++ b/src/video/cocoa/SDL_cocoaopengl.m @@ -35,6 +35,18 @@ #define DEFAULT_OPENGL "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib" +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070 +/* New methods for converting to and from backing store pixels, taken from + * AppKite/NSView.h in 10.8 SDK. */ +@interface NSView (Backing) +- (NSPoint)convertPointToBacking:(NSPoint)aPoint; +- (NSPoint)convertPointFromBacking:(NSPoint)aPoint; +- (NSSize)convertSizeToBacking:(NSSize)aSize; +- (NSSize)convertSizeFromBacking:(NSSize)aSize; +- (NSRect)convertRectToBacking:(NSRect)aRect; +- (NSRect)convertRectFromBacking:(NSRect)aRect; +@end +#endif #ifndef kCGLPFAOpenGLProfile #define kCGLPFAOpenGLProfile 99 @@ -294,6 +306,28 @@ Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) return 0; } +void +Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h) +{ + SDL_WindowData *windata = (SDL_WindowData *) window->driverdata; + NSView *contentView = [windata->nswindow contentView]; + NSRect viewport = [contentView bounds]; + + /* This gives us the correct viewport for a Retina-enabled view, only + * supported on 10.7+. */ + if ([contentView respondsToSelector:@selector(convertRectToBacking:)]) { + viewport = [contentView convertRectToBacking:viewport]; + } + + if (w) { + *w = viewport.size.width; + } + + if (h) { + *h = viewport.size.height; + } +} + int Cocoa_GL_SetSwapInterval(_THIS, int interval) { @@ -302,6 +336,10 @@ Cocoa_GL_SetSwapInterval(_THIS, int interval) GLint value; int status; + if (interval < 0) { /* no extension for this on Mac OS X at the moment. */ + return SDL_SetError("Late swap tearing currently unsupported"); + } + pool = [[NSAutoreleasePool alloc] init]; nscontext = (NSOpenGLContext*)SDL_GL_GetCurrentContext(); @@ -344,7 +382,7 @@ Cocoa_GL_SwapWindow(_THIS, SDL_Window * window) pool = [[NSAutoreleasePool alloc] init]; - SDLOpenGLContext* nscontext = (NSOpenGLContext*)SDL_GL_GetCurrentContext(); + SDLOpenGLContext* nscontext = (SDLOpenGLContext*)SDL_GL_GetCurrentContext(); [nscontext flushBuffer]; [nscontext updateIfNeeded]; diff --git a/src/video/cocoa/SDL_cocoashape.m b/src/video/cocoa/SDL_cocoashape.m index 71085261a..ae8df8d19 100644 --- a/src/video/cocoa/SDL_cocoashape.m +++ b/src/video/cocoa/SDL_cocoashape.m @@ -82,8 +82,8 @@ Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShape data->saved = SDL_FALSE; } - //[data->context saveGraphicsState]; - //data->saved = SDL_TRUE; + /*[data->context saveGraphicsState];*/ + /*data->saved = SDL_TRUE;*/ [NSGraphicsContext setCurrentContext:data->context]; [[NSColor clearColor] set]; diff --git a/src/video/cocoa/SDL_cocoavideo.m b/src/video/cocoa/SDL_cocoavideo.m index 849915247..d1b958768 100644 --- a/src/video/cocoa/SDL_cocoavideo.m +++ b/src/video/cocoa/SDL_cocoavideo.m @@ -71,9 +71,7 @@ Cocoa_CreateDevice(int devindex) } if (!data) { SDL_OutOfMemory(); - if (device) { - SDL_free(device); - } + SDL_free(device); return NULL; } device->driverdata = data; @@ -121,6 +119,7 @@ Cocoa_CreateDevice(int devindex) device->GL_UnloadLibrary = Cocoa_GL_UnloadLibrary; device->GL_CreateContext = Cocoa_GL_CreateContext; device->GL_MakeCurrent = Cocoa_GL_MakeCurrent; + device->GL_GetDrawableSize = Cocoa_GL_GetDrawableSize; device->GL_SetSwapInterval = Cocoa_GL_SetSwapInterval; device->GL_GetSwapInterval = Cocoa_GL_GetSwapInterval; device->GL_SwapWindow = Cocoa_GL_SwapWindow; diff --git a/src/video/cocoa/SDL_cocoawindow.h b/src/video/cocoa/SDL_cocoawindow.h index 022694f52..c08c55c11 100644 --- a/src/video/cocoa/SDL_cocoawindow.h +++ b/src/video/cocoa/SDL_cocoawindow.h @@ -30,6 +30,7 @@ typedef struct SDL_WindowData SDL_WindowData; @interface Cocoa_WindowListener : NSResponder { SDL_WindowData *_data; BOOL observingVisible; + BOOL wasCtrlLeft; BOOL wasVisible; } diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 9cee4d3ba..552998306 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -34,10 +34,17 @@ #include "SDL_cocoamouse.h" #include "SDL_cocoaopengl.h" +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070 +/* Taken from AppKit/NSOpenGLView.h in 10.8 SDK. */ +@interface NSView (NSOpenGLSurfaceResolution) +- (BOOL)wantsBestResolutionOpenGLSurface; +- (void)setWantsBestResolutionOpenGLSurface:(BOOL)flag; +@end +#endif static Uint32 s_moveHack; -static __inline__ void ConvertNSRect(NSRect *r) +static void ConvertNSRect(NSRect *r) { r->origin.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - r->origin.y - r->size.height; } @@ -62,6 +69,7 @@ static void ScheduleContextUpdates(SDL_WindowData *data) _data = data; observingVisible = YES; + wasCtrlLeft = NO; wasVisible = [window isVisible]; center = [NSNotificationCenter defaultCenter]; @@ -333,7 +341,13 @@ static void ScheduleContextUpdates(SDL_WindowData *data) switch ([theEvent buttonNumber]) { case 0: - button = SDL_BUTTON_LEFT; + if ([theEvent modifierFlags] & NSControlKeyMask) { + wasCtrlLeft = YES; + button = SDL_BUTTON_RIGHT; + } else { + wasCtrlLeft = NO; + button = SDL_BUTTON_LEFT; + } break; case 1: button = SDL_BUTTON_RIGHT; @@ -364,7 +378,12 @@ static void ScheduleContextUpdates(SDL_WindowData *data) switch ([theEvent buttonNumber]) { case 0: - button = SDL_BUTTON_LEFT; + if (wasCtrlLeft) { + button = SDL_BUTTON_RIGHT; + wasCtrlLeft = NO; + } else { + button = SDL_BUTTON_LEFT; + } break; case 1: button = SDL_BUTTON_RIGHT; @@ -727,6 +746,13 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window) /* Create a default view for this window */ rect = [nswindow contentRectForFrameRect:[nswindow frame]]; NSView *contentView = [[SDLView alloc] initWithFrame:rect]; + + if ((window->flags & SDL_WINDOW_ALLOW_HIGHDPI) > 0) { + if ([contentView respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)]) { + [contentView setWantsBestResolutionOpenGLSurface:YES]; + } + } + [nswindow setContentView: contentView]; [contentView release]; @@ -894,8 +920,9 @@ Cocoa_RaiseWindow(_THIS, SDL_Window * window) SDL_WindowData *windowData = ((SDL_WindowData *) window->driverdata); NSWindow *nswindow = windowData->nswindow; - // makeKeyAndOrderFront: has the side-effect of deminiaturizing and showing - // a minimized or hidden window, so check for that before showing it. + /* makeKeyAndOrderFront: has the side-effect of deminiaturizing and showing + a minimized or hidden window, so check for that before showing it. + */ [windowData->listener pauseVisibleObservation]; if (![nswindow isMiniaturized] && [nswindow isVisible]) { [nswindow makeKeyAndOrderFront:nil]; @@ -1031,8 +1058,8 @@ Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display } s_moveHack = 0; - [nswindow setFrameOrigin:rect.origin]; [nswindow setContentSize:rect.size]; + [nswindow setFrameOrigin:rect.origin]; s_moveHack = SDL_GetTicks(); /* When the window style changes the title is cleared */ @@ -1047,9 +1074,11 @@ Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display [nswindow setLevel:kCGNormalWindowLevel]; } - [data->listener pauseVisibleObservation]; - [nswindow makeKeyAndOrderFront:nil]; - [data->listener resumeVisibleObservation]; + if ([nswindow isVisible] || fullscreen) { + [data->listener pauseVisibleObservation]; + [nswindow makeKeyAndOrderFront:nil]; + [data->listener resumeVisibleObservation]; + } ScheduleContextUpdates(data); diff --git a/src/video/directfb/SDL_DirectFB_WM.c b/src/video/directfb/SDL_DirectFB_WM.c index 8241d9b3d..83912bded 100644 --- a/src/video/directfb/SDL_DirectFB_WM.c +++ b/src/video/directfb/SDL_DirectFB_WM.c @@ -131,7 +131,7 @@ DirectFB_WM_RedrawLayout(_THIS, SDL_Window * window) SDL_DFB_CHECK(s->SetBlittingFlags(s, DSBLIT_NOFX)); LoadFont(_this, window); - /*s->SetDrawingFlags(s, DSDRAW_BLEND); */ + /* s->SetDrawingFlags(s, DSDRAW_BLEND); */ s->SetColor(s, COLOR_EXPAND(t->frame_color)); /* top */ for (i = 0; i < t->top_size; i++) @@ -203,7 +203,7 @@ DirectFB_WM_AdjustWindowLayout(SDL_Window * window, int flags, int w, int h) if (!windata->is_managed) windata->theme = theme_none; else if (flags & SDL_WINDOW_BORDERLESS) - /*desc.caps |= DWCAPS_NODECORATION;) */ + /* desc.caps |= DWCAPS_NODECORATION;) */ windata->theme = theme_none; else if (flags & SDL_WINDOW_FULLSCREEN) { windata->theme = theme_none; @@ -351,7 +351,7 @@ DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt) dy = 0; SDL_DFB_CHECK(dfbwin->GetSize(dfbwin, &cw, &ch)); - /* necessary to trigger an event - ugly*/ + /* necessary to trigger an event - ugly */ SDL_DFB_CHECK(dfbwin->DisableEvents(dfbwin, DWET_ALL)); SDL_DFB_CHECK(dfbwin->Resize(dfbwin, cw + dx + 1, ch + dy)); SDL_DFB_CHECK(dfbwin->EnableEvents(dfbwin, DWET_ALL)); diff --git a/src/video/directfb/SDL_DirectFB_events.c b/src/video/directfb/SDL_DirectFB_events.c index 483ba9cb1..cb669bce1 100644 --- a/src/video/directfb/SDL_DirectFB_events.c +++ b/src/video/directfb/SDL_DirectFB_events.c @@ -132,7 +132,7 @@ MotionAllMice(_THIS, int x, int y) SDL_Mouse *mouse = SDL_GetMouse(index); mouse->x = mouse->last_x = x; mouse->y = mouse->last_y = y; - /*SDL_SendMouseMotion(devdata->mouse_id[index], 0, x, y, 0);*/ + /* SDL_SendMouseMotion(devdata->mouse_id[index], 0, x, y, 0); */ } #endif } @@ -233,7 +233,7 @@ ProcessWindowEvent(_THIS, SDL_Window *sdlwin, DFBWindowEvent * evt) case DWET_KEYDOWN: if (!devdata->use_linux_input) { DirectFB_TranslateKey(_this, evt, &keysym, &unicode); - /*printf("Scancode %d %d %d\n", keysym.scancode, evt->key_code, evt->key_id);*/ + /* printf("Scancode %d %d %d\n", keysym.scancode, evt->key_code, evt->key_id); */ SDL_SendKeyboardKey_ex(0, SDL_PRESSED, keysym.scancode); if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { SDL_zero(text); @@ -369,7 +369,7 @@ ProcessInputEvent(_THIS, DFBInputEvent * ievt) case DIET_KEYPRESS: kbd_idx = KbdIndex(_this, ievt->device_id); DirectFB_TranslateKeyInputEvent(_this, ievt, &keysym, &unicode); - /*printf("Scancode %d %d %d\n", keysym.scancode, evt->key_code, evt->key_id); */ + /* printf("Scancode %d %d %d\n", keysym.scancode, evt->key_code, evt->key_id); */ SDL_SendKeyboardKey_ex(kbd_idx, SDL_PRESSED, keysym.scancode); if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { SDL_zero(text); @@ -742,7 +742,7 @@ DirectFB_InitKeyboard(_THIS) void DirectFB_QuitKeyboard(_THIS) { - /*SDL_DFB_DEVICEDATA(_this); */ + /* SDL_DFB_DEVICEDATA(_this); */ SDL_KeyboardQuit(); diff --git a/src/video/directfb/SDL_DirectFB_render.c b/src/video/directfb/SDL_DirectFB_render.c index 958793db7..219f52070 100644 --- a/src/video/directfb/SDL_DirectFB_render.c +++ b/src/video/directfb/SDL_DirectFB_render.c @@ -131,7 +131,7 @@ SDL_RenderDriver DirectFB_RenderDriver = { (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD), (SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST | - SDL_SCALEMODE_SLOW | SDL_SCALEMODE_BEST),*/ + SDL_SCALEMODE_SLOW | SDL_SCALEMODE_BEST), */ 0, { /* formats filled in later */ @@ -167,7 +167,7 @@ typedef struct #endif } DirectFB_TextureData; -static __inline__ void +static SDL_INLINE void SDLtoDFBRect(const SDL_Rect * sr, DFBRectangle * dr) { dr->x = sr->x; @@ -175,7 +175,7 @@ SDLtoDFBRect(const SDL_Rect * sr, DFBRectangle * dr) dr->h = sr->h; dr->w = sr->w; } -static __inline__ void +static SDL_INLINE void SDLtoDFBRect_Float(const SDL_FRect * sr, DFBRectangle * dr) { dr->x = sr->x; @@ -211,7 +211,7 @@ TextureHasAlpha(DirectFB_TextureData * data) #endif } -static inline IDirectFBSurface *get_dfb_surface(SDL_Window *window) +static SDL_INLINE IDirectFBSurface *get_dfb_surface(SDL_Window *window) { SDL_SysWMinfo wm_info; SDL_memset(&wm_info, 0, sizeof(SDL_SysWMinfo)); @@ -222,7 +222,7 @@ static inline IDirectFBSurface *get_dfb_surface(SDL_Window *window) return wm_info.info.dfb.surface; } -static inline IDirectFBWindow *get_dfb_window(SDL_Window *window) +static SDL_INLINE IDirectFBWindow *get_dfb_window(SDL_Window *window) { SDL_SysWMinfo wm_info; SDL_memset(&wm_info, 0, sizeof(SDL_SysWMinfo)); @@ -266,7 +266,7 @@ SetBlendMode(DirectFB_RenderData * data, int blendMode, case SDL_BLENDMODE_ADD: data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL; data->drawFlags = DSDRAW_BLEND; - /* FIXME: SRCALPHA kills performance on radeon ... */ + /* FIXME: SRCALPHA kills performance on radeon ... * It will be cheaper to copy the surface to a temporary surface and premultiply */ if (source && TextureHasAlpha(source)) @@ -308,7 +308,7 @@ DisplayPaletteChanged(void *userdata, SDL_Palette * palette) entries[i].r = palette->colors[i].r; entries[i].g = palette->colors[i].g; entries[i].b = palette->colors[i].b; - entries[i].a = palette->colors[i].unused; + entries[i].a = palette->colors[i].a; } SDL_DFB_CHECKERR(surfpal->SetEntries(surfpal, entries, ncolors, 0)); return 0; @@ -326,8 +326,8 @@ DirectFB_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) { /* Rebind the context to the window area and update matrices */ - /*SDL_CurrentContext = NULL; */ - /*data->updateSize = SDL_TRUE; */ + /* SDL_CurrentContext = NULL; */ + /* data->updateSize = SDL_TRUE; */ renddata->size_changed = SDL_TRUE; } } @@ -379,7 +379,7 @@ DirectFB_CreateRenderer(SDL_Window * window, Uint32 flags) /* FIXME: Yet to be tested */ renderer->RenderReadPixels = DirectFB_RenderReadPixels; - /*renderer->RenderWritePixels = DirectFB_RenderWritePixels; */ + /* renderer->RenderWritePixels = DirectFB_RenderWritePixels; */ renderer->DestroyTexture = DirectFB_DestroyTexture; renderer->DestroyRenderer = DirectFB_DestroyRenderer; @@ -450,7 +450,7 @@ DirectFB_ActivateRenderer(SDL_Renderer * renderer) SDL_Window *window = renderer->window; SDL_DFB_WINDOWDATA(window); - if (renddata->size_changed /*|| windata->wm_needs_redraw*/) { + if (renddata->size_changed /* || windata->wm_needs_redraw */) { renddata->size_changed = SDL_FALSE; } } @@ -674,7 +674,7 @@ DirectFB_GetTexturePalette(SDL_Renderer * renderer, colors[i].r = entries[i].r; colors[i].g = entries[i].g; colors[i].b = entries[i].b; - colors[i].unused = SDL_ALPHA_OPAQUE; + colors[i].a = SDL_ALPHA_OPAQUE; } return 0; } else { @@ -701,7 +701,7 @@ DirectFB_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture) { switch (texture->blendMode) { case SDL_BLENDMODE_NONE: - /*case SDL_BLENDMODE_MASK: */ + /* case SDL_BLENDMODE_MASK: */ case SDL_BLENDMODE_BLEND: case SDL_BLENDMODE_ADD: case SDL_BLENDMODE_MOD: @@ -717,7 +717,7 @@ DirectFB_SetDrawBlendMode(SDL_Renderer * renderer) { switch (renderer->blendMode) { case SDL_BLENDMODE_NONE: - /*case SDL_BLENDMODE_MASK: */ + /* case SDL_BLENDMODE_MASK: */ case SDL_BLENDMODE_BLEND: case SDL_BLENDMODE_ADD: case SDL_BLENDMODE_MOD: @@ -916,7 +916,7 @@ PrepareDraw(SDL_Renderer * renderer) switch (renderer->blendMode) { case SDL_BLENDMODE_NONE: - /*case SDL_BLENDMODE_MASK: */ + /* case SDL_BLENDMODE_MASK: */ case SDL_BLENDMODE_BLEND: break; case SDL_BLENDMODE_ADD: @@ -1226,9 +1226,7 @@ DirectFB_DestroyRenderer(SDL_Renderer * renderer) } #endif - if (data) { - SDL_free(data); - } + SDL_free(data); SDL_free(renderer); } diff --git a/src/video/directfb/SDL_DirectFB_shape.c b/src/video/directfb/SDL_DirectFB_shape.c index 13c3d703e..358078f15 100644 --- a/src/video/directfb/SDL_DirectFB_shape.c +++ b/src/video/directfb/SDL_DirectFB_shape.c @@ -31,7 +31,7 @@ SDL_Window* DirectFB_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) { - return SDL_CreateWindow(title,x,y,w,h,flags /*| SDL_DFB_WINDOW_SHAPED */); + return SDL_CreateWindow(title,x,y,w,h,flags /* | SDL_DFB_WINDOW_SHAPED */); } SDL_WindowShaper* diff --git a/src/video/directfb/SDL_DirectFB_video.c b/src/video/directfb/SDL_DirectFB_video.c index d20b5f122..4e5eae4ed 100644 --- a/src/video/directfb/SDL_DirectFB_video.c +++ b/src/video/directfb/SDL_DirectFB_video.c @@ -258,7 +258,7 @@ DirectFB_VideoInit(_THIS) &devdata->events)); } else { SDL_DFB_CHECKERR(dfb->CreateInputEventBuffer(dfb, DICAPS_AXES - /*DICAPS_ALL */ , + /* DICAPS_ALL */ , DFB_TRUE, &devdata->events)); } diff --git a/src/video/directfb/SDL_DirectFB_video.h b/src/video/directfb/SDL_DirectFB_video.h index 53fcdcfb9..b40bac0d5 100644 --- a/src/video/directfb/SDL_DirectFB_video.h +++ b/src/video/directfb/SDL_DirectFB_video.h @@ -76,7 +76,7 @@ #define DFBENV_USE_WM "SDL_DIRECTFB_WM" /* Default: off */ #define SDL_DFB_RELEASE(x) do { if ( (x) != NULL ) { SDL_DFB_CHECK(x->Release(x)); x = NULL; } } while (0) -#define SDL_DFB_FREE(x) do { if ( (x) != NULL ) { SDL_free(x); x = NULL; } } while (0) +#define SDL_DFB_FREE(x) do { SDL_free((x)); (x) = NULL; } while (0) #define SDL_DFB_UNLOCK(x) do { if ( (x) != NULL ) { x->Unlock(x); } } while (0) #define SDL_DFB_CONTEXT "SDL_DirectFB" @@ -88,7 +88,7 @@ #define SDL_DFB_DEBUG(x...) SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, x) -static inline DFBResult sdl_dfb_check(DFBResult ret, const char *src_file, int src_line) { +static SDL_INLINE DFBResult sdl_dfb_check(DFBResult ret, const char *src_file, int src_line) { if (ret != DFB_OK) { SDL_DFB_LOG("%s (%d):%s", src_file, src_line, DirectFBErrorString (ret) ); SDL_SetError("%s:%s", SDL_DFB_CONTEXT, DirectFBErrorString (ret) ); diff --git a/src/video/directfb/SDL_DirectFB_window.c b/src/video/directfb/SDL_DirectFB_window.c index cdcb4cce6..e373d4beb 100644 --- a/src/video/directfb/SDL_DirectFB_window.c +++ b/src/video/directfb/SDL_DirectFB_window.c @@ -155,7 +155,7 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window) SDL_DFB_CHECK(windata->dfbwin->RaiseToTop(windata->dfbwin)); /* remember parent */ - /*windata->sdlwin = window; */ + /* windata->sdlwin = window; */ /* Add to list ... */ @@ -237,8 +237,7 @@ DirectFB_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) } return; error: - if (surface) - SDL_FreeSurface(surface); + SDL_FreeSurface(surface); SDL_DFB_RELEASE(windata->icon); return; } diff --git a/src/video/directfb/SDL_DirectFB_window.h b/src/video/directfb/SDL_DirectFB_window.h index a4a1cc840..96afc59ec 100644 --- a/src/video/directfb/SDL_DirectFB_window.h +++ b/src/video/directfb/SDL_DirectFB_window.h @@ -34,7 +34,7 @@ struct _DFB_WindowData IDirectFBSurface *surface; /* client drawing surface */ IDirectFBWindow *dfbwin; IDirectFBEventBuffer *eventbuffer; - /*SDL_Window *sdlwin; */ + /* SDL_Window *sdlwin; */ SDL_Window *next; Uint8 opacity; DFBRectangle client; diff --git a/src/video/dummy/SDL_nullframebuffer.c b/src/video/dummy/SDL_nullframebuffer.c index f3904918a..f18ceea26 100644 --- a/src/video/dummy/SDL_nullframebuffer.c +++ b/src/video/dummy/SDL_nullframebuffer.c @@ -38,9 +38,7 @@ int SDL_DUMMY_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * forma /* Free the old framebuffer surface */ surface = (SDL_Surface *) SDL_GetWindowData(window, DUMMY_SURFACE); - if (surface) { - SDL_FreeSurface(surface); - } + SDL_FreeSurface(surface); /* Create a new one */ SDL_PixelFormatEnumToMasks(surface_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask); @@ -83,9 +81,7 @@ void SDL_DUMMY_DestroyWindowFramebuffer(_THIS, SDL_Window * window) SDL_Surface *surface; surface = (SDL_Surface *) SDL_SetWindowData(window, DUMMY_SURFACE, NULL); - if (surface) { - SDL_FreeSurface(surface); - } + SDL_FreeSurface(surface); } #endif /* SDL_VIDEO_DRIVER_DUMMY */ diff --git a/src/video/dummy/SDL_nullvideo.c b/src/video/dummy/SDL_nullvideo.c index 21f1124b6..9d6ea6785 100644 --- a/src/video/dummy/SDL_nullvideo.c +++ b/src/video/dummy/SDL_nullvideo.c @@ -82,9 +82,7 @@ DUMMY_CreateDevice(int devindex) device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); if (!device) { SDL_OutOfMemory(); - if (device) { - SDL_free(device); - } + SDL_free(device); return (0); } diff --git a/src/video/psp/SDL_pspevents.c b/src/video/psp/SDL_pspevents.c index 54cd4e7d8..87bc52995 100644 --- a/src/video/psp/SDL_pspevents.c +++ b/src/video/psp/SDL_pspevents.c @@ -118,8 +118,8 @@ void PSP_PumpEvents(_THIS) pressed = scanData->pressed; sym.scancode = raw; sym.sym = keymap[raw]; - /* not tested*/ - /*SDL_PrivateKeyboard(pressed?SDL_PRESSED:SDL_RELEASED, &sym); */ + /* not tested */ + /* SDL_PrivateKeyboard(pressed?SDL_PRESSED:SDL_RELEASED, &sym); */ SDL_SendKeyboardKey((keys & keymap_psp[i].id) ? SDL_PRESSED : SDL_RELEASED, SDL_GetScancodeFromKey(keymap[raw]); diff --git a/src/video/psp/SDL_pspvideo.c b/src/video/psp/SDL_pspvideo.c index ed5ab1c96..64b48eb5e 100644 --- a/src/video/psp/SDL_pspvideo.c +++ b/src/video/psp/SDL_pspvideo.c @@ -306,7 +306,7 @@ PSP_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info) } -/* TO Write Me*/ +/* TO Write Me */ SDL_bool PSP_HasScreenKeyboardSupport(_THIS) { return SDL_FALSE; diff --git a/src/video/psp/SDL_pspvideo.h b/src/video/psp/SDL_pspvideo.h index d4ab32bfe..5b6435f56 100644 --- a/src/video/psp/SDL_pspvideo.h +++ b/src/video/psp/SDL_pspvideo.h @@ -91,7 +91,7 @@ int PSP_GL_GetSwapInterval(_THIS); void PSP_GL_SwapWindow(_THIS, SDL_Window * window); void PSP_GL_DeleteContext(_THIS, SDL_GLContext context); -/*PSP on screen keyboard */ +/* PSP on screen keyboard */ SDL_bool PSP_HasScreenKeyboardSupport(_THIS); void PSP_ShowScreenKeyboard(_THIS, SDL_Window *window); void PSP_HideScreenKeyboard(_THIS, SDL_Window *window); diff --git a/src/video/raspberry/SDL_rpievents.c b/src/video/raspberry/SDL_rpievents.c new file mode 100644 index 000000000..8c420fe71 --- /dev/null +++ b/src/video/raspberry/SDL_rpievents.c @@ -0,0 +1,45 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_RPI + +#include "../../events/SDL_sysevents.h" +#include "../../events/SDL_events_c.h" +#include "../../events/SDL_keyboard_c.h" +#include "SDL_rpivideo.h" +#include "SDL_rpievents_c.h" + +#ifdef SDL_INPUT_LINUXEV +#include "../../input/evdev/SDL_evdev.h" +#endif + +void RPI_PumpEvents(_THIS) +{ +#ifdef SDL_INPUT_LINUXEV + SDL_EVDEV_Poll(); +#endif + +} + +#endif /* SDL_VIDEO_DRIVER_RPI */ + diff --git a/src/video/raspberry/SDL_rpievents_c.h b/src/video/raspberry/SDL_rpievents_c.h new file mode 100644 index 000000000..54d3119d1 --- /dev/null +++ b/src/video/raspberry/SDL_rpievents_c.h @@ -0,0 +1,31 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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_rpievents_c_h +#define _SDL_rpievents_c_h + +#include "SDL_rpivideo.h" + +void RPI_PumpEvents(_THIS); +void RPI_EventInit(_THIS); +void RPI_EventQuit(_THIS); + +#endif /* _SDL_rpievents_c_h */ diff --git a/src/video/raspberry/SDL_rpimouse.c b/src/video/raspberry/SDL_rpimouse.c new file mode 100644 index 000000000..429214b91 --- /dev/null +++ b/src/video/raspberry/SDL_rpimouse.c @@ -0,0 +1,277 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_RPI + +#include "SDL_assert.h" +#include "SDL_surface.h" + +#include "SDL_rpivideo.h" +#include "SDL_rpimouse.h" + +#include "../SDL_sysvideo.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/default_cursor.h" + +/* Copied from vc_vchi_dispmanx.h which is bugged and tries to include a non existing file */ +/* Attributes changes flag mask */ +#define ELEMENT_CHANGE_LAYER (1<<0) +#define ELEMENT_CHANGE_OPACITY (1<<1) +#define ELEMENT_CHANGE_DEST_RECT (1<<2) +#define ELEMENT_CHANGE_SRC_RECT (1<<3) +#define ELEMENT_CHANGE_MASK_RESOURCE (1<<4) +#define ELEMENT_CHANGE_TRANSFORM (1<<5) +/* End copied from vc_vchi_dispmanx.h */ + +static SDL_Cursor *RPI_CreateDefaultCursor(void); +static SDL_Cursor *RPI_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y); +static int RPI_ShowCursor(SDL_Cursor * cursor); +static void RPI_MoveCursor(SDL_Cursor * cursor); +static void RPI_FreeCursor(SDL_Cursor * cursor); +static void RPI_WarpMouse(SDL_Window * window, int x, int y); + +static SDL_Cursor * +RPI_CreateDefaultCursor(void) +{ + return SDL_CreateCursor(default_cdata, default_cmask, DEFAULT_CWIDTH, DEFAULT_CHEIGHT, DEFAULT_CHOTX, DEFAULT_CHOTY); +} + +/* Create a cursor from a surface */ +static SDL_Cursor * +RPI_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) +{ + RPI_CursorData *curdata; + SDL_Cursor *cursor; + int ret; + VC_RECT_T dst_rect; + Uint32 dummy; + + SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888); + SDL_assert(surface->pitch == surface->w * 4); + + cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor)); + curdata = (RPI_CursorData *) SDL_calloc(1, sizeof(*curdata)); + + curdata->hot_x = hot_x; + curdata->hot_y = hot_y; + curdata->w = surface->w; + curdata->h = surface->h; + + /* This usage is inspired by Wayland/Weston RPI code, how they figured this out is anyone's guess */ + curdata->resource = vc_dispmanx_resource_create( VC_IMAGE_ARGB8888, surface->w | (surface->pitch << 16), surface->h | (surface->h << 16), &dummy ); + SDL_assert(curdata->resource); + vc_dispmanx_rect_set( &dst_rect, 0, 0, curdata->w, curdata->h); + /* A note from Weston: + * vc_dispmanx_resource_write_data() ignores ifmt, + * rect.x, rect.width, and uses stride only for computing + * the size of the transfer as rect.height * stride. + * Therefore we can only write rows starting at x=0. + */ + ret = vc_dispmanx_resource_write_data( curdata->resource, VC_IMAGE_ARGB8888, surface->pitch, surface->pixels, &dst_rect ); + SDL_assert ( ret == DISPMANX_SUCCESS ); + + cursor->driverdata = curdata; + + return cursor; + +} + +/* Show the specified cursor, or hide if cursor is NULL */ +static int +RPI_ShowCursor(SDL_Cursor * cursor) +{ + int ret; + DISPMANX_UPDATE_HANDLE_T update; + RPI_CursorData *curdata; + VC_RECT_T src_rect, dst_rect; + SDL_Mouse *mouse; + SDL_VideoDisplay *display; + SDL_DisplayData *data; + VC_DISPMANX_ALPHA_T alpha = { DISPMANX_FLAGS_ALPHA_FROM_SOURCE /* flags */ , 255 /*opacity 0->255*/, 0 /* mask */ }; + + mouse = SDL_GetMouse(); + if (mouse == NULL) { + return -1; + } + + if (cursor == NULL) { + /* FIXME: We hide the current mouse's cursor, what we actually need is *_HideCursor */ + + if ( mouse->cur_cursor != NULL && mouse->cur_cursor->driverdata != NULL) { + curdata = (RPI_CursorData *) mouse->cur_cursor->driverdata; + if (curdata->element > DISPMANX_NO_HANDLE) { + update = vc_dispmanx_update_start( 10 ); + SDL_assert( update ); + ret = vc_dispmanx_element_remove( update, curdata->element ); + SDL_assert( ret == DISPMANX_SUCCESS ); + ret = vc_dispmanx_update_submit_sync( update ); + SDL_assert( ret == DISPMANX_SUCCESS ); + curdata->element = DISPMANX_NO_HANDLE; + } + } + return 0; + } + + curdata = (RPI_CursorData *) cursor->driverdata; + if (curdata == NULL) { + return -1; + } + + if (mouse->focus == NULL) { + return -1; + } + + display = SDL_GetDisplayForWindow(mouse->focus); + if (display == NULL) { + return -1; + } + + data = (SDL_DisplayData*) display->driverdata; + if (data == NULL) { + return -1; + } + + if (curdata->element == DISPMANX_NO_HANDLE) { + vc_dispmanx_rect_set( &src_rect, 0, 0, curdata->w << 16, curdata->h << 16 ); + vc_dispmanx_rect_set( &dst_rect, 0, 0, curdata->w, curdata->h); + + update = vc_dispmanx_update_start( 10 ); + SDL_assert( update ); + + curdata->element = vc_dispmanx_element_add( update, + data->dispman_display, + SDL_RPI_MOUSELAYER, // layer + &dst_rect, + curdata->resource, + &src_rect, + DISPMANX_PROTECTION_NONE, + &alpha, + DISPMANX_NO_HANDLE, // clamp + VC_IMAGE_ROT0 ); + SDL_assert( curdata->element > DISPMANX_NO_HANDLE); + ret = vc_dispmanx_update_submit_sync( update ); + SDL_assert( ret == DISPMANX_SUCCESS ); + } + + return 0; +} + +/* Free a window manager cursor */ +static void +RPI_FreeCursor(SDL_Cursor * cursor) +{ + int ret; + DISPMANX_UPDATE_HANDLE_T update; + RPI_CursorData *curdata; + + if (cursor != NULL) { + curdata = (RPI_CursorData *) cursor->driverdata; + + if (curdata != NULL) { + if (curdata->element != DISPMANX_NO_HANDLE) { + update = vc_dispmanx_update_start( 10 ); + SDL_assert( update ); + ret = vc_dispmanx_element_remove( update, curdata->element ); + SDL_assert( ret == DISPMANX_SUCCESS ); + ret = vc_dispmanx_update_submit_sync( update ); + SDL_assert( ret == DISPMANX_SUCCESS ); + } + + if (curdata->resource != DISPMANX_NO_HANDLE) { + ret = vc_dispmanx_resource_delete( curdata->resource ); + SDL_assert( ret == DISPMANX_SUCCESS ); + } + + SDL_free(cursor->driverdata); + } + SDL_free(cursor); + } +} + +/* Warp the mouse to (x,y) */ +static void +RPI_WarpMouse(SDL_Window * window, int x, int y) +{ + RPI_CursorData *curdata; + DISPMANX_UPDATE_HANDLE_T update; + int ret; + VC_RECT_T dst_rect; + SDL_Mouse *mouse = SDL_GetMouse(); + + if (mouse != NULL && mouse->cur_cursor != NULL && mouse->cur_cursor->driverdata != NULL) { + curdata = (RPI_CursorData *) mouse->cur_cursor->driverdata; + if (curdata->element != DISPMANX_NO_HANDLE) { + update = vc_dispmanx_update_start( 10 ); + SDL_assert( update ); + vc_dispmanx_rect_set( &dst_rect, x, y, curdata->w, curdata->h); + ret = vc_dispmanx_element_change_attributes( + update, + curdata->element, + ELEMENT_CHANGE_DEST_RECT, + 0, + 0, + &dst_rect, + NULL, + DISPMANX_NO_HANDLE, + DISPMANX_NO_ROTATE); + SDL_assert( ret == DISPMANX_SUCCESS ); + /* Submit asynchronously, otherwise the peformance suffers a lot */ + ret = vc_dispmanx_update_submit( update, 0, NULL ); + SDL_assert( ret == DISPMANX_SUCCESS ); + } + } +} + +void +RPI_InitMouse(_THIS) +{ + /* FIXME: Using UDEV it should be possible to scan all mice + * but there's no point in doing so as there's no multimice support...yet! + */ + SDL_Mouse *mouse = SDL_GetMouse(); + + mouse->CreateCursor = RPI_CreateCursor; + mouse->ShowCursor = RPI_ShowCursor; + mouse->MoveCursor = RPI_MoveCursor; + mouse->FreeCursor = RPI_FreeCursor; + mouse->WarpMouse = RPI_WarpMouse; + + SDL_SetDefaultCursor(RPI_CreateDefaultCursor()); +} + +void +RPI_QuitMouse(_THIS) +{ + +} + +/* This is called when a mouse motion event occurs */ +static void +RPI_MoveCursor(SDL_Cursor * cursor) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + RPI_WarpMouse(mouse->focus, mouse->x, mouse->y); +} + +#endif /* SDL_VIDEO_DRIVER_RPI */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/raspberry/SDL_rpimouse.h b/src/video/raspberry/SDL_rpimouse.h new file mode 100644 index 000000000..aa8eec9ba --- /dev/null +++ b/src/video/raspberry/SDL_rpimouse.h @@ -0,0 +1,43 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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_RPI_mouse_h +#define _SDL_RPI_mouse_h + +#include "../SDL_sysvideo.h" + +typedef struct _RPI_CursorData RPI_CursorData; +struct _RPI_CursorData +{ + DISPMANX_RESOURCE_HANDLE_T resource; + DISPMANX_ELEMENT_HANDLE_T element; + int hot_x, hot_y; + int w, h; +}; + +#define SDL_RPI_CURSORDATA(curs) RPI_CursorData *curdata = (RPI_CursorData *) ((curs) ? (curs)->driverdata : NULL) + +extern void RPI_InitMouse(_THIS); +extern void RPI_QuitMouse(_THIS); + +#endif /* _SDL_RPI_mouse_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/raspberry/SDL_rpiopengles.c b/src/video/raspberry/SDL_rpiopengles.c new file mode 100644 index 000000000..23c89fe0d --- /dev/null +++ b/src/video/raspberry/SDL_rpiopengles.c @@ -0,0 +1,42 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_RPI && SDL_VIDEO_OPENGL_EGL + +#include "SDL_rpivideo.h" +#include "SDL_rpiopengles.h" + +/* EGL implementation of SDL OpenGL support */ + +int +RPI_GLES_LoadLibrary(_THIS, const char *path) { + return SDL_EGL_LoadLibrary(_this, path, EGL_DEFAULT_DISPLAY); +} + +SDL_EGL_CreateContext_impl(RPI) +SDL_EGL_SwapWindow_impl(RPI) +SDL_EGL_MakeCurrent_impl(RPI) + +#endif /* SDL_VIDEO_DRIVER_RPI && SDL_VIDEO_OPENGL_EGL */ + +/* vi: set ts=4 sw=4 expandtab: */ + diff --git a/src/video/raspberry/SDL_rpiopengles.h b/src/video/raspberry/SDL_rpiopengles.h new file mode 100644 index 000000000..deb4b2f36 --- /dev/null +++ b/src/video/raspberry/SDL_rpiopengles.h @@ -0,0 +1,48 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ +#include "SDL_config.h" + +#ifndef _SDL_rpiopengles_h +#define _SDL_rpiopengles_h + +#if SDL_VIDEO_DRIVER_RPI && SDL_VIDEO_OPENGL_EGL + +#include "../SDL_sysvideo.h" +#include "../SDL_egl.h" + +/* OpenGLES functions */ +#define RPI_GLES_GetAttribute SDL_EGL_GetAttribute +#define RPI_GLES_GetProcAddress SDL_EGL_GetProcAddress +#define RPI_GLES_UnloadLibrary SDL_EGL_UnloadLibrary +#define RPI_GLES_SetSwapInterval SDL_EGL_SetSwapInterval +#define RPI_GLES_GetSwapInterval SDL_EGL_GetSwapInterval +#define RPI_GLES_DeleteContext SDL_EGL_DeleteContext + +extern int RPI_GLES_LoadLibrary(_THIS, const char *path); +extern SDL_GLContext RPI_GLES_CreateContext(_THIS, SDL_Window * window); +extern void RPI_GLES_SwapWindow(_THIS, SDL_Window * window); +extern int RPI_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); + +#endif /* SDL_VIDEO_DRIVER_RPI && SDL_VIDEO_OPENGL_EGL */ + +#endif /* _SDL_rpiopengles_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/raspberry/SDL_rpivideo.c b/src/video/raspberry/SDL_rpivideo.c new file mode 100644 index 000000000..dfad9ba76 --- /dev/null +++ b/src/video/raspberry/SDL_rpivideo.c @@ -0,0 +1,360 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_RPI + +/* References + * http://elinux.org/RPi_VideoCore_APIs + * https://github.com/raspberrypi/firmware/blob/master/opt/vc/src/hello_pi/hello_triangle/triangle.c + * http://cgit.freedesktop.org/wayland/weston/tree/src/rpi-renderer.c + * http://cgit.freedesktop.org/wayland/weston/tree/src/compositor-rpi.c + */ + +/* SDL internals */ +#include "../SDL_sysvideo.h" +#include "SDL_version.h" +#include "SDL_syswm.h" +#include "SDL_loadso.h" +#include "SDL_events.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_keyboard_c.h" + +#ifdef SDL_INPUT_LINUXEV +#include "../../input/evdev/SDL_evdev.h" +#endif + +/* RPI declarations */ +#include "SDL_rpivideo.h" +#include "SDL_rpievents_c.h" +#include "SDL_rpiopengles.h" +#include "SDL_rpimouse.h" + +static int +RPI_Available(void) +{ + return 1; +} + +static void +RPI_Destroy(SDL_VideoDevice * device) +{ + /* SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; */ + + if (device->driverdata != NULL) { + device->driverdata = NULL; + } +} + +static SDL_VideoDevice * +RPI_Create() +{ + SDL_VideoDevice *device; + SDL_VideoData *phdata; + + /* Initialize SDL_VideoDevice structure */ + device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (device == NULL) { + SDL_OutOfMemory(); + return NULL; + } + + /* Initialize internal data */ + phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); + if (phdata == NULL) { + SDL_OutOfMemory(); + SDL_free(device); + return NULL; + } + + device->driverdata = phdata; + + /* Setup amount of available displays and current display */ + device->num_displays = 0; + + /* Set device free function */ + device->free = RPI_Destroy; + + /* Setup all functions which we can handle */ + device->VideoInit = RPI_VideoInit; + device->VideoQuit = RPI_VideoQuit; + device->GetDisplayModes = RPI_GetDisplayModes; + device->SetDisplayMode = RPI_SetDisplayMode; + device->CreateWindow = RPI_CreateWindow; + device->CreateWindowFrom = RPI_CreateWindowFrom; + device->SetWindowTitle = RPI_SetWindowTitle; + device->SetWindowIcon = RPI_SetWindowIcon; + device->SetWindowPosition = RPI_SetWindowPosition; + device->SetWindowSize = RPI_SetWindowSize; + device->ShowWindow = RPI_ShowWindow; + device->HideWindow = RPI_HideWindow; + device->RaiseWindow = RPI_RaiseWindow; + device->MaximizeWindow = RPI_MaximizeWindow; + device->MinimizeWindow = RPI_MinimizeWindow; + device->RestoreWindow = RPI_RestoreWindow; + device->SetWindowGrab = RPI_SetWindowGrab; + device->DestroyWindow = RPI_DestroyWindow; + device->GetWindowWMInfo = RPI_GetWindowWMInfo; + device->GL_LoadLibrary = RPI_GLES_LoadLibrary; + device->GL_GetProcAddress = RPI_GLES_GetProcAddress; + device->GL_UnloadLibrary = RPI_GLES_UnloadLibrary; + device->GL_CreateContext = RPI_GLES_CreateContext; + device->GL_MakeCurrent = RPI_GLES_MakeCurrent; + device->GL_SetSwapInterval = RPI_GLES_SetSwapInterval; + device->GL_GetSwapInterval = RPI_GLES_GetSwapInterval; + device->GL_SwapWindow = RPI_GLES_SwapWindow; + device->GL_DeleteContext = RPI_GLES_DeleteContext; + + device->PumpEvents = RPI_PumpEvents; + + return device; +} + +VideoBootStrap RPI_bootstrap = { + "RPI", + "RPI Video Driver", + RPI_Available, + RPI_Create +}; + +/*****************************************************************************/ +/* SDL Video and Display initialization/handling functions */ +/*****************************************************************************/ +int +RPI_VideoInit(_THIS) +{ + SDL_VideoDisplay display; + SDL_DisplayMode current_mode; + SDL_DisplayData *data; + uint32_t w,h; + + /* Initialize BCM Host */ + bcm_host_init(); + + SDL_zero(current_mode); + + if (graphics_get_display_size( 0, &w, &h) < 0) { + return -1; + } + + current_mode.w = w; + current_mode.h = h; + /* FIXME: Is there a way to tell the actual refresh rate? */ + current_mode.refresh_rate = 60; + /* 32 bpp for default */ + current_mode.format = SDL_PIXELFORMAT_ABGR8888; + + current_mode.driverdata = NULL; + + SDL_zero(display); + display.desktop_mode = current_mode; + display.current_mode = current_mode; + + /* Allocate display internal data */ + data = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData)); + if (data == NULL) { + return SDL_OutOfMemory(); + } + + data->dispman_display = vc_dispmanx_display_open( 0 /* LCD */); + + display.driverdata = data; + + SDL_AddVideoDisplay(&display); + +#ifdef SDL_INPUT_LINUXEV + SDL_EVDEV_Init(); +#endif + + RPI_InitMouse(_this); + + return 1; +} + +void +RPI_VideoQuit(_THIS) +{ +#ifdef SDL_INPUT_LINUXEV + SDL_EVDEV_Quit(); +#endif +} + +void +RPI_GetDisplayModes(_THIS, SDL_VideoDisplay * display) +{ + /* Only one display mode available, the current one */ + SDL_AddDisplayMode(display, &display->current_mode); +} + +int +RPI_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) +{ + return 0; +} + +int +RPI_CreateWindow(_THIS, SDL_Window * window) +{ + SDL_WindowData *wdata; + SDL_VideoDisplay *display; + SDL_DisplayData *displaydata; + VC_RECT_T dst_rect; + VC_RECT_T src_rect; + VC_DISPMANX_ALPHA_T dispman_alpha; + DISPMANX_UPDATE_HANDLE_T dispman_update; + + /* Disable alpha, otherwise the app looks composed with whatever dispman is showing (X11, console,etc) */ + dispman_alpha.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS; + dispman_alpha.opacity = 0xFF; + dispman_alpha.mask = 0; + + /* Allocate window internal data */ + wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData)); + if (wdata == NULL) { + return SDL_OutOfMemory(); + } + display = SDL_GetDisplayForWindow(window); + displaydata = (SDL_DisplayData *) display->driverdata; + + /* Windows have one size for now */ + window->w = display->desktop_mode.w; + window->h = display->desktop_mode.h; + + /* OpenGL ES is the law here, buddy */ + window->flags |= SDL_WINDOW_OPENGL; + + /* Create a dispman element and associate a window to it */ + dst_rect.x = 0; + dst_rect.y = 0; + dst_rect.width = window->w; + dst_rect.height = window->h; + + src_rect.x = 0; + src_rect.y = 0; + src_rect.width = window->w << 16; + src_rect.height = window->h << 16; + + dispman_update = vc_dispmanx_update_start( 0 ); + wdata->dispman_window.element = vc_dispmanx_element_add ( dispman_update, displaydata->dispman_display, SDL_RPI_VIDEOLAYER /* layer */, &dst_rect, 0/*src*/, &src_rect, DISPMANX_PROTECTION_NONE, &dispman_alpha /*alpha*/, 0/*clamp*/, 0/*transform*/); + wdata->dispman_window.width = window->w; + wdata->dispman_window.height = window->h; + vc_dispmanx_update_submit_sync( dispman_update ); + + if (!_this->egl_data) { + if (SDL_GL_LoadLibrary(NULL) < 0) { + return -1; + } + } + wdata->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) &wdata->dispman_window); + + if (wdata->egl_surface == EGL_NO_SURFACE) { + return SDL_SetError("Could not create GLES window surface"); + } + + /* Setup driver data for this window */ + window->driverdata = wdata; + + /* One window, it always has focus */ + SDL_SetMouseFocus(window); + SDL_SetKeyboardFocus(window); + + /* Window has been successfully created */ + return 0; +} + +int +RPI_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) +{ + return -1; +} + +void +RPI_SetWindowTitle(_THIS, SDL_Window * window) +{ +} +void +RPI_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) +{ +} +void +RPI_SetWindowPosition(_THIS, SDL_Window * window) +{ +} +void +RPI_SetWindowSize(_THIS, SDL_Window * window) +{ +} +void +RPI_ShowWindow(_THIS, SDL_Window * window) +{ +} +void +RPI_HideWindow(_THIS, SDL_Window * window) +{ +} +void +RPI_RaiseWindow(_THIS, SDL_Window * window) +{ +} +void +RPI_MaximizeWindow(_THIS, SDL_Window * window) +{ +} +void +RPI_MinimizeWindow(_THIS, SDL_Window * window) +{ +} +void +RPI_RestoreWindow(_THIS, SDL_Window * window) +{ +} +void +RPI_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) +{ + +} +void +RPI_DestroyWindow(_THIS, SDL_Window * window) +{ +} + +/*****************************************************************************/ +/* SDL Window Manager function */ +/*****************************************************************************/ +SDL_bool +RPI_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info) +{ + if (info->version.major <= SDL_MAJOR_VERSION) { + return SDL_TRUE; + } else { + SDL_SetError("application not compiled with SDL %d.%d\n", + SDL_MAJOR_VERSION, SDL_MINOR_VERSION); + return SDL_FALSE; + } + + /* Failed to get window manager information */ + return SDL_FALSE; +} + +#endif /* SDL_VIDEO_DRIVER_RPI */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/raspberry/SDL_rpivideo.h b/src/video/raspberry/SDL_rpivideo.h new file mode 100644 index 000000000..6359badc9 --- /dev/null +++ b/src/video/raspberry/SDL_rpivideo.h @@ -0,0 +1,98 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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_RPIVIDEO_H__ +#define __SDL_RPIVIDEO_H__ + +#include "SDL_config.h" +#include "../SDL_sysvideo.h" + +#include "bcm_host.h" +#include "GLES/gl.h" +#include "EGL/egl.h" +#include "EGL/eglext.h" + +typedef struct SDL_VideoData +{ + uint32_t egl_refcount; /* OpenGL ES reference count */ +} SDL_VideoData; + + +typedef struct SDL_DisplayData +{ + DISPMANX_DISPLAY_HANDLE_T dispman_display; +} SDL_DisplayData; + + +typedef struct SDL_WindowData +{ + EGL_DISPMANX_WINDOW_T dispman_window; +#if SDL_VIDEO_OPENGL_EGL + EGLSurface egl_surface; +#endif +} SDL_WindowData; + +#define SDL_RPI_VIDEOLAYER 10000 /* High enough so to occlude everything */ +#define SDL_RPI_MOUSELAYER SDL_RPI_VIDEOLAYER + 1 + + +/****************************************************************************/ +/* SDL_VideoDevice functions declaration */ +/****************************************************************************/ + +/* Display and window functions */ +int RPI_VideoInit(_THIS); +void RPI_VideoQuit(_THIS); +void RPI_GetDisplayModes(_THIS, SDL_VideoDisplay * display); +int RPI_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); +int RPI_CreateWindow(_THIS, SDL_Window * window); +int RPI_CreateWindowFrom(_THIS, SDL_Window * window, const void *data); +void RPI_SetWindowTitle(_THIS, SDL_Window * window); +void RPI_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon); +void RPI_SetWindowPosition(_THIS, SDL_Window * window); +void RPI_SetWindowSize(_THIS, SDL_Window * window); +void RPI_ShowWindow(_THIS, SDL_Window * window); +void RPI_HideWindow(_THIS, SDL_Window * window); +void RPI_RaiseWindow(_THIS, SDL_Window * window); +void RPI_MaximizeWindow(_THIS, SDL_Window * window); +void RPI_MinimizeWindow(_THIS, SDL_Window * window); +void RPI_RestoreWindow(_THIS, SDL_Window * window); +void RPI_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed); +void RPI_DestroyWindow(_THIS, SDL_Window * window); + +/* Window manager function */ +SDL_bool RPI_GetWindowWMInfo(_THIS, SDL_Window * window, + struct SDL_SysWMinfo *info); + +/* OpenGL/OpenGL ES functions */ +int RPI_GLES_LoadLibrary(_THIS, const char *path); +void *RPI_GLES_GetProcAddress(_THIS, const char *proc); +void RPI_GLES_UnloadLibrary(_THIS); +SDL_GLContext RPI_GLES_CreateContext(_THIS, SDL_Window * window); +int RPI_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); +int RPI_GLES_SetSwapInterval(_THIS, int interval); +int RPI_GLES_GetSwapInterval(_THIS); +void RPI_GLES_SwapWindow(_THIS, SDL_Window * window); +void RPI_GLES_DeleteContext(_THIS, SDL_GLContext context); + +#endif /* __SDL_RPIVIDEO_H__ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/uikit/SDL_uikitopenglview.m b/src/video/uikit/SDL_uikitopenglview.m index 9f3dc136a..b43f3455f 100644 --- a/src/video/uikit/SDL_uikitopenglview.m +++ b/src/video/uikit/SDL_uikitopenglview.m @@ -121,6 +121,8 @@ if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { return NO; } + + glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); /* end create buffers */ self.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight); @@ -148,6 +150,8 @@ glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer); glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depthBufferFormat, backingWidth, backingHeight); } + + glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); } - (void)setAnimationCallback:(int)interval @@ -197,7 +201,9 @@ - (void)swapBuffers { - glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); + /* viewRenderbuffer should always be bound here. Code that binds something + else is responsible for rebinding viewRenderbuffer, to reduce + duplicate state changes. */ [context presentRenderbuffer:GL_RENDERBUFFER_OES]; } diff --git a/src/video/uikit/SDL_uikitvideo.m b/src/video/uikit/SDL_uikitvideo.m index 662b10906..74b24b8da 100644 --- a/src/video/uikit/SDL_uikitvideo.m +++ b/src/video/uikit/SDL_uikitvideo.m @@ -63,9 +63,7 @@ UIKit_CreateDevice(int devindex) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); if (!device) { - if (device) { - SDL_free(device); - } + SDL_free(device); SDL_OutOfMemory(); return (0); } diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m index e808962ef..66129be23 100644 --- a/src/video/uikit/SDL_uikitview.m +++ b/src/video/uikit/SDL_uikitview.m @@ -246,8 +246,8 @@ { if ([string length] == 0) { /* it wants to replace text with nothing, ie a delete */ - SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE); - SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE); + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_BACKSPACE); + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_BACKSPACE); } else { /* go through all the characters in the string we've been sent diff --git a/src/video/uikit/SDL_uikitviewcontroller.h b/src/video/uikit/SDL_uikitviewcontroller.h index 2bc664d6c..a69c1e117 100644 --- a/src/video/uikit/SDL_uikitviewcontroller.h +++ b/src/video/uikit/SDL_uikitviewcontroller.h @@ -35,5 +35,6 @@ - (void)viewDidLayoutSubviews; - (NSUInteger)supportedInterfaceOrientations; - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient; +- (BOOL)prefersStatusBarHidden; @end diff --git a/src/video/uikit/SDL_uikitviewcontroller.m b/src/video/uikit/SDL_uikitviewcontroller.m index 157b70aa0..077c160da 100644 --- a/src/video/uikit/SDL_uikitviewcontroller.m +++ b/src/video/uikit/SDL_uikitviewcontroller.m @@ -119,6 +119,15 @@ return (orientationMask & (1 << orient)); } +- (BOOL)prefersStatusBarHidden +{ + if (self->window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) { + return YES; + } else { + return NO; + } +} + @end #endif /* SDL_VIDEO_DRIVER_UIKIT */ diff --git a/src/video/uikit/SDL_uikitwindow.m b/src/video/uikit/SDL_uikitwindow.m index 0285b6bcc..6a1946202 100644 --- a/src/video/uikit/SDL_uikitwindow.m +++ b/src/video/uikit/SDL_uikitwindow.m @@ -99,11 +99,13 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo if (displaydata->uiscreen == [UIScreen mainScreen]) { window->flags |= SDL_WINDOW_INPUT_FOCUS; /* always has input focus */ + /* This was setup earlier for our window, and in iOS 7 is controlled by the view, not the application if ([UIApplication sharedApplication].statusBarHidden) { window->flags |= SDL_WINDOW_BORDERLESS; } else { window->flags &= ~SDL_WINDOW_BORDERLESS; } + */ } else { window->flags &= ~SDL_WINDOW_RESIZABLE; /* window is NEVER resizeable */ window->flags &= ~SDL_WINDOW_INPUT_FOCUS; /* never has input focus */ diff --git a/src/video/uikit/keyinfotable.h b/src/video/uikit/keyinfotable.h index d12674b9a..d588f915e 100644 --- a/src/video/uikit/keyinfotable.h +++ b/src/video/uikit/keyinfotable.h @@ -166,7 +166,7 @@ static UIKitKeyInfo unicharToUIKeyInfoTable[] = { /* 124 */{ SDL_SCANCODE_BACKSLASH, KMOD_SHIFT }, /* plus shift modifier '|' */ /* 125 */{ SDL_SCANCODE_RIGHTBRACKET, KMOD_SHIFT }, /* plus shift modifier '}' */ /* 126 */{ SDL_SCANCODE_GRAVE, KMOD_SHIFT }, /* plus shift modifier '~' */ -/* 127 */{ SDL_SCANCODE_DELETE, KMOD_SHIFT } +/* 127 */{ SDL_SCANCODE_BACKSPACE, KMOD_SHIFT } }; #endif /* UIKitKeyInfo */ diff --git a/src/video/windows/SDL_windowsclipboard.c b/src/video/windows/SDL_windowsclipboard.c index 3d1db4a41..15eea1aa8 100644 --- a/src/video/windows/SDL_windowsclipboard.c +++ b/src/video/windows/SDL_windowsclipboard.c @@ -137,7 +137,7 @@ WIN_HasClipboardText(_THIS) SDL_bool result = SDL_FALSE; char *text = WIN_GetClipboardText(_this); if (text) { - result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE; + result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE; SDL_free(text); } return result; diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index acf8d5e51..1826258c8 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -36,7 +36,7 @@ /* For GET_X_LPARAM, GET_Y_LPARAM. */ #include -/*#define WMMSG_DEBUG*/ +/* #define WMMSG_DEBUG */ #ifdef WMMSG_DEBUG #include #include "wmmsg.h" @@ -256,6 +256,33 @@ WIN_CheckRawMouseButtons( ULONG rawButtons, SDL_WindowData *data ) } } +SDL_FORCE_INLINE BOOL +WIN_ConvertUTF32toUTF8(UINT32 codepoint, char * text) +{ + if (codepoint <= 0x7F) { + text[0] = (char) codepoint; + text[1] = '\0'; + } else if (codepoint <= 0x7FF) { + text[0] = 0xC0 | (char) ((codepoint >> 6) & 0x1F); + text[1] = 0x80 | (char) (codepoint & 0x3F); + text[2] = '\0'; + } else if (codepoint <= 0xFFFF) { + text[0] = 0xE0 | (char) ((codepoint >> 12) & 0x0F); + text[1] = 0x80 | (char) ((codepoint >> 6) & 0x3F); + text[2] = 0x80 | (char) (codepoint & 0x3F); + text[3] = '\0'; + } else if (codepoint <= 0x10FFFF) { + text[0] = 0xF0 | (char) ((codepoint >> 18) & 0x0F); + text[1] = 0x80 | (char) ((codepoint >> 12) & 0x3F); + text[2] = 0x80 | (char) ((codepoint >> 6) & 0x3F); + text[3] = 0x80 | (char) (codepoint & 0x3F); + text[4] = '\0'; + } else { + return SDL_FALSE; + } + return SDL_TRUE; +} + LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -282,18 +309,16 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } #ifdef WMMSG_DEBUG - { - FILE *log = fopen("wmmsg.txt", "a"); - fprintf(log, "Received windows message: %p ", hwnd); - if (msg > MAX_WMMSG) { - fprintf(log, "%d", msg); - } else { - fprintf(log, "%s", wmtab[msg]); - } - fprintf(log, " -- 0x%X, 0x%X\n", wParam, lParam); - fclose(log); - } -#endif + { + char message[1024]; + if (msg > MAX_WMMSG) { + SDL_snprintf(message, sizeof(message), "Received windows message: %p UNKNOWN (%d) -- 0x%X, 0x%X\n", hwnd, msg, wParam, lParam); + } else { + SDL_snprintf(message, sizeof(message), "Received windows message: %p %s -- 0x%X, 0x%X\n", hwnd, wmtab[msg], wParam, lParam); + } + OutputDebugStringA(message); + } +#endif /* WMMSG_DEBUG */ if (IME_HandleMessage(hwnd, msg, wParam, &lParam, data->videodata)) return 0; @@ -439,10 +464,20 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_MOUSEWHEEL: { - /* FIXME: This may need to accumulate deltas up to WHEEL_DELTA */ - short motion = GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA; + static short s_AccumulatedMotion; - SDL_SendMouseWheel(data->window, 0, 0, motion); + s_AccumulatedMotion += GET_WHEEL_DELTA_WPARAM(wParam); + if (s_AccumulatedMotion > 0) { + while (s_AccumulatedMotion >= WHEEL_DELTA) { + SDL_SendMouseWheel(data->window, 0, 0, 1); + s_AccumulatedMotion -= WHEEL_DELTA; + } + } else { + while (s_AccumulatedMotion <= -WHEEL_DELTA) { + SDL_SendMouseWheel(data->window, 0, 0, -1); + s_AccumulatedMotion += WHEEL_DELTA; + } + } break; } @@ -459,14 +494,28 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) break; #endif /* WM_MOUSELEAVE */ - case WM_SYSKEYDOWN: case WM_KEYDOWN: + case WM_SYSKEYDOWN: { SDL_Scancode code = WindowsScanCodeToSDLScanCode( lParam, wParam ); if ( code != SDL_SCANCODE_UNKNOWN ) { SDL_SendKeyboardKey(SDL_PRESSED, code ); } } + if (msg == WM_KEYDOWN) { + BYTE keyboardState[256]; + char text[5]; + UINT32 utf32 = 0; + + GetKeyboardState(keyboardState); + if (ToUnicode(wParam, (lParam >> 16) & 0xff, keyboardState, (LPWSTR)&utf32, 1, 0) > 0) { + WORD repitition; + for (repitition = lParam & 0xffff; repitition > 0; repitition--) { + WIN_ConvertUTF32toUTF8(utf32, text); + SDL_SendKeyboardText(text); + } + } + } returnCode = 0; break; @@ -485,24 +534,19 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) returnCode = 0; break; + case WM_UNICHAR: + { + if (wParam == UNICODE_NOCHAR) { + returnCode = 1; + break; + } + } + /* no break */ case WM_CHAR: { - char text[4]; + char text[5]; - /* Convert to UTF-8 and send it on... */ - if (wParam <= 0x7F) { - text[0] = (char) wParam; - text[1] = '\0'; - } else if (wParam <= 0x7FF) { - text[0] = 0xC0 | (char) ((wParam >> 6) & 0x1F); - text[1] = 0x80 | (char) (wParam & 0x3F); - text[2] = '\0'; - } else { - text[0] = 0xE0 | (char) ((wParam >> 12) & 0x0F); - text[1] = 0x80 | (char) ((wParam >> 6) & 0x3F); - text[2] = 0x80 | (char) (wParam & 0x3F); - text[3] = '\0'; - } + WIN_ConvertUTF32toUTF8(wParam, text); SDL_SendKeyboardText(text); } returnCode = 0; @@ -772,7 +816,6 @@ WIN_PumpEvents(_THIS) const Uint8 *keystate; MSG msg; while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - TranslateMessage(&msg); DispatchMessage(&msg); } diff --git a/src/video/windows/SDL_windowskeyboard.c b/src/video/windows/SDL_windowskeyboard.c index de5848043..17d4eed45 100644 --- a/src/video/windows/SDL_windowskeyboard.c +++ b/src/video/windows/SDL_windowskeyboard.c @@ -758,10 +758,10 @@ IME_GetCandidateList(HIMC himc, SDL_VideoData *videodata) if (LANG() == LANG_CHS && IME_GetId(videodata, 0)) { const UINT maxcandchar = 18; UINT i = 0; - UINT cchars = 0; + size_t cchars = 0; for (; i < videodata->ime_candcount; ++i) { - UINT len = SDL_wcslen((LPWSTR)((DWORD_PTR)cand_list + cand_list->dwOffset[i])) + 1; + size_t len = SDL_wcslen((LPWSTR)((DWORD_PTR)cand_list + cand_list->dwOffset[i])) + 1; if (len + cchars > maxcandchar) { if (i > cand_list->dwSelection) break; diff --git a/src/video/windows/SDL_windowsmessagebox.c b/src/video/windows/SDL_windowsmessagebox.c index bbe79237f..06937adba 100644 --- a/src/video/windows/SDL_windowsmessagebox.c +++ b/src/video/windows/SDL_windowsmessagebox.c @@ -22,7 +22,9 @@ #if SDL_VIDEO_DRIVER_WINDOWS -#include "SDL.h" +#include "../../core/windows/SDL_windows.h" + +#include "SDL_assert.h" #include "SDL_windowsvideo.h" @@ -233,9 +235,7 @@ static SDL_bool AddDialogButton(WIN_DialogData *dialog, int x, int y, int w, int static void FreeDialogData(WIN_DialogData *dialog) { - if (dialog->data) { - SDL_free(dialog->data); - } + SDL_free(dialog->data); SDL_free(dialog); } @@ -342,7 +342,8 @@ int WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) { WIN_DialogData *dialog; - int i, x, y, which; + int i, x, y; + UINT_PTR which; const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons; HFONT DialogFont; SIZE Size; diff --git a/src/video/windows/SDL_windowsopengl.c b/src/video/windows/SDL_windowsopengl.c index 9cda41596..20d9913d8 100644 --- a/src/video/windows/SDL_windowsopengl.c +++ b/src/video/windows/SDL_windowsopengl.c @@ -23,6 +23,7 @@ #if SDL_VIDEO_DRIVER_WINDOWS #include "SDL_assert.h" +#include "SDL_loadso.h" #include "SDL_windowsvideo.h" /* WGL implementation of SDL OpenGL support */ @@ -67,6 +68,11 @@ #define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 #endif +#ifndef WGL_ARB_framebuffer_sRGB +#define WGL_ARB_framebuffer_sRGB +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 +#endif + typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, @@ -76,8 +82,7 @@ typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, int WIN_GL_LoadLibrary(_THIS, const char *path) { - LPTSTR wpath; - HANDLE handle; + void *handle; if (path == NULL) { path = SDL_getenv("SDL_OPENGL_LIBRARY"); @@ -85,23 +90,15 @@ WIN_GL_LoadLibrary(_THIS, const char *path) if (path == NULL) { path = DEFAULT_OPENGL; } - wpath = WIN_UTF8ToString(path); - _this->gl_config.dll_handle = LoadLibrary(wpath); - SDL_free(wpath); + _this->gl_config.dll_handle = SDL_LoadObject(path); if (!_this->gl_config.dll_handle) { - char message[1024]; - SDL_snprintf(message, SDL_arraysize(message), "LoadLibrary(\"%s\")", - path); - return WIN_SetError(message); + return -1; } SDL_strlcpy(_this->gl_config.driver_path, path, SDL_arraysize(_this->gl_config.driver_path)); /* Allocate OpenGL memory */ - _this->gl_data = - (struct SDL_GLDriverData *) SDL_calloc(1, - sizeof(struct - SDL_GLDriverData)); + _this->gl_data = (struct SDL_GLDriverData *) SDL_calloc(1, sizeof(struct SDL_GLDriverData)); if (!_this->gl_data) { return SDL_OutOfMemory(); } @@ -109,21 +106,20 @@ WIN_GL_LoadLibrary(_THIS, const char *path) /* Load function pointers */ handle = _this->gl_config.dll_handle; _this->gl_data->wglGetProcAddress = (void *(WINAPI *) (const char *)) - GetProcAddress(handle, "wglGetProcAddress"); + SDL_LoadFunction(handle, "wglGetProcAddress"); _this->gl_data->wglCreateContext = (HGLRC(WINAPI *) (HDC)) - GetProcAddress(handle, "wglCreateContext"); + SDL_LoadFunction(handle, "wglCreateContext"); _this->gl_data->wglDeleteContext = (BOOL(WINAPI *) (HGLRC)) - GetProcAddress(handle, "wglDeleteContext"); + SDL_LoadFunction(handle, "wglDeleteContext"); _this->gl_data->wglMakeCurrent = (BOOL(WINAPI *) (HDC, HGLRC)) - GetProcAddress(handle, "wglMakeCurrent"); + SDL_LoadFunction(handle, "wglMakeCurrent"); _this->gl_data->wglShareLists = (BOOL(WINAPI *) (HGLRC, HGLRC)) - GetProcAddress(handle, "wglShareLists"); + SDL_LoadFunction(handle, "wglShareLists"); if (!_this->gl_data->wglGetProcAddress || !_this->gl_data->wglCreateContext || !_this->gl_data->wglDeleteContext || !_this->gl_data->wglMakeCurrent) { - SDL_UnloadObject(handle); return SDL_SetError("Could not retrieve OpenGL functions"); } @@ -147,7 +143,7 @@ WIN_GL_GetProcAddress(_THIS, const char *proc) void WIN_GL_UnloadLibrary(_THIS) { - FreeLibrary((HMODULE) _this->gl_config.dll_handle); + SDL_UnloadObject(_this->gl_config.dll_handle); _this->gl_config.dll_handle = NULL; /* Free OpenGL memory */ @@ -495,6 +491,11 @@ WIN_GL_SetupWindowInternal(_THIS, SDL_Window * window) *iAttr++ = _this->gl_config.multisamplesamples; } + if (_this->gl_config.framebuffer_srgb_capable) { + *iAttr++ = WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB; + *iAttr++ = _this->gl_config.framebuffer_srgb_capable; + } + /* We always choose either FULL or NO accel on Windows, because of flaky drivers. If the app didn't specify, we use FULL, because that's probably what they wanted (and if you didn't care and got FULL, that's diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c index 883cafae4..8f708cf0d 100644 --- a/src/video/windows/SDL_windowsvideo.c +++ b/src/video/windows/SDL_windowsvideo.c @@ -25,6 +25,7 @@ #include "SDL_main.h" #include "SDL_video.h" #include "SDL_mouse.h" +#include "SDL_system.h" #include "../SDL_sysvideo.h" #include "../SDL_pixels_c.h" @@ -75,9 +76,7 @@ WIN_CreateDevice(int devindex) data = NULL; } if (!data) { - if (device) { - SDL_free(device); - } + SDL_free(device); SDL_OutOfMemory(); return NULL; } @@ -176,6 +175,76 @@ WIN_VideoQuit(_THIS) WIN_QuitMouse(_this); } + +#define D3D_DEBUG_INFO +#include + +SDL_bool +D3D_LoadDLL( void **pD3DDLL, IDirect3D9 **pDirect3D9Interface ) +{ + *pD3DDLL = SDL_LoadObject("D3D9.DLL"); + if (*pD3DDLL) { + IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion); + + D3DCreate = + (IDirect3D9 * (WINAPI *) (UINT)) SDL_LoadFunction(*pD3DDLL, + "Direct3DCreate9"); + if (D3DCreate) { + *pDirect3D9Interface = D3DCreate(D3D_SDK_VERSION); + } + if (!*pDirect3D9Interface) { + SDL_UnloadObject(*pD3DDLL); + *pD3DDLL = NULL; + return SDL_FALSE; + } + + return SDL_TRUE; + } else { + *pDirect3D9Interface = NULL; + return SDL_FALSE; + } +} + + +int +SDL_Direct3D9GetAdapterIndex( int displayIndex ) +{ + void *pD3DDLL; + IDirect3D9 *pD3D; + if (!D3D_LoadDLL(&pD3DDLL, &pD3D)) { + SDL_SetError("Unable to create Direct3D interface"); + return D3DADAPTER_DEFAULT; + } else { + SDL_DisplayData *pData = (SDL_DisplayData *)SDL_GetDisplayDriverData(displayIndex); + int adapterIndex = D3DADAPTER_DEFAULT; + + if (!pData) { + SDL_SetError("Invalid display index"); + adapterIndex = -1; /* make sure we return something invalid */ + } else { + char *displayName = WIN_StringToUTF8(pData->DeviceName); + unsigned int count = IDirect3D9_GetAdapterCount(pD3D); + unsigned int i; + for (i=0; i #else @@ -170,6 +170,10 @@ typedef struct SDL_VideoData TSFSink *ime_ippasink; } SDL_VideoData; + +typedef struct IDirect3D9 IDirect3D9; +extern SDL_bool D3D_LoadDLL( void **pD3DDLL, IDirect3D9 **pDirect3D9Interface ); + #endif /* _SDL_windowsvideo_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index e83115f00..cd53975d1 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -22,6 +22,8 @@ #if SDL_VIDEO_DRIVER_WINDOWS +#include "../../core/windows/SDL_windows.h" + #include "SDL_assert.h" #include "../SDL_sysvideo.h" #include "../SDL_pixels_c.h" @@ -113,7 +115,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created) SDL_WindowData *data; /* Allocate the window data */ - data = (SDL_WindowData *) SDL_malloc(sizeof(*data)); + data = (SDL_WindowData *) SDL_calloc(1, sizeof(*data)); if (!data) { return SDL_OutOfMemory(); } @@ -157,7 +159,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created) int w = rect.right; int h = rect.bottom; if ((window->w && window->w != w) || (window->h && window->h != h)) { - // We tried to create a window larger than the desktop and Windows didn't allow it. Override! + /* We tried to create a window larger than the desktop and Windows didn't allow it. Override! */ WIN_SetWindowPositionInternal(_this, window, SWP_NOCOPYBITS | SWP_NOZORDER | SWP_NOACTIVATE); } else { window->w = w; @@ -319,9 +321,7 @@ WIN_SetWindowTitle(_THIS, SDL_Window * window) title = NULL; } SetWindowText(hwnd, title ? title : TEXT("")); - if (title) { - SDL_free(title); - } + SDL_free(title); } void @@ -405,6 +405,9 @@ void WIN_RaiseWindow(_THIS, SDL_Window * window) { WIN_SetWindowPositionInternal(_this, window, SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOSIZE); + + /* Raising the window while alt-tabbed can cause it to be minimized for some reason? */ + WIN_RestoreWindow(_this, window); } void diff --git a/src/video/x11/SDL_x11clipboard.c b/src/video/x11/SDL_x11clipboard.c index 54b5eb602..e6ca86bc3 100644 --- a/src/video/x11/SDL_x11clipboard.c +++ b/src/video/x11/SDL_x11clipboard.c @@ -31,7 +31,7 @@ /* If you don't support UTF-8, you might use XA_STRING here */ #ifdef X_HAVE_UTF8_STRING -#define TEXT_FORMAT XInternAtom(display, "UTF8_STRING", False) +#define TEXT_FORMAT X11_XInternAtom(display, "UTF8_STRING", False) #else #define TEXT_FORMAT XA_STRING #endif @@ -55,7 +55,7 @@ X11_SetClipboardText(_THIS, const char *text) Display *display = ((SDL_VideoData *) _this->driverdata)->display; Atom format; Window window; - Atom XA_CLIPBOARD = XInternAtom(display, "CLIPBOARD", 0); + Atom XA_CLIPBOARD = X11_XInternAtom(display, "CLIPBOARD", 0); /* Get the SDL window that will own the selection */ window = GetWindow(_this); @@ -65,17 +65,17 @@ X11_SetClipboardText(_THIS, const char *text) /* Save the selection on the root window */ format = TEXT_FORMAT; - XChangeProperty(display, DefaultRootWindow(display), + X11_XChangeProperty(display, DefaultRootWindow(display), XA_CUT_BUFFER0, format, 8, PropModeReplace, (const unsigned char *)text, SDL_strlen(text)); if (XA_CLIPBOARD != None && - XGetSelectionOwner(display, XA_CLIPBOARD) != window) { - XSetSelectionOwner(display, XA_CLIPBOARD, window, CurrentTime); + X11_XGetSelectionOwner(display, XA_CLIPBOARD) != window) { + X11_XSetSelectionOwner(display, XA_CLIPBOARD, window, CurrentTime); } - if (XGetSelectionOwner(display, XA_PRIMARY) != window) { - XSetSelectionOwner(display, XA_PRIMARY, window, CurrentTime); + if (X11_XGetSelectionOwner(display, XA_PRIMARY) != window) { + X11_XSetSelectionOwner(display, XA_PRIMARY, window, CurrentTime); } return 0; } @@ -97,7 +97,7 @@ X11_GetClipboardText(_THIS) char *text; Uint32 waitStart; Uint32 waitElapsed; - Atom XA_CLIPBOARD = XInternAtom(display, "CLIPBOARD", 0); + Atom XA_CLIPBOARD = X11_XInternAtom(display, "CLIPBOARD", 0); if (XA_CLIPBOARD == None) { SDL_SetError("Couldn't access X clipboard"); return SDL_strdup(""); @@ -108,15 +108,15 @@ X11_GetClipboardText(_THIS) /* Get the window that holds the selection */ window = GetWindow(_this); format = TEXT_FORMAT; - owner = XGetSelectionOwner(display, XA_CLIPBOARD); + owner = X11_XGetSelectionOwner(display, XA_CLIPBOARD); if ((owner == None) || (owner == window)) { owner = DefaultRootWindow(display); selection = XA_CUT_BUFFER0; } else { /* Request that the selection owner copy the data to our window */ owner = window; - selection = XInternAtom(display, "SDL_SELECTION", False); - XConvertSelection(display, XA_CLIPBOARD, format, selection, owner, + selection = X11_XInternAtom(display, "SDL_SELECTION", False); + X11_XConvertSelection(display, XA_CLIPBOARD, format, selection, owner, CurrentTime); /* When using synergy on Linux and when data has been put in the clipboard @@ -139,7 +139,7 @@ X11_GetClipboardText(_THIS) } } - if (XGetWindowProperty(display, owner, selection, 0, INT_MAX/4, False, + if (X11_XGetWindowProperty(display, owner, selection, 0, INT_MAX/4, False, format, &seln_type, &seln_format, &nbytes, &overflow, &src) == Success) { if (seln_type == format) { @@ -149,7 +149,7 @@ X11_GetClipboardText(_THIS) text[nbytes] = '\0'; } } - XFree(src); + X11_XFree(src); } if (!text) { @@ -165,7 +165,7 @@ X11_HasClipboardText(_THIS) SDL_bool result = SDL_FALSE; char *text = X11_GetClipboardText(_this); if (text) { - result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE; + result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE; SDL_free(text); } return result; diff --git a/src/video/x11/SDL_x11dyn.c b/src/video/x11/SDL_x11dyn.c index ab0eafb4d..24caea49f 100644 --- a/src/video/x11/SDL_x11dyn.c +++ b/src/video/x11/SDL_x11dyn.c @@ -103,24 +103,19 @@ X11_GetSym(const char *fnname, int *pHasModule) return fn; } +#endif /* SDL_VIDEO_DRIVER_X11_DYNAMIC */ /* Define all the function pointers and wrappers... */ #define SDL_X11_MODULE(modname) -#define SDL_X11_SYM(rc,fn,params,args,ret) \ - typedef rc (*SDL_DYNX11FN_##fn) params; \ - static SDL_DYNX11FN_##fn p##fn = NULL; \ - rc fn params { ret p##fn args ; } +#define SDL_X11_SYM(rc,fn,params,args,ret) SDL_DYNX11FN_##fn X11_##fn = NULL; #include "SDL_x11sym.h" #undef SDL_X11_MODULE #undef SDL_X11_SYM -#endif /* SDL_VIDEO_DRIVER_X11_DYNAMIC */ /* Annoying varargs entry point... */ #ifdef X_HAVE_UTF8_STRING -typedef XIC(*SDL_DYNX11FN_XCreateIC) (XIM,...); -SDL_DYNX11FN_XCreateIC pXCreateIC = NULL; -typedef char *(*SDL_DYNX11FN_XGetICValues) (XIC, ...); -SDL_DYNX11FN_XGetICValues pXGetICValues = NULL; +SDL_DYNX11FN_XCreateIC X11_XCreateIC = NULL; +SDL_DYNX11FN_XGetICValues X11_XGetICValues = NULL; #endif /* These SDL_X11_HAVE_* flags are here whether you have dynamic X11 or not. */ @@ -130,13 +125,11 @@ SDL_DYNX11FN_XGetICValues pXGetICValues = NULL; #undef SDL_X11_MODULE #undef SDL_X11_SYM - static int x11_load_refcount = 0; void SDL_X11_UnloadSymbols(void) { -#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC /* Don't actually unload if more than one module is using the libs... */ if (x11_load_refcount > 0) { if (--x11_load_refcount == 0) { @@ -144,25 +137,26 @@ SDL_X11_UnloadSymbols(void) /* set all the function pointers to NULL. */ #define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 0; -#define SDL_X11_SYM(rc,fn,params,args,ret) p##fn = NULL; +#define SDL_X11_SYM(rc,fn,params,args,ret) X11_##fn = NULL; #include "SDL_x11sym.h" #undef SDL_X11_MODULE #undef SDL_X11_SYM #ifdef X_HAVE_UTF8_STRING - pXCreateIC = NULL; - pXGetICValues = NULL; + X11_XCreateIC = NULL; + X11_XGetICValues = NULL; #endif +#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC for (i = 0; i < SDL_TABLESIZE(x11libs); i++) { if (x11libs[i].lib != NULL) { SDL_UnloadObject(x11libs[i].lib); x11libs[i].lib = NULL; } } +#endif } } -#endif } /* returns non-zero if all needed symbols were loaded. */ @@ -171,9 +165,9 @@ SDL_X11_LoadSymbols(void) { int rc = 1; /* always succeed if not using Dynamic X11 stuff. */ -#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC /* deal with multiple modules (dga, x11, etc) needing these symbols... */ if (x11_load_refcount++ == 0) { +#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC int i; int *thismod = NULL; for (i = 0; i < SDL_TABLESIZE(x11libs); i++) { @@ -189,15 +183,15 @@ SDL_X11_LoadSymbols(void) #undef SDL_X11_SYM #define SDL_X11_MODULE(modname) thismod = &SDL_X11_HAVE_##modname; -#define SDL_X11_SYM(a,fn,x,y,z) p##fn = (SDL_DYNX11FN_##fn) X11_GetSym(#fn,thismod); +#define SDL_X11_SYM(a,fn,x,y,z) X11_##fn = (SDL_DYNX11FN_##fn) X11_GetSym(#fn,thismod); #include "SDL_x11sym.h" #undef SDL_X11_MODULE #undef SDL_X11_SYM #ifdef X_HAVE_UTF8_STRING - pXCreateIC = (SDL_DYNX11FN_XCreateIC) + X11_XCreateIC = (SDL_DYNX11FN_XCreateIC) X11_GetSym("XCreateIC", &SDL_X11_HAVE_UTF8); - pXGetICValues = (SDL_DYNX11FN_XGetICValues) + X11_XGetICValues = (SDL_DYNX11FN_XGetICValues) X11_GetSym("XGetICValues", &SDL_X11_HAVE_UTF8); #endif @@ -209,19 +203,21 @@ SDL_X11_LoadSymbols(void) SDL_X11_UnloadSymbols(); rc = 0; } - } -#else + +#else /* no dynamic X11 */ + #define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 1; /* default yes */ -#define SDL_X11_SYM(a,fn,x,y,z) +#define SDL_X11_SYM(a,fn,x,y,z) X11_##fn = fn; #include "SDL_x11sym.h" #undef SDL_X11_MODULE #undef SDL_X11_SYM #ifdef X_HAVE_UTF8_STRING - pXCreateIC = XCreateIC; - pXGetICValues = XGetICValues; + X11_XCreateIC = XCreateIC; + X11_XGetICValues = XGetICValues; #endif #endif + } return rc; } diff --git a/src/video/x11/SDL_x11dyn.h b/src/video/x11/SDL_x11dyn.h index 2cebf3b8b..168c07e22 100644 --- a/src/video/x11/SDL_x11dyn.h +++ b/src/video/x11/SDL_x11dyn.h @@ -69,35 +69,34 @@ #include #endif -/* - * When using the "dynamic X11" functionality, we duplicate all the Xlib - * symbols that would be referenced by SDL inside of SDL itself. - * These duplicated symbols just serve as passthroughs to the functions - * in Xlib, that was dynamically loaded. - * - * This allows us to use Xlib as-is when linking against it directly, but - * also handles all the strange cases where there was code in the Xlib - * headers that may or may not exist or vary on a given platform. - */ #ifdef __cplusplus extern "C" { #endif /* evil function signatures... */ - typedef Bool(*SDL_X11_XESetWireToEventRetType) (Display *, XEvent *, - xEvent *); - typedef int (*SDL_X11_XSynchronizeRetType) (Display *); - typedef Status(*SDL_X11_XESetEventToWireRetType) (Display *, XEvent *, - xEvent *); +typedef Bool(*SDL_X11_XESetWireToEventRetType) (Display *, XEvent *, xEvent *); +typedef int (*SDL_X11_XSynchronizeRetType) (Display *); +typedef Status(*SDL_X11_XESetEventToWireRetType) (Display *, XEvent *, xEvent *); - int SDL_X11_LoadSymbols(void); - void SDL_X11_UnloadSymbols(void); +int SDL_X11_LoadSymbols(void); +void SDL_X11_UnloadSymbols(void); -/* That's really annoying...make these function pointers no matter what. */ +/* Declare all the function pointers and wrappers... */ +#define SDL_X11_MODULE(modname) +#define SDL_X11_SYM(rc,fn,params,args,ret) \ + typedef rc (*SDL_DYNX11FN_##fn) params; \ + extern SDL_DYNX11FN_##fn X11_##fn; +#include "SDL_x11sym.h" +#undef SDL_X11_MODULE +#undef SDL_X11_SYM + +/* Annoying varargs entry point... */ #ifdef X_HAVE_UTF8_STRING - extern XIC(*pXCreateIC) (XIM, ...); - extern char *(*pXGetICValues) (XIC, ...); +typedef XIC(*SDL_DYNX11FN_XCreateIC) (XIM,...); +typedef char *(*SDL_DYNX11FN_XGetICValues) (XIC, ...); +extern SDL_DYNX11FN_XCreateIC X11_XCreateIC; +extern SDL_DYNX11FN_XGetICValues X11_XGetICValues; #endif /* These SDL_X11_HAVE_* flags are here whether you have dynamic X11 or not. */ @@ -107,7 +106,6 @@ extern "C" #undef SDL_X11_MODULE #undef SDL_X11_SYM - #ifdef __cplusplus } #endif diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index a9a3ac996..d9dcc2dd9 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -48,7 +48,7 @@ typedef struct { } SDL_x11Prop; /* Reads property - Must call XFree on results + Must call X11_XFree on results */ static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop) { @@ -60,8 +60,8 @@ static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop) int bytes_fetch = 0; do { - if (ret != 0) XFree(ret); - XGetWindowProperty(disp, w, prop, 0, bytes_fetch, False, AnyPropertyType, &type, &fmt, &count, &bytes_left, &ret); + if (ret != 0) X11_XFree(ret); + X11_XGetWindowProperty(disp, w, prop, 0, bytes_fetch, False, AnyPropertyType, &type, &fmt, &count, &bytes_left, &ret); bytes_fetch += bytes_left; } while (bytes_left != 0); @@ -79,9 +79,9 @@ static Atom X11_PickTarget(Display *disp, Atom list[], int list_count) char *name; int i; for (i=0; i < list_count && request == None; i++) { - name = XGetAtomName(disp, list[i]); + name = X11_XGetAtomName(disp, list[i]); if (strcmp("text/uri-list", name)==0) request = list[i]; - XFree(name); + X11_XFree(name); } return request; } @@ -97,7 +97,7 @@ static Atom X11_PickTargetFromAtoms(Display *disp, Atom a0, Atom a1, Atom a2) if (a2 != None) atom[count++] = a2; return X11_PickTarget(disp, atom, count); } -/*#define DEBUG_XEVENTS*/ +/* #define DEBUG_XEVENTS */ struct KeyRepeatCheckData { @@ -125,8 +125,8 @@ static SDL_bool X11_KeyRepeat(Display *display, XEvent *event) struct KeyRepeatCheckData d; d.event = event; d.found = SDL_FALSE; - if (XPending(display)) - XCheckIfEvent(display, &dummyev, X11_KeyRepeatCheckIfEvent, + if (X11_XPending(display)) + X11_XCheckIfEvent(display, &dummyev, X11_KeyRepeatCheckIfEvent, (XPointer) &d); return d.found; } @@ -135,7 +135,9 @@ static Bool X11_IsWheelCheckIfEvent(Display *display, XEvent *chkev, XPointer arg) { XEvent *event = (XEvent *) arg; + /* we only handle buttons 4 and 5 - false positive avoidance */ if (chkev->type == ButtonRelease && + (event->xbutton.button == Button4 || event->xbutton.button == Button5) && chkev->xbutton.button == event->xbutton.button && chkev->xbutton.time == event->xbutton.time) return True; @@ -145,13 +147,18 @@ static Bool X11_IsWheelCheckIfEvent(Display *display, XEvent *chkev, static SDL_bool X11_IsWheelEvent(Display * display,XEvent * event,int * ticks) { XEvent relevent; - if (XPending(display)) { + if (X11_XPending(display)) { /* according to the xlib docs, no specific mouse wheel events exist. however, mouse wheel events trigger a button press and a button release immediately. thus, checking if the same button was released at the same time as it was pressed, should be an adequate hack to derive a mouse - wheel event. */ - if (XCheckIfEvent(display, &relevent, X11_IsWheelCheckIfEvent, + wheel event. + However, there is broken and unusual hardware out there... + - False positive: a button for which a release event is + generated (or synthesised) immediately. + - False negative: a wheel which, when rolled, doesn't have + a release event generated immediately. */ + if (X11_XCheckIfEvent(display, &relevent, X11_IsWheelCheckIfEvent, (XPointer) event)) { /* by default, X11 only knows 5 buttons. on most 3 button + wheel mouse, @@ -173,11 +180,12 @@ static SDL_bool X11_IsWheelEvent(Display * display,XEvent * event,int * ticks) */ static char* X11_URIToLocal(char* uri) { char *file = NULL; + SDL_bool local; if (memcmp(uri,"file:/",6) == 0) uri += 6; /* local file? */ else if (strstr(uri,":/") != NULL) return file; /* wrong scheme */ - SDL_bool local = uri[0] != '/' || ( uri[0] != '\0' && uri[1] == '/' ); + local = uri[0] != '/' || ( uri[0] != '\0' && uri[1] == '/' ); /* got a hostname? */ if ( !local && uri[0] == '/' && uri[2] != '/' ) { @@ -209,9 +217,9 @@ static void X11_HandleGenericEvent(SDL_VideoData *videodata,XEvent event) { /* event is a union, so cookie == &event, but this is type safe. */ XGenericEventCookie *cookie = &event.xcookie; - if (XGetEventData(videodata->display, cookie)) { + if (X11_XGetEventData(videodata->display, cookie)) { X11_HandleXinput2Event(videodata, cookie); - XFreeEventData(videodata->display, cookie); + X11_XFreeEventData(videodata->display, cookie); } } #endif /* SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS */ @@ -226,7 +234,7 @@ X11_DispatchFocusIn(SDL_WindowData *data) SDL_SetKeyboardFocus(data->window); #ifdef X_HAVE_UTF8_STRING if (data->ic) { - XSetICFocus(data->ic); + X11_XSetICFocus(data->ic); } #endif } @@ -240,7 +248,7 @@ X11_DispatchFocusOut(SDL_WindowData *data) SDL_SetKeyboardFocus(NULL); #ifdef X_HAVE_UTF8_STRING if (data->ic) { - XUnsetICFocus(data->ic); + X11_XUnsetICFocus(data->ic); } #endif } @@ -267,13 +275,14 @@ X11_DispatchEvent(_THIS) SDL_WindowData *data; XEvent xevent; int i; + XClientMessageEvent m; SDL_zero(xevent); /* valgrind fix. --ryan. */ - XNextEvent(display, &xevent); + X11_XNextEvent(display, &xevent); /* filter events catchs XIM events and sends them to the correct handler */ - if (XFilterEvent(&xevent, None) == True) { + if (X11_XFilterEvent(&xevent, None) == True) { #if 0 printf("Filtered event type = %d display = %d window = %d\n", xevent.type, xevent.xany.display, xevent.xany.window); @@ -384,7 +393,7 @@ X11_DispatchEvent(_THIS) I think it's better to think the ALT key is held down when it's not, then always lose the ALT modifier on Unity. */ - /*SDL_ResetKeyboard();*/ + /* SDL_ResetKeyboard(); */ } data->pending_focus = PENDING_FOCUS_IN; data->pending_focus_time = SDL_GetTicks() + PENDING_FOCUS_IN_TIME; @@ -440,25 +449,25 @@ X11_DispatchEvent(_THIS) #endif SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode]); #if 1 - if (videodata->key_layout[keycode] == SDL_SCANCODE_UNKNOWN) { + if (videodata->key_layout[keycode] == SDL_SCANCODE_UNKNOWN && keycode) { int min_keycode, max_keycode; - XDisplayKeycodes(display, &min_keycode, &max_keycode); + X11_XDisplayKeycodes(display, &min_keycode, &max_keycode); #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM - keysym = XkbKeycodeToKeysym(display, keycode, 0, 0); + keysym = X11_XkbKeycodeToKeysym(display, keycode, 0, 0); #else keysym = XKeycodeToKeysym(display, keycode, 0); #endif fprintf(stderr, "The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL mailing list X11 KeyCode %d (%d), X11 KeySym 0x%lX (%s).\n", keycode, keycode - min_keycode, keysym, - XKeysymToString(keysym)); + X11_XKeysymToString(keysym)); } #endif /* */ SDL_zero(text); #ifdef X_HAVE_UTF8_STRING if (data->ic) { - Xutf8LookupString(data->ic, &xevent.xkey, text, sizeof(text), + X11_Xutf8LookupString(data->ic, &xevent.xkey, text, sizeof(text), &keysym, &status); } #else @@ -510,10 +519,35 @@ X11_DispatchEvent(_THIS) xevent.xconfigure.x, xevent.xconfigure.y, xevent.xconfigure.width, xevent.xconfigure.height); #endif + long border_left = 0; + long border_right = 0; + long border_top = 0; + long border_bottom = 0; + if (data->xwindow) { + Atom _net_frame_extents = X11_XInternAtom(display, "_NET_FRAME_EXTENTS", 0); + Atom type = None; + int format; + unsigned long nitems = 0, bytes_after; + unsigned char *property; + X11_XGetWindowProperty(display, data->xwindow, + _net_frame_extents, 0, 16, 0, + XA_CARDINAL, &type, &format, + &nitems, &bytes_after, &property); + + if (type != None && nitems == 4) + { + border_left = ((long*)property)[0]; + border_right = ((long*)property)[1]; + border_top = ((long*)property)[2]; + border_bottom = ((long*)property)[3]; + } + } + if (xevent.xconfigure.x != data->last_xconfigure.x || xevent.xconfigure.y != data->last_xconfigure.y) { SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MOVED, - xevent.xconfigure.x, xevent.xconfigure.y); + xevent.xconfigure.x - border_left, + xevent.xconfigure.y - border_top); } if (xevent.xconfigure.width != data->last_xconfigure.width || xevent.xconfigure.height != data->last_xconfigure.height) { @@ -540,7 +574,7 @@ X11_DispatchEvent(_THIS) X11_ReadProperty(&p, display, data->xdnd_source, videodata->XdndTypeList); /* pick one */ data->xdnd_req = X11_PickTarget(display, (Atom*)p.data, p.count); - XFree(p.data); + X11_XFree(p.data); } else { /* pick from list of three */ data->xdnd_req = X11_PickTargetFromAtoms(display, xevent.xclient.data.l[2], xevent.xclient.data.l[3], xevent.xclient.data.l[4]); @@ -549,7 +583,6 @@ X11_DispatchEvent(_THIS) else if (xevent.xclient.message_type == videodata->XdndPosition) { /* reply with status */ - XClientMessageEvent m; memset(&m, 0, sizeof(XClientMessageEvent)); m.type = ClientMessage; m.display = xevent.xclient.display; @@ -562,13 +595,12 @@ X11_DispatchEvent(_THIS) m.data.l[3] = 0; m.data.l[4] = videodata->XdndActionCopy; /* we only accept copying anyway */ - XSendEvent(display, xevent.xclient.data.l[0], False, NoEventMask, (XEvent*)&m); - XFlush(display); + X11_XSendEvent(display, xevent.xclient.data.l[0], False, NoEventMask, (XEvent*)&m); + X11_XFlush(display); } else if(xevent.xclient.message_type == videodata->XdndDrop) { if (data->xdnd_req == None) { /* say again - not interested! */ - XClientMessageEvent m; memset(&m, 0, sizeof(XClientMessageEvent)); m.type = ClientMessage; m.display = xevent.xclient.display; @@ -578,13 +610,13 @@ X11_DispatchEvent(_THIS) m.data.l[0] = data->xwindow; m.data.l[1] = 0; m.data.l[2] = None; /* fail! */ - XSendEvent(display, xevent.xclient.data.l[0], False, NoEventMask, (XEvent*)&m); + X11_XSendEvent(display, xevent.xclient.data.l[0], False, NoEventMask, (XEvent*)&m); } else { /* convert */ if(xdnd_version >= 1) { - XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, xevent.xclient.data.l[2]); + X11_XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, xevent.xclient.data.l[2]); } else { - XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, CurrentTime); + X11_XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, CurrentTime); } } } @@ -597,7 +629,7 @@ X11_DispatchEvent(_THIS) printf("window %p: _NET_WM_PING\n", data); #endif xevent.xclient.window = root; - XSendEvent(display, root, False, SubstructureRedirectMask | SubstructureNotifyMask, &xevent); + X11_XSendEvent(display, root, False, SubstructureRedirectMask | SubstructureNotifyMask, &xevent); break; } @@ -657,13 +689,13 @@ X11_DispatchEvent(_THIS) Atom real_type; unsigned long items_read, items_left, i; - char *name = XGetAtomName(display, xevent.xproperty.atom); + char *name = X11_XGetAtomName(display, xevent.xproperty.atom); if (name) { printf("window %p: PropertyNotify: %s %s\n", data, name, (xevent.xproperty.state == PropertyDelete) ? "deleted" : "changed"); - XFree(name); + X11_XFree(name); } - status = XGetWindowProperty(display, data->xwindow, xevent.xproperty.atom, 0L, 8192L, False, AnyPropertyType, &real_type, &real_format, &items_read, &items_left, &propdata); + status = X11_XGetWindowProperty(display, data->xwindow, xevent.xproperty.atom, 0L, 8192L, False, AnyPropertyType, &real_type, &real_format, &items_read, &items_left, &propdata); if (status == Success && items_read > 0) { if (real_type == XA_INTEGER) { int *values = (int *)propdata; @@ -707,23 +739,23 @@ X11_DispatchEvent(_THIS) printf("{"); for (i = 0; i < items_read; i++) { - char *name = XGetAtomName(display, atoms[i]); + char *name = X11_XGetAtomName(display, atoms[i]); if (name) { printf(" %s", name); - XFree(name); + X11_XFree(name); } } printf(" }\n"); } else { - char *name = XGetAtomName(display, real_type); + char *name = X11_XGetAtomName(display, real_type); printf("Unknown type: %ld (%s)\n", real_type, name ? name : "UNKNOWN"); if (name) { - XFree(name); + X11_XFree(name); } } } if (status == Success) { - XFree(propdata); + X11_XFree(propdata); } #endif /* DEBUG_XEVENTS */ @@ -767,28 +799,28 @@ X11_DispatchEvent(_THIS) sevent.xselection.property = None; sevent.xselection.requestor = req->requestor; sevent.xselection.time = req->time; - if (XGetWindowProperty(display, DefaultRootWindow(display), + if (X11_XGetWindowProperty(display, DefaultRootWindow(display), XA_CUT_BUFFER0, 0, INT_MAX/4, False, req->target, &sevent.xselection.target, &seln_format, &nbytes, &overflow, &seln_data) == Success) { - Atom XA_TARGETS = XInternAtom(display, "TARGETS", 0); + Atom XA_TARGETS = X11_XInternAtom(display, "TARGETS", 0); if (sevent.xselection.target == req->target) { - XChangeProperty(display, req->requestor, req->property, + X11_XChangeProperty(display, req->requestor, req->property, sevent.xselection.target, seln_format, PropModeReplace, seln_data, nbytes); sevent.xselection.property = req->property; } else if (XA_TARGETS == req->target) { Atom SupportedFormats[] = { sevent.xselection.target, XA_TARGETS }; - XChangeProperty(display, req->requestor, req->property, + X11_XChangeProperty(display, req->requestor, req->property, XA_ATOM, 32, PropModeReplace, (unsigned char*)SupportedFormats, sizeof(SupportedFormats)/sizeof(*SupportedFormats)); sevent.xselection.property = req->property; } - XFree(seln_data); + X11_XFree(seln_data); } - XSendEvent(display, req->requestor, False, 0, &sevent); - XSync(display, False); + X11_XSendEvent(display, req->requestor, False, 0, &sevent); + X11_XSync(display, False); } break; @@ -838,10 +870,9 @@ X11_DispatchEvent(_THIS) } } - XFree(p.data); + X11_XFree(p.data); /* send reply */ - XClientMessageEvent m; SDL_memset(&m, 0, sizeof(XClientMessageEvent)); m.type = ClientMessage; m.display = display; @@ -851,9 +882,9 @@ X11_DispatchEvent(_THIS) m.data.l[0] = data->xwindow; m.data.l[1] = 1; m.data.l[2] = videodata->XdndActionCopy; - XSendEvent(display, data->xdnd_source, False, NoEventMask, (XEvent*)&m); + X11_XSendEvent(display, data->xdnd_source, False, NoEventMask, (XEvent*)&m); - XSync(display, False); + X11_XSync(display, False); } else { videodata->selection_waiting = SDL_FALSE; @@ -881,7 +912,7 @@ X11_HandleFocusChanges(_THIS) SDL_WindowData *data = videodata->windowlist[i]; if (data && data->pending_focus != PENDING_FOCUS_NONE) { Uint32 now = SDL_GetTicks(); - if ( (int)(data->pending_focus_time-now) <= 0 ) { + if (SDL_TICKS_PASSED(now, data->pending_focus_time)) { if ( data->pending_focus == PENDING_FOCUS_IN ) { X11_DispatchFocusIn(data); } else { @@ -893,13 +924,13 @@ X11_HandleFocusChanges(_THIS) } } } -/* Ack! XPending() actually performs a blocking read if no events available */ +/* Ack! X11_XPending() actually performs a blocking read if no events available */ static int X11_Pending(Display * display) { /* Flush the display connection and look to see if events are queued */ - XFlush(display); - if (XEventsQueued(display, QueuedAlready)) { + X11_XFlush(display); + if (X11_XEventsQueued(display, QueuedAlready)) { return (1); } @@ -913,7 +944,7 @@ X11_Pending(Display * display) FD_ZERO(&fdset); FD_SET(x11_fd, &fdset); if (select(x11_fd + 1, &fdset, NULL, NULL, &zero_time) == 1) { - return (XPending(display)); + return (X11_XPending(display)); } } @@ -935,8 +966,8 @@ X11_PumpEvents(_THIS) if (_this->suspend_screensaver) { Uint32 now = SDL_GetTicks(); if (!data->screensaver_activity || - (int) (now - data->screensaver_activity) >= 30000) { - XResetScreenSaver(data->display); + SDL_TICKS_PASSED(now, data->screensaver_activity + 30000)) { + X11_XResetScreenSaver(data->display); #if SDL_USE_LIBDBUS SDL_dbus_screensaver_tickle(_this); @@ -965,16 +996,16 @@ X11_SuspendScreenSaver(_THIS) int major_version, minor_version; if (SDL_X11_HAVE_XSS) { - /* XScreenSaverSuspend was introduced in MIT-SCREEN-SAVER 1.1 */ - if (!XScreenSaverQueryExtension(data->display, &dummy, &dummy) || - !XScreenSaverQueryVersion(data->display, + /* X11_XScreenSaverSuspend was introduced in MIT-SCREEN-SAVER 1.1 */ + if (!X11_XScreenSaverQueryExtension(data->display, &dummy, &dummy) || + !X11_XScreenSaverQueryVersion(data->display, &major_version, &minor_version) || major_version < 1 || (major_version == 1 && minor_version < 1)) { return; } - XScreenSaverSuspend(data->display, _this->suspend_screensaver); - XResetScreenSaver(data->display); + X11_XScreenSaverSuspend(data->display, _this->suspend_screensaver); + X11_XResetScreenSaver(data->display); } #endif diff --git a/src/video/x11/SDL_x11framebuffer.c b/src/video/x11/SDL_x11framebuffer.c index 4dfe0d174..af39147f4 100644 --- a/src/video/x11/SDL_x11framebuffer.c +++ b/src/video/x11/SDL_x11framebuffer.c @@ -43,8 +43,8 @@ static int shm_errhandler(Display *d, XErrorEvent *e) static SDL_bool have_mitshm(void) { /* Only use shared memory on local X servers */ - if ( (SDL_strncmp(XDisplayName(NULL), ":", 1) == 0) || - (SDL_strncmp(XDisplayName(NULL), "unix:", 5) == 0) ) { + if ( (SDL_strncmp(X11_XDisplayName(NULL), ":", 1) == 0) || + (SDL_strncmp(X11_XDisplayName(NULL), "unix:", 5) == 0) ) { return SDL_X11_HAVE_SHM; } return SDL_FALSE; @@ -66,7 +66,7 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, /* Create the graphics context for drawing */ gcv.graphics_exposures = False; - data->gc = XCreateGC(display, data->xwindow, GCGraphicsExposures, &gcv); + data->gc = X11_XCreateGC(display, data->xwindow, GCGraphicsExposures, &gcv); if (!data->gc) { return SDL_SetError("Couldn't create graphics context"); } @@ -95,10 +95,10 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, shminfo->readOnly = False; if ( shminfo->shmaddr != (char *)-1 ) { shm_error = False; - X_handler = XSetErrorHandler(shm_errhandler); - XShmAttach(display, shminfo); - XSync(display, True); - XSetErrorHandler(X_handler); + X_handler = X11_XSetErrorHandler(shm_errhandler); + X11_XShmAttach(display, shminfo); + X11_XSync(display, True); + X11_XSetErrorHandler(X_handler); if ( shm_error ) shmdt(shminfo->shmaddr); } else { @@ -109,13 +109,13 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, shm_error = True; } if (!shm_error) { - data->ximage = XShmCreateImage(display, data->visual, + data->ximage = X11_XShmCreateImage(display, data->visual, vinfo.depth, ZPixmap, shminfo->shmaddr, shminfo, window->w, window->h); if (!data->ximage) { - XShmDetach(display, shminfo); - XSync(display, False); + X11_XShmDetach(display, shminfo); + X11_XSync(display, False); shmdt(shminfo->shmaddr); } else { /* Done! */ @@ -132,7 +132,7 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, return SDL_OutOfMemory(); } - data->ximage = XCreateImage(display, data->visual, + data->ximage = X11_XCreateImage(display, data->visual, vinfo.depth, ZPixmap, 0, (char *)(*pixels), window->w, window->h, 32, 0); if (!data->ximage) { @@ -177,7 +177,7 @@ X11_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, if (y + h > window->h) h = window->h - y; - XShmPutImage(display, data->xwindow, data->gc, data->ximage, + X11_XShmPutImage(display, data->xwindow, data->gc, data->ximage, x, y, x, y, w, h, False); } } @@ -209,12 +209,12 @@ X11_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, if (y + h > window->h) h = window->h - y; - XPutImage(display, data->xwindow, data->gc, data->ximage, + X11_XPutImage(display, data->xwindow, data->gc, data->ximage, x, y, x, y, w, h); } } - XSync(display, False); + X11_XSync(display, False); return 0; } @@ -237,8 +237,8 @@ X11_DestroyWindowFramebuffer(_THIS, SDL_Window * window) #ifndef NO_SHARED_MEMORY if (data->use_mitshm) { - XShmDetach(display, &data->shminfo); - XSync(display, False); + X11_XShmDetach(display, &data->shminfo); + X11_XSync(display, False); shmdt(data->shminfo.shmaddr); data->use_mitshm = SDL_FALSE; } @@ -247,7 +247,7 @@ X11_DestroyWindowFramebuffer(_THIS, SDL_Window * window) data->ximage = NULL; } if (data->gc) { - XFreeGC(display, data->gc); + X11_XFreeGC(display, data->gc); data->gc = NULL; } } diff --git a/src/video/x11/SDL_x11keyboard.c b/src/video/x11/SDL_x11keyboard.c index 81d64b2df..f3b83c968 100644 --- a/src/video/x11/SDL_x11keyboard.c +++ b/src/video/x11/SDL_x11keyboard.c @@ -135,7 +135,7 @@ static const struct { static const struct { - const SDL_Scancode const *table; + SDL_Scancode const *table; int table_size; } scancode_set[] = { { darwin_scancode_table, SDL_arraysize(darwin_scancode_table) }, @@ -152,7 +152,7 @@ X11_KeyCodeToSDLScancode(Display *display, KeyCode keycode) int i; #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM - keysym = XkbKeycodeToKeysym(display, keycode, 0, 0); + keysym = X11_XkbKeycodeToKeysym(display, keycode, 0, 0); #else keysym = XKeycodeToKeysym(display, keycode, 0); #endif @@ -182,7 +182,7 @@ X11_KeyCodeToUcs4(Display *display, KeyCode keycode) KeySym keysym; #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM - keysym = XkbKeycodeToKeysym(display, keycode, 0, 0); + keysym = X11_XkbKeycodeToKeysym(display, keycode, 0, 0); #else keysym = XKeycodeToKeysym(display, keycode, 0); #endif @@ -197,7 +197,8 @@ int X11_InitKeyboard(_THIS) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - int i, j; + int i = 0; + int j = 0; int min_keycode, max_keycode; struct { SDL_Scancode scancode; @@ -210,14 +211,14 @@ X11_InitKeyboard(_THIS) }; SDL_bool fingerprint_detected; - XAutoRepeatOn(data->display); + X11_XAutoRepeatOn(data->display); /* Try to determine which scancodes are being used based on fingerprint */ fingerprint_detected = SDL_FALSE; - XDisplayKeycodes(data->display, &min_keycode, &max_keycode); + X11_XDisplayKeycodes(data->display, &min_keycode, &max_keycode); for (i = 0; i < SDL_arraysize(fingerprint); ++i) { fingerprint[i].value = - XKeysymToKeycode(data->display, fingerprint[i].keysym) - + X11_XKeysymToKeycode(data->display, fingerprint[i].keysym) - min_keycode; } for (i = 0; i < SDL_arraysize(scancode_set); ++i) { @@ -257,20 +258,20 @@ X11_InitKeyboard(_THIS) for (i = min_keycode; i <= max_keycode; ++i) { KeySym sym; #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM - sym = XkbKeycodeToKeysym(data->display, i, 0, 0); + sym = X11_XkbKeycodeToKeysym(data->display, i, 0, 0); #else sym = XKeycodeToKeysym(data->display, i, 0); #endif if (sym != NoSymbol) { SDL_Scancode scancode; printf("code = %d, sym = 0x%X (%s) ", i - min_keycode, - (unsigned int) sym, XKeysymToString(sym)); + (unsigned int) sym, X11_XKeysymToString(sym)); scancode = X11_KeyCodeToSDLScancode(data->display, i); data->key_layout[i] = scancode; if (scancode == SDL_SCANCODE_UNKNOWN) { printf("scancode not found\n"); } else { - printf("scancode = %d (%s)\n", j, SDL_GetScancodeName(j)); + printf("scancode = %d (%s)\n", scancode, SDL_GetScancodeName(scancode)); } } } diff --git a/src/video/x11/SDL_x11messagebox.c b/src/video/x11/SDL_x11messagebox.c index f938ded8b..81c148005 100644 --- a/src/video/x11/SDL_x11messagebox.c +++ b/src/video/x11/SDL_x11messagebox.c @@ -112,7 +112,7 @@ typedef struct SDL_MessageBoxDataX11 } SDL_MessageBoxDataX11; /* Maximum helper for ints. */ -static __inline__ int +static SDL_INLINE int IntMax( int a, int b ) { return ( a > b ) ? a : b; @@ -124,13 +124,13 @@ GetTextWidthHeight( SDL_MessageBoxDataX11 *data, const char *str, int nbytes, in { if (SDL_X11_HAVE_UTF8) { XRectangle overall_ink, overall_logical; - Xutf8TextExtents(data->font_set, str, nbytes, &overall_ink, &overall_logical); + X11_Xutf8TextExtents(data->font_set, str, nbytes, &overall_ink, &overall_logical); *pwidth = overall_logical.width; *pheight = overall_logical.height; } else { XCharStruct text_structure; int font_direction, font_ascent, font_descent; - XTextExtents( data->font_struct, str, nbytes, + X11_XTextExtents( data->font_struct, str, nbytes, &font_direction, &font_ascent, &font_descent, &text_structure ); *pwidth = text_structure.width; @@ -180,7 +180,7 @@ X11_MessageBoxInit( SDL_MessageBoxDataX11 *data, const SDL_MessageBoxData * mess data->numbuttons = numbuttons; data->pbuttonid = pbuttonid; - data->display = XOpenDisplay( NULL ); + data->display = X11_XOpenDisplay( NULL ); if ( !data->display ) { return SDL_SetError("Couldn't open X11 display"); } @@ -188,16 +188,16 @@ X11_MessageBoxInit( SDL_MessageBoxDataX11 *data, const SDL_MessageBoxData * mess if (SDL_X11_HAVE_UTF8) { char **missing = NULL; int num_missing = 0; - data->font_set = XCreateFontSet(data->display, g_MessageBoxFont, + data->font_set = X11_XCreateFontSet(data->display, g_MessageBoxFont, &missing, &num_missing, NULL); if ( missing != NULL ) { - XFreeStringList(missing); + X11_XFreeStringList(missing); } if ( data->font_set == NULL ) { return SDL_SetError("Couldn't load font %s", g_MessageBoxFont); } } else { - data->font_struct = XLoadQueryFont( data->display, g_MessageBoxFontLatin1 ); + data->font_struct = X11_XLoadQueryFont( data->display, g_MessageBoxFontLatin1 ); if ( data->font_struct == NULL ) { return SDL_SetError("Couldn't load font %s", g_MessageBoxFontLatin1); } @@ -338,23 +338,23 @@ static void X11_MessageBoxShutdown( SDL_MessageBoxDataX11 *data ) { if ( data->font_set != NULL ) { - XFreeFontSet( data->display, data->font_set ); + X11_XFreeFontSet( data->display, data->font_set ); data->font_set = NULL; } if ( data->font_struct != NULL ) { - XFreeFont( data->display, data->font_struct ); + X11_XFreeFont( data->display, data->font_struct ); data->font_struct = NULL; } if ( data->display ) { if ( data->window != None ) { - XWithdrawWindow( data->display, data->window, data->screen ); - XDestroyWindow( data->display, data->window ); + X11_XWithdrawWindow( data->display, data->window, data->screen ); + X11_XDestroyWindow( data->display, data->window ); data->window = None; } - XCloseDisplay( data->display ); + X11_XCloseDisplay( data->display ); data->display = NULL; } } @@ -384,7 +384,7 @@ X11_MessageBoxCreateWindow( SDL_MessageBoxDataX11 *data ) StructureNotifyMask | FocusChangeMask | PointerMotionMask; wnd_attr.event_mask = data->event_mask; - data->window = XCreateWindow( + data->window = X11_XCreateWindow( display, RootWindow(display, data->screen), 0, 0, data->dialog_width, data->dialog_height, @@ -396,31 +396,31 @@ X11_MessageBoxCreateWindow( SDL_MessageBoxDataX11 *data ) if ( windowdata ) { /* http://tronche.com/gui/x/icccm/sec-4.html#WM_TRANSIENT_FOR */ - XSetTransientForHint( display, data->window, windowdata->xwindow ); + X11_XSetTransientForHint( display, data->window, windowdata->xwindow ); } - XStoreName( display, data->window, messageboxdata->title ); + X11_XStoreName( display, data->window, messageboxdata->title ); /* Allow the window to be deleted by the window manager */ - data->wm_protocols = XInternAtom( display, "WM_PROTOCOLS", False ); - data->wm_delete_message = XInternAtom( display, "WM_DELETE_WINDOW", False ); - XSetWMProtocols( display, data->window, &data->wm_delete_message, 1 ); + data->wm_protocols = X11_XInternAtom( display, "WM_PROTOCOLS", False ); + data->wm_delete_message = X11_XInternAtom( display, "WM_DELETE_WINDOW", False ); + X11_XSetWMProtocols( display, data->window, &data->wm_delete_message, 1 ); if ( windowdata ) { XWindowAttributes attrib; Window dummy; - XGetWindowAttributes(display, windowdata->xwindow, &attrib); + X11_XGetWindowAttributes(display, windowdata->xwindow, &attrib); x = attrib.x + ( attrib.width - data->dialog_width ) / 2; y = attrib.y + ( attrib.height - data->dialog_height ) / 3 ; - XTranslateCoordinates(display, windowdata->xwindow, RootWindow(display, data->screen), x, y, &x, &y, &dummy); + X11_XTranslateCoordinates(display, windowdata->xwindow, RootWindow(display, data->screen), x, y, &x, &y, &dummy); } else { x = ( DisplayWidth( display, data->screen ) - data->dialog_width ) / 2; y = ( DisplayHeight( display, data->screen ) - data->dialog_height ) / 3 ; } - XMoveWindow( display, data->window, x, y ); + X11_XMoveWindow( display, data->window, x, y ); - sizehints = XAllocSizeHints(); + sizehints = X11_XAllocSizeHints(); if ( sizehints ) { sizehints->flags = USPosition | USSize | PMaxSize | PMinSize; sizehints->x = x; @@ -431,12 +431,12 @@ X11_MessageBoxCreateWindow( SDL_MessageBoxDataX11 *data ) sizehints->min_width = sizehints->max_width = data->dialog_width; sizehints->min_height = sizehints->max_height = data->dialog_height; - XSetWMNormalHints( display, data->window, sizehints ); + X11_XSetWMNormalHints( display, data->window, sizehints ); - XFree( sizehints ); + X11_XFree( sizehints ); } - XMapRaised( display, data->window ); + X11_XMapRaised( display, data->window ); return 0; } @@ -448,19 +448,19 @@ X11_MessageBoxDraw( SDL_MessageBoxDataX11 *data, GC ctx ) Window window = data->window; Display *display = data->display; - XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ] ); - XFillRectangle( display, window, ctx, 0, 0, data->dialog_width, data->dialog_height ); + X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ] ); + X11_XFillRectangle( display, window, ctx, 0, 0, data->dialog_width, data->dialog_height ); - XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] ); + X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] ); for ( i = 0; i < data->numlines; i++ ) { TextLineData *plinedata = &data->linedata[ i ]; if (SDL_X11_HAVE_UTF8) { - Xutf8DrawString( display, window, data->font_set, ctx, + X11_Xutf8DrawString( display, window, data->font_set, ctx, data->xtext, data->ytext + i * data->text_height, plinedata->text, plinedata->length ); } else { - XDrawString( display, window, ctx, + X11_XDrawString( display, window, ctx, data->xtext, data->ytext + i * data->text_height, plinedata->text, plinedata->length ); } @@ -472,27 +472,27 @@ X11_MessageBoxDraw( SDL_MessageBoxDataX11 *data, GC ctx ) int border = ( buttondata->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT ) ? 2 : 0; int offset = ( ( data->mouse_over_index == i ) && ( data->button_press_index == data->mouse_over_index ) ) ? 1 : 0; - XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND ] ); - XFillRectangle( display, window, ctx, + X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND ] ); + X11_XFillRectangle( display, window, ctx, buttondatax11->rect.x - border, buttondatax11->rect.y - border, buttondatax11->rect.w + 2 * border, buttondatax11->rect.h + 2 * border ); - XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BORDER ] ); - XDrawRectangle( display, window, ctx, + X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BORDER ] ); + X11_XDrawRectangle( display, window, ctx, buttondatax11->rect.x, buttondatax11->rect.y, buttondatax11->rect.w, buttondatax11->rect.h ); - XSetForeground( display, ctx, ( data->mouse_over_index == i ) ? + X11_XSetForeground( display, ctx, ( data->mouse_over_index == i ) ? data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED ] : data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] ); if (SDL_X11_HAVE_UTF8) { - Xutf8DrawString( display, window, data->font_set, ctx, + X11_Xutf8DrawString( display, window, data->font_set, ctx, buttondatax11->x + offset, buttondatax11->y + offset, buttondata->text, buttondatax11->length ); } else { - XDrawString( display, window, ctx, + X11_XDrawString( display, window, ctx, buttondatax11->x + offset, buttondatax11->y + offset, buttondata->text, buttondatax11->length ); } @@ -519,7 +519,7 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data ) ctx_vals.font = data->font_struct->fid; } - ctx = XCreateGC( data->display, data->window, gcflags, &ctx_vals ); + ctx = X11_XCreateGC( data->display, data->window, gcflags, &ctx_vals ); if ( ctx == None ) { return SDL_SetError("Couldn't create graphics context"); } @@ -531,11 +531,11 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data ) XEvent e; SDL_bool draw = SDL_TRUE; - XWindowEvent( data->display, data->window, data->event_mask, &e ); + X11_XWindowEvent( data->display, data->window, data->event_mask, &e ); - /* If XFilterEvent returns True, then some input method has filtered the + /* If X11_XFilterEvent returns True, then some input method has filtered the event, and the client should discard the event. */ - if ( ( e.type != Expose ) && XFilterEvent( &e, None ) ) + if ( ( e.type != Expose ) && X11_XFilterEvent( &e, None ) ) continue; switch( e.type ) { @@ -574,12 +574,12 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data ) case KeyPress: /* Store key press - we make sure in key release that we got both. */ - last_key_pressed = XLookupKeysym( &e.xkey, 0 ); + last_key_pressed = X11_XLookupKeysym( &e.xkey, 0 ); break; case KeyRelease: { Uint32 mask = 0; - KeySym key = XLookupKeysym( &e.xkey, 0 ); + KeySym key = X11_XLookupKeysym( &e.xkey, 0 ); /* If this is a key release for something we didn't get the key down for, then bail. */ if ( key != last_key_pressed ) @@ -637,7 +637,7 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data ) } } - XFreeGC( data->display, ctx ); + X11_XFreeGC( data->display, ctx ); return 0; } @@ -667,7 +667,7 @@ X11_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid) #endif /* This code could get called from multiple threads maybe? */ - XInitThreads(); + X11_XInitThreads(); /* Initialize the return buttonid value to -1 (for error or dialogbox closed). */ *buttonid = -1; @@ -707,7 +707,7 @@ X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) int status = 0; /* Need to flush here in case someone has turned grab off and it hasn't gone through yet, etc. */ - XFlush(data->display); + X11_XFlush(data->display); if (pipe(fds) == -1) { return X11_ShowMessageBoxImpl(messageboxdata, buttonid); /* oh well. */ diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c index b66b94b1a..a4c242cdc 100644 --- a/src/video/x11/SDL_x11modes.c +++ b/src/video/x11/SDL_x11modes.c @@ -26,7 +26,7 @@ #include "SDL_x11video.h" #include "edid.h" -/*#define X11MODES_DEBUG*/ +/* #define X11MODES_DEBUG */ /* I'm becoming more and more convinced that the application should never * use XRandR, and it's the window manager's responsibility to track and @@ -38,7 +38,7 @@ * * However, many people swear by it, so let them swear at it. :) */ -/*#define XRANDR_DISABLED_BY_DEFAULT*/ +/* #define XRANDR_DISABLED_BY_DEFAULT */ static int @@ -54,20 +54,20 @@ get_visualinfo(Display * display, int screen, XVisualInfo * vinfo) SDL_zero(template); template.visualid = SDL_strtol(visual_id, NULL, 0); - vi = XGetVisualInfo(display, VisualIDMask, &template, &nvis); + vi = X11_XGetVisualInfo(display, VisualIDMask, &template, &nvis); if (vi) { *vinfo = *vi; - XFree(vi); + X11_XFree(vi); return 0; } } depth = DefaultDepth(display, screen); if ((X11_UseDirectColorVisuals() && - XMatchVisualInfo(display, screen, depth, DirectColor, vinfo)) || - XMatchVisualInfo(display, screen, depth, TrueColor, vinfo) || - XMatchVisualInfo(display, screen, depth, PseudoColor, vinfo) || - XMatchVisualInfo(display, screen, depth, StaticColor, vinfo)) { + X11_XMatchVisualInfo(display, screen, depth, DirectColor, vinfo)) || + X11_XMatchVisualInfo(display, screen, depth, TrueColor, vinfo) || + X11_XMatchVisualInfo(display, screen, depth, PseudoColor, vinfo) || + X11_XMatchVisualInfo(display, screen, depth, StaticColor, vinfo)) { return 0; } return -1; @@ -79,11 +79,11 @@ X11_GetVisualInfoFromVisual(Display * display, Visual * visual, XVisualInfo * vi XVisualInfo *vi; int nvis; - vinfo->visualid = XVisualIDFromVisual(visual); - vi = XGetVisualInfo(display, VisualIDMask, vinfo, &nvis); + vinfo->visualid = X11_XVisualIDFromVisual(visual); + vi = X11_XGetVisualInfo(display, VisualIDMask, vinfo, &nvis); if (vi) { *vinfo = *vi; - XFree(vi); + X11_XFree(vi); return 0; } return -1; @@ -108,7 +108,7 @@ X11_GetPixelFormatFromVisualInfo(Display * display, XVisualInfo * vinfo) bpp = vinfo->depth; if (bpp == 24) { int i, n; - XPixmapFormatValues *p = XListPixmapFormats(display, &n); + XPixmapFormatValues *p = X11_XListPixmapFormats(display, &n); if (p) { for (i = 0; i < n; ++i) { if (p[i].depth == 24) { @@ -116,7 +116,7 @@ X11_GetPixelFormatFromVisualInfo(Display * display, XVisualInfo * vinfo) break; } } - XFree(p); + X11_XFree(p); } } @@ -178,9 +178,9 @@ CheckXinerama(Display * display, int *major, int *minor) } /* Query the extension version */ - if (!XineramaQueryExtension(display, &event_base, &error_base) || - !XineramaQueryVersion(display, major, minor) || - !XineramaIsActive(display)) { + if (!X11_XineramaQueryExtension(display, &event_base, &error_base) || + !X11_XineramaQueryVersion(display, major, minor) || + !X11_XineramaIsActive(display)) { #ifdef X11MODES_DEBUG printf("Xinerama not active on the display\n"); #endif @@ -228,7 +228,7 @@ CheckXRandR(Display * display, int *major, int *minor) } /* Query the extension version */ - if (!XRRQueryVersion(display, major, minor)) { + if (!X11_XRRQueryVersion(display, major, minor)) { #ifdef X11MODES_DEBUG printf("XRandR not active on the display\n"); #endif @@ -261,10 +261,10 @@ SetXRandRModeInfo(Display *display, XRRScreenResources *res, XRROutputInfo *outp Rotation rotation = 0; const XRRModeInfo *info = &res->modes[i]; - crtc = XRRGetCrtcInfo(display, res, output_info->crtc); + crtc = X11_XRRGetCrtcInfo(display, res, output_info->crtc); if (crtc) { rotation = crtc->rotation; - XRRFreeCrtcInfo(crtc); + X11_XRRFreeCrtcInfo(crtc); } if (rotation & (XRANDR_ROTATION_LEFT|XRANDR_ROTATION_RIGHT)) { @@ -313,8 +313,8 @@ CheckVidMode(Display * display, int *major, int *minor) /* Query the extension version */ vm_error = -1; - if (!XF86VidModeQueryExtension(display, &vm_event, &vm_error) - || !XF86VidModeQueryVersion(display, major, minor)) { + if (!X11_XF86VidModeQueryExtension(display, &vm_event, &vm_error) + || !X11_XF86VidModeQueryVersion(display, major, minor)) { #ifdef X11MODES_DEBUG printf("XVidMode not active on the display\n"); #endif @@ -335,7 +335,7 @@ Bool XF86VidModeGetModeInfo(Display * dpy, int scr, XF86VidModeModeLine l; SDL_zerop(info); SDL_zero(l); - retval = XF86VidModeGetModeLine(dpy, scr, &dotclock, &l); + retval = X11_XF86VidModeGetModeLine(dpy, scr, &dotclock, &l); info->dotclock = dotclock; info->hdisplay = l.hdisplay; info->hsyncstart = l.hsyncstart; @@ -397,7 +397,7 @@ X11_InitModes(_THIS) * or newer of the Nvidia binary drivers */ if (CheckXinerama(data->display, &xinerama_major, &xinerama_minor)) { - xinerama = XineramaQueryScreens(data->display, &screencount); + xinerama = X11_XineramaQueryScreens(data->display, &screencount); if (xinerama) { use_xinerama = xinerama_major * 100 + xinerama_minor; } @@ -501,7 +501,7 @@ X11_InitModes(_THIS) displaydata->depth = vinfo.depth; displaydata->scanline_pad = SDL_BYTESPERPIXEL(mode.format) * 8; - pixmapFormats = XListPixmapFormats(data->display, &n); + pixmapFormats = X11_XListPixmapFormats(data->display, &n); if (pixmapFormats) { for (i = 0; i < n; ++i) { if (pixmapFormats[i].depth == displaydata->depth) { @@ -509,7 +509,7 @@ X11_InitModes(_THIS) break; } } - XFree(pixmapFormats); + X11_XFree(pixmapFormats); } #if SDL_VIDEO_DRIVER_X11_XINERAMA @@ -526,13 +526,13 @@ X11_InitModes(_THIS) #if SDL_VIDEO_DRIVER_X11_XRANDR if (use_xrandr) { - res = XRRGetScreenResources(data->display, RootWindow(data->display, displaydata->screen)); + res = X11_XRRGetScreenResources(data->display, RootWindow(data->display, displaydata->screen)); } if (res) { XRROutputInfo *output_info; XRRCrtcInfo *crtc; int output; - Atom EDID = XInternAtom(data->display, "EDID", False); + Atom EDID = X11_XInternAtom(data->display, "EDID", False); Atom *props; int nprop; unsigned long width_mm; @@ -540,10 +540,10 @@ X11_InitModes(_THIS) int inches = 0; for (output = 0; output < res->noutput; output++) { - output_info = XRRGetOutputInfo(data->display, res, res->outputs[output]); + output_info = X11_XRRGetOutputInfo(data->display, res, res->outputs[output]); if (!output_info || !output_info->crtc || output_info->connection == RR_Disconnected) { - XRRFreeOutputInfo(output_info); + X11_XRRFreeOutputInfo(output_info); continue; } @@ -551,10 +551,10 @@ X11_InitModes(_THIS) We're checking the crtc position, but that may not be a valid test in all cases. Anybody want to give this some love? */ - crtc = XRRGetCrtcInfo(data->display, res, output_info->crtc); + crtc = X11_XRRGetCrtcInfo(data->display, res, output_info->crtc); if (!crtc || crtc->x != displaydata->x || crtc->y != displaydata->y) { - XRRFreeOutputInfo(output_info); - XRRFreeCrtcInfo(crtc); + X11_XRRFreeOutputInfo(output_info); + X11_XRRFreeCrtcInfo(crtc); continue; } @@ -570,7 +570,7 @@ X11_InitModes(_THIS) SDL_strlcpy(display_name, output_info->name, sizeof(display_name)); /* See if we can get the EDID data for the real monitor name */ - props = XRRListOutputProperties(data->display, res->outputs[output], &nprop); + props = X11_XRRListOutputProperties(data->display, res->outputs[output], &nprop); for (i = 0; i < nprop; ++i) { unsigned char *prop; int actual_format; @@ -578,7 +578,7 @@ X11_InitModes(_THIS) Atom actual_type; if (props[i] == EDID) { - if (XRRGetOutputProperty(data->display, + if (X11_XRRGetOutputProperty(data->display, res->outputs[output], props[i], 0, 100, False, False, AnyPropertyType, @@ -593,13 +593,13 @@ X11_InitModes(_THIS) SDL_strlcpy(display_name, info->dsc_product_name, sizeof(display_name)); free(info); } - XFree(prop); + X11_XFree(prop); } break; } } if (props) { - XFree(props); + X11_XFree(props); } if (*display_name && inches) { @@ -610,8 +610,8 @@ X11_InitModes(_THIS) printf("Display name: %s\n", display_name); #endif - XRRFreeOutputInfo(output_info); - XRRFreeCrtcInfo(crtc); + X11_XRRFreeOutputInfo(output_info); + X11_XRRFreeCrtcInfo(crtc); break; } #ifdef X11MODES_DEBUG @@ -619,7 +619,7 @@ X11_InitModes(_THIS) printf("Couldn't find XRandR CRTC at %d,%d\n", displaydata->x, displaydata->y); } #endif - XRRFreeScreenResources(res); + X11_XRRFreeScreenResources(res); } #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */ @@ -652,7 +652,7 @@ X11_InitModes(_THIS) } #if SDL_VIDEO_DRIVER_X11_XINERAMA - if (xinerama) XFree(xinerama); + if (xinerama) X11_XFree(xinerama); #endif if (_this->num_displays == 0) { @@ -725,13 +725,13 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display) if (data->use_xrandr) { XRRScreenResources *res; - res = XRRGetScreenResources (display, RootWindow(display, data->screen)); + res = X11_XRRGetScreenResources (display, RootWindow(display, data->screen)); if (res) { SDL_DisplayModeData *modedata; XRROutputInfo *output_info; int i; - output_info = XRRGetOutputInfo(display, res, data->xrandr_output); + output_info = X11_XRRGetOutputInfo(display, res, data->xrandr_output); if (output_info && output_info->connection != RR_Disconnected) { for (i = 0; i < output_info->nmode; ++i) { modedata = (SDL_DisplayModeData *) SDL_calloc(1, sizeof(SDL_DisplayModeData)); @@ -747,8 +747,8 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display) } } } - XRRFreeOutputInfo(output_info); - XRRFreeScreenResources(res); + X11_XRRFreeOutputInfo(output_info); + X11_XRRFreeScreenResources(res); } return; } @@ -756,7 +756,7 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display) #if SDL_VIDEO_DRIVER_X11_XVIDMODE if (data->use_vidmode && - XF86VidModeGetAllModeLines(display, data->vidmode_screen, &nmodes, &modes)) { + X11_XF86VidModeGetAllModeLines(display, data->vidmode_screen, &nmodes, &modes)) { int i; #ifdef X11MODES_DEBUG @@ -780,7 +780,7 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display) SDL_free(modedata); } } - XFree(modes); + X11_XFree(modes); return; } #endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */ @@ -811,41 +811,41 @@ X11_SetDisplayMode(_THIS, SDL_VideoDisplay * sdl_display, SDL_DisplayMode * mode XRRCrtcInfo *crtc; Status status; - res = XRRGetScreenResources (display, RootWindow(display, data->screen)); + res = X11_XRRGetScreenResources (display, RootWindow(display, data->screen)); if (!res) { return SDL_SetError("Couldn't get XRandR screen resources"); } - output_info = XRRGetOutputInfo(display, res, data->xrandr_output); + output_info = X11_XRRGetOutputInfo(display, res, data->xrandr_output); if (!output_info || output_info->connection == RR_Disconnected) { - XRRFreeScreenResources(res); + X11_XRRFreeScreenResources(res); return SDL_SetError("Couldn't get XRandR output info"); } - crtc = XRRGetCrtcInfo(display, res, output_info->crtc); + crtc = X11_XRRGetCrtcInfo(display, res, output_info->crtc); if (!crtc) { - XRRFreeOutputInfo(output_info); - XRRFreeScreenResources(res); + X11_XRRFreeOutputInfo(output_info); + X11_XRRFreeScreenResources(res); return SDL_SetError("Couldn't get XRandR crtc info"); } - status = XRRSetCrtcConfig (display, res, output_info->crtc, CurrentTime, + status = X11_XRRSetCrtcConfig (display, res, output_info->crtc, CurrentTime, crtc->x, crtc->y, modedata->xrandr_mode, crtc->rotation, &data->xrandr_output, 1); - XRRFreeCrtcInfo(crtc); - XRRFreeOutputInfo(output_info); - XRRFreeScreenResources(res); + X11_XRRFreeCrtcInfo(crtc); + X11_XRRFreeOutputInfo(output_info); + X11_XRRFreeScreenResources(res); if (status != Success) { - return SDL_SetError("XRRSetCrtcConfig failed"); + return SDL_SetError("X11_XRRSetCrtcConfig failed"); } } #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */ #if SDL_VIDEO_DRIVER_X11_XVIDMODE if (data->use_vidmode) { - XF86VidModeSwitchToMode(display, data->vidmode_screen, &modedata->vm_mode); + X11_XF86VidModeSwitchToMode(display, data->vidmode_screen, &modedata->vm_mode); } #endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */ @@ -872,11 +872,11 @@ X11_GetDisplayBounds(_THIS, SDL_VideoDisplay * sdl_display, SDL_Rect * rect) if (data->use_xinerama) { Display *display = ((SDL_VideoData *) _this->driverdata)->display; int screencount; - XineramaScreenInfo *xinerama = XineramaQueryScreens(display, &screencount); + XineramaScreenInfo *xinerama = X11_XineramaQueryScreens(display, &screencount); if (xinerama) { rect->x = xinerama[data->xinerama_screen].x_org; rect->y = xinerama[data->xinerama_screen].y_org; - XFree(xinerama); + X11_XFree(xinerama); } } #endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */ diff --git a/src/video/x11/SDL_x11mouse.c b/src/video/x11/SDL_x11mouse.c index 441ecdfe3..4bcd9d6c8 100644 --- a/src/video/x11/SDL_x11mouse.c +++ b/src/video/x11/SDL_x11mouse.c @@ -50,12 +50,12 @@ X11_CreateEmptyCursor() SDL_zero(data); color.red = color.green = color.blue = 0; - pixmap = XCreateBitmapFromData(display, DefaultRootWindow(display), + pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display), data, 1, 1); if (pixmap) { - x11_empty_cursor = XCreatePixmapCursor(display, pixmap, pixmap, + x11_empty_cursor = X11_XCreatePixmapCursor(display, pixmap, pixmap, &color, &color, 0, 0); - XFreePixmap(display, pixmap); + X11_XFreePixmap(display, pixmap); } } return x11_empty_cursor; @@ -65,7 +65,7 @@ static void X11_DestroyEmptyCursor(void) { if (x11_empty_cursor != None) { - XFreeCursor(GetDisplay(), x11_empty_cursor); + X11_XFreeCursor(GetDisplay(), x11_empty_cursor); x11_empty_cursor = None; } } @@ -94,7 +94,7 @@ X11_CreateXCursorCursor(SDL_Surface * surface, int hot_x, int hot_y) Cursor cursor = None; XcursorImage *image; - image = XcursorImageCreate(surface->w, surface->h); + image = X11_XcursorImageCreate(surface->w, surface->h); if (!image) { SDL_OutOfMemory(); return None; @@ -107,9 +107,9 @@ X11_CreateXCursorCursor(SDL_Surface * surface, int hot_x, int hot_y) SDL_assert(surface->pitch == surface->w * 4); SDL_memcpy(image->pixels, surface->pixels, surface->h * surface->pitch); - cursor = XcursorImageLoadCursor(display, image); + cursor = X11_XcursorImageLoadCursor(display, image); - XcursorImageDestroy(image); + X11_XcursorImageDestroy(image); return cursor; } @@ -186,16 +186,16 @@ X11_CreatePixmapCursor(SDL_Surface * surface, int hot_x, int hot_y) } else bg.red = bg.green = bg.blue = 0; - data_pixmap = XCreateBitmapFromData(display, DefaultRootWindow(display), + data_pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display), (char*)data_bits, surface->w, surface->h); - mask_pixmap = XCreateBitmapFromData(display, DefaultRootWindow(display), + mask_pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display), (char*)mask_bits, surface->w, surface->h); - cursor = XCreatePixmapCursor(display, data_pixmap, mask_pixmap, + cursor = X11_XCreatePixmapCursor(display, data_pixmap, mask_pixmap, &fg, &bg, hot_x, hot_y); - XFreePixmap(display, data_pixmap); - XFreePixmap(display, mask_pixmap); + X11_XFreePixmap(display, data_pixmap); + X11_XFreePixmap(display, mask_pixmap); return cursor; } @@ -256,7 +256,7 @@ X11_CreateSystemCursor(SDL_SystemCursor id) if (cursor) { Cursor x11_cursor; - x11_cursor = XCreateFontCursor(GetDisplay(), shape); + x11_cursor = X11_XCreateFontCursor(GetDisplay(), shape); cursor->driverdata = (void*)x11_cursor; } else { @@ -272,7 +272,7 @@ X11_FreeCursor(SDL_Cursor * cursor) Cursor x11_cursor = (Cursor)cursor->driverdata; if (x11_cursor != None) { - XFreeCursor(GetDisplay(), x11_cursor); + X11_XFreeCursor(GetDisplay(), x11_cursor); } SDL_free(cursor); } @@ -298,12 +298,12 @@ X11_ShowCursor(SDL_Cursor * cursor) for (window = video->windows; window; window = window->next) { data = (SDL_WindowData *)window->driverdata; if (x11_cursor != None) { - XDefineCursor(display, data->xwindow, x11_cursor); + X11_XDefineCursor(display, data->xwindow, x11_cursor); } else { - XUndefineCursor(display, data->xwindow); + X11_XUndefineCursor(display, data->xwindow); } } - XFlush(display); + X11_XFlush(display); } return 0; } @@ -314,8 +314,8 @@ X11_WarpMouse(SDL_Window * window, int x, int y) SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Display *display = data->videodata->display; - XWarpPointer(display, None, data->xwindow, 0, 0, 0, 0, x, y); - XSync(display, False); + X11_XWarpPointer(display, None, data->xwindow, 0, 0, 0, 0, x, y); + X11_XSync(display, False); } static int diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c index 2eaed8698..a41033a70 100644 --- a/src/video/x11/SDL_x11opengl.c +++ b/src/video/x11/SDL_x11opengl.c @@ -106,6 +106,13 @@ typedef GLXContext(*PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display * dpy, #endif #endif +#ifndef GLX_ARB_framebuffer_sRGB +#define GLX_ARB_framebuffer_sRGB +#ifndef GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB +#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2 +#endif +#endif + #ifndef GLX_EXT_swap_control #define GLX_SWAP_INTERVAL_EXT 0x20F1 #define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2 @@ -140,25 +147,6 @@ X11_GL_LoadLibrary(_THIS, const char *path) return SDL_SetError("OpenGL context already created"); } - /* If SDL_GL_CONTEXT_EGL has been changed to 1, switch over to X11_GLES functions */ - if (_this->gl_config.use_egl == 1) { -#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 - _this->GL_LoadLibrary = X11_GLES_LoadLibrary; - _this->GL_GetProcAddress = X11_GLES_GetProcAddress; - _this->GL_UnloadLibrary = X11_GLES_UnloadLibrary; - _this->GL_CreateContext = X11_GLES_CreateContext; - _this->GL_MakeCurrent = X11_GLES_MakeCurrent; - _this->GL_SetSwapInterval = X11_GLES_SetSwapInterval; - _this->GL_GetSwapInterval = X11_GLES_GetSwapInterval; - _this->GL_SwapWindow = X11_GLES_SwapWindow; - _this->GL_DeleteContext = X11_GLES_DeleteContext; - return X11_GLES_LoadLibrary(_this, path); -#else - return SDL_SetError("SDL not configured with OpenGL ES/EGL support"); -#endif - } - - /* Load the OpenGL library */ if (path == NULL) { path = SDL_getenv("SDL_OPENGL_LIBRARY"); @@ -228,6 +216,33 @@ X11_GL_LoadLibrary(_THIS, const char *path) /* Initialize extensions */ X11_GL_InitExtensions(_this); + + /* If we need a GL ES context and there's no + * GLX_EXT_create_context_es2_profile extension, switch over to X11_GLES functions + */ + if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES && + ! _this->gl_data->HAS_GLX_EXT_create_context_es2_profile ) { +#if SDL_VIDEO_OPENGL_EGL + X11_GL_UnloadLibrary(_this); + /* Better avoid conflicts! */ + if (_this->gl_config.dll_handle != NULL ) { + GL_UnloadObject(_this->gl_config.dll_handle); + _this->gl_config.dll_handle = NULL; + } + _this->GL_LoadLibrary = X11_GLES_LoadLibrary; + _this->GL_GetProcAddress = X11_GLES_GetProcAddress; + _this->GL_UnloadLibrary = X11_GLES_UnloadLibrary; + _this->GL_CreateContext = X11_GLES_CreateContext; + _this->GL_MakeCurrent = X11_GLES_MakeCurrent; + _this->GL_SetSwapInterval = X11_GLES_SetSwapInterval; + _this->GL_GetSwapInterval = X11_GLES_GetSwapInterval; + _this->GL_SwapWindow = X11_GLES_SwapWindow; + _this->GL_DeleteContext = X11_GLES_DeleteContext; + return X11_GLES_LoadLibrary(_this, NULL); +#else + return SDL_SetError("SDL not configured with EGL support"); +#endif + } return 0; } @@ -254,10 +269,8 @@ X11_GL_UnloadLibrary(_THIS) #endif /* Free OpenGL memory */ - if (_this->gl_data) { - SDL_free(_this->gl_data); - _this->gl_data = NULL; - } + SDL_free(_this->gl_data); + _this->gl_data = NULL; } static SDL_bool @@ -314,16 +327,16 @@ X11_GL_InitExtensions(_THIS) xattr.background_pixel = 0; xattr.border_pixel = 0; xattr.colormap = - XCreateColormap(display, RootWindow(display, screen), vinfo->visual, + X11_XCreateColormap(display, RootWindow(display, screen), vinfo->visual, AllocNone); - w = XCreateWindow(display, RootWindow(display, screen), 0, 0, 32, 32, 0, + w = X11_XCreateWindow(display, RootWindow(display, screen), 0, 0, 32, 32, 0, vinfo->depth, InputOutput, vinfo->visual, (CWBackPixel | CWBorderPixel | CWColormap), &xattr); context = _this->gl_data->glXCreateContext(display, vinfo, NULL, True); if (context) { _this->gl_data->glXMakeCurrent(display, w, context); } - XFree(vinfo); + X11_XFree(vinfo); glXQueryExtensionsStringFunc = (const char *(*)(Display *, int)) X11_GL_GetProcAddress(_this, @@ -369,12 +382,17 @@ X11_GL_InitExtensions(_THIS) if (HasExtension("GLX_EXT_visual_info", extensions)) { _this->gl_data->HAS_GLX_EXT_visual_info = SDL_TRUE; } + + /* Check for GLX_EXT_create_context_es2_profile */ + if (HasExtension("GLX_EXT_create_context_es2_profile", extensions)) { + _this->gl_data->HAS_GLX_EXT_create_context_es2_profile = SDL_TRUE; + } if (context) { _this->gl_data->glXMakeCurrent(display, None, NULL); _this->gl_data->glXDestroyContext(display, context); } - XDestroyWindow(display, w); + X11_XDestroyWindow(display, w); X11_PumpEvents(_this); } @@ -461,6 +479,13 @@ X11_GL_GetAttributes(_THIS, Display * display, int screen, int * attribs, int si attribs[i++] = _this->gl_config.multisamplesamples; } + if (_this->gl_config.framebuffer_srgb_capable) { + attribs[i++] = GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB; + if( for_FBConfig ) { + attribs[i++] = True; + } + } + if (_this->gl_config.accelerated >= 0 && _this->gl_data->HAS_GLX_EXT_visual_rating) { attribs[i++] = GLX_VISUAL_CAVEAT_EXT; @@ -546,6 +571,7 @@ X11_GL_CreateContext(_THIS, SDL_Window * window) XVisualInfo v, *vinfo; int n; GLXContext context = NULL, share_context; + PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs = NULL; if (_this->gl_config.share_with_current_context) { share_context = (GLXContext)SDL_GL_GetCurrentContext(); @@ -554,13 +580,13 @@ X11_GL_CreateContext(_THIS, SDL_Window * window) } /* We do this to create a clean separation between X and GLX errors. */ - XSync(display, False); + X11_XSync(display, False); errorBase = _this->gl_data->errorBase; - handler = XSetErrorHandler(X11_GL_CreateContextErrorHandler); - XGetWindowAttributes(display, data->xwindow, &xattr); + handler = X11_XSetErrorHandler(X11_GL_CreateContextErrorHandler); + X11_XGetWindowAttributes(display, data->xwindow, &xattr); v.screen = screen; - v.visualid = XVisualIDFromVisual(xattr.visual); - vinfo = XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &v, &n); + v.visualid = X11_XVisualIDFromVisual(xattr.visual); + vinfo = X11_XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &v, &n); if (vinfo) { if (_this->gl_config.major_version < 3 && _this->gl_config.profile_mask == 0 && @@ -599,7 +625,7 @@ X11_GL_CreateContext(_THIS, SDL_Window * window) attribs[iattr++] = 0; /* Get a pointer to the context creation function for GL 3.0 */ - PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs = + glXCreateContextAttribs = (PFNGLXCREATECONTEXTATTRIBSARBPROC) _this->gl_data-> glXGetProcAddress((GLubyte *) "glXCreateContextAttribsARB"); @@ -644,10 +670,10 @@ X11_GL_CreateContext(_THIS, SDL_Window * window) } } } - XFree(vinfo); + X11_XFree(vinfo); } - XSync(display, False); - XSetErrorHandler(handler); + X11_XSync(display, False); + X11_XSetErrorHandler(handler); if (!context) { SDL_SetError("Could not create GL context"); @@ -789,7 +815,7 @@ X11_GL_DeleteContext(_THIS, SDL_GLContext context) return; } _this->gl_data->glXDestroyContext(display, glx_context); - XSync(display, False); + X11_XSync(display, False); } #endif /* SDL_VIDEO_OPENGL_GLX */ diff --git a/src/video/x11/SDL_x11opengl.h b/src/video/x11/SDL_x11opengl.h index db1b3152e..27d7f9a2f 100644 --- a/src/video/x11/SDL_x11opengl.h +++ b/src/video/x11/SDL_x11opengl.h @@ -34,6 +34,7 @@ struct SDL_GLDriverData SDL_bool HAS_GLX_EXT_visual_rating; SDL_bool HAS_GLX_EXT_visual_info; SDL_bool HAS_GLX_EXT_swap_control_tear; + SDL_bool HAS_GLX_EXT_create_context_es2_profile; Bool (*glXQueryExtension) (Display*,int*,int*); void *(*glXGetProcAddress) (const GLubyte*); diff --git a/src/video/x11/SDL_x11opengles.c b/src/video/x11/SDL_x11opengles.c index ba72aff17..f972ceeeb 100644 --- a/src/video/x11/SDL_x11opengles.c +++ b/src/video/x11/SDL_x11opengles.c @@ -20,86 +20,22 @@ */ #include "SDL_config.h" -#if SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_OPENGL_ES +#if SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_OPENGL_EGL #include "SDL_x11video.h" #include "SDL_x11opengles.h" #include "SDL_x11opengl.h" -#define DEFAULT_EGL "libEGL.so" -#define DEFAULT_OGL_ES2 "libGLESv2.so" -#define DEFAULT_OGL_ES_PVR "libGLES_CM.so" -#define DEFAULT_OGL_ES "libGLESv1_CM.so" - -#define LOAD_FUNC(NAME) \ - *((void**)&_this->gles_data->NAME) = dlsym(handle, #NAME); \ - if (!_this->gles_data->NAME) \ - { \ - return SDL_SetError("Could not retrieve EGL function " #NAME); \ - } - -/* GLES implementation of SDL OpenGL support */ - -void * -X11_GLES_GetProcAddress(_THIS, const char *proc) -{ - static char procname[1024]; - void *handle; - void *retval; - - handle = _this->gles_data->egl_dll_handle; - if (_this->gles_data->eglGetProcAddress) { - retval = _this->gles_data->eglGetProcAddress(proc); - if (retval) { - return retval; - } - } - - handle = _this->gl_config.dll_handle; -#if defined(__OpenBSD__) && !defined(__ELF__) -#undef dlsym(x,y); -#endif - retval = dlsym(handle, proc); - if (!retval && strlen(proc) <= 1022) { - procname[0] = '_'; - strcpy(procname + 1, proc); - retval = dlsym(handle, procname); - } - return retval; -} - -void -X11_GLES_UnloadLibrary(_THIS) -{ - if ((_this->gles_data) && (_this->gl_config.driver_loaded)) { - _this->gles_data->eglTerminate(_this->gles_data->egl_display); - - dlclose(_this->gl_config.dll_handle); - dlclose(_this->gles_data->egl_dll_handle); - - SDL_free(_this->gles_data); - _this->gles_data = NULL; - - _this->gl_config.dll_handle = NULL; - _this->gl_config.driver_loaded = 0; - } -} +/* EGL implementation of SDL OpenGL support */ int -X11_GLES_LoadLibrary(_THIS, const char *path) -{ - void *handle; - int dlopen_flags; - +X11_GLES_LoadLibrary(_THIS, const char *path) { + SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - if (_this->gles_data) { - return SDL_SetError("OpenGL ES context already created"); - } - - /* If SDL_GL_CONTEXT_EGL has been changed to 0, switch over to X11_GL functions */ - if (_this->gl_config.use_egl == 0) { -#if SDL_VIDEO_OPENGL_GLX + /* If the profile requested is not GL ES, switch over to X11_GL functions */ + if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) { + #if SDL_VIDEO_OPENGL_GLX _this->GL_LoadLibrary = X11_GL_LoadLibrary; _this->GL_GetProcAddress = X11_GL_GetProcAddress; _this->GL_UnloadLibrary = X11_GL_UnloadLibrary; @@ -110,331 +46,63 @@ X11_GLES_LoadLibrary(_THIS, const char *path) _this->GL_SwapWindow = X11_GL_SwapWindow; _this->GL_DeleteContext = X11_GL_DeleteContext; return X11_GL_LoadLibrary(_this, path); -#else + #else return SDL_SetError("SDL not configured with OpenGL/GLX support"); -#endif + #endif } - -#ifdef RTLD_GLOBAL - dlopen_flags = RTLD_LAZY | RTLD_GLOBAL; -#else - dlopen_flags = RTLD_LAZY; -#endif - handle = dlopen(path, dlopen_flags); - /* Catch the case where the application isn't linked with EGL */ - if ((dlsym(handle, "eglChooseConfig") == NULL) && (path == NULL)) { - - dlclose(handle); - path = getenv("SDL_VIDEO_EGL_DRIVER"); - if (path == NULL) { - path = DEFAULT_EGL; - } - handle = dlopen(path, dlopen_flags); - } - - if (handle == NULL) { - return SDL_SetError("Could not load OpenGL ES/EGL library"); - } - - /* Unload the old driver and reset the pointers */ - X11_GLES_UnloadLibrary(_this); - - _this->gles_data = (struct SDL_PrivateGLESData *) SDL_calloc(1, sizeof(SDL_PrivateGLESData)); - if (!_this->gles_data) { - return SDL_OutOfMemory(); - } - - /* Load new function pointers */ - LOAD_FUNC(eglGetDisplay); - LOAD_FUNC(eglInitialize); - LOAD_FUNC(eglTerminate); - LOAD_FUNC(eglGetProcAddress); - LOAD_FUNC(eglChooseConfig); - LOAD_FUNC(eglGetConfigAttrib); - LOAD_FUNC(eglCreateContext); - LOAD_FUNC(eglDestroyContext); - LOAD_FUNC(eglCreateWindowSurface); - LOAD_FUNC(eglDestroySurface); - LOAD_FUNC(eglMakeCurrent); - LOAD_FUNC(eglSwapBuffers); - LOAD_FUNC(eglSwapInterval); - - _this->gles_data->egl_display = - _this->gles_data->eglGetDisplay((NativeDisplayType) data->display); - - if (!_this->gles_data->egl_display) { - return SDL_SetError("Could not get EGL display"); - } - - if (_this->gles_data-> - eglInitialize(_this->gles_data->egl_display, NULL, - NULL) != EGL_TRUE) { - return SDL_SetError("Could not initialize EGL"); - } - - _this->gles_data->egl_dll_handle = handle; - - path = getenv("SDL_VIDEO_GL_DRIVER"); - handle = dlopen(path, dlopen_flags); - if ((path == NULL) | (handle == NULL)) { - if (_this->gl_config.major_version > 1) { - path = DEFAULT_OGL_ES2; - handle = dlopen(path, dlopen_flags); - } else { - path = DEFAULT_OGL_ES; - handle = dlopen(path, dlopen_flags); - if (handle == NULL) { - path = DEFAULT_OGL_ES_PVR; - handle = dlopen(path, dlopen_flags); - } - } - } - - if (handle == NULL) { - return SDL_SetError("Could not initialize OpenGL ES library"); - } - - _this->gl_config.dll_handle = handle; - _this->gl_config.driver_loaded = 1; - - if (path) { - strncpy(_this->gl_config.driver_path, path, - sizeof(_this->gl_config.driver_path) - 1); - } else { - strcpy(_this->gl_config.driver_path, ""); - } - return 0; + + return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType) data->display); } XVisualInfo * X11_GLES_GetVisual(_THIS, Display * display, int screen) { - /* 64 seems nice. */ - EGLint attribs[64]; - EGLint found_configs = 0; + + XVisualInfo *egl_visualinfo = NULL; EGLint visual_id; - int i; + XVisualInfo vi_in; + int out_count; - if (!_this->gles_data) { + if (!_this->egl_data) { /* The EGL library wasn't loaded, SDL_GetError() should have info */ return NULL; } - i = 0; - attribs[i++] = EGL_RED_SIZE; - attribs[i++] = _this->gl_config.red_size; - attribs[i++] = EGL_GREEN_SIZE; - attribs[i++] = _this->gl_config.green_size; - attribs[i++] = EGL_BLUE_SIZE; - attribs[i++] = _this->gl_config.blue_size; - - if (_this->gl_config.alpha_size) { - attribs[i++] = EGL_ALPHA_SIZE; - attribs[i++] = _this->gl_config.alpha_size; - } - - if (_this->gl_config.buffer_size) { - attribs[i++] = EGL_BUFFER_SIZE; - attribs[i++] = _this->gl_config.buffer_size; - } - - attribs[i++] = EGL_DEPTH_SIZE; - attribs[i++] = _this->gl_config.depth_size; - - if (_this->gl_config.stencil_size) { - attribs[i++] = EGL_STENCIL_SIZE; - attribs[i++] = _this->gl_config.stencil_size; - } - - if (_this->gl_config.multisamplebuffers) { - attribs[i++] = EGL_SAMPLE_BUFFERS; - attribs[i++] = _this->gl_config.multisamplebuffers; - } - - if (_this->gl_config.multisamplesamples) { - attribs[i++] = EGL_SAMPLES; - attribs[i++] = _this->gl_config.multisamplesamples; - } - - attribs[i++] = EGL_RENDERABLE_TYPE; - if (_this->gl_config.major_version == 2) { - attribs[i++] = EGL_OPENGL_ES2_BIT; - } else { - attribs[i++] = EGL_OPENGL_ES_BIT; - } - - attribs[i++] = EGL_NONE; - - if (_this->gles_data->eglChooseConfig(_this->gles_data->egl_display, - attribs, - &_this->gles_data->egl_config, 1, - &found_configs) == EGL_FALSE || - found_configs == 0) { - SDL_SetError("Couldn't find matching EGL config"); - return NULL; - } - - if (_this->gles_data->eglGetConfigAttrib(_this->gles_data->egl_display, - _this->gles_data->egl_config, - EGL_NATIVE_VISUAL_ID, - &visual_id) == - EGL_FALSE || !visual_id) { + if (_this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, + _this->egl_data->egl_config, + EGL_NATIVE_VISUAL_ID, + &visual_id) == EGL_FALSE || !visual_id) { /* Use the default visual when all else fails */ - XVisualInfo vi_in; - int out_count; vi_in.screen = screen; - - _this->gles_data->egl_visualinfo = XGetVisualInfo(display, - VisualScreenMask, - &vi_in, &out_count); + egl_visualinfo = X11_XGetVisualInfo(display, + VisualScreenMask, + &vi_in, &out_count); } else { - XVisualInfo vi_in; - int out_count; - vi_in.screen = screen; vi_in.visualid = visual_id; - _this->gles_data->egl_visualinfo = XGetVisualInfo(display, - VisualScreenMask | - VisualIDMask, - &vi_in, &out_count); + egl_visualinfo = X11_XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &vi_in, &out_count); } - return _this->gles_data->egl_visualinfo; + return egl_visualinfo; } SDL_GLContext X11_GLES_CreateContext(_THIS, SDL_Window * window) { - EGLint context_attrib_list[] = { - EGL_CONTEXT_CLIENT_VERSION, - 1, - EGL_NONE - }; - + SDL_GLContext context; SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Display *display = data->videodata->display; - SDL_GLContext context = (SDL_GLContext)1; - XSync(display, False); - - if (_this->gl_config.major_version) { - context_attrib_list[1] = _this->gl_config.major_version; - } - - _this->gles_data->egl_context = - _this->gles_data->eglCreateContext(_this->gles_data->egl_display, - _this->gles_data->egl_config, - EGL_NO_CONTEXT, context_attrib_list); - XSync(display, False); - - if (_this->gles_data->egl_context == EGL_NO_CONTEXT) { - SDL_SetError("Could not create EGL context"); - return NULL; - } - - _this->gles_data->egl_swapinterval = 0; - - if (X11_GLES_MakeCurrent(_this, window, context) < 0) { - X11_GLES_DeleteContext(_this, context); - return NULL; - } + X11_XSync(display, False); + context = SDL_EGL_CreateContext(_this, data->egl_surface); + X11_XSync(display, False); return context; } -int -X11_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) -{ -/* - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; - Display *display = data->videodata->display; -*/ +SDL_EGL_SwapWindow_impl(X11) +SDL_EGL_MakeCurrent_impl(X11) - if (!_this->gles_data) { - return SDL_SetError("OpenGL not initialized"); - } - - if (!_this->gles_data->eglMakeCurrent(_this->gles_data->egl_display, - _this->gles_data->egl_surface, - _this->gles_data->egl_surface, - _this->gles_data->egl_context)) { - return SDL_SetError("Unable to make EGL context current"); - } - -/* - XSync(display, False); -*/ - - return 1; -} - -int -X11_GLES_SetSwapInterval(_THIS, int interval) -{ - if (_this->gles_data) { - return SDL_SetError("OpenGL ES context not active"); - } - - EGLBoolean status; - status = _this->gles_data->eglSwapInterval(_this->gles_data->egl_display, interval); - if (status == EGL_TRUE) { - _this->gles_data->egl_swapinterval = interval; - return 0; - } - - return SDL_SetError("Unable to set the EGL swap interval"); -} - -int -X11_GLES_GetSwapInterval(_THIS) -{ - if (_this->gles_data) { - return SDL_SetError("OpenGL ES context not active"); - } - - return _this->gles_data->egl_swapinterval; -} - -void -X11_GLES_SwapWindow(_THIS, SDL_Window * window) -{ - _this->gles_data->eglSwapBuffers(_this->gles_data->egl_display, - _this->gles_data->egl_surface); -} - -void -X11_GLES_DeleteContext(_THIS, SDL_GLContext context) -{ - /* Clean up GLES and EGL */ - if (!_this->gles_data) { - return; - } - - if (_this->gles_data->egl_context != EGL_NO_CONTEXT || - _this->gles_data->egl_surface != EGL_NO_SURFACE) { - _this->gles_data->eglMakeCurrent(_this->gles_data->egl_display, - EGL_NO_SURFACE, EGL_NO_SURFACE, - EGL_NO_CONTEXT); - - if (_this->gles_data->egl_context != EGL_NO_CONTEXT) { - _this->gles_data->eglDestroyContext(_this->gles_data->egl_display, - _this->gles_data-> - egl_context); - _this->gles_data->egl_context = EGL_NO_CONTEXT; - } - - if (_this->gles_data->egl_surface != EGL_NO_SURFACE) { - _this->gles_data->eglDestroySurface(_this->gles_data->egl_display, - _this->gles_data-> - egl_surface); - _this->gles_data->egl_surface = EGL_NO_SURFACE; - } - } - - /* crappy fix */ - X11_GLES_UnloadLibrary(_this); -} - -#endif /* SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_OPENGL_ES */ +#endif /* SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_OPENGL_EGL */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/x11/SDL_x11opengles.h b/src/video/x11/SDL_x11opengles.h index fa1506c76..978f91f3d 100644 --- a/src/video/x11/SDL_x11opengles.h +++ b/src/video/x11/SDL_x11opengles.h @@ -23,81 +23,30 @@ #ifndef _SDL_x11opengles_h #define _SDL_x11opengles_h -#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 -#include -#include -#include -#if defined(__OpenBSD__) && !defined(__ELF__) -#define dlsym(x,y) dlsym(x, "_" y) -#endif +#if SDL_VIDEO_OPENGL_EGL #include "../SDL_sysvideo.h" +#include "../SDL_egl.h" typedef struct SDL_PrivateGLESData { - XVisualInfo *egl_visualinfo; - void *egl_dll_handle; - EGLDisplay egl_display; - EGLContext egl_context; /* Current GLES context */ - EGLSurface egl_surface; - EGLConfig egl_config; - int egl_swapinterval; - - EGLDisplay(*eglGetDisplay) (NativeDisplayType display); - EGLBoolean(*eglInitialize) (EGLDisplay dpy, EGLint * major, - EGLint * minor); - EGLBoolean(*eglTerminate) (EGLDisplay dpy); - - void *(*eglGetProcAddress) (const char * procName); - - EGLBoolean(*eglChooseConfig) (EGLDisplay dpy, - const EGLint * attrib_list, - EGLConfig * configs, - EGLint config_size, EGLint * num_config); - - EGLContext(*eglCreateContext) (EGLDisplay dpy, - EGLConfig config, - EGLContext share_list, - const EGLint * attrib_list); - - EGLBoolean(*eglDestroyContext) (EGLDisplay dpy, EGLContext ctx); - - EGLSurface(*eglCreateWindowSurface) (EGLDisplay dpy, - EGLConfig config, - NativeWindowType window, - const EGLint * attrib_list); - EGLBoolean(*eglDestroySurface) (EGLDisplay dpy, EGLSurface surface); - - EGLBoolean(*eglMakeCurrent) (EGLDisplay dpy, EGLSurface draw, - EGLSurface read, EGLContext ctx); - - EGLBoolean(*eglSwapBuffers) (EGLDisplay dpy, EGLSurface draw); - - EGLBoolean(*eglSwapInterval) (EGLDisplay dpy, EGLint interval); - - const char *(*eglQueryString) (EGLDisplay dpy, EGLint name); - - EGLBoolean(*eglGetConfigAttrib) (EGLDisplay dpy, EGLConfig config, - EGLint attribute, EGLint * value); - } SDL_PrivateGLESData; /* OpenGLES functions */ -extern SDL_GLContext X11_GLES_CreateContext(_THIS, SDL_Window * window); -extern XVisualInfo *X11_GLES_GetVisual(_THIS, Display * display, int screen); -extern int X11_GLES_MakeCurrent(_THIS, SDL_Window * window, - SDL_GLContext context); -extern int X11_GLES_GetAttribute(_THIS, SDL_GLattr attrib, int *value); +#define X11_GLES_GetAttribute SDL_EGL_GetAttribute +#define X11_GLES_GetProcAddress SDL_EGL_GetProcAddress +#define X11_GLES_UnloadLibrary SDL_EGL_UnloadLibrary +#define X11_GLES_SetSwapInterval SDL_EGL_SetSwapInterval +#define X11_GLES_GetSwapInterval SDL_EGL_GetSwapInterval +#define X11_GLES_DeleteContext SDL_EGL_DeleteContext + extern int X11_GLES_LoadLibrary(_THIS, const char *path); -extern void *X11_GLES_GetProcAddress(_THIS, const char *proc); -extern void X11_GLES_UnloadLibrary(_THIS); - -extern int X11_GLES_SetSwapInterval(_THIS, int interval); -extern int X11_GLES_GetSwapInterval(_THIS); +extern XVisualInfo *X11_GLES_GetVisual(_THIS, Display * display, int screen); +extern SDL_GLContext X11_GLES_CreateContext(_THIS, SDL_Window * window); extern void X11_GLES_SwapWindow(_THIS, SDL_Window * window); -extern void X11_GLES_DeleteContext(_THIS, SDL_GLContext context); +extern int X11_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); -#endif /* SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 */ +#endif /* SDL_VIDEO_OPENGL_EGL */ #endif /* _SDL_x11opengles_h */ diff --git a/src/video/x11/SDL_x11shape.c b/src/video/x11/SDL_x11shape.c index cea280722..af89851e6 100644 --- a/src/video/x11/SDL_x11shape.c +++ b/src/video/x11/SDL_x11shape.c @@ -36,6 +36,8 @@ X11_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned SDL_WindowShaper* X11_CreateShaper(SDL_Window* window) { SDL_WindowShaper* result = NULL; + SDL_ShapeData* data = NULL; + int resized_properly; #if SDL_VIDEO_DRIVER_X11_XSHAPE if (SDL_X11_HAVE_XSHAPE) { /* Make sure X server supports it. */ @@ -44,12 +46,12 @@ X11_CreateShaper(SDL_Window* window) { result->mode.mode = ShapeModeDefault; result->mode.parameters.binarizationCutoff = 1; result->userx = result->usery = 0; - SDL_ShapeData* data = SDL_malloc(sizeof(SDL_ShapeData)); + data = SDL_malloc(sizeof(SDL_ShapeData)); result->driverdata = data; data->bitmapsize = 0; data->bitmap = NULL; window->shaper = result; - int resized_properly = X11_ResizeWindowShape(window); + resized_properly = X11_ResizeWindowShape(window); SDL_assert(resized_properly == 0); } #endif @@ -60,9 +62,9 @@ X11_CreateShaper(SDL_Window* window) { int X11_ResizeWindowShape(SDL_Window* window) { SDL_ShapeData* data = window->shaper->driverdata; + unsigned int bitmapsize = window->w / 8; SDL_assert(data != NULL); - unsigned int bitmapsize = window->w / 8; if(window->w % 8 > 0) bitmapsize += 1; bitmapsize *= window->h; @@ -86,6 +88,10 @@ X11_ResizeWindowShape(SDL_Window* window) { int X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) { + SDL_ShapeData *data = NULL; + SDL_WindowData *windowdata = NULL; + Pixmap shapemask; + if(shaper == NULL || shape == NULL || shaper->driverdata == NULL) return -1; @@ -94,18 +100,18 @@ X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMo return -2; if(shape->w != shaper->window->w || shape->h != shaper->window->h) return -3; - SDL_ShapeData *data = shaper->driverdata; + data = shaper->driverdata; /* Assume that shaper->alphacutoff already has a value, because SDL_SetWindowShape() should have given it one. */ SDL_CalculateShapeBitmap(shaper->mode,shape,data->bitmap,8); - SDL_WindowData *windowdata = (SDL_WindowData*)(shaper->window->driverdata); - Pixmap shapemask = XCreateBitmapFromData(windowdata->videodata->display,windowdata->xwindow,data->bitmap,shaper->window->w,shaper->window->h); + windowdata = (SDL_WindowData*)(shaper->window->driverdata); + shapemask = X11_XCreateBitmapFromData(windowdata->videodata->display,windowdata->xwindow,data->bitmap,shaper->window->w,shaper->window->h); - XShapeCombineMask(windowdata->videodata->display,windowdata->xwindow, ShapeBounding, 0, 0,shapemask, ShapeSet); - XSync(windowdata->videodata->display,False); + X11_XShapeCombineMask(windowdata->videodata->display,windowdata->xwindow, ShapeBounding, 0, 0,shapemask, ShapeSet); + X11_XSync(windowdata->videodata->display,False); - XFreePixmap(windowdata->videodata->display,shapemask); + X11_XFreePixmap(windowdata->videodata->display,shapemask); #endif return 0; diff --git a/src/video/x11/SDL_x11sym.h b/src/video/x11/SDL_x11sym.h index 79f61e0fb..1ee982b55 100644 --- a/src/video/x11/SDL_x11sym.h +++ b/src/video/x11/SDL_x11sym.h @@ -176,9 +176,9 @@ SDL_X11_SYM(KeySym,XKeycodeToKeysym,(Display* a,KeyCode b,int c),(a,b,c),return) SDL_X11_MODULE(UTF8) SDL_X11_SYM(int,Xutf8TextListToTextProperty,(Display* a,char** b,int c,XICCEncodingStyle d,XTextProperty* e),(a,b,c,d,e),return) SDL_X11_SYM(int,Xutf8LookupString,(XIC a,XKeyPressedEvent* b,char* c,int d,KeySym* e,Status* f),(a,b,c,d,e,f),return) -/*SDL_X11_SYM(XIC,XCreateIC,(XIM, ...),return) !!! ARGH! */ +/* SDL_X11_SYM(XIC,XCreateIC,(XIM, ...),return) !!! ARGH! */ SDL_X11_SYM(void,XDestroyIC,(XIC a),(a),) -/*SDL_X11_SYM(char*,XGetICValues,(XIC, ...),return) !!! ARGH! */ +/* SDL_X11_SYM(char*,XGetICValues,(XIC, ...),return) !!! ARGH! */ SDL_X11_SYM(void,XSetICFocus,(XIC a),(a),) SDL_X11_SYM(void,XUnsetICFocus,(XIC a),(a),) SDL_X11_SYM(XIM,XOpenIM,(Display* a,struct _XrmHashBucketRec* b,char* c,char* d),(a,b,c,d),return) diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 86597ecf2..c84d4ec68 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -35,7 +35,7 @@ #include "SDL_x11touch.h" #include "SDL_x11xinput2.h" -#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 +#if SDL_VIDEO_OPENGL_EGL #include "SDL_x11opengles.h" #endif @@ -230,9 +230,9 @@ X11_Available(void) { Display *display = NULL; if (SDL_X11_LoadSymbols()) { - display = XOpenDisplay(NULL); + display = X11_XOpenDisplay(NULL); if (display != NULL) { - XCloseDisplay(display); + X11_XCloseDisplay(display); } SDL_X11_UnloadSymbols(); } @@ -244,7 +244,7 @@ X11_DeleteDevice(SDL_VideoDevice * device) { SDL_VideoData *data = (SDL_VideoData *) device->driverdata; if (data->display) { - XCloseDisplay(data->display); + X11_XCloseDisplay(data->display); } SDL_free(data->windowlist); SDL_free(device->driverdata); @@ -259,10 +259,11 @@ static int (*orig_x11_errhandler) (Display *, XErrorEvent *) = NULL; static int X11_SafetyNetErrHandler(Display * d, XErrorEvent * e) { + SDL_VideoDevice *device = NULL; /* if we trigger an error in our error handler, don't try again. */ if (!safety_net_triggered) { safety_net_triggered = SDL_TRUE; - SDL_VideoDevice *device = SDL_GetVideoDevice(); + device = SDL_GetVideoDevice(); if (device != NULL) { int i; for (i = 0; i < device->num_displays; i++) { @@ -295,7 +296,7 @@ X11_CreateDevice(int devindex) /* Need for threading gl calls. This is also required for the proprietary nVidia driver to be threaded. */ - XInitThreads(); + X11_XInitThreads(); /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); @@ -312,14 +313,14 @@ X11_CreateDevice(int devindex) device->driverdata = data; /* FIXME: Do we need this? - if ( (SDL_strncmp(XDisplayName(display), ":", 1) == 0) || - (SDL_strncmp(XDisplayName(display), "unix:", 5) == 0) ) { + if ( (SDL_strncmp(X11_XDisplayName(display), ":", 1) == 0) || + (SDL_strncmp(X11_XDisplayName(display), "unix:", 5) == 0) ) { local_X11 = 1; } else { local_X11 = 0; } */ - data->display = XOpenDisplay(display); + data->display = X11_XOpenDisplay(display); #if defined(__osf__) && defined(SDL_VIDEO_DRIVER_X11_DYNAMIC) /* On Tru64 if linking without -lX11, it fails and you get following message. * Xlib: connection to ":0.0" refused by server @@ -330,7 +331,7 @@ X11_CreateDevice(int devindex) */ if (data->display == NULL) { SDL_Delay(1000); - data->display = XOpenDisplay(display); + data->display = X11_XOpenDisplay(display); } #endif if (data->display == NULL) { @@ -340,12 +341,12 @@ X11_CreateDevice(int devindex) return NULL; } #ifdef X11_DEBUG - XSynchronize(data->display, True); + X11_XSynchronize(data->display, True); #endif /* Hook up an X11 error handler to recover the desktop resolution. */ safety_net_triggered = SDL_FALSE; - orig_x11_errhandler = XSetErrorHandler(X11_SafetyNetErrHandler); + orig_x11_errhandler = X11_XSetErrorHandler(X11_SafetyNetErrHandler); /* Set the function pointers */ device->VideoInit = X11_VideoInit; @@ -394,7 +395,7 @@ X11_CreateDevice(int devindex) device->GL_GetSwapInterval = X11_GL_GetSwapInterval; device->GL_SwapWindow = X11_GL_SwapWindow; device->GL_DeleteContext = X11_GL_DeleteContext; -#elif SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 +#elif SDL_VIDEO_OPENGL_EGL device->GL_LoadLibrary = X11_GLES_LoadLibrary; device->GL_GetProcAddress = X11_GLES_GetProcAddress; device->GL_UnloadLibrary = X11_GLES_UnloadLibrary; @@ -447,31 +448,31 @@ X11_CheckWindowManager(_THIS) #endif /* Set up a handler to gracefully catch errors */ - XSync(display, False); - handler = XSetErrorHandler(X11_CheckWindowManagerErrorHandler); + X11_XSync(display, False); + handler = X11_XSetErrorHandler(X11_CheckWindowManagerErrorHandler); - _NET_SUPPORTING_WM_CHECK = XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", False); - status = XGetWindowProperty(display, DefaultRootWindow(display), _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata); + _NET_SUPPORTING_WM_CHECK = X11_XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", False); + status = X11_XGetWindowProperty(display, DefaultRootWindow(display), _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata); if (status == Success && items_read) { wm_window = ((Window*)propdata)[0]; } if (propdata) { - XFree(propdata); + X11_XFree(propdata); } if (wm_window) { - status = XGetWindowProperty(display, wm_window, _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata); + status = X11_XGetWindowProperty(display, wm_window, _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata); if (status != Success || !items_read || wm_window != ((Window*)propdata)[0]) { wm_window = None; } if (propdata) { - XFree(propdata); + X11_XFree(propdata); } } /* Reset the error handler, we're done checking */ - XSync(display, False); - XSetErrorHandler(handler); + X11_XSync(display, False); + X11_XSetErrorHandler(handler); if (!wm_window) { #ifdef DEBUG_WINDOW_MANAGER @@ -504,12 +505,12 @@ X11_VideoInit(_THIS) #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8) { data->im = - XOpenIM(data->display, NULL, data->classname, data->classname); + X11_XOpenIM(data->display, NULL, data->classname, data->classname); } #endif /* Look up some useful Atoms */ -#define GET_ATOM(X) data->X = XInternAtom(data->display, #X, False) +#define GET_ATOM(X) data->X = X11_XInternAtom(data->display, #X, False) GET_ATOM(WM_PROTOCOLS); GET_ATOM(WM_DELETE_WINDOW); GET_ATOM(_NET_WM_STATE); @@ -564,12 +565,10 @@ X11_VideoQuit(_THIS) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - if (data->classname) { - SDL_free(data->classname); - } + SDL_free(data->classname); #ifdef X_HAVE_UTF8_STRING if (data->im) { - XCloseIM(data->im); + X11_XCloseIM(data->im); } #endif diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 02529e08a..62a7e7305 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -34,7 +34,7 @@ #include "SDL_x11shape.h" #include "SDL_x11xinput2.h" -#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 +#if SDL_VIDEO_OPENGL_EGL #include "SDL_x11opengles.h" #endif @@ -61,12 +61,12 @@ static Bool isConfigureNotify(Display *dpy, XEvent *ev, XPointer win) /* static Bool -XIfEventTimeout(Display *display, XEvent *event_return, Bool (*predicate)(), XPointer arg, int timeoutMS) +X11_XIfEventTimeout(Display *display, XEvent *event_return, Bool (*predicate)(), XPointer arg, int timeoutMS) { Uint32 start = SDL_GetTicks(); - while (!XCheckIfEvent(display, event_return, predicate, arg)) { - if ((SDL_GetTicks() - start) >= timeoutMS) { + while (!X11_XCheckIfEvent(display, event_return, predicate, arg)) { + if (SDL_TICKS_PASSED(SDL_GetTicks(), start + timeoutMS)) { return False; } } @@ -88,7 +88,7 @@ X11_IsWindowMapped(_THIS, SDL_Window * window) SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; XWindowAttributes attr; - XGetWindowAttributes(videodata->display, data->xwindow, &attr); + X11_XGetWindowAttributes(videodata->display, data->xwindow, &attr); if (attr.map_state != IsUnmapped) { return SDL_TRUE; } else { @@ -110,7 +110,7 @@ X11_IsActionAllowed(SDL_Window *window, Atom action) Atom *list; SDL_bool ret = SDL_FALSE; - if (XGetWindowProperty(display, data->xwindow, _NET_WM_ALLOWED_ACTIONS, 0, 1024, False, XA_ATOM, &type, &form, &len, &remain, (unsigned char **)&list) == Success) + if (X11_XGetWindowProperty(display, data->xwindow, _NET_WM_ALLOWED_ACTIONS, 0, 1024, False, XA_ATOM, &type, &form, &len, &remain, (unsigned char **)&list) == Success) { for (i=0; idriverdata; Display *display = videodata->display; Atom _NET_WM_STATE = videodata->_NET_WM_STATE; - /*Atom _NET_WM_STATE_HIDDEN = videodata->_NET_WM_STATE_HIDDEN;*/ + /* Atom _NET_WM_STATE_HIDDEN = videodata->_NET_WM_STATE_HIDDEN; */ Atom _NET_WM_STATE_FOCUSED = videodata->_NET_WM_STATE_FOCUSED; Atom _NET_WM_STATE_MAXIMIZED_VERT = videodata->_NET_WM_STATE_MAXIMIZED_VERT; Atom _NET_WM_STATE_MAXIMIZED_HORZ = videodata->_NET_WM_STATE_MAXIMIZED_HORZ; @@ -141,7 +141,7 @@ X11_SetNetWMState(_THIS, Window xwindow, Uint32 flags) /* The window manager sets this property, we shouldn't set it. If we did, this would indicate to the window manager that we don't - actually want to be mapped during XMapRaised(), which would be bad. + actually want to be mapped during X11_XMapRaised(), which would be bad. * if (flags & SDL_WINDOW_HIDDEN) { atoms[count++] = _NET_WM_STATE_HIDDEN; @@ -158,10 +158,10 @@ X11_SetNetWMState(_THIS, Window xwindow, Uint32 flags) atoms[count++] = _NET_WM_STATE_FULLSCREEN; } if (count > 0) { - XChangeProperty(display, xwindow, _NET_WM_STATE, XA_ATOM, 32, + X11_XChangeProperty(display, xwindow, _NET_WM_STATE, XA_ATOM, 32, PropModeReplace, (unsigned char *)atoms, count); } else { - XDeleteProperty(display, xwindow, _NET_WM_STATE); + X11_XDeleteProperty(display, xwindow, _NET_WM_STATE); } } @@ -183,7 +183,7 @@ X11_GetNetWMState(_THIS, Window xwindow) long maxLength = 1024; Uint32 flags = 0; - if (XGetWindowProperty(display, xwindow, _NET_WM_STATE, + if (X11_XGetWindowProperty(display, xwindow, _NET_WM_STATE, 0l, maxLength, False, XA_ATOM, &actualType, &actualFormat, &numItems, &bytesAfter, &propertyValue) == Success) { @@ -209,11 +209,11 @@ X11_GetNetWMState(_THIS, Window xwindow) } else if (fullscreen == 1) { flags |= SDL_WINDOW_FULLSCREEN; } - XFree(propertyValue); + X11_XFree(propertyValue); } /* FIXME, check the size hints for resizable */ - /*flags |= SDL_WINDOW_RESIZABLE;*/ + /* flags |= SDL_WINDOW_RESIZABLE; */ return flags; } @@ -237,7 +237,7 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8 && videodata->im) { data->ic = - pXCreateIC(videodata->im, XNClientWindow, w, XNFocusWindow, w, + X11_XCreateIC(videodata->im, XNClientWindow, w, XNFocusWindow, w, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNResourceName, videodata->classname, XNResourceClass, videodata->classname, NULL); @@ -270,7 +270,7 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) { XWindowAttributes attrib; - XGetWindowAttributes(data->videodata->display, w, &attrib); + X11_XGetWindowAttributes(data->videodata->display, w, &attrib); window->x = attrib.x; window->y = attrib.y; window->w = attrib.width; @@ -289,7 +289,7 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) { Window FocalWindow; int RevertTo=0; - XGetInputFocus(data->videodata->display, &FocalWindow, &RevertTo); + X11_XGetInputFocus(data->videodata->display, &FocalWindow, &RevertTo); if (FocalWindow==w) { window->flags |= SDL_WINDOW_INPUT_FOCUS; @@ -318,7 +318,7 @@ SetWindowBordered(Display *display, int screen, Window window, SDL_bool border) * Gnome is similar: just use the Motif atom. */ - Atom WM_HINTS = XInternAtom(display, "_MOTIF_WM_HINTS", True); + Atom WM_HINTS = X11_XInternAtom(display, "_MOTIF_WM_HINTS", True); if (WM_HINTS != None) { /* Hints used by Motif compliant window managers */ struct @@ -332,11 +332,11 @@ SetWindowBordered(Display *display, int screen, Window window, SDL_bool border) (1L << 1), 0, border ? 1 : 0, 0, 0 }; - XChangeProperty(display, window, WM_HINTS, WM_HINTS, 32, + X11_XChangeProperty(display, window, WM_HINTS, WM_HINTS, 32, PropModeReplace, (unsigned char *) &MWMHints, sizeof(MWMHints) / 4); } else { /* set the transient hints instead, if necessary */ - XSetTransientForHint(display, window, RootWindow(display, screen)); + X11_XSetTransientForHint(display, window, RootWindow(display, screen)); } } @@ -346,6 +346,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; + SDL_WindowData *windowdata; Display *display = data->display; int screen = displaydata->screen; Visual *visual; @@ -363,12 +364,17 @@ X11_CreateWindow(_THIS, SDL_Window * window) Atom XdndAware, xdnd_version = 5; Uint32 fevent = 0; -#if SDL_VIDEO_OPENGL_GLX || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 - if (window->flags & SDL_WINDOW_OPENGL) { - XVisualInfo *vinfo; +#if SDL_VIDEO_OPENGL_GLX || SDL_VIDEO_OPENGL_EGL + if ((window->flags & SDL_WINDOW_OPENGL) && + !SDL_getenv("SDL_VIDEO_X11_VISUALID")) { + XVisualInfo *vinfo = NULL; -#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 - if (_this->gl_config.use_egl == 1) { +#if SDL_VIDEO_OPENGL_EGL + if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES +#if SDL_VIDEO_OPENGL_GLX + && ( !_this->gl_data || ! _this->gl_data->HAS_GLX_EXT_create_context_es2_profile ) +#endif + ){ vinfo = X11_GLES_GetVisual(_this, display, screen); } else #endif @@ -377,12 +383,13 @@ X11_CreateWindow(_THIS, SDL_Window * window) vinfo = X11_GL_GetVisual(_this, display, screen); #endif } + if (!vinfo) { return -1; } visual = vinfo->visual; depth = vinfo->depth; - XFree(vinfo); + X11_XFree(vinfo); } else #endif { @@ -391,7 +398,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) } xattr.override_redirect = False; - xattr.background_pixel = 0; + xattr.background_pixmap = None; xattr.border_pixel = 0; if (visual->class == DirectColor) { @@ -403,7 +410,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) int rshift, gshift, bshift; xattr.colormap = - XCreateColormap(display, RootWindow(display, screen), + X11_XCreateColormap(display, RootWindow(display, screen), visual, AllocAll); /* If we can't create a colormap, then we must die */ @@ -464,48 +471,28 @@ X11_CreateWindow(_THIS, SDL_Window * window) colorcells[i].flags = DoRed | DoGreen | DoBlue; } - XStoreColors(display, xattr.colormap, colorcells, ncolors); + X11_XStoreColors(display, xattr.colormap, colorcells, ncolors); SDL_free(colorcells); } else { xattr.colormap = - XCreateColormap(display, RootWindow(display, screen), + X11_XCreateColormap(display, RootWindow(display, screen), visual, AllocNone); } - w = XCreateWindow(display, RootWindow(display, screen), + w = X11_XCreateWindow(display, RootWindow(display, screen), window->x, window->y, window->w, window->h, 0, depth, InputOutput, visual, - (CWOverrideRedirect | CWBackPixel | CWBorderPixel | + (CWOverrideRedirect | CWBackPixmap | CWBorderPixel | CWColormap), &xattr); if (!w) { return SDL_SetError("Couldn't create window"); } -#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 - if ((window->flags & SDL_WINDOW_OPENGL) && (_this->gl_config.use_egl == 1)) { - if (!_this->gles_data) { - XDestroyWindow(display, w); - return -1; - } - - /* Create the GLES window surface */ - _this->gles_data->egl_surface = - _this->gles_data->eglCreateWindowSurface(_this->gles_data-> - egl_display, - _this->gles_data->egl_config, - (NativeWindowType) w, NULL); - - if (_this->gles_data->egl_surface == EGL_NO_SURFACE) { - XDestroyWindow(display, w); - return SDL_SetError("Could not create GLES window surface"); - } - } -#endif SetWindowBordered(display, screen, w, (window->flags & SDL_WINDOW_BORDERLESS) == 0); - sizehints = XAllocSizeHints(); + sizehints = X11_XAllocSizeHints(); /* Setup the normal size hints */ sizehints->flags = 0; if (!(window->flags & SDL_WINDOW_RESIZABLE)) { @@ -518,25 +505,25 @@ X11_CreateWindow(_THIS, SDL_Window * window) sizehints->flags |= USPosition; /* Setup the input hints so we get keyboard input */ - wmhints = XAllocWMHints(); + wmhints = X11_XAllocWMHints(); wmhints->input = True; wmhints->flags = InputHint; /* Setup the class hints so we can get an icon (AfterStep) */ - classhints = XAllocClassHint(); + classhints = X11_XAllocClassHint(); classhints->res_name = data->classname; classhints->res_class = data->classname; /* Set the size, input and class hints, and define WM_CLIENT_MACHINE and WM_LOCALE_NAME */ - XSetWMProperties(display, w, NULL, NULL, NULL, 0, sizehints, wmhints, classhints); + X11_XSetWMProperties(display, w, NULL, NULL, NULL, 0, sizehints, wmhints, classhints); - XFree(sizehints); - XFree(wmhints); - XFree(classhints); + X11_XFree(sizehints); + X11_XFree(wmhints); + X11_XFree(classhints); /* Set the PID related to the window for the given hostname, if possible */ if (data->pid > 0) { - _NET_WM_PID = XInternAtom(display, "_NET_WM_PID", False); - XChangeProperty(display, w, _NET_WM_PID, XA_CARDINAL, 32, PropModeReplace, + _NET_WM_PID = X11_XInternAtom(display, "_NET_WM_PID", False); + X11_XChangeProperty(display, w, _NET_WM_PID, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&data->pid, 1); } @@ -544,14 +531,14 @@ X11_CreateWindow(_THIS, SDL_Window * window) X11_SetNetWMState(_this, w, window->flags); /* Let the window manager know we're a "normal" window */ - _NET_WM_WINDOW_TYPE = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False); - _NET_WM_WINDOW_TYPE_NORMAL = XInternAtom(display, "_NET_WM_WINDOW_TYPE_NORMAL", False); - XChangeProperty(display, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32, + _NET_WM_WINDOW_TYPE = X11_XInternAtom(display, "_NET_WM_WINDOW_TYPE", False); + _NET_WM_WINDOW_TYPE_NORMAL = X11_XInternAtom(display, "_NET_WM_WINDOW_TYPE_NORMAL", False); + X11_XChangeProperty(display, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32, PropModeReplace, (unsigned char *)&_NET_WM_WINDOW_TYPE_NORMAL, 1); - _NET_WM_BYPASS_COMPOSITOR = XInternAtom(display, "_NET_WM_BYPASS_COMPOSITOR", False); - XChangeProperty(display, w, _NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32, + _NET_WM_BYPASS_COMPOSITOR = X11_XInternAtom(display, "_NET_WM_BYPASS_COMPOSITOR", False); + X11_XChangeProperty(display, w, _NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&_NET_WM_BYPASS_COMPOSITOR_HINT_ON, 1); @@ -560,36 +547,59 @@ X11_CreateWindow(_THIS, SDL_Window * window) data->WM_DELETE_WINDOW, /* Allow window to be deleted by the WM */ data->_NET_WM_PING, /* Respond so WM knows we're alive */ }; - XSetWMProtocols(display, w, protocols, sizeof (protocols) / sizeof (protocols[0])); + X11_XSetWMProtocols(display, w, protocols, sizeof (protocols) / sizeof (protocols[0])); } if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) { - XDestroyWindow(display, w); + X11_XDestroyWindow(display, w); return -1; } + windowdata = (SDL_WindowData *) window->driverdata; + +#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 + if ((window->flags & SDL_WINDOW_OPENGL) && + _this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES +#if SDL_VIDEO_OPENGL_GLX + && ( !_this->gl_data || ! _this->gl_data->HAS_GLX_EXT_create_context_es2_profile ) +#endif + ) { + if (!_this->egl_data) { + X11_XDestroyWindow(display, w); + return -1; + } + + /* Create the GLES window surface */ + windowdata->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) w); + + if (windowdata->egl_surface == EGL_NO_SURFACE) { + X11_XDestroyWindow(display, w); + return SDL_SetError("Could not create GLES window surface"); + } + } +#endif + #ifdef X_HAVE_UTF8_STRING - if (SDL_X11_HAVE_UTF8) { - pXGetICValues(((SDL_WindowData *) window->driverdata)->ic, - XNFilterEvents, &fevent, NULL); + if (SDL_X11_HAVE_UTF8 && windowdata->ic) { + X11_XGetICValues(windowdata->ic, XNFilterEvents, &fevent, NULL); } #endif X11_Xinput2SelectTouch(_this, window); - XSelectInput(display, w, + X11_XSelectInput(display, w, (FocusChangeMask | EnterWindowMask | LeaveWindowMask | ExposureMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask | KeyReleaseMask | PropertyChangeMask | StructureNotifyMask | KeymapStateMask | fevent)); - XdndAware = XInternAtom(display, "XdndAware", False); - XChangeProperty(display, w, XdndAware, XA_ATOM, 32, + XdndAware = X11_XInternAtom(display, "XdndAware", False); + X11_XChangeProperty(display, w, XdndAware, XA_ATOM, 32, PropModeReplace, (unsigned char*)&xdnd_version, 1); - XFlush(display); + X11_XFlush(display); return 0; } @@ -618,14 +628,14 @@ X11_GetWindowTitle(_THIS, Window xwindow) unsigned char *propdata; char *title = NULL; - status = XGetWindowProperty(display, xwindow, data->_NET_WM_NAME, + status = X11_XGetWindowProperty(display, xwindow, data->_NET_WM_NAME, 0L, 8192L, False, data->UTF8_STRING, &real_type, &real_format, &items_read, &items_left, &propdata); if (status == Success && propdata) { title = SDL_strdup(SDL_static_cast(char*, propdata)); - XFree(propdata); + X11_XFree(propdata); } else { - status = XGetWindowProperty(display, xwindow, XA_WM_NAME, + status = X11_XGetWindowProperty(display, xwindow, XA_WM_NAME, 0L, 8192L, False, XA_STRING, &real_type, &real_format, &items_read, &items_left, &propdata); if (status == Success && propdata) { @@ -658,21 +668,21 @@ X11_SetWindowTitle(_THIS, SDL_Window * window) SDL_OutOfMemory(); return; } - status = XStringListToTextProperty(&title_locale, 1, &titleprop); + status = X11_XStringListToTextProperty(&title_locale, 1, &titleprop); SDL_free(title_locale); if (status) { - XSetTextProperty(display, data->xwindow, &titleprop, XA_WM_NAME); - XFree(titleprop.value); + X11_XSetTextProperty(display, data->xwindow, &titleprop, XA_WM_NAME); + X11_XFree(titleprop.value); } #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8) { status = - Xutf8TextListToTextProperty(display, (char **) &title, 1, + X11_Xutf8TextListToTextProperty(display, (char **) &title, 1, XUTF8StringStyle, &titleprop); if (status == Success) { - XSetTextProperty(display, data->xwindow, &titleprop, + X11_XSetTextProperty(display, data->xwindow, &titleprop, _NET_WM_NAME); - XFree(titleprop.value); + X11_XFree(titleprop.value); } } #endif @@ -683,27 +693,27 @@ X11_SetWindowTitle(_THIS, SDL_Window * window) SDL_OutOfMemory(); return; } - status = XStringListToTextProperty(&icon_locale, 1, &iconprop); + status = X11_XStringListToTextProperty(&icon_locale, 1, &iconprop); SDL_free(icon_locale); if (status) { - XSetTextProperty(display, data->xwindow, &iconprop, + X11_XSetTextProperty(display, data->xwindow, &iconprop, XA_WM_ICON_NAME); - XFree(iconprop.value); + X11_XFree(iconprop.value); } #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8) { status = - Xutf8TextListToTextProperty(display, (char **) &icon, 1, + X11_Xutf8TextListToTextProperty(display, (char **) &icon, 1, XUTF8StringStyle, &iconprop); if (status == Success) { - XSetTextProperty(display, data->xwindow, &iconprop, + X11_XSetTextProperty(display, data->xwindow, &iconprop, _NET_WM_ICON_NAME); - XFree(iconprop.value); + X11_XFree(iconprop.value); } } #endif } - XFlush(display); + X11_XFlush(display); } void @@ -735,15 +745,15 @@ X11_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) *dst++ = *src++; } } - XChangeProperty(display, data->xwindow, _NET_WM_ICON, XA_CARDINAL, + X11_XChangeProperty(display, data->xwindow, _NET_WM_ICON, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) propdata, propsize); } SDL_free(propdata); } else { - XDeleteProperty(display, data->xwindow, _NET_WM_ICON); + X11_XDeleteProperty(display, data->xwindow, _NET_WM_ICON); } - XFlush(display); + X11_XFlush(display); } void @@ -752,8 +762,8 @@ X11_SetWindowPosition(_THIS, SDL_Window * window) SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Display *display = data->videodata->display; - XMoveWindow(display, data->xwindow, window->x, window->y); - XFlush(display); + X11_XMoveWindow(display, data->xwindow, window->x, window->y); + X11_XFlush(display); } void @@ -763,26 +773,26 @@ X11_SetWindowMinimumSize(_THIS, SDL_Window * window) Display *display = data->videodata->display; if (window->flags & SDL_WINDOW_RESIZABLE) { - XSizeHints *sizehints = XAllocSizeHints(); + XSizeHints *sizehints = X11_XAllocSizeHints(); long userhints; - XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); + X11_XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); sizehints->min_width = window->min_w; sizehints->min_height = window->min_h; sizehints->flags |= PMinSize; - XSetWMNormalHints(display, data->xwindow, sizehints); + X11_XSetWMNormalHints(display, data->xwindow, sizehints); - XFree(sizehints); + X11_XFree(sizehints); /* See comment in X11_SetWindowSize. */ - XResizeWindow(display, data->xwindow, window->w, window->h); - XMoveWindow(display, data->xwindow, window->x, window->y); - XRaiseWindow(display, data->xwindow); + X11_XResizeWindow(display, data->xwindow, window->w, window->h); + X11_XMoveWindow(display, data->xwindow, window->x, window->y); + X11_XRaiseWindow(display, data->xwindow); } - XFlush(display); + X11_XFlush(display); } void @@ -792,26 +802,26 @@ X11_SetWindowMaximumSize(_THIS, SDL_Window * window) Display *display = data->videodata->display; if (window->flags & SDL_WINDOW_RESIZABLE) { - XSizeHints *sizehints = XAllocSizeHints(); + XSizeHints *sizehints = X11_XAllocSizeHints(); long userhints; - XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); + X11_XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); sizehints->max_width = window->max_w; sizehints->max_height = window->max_h; sizehints->flags |= PMaxSize; - XSetWMNormalHints(display, data->xwindow, sizehints); + X11_XSetWMNormalHints(display, data->xwindow, sizehints); - XFree(sizehints); + X11_XFree(sizehints); /* See comment in X11_SetWindowSize. */ - XResizeWindow(display, data->xwindow, window->w, window->h); - XMoveWindow(display, data->xwindow, window->x, window->y); - XRaiseWindow(display, data->xwindow); + X11_XResizeWindow(display, data->xwindow, window->w, window->h); + X11_XMoveWindow(display, data->xwindow, window->x, window->y); + X11_XRaiseWindow(display, data->xwindow); } - XFlush(display); + X11_XFlush(display); } void @@ -824,20 +834,20 @@ X11_SetWindowSize(_THIS, SDL_Window * window) X11_ResizeWindowShape(window); } if (!(window->flags & SDL_WINDOW_RESIZABLE)) { - /* Apparently, if the X11 Window is set to a 'non-resizable' window, you cannot resize it using the XResizeWindow, thus - we must set the size hints to adjust the window size.*/ - XSizeHints *sizehints = XAllocSizeHints(); + /* Apparently, if the X11 Window is set to a 'non-resizable' window, you cannot resize it using the X11_XResizeWindow, thus + we must set the size hints to adjust the window size. */ + XSizeHints *sizehints = X11_XAllocSizeHints(); long userhints; - XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); + X11_XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); sizehints->min_width = sizehints->max_width = window->w; sizehints->min_height = sizehints->max_height = window->h; sizehints->flags |= PMinSize | PMaxSize; - XSetWMNormalHints(display, data->xwindow, sizehints); + X11_XSetWMNormalHints(display, data->xwindow, sizehints); - XFree(sizehints); + X11_XFree(sizehints); /* From Pierre-Loup: WMs each have their little quirks with that. When you change the @@ -855,14 +865,14 @@ X11_SetWindowSize(_THIS, SDL_Window * window) hide/show, because there are supposedly subtle problems with doing so and transitioning from windowed to fullscreen in Unity. */ - XResizeWindow(display, data->xwindow, window->w, window->h); - XMoveWindow(display, data->xwindow, window->x, window->y); - XRaiseWindow(display, data->xwindow); + X11_XResizeWindow(display, data->xwindow, window->w, window->h); + X11_XMoveWindow(display, data->xwindow, window->x, window->y); + X11_XRaiseWindow(display, data->xwindow); } else { - XResizeWindow(display, data->xwindow, window->w, window->h); + X11_XResizeWindow(display, data->xwindow, window->w, window->h); } - XFlush(display); + X11_XFlush(display); } void @@ -877,25 +887,25 @@ X11_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered) XEvent event; SetWindowBordered(display, displaydata->screen, data->xwindow, bordered); - XFlush(display); - XIfEvent(display, &event, &isConfigureNotify, (XPointer)&data->xwindow); + X11_XFlush(display); + X11_XIfEvent(display, &event, &isConfigureNotify, (XPointer)&data->xwindow); if (visible) { XWindowAttributes attr; do { - XSync(display, False); - XGetWindowAttributes(display, data->xwindow, &attr); + X11_XSync(display, False); + X11_XGetWindowAttributes(display, data->xwindow, &attr); } while (attr.map_state != IsViewable); if (focused) { - XSetInputFocus(display, data->xwindow, RevertToParent, CurrentTime); + X11_XSetInputFocus(display, data->xwindow, RevertToParent, CurrentTime); } } /* make sure these don't make it to the real event queue if they fired here. */ - XSync(display, False); - XCheckIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow); - XCheckIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow); + X11_XSync(display, False); + X11_XCheckIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow); + X11_XCheckIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow); } void @@ -906,12 +916,12 @@ X11_ShowWindow(_THIS, SDL_Window * window) XEvent event; if (!X11_IsWindowMapped(_this, window)) { - XMapRaised(display, data->xwindow); + X11_XMapRaised(display, data->xwindow); /* Blocking wait for "MapNotify" event. - * We use XIfEvent because XWindowEvent takes a mask rather than a type, + * We use X11_XIfEvent because pXWindowEvent takes a mask rather than a type, * and XCheckTypedWindowEvent doesn't block */ - XIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow); - XFlush(display); + X11_XIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow); + X11_XFlush(display); } } @@ -924,10 +934,38 @@ X11_HideWindow(_THIS, SDL_Window * window) XEvent event; if (X11_IsWindowMapped(_this, window)) { - XWithdrawWindow(display, data->xwindow, displaydata->screen); + X11_XWithdrawWindow(display, data->xwindow, displaydata->screen); /* Blocking wait for "UnmapNotify" event */ - XIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow); - XFlush(display); + X11_XIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow); + X11_XFlush(display); + } +} + +static void +SetWindowActive(_THIS, SDL_Window * window) +{ + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_DisplayData *displaydata = + (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; + Display *display = data->videodata->display; + Atom _NET_ACTIVE_WINDOW = data->videodata->_NET_ACTIVE_WINDOW; + + if (X11_IsWindowMapped(_this, window)) { + XEvent e; + + SDL_zero(e); + e.xany.type = ClientMessage; + e.xclient.message_type = _NET_ACTIVE_WINDOW; + e.xclient.format = 32; + e.xclient.window = data->xwindow; + e.xclient.data.l[0] = 1; /* source indication. 1 = application */ + e.xclient.data.l[1] = CurrentTime; + e.xclient.data.l[2] = 0; + + X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0, + SubstructureNotifyMask | SubstructureRedirectMask, &e); + + X11_XFlush(display); } } @@ -937,8 +975,9 @@ X11_RaiseWindow(_THIS, SDL_Window * window) SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Display *display = data->videodata->display; - XRaiseWindow(display, data->xwindow); - XFlush(display); + X11_XRaiseWindow(display, data->xwindow); + SetWindowActive(_this, window); + X11_XFlush(display); } static void @@ -972,12 +1011,12 @@ SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized) e.xclient.data.l[2] = _NET_WM_STATE_MAXIMIZED_HORZ; e.xclient.data.l[3] = 0l; - XSendEvent(display, RootWindow(display, displaydata->screen), 0, + X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0, SubstructureNotifyMask | SubstructureRedirectMask, &e); } else { X11_SetNetWMState(_this, data->xwindow, window->flags); } - XFlush(display); + X11_XFlush(display); } void @@ -994,44 +1033,16 @@ X11_MinimizeWindow(_THIS, SDL_Window * window) (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; Display *display = data->videodata->display; - XIconifyWindow(display, data->xwindow, displaydata->screen); - XFlush(display); -} - -static void -SetWindowActive(_THIS, SDL_Window * window) -{ - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; - SDL_DisplayData *displaydata = - (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; - Display *display = data->videodata->display; - Atom _NET_ACTIVE_WINDOW = data->videodata->_NET_ACTIVE_WINDOW; - - if (X11_IsWindowMapped(_this, window)) { - XEvent e; - - SDL_zero(e); - e.xany.type = ClientMessage; - e.xclient.message_type = _NET_ACTIVE_WINDOW; - e.xclient.format = 32; - e.xclient.window = data->xwindow; - e.xclient.data.l[0] = 1; /* source indication. 1 = application */ - e.xclient.data.l[1] = CurrentTime; - e.xclient.data.l[2] = 0; - - XSendEvent(display, RootWindow(display, displaydata->screen), 0, - SubstructureNotifyMask | SubstructureRedirectMask, &e); - - XFlush(display); - } + X11_XIconifyWindow(display, data->xwindow, displaydata->screen); + X11_XFlush(display); } void X11_RestoreWindow(_THIS, SDL_Window * window) { SetWindowMaximized(_this, window, SDL_FALSE); - SetWindowActive(_this, window); X11_ShowWindow(_this, window); + SetWindowActive(_this, window); } /* This asks the Window Manager to handle fullscreen for us. Most don't do it right, though. */ @@ -1050,9 +1061,9 @@ X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _dis if (!(window->flags & SDL_WINDOW_RESIZABLE)) { /* Compiz refuses fullscreen toggle if we're not resizable, so update the hints so we can be resized to the fullscreen resolution (or reset so we're not resizable again) */ - XSizeHints *sizehints = XAllocSizeHints(); + XSizeHints *sizehints = X11_XAllocSizeHints(); long flags = 0; - XGetWMNormalHints(display, data->xwindow, sizehints, &flags); + X11_XGetWMNormalHints(display, data->xwindow, sizehints, &flags); /* set the resize flags on */ if (fullscreen) { /* we are going fullscreen so turn the flags off */ @@ -1063,8 +1074,8 @@ X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _dis sizehints->min_width = sizehints->max_width = window->windowed.w; sizehints->min_height = sizehints->max_height = window->windowed.h; } - XSetWMNormalHints(display, data->xwindow, sizehints); - XFree(sizehints); + X11_XSetWMNormalHints(display, data->xwindow, sizehints); + X11_XFree(sizehints); } SDL_zero(e); @@ -1077,7 +1088,7 @@ X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _dis e.xclient.data.l[1] = _NET_WM_STATE_FULLSCREEN; e.xclient.data.l[3] = 0l; - XSendEvent(display, RootWindow(display, displaydata->screen), 0, + X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0, SubstructureNotifyMask | SubstructureRedirectMask, &e); } else { Uint32 flags; @@ -1093,13 +1104,13 @@ X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _dis if (data->visual->class == DirectColor) { if ( fullscreen ) { - XInstallColormap(display, data->colormap); + X11_XInstallColormap(display, data->colormap); } else { - XUninstallColormap(display, data->colormap); + X11_XUninstallColormap(display, data->colormap); } } - XFlush(display); + X11_XFlush(display); } /* This handles fullscreen itself, outside the Window Manager. */ @@ -1134,48 +1145,48 @@ X11_BeginWindowFullscreenLegacy(_THIS, SDL_Window * window, SDL_VideoDisplay * _ xattr.colormap = data->colormap; xattrmask |= CWColormap; - data->fswindow = XCreateWindow(display, root, + data->fswindow = X11_XCreateWindow(display, root, rect.x, rect.y, rect.w, rect.h, 0, displaydata->depth, InputOutput, visual, xattrmask, &xattr); - XSelectInput(display, data->fswindow, StructureNotifyMask); - XSetWindowBackground(display, data->fswindow, 0); - XInstallColormap(display, data->colormap); - XClearWindow(display, data->fswindow); - XMapRaised(display, data->fswindow); + X11_XSelectInput(display, data->fswindow, StructureNotifyMask); + X11_XSetWindowBackground(display, data->fswindow, 0); + X11_XInstallColormap(display, data->colormap); + X11_XClearWindow(display, data->fswindow); + X11_XMapRaised(display, data->fswindow); /* Make sure the fswindow is in view by warping mouse to the corner */ - XUngrabPointer(display, CurrentTime); - XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y); + X11_XUngrabPointer(display, CurrentTime); + X11_XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y); /* Wait to be mapped, filter Unmap event out if it arrives. */ - XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->fswindow); - XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->fswindow); + X11_XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->fswindow); + X11_XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->fswindow); #if SDL_VIDEO_DRIVER_X11_XVIDMODE if ( displaydata->use_vidmode ) { - XF86VidModeLockModeSwitch(display, screen, True); + X11_XF86VidModeLockModeSwitch(display, screen, True); } #endif SetWindowBordered(display, displaydata->screen, data->xwindow, SDL_FALSE); /* Center actual window within our cover-the-screen window. */ - XReparentWindow(display, data->xwindow, data->fswindow, + X11_XReparentWindow(display, data->xwindow, data->fswindow, (rect.w - window->w) / 2, (rect.h - window->h) / 2); /* Move the mouse to the upper left to make sure it's on-screen */ - XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y); + X11_XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y); /* Center mouse in the fullscreen window. */ rect.x += (rect.w / 2); rect.y += (rect.h / 2); - XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y); + X11_XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y); /* Wait to be mapped, filter Unmap event out if it arrives. */ - XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->xwindow); - XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->xwindow); + X11_XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->xwindow); + X11_XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->xwindow); SDL_UpdateWindowGrab(window); } @@ -1199,27 +1210,27 @@ X11_EndWindowFullscreenLegacy(_THIS, SDL_Window * window, SDL_VideoDisplay * _di #if SDL_VIDEO_DRIVER_X11_VIDMODE if ( displaydata->use_vidmode ) { - XF86VidModeLockModeSwitch(display, screen, False); + X11_XF86VidModeLockModeSwitch(display, screen, False); } #endif SDL_UpdateWindowGrab(window); - XReparentWindow(display, data->xwindow, root, window->x, window->y); + X11_XReparentWindow(display, data->xwindow, root, window->x, window->y); /* flush these events so they don't confuse normal event handling */ - XSync(display, False); - XCheckIfEvent(display, &ev, &isMapNotify, (XPointer)&data->xwindow); - XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->xwindow); + X11_XSync(display, False); + X11_XCheckIfEvent(display, &ev, &isMapNotify, (XPointer)&data->xwindow); + X11_XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->xwindow); SetWindowBordered(display, screen, data->xwindow, (window->flags & SDL_WINDOW_BORDERLESS) == 0); - XWithdrawWindow(display, fswindow, screen); + X11_XWithdrawWindow(display, fswindow, screen); /* Wait to be unmapped. */ - XIfEvent(display, &ev, &isUnmapNotify, (XPointer)&fswindow); - XDestroyWindow(display, fswindow); + X11_XIfEvent(display, &ev, &isUnmapNotify, (XPointer)&fswindow); + X11_XDestroyWindow(display, fswindow); } @@ -1317,8 +1328,8 @@ X11_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) colorcells[i].flags = DoRed | DoGreen | DoBlue; } - XStoreColors(display, colormap, colorcells, ncolors); - XFlush(display); + X11_XStoreColors(display, colormap, colorcells, ncolors); + X11_XFlush(display); SDL_free(colorcells); return 0; @@ -1343,7 +1354,7 @@ X11_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) /* Try to grab the mouse */ for (;;) { int result = - XGrabPointer(display, data->xwindow, True, 0, GrabModeAsync, + X11_XGrabPointer(display, data->xwindow, True, 0, GrabModeAsync, GrabModeAsync, data->xwindow, None, CurrentTime); if (result == GrabSuccess) { break; @@ -1352,7 +1363,7 @@ X11_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) } /* Raise the window if we grab the mouse */ - XRaiseWindow(display, data->xwindow); + X11_XRaiseWindow(display, data->xwindow); /* Now grab the keyboard */ hint = SDL_GetHint(SDL_HINT_GRAB_KEYBOARD); @@ -1365,14 +1376,14 @@ X11_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) grab_keyboard = oldstyle_fullscreen; } if (grab_keyboard) { - XGrabKeyboard(display, data->xwindow, True, GrabModeAsync, + X11_XGrabKeyboard(display, data->xwindow, True, GrabModeAsync, GrabModeAsync, CurrentTime); } } else { - XUngrabPointer(display, CurrentTime); - XUngrabKeyboard(display, CurrentTime); + X11_XUngrabPointer(display, CurrentTime); + X11_XUngrabKeyboard(display, CurrentTime); } - XSync(display, False); + X11_XSync(display, False); } void @@ -1400,12 +1411,12 @@ X11_DestroyWindow(_THIS, SDL_Window * window) } #ifdef X_HAVE_UTF8_STRING if (data->ic) { - XDestroyIC(data->ic); + X11_XDestroyIC(data->ic); } #endif if (data->created) { - XDestroyWindow(display, data->xwindow); - XFlush(display); + X11_XDestroyWindow(display, data->xwindow); + X11_XFlush(display); } SDL_free(data); } diff --git a/src/video/x11/SDL_x11window.h b/src/video/x11/SDL_x11window.h index f53fd8aa2..b0eff5cf4 100644 --- a/src/video/x11/SDL_x11window.h +++ b/src/video/x11/SDL_x11window.h @@ -30,6 +30,10 @@ #define PENDING_FOCUS_IN_TIME 200 #define PENDING_FOCUS_OUT_TIME 200 +#if SDL_VIDEO_OPENGL_EGL +#include +#endif + typedef enum { PENDING_FOCUS_NONE, @@ -59,6 +63,9 @@ typedef struct struct SDL_VideoData *videodata; Atom xdnd_req; Window xdnd_source; +#if SDL_VIDEO_OPENGL_EGL + EGLSurface egl_surface; +#endif } SDL_WindowData; extern void X11_SetNetWMState(_THIS, Window xwindow, Uint32 flags); diff --git a/src/video/x11/SDL_x11xinput2.c b/src/video/x11/SDL_x11xinput2.c index 1b86c6774..719d2e351 100644 --- a/src/video/x11/SDL_x11xinput2.c +++ b/src/video/x11/SDL_x11xinput2.c @@ -36,7 +36,7 @@ static int xinput2_initialized = 0; static int xinput2_multitouch_supported = 0; #endif -/* Opcode returned XQueryExtension +/* Opcode returned X11_XQueryExtension * It will be used in event processing * to know that the event came from * this extension */ @@ -82,40 +82,40 @@ X11_InitXinput2(_THIS) * "As XI2 progresses it becomes important that you use this call as the server may treat the client * differently depending on the supported version". * - * FIXME:event and err are not needed but if not passed XQueryExtension returns SegmentationFault + * FIXME:event and err are not needed but if not passed X11_XQueryExtension returns SegmentationFault */ if (!SDL_X11_HAVE_XINPUT2 || - !XQueryExtension(data->display, "XInputExtension", &xinput2_opcode, &event, &err)) { + !X11_XQueryExtension(data->display, "XInputExtension", &xinput2_opcode, &event, &err)) { return; } outmajor = major; outminor = minor; - if (XIQueryVersion(data->display, &outmajor, &outminor) != Success) { + if (X11_XIQueryVersion(data->display, &outmajor, &outminor) != Success) { return; } - /*Check supported version*/ + /* Check supported version */ if(outmajor * 1000 + outminor < major * 1000 + minor) { - /*X server does not support the version we want*/ + /* X server does not support the version we want */ return; } xinput2_initialized = 1; #if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH - /*XInput 2.2*/ + /* XInput 2.2 */ if(outmajor * 1000 + outminor >= major * 1000 + minor) { xinput2_multitouch_supported = 1; } #endif - /*Enable Raw motion events for this display*/ + /* Enable Raw motion events for this display */ eventmask.deviceid = XIAllMasterDevices; eventmask.mask_len = sizeof(mask); eventmask.mask = mask; XISetMask(mask, XI_RawMotion); - if (XISelectEvents(data->display,DefaultRootWindow(data->display),&eventmask,1) != Success) { + if (X11_XISelectEvents(data->display,DefaultRootWindow(data->display),&eventmask,1) != Success) { return; } #endif @@ -179,7 +179,7 @@ X11_InitXinput2Multitouch(_THIS) SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; XIDeviceInfo *info; int ndevices,i,j; - info = XIQueryDevice(data->display, XIAllMasterDevices, &ndevices); + info = X11_XIQueryDevice(data->display, XIAllMasterDevices, &ndevices); for (i = 0; i < ndevices; i++) { XIDeviceInfo *dev = &info[i]; @@ -188,7 +188,7 @@ X11_InitXinput2Multitouch(_THIS) XIAnyClassInfo *class = dev->classes[j]; XITouchClassInfo *t = (XITouchClassInfo*)class; - /*Only touch devices*/ + /* Only touch devices */ if (class->type != XITouchClass) continue; @@ -198,7 +198,7 @@ X11_InitXinput2Multitouch(_THIS) } } } - XIFreeDeviceInfo(info); + X11_XIFreeDeviceInfo(info); #endif } @@ -206,14 +206,17 @@ void X11_Xinput2SelectTouch(_THIS, SDL_Window *window) { #if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH + SDL_VideoData *data = NULL; + XIEventMask eventmask; + unsigned char mask[3] = { 0,0,0 }; + SDL_WindowData *window_data = NULL; + if (!X11_Xinput2IsMultitouchSupported()) { return; } - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - XIEventMask eventmask; - unsigned char mask[3] = { 0,0,0 }; - SDL_WindowData *window_data = (SDL_WindowData*)window->driverdata; + data = (SDL_VideoData *) _this->driverdata; + window_data = (SDL_WindowData*)window->driverdata; eventmask.deviceid = XIAllMasterDevices; eventmask.mask_len = sizeof(mask); @@ -223,7 +226,7 @@ X11_Xinput2SelectTouch(_THIS, SDL_Window *window) XISetMask(mask, XI_TouchUpdate); XISetMask(mask, XI_TouchEnd); - XISelectEvents(data->display,window_data->xwindow,&eventmask,1); + X11_XISelectEvents(data->display,window_data->xwindow,&eventmask,1); #endif } diff --git a/src/video/x11/SDL_x11xinput2.h b/src/video/x11/SDL_x11xinput2.h index 56a4b906c..920c17093 100644 --- a/src/video/x11/SDL_x11xinput2.h +++ b/src/video/x11/SDL_x11xinput2.h @@ -24,8 +24,8 @@ #define _SDL_x11xinput2_h #ifndef SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS -/*Define XGenericEventCookie as forward declaration when - *xinput2 is not available in order to compile*/ +/* Define XGenericEventCookie as forward declaration when + *xinput2 is not available in order to compile */ struct XGenericEventCookie; typedef struct XGenericEventCookie XGenericEventCookie; #endif diff --git a/src/video/x11/imKStoUCS.h b/src/video/x11/imKStoUCS.h index 252f9a4bf..cc684c2e3 100644 --- a/src/video/x11/imKStoUCS.h +++ b/src/video/x11/imKStoUCS.h @@ -28,4 +28,4 @@ Project. extern unsigned int X11_KeySymToUcs4(KeySym keysym); -#endif /*_imKStoUCS_h */ +#endif /* _imKStoUCS_h */ diff --git a/test/Makefile.in b/test/Makefile.in index 2a39afc6b..f57c46029 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -4,7 +4,7 @@ srcdir = @srcdir@ CC = @CC@ EXE = @EXE@ -CFLAGS = @CFLAGS@ +CFLAGS = @CFLAGS@ -g LIBS = @LIBS@ TARGETS = \ @@ -14,6 +14,7 @@ TARGETS = \ testautomation$(EXE) \ testdraw2$(EXE) \ testdrawchessboard$(EXE) \ + testdropfile$(EXE) \ testerror$(EXE) \ testfile$(EXE) \ testgamecontroller$(EXE) \ @@ -36,6 +37,7 @@ TARGETS = \ testoverlay2$(EXE) \ testplatform$(EXE) \ testpower$(EXE) \ + testfilesystem$(EXE) \ testrendertarget$(EXE) \ testresample$(EXE) \ testscale$(EXE) \ @@ -107,6 +109,9 @@ testdraw2$(EXE): $(srcdir)/testdraw2.c testdrawchessboard$(EXE): $(srcdir)/testdrawchessboard.c $(CC) -o $@ $^ $(CFLAGS) $(LIBS) +testdropfile$(EXE): $(srcdir)/testdropfile.c + $(CC) -o $@ $^ $(CFLAGS) $(LIBS) + testerror$(EXE): $(srcdir)/testerror.c $(CC) -o $@ $^ $(CFLAGS) $(LIBS) @@ -123,7 +128,7 @@ testgl2$(EXE): $(srcdir)/testgl2.c $(CC) -o $@ $^ $(CFLAGS) $(LIBS) @GLLIB@ @MATHLIB@ testgles$(EXE): $(srcdir)/testgles.c - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) @GLLIB@ @MATHLIB@ + $(CC) -o $@ $^ $(CFLAGS) $(LIBS) @GLESLIB@ @MATHLIB@ testhaptic$(EXE): $(srcdir)/testhaptic.c $(CC) -o $@ $^ $(CFLAGS) $(LIBS) @@ -180,6 +185,9 @@ testplatform$(EXE): $(srcdir)/testplatform.c testpower$(EXE): $(srcdir)/testpower.c $(CC) -o $@ $^ $(CFLAGS) $(LIBS) +testfilesystem$(EXE): $(srcdir)/testfilesystem.c + $(CC) -o $@ $^ $(CFLAGS) $(LIBS) + testrendertarget$(EXE): $(srcdir)/testrendertarget.c $(CC) -o $@ $^ $(CFLAGS) $(LIBS) diff --git a/test/checkkeys.c b/test/checkkeys.c index 61e8be043..5f2d14847 100644 --- a/test/checkkeys.c +++ b/test/checkkeys.c @@ -117,13 +117,13 @@ PrintKey(SDL_Keysym * sym, SDL_bool pressed, SDL_bool repeat) static void PrintText(char *text) { - unsigned char *spot, expanded[1024]; + char *spot, expanded[1024]; expanded[0] = '\0'; for ( spot = text; *spot; ++spot ) { size_t length = SDL_strlen(expanded); - SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", *spot); + SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", (unsigned char)*spot); } SDL_Log("Text (%s): \"%s%s\"\n", expanded, *text == '"' ? "\\" : "", text); } @@ -134,10 +134,13 @@ main(int argc, char *argv[]) SDL_Window *window; SDL_Event event; int done; + + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); /* Initialize SDL */ if (SDL_Init(SDL_INIT_VIDEO) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } @@ -146,7 +149,7 @@ main(int argc, char *argv[]) SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, 0); if (!window) { - fprintf(stderr, "Couldn't create 640x480 window: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create 640x480 window: %s\n", SDL_GetError()); quit(2); } @@ -166,7 +169,7 @@ main(int argc, char *argv[]) switch (event.type) { case SDL_KEYDOWN: case SDL_KEYUP: - PrintKey(&event.key.keysym, event.key.state, event.key.repeat); + PrintKey(&event.key.keysym, (event.key.state == SDL_PRESSED) ? SDL_TRUE : SDL_FALSE, (event.key.repeat) ? SDL_TRUE : SDL_FALSE); break; case SDL_TEXTINPUT: PrintText(event.text.text); diff --git a/test/configure b/test/configure index 319c03298..136606c77 100755 --- a/test/configure +++ b/test/configure @@ -586,6 +586,7 @@ ac_subst_vars='LTLIBOBJS LIBOBJS SDL_TTF_LIB XLIB +GLESLIB GLLIB CPP XMKMF @@ -3785,16 +3786,21 @@ $as_echo "libraries $x_libraries, headers $x_includes" >&6; } fi if test x$have_x = xyes; then - if test x$ac_x_includes = xno || test x$ac_x_includes = x; then + if test x$ac_x_includes = xno || test "x$ac_x_includes" = xNone || test "x$ac_x_includes" = x; then : else CFLAGS="$CFLAGS -I$ac_x_includes" fi - if test x$ac_x_libraries = xno || test x$ac_x_libraries = x; then + if test x$ac_x_libraries = xno || test "x$ac_x_libraries" = xNone; then : else - XPATH="-L$ac_x_libraries" - XLIB="-L$ac_x_libraries -lX11" + if test "x$ac_x_libraries" = x; then + XPATH="" + XLIB="-lX11" + else + XPATH="-L$ac_x_libraries" + XLIB="-L$ac_x_libraries -lX11" + fi fi fi @@ -3855,19 +3861,20 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext $as_echo "$have_opengles" >&6; } GLLIB="" +GLESLIB="" if test x$have_opengles = xyes; then CFLAGS="$CFLAGS -DHAVE_OPENGLES" - GLLIB="$XPATH -lGLESv1_CM" -elif test x$have_opengl = xyes; then + GLESLIB="$XPATH -lGLESv1_CM" +fi +if test x$have_opengl = xyes; then CFLAGS="$CFLAGS -DHAVE_OPENGL" GLLIB="$XPATH $SYS_GL_LIBS" -else - GLLIB="" fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for TTF_Init in -lSDL2_ttf" >&5 $as_echo_n "checking for TTF_Init in -lSDL2_ttf... " >&6; } if ${ac_cv_lib_SDL2_ttf_TTF_Init+:} false; then : diff --git a/test/configure.in b/test/configure.in index b74800758..eb3028747 100644 --- a/test/configure.in +++ b/test/configure.in @@ -91,16 +91,21 @@ LIBS="$LIBS -lSDL2_test $SDL_LIBS" dnl Check for X11 path, needed for OpenGL on some systems AC_PATH_X if test x$have_x = xyes; then - if test x$ac_x_includes = xno || test x$ac_x_includes = x; then + if test x$ac_x_includes = xno || test "x$ac_x_includes" = xNone || test "x$ac_x_includes" = x; then : else CFLAGS="$CFLAGS -I$ac_x_includes" fi - if test x$ac_x_libraries = xno || test x$ac_x_libraries = x; then + if test x$ac_x_libraries = xno || test "x$ac_x_libraries" = xNone; then : else - XPATH="-L$ac_x_libraries" - XLIB="-L$ac_x_libraries -lX11" + if test "x$ac_x_libraries" = x; then + XPATH="" + XLIB="-lX11" + else + XPATH="-L$ac_x_libraries" + XLIB="-L$ac_x_libraries -lX11" + fi fi fi @@ -131,17 +136,18 @@ have_opengles=yes AC_MSG_RESULT($have_opengles) GLLIB="" +GLESLIB="" if test x$have_opengles = xyes; then CFLAGS="$CFLAGS -DHAVE_OPENGLES" - GLLIB="$XPATH -lGLESv1_CM" -elif test x$have_opengl = xyes; then + GLESLIB="$XPATH -lGLESv1_CM" +fi +if test x$have_opengl = xyes; then CFLAGS="$CFLAGS -DHAVE_OPENGL" GLLIB="$XPATH $SYS_GL_LIBS" -else - GLLIB="" fi AC_SUBST(GLLIB) +AC_SUBST(GLESLIB) AC_SUBST(XLIB) dnl Check for SDL_ttf diff --git a/test/loopwave.c b/test/loopwave.c index de8329af1..403d16c53 100644 --- a/test/loopwave.c +++ b/test/loopwave.c @@ -1,146 +1,144 @@ -/* - Copyright (C) 1997-2013 Sam Lantinga - - 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. -*/ - -/* Program to load a wave file and loop playing it using SDL sound */ - -/* loopwaves.c is much more robust in handling WAVE files -- - This is only for simple WAVEs -*/ -#include "SDL_config.h" - -#include -#include - -#if HAVE_SIGNAL_H -#include -#endif - -#include "SDL.h" -#include "SDL_audio.h" - -struct -{ - SDL_AudioSpec spec; - Uint8 *sound; /* Pointer to wave data */ - Uint32 soundlen; /* Length of wave data */ - int soundpos; /* Current play position */ -} wave; - - -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ -static void -quit(int rc) -{ - SDL_Quit(); - exit(rc); -} - - -void SDLCALL -fillerup(void *unused, Uint8 * stream, int len) -{ - Uint8 *waveptr; - int waveleft; - - /* Set up the pointers */ - waveptr = wave.sound + wave.soundpos; - waveleft = wave.soundlen - wave.soundpos; - - /* Go! */ - while (waveleft <= len) { - SDL_memcpy(stream, waveptr, waveleft); - stream += waveleft; - len -= waveleft; - waveptr = wave.sound; - waveleft = wave.soundlen; - wave.soundpos = 0; - } - SDL_memcpy(stream, waveptr, len); - wave.soundpos += len; -} - -static int done = 0; -void -poked(int sig) -{ - done = 1; -} - -int -main(int argc, char *argv[]) -{ - int i; - char filename[4096]; - - /* Load the SDL library */ - if (SDL_Init(SDL_INIT_AUDIO) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); - return (1); - } - - if (argc >= 1) { - SDL_strlcpy(filename, argv[1], sizeof(filename)); - } else { - SDL_strlcpy(filename, "sample.wav", sizeof(filename)); - } - /* Load the wave file into memory */ - if (SDL_LoadWAV(filename, &wave.spec, &wave.sound, &wave.soundlen) == NULL) { - fprintf(stderr, "Couldn't load %s: %s\n", filename, SDL_GetError()); - quit(1); - } - - wave.spec.callback = fillerup; -#if HAVE_SIGNAL_H - /* Set the signals */ -#ifdef SIGHUP - signal(SIGHUP, poked); -#endif - signal(SIGINT, poked); -#ifdef SIGQUIT - signal(SIGQUIT, poked); -#endif - signal(SIGTERM, poked); -#endif /* HAVE_SIGNAL_H */ - - /* Show the list of available drivers */ - printf("Available audio drivers: "); - for (i = 0; i < SDL_GetNumAudioDrivers(); ++i) { - if (i == 0) { - printf("%s", SDL_GetAudioDriver(i)); - } else { - printf(", %s", SDL_GetAudioDriver(i)); - } - } - printf("\n"); - - /* Initialize fillerup() variables */ - if (SDL_OpenAudio(&wave.spec, NULL) < 0) { - fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError()); - SDL_FreeWAV(wave.sound); - quit(2); - } - - printf("Using audio driver: %s\n", SDL_GetCurrentAudioDriver()); - - /* Let the audio run */ - SDL_PauseAudio(0); - while (!done && (SDL_GetAudioStatus() == SDL_AUDIO_PLAYING)) - SDL_Delay(1000); - - /* Clean up on signal */ - SDL_CloseAudio(); - SDL_FreeWAV(wave.sound); - SDL_Quit(); - return (0); -} - -/* vi: set ts=4 sw=4 expandtab: */ +/* + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/* Program to load a wave file and loop playing it using SDL sound */ + +/* loopwaves.c is much more robust in handling WAVE files -- + This is only for simple WAVEs +*/ +#include "SDL_config.h" + +#include +#include + +#if HAVE_SIGNAL_H +#include +#endif + +#include "SDL.h" +#include "SDL_audio.h" + +struct +{ + SDL_AudioSpec spec; + Uint8 *sound; /* Pointer to wave data */ + Uint32 soundlen; /* Length of wave data */ + int soundpos; /* Current play position */ +} wave; + + +/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ +static void +quit(int rc) +{ + SDL_Quit(); + exit(rc); +} + + +void SDLCALL +fillerup(void *unused, Uint8 * stream, int len) +{ + Uint8 *waveptr; + int waveleft; + + /* Set up the pointers */ + waveptr = wave.sound + wave.soundpos; + waveleft = wave.soundlen - wave.soundpos; + + /* Go! */ + while (waveleft <= len) { + SDL_memcpy(stream, waveptr, waveleft); + stream += waveleft; + len -= waveleft; + waveptr = wave.sound; + waveleft = wave.soundlen; + wave.soundpos = 0; + } + SDL_memcpy(stream, waveptr, len); + wave.soundpos += len; +} + +static int done = 0; +void +poked(int sig) +{ + done = 1; +} + +int +main(int argc, char *argv[]) +{ + int i; + char filename[4096]; + + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + + /* Load the SDL library */ + if (SDL_Init(SDL_INIT_AUDIO) < 0) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); + return (1); + } + + if (argc >= 1) { + SDL_strlcpy(filename, argv[1], sizeof(filename)); + } else { + SDL_strlcpy(filename, "sample.wav", sizeof(filename)); + } + /* Load the wave file into memory */ + if (SDL_LoadWAV(filename, &wave.spec, &wave.sound, &wave.soundlen) == NULL) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", argv[1], SDL_GetError()); + quit(1); + } + + wave.spec.callback = fillerup; +#if HAVE_SIGNAL_H + /* Set the signals */ +#ifdef SIGHUP + signal(SIGHUP, poked); +#endif + signal(SIGINT, poked); +#ifdef SIGQUIT + signal(SIGQUIT, poked); +#endif + signal(SIGTERM, poked); +#endif /* HAVE_SIGNAL_H */ + + /* Show the list of available drivers */ + SDL_Log("Available audio drivers:"); + for (i = 0; i < SDL_GetNumAudioDrivers(); ++i) { + SDL_Log("%i: %s", i, SDL_GetAudioDriver(i)); + } + + /* Initialize fillerup() variables */ + if (SDL_OpenAudio(&wave.spec, NULL) < 0) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s\n", SDL_GetError()); + SDL_FreeWAV(wave.sound); + quit(2); + } + + SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver()); + + /* Let the audio run */ + SDL_PauseAudio(0); + while (!done && (SDL_GetAudioStatus() == SDL_AUDIO_PLAYING)) + SDL_Delay(1000); + + /* Clean up on signal */ + SDL_CloseAudio(); + SDL_FreeWAV(wave.sound); + SDL_Quit(); + return (0); +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/test/testatomic.c b/test/testatomic.c index be60a611b..b360616d2 100644 --- a/test/testatomic.c +++ b/test/testatomic.c @@ -45,39 +45,39 @@ void RunBasicTest() SDL_atomic_t v; SDL_bool tfret = SDL_FALSE; - printf("\nspin lock---------------------------------------\n\n"); + SDL_Log("\nspin lock---------------------------------------\n\n"); SDL_AtomicLock(&lock); - printf("AtomicLock lock=%d\n", lock); + SDL_Log("AtomicLock lock=%d\n", lock); SDL_AtomicUnlock(&lock); - printf("AtomicUnlock lock=%d\n", lock); + SDL_Log("AtomicUnlock lock=%d\n", lock); - printf("\natomic -----------------------------------------\n\n"); + SDL_Log("\natomic -----------------------------------------\n\n"); SDL_AtomicSet(&v, 0); - tfret = SDL_AtomicSet(&v, 10) == 0; - printf("AtomicSet(10) tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); - tfret = SDL_AtomicAdd(&v, 10) == 10; - printf("AtomicAdd(10) tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); + tfret = SDL_AtomicSet(&v, 10) == 0 ? SDL_TRUE : SDL_FALSE; + SDL_Log("AtomicSet(10) tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); + tfret = SDL_AtomicAdd(&v, 10) == 10 ? SDL_TRUE : SDL_FALSE; + SDL_Log("AtomicAdd(10) tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); SDL_AtomicSet(&v, 0); SDL_AtomicIncRef(&v); - tfret = (SDL_AtomicGet(&v) == 1); - printf("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); + tfret = (SDL_AtomicGet(&v) == 1) ? SDL_TRUE : SDL_FALSE; + SDL_Log("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); SDL_AtomicIncRef(&v); - tfret = (SDL_AtomicGet(&v) == 2); - printf("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); - tfret = (SDL_AtomicDecRef(&v) == SDL_FALSE); - printf("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); - tfret = (SDL_AtomicDecRef(&v) == SDL_TRUE); - printf("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); + tfret = (SDL_AtomicGet(&v) == 2) ? SDL_TRUE : SDL_FALSE; + SDL_Log("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); + tfret = (SDL_AtomicDecRef(&v) == SDL_FALSE) ? SDL_TRUE : SDL_FALSE; + SDL_Log("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); + tfret = (SDL_AtomicDecRef(&v) == SDL_TRUE) ? SDL_TRUE : SDL_FALSE; + SDL_Log("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); SDL_AtomicSet(&v, 10); - tfret = (SDL_AtomicCAS(&v, 0, 20) == SDL_FALSE); - printf("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); + tfret = (SDL_AtomicCAS(&v, 0, 20) == SDL_FALSE) ? SDL_TRUE : SDL_FALSE; + SDL_Log("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); value = SDL_AtomicGet(&v); - tfret = (SDL_AtomicCAS(&v, value, 20) == SDL_TRUE); - printf("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); + tfret = (SDL_AtomicCAS(&v, value, 20) == SDL_TRUE) ? SDL_TRUE : SDL_FALSE; + SDL_Log("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); } /**************************************************************************/ @@ -120,7 +120,7 @@ static int adder(void* junk) { unsigned long N=NInter; - printf("Thread subtracting %d %lu times\n",CountInc,N); + SDL_Log("Thread subtracting %d %lu times\n",CountInc,N); while (N--) { SDL_AtomicAdd(&good, -CountInc); bad-=CountInc; @@ -152,7 +152,7 @@ void runAdder(void) end = SDL_GetTicks(); - printf("Finished in %f sec\n", (end - start) / 1000.f); + SDL_Log("Finished in %f sec\n", (end - start) / 1000.f); } static @@ -161,28 +161,28 @@ void RunEpicTest() int b; atomicValue v; - printf("\nepic test---------------------------------------\n\n"); + SDL_Log("\nepic test---------------------------------------\n\n"); - printf("Size asserted to be >= 32-bit\n"); + SDL_Log("Size asserted to be >= 32-bit\n"); SDL_assert(sizeof(atomicValue)>=4); - printf("Check static initializer\n"); + SDL_Log("Check static initializer\n"); v=SDL_AtomicGet(&good); SDL_assert(v==42); SDL_assert(bad==42); - printf("Test negative values\n"); + SDL_Log("Test negative values\n"); SDL_AtomicSet(&good, -5); v=SDL_AtomicGet(&good); SDL_assert(v==-5); - printf("Verify maximum value\n"); + SDL_Log("Verify maximum value\n"); SDL_AtomicSet(&good, CountTo); v=SDL_AtomicGet(&good); SDL_assert(v==CountTo); - printf("Test compare and exchange\n"); + SDL_Log("Test compare and exchange\n"); b=SDL_AtomicCAS(&good, 500, 43); SDL_assert(!b); /* no swap since CountTo!=500 */ @@ -194,7 +194,7 @@ void RunEpicTest() v=SDL_AtomicGet(&good); SDL_assert(v==44); - printf("Test Add\n"); + SDL_Log("Test Add\n"); v=SDL_AtomicAdd(&good, 1); SDL_assert(v==44); @@ -206,7 +206,7 @@ void RunEpicTest() v=SDL_AtomicGet(&good); SDL_assert(v==55); - printf("Test Add (Negative values)\n"); + SDL_Log("Test Add (Negative values)\n"); v=SDL_AtomicAdd(&good, -20); SDL_assert(v==55); @@ -223,7 +223,7 @@ void RunEpicTest() v=SDL_AtomicGet(&good); SDL_assert(v==15); - printf("Reset before count down test\n"); + SDL_Log("Reset before count down test\n"); SDL_AtomicSet(&good, CountTo); v=SDL_AtomicGet(&good); SDL_assert(v==CountTo); @@ -231,11 +231,11 @@ void RunEpicTest() bad=CountTo; SDL_assert(bad==CountTo); - printf("Counting down from %d, Expect %d remaining\n",CountTo,Expect); + SDL_Log("Counting down from %d, Expect %d remaining\n",CountTo,Expect); runAdder(); v=SDL_AtomicGet(&good); - printf("Atomic %d Non-Atomic %d\n",v,bad); + SDL_Log("Atomic %d Non-Atomic %d\n",v,bad); SDL_assert(v==Expect); SDL_assert(bad!=Expect); } @@ -429,7 +429,7 @@ static SDL_bool EnqueueEvent_Mutex(SDL_EventQueue *queue, const SDL_Event *event } else if (delta < 0) { /* We ran into an old queue entry, which means it still needs to be dequeued */ } else { - printf("ERROR: mutex failed!\n"); + SDL_Log("ERROR: mutex failed!\n"); } SDL_UnlockMutex(queue->mutex); @@ -462,7 +462,7 @@ static SDL_bool DequeueEvent_Mutex(SDL_EventQueue *queue, SDL_Event *event) } else if (delta < 0) { /* We ran into an old queue entry, which means we've hit empty */ } else { - printf("ERROR: mutex failed!\n"); + SDL_Log("ERROR: mutex failed!\n"); } SDL_UnlockMutex(queue->mutex); @@ -598,9 +598,11 @@ static void RunFIFOTest(SDL_bool lock_free) Uint32 start, end; int i, j; int grand_total; + char textBuffer[1024]; + int len; - printf("\nFIFO test---------------------------------------\n\n"); - printf("Mode: %s\n", lock_free ? "LockFree" : "Mutex"); + SDL_Log("\nFIFO test---------------------------------------\n\n"); + SDL_Log("Mode: %s\n", lock_free ? "LockFree" : "Mutex"); readersDone = SDL_CreateSemaphore(0); writersDone = SDL_CreateSemaphore(0); @@ -622,7 +624,7 @@ static void RunFIFOTest(SDL_bool lock_free) #endif /* Start the readers first */ - printf("Starting %d readers\n", NUM_READERS); + SDL_Log("Starting %d readers\n", NUM_READERS); SDL_zero(readerData); SDL_AtomicSet(&readersRunning, NUM_READERS); for (i = 0; i < NUM_READERS; ++i) { @@ -634,7 +636,7 @@ static void RunFIFOTest(SDL_bool lock_free) } /* Start up the writers */ - printf("Starting %d writers\n", NUM_WRITERS); + SDL_Log("Starting %d writers\n", NUM_WRITERS); SDL_zero(writerData); SDL_AtomicSet(&writersRunning, NUM_WRITERS); for (i = 0; i < NUM_WRITERS; ++i) { @@ -668,16 +670,16 @@ static void RunFIFOTest(SDL_bool lock_free) SDL_DestroyMutex(queue.mutex); } - printf("Finished in %f sec\n", (end - start) / 1000.f); + SDL_Log("Finished in %f sec\n", (end - start) / 1000.f); - printf("\n"); + SDL_Log("\n"); for (i = 0; i < NUM_WRITERS; ++i) { - printf("Writer %d wrote %d events, had %d waits\n", i, EVENTS_PER_WRITER, writerData[i].waits); + SDL_Log("Writer %d wrote %d events, had %d waits\n", i, EVENTS_PER_WRITER, writerData[i].waits); } - printf("Writers wrote %d total events\n", NUM_WRITERS*EVENTS_PER_WRITER); + SDL_Log("Writers wrote %d total events\n", NUM_WRITERS*EVENTS_PER_WRITER); /* Print a breakdown of which readers read messages from which writer */ - printf("\n"); + SDL_Log("\n"); grand_total = 0; for (i = 0; i < NUM_READERS; ++i) { int total = 0; @@ -685,17 +687,21 @@ static void RunFIFOTest(SDL_bool lock_free) total += readerData[i].counters[j]; } grand_total += total; - printf("Reader %d read %d events, had %d waits\n", i, total, readerData[i].waits); - printf(" { "); + SDL_Log("Reader %d read %d events, had %d waits\n", i, total, readerData[i].waits); + SDL_snprintf(textBuffer, sizeof(textBuffer), " { "); for (j = 0; j < NUM_WRITERS; ++j) { if (j > 0) { - printf(", "); + len = SDL_strlen(textBuffer); + SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, ", "); } - printf("%d", readerData[i].counters[j]); + len = SDL_strlen(textBuffer); + SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, "%d", readerData[i].counters[j]); } - printf(" }\n"); + len = SDL_strlen(textBuffer); + SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, " }\n"); + SDL_Log(textBuffer); } - printf("Readers read %d total events\n", grand_total); + SDL_Log("Readers read %d total events\n", grand_total); } /* End FIFO test */ @@ -704,6 +710,9 @@ static void RunFIFOTest(SDL_bool lock_free) int main(int argc, char *argv[]) { + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + RunBasicTest(); RunEpicTest(); /* This test is really slow, so don't run it by default */ diff --git a/test/testaudioinfo.c b/test/testaudioinfo.c index c1d7fa389..a65db5fa1 100644 --- a/test/testaudioinfo.c +++ b/test/testaudioinfo.c @@ -18,18 +18,18 @@ print_devices(int iscapture) const char *typestr = ((iscapture) ? "capture" : "output"); int n = SDL_GetNumAudioDevices(iscapture); - printf("%s devices:\n", typestr); + SDL_Log("%s devices:\n", typestr); if (n == -1) - printf(" Driver can't detect specific %s devices.\n\n", typestr); + SDL_Log(" Driver can't detect specific %s devices.\n\n", typestr); else if (n == 0) - printf(" No %s devices found.\n\n", typestr); + SDL_Log(" No %s devices found.\n\n", typestr); else { int i; for (i = 0; i < n; i++) { - printf(" %s\n", SDL_GetAudioDeviceName(i, iscapture)); + SDL_Log(" %s\n", SDL_GetAudioDeviceName(i, iscapture)); } - printf("\n"); + SDL_Log("\n"); } } @@ -38,26 +38,29 @@ main(int argc, char **argv) { int n; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Load the SDL library */ if (SDL_Init(SDL_INIT_AUDIO) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } /* Print available audio drivers */ n = SDL_GetNumAudioDrivers(); if (n == 0) { - printf("No built-in audio drivers\n\n"); + SDL_Log("No built-in audio drivers\n\n"); } else { int i; - printf("Built-in audio drivers:\n"); + SDL_Log("Built-in audio drivers:\n"); for (i = 0; i < n; ++i) { - printf(" %s\n", SDL_GetAudioDriver(i)); + SDL_Log(" %s\n", SDL_GetAudioDriver(i)); } - printf("\n"); + SDL_Log("\n"); } - printf("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver()); + SDL_Log("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver()); print_devices(0); print_devices(1); diff --git a/test/testautomation.c b/test/testautomation.c index 5eea7ec6f..0a181bd9b 100644 --- a/test/testautomation.c +++ b/test/testautomation.c @@ -80,8 +80,7 @@ main(int argc, char *argv[]) } } if (consumed < 0) { - fprintf(stderr, - "Usage: %s %s [--iterations #] [--execKey #] [--seed string] [--filter suite_name|test_name]\n", + SDL_Log("Usage: %s %s [--iterations #] [--execKey #] [--seed string] [--filter suite_name|test_name]\n", argv[0], SDLTest_CommonUsage(state)); quit(1); } @@ -114,12 +113,8 @@ main(int argc, char *argv[]) } /* Clean up */ - if (userRunSeed != NULL) { - SDL_free(userRunSeed); - } - if (filter != NULL) { - SDL_free(filter); - } + SDL_free(userRunSeed); + SDL_free(filter); /* Shutdown everything */ quit(result); diff --git a/test/testautomation_audio.c b/test/testautomation_audio.c index 90b08acbd..c5c3f047d 100644 --- a/test/testautomation_audio.c +++ b/test/testautomation_audio.c @@ -77,7 +77,7 @@ int audio_initQuitAudio() audioDriver = SDL_GetAudioDriver(i); SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i); SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL"); - SDLTest_AssertCheck(SDL_strlen(audioDriver) > 0, "Audio driver name is not empty; got: %s", audioDriver); + SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* Call Init */ result = SDL_AudioInit(audioDriver); @@ -134,7 +134,7 @@ int audio_initOpenCloseQuitAudio() audioDriver = SDL_GetAudioDriver(i); SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i); SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL"); - SDLTest_AssertCheck(SDL_strlen(audioDriver) > 0, "Audio driver name is not empty; got: %s", audioDriver); + SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* Change specs */ for (j = 0; j < 2; j++) { @@ -226,14 +226,14 @@ int audio_enumerateAndNameAudioDevices() SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t); SDLTest_AssertCheck(name != NULL, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not NULL", i, t); if (name != NULL) { - SDLTest_AssertCheck(SDL_strlen(name)>0, "verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, t, name); + SDLTest_AssertCheck(name[0] != '\0', "verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, t, name); if (t==1) { /* Also try non-zero type */ tt = t + SDLTest_RandomIntegerInRange(1,10); nameAgain = SDL_GetAudioDeviceName(i, tt); SDLTest_AssertCheck(nameAgain != NULL, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not NULL", i, tt); if (nameAgain != NULL) { - SDLTest_AssertCheck(SDL_strlen(nameAgain)>0, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, tt, nameAgain); + SDLTest_AssertCheck(nameAgain[0] != '\0', "Verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, tt, nameAgain); SDLTest_AssertCheck(SDL_strcmp(name, nameAgain)==0, "Verify SDL_GetAudioDeviceName(%i, %i) and SDL_GetAudioDeviceName(%i %i) return the same string", i, t, i, tt); @@ -318,7 +318,7 @@ int audio_printAudioDrivers() SDLTest_AssertPass("Call to SDL_GetAudioDriver(%i)", i); SDLTest_AssertCheck(name != NULL, "Verify returned name is not NULL"); if (name != NULL) { - SDLTest_AssertCheck(SDL_strlen(name)>0, "Verify returned name is not empty, got: '%s'", name); + SDLTest_AssertCheck(name[0] != '\0', "Verify returned name is not empty, got: '%s'", name); } } } @@ -339,7 +339,7 @@ int audio_printCurrentAudioDriver() SDLTest_AssertPass("Call to SDL_GetCurrentAudioDriver()"); SDLTest_AssertCheck(name != NULL, "Verify returned name is not NULL"); if (name != NULL) { - SDLTest_AssertCheck(SDL_strlen(name)>0, "Verify returned name is not empty, got: '%s'", name); + SDLTest_AssertCheck(name[0] != '\0', "Verify returned name is not empty, got: '%s'", name); } return TEST_COMPLETED; @@ -509,7 +509,7 @@ int audio_buildAudioCVTNegative() SDLTest_AssertCheck(result == -1, "Verify result value; expected: -1, got: %i", result); error = SDL_GetError(); SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL && SDL_strlen(error)>0, "Validate that error message was not NULL or empty"); + SDLTest_AssertCheck(error != NULL && error[0] != '\0', "Validate that error message was not NULL or empty"); } SDL_ClearError(); @@ -643,7 +643,7 @@ int audio_lockUnlockOpenAudioDevice() SDL_Delay(10); SDLTest_Log("Simulate callback processing - delay"); - /* Unlock again*/ + /* Unlock again */ SDL_UnlockAudioDevice(id); SDLTest_AssertPass("SDL_UnlockAudioDevice(%i)", id); @@ -747,11 +747,9 @@ int audio_convertAudio() SDLTest_AssertCheck(cvt.len_ratio > 0.0, "Verify conversion length ratio; expected: >0; got: %f", cvt.len_ratio); /* Free converted buffer */ - if (cvt.buf != NULL) { SDL_free(cvt.buf); cvt.buf = NULL; - } - } + } } } } diff --git a/test/testautomation_clipboard.c b/test/testautomation_clipboard.c index 92aec7d03..9ce4f5149 100644 --- a/test/testautomation_clipboard.c +++ b/test/testautomation_clipboard.c @@ -41,7 +41,7 @@ clipboard_testGetClipboardText(void *arg) charResult = SDL_GetClipboardText(); SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded"); - if (charResult) SDL_free(charResult); + SDL_free(charResult); return TEST_COMPLETED; } @@ -69,8 +69,8 @@ clipboard_testSetClipboardText(void *arg) textRef, text); /* Cleanup */ - if (textRef) SDL_free(textRef); - if (text) SDL_free(text); + SDL_free(textRef); + SDL_free(text); return TEST_COMPLETED; } @@ -118,7 +118,7 @@ clipboard_testClipboardTextFunctions(void *arg) charResult != NULL, "Verify SDL_GetClipboardText did not return NULL"); SDLTest_AssertCheck( - SDL_strlen(charResult) == 0, + charResult[0] == '\0', "Verify SDL_GetClipboardText returned string with length 0, got length %i", SDL_strlen(charResult)); intResult = SDL_SetClipboardText((const char *)text); @@ -145,9 +145,9 @@ clipboard_testClipboardTextFunctions(void *arg) textRef, charResult); /* Cleanup */ - if (textRef) SDL_free(textRef); - if (text) SDL_free(text); - if (charResult) SDL_free(charResult); + SDL_free(textRef); + SDL_free(text); + SDL_free(charResult); return TEST_COMPLETED; } diff --git a/test/testautomation_events.c b/test/testautomation_events.c index 638607e76..f9eb5bb9e 100644 --- a/test/testautomation_events.c +++ b/test/testautomation_events.c @@ -58,7 +58,7 @@ events_pushPumpAndPollUserevent(void *arg) event1.user.data1 = (void *)&_userdataValue1; event1.user.data2 = (void *)&_userdataValue2; - /* Push a user event onto the queue and force queue update*/ + /* Push a user event onto the queue and force queue update */ SDL_PushEvent(&event1); SDLTest_AssertPass("Call to SDL_PushEvent()"); SDL_PumpEvents(); @@ -101,7 +101,7 @@ events_addDelEventWatch(void *arg) SDL_AddEventWatch(_events_sampleNullEventFilter, NULL); SDLTest_AssertPass("Call to SDL_AddEventWatch()"); - /* Push a user event onto the queue and force queue update*/ + /* Push a user event onto the queue and force queue update */ SDL_PushEvent(&event); SDLTest_AssertPass("Call to SDL_PushEvent()"); SDL_PumpEvents(); @@ -112,7 +112,7 @@ events_addDelEventWatch(void *arg) SDL_DelEventWatch(_events_sampleNullEventFilter, NULL); SDLTest_AssertPass("Call to SDL_DelEventWatch()"); - /* Push a user event onto the queue and force queue update*/ + /* Push a user event onto the queue and force queue update */ _eventFilterCalled = 0; SDL_PushEvent(&event); SDLTest_AssertPass("Call to SDL_PushEvent()"); @@ -152,7 +152,7 @@ events_addDelEventWatchWithUserdata(void *arg) SDL_AddEventWatch(_events_sampleNullEventFilter, (void *)&_userdataValue); SDLTest_AssertPass("Call to SDL_AddEventWatch()"); - /* Push a user event onto the queue and force queue update*/ + /* Push a user event onto the queue and force queue update */ SDL_PushEvent(&event); SDLTest_AssertPass("Call to SDL_PushEvent()"); SDL_PumpEvents(); @@ -163,7 +163,7 @@ events_addDelEventWatchWithUserdata(void *arg) SDL_DelEventWatch(_events_sampleNullEventFilter, (void *)&_userdataValue); SDLTest_AssertPass("Call to SDL_DelEventWatch()"); - /* Push a user event onto the queue and force queue update*/ + /* Push a user event onto the queue and force queue update */ _eventFilterCalled = 0; SDL_PushEvent(&event); SDLTest_AssertPass("Call to SDL_PushEvent()"); diff --git a/test/testautomation_main.c b/test/testautomation_main.c index f695903c2..ef8f19e9e 100644 --- a/test/testautomation_main.c +++ b/test/testautomation_main.c @@ -1,7 +1,7 @@ /** * Automated SDL subsystems management test. * - * Written by Jrgen Tjern "jorgenpt" + * Written by J�rgen Tjern� "jorgenpt" * * Released under Public Domain. */ @@ -10,7 +10,7 @@ #include "SDL_test.h" -/*! +/* ! * \brief Tests SDL_Init() and SDL_Quit() of Joystick and Haptic subsystems * \sa * http://wiki.libsdl.org/moin.cgi/SDL_Init @@ -38,7 +38,7 @@ static int main_testInitQuitJoystickHaptic (void *arg) #endif } -/*! +/* ! * \brief Tests SDL_InitSubSystem() and SDL_QuitSubSystem() * \sa * http://wiki.libsdl.org/moin.cgi/SDL_Init @@ -79,16 +79,16 @@ static int main_testImpliedJoystickInit (void *arg) #else int initialized_system; - // First initialize the controller + /* First initialize the controller */ SDLTest_AssertCheck( (SDL_WasInit(joy_and_controller) & joy_and_controller) == 0, "SDL_WasInit() before init should be false for joystick & controller" ); SDLTest_AssertCheck( SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) == 0, "SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER)" ); - // Then make sure this implicitly initialized the joystick subsystem + /* Then make sure this implicitly initialized the joystick subsystem */ initialized_system = SDL_WasInit(joy_and_controller); SDLTest_AssertCheck( (initialized_system & joy_and_controller) == joy_and_controller, "SDL_WasInit() should be true for joystick & controller (%x)", initialized_system ); - // Then quit the controller, and make sure that implicitly also quits the - // joystick subsystem + /* Then quit the controller, and make sure that implicitly also quits the */ + /* joystick subsystem */ SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER); initialized_system = SDL_WasInit(joy_and_controller); SDLTest_AssertCheck( (initialized_system & joy_and_controller) == 0, "SDL_WasInit() should be false for joystick & controller (%x)", initialized_system ); @@ -104,17 +104,17 @@ static int main_testImpliedJoystickQuit (void *arg) #else int initialized_system; - // First initialize the controller and the joystick (explicitly) + /* First initialize the controller and the joystick (explicitly) */ SDLTest_AssertCheck( (SDL_WasInit(joy_and_controller) & joy_and_controller) == 0, "SDL_WasInit() before init should be false for joystick & controller" ); SDLTest_AssertCheck( SDL_InitSubSystem(SDL_INIT_JOYSTICK) == 0, "SDL_InitSubSystem(SDL_INIT_JOYSTICK)" ); SDLTest_AssertCheck( SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) == 0, "SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER)" ); - // Then make sure they're both initialized properly + /* Then make sure they're both initialized properly */ initialized_system = SDL_WasInit(joy_and_controller); SDLTest_AssertCheck( (initialized_system & joy_and_controller) == joy_and_controller, "SDL_WasInit() should be true for joystick & controller (%x)", initialized_system ); - // Then quit the controller, and make sure that it does NOT quit the - // explicitly initialized joystick subsystem. + /* Then quit the controller, and make sure that it does NOT quit the */ + /* explicitly initialized joystick subsystem. */ SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER); initialized_system = SDL_WasInit(joy_and_controller); SDLTest_AssertCheck( (initialized_system & joy_and_controller) == SDL_INIT_JOYSTICK, "SDL_WasInit() should be false for joystick & controller (%x)", initialized_system ); diff --git a/test/testautomation_pixels.c b/test/testautomation_pixels.c index 48f9838c8..04e00deb2 100644 --- a/test/testautomation_pixels.c +++ b/test/testautomation_pixels.c @@ -242,7 +242,7 @@ pixels_getPixelFormatName(void *arg) SDLTest_AssertPass("Call to SDL_GetPixelFormatName()"); SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); if (result != NULL) { - SDLTest_AssertCheck(SDL_strlen(result) > 0, "Verify result is non-empty"); + SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty"); SDLTest_AssertCheck(SDL_strcmp(result, unknownFormat) == 0, "Verify result text; expected: %s, got %s", unknownFormat, result); } @@ -257,7 +257,7 @@ pixels_getPixelFormatName(void *arg) SDLTest_AssertPass("Call to SDL_GetPixelFormatName()"); SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); if (result != NULL) { - SDLTest_AssertCheck(SDL_strlen(result) > 0, "Verify result is non-empty"); + SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty"); SDLTest_AssertCheck(SDL_strcmp(result, _RGBPixelFormatsVerbose[i]) == 0, "Verify result text; expected: %s, got %s", _RGBPixelFormatsVerbose[i], result); } @@ -273,7 +273,7 @@ pixels_getPixelFormatName(void *arg) SDLTest_AssertPass("Call to SDL_GetPixelFormatName()"); SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); if (result != NULL) { - SDLTest_AssertCheck(SDL_strlen(result) > 0, "Verify result is non-empty"); + SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty"); SDLTest_AssertCheck(SDL_strcmp(result, _nonRGBPixelFormatsVerbose[i]) == 0, "Verify result text; expected: %s, got %s", _nonRGBPixelFormatsVerbose[i], result); } @@ -290,14 +290,14 @@ pixels_getPixelFormatName(void *arg) SDLTest_AssertPass("Call to SDL_GetPixelFormatName(%u)", format); SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); if (result != NULL) { - SDLTest_AssertCheck(SDL_strlen(result) > 0, + SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty; got: %s", result); SDLTest_AssertCheck(SDL_strcmp(result, _invalidPixelFormatsVerbose[i]) == 0, "Validate name is UNKNOWN, expected: '%s', got: '%s'", _invalidPixelFormatsVerbose[i], result); } error = SDL_GetError(); SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL && SDL_strlen(error) == 0, "Validate that error message is empty"); + SDLTest_AssertCheck(error == NULL || error[0] == '\0', "Validate that error message is empty"); } return TEST_COMPLETED; @@ -411,7 +411,7 @@ pixels_calcGammaRamp(void *arg) int changed; Uint16 magic = 0xbeef; - /* Allocate temp ramp array and fill with some value*/ + /* Allocate temp ramp array and fill with some value */ ramp = (Uint16 *)SDL_malloc(256 * sizeof(Uint16)); SDLTest_AssertCheck(ramp != NULL, "Validate temp ramp array could be allocated"); if (ramp == NULL) return TEST_ABORTED; diff --git a/test/testautomation_platform.c b/test/testautomation_platform.c index 5ed2abad1..19896b48d 100644 --- a/test/testautomation_platform.c +++ b/test/testautomation_platform.c @@ -102,7 +102,7 @@ int platform_testEndianessAndSwap(void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_GetXYZ() functions * \sa * http://wiki.libsdl.org/moin.cgi/SDL_GetPlatform @@ -151,7 +151,7 @@ int platform_testGetFunctions (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_HasXYZ() functions * \sa * http://wiki.libsdl.org/moin.cgi/SDL_Has3DNow @@ -168,7 +168,7 @@ int platform_testHasFunctions (void *arg) { int ret; - // TODO: independently determine and compare values as well + /* TODO: independently determine and compare values as well */ ret = SDL_HasRDTSC(); SDLTest_AssertPass("SDL_HasRDTSC()"); @@ -200,7 +200,7 @@ int platform_testHasFunctions (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_GetVersion * \sa * http://wiki.libsdl.org/moin.cgi/SDL_GetVersion @@ -225,7 +225,7 @@ int platform_testGetVersion(void *arg) } -/*! +/* ! * \brief Tests SDL_VERSION macro */ int platform_testSDLVersion(void *arg) @@ -248,7 +248,7 @@ int platform_testSDLVersion(void *arg) } -/*! +/* ! * \brief Tests default SDL_Init */ int platform_testDefaultInit(void *arg) @@ -270,7 +270,7 @@ int platform_testDefaultInit(void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_Get/Set/ClearError * \sa * http://wiki.libsdl.org/moin.cgi/SDL_GetError @@ -315,14 +315,14 @@ int platform_testGetSetClearError(void *arg) lastError); } - // Clean up + /* Clean up */ SDL_ClearError(); SDLTest_AssertPass("SDL_ClearError()"); return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_SetError with empty input * \sa * http://wiki.libsdl.org/moin.cgi/SDL_SetError @@ -351,14 +351,14 @@ int platform_testSetErrorEmptyInput(void *arg) lastError); } - // Clean up + /* Clean up */ SDL_ClearError(); SDLTest_AssertPass("SDL_ClearError()"); return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_SetError with invalid input * \sa * http://wiki.libsdl.org/moin.cgi/SDL_SetError @@ -370,11 +370,11 @@ int platform_testSetErrorInvalidInput(void *arg) char *lastError; int len; - // Reset + /* Reset */ SDL_ClearError(); SDLTest_AssertPass("SDL_ClearError()"); - // Check for no-op + /* Check for no-op */ SDL_SetError(testError); SDLTest_AssertPass("SDL_SetError()"); lastError = (char *)SDL_GetError(); @@ -392,11 +392,11 @@ int platform_testSetErrorInvalidInput(void *arg) lastError); } - // Set + /* Set */ SDL_SetError(probeError); SDLTest_AssertPass("SDL_SetError()"); - // Check for no-op + /* Check for no-op */ SDL_SetError(testError); SDLTest_AssertPass("SDL_SetError()"); lastError = (char *)SDL_GetError(); @@ -415,14 +415,14 @@ int platform_testSetErrorInvalidInput(void *arg) lastError); } - // Clean up + /* Clean up */ SDL_ClearError(); SDLTest_AssertPass("SDL_ClearError()"); return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_GetPowerInfo * \sa * http://wiki.libsdl.org/moin.cgi/SDL_GetPowerInfo @@ -472,7 +472,7 @@ int platform_testGetPowerInfo(void *arg) pct); } - // Partial return value variations + /* Partial return value variations */ stateAgain = SDL_GetPowerInfo(&secsAgain, NULL); SDLTest_AssertCheck( state==stateAgain, diff --git a/test/testautomation_rect.c b/test/testautomation_rect.c index 77a7347e6..abf19f593 100644 --- a/test/testautomation_rect.c +++ b/test/testautomation_rect.c @@ -12,7 +12,7 @@ /* Helper functions */ -/*! +/* ! * \brief Private helper to check SDL_IntersectRectAndLine results */ void _validateIntersectRectAndLineResults( @@ -39,7 +39,7 @@ void _validateIntersectRectAndLineResults( /* Test case functions */ -/*! +/* ! * \brief Tests SDL_IntersectRectAndLine() clipping cases * * \sa @@ -110,7 +110,7 @@ rect_testIntersectRectAndLine (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_IntersectRectAndLine() non-clipping case line inside * * \sa @@ -177,7 +177,7 @@ rect_testIntersectRectAndLineInside (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_IntersectRectAndLine() non-clipping cases outside * * \sa @@ -232,7 +232,7 @@ rect_testIntersectRectAndLineOutside (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_IntersectRectAndLine() with empty rectangle * * \sa @@ -267,7 +267,7 @@ rect_testIntersectRectAndLineEmpty (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Negative tests against SDL_IntersectRectAndLine() with invalid parameters * * \sa @@ -302,7 +302,7 @@ rect_testIntersectRectAndLineParam (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Private helper to check SDL_HasIntersection results */ void _validateHasIntersectionResults( @@ -325,7 +325,7 @@ void _validateHasIntersectionResults( refRectB->x, refRectB->y, refRectB->w, refRectB->h); } -/*! +/* ! * \brief Private helper to check SDL_IntersectRect results */ void _validateIntersectRectResults( @@ -344,7 +344,7 @@ void _validateIntersectRectResults( } } -/*! +/* ! * \brief Private helper to check SDL_UnionRect results */ void _validateUnionRectResults( @@ -367,7 +367,7 @@ void _validateUnionRectResults( expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h); } -/*! +/* ! * \brief Private helper to check SDL_RectEmpty results */ void _validateRectEmptyResults( @@ -385,7 +385,7 @@ void _validateRectEmptyResults( refRect->x, refRect->y, refRect->w, refRect->h); } -/*! +/* ! * \brief Private helper to check SDL_RectEquals results */ void _validateRectEqualsResults( @@ -408,7 +408,7 @@ void _validateRectEqualsResults( refRectB->x, refRectB->y, refRectB->w, refRectB->h); } -/*! +/* ! * \brief Tests SDL_IntersectRect() with B fully inside A * * \sa @@ -423,7 +423,7 @@ int rect_testIntersectRectInside (void *arg) SDL_Rect result; SDL_bool intersection; - // rectB fully contained in rectA + /* rectB fully contained in rectA */ refRectB.x = 0; refRectB.y = 0; refRectB.w = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1); @@ -436,7 +436,7 @@ int rect_testIntersectRectInside (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_IntersectRect() with B fully outside A * * \sa @@ -451,7 +451,7 @@ int rect_testIntersectRectOutside (void *arg) SDL_Rect result; SDL_bool intersection; - // rectB fully outside of rectA + /* rectB fully outside of rectA */ refRectB.x = refRectA.x + refRectA.w + SDLTest_RandomIntegerInRange(1, 10); refRectB.y = refRectA.y + refRectA.h + SDLTest_RandomIntegerInRange(1, 10); refRectB.w = refRectA.w; @@ -464,7 +464,7 @@ int rect_testIntersectRectOutside (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_IntersectRect() with B partially intersecting A * * \sa @@ -480,7 +480,7 @@ int rect_testIntersectRectPartial (void *arg) SDL_Rect expectedResult; SDL_bool intersection; - // rectB partially contained in rectA + /* rectB partially contained in rectA */ refRectB.x = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1); refRectB.y = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1); refRectB.w = refRectA.w; @@ -494,7 +494,7 @@ int rect_testIntersectRectPartial (void *arg) intersection = SDL_IntersectRect(&rectA, &rectB, &result); _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - // rectB right edge + /* rectB right edge */ refRectB.x = rectA.w - 1; refRectB.y = rectA.y; refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1); @@ -508,7 +508,7 @@ int rect_testIntersectRectPartial (void *arg) intersection = SDL_IntersectRect(&rectA, &rectB, &result); _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - // rectB left edge + /* rectB left edge */ refRectB.x = 1 - rectA.w; refRectB.y = rectA.y; refRectB.w = refRectA.w; @@ -522,7 +522,7 @@ int rect_testIntersectRectPartial (void *arg) intersection = SDL_IntersectRect(&rectA, &rectB, &result); _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - // rectB bottom edge + /* rectB bottom edge */ refRectB.x = rectA.x; refRectB.y = rectA.h - 1; refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1); @@ -536,7 +536,7 @@ int rect_testIntersectRectPartial (void *arg) intersection = SDL_IntersectRect(&rectA, &rectB, &result); _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - // rectB top edge + /* rectB top edge */ refRectB.x = rectA.x; refRectB.y = 1 - rectA.h; refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1); @@ -553,7 +553,7 @@ int rect_testIntersectRectPartial (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_IntersectRect() with 1x1 pixel sized rectangles * * \sa @@ -569,7 +569,7 @@ int rect_testIntersectRectPoint (void *arg) SDL_bool intersection; int offsetX, offsetY; - // intersecting pixels + /* intersecting pixels */ refRectA.x = SDLTest_RandomIntegerInRange(1, 100); refRectA.y = SDLTest_RandomIntegerInRange(1, 100); refRectB.x = refRectA.x; @@ -579,7 +579,7 @@ int rect_testIntersectRectPoint (void *arg) intersection = SDL_IntersectRect(&rectA, &rectB, &result); _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &refRectA); - // non-intersecting pixels cases + /* non-intersecting pixels cases */ for (offsetX = -1; offsetX <= 1; offsetX++) { for (offsetY = -1; offsetY <= 1; offsetY++) { if (offsetX != 0 || offsetY != 0) { @@ -600,7 +600,7 @@ int rect_testIntersectRectPoint (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_IntersectRect() with empty rectangles * * \sa @@ -616,7 +616,7 @@ int rect_testIntersectRectEmpty (void *arg) SDL_bool intersection; SDL_bool empty; - // Rect A empty + /* Rect A empty */ result.w = SDLTest_RandomIntegerInRange(1, 100); result.h = SDLTest_RandomIntegerInRange(1, 100); refRectA.x = SDLTest_RandomIntegerInRange(1, 100); @@ -633,7 +633,7 @@ int rect_testIntersectRectEmpty (void *arg) empty = (SDL_bool)SDL_RectEmpty(&result); SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE"); - // Rect B empty + /* Rect B empty */ result.w = SDLTest_RandomIntegerInRange(1, 100); result.h = SDLTest_RandomIntegerInRange(1, 100); refRectA.x = SDLTest_RandomIntegerInRange(1, 100); @@ -650,7 +650,7 @@ int rect_testIntersectRectEmpty (void *arg) empty = (SDL_bool)SDL_RectEmpty(&result); SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE"); - // Rect A and B empty + /* Rect A and B empty */ result.w = SDLTest_RandomIntegerInRange(1, 100); result.h = SDLTest_RandomIntegerInRange(1, 100); refRectA.x = SDLTest_RandomIntegerInRange(1, 100); @@ -672,7 +672,7 @@ int rect_testIntersectRectEmpty (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Negative tests against SDL_IntersectRect() with invalid parameters * * \sa @@ -685,7 +685,7 @@ int rect_testIntersectRectParam(void *arg) SDL_Rect result; SDL_bool intersection; - // invalid parameter combinations + /* invalid parameter combinations */ intersection = SDL_IntersectRect((SDL_Rect *)NULL, &rectB, &result); SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); intersection = SDL_IntersectRect(&rectA, (SDL_Rect *)NULL, &result); @@ -702,7 +702,7 @@ int rect_testIntersectRectParam(void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_HasIntersection() with B fully inside A * * \sa @@ -716,7 +716,7 @@ int rect_testHasIntersectionInside (void *arg) SDL_Rect rectB; SDL_bool intersection; - // rectB fully contained in rectA + /* rectB fully contained in rectA */ refRectB.x = 0; refRectB.y = 0; refRectB.w = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1); @@ -729,7 +729,7 @@ int rect_testHasIntersectionInside (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_HasIntersection() with B fully outside A * * \sa @@ -743,7 +743,7 @@ int rect_testHasIntersectionOutside (void *arg) SDL_Rect rectB; SDL_bool intersection; - // rectB fully outside of rectA + /* rectB fully outside of rectA */ refRectB.x = refRectA.x + refRectA.w + SDLTest_RandomIntegerInRange(1, 10); refRectB.y = refRectA.y + refRectA.h + SDLTest_RandomIntegerInRange(1, 10); refRectB.w = refRectA.w; @@ -756,7 +756,7 @@ int rect_testHasIntersectionOutside (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_HasIntersection() with B partially intersecting A * * \sa @@ -770,7 +770,7 @@ int rect_testHasIntersectionPartial (void *arg) SDL_Rect rectB; SDL_bool intersection; - // rectB partially contained in rectA + /* rectB partially contained in rectA */ refRectB.x = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1); refRectB.y = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1); refRectB.w = refRectA.w; @@ -780,7 +780,7 @@ int rect_testHasIntersectionPartial (void *arg) intersection = SDL_HasIntersection(&rectA, &rectB); _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); - // rectB right edge + /* rectB right edge */ refRectB.x = rectA.w - 1; refRectB.y = rectA.y; refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1); @@ -790,7 +790,7 @@ int rect_testHasIntersectionPartial (void *arg) intersection = SDL_HasIntersection(&rectA, &rectB); _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); - // rectB left edge + /* rectB left edge */ refRectB.x = 1 - rectA.w; refRectB.y = rectA.y; refRectB.w = refRectA.w; @@ -800,7 +800,7 @@ int rect_testHasIntersectionPartial (void *arg) intersection = SDL_HasIntersection(&rectA, &rectB); _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); - // rectB bottom edge + /* rectB bottom edge */ refRectB.x = rectA.x; refRectB.y = rectA.h - 1; refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1); @@ -810,7 +810,7 @@ int rect_testHasIntersectionPartial (void *arg) intersection = SDL_HasIntersection(&rectA, &rectB); _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); - // rectB top edge + /* rectB top edge */ refRectB.x = rectA.x; refRectB.y = 1 - rectA.h; refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1); @@ -823,7 +823,7 @@ int rect_testHasIntersectionPartial (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_HasIntersection() with 1x1 pixel sized rectangles * * \sa @@ -838,7 +838,7 @@ int rect_testHasIntersectionPoint (void *arg) SDL_bool intersection; int offsetX, offsetY; - // intersecting pixels + /* intersecting pixels */ refRectA.x = SDLTest_RandomIntegerInRange(1, 100); refRectA.y = SDLTest_RandomIntegerInRange(1, 100); refRectB.x = refRectA.x; @@ -848,7 +848,7 @@ int rect_testHasIntersectionPoint (void *arg) intersection = SDL_HasIntersection(&rectA, &rectB); _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); - // non-intersecting pixels cases + /* non-intersecting pixels cases */ for (offsetX = -1; offsetX <= 1; offsetX++) { for (offsetY = -1; offsetY <= 1; offsetY++) { if (offsetX != 0 || offsetY != 0) { @@ -869,7 +869,7 @@ int rect_testHasIntersectionPoint (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Tests SDL_HasIntersection() with empty rectangles * * \sa @@ -883,7 +883,7 @@ int rect_testHasIntersectionEmpty (void *arg) SDL_Rect rectB; SDL_bool intersection; - // Rect A empty + /* Rect A empty */ refRectA.x = SDLTest_RandomIntegerInRange(1, 100); refRectA.y = SDLTest_RandomIntegerInRange(1, 100); refRectA.w = SDLTest_RandomIntegerInRange(1, 100); @@ -896,7 +896,7 @@ int rect_testHasIntersectionEmpty (void *arg) intersection = SDL_HasIntersection(&rectA, &rectB); _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB); - // Rect B empty + /* Rect B empty */ refRectA.x = SDLTest_RandomIntegerInRange(1, 100); refRectA.y = SDLTest_RandomIntegerInRange(1, 100); refRectA.w = SDLTest_RandomIntegerInRange(1, 100); @@ -909,7 +909,7 @@ int rect_testHasIntersectionEmpty (void *arg) intersection = SDL_HasIntersection(&rectA, &rectB); _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB); - // Rect A and B empty + /* Rect A and B empty */ refRectA.x = SDLTest_RandomIntegerInRange(1, 100); refRectA.y = SDLTest_RandomIntegerInRange(1, 100); refRectA.w = SDLTest_RandomIntegerInRange(1, 100); @@ -927,7 +927,7 @@ int rect_testHasIntersectionEmpty (void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Negative tests against SDL_HasIntersection() with invalid parameters * * \sa @@ -939,7 +939,7 @@ int rect_testHasIntersectionParam(void *arg) SDL_Rect rectB; SDL_bool intersection; - // invalid parameter combinations + /* invalid parameter combinations */ intersection = SDL_HasIntersection((SDL_Rect *)NULL, &rectB); SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); intersection = SDL_HasIntersection(&rectA, (SDL_Rect *)NULL); @@ -950,7 +950,7 @@ int rect_testHasIntersectionParam(void *arg) return TEST_COMPLETED; } -/*! +/* ! * \brief Test SDL_EnclosePoints() without clipping * * \sa @@ -969,7 +969,7 @@ int rect_testEnclosePoints(void *arg) int minx = 0, maxx = 0, miny = 0, maxy = 0; int i; - // Create input data, tracking result + /* Create input data, tracking result */ for (i=0; i %s\n", SDL_GetPixelFormatName(pixel_formats[i]), SDL_GetPixelFormatName(pixel_formats[j]));*/ - fmt1 = SDL_AllocFormat(pixel_formats[i]); SDL_assert(fmt1 != NULL); cvt1 = SDL_ConvertSurface(face, fmt1, 0); @@ -429,9 +413,7 @@ surface_testBlit(void *arg) SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); - } + SDL_FreeSurface(compareSurface); return TEST_COMPLETED; } @@ -454,9 +436,7 @@ surface_testBlitColorMod(void *arg) SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); - } + SDL_FreeSurface(compareSurface); return TEST_COMPLETED; } @@ -479,9 +459,7 @@ surface_testBlitAlphaMod(void *arg) SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); - } + SDL_FreeSurface(compareSurface); return TEST_COMPLETED; } @@ -505,9 +483,7 @@ surface_testBlitBlendNone(void *arg) SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); - } + SDL_FreeSurface(compareSurface); return TEST_COMPLETED; } @@ -530,9 +506,7 @@ surface_testBlitBlendBlend(void *arg) SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); - } + SDL_FreeSurface(compareSurface); return TEST_COMPLETED; } @@ -555,9 +529,7 @@ surface_testBlitBlendAdd(void *arg) SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); - } + SDL_FreeSurface(compareSurface); return TEST_COMPLETED; } @@ -580,9 +552,7 @@ surface_testBlitBlendMod(void *arg) SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); - } + SDL_FreeSurface(compareSurface); return TEST_COMPLETED; } @@ -605,9 +575,7 @@ surface_testBlitBlendLoop(void *arg) { SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface(compareSurface); - } + SDL_FreeSurface(compareSurface); return TEST_COMPLETED; diff --git a/test/testautomation_video.c b/test/testautomation_video.c index 46061090e..3a7bfca05 100644 --- a/test/testautomation_video.c +++ b/test/testautomation_video.c @@ -876,7 +876,7 @@ video_getWindowId(void *arg) /* Clean up */ _destroyVideoSuiteTestWindow(window); - /* Get window from ID for closed window*/ + /* Get window from ID for closed window */ result = SDL_GetWindowFromID(id); SDLTest_AssertPass("Call to SDL_GetWindowID(%d/closed_window)", id); SDLTest_AssertCheck(result == NULL, "Verify result is NULL"); @@ -1714,10 +1714,10 @@ video_getSetWindowData(void *arg) _destroyVideoSuiteTestWindow(window); cleanup: - if (referenceUserdata != NULL) SDL_free(referenceUserdata); - if (referenceUserdata2 != NULL) SDL_free(referenceUserdata2); - if (userdata != NULL) SDL_free(userdata); - if (userdata2 != NULL) SDL_free(userdata2); + SDL_free(referenceUserdata); + SDL_free(referenceUserdata2); + SDL_free(userdata); + SDL_free(userdata2); return returnValue; } diff --git a/test/testdraw2.c b/test/testdraw2.c index a4509fe74..62e2dbf64 100644 --- a/test/testdraw2.c +++ b/test/testdraw2.c @@ -176,6 +176,9 @@ main(int argc, char *argv[]) SDL_Event event; Uint32 then, now, frames; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Initialize parameters */ num_objects = NUM_OBJECTS; @@ -218,8 +221,7 @@ main(int argc, char *argv[]) } } if (consumed < 0) { - fprintf(stderr, - "Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n", + SDL_Log("Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n", argv[0], SDLTest_CommonUsage(state)); return 1; } @@ -251,6 +253,8 @@ main(int argc, char *argv[]) } for (i = 0; i < state->num_windows; ++i) { SDL_Renderer *renderer = state->renderers[i]; + if (state->windows[i] == NULL) + continue; SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); SDL_RenderClear(renderer); @@ -268,7 +272,7 @@ main(int argc, char *argv[]) now = SDL_GetTicks(); if (now > then) { double fps = ((double) frames * 1000) / (now - then); - printf("%2.2f frames per second\n", fps); + SDL_Log("%2.2f frames per second\n", fps); } return 0; } diff --git a/test/testdrawchessboard.c b/test/testdrawchessboard.c index 002d8d717..567d3fb85 100644 --- a/test/testdrawchessboard.c +++ b/test/testdrawchessboard.c @@ -54,10 +54,13 @@ main(int argc, char *argv[]) SDL_Surface *surface; SDL_Renderer *renderer; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Initialize SDL */ if(SDL_Init(SDL_INIT_VIDEO) != 0) { - fprintf(stderr,"SDL_Init fail : %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init fail : %s\n", SDL_GetError()); return 1; } @@ -66,14 +69,14 @@ main(int argc, char *argv[]) window = SDL_CreateWindow("Chess Board", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN); if(!window) { - fprintf(stderr,"Window creation fail : %s\n",SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Window creation fail : %s\n",SDL_GetError()); return 1; } surface = SDL_GetWindowSurface(window); renderer = SDL_CreateSoftwareRenderer(surface); if(!renderer) { - fprintf(stderr,"Render creation for surface fail : %s\n",SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Render creation for surface fail : %s\n",SDL_GetError()); return 1; } diff --git a/test/testdropfile.c b/test/testdropfile.c new file mode 100644 index 000000000..9f4fa7b6a --- /dev/null +++ b/test/testdropfile.c @@ -0,0 +1,87 @@ +/* + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +#include +#include + +#include "SDL_test_common.h" + +static SDLTest_CommonState *state; + +/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ +static void +quit(int rc) +{ + SDLTest_CommonQuit(state); + exit(rc); +} + +int +main(int argc, char *argv[]) +{ + int i, done; + SDL_Event event; + + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + + /* Initialize test framework */ + state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); + if (!state) { + return 1; + } + + for (i = 1; i < argc;) { + int consumed; + + consumed = SDLTest_CommonArg(state, i); + if (consumed == 0) { + consumed = -1; + } + if (consumed < 0) { + SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state)); + quit(1); + } + i += consumed; + } + if (!SDLTest_CommonInit(state)) { + quit(2); + } + + for (i = 0; i < state->num_windows; ++i) { + SDL_Renderer *renderer = state->renderers[i]; + SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); + SDL_RenderClear(renderer); + SDL_RenderPresent(renderer); + } + + /* Main render loop */ + done = 0; + while (!done) { + /* Check for events */ + while (SDL_PollEvent(&event)) { + SDLTest_CommonEvent(state, &event, &done); + + if (event.type == SDL_DROPFILE) { + char *dropped_filedir = event.drop.file; + SDL_Log("File dropped on window: %s", dropped_filedir); + SDL_free(dropped_filedir); + } + } + } + + quit(0); + /* keep the compiler happy ... */ + return(0); +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/test/testerror.c b/test/testerror.c index e7356c06b..e9c76ff1f 100644 --- a/test/testerror.c +++ b/test/testerror.c @@ -36,10 +36,10 @@ ThreadFunc(void *data) SDL_SetError("Thread %s (%lu) had a problem: %s", (char *) data, SDL_ThreadID(), "nevermind"); while (alive) { - printf("Thread '%s' is alive!\n", (char *) data); + SDL_Log("Thread '%s' is alive!\n", (char *) data); SDL_Delay(1 * 1000); } - printf("Child thread error string: %s\n", SDL_GetError()); + SDL_Log("Child thread error string: %s\n", SDL_GetError()); return (0); } @@ -48,9 +48,12 @@ main(int argc, char *argv[]) { SDL_Thread *thread; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Load the SDL library */ if (SDL_Init(0) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } @@ -60,15 +63,15 @@ main(int argc, char *argv[]) alive = 1; thread = SDL_CreateThread(ThreadFunc, NULL, "#1"); if (thread == NULL) { - fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError()); quit(1); } SDL_Delay(5 * 1000); - printf("Waiting for thread #1\n"); + SDL_Log("Waiting for thread #1\n"); alive = 0; SDL_WaitThread(thread, NULL); - printf("Main thread error string: %s\n", SDL_GetError()); + SDL_Log("Main thread error string: %s\n", SDL_GetError()); SDL_Quit(); return (0); diff --git a/test/testfile.c b/test/testfile.c index d82d0eb7c..57ba02f58 100644 --- a/test/testfile.c +++ b/test/testfile.c @@ -12,7 +12,7 @@ /* sanity tests on SDL_rwops.c (usefull for alternative implementations of stdio rwops) */ -// quiet windows compiler warnings +/* quiet windows compiler warnings */ #define _CRT_NONSTDC_NO_WARNINGS #include @@ -44,7 +44,6 @@ static void cleanup(void) { - unlink(FBASENAME1); unlink(FBASENAME2); } @@ -52,8 +51,7 @@ cleanup(void) static void rwops_error_quit(unsigned line, SDL_RWops * rwops) { - - printf("testfile.c(%d): failed\n", line); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "testfile.c(%d): failed\n", line); if (rwops) { rwops->close(rwops); /* This calls SDL_FreeRW(rwops); */ } @@ -71,6 +69,9 @@ main(int argc, char *argv[]) SDL_RWops *rwops = NULL; char test_buf[30]; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + cleanup(); /* test 1 : basic argument test: all those calls to SDL_RWFromFile should fail */ @@ -90,7 +91,7 @@ main(int argc, char *argv[]) rwops = SDL_RWFromFile("something", NULL); if (rwops) RWOP_ERR_QUIT(rwops); - printf("test1 OK\n"); + SDL_Log("test1 OK\n"); /* test 2 : check that inexistent file is not successfully opened/created when required */ /* modes : r, r+ imply that file MUST exist @@ -123,7 +124,7 @@ main(int argc, char *argv[]) RWOP_ERR_QUIT(rwops); rwops->close(rwops); unlink(FBASENAME2); - printf("test2 OK\n"); + SDL_Log("test2 OK\n"); /* test 3 : creation, writing , reading, seeking, test : w mode, r mode, w+ mode @@ -201,7 +202,7 @@ main(int argc, char *argv[]) if (SDL_memcmp(test_buf, "12345678901234567890", 20)) RWOP_ERR_QUIT(rwops); rwops->close(rwops); - printf("test3 OK\n"); + SDL_Log("test3 OK\n"); /* test 4: same in r+ mode */ rwops = SDL_RWFromFile(FBASENAME1, "rb+"); /* write + read + file must exists, no truncation */ @@ -236,7 +237,7 @@ main(int argc, char *argv[]) if (SDL_memcmp(test_buf, "12345678901234567890", 20)) RWOP_ERR_QUIT(rwops); rwops->close(rwops); - printf("test4 OK\n"); + SDL_Log("test4 OK\n"); /* test5 : append mode */ rwops = SDL_RWFromFile(FBASENAME1, "ab+"); /* write + read + append */ @@ -277,7 +278,7 @@ main(int argc, char *argv[]) if (SDL_memcmp(test_buf, "123456789012345678901234567123", 30)) RWOP_ERR_QUIT(rwops); rwops->close(rwops); - printf("test5 OK\n"); + SDL_Log("test5 OK\n"); cleanup(); return 0; /* all ok */ } diff --git a/test/testfilesystem.c b/test/testfilesystem.c new file mode 100644 index 000000000..e1f251371 --- /dev/null +++ b/test/testfilesystem.c @@ -0,0 +1,33 @@ +/* + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ +/* Simple test of power subsystem. */ + +#include +#include "SDL.h" + +int +main(int argc, char *argv[]) +{ + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + + if (SDL_Init(0) == -1) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError()); + return 1; + } + + SDL_Log("base path: '%s'\n", SDL_GetBasePath()); + SDL_Log("pref path: '%s'\n", SDL_GetPrefPath("libsdl", "testfilesystem")); + + SDL_Quit(); + return 0; +} diff --git a/test/testgamecontroller.c b/test/testgamecontroller.c index cd18aa5cc..cbdf8c3b1 100644 --- a/test/testgamecontroller.c +++ b/test/testgamecontroller.c @@ -91,7 +91,7 @@ WatchGameController(SDL_GameController * gamecontroller) const char *name = SDL_GameControllerName(gamecontroller); const char *basetitle = "Game Controller Test: "; const size_t titlelen = SDL_strlen(basetitle) + SDL_strlen(name) + 1; - char *title = SDL_malloc(titlelen); + char *title = (char *)SDL_malloc(titlelen); SDL_Window *window = NULL; SDL_Renderer *screen = NULL; int done = 0; @@ -107,13 +107,13 @@ WatchGameController(SDL_GameController * gamecontroller) SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, SCREEN_HEIGHT, 0); if (window == NULL) { - fprintf(stderr, "Couldn't create window: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError()); return; } screen = SDL_CreateRenderer(window, -1, 0); if (screen == NULL) { - fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); SDL_DestroyWindow(window); return; } @@ -124,7 +124,7 @@ WatchGameController(SDL_GameController * gamecontroller) SDL_RaiseWindow(window); /* Print info about the controller we are watching */ - printf("Watching controller %s\n", name ? name : "Unknown Controller"); + SDL_Log("Watching controller %s\n", name ? name : "Unknown Controller"); /* Loop, getting controller events! */ while (!done) { @@ -135,21 +135,21 @@ WatchGameController(SDL_GameController * gamecontroller) while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_CONTROLLERAXISMOTION: - printf("Controller %d axis %d ('%s') value: %d\n", + SDL_Log("Controller %d axis %d ('%s') value: %d\n", event.caxis.which, event.caxis.axis, - ControllerAxisName(event.caxis.axis), + ControllerAxisName((SDL_GameControllerAxis)event.caxis.axis), event.caxis.value); break; case SDL_CONTROLLERBUTTONDOWN: - printf("Controller %d button %d ('%s') down\n", + SDL_Log("Controller %d button %d ('%s') down\n", event.cbutton.which, event.cbutton.button, - ControllerButtonName(event.cbutton.button)); + ControllerButtonName((SDL_GameControllerButton)event.cbutton.button)); break; case SDL_CONTROLLERBUTTONUP: - printf("Controller %d button %d ('%s') up\n", + SDL_Log("Controller %d button %d ('%s') up\n", event.cbutton.which, event.cbutton.button, - ControllerButtonName(event.cbutton.button)); + ControllerButtonName((SDL_GameControllerButton)event.cbutton.button)); break; case SDL_KEYDOWN: if (event.key.keysym.sym != SDLK_ESCAPE) { @@ -167,7 +167,7 @@ WatchGameController(SDL_GameController * gamecontroller) /* Update visual controller state */ SDL_SetRenderDrawColor(screen, 0x00, 0xFF, 0x00, SDL_ALPHA_OPAQUE); for (i = 0; i (SCREEN_WIDTH - 16)) { x = SCREEN_WIDTH - 16; } - y = (((int) SDL_GameControllerGetAxis(gamecontroller, i * 2 + 1)) + 32768); + y = (((int) SDL_GameControllerGetAxis(gamecontroller, (SDL_GameControllerAxis)(i * 2 + 1))) + 32768); y *= SCREEN_HEIGHT; y /= 65535; if (y < 0) { @@ -217,16 +217,19 @@ main(int argc, char *argv[]) char guid[64]; SDL_GameController *gamecontroller; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Initialize SDL (Note: video is required to start event loop) */ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER ) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return 1; } /* Print information about the controller */ for (i = 0; i < SDL_NumJoysticks(); ++i) { const char *name; - const char *description = "Joystick (not recognized as game controller)"; + const char *description; SDL_JoystickGetGUIDString(SDL_JoystickGetDeviceGUID(i), guid, sizeof (guid)); @@ -235,25 +238,27 @@ main(int argc, char *argv[]) { nController++; name = SDL_GameControllerNameForIndex(i); + description = "Controller"; } else { name = SDL_JoystickNameForIndex(i); + description = "Joystick"; } - printf("%s %d: %s (guid %s)\n", description, i, name ? name : "Unknown", guid); + SDL_Log("%s %d: %s (guid %s)\n", description, i, name ? name : "Unknown", guid); } - printf("There are %d game controller(s) attached (%d joystick(s))\n", nController, SDL_NumJoysticks()); + SDL_Log("There are %d game controller(s) attached (%d joystick(s))\n", nController, SDL_NumJoysticks()); if (argv[1]) { int device = atoi(argv[1]); if (device >= SDL_NumJoysticks()) { - printf("%i is an invalid joystick index.\n", device); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%i is an invalid joystick index.\n", device); retcode = 1; } else { SDL_JoystickGetGUIDString(SDL_JoystickGetDeviceGUID(device), guid, sizeof (guid)); - printf("Attempting to open device %i, guid %s\n", device, guid); + SDL_Log("Attempting to open device %i, guid %s\n", device, guid); gamecontroller = SDL_GameControllerOpen(device); if (gamecontroller == NULL) { - printf("Couldn't open joystick %d: %s\n", device, SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open joystick %d: %s\n", device, SDL_GetError()); retcode = 1; } else { WatchGameController(gamecontroller); @@ -272,7 +277,7 @@ main(int argc, char *argv[]) int main(int argc, char *argv[]) { - fprintf(stderr, "SDL compiled without Joystick support.\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Joystick support.\n"); exit(1); } diff --git a/test/testgesture.c b/test/testgesture.c index e2a9694ae..016506e11 100644 --- a/test/testgesture.c +++ b/test/testgesture.c @@ -49,7 +49,7 @@ #define BPP 4 #define DEPTH 32 -//MUST BE A POWER OF 2! +/* MUST BE A POWER OF 2! */ #define EVENT_BUF_SIZE 256 @@ -102,9 +102,9 @@ void setpix(SDL_Surface *screen, float _x, float _y, unsigned int col) SDL_memcpy(&colour,pixmem32,screen->format->BytesPerPixel); SDL_GetRGB(colour,screen->format,&r,&g,&b); - //r = 0;g = 0; b = 0; + /* r = 0;g = 0; b = 0; */ a = (float)((col>>24)&0xFF); - if(a == 0) a = 0xFF; //Hack, to make things easier. + if(a == 0) a = 0xFF; /* Hack, to make things easier. */ a /= 0xFF; r = (Uint8)(r*(1-a) + ((col>>16)&0xFF)*(a)); g = (Uint8)(g*(1-a) + ((col>> 8)&0xFF)*(a)); @@ -127,7 +127,7 @@ void drawCircle(SDL_Surface* screen,float x,float y,float r,unsigned int c) float xr; for(ty = (float)-SDL_fabs(r);ty <= (float)SDL_fabs((int)r);ty++) { xr = (float)sqrt(r*r - ty*ty); - if(r > 0) { //r > 0 ==> filled circle + if(r > 0) { /* r > 0 ==> filled circle */ for(tx=-xr+.5f;tx<=xr-.5;tx++) { setpix(screen,x+tx,y+ty,c); } @@ -157,7 +157,7 @@ void DrawScreen(SDL_Surface* screen) setpix(screen,(float)x,(float)y,((x%255)<<16) + ((y%255)<<8) + (x+y)%255); #endif - //draw Touch History + /* draw Touch History */ for(i = eventWrite; i < eventWrite+EVENT_BUF_SIZE; ++i) { const SDL_Event *event = &events[i&(EVENT_BUF_SIZE-1)]; float age = (float)(i - eventWrite) / EVENT_BUF_SIZE; @@ -170,7 +170,7 @@ void DrawScreen(SDL_Surface* screen) x = event->tfinger.x; y = event->tfinger.y; - //draw the touch: + /* draw the touch: */ c = colors[event->tfinger.fingerId%7]; col = ((unsigned int)(c*(.1+.85))) | (unsigned int)(0xFF*age)<<24; @@ -207,7 +207,10 @@ int main(int argc, char* argv[]) SDL_bool quitting = SDL_FALSE; SDL_RWops *src; - //gesture variables + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + + /* gesture variables */ knob.r = .1f; knob.ang = 0; @@ -222,7 +225,7 @@ int main(int argc, char* argv[]) while(!quitting) { while(SDL_PollEvent(&event)) { - //Record _all_ events + /* Record _all_ events */ events[eventWrite & (EVENT_BUF_SIZE-1)] = event; eventWrite++; diff --git a/test/testgl2.c b/test/testgl2.c index eb1a245e3..19685eae1 100644 --- a/test/testgl2.c +++ b/test/testgl2.c @@ -180,6 +180,10 @@ main(int argc, char *argv[]) SDL_Event event; Uint32 then, now, frames; int status; + int dw, dh; + + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); /* Initialize parameters */ fsaa = 0; @@ -206,7 +210,7 @@ main(int argc, char *argv[]) } } if (consumed < 0) { - fprintf(stderr, "Usage: %s %s [--fsaa n] [--accel n]\n", argv[0], + SDL_Log("Usage: %s %s [--fsaa n] [--accel n]\n", argv[0], SDLTest_CommonUsage(state)); quit(1); } @@ -235,7 +239,7 @@ main(int argc, char *argv[]) /* Create OpenGL context */ context = SDL_GL_CreateContext(state->windows[0]); if (!context) { - fprintf(stderr, "SDL_GL_CreateContext(): %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %s\n", SDL_GetError()); quit(2); } @@ -249,63 +253,67 @@ main(int argc, char *argv[]) } SDL_GetCurrentDisplayMode(0, &mode); - printf("Screen BPP : %d\n", SDL_BITSPERPIXEL(mode.format)); - printf("Swap Interval : %d\n", SDL_GL_GetSwapInterval()); - printf("\n"); - printf("Vendor : %s\n", glGetString(GL_VENDOR)); - printf("Renderer : %s\n", glGetString(GL_RENDERER)); - printf("Version : %s\n", glGetString(GL_VERSION)); - printf("Extensions : %s\n", glGetString(GL_EXTENSIONS)); - printf("\n"); + SDL_Log("Screen BPP : %d\n", SDL_BITSPERPIXEL(mode.format)); + SDL_Log("Swap Interval : %d\n", SDL_GL_GetSwapInterval()); + SDL_GetWindowSize(state->windows[0], &dw, &dh); + SDL_Log("Window Size : %d,%d\n", dw, dh); + SDL_GL_GetDrawableSize(state->windows[0], &dw, &dh); + SDL_Log("Draw Size : %d,%d\n", dw, dh); + SDL_Log("\n"); + SDL_Log("Vendor : %s\n", glGetString(GL_VENDOR)); + SDL_Log("Renderer : %s\n", glGetString(GL_RENDERER)); + SDL_Log("Version : %s\n", glGetString(GL_VERSION)); + SDL_Log("Extensions : %s\n", glGetString(GL_EXTENSIONS)); + SDL_Log("\n"); status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value); if (!status) { - printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value); + SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value); } else { - printf("Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value); if (!status) { - printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value); + SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value); } else { - printf("Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value); if (!status) { - printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value); + SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value); } else { - printf("Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value); if (!status) { - printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value); + SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value); } else { - printf("Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError()); } if (fsaa) { status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value); if (!status) { - printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); + SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); } else { - printf("Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value); if (!status) { - printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, + SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value); } else { - printf("Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", SDL_GetError()); } } if (accel >= 0) { status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); if (!status) { - printf("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel, + SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel, value); } else { - printf("Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", SDL_GetError()); } } @@ -319,7 +327,7 @@ main(int argc, char *argv[]) glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); glShadeModel(GL_SMOOTH); - + /* Main render loop */ frames = 0; then = SDL_GetTicks(); @@ -332,8 +340,10 @@ main(int argc, char *argv[]) } for (i = 0; i < state->num_windows; ++i) { int w, h; + if (state->windows[i] == NULL) + continue; SDL_GL_MakeCurrent(state->windows[i], context); - SDL_GetWindowSize(state->windows[i], &w, &h); + SDL_GL_GetDrawableSize(state->windows[i], &w, &h); glViewport(0, 0, w, h); Render(); SDL_GL_SwapWindow(state->windows[i]); @@ -343,7 +353,7 @@ main(int argc, char *argv[]) /* Print out some timing information */ now = SDL_GetTicks(); if (now > then) { - printf("%2.2f frames per second\n", + SDL_Log("%2.2f frames per second\n", ((double) frames * 1000) / (now - then)); } quit(0); @@ -355,7 +365,7 @@ main(int argc, char *argv[]) int main(int argc, char *argv[]) { - printf("No OpenGL support on this system\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL support on this system\n"); return 1; } diff --git a/test/testgles.c b/test/testgles.c index 41312a8bb..4e1bc074c 100644 --- a/test/testgles.c +++ b/test/testgles.c @@ -110,6 +110,9 @@ main(int argc, char *argv[]) Uint32 then, now, frames; int status; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Initialize parameters */ fsaa = 0; accel = 0; @@ -143,7 +146,7 @@ main(int argc, char *argv[]) } } if (consumed < 0) { - fprintf(stderr, "Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0], + SDL_Log("Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0], SDLTest_CommonUsage(state)); quit(1); } @@ -156,6 +159,9 @@ main(int argc, char *argv[]) state->gl_green_size = 5; state->gl_blue_size = 5; state->gl_depth_size = depth; + state->gl_major_version = 1; + state->gl_minor_version = 1; + state->gl_profile_mask = SDL_GL_CONTEXT_PROFILE_ES; if (fsaa) { state->gl_multisamplebuffers=1; state->gl_multisamplesamples=fsaa; @@ -169,7 +175,7 @@ main(int argc, char *argv[]) context = SDL_calloc(state->num_windows, sizeof(context)); if (context == NULL) { - fprintf(stderr, "Out of memory!\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); quit(2); } @@ -177,7 +183,7 @@ main(int argc, char *argv[]) for (i = 0; i < state->num_windows; i++) { context[i] = SDL_GL_CreateContext(state->windows[i]); if (!context[i]) { - fprintf(stderr, "SDL_GL_CreateContext(): %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %s\n", SDL_GetError()); quit(2); } } @@ -189,65 +195,65 @@ main(int argc, char *argv[]) } SDL_GetCurrentDisplayMode(0, &mode); - printf("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format)); - printf("\n"); - printf("Vendor : %s\n", glGetString(GL_VENDOR)); - printf("Renderer : %s\n", glGetString(GL_RENDERER)); - printf("Version : %s\n", glGetString(GL_VERSION)); - printf("Extensions : %s\n", glGetString(GL_EXTENSIONS)); - printf("\n"); + SDL_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format)); + SDL_Log("\n"); + SDL_Log("Vendor : %s\n", glGetString(GL_VENDOR)); + SDL_Log("Renderer : %s\n", glGetString(GL_RENDERER)); + SDL_Log("Version : %s\n", glGetString(GL_VERSION)); + SDL_Log("Extensions : %s\n", glGetString(GL_EXTENSIONS)); + SDL_Log("\n"); status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value); if (!status) { - printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value); + SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value); } else { - fprintf(stderr, "Failed to get SDL_GL_RED_SIZE: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value); if (!status) { - printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value); + SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value); } else { - fprintf(stderr, "Failed to get SDL_GL_GREEN_SIZE: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value); if (!status) { - printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value); + SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value); } else { - fprintf(stderr, "Failed to get SDL_GL_BLUE_SIZE: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value); if (!status) { - printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value); + SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value); } else { - fprintf(stderr, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError()); } if (fsaa) { status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value); if (!status) { - printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); + SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); } else { - fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value); if (!status) { - printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, + SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value); } else { - fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", SDL_GetError()); } } if (accel) { status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); if (!status) { - printf("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value); + SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value); } else { - fprintf(stderr, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", SDL_GetError()); } } @@ -258,7 +264,7 @@ main(int argc, char *argv[]) status = SDL_GL_MakeCurrent(state->windows[i], context[i]); if (status) { - printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); + SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); /* Continue for next window */ continue; @@ -292,7 +298,7 @@ main(int argc, char *argv[]) if (event.window.windowID == SDL_GetWindowID(state->windows[i])) { status = SDL_GL_MakeCurrent(state->windows[i], context[i]); if (status) { - printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); + SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); break; } /* Change view port to the new window dimensions */ @@ -309,9 +315,11 @@ main(int argc, char *argv[]) SDLTest_CommonEvent(state, &event, &done); } for (i = 0; i < state->num_windows; ++i) { + if (state->windows[i] == NULL) + continue; status = SDL_GL_MakeCurrent(state->windows[i], context[i]); if (status) { - printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); + SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); /* Continue for next window */ continue; @@ -324,7 +332,7 @@ main(int argc, char *argv[]) /* Print out some timing information */ now = SDL_GetTicks(); if (now > then) { - printf("%2.2f frames per second\n", + SDL_Log("%2.2f frames per second\n", ((double) frames * 1000) / (now - then)); } quit(0); @@ -336,7 +344,7 @@ main(int argc, char *argv[]) int main(int argc, char *argv[]) { - printf("No OpenGL ES support on this system\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL ES support on this system\n"); return 1; } diff --git a/test/testhaptic.c b/test/testhaptic.c index 13dd19d67..1e9dd3bdb 100644 --- a/test/testhaptic.c +++ b/test/testhaptic.c @@ -26,7 +26,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * includes */ #include -#include /* printf */ #include /* strstr */ #include /* isdigit */ @@ -62,12 +61,15 @@ main(int argc, char **argv) int nefx; unsigned int supported; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + name = NULL; index = -1; if (argc > 1) { name = argv[1]; if ((strcmp(name, "--help") == 0) || (strcmp(name, "-h") == 0)) { - printf("USAGE: %s [device]\n" + SDL_Log("USAGE: %s [device]\n" "If device is a two-digit number it'll use it as an index, otherwise\n" "it'll use it as if it were part of the device's name.\n", argv[0]); @@ -84,7 +86,7 @@ main(int argc, char **argv) /* Initialize the force feedbackness */ SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC); - printf("%d Haptic devices detected.\n", SDL_NumHaptics()); + SDL_Log("%d Haptic devices detected.\n", SDL_NumHaptics()); if (SDL_NumHaptics() > 0) { /* We'll just use index or the first force feedback device found */ if (name == NULL) { @@ -98,7 +100,7 @@ main(int argc, char **argv) } if (i >= SDL_NumHaptics()) { - printf("Unable to find device matching '%s', aborting.\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to find device matching '%s', aborting.\n", name); return 1; } @@ -106,14 +108,14 @@ main(int argc, char **argv) haptic = SDL_HapticOpen(i); if (haptic == NULL) { - printf("Unable to create the haptic device: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s\n", SDL_GetError()); return 1; } - printf("Device: %s\n", SDL_HapticName(i)); + SDL_Log("Device: %s\n", SDL_HapticName(i)); HapticPrintSupported(haptic); } else { - printf("No Haptic devices found!\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No Haptic devices found!\n"); return 1; } @@ -125,10 +127,10 @@ main(int argc, char **argv) nefx = 0; supported = SDL_HapticQuery(haptic); - printf("\nUploading effects\n"); + SDL_Log("\nUploading effects\n"); /* First we'll try a SINE effect. */ if (supported & SDL_HAPTIC_SINE) { - printf(" effect %d: Sine Wave\n", nefx); + SDL_Log(" effect %d: Sine Wave\n", nefx); efx[nefx].type = SDL_HAPTIC_SINE; efx[nefx].periodic.period = 1000; efx[nefx].periodic.magnitude = 0x4000; @@ -137,14 +139,14 @@ main(int argc, char **argv) efx[nefx].periodic.fade_length = 1000; id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); if (id[nefx] < 0) { - printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); abort_execution(); } nefx++; } /* Now we'll try a SAWTOOTHUP */ if (supported & SDL_HAPTIC_SAWTOOTHUP) { - printf(" effect %d: Sawtooth Up\n", nefx); + SDL_Log(" effect %d: Sawtooth Up\n", nefx); efx[nefx].type = SDL_HAPTIC_SAWTOOTHUP; efx[nefx].periodic.period = 500; efx[nefx].periodic.magnitude = 0x5000; @@ -153,14 +155,14 @@ main(int argc, char **argv) efx[nefx].periodic.fade_length = 1000; id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); if (id[nefx] < 0) { - printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); abort_execution(); } nefx++; } /* Now the classical constant effect. */ if (supported & SDL_HAPTIC_CONSTANT) { - printf(" effect %d: Constant Force\n", nefx); + SDL_Log(" effect %d: Constant Force\n", nefx); efx[nefx].type = SDL_HAPTIC_CONSTANT; efx[nefx].constant.direction.type = SDL_HAPTIC_POLAR; efx[nefx].constant.direction.dir[0] = 20000; /* Force comes from the south-west. */ @@ -170,14 +172,14 @@ main(int argc, char **argv) efx[nefx].constant.fade_length = 1000; id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); if (id[nefx] < 0) { - printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); abort_execution(); } nefx++; } /* The cute spring effect. */ if (supported & SDL_HAPTIC_SPRING) { - printf(" effect %d: Condition Spring\n", nefx); + SDL_Log(" effect %d: Condition Spring\n", nefx); efx[nefx].type = SDL_HAPTIC_SPRING; efx[nefx].condition.length = 5000; for (i = 0; i < SDL_HapticNumAxes(haptic); i++) { @@ -189,14 +191,14 @@ main(int argc, char **argv) } id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); if (id[nefx] < 0) { - printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); abort_execution(); } nefx++; } /* The pretty awesome inertia effect. */ if (supported & SDL_HAPTIC_INERTIA) { - printf(" effect %d: Condition Inertia\n", nefx); + SDL_Log(" effect %d: Condition Inertia\n", nefx); efx[nefx].type = SDL_HAPTIC_SPRING; efx[nefx].condition.length = 5000; for (i = 0; i < SDL_HapticNumAxes(haptic); i++) { @@ -207,7 +209,7 @@ main(int argc, char **argv) } id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); if (id[nefx] < 0) { - printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); abort_execution(); } nefx++; @@ -215,24 +217,24 @@ main(int argc, char **argv) /* Finally we'll try a left/right effect. */ if (supported & SDL_HAPTIC_LEFTRIGHT) { - printf(" effect %d: Left/Right\n", nefx); + SDL_Log(" effect %d: Left/Right\n", nefx); efx[nefx].type = SDL_HAPTIC_LEFTRIGHT; efx[nefx].leftright.length = 5000; efx[nefx].leftright.large_magnitude = 0x3000; efx[nefx].leftright.small_magnitude = 0xFFFF; id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); if (id[nefx] < 0) { - printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); abort_execution(); } nefx++; } - printf + SDL_Log ("\nNow playing effects for 5 seconds each with 1 second delay between\n"); for (i = 0; i < nefx; i++) { - printf(" Playing effect %d\n", i); + SDL_Log(" Playing effect %d\n", i); SDL_HapticRunEffect(haptic, id[i], 1); SDL_Delay(6000); /* Effects only have length 5000 */ } @@ -252,7 +254,7 @@ main(int argc, char **argv) static void abort_execution(void) { - printf("\nAborting program execution.\n"); + SDL_Log("\nAborting program execution.\n"); SDL_HapticClose(haptic); SDL_Quit(); @@ -270,42 +272,42 @@ HapticPrintSupported(SDL_Haptic * haptic) unsigned int supported; supported = SDL_HapticQuery(haptic); - printf(" Supported effects [%d effects, %d playing]:\n", + SDL_Log(" Supported effects [%d effects, %d playing]:\n", SDL_HapticNumEffects(haptic), SDL_HapticNumEffectsPlaying(haptic)); if (supported & SDL_HAPTIC_CONSTANT) - printf(" constant\n"); + SDL_Log(" constant\n"); if (supported & SDL_HAPTIC_SINE) - printf(" sine\n"); + SDL_Log(" sine\n"); /* !!! FIXME: put this back when we have more bits in 2.1 */ - /*if (supported & SDL_HAPTIC_SQUARE) - printf(" square\n");*/ + /* if (supported & SDL_HAPTIC_SQUARE) + SDL_Log(" square\n"); */ if (supported & SDL_HAPTIC_TRIANGLE) - printf(" triangle\n"); + SDL_Log(" triangle\n"); if (supported & SDL_HAPTIC_SAWTOOTHUP) - printf(" sawtoothup\n"); + SDL_Log(" sawtoothup\n"); if (supported & SDL_HAPTIC_SAWTOOTHDOWN) - printf(" sawtoothdown\n"); + SDL_Log(" sawtoothdown\n"); if (supported & SDL_HAPTIC_RAMP) - printf(" ramp\n"); + SDL_Log(" ramp\n"); if (supported & SDL_HAPTIC_FRICTION) - printf(" friction\n"); + SDL_Log(" friction\n"); if (supported & SDL_HAPTIC_SPRING) - printf(" spring\n"); + SDL_Log(" spring\n"); if (supported & SDL_HAPTIC_DAMPER) - printf(" damper\n"); + SDL_Log(" damper\n"); if (supported & SDL_HAPTIC_INERTIA) - printf(" intertia\n"); + SDL_Log(" inertia\n"); if (supported & SDL_HAPTIC_CUSTOM) - printf(" custom\n"); + SDL_Log(" custom\n"); if (supported & SDL_HAPTIC_LEFTRIGHT) - printf(" left/right\n"); - printf(" Supported capabilities:\n"); + SDL_Log(" left/right\n"); + SDL_Log(" Supported capabilities:\n"); if (supported & SDL_HAPTIC_GAIN) - printf(" gain\n"); + SDL_Log(" gain\n"); if (supported & SDL_HAPTIC_AUTOCENTER) - printf(" autocenter\n"); + SDL_Log(" autocenter\n"); if (supported & SDL_HAPTIC_STATUS) - printf(" status\n"); + SDL_Log(" status\n"); } #else @@ -313,7 +315,7 @@ HapticPrintSupported(SDL_Haptic * haptic) int main(int argc, char *argv[]) { - fprintf(stderr, "SDL compiled without Haptic support.\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Haptic support.\n"); exit(1); } diff --git a/test/testiconv.c b/test/testiconv.c index d2081995d..3165b3426 100644 --- a/test/testiconv.c +++ b/test/testiconv.c @@ -49,12 +49,15 @@ main(int argc, char *argv[]) FILE *file; int errors = 0; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + if (!argv[1]) { argv[1] = "utf8.txt"; } file = fopen(argv[1], "rb"); if (!file) { - fprintf(stderr, "Unable to open %s\n", argv[1]); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to open %s\n", argv[1]); return (1); } @@ -69,15 +72,11 @@ main(int argc, char *argv[]) test[0] = SDL_iconv_string(formats[i], "UCS-4", ucs4, len); test[1] = SDL_iconv_string("UCS-4", formats[i], test[0], len); if (!test[1] || SDL_memcmp(test[1], ucs4, len) != 0) { - fprintf(stderr, "FAIL: %s\n", formats[i]); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "FAIL: %s\n", formats[i]); ++errors; } - if (test[0]) { - SDL_free(test[0]); - } - if (test[1]) { - SDL_free(test[1]); - } + SDL_free(test[0]); + SDL_free(test[1]); } test[0] = SDL_iconv_string("UTF-8", "UCS-4", ucs4, len); SDL_free(ucs4); diff --git a/test/testime.c b/test/testime.c index ce9f02b1f..3d9789ad6 100644 --- a/test/testime.c +++ b/test/testime.c @@ -80,7 +80,7 @@ char *utf8_advance(char *p, size_t distance) void usage() { - printf("usage: testime [--font fontfile]\n"); + SDL_Log("usage: testime [--font fontfile]\n"); exit(0); } @@ -135,7 +135,7 @@ void _Redraw(SDL_Renderer * renderer) { markedRect.w = textRect.w - w; if (markedRect.w < 0) { - // Stop text input because we cannot hold any more characters + /* Stop text input because we cannot hold any more characters */ SDL_StopTextInput(); return; } @@ -196,6 +196,8 @@ void Redraw() { int i; for (i = 0; i < state->num_windows; ++i) { SDL_Renderer *renderer = state->renderers[i]; + if (state->windows[i] == NULL) + continue; SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0); SDL_RenderClear(renderer); @@ -210,6 +212,9 @@ int main(int argc, char *argv[]) { SDL_Event event; const char *fontname = DEFAULT_FONT; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); if (!state) { @@ -251,12 +256,12 @@ int main(int argc, char *argv[]) { font = TTF_OpenFont(fontname, DEFAULT_PTSIZE); if (! font) { - fprintf(stderr, "Failed to find font: %s\n", TTF_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to find font: %s\n", TTF_GetError()); exit(-1); } #endif - printf("Using font: %s\n", fontname); + SDL_Log("Using font: %s\n", fontname); atexit(SDL_Quit); InitInput(); @@ -321,33 +326,32 @@ int main(int argc, char *argv[]) { break; } - fprintf(stderr, - "Keyboard: scancode 0x%08X = %s, keycode 0x%08X = %s\n", + SDL_Log("Keyboard: scancode 0x%08X = %s, keycode 0x%08X = %s\n", event.key.keysym.scancode, SDL_GetScancodeName(event.key.keysym.scancode), event.key.keysym.sym, SDL_GetKeyName(event.key.keysym.sym)); break; case SDL_TEXTINPUT: - if (SDL_strlen(event.text.text) == 0 || event.text.text[0] == '\n' || + if (event.text.text[0] == '\0' || event.text.text[0] == '\n' || markedRect.w < 0) break; - fprintf(stderr, "Keyboard: text input \"%s\"\n", event.text.text); + SDL_Log("Keyboard: text input \"%s\"\n", event.text.text); if (SDL_strlen(text) + SDL_strlen(event.text.text) < sizeof(text)) SDL_strlcat(text, event.text.text, sizeof(text)); - fprintf(stderr, "text inputed: %s\n", text); + SDL_Log("text inputed: %s\n", text); - // After text inputed, we can clear up markedText because it - // is committed + /* After text inputed, we can clear up markedText because it */ + /* is committed */ markedText[0] = 0; Redraw(); break; case SDL_TEXTEDITING: - fprintf(stderr, "text editing \"%s\", selected range (%d, %d)\n", + SDL_Log("text editing \"%s\", selected range (%d, %d)\n", event.edit.text, event.edit.start, event.edit.length); strcpy(markedText, event.edit.text); diff --git a/test/testintersections.c b/test/testintersections.c index d858717e5..b4deeecd0 100644 --- a/test/testintersections.c +++ b/test/testintersections.c @@ -84,7 +84,7 @@ add_line(int x1, int y1, int x2, int y2) if ((x1 == x2) && (y1 == y2)) return 0; - printf("adding line (%d, %d), (%d, %d)\n", x1, y1, x2, y2); + SDL_Log("adding line (%d, %d), (%d, %d)\n", x1, y1, x2, y2); lines[num_lines].x = x1; lines[num_lines].y = y1; lines[num_lines].w = x2; @@ -133,7 +133,7 @@ add_rect(int x1, int y1, int x2, int y2) if (y1 > y2) SWAP(int, y1, y2); - printf("adding rect (%d, %d), (%d, %d) [%dx%d]\n", x1, y1, x2, y2, + SDL_Log("adding rect (%d, %d), (%d, %d) [%dx%d]\n", x1, y1, x2, y2, x2 - x1, y2 - y1); rects[num_rects].x = x1; @@ -199,6 +199,9 @@ main(int argc, char *argv[]) SDL_Event event; Uint32 then, now, frames; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Initialize parameters */ num_objects = NUM_OBJECTS; @@ -241,8 +244,7 @@ main(int argc, char *argv[]) } } if (consumed < 0) { - fprintf(stderr, - "Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n", + SDL_Log("Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n", argv[0], SDLTest_CommonUsage(state)); return 1; } @@ -308,6 +310,8 @@ main(int argc, char *argv[]) } for (i = 0; i < state->num_windows; ++i) { SDL_Renderer *renderer = state->renderers[i]; + if (state->windows[i] == NULL) + continue; SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); SDL_RenderClear(renderer); @@ -327,7 +331,7 @@ main(int argc, char *argv[]) now = SDL_GetTicks(); if (now > then) { double fps = ((double) frames * 1000) / (now - then); - printf("%2.2f frames per second\n", fps); + SDL_Log("%2.2f frames per second\n", fps); } return 0; } diff --git a/test/testjoystick.c b/test/testjoystick.c index da307ed29..7d3c573df 100644 --- a/test/testjoystick.c +++ b/test/testjoystick.c @@ -52,13 +52,13 @@ WatchJoystick(SDL_Joystick * joystick) SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, SCREEN_HEIGHT, 0); if (window == NULL) { - fprintf(stderr, "Couldn't create window: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError()); return SDL_FALSE; } screen = SDL_CreateRenderer(window, -1, 0); if (screen == NULL) { - fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); SDL_DestroyWindow(window); return SDL_FALSE; } @@ -70,9 +70,9 @@ WatchJoystick(SDL_Joystick * joystick) /* Print info about the joystick we are watching */ name = SDL_JoystickName(joystick); - printf("Watching joystick %d: (%s)\n", SDL_JoystickInstanceID(joystick), + SDL_Log("Watching joystick %d: (%s)\n", SDL_JoystickInstanceID(joystick), name ? name : "Unknown Joystick"); - printf("Joystick has %d axes, %d hats, %d balls, and %d buttons\n", + SDL_Log("Joystick has %d axes, %d hats, %d balls, and %d buttons\n", SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick), SDL_JoystickNumBalls(joystick), SDL_JoystickNumButtons(joystick)); @@ -85,36 +85,36 @@ WatchJoystick(SDL_Joystick * joystick) while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_JOYAXISMOTION: - printf("Joystick %d axis %d value: %d\n", + SDL_Log("Joystick %d axis %d value: %d\n", event.jaxis.which, event.jaxis.axis, event.jaxis.value); break; case SDL_JOYHATMOTION: - printf("Joystick %d hat %d value:", + SDL_Log("Joystick %d hat %d value:", event.jhat.which, event.jhat.hat); if (event.jhat.value == SDL_HAT_CENTERED) - printf(" centered"); + SDL_Log(" centered"); if (event.jhat.value & SDL_HAT_UP) - printf(" up"); + SDL_Log(" up"); if (event.jhat.value & SDL_HAT_RIGHT) - printf(" right"); + SDL_Log(" right"); if (event.jhat.value & SDL_HAT_DOWN) - printf(" down"); + SDL_Log(" down"); if (event.jhat.value & SDL_HAT_LEFT) - printf(" left"); - printf("\n"); + SDL_Log(" left"); + SDL_Log("\n"); break; case SDL_JOYBALLMOTION: - printf("Joystick %d ball %d delta: (%d,%d)\n", + SDL_Log("Joystick %d ball %d delta: (%d,%d)\n", event.jball.which, event.jball.ball, event.jball.xrel, event.jball.yrel); break; case SDL_JOYBUTTONDOWN: - printf("Joystick %d button %d down\n", + SDL_Log("Joystick %d button %d down\n", event.jbutton.which, event.jbutton.button); break; case SDL_JOYBUTTONUP: - printf("Joystick %d button %d up\n", + SDL_Log("Joystick %d button %d up\n", event.jbutton.which, event.jbutton.button); break; case SDL_KEYDOWN: @@ -211,31 +211,34 @@ main(int argc, char *argv[]) int i; SDL_Joystick *joystick; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Initialize SDL (Note: video is required to start event loop) */ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); exit(1); } /* Print information about the joysticks */ - printf("There are %d joysticks attached\n", SDL_NumJoysticks()); + SDL_Log("There are %d joysticks attached\n", SDL_NumJoysticks()); for (i = 0; i < SDL_NumJoysticks(); ++i) { name = SDL_JoystickNameForIndex(i); - printf("Joystick %d: %s\n", i, name ? name : "Unknown Joystick"); + SDL_Log("Joystick %d: %s\n", i, name ? name : "Unknown Joystick"); joystick = SDL_JoystickOpen(i); if (joystick == NULL) { - fprintf(stderr, "SDL_JoystickOpen(%d) failed: %s\n", i, + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_JoystickOpen(%d) failed: %s\n", i, SDL_GetError()); } else { char guid[64]; SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick), guid, sizeof (guid)); - printf(" axes: %d\n", SDL_JoystickNumAxes(joystick)); - printf(" balls: %d\n", SDL_JoystickNumBalls(joystick)); - printf(" hats: %d\n", SDL_JoystickNumHats(joystick)); - printf(" buttons: %d\n", SDL_JoystickNumButtons(joystick)); - printf("instance id: %d\n", SDL_JoystickInstanceID(joystick)); - printf(" guid: %s\n", guid); + SDL_Log(" axes: %d\n", SDL_JoystickNumAxes(joystick)); + SDL_Log(" balls: %d\n", SDL_JoystickNumBalls(joystick)); + SDL_Log(" hats: %d\n", SDL_JoystickNumHats(joystick)); + SDL_Log(" buttons: %d\n", SDL_JoystickNumButtons(joystick)); + SDL_Log("instance id: %d\n", SDL_JoystickInstanceID(joystick)); + SDL_Log(" guid: %s\n", guid); SDL_JoystickClose(joystick); } } @@ -256,7 +259,7 @@ main(int argc, char *argv[]) while ( keepGoing ) { if (joystick == NULL) { if ( !reportederror ) { - printf("Couldn't open joystick %d: %s\n", atoi(argv[1]), SDL_GetError()); + SDL_Log("Couldn't open joystick %d: %s\n", atoi(argv[1]), SDL_GetError()); keepGoing = SDL_FALSE; reportederror = SDL_TRUE; } @@ -268,7 +271,7 @@ main(int argc, char *argv[]) joystick = NULL; if (keepGoing) { - printf("Waiting for attach\n"); + SDL_Log("Waiting for attach\n"); } while (keepGoing) { SDL_WaitEvent(&event); @@ -296,7 +299,7 @@ main(int argc, char *argv[]) int main(int argc, char *argv[]) { - fprintf(stderr, "SDL compiled without Joystick support.\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Joystick support.\n"); exit(1); } diff --git a/test/testkeys.c b/test/testkeys.c index 71f895602..f4a35aba6 100644 --- a/test/testkeys.c +++ b/test/testkeys.c @@ -24,12 +24,15 @@ main(int argc, char *argv[]) { SDL_Scancode scancode; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + if (SDL_Init(SDL_INIT_VIDEO) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); exit(1); } for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) { - printf("Scancode #%d, \"%s\"\n", scancode, + SDL_Log("Scancode #%d, \"%s\"\n", scancode, SDL_GetScancodeName(scancode)); } SDL_Quit(); diff --git a/test/testloadso.c b/test/testloadso.c index 4bf7bf654..946aafd20 100644 --- a/test/testloadso.c +++ b/test/testloadso.c @@ -33,14 +33,14 @@ main(int argc, char *argv[]) if (argc != 3) { const char *app = argv[0]; - fprintf(stderr, "USAGE: %s \n", app); - fprintf(stderr, " %s --hello \n", app); + SDL_Log("USAGE: %s \n", app); + SDL_Log(" %s --hello \n", app); return 1; } /* Initialize SDL */ if (SDL_Init(0) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return 2; } @@ -55,23 +55,23 @@ main(int argc, char *argv[]) lib = SDL_LoadObject(libname); if (lib == NULL) { - fprintf(stderr, "SDL_LoadObject('%s') failed: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadObject('%s') failed: %s\n", libname, SDL_GetError()); retval = 3; } else { fn = (fntype) SDL_LoadFunction(lib, symname); if (fn == NULL) { - fprintf(stderr, "SDL_LoadFunction('%s') failed: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadFunction('%s') failed: %s\n", symname, SDL_GetError()); retval = 4; } else { - printf("Found %s in %s at %p\n", symname, libname, fn); + SDL_Log("Found %s in %s at %p\n", symname, libname, fn); if (hello) { - printf("Calling function...\n"); + SDL_Log("Calling function...\n"); fflush(stdout); fn(" HELLO, WORLD!\n"); - printf("...apparently, we survived. :)\n"); - printf("Unloading library...\n"); + SDL_Log("...apparently, we survived. :)\n"); + SDL_Log("Unloading library...\n"); fflush(stdout); } } diff --git a/test/testlock.c b/test/testlock.c index fcfeb8bc8..0414fe316 100644 --- a/test/testlock.c +++ b/test/testlock.c @@ -40,7 +40,7 @@ SDL_Quit_Wrapper(void) void printid(void) { - printf("Process %lu: exiting\n", SDL_ThreadID()); + SDL_Log("Process %lu: exiting\n", SDL_ThreadID()); } void @@ -55,7 +55,7 @@ closemutex(int sig) { SDL_threadID id = SDL_ThreadID(); int i; - printf("Process %lu: Cleaning up...\n", id == mainthread ? 0 : id); + SDL_Log("Process %lu: Cleaning up...\n", id == mainthread ? 0 : id); doterminate = 1; for (i = 0; i < 6; ++i) SDL_WaitThread(threads[i], NULL); @@ -69,23 +69,23 @@ Run(void *data) if (SDL_ThreadID() == mainthread) signal(SIGTERM, closemutex); while (!doterminate) { - printf("Process %lu ready to work\n", SDL_ThreadID()); + SDL_Log("Process %lu ready to work\n", SDL_ThreadID()); if (SDL_LockMutex(mutex) < 0) { - fprintf(stderr, "Couldn't lock mutex: %s", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't lock mutex: %s", SDL_GetError()); exit(1); } - printf("Process %lu, working!\n", SDL_ThreadID()); + SDL_Log("Process %lu, working!\n", SDL_ThreadID()); SDL_Delay(1 * 1000); - printf("Process %lu, done!\n", SDL_ThreadID()); + SDL_Log("Process %lu, done!\n", SDL_ThreadID()); if (SDL_UnlockMutex(mutex) < 0) { - fprintf(stderr, "Couldn't unlock mutex: %s", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't unlock mutex: %s", SDL_GetError()); exit(1); } /* If this sleep isn't done, then threads may starve */ SDL_Delay(10); } if (SDL_ThreadID() == mainthread && doterminate) { - printf("Process %lu: raising SIGTERM\n", SDL_ThreadID()); + SDL_Log("Process %lu: raising SIGTERM\n", SDL_ThreadID()); raise(SIGTERM); } return (0); @@ -97,26 +97,29 @@ main(int argc, char *argv[]) int i; int maxproc = 6; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Load the SDL library */ if (SDL_Init(0) < 0) { - fprintf(stderr, "%s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError()); exit(1); } atexit(SDL_Quit_Wrapper); if ((mutex = SDL_CreateMutex()) == NULL) { - fprintf(stderr, "Couldn't create mutex: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create mutex: %s\n", SDL_GetError()); exit(1); } mainthread = SDL_ThreadID(); - printf("Main thread: %lu\n", mainthread); + SDL_Log("Main thread: %lu\n", mainthread); atexit(printid); for (i = 0; i < maxproc; ++i) { char name[64]; SDL_snprintf(name, sizeof (name), "Worker%d", i); if ((threads[i] = SDL_CreateThread(Run, name, NULL)) == NULL) - fprintf(stderr, "Couldn't create thread!\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread!\n"); } signal(SIGINT, terminate); Run(NULL); diff --git a/test/testmessage.c b/test/testmessage.c index f76b7ebac..254bd9b3d 100644 --- a/test/testmessage.c +++ b/test/testmessage.c @@ -10,7 +10,7 @@ freely. */ -/* Simple test of the SDL MessageBox API*/ +/* Simple test of the SDL MessageBox API */ #include #include @@ -46,12 +46,12 @@ button_messagebox(void *eventNumber) SDL_MessageBoxData data = { SDL_MESSAGEBOX_INFORMATION, - NULL, // no parent window + NULL, /* no parent window */ "Custom MessageBox", "This is a custom messagebox", 2, buttons, - NULL // Default color scheme + NULL /* Default color scheme */ }; int button = -1; @@ -62,7 +62,7 @@ button_messagebox(void *eventNumber) success = SDL_ShowMessageBox(&data, &button); if (success == -1) { - printf("Error Presenting MessageBox: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); if (eventNumber) { SDL_UserEvent event; event.type = (intptr_t)eventNumber; @@ -72,7 +72,7 @@ button_messagebox(void *eventNumber) quit(2); } } - printf("Pressed button: %d, %s\n", button, button == 1 ? "Cancel" : "OK"); + SDL_Log("Pressed button: %d, %s\n", button, button == 1 ? "Cancel" : "OK"); if (eventNumber) { SDL_UserEvent event; @@ -88,12 +88,15 @@ main(int argc, char *argv[]) { int success; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Simple MessageBox", "This is a simple error MessageBox", NULL); if (success == -1) { - printf("Error Presenting MessageBox: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); quit(1); } @@ -102,7 +105,7 @@ main(int argc, char *argv[]) "This is a simple MessageBox with a newline:\r\nHello world!", NULL); if (success == -1) { - printf("Error Presenting MessageBox: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); quit(1); } @@ -112,7 +115,7 @@ main(int argc, char *argv[]) "Unicode text: '牛肉西蘭花' ...", NULL); if (success == -1) { - printf("Error Presenting MessageBox: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); quit(1); } @@ -122,7 +125,7 @@ main(int argc, char *argv[]) "Unicode text and newline:\r\n'牛肉西蘭花'\n'牛肉西蘭花'", NULL); if (success == -1) { - printf("Error Presenting MessageBox: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); quit(1); } @@ -135,7 +138,7 @@ main(int argc, char *argv[]) subsystem on the main thread. */ if (SDL_Init(SDL_INIT_VIDEO) < 0) { - fprintf(stderr, "Couldn't initialize SDL video subsystem: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video subsystem: %s\n", SDL_GetError()); return (1); } { @@ -153,7 +156,7 @@ main(int argc, char *argv[]) SDL_WaitThread(thread, &status); - printf("Message box thread return %i\n", status); + SDL_Log("Message box thread return %i\n", status); } /* Test showing a message box with a parent window */ @@ -166,7 +169,7 @@ main(int argc, char *argv[]) "This is a simple error MessageBox with a parent window", window); if (success == -1) { - printf("Error Presenting MessageBox: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError()); quit(1); } diff --git a/test/testmultiaudio.c b/test/testmultiaudio.c index 47a95e344..48d628ae3 100644 --- a/test/testmultiaudio.c +++ b/test/testmultiaudio.c @@ -10,7 +10,6 @@ freely. */ #include "SDL.h" -#include static SDL_AudioSpec spec; static Uint8 *sound = NULL; /* Pointer to wave data */ @@ -51,7 +50,7 @@ test_multi_audio(int devcount) int i; if (devcount > 64) { - fprintf(stderr, "Too many devices (%d), clamping to 64...\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Too many devices (%d), clamping to 64...\n", devcount); devcount = 64; } @@ -60,33 +59,33 @@ test_multi_audio(int devcount) for (i = 0; i < devcount; i++) { const char *devname = SDL_GetAudioDeviceName(i, 0); - printf("playing on device #%d: ('%s')...", i, devname); + SDL_Log("playing on device #%d: ('%s')...", i, devname); fflush(stdout); SDL_memset(&cbd[0], '\0', sizeof(callback_data)); spec.userdata = &cbd[0]; cbd[0].dev = SDL_OpenAudioDevice(devname, 0, &spec, NULL, 0); if (cbd[0].dev == 0) { - printf("\nOpen device failed: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Open device failed: %s\n", SDL_GetError()); } else { SDL_PauseAudioDevice(cbd[0].dev, 0); while (!cbd[0].done) SDL_Delay(100); SDL_PauseAudioDevice(cbd[0].dev, 1); - printf("done.\n"); + SDL_Log("done.\n"); SDL_CloseAudioDevice(cbd[0].dev); } } SDL_memset(cbd, '\0', sizeof(cbd)); - printf("playing on all devices...\n"); + SDL_Log("playing on all devices...\n"); for (i = 0; i < devcount; i++) { const char *devname = SDL_GetAudioDeviceName(i, 0); spec.userdata = &cbd[i]; cbd[i].dev = SDL_OpenAudioDevice(devname, 0, &spec, NULL, 0); if (cbd[i].dev == 0) { - printf("Open device %d failed: %s\n", i, SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Open device %d failed: %s\n", i, SDL_GetError()); } } @@ -113,7 +112,7 @@ test_multi_audio(int devcount) } } - printf("All done!\n"); + SDL_Log("All done!\n"); } @@ -122,17 +121,20 @@ main(int argc, char **argv) { int devcount = 0; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Load the SDL library */ if (SDL_Init(SDL_INIT_AUDIO) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } - printf("Using audio driver: %s\n", SDL_GetCurrentAudioDriver()); + SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver()); devcount = SDL_GetNumAudioDevices(0); if (devcount < 1) { - fprintf(stderr, "Don't see any specific audio devices!\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Don't see any specific audio devices!\n"); } else { if (argv[1] == NULL) { argv[1] = "sample.wav"; @@ -140,7 +142,7 @@ main(int argc, char **argv) /* Load the wave file into memory */ if (SDL_LoadWAV(argv[1], &spec, &sound, &soundlen) == NULL) { - fprintf(stderr, "Couldn't load %s: %s\n", argv[1], + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", argv[1], SDL_GetError()); } else { test_multi_audio(devcount); diff --git a/test/testnative.c b/test/testnative.c index 63cba29c3..0ac99b2a3 100644 --- a/test/testnative.c +++ b/test/testnative.c @@ -58,7 +58,7 @@ LoadSprite(SDL_Renderer *renderer, char *file) /* Load the sprite image */ temp = SDL_LoadBMP(file); if (temp == NULL) { - fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError()); return 0; } @@ -70,7 +70,7 @@ LoadSprite(SDL_Renderer *renderer, char *file) /* Create textures from the image */ sprite = SDL_CreateTextureFromSurface(renderer, temp); if (!sprite) { - fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError()); SDL_FreeSurface(temp); return 0; } @@ -131,8 +131,11 @@ main(int argc, char *argv[]) int sprite_w, sprite_h; SDL_Event event; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + if (SDL_VideoInit(NULL) < 0) { - fprintf(stderr, "Couldn't initialize SDL video: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video: %s\n", SDL_GetError()); exit(1); } @@ -146,19 +149,19 @@ main(int argc, char *argv[]) } } if (!factory) { - fprintf(stderr, "Couldn't find native window code for %s driver\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find native window code for %s driver\n", driver); quit(2); } - printf("Creating native window for %s driver\n", driver); + SDL_Log("Creating native window for %s driver\n", driver); native_window = factory->CreateNativeWindow(WINDOW_W, WINDOW_H); if (!native_window) { - fprintf(stderr, "Couldn't create native window\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create native window\n"); quit(3); } window = SDL_CreateWindowFrom(native_window); if (!window) { - fprintf(stderr, "Couldn't create SDL window: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create SDL window: %s\n", SDL_GetError()); quit(4); } SDL_SetWindowTitle(window, "SDL Native Window Test"); @@ -166,7 +169,7 @@ main(int argc, char *argv[]) /* Create the renderer */ renderer = SDL_CreateRenderer(window, -1, 0); if (!renderer) { - fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); quit(5); } @@ -185,7 +188,7 @@ main(int argc, char *argv[]) positions = (SDL_Rect *) SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect)); velocities = (SDL_Rect *) SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect)); if (!positions || !velocities) { - fprintf(stderr, "Out of memory!\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); quit(2); } srand(time(NULL)); diff --git a/test/testoverlay2.c b/test/testoverlay2.c index e071614ad..4561f9845 100644 --- a/test/testoverlay2.c +++ b/test/testoverlay2.c @@ -209,19 +209,18 @@ ConvertRGBtoYV12(Uint8 *rgb, Uint8 *out, int w, int h, static void PrintUsage(char *argv0) { - fprintf(stderr, "Usage: %s [arg] [arg] [arg] ...\n", argv0); - fprintf(stderr, "\n"); - fprintf(stderr, "Where 'arg' is any of the following options:\n"); - fprintf(stderr, "\n"); - fprintf(stderr, " -fps \n"); - fprintf(stderr, " -nodelay\n"); - fprintf(stderr, " -format (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n"); - fprintf(stderr, " -scale (initial scale of the overlay)\n"); - fprintf(stderr, " -help (shows this help)\n"); - fprintf(stderr, "\n"); - fprintf(stderr, - "Press ESC to exit, or SPACE to freeze the movie while application running.\n"); - fprintf(stderr, "\n"); + SDL_Log("Usage: %s [arg] [arg] [arg] ...\n", argv0); + SDL_Log("\n"); + SDL_Log("Where 'arg' is any of the following options:\n"); + SDL_Log("\n"); + SDL_Log(" -fps \n"); + SDL_Log(" -nodelay\n"); + SDL_Log(" -format (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n"); + SDL_Log(" -scale (initial scale of the overlay)\n"); + SDL_Log(" -help (shows this help)\n"); + SDL_Log("\n"); + SDL_Log("Press ESC to exit, or SPACE to freeze the movie while application running.\n"); + SDL_Log("\n"); } int @@ -246,8 +245,11 @@ main(int argc, char **argv) int scale = 5; SDL_bool done = SDL_FALSE; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + if (SDL_Init(SDL_INIT_VIDEO) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return 3; } @@ -256,19 +258,19 @@ main(int argc, char **argv) if (argv[2]) { fps = atoi(argv[2]); if (fps == 0) { - fprintf(stderr, + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The -fps option requires an argument [from 1 to 1000], default is 12.\n"); quit(10); } if ((fps < 0) || (fps > 1000)) { - fprintf(stderr, + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The -fps option must be in range from 1 to 1000, default is 12.\n"); quit(10); } argv += 2; argc -= 2; } else { - fprintf(stderr, + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The -fps option requires an argument [from 1 to 1000], default is 12.\n"); quit(10); } @@ -280,19 +282,19 @@ main(int argc, char **argv) if (argv[2]) { scale = atoi(argv[2]); if (scale == 0) { - fprintf(stderr, + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The -scale option requires an argument [from 1 to 50], default is 5.\n"); quit(10); } if ((scale < 0) || (scale > 50)) { - fprintf(stderr, + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The -scale option must be in range from 1 to 50, default is 5.\n"); quit(10); } argv += 2; argc -= 2; } else { - fprintf(stderr, + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The -fps option requires an argument [from 1 to 1000], default is 12.\n"); quit(10); } @@ -301,7 +303,7 @@ main(int argc, char **argv) PrintUsage(argv[0]); quit(0); } else { - fprintf(stderr, "Unrecognized option: %s.\n", argv[1]); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unrecognized option: %s.\n", argv[1]); quit(10); } break; @@ -309,7 +311,7 @@ main(int argc, char **argv) RawMooseData = (Uint8 *) malloc(MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT); if (RawMooseData == NULL) { - fprintf(stderr, "Can't allocate memory for movie !\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't allocate memory for movie !\n"); free(RawMooseData); quit(1); } @@ -317,7 +319,7 @@ main(int argc, char **argv) /* load the trojan moose images */ handle = SDL_RWFromFile("moose.dat", "rb"); if (handle == NULL) { - fprintf(stderr, "Can't find the file moose.dat !\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n"); free(RawMooseData); quit(2); } @@ -335,26 +337,26 @@ main(int argc, char **argv) window_w, window_h, SDL_WINDOW_RESIZABLE); if (!window) { - fprintf(stderr, "Couldn't set create window: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError()); free(RawMooseData); quit(4); } renderer = SDL_CreateRenderer(window, -1, 0); if (!renderer) { - fprintf(stderr, "Couldn't set create renderer: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError()); free(RawMooseData); quit(4); } MooseTexture = SDL_CreateTexture(renderer, pixel_format, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H); if (!MooseTexture) { - fprintf(stderr, "Couldn't set create texture: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError()); free(RawMooseData); quit(5); } /* Uncomment this to check vertex color with a YUV texture */ - /*SDL_SetTextureColorMod(MooseTexture, 0xff, 0x80, 0x80);*/ + /* SDL_SetTextureColorMod(MooseTexture, 0xff, 0x80, 0x80); */ for (i = 0; i < MOOSEFRAMES_COUNT; i++) { Uint8 MooseFrameRGB[MOOSEFRAME_SIZE*3]; diff --git a/test/testplatform.c b/test/testplatform.c index 326b6f7e4..a8ed39dd2 100644 --- a/test/testplatform.c +++ b/test/testplatform.c @@ -35,30 +35,30 @@ TestTypes(SDL_bool verbose) if (badsize(sizeof(Uint8), 1)) { if (verbose) - printf("sizeof(Uint8) != 1, instead = %u\n", + SDL_Log("sizeof(Uint8) != 1, instead = %u\n", (unsigned int)sizeof(Uint8)); ++error; } if (badsize(sizeof(Uint16), 2)) { if (verbose) - printf("sizeof(Uint16) != 2, instead = %u\n", + SDL_Log("sizeof(Uint16) != 2, instead = %u\n", (unsigned int)sizeof(Uint16)); ++error; } if (badsize(sizeof(Uint32), 4)) { if (verbose) - printf("sizeof(Uint32) != 4, instead = %u\n", + SDL_Log("sizeof(Uint32) != 4, instead = %u\n", (unsigned int)sizeof(Uint32)); ++error; } if (badsize(sizeof(Uint64), 8)) { if (verbose) - printf("sizeof(Uint64) != 8, instead = %u\n", + SDL_Log("sizeof(Uint64) != 8, instead = %u\n", (unsigned int)sizeof(Uint64)); ++error; } if (verbose && !error) - printf("All data types are the expected size.\n"); + SDL_Log("All data types are the expected size.\n"); return (error ? 1 : 0); } @@ -83,7 +83,7 @@ TestEndian(SDL_bool verbose) swapped64 |= 0xDEADBEEF; if (verbose) { - printf("Detected a %s endian machine.\n", + SDL_Log("Detected a %s endian machine.\n", (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big"); } if ((*((char *) &value) >> 4) == 0x1) { @@ -93,44 +93,44 @@ TestEndian(SDL_bool verbose) } if (real_byteorder != SDL_BYTEORDER) { if (verbose) { - printf("Actually a %s endian machine!\n", + SDL_Log("Actually a %s endian machine!\n", (real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big"); } ++error; } if (verbose) { - printf("Value 16 = 0x%X, swapped = 0x%X\n", value16, + SDL_Log("Value 16 = 0x%X, swapped = 0x%X\n", value16, SDL_Swap16(value16)); } if (SDL_Swap16(value16) != swapped16) { if (verbose) { - printf("16 bit value swapped incorrectly!\n"); + SDL_Log("16 bit value swapped incorrectly!\n"); } ++error; } if (verbose) { - printf("Value 32 = 0x%X, swapped = 0x%X\n", value32, + SDL_Log("Value 32 = 0x%X, swapped = 0x%X\n", value32, SDL_Swap32(value32)); } if (SDL_Swap32(value32) != swapped32) { if (verbose) { - printf("32 bit value swapped incorrectly!\n"); + SDL_Log("32 bit value swapped incorrectly!\n"); } ++error; } if (verbose) { #ifdef _MSC_VER - printf("Value 64 = 0x%I64X, swapped = 0x%I64X\n", value64, + SDL_Log("Value 64 = 0x%I64X, swapped = 0x%I64X\n", value64, SDL_Swap64(value64)); #else - printf("Value 64 = 0x%llX, swapped = 0x%llX\n", + SDL_Log("Value 64 = 0x%llX, swapped = 0x%llX\n", (unsigned long long) value64, (unsigned long long) SDL_Swap64(value64)); #endif } if (SDL_Swap64(value64) != swapped64) { if (verbose) { - printf("64 bit value swapped incorrectly!\n"); + SDL_Log("64 bit value swapped incorrectly!\n"); } ++error; } @@ -142,17 +142,18 @@ int TestCPUInfo(SDL_bool verbose) { if (verbose) { - printf("CPU count: %d\n", SDL_GetCPUCount()); - printf("CPU cache line size: %d\n", SDL_GetCPUCacheLineSize()); - printf("RDTSC %s\n", SDL_HasRDTSC()? "detected" : "not detected"); - printf("AltiVec %s\n", SDL_HasAltiVec()? "detected" : "not detected"); - printf("MMX %s\n", SDL_HasMMX()? "detected" : "not detected"); - printf("3DNow! %s\n", SDL_Has3DNow()? "detected" : "not detected"); - printf("SSE %s\n", SDL_HasSSE()? "detected" : "not detected"); - printf("SSE2 %s\n", SDL_HasSSE2()? "detected" : "not detected"); - printf("SSE3 %s\n", SDL_HasSSE3()? "detected" : "not detected"); - printf("SSE4.1 %s\n", SDL_HasSSE41()? "detected" : "not detected"); - printf("SSE4.2 %s\n", SDL_HasSSE42()? "detected" : "not detected"); + SDL_Log("CPU count: %d\n", SDL_GetCPUCount()); + SDL_Log("CPU cache line size: %d\n", SDL_GetCPUCacheLineSize()); + SDL_Log("RDTSC %s\n", SDL_HasRDTSC()? "detected" : "not detected"); + SDL_Log("AltiVec %s\n", SDL_HasAltiVec()? "detected" : "not detected"); + SDL_Log("MMX %s\n", SDL_HasMMX()? "detected" : "not detected"); + SDL_Log("3DNow! %s\n", SDL_Has3DNow()? "detected" : "not detected"); + SDL_Log("SSE %s\n", SDL_HasSSE()? "detected" : "not detected"); + SDL_Log("SSE2 %s\n", SDL_HasSSE2()? "detected" : "not detected"); + SDL_Log("SSE3 %s\n", SDL_HasSSE3()? "detected" : "not detected"); + SDL_Log("SSE4.1 %s\n", SDL_HasSSE41()? "detected" : "not detected"); + SDL_Log("SSE4.2 %s\n", SDL_HasSSE42()? "detected" : "not detected"); + SDL_Log("System RAM %d MB\n", SDL_GetSystemRAM()); } return (0); } @@ -176,7 +177,7 @@ TestAssertions(SDL_bool verbose) { const SDL_assert_data *item = SDL_GetAssertionReport(); while (item) { - printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n", + SDL_Log("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n", item->condition, item->function, item->filename, item->linenum, item->trigger_count, item->always_ignore ? "yes" : "no"); @@ -192,11 +193,14 @@ main(int argc, char *argv[]) SDL_bool verbose = SDL_TRUE; int status = 0; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + if (argv[1] && (SDL_strcmp(argv[1], "-q") == 0)) { verbose = SDL_FALSE; } if (verbose) { - printf("This system is running %s\n", SDL_GetPlatform()); + SDL_Log("This system is running %s\n", SDL_GetPlatform()); } status += TestTypes(verbose); diff --git a/test/testpower.c b/test/testpower.c index 3e13d0ac1..1b3214393 100644 --- a/test/testpower.c +++ b/test/testpower.c @@ -21,7 +21,7 @@ report_power(void) const SDL_PowerState state = SDL_GetPowerInfo(&seconds, &percent); char *statestr = NULL; - printf("SDL-reported power info...\n"); + SDL_Log("SDL-reported power info...\n"); switch (state) { case SDL_POWERSTATE_UNKNOWN: statestr = "Unknown"; @@ -43,18 +43,18 @@ report_power(void) break; } - printf("State: %s\n", statestr); + SDL_Log("State: %s\n", statestr); if (percent == -1) { - printf("Percent left: unknown\n"); + SDL_Log("Percent left: unknown\n"); } else { - printf("Percent left: %d%%\n", percent); + SDL_Log("Percent left: %d%%\n", percent); } if (seconds == -1) { - printf("Time left: unknown\n"); + SDL_Log("Time left: unknown\n"); } else { - printf("Time left: %d minutes, %d seconds\n", (int) (seconds / 60), + SDL_Log("Time left: %d minutes, %d seconds\n", (int) (seconds / 60), (int) (seconds % 60)); } } @@ -63,8 +63,11 @@ report_power(void) int main(int argc, char *argv[]) { + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + if (SDL_Init(0) == -1) { - fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError()); return 1; } diff --git a/test/testrelative.c b/test/testrelative.c index fa5bda660..9e8e1e2d0 100644 --- a/test/testrelative.c +++ b/test/testrelative.c @@ -35,6 +35,8 @@ main(int argc, char *argv[]) int i, done; SDL_Event event; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); @@ -74,16 +76,16 @@ main(int argc, char *argv[]) switch(event.type) { case SDL_MOUSEMOTION: { - /*printf("mouse motion ABS x %d y %d REL x %d y %d\n",event.motion.x,event.motion.y,event.motion.xrel,event.motion.yrel);*/ rect.x += event.motion.xrel; rect.y += event.motion.yrel; - } break; } } for (i = 0; i < state->num_windows; ++i) { SDL_Renderer *renderer = state->renderers[i]; + if (state->windows[i] == NULL) + continue; SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); SDL_RenderClear(renderer); diff --git a/test/testrendercopyex.c b/test/testrendercopyex.c index 6dd59c0ac..0c8ad7def 100644 --- a/test/testrendercopyex.c +++ b/test/testrendercopyex.c @@ -46,7 +46,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent) /* Load the sprite image */ temp = SDL_LoadBMP(file); if (temp == NULL) { - fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError()); return NULL; } @@ -77,7 +77,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent) /* Create textures from the image */ texture = SDL_CreateTextureFromSurface(renderer, temp); if (!texture) { - fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError()); SDL_FreeSurface(temp); return NULL; } @@ -127,7 +127,7 @@ Draw(DrawState *s) /* Update the screen! */ SDL_RenderPresent(s->renderer); - //SDL_Delay(10); + /* SDL_Delay(10); */ } int @@ -139,6 +139,9 @@ main(int argc, char *argv[]) int frames; Uint32 then, now; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); if (!state) { @@ -149,7 +152,7 @@ main(int argc, char *argv[]) consumed = SDLTest_CommonArg(state, i); if (consumed == 0) { - fprintf(stderr, "Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state)); + SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state)); return 1; } i += consumed; @@ -185,6 +188,8 @@ main(int argc, char *argv[]) SDLTest_CommonEvent(state, &event, &done); } for (i = 0; i < state->num_windows; ++i) { + if (state->windows[i] == NULL) + continue; Draw(&drawstates[i]); } } @@ -193,7 +198,7 @@ main(int argc, char *argv[]) now = SDL_GetTicks(); if (now > then) { double fps = ((double) frames * 1000) / (now - then); - printf("%2.2f frames per second\n", fps); + SDL_Log("%2.2f frames per second\n", fps); } SDL_stack_free(drawstates); diff --git a/test/testrendertarget.c b/test/testrendertarget.c index bc3104825..ac4aa5004 100644 --- a/test/testrendertarget.c +++ b/test/testrendertarget.c @@ -46,7 +46,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent) /* Load the sprite image */ temp = SDL_LoadBMP(file); if (temp == NULL) { - fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError()); return NULL; } @@ -77,7 +77,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent) /* Create textures from the image */ texture = SDL_CreateTextureFromSurface(renderer, temp); if (!texture) { - fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError()); SDL_FreeSurface(temp); return NULL; } @@ -87,7 +87,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent) return texture; } -void +SDL_bool DrawComposite(DrawState *s) { SDL_Rect viewport, R; @@ -114,7 +114,7 @@ DrawComposite(DrawState *s) SDL_RenderCopy(s->renderer, A, NULL, NULL); SDL_RenderReadPixels(s->renderer, NULL, SDL_PIXELFORMAT_ARGB8888, &P, sizeof(P)); - printf("Blended pixel: 0x%8.8X\n", P); + SDL_Log("Blended pixel: 0x%8.8X\n", P); SDL_DestroyTexture(A); SDL_DestroyTexture(B); @@ -167,9 +167,10 @@ DrawComposite(DrawState *s) /* Update the screen! */ SDL_RenderPresent(s->renderer); + return SDL_TRUE; } -void +SDL_bool Draw(DrawState *s) { SDL_Rect viewport; @@ -178,6 +179,10 @@ Draw(DrawState *s) SDL_RenderGetViewport(s->renderer, &viewport); target = SDL_CreateTexture(s->renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, viewport.w, viewport.h); + if (!target) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create render target texture: %s\n", SDL_GetError()); + return SDL_FALSE; + } SDL_SetRenderTarget(s->renderer, target); /* Draw the background */ @@ -206,6 +211,7 @@ Draw(DrawState *s) /* Update the screen! */ SDL_RenderPresent(s->renderer); + return SDL_TRUE; } int @@ -218,6 +224,9 @@ main(int argc, char *argv[]) Uint32 then, now; SDL_bool test_composite = SDL_FALSE; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); if (!state) { @@ -235,8 +244,7 @@ main(int argc, char *argv[]) } } if (consumed < 0) { - fprintf(stderr, - "Usage: %s %s [--composite]\n", + SDL_Log("Usage: %s %s [--composite]\n", argv[0], SDLTest_CommonUsage(state)); quit(1); } @@ -277,10 +285,12 @@ main(int argc, char *argv[]) SDLTest_CommonEvent(state, &event, &done); } for (i = 0; i < state->num_windows; ++i) { + if (state->windows[i] == NULL) + continue; if (test_composite) { - DrawComposite(&drawstates[i]); + if (!DrawComposite(&drawstates[i])) done = 1; } else { - Draw(&drawstates[i]); + if (!Draw(&drawstates[i])) done = 1; } } } @@ -289,7 +299,7 @@ main(int argc, char *argv[]) now = SDL_GetTicks(); if (now > then) { double fps = ((double) frames * 1000) / (now - then); - printf("%2.2f frames per second\n", fps); + SDL_Log("%2.2f frames per second\n", fps); } SDL_stack_free(drawstates); diff --git a/test/testresample.c b/test/testresample.c index d79f1ac8a..a6e859d36 100644 --- a/test/testresample.c +++ b/test/testresample.c @@ -9,7 +9,7 @@ including commercial applications, and to alter it and redistribute it freely. */ -#include + #include "SDL.h" int @@ -25,27 +25,30 @@ main(int argc, char **argv) int avgbytes = 0; SDL_RWops *io = NULL; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + if (argc != 4) { - fprintf(stderr, "USAGE: %s in.wav out.wav newfreq\n", argv[0]); + SDL_Log("USAGE: %s in.wav out.wav newfreq\n", argv[0]); return 1; } cvtfreq = SDL_atoi(argv[3]); if (SDL_Init(SDL_INIT_AUDIO) == -1) { - fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError()); return 2; } if (SDL_LoadWAV(argv[1], &spec, &data, &len) == NULL) { - fprintf(stderr, "failed to load %s: %s\n", argv[1], SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to load %s: %s\n", argv[1], SDL_GetError()); SDL_Quit(); return 3; } if (SDL_BuildAudioCVT(&cvt, spec.format, spec.channels, spec.freq, spec.format, spec.channels, cvtfreq) == -1) { - fprintf(stderr, "failed to build CVT: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to build CVT: %s\n", SDL_GetError()); SDL_FreeWAV(data); SDL_Quit(); return 4; @@ -54,7 +57,7 @@ main(int argc, char **argv) cvt.len = len; cvt.buf = (Uint8 *) SDL_malloc(len * cvt.len_mult); if (cvt.buf == NULL) { - fprintf(stderr, "Out of memory.\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory.\n"); SDL_FreeWAV(data); SDL_Quit(); return 5; @@ -62,7 +65,7 @@ main(int argc, char **argv) SDL_memcpy(cvt.buf, data, len); if (SDL_ConvertAudio(&cvt) == -1) { - fprintf(stderr, "Conversion failed: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Conversion failed: %s\n", SDL_GetError()); SDL_free(cvt.buf); SDL_FreeWAV(data); SDL_Quit(); @@ -72,7 +75,7 @@ main(int argc, char **argv) /* write out a WAV header... */ io = SDL_RWFromFile(argv[2], "wb"); if (io == NULL) { - fprintf(stderr, "fopen('%s') failed: %s\n", argv[2], SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "fopen('%s') failed: %s\n", argv[2], SDL_GetError()); SDL_free(cvt.buf); SDL_FreeWAV(data); SDL_Quit(); @@ -99,17 +102,17 @@ main(int argc, char **argv) SDL_RWwrite(io, cvt.buf, cvt.len_cvt, 1); if (SDL_RWclose(io) == -1) { - fprintf(stderr, "fclose('%s') failed: %s\n", argv[2], SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "fclose('%s') failed: %s\n", argv[2], SDL_GetError()); SDL_free(cvt.buf); SDL_FreeWAV(data); SDL_Quit(); return 8; - } // if + } /* if */ SDL_free(cvt.buf); SDL_FreeWAV(data); SDL_Quit(); return 0; -} // main +} /* main */ -// end of resample_test.c ... +/* end of resample_test.c ... */ diff --git a/test/testrumble.c b/test/testrumble.c index e5b5424d4..ffcaae4a8 100644 --- a/test/testrumble.c +++ b/test/testrumble.c @@ -26,7 +26,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * includes */ #include -#include /* printf */ #include /* strstr */ #include /* isdigit */ @@ -51,12 +50,15 @@ main(int argc, char **argv) char *name; int index; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + name = NULL; index = -1; if (argc > 1) { name = argv[1]; if ((strcmp(name, "--help") == 0) || (strcmp(name, "-h") == 0)) { - printf("USAGE: %s [device]\n" + SDL_Log("USAGE: %s [device]\n" "If device is a two-digit number it'll use it as an index, otherwise\n" "it'll use it as if it were part of the device's name.\n", argv[0]); @@ -73,7 +75,7 @@ main(int argc, char **argv) /* Initialize the force feedbackness */ SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC); - printf("%d Haptic devices detected.\n", SDL_NumHaptics()); + SDL_Log("%d Haptic devices detected.\n", SDL_NumHaptics()); if (SDL_NumHaptics() > 0) { /* We'll just use index or the first force feedback device found */ if (name == NULL) { @@ -87,7 +89,7 @@ main(int argc, char **argv) } if (i >= SDL_NumHaptics()) { - printf("Unable to find device matching '%s', aborting.\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to find device matching '%s', aborting.\n", name); return 1; } @@ -95,13 +97,13 @@ main(int argc, char **argv) haptic = SDL_HapticOpen(i); if (haptic == NULL) { - printf("Unable to create the haptic device: %s\n", + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s\n", SDL_GetError()); return 1; } - printf("Device: %s\n", SDL_HapticName(i)); + SDL_Log("Device: %s\n", SDL_HapticName(i)); } else { - printf("No Haptic devices found!\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No Haptic devices found!\n"); return 1; } @@ -109,25 +111,25 @@ main(int argc, char **argv) SDL_ClearError(); if (SDL_HapticRumbleSupported(haptic) == SDL_FALSE) { - printf("\nRumble not supported!\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Rumble not supported!\n"); return 1; } if (SDL_HapticRumbleInit(haptic) != 0) { - printf("\nFailed to initialize rumble: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to initialize rumble: %s\n", SDL_GetError()); return 1; } - printf("Playing 2 second rumble at 0.5 magnitude.\n"); + SDL_Log("Playing 2 second rumble at 0.5 magnitude.\n"); if (SDL_HapticRumblePlay(haptic, 0.5, 5000) != 0) { - printf("\nFailed to play rumble: %s\n", SDL_GetError() ); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s\n", SDL_GetError() ); return 1; } SDL_Delay(2000); - printf("Stopping rumble.\n"); + SDL_Log("Stopping rumble.\n"); SDL_HapticRumbleStop(haptic); SDL_Delay(2000); - printf("Playing 2 second rumble at 0.3 magnitude.\n"); + SDL_Log("Playing 2 second rumble at 0.3 magnitude.\n"); if (SDL_HapticRumblePlay(haptic, 0.3f, 5000) != 0) { - printf("\nFailed to play rumble: %s\n", SDL_GetError() ); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s\n", SDL_GetError() ); return 1; } SDL_Delay(2000); @@ -145,7 +147,7 @@ main(int argc, char **argv) int main(int argc, char *argv[]) { - fprintf(stderr, "SDL compiled without Haptic support.\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Haptic support.\n"); exit(1); } diff --git a/test/testscale.c b/test/testscale.c index 0f0096c6e..8449f233d 100644 --- a/test/testscale.c +++ b/test/testscale.c @@ -48,7 +48,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent) /* Load the sprite image */ temp = SDL_LoadBMP(file); if (temp == NULL) { - fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError()); return NULL; } @@ -79,7 +79,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent) /* Create textures from the image */ texture = SDL_CreateTextureFromSurface(renderer, temp); if (!texture) { - fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError()); SDL_FreeSurface(temp); return NULL; } @@ -129,6 +129,9 @@ main(int argc, char *argv[]) int frames; Uint32 then, now; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); if (!state) { @@ -139,7 +142,7 @@ main(int argc, char *argv[]) consumed = SDLTest_CommonArg(state, i); if (consumed == 0) { - fprintf(stderr, "Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state)); + SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state)); return 1; } i += consumed; @@ -175,6 +178,8 @@ main(int argc, char *argv[]) SDLTest_CommonEvent(state, &event, &done); } for (i = 0; i < state->num_windows; ++i) { + if (state->windows[i] == NULL) + continue; Draw(&drawstates[i]); } } @@ -183,7 +188,7 @@ main(int argc, char *argv[]) now = SDL_GetTicks(); if (now > then) { double fps = ((double) frames * 1000) / (now - then); - printf("%2.2f frames per second\n", fps); + SDL_Log("%2.2f frames per second\n", fps); } SDL_stack_free(drawstates); diff --git a/test/testsem.c b/test/testsem.c index eab280e1d..6a2a59e67 100644 --- a/test/testsem.c +++ b/test/testsem.c @@ -30,17 +30,15 @@ ThreadFunc(void *data) int threadnum = (int) (uintptr_t) data; while (alive) { SDL_SemWait(sem); - fprintf(stderr, - "Thread number %d has got the semaphore (value = %d)!\n", + SDL_Log("Thread number %d has got the semaphore (value = %d)!\n", threadnum, SDL_SemValue(sem)); SDL_Delay(200); SDL_SemPost(sem); - fprintf(stderr, - "Thread number %d has released the semaphore (value = %d)!\n", + SDL_Log("Thread number %d has released the semaphore (value = %d)!\n", threadnum, SDL_SemValue(sem)); SDL_Delay(1); /* For the scheduler */ } - printf("Thread number %d exiting.\n", threadnum); + SDL_Log("Thread number %d exiting.\n", threadnum); return 0; } @@ -59,7 +57,7 @@ TestWaitTimeout(void) int retval; sem = SDL_CreateSemaphore(0); - printf("Waiting 2 seconds on semaphore\n"); + SDL_Log("Waiting 2 seconds on semaphore\n"); start_ticks = SDL_GetTicks(); retval = SDL_SemWaitTimeout(sem, 2000); @@ -69,13 +67,13 @@ TestWaitTimeout(void) /* Accept a little offset in the effective wait */ if (duration > 1900 && duration < 2050) - printf("Wait done.\n"); + SDL_Log("Wait done.\n"); else - fprintf(stderr, "Wait took %d milliseconds\n", duration); + SDL_Log("Wait took %d milliseconds\n", duration); /* Check to make sure the return value indicates timed out */ if (retval != SDL_MUTEX_TIMEDOUT) - fprintf(stderr, "SDL_SemWaitTimeout returned: %d; expected: %d\n", retval, SDL_MUTEX_TIMEDOUT); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_SemWaitTimeout returned: %d; expected: %d\n", retval, SDL_MUTEX_TIMEDOUT); } int @@ -85,14 +83,17 @@ main(int argc, char **argv) uintptr_t i; int init_sem; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + if (argc < 2) { - fprintf(stderr, "Usage: %s init_value\n", argv[0]); + SDL_Log("Usage: %s init_value\n", argv[0]); return (1); } /* Load the SDL library */ if (SDL_Init(0) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } signal(SIGTERM, killed); @@ -101,7 +102,7 @@ main(int argc, char **argv) init_sem = atoi(argv[1]); sem = SDL_CreateSemaphore(init_sem); - printf("Running %d threads, semaphore value = %d\n", NUM_THREADS, + SDL_Log("Running %d threads, semaphore value = %d\n", NUM_THREADS, init_sem); /* Create all the threads */ for (i = 0; i < NUM_THREADS; ++i) { @@ -114,12 +115,12 @@ main(int argc, char **argv) SDL_Delay(10 * 1000); /* Wait for all threads to finish */ - printf("Waiting for threads to finish\n"); + SDL_Log("Waiting for threads to finish\n"); alive = 0; for (i = 0; i < NUM_THREADS; ++i) { SDL_WaitThread(threads[i], NULL); } - printf("Finished waiting for threads\n"); + SDL_Log("Finished waiting for threads\n"); SDL_DestroySemaphore(sem); diff --git a/test/testshader.c b/test/testshader.c index 376b445e7..04467709e 100644 --- a/test/testshader.c +++ b/test/testshader.c @@ -11,7 +11,6 @@ */ /* This is a simple example of using GLSL shaders with SDL */ -#include /* for printf() */ #include "SDL.h" #ifdef HAVE_OPENGL @@ -139,7 +138,7 @@ static SDL_bool CompileShader(GLhandleARB shader, const char *source) glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length); info = SDL_stack_alloc(char, length+1); glGetInfoLogARB(shader, length, NULL, info); - fprintf(stderr, "Failed to compile shader:\n%s\n%s", source, info); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to compile shader:\n%s\n%s", source, info); SDL_stack_free(info); return SDL_FALSE; @@ -245,7 +244,7 @@ static SDL_bool InitShaders() /* Compile all the shaders */ for (i = 0; i < NUM_SHADERS; ++i) { if (!CompileShaderProgram(&shaders[i])) { - fprintf(stderr, "Unable to compile shader!\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to compile shader!\n"); return SDL_FALSE; } } @@ -333,19 +332,19 @@ SDL_GL_LoadTexture(SDL_Surface * surface, GLfloat * texcoord) } /* A general OpenGL initialization function. Sets all of the initial parameters. */ -void InitGL(int Width, int Height) // We call this right after our OpenGL window is created. +void InitGL(int Width, int Height) /* We call this right after our OpenGL window is created. */ { GLdouble aspect; glViewport(0, 0, Width, Height); - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // This Will Clear The Background Color To Black - glClearDepth(1.0); // Enables Clearing Of The Depth Buffer - glDepthFunc(GL_LESS); // The Type Of Depth Test To Do - glEnable(GL_DEPTH_TEST); // Enables Depth Testing - glShadeModel(GL_SMOOTH); // Enables Smooth Color Shading + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); /* This Will Clear The Background Color To Black */ + glClearDepth(1.0); /* Enables Clearing Of The Depth Buffer */ + glDepthFunc(GL_LESS); /* The Type Of Depth Test To Do */ + glEnable(GL_DEPTH_TEST); /* Enables Depth Testing */ + glShadeModel(GL_SMOOTH); /* Enables Smooth Color Shading */ glMatrixMode(GL_PROJECTION); - glLoadIdentity(); // Reset The Projection Matrix + glLoadIdentity(); /* Reset The Projection Matrix */ aspect = (GLdouble)Width / Height; glOrtho(-3.0, 3.0, -3.0 / aspect, 3.0 / aspect, 0.0, 1.0); @@ -364,29 +363,29 @@ void DrawGLScene(SDL_Window *window, GLuint texture, GLfloat * texcoord) MAXY }; - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer - glLoadIdentity(); // Reset The View + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* Clear The Screen And The Depth Buffer */ + glLoadIdentity(); /* Reset The View */ - glTranslatef(-1.5f,0.0f,0.0f); // Move Left 1.5 Units + glTranslatef(-1.5f,0.0f,0.0f); /* Move Left 1.5 Units */ - // draw a triangle (in smooth coloring mode) - glBegin(GL_POLYGON); // start drawing a polygon - glColor3f(1.0f,0.0f,0.0f); // Set The Color To Red - glVertex3f( 0.0f, 1.0f, 0.0f); // Top - glColor3f(0.0f,1.0f,0.0f); // Set The Color To Green - glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right - glColor3f(0.0f,0.0f,1.0f); // Set The Color To Blue - glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left - glEnd(); // we're done with the polygon (smooth color interpolation) + /* draw a triangle (in smooth coloring mode) */ + glBegin(GL_POLYGON); /* start drawing a polygon */ + glColor3f(1.0f,0.0f,0.0f); /* Set The Color To Red */ + glVertex3f( 0.0f, 1.0f, 0.0f); /* Top */ + glColor3f(0.0f,1.0f,0.0f); /* Set The Color To Green */ + glVertex3f( 1.0f,-1.0f, 0.0f); /* Bottom Right */ + glColor3f(0.0f,0.0f,1.0f); /* Set The Color To Blue */ + glVertex3f(-1.0f,-1.0f, 0.0f); /* Bottom Left */ + glEnd(); /* we're done with the polygon (smooth color interpolation) */ - glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 Units + glTranslatef(3.0f,0.0f,0.0f); /* Move Right 3 Units */ - // Enable blending + /* Enable blending */ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - // draw a textured square (quadrilateral) + /* draw a textured square (quadrilateral) */ glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture); glColor3f(1.0f,1.0f,1.0f); @@ -394,23 +393,23 @@ void DrawGLScene(SDL_Window *window, GLuint texture, GLfloat * texcoord) glUseProgramObjectARB(shaders[current_shader].program); } - glBegin(GL_QUADS); // start drawing a polygon (4 sided) + glBegin(GL_QUADS); /* start drawing a polygon (4 sided) */ glTexCoord2f(texcoord[MINX], texcoord[MINY]); - glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left + glVertex3f(-1.0f, 1.0f, 0.0f); /* Top Left */ glTexCoord2f(texcoord[MAXX], texcoord[MINY]); - glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right + glVertex3f( 1.0f, 1.0f, 0.0f); /* Top Right */ glTexCoord2f(texcoord[MAXX], texcoord[MAXY]); - glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right + glVertex3f( 1.0f,-1.0f, 0.0f); /* Bottom Right */ glTexCoord2f(texcoord[MINX], texcoord[MAXY]); - glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left - glEnd(); // done with the polygon + glVertex3f(-1.0f,-1.0f, 0.0f); /* Bottom Left */ + glEnd(); /* done with the polygon */ if (shaders_supported) { glUseProgramObjectARB(0); } glDisable(GL_TEXTURE_2D); - // swap buffers to display, since we're double buffered. + /* swap buffers to display, since we're double buffered. */ SDL_GL_SwapWindow(window); } @@ -422,29 +421,32 @@ int main(int argc, char **argv) GLuint texture; GLfloat texcoords[4]; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Initialize SDL for video output */ if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { - fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to initialize SDL: %s\n", SDL_GetError()); exit(1); } /* Create a 640x480 OpenGL screen */ window = SDL_CreateWindow( "Shader Demo", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_OPENGL ); if ( !window ) { - fprintf(stderr, "Unable to create OpenGL window: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL window: %s\n", SDL_GetError()); SDL_Quit(); exit(2); } if ( !SDL_GL_CreateContext(window)) { - fprintf(stderr, "Unable to create OpenGL context: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL context: %s\n", SDL_GetError()); SDL_Quit(); exit(2); } surface = SDL_LoadBMP("icon.bmp"); if ( ! surface ) { - fprintf(stderr, "Unable to load icon.bmp: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to load icon.bmp: %s\n", SDL_GetError()); SDL_Quit(); exit(3); } @@ -454,9 +456,9 @@ int main(int argc, char **argv) /* Loop, drawing and checking events */ InitGL(640, 480); if (InitShaders()) { - printf("Shaders supported, press SPACE to cycle them.\n"); + SDL_Log("Shaders supported, press SPACE to cycle them.\n"); } else { - printf("Shaders not supported!\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Shaders not supported!\n"); } done = 0; while ( ! done ) { @@ -489,7 +491,7 @@ int main(int argc, char **argv) int main(int argc, char *argv[]) { - printf("No OpenGL support on this system\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL support on this system\n"); return 1; } diff --git a/test/testshape.c b/test/testshape.c index 59dfb9fc2..c202d8ec6 100644 --- a/test/testshape.c +++ b/test/testshape.c @@ -29,11 +29,11 @@ typedef struct LoadedPicture { void render(SDL_Renderer *renderer,SDL_Texture *texture,SDL_Rect texture_dimensions) { - //Clear render-target to blue. + /* Clear render-target to blue. */ SDL_SetRenderDrawColor(renderer,0x00,0x00,0xff,0xff); SDL_RenderClear(renderer); - //Render the texture. + /* Render the texture. */ SDL_RenderCopy(renderer,texture,&texture_dimensions,&texture_dimensions); SDL_RenderPresent(renderer); @@ -68,13 +68,16 @@ int main(int argc,char** argv) int access = 0; SDL_Rect texture_dimensions;; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + if(argc < 2) { - printf("SDL_Shape requires at least one bitmap file as argument.\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Shape requires at least one bitmap file as argument."); exit(-1); } if(SDL_VideoInit(NULL) == -1) { - printf("Could not initialize SDL video.\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not initialize SDL video."); exit(-2); } @@ -87,11 +90,10 @@ int main(int argc,char** argv) if(pictures[i].surface == NULL) { j = 0; for(j=0;jw; @@ -95,7 +89,7 @@ LoadSprite(const char *file) SDL_Renderer *renderer = state->renderers[i]; sprites[i] = SDL_CreateTextureFromSurface(renderer, temp); if (!sprites[i]) { - fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError()); SDL_FreeSurface(temp); return (-1); } @@ -299,8 +293,7 @@ main(int argc, char *argv[]) } } if (consumed < 0) { - fprintf(stderr, - "Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha] [--iterations N] [num_sprites] [icon.bmp]\n", + SDL_Log("Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha] [--iterations N] [num_sprites] [icon.bmp]\n", argv[0], SDLTest_CommonUsage(state)); quit(1); } @@ -314,7 +307,7 @@ main(int argc, char *argv[]) sprites = (SDL_Texture **) SDL_malloc(state->num_windows * sizeof(*sprites)); if (!sprites) { - fprintf(stderr, "Out of memory!\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); quit(2); } for (i = 0; i < state->num_windows; ++i) { @@ -330,7 +323,7 @@ main(int argc, char *argv[]) positions = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect)); velocities = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect)); if (!positions || !velocities) { - fprintf(stderr, "Out of memory!\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); quit(2); } @@ -367,6 +360,8 @@ main(int argc, char *argv[]) SDLTest_CommonEvent(state, &event, &done); } for (i = 0; i < state->num_windows; ++i) { + if (state->windows[i] == NULL) + continue; MoveSprites(state->renderers[i], sprites[i]); } } @@ -375,7 +370,7 @@ main(int argc, char *argv[]) now = SDL_GetTicks(); if (now > then) { double fps = ((double) frames * 1000) / (now - then); - printf("%2.2f frames per second\n", fps); + SDL_Log("%2.2f frames per second\n", fps); } quit(0); return 0; diff --git a/test/testspriteminimal.c b/test/testspriteminimal.c index 6f3ac25c0..157293f30 100644 --- a/test/testspriteminimal.c +++ b/test/testspriteminimal.c @@ -42,7 +42,7 @@ LoadSprite(char *file, SDL_Renderer *renderer) /* Load the sprite image */ temp = SDL_LoadBMP(file); if (temp == NULL) { - fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", file, SDL_GetError()); return (-1); } sprite_w = temp->w; @@ -73,7 +73,7 @@ LoadSprite(char *file, SDL_Renderer *renderer) /* Create textures from the image */ sprite = SDL_CreateTextureFromSurface(renderer, temp); if (!sprite) { - fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError()); SDL_FreeSurface(temp); return (-1); } @@ -126,6 +126,9 @@ main(int argc, char *argv[]) int i, done; SDL_Event event; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + if (SDL_CreateWindowAndRenderer(WINDOW_WIDTH, WINDOW_HEIGHT, 0, &window, &renderer) < 0) { quit(2); } diff --git a/test/teststreaming.c b/test/teststreaming.c index ea3ac2d61..1d3f68250 100644 --- a/test/teststreaming.c +++ b/test/teststreaming.c @@ -68,7 +68,7 @@ void UpdateTexture(SDL_Texture *texture, int frame) int pitch; if (SDL_LockTexture(texture, NULL, &pixels, &pitch) < 0) { - fprintf(stderr, "Couldn't lock texture: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't lock texture: %s\n", SDL_GetError()); quit(5); } src = MooseFrames[frame]; @@ -93,15 +93,18 @@ main(int argc, char **argv) SDL_bool done = SDL_FALSE; int frame; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + if (SDL_Init(SDL_INIT_VIDEO) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return 1; } /* load the moose images */ handle = SDL_RWFromFile("moose.dat", "rb"); if (handle == NULL) { - fprintf(stderr, "Can't find the file moose.dat !\n"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n"); quit(2); } SDL_RWread(handle, MooseFrames, MOOSEFRAME_SIZE, MOOSEFRAMES_COUNT); @@ -115,19 +118,19 @@ main(int argc, char **argv) MOOSEPIC_W*4, MOOSEPIC_H*4, SDL_WINDOW_RESIZABLE); if (!window) { - fprintf(stderr, "Couldn't set create window: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError()); quit(3); } renderer = SDL_CreateRenderer(window, -1, 0); if (!renderer) { - fprintf(stderr, "Couldn't set create renderer: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError()); quit(4); } MooseTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H); if (!MooseTexture) { - fprintf(stderr, "Couldn't set create texture: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError()); quit(5); } diff --git a/test/testthread.c b/test/testthread.c index 9cea7576b..c5ce2d5a8 100644 --- a/test/testthread.c +++ b/test/testthread.c @@ -1,96 +1,99 @@ -/* - Copyright (C) 1997-2013 Sam Lantinga - - 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. -*/ - -/* Simple test of the SDL threading code */ - -#include -#include -#include - -#include "SDL.h" -#include "SDL_thread.h" - -static SDL_TLSID tls; -static int alive = 0; - -/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ -static void -quit(int rc) -{ - SDL_Quit(); - exit(rc); -} - -int SDLCALL -ThreadFunc(void *data) -{ - SDL_TLSSet(tls, "baby thread", NULL); - SDL_Log("Started thread %s: My thread id is %lu, thread data = %s\n", - (char *) data, SDL_ThreadID(), (const char *)SDL_TLSGet(tls)); - while (alive) { - SDL_Log("Thread '%s' is alive!\n", (char *) data); - SDL_Delay(1 * 1000); - } - SDL_Log("Thread '%s' exiting!\n", (char *) data); - return (0); -} - -static void -killed(int sig) -{ - SDL_Log("Killed with SIGTERM, waiting 5 seconds to exit\n"); - SDL_Delay(5 * 1000); - alive = 0; - quit(0); -} - -int -main(int argc, char *argv[]) -{ - SDL_Thread *thread; - - /* Load the SDL library */ - if (SDL_Init(0) < 0) { - SDL_Log("Couldn't initialize SDL: %s\n", SDL_GetError()); - return (1); - } - - tls = SDL_TLSCreate(); - SDL_assert(tls); - SDL_TLSSet(tls, "main thread", NULL); - SDL_Log("Main thread data initially: %s\n", (const char *)SDL_TLSGet(tls)); - - alive = 1; - thread = SDL_CreateThread(ThreadFunc, "One", "#1"); - if (thread == NULL) { - SDL_Log("Couldn't create thread: %s\n", SDL_GetError()); - quit(1); - } - SDL_Delay(5 * 1000); - SDL_Log("Waiting for thread #1\n"); - alive = 0; - SDL_WaitThread(thread, NULL); - - SDL_Log("Main thread data finally: %s\n", (const char *)SDL_TLSGet(tls)); - - alive = 1; - signal(SIGTERM, killed); - thread = SDL_CreateThread(ThreadFunc, "Two", "#2"); - if (thread == NULL) { - SDL_Log("Couldn't create thread: %s\n", SDL_GetError()); - quit(1); - } - raise(SIGTERM); - - SDL_Quit(); /* Never reached */ - return (0); /* Never reached */ -} +/* + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/* Simple test of the SDL threading code */ + +#include +#include +#include + +#include "SDL.h" +#include "SDL_thread.h" + +static SDL_TLSID tls; +static int alive = 0; + +/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ +static void +quit(int rc) +{ + SDL_Quit(); + exit(rc); +} + +int SDLCALL +ThreadFunc(void *data) +{ + SDL_TLSSet(tls, "baby thread", NULL); + SDL_Log("Started thread %s: My thread id is %lu, thread data = %s\n", + (char *) data, SDL_ThreadID(), (const char *)SDL_TLSGet(tls)); + while (alive) { + SDL_Log("Thread '%s' is alive!\n", (char *) data); + SDL_Delay(1 * 1000); + } + SDL_Log("Thread '%s' exiting!\n", (char *) data); + return (0); +} + +static void +killed(int sig) +{ + SDL_Log("Killed with SIGTERM, waiting 5 seconds to exit\n"); + SDL_Delay(5 * 1000); + alive = 0; + quit(0); +} + +int +main(int argc, char *argv[]) +{ + SDL_Thread *thread; + + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + + /* Load the SDL library */ + if (SDL_Init(0) < 0) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); + return (1); + } + + tls = SDL_TLSCreate(); + SDL_assert(tls); + SDL_TLSSet(tls, "main thread", NULL); + SDL_Log("Main thread data initially: %s\n", (const char *)SDL_TLSGet(tls)); + + alive = 1; + thread = SDL_CreateThread(ThreadFunc, "One", "#1"); + if (thread == NULL) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError()); + quit(1); + } + SDL_Delay(5 * 1000); + SDL_Log("Waiting for thread #1\n"); + alive = 0; + SDL_WaitThread(thread, NULL); + + SDL_Log("Main thread data finally: %s\n", (const char *)SDL_TLSGet(tls)); + + alive = 1; + signal(SIGTERM, killed); + thread = SDL_CreateThread(ThreadFunc, "Two", "#2"); + if (thread == NULL) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError()); + quit(1); + } + raise(SIGTERM); + + SDL_Quit(); /* Never reached */ + return (0); /* Never reached */ +} diff --git a/test/testtimer.c b/test/testtimer.c index ebc655d10..ea985e264 100644 --- a/test/testtimer.c +++ b/test/testtimer.c @@ -33,7 +33,7 @@ ticktock(Uint32 interval, void *param) static Uint32 SDLCALL callback(Uint32 interval, void *param) { - printf("Timer %d : param = %d\n", interval, (int) (uintptr_t) param); + SDL_Log("Timer %d : param = %d\n", interval, (int) (uintptr_t) param); return interval; } @@ -45,8 +45,11 @@ main(int argc, char *argv[]) Uint32 start32, now32; Uint64 start, now; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + if (SDL_Init(SDL_INIT_TIMER) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } @@ -61,7 +64,7 @@ main(int argc, char *argv[]) t1 = SDL_AddTimer(desired, ticktock, NULL); /* Wait 10 seconds */ - printf("Waiting 10 seconds\n"); + SDL_Log("Waiting 10 seconds\n"); SDL_Delay(10 * 1000); /* Stop the timer */ @@ -69,28 +72,27 @@ main(int argc, char *argv[]) /* Print the results */ if (ticks) { - fprintf(stderr, - "Timer resolution: desired = %d ms, actual = %f ms\n", + SDL_Log("Timer resolution: desired = %d ms, actual = %f ms\n", desired, (double) (10 * 1000) / ticks); } /* Test multiple timers */ - printf("Testing multiple timers...\n"); + SDL_Log("Testing multiple timers...\n"); t1 = SDL_AddTimer(100, callback, (void *) 1); if (!t1) - fprintf(stderr, "Could not create timer 1: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 1: %s\n", SDL_GetError()); t2 = SDL_AddTimer(50, callback, (void *) 2); if (!t2) - fprintf(stderr, "Could not create timer 2: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 2: %s\n", SDL_GetError()); t3 = SDL_AddTimer(233, callback, (void *) 3); if (!t3) - fprintf(stderr, "Could not create timer 3: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 3: %s\n", SDL_GetError()); /* Wait 10 seconds */ - printf("Waiting 10 seconds\n"); + SDL_Log("Waiting 10 seconds\n"); SDL_Delay(10 * 1000); - printf("Removing timer 1 and waiting 5 more seconds\n"); + SDL_Log("Removing timer 1 and waiting 5 more seconds\n"); SDL_RemoveTimer(t1); SDL_Delay(5 * 1000); @@ -103,15 +105,15 @@ main(int argc, char *argv[]) ticktock(0, NULL); } now = SDL_GetPerformanceCounter(); - printf("1 million iterations of ticktock took %f ms\n", (double)((now - start)*1000) / SDL_GetPerformanceFrequency()); + SDL_Log("1 million iterations of ticktock took %f ms\n", (double)((now - start)*1000) / SDL_GetPerformanceFrequency()); - printf("Performance counter frequency: %llu\n", (unsigned long long) SDL_GetPerformanceFrequency()); + SDL_Log("Performance counter frequency: %llu\n", (unsigned long long) SDL_GetPerformanceFrequency()); start32 = SDL_GetTicks(); start = SDL_GetPerformanceCounter(); SDL_Delay(1000); now = SDL_GetPerformanceCounter(); now32 = SDL_GetTicks(); - printf("Delay 1 second = %d ms in ticks, %f ms according to performance counter\n", (now32-start32), (double)((now - start)*1000) / SDL_GetPerformanceFrequency()); + SDL_Log("Delay 1 second = %d ms in ticks, %f ms according to performance counter\n", (now32-start32), (double)((now - start)*1000) / SDL_GetPerformanceFrequency()); SDL_Quit(); return (0); diff --git a/test/testver.c b/test/testver.c index ecfcdf35e..cf3a54598 100644 --- a/test/testver.c +++ b/test/testver.c @@ -26,17 +26,20 @@ main(int argc, char *argv[]) SDL_version compiled; SDL_version linked; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + #if SDL_VERSION_ATLEAST(2, 0, 0) - printf("Compiled with SDL 2.0 or newer\n"); + SDL_Log("Compiled with SDL 2.0 or newer\n"); #else - printf("Compiled with SDL older than 2.0\n"); + SDL_Log("Compiled with SDL older than 2.0\n"); #endif SDL_VERSION(&compiled); - printf("Compiled version: %d.%d.%d.%d (%s)\n", + SDL_Log("Compiled version: %d.%d.%d.%d (%s)\n", compiled.major, compiled.minor, compiled.patch, SDL_REVISION_NUMBER, SDL_REVISION); SDL_GetVersion(&linked); - printf("Linked version: %d.%d.%d.%d (%s)\n", + SDL_Log("Linked version: %d.%d.%d.%d (%s)\n", linked.major, linked.minor, linked.patch, SDL_GetRevisionNumber(), SDL_GetRevision()); SDL_Quit(); diff --git a/test/testwm2.c b/test/testwm2.c index efe6ea4dd..127a4d877 100644 --- a/test/testwm2.c +++ b/test/testwm2.c @@ -48,6 +48,9 @@ main(int argc, char *argv[]) int system_cursor = -1; SDL_Cursor *cursor = NULL; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + SDL_assert(SDL_arraysize(cursorNames) == SDL_NUM_SYSTEM_CURSORS); /* Initialize test framework */ @@ -64,7 +67,7 @@ main(int argc, char *argv[]) consumed = -1; } if (consumed < 0) { - fprintf(stderr, "Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state)); + SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state)); quit(1); } i += consumed; @@ -84,7 +87,7 @@ main(int argc, char *argv[]) if (event.window.event == SDL_WINDOWEVENT_RESIZED) { SDL_Window *window = SDL_GetWindowFromID(event.window.windowID); if (window) { - printf("Window %d resized to %dx%d\n", + SDL_Log("Window %d resized to %dx%d\n", event.window.windowID, event.window.data1, event.window.data2); @@ -93,7 +96,7 @@ main(int argc, char *argv[]) if (event.window.event == SDL_WINDOWEVENT_MOVED) { SDL_Window *window = SDL_GetWindowFromID(event.window.windowID); if (window) { - printf("Window %d moved to %d,%d (display %s)\n", + SDL_Log("Window %d moved to %d,%d (display %s)\n", event.window.windowID, event.window.data1, event.window.data2, @@ -129,7 +132,7 @@ main(int argc, char *argv[]) SDL_FreeCursor(cursor); quit(0); - // keep the compiler happy ... + /* keep the compiler happy ... */ return(0); } diff --git a/test/torturethread.c b/test/torturethread.c index 795b60b93..b22ee2af7 100644 --- a/test/torturethread.c +++ b/test/torturethread.c @@ -36,7 +36,7 @@ int SDLCALL SubThreadFunc(void *data) { while (!*(int volatile *) data) { - ; /*SDL_Delay(10); *//* do nothing */ + ; /* SDL_Delay(10); *//* do nothing */ } return 0; } @@ -49,7 +49,7 @@ ThreadFunc(void *data) int i; int tid = (int) (uintptr_t) data; - fprintf(stderr, "Creating Thread %d\n", tid); + SDL_Log("Creating Thread %d\n", tid); for (i = 0; i < NUMTHREADS; i++) { char name[64]; @@ -58,18 +58,18 @@ ThreadFunc(void *data) sub_threads[i] = SDL_CreateThread(SubThreadFunc, name, &flags[i]); } - printf("Thread '%d' waiting for signal\n", tid); + SDL_Log("Thread '%d' waiting for signal\n", tid); while (time_for_threads_to_die[tid] != 1) { ; /* do nothing */ } - printf("Thread '%d' sending signals to subthreads\n", tid); + SDL_Log("Thread '%d' sending signals to subthreads\n", tid); for (i = 0; i < NUMTHREADS; i++) { flags[i] = 1; SDL_WaitThread(sub_threads[i], NULL); } - printf("Thread '%d' exiting!\n", tid); + SDL_Log("Thread '%d' exiting!\n", tid); return 0; } @@ -80,9 +80,12 @@ main(int argc, char *argv[]) SDL_Thread *threads[NUMTHREADS]; int i; + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Load the SDL library */ if (SDL_Init(0) < 0) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } @@ -94,7 +97,7 @@ main(int argc, char *argv[]) threads[i] = SDL_CreateThread(ThreadFunc, name, (void*) (uintptr_t) i); if (threads[i] == NULL) { - fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError()); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError()); quit(1); } }