1.1 --- a/CMakeLists.txt Thu Jan 15 01:06:14 2015 -0400
1.2 +++ b/CMakeLists.txt Thu Jan 15 01:15:24 2015 -0400
1.3 @@ -2,7 +2,7 @@
1.4 message(FATAL_ERROR "Prevented in-tree built. Please create a build directory outside of the SDL source code and call cmake from there")
1.5 endif()
1.6
1.7 -cmake_minimum_required(VERSION 2.6)
1.8 +cmake_minimum_required(VERSION 2.8)
1.9 project(SDL2 C)
1.10 include(CheckFunctionExists)
1.11 include(CheckLibraryExists)
1.12 @@ -117,6 +117,12 @@
1.13 set(UNIX_OR_MAC_SYS OFF)
1.14 endif()
1.15
1.16 +if (UNIX_OR_MAC_SYS AND NOT EMSCRIPTEN) # JavaScript does not yet have threading support, so disable pthreads when building for Emscripten.
1.17 + set(PTHREADS_ENABLED_BY_DEFAULT ON)
1.18 +else()
1.19 + set(PTHREADS_ENABLED_BY_DEFAULT OFF)
1.20 +endif()
1.21 +
1.22 # Default option knobs
1.23 if(APPLE OR ARCH_64)
1.24 set(OPT_DEF_SSEMATH ON)
1.25 @@ -144,7 +150,7 @@
1.26 if(USE_GCC OR USE_CLANG)
1.27 set(CMAKE_C_FLAGS "-g -O3")
1.28 endif()
1.29 -else("$ENV{CFLAGS}" STREQUAL "")
1.30 +else()
1.31 set(CMAKE_C_FLAGS "$ENV{CFLAGS}")
1.32 list(APPEND EXTRA_CFLAGS "$ENV{CFLAGS}")
1.33 endif()
1.34 @@ -161,7 +167,7 @@
1.35 if(${flag_var} MATCHES "/MD")
1.36 string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
1.37 endif()
1.38 - endforeach(flag_var)
1.39 + endforeach()
1.40 endif()
1.41 endif()
1.42
1.43 @@ -170,13 +176,19 @@
1.44 set(SDL_LIBS "-lSDL2")
1.45 set(SDL_CFLAGS "")
1.46
1.47 +# Emscripten toolchain has a nonempty default value for this, and the checks
1.48 +# in this file need to change that, so remember the original value, and
1.49 +# restore back to that afterwards. For check_function_exists() to work in
1.50 +# Emscripten, this value must be at its default value.
1.51 +set(ORIG_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
1.52 +
1.53 if(CYGWIN)
1.54 # We build SDL on cygwin without the UNIX emulation layer
1.55 include_directories("-I/usr/include/mingw")
1.56 set(CMAKE_REQUIRED_FLAGS "-mno-cygwin")
1.57 check_c_source_compiles("int main(int argc, char **argv) {}"
1.58 HAVE_GCC_NO_CYGWIN)
1.59 - set(CMAKE_REQUIRED_FLAGS)
1.60 + set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
1.61 if(HAVE_GCC_NO_CYGWIN)
1.62 list(APPEND EXTRA_LDFLAGS "-mno-cygwin")
1.63 list(APPEND SDL_LIBS "-mno-cygwin")
1.64 @@ -188,12 +200,30 @@
1.65 # General includes
1.66 include_directories(${SDL2_BINARY_DIR}/include ${SDL2_SOURCE_DIR}/include)
1.67
1.68 +# All these ENABLED_BY_DEFAULT vars will default to ON if not specified, so
1.69 +# you only need to have a platform override them if they are disabling.
1.70 +if(EMSCRIPTEN)
1.71 + # Set up default values for the currently supported set of subsystems:
1.72 + # Emscripten/Javascript does not have assembly support, a dynamic library
1.73 + # loading architecture, low-level CPU inspection or multithreading.
1.74 + set(OPT_DEF_ASM FALSE)
1.75 + set(SDL_SHARED_ENABLED_BY_DEFAULT OFF)
1.76 + set(SDL_ATOMIC_ENABLED_BY_DEFAULT OFF)
1.77 + set(SDL_THREADS_ENABLED_BY_DEFAULT OFF)
1.78 + set(SDL_LOADSO_ENABLED_BY_DEFAULT OFF)
1.79 + set(SDL_CPUINFO_ENABLED_BY_DEFAULT OFF)
1.80 + set(DLOPEN_ENABLED_BY_DEFAULT OFF)
1.81 +endif()
1.82 +
1.83 set(SDL_SUBSYSTEMS
1.84 Atomic Audio Video Render Events Joystick Haptic Power Threads Timers
1.85 File Loadso CPUinfo Filesystem)
1.86 foreach(_SUB ${SDL_SUBSYSTEMS})
1.87 string(TOUPPER ${_SUB} _OPT)
1.88 - option(SDL_${_OPT} "Enable the ${_SUB} subsystem" ON)
1.89 + if (NOT DEFINED SDL_${_OPT}_ENABLED_BY_DEFAULT)
1.90 + set(SDL_${_OPT}_ENABLED_BY_DEFAULT ON)
1.91 + endif()
1.92 + option(SDL_${_OPT} "Enable the ${_SUB} subsystem" ${SDL_${_OPT}_ENABLED_BY_DEFAULT})
1.93 endforeach()
1.94
1.95 option_string(ASSERTIONS "Enable internal sanity checks (auto/disabled/release/enabled/paranoid)" "auto")
1.96 @@ -216,9 +246,9 @@
1.97 set_option(VIDEO_DUMMY "Use dummy video driver" ON)
1.98 set_option(VIDEO_OPENGL "Include OpenGL support" ON)
1.99 set_option(VIDEO_OPENGLES "Include OpenGL ES support" ON)
1.100 -set_option(PTHREADS "Use POSIX threads for multi-threading" ${UNIX_OR_MAC_SYS})
1.101 +set_option(PTHREADS "Use POSIX threads for multi-threading" ${PTHREADS_ENABLED_BY_DEFAULT})
1.102 dep_option(PTHREADS_SEM "Use pthread semaphores" ON "PTHREADS" OFF)
1.103 -set_option(SDL_DLOPEN "Use dlopen for shared object loading" ON)
1.104 +set_option(SDL_DLOPEN "Use dlopen for shared object loading" ${DLOPEN_ENABLED_BY_DEFAULT})
1.105 set_option(OSS "Support the OSS audio API" ${UNIX_SYS})
1.106 set_option(ALSA "Support the ALSA audio API" ${UNIX_SYS})
1.107 dep_option(ALSA_SHARED "Dynamically load ALSA audio support" ON "ALSA" OFF)
1.108 @@ -251,7 +281,7 @@
1.109
1.110 # TODO: We should (should we?) respect cmake's ${BUILD_SHARED_LIBS} flag here
1.111 # The options below are for compatibility to configure's default behaviour.
1.112 -set(SDL_SHARED ON CACHE BOOL "Build a shared version of the library")
1.113 +set(SDL_SHARED ${SDL_SHARED_ENABLED_BY_DEFAULT} CACHE BOOL "Build a shared version of the library")
1.114 set(SDL_STATIC ON CACHE BOOL "Build a static version of the library")
1.115
1.116 # General source files
1.117 @@ -317,7 +347,7 @@
1.118 set(CMAKE_REQUIRED_FLAGS "-mpreferred-stack-boundary=2")
1.119 check_c_source_compiles("int x = 0; int main(int argc, char **argv) {}"
1.120 HAVE_GCC_PREFERRED_STACK_BOUNDARY)
1.121 - set(CMAKE_REQUIRED_FLAGS)
1.122 + set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
1.123
1.124 set(CMAKE_REQUIRED_FLAGS "-fvisibility=hidden -Werror")
1.125 check_c_source_compiles("
1.126 @@ -328,7 +358,7 @@
1.127 if(HAVE_GCC_FVISIBILITY)
1.128 list(APPEND EXTRA_CFLAGS "-fvisibility=hidden")
1.129 endif()
1.130 - set(CMAKE_REQUIRED_FLAGS)
1.131 + set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
1.132
1.133 check_c_compiler_flag(-Wall HAVE_GCC_WALL)
1.134 if(HAVE_GCC_WALL)
1.135 @@ -376,7 +406,7 @@
1.136 if(HAVE_MMX)
1.137 list(APPEND EXTRA_CFLAGS "-mmmx")
1.138 endif()
1.139 - set(CMAKE_REQUIRED_FLAGS)
1.140 + set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
1.141 endif()
1.142
1.143 if(3DNOW)
1.144 @@ -393,7 +423,7 @@
1.145 if(HAVE_3DNOW)
1.146 list(APPEND EXTRA_CFLAGS "-m3dnow")
1.147 endif()
1.148 - set(CMAKE_REQUIRED_FLAGS)
1.149 + set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
1.150 endif()
1.151
1.152 if(SSE)
1.153 @@ -416,7 +446,7 @@
1.154 if(HAVE_SSE)
1.155 list(APPEND EXTRA_CFLAGS "-msse")
1.156 endif()
1.157 - set(CMAKE_REQUIRED_FLAGS)
1.158 + set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
1.159 endif()
1.160
1.161 if(SSE2)
1.162 @@ -439,7 +469,7 @@
1.163 if(HAVE_SSE2)
1.164 list(APPEND EXTRA_CFLAGS "-msse2")
1.165 endif()
1.166 - set(CMAKE_REQUIRED_FLAGS)
1.167 + set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
1.168 endif()
1.169
1.170 if(SSEMATH)
1.171 @@ -464,7 +494,7 @@
1.172 return vec_splat_u32(0);
1.173 }
1.174 int main(int argc, char **argv) { }" HAVE_ALTIVEC)
1.175 - set(CMAKE_REQUIRED_FLAGS)
1.176 + set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
1.177 if(HAVE_ALTIVEC OR HAVE_ALTIVEC_H_HDR)
1.178 set(HAVE_ALTIVEC TRUE) # if only HAVE_ALTIVEC_H_HDR is set
1.179 list(APPEND EXTRA_CFLAGS "-maltivec")
1.180 @@ -486,7 +516,7 @@
1.181 set(SDL_ASSEMBLY_ROUTINES 1)
1.182 endif()
1.183 # TODO:
1.184 -#else(ASSEMBLY)
1.185 +#else()
1.186 # if(USE_GCC OR USE_CLANG)
1.187 # list(APPEND EXTRA_CFLAGS "-mno-sse" "-mno-sse2" "-mno-mmx")
1.188 # endif()
1.189 @@ -518,7 +548,7 @@
1.190 set(HAVE_M_PI 1)
1.191 add_definitions(-D_USE_MATH_DEFINES) # needed for M_PI
1.192 set(STDC_HEADERS 1)
1.193 - else(WINDOWS AND NOT MINGW)
1.194 + else()
1.195 set(HAVE_LIBC TRUE)
1.196 check_include_file(sys/types.h HAVE_SYS_TYPES_H)
1.197 foreach(_HEADER
1.198 @@ -571,7 +601,7 @@
1.199
1.200 check_struct_has_member("struct sigaction" "sa_sigaction" "signal.h" HAVE_SA_SIGACTION)
1.201 endif()
1.202 -else(LIBC)
1.203 +else()
1.204 if(WINDOWS)
1.205 set(HAVE_STDARG_H 1)
1.206 set(HAVE_STDDEF_H 1)
1.207 @@ -642,7 +672,49 @@
1.208 endif()
1.209
1.210 # Platform-specific options and settings
1.211 -if(UNIX AND NOT APPLE)
1.212 +if(EMSCRIPTEN)
1.213 + # Hide noisy warnings that intend to aid mostly during initial stages of porting a new
1.214 + # project. Uncomment at will for verbose cross-compiling -I/../ path info.
1.215 + add_definitions(-Wno-warn-absolute-paths)
1.216 + if(SDL_AUDIO)
1.217 + set(SDL_AUDIO_DRIVER_EMSCRIPTEN 1)
1.218 + file(GLOB EM_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/emscripten/*.c)
1.219 + set(SOURCE_FILES ${SOURCE_FILES} ${EM_AUDIO_SOURCES})
1.220 + set(HAVE_SDL_AUDIO TRUE)
1.221 + endif()
1.222 + if(SDL_FILESYSTEM)
1.223 + set(SDL_FILESYSTEM_EMSCRIPTEN 1)
1.224 + file(GLOB EM_FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/emscripten/*.c)
1.225 + set(SOURCE_FILES ${SOURCE_FILES} ${EM_FILESYSTEM_SOURCES})
1.226 + set(HAVE_SDL_FILESYSTEM TRUE)
1.227 + endif()
1.228 + if(SDL_JOYSTICK)
1.229 + set(SDL_JOYSTICK_EMSCRIPTEN 1)
1.230 + file(GLOB EM_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/emscripten/*.c)
1.231 + set(SOURCE_FILES ${SOURCE_FILES} ${EM_JOYSTICK_SOURCES})
1.232 + set(HAVE_SDL_JOYSTICK TRUE)
1.233 + endif()
1.234 + if(SDL_POWER)
1.235 + set(SDL_POWER_EMSCRIPTEN 1)
1.236 + file(GLOB EM_POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/emscripten/*.c)
1.237 + set(SOURCE_FILES ${SOURCE_FILES} ${EM_POWER_SOURCES})
1.238 + set(HAVE_SDL_POWER TRUE)
1.239 + endif()
1.240 + if(SDL_VIDEO)
1.241 + set(SDL_VIDEO_DRIVER_EMSCRIPTEN 1)
1.242 + file(GLOB EM_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/emscripten/*.c)
1.243 + set(SOURCE_FILES ${SOURCE_FILES} ${EM_VIDEO_SOURCES})
1.244 + set(HAVE_SDL_VIDEO TRUE)
1.245 +
1.246 + #enable gles
1.247 + if(VIDEO_OPENGLES)
1.248 + set(SDL_VIDEO_OPENGL_EGL 1)
1.249 + set(HAVE_VIDEO_OPENGLES TRUE)
1.250 + set(SDL_VIDEO_OPENGL_ES2 1)
1.251 + set(SDL_VIDEO_RENDER_OGL_ES2 1)
1.252 + endif()
1.253 + endif()
1.254 +elseif(UNIX AND NOT APPLE)
1.255 if(SDL_AUDIO)
1.256 if(SYSV5 OR SOLARIS OR HPUX)
1.257 set(SDL_AUDIO_DRIVER_SUNAUDIO 1)
1.258 @@ -752,7 +824,7 @@
1.259 if(FOUND_CLOCK_GETTIME)
1.260 list(APPEND EXTRA_LIBS rt)
1.261 set(HAVE_CLOCK_GETTIME 1)
1.262 - else(FOUND_CLOCK_GETTIME)
1.263 + else()
1.264 check_library_exists(c clock_gettime "" FOUND_CLOCK_GETTIME)
1.265 if(FOUND_CLOCK_GETTIME)
1.266 set(HAVE_CLOCK_GETTIME 1)
1.267 @@ -829,7 +901,7 @@
1.268 link_directories($ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH})
1.269 include_directories($ENV{DXSDK_DIR}\\Include)
1.270 endif()
1.271 - set(CMAKE_REQUIRED_FLAGS)
1.272 + set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
1.273 endif()
1.274
1.275 if(SDL_AUDIO)
1.276 @@ -1193,14 +1265,14 @@
1.277 if(SDL_STATIC)
1.278 set(ENABLE_STATIC_TRUE "")
1.279 set(ENABLE_STATIC_FALSE "#")
1.280 - else(SDL_STATIC)
1.281 + else()
1.282 set(ENABLE_STATIC_TRUE "#")
1.283 set(ENABLE_STATIC_FALSE "")
1.284 endif()
1.285 if(SDL_SHARED)
1.286 set(ENABLE_SHARED_TRUE "")
1.287 set(ENABLE_SHARED_FALSE "#")
1.288 - else(SDL_SHARED)
1.289 + else()
1.290 set(ENABLE_SHARED_TRUE "#")
1.291 set(ENABLE_SHARED_FALSE "")
1.292 endif()
1.293 @@ -1281,7 +1353,7 @@
1.294 VERSION ${LT_VERSION}
1.295 SOVERSION ${LT_REVISION}
1.296 OUTPUT_NAME "SDL2-${LT_RELEASE}")
1.297 - else(UNIX)
1.298 + else()
1.299 set_target_properties(SDL2 PROPERTIES
1.300 VERSION ${SDL_VERSION}
1.301 SOVERSION ${LT_REVISION}
1.302 @@ -1330,7 +1402,7 @@
1.303 if(FREEBSD)
1.304 # FreeBSD uses ${PREFIX}/libdata/pkgconfig
1.305 install(FILES ${SDL2_BINARY_DIR}/sdl2.pc DESTINATION "libdata/pkgconfig")
1.306 - else(FREEBSD)
1.307 + else()
1.308 install(FILES ${SDL2_BINARY_DIR}/sdl2.pc
1.309 DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
1.310 endif()
2.1 --- a/build-scripts/config.sub Thu Jan 15 01:06:14 2015 -0400
2.2 +++ b/build-scripts/config.sub Thu Jan 15 01:15:24 2015 -0400
2.3 @@ -1534,6 +1534,8 @@
2.4 -pnacl*)
2.5 os=-pnacl
2.6 ;;
2.7 + -emscripten*)
2.8 + ;;
2.9 -none)
2.10 ;;
2.11 *)
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/build-scripts/emscripten-buildbot.sh Thu Jan 15 01:15:24 2015 -0400
3.3 @@ -0,0 +1,72 @@
3.4 +#!/bin/bash
3.5 +
3.6 +SDKDIR="/emsdk_portable"
3.7 +ENVSCRIPT="$SDKDIR/emsdk_env.sh"
3.8 +if [ ! -f "$ENVSCRIPT" ]; then
3.9 + echo "ERROR: This script expects the Emscripten SDK to be in '$SDKDIR'." 1>&2
3.10 + exit 1
3.11 +fi
3.12 +
3.13 +TARBALL="$1"
3.14 +if [ -z $1 ]; then
3.15 + TARBALL=sdl-emscripten.tar.xz
3.16 +fi
3.17 +
3.18 +cd `dirname "$0"`
3.19 +cd ..
3.20 +SDLBASE=`pwd`
3.21 +
3.22 +if [ -z "$MAKE" ]; then
3.23 + OSTYPE=`uname -s`
3.24 + if [ "$OSTYPE" == "Linux" ]; then
3.25 + NCPU=`cat /proc/cpuinfo |grep vendor_id |wc -l`
3.26 + let NCPU=$NCPU+1
3.27 + elif [ "$OSTYPE" = "Darwin" ]; then
3.28 + NCPU=`sysctl -n hw.ncpu`
3.29 + elif [ "$OSTYPE" = "SunOS" ]; then
3.30 + NCPU=`/usr/sbin/psrinfo |wc -l |sed -e 's/^ *//g;s/ *$//g'`
3.31 + else
3.32 + NCPU=1
3.33 + fi
3.34 +
3.35 + if [ -z "$NCPU" ]; then
3.36 + NCPU=1
3.37 + elif [ "$NCPU" = "0" ]; then
3.38 + NCPU=1
3.39 + fi
3.40 +
3.41 + MAKE="make -j$NCPU"
3.42 +fi
3.43 +
3.44 +echo "\$MAKE is '$MAKE'"
3.45 +
3.46 +echo "Setting up Emscripten SDK environment..."
3.47 +source "$ENVSCRIPT"
3.48 +
3.49 +echo "Setting up..."
3.50 +set -x
3.51 +cd "$SDLBASE"
3.52 +rm -rf buildbot
3.53 +mkdir buildbot
3.54 +pushd buildbot
3.55 +
3.56 +echo "Configuring..."
3.57 +emconfigure ../configure --host=asmjs-unknown-emscripten --disable-assembly --disable-threads --enable-cpuinfo=false CFLAGS="-O2 -Wno-warn-absolute-paths -Wdeclaration-after-statement -Werror=declaration-after-statement" --prefix="$PWD/emscripten-sdl2-installed"
3.58 +
3.59 +echo "Building..."
3.60 +emmake $MAKE
3.61 +
3.62 +echo "Moving things around..."
3.63 +emmake $MAKE install
3.64 +# Fix up a few things to a real install path
3.65 +perl -w -pi -e "s#$PWD/emscripten-sdl2-installed#/usr/local#g;" ./emscripten-sdl2-installed/lib/libSDL2.la ./emscripten-sdl2-installed/lib/pkgconfig/sdl2.pc ./emscripten-sdl2-installed/bin/sdl2-config
3.66 +mkdir -p ./usr
3.67 +mv ./emscripten-sdl2-installed ./usr/local
3.68 +popd
3.69 +tar -cJvvf $TARBALL -C buildbot usr
3.70 +rm -rf buildbot
3.71 +
3.72 +exit 0
3.73 +
3.74 +# end of emscripten-buildbot.sh ...
3.75 +
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/build-scripts/windows-buildbot-zipper.bat Thu Jan 15 01:15:24 2015 -0400
4.3 @@ -0,0 +1,31 @@
4.4 +@echo off
4.5 +rem just a helper batch file for collecting up files and zipping them.
4.6 +rem usage: windows-buildbot-zipper.bat <zipfilename>
4.7 +rem must be run from root of SDL source tree.
4.8 +
4.9 +IF EXIST VisualC\Win32\Release GOTO okaydir
4.10 +echo Please run from root of source tree after doing a Release build.
4.11 +GOTO done
4.12 +
4.13 +:okaydir
4.14 +erase /q /f /s zipper
4.15 +IF EXIST zipper GOTO zippermade
4.16 +mkdir zipper
4.17 +:zippermade
4.18 +cd zipper
4.19 +mkdir SDL
4.20 +cd SDL
4.21 +mkdir include
4.22 +mkdir lib
4.23 +mkdir lib\win32
4.24 +copy ..\..\include\*.h include\
4.25 +copy ..\..\VisualC\Win32\Release\SDL2.dll lib\win32\
4.26 +copy ..\..\VisualC\Win32\Release\SDL2.lib lib\win32\
4.27 +copy ..\..\VisualC\Win32\Release\SDL2main.lib lib\win32\
4.28 +cd ..
4.29 +zip -9r ..\%1 SDL
4.30 +cd ..
4.31 +erase /q /f /s zipper
4.32 +
4.33 +:done
4.34 +
5.1 --- a/cmake/sdlchecks.cmake Thu Jan 15 01:06:14 2015 -0400
5.2 +++ b/cmake/sdlchecks.cmake Thu Jan 15 01:15:24 2015 -0400
5.3 @@ -39,7 +39,7 @@
5.4 set(_DLLIB ${_LIBNAME})
5.5 set(HAVE_DLOPEN TRUE)
5.6 break()
5.7 - endif(DLOPEN_LIB)
5.8 + endif()
5.9 endforeach()
5.10 endif()
5.11
5.12 @@ -63,7 +63,7 @@
5.13 set(SOURCE_FILES ${SOURCE_FILES} ${DLOPEN_SOURCES})
5.14 set(HAVE_SDL_LOADSO TRUE)
5.15 endif()
5.16 -endmacro(CheckDLOPEN)
5.17 +endmacro()
5.18
5.19 # Requires:
5.20 # - n/a
5.21 @@ -78,23 +78,23 @@
5.22 check_c_source_compiles("
5.23 #include <soundcard.h>
5.24 int main() { int arg = SNDCTL_DSP_SETFRAGMENT; }" OSS_FOUND)
5.25 - endif(NOT OSS_FOUND)
5.26 + endif()
5.27
5.28 if(OSS_FOUND)
5.29 set(HAVE_OSS TRUE)
5.30 file(GLOB OSS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/dsp/*.c)
5.31 if(OSS_HEADER_FILE STREQUAL "soundcard.h")
5.32 set(SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H 1)
5.33 - endif(OSS_HEADER_FILE STREQUAL "soundcard.h")
5.34 + endif()
5.35 set(SDL_AUDIO_DRIVER_OSS 1)
5.36 set(SOURCE_FILES ${SOURCE_FILES} ${OSS_SOURCES})
5.37 if(NETBSD OR OPENBSD)
5.38 list(APPEND EXTRA_LIBS ossaudio)
5.39 - endif(NETBSD OR OPENBSD)
5.40 + endif()
5.41 set(HAVE_SDL_AUDIO TRUE)
5.42 - endif(OSS_FOUND)
5.43 - endif(OSS)
5.44 -endmacro(CheckOSS)
5.45 + endif()
5.46 + endif()
5.47 +endmacro()
5.48
5.49 # Requires:
5.50 # - n/a
5.51 @@ -117,14 +117,14 @@
5.52 FindLibraryAndSONAME("asound")
5.53 set(SDL_AUDIO_DRIVER_ALSA_DYNAMIC "\"${ASOUND_LIB_SONAME}\"")
5.54 set(HAVE_ALSA_SHARED TRUE)
5.55 - endif(NOT HAVE_DLOPEN)
5.56 - else(ALSA_SHARED)
5.57 + endif()
5.58 + else()
5.59 list(APPEND EXTRA_LIBS asound)
5.60 - endif(ALSA_SHARED)
5.61 + endif()
5.62 set(HAVE_SDL_AUDIO TRUE)
5.63 - endif(HAVE_ASOUNDLIB_H)
5.64 - endif(ALSA)
5.65 -endmacro(CheckALSA)
5.66 + endif()
5.67 + endif()
5.68 +endmacro()
5.69
5.70 # Requires:
5.71 # - PkgCheckModules
5.72 @@ -147,14 +147,14 @@
5.73 FindLibraryAndSONAME("pulse-simple")
5.74 set(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC "\"${PULSE_SIMPLE_LIB_SONAME}\"")
5.75 set(HAVE_PULSEAUDIO_SHARED TRUE)
5.76 - endif(NOT HAVE_DLOPEN)
5.77 - else(PULSEAUDIO_SHARED)
5.78 + endif()
5.79 + else()
5.80 list(APPEND EXTRA_LDFLAGS ${PKG_PULSEAUDIO_LDFLAGS})
5.81 - endif(PULSEAUDIO_SHARED)
5.82 + endif()
5.83 set(HAVE_SDL_AUDIO TRUE)
5.84 - endif(PKG_PULSEAUDIO_FOUND)
5.85 - endif(PULSEAUDIO)
5.86 -endmacro(CheckPulseAudio)
5.87 + endif()
5.88 + endif()
5.89 +endmacro()
5.90
5.91 # Requires:
5.92 # - PkgCheckModules
5.93 @@ -177,14 +177,14 @@
5.94 FindLibraryAndSONAME(esd)
5.95 set(SDL_AUDIO_DRIVER_ESD_DYNAMIC "\"${ESD_LIB_SONAME}\"")
5.96 set(HAVE_ESD_SHARED TRUE)
5.97 - endif(NOT HAVE_DLOPEN)
5.98 - else(ESD_SHARED)
5.99 + endif()
5.100 + else()
5.101 list(APPEND EXTRA_LDFLAGS ${PKG_ESD_LDFLAGS})
5.102 - endif(ESD_SHARED)
5.103 + endif()
5.104 set(HAVE_SDL_AUDIO TRUE)
5.105 - endif(PKG_ESD_FOUND)
5.106 - endif(ESD)
5.107 -endmacro(CheckESD)
5.108 + endif()
5.109 + endif()
5.110 +endmacro()
5.111
5.112 # Requires:
5.113 # - n/a
5.114 @@ -212,14 +212,14 @@
5.115 FindLibraryAndSONAME(artsc)
5.116 set(SDL_AUDIO_DRIVER_ARTS_DYNAMIC "\"${ARTSC_LIB_SONAME}\"")
5.117 set(HAVE_ARTS_SHARED TRUE)
5.118 - endif(NOT HAVE_DLOPEN)
5.119 - else(ARTS_SHARED)
5.120 + endif()
5.121 + else()
5.122 list(APPEND EXTRA_LDFLAGS ${ARTS_LIBS})
5.123 - endif(ARTS_SHARED)
5.124 + endif()
5.125 set(HAVE_SDL_AUDIO TRUE)
5.126 - endif(ARTS_CONFIG)
5.127 - endif(ARTS)
5.128 -endmacro(CheckARTS)
5.129 + endif()
5.130 + endif()
5.131 +endmacro()
5.132
5.133 # Requires:
5.134 # - n/a
5.135 @@ -243,14 +243,14 @@
5.136 FindLibraryAndSONAME("audio")
5.137 set(SDL_AUDIO_DRIVER_NAS_DYNAMIC "\"${AUDIO_LIB_SONAME}\"")
5.138 set(HAVE_NAS_SHARED TRUE)
5.139 - endif(NOT HAVE_DLOPEN)
5.140 - else(NAS_SHARED)
5.141 + endif()
5.142 + else()
5.143 list(APPEND EXTRA_LIBS ${D_NAS_LIB})
5.144 - endif(NAS_SHARED)
5.145 + endif()
5.146 set(HAVE_SDL_AUDIO TRUE)
5.147 - endif(HAVE_NAS_H AND D_NAS_LIB)
5.148 - endif(NAS)
5.149 -endmacro(CheckNAS)
5.150 + endif()
5.151 + endif()
5.152 +endmacro()
5.153
5.154 # Requires:
5.155 # - n/a
5.156 @@ -274,14 +274,14 @@
5.157 FindLibraryAndSONAME("sndio")
5.158 set(SDL_AUDIO_DRIVER_SNDIO_DYNAMIC "\"${SNDIO_LIB_SONAME}\"")
5.159 set(HAVE_SNDIO_SHARED TRUE)
5.160 - endif(NOT HAVE_DLOPEN)
5.161 - else(SNDIO_SHARED)
5.162 + endif()
5.163 + else()
5.164 list(APPEND EXTRA_LIBS ${D_SNDIO_LIB})
5.165 - endif(SNDIO_SHARED)
5.166 + endif()
5.167 set(HAVE_SDL_AUDIO TRUE)
5.168 - endif(HAVE_SNDIO_H AND D_SNDIO_LIB)
5.169 - endif(SNDIO)
5.170 -endmacro(CheckSNDIO)
5.171 + endif()
5.172 + endif()
5.173 +endmacro()
5.174
5.175 # Requires:
5.176 # - PkgCheckModules
5.177 @@ -304,14 +304,14 @@
5.178 FindLibraryAndSONAME("fusionsound")
5.179 set(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC "\"${FUSIONSOUND_LIB_SONAME}\"")
5.180 set(HAVE_FUSIONSOUND_SHARED TRUE)
5.181 - endif(NOT HAVE_DLOPEN)
5.182 - else(FUSIONSOUND_SHARED)
5.183 + endif()
5.184 + else()
5.185 list(APPEND EXTRA_LDFLAGS ${PKG_FUSIONSOUND_LDFLAGS})
5.186 - endif(FUSIONSOUND_SHARED)
5.187 + endif()
5.188 set(HAVE_SDL_AUDIO TRUE)
5.189 - endif(PKG_FUSIONSOUND_FOUND)
5.190 - endif(FUSIONSOUND)
5.191 -endmacro(CheckFusionSound)
5.192 + endif()
5.193 + endif()
5.194 +endmacro()
5.195
5.196 # Requires:
5.197 # - n/a
5.198 @@ -353,34 +353,34 @@
5.199
5.200 if(APPLE)
5.201 set(X11_SHARED OFF)
5.202 - endif(APPLE)
5.203 + endif()
5.204
5.205 check_function_exists("shmat" HAVE_SHMAT)
5.206 if(NOT HAVE_SHMAT)
5.207 check_library_exists(ipc shmat "" HAVE_SHMAT)
5.208 if(HAVE_SHMAT)
5.209 list(APPEND EXTRA_LIBS ipc)
5.210 - endif(HAVE_SHMAT)
5.211 + endif()
5.212 if(NOT HAVE_SHMAT)
5.213 add_definitions(-DNO_SHARED_MEMORY)
5.214 set(X_CFLAGS "${X_CFLAGS} -DNO_SHARED_MEMORY")
5.215 - endif(NOT HAVE_SHMAT)
5.216 - endif(NOT HAVE_SHMAT)
5.217 + endif()
5.218 + endif()
5.219
5.220 if(X11_SHARED)
5.221 if(NOT HAVE_DLOPEN)
5.222 message_warn("You must have SDL_LoadObject() support for dynamic X11 loading")
5.223 set(HAVE_X11_SHARED FALSE)
5.224 - else(NOT HAVE_DLOPEN)
5.225 + else()
5.226 set(HAVE_X11_SHARED TRUE)
5.227 endif()
5.228 if(HAVE_X11_SHARED)
5.229 set(SDL_VIDEO_DRIVER_X11_DYNAMIC "\"${X11_LIB_SONAME}\"")
5.230 set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "\"${XEXT_LIB_SONAME}\"")
5.231 - else(HAVE_X11_SHARED)
5.232 + else()
5.233 list(APPEND EXTRA_LIBS ${X11_LIB} ${XEXT_LIB})
5.234 - endif(HAVE_X11_SHARED)
5.235 - endif(X11_SHARED)
5.236 + endif()
5.237 + endif()
5.238
5.239 set(SDL_CFLAGS "${SDL_CFLAGS} ${X_CFLAGS}")
5.240
5.241 @@ -394,7 +394,7 @@
5.242 int main(int argc, char **argv) {}" HAVE_CONST_XEXT_ADDDISPLAY)
5.243 if(HAVE_CONST_XEXT_ADDDISPLAY)
5.244 set(SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY 1)
5.245 - endif(HAVE_CONST_XEXT_ADDDISPLAY)
5.246 + endif()
5.247
5.248 check_c_source_compiles("
5.249 #include <X11/Xlib.h>
5.250 @@ -407,7 +407,7 @@
5.251 XFreeEventData(display, cookie); }" HAVE_XGENERICEVENT)
5.252 if(HAVE_XGENERICEVENT)
5.253 set(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1)
5.254 - endif(HAVE_XGENERICEVENT)
5.255 + endif()
5.256
5.257 check_c_source_compiles("
5.258 #include <X11/Xlibint.h>
5.259 @@ -415,7 +415,7 @@
5.260 int main(int argc, char **argv) {}" HAVE_CONST_XDATA32)
5.261 if(HAVE_CONST_XDATA32)
5.262 set(SDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32 1)
5.263 - endif(HAVE_CONST_XDATA32)
5.264 + endif()
5.265
5.266 check_function_exists(XkbKeycodeToKeysym SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM)
5.267
5.268 @@ -423,29 +423,29 @@
5.269 set(HAVE_VIDEO_X11_XCURSOR TRUE)
5.270 if(HAVE_X11_SHARED AND XCURSOR_LIB)
5.271 set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR "\"${XCURSOR_LIB_SONAME}\"")
5.272 - else(HAVE_X11_SHARED AND XCURSOR_LIB)
5.273 + else()
5.274 list(APPEND EXTRA_LIBS ${XCURSOR_LIB})
5.275 - endif(HAVE_X11_SHARED AND XCURSOR_LIB)
5.276 + endif()
5.277 set(SDL_VIDEO_DRIVER_X11_XCURSOR 1)
5.278 - endif(VIDEO_X11_XCURSOR AND HAVE_XCURSOR_H)
5.279 + endif()
5.280
5.281 if(VIDEO_X11_XINERAMA AND HAVE_XINERAMA_H)
5.282 set(HAVE_VIDEO_X11_XINERAMA TRUE)
5.283 if(HAVE_X11_SHARED AND XINERAMA_LIB)
5.284 set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "\"${XINERAMA_LIB_SONAME}\"")
5.285 - else(HAVE_X11_SHARED AND XINERAMA_LIB)
5.286 + else()
5.287 list(APPEND EXTRA_LIBS ${XINERAMA_LIB})
5.288 - endif(HAVE_X11_SHARED AND XINERAMA_LIB)
5.289 + endif()
5.290 set(SDL_VIDEO_DRIVER_X11_XINERAMA 1)
5.291 - endif(VIDEO_X11_XINERAMA AND HAVE_XINERAMA_H)
5.292 + endif()
5.293
5.294 if(VIDEO_X11_XINPUT AND HAVE_XINPUT_H)
5.295 set(HAVE_VIDEO_X11_XINPUT TRUE)
5.296 if(HAVE_X11_SHARED AND XI_LIB)
5.297 set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "\"${XI_LIB_SONAME}\"")
5.298 - else(HAVE_X11_SHARED AND XI_LIB)
5.299 + else()
5.300 list(APPEND EXTRA_LIBS ${XI_LIB})
5.301 - endif(HAVE_X11_SHARED AND XI_LIB)
5.302 + endif()
5.303 set(SDL_VIDEO_DRIVER_X11_XINPUT2 1)
5.304
5.305 # Check for multitouch
5.306 @@ -462,48 +462,48 @@
5.307 int main(int argc, char **argv) {}" HAVE_XINPUT2_MULTITOUCH)
5.308 if(HAVE_XINPUT2_MULTITOUCH)
5.309 set(SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH 1)
5.310 - endif(HAVE_XINPUT2_MULTITOUCH)
5.311 - endif(VIDEO_X11_XINPUT AND HAVE_XINPUT_H)
5.312 + endif()
5.313 + endif()
5.314
5.315 if(VIDEO_X11_XRANDR AND HAVE_XRANDR_H)
5.316 if(HAVE_X11_SHARED AND XRANDR_LIB)
5.317 set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "\"${XRANDR_LIB_SONAME}\"")
5.318 - else(HAVE_X11_SHARED AND XRANDR_LIB)
5.319 + else()
5.320 list(APPEND EXTRA_LIBS ${XRANDR_LIB})
5.321 - endif(HAVE_X11_SHARED AND XRANDR_LIB)
5.322 + endif()
5.323 set(SDL_VIDEO_DRIVER_X11_XRANDR 1)
5.324 set(HAVE_VIDEO_X11_XRANDR TRUE)
5.325 - endif(VIDEO_X11_XRANDR AND HAVE_XRANDR_H)
5.326 + endif()
5.327
5.328 if(VIDEO_X11_XSCRNSAVER AND HAVE_XSS_H)
5.329 if(HAVE_X11_SHARED AND XSS_LIB)
5.330 set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "\"${XSS_LIB_SONAME}\"")
5.331 - else(HAVE_X11_SHARED AND XSS_LIB)
5.332 + else()
5.333 list(APPEND EXTRA_LIBS ${XSS_LIB})
5.334 - endif(HAVE_X11_SHARED AND XSS_LIB)
5.335 + endif()
5.336 set(SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1)
5.337 set(HAVE_VIDEO_X11_XSCRNSAVER TRUE)
5.338 - endif(VIDEO_X11_XSCRNSAVER AND HAVE_XSS_H)
5.339 + endif()
5.340
5.341 if(VIDEO_X11_XSHAPE AND HAVE_XSHAPE_H)
5.342 set(SDL_VIDEO_DRIVER_X11_XSHAPE 1)
5.343 set(HAVE_VIDEO_X11_XSHAPE TRUE)
5.344 - endif(VIDEO_X11_XSHAPE AND HAVE_XSHAPE_H)
5.345 + endif()
5.346
5.347 if(VIDEO_X11_XVM AND HAVE_XF86VM_H)
5.348 if(HAVE_X11_SHARED AND XXF86VM_LIB)
5.349 set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "\"${XXF86VM_LIB_SONAME}\"")
5.350 - else(HAVE_X11_SHARED AND XXF86VM_LIB)
5.351 + else()
5.352 list(APPEND EXTRA_LIBS ${XXF86VM_LIB})
5.353 - endif(HAVE_X11_SHARED AND XXF86VM_LIB)
5.354 + endif()
5.355 set(SDL_VIDEO_DRIVER_X11_XVIDMODE 1)
5.356 set(HAVE_VIDEO_X11_XVM TRUE)
5.357 - endif(VIDEO_X11_XVM AND HAVE_XF86VM_H)
5.358 + endif()
5.359
5.360 set(CMAKE_REQUIRED_LIBRARIES)
5.361 - endif(X11_LIB)
5.362 - endif(VIDEO_X11)
5.363 -endmacro(CheckX11)
5.364 + endif()
5.365 + endif()
5.366 +endmacro()
5.367
5.368 macro(CheckMir)
5.369 # !!! FIXME: hook up dynamic loading here.
5.370 @@ -524,8 +524,8 @@
5.371 list(APPEND EXTRA_CFLAGS ${MIR_TOOLKIT_CFLAGS} ${EGL_CLFAGS} ${XKB_CLFLAGS})
5.372 list(APPEND EXTRA_LDFLAGS ${MIR_TOOLKIT_LDFLAGS} ${EGL_LDLAGS} ${XKB_LDLAGS})
5.373 endif (MIR_LIB AND MIR_TOOLKIT_FOUND AND EGL_FOUND AND XKB_FOUND)
5.374 - endif(VIDEO_MIR)
5.375 -endmacro(CheckMir)
5.376 + endif()
5.377 +endmacro()
5.378
5.379 # Requires:
5.380 # - EGL
5.381 @@ -547,9 +547,9 @@
5.382 file(GLOB WAYLAND_SOURCES ${SDL2_SOURCE_DIR}/src/video/wayland/*.c)
5.383 set(SOURCE_FILES ${SOURCE_FILES} ${WAYLAND_SOURCES})
5.384 set(SDL_VIDEO_DRIVER_WAYLAND 1)
5.385 - endif(WAYLAND_FOUND)
5.386 - endif(VIDEO_WAYLAND)
5.387 -endmacro(CheckWayland)
5.388 + endif()
5.389 + endif()
5.390 +endmacro()
5.391
5.392 # Requires:
5.393 # - n/a
5.394 @@ -558,16 +558,16 @@
5.395 if(VIDEO_COCOA)
5.396 if(APPLE) # Apple always has Cocoa.
5.397 set(HAVE_VIDEO_COCOA TRUE)
5.398 - endif(APPLE)
5.399 + endif()
5.400 if(HAVE_VIDEO_COCOA)
5.401 file(GLOB COCOA_SOURCES ${SDL2_SOURCE_DIR}/src/video/cocoa/*.m)
5.402 set_source_files_properties(${COCOA_SOURCES} PROPERTIES LANGUAGE C)
5.403 set(SOURCE_FILES ${SOURCE_FILES} ${COCOA_SOURCES})
5.404 set(SDL_VIDEO_DRIVER_COCOA 1)
5.405 set(HAVE_SDL_VIDEO TRUE)
5.406 - endif(HAVE_VIDEO_COCOA)
5.407 - endif(VIDEO_COCOA)
5.408 -endmacro(CheckCOCOA)
5.409 + endif()
5.410 + endif()
5.411 +endmacro()
5.412
5.413 # Requires:
5.414 # - PkgCheckModules
5.415 @@ -591,14 +591,14 @@
5.416 FindLibraryAndSONAME("directfb")
5.417 set(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC "\"${DIRECTFB_LIB_SONAME}\"")
5.418 set(HAVE_DIRECTFB_SHARED TRUE)
5.419 - endif(NOT HAVE_DLOPEN)
5.420 - else(DIRECTFB_SHARED)
5.421 + endif()
5.422 + else()
5.423 list(APPEND EXTRA_LDFLAGS ${PKG_DIRECTFB_LDFLAGS})
5.424 - endif(DIRECTFB_SHARED)
5.425 + endif()
5.426 set(HAVE_SDL_VIDEO TRUE)
5.427 - endif(PKG_DIRECTFB_FOUND)
5.428 - endif(VIDEO_DIRECTFB)
5.429 -endmacro(CheckDirectFB)
5.430 + endif()
5.431 + endif()
5.432 +endmacro()
5.433
5.434 # Requires:
5.435 # - n/a
5.436 @@ -645,9 +645,9 @@
5.437 set(SDL_VIDEO_OPENGL_GLX 1)
5.438 set(SDL_VIDEO_RENDER_OGL 1)
5.439 list(APPEND EXTRA_LIBS GL)
5.440 - endif(HAVE_VIDEO_OPENGL)
5.441 - endif(VIDEO_OPENGL)
5.442 -endmacro(CheckOpenGLX11)
5.443 + endif()
5.444 + endif()
5.445 +endmacro()
5.446
5.447 # Requires:
5.448 # - nada
5.449 @@ -659,7 +659,7 @@
5.450 int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGL_EGL)
5.451 if(HAVE_VIDEO_OPENGL_EGL)
5.452 set(SDL_VIDEO_OPENGL_EGL 1)
5.453 - endif(HAVE_VIDEO_OPENGL_EGL)
5.454 + endif()
5.455 check_c_source_compiles("
5.456 #include <GLES/gl.h>
5.457 #include <GLES/glext.h>
5.458 @@ -668,7 +668,7 @@
5.459 set(HAVE_VIDEO_OPENGLES TRUE)
5.460 set(SDL_VIDEO_OPENGL_ES 1)
5.461 set(SDL_VIDEO_RENDER_OGL_ES 1)
5.462 - endif(HAVE_VIDEO_OPENGLES_V1)
5.463 + endif()
5.464 check_c_source_compiles("
5.465 #include <GLES2/gl2.h>
5.466 #include <GLES2/gl2ext.h>
5.467 @@ -677,10 +677,10 @@
5.468 set(HAVE_VIDEO_OPENGLES TRUE)
5.469 set(SDL_VIDEO_OPENGL_ES2 1)
5.470 set(SDL_VIDEO_RENDER_OGL_ES2 1)
5.471 - endif(HAVE_VIDEO_OPENGLES_V2)
5.472 + endif()
5.473
5.474 - endif(VIDEO_OPENGLES)
5.475 -endmacro(CheckOpenGLESX11)
5.476 + endif()
5.477 +endmacro()
5.478
5.479 # Rquires:
5.480 # - nada
5.481 @@ -729,7 +729,7 @@
5.482 else()
5.483 set(PTHREAD_CFLAGS "-D_REENTRANT")
5.484 set(PTHREAD_LDFLAGS "-lpthread")
5.485 - endif(LINUX)
5.486 + endif()
5.487
5.488 # Run some tests
5.489 set(CMAKE_REQUIRED_FLAGS "${PTHREAD_CFLAGS} ${PTHREAD_LDFLAGS}")
5.490 @@ -756,7 +756,7 @@
5.491 }" HAVE_RECURSIVE_MUTEXES)
5.492 if(HAVE_RECURSIVE_MUTEXES)
5.493 set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1)
5.494 - else(HAVE_RECURSIVE_MUTEXES)
5.495 + else()
5.496 check_c_source_compiles("
5.497 #include <pthread.h>
5.498 int main(int argc, char **argv) {
5.499 @@ -766,8 +766,8 @@
5.500 }" HAVE_RECURSIVE_MUTEXES_NP)
5.501 if(HAVE_RECURSIVE_MUTEXES_NP)
5.502 set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1)
5.503 - endif(HAVE_RECURSIVE_MUTEXES_NP)
5.504 - endif(HAVE_RECURSIVE_MUTEXES)
5.505 + endif()
5.506 + endif()
5.507
5.508 if(PTHREADS_SEM)
5.509 check_c_source_compiles("#include <pthread.h>
5.510 @@ -781,8 +781,8 @@
5.511 sem_timedwait(NULL, NULL);
5.512 return 0;
5.513 }" HAVE_SEM_TIMEDWAIT)
5.514 - endif(HAVE_PTHREADS_SEM)
5.515 - endif(PTHREADS_SEM)
5.516 + endif()
5.517 + endif()
5.518
5.519 check_c_source_compiles("
5.520 #include <pthread.h>
5.521 @@ -801,14 +801,14 @@
5.522 if(HAVE_PTHREADS_SEM)
5.523 set(SOURCE_FILES ${SOURCE_FILES}
5.524 ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_syssem.c)
5.525 - else(HAVE_PTHREADS_SEM)
5.526 + else()
5.527 set(SOURCE_FILES ${SOURCE_FILES}
5.528 ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_syssem.c)
5.529 - endif(HAVE_PTHREADS_SEM)
5.530 + endif()
5.531 set(HAVE_SDL_THREADS TRUE)
5.532 - endif(HAVE_PTHREADS)
5.533 - endif(PTHREADS)
5.534 -endmacro(CheckPTHREAD)
5.535 + endif()
5.536 + endif()
5.537 +endmacro()
5.538
5.539 # Requires
5.540 # - nada
5.541 @@ -822,27 +822,27 @@
5.542 check_include_file(usbhid.h HAVE_USBHID_H)
5.543 if(HAVE_USBHID_H)
5.544 set(USB_CFLAGS "-DHAVE_USBHID_H")
5.545 - endif(HAVE_USBHID_H)
5.546 + endif()
5.547
5.548 check_include_file(libusbhid.h HAVE_LIBUSBHID_H)
5.549 if(HAVE_LIBUSBHID_H)
5.550 set(USB_CFLAGS "${USB_CFLAGS} -DHAVE_LIBUSBHID_H")
5.551 - endif(HAVE_LIBUSBHID_H)
5.552 + endif()
5.553 set(USB_LIBS ${USB_LIBS} usbhid)
5.554 - else(LIBUSBHID)
5.555 + else()
5.556 check_include_file(usb.h HAVE_USB_H)
5.557 if(HAVE_USB_H)
5.558 set(USB_CFLAGS "-DHAVE_USB_H")
5.559 - endif(HAVE_USB_H)
5.560 + endif()
5.561 check_include_file(libusb.h HAVE_LIBUSB_H)
5.562 if(HAVE_LIBUSB_H)
5.563 set(USB_CFLAGS "${USB_CFLAGS} -DHAVE_LIBUSB_H")
5.564 - endif(HAVE_LIBUSB_H)
5.565 + endif()
5.566 check_library_exists(usb hid_init "" LIBUSB)
5.567 if(LIBUSB)
5.568 set(USB_LIBS ${USB_LIBS} usb)
5.569 - endif(LIBUSB)
5.570 - endif(LIBUSBHID)
5.571 + endif()
5.572 + endif()
5.573
5.574 set(CMAKE_REQUIRED_FLAGS "${USB_CFLAGS}")
5.575 set(CMAKE_REQUIRED_LIBRARIES "${USB_LIBS}")
5.576 @@ -898,7 +898,7 @@
5.577 }" HAVE_USBHID_UCR_DATA)
5.578 if(HAVE_USBHID_UCR_DATA)
5.579 set(USB_CFLAGS "${USB_CFLAGS} -DUSBHID_UCR_DATA")
5.580 - endif(HAVE_USBHID_UCR_DATA)
5.581 + endif()
5.582
5.583 check_c_source_compiles("
5.584 #include <sys/types.h>
5.585 @@ -926,7 +926,7 @@
5.586 }" HAVE_USBHID_NEW)
5.587 if(HAVE_USBHID_NEW)
5.588 set(USB_CFLAGS "${USB_CFLAGS} -DUSBHID_NEW")
5.589 - endif(HAVE_USBHID_NEW)
5.590 + endif()
5.591
5.592 check_c_source_compiles("
5.593 #include <machine/joystick.h>
5.594 @@ -936,7 +936,7 @@
5.595 }" HAVE_MACHINE_JOYSTICK)
5.596 if(HAVE_MACHINE_JOYSTICK)
5.597 set(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H 1)
5.598 - endif(HAVE_MACHINE_JOYSTICK)
5.599 + endif()
5.600 set(SDL_JOYSTICK_USBHID 1)
5.601 file(GLOB BSD_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/bsd/*.c)
5.602 set(SOURCE_FILES ${SOURCE_FILES} ${BSD_JOYSTICK_SOURCES})
5.603 @@ -946,8 +946,8 @@
5.604
5.605 set(CMAKE_REQUIRED_LIBRARIES)
5.606 set(CMAKE_REQUIRED_FLAGS)
5.607 - endif(HAVE_USBHID)
5.608 -endmacro(CheckUSBHID)
5.609 + endif()
5.610 +endmacro()
5.611
5.612 # Requires:
5.613 # - n/a
6.1 --- a/configure Thu Jan 15 01:06:14 2015 -0400
6.2 +++ b/configure Thu Jan 15 01:15:24 2015 -0400
6.3 @@ -21385,6 +21385,78 @@
6.4 fi
6.5 }
6.6
6.7 +CheckEmscriptenGLES()
6.8 +{
6.9 + if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then
6.10 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EGL support" >&5
6.11 +$as_echo_n "checking for EGL support... " >&6; }
6.12 + video_opengl_egl=no
6.13 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6.14 +/* end confdefs.h. */
6.15 +
6.16 + #include <EGL/egl.h>
6.17 +
6.18 +int
6.19 +main ()
6.20 +{
6.21 +
6.22 +
6.23 + ;
6.24 + return 0;
6.25 +}
6.26 +_ACEOF
6.27 +if ac_fn_c_try_compile "$LINENO"; then :
6.28 +
6.29 + video_opengl_egl=yes
6.30 +
6.31 +fi
6.32 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
6.33 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengl_egl" >&5
6.34 +$as_echo "$video_opengl_egl" >&6; }
6.35 + if test x$video_opengl_egl = xyes; then
6.36 +
6.37 +$as_echo "#define SDL_VIDEO_OPENGL_EGL 1" >>confdefs.h
6.38 +
6.39 + fi
6.40 +
6.41 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v2 headers" >&5
6.42 +$as_echo_n "checking for OpenGL ES v2 headers... " >&6; }
6.43 + video_opengles_v2=no
6.44 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6.45 +/* end confdefs.h. */
6.46 +
6.47 + #include <GLES2/gl2.h>
6.48 + #include <GLES2/gl2ext.h>
6.49 +
6.50 +int
6.51 +main ()
6.52 +{
6.53 +
6.54 +
6.55 + ;
6.56 + return 0;
6.57 +}
6.58 +_ACEOF
6.59 +if ac_fn_c_try_compile "$LINENO"; then :
6.60 +
6.61 + video_opengles_v2=yes
6.62 +
6.63 +fi
6.64 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
6.65 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v2" >&5
6.66 +$as_echo "$video_opengles_v2" >&6; }
6.67 + if test x$video_opengles_v2 = xyes; then
6.68 +
6.69 +$as_echo "#define SDL_VIDEO_OPENGL_ES2 1" >>confdefs.h
6.70 +
6.71 +
6.72 +$as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h
6.73 +
6.74 + SUMMARY_video="${SUMMARY_video} opengl_es2"
6.75 + fi
6.76 + fi
6.77 +}
6.78 +
6.79 CheckInputEvents()
6.80 {
6.81 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Linux 2.4 unified input interface" >&5
6.82 @@ -23483,7 +23555,68 @@
6.83 SOURCES="$SOURCES $srcdir/src/filesystem/nacl/*.c"
6.84 have_filesystem=yes
6.85 fi
6.86 -
6.87 + ;;
6.88 + *-*-emscripten* )
6.89 + if test x$enable_video = xyes; then
6.90 +
6.91 +$as_echo "#define SDL_VIDEO_DRIVER_EMSCRIPTEN 1" >>confdefs.h
6.92 +
6.93 + SOURCES="$SOURCES $srcdir/src/video/emscripten/*.c"
6.94 + have_video=yes
6.95 + SUMMARY_video="${SUMMARY_video} emscripten"
6.96 + fi
6.97 +
6.98 + if test x$enable_audio = xyes; then
6.99 +
6.100 +$as_echo "#define SDL_AUDIO_DRIVER_EMSCRIPTEN 1" >>confdefs.h
6.101 +
6.102 + SOURCES="$SOURCES $srcdir/src/audio/emscripten/*.c"
6.103 + have_audio=yes
6.104 + SUMMARY_audio="${SUMMARY_audio} emscripten"
6.105 + fi
6.106 +
6.107 + CheckVisibilityHidden
6.108 + CheckDummyVideo
6.109 + CheckDiskAudio
6.110 + CheckDummyAudio
6.111 + CheckDLOPEN
6.112 + CheckClockGettime
6.113 + CheckEmscriptenGLES
6.114 +
6.115 + # Set up files for the power library
6.116 + if test x$enable_power = xyes; then
6.117 +
6.118 +$as_echo "#define SDL_POWER_EMSCRIPTEN 1" >>confdefs.h
6.119 +
6.120 + SOURCES="$SOURCES $srcdir/src/power/emscripten/*.c"
6.121 + have_power=yes
6.122 + fi
6.123 +
6.124 + # Set up files for the power library
6.125 + if test x$enable_joystick = xyes; then
6.126 +
6.127 +$as_echo "#define SDL_JOYSTICK_EMSCRIPTEN 1" >>confdefs.h
6.128 +
6.129 + SOURCES="$SOURCES $srcdir/src/joystick/emscripten/*.c"
6.130 + have_joystick=yes
6.131 + fi
6.132 +
6.133 + # Set up files for the filesystem library
6.134 + if test x$enable_filesystem = xyes; then
6.135 +
6.136 +$as_echo "#define SDL_FILESYSTEM_EMSCRIPTEN 1" >>confdefs.h
6.137 +
6.138 + SOURCES="$SOURCES $srcdir/src/filesystem/emscripten/*.c"
6.139 + have_filesystem=yes
6.140 + fi
6.141 + # Set up files for the timer library
6.142 + if test x$enable_timers = xyes; then
6.143 +
6.144 +$as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h
6.145 +
6.146 + SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
6.147 + have_timers=yes
6.148 + fi
6.149 ;;
6.150 *)
6.151 as_fn_error $? "
7.1 --- a/configure.in Thu Jan 15 01:06:14 2015 -0400
7.2 +++ b/configure.in Thu Jan 15 01:15:24 2015 -0400
7.3 @@ -2130,6 +2130,40 @@
7.4 fi
7.5 }
7.6
7.7 +CheckEmscriptenGLES()
7.8 +{
7.9 + if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then
7.10 + AC_MSG_CHECKING(for EGL support)
7.11 + video_opengl_egl=no
7.12 + AC_TRY_COMPILE([
7.13 + #include <EGL/egl.h>
7.14 + ],[
7.15 + ],[
7.16 + video_opengl_egl=yes
7.17 + ])
7.18 + AC_MSG_RESULT($video_opengl_egl)
7.19 + if test x$video_opengl_egl = xyes; then
7.20 + AC_DEFINE(SDL_VIDEO_OPENGL_EGL, 1, [ ])
7.21 + fi
7.22 +
7.23 + AC_MSG_CHECKING(for OpenGL ES v2 headers)
7.24 + video_opengles_v2=no
7.25 + AC_TRY_COMPILE([
7.26 + #include <GLES2/gl2.h>
7.27 + #include <GLES2/gl2ext.h>
7.28 + ],[
7.29 + ],[
7.30 + video_opengles_v2=yes
7.31 + ])
7.32 + AC_MSG_RESULT($video_opengles_v2)
7.33 + if test x$video_opengles_v2 = xyes; then
7.34 + AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
7.35 + AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
7.36 + SUMMARY_video="${SUMMARY_video} opengl_es2"
7.37 + fi
7.38 + fi
7.39 +}
7.40 +
7.41 dnl See if we can use the new unified event interface in Linux 2.4
7.42 CheckInputEvents()
7.43 {
7.44 @@ -3302,7 +3336,56 @@
7.45 SOURCES="$SOURCES $srcdir/src/filesystem/nacl/*.c"
7.46 have_filesystem=yes
7.47 fi
7.48 + ;;
7.49 + *-*-emscripten* )
7.50 + if test x$enable_video = xyes; then
7.51 + AC_DEFINE(SDL_VIDEO_DRIVER_EMSCRIPTEN, 1, [ ])
7.52 + SOURCES="$SOURCES $srcdir/src/video/emscripten/*.c"
7.53 + have_video=yes
7.54 + SUMMARY_video="${SUMMARY_video} emscripten"
7.55 + fi
7.56 +
7.57 + if test x$enable_audio = xyes; then
7.58 + AC_DEFINE(SDL_AUDIO_DRIVER_EMSCRIPTEN, 1, [ ])
7.59 + SOURCES="$SOURCES $srcdir/src/audio/emscripten/*.c"
7.60 + have_audio=yes
7.61 + SUMMARY_audio="${SUMMARY_audio} emscripten"
7.62 + fi
7.63 +
7.64 + CheckVisibilityHidden
7.65 + CheckDummyVideo
7.66 + CheckDiskAudio
7.67 + CheckDummyAudio
7.68 + CheckDLOPEN
7.69 + CheckClockGettime
7.70 + CheckEmscriptenGLES
7.71 +
7.72 + # Set up files for the power library
7.73 + if test x$enable_power = xyes; then
7.74 + AC_DEFINE(SDL_POWER_EMSCRIPTEN, 1, [ ])
7.75 + SOURCES="$SOURCES $srcdir/src/power/emscripten/*.c"
7.76 + have_power=yes
7.77 + fi
7.78
7.79 + # Set up files for the power library
7.80 + if test x$enable_joystick = xyes; then
7.81 + AC_DEFINE(SDL_JOYSTICK_EMSCRIPTEN, 1, [ ])
7.82 + SOURCES="$SOURCES $srcdir/src/joystick/emscripten/*.c"
7.83 + have_joystick=yes
7.84 + fi
7.85 +
7.86 + # Set up files for the filesystem library
7.87 + if test x$enable_filesystem = xyes; then
7.88 + AC_DEFINE(SDL_FILESYSTEM_EMSCRIPTEN, 1, [ ])
7.89 + SOURCES="$SOURCES $srcdir/src/filesystem/emscripten/*.c"
7.90 + have_filesystem=yes
7.91 + fi
7.92 + # Set up files for the timer library
7.93 + if test x$enable_timers = xyes; then
7.94 + AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
7.95 + SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
7.96 + have_timers=yes
7.97 + fi
7.98 ;;
7.99 *)
7.100 AC_MSG_ERROR([
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/docs/README-emscripten.md Thu Jan 15 01:15:24 2015 -0400
8.3 @@ -0,0 +1,33 @@
8.4 +Emscripten
8.5 +================================================================================
8.6 +
8.7 +Build:
8.8 +
8.9 + $ emconfigure ./configure --host=asmjs-unknown-emscripten --disable-assembly --disable-threads --enable-cpuinfo=false CFLAGS="-O2"
8.10 + $ emmake make
8.11 +
8.12 +Or with cmake:
8.13 +
8.14 + $ emconfigure cmake ..
8.15 + $ make
8.16 +
8.17 +To build one of the tests:
8.18 +
8.19 + $ cd test/
8.20 + $ emcc -O2 --js-opts 0 -g4 testdraw2.c -I../include ../build/.libs/libSDL2.a ../build/libSDL2_test.a -o a.html
8.21 +
8.22 +Uses GLES2 renderer or software
8.23 +
8.24 +tests: https://dl.dropboxusercontent.com/u/17360362/SDL2-em/index.html
8.25 +
8.26 +Some other SDL2 libraries can be easily built (assuming SDL2 is installed somewhere):
8.27 +
8.28 +SDL_mixer (http://www.libsdl.org/projects/SDL_mixer/)
8.29 +
8.30 + $ EMCONFIGURE_JS=1 emconfigure ../configure
8.31 + build as usual...
8.32 +
8.33 +SDL_gfx (http://cms.ferzkopp.net/index.php/software/13-sdl-gfx):
8.34 +
8.35 + $ EMCONFIGURE_JS=1 emconfigure ../configure --disable-mmx
8.36 + build as usual...
9.1 --- a/docs/README-winrt.md Thu Jan 15 01:06:14 2015 -0400
9.2 +++ b/docs/README-winrt.md Thu Jan 15 01:15:24 2015 -0400
9.3 @@ -116,29 +116,28 @@
9.4
9.5
9.6
9.7 -Caveats
9.8 --------
9.9 +Upgrade Notes
9.10 +-------------
9.11
9.12 -#### SDL_GetPrefPath() usage when upgrading existing WinRT apps to SDL 2.0.4
9.13 +#### SDL_GetPrefPath() usage when upgrading WinRT apps from SDL 2.0.3
9.14
9.15 -SDL 2.0.4 fixes two bugs found in SDL_GetPrefPath() which can affect
9.16 -an app's save data. These bugs only apply to WinRT apps (and not
9.17 -Windows Desktop / Win32 apps, or to apps on any other SDL platform).
9.18 -In particular, for older versions of SDL (anything before 2.0.4):
9.19 +SDL 2.0.4 fixes two bugs found in the WinRT version of SDL_GetPrefPath().
9.20 +The fixes may affect older, SDL 2.0.3-based apps' save data. Please note
9.21 +that these changes only apply to SDL-based WinRT apps, and not to apps for
9.22 +any other platform.
9.23
9.24 -1. SDL_GetPrefPath() would return an invalid path, one in which attempts
9.25 - to write files to would fail, in many cases. Some of the path elements
9.26 - returned by SDL_GetPrefPath() would not get created (as done on other
9.27 - SDL platforms). Files could be written to this path, however apps would
9.28 - need to explicitly create the missing directories first.
9.29 -
9.30 -2. SDL_GetPrefPath() would return a path inside a WinRT 'Roaming' folder,
9.31 - the contents of which could get automatically synchronized across multiple
9.32 - devices, by Windows. This process could occur while an app was running.
9.33 - Apps which were not explicitly built to handle this scenario could
9.34 - have their SDL_GetPrefPath-backed save data swapped out by Windows at
9.35 - unexpected times, which raised potential for data-loss (if apps weren't
9.36 - designed to support live file-synchronization.)
9.37 +1. SDL_GetPrefPath() would return an invalid path, one in which the path's
9.38 + directory had not been created. Attempts to create files there
9.39 + (via fopen(), for example), would fail, unless that directory was
9.40 + explicitly created beforehand.
9.41 +
9.42 +2. SDL_GetPrefPath(), for non-WinPhone-based apps, would return a path inside
9.43 + a WinRT 'Roaming' folder, the contents of which get automatically
9.44 + synchronized across multiple devices. This process can occur while an
9.45 + application runs, and can cause existing save-data to be overwritten
9.46 + at unexpected times, with data from other devices. (Windows Phone apps
9.47 + written with SDL 2.0.3 did not utilize a Roaming folder, due to API
9.48 + restrictions in Windows Phone 8.0).
9.49
9.50
9.51 SDL_GetPrefPath(), starting with SDL 2.0.4, addresses these by:
9.52 @@ -146,37 +145,14 @@
9.53 1. making sure that SDL_GetPrefPath() returns a directory in which data
9.54 can be written to immediately, without first needing to create directories.
9.55
9.56 -2. basing SDL_GetPrefPath() off of a non-Roaming / 'Local' folder, the
9.57 - contents of which do not get automatically synchronized across devices,
9.58 - and which may be safer in terms of data-integrity.
9.59 -
9.60 - Apps can, at their discretion, choose to utilize WinRT's Roaming
9.61 - functionality by calling the following before calling SDL_GetPrefPath():
9.62 -
9.63 - SDL_SetHint(SDL_HINT_WINRT_PREF_PATH_ROOT, "roaming");
9.64 +2. basing SDL_GetPrefPath() off of a different, non-Roaming folder, the
9.65 + contents of which do not automatically get synchronized across devices
9.66 + (and which require less work to use safely, in terms of data integrity).
9.67
9.68 - Alternatively, to restore SDL_GetPrefPath()'s old behavior (found in
9.69 - SDL 2.0.3, and in many pre-2.0.4 versions of SDL found on hg.libsdl.org),
9.70 - whereby a Roaming path is returned for Windows Store apps, and a Local
9.71 - folder is returned for Windows Phone apps, use the following code:
9.72 -
9.73 - SDL_SetHint(SDL_HINT_WINRT_PREF_PATH_ROOT, "old");
9.74 -
9.75 - Before using Roaming data in any capacity, it is highly recommended that
9.76 - one read the following:
9.77 -
9.78 - 1. Microsoft's documentation on the Roaming data. Details on this can be
9.79 - found on MSDN, at:
9.80 - [Guidelines for roaming app data](http://msdn.microsoft.com/en-us/library/windows/apps/hh465094.aspx).
9.81 -
9.82 - 2. the SDL documentation for SDL_HINT_WINRT_PREF_PATH_ROOT, which is
9.83 - listed inside SDL_hints.h.
9.84 -
9.85 - Please note that Roaming support is not available on Windows Phone 8.0,
9.86 - due to limitations in the OS itself. Attempts to use it will fail, with
9.87 - SDL_GetPrefPath() returning NULL (if SDL_HINT_WINRT_PREF_PATH_ROOT is
9.88 - set to "roaming" on that platform). Windows Phone 8.1 does not have this
9.89 - limitation, and does support Roaming data.
9.90 +Apps that wish to get their Roaming folder's path can do so either by using
9.91 +SDL_WinRTGetFSPathUTF8(), SDL_WinRTGetFSPathUNICODE() (which returns a
9.92 +UCS-2/wide-char string), or directly through the WinRT class,
9.93 +Windows.Storage.ApplicationData.
9.94
9.95
9.96
10.1 --- a/docs/README.md Thu Jan 15 01:06:14 2015 -0400
10.2 +++ b/docs/README.md Thu Jan 15 01:15:24 2015 -0400
10.3 @@ -33,6 +33,7 @@
10.4 - [CMake](README-cmake.md)
10.5 - [DirectFB](README-directfb.md)
10.6 - [DynAPI](README-dynapi.md)
10.7 +- [Emscripten](README-emscripten.md)
10.8 - [Gesture](README-gesture.md)
10.9 - [Mercurial](README-hg.md)
10.10 - [iOS](README-ios.md)
11.1 --- a/include/SDL_atomic.h Thu Jan 15 01:06:14 2015 -0400
11.2 +++ b/include/SDL_atomic.h Thu Jan 15 01:15:24 2015 -0400
11.3 @@ -122,7 +122,7 @@
11.4 void _ReadWriteBarrier(void);
11.5 #pragma intrinsic(_ReadWriteBarrier)
11.6 #define SDL_CompilerBarrier() _ReadWriteBarrier()
11.7 -#elif defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120))
11.8 +#elif (defined(__GNUC__) && !defined(__EMSCRIPTEN__)) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120))
11.9 /* This is correct for all CPUs when using GCC or Solaris Studio 12.1+. */
11.10 #define SDL_CompilerBarrier() __asm__ __volatile__ ("" : : : "memory")
11.11 #else
12.1 --- a/include/SDL_config.h.cmake Thu Jan 15 01:06:14 2015 -0400
12.2 +++ b/include/SDL_config.h.cmake Thu Jan 15 01:15:24 2015 -0400
12.3 @@ -217,6 +217,7 @@
12.4 #cmakedefine SDL_AUDIO_DRIVER_WINMM @SDL_AUDIO_DRIVER_WINMM@
12.5 #cmakedefine SDL_AUDIO_DRIVER_FUSIONSOUND @SDL_AUDIO_DRIVER_FUSIONSOUND@
12.6 #cmakedefine SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC @SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC@
12.7 +#cmakedefine SDL_AUDIO_DRIVER_EMSCRIPTEN @SDL_AUDIO_DRIVER_EMSCRIPTEN@
12.8
12.9 /* Enable various input drivers */
12.10 #cmakedefine SDL_INPUT_LINUXEV @SDL_INPUT_LINUXEV@
12.11 @@ -230,6 +231,7 @@
12.12 #cmakedefine SDL_JOYSTICK_WINMM @SDL_JOYSTICK_WINMM@
12.13 #cmakedefine SDL_JOYSTICK_USBHID @SDL_JOYSTICK_USBHID@
12.14 #cmakedefine SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H @SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H@
12.15 +#cmakedefine SDL_JOYSTICK_EMSCRIPTEN @SDL_JOYSTICK_EMSCRIPTEN@
12.16 #cmakedefine SDL_HAPTIC_DUMMY @SDL_HAPTIC_DUMMY@
12.17 #cmakedefine SDL_HAPTIC_LINUX @SDL_HAPTIC_LINUX@
12.18 #cmakedefine SDL_HAPTIC_IOKIT @SDL_HAPTIC_IOKIT@
12.19 @@ -279,6 +281,7 @@
12.20 #cmakedefine SDL_VIDEO_DRIVER_MIR @SDL_VIDEO_DRIVER_MIR@
12.21 #cmakedefine SDL_VIDEO_DRIVER_MIR_DYNAMIC @SDL_VIDEO_DRIVER_MIR_DYNAMIC@
12.22 #cmakedefine SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON @SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON@
12.23 +#cmakedefine SDL_VIDEO_DRIVER_EMSCRIPTEN @SDL_VIDEO_DRIVER_EMSCRIPTEN@
12.24 #cmakedefine SDL_VIDEO_DRIVER_X11 @SDL_VIDEO_DRIVER_X11@
12.25 #cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC @SDL_VIDEO_DRIVER_X11_DYNAMIC@
12.26 #cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT @SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT@
12.27 @@ -325,6 +328,7 @@
12.28 #cmakedefine SDL_POWER_WINDOWS @SDL_POWER_WINDOWS@
12.29 #cmakedefine SDL_POWER_MACOSX @SDL_POWER_MACOSX@
12.30 #cmakedefine SDL_POWER_HAIKU @SDL_POWER_HAIKU@
12.31 +#cmakedefine SDL_POWER_EMSCRIPTEN @SDL_POWER_EMSCRIPTEN@
12.32 #cmakedefine SDL_POWER_HARDWIRED @SDL_POWER_HARDWIRED@
12.33
12.34 /* Enable system filesystem support */
12.35 @@ -333,6 +337,7 @@
12.36 #cmakedefine SDL_FILESYSTEM_DUMMY @SDL_FILESYSTEM_DUMMY@
12.37 #cmakedefine SDL_FILESYSTEM_UNIX @SDL_FILESYSTEM_UNIX@
12.38 #cmakedefine SDL_FILESYSTEM_WINDOWS @SDL_FILESYSTEM_WINDOWS@
12.39 +#cmakedefine SDL_FILESYSTEM_EMSCRIPTEN @SDL_FILESYSTEM_EMSCRIPTEN@
12.40
12.41 /* Enable assembly routines */
12.42 #cmakedefine SDL_ASSEMBLY_ROUTINES @SDL_ASSEMBLY_ROUTINES@
13.1 --- a/include/SDL_config.h.in Thu Jan 15 01:06:14 2015 -0400
13.2 +++ b/include/SDL_config.h.in Thu Jan 15 01:15:24 2015 -0400
13.3 @@ -228,6 +228,7 @@
13.4 #undef SDL_AUDIO_DRIVER_WINMM
13.5 #undef SDL_AUDIO_DRIVER_FUSIONSOUND
13.6 #undef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC
13.7 +#undef SDL_AUDIO_DRIVER_EMSCRIPTEN
13.8
13.9 /* Enable various input drivers */
13.10 #undef SDL_INPUT_LINUXEV
13.11 @@ -243,6 +244,7 @@
13.12 #undef SDL_JOYSTICK_WINMM
13.13 #undef SDL_JOYSTICK_USBHID
13.14 #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H
13.15 +#undef SDL_JOYSTICK_EMSCRIPTEN
13.16 #undef SDL_HAPTIC_DUMMY
13.17 #undef SDL_HAPTIC_LINUX
13.18 #undef SDL_HAPTIC_IOKIT
13.19 @@ -287,6 +289,7 @@
13.20 #undef SDL_VIDEO_DRIVER_X11
13.21 #undef SDL_VIDEO_DRIVER_RPI
13.22 #undef SDL_VIDEO_DRIVER_ANDROID
13.23 +#undef SDL_VIDEO_DRIVER_EMSCRIPTEN
13.24 #undef SDL_VIDEO_DRIVER_X11_DYNAMIC
13.25 #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT
13.26 #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR
13.27 @@ -336,6 +339,7 @@
13.28 #undef SDL_POWER_MACOSX
13.29 #undef SDL_POWER_HAIKU
13.30 #undef SDL_POWER_ANDROID
13.31 +#undef SDL_POWER_EMSCRIPTEN
13.32 #undef SDL_POWER_HARDWIRED
13.33
13.34 /* Enable system filesystem support */
13.35 @@ -345,6 +349,7 @@
13.36 #undef SDL_FILESYSTEM_UNIX
13.37 #undef SDL_FILESYSTEM_WINDOWS
13.38 #undef SDL_FILESYSTEM_NACL
13.39 +#undef SDL_FILESYSTEM_EMSCRIPTEN
13.40
13.41 /* Enable assembly routines */
13.42 #undef SDL_ASSEMBLY_ROUTINES
14.1 --- a/include/SDL_config_winrt.h Thu Jan 15 01:06:14 2015 -0400
14.2 +++ b/include/SDL_config_winrt.h Thu Jan 15 01:15:24 2015 -0400
14.3 @@ -1,6 +1,6 @@
14.4 /*
14.5 Simple DirectMedia Layer
14.6 - Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
14.7 + Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
14.8
14.9 This software is provided 'as-is', without any express or implied
14.10 warranty. In no event will the authors be held liable for any damages
15.1 --- a/include/SDL_events.h Thu Jan 15 01:06:14 2015 -0400
15.2 +++ b/include/SDL_events.h Thu Jan 15 01:15:24 2015 -0400
15.3 @@ -260,6 +260,7 @@
15.4 Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
15.5 Sint32 x; /**< The amount scrolled horizontally, positive to the right and negative to the left */
15.6 Sint32 y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */
15.7 + Uint32 direction; /**< Set to one of the SDL_MOUSEWHEEL_* defines. When FLIPPED the values in X and Y will be opposite. Multiply by -1 to change them back */
15.8 } SDL_MouseWheelEvent;
15.9
15.10 /**
16.1 --- a/include/SDL_hints.h Thu Jan 15 01:06:14 2015 -0400
16.2 +++ b/include/SDL_hints.h Thu Jan 15 01:15:24 2015 -0400
16.3 @@ -493,36 +493,6 @@
16.4 #define SDL_HINT_WINRT_HANDLE_BACK_BUTTON "SDL_WINRT_HANDLE_BACK_BUTTON"
16.5
16.6 /**
16.7 - * \brief A variable that dictates what SDL_GetPrefPath() returns in WinRT apps.
16.8 - *
16.9 - * The variable can be set to the following values:
16.10 - * * "local" - Use the app's 'local' folder to store data.
16.11 - * * "roaming" - Use the app's 'roaming' folder to store data.
16.12 - * On Windows Phone 8.0, this setting is not supported due to
16.13 - * limitations in the OS itself. Attempts to use this (via
16.14 - * SDL_GetPrefPath()) on Windows Phone 8.0 will fail, with
16.15 - * SDL_GetPrefPath() returning NULL. (Windows Phone 8.1 does,
16.16 - * however, support roaming folders.)
16.17 - * * "old" - Use the app's 'local' folder on Windows Phone, and 'roaming'
16.18 - * on non-Phone versions of WinRT. This mimics behavior found
16.19 - * in SDL 2.0.3's implementation of SDL_GetPrefPath() for WinRT
16.20 - * (and was changed for SDL 2.0.4, further details of which are
16.21 - * in the "Caveats" section of SDL's
16.22 - * [WinRT README file](README-winrt.md).
16.23 - *
16.24 - * The default is to use the app's "local" folder.
16.25 - *
16.26 - * Details on 'local' verses 'roaming' folders can be found on MSDN, in
16.27 - * the documentation for WinRT's Windows.Storage.ApplicationData class,
16.28 - * (available at http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.applicationdata ).
16.29 - *
16.30 - * The application's local and roaming paths may, alternatively, be retrieved
16.31 - * via the SDL_WinRTGetFSPathUTF8() and SDL_WinRTGetFSPathUNICODE() functions,
16.32 - * which are defined in SDL_system.h.
16.33 - */
16.34 -#define SDL_HINT_WINRT_PREF_PATH_ROOT "SDL_WINRT_PREF_PATH_ROOT"
16.35 -
16.36 -/**
16.37 * \brief A variable that dictates policy for fullscreen Spaces on Mac OS X.
16.38 *
16.39 * This hint only applies to Mac OS X.
16.40 @@ -564,6 +534,20 @@
16.41 #define SDL_HINT_IME_INTERNAL_EDITING "SDL_IME_INTERNAL_EDITING"
16.42
16.43 /**
16.44 + * \brief override the binding element for keyboard inputs for Emscripten builds
16.45 + *
16.46 + * This hint only applies to the emscripten platform
16.47 + *
16.48 + * The variable can be one of
16.49 + * "#window" - The javascript window object (this is the default)
16.50 + * "#document" - The javascript document object
16.51 + * "#screen" - the javascript window.screen object
16.52 + * "#canvas" - the WebGL canvas element
16.53 + * any other string without a leading # sign applies to the element on the page with that ID.
16.54 + */
16.55 +#define SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT "SDL_EMSCRIPTEN_KEYBOARD_ELEMENT"
16.56 +
16.57 +/**
16.58 * \brief An enumeration of hint priorities
16.59 */
16.60 typedef enum
17.1 --- a/include/SDL_main.h Thu Jan 15 01:06:14 2015 -0400
17.2 +++ b/include/SDL_main.h Thu Jan 15 01:15:24 2015 -0400
17.3 @@ -142,14 +142,11 @@
17.4 * \brief Initializes and launches an SDL/WinRT application.
17.5 *
17.6 * \param mainFunction The SDL app's C-style main().
17.7 - * \param xamlBackgroundPanel An optional, XAML-based, background panel.
17.8 - * For Non-XAML apps, this value must be set to NULL. For XAML apps,
17.9 - * pass in a pointer to a SwapChainBackgroundPanel, casted to an
17.10 - * IInspectable (via reinterpret_cast).
17.11 + * \param reserved Reserved for future use; should be NULL
17.12 * \ret 0 on success, -1 on failure. On failure, use SDL_GetError to retrieve more
17.13 * information on the failure.
17.14 */
17.15 -extern DECLSPEC int SDLCALL SDL_WinRTRunApp(int (*mainFunction)(int, char **), void * xamlBackgroundPanel);
17.16 +extern DECLSPEC int SDLCALL SDL_WinRTRunApp(int (*mainFunction)(int, char **), void * reserved);
17.17
17.18 #endif /* __WINRT__ */
17.19
18.1 --- a/include/SDL_mouse.h Thu Jan 15 01:06:14 2015 -0400
18.2 +++ b/include/SDL_mouse.h Thu Jan 15 01:15:24 2015 -0400
18.3 @@ -60,6 +60,15 @@
18.4 SDL_NUM_SYSTEM_CURSORS
18.5 } SDL_SystemCursor;
18.6
18.7 +/**
18.8 + * \brief Scroll direction types for the Scroll event
18.9 + */
18.10 +typedef enum
18.11 +{
18.12 + SDL_MOUSEWHEEL_NORMAL, /**< The scroll direction is normal */
18.13 + SDL_MOUSEWHEEL_FLIPPED /**< The scroll direction is flipped / natural */
18.14 +} SDL_MouseWheelDirection;
18.15 +
18.16 /* Function prototypes */
18.17
18.18 /**
19.1 --- a/include/SDL_stdinc.h Thu Jan 15 01:06:14 2015 -0400
19.2 +++ b/include/SDL_stdinc.h Thu Jan 15 01:15:24 2015 -0400
19.3 @@ -172,7 +172,7 @@
19.4 #ifdef PRIs64
19.5 #define SDL_PRIs64 PRIs64
19.6 #elif defined(__WIN32__)
19.7 -#define SDL_PRIs64 "I64"
19.8 +#define SDL_PRIs64 "I64d"
19.9 #else
19.10 #define SDL_PRIs64 "lld"
19.11 #endif
19.12 @@ -186,6 +186,24 @@
19.13 #define SDL_PRIu64 "llu"
19.14 #endif
19.15 #endif
19.16 +#ifndef SDL_PRIx64
19.17 +#ifdef PRIx64
19.18 +#define SDL_PRIx64 PRIx64
19.19 +#elif defined(__WIN32__)
19.20 +#define SDL_PRIx64 "I64x"
19.21 +#else
19.22 +#define SDL_PRIx64 "llx"
19.23 +#endif
19.24 +#endif
19.25 +#ifndef SDL_PRIX64
19.26 +#ifdef PRIX64
19.27 +#define SDL_PRIX64 PRIX64
19.28 +#elif defined(__WIN32__)
19.29 +#define SDL_PRIX64 "I64X"
19.30 +#else
19.31 +#define SDL_PRIX64 "llX"
19.32 +#endif
19.33 +#endif
19.34
19.35 /* Annotations to help code analysis tools */
19.36 #ifdef SDL_DISABLE_ANALYZE_MACROS
19.37 @@ -361,11 +379,6 @@
19.38
19.39 extern DECLSPEC void *SDLCALL SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len);
19.40
19.41 -SDL_FORCE_INLINE void *SDL_memcpy4(SDL_OUT_BYTECAP(dwords*4) void *dst, SDL_IN_BYTECAP(dwords*4) const void *src, size_t dwords)
19.42 -{
19.43 - return SDL_memcpy(dst, src, dwords * 4);
19.44 -}
19.45 -
19.46 extern DECLSPEC void *SDLCALL SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len);
19.47 extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len);
19.48
19.49 @@ -462,6 +475,39 @@
19.50 #define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", S, SDL_strlen(S)+1)
19.51 #define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4-INTERNAL", "UTF-8", S, SDL_strlen(S)+1)
19.52
19.53 +/* force builds using Clang's static analysis tools to use literal C runtime
19.54 + here, since there are possibly tests that are ineffective otherwise. */
19.55 +#if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS)
19.56 +#define SDL_malloc malloc
19.57 +#define SDL_calloc calloc
19.58 +#define SDL_realloc realloc
19.59 +#define SDL_free free
19.60 +#define SDL_memset memset
19.61 +#define SDL_memcpy memcpy
19.62 +#define SDL_memmove memmove
19.63 +#define SDL_memcmp memcmp
19.64 +#define SDL_strlen strlen
19.65 +#define SDL_strlcpy strlcpy
19.66 +#define SDL_strlcat strlcat
19.67 +#define SDL_strdup strdup
19.68 +#define SDL_strchr strchr
19.69 +#define SDL_strrchr strrchr
19.70 +#define SDL_strstr strstr
19.71 +#define SDL_strcmp strcmp
19.72 +#define SDL_strncmp strncmp
19.73 +#define SDL_strcasecmp strcasecmp
19.74 +#define SDL_strncasecmp strncasecmp
19.75 +#define SDL_sscanf sscanf
19.76 +#define SDL_vsscanf vsscanf
19.77 +#define SDL_snprintf snprintf
19.78 +#define SDL_vsnprintf vsnprintf
19.79 +#endif
19.80 +
19.81 +SDL_FORCE_INLINE void *SDL_memcpy4(SDL_OUT_BYTECAP(dwords*4) void *dst, SDL_IN_BYTECAP(dwords*4) const void *src, size_t dwords)
19.82 +{
19.83 + return SDL_memcpy(dst, src, dwords * 4);
19.84 +}
19.85 +
19.86 /* Ends C function definitions when using C++ */
19.87 #ifdef __cplusplus
19.88 }
20.1 --- a/include/SDL_system.h Thu Jan 15 01:06:14 2015 -0400
20.2 +++ b/include/SDL_system.h Thu Jan 15 01:15:24 2015 -0400
20.3 @@ -43,19 +43,25 @@
20.4 /* Platform specific functions for Windows */
20.5 #ifdef __WIN32__
20.6
20.7 -/* Returns the D3D9 adapter index that matches the specified display index.
20.8 +/**
20.9 + \brief Returns the D3D9 adapter index that matches the specified display index.
20.10 +
20.11 This adapter index can be passed to IDirect3D9::CreateDevice and controls
20.12 on which monitor a full screen application will appear.
20.13 */
20.14 extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex( int displayIndex );
20.15
20.16 -/* Returns the D3D device associated with a renderer, or NULL if it's not a D3D renderer.
20.17 +typedef struct IDirect3DDevice9 IDirect3DDevice9;
20.18 +/**
20.19 + \brief Returns the D3D device associated with a renderer, or NULL if it's not a D3D renderer.
20.20 +
20.21 Once you are done using the device, you should release it to avoid a resource leak.
20.22 */
20.23 -typedef struct IDirect3DDevice9 IDirect3DDevice9;
20.24 extern DECLSPEC IDirect3DDevice9* SDLCALL SDL_RenderGetD3D9Device(SDL_Renderer * renderer);
20.25
20.26 -/* Returns the DXGI Adapter and Output indices for the specified display index.
20.27 +/**
20.28 + \brief Returns the DXGI Adapter and Output indices for the specified display index.
20.29 +
20.30 These can be passed to EnumAdapters and EnumOutputs respectively to get the objects
20.31 required to create a DX10 or DX11 device and swap chain.
20.32 */
20.33 @@ -70,12 +76,16 @@
20.34 extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
20.35 extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled);
20.36
20.37 -/* Returns the OpenGL Renderbuffer Object associated with the window's main view.
20.38 +/**
20.39 + \brief Returns the OpenGL Renderbuffer Object associated with the window's main view.
20.40 +
20.41 The Renderbuffer must be bound when calling SDL_GL_SwapWindow.
20.42 */
20.43 extern DECLSPEC Uint32 SDLCALL SDL_iPhoneGetViewRenderbuffer(SDL_Window * window);
20.44
20.45 -/* Returns the OpenGL Framebuffer Object associated with the window's main view.
20.46 +/**
20.47 + \brief Returns the OpenGL Framebuffer Object associated with the window's main view.
20.48 +
20.49 The Framebuffer must be bound when rendering to the screen.
20.50 */
20.51 extern DECLSPEC Uint32 SDLCALL SDL_iPhoneGetViewFramebuffer(SDL_Window * window);
20.52 @@ -86,12 +96,16 @@
20.53 /* Platform specific functions for Android */
20.54 #if defined(__ANDROID__) && __ANDROID__
20.55
20.56 -/* Get the JNI environment for the current thread
20.57 +/**
20.58 + \brief Get the JNI environment for the current thread
20.59 +
20.60 This returns JNIEnv*, but the prototype is void* so we don't need jni.h
20.61 */
20.62 extern DECLSPEC void * SDLCALL SDL_AndroidGetJNIEnv();
20.63
20.64 -/* Get the SDL Activity object for the application
20.65 +/**
20.66 + \brief Get the SDL Activity object for the application
20.67 +
20.68 This returns jobject, but the prototype is void* so we don't need jni.h
20.69 The jobject returned by SDL_AndroidGetActivity is a local reference.
20.70 It is the caller's responsibility to properly release it
20.71 @@ -99,26 +113,33 @@
20.72 */
20.73 extern DECLSPEC void * SDLCALL SDL_AndroidGetActivity();
20.74
20.75 -/* See the official Android developer guide for more information:
20.76 +/**
20.77 + See the official Android developer guide for more information:
20.78 http://developer.android.com/guide/topics/data/data-storage.html
20.79 */
20.80 #define SDL_ANDROID_EXTERNAL_STORAGE_READ 0x01
20.81 #define SDL_ANDROID_EXTERNAL_STORAGE_WRITE 0x02
20.82
20.83 -/* Get the path used for internal storage for this application.
20.84 +/**
20.85 + \brief Get the path used for internal storage for this application.
20.86 +
20.87 This path is unique to your application and cannot be written to
20.88 by other applications.
20.89 */
20.90 extern DECLSPEC const char * SDLCALL SDL_AndroidGetInternalStoragePath();
20.91
20.92 -/* Get the current state of external storage, a bitmask of these values:
20.93 +/**
20.94 + \brief Get the current state of external storage, a bitmask of these values:
20.95 SDL_ANDROID_EXTERNAL_STORAGE_READ
20.96 SDL_ANDROID_EXTERNAL_STORAGE_WRITE
20.97 +
20.98 If external storage is currently unavailable, this will return 0.
20.99 */
20.100 extern DECLSPEC int SDLCALL SDL_AndroidGetExternalStorageState();
20.101
20.102 -/* Get the path used for external storage for this application.
20.103 +/**
20.104 + \brief Get the path used for external storage for this application.
20.105 +
20.106 This path is unique to your application, but is public and can be
20.107 written to by other applications.
20.108 */
20.109 @@ -161,7 +182,7 @@
20.110 * http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
20.111 *
20.112 * \param pathType The type of path to retrieve.
20.113 - * \ret A UCS-2 string (16-bit, wide-char) containing the path, or NULL
20.114 + * \return A UCS-2 string (16-bit, wide-char) containing the path, or NULL
20.115 * if the path is not available for any reason. Not all paths are
20.116 * available on all versions of Windows. This is especially true on
20.117 * Windows Phone. Check the documentation for the given
20.118 @@ -178,7 +199,7 @@
20.119 * http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
20.120 *
20.121 * \param pathType The type of path to retrieve.
20.122 - * \ret A UTF-8 string (8-bit, multi-byte) containing the path, or NULL
20.123 + * \return A UTF-8 string (8-bit, multi-byte) containing the path, or NULL
20.124 * if the path is not available for any reason. Not all paths are
20.125 * available on all versions of Windows. This is especially true on
20.126 * Windows Phone. Check the documentation for the given
21.1 --- a/src/audio/SDL_audio.c Thu Jan 15 01:06:14 2015 -0400
21.2 +++ b/src/audio/SDL_audio.c Thu Jan 15 01:15:24 2015 -0400
21.3 @@ -71,6 +71,7 @@
21.4 extern AudioBootStrap ANDROIDAUD_bootstrap;
21.5 extern AudioBootStrap PSPAUD_bootstrap;
21.6 extern AudioBootStrap SNDIO_bootstrap;
21.7 +extern AudioBootStrap EmscriptenAudio_bootstrap;
21.8
21.9
21.10 /* Available audio drivers */
21.11 @@ -141,6 +142,9 @@
21.12 #if SDL_AUDIO_DRIVER_PSP
21.13 &PSPAUD_bootstrap,
21.14 #endif
21.15 +#if SDL_AUDIO_DRIVER_EMSCRIPTEN
21.16 + &EmscriptenAudio_bootstrap,
21.17 +#endif
21.18 NULL
21.19 };
21.20
22.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
22.2 +++ b/src/audio/emscripten/SDL_emscriptenaudio.c Thu Jan 15 01:15:24 2015 -0400
22.3 @@ -0,0 +1,270 @@
22.4 +/*
22.5 + Simple DirectMedia Layer
22.6 + Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
22.7 +
22.8 + This software is provided 'as-is', without any express or implied
22.9 + warranty. In no event will the authors be held liable for any damages
22.10 + arising from the use of this software.
22.11 +
22.12 + Permission is granted to anyone to use this software for any purpose,
22.13 + including commercial applications, and to alter it and redistribute it
22.14 + freely, subject to the following restrictions:
22.15 +
22.16 + 1. The origin of this software must not be misrepresented; you must not
22.17 + claim that you wrote the original software. If you use this software
22.18 + in a product, an acknowledgment in the product documentation would be
22.19 + appreciated but is not required.
22.20 + 2. Altered source versions must be plainly marked as such, and must not be
22.21 + misrepresented as being the original software.
22.22 + 3. This notice may not be removed or altered from any source distribution.
22.23 +*/
22.24 +#include "../../SDL_internal.h"
22.25 +
22.26 +#if SDL_AUDIO_DRIVER_EMSCRIPTEN
22.27 +
22.28 +#include "SDL_audio.h"
22.29 +#include "SDL_log.h"
22.30 +#include "../SDL_audio_c.h"
22.31 +#include "SDL_emscriptenaudio.h"
22.32 +
22.33 +#include <emscripten/emscripten.h>
22.34 +
22.35 +static int
22.36 +copyData(_THIS)
22.37 +{
22.38 + int byte_len;
22.39 +
22.40 + if (this->hidden->write_off + this->convert.len_cvt > this->hidden->mixlen) {
22.41 + if (this->hidden->write_off > this->hidden->read_off) {
22.42 + SDL_memmove(this->hidden->mixbuf,
22.43 + this->hidden->mixbuf + this->hidden->read_off,
22.44 + this->hidden->mixlen - this->hidden->read_off);
22.45 + this->hidden->write_off = this->hidden->write_off - this->hidden->read_off;
22.46 + } else {
22.47 + this->hidden->write_off = 0;
22.48 + }
22.49 + this->hidden->read_off = 0;
22.50 + }
22.51 +
22.52 + SDL_memcpy(this->hidden->mixbuf + this->hidden->write_off,
22.53 + this->convert.buf,
22.54 + this->convert.len_cvt);
22.55 + this->hidden->write_off += this->convert.len_cvt;
22.56 + byte_len = this->hidden->write_off - this->hidden->read_off;
22.57 +
22.58 + return byte_len;
22.59 +}
22.60 +
22.61 +static void
22.62 +HandleAudioProcess(_THIS)
22.63 +{
22.64 + Uint8 *buf = NULL;
22.65 + int byte_len = 0;
22.66 + int bytes = SDL_AUDIO_BITSIZE(this->spec.format) / 8;
22.67 + int bytes_in = SDL_AUDIO_BITSIZE(this->convert.src_format) / 8;
22.68 +
22.69 + /* Only do soemthing if audio is enabled */
22.70 + if (!this->enabled)
22.71 + return;
22.72 +
22.73 + if (this->paused)
22.74 + return;
22.75 +
22.76 + if (this->convert.needed) {
22.77 + if (this->hidden->conv_in_len != 0) {
22.78 + this->convert.len = this->hidden->conv_in_len * bytes_in * this->spec.channels;
22.79 + }
22.80 +
22.81 + (*this->spec.callback) (this->spec.userdata,
22.82 + this->convert.buf,
22.83 + this->convert.len);
22.84 + SDL_ConvertAudio(&this->convert);
22.85 + buf = this->convert.buf;
22.86 + byte_len = this->convert.len_cvt;
22.87 +
22.88 + /* size mismatch*/
22.89 + if (byte_len != this->spec.size) {
22.90 + if (!this->hidden->mixbuf) {
22.91 + this->hidden->mixlen = this->spec.size > byte_len ? this->spec.size * 2 : byte_len * 2;
22.92 + this->hidden->mixbuf = SDL_malloc(this->hidden->mixlen);
22.93 + }
22.94 +
22.95 + /* copy existing data */
22.96 + byte_len = copyData(this);
22.97 +
22.98 + /* read more data*/
22.99 + while (byte_len < this->spec.size) {
22.100 + (*this->spec.callback) (this->spec.userdata,
22.101 + this->convert.buf,
22.102 + this->convert.len);
22.103 + SDL_ConvertAudio(&this->convert);
22.104 + byte_len = copyData(this);
22.105 + }
22.106 +
22.107 + byte_len = this->spec.size;
22.108 + buf = this->hidden->mixbuf + this->hidden->read_off;
22.109 + this->hidden->read_off += byte_len;
22.110 + }
22.111 +
22.112 + } else {
22.113 + if (!this->hidden->mixbuf) {
22.114 + this->hidden->mixlen = this->spec.size;
22.115 + this->hidden->mixbuf = SDL_malloc(this->hidden->mixlen);
22.116 + }
22.117 + (*this->spec.callback) (this->spec.userdata,
22.118 + this->hidden->mixbuf,
22.119 + this->hidden->mixlen);
22.120 + buf = this->hidden->mixbuf;
22.121 + byte_len = this->hidden->mixlen;
22.122 + }
22.123 +
22.124 + if (buf) {
22.125 + EM_ASM_ARGS({
22.126 + var numChannels = SDL2.audio.currentOutputBuffer['numberOfChannels'];
22.127 + for (var c = 0; c < numChannels; ++c) {
22.128 + var channelData = SDL2.audio.currentOutputBuffer['getChannelData'](c);
22.129 + if (channelData.length != $1) {
22.130 + throw 'Web Audio output buffer length mismatch! Destination size: ' + channelData.length + ' samples vs expected ' + $1 + ' samples!';
22.131 + }
22.132 +
22.133 + for (var j = 0; j < $1; ++j) {
22.134 + channelData[j] = getValue($0 + (j*numChannels + c)*4, 'float');
22.135 + }
22.136 + }
22.137 + }, buf, byte_len / bytes / this->spec.channels);
22.138 + }
22.139 +}
22.140 +
22.141 +static void
22.142 +Emscripten_CloseDevice(_THIS)
22.143 +{
22.144 + if (this->hidden != NULL) {
22.145 + if (this->hidden->mixbuf != NULL) {
22.146 + /* Clean up the audio buffer */
22.147 + SDL_free(this->hidden->mixbuf);
22.148 + this->hidden->mixbuf = NULL;
22.149 + }
22.150 +
22.151 + SDL_free(this->hidden);
22.152 + this->hidden = NULL;
22.153 + }
22.154 +}
22.155 +
22.156 +static int
22.157 +Emscripten_OpenDevice(_THIS, const char *devname, int iscapture)
22.158 +{
22.159 + SDL_bool valid_format = SDL_FALSE;
22.160 + SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
22.161 + int i;
22.162 + float f;
22.163 +
22.164 + while ((!valid_format) && (test_format)) {
22.165 + switch (test_format) {
22.166 + case AUDIO_F32: /* web audio only supports floats */
22.167 + this->spec.format = test_format;
22.168 +
22.169 + valid_format = SDL_TRUE;
22.170 + break;
22.171 + }
22.172 + test_format = SDL_NextAudioFormat();
22.173 + }
22.174 +
22.175 + if (!valid_format) {
22.176 + /* Didn't find a compatible format :( */
22.177 + return SDL_SetError("No compatible audio format!");
22.178 + }
22.179 +
22.180 + /* Initialize all variables that we clean on shutdown */
22.181 + this->hidden = (struct SDL_PrivateAudioData *)
22.182 + SDL_malloc((sizeof *this->hidden));
22.183 + if (this->hidden == NULL) {
22.184 + return SDL_OutOfMemory();
22.185 + }
22.186 + SDL_memset(this->hidden, 0, (sizeof *this->hidden));
22.187 +
22.188 + /* based on parts of library_sdl.js */
22.189 +
22.190 + /* create context (TODO: this puts stuff in the global namespace...)*/
22.191 + EM_ASM({
22.192 + if(typeof(SDL2) === 'undefined')
22.193 + SDL2 = {};
22.194 +
22.195 + if(typeof(SDL2.audio) === 'undefined')
22.196 + SDL2.audio = {};
22.197 +
22.198 + if (!SDL2.audioContext) {
22.199 + if (typeof(AudioContext) !== 'undefined') {
22.200 + SDL2.audioContext = new AudioContext();
22.201 + } else if (typeof(webkitAudioContext) !== 'undefined') {
22.202 + SDL2.audioContext = new webkitAudioContext();
22.203 + } else {
22.204 + throw 'Web Audio API is not available!';
22.205 + }
22.206 + }
22.207 + });
22.208 +
22.209 + /* limit to native freq */
22.210 + int sampleRate = EM_ASM_INT_V({
22.211 + return SDL2.audioContext['sampleRate'];
22.212 + });
22.213 +
22.214 + if(this->spec.freq != sampleRate) {
22.215 + for (i = this->spec.samples; i > 0; i--) {
22.216 + f = (float)i / (float)sampleRate * (float)this->spec.freq;
22.217 + if (SDL_floor(f) == f) {
22.218 + this->hidden->conv_in_len = SDL_floor(f);
22.219 + break;
22.220 + }
22.221 + }
22.222 +
22.223 + this->spec.freq = sampleRate;
22.224 + }
22.225 +
22.226 + SDL_CalculateAudioSpec(&this->spec);
22.227 +
22.228 + /* setup a ScriptProcessorNode */
22.229 + EM_ASM_ARGS({
22.230 + SDL2.audio.scriptProcessorNode = SDL2.audioContext['createScriptProcessor']($1, 0, $0);
22.231 + SDL2.audio.scriptProcessorNode['onaudioprocess'] = function (e) {
22.232 + SDL2.audio.currentOutputBuffer = e['outputBuffer'];
22.233 + Runtime.dynCall('vi', $2, [$3]);
22.234 + };
22.235 + SDL2.audio.scriptProcessorNode['connect'](SDL2.audioContext['destination']);
22.236 + }, this->spec.channels, this->spec.samples, HandleAudioProcess, this);
22.237 + return 0;
22.238 +}
22.239 +
22.240 +static int
22.241 +Emscripten_Init(SDL_AudioDriverImpl * impl)
22.242 +{
22.243 + /* Set the function pointers */
22.244 + impl->OpenDevice = Emscripten_OpenDevice;
22.245 + impl->CloseDevice = Emscripten_CloseDevice;
22.246 +
22.247 + /* only one output */
22.248 + impl->OnlyHasDefaultOutputDevice = 1;
22.249 +
22.250 + /* no threads here */
22.251 + impl->SkipMixerLock = 1;
22.252 + impl->ProvidesOwnCallbackThread = 1;
22.253 +
22.254 + /* check availability */
22.255 + int available = EM_ASM_INT_V({
22.256 + if (typeof(AudioContext) !== 'undefined') {
22.257 + return 1;
22.258 + } else if (typeof(webkitAudioContext) !== 'undefined') {
22.259 + return 1;
22.260 + }
22.261 + return 0;
22.262 + });
22.263 +
22.264 + return available;
22.265 +}
22.266 +
22.267 +AudioBootStrap EmscriptenAudio_bootstrap = {
22.268 + "emscripten", "SDL emscripten audio driver", Emscripten_Init, 0
22.269 +};
22.270 +
22.271 +#endif /* SDL_AUDIO_DRIVER_EMSCRIPTEN */
22.272 +
22.273 +/* vi: set ts=4 sw=4 expandtab: */
23.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
23.2 +++ b/src/audio/emscripten/SDL_emscriptenaudio.h Thu Jan 15 01:15:24 2015 -0400
23.3 @@ -0,0 +1,42 @@
23.4 +/*
23.5 + Simple DirectMedia Layer
23.6 + Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
23.7 +
23.8 + This software is provided 'as-is', without any express or implied
23.9 + warranty. In no event will the authors be held liable for any damages
23.10 + arising from the use of this software.
23.11 +
23.12 + Permission is granted to anyone to use this software for any purpose,
23.13 + including commercial applications, and to alter it and redistribute it
23.14 + freely, subject to the following restrictions:
23.15 +
23.16 + 1. The origin of this software must not be misrepresented; you must not
23.17 + claim that you wrote the original software. If you use this software
23.18 + in a product, an acknowledgment in the product documentation would be
23.19 + appreciated but is not required.
23.20 + 2. Altered source versions must be plainly marked as such, and must not be
23.21 + misrepresented as being the original software.
23.22 + 3. This notice may not be removed or altered from any source distribution.
23.23 +*/
23.24 +#include "../../SDL_internal.h"
23.25 +
23.26 +#ifndef _SDL_emscriptenaudio_h
23.27 +#define _SDL_emscriptenaudio_h
23.28 +
23.29 +#include "../SDL_sysaudio.h"
23.30 +
23.31 +/* Hidden "this" pointer for the audio functions */
23.32 +#define _THIS SDL_AudioDevice *this
23.33 +
23.34 +struct SDL_PrivateAudioData
23.35 +{
23.36 + Uint8 *mixbuf;
23.37 + Uint32 mixlen;
23.38 +
23.39 + Uint32 conv_in_len;
23.40 +
23.41 + Uint32 write_off, read_off;
23.42 +};
23.43 +
23.44 +#endif /* _SDL_emscriptenaudio_h */
23.45 +/* vi: set ts=4 sw=4 expandtab: */
24.1 --- a/src/core/android/SDL_android.c Thu Jan 15 01:06:14 2015 -0400
24.2 +++ b/src/core/android/SDL_android.c Thu Jan 15 01:15:24 2015 -0400
24.3 @@ -44,8 +44,8 @@
24.4 #define LOG_TAG "SDL_android"
24.5 /* #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__) */
24.6 /* #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) */
24.7 -#define LOGI(...) do {} while (false)
24.8 -#define LOGE(...) do {} while (false)
24.9 +#define LOGI(...) do {} while (0)
24.10 +#define LOGE(...) do {} while (0)
24.11
24.12 /* Uncomment this to log messages entering and exiting methods in this file */
24.13 /* #define DEBUG_JNI */
24.14 @@ -57,7 +57,6 @@
24.15 *******************************************************************************/
24.16 #include <jni.h>
24.17 #include <android/log.h>
24.18 -#include <stdbool.h>
24.19
24.20
24.21 /*******************************************************************************
24.22 @@ -80,7 +79,7 @@
24.23
24.24 /* Accelerometer data storage */
24.25 static float fLastAccelerometer[3];
24.26 -static bool bHasNewData;
24.27 +static SDL_bool bHasNewData;
24.28
24.29 /*******************************************************************************
24.30 Functions called by JNI
24.31 @@ -132,7 +131,7 @@
24.32 midPollInputDevices = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
24.33 "pollInputDevices", "()V");
24.34
24.35 - bHasNewData = false;
24.36 + bHasNewData = SDL_FALSE;
24.37
24.38 if(!midGetNativeSurface || !midFlipBuffers || !midAudioInit ||
24.39 !midAudioWriteShortBuffer || !midAudioWriteByteBuffer || !midAudioQuit || !midPollInputDevices) {
24.40 @@ -302,7 +301,7 @@
24.41 fLastAccelerometer[0] = x;
24.42 fLastAccelerometer[1] = y;
24.43 fLastAccelerometer[2] = z;
24.44 - bHasNewData = true;
24.45 + bHasNewData = SDL_TRUE;
24.46 }
24.47
24.48 /* Low memory */
24.49 @@ -386,7 +385,7 @@
24.50 (*env)->ReleaseStringUTFChars(env, text, utftext);
24.51 }
24.52
24.53 -jstring Java_org_libsdl_app_SDLActivity_nativeGetHint(JNIEnv* env, jclass cls, jstring name) {
24.54 +JNIEXPORT jstring JNICALL Java_org_libsdl_app_SDLActivity_nativeGetHint(JNIEnv* env, jclass cls, jstring name) {
24.55 const char *utfname = (*env)->GetStringUTFChars(env, name, NULL);
24.56 const char *hint = SDL_GetHint(utfname);
24.57
24.58 @@ -487,7 +486,7 @@
24.59 for (i = 0; i < 3; ++i) {
24.60 values[i] = fLastAccelerometer[i];
24.61 }
24.62 - bHasNewData = false;
24.63 + bHasNewData = SDL_FALSE;
24.64 retval = SDL_TRUE;
24.65 }
24.66
24.67 @@ -647,7 +646,7 @@
24.68
24.69 /* Test for an exception and call SDL_SetError with its detail if one occurs */
24.70 /* If the parameter silent is truthy then SDL_SetError() will not be called. */
24.71 -static bool Android_JNI_ExceptionOccurred(bool silent)
24.72 +static SDL_bool Android_JNI_ExceptionOccurred(SDL_bool silent)
24.73 {
24.74 SDL_assert(LocalReferenceHolder_IsActive());
24.75 JNIEnv *mEnv = Android_JNI_GetEnv();
24.76 @@ -681,10 +680,10 @@
24.77 (*mEnv)->ReleaseStringUTFChars(mEnv, exceptionName, exceptionNameUTF8);
24.78 }
24.79
24.80 - return true;
24.81 + return SDL_TRUE;
24.82 }
24.83
24.84 - return false;
24.85 + return SDL_FALSE;
24.86 }
24.87
24.88 static int Internal_Android_JNI_FileOpen(SDL_RWops* ctx)
24.89 @@ -728,19 +727,19 @@
24.90 */
24.91 mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, assetManager), "openFd", "(Ljava/lang/String;)Landroid/content/res/AssetFileDescriptor;");
24.92 inputStream = (*mEnv)->CallObjectMethod(mEnv, assetManager, mid, fileNameJString);
24.93 - if (Android_JNI_ExceptionOccurred(true)) {
24.94 + if (Android_JNI_ExceptionOccurred(SDL_TRUE)) {
24.95 goto fallback;
24.96 }
24.97
24.98 mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "getStartOffset", "()J");
24.99 ctx->hidden.androidio.offset = (*mEnv)->CallLongMethod(mEnv, inputStream, mid);
24.100 - if (Android_JNI_ExceptionOccurred(true)) {
24.101 + if (Android_JNI_ExceptionOccurred(SDL_TRUE)) {
24.102 goto fallback;
24.103 }
24.104
24.105 mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "getDeclaredLength", "()J");
24.106 ctx->hidden.androidio.size = (*mEnv)->CallLongMethod(mEnv, inputStream, mid);
24.107 - if (Android_JNI_ExceptionOccurred(true)) {
24.108 + if (Android_JNI_ExceptionOccurred(SDL_TRUE)) {
24.109 goto fallback;
24.110 }
24.111
24.112 @@ -754,7 +753,7 @@
24.113 /* Seek to the correct offset in the file. */
24.114 lseek(ctx->hidden.androidio.fd, (off_t)ctx->hidden.androidio.offset, SEEK_SET);
24.115
24.116 - if (false) {
24.117 + if (0) {
24.118 fallback:
24.119 /* Disabled log message because of spam on the Nexus 7 */
24.120 /* __android_log_print(ANDROID_LOG_DEBUG, "SDL", "Falling back to legacy InputStream method for opening file"); */
24.121 @@ -766,13 +765,13 @@
24.122 mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, assetManager),
24.123 "open", "(Ljava/lang/String;I)Ljava/io/InputStream;");
24.124 inputStream = (*mEnv)->CallObjectMethod(mEnv, assetManager, mid, fileNameJString, 1 /* ACCESS_RANDOM */);
24.125 - if (Android_JNI_ExceptionOccurred(false)) {
24.126 + if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
24.127 // Try fallback to APK Extension files
24.128 mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, context),
24.129 "openAPKExtensionInputStream", "(Ljava/lang/String;)Ljava/io/InputStream;");
24.130 inputStream = (*mEnv)->CallObjectMethod(mEnv, context, mid, fileNameJString);
24.131
24.132 - if (Android_JNI_ExceptionOccurred(false)) {
24.133 + if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
24.134 goto failure;
24.135 }
24.136 }
24.137 @@ -790,7 +789,7 @@
24.138 mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream),
24.139 "available", "()I");
24.140 ctx->hidden.androidio.size = (long)(*mEnv)->CallIntMethod(mEnv, inputStream, mid);
24.141 - if (Android_JNI_ExceptionOccurred(false)) {
24.142 + if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
24.143 goto failure;
24.144 }
24.145
24.146 @@ -801,7 +800,7 @@
24.147 "(Ljava/io/InputStream;)Ljava/nio/channels/ReadableByteChannel;");
24.148 readableByteChannel = (*mEnv)->CallStaticObjectMethod(
24.149 mEnv, channels, mid, inputStream);
24.150 - if (Android_JNI_ExceptionOccurred(false)) {
24.151 + if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
24.152 goto failure;
24.153 }
24.154
24.155 @@ -814,7 +813,7 @@
24.156 ctx->hidden.androidio.readMethod = mid;
24.157 }
24.158
24.159 - if (false) {
24.160 + if (0) {
24.161 failure:
24.162 result = -1;
24.163
24.164 @@ -907,7 +906,7 @@
24.165 /* result = readableByteChannel.read(...); */
24.166 int result = (*mEnv)->CallIntMethod(mEnv, readableByteChannel, readMethod, byteBuffer);
24.167
24.168 - if (Android_JNI_ExceptionOccurred(false)) {
24.169 + if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
24.170 LocalReferenceHolder_Cleanup(&refs);
24.171 return 0;
24.172 }
24.173 @@ -932,7 +931,7 @@
24.174 return 0;
24.175 }
24.176
24.177 -static int Internal_Android_JNI_FileClose(SDL_RWops* ctx, bool release)
24.178 +static int Internal_Android_JNI_FileClose(SDL_RWops* ctx, SDL_bool release)
24.179 {
24.180 struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__);
24.181
24.182 @@ -955,7 +954,7 @@
24.183 "close", "()V");
24.184 (*mEnv)->CallVoidMethod(mEnv, inputStream, mid);
24.185 (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.assetFileDescriptorRef);
24.186 - if (Android_JNI_ExceptionOccurred(false)) {
24.187 + if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
24.188 result = -1;
24.189 }
24.190 }
24.191 @@ -968,7 +967,7 @@
24.192 (*mEnv)->CallVoidMethod(mEnv, inputStream, mid);
24.193 (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.inputStreamRef);
24.194 (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.readableByteChannelRef);
24.195 - if (Android_JNI_ExceptionOccurred(false)) {
24.196 + if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
24.197 result = -1;
24.198 }
24.199 }
24.200 @@ -1059,7 +1058,7 @@
24.201 } else if (movement < 0) {
24.202 /* We can't seek backwards so we have to reopen the file and seek */
24.203 /* forwards which obviously isn't very efficient */
24.204 - Internal_Android_JNI_FileClose(ctx, false);
24.205 + Internal_Android_JNI_FileClose(ctx, SDL_FALSE);
24.206 Internal_Android_JNI_FileOpen(ctx);
24.207 Android_JNI_FileSeek(ctx, newPosition, RW_SEEK_SET);
24.208 }
24.209 @@ -1071,7 +1070,7 @@
24.210
24.211 int Android_JNI_FileClose(SDL_RWops* ctx)
24.212 {
24.213 - return Internal_Android_JNI_FileClose(ctx, true);
24.214 + return Internal_Android_JNI_FileClose(ctx, SDL_TRUE);
24.215 }
24.216
24.217 /* returns a new global reference which needs to be released later */
25.1 --- a/src/core/linux/SDL_evdev.c Thu Jan 15 01:06:14 2015 -0400
25.2 +++ b/src/core/linux/SDL_evdev.c Thu Jan 15 01:15:24 2015 -0400
25.3 @@ -681,10 +681,10 @@
25.4 SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_TRUE, 0, events[i].value);
25.5 break;
25.6 case REL_WHEEL:
25.7 - SDL_SendMouseWheel(mouse->focus, mouse->mouseID, 0, events[i].value);
25.8 + SDL_SendMouseWheel(mouse->focus, mouse->mouseID, 0, events[i].value, SDL_MOUSEWHEEL_NORMAL);
25.9 break;
25.10 case REL_HWHEEL:
25.11 - SDL_SendMouseWheel(mouse->focus, mouse->mouseID, events[i].value, 0);
25.12 + SDL_SendMouseWheel(mouse->focus, mouse->mouseID, events[i].value, 0, SDL_MOUSEWHEEL_NORMAL);
25.13 break;
25.14 default:
25.15 break;
26.1 --- a/src/core/linux/SDL_udev.c Thu Jan 15 01:06:14 2015 -0400
26.2 +++ b/src/core/linux/SDL_udev.c Thu Jan 15 01:15:24 2015 -0400
26.3 @@ -371,10 +371,10 @@
26.4 devclass |= SDL_UDEV_DEVICE_MOUSE; /* ID_INPUT_MOUSE */
26.5 }
26.6
26.7 - /* the first 32 bits are ESC, numbers, and Q to D; if we have all of
26.8 - * those, consider it a full keyboard; do not test KEY_RESERVED, though */
26.9 + /* the first 32 bits are ESC, numbers, and Q to D; if we have any of
26.10 + * those, consider it a keyboard device; do not test KEY_RESERVED, though */
26.11 keyboard_mask = 0xFFFFFFFE;
26.12 - if ((bitmask_key[0] & keyboard_mask) == keyboard_mask)
26.13 + if ((bitmask_key[0] & keyboard_mask) != 0)
26.14 devclass |= SDL_UDEV_DEVICE_KEYBOARD; /* ID_INPUT_KEYBOARD */
26.15
26.16 return devclass;
27.1 --- a/src/core/winrt/SDL_winrtapp_direct3d.cpp Thu Jan 15 01:06:14 2015 -0400
27.2 +++ b/src/core/winrt/SDL_winrtapp_direct3d.cpp Thu Jan 15 01:15:24 2015 -0400
27.3 @@ -126,6 +126,16 @@
27.4 {
27.5 SDL_assert(SDL_strcmp(name, SDL_HINT_ORIENTATIONS) == 0);
27.6
27.7 + /* HACK: prevent SDL from altering an app's .appxmanifest-set orientation
27.8 + * from being changed on startup, by detecting when SDL_HINT_ORIENTATIONS
27.9 + * is getting registered.
27.10 + *
27.11 + * TODO, WinRT: consider reading in an app's .appxmanifest file, and apply its orientation when 'newValue == NULL'.
27.12 + */
27.13 + if ((oldValue == NULL) && (newValue == NULL)) {
27.14 + return;
27.15 + }
27.16 +
27.17 // Start with no orientation flags, then add each in as they're parsed
27.18 // from newValue.
27.19 unsigned int orientationFlags = 0;
28.1 --- a/src/core/winrt/SDL_winrtapp_xaml.h Thu Jan 15 01:06:14 2015 -0400
28.2 +++ b/src/core/winrt/SDL_winrtapp_xaml.h Thu Jan 15 01:15:24 2015 -0400
28.3 @@ -23,7 +23,7 @@
28.4 #ifndef _SDL_winrtapp_xaml_h
28.5 #define _SDL_winrtapp_xaml_h
28.6
28.7 -#include "SDL_types.h"
28.8 +#include "SDL_stdinc.h"
28.9
28.10 #ifdef __cplusplus
28.11 extern SDL_bool WINRT_XAMLWasEnabled;
29.1 --- a/src/cpuinfo/SDL_cpuinfo.c Thu Jan 15 01:06:14 2015 -0400
29.2 +++ b/src/cpuinfo/SDL_cpuinfo.c Thu Jan 15 01:15:24 2015 -0400
29.3 @@ -79,6 +79,7 @@
29.4 {
29.5 int has_CPUID = 0;
29.6 /* *INDENT-OFF* */
29.7 +#ifndef SDL_CPUINFO_DISABLED
29.8 #if defined(__GNUC__) && defined(i386)
29.9 __asm__ (
29.10 " pushfl # Get original EFLAGS \n"
29.11 @@ -165,6 +166,7 @@
29.12 "1: \n"
29.13 );
29.14 #endif
29.15 +#endif
29.16 /* *INDENT-ON* */
29.17 return has_CPUID;
29.18 }
29.19 @@ -272,6 +274,7 @@
29.20 CPU_haveAltiVec(void)
29.21 {
29.22 volatile int altivec = 0;
29.23 +#ifndef SDL_CPUINFO_DISABLED
29.24 #if (defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__))) || (defined(__OpenBSD__) && defined(__powerpc__))
29.25 #ifdef __OpenBSD__
29.26 int selectors[2] = { CTL_MACHDEP, CPU_ALTIVEC };
29.27 @@ -292,6 +295,7 @@
29.28 }
29.29 signal(SIGILL, handler);
29.30 #endif
29.31 +#endif
29.32 return altivec;
29.33 }
29.34
29.35 @@ -418,6 +422,7 @@
29.36 SDL_GetCPUCount(void)
29.37 {
29.38 if (!SDL_CPUCount) {
29.39 +#ifndef SDL_CPUINFO_DISABLED
29.40 #if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)
29.41 if (SDL_CPUCount <= 0) {
29.42 SDL_CPUCount = (int)sysconf(_SC_NPROCESSORS_ONLN);
29.43 @@ -436,6 +441,7 @@
29.44 SDL_CPUCount = info.dwNumberOfProcessors;
29.45 }
29.46 #endif
29.47 +#endif
29.48 /* There has to be at least 1, right? :) */
29.49 if (SDL_CPUCount <= 0) {
29.50 SDL_CPUCount = 1;
29.51 @@ -452,10 +458,11 @@
29.52
29.53 if (!SDL_CPUType[0]) {
29.54 int i = 0;
29.55 - int a, b, c, d;
29.56
29.57 if (CPU_haveCPUID()) {
29.58 + int a, b, c, d;
29.59 cpuid(0x00000000, a, b, c, d);
29.60 + (void) a;
29.61 SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
29.62 SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
29.63 SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
29.64 @@ -557,15 +564,12 @@
29.65 SDL_GetCPUCacheLineSize(void)
29.66 {
29.67 const char *cpuType = SDL_GetCPUType();
29.68 -
29.69 + int a, b, c, d;
29.70 + (void) a; (void) b; (void) c; (void) d;
29.71 if (SDL_strcmp(cpuType, "GenuineIntel") == 0) {
29.72 - int a, b, c, d;
29.73 -
29.74 cpuid(0x00000001, a, b, c, d);
29.75 return (((b >> 8) & 0xff) * 8);
29.76 } else if (SDL_strcmp(cpuType, "AuthenticAMD") == 0) {
29.77 - int a, b, c, d;
29.78 -
29.79 cpuid(0x80000005, a, b, c, d);
29.80 return (c & 0xff);
29.81 } else {
29.82 @@ -723,6 +727,7 @@
29.83 SDL_GetSystemRAM(void)
29.84 {
29.85 if (!SDL_SystemRAM) {
29.86 +#ifndef SDL_CPUINFO_DISABLED
29.87 #if defined(HAVE_SYSCONF) && defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE)
29.88 if (SDL_SystemRAM <= 0) {
29.89 SDL_SystemRAM = (int)((Sint64)sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGESIZE) / (1024*1024));
29.90 @@ -757,6 +762,7 @@
29.91 }
29.92 }
29.93 #endif
29.94 +#endif
29.95 }
29.96 return SDL_SystemRAM;
29.97 }
30.1 --- a/src/dynapi/SDL_dynapi.c Thu Jan 15 01:06:14 2015 -0400
30.2 +++ b/src/dynapi/SDL_dynapi.c Thu Jan 15 01:15:24 2015 -0400
30.3 @@ -206,7 +206,14 @@
30.4 static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym)
30.5 {
30.6 HANDLE lib = LoadLibraryA(fname);
30.7 - return lib ? GetProcAddress(lib, sym) : NULL;
30.8 + void *retval = NULL;
30.9 + if (lib) {
30.10 + retval = GetProcAddress(lib, sym);
30.11 + if (retval == NULL) {
30.12 + FreeLibrary(lib);
30.13 + }
30.14 + }
30.15 + return retval;
30.16 }
30.17
30.18 #elif defined(__HAIKU__)
30.19 @@ -215,8 +222,11 @@
30.20 {
30.21 image_id lib = load_add_on(fname);
30.22 void *retval = NULL;
30.23 - if ((lib < 0) || (get_image_symbol(lib, sym, B_SYMBOL_TYPE_TEXT, &retval) != B_NO_ERROR)) {
30.24 - retval = NULL;
30.25 + if (lib >= 0) {
30.26 + if (get_image_symbol(lib, sym, B_SYMBOL_TYPE_TEXT, &retval) != B_NO_ERROR) {
30.27 + unload_add_on(lib);
30.28 + retval = NULL;
30.29 + }
30.30 }
30.31 return retval;
30.32 }
30.33 @@ -225,7 +235,14 @@
30.34 static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym)
30.35 {
30.36 void *lib = dlopen(fname, RTLD_NOW | RTLD_LOCAL);
30.37 - return lib ? dlsym(lib, sym) : NULL;
30.38 + void *retval = NULL;
30.39 + if (lib != NULL) {
30.40 + retval = dlsym(lib, sym);
30.41 + if (retval == NULL) {
30.42 + dlclose(lib);
30.43 + }
30.44 + }
30.45 + return retval;
30.46 }
30.47 #else
30.48 #error Please define your platform.
31.1 --- a/src/dynapi/SDL_dynapi.h Thu Jan 15 01:06:14 2015 -0400
31.2 +++ b/src/dynapi/SDL_dynapi.h Thu Jan 15 01:15:24 2015 -0400
31.3 @@ -43,7 +43,7 @@
31.4 #include "TargetConditionals.h"
31.5 #endif
31.6
31.7 -#if TARGET_OS_IPHONE || __native_client__ /* probably not useful on iOS or NACL. */
31.8 +#if TARGET_OS_IPHONE || __native_client__ || __EMSCRIPTEN__ /* probably not useful on iOS, NACL or Emscripten. */
31.9 #define SDL_DYNAMIC_API 0
31.10 #elif SDL_BUILDING_WINRT /* probaly not useful on WinRT, given current .dll loading restrictions */
31.11 #define SDL_DYNAMIC_API 0
32.1 --- a/src/events/SDL_mouse.c Thu Jan 15 01:06:14 2015 -0400
32.2 +++ b/src/events/SDL_mouse.c Thu Jan 15 01:15:24 2015 -0400
32.3 @@ -397,7 +397,7 @@
32.4 }
32.5
32.6 int
32.7 -SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, int x, int y)
32.8 +SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, int x, int y, SDL_MouseWheelDirection direction)
32.9 {
32.10 SDL_Mouse *mouse = SDL_GetMouse();
32.11 int posted;
32.12 @@ -419,6 +419,7 @@
32.13 event.wheel.which = mouseID;
32.14 event.wheel.x = x;
32.15 event.wheel.y = y;
32.16 + event.wheel.direction = (Uint32)direction;
32.17 posted = (SDL_PushEvent(&event) > 0);
32.18 }
32.19 return posted;
33.1 --- a/src/events/SDL_mouse_c.h Thu Jan 15 01:06:14 2015 -0400
33.2 +++ b/src/events/SDL_mouse_c.h Thu Jan 15 01:15:24 2015 -0400
33.3 @@ -120,7 +120,7 @@
33.4 extern int SDL_SendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state, Uint8 button);
33.5
33.6 /* Send a mouse wheel event */
33.7 -extern int SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, int x, int y);
33.8 +extern int SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, int x, int y, SDL_MouseWheelDirection direction);
33.9
33.10 /* Shutdown the mouse subsystem */
33.11 extern void SDL_MouseQuit(void);
34.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
34.2 +++ b/src/filesystem/emscripten/SDL_sysfilesystem.c Thu Jan 15 01:15:24 2015 -0400
34.3 @@ -0,0 +1,68 @@
34.4 +/*
34.5 + Simple DirectMedia Layer
34.6 + Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
34.7 +
34.8 + This software is provided 'as-is', without any express or implied
34.9 + warranty. In no event will the authors be held liable for any damages
34.10 + arising from the use of this software.
34.11 +
34.12 + Permission is granted to anyone to use this software for any purpose,
34.13 + including commercial applications, and to alter it and redistribute it
34.14 + freely, subject to the following restrictions:
34.15 +
34.16 + 1. The origin of this software must not be misrepresented; you must not
34.17 + claim that you wrote the original software. If you use this software
34.18 + in a product, an acknowledgment in the product documentation would be
34.19 + appreciated but is not required.
34.20 + 2. Altered source versions must be plainly marked as such, and must not be
34.21 + misrepresented as being the original software.
34.22 + 3. This notice may not be removed or altered from any source distribution.
34.23 +*/
34.24 +#include "../../SDL_internal.h"
34.25 +
34.26 +#ifdef SDL_FILESYSTEM_EMSCRIPTEN
34.27 +
34.28 +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
34.29 +/* System dependent filesystem routines */
34.30 +#include <errno.h>
34.31 +#include <sys/stat.h>
34.32 +
34.33 +#include "SDL_error.h"
34.34 +#include "SDL_filesystem.h"
34.35 +
34.36 +#include <emscripten/emscripten.h>
34.37 +
34.38 +char *
34.39 +SDL_GetBasePath(void)
34.40 +{
34.41 + char *retval = "/";
34.42 + return SDL_strdup(retval);
34.43 +}
34.44 +
34.45 +char *
34.46 +SDL_GetPrefPath(const char *org, const char *app)
34.47 +{
34.48 + const char *append = "/libsdl/";
34.49 + char *retval;
34.50 + size_t len = 0;
34.51 +
34.52 + len = SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
34.53 + retval = (char *) SDL_malloc(len);
34.54 + if (!retval) {
34.55 + SDL_OutOfMemory();
34.56 + return NULL;
34.57 + }
34.58 +
34.59 + SDL_snprintf(retval, len, "%s%s/%s/", append, org, app);
34.60 +
34.61 + if (mkdir(retval, 0700) != 0 && errno != EEXIST) {
34.62 + SDL_SetError("Couldn't create directory '%s': '%s'", retval, strerror(errno));
34.63 + return NULL;
34.64 + }
34.65 +
34.66 + return retval;
34.67 +}
34.68 +
34.69 +#endif /* SDL_FILESYSTEM_EMSCRIPTEN */
34.70 +
34.71 +/* vi: set ts=4 sw=4 expandtab: */
35.1 --- a/src/filesystem/winrt/SDL_sysfilesystem.cpp Thu Jan 15 01:06:14 2015 -0400
35.2 +++ b/src/filesystem/winrt/SDL_sysfilesystem.cpp Thu Jan 15 01:15:24 2015 -0400
35.3 @@ -144,49 +144,6 @@
35.4 * without violating Microsoft's app-store requirements.
35.5 */
35.6
35.7 - /* Default to using a Local/non-Roaming path. WinRT will often attempt
35.8 - * to synchronize files in Roaming paths, and will do so while an app is
35.9 - * running. Using a Local path prevents the possibility that an app's
35.10 - * save-data files will get changed from underneath it, without it
35.11 - * being ready.
35.12 - *
35.13 - * This behavior can be changed via use of the
35.14 - * SDL_HINT_WINRT_PREF_PATH_ROOT hint.
35.15 - */
35.16 - SDL_WinRT_Path pathType = SDL_WINRT_PATH_LOCAL_FOLDER;
35.17 -
35.18 - const char * hint = SDL_GetHint(SDL_HINT_WINRT_PREF_PATH_ROOT);
35.19 - if (hint) {
35.20 - if (SDL_strcasecmp(hint, "local") == 0) {
35.21 - pathType = SDL_WINRT_PATH_LOCAL_FOLDER;
35.22 - } else if (SDL_strcasecmp(hint, "roaming") == 0) {
35.23 -#if (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (NTDDI_VERSION > NTDDI_WIN8)
35.24 - pathType = SDL_WINRT_PATH_ROAMING_FOLDER;
35.25 -#else
35.26 - /* Don't apply a 'Roaming' path on Windows Phone 8.0. Roaming
35.27 - * data is not supported by that version of the operating system.
35.28 - */
35.29 - SDL_SetError("A Roaming path was specified via SDL_HINT_WINRT_PREF_PATH_ROOT, but Roaming is not supported on Windows Phone 8.0");
35.30 - return NULL;
35.31 -#endif
35.32 - } else if (SDL_strcasecmp(hint, "old") == 0) {
35.33 - /* Older versions of SDL/WinRT, including 2.0.3, would return a
35.34 - * pref-path that used a Roaming folder on non-Phone versions of
35.35 - * Windows, such as Windows 8.0 and Windows 8.1. This has since
35.36 - * been reverted to using a Local folder, in order to prevent
35.37 - * problems arising from WinRT automatically synchronizing files
35.38 - * during an app's lifetime. In case this functionality is
35.39 - * desired, setting SDL_HINT_WINRT_PREF_PATH_ROOT to "old" will
35.40 - * trigger the older behavior.
35.41 - */
35.42 -#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
35.43 - pathType = SDL_WINRT_PATH_LOCAL_FOLDER;
35.44 -#else
35.45 - pathType = SDL_WINRT_PATH_ROAMING_FOLDER;
35.46 -#endif
35.47 - }
35.48 - }
35.49 -
35.50 const WCHAR * srcPath = NULL;
35.51 WCHAR path[MAX_PATH];
35.52 char *retval = NULL;
35.53 @@ -195,7 +152,7 @@
35.54 size_t new_wpath_len = 0;
35.55 BOOL api_result = FALSE;
35.56
35.57 - srcPath = SDL_WinRTGetFSPathUNICODE(pathType);
35.58 + srcPath = SDL_WinRTGetFSPathUNICODE(SDL_WINRT_PATH_LOCAL_FOLDER);
35.59 if ( ! srcPath) {
35.60 SDL_SetError("Unable to find a source path");
35.61 return NULL;
36.1 --- a/src/haptic/SDL_syshaptic.h Thu Jan 15 01:06:14 2015 -0400
36.2 +++ b/src/haptic/SDL_syshaptic.h Thu Jan 15 01:15:24 2015 -0400
36.3 @@ -27,12 +27,6 @@
36.4 #include "SDL_haptic.h"
36.5
36.6
36.7 -/*
36.8 - * Number of haptic devices on the system.
36.9 - */
36.10 -extern Uint8 SDL_numhaptics;
36.11 -
36.12 -
36.13 struct haptic_effect
36.14 {
36.15 SDL_HapticEffect effect; /* The current event */
37.1 --- a/src/haptic/darwin/SDL_syshaptic.c Thu Jan 15 01:06:14 2015 -0400
37.2 +++ b/src/haptic/darwin/SDL_syshaptic.c Thu Jan 15 01:15:24 2015 -0400
37.3 @@ -551,7 +551,7 @@
37.4 FFReleaseDevice(haptic->hwdata->device);
37.5 creat_err:
37.6 if (haptic->hwdata != NULL) {
37.7 - free(haptic->hwdata);
37.8 + SDL_free(haptic->hwdata);
37.9 haptic->hwdata = NULL;
37.10 }
37.11 return -1;
38.1 --- a/src/haptic/linux/SDL_syshaptic.c Thu Jan 15 01:06:14 2015 -0400
38.2 +++ b/src/haptic/linux/SDL_syshaptic.c Thu Jan 15 01:15:24 2015 -0400
38.3 @@ -441,7 +441,7 @@
38.4 open_err:
38.5 close(fd);
38.6 if (haptic->hwdata != NULL) {
38.7 - free(haptic->hwdata);
38.8 + SDL_free(haptic->hwdata);
38.9 haptic->hwdata = NULL;
38.10 }
38.11 return -1;
38.12 @@ -959,7 +959,7 @@
38.13 return 0;
38.14
38.15 new_effect_err:
38.16 - free(effect->hweffect);
38.17 + SDL_free(effect->hweffect);
38.18 effect->hweffect = NULL;
38.19 return -1;
38.20 }
39.1 --- a/src/joystick/SDL_gamecontroller.c Thu Jan 15 01:06:14 2015 -0400
39.2 +++ b/src/joystick/SDL_gamecontroller.c Thu Jan 15 01:15:24 2015 -0400
39.3 @@ -89,6 +89,7 @@
39.4
39.5 static ControllerMapping_t *s_pSupportedControllers = NULL;
39.6 static ControllerMapping_t *s_pXInputMapping = NULL;
39.7 +static ControllerMapping_t *s_pEmscriptenMapping = NULL;
39.8
39.9 /* The SDL game controller structure */
39.10 struct _SDL_GameController
39.11 @@ -263,7 +264,13 @@
39.12 return s_pXInputMapping;
39.13 }
39.14 else
39.15 -#endif /* SDL_JOYSTICK_XINPUT */
39.16 +#endif
39.17 +#if defined(SDL_JOYSTICK_EMSCRIPTEN)
39.18 + if (s_pEmscriptenMapping) {
39.19 + return s_pEmscriptenMapping;
39.20 + }
39.21 + else
39.22 +#endif
39.23 {
39.24 SDL_JoystickGUID jGUID = SDL_JoystickGetDeviceGUID(device_index);
39.25 return SDL_PrivateGetControllerMappingForGUID(&jGUID);
39.26 @@ -668,6 +675,7 @@
39.27 SDL_JoystickGUID jGUID;
39.28 ControllerMapping_t *pControllerMapping;
39.29 SDL_bool is_xinput_mapping = SDL_FALSE;
39.30 + SDL_bool is_emscripten_mapping = SDL_FALSE;
39.31
39.32 if (!mappingString) {
39.33 return SDL_InvalidParamError("mappingString");
39.34 @@ -680,6 +688,9 @@
39.35 if (!SDL_strcasecmp(pchGUID, "xinput")) {
39.36 is_xinput_mapping = SDL_TRUE;
39.37 }
39.38 + if (!SDL_strcasecmp(pchGUID, "emscripten")) {
39.39 + is_emscripten_mapping = SDL_TRUE;
39.40 + }
39.41 jGUID = SDL_JoystickGetGUIDFromString(pchGUID);
39.42 SDL_free(pchGUID);
39.43
39.44 @@ -715,6 +726,9 @@
39.45 if (is_xinput_mapping) {
39.46 s_pXInputMapping = pControllerMapping;
39.47 }
39.48 + if (is_emscripten_mapping) {
39.49 + s_pEmscriptenMapping = pControllerMapping;
39.50 + }
39.51 pControllerMapping->guid = jGUID;
39.52 pControllerMapping->name = pchName;
39.53 pControllerMapping->mapping = pchMapping;
40.1 --- a/src/joystick/SDL_gamecontrollerdb.h Thu Jan 15 01:06:14 2015 -0400
40.2 +++ b/src/joystick/SDL_gamecontrollerdb.h Thu Jan 15 01:15:24 2015 -0400
40.3 @@ -77,6 +77,9 @@
40.4 #if defined(__ANDROID__)
40.5 "4e564944494120436f72706f72617469,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,",
40.6 #endif
40.7 +#if defined(SDL_JOYSTICK_EMSCRIPTEN)
40.8 + "emscripten,Standard Gamepad,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,lefttrigger:b6,righttrigger:b7,back:b8,start:b9,leftstick:b10,rightstick:b11,dpup:b12,dpdown:b13,dpleft:b14,dpright:b15,guide:b16,leftx:a0,lefty:a1,rightx:a2,righty:a3,",
40.9 +#endif
40.10 NULL
40.11 };
40.12
41.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
41.2 +++ b/src/joystick/emscripten/SDL_sysjoystick.c Thu Jan 15 01:15:24 2015 -0400
41.3 @@ -0,0 +1,426 @@
41.4 +/*
41.5 + Simple DirectMedia Layer
41.6 + Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
41.7 +
41.8 + This software is provided 'as-is', without any express or implied
41.9 + warranty. In no event will the authors be held liable for any damages
41.10 + arising from the use of this software.
41.11 +
41.12 + Permission is granted to anyone to use this software for any purpose,
41.13 + including commercial applications, and to alter it and redistribute it
41.14 + freely, subject to the following restrictions:
41.15 +
41.16 + 1. The origin of this software must not be misrepresented; you must not
41.17 + claim that you wrote the original software. If you use this software
41.18 + in a product, an acknowledgment in the product documentation would be
41.19 + appreciated but is not required.
41.20 + 2. Altered source versions must be plainly marked as such, and must not be
41.21 + misrepresented as being the original software.
41.22 + 3. This notice may not be removed or altered from any source distribution.
41.23 +*/
41.24 +
41.25 +#include "../../SDL_internal.h"
41.26 +
41.27 +#ifdef SDL_JOYSTICK_EMSCRIPTEN
41.28 +
41.29 +#include <stdio.h> /* For the definition of NULL */
41.30 +#include "SDL_error.h"
41.31 +#include "SDL_events.h"
41.32 +
41.33 +#if !SDL_EVENTS_DISABLED
41.34 +#include "../../events/SDL_events_c.h"
41.35 +#endif
41.36 +
41.37 +#include "SDL_joystick.h"
41.38 +#include "SDL_hints.h"
41.39 +#include "SDL_assert.h"
41.40 +#include "SDL_timer.h"
41.41 +#include "SDL_log.h"
41.42 +#include "SDL_sysjoystick_c.h"
41.43 +#include "../SDL_joystick_c.h"
41.44 +
41.45 +static SDL_joylist_item * JoystickByIndex(int index);
41.46 +
41.47 +static SDL_joylist_item *SDL_joylist = NULL;
41.48 +static SDL_joylist_item *SDL_joylist_tail = NULL;
41.49 +static int numjoysticks = 0;
41.50 +static int instance_counter = 0;
41.51 +
41.52 +int
41.53 +Emscripten_JoyStickConnected(int eventType, const EmscriptenGamepadEvent *gamepadEvent, void *userData)
41.54 +{
41.55 + int i;
41.56 +
41.57 + SDL_joylist_item *item;
41.58 +
41.59 + if (JoystickByIndex(gamepadEvent->index) != NULL) {
41.60 + return 1;
41.61 + }
41.62 +
41.63 +#if !SDL_EVENTS_DISABLED
41.64 + SDL_Event event;
41.65 +#endif
41.66 +
41.67 + item = (SDL_joylist_item *) SDL_malloc(sizeof (SDL_joylist_item));
41.68 + if (item == NULL) {
41.69 + return 1;
41.70 + }
41.71 +
41.72 + SDL_zerop(item);
41.73 + item->index = gamepadEvent->index;
41.74 +
41.75 + item->name = SDL_strdup(gamepadEvent->id);
41.76 + if ( item->name == NULL ) {
41.77 + SDL_free(item);
41.78 + return 1;
41.79 + }
41.80 +
41.81 + item->mapping = SDL_strdup(gamepadEvent->mapping);
41.82 + if ( item->mapping == NULL ) {
41.83 + SDL_free(item->name);
41.84 + SDL_free(item);
41.85 + return 1;
41.86 + }
41.87 +
41.88 + item->naxes = gamepadEvent->numAxes;
41.89 + item->nbuttons = gamepadEvent->numButtons;
41.90 + item->device_instance = instance_counter++;
41.91 +
41.92 + item->timestamp = gamepadEvent->timestamp;
41.93 +
41.94 + for( i = 0; i < item->naxes; i++) {
41.95 + item->axis[i] = gamepadEvent->axis[i];
41.96 + }
41.97 +
41.98 + for( i = 0; i < item->nbuttons; i++) {
41.99 + item->analogButton[i] = gamepadEvent->analogButton[i];
41.100 + item->digitalButton[i] = gamepadEvent->digitalButton[i];
41.101 + }
41.102 +
41.103 + if (SDL_joylist_tail == NULL) {
41.104 + SDL_joylist = SDL_joylist_tail = item;
41.105 + } else {
41.106 + SDL_joylist_tail->next = item;
41.107 + SDL_joylist_tail = item;
41.108 + }
41.109 +
41.110 + ++numjoysticks;
41.111 + SDL_Log("%d",numjoysticks);
41.112 +#if !SDL_EVENTS_DISABLED
41.113 + event.type = SDL_JOYDEVICEADDED;
41.114 +
41.115 + if (SDL_GetEventState(event.type) == SDL_ENABLE) {
41.116 + event.jdevice.which = item->device_instance - 1;
41.117 + if ( (SDL_EventOK == NULL) ||
41.118 + (*SDL_EventOK) (SDL_EventOKParam, &event) ) {
41.119 + SDL_PushEvent(&event);
41.120 + }
41.121 + }
41.122 +#endif /* !SDL_EVENTS_DISABLED */
41.123 +
41.124 + SDL_Log("Added joystick with index %d", item->index);
41.125 +
41.126 + return 1;
41.127 +}
41.128 +
41.129 +int
41.130 +Emscripten_JoyStickDisconnected(int eventType, const EmscriptenGamepadEvent *gamepadEvent, void *userData)
41.131 +{
41.132 + SDL_joylist_item *item = SDL_joylist;
41.133 + SDL_joylist_item *prev = NULL;
41.134 +#if !SDL_EVENTS_DISABLED
41.135 + SDL_Event event;
41.136 +#endif
41.137 +
41.138 + while (item != NULL) {
41.139 + if (item->index == gamepadEvent->index) {
41.140 + break;
41.141 + }
41.142 + prev = item;
41.143 + item = item->next;
41.144 + }
41.145 +
41.146 + if (item == NULL) {
41.147 + return 1;
41.148 + }
41.149 +
41.150 + const int retval = item->device_instance;
41.151 + if (item->joystick) {
41.152 + item->joystick->hwdata = NULL;
41.153 + }
41.154 +
41.155 + if (prev != NULL) {
41.156 + prev->next = item->next;
41.157 + } else {
41.158 + SDL_assert(SDL_joylist == item);
41.159 + SDL_joylist = item->next;
41.160 + }
41.161 + if (item == SDL_joylist_tail) {
41.162 + SDL_joylist_tail = prev;
41.163 + }
41.164 +
41.165 + /* Need to decrement the joystick count before we post the event */
41.166 + --numjoysticks;
41.167 +
41.168 +#if !SDL_EVENTS_DISABLED
41.169 + event.type = SDL_JOYDEVICEREMOVED;
41.170 +
41.171 + if (SDL_GetEventState(event.type) == SDL_ENABLE) {
41.172 + event.jdevice.which = item->device_instance;
41.173 + if ( (SDL_EventOK == NULL) ||
41.174 + (*SDL_EventOK) (SDL_EventOKParam, &event) ) {
41.175 + SDL_PushEvent(&event);
41.176 + }
41.177 + }
41.178 +#endif /* !SDL_EVENTS_DISABLED */
41.179 +
41.180 + SDL_Log("Removed joystick with index %d", retval);
41.181 + SDL_free(item->name);
41.182 + SDL_free(item->mapping);
41.183 + SDL_free(item);
41.184 + return 1;
41.185 +}
41.186 +
41.187 +/* Function to scan the system for joysticks.
41.188 + * It should return 0, or -1 on an unrecoverable fatal error.
41.189 + */
41.190 +int
41.191 +SDL_SYS_JoystickInit(void)
41.192 +{
41.193 + int retval, i, numjs;
41.194 + EmscriptenGamepadEvent gamepadState;
41.195 +
41.196 + numjoysticks = 0;
41.197 + numjs = emscripten_get_num_gamepads();
41.198 +
41.199 + /* Check if gamepad is supported by browser */
41.200 + if (numjs == EMSCRIPTEN_RESULT_NOT_SUPPORTED) {
41.201 + return -1;
41.202 + }
41.203 +
41.204 + /* handle already connected gamepads */
41.205 + if (numjs > 0) {
41.206 + for(i = 0; i < numjs; i++) {
41.207 + retval = emscripten_get_gamepad_status(i, &gamepadState);
41.208 + if (retval == EMSCRIPTEN_RESULT_SUCCESS) {
41.209 + Emscripten_JoyStickConnected(EMSCRIPTEN_EVENT_GAMEPADCONNECTED,
41.210 + &gamepadState,
41.211 + NULL);
41.212 + }
41.213 + }
41.214 + }
41.215 +
41.216 + retval = emscripten_set_gamepadconnected_callback(NULL,
41.217 + 0,
41.218 + Emscripten_JoyStickConnected);
41.219 +
41.220 + if(retval != EMSCRIPTEN_RESULT_SUCCESS) {
41.221 + return -1;
41.222 + }
41.223 +
41.224 + retval = emscripten_set_gamepaddisconnected_callback(NULL,
41.225 + 0,
41.226 + Emscripten_JoyStickDisconnected);
41.227 + if(retval != EMSCRIPTEN_RESULT_SUCCESS) {
41.228 + return -1;
41.229 + }
41.230 +
41.231 + return 0;
41.232 +}
41.233 +
41.234 +static SDL_joylist_item *
41.235 +JoystickByIndex(int index)
41.236 +{
41.237 + SDL_joylist_item *item = SDL_joylist;
41.238 +
41.239 + if (index < 0) {
41.240 + return NULL;
41.241 + }
41.242 +
41.243 + while (item != NULL) {
41.244 + if (item->index == index) {
41.245 + break;
41.246 + }
41.247 + item = item->next;
41.248 + }
41.249 +
41.250 + return item;
41.251 +}
41.252 +
41.253 +int SDL_SYS_NumJoysticks()
41.254 +{
41.255 + return numjoysticks;
41.256 +}
41.257 +
41.258 +void SDL_SYS_JoystickDetect()
41.259 +{
41.260 +}
41.261 +
41.262 +// we need to poll to see if the gamepad state has changed
41.263 +SDL_bool SDL_SYS_JoystickNeedsPolling()
41.264 +{
41.265 + return SDL_TRUE;
41.266 +}
41.267 +
41.268 +/* Function to get the device-dependent name of a joystick */
41.269 +const char *
41.270 +SDL_SYS_JoystickNameForDeviceIndex(int index)
41.271 +{
41.272 + SDL_joylist_item *item = JoystickByIndex(index);
41.273 + if (item == NULL) {
41.274 + SDL_SetError("Joystick with index %d not found", index);
41.275 + return NULL;
41.276 + }
41.277 +
41.278 + return item->name;
41.279 +}
41.280 +
41.281 +/* Function to perform the mapping from device index to the instance id for this index */
41.282 +SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int index)
41.283 +{
41.284 + SDL_joylist_item *item = JoystickByIndex(index);
41.285 + if (item == NULL) {
41.286 + SDL_SetError("Joystick with index %d not found", index);
41.287 + return 0;
41.288 + }
41.289 +
41.290 + return item->device_instance;
41.291 +}
41.292 +
41.293 +/* Function to open a joystick for use.
41.294 + The joystick to open is specified by the index field of the joystick.
41.295 + This should fill the nbuttons and naxes fields of the joystick structure.
41.296 + It returns 0, or -1 if there is an error.
41.297 + */
41.298 +int
41.299 +SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int index)
41.300 +{
41.301 + SDL_joylist_item *item = JoystickByIndex(index);
41.302 +
41.303 + if (item == NULL ) {
41.304 + return SDL_SetError("No such device");
41.305 + }
41.306 +
41.307 + if (item->joystick != NULL) {
41.308 + return SDL_SetError("Joystick already opened");
41.309 + }
41.310 +
41.311 + joystick->instance_id = item->device_instance;
41.312 + joystick->hwdata = (struct joystick_hwdata *) item;
41.313 + item->joystick = joystick;
41.314 +
41.315 + /* HTML5 Gamepad API doesn't say anything about these */
41.316 + joystick->nhats = 0;
41.317 + joystick->nballs = 0;
41.318 +
41.319 + joystick->nbuttons = item->nbuttons;
41.320 + joystick->naxes = item->naxes;
41.321 +
41.322 + return (0);
41.323 +}
41.324 +
41.325 +/* Function to determine is this joystick is attached to the system right now */
41.326 +SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
41.327 +{
41.328 + return !joystick->closed && (joystick->hwdata != NULL);
41.329 +}
41.330 +
41.331 +/* Function to update the state of a joystick - called as a device poll.
41.332 + * This function shouldn't update the joystick structure directly,
41.333 + * but instead should call SDL_PrivateJoystick*() to deliver events
41.334 + * and update joystick device state.
41.335 + */
41.336 +void
41.337 +SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
41.338 +{
41.339 + EmscriptenGamepadEvent gamepadState;
41.340 + SDL_joylist_item *item = SDL_joylist;
41.341 + int i, result, buttonState;
41.342 +
41.343 + while (item != NULL) {
41.344 + result = emscripten_get_gamepad_status(item->index, &gamepadState);
41.345 + if( result == EMSCRIPTEN_RESULT_SUCCESS) {
41.346 + if(gamepadState.timestamp == 0 || gamepadState.timestamp != item->timestamp) {
41.347 + for(i = 0; i < item->nbuttons; i++) {
41.348 + if(item->digitalButton[i] != gamepadState.digitalButton[i]) {
41.349 + buttonState = gamepadState.digitalButton[i]? SDL_PRESSED: SDL_RELEASED;
41.350 + SDL_PrivateJoystickButton(item->joystick, i, buttonState);
41.351 + }
41.352 + }
41.353 +
41.354 + for(i = 0; i < item->naxes; i++) {
41.355 + if(item->axis[i] != gamepadState.axis[i]) {
41.356 + // do we need to do conversion?
41.357 + SDL_PrivateJoystickAxis(item->joystick, i,
41.358 + (Sint16) (32767.*gamepadState.axis[i]));
41.359 + }
41.360 + }
41.361 +
41.362 + item->timestamp = gamepadState.timestamp;
41.363 + for( i = 0; i < item->naxes; i++) {
41.364 + item->axis[i] = gamepadState.axis[i];
41.365 + }
41.366 +
41.367 + for( i = 0; i < item->nbuttons; i++) {
41.368 + item->analogButton[i] = gamepadState.analogButton[i];
41.369 + item->digitalButton[i] = gamepadState.digitalButton[i];
41.370 + }
41.371 + }
41.372 + }
41.373 + item = item->next;
41.374 + }
41.375 +}
41.376 +
41.377 +/* Function to close a joystick after use */
41.378 +void
41.379 +SDL_SYS_JoystickClose(SDL_Joystick * joystick)
41.380 +{
41.381 + if (joystick->hwdata) {
41.382 + ((SDL_joylist_item*)joystick->hwdata)->joystick = NULL;
41.383 + joystick->hwdata = NULL;
41.384 + }
41.385 + joystick->closed = 1;
41.386 +}
41.387 +
41.388 +/* Function to perform any system-specific joystick related cleanup */
41.389 +void
41.390 +SDL_SYS_JoystickQuit(void)
41.391 +{
41.392 + SDL_joylist_item *item = NULL;
41.393 + SDL_joylist_item *next = NULL;
41.394 +
41.395 + for (item = SDL_joylist; item; item = next) {
41.396 + next = item->next;
41.397 + SDL_free(item->mapping);
41.398 + SDL_free(item->name);
41.399 + SDL_free(item);
41.400 + }
41.401 +
41.402 + SDL_joylist = SDL_joylist_tail = NULL;
41.403 +
41.404 + numjoysticks = 0;
41.405 + instance_counter = 0;
41.406 +}
41.407 +
41.408 +SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID(int index)
41.409 +{
41.410 + SDL_JoystickGUID guid;
41.411 + /* the GUID is just the first 16 chars of the name for now */
41.412 + const char *name = SDL_SYS_JoystickNameForDeviceIndex(index);
41.413 + SDL_zero(guid);
41.414 + SDL_memcpy(&guid, name, SDL_min(sizeof(guid), SDL_strlen(name)));
41.415 + return guid;
41.416 +}
41.417 +
41.418 +
41.419 +SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick)
41.420 +{
41.421 + SDL_JoystickGUID guid;
41.422 + /* the GUID is just the first 16 chars of the name for now */
41.423 + const char *name = joystick->name;
41.424 + SDL_zero(guid);
41.425 + SDL_memcpy(&guid, name, SDL_min(sizeof(guid), SDL_strlen(name)));
41.426 + return guid;
41.427 +}
41.428 +
41.429 +#endif /* SDL_JOYSTICK_EMSCRIPTEN */
42.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
42.2 +++ b/src/joystick/emscripten/SDL_sysjoystick_c.h Thu Jan 15 01:15:24 2015 -0400
42.3 @@ -0,0 +1,52 @@
42.4 +/*
42.5 + Simple DirectMedia Layer
42.6 + Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
42.7 +
42.8 + This software is provided 'as-is', without any express or implied
42.9 + warranty. In no event will the authors be held liable for any damages
42.10 + arising from the use of this software.
42.11 +
42.12 + Permission is granted to anyone to use this software for any purpose,
42.13 + including commercial applications, and to alter it and redistribute it
42.14 + freely, subject to the following restrictions:
42.15 +
42.16 + 1. The origin of this software must not be misrepresented; you must not
42.17 + claim that you wrote the original software. If you use this software
42.18 + in a product, an acknowledgment in the product documentation would be
42.19 + appreciated but is not required.
42.20 + 2. Altered source versions must be plainly marked as such, and must not be
42.21 + misrepresented as being the original software.
42.22 + 3. This notice may not be removed or altered from any source distribution.
42.23 + */
42.24 +
42.25 +#include "SDL_config.h"
42.26 +
42.27 +#ifdef SDL_JOYSTICK_EMSCRIPTEN
42.28 +#include "../SDL_sysjoystick.h"
42.29 +
42.30 +
42.31 +#include <emscripten/html5.h>
42.32 +
42.33 +/* A linked list of available joysticks */
42.34 +typedef struct SDL_joylist_item
42.35 +{
42.36 + int index;
42.37 + char *name;
42.38 + char *mapping;
42.39 + SDL_JoystickID device_instance;
42.40 + SDL_Joystick *joystick;
42.41 + int nbuttons;
42.42 + int naxes;
42.43 + double timestamp;
42.44 + double axis[64];
42.45 + double analogButton[64];
42.46 + EM_BOOL digitalButton[64];
42.47 +
42.48 + struct SDL_joylist_item *next;
42.49 +} SDL_joylist_item;
42.50 +
42.51 +typedef SDL_joylist_item joystick_hwdata;
42.52 +
42.53 +#endif /* SDL_JOYSTICK_EMSCRIPTEN */
42.54 +
42.55 +/* vi: set ts=4 sw=4 expandtab: */
43.1 --- a/src/main/haiku/SDL_BApp.h Thu Jan 15 01:06:14 2015 -0400
43.2 +++ b/src/main/haiku/SDL_BApp.h Thu Jan 15 01:15:24 2015 -0400
43.3 @@ -254,7 +254,7 @@
43.4 return;
43.5 }
43.6 win = GetSDLWindow(winID);
43.7 - SDL_SendMouseWheel(win, 0, xTicks, yTicks);
43.8 + SDL_SendMouseWheel(win, 0, xTicks, yTicks, SDL_MOUSEWHEEL_NORMAL);
43.9 }
43.10
43.11 void _HandleKey(BMessage *msg) {
44.1 --- a/src/power/SDL_power.c Thu Jan 15 01:06:14 2015 -0400
44.2 +++ b/src/power/SDL_power.c Thu Jan 15 01:15:24 2015 -0400
44.3 @@ -38,6 +38,7 @@
44.4 SDL_bool SDL_GetPowerInfo_Android(SDL_PowerState *, int *, int *);
44.5 SDL_bool SDL_GetPowerInfo_PSP(SDL_PowerState *, int *, int *);
44.6 SDL_bool SDL_GetPowerInfo_WinRT(SDL_PowerState *, int *, int *);
44.7 +SDL_bool SDL_GetPowerInfo_Emscripten(SDL_PowerState *, int *, int *);
44.8
44.9 #ifndef SDL_POWER_DISABLED
44.10 #ifdef SDL_POWER_HARDWIRED
44.11 @@ -81,6 +82,9 @@
44.12 #ifdef SDL_POWER_WINRT /* handles WinRT */
44.13 SDL_GetPowerInfo_WinRT,
44.14 #endif
44.15 +#ifdef SDL_POWER_EMSCRIPTEN /* handles Emscripten */
44.16 + SDL_GetPowerInfo_Emscripten,
44.17 +#endif
44.18
44.19 #ifdef SDL_POWER_HARDWIRED
44.20 SDL_GetPowerInfo_Hardwired,
45.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
45.2 +++ b/src/power/emscripten/SDL_syspower.c Thu Jan 15 01:15:24 2015 -0400
45.3 @@ -0,0 +1,62 @@
45.4 +/*
45.5 + Simple DirectMedia Layer
45.6 + Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
45.7 +
45.8 + This software is provided 'as-is', without any express or implied
45.9 + warranty. In no event will the authors be held liable for any damages
45.10 + arising from the use of this software.
45.11 +
45.12 + Permission is granted to anyone to use this software for any purpose,
45.13 + including commercial applications, and to alter it and redistribute it
45.14 + freely, subject to the following restrictions:
45.15 +
45.16 + 1. The origin of this software must not be misrepresented; you must not
45.17 + claim that you wrote the original software. If you use this software
45.18 + in a product, an acknowledgment in the product documentation would be
45.19 + appreciated but is not required.
45.20 + 2. Altered source versions must be plainly marked as such, and must not be
45.21 + misrepresented as being the original software.
45.22 + 3. This notice may not be removed or altered from any source distribution.
45.23 +*/
45.24 +#include "../../SDL_internal.h"
45.25 +
45.26 +#ifndef SDL_POWER_DISABLED
45.27 +#if SDL_POWER_EMSCRIPTEN
45.28 +
45.29 +#include <emscripten/html5.h>
45.30 +
45.31 +#include "SDL_power.h"
45.32 +
45.33 +SDL_bool
45.34 +SDL_GetPowerInfo_Emscripten(SDL_PowerState *state, int *seconds, int *percent)
45.35 +{
45.36 + EmscriptenBatteryEvent batteryState;
45.37 + int haveBattery = 0;
45.38 +
45.39 + if (emscripten_get_battery_status(&batteryState) == EMSCRIPTEN_RESULT_NOT_SUPPORTED)
45.40 + return SDL_FALSE;
45.41 +
45.42 + haveBattery = batteryState.level != 1.0 || !batteryState.charging || batteryState.chargingTime != 0.0;
45.43 +
45.44 + if (!haveBattery) {
45.45 + *state = SDL_POWERSTATE_NO_BATTERY;
45.46 + *seconds = -1;
45.47 + *percent = -1;
45.48 + return SDL_TRUE;
45.49 + }
45.50 +
45.51 + if (batteryState.charging)
45.52 + *state = batteryState.chargingTime == 0.0 ? SDL_POWERSTATE_CHARGED : SDL_POWERSTATE_CHARGING;
45.53 + else
45.54 + *state = SDL_POWERSTATE_ON_BATTERY;
45.55 +
45.56 + *seconds = batteryState.dischargingTime;
45.57 + *percent = batteryState.level * 100;
45.58 +
45.59 + return SDL_TRUE;
45.60 +}
45.61 +
45.62 +#endif /* SDL_POWER_EMSCRIPTEN */
45.63 +#endif /* SDL_POWER_DISABLED */
45.64 +
45.65 +/* vi: set ts=4 sw=4 expandtab: */
46.1 --- a/src/render/opengles2/SDL_gles2funcs.h Thu Jan 15 01:06:14 2015 -0400
46.2 +++ b/src/render/opengles2/SDL_gles2funcs.h Thu Jan 15 01:15:24 2015 -0400
46.3 @@ -69,3 +69,7 @@
46.4 SDL_PROC(void, glDeleteFramebuffers, (GLsizei, const GLuint *))
46.5 SDL_PROC(GLint, glGetAttribLocation, (GLuint, const GLchar *))
46.6 SDL_PROC(void, glGetProgramInfoLog, (GLuint, GLsizei, GLsizei*, GLchar*))
46.7 +SDL_PROC(void, glGenBuffers, (GLsizei, GLuint *))
46.8 +SDL_PROC(void, glBindBuffer, (GLenum, GLuint))
46.9 +SDL_PROC(void, glBufferData, (GLenum, GLsizeiptr, const GLvoid *, GLenum))
46.10 +SDL_PROC(void, glBufferSubData, (GLenum, GLintptr, GLsizeiptr, const GLvoid *))
47.1 --- a/src/render/opengles2/SDL_render_gles2.c Thu Jan 15 01:06:14 2015 -0400
47.2 +++ b/src/render/opengles2/SDL_render_gles2.c Thu Jan 15 01:15:24 2015 -0400
47.3 @@ -28,7 +28,20 @@
47.4 #include "../../video/SDL_blit.h"
47.5 #include "SDL_shaders_gles2.h"
47.6
47.7 -/* To prevent unnecessary window recreation,
47.8 +/* !!! FIXME: Emscripten makes these into WebGL calls, and WebGL doesn't offer
47.9 + !!! FIXME: client-side arrays (without an Emscripten compatibility hack,
47.10 + !!! FIXME: at least), but the current VBO code here is dramatically
47.11 + !!! FIXME: slower on actual iOS devices, even though the iOS Simulator
47.12 + !!! FIXME: is okay. Some time after 2.0.4 ships, we should revisit this,
47.13 + !!! FIXME: fix the performance bottleneck, and make everything use VBOs.
47.14 +*/
47.15 +#ifdef __EMSCRIPTEN__
47.16 +#define SDL_GLES2_USE_VBOS 1
47.17 +#else
47.18 +#define SDL_GLES2_USE_VBOS 0
47.19 +#endif
47.20 +
47.21 +/* To prevent unnecessary window recreation,
47.22 * these should match the defaults selected in SDL_GL_ResetAttributes
47.23 */
47.24 #define RENDERER_CONTEXT_MAJOR 2
47.25 @@ -180,6 +193,11 @@
47.26 GLES2_ProgramCache program_cache;
47.27 GLES2_ProgramCacheEntry *current_program;
47.28 Uint8 clear_r, clear_g, clear_b, clear_a;
47.29 +
47.30 +#if SDL_GLES2_USE_VBOS
47.31 + GLuint vertex_buffers[4];
47.32 + GLsizeiptr vertex_buffer_size[4];
47.33 +#endif
47.34 } GLES2_DriverContext;
47.35
47.36 #define GLES2_MAX_CACHED_PROGRAMS 8
47.37 @@ -1393,6 +1411,33 @@
47.38 }
47.39
47.40 static int
47.41 +GLES2_UpdateVertexBuffer(SDL_Renderer *renderer, GLES2_Attribute attr,
47.42 + const void *vertexData, size_t dataSizeInBytes)
47.43 +{
47.44 + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata;
47.45 +
47.46 +#if !SDL_GLES2_USE_VBOS
47.47 + data->glVertexAttribPointer(attr, attr == GLES2_ATTRIBUTE_ANGLE ? 1 : 2, GL_FLOAT, GL_FALSE, 0, vertexData);
47.48 +#else
47.49 + if (!data->vertex_buffers[attr])
47.50 + data->glGenBuffers(1, &data->vertex_buffers[attr]);
47.51 +
47.52 + data->glBindBuffer(GL_ARRAY_BUFFER, data->vertex_buffers[attr]);
47.53 +
47.54 + if (data->vertex_buffer_size[attr] < dataSizeInBytes) {
47.55 + data->glBufferData(GL_ARRAY_BUFFER, dataSizeInBytes, vertexData, GL_STREAM_DRAW);
47.56 + data->vertex_buffer_size[attr] = dataSizeInBytes;
47.57 + } else {
47.58 + data->glBufferSubData(GL_ARRAY_BUFFER, 0, dataSizeInBytes, vertexData);
47.59 + }
47.60 +
47.61 + data->glVertexAttribPointer(attr, attr == GLES2_ATTRIBUTE_ANGLE ? 1 : 2, GL_FLOAT, GL_FALSE, 0, 0);
47.62 +#endif
47.63 +
47.64 + return 0;
47.65 +}
47.66 +
47.67 +static int
47.68 GLES2_RenderDrawPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int count)
47.69 {
47.70 GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata;
47.71 @@ -1412,7 +1457,8 @@
47.72 vertices[idx * 2] = x;
47.73 vertices[(idx * 2) + 1] = y;
47.74 }
47.75 - data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
47.76 + /*data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);*/
47.77 + GLES2_UpdateVertexBuffer(renderer, GLES2_ATTRIBUTE_POSITION, vertices, count * 2 * sizeof(GLfloat));
47.78 data->glDrawArrays(GL_POINTS, 0, count);
47.79 SDL_stack_free(vertices);
47.80 return 0;
47.81 @@ -1438,7 +1484,8 @@
47.82 vertices[idx * 2] = x;
47.83 vertices[(idx * 2) + 1] = y;
47.84 }
47.85 - data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
47.86 + /*data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);*/
47.87 + GLES2_UpdateVertexBuffer(renderer, GLES2_ATTRIBUTE_POSITION, vertices, count * 2 * sizeof(GLfloat));
47.88 data->glDrawArrays(GL_LINE_STRIP, 0, count);
47.89
47.90 /* We need to close the endpoint of the line */
47.91 @@ -1479,7 +1526,8 @@
47.92 vertices[5] = yMax;
47.93 vertices[6] = xMax;
47.94 vertices[7] = yMax;
47.95 - data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
47.96 + /*data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);*/
47.97 + GLES2_UpdateVertexBuffer(renderer, GLES2_ATTRIBUTE_POSITION, vertices, 8 * sizeof(GLfloat));
47.98 data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
47.99 }
47.100 return GL_CheckError("", renderer);
47.101 @@ -1675,7 +1723,8 @@
47.102 vertices[5] = (dstrect->y + dstrect->h);
47.103 vertices[6] = (dstrect->x + dstrect->w);
47.104 vertices[7] = (dstrect->y + dstrect->h);
47.105 - data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
47.106 + /*data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);*/
47.107 + GLES2_UpdateVertexBuffer(renderer, GLES2_ATTRIBUTE_POSITION, vertices, 8 * sizeof(GLfloat));
47.108 texCoords[0] = srcrect->x / (GLfloat)texture->w;
47.109 texCoords[1] = srcrect->y / (GLfloat)texture->h;
47.110 texCoords[2] = (srcrect->x + srcrect->w) / (GLfloat)texture->w;
47.111 @@ -1684,7 +1733,8 @@
47.112 texCoords[5] = (srcrect->y + srcrect->h) / (GLfloat)texture->h;
47.113 texCoords[6] = (srcrect->x + srcrect->w) / (GLfloat)texture->w;
47.114 texCoords[7] = (srcrect->y + srcrect->h) / (GLfloat)texture->h;
47.115 - data->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, texCoords);
47.116 + /*data->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, texCoords);*/
47.117 + GLES2_UpdateVertexBuffer(renderer, GLES2_ATTRIBUTE_TEXCOORD, texCoords, 8 * sizeof(GLfloat));
47.118 data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
47.119
47.120 return GL_CheckError("", renderer);
47.121 @@ -1734,9 +1784,13 @@
47.122 vertices[5] = vertices[7] = tmp;
47.123 }
47.124
47.125 - data->glVertexAttribPointer(GLES2_ATTRIBUTE_ANGLE, 1, GL_FLOAT, GL_FALSE, 0, &fAngle);
47.126 + /*data->glVertexAttribPointer(GLES2_ATTRIBUTE_ANGLE, 1, GL_FLOAT, GL_FALSE, 0, &fAngle);
47.127 data->glVertexAttribPointer(GLES2_ATTRIBUTE_CENTER, 2, GL_FLOAT, GL_FALSE, 0, translate);
47.128 - data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
47.129 + data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);*/
47.130 +
47.131 + GLES2_UpdateVertexBuffer(renderer, GLES2_ATTRIBUTE_ANGLE, fAngle, 4 * sizeof(GLfloat));
47.132 + GLES2_UpdateVertexBuffer(renderer, GLES2_ATTRIBUTE_CENTER, translate, 8 * sizeof(GLfloat));
47.133 + GLES2_UpdateVertexBuffer(renderer, GLES2_ATTRIBUTE_POSITION, vertices, 8 * sizeof(GLfloat));
47.134
47.135 texCoords[0] = srcrect->x / (GLfloat)texture->w;
47.136 texCoords[1] = srcrect->y / (GLfloat)texture->h;
47.137 @@ -1746,7 +1800,8 @@
47.138 texCoords[5] = (srcrect->y + srcrect->h) / (GLfloat)texture->h;
47.139 texCoords[6] = (srcrect->x + srcrect->w) / (GLfloat)texture->w;
47.140 texCoords[7] = (srcrect->y + srcrect->h) / (GLfloat)texture->h;
47.141 - data->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, texCoords);
47.142 + /*data->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, texCoords);*/
47.143 + GLES2_UpdateVertexBuffer(renderer, GLES2_ATTRIBUTE_TEXCOORD, texCoords, 8 * sizeof(GLfloat));
47.144 data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
47.145 data->glDisableVertexAttribArray(GLES2_ATTRIBUTE_CENTER);
47.146 data->glDisableVertexAttribArray(GLES2_ATTRIBUTE_ANGLE);
48.1 --- a/src/stdlib/SDL_getenv.c Thu Jan 15 01:06:14 2015 -0400
48.2 +++ b/src/stdlib/SDL_getenv.c Thu Jan 15 01:15:24 2015 -0400
48.3 @@ -18,6 +18,11 @@
48.4 misrepresented as being the original software.
48.5 3. This notice may not be removed or altered from any source distribution.
48.6 */
48.7 +
48.8 +#if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS)
48.9 +#define SDL_DISABLE_ANALYZE_MACROS 1
48.10 +#endif
48.11 +
48.12 #include "../SDL_internal.h"
48.13
48.14 #if defined(__WIN32__)
49.1 --- a/src/stdlib/SDL_iconv.c Thu Jan 15 01:06:14 2015 -0400
49.2 +++ b/src/stdlib/SDL_iconv.c Thu Jan 15 01:15:24 2015 -0400
49.3 @@ -18,6 +18,11 @@
49.4 misrepresented as being the original software.
49.5 3. This notice may not be removed or altered from any source distribution.
49.6 */
49.7 +
49.8 +#if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS)
49.9 +#define SDL_DISABLE_ANALYZE_MACROS 1
49.10 +#endif
49.11 +
49.12 #include "../SDL_internal.h"
49.13
49.14 /* This file contains portable iconv functions for SDL */
50.1 --- a/src/stdlib/SDL_malloc.c Thu Jan 15 01:06:14 2015 -0400
50.2 +++ b/src/stdlib/SDL_malloc.c Thu Jan 15 01:15:24 2015 -0400
50.3 @@ -18,6 +18,11 @@
50.4 misrepresented as being the original software.
50.5 3. This notice may not be removed or altered from any source distribution.
50.6 */
50.7 +
50.8 +#if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS)
50.9 +#define SDL_DISABLE_ANALYZE_MACROS 1
50.10 +#endif
50.11 +
50.12 #include "../SDL_internal.h"
50.13
50.14 /* This file contains portable memory management functions for SDL */
51.1 --- a/src/stdlib/SDL_qsort.c Thu Jan 15 01:06:14 2015 -0400
51.2 +++ b/src/stdlib/SDL_qsort.c Thu Jan 15 01:15:24 2015 -0400
51.3 @@ -41,6 +41,11 @@
51.4 *
51.5 * Gareth McCaughan Peterhouse Cambridge 1998
51.6 */
51.7 +
51.8 +#if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS)
51.9 +#define SDL_DISABLE_ANALYZE_MACROS 1
51.10 +#endif
51.11 +
51.12 #include "../SDL_internal.h"
51.13
51.14 /*
52.1 --- a/src/stdlib/SDL_stdlib.c Thu Jan 15 01:06:14 2015 -0400
52.2 +++ b/src/stdlib/SDL_stdlib.c Thu Jan 15 01:15:24 2015 -0400
52.3 @@ -18,6 +18,11 @@
52.4 misrepresented as being the original software.
52.5 3. This notice may not be removed or altered from any source distribution.
52.6 */
52.7 +
52.8 +#if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS)
52.9 +#define SDL_DISABLE_ANALYZE_MACROS 1
52.10 +#endif
52.11 +
52.12 #include "../SDL_internal.h"
52.13
52.14 /* This file contains portable stdlib functions for SDL */
53.1 --- a/src/stdlib/SDL_string.c Thu Jan 15 01:06:14 2015 -0400
53.2 +++ b/src/stdlib/SDL_string.c Thu Jan 15 01:15:24 2015 -0400
53.3 @@ -18,6 +18,11 @@
53.4 misrepresented as being the original software.
53.5 3. This notice may not be removed or altered from any source distribution.
53.6 */
53.7 +
53.8 +#if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS)
53.9 +#define SDL_DISABLE_ANALYZE_MACROS 1
53.10 +#endif
53.11 +
53.12 #include "../SDL_internal.h"
53.13
53.14 /* This file contains portable string manipulation functions for SDL */
54.1 --- a/src/test/SDL_test_common.c Thu Jan 15 01:06:14 2015 -0400
54.2 +++ b/src/test/SDL_test_common.c Thu Jan 15 01:15:24 2015 -0400
54.3 @@ -1105,8 +1105,8 @@
54.4 event->button.windowID);
54.5 break;
54.6 case SDL_MOUSEWHEEL:
54.7 - SDL_Log("SDL EVENT: Mouse: wheel scrolled %d in x and %d in y in window %d",
54.8 - event->wheel.x, event->wheel.y, event->wheel.windowID);
54.9 + SDL_Log("SDL EVENT: Mouse: wheel scrolled %d in x and %d in y (reversed: %d) in window %d",
54.10 + event->wheel.x, event->wheel.y, event->wheel.direction, event->wheel.windowID);
54.11 break;
54.12 case SDL_JOYDEVICEADDED:
54.13 SDL_Log("SDL EVENT: Joystick index %d attached",
54.14 @@ -1203,6 +1203,15 @@
54.15 event->tfinger.x, event->tfinger.y,
54.16 event->tfinger.dx, event->tfinger.dy, event->tfinger.pressure);
54.17 break;
54.18 + case SDL_DOLLARGESTURE:
54.19 + SDL_Log("SDL_EVENT: Dollar gesture detect: %"SDL_PRIs64, (long long) event->dgesture.gestureId);
54.20 + break;
54.21 + case SDL_DOLLARRECORD:
54.22 + SDL_Log("SDL_EVENT: Dollar gesture record: %"SDL_PRIs64, (long long) event->dgesture.gestureId);
54.23 + break;
54.24 + case SDL_MULTIGESTURE:
54.25 + SDL_Log("SDL_EVENT: Multi gesture fingers: %d", event->mgesture.numFingers);
54.26 + break;
54.27
54.28 case SDL_RENDER_DEVICE_RESET:
54.29 SDL_Log("SDL EVENT: render device reset");
54.30 @@ -1218,7 +1227,7 @@
54.31 SDL_Log("SDL EVENT: User event %d", event->user.code);
54.32 break;
54.33 default:
54.34 - SDL_Log("Unknown event %d", event->type);
54.35 + SDL_Log("Unknown event %04x", event->type);
54.36 break;
54.37 }
54.38 }
55.1 --- a/src/video/SDL_surface.c Thu Jan 15 01:06:14 2015 -0400
55.2 +++ b/src/video/SDL_surface.c Thu Jan 15 01:15:24 2015 -0400
55.3 @@ -741,15 +741,15 @@
55.4 dst_y0 += dst->clip_rect.y;
55.5 dst_y1 += dst->clip_rect.y;
55.6
55.7 - final_src.x = SDL_floor(src_x0 + 0.5);
55.8 - final_src.y = SDL_floor(src_y0 + 0.5);
55.9 - final_src.w = SDL_floor(src_x1 - src_x0 + 1.5);
55.10 - final_src.h = SDL_floor(src_y1 - src_y0 + 1.5);
55.11 + final_src.x = (int)SDL_floor(src_x0 + 0.5);
55.12 + final_src.y = (int)SDL_floor(src_y0 + 0.5);
55.13 + final_src.w = (int)SDL_floor(src_x1 - src_x0 + 1.5);
55.14 + final_src.h = (int)SDL_floor(src_y1 - src_y0 + 1.5);
55.15
55.16 - final_dst.x = SDL_floor(dst_x0 + 0.5);
55.17 - final_dst.y = SDL_floor(dst_y0 + 0.5);
55.18 - final_dst.w = SDL_floor(dst_x1 - dst_x0 + 1.5);
55.19 - final_dst.h = SDL_floor(dst_y1 - dst_y0 + 1.5);
55.20 + final_dst.x = (int)SDL_floor(dst_x0 + 0.5);
55.21 + final_dst.y = (int)SDL_floor(dst_y0 + 0.5);
55.22 + final_dst.w = (int)SDL_floor(dst_x1 - dst_x0 + 1.5);
55.23 + final_dst.h = (int)SDL_floor(dst_y1 - dst_y0 + 1.5);
55.24
55.25 if (final_dst.w < 0)
55.26 final_dst.w = 0;
56.1 --- a/src/video/SDL_sysvideo.h Thu Jan 15 01:06:14 2015 -0400
56.2 +++ b/src/video/SDL_sysvideo.h Thu Jan 15 01:15:24 2015 -0400
56.3 @@ -394,6 +394,9 @@
56.4 #if SDL_VIDEO_DRIVER_VIVANTE
56.5 extern VideoBootStrap VIVANTE_bootstrap;
56.6 #endif
56.7 +#if SDL_VIDEO_DRIVER_EMSCRIPTEN
56.8 +extern VideoBootStrap Emscripten_bootstrap;
56.9 +#endif
56.10
56.11 extern SDL_VideoDevice *SDL_GetVideoDevice(void);
56.12 extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
57.1 --- a/src/video/SDL_video.c Thu Jan 15 01:06:14 2015 -0400
57.2 +++ b/src/video/SDL_video.c Thu Jan 15 01:15:24 2015 -0400
57.3 @@ -98,6 +98,9 @@
57.4 #if SDL_VIDEO_DRIVER_NACL
57.5 &NACL_bootstrap,
57.6 #endif
57.7 +#if SDL_VIDEO_DRIVER_EMSCRIPTEN
57.8 + &Emscripten_bootstrap,
57.9 +#endif
57.10 #if SDL_VIDEO_DRIVER_DUMMY
57.11 &DUMMY_bootstrap,
57.12 #endif
58.1 --- a/src/video/cocoa/SDL_cocoamouse.m Thu Jan 15 01:06:14 2015 -0400
58.2 +++ b/src/video/cocoa/SDL_cocoamouse.m Thu Jan 15 01:15:24 2015 -0400
58.3 @@ -399,6 +399,13 @@
58.4
58.5 float x = -[event deltaX];
58.6 float y = [event deltaY];
58.7 + SDL_MouseWheelDirection direction = SDL_MOUSEWHEEL_NORMAL;
58.8 +
58.9 + if ([event respondsToSelector:@selector(isDirectionInvertedFromDevice)]) {
58.10 + if ([event isDirectionInvertedFromDevice] == YES) {
58.11 + direction = SDL_MOUSEWHEEL_FLIPPED;
58.12 + }
58.13 + }
58.14
58.15 if (x > 0) {
58.16 x += 0.9f;
58.17 @@ -410,7 +417,7 @@
58.18 } else if (y < 0) {
58.19 y -= 0.9f;
58.20 }
58.21 - SDL_SendMouseWheel(window, mouse->mouseID, (int)x, (int)y);
58.22 + SDL_SendMouseWheel(window, mouse->mouseID, (int)x, (int)y, direction);
58.23 }
58.24
58.25 void
59.1 --- a/src/video/directfb/SDL_DirectFB_video.c Thu Jan 15 01:06:14 2015 -0400
59.2 +++ b/src/video/directfb/SDL_DirectFB_video.c Thu Jan 15 01:15:24 2015 -0400
59.3 @@ -156,7 +156,7 @@
59.4 return device;
59.5 error:
59.6 if (device)
59.7 - free(device);
59.8 + SDL_free(device);
59.9 return (0);
59.10 }
59.11
60.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
60.2 +++ b/src/video/emscripten/SDL_emscriptenevents.c Thu Jan 15 01:15:24 2015 -0400
60.3 @@ -0,0 +1,638 @@
60.4 +/*
60.5 + Simple DirectMedia Layer
60.6 + Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
60.7 +
60.8 + This software is provided 'as-is', without any express or implied
60.9 + warranty. In no event will the authors be held liable for any damages
60.10 + arising from the use of this software.
60.11 +
60.12 + Permission is granted to anyone to use this software for any purpose,
60.13 + including commercial applications, and to alter it and redistribute it
60.14 + freely, subject to the following restrictions:
60.15 +
60.16 + 1. The origin of this software must not be misrepresented; you must not
60.17 + claim that you wrote the original software. If you use this software
60.18 + in a product, an acknowledgment in the product documentation would be
60.19 + appreciated but is not required.
60.20 + 2. Altered source versions must be plainly marked as such, and must not be
60.21 + misrepresented as being the original software.
60.22 + 3. This notice may not be removed or altered from any source distribution.
60.23 +*/
60.24 +
60.25 +
60.26 +#include "../../SDL_internal.h"
60.27 +
60.28 +#if SDL_VIDEO_DRIVER_EMSCRIPTEN
60.29 +
60.30 +#include <emscripten/html5.h>
60.31 +
60.32 +#include "../../events/SDL_events_c.h"
60.33 +#include "../../events/SDL_keyboard_c.h"
60.34 +#include "../../events/SDL_touch_c.h"
60.35 +
60.36 +#include "SDL_emscriptenevents.h"
60.37 +#include "SDL_emscriptenvideo.h"
60.38 +
60.39 +#include "SDL_hints.h"
60.40 +
60.41 +#define FULLSCREEN_MASK ( SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN )
60.42 +
60.43 +/*
60.44 +.which to scancode
60.45 +https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Constants
60.46 +*/
60.47 +static const SDL_Scancode emscripten_scancode_table[] = {
60.48 + /* 0 */ SDL_SCANCODE_UNKNOWN,
60.49 + /* 1 */ SDL_SCANCODE_UNKNOWN,
60.50 + /* 2 */ SDL_SCANCODE_UNKNOWN,
60.51 + /* 3 */ SDL_SCANCODE_CANCEL,
60.52 + /* 4 */ SDL_SCANCODE_UNKNOWN,
60.53 + /* 5 */ SDL_SCANCODE_UNKNOWN,
60.54 + /* 6 */ SDL_SCANCODE_HELP,
60.55 + /* 7 */ SDL_SCANCODE_UNKNOWN,
60.56 + /* 8 */ SDL_SCANCODE_BACKSPACE,
60.57 + /* 9 */ SDL_SCANCODE_TAB,
60.58 + /* 10 */ SDL_SCANCODE_UNKNOWN,
60.59 + /* 11 */ SDL_SCANCODE_UNKNOWN,
60.60 + /* 12 */ SDL_SCANCODE_UNKNOWN,
60.61 + /* 13 */ SDL_SCANCODE_RETURN,
60.62 + /* 14 */ SDL_SCANCODE_UNKNOWN,
60.63 + /* 15 */ SDL_SCANCODE_UNKNOWN,
60.64 + /* 16 */ SDL_SCANCODE_LSHIFT,
60.65 + /* 17 */ SDL_SCANCODE_LCTRL,
60.66 + /* 18 */ SDL_SCANCODE_LALT,
60.67 + /* 19 */ SDL_SCANCODE_PAUSE,
60.68 + /* 20 */ SDL_SCANCODE_CAPSLOCK,
60.69 + /* 21 */ SDL_SCANCODE_UNKNOWN,
60.70 + /* 22 */ SDL_SCANCODE_UNKNOWN,
60.71 + /* 23 */ SDL_SCANCODE_UNKNOWN,
60.72 + /* 24 */ SDL_SCANCODE_UNKNOWN,
60.73 + /* 25 */ SDL_SCANCODE_UNKNOWN,
60.74 + /* 26 */ SDL_SCANCODE_UNKNOWN,
60.75 + /* 27 */ SDL_SCANCODE_ESCAPE,
60.76 + /* 28 */ SDL_SCANCODE_UNKNOWN,
60.77 + /* 29 */ SDL_SCANCODE_UNKNOWN,
60.78 + /* 30 */ SDL_SCANCODE_UNKNOWN,
60.79 + /* 31 */ SDL_SCANCODE_UNKNOWN,
60.80 + /* 32 */ SDL_SCANCODE_SPACE,
60.81 + /* 33 */ SDL_SCANCODE_PAGEUP,
60.82 + /* 34 */ SDL_SCANCODE_PAGEDOWN,
60.83 + /* 35 */ SDL_SCANCODE_END,
60.84 + /* 36 */ SDL_SCANCODE_HOME,
60.85 + /* 37 */ SDL_SCANCODE_LEFT,
60.86 + /* 38 */ SDL_SCANCODE_UP,
60.87 + /* 39 */ SDL_SCANCODE_RIGHT,
60.88 + /* 40 */ SDL_SCANCODE_DOWN,
60.89 + /* 41 */ SDL_SCANCODE_UNKNOWN,
60.90 + /* 42 */ SDL_SCANCODE_UNKNOWN,
60.91 + /* 43 */ SDL_SCANCODE_UNKNOWN,
60.92 + /* 44 */ SDL_SCANCODE_UNKNOWN,
60.93 + /* 45 */ SDL_SCANCODE_INSERT,
60.94 + /* 46 */ SDL_SCANCODE_DELETE,
60.95 + /* 47 */ SDL_SCANCODE_UNKNOWN,
60.96 + /* 48 */ SDL_SCANCODE_0,
60.97 + /* 49 */ SDL_SCANCODE_1,
60.98 + /* 50 */ SDL_SCANCODE_2,
60.99 + /* 51 */ SDL_SCANCODE_3,
60.100 + /* 52 */ SDL_SCANCODE_4,
60.101 + /* 53 */ SDL_SCANCODE_5,
60.102 + /* 54 */ SDL_SCANCODE_6,
60.103 + /* 55 */ SDL_SCANCODE_7,
60.104 + /* 56 */ SDL_SCANCODE_8,
60.105 + /* 57 */ SDL_SCANCODE_9,
60.106 + /* 58 */ SDL_SCANCODE_UNKNOWN,
60.107 + /* 59 */ SDL_SCANCODE_SEMICOLON,
60.108 + /* 60 */ SDL_SCANCODE_UNKNOWN,
60.109 + /* 61 */ SDL_SCANCODE_EQUALS,
60.110 + /* 62 */ SDL_SCANCODE_UNKNOWN,
60.111 + /* 63 */ SDL_SCANCODE_UNKNOWN,
60.112 + /* 64 */ SDL_SCANCODE_UNKNOWN,
60.113 + /* 65 */ SDL_SCANCODE_A,
60.114 + /* 66 */ SDL_SCANCODE_B,
60.115 + /* 67 */ SDL_SCANCODE_C,
60.116 + /* 68 */ SDL_SCANCODE_D,
60.117 + /* 69 */ SDL_SCANCODE_E,
60.118 + /* 70 */ SDL_SCANCODE_F,
60.119 + /* 71 */ SDL_SCANCODE_G,
60.120 + /* 72 */ SDL_SCANCODE_H,
60.121 + /* 73 */ SDL_SCANCODE_I,
60.122 + /* 74 */ SDL_SCANCODE_J,
60.123 + /* 75 */ SDL_SCANCODE_K,
60.124 + /* 76 */ SDL_SCANCODE_L,
60.125 + /* 77 */ SDL_SCANCODE_M,
60.126 + /* 78 */ SDL_SCANCODE_N,
60.127 + /* 79 */ SDL_SCANCODE_O,
60.128 + /* 80 */ SDL_SCANCODE_P,
60.129 + /* 81 */ SDL_SCANCODE_Q,
60.130 + /* 82 */ SDL_SCANCODE_R,
60.131 + /* 83 */ SDL_SCANCODE_S,
60.132 + /* 84 */ SDL_SCANCODE_T,
60.133 + /* 85 */ SDL_SCANCODE_U,
60.134 + /* 86 */ SDL_SCANCODE_V,
60.135 + /* 87 */ SDL_SCANCODE_W,
60.136 + /* 88 */ SDL_SCANCODE_X,
60.137 + /* 89 */ SDL_SCANCODE_Y,
60.138 + /* 90 */ SDL_SCANCODE_Z,
60.139 + /* 91 */ SDL_SCANCODE_LGUI,
60.140 + /* 92 */ SDL_SCANCODE_UNKNOWN,
60.141 + /* 93 */ SDL_SCANCODE_APPLICATION,
60.142 + /* 94 */ SDL_SCANCODE_UNKNOWN,
60.143 + /* 95 */ SDL_SCANCODE_UNKNOWN,
60.144 + /* 96 */ SDL_SCANCODE_KP_0,
60.145 + /* 97 */ SDL_SCANCODE_KP_1,
60.146 + /* 98 */ SDL_SCANCODE_KP_2,
60.147 + /* 99 */ SDL_SCANCODE_KP_3,
60.148 + /* 100 */ SDL_SCANCODE_KP_4,
60.149 + /* 101 */ SDL_SCANCODE_KP_5,
60.150 + /* 102 */ SDL_SCANCODE_KP_6,
60.151 + /* 103 */ SDL_SCANCODE_KP_7,
60.152 + /* 104 */ SDL_SCANCODE_KP_8,
60.153 + /* 105 */ SDL_SCANCODE_KP_9,
60.154 + /* 106 */ SDL_SCANCODE_KP_MULTIPLY,
60.155 + /* 107 */ SDL_SCANCODE_KP_PLUS,
60.156 + /* 108 */ SDL_SCANCODE_UNKNOWN,
60.157 + /* 109 */ SDL_SCANCODE_KP_MINUS,
60.158 + /* 110 */ SDL_SCANCODE_KP_PERIOD,
60.159 + /* 111 */ SDL_SCANCODE_KP_DIVIDE,
60.160 + /* 112 */ SDL_SCANCODE_F1,
60.161 + /* 113 */ SDL_SCANCODE_F2,
60.162 + /* 114 */ SDL_SCANCODE_F3,
60.163 + /* 115 */ SDL_SCANCODE_F4,
60.164 + /* 116 */ SDL_SCANCODE_F5,
60.165 + /* 117 */ SDL_SCANCODE_F6,
60.166 + /* 118 */ SDL_SCANCODE_F7,
60.167 + /* 119 */ SDL_SCANCODE_F8,
60.168 + /* 120 */ SDL_SCANCODE_F9,
60.169 + /* 121 */ SDL_SCANCODE_F10,
60.170 + /* 122 */ SDL_SCANCODE_F11,
60.171 + /* 123 */ SDL_SCANCODE_F12,
60.172 + /* 124 */ SDL_SCANCODE_F13,
60.173 + /* 125 */ SDL_SCANCODE_F14,
60.174 + /* 126 */ SDL_SCANCODE_F15,
60.175 + /* 127 */ SDL_SCANCODE_F16,
60.176 + /* 128 */ SDL_SCANCODE_F17,
60.177 + /* 129 */ SDL_SCANCODE_F18,
60.178 + /* 130 */ SDL_SCANCODE_F19,
60.179 + /* 131 */ SDL_SCANCODE_F20,
60.180 + /* 132 */ SDL_SCANCODE_F21,
60.181 + /* 133 */ SDL_SCANCODE_F22,
60.182 + /* 134 */ SDL_SCANCODE_F23,
60.183 + /* 135 */ SDL_SCANCODE_F24,
60.184 + /* 136 */ SDL_SCANCODE_UNKNOWN,
60.185 + /* 137 */ SDL_SCANCODE_UNKNOWN,
60.186 + /* 138 */ SDL_SCANCODE_UNKNOWN,
60.187 + /* 139 */ SDL_SCANCODE_UNKNOWN,
60.188 + /* 140 */ SDL_SCANCODE_UNKNOWN,
60.189 + /* 141 */ SDL_SCANCODE_UNKNOWN,
60.190 + /* 142 */ SDL_SCANCODE_UNKNOWN,
60.191 + /* 143 */ SDL_SCANCODE_UNKNOWN,
60.192 + /* 144 */ SDL_SCANCODE_NUMLOCKCLEAR,
60.193 + /* 145 */ SDL_SCANCODE_SCROLLLOCK,
60.194 + /* 146 */ SDL_SCANCODE_UNKNOWN,
60.195 + /* 147 */ SDL_SCANCODE_UNKNOWN,
60.196 + /* 148 */ SDL_SCANCODE_UNKNOWN,
60.197 + /* 149 */ SDL_SCANCODE_UNKNOWN,
60.198 + /* 150 */ SDL_SCANCODE_UNKNOWN,
60.199 + /* 151 */ SDL_SCANCODE_UNKNOWN,
60.200 + /* 152 */ SDL_SCANCODE_UNKNOWN,
60.201 + /* 153 */ SDL_SCANCODE_UNKNOWN,
60.202 + /* 154 */ SDL_SCANCODE_UNKNOWN,
60.203 + /* 155 */ SDL_SCANCODE_UNKNOWN,
60.204 + /* 156 */ SDL_SCANCODE_UNKNOWN,
60.205 + /* 157 */ SDL_SCANCODE_UNKNOWN,
60.206 + /* 158 */ SDL_SCANCODE_UNKNOWN,
60.207 + /* 159 */ SDL_SCANCODE_UNKNOWN,
60.208 + /* 160 */ SDL_SCANCODE_UNKNOWN,
60.209 + /* 161 */ SDL_SCANCODE_UNKNOWN,
60.210 + /* 162 */ SDL_SCANCODE_UNKNOWN,
60.211 + /* 163 */ SDL_SCANCODE_UNKNOWN,
60.212 + /* 164 */ SDL_SCANCODE_UNKNOWN,
60.213 + /* 165 */ SDL_SCANCODE_UNKNOWN,
60.214 + /* 166 */ SDL_SCANCODE_UNKNOWN,
60.215 + /* 167 */ SDL_SCANCODE_UNKNOWN,
60.216 + /* 168 */ SDL_SCANCODE_UNKNOWN,
60.217 + /* 169 */ SDL_SCANCODE_UNKNOWN,
60.218 + /* 170 */ SDL_SCANCODE_UNKNOWN,
60.219 + /* 171 */ SDL_SCANCODE_UNKNOWN,
60.220 + /* 172 */ SDL_SCANCODE_UNKNOWN,
60.221 + /* 173 */ SDL_SCANCODE_MINUS, /*FX*/
60.222 + /* 174 */ SDL_SCANCODE_UNKNOWN,
60.223 + /* 175 */ SDL_SCANCODE_UNKNOWN,
60.224 + /* 176 */ SDL_SCANCODE_UNKNOWN,
60.225 + /* 177 */ SDL_SCANCODE_UNKNOWN,
60.226 + /* 178 */ SDL_SCANCODE_UNKNOWN,
60.227 + /* 179 */ SDL_SCANCODE_UNKNOWN,
60.228 + /* 180 */ SDL_SCANCODE_UNKNOWN,
60.229 + /* 181 */ SDL_SCANCODE_UNKNOWN,
60.230 + /* 182 */ SDL_SCANCODE_UNKNOWN,
60.231 + /* 183 */ SDL_SCANCODE_UNKNOWN,
60.232 + /* 184 */ SDL_SCANCODE_UNKNOWN,
60.233 + /* 185 */ SDL_SCANCODE_UNKNOWN,
60.234 + /* 186 */ SDL_SCANCODE_SEMICOLON, /*IE, Chrome, D3E legacy*/
60.235 + /* 187 */ SDL_SCANCODE_EQUALS, /*IE, Chrome, D3E legacy*/
60.236 + /* 188 */ SDL_SCANCODE_COMMA,
60.237 + /* 189 */ SDL_SCANCODE_MINUS, /*IE, Chrome, D3E legacy*/
60.238 + /* 190 */ SDL_SCANCODE_PERIOD,
60.239 + /* 191 */ SDL_SCANCODE_SLASH,
60.240 + /* 192 */ SDL_SCANCODE_GRAVE, /*FX, D3E legacy (SDL_SCANCODE_APOSTROPHE in IE/Chrome)*/
60.241 + /* 193 */ SDL_SCANCODE_UNKNOWN,
60.242 + /* 194 */ SDL_SCANCODE_UNKNOWN,
60.243 + /* 195 */ SDL_SCANCODE_UNKNOWN,
60.244 + /* 196 */ SDL_SCANCODE_UNKNOWN,
60.245 + /* 197 */ SDL_SCANCODE_UNKNOWN,
60.246 + /* 198 */ SDL_SCANCODE_UNKNOWN,
60.247 + /* 199 */ SDL_SCANCODE_UNKNOWN,
60.248 + /* 200 */ SDL_SCANCODE_UNKNOWN,
60.249 + /* 201 */ SDL_SCANCODE_UNKNOWN,
60.250 + /* 202 */ SDL_SCANCODE_UNKNOWN,
60.251 + /* 203 */ SDL_SCANCODE_UNKNOWN,
60.252 + /* 204 */ SDL_SCANCODE_UNKNOWN,
60.253 + /* 205 */ SDL_SCANCODE_UNKNOWN,
60.254 + /* 206 */ SDL_SCANCODE_UNKNOWN,
60.255 + /* 207 */ SDL_SCANCODE_UNKNOWN,
60.256 + /* 208 */ SDL_SCANCODE_UNKNOWN,
60.257 + /* 209 */ SDL_SCANCODE_UNKNOWN,
60.258 + /* 210 */ SDL_SCANCODE_UNKNOWN,
60.259 + /* 211 */ SDL_SCANCODE_UNKNOWN,
60.260 + /* 212 */ SDL_SCANCODE_UNKNOWN,
60.261 + /* 213 */ SDL_SCANCODE_UNKNOWN,
60.262 + /* 214 */ SDL_SCANCODE_UNKNOWN,
60.263 + /* 215 */ SDL_SCANCODE_UNKNOWN,
60.264 + /* 216 */ SDL_SCANCODE_UNKNOWN,
60.265 + /* 217 */ SDL_SCANCODE_UNKNOWN,
60.266 + /* 218 */ SDL_SCANCODE_UNKNOWN,
60.267 + /* 219 */ SDL_SCANCODE_LEFTBRACKET,
60.268 + /* 220 */ SDL_SCANCODE_BACKSLASH,
60.269 + /* 221 */ SDL_SCANCODE_RIGHTBRACKET,
60.270 + /* 222 */ SDL_SCANCODE_APOSTROPHE, /*FX, D3E legacy*/
60.271 +};
60.272 +
60.273 +
60.274 +/* "borrowed" from SDL_windowsevents.c */
60.275 +int
60.276 +Emscripten_ConvertUTF32toUTF8(Uint32 codepoint, char * text)
60.277 +{
60.278 + if (codepoint <= 0x7F) {
60.279 + text[0] = (char) codepoint;
60.280 + text[1] = '\0';
60.281 + } else if (codepoint <= 0x7FF) {
60.282 + text[0] = 0xC0 | (char) ((codepoint >> 6) & 0x1F);
60.283 + text[1] = 0x80 | (char) (codepoint & 0x3F);
60.284 + text[2] = '\0';
60.285 + } else if (codepoint <= 0xFFFF) {
60.286 + text[0] = 0xE0 | (char) ((codepoint >> 12) & 0x0F);
60.287 + text[1] = 0x80 | (char) ((codepoint >> 6) & 0x3F);
60.288 + text[2] = 0x80 | (char) (codepoint & 0x3F);
60.289 + text[3] = '\0';
60.290 + } else if (codepoint <= 0x10FFFF) {
60.291 + text[0] = 0xF0 | (char) ((codepoint >> 18) & 0x0F);
60.292 + text[1] = 0x80 | (char) ((codepoint >> 12) & 0x3F);
60.293 + text[2] = 0x80 | (char) ((codepoint >> 6) & 0x3F);
60.294 + text[3] = 0x80 | (char) (codepoint & 0x3F);
60.295 + text[4] = '\0';
60.296 + } else {
60.297 + return SDL_FALSE;
60.298 + }
60.299 + return SDL_TRUE;
60.300 +}
60.301 +
60.302 +int
60.303 +Emscripten_HandleMouseMove(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData)
60.304 +{
60.305 + SDL_WindowData *window_data = userData;
60.306 + int mx = mouseEvent->canvasX, my = mouseEvent->canvasY;
60.307 + EmscriptenPointerlockChangeEvent pointerlock_status;
60.308 +
60.309 + /* check for pointer lock */
60.310 + emscripten_get_pointerlock_status(&pointerlock_status);
60.311 +
60.312 + if (pointerlock_status.isActive) {
60.313 + mx = mouseEvent->movementX;
60.314 + my = mouseEvent->movementY;
60.315 + }
60.316 +
60.317 + /* rescale (in case canvas is being scaled)*/
60.318 + double client_w, client_h;
60.319 + emscripten_get_element_css_size(NULL, &client_w, &client_h);
60.320 +
60.321 + mx = mx * (window_data->window->w / (client_w * window_data->pixel_ratio));
60.322 + my = my * (window_data->window->h / (client_h * window_data->pixel_ratio));
60.323 +
60.324 + SDL_SendMouseMotion(window_data->window, 0, pointerlock_status.isActive, mx, my);
60.325 + return 0;
60.326 +}
60.327 +
60.328 +int
60.329 +Emscripten_HandleMouseButton(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData)
60.330 +{
60.331 + SDL_WindowData *window_data = userData;
60.332 + uint32_t sdl_button;
60.333 + switch (mouseEvent->button) {
60.334 + case 0:
60.335 + sdl_button = SDL_BUTTON_LEFT;
60.336 + break;
60.337 + case 1:
60.338 + sdl_button = SDL_BUTTON_MIDDLE;
60.339 + break;
60.340 + case 2:
60.341 + sdl_button = SDL_BUTTON_RIGHT;
60.342 + break;
60.343 + default:
60.344 + return 0;
60.345 + }
60.346 + SDL_SendMouseButton(window_data->window, 0, eventType == EMSCRIPTEN_EVENT_MOUSEDOWN ? SDL_PRESSED : SDL_RELEASED, sdl_button);
60.347 + return 1;
60.348 +}
60.349 +
60.350 +int
60.351 +Emscripten_HandleMouseFocus(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData)
60.352 +{
60.353 + SDL_WindowData *window_data = userData;
60.354 + SDL_SendWindowEvent(window_data->window, eventType == EMSCRIPTEN_EVENT_MOUSEENTER ? SDL_WINDOWEVENT_ENTER : SDL_WINDOWEVENT_LEAVE, 0, 0);
60.355 + return 1;
60.356 +}
60.357 +
60.358 +int
60.359 +Emscripten_HandleWheel(int eventType, const EmscriptenWheelEvent *wheelEvent, void *userData)
60.360 +{
60.361 + SDL_WindowData *window_data = userData;
60.362 + SDL_SendMouseWheel(window_data->window, 0, wheelEvent->deltaX, -wheelEvent->deltaY, SDL_MOUSEWHEEL_NORMAL);
60.363 + return 1;
60.364 +}
60.365 +
60.366 +int
60.367 +Emscripten_HandleFocus(int eventType, const EmscriptenFocusEvent *wheelEvent, void *userData)
60.368 +{
60.369 + SDL_WindowData *window_data = userData;
60.370 + SDL_SendWindowEvent(window_data->window, eventType == EMSCRIPTEN_EVENT_FOCUS ? SDL_WINDOWEVENT_FOCUS_GAINED : SDL_WINDOWEVENT_FOCUS_LOST, 0, 0);
60.371 + return 1;
60.372 +}
60.373 +
60.374 +int
60.375 +Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData)
60.376 +{
60.377 + /*SDL_WindowData *window_data = userData;*/
60.378 + int i;
60.379 +
60.380 + SDL_TouchID deviceId = 0;
60.381 + if (!SDL_GetTouch(deviceId)) {
60.382 + if (SDL_AddTouch(deviceId, "") < 0) {
60.383 + return 0;
60.384 + }
60.385 + }
60.386 +
60.387 + for (i = 0; i < touchEvent->numTouches; i++) {
60.388 + long x, y, id;
60.389 +
60.390 + if (!touchEvent->touches[i].isChanged)
60.391 + continue;
60.392 +
60.393 + id = touchEvent->touches[i].identifier;
60.394 + x = touchEvent->touches[i].canvasX;
60.395 + y = touchEvent->touches[i].canvasY;
60.396 +
60.397 + if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE) {
60.398 + SDL_SendTouchMotion(deviceId, id, x, y, 1.0f);
60.399 + } else if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) {
60.400 + SDL_SendTouch(deviceId, id, SDL_TRUE, x, y, 1.0f);
60.401 + } else {
60.402 + SDL_SendTouch(deviceId, id, SDL_FALSE, x, y, 1.0f);
60.403 + }
60.404 + }
60.405 +
60.406 +
60.407 + return 1;
60.408 +}
60.409 +
60.410 +int
60.411 +Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData)
60.412 +{
60.413 + Uint32 scancode;
60.414 +
60.415 + /* .keyCode is deprecated, but still the most reliable way to get keys */
60.416 + if (keyEvent->keyCode < SDL_arraysize(emscripten_scancode_table)) {
60.417 + scancode = emscripten_scancode_table[keyEvent->keyCode];
60.418 +
60.419 + if (scancode != SDL_SCANCODE_UNKNOWN) {
60.420 +
60.421 + if (keyEvent->location == DOM_KEY_LOCATION_RIGHT) {
60.422 + switch (scancode) {
60.423 + case SDL_SCANCODE_LSHIFT:
60.424 + scancode = SDL_SCANCODE_RSHIFT;
60.425 + break;
60.426 + case SDL_SCANCODE_LCTRL:
60.427 + scancode = SDL_SCANCODE_RCTRL;
60.428 + break;
60.429 + case SDL_SCANCODE_LALT:
60.430 + scancode = SDL_SCANCODE_RALT;
60.431 + break;
60.432 + case SDL_SCANCODE_LGUI:
60.433 + scancode = SDL_SCANCODE_RGUI;
60.434 + break;
60.435 + }
60.436 + }
60.437 + SDL_SendKeyboardKey(eventType == EMSCRIPTEN_EVENT_KEYDOWN ?
60.438 + SDL_PRESSED : SDL_RELEASED, scancode);
60.439 + }
60.440 + }
60.441 +
60.442 + /* if we prevent keydown, we won't get keypress
60.443 + * also we need to ALWAYS prevent backspace and tab otherwise chrome takes action and does bad navigation UX
60.444 + */
60.445 + return SDL_GetEventState(SDL_TEXTINPUT) != SDL_ENABLE || eventType != EMSCRIPTEN_EVENT_KEYDOWN
60.446 + || keyEvent->keyCode == 8 /* backspace */ || keyEvent->keyCode == 9 /* tab */;
60.447 +}
60.448 +
60.449 +int
60.450 +Emscripten_HandleKeyPress(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData)
60.451 +{
60.452 + char text[5];
60.453 + Emscripten_ConvertUTF32toUTF8(keyEvent->charCode, text);
60.454 + SDL_SendKeyboardText(text);
60.455 + return 1;
60.456 +}
60.457 +
60.458 +int
60.459 +Emscripten_HandleFullscreenChange(int eventType, const EmscriptenFullscreenChangeEvent *fullscreenChangeEvent, void *userData)
60.460 +{
60.461 + /*make sure this is actually our element going fullscreen*/
60.462 + if(SDL_strcmp(fullscreenChangeEvent->id, "SDLFullscreenElement") != 0)
60.463 + return 0;
60.464 +
60.465 + SDL_WindowData *window_data = userData;
60.466 + if(fullscreenChangeEvent->isFullscreen)
60.467 + {
60.468 + SDL_bool is_desktop_fullscreen;
60.469 + window_data->window->flags |= window_data->requested_fullscreen_mode;
60.470 +
60.471 + if(!window_data->requested_fullscreen_mode)
60.472 + window_data->window->flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; /*we didn't reqest fullscreen*/
60.473 +
60.474 + window_data->requested_fullscreen_mode = 0;
60.475 +
60.476 + is_desktop_fullscreen = (window_data->window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP;
60.477 +
60.478 + /*update size*/
60.479 + if(window_data->window->flags & SDL_WINDOW_RESIZABLE || is_desktop_fullscreen)
60.480 + {
60.481 + emscripten_set_canvas_size(fullscreenChangeEvent->screenWidth, fullscreenChangeEvent->screenHeight);
60.482 + SDL_SendWindowEvent(window_data->window, SDL_WINDOWEVENT_RESIZED, fullscreenChangeEvent->screenWidth, fullscreenChangeEvent->screenHeight);
60.483 + }
60.484 + else
60.485 + {
60.486 + /*preserve ratio*/
60.487 + double w = window_data->window->w;
60.488 + double h = window_data->window->h;
60.489 + double factor = SDL_min(fullscreenChangeEvent->screenWidth / w, fullscreenChangeEvent->screenHeight / h);
60.490 + emscripten_set_element_css_size(NULL, w * factor, h * factor);
60.491 + }
60.492 + }
60.493 + else
60.494 + {
60.495 + EM_ASM({
60.496 + //un-reparent canvas (similar to Module.requestFullscreen)
60.497 + var canvas = Module['canvas'];
60.498 + if(canvas.parentNode.id == "SDLFullscreenElement") {
60.499 + var canvasContainer = canvas.parentNode;
60.500 + canvasContainer.parentNode.insertBefore(canvas, canvasContainer);
60.501 + canvasContainer.parentNode.removeChild(canvasContainer);
60.502 + }
60.503 + });
60.504 + double unscaled_w = window_data->windowed_width / window_data->pixel_ratio;
60.505 + double unscaled_h = window_data->windowed_height / window_data->pixel_ratio;
60.506 + emscripten_set_canvas_size(window_data->windowed_width, window_data->windowed_height);
60.507 +
60.508 + if (!window_data->external_size && window_data->pixel_ratio != 1.0f) {
60.509 + emscripten_set_element_css_size(NULL, unscaled_w, unscaled_h);
60.510 + }
60.511 +
60.512 + SDL_SendWindowEvent(window_data->window, SDL_WINDOWEVENT_RESIZED, unscaled_w, unscaled_h);
60.513 +
60.514 + window_data->window->flags &= ~FULLSCREEN_MASK;
60.515 + }
60.516 +
60.517 + return 0;
60.518 +}
60.519 +
60.520 +int
60.521 +Emscripten_HandleResize(int eventType, const EmscriptenUiEvent *uiEvent, void *userData)
60.522 +{
60.523 + SDL_WindowData *window_data = userData;
60.524 + if(window_data->window->flags & FULLSCREEN_MASK)
60.525 + {
60.526 + SDL_bool is_desktop_fullscreen = (window_data->window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP;
60.527 +
60.528 + if(window_data->window->flags & SDL_WINDOW_RESIZABLE || is_desktop_fullscreen)
60.529 + {
60.530 + emscripten_set_canvas_size(uiEvent->windowInnerWidth * window_data->pixel_ratio, uiEvent->windowInnerHeight * window_data->pixel_ratio);
60.531 + SDL_SendWindowEvent(window_data->window, SDL_WINDOWEVENT_RESIZED, uiEvent->windowInnerWidth, uiEvent->windowInnerHeight);
60.532 + }
60.533 + }
60.534 + else
60.535 + {
60.536 + /* this will only work if the canvas size is set through css */
60.537 + if(window_data->window->flags & SDL_WINDOW_RESIZABLE)
60.538 + {
60.539 + double w = window_data->window->w;
60.540 + double h = window_data->window->h;
60.541 +
60.542 + if(window_data->external_size) {
60.543 + emscripten_get_element_css_size(NULL, &w, &h);
60.544 + }
60.545 +
60.546 + emscripten_set_canvas_size(w * window_data->pixel_ratio, h * window_data->pixel_ratio);
60.547 +
60.548 + /* set_canvas_size unsets this */
60.549 + if (!window_data->external_size && window_data->pixel_ratio != 1.0f) {
60.550 + emscripten_set_element_css_size(NULL, w, h);
60.551 + }
60.552 +
60.553 + SDL_SendWindowEvent(window_data->window, SDL_WINDOWEVENT_RESIZED, w, h);
60.554 + }
60.555 + }
60.556 +
60.557 + return 0;
60.558 +}
60.559 +
60.560 +int
60.561 +Emscripten_HandleVisibilityChange(int eventType, const EmscriptenVisibilityChangeEvent *visEvent, void *userData)
60.562 +{
60.563 + SDL_WindowData *window_data = userData;
60.564 + SDL_SendWindowEvent(window_data->window, visEvent->hidden ? SDL_WINDOWEVENT_HIDDEN : SDL_WINDOWEVENT_SHOWN, 0, 0);
60.565 + return 0;
60.566 +}
60.567 +
60.568 +void
60.569 +Emscripten_RegisterEventHandlers(SDL_WindowData *data)
60.570 +{
60.571 + /* There is only one window and that window is the canvas */
60.572 + emscripten_set_mousemove_callback("#canvas", data, 0, Emscripten_HandleMouseMove);
60.573 +
60.574 + emscripten_set_mousedown_callback("#canvas", data, 0, Emscripten_HandleMouseButton);
60.575 + emscripten_set_mouseup_callback("#canvas", data, 0, Emscripten_HandleMouseButton);
60.576 +
60.577 + emscripten_set_mouseenter_callback("#canvas", data, 0, Emscripten_HandleMouseFocus);
60.578 + emscripten_set_mouseleave_callback("#canvas", data, 0, Emscripten_HandleMouseFocus);
60.579 +
60.580 + emscripten_set_wheel_callback("#canvas", data, 0, Emscripten_HandleWheel);
60.581 +
60.582 + emscripten_set_focus_callback("#canvas", data, 0, Emscripten_HandleFocus);
60.583 + emscripten_set_blur_callback("#canvas", data, 0, Emscripten_HandleFocus);
60.584 +
60.585 + emscripten_set_touchstart_callback("#canvas", data, 0, Emscripten_HandleTouch);
60.586 + emscripten_set_touchend_callback("#canvas", data, 0, Emscripten_HandleTouch);
60.587 + emscripten_set_touchmove_callback("#canvas", data, 0, Emscripten_HandleTouch);
60.588 + emscripten_set_touchcancel_callback("#canvas", data, 0, Emscripten_HandleTouch);
60.589 +
60.590 + /* Keyboard events are awkward */
60.591 + const char *keyElement = SDL_GetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT);
60.592 + if (!keyElement) keyElement = "#window";
60.593 +
60.594 + emscripten_set_keydown_callback(keyElement, data, 0, Emscripten_HandleKey);
60.595 + emscripten_set_keyup_callback(keyElement, data, 0, Emscripten_HandleKey);
60.596 + emscripten_set_keypress_callback(keyElement, data, 0, Emscripten_HandleKeyPress);
60.597 +
60.598 + emscripten_set_fullscreenchange_callback("#document", data, 0, Emscripten_HandleFullscreenChange);
60.599 +
60.600 + emscripten_set_resize_callback("#window", data, 0, Emscripten_HandleResize);
60.601 +
60.602 + emscripten_set_visibilitychange_callback(data, 0, Emscripten_HandleVisibilityChange);
60.603 +}
60.604 +
60.605 +void
60.606 +Emscripten_UnregisterEventHandlers(SDL_WindowData *data)
60.607 +{
60.608 + /* only works due to having one window */
60.609 + emscripten_set_mousemove_callback("#canvas", NULL, 0, NULL);
60.610 +
60.611 + emscripten_set_mousedown_callback("#canvas", NULL, 0, NULL);
60.612 + emscripten_set_mouseup_callback("#canvas", NULL, 0, NULL);
60.613 +
60.614 + emscripten_set_mouseenter_callback("#canvas", NULL, 0, NULL);
60.615 + emscripten_set_mouseleave_callback("#canvas", NULL, 0, NULL);
60.616 +
60.617 + emscripten_set_wheel_callback("#canvas", NULL, 0, NULL);
60.618 +
60.619 + emscripten_set_focus_callback("#canvas", NULL, 0, NULL);
60.620 + emscripten_set_blur_callback("#canvas", NULL, 0, NULL);
60.621 +
60.622 + emscripten_set_touchstart_callback("#canvas", NULL, 0, NULL);
60.623 + emscripten_set_touchend_callback("#canvas", NULL, 0, NULL);
60.624 + emscripten_set_touchmove_callback("#canvas", NULL, 0, NULL);
60.625 + emscripten_set_touchcancel_callback("#canvas", NULL, 0, NULL);
60.626 +
60.627 + emscripten_set_keydown_callback("#window", NULL, 0, NULL);
60.628 + emscripten_set_keyup_callback("#window", NULL, 0, NULL);
60.629 +
60.630 + emscripten_set_keypress_callback("#window", NULL, 0, NULL);
60.631 +
60.632 + emscripten_set_fullscreenchange_callback("#document", NULL, 0, NULL);
60.633 +
60.634 + emscripten_set_resize_callback("#window", NULL, 0, NULL);
60.635 +
60.636 + emscripten_set_visibilitychange_callback(NULL, 0, NULL);
60.637 +}
60.638 +
60.639 +#endif /* SDL_VIDEO_DRIVER_EMSCRIPTEN */
60.640 +
60.641 +/* vi: set ts=4 sw=4 expandtab: */
61.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
61.2 +++ b/src/video/emscripten/SDL_emscriptenevents.h Thu Jan 15 01:15:24 2015 -0400
61.3 @@ -0,0 +1,36 @@
61.4 +/*
61.5 + Simple DirectMedia Layer
61.6 + Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
61.7 +
61.8 + This software is provided 'as-is', without any express or implied
61.9 + warranty. In no event will the authors be held liable for any damages
61.10 + arising from the use of this software.
61.11 +
61.12 + Permission is granted to anyone to use this software for any purpose,
61.13 + including commercial applications, and to alter it and redistribute it
61.14 + freely, subject to the following restrictions:
61.15 +
61.16 + 1. The origin of this software must not be misrepresented; you must not
61.17 + claim that you wrote the original software. If you use this software
61.18 + in a product, an acknowledgment in the product documentation would be
61.19 + appreciated but is not required.
61.20 + 2. Altered source versions must be plainly marked as such, and must not be
61.21 + misrepresented as being the original software.
61.22 + 3. This notice may not be removed or altered from any source distribution.
61.23 +*/
61.24 +
61.25 +
61.26 +#ifndef _SDL_emscriptenevents_h
61.27 +#define _SDL_emscriptenevents_h
61.28 +
61.29 +#include "SDL_emscriptenvideo.h"
61.30 +
61.31 +extern void
61.32 +Emscripten_RegisterEventHandlers(SDL_WindowData *data);
61.33 +
61.34 +extern void
61.35 +Emscripten_UnregisterEventHandlers(SDL_WindowData *data);
61.36 +#endif /* _SDL_emscriptenevents_h */
61.37 +
61.38 +/* vi: set ts=4 sw=4 expandtab: */
61.39 +
62.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
62.2 +++ b/src/video/emscripten/SDL_emscriptenframebuffer.c Thu Jan 15 01:15:24 2015 -0400
62.3 @@ -0,0 +1,136 @@
62.4 +/*
62.5 + Simple DirectMedia Layer
62.6 + Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
62.7 +
62.8 + This software is provided 'as-is', without any express or implied
62.9 + warranty. In no event will the authors be held liable for any damages
62.10 + arising from the use of this software.
62.11 +
62.12 + Permission is granted to anyone to use this software for any purpose,
62.13 + including commercial applications, and to alter it and redistribute it
62.14 + freely, subject to the following restrictions:
62.15 +
62.16 + 1. The origin of this software must not be misrepresented; you must not
62.17 + claim that you wrote the original software. If you use this software
62.18 + in a product, an acknowledgment in the product documentation would be
62.19 + appreciated but is not required.
62.20 + 2. Altered source versions must be plainly marked as such, and must not be
62.21 + misrepresented as being the original software.
62.22 + 3. This notice may not be removed or altered from any source distribution.
62.23 +*/
62.24 +#include "../../SDL_internal.h"
62.25 +
62.26 +#if SDL_VIDEO_DRIVER_EMSCRIPTEN
62.27 +
62.28 +#include "SDL_emscriptenvideo.h"
62.29 +#include "SDL_emscriptenframebuffer.h"
62.30 +
62.31 +
62.32 +int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
62.33 +{
62.34 + SDL_Surface *surface;
62.35 + const Uint32 surface_format = SDL_PIXELFORMAT_BGR888;
62.36 + int w, h;
62.37 + int bpp;
62.38 + Uint32 Rmask, Gmask, Bmask, Amask;
62.39 +
62.40 + /* Free the old framebuffer surface */
62.41 + SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
62.42 + surface = data->surface;
62.43 + SDL_FreeSurface(surface);
62.44 +
62.45 + /* Create a new one */
62.46 + SDL_PixelFormatEnumToMasks(surface_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
62.47 + SDL_GetWindowSize(window, &w, &h);
62.48 +
62.49 + surface = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask);
62.50 + if (!surface) {
62.51 + return -1;
62.52 + }
62.53 +
62.54 + /* Save the info and return! */
62.55 + data->surface = surface;
62.56 + *format = surface_format;
62.57 + *pixels = surface->pixels;
62.58 + *pitch = surface->pitch;
62.59 + return 0;
62.60 +}
62.61 +
62.62 +int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects)
62.63 +{
62.64 + SDL_Surface *surface;
62.65 +
62.66 + SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
62.67 + surface = data->surface;
62.68 + if (!surface) {
62.69 + return SDL_SetError("Couldn't find dummy surface for window");
62.70 + }
62.71 +
62.72 + /* Send the data to the display */
62.73 +
62.74 + EM_ASM_INT({
62.75 + //TODO: don't create context every update
62.76 + var ctx = Module['canvas'].getContext('2d');
62.77 +
62.78 + //library_sdl.js SDL_UnlockSurface
62.79 + var image = ctx.createImageData($0, $1);
62.80 + var data = image.data;
62.81 + var src = $2 >> 2;
62.82 + var dst = 0;
62.83 + var isScreen = true;
62.84 + var num;
62.85 + if (typeof CanvasPixelArray !== 'undefined' && data instanceof CanvasPixelArray) {
62.86 + // IE10/IE11: ImageData objects are backed by the deprecated CanvasPixelArray,
62.87 + // not UInt8ClampedArray. These don't have buffers, so we need to revert
62.88 + // to copying a byte at a time. We do the undefined check because modern
62.89 + // browsers do not define CanvasPixelArray anymore.
62.90 + num = data.length;
62.91 + while (dst < num) {
62.92 + var val = HEAP32[src]; // This is optimized. Instead, we could do {{{ makeGetValue('buffer', 'dst', 'i32') }}};
62.93 + data[dst ] = val & 0xff;
62.94 + data[dst+1] = (val >> 8) & 0xff;
62.95 + data[dst+2] = (val >> 16) & 0xff;
62.96 + data[dst+3] = isScreen ? 0xff : ((val >> 24) & 0xff);
62.97 + src++;
62.98 + dst += 4;
62.99 + }
62.100 + } else {
62.101 + var data32 = new Uint32Array(data.buffer);
62.102 + num = data32.length;
62.103 + if (isScreen) {
62.104 + while (dst < num) {
62.105 + // HEAP32[src++] is an optimization. Instead, we could do {{{ makeGetValue('buffer', 'dst', 'i32') }}};
62.106 + data32[dst++] = HEAP32[src++] | 0xff000000;
62.107 + }
62.108 + } else {
62.109 + while (dst < num) {
62.110 + data32[dst++] = HEAP32[src++];
62.111 + }
62.112 + }
62.113 + }
62.114 +
62.115 + ctx.putImageData(image, 0, 0);
62.116 + return 0;
62.117 + }, surface->w, surface->h, surface->pixels);
62.118 +
62.119 + /*if (SDL_getenv("SDL_VIDEO_Emscripten_SAVE_FRAMES")) {
62.120 + static int frame_number = 0;
62.121 + char file[128];
62.122 + SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp",
62.123 + SDL_GetWindowID(window), ++frame_number);
62.124 + SDL_SaveBMP(surface, file);
62.125 + }*/
62.126 + return 0;
62.127 +}
62.128 +
62.129 +void Emscripten_DestroyWindowFramebuffer(_THIS, SDL_Window * window)
62.130 +{
62.131 + SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
62.132 +
62.133 + SDL_FreeSurface(data->surface);
62.134 + data->surface = NULL;
62.135 +}
62.136 +
62.137 +#endif /* SDL_VIDEO_DRIVER_EMSCRIPTEN */
62.138 +
62.139 +/* vi: set ts=4 sw=4 expandtab: */
63.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
63.2 +++ b/src/video/emscripten/SDL_emscriptenframebuffer.h Thu Jan 15 01:15:24 2015 -0400
63.3 @@ -0,0 +1,32 @@
63.4 +/*
63.5 + Simple DirectMedia Layer
63.6 + Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
63.7 +
63.8 + This software is provided 'as-is', without any express or implied
63.9 + warranty. In no event will the authors be held liable for any damages
63.10 + arising from the use of this software.
63.11 +
63.12 + Permission is granted to anyone to use this software for any purpose,
63.13 + including commercial applications, and to alter it and redistribute it
63.14 + freely, subject to the following restrictions:
63.15 +
63.16 + 1. The origin of this software must not be misrepresented; you must not
63.17 + claim that you wrote the original software. If you use this software
63.18 + in a product, an acknowledgment in the product documentation would be
63.19 + appreciated but is not required.
63.20 + 2. Altered source versions must be plainly marked as such, and must not be
63.21 + misrepresented as being the original software.
63.22 + 3. This notice may not be removed or altered from any source distribution.
63.23 +*/
63.24 +#include "../../SDL_internal.h"
63.25 +
63.26 +#ifndef _SDL_emscriptenframebuffer_h
63.27 +#define _SDL_emscriptenframebuffer_h
63.28 +
63.29 +extern int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch);
63.30 +extern int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects);
63.31 +extern void Emscripten_DestroyWindowFramebuffer(_THIS, SDL_Window * window);
63.32 +
63.33 +#endif /* _SDL_emsctiptenframebuffer_h */
63.34 +
63.35 +/* vi: set ts=4 sw=4 expandtab: */
64.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
64.2 +++ b/src/video/emscripten/SDL_emscriptenmouse.c Thu Jan 15 01:15:24 2015 -0400
64.3 @@ -0,0 +1,232 @@
64.4 +/*
64.5 + Simple DirectMedia Layer
64.6 + Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
64.7 +
64.8 + This software is provided 'as-is', without any express or implied
64.9 + warranty. In no event will the authors be held liable for any damages
64.10 + arising from the use of this software.
64.11 +
64.12 + Permission is granted to anyone to use this software for any purpose,
64.13 + including commercial applications, and to alter it and redistribute it
64.14 + freely, subject to the following restrictions:
64.15 +
64.16 + 1. The origin of this software must not be misrepresented; you must not
64.17 + claim that you wrote the original software. If you use this software
64.18 + in a product, an acknowledgment in the product documentation would be
64.19 + appreciated but is not required.
64.20 + 2. Altered source versions must be plainly marked as such, and must not be
64.21 + misrepresented as being the original software.
64.22 + 3. This notice may not be removed or altered from any source distribution.
64.23 +*/
64.24 +
64.25 +
64.26 +#include "../../SDL_internal.h"
64.27 +
64.28 +#if SDL_VIDEO_DRIVER_EMSCRIPTEN
64.29 +
64.30 +#include <emscripten/emscripten.h>
64.31 +#include <emscripten/html5.h>
64.32 +
64.33 +#include "SDL_emscriptenmouse.h"
64.34 +
64.35 +#include "../../events/SDL_mouse_c.h"
64.36 +#include "SDL_assert.h"
64.37 +
64.38 +
64.39 +static SDL_Cursor*
64.40 +Emscripten_CreateDefaultCursor()
64.41 +{
64.42 + SDL_Cursor* cursor;
64.43 + Emscripten_CursorData *curdata;
64.44 +
64.45 + cursor = SDL_calloc(1, sizeof(SDL_Cursor));
64.46 + if (cursor) {
64.47 + curdata = (Emscripten_CursorData *) SDL_calloc(1, sizeof(*curdata));
64.48 + if (!curdata) {
64.49 + SDL_OutOfMemory();
64.50 + SDL_free(cursor);
64.51 + return NULL;
64.52 + }
64.53 +
64.54 + curdata->system_cursor = "default";
64.55 + cursor->driverdata = curdata;
64.56 + }
64.57 + else {
64.58 + SDL_OutOfMemory();
64.59 + }
64.60 +
64.61 + return cursor;
64.62 +}
64.63 +
64.64 +static SDL_Cursor*
64.65 +Emscripten_CreateCursor(SDL_Surface* sruface, int hot_x, int hot_y)
64.66 +{
64.67 + return Emscripten_CreateDefaultCursor();
64.68 +}
64.69 +
64.70 +static SDL_Cursor*
64.71 +Emscripten_CreateSystemCursor(SDL_SystemCursor id)
64.72 +{
64.73 + SDL_Cursor *cursor;
64.74 + Emscripten_CursorData *curdata;
64.75 + const char *cursor_name = NULL;
64.76 +
64.77 + switch(id) {
64.78 + case SDL_SYSTEM_CURSOR_ARROW:
64.79 + cursor_name = "default";
64.80 + break;
64.81 + case SDL_SYSTEM_CURSOR_IBEAM:
64.82 + cursor_name = "text";
64.83 + break;
64.84 + case SDL_SYSTEM_CURSOR_WAIT:
64.85 + cursor_name = "wait";
64.86 + break;
64.87 + case SDL_SYSTEM_CURSOR_CROSSHAIR:
64.88 + cursor_name = "crosshair";
64.89 + break;
64.90 + case SDL_SYSTEM_CURSOR_WAITARROW:
64.91 + cursor_name = "progress";
64.92 + break;
64.93 + case SDL_SYSTEM_CURSOR_SIZENWSE:
64.94 + cursor_name = "nwse-resize";
64.95 + break;
64.96 + case SDL_SYSTEM_CURSOR_SIZENESW:
64.97 + cursor_name = "nesw-resize";
64.98 + break;
64.99 + case SDL_SYSTEM_CURSOR_SIZEWE:
64.100 + cursor_name = "ew-resize";
64.101 + break;
64.102 + case SDL_SYSTEM_CURSOR_SIZENS:
64.103 + cursor_name = "ns-resize";
64.104 + break;
64.105 + case SDL_SYSTEM_CURSOR_SIZEALL:
64.106 + break;
64.107 + case SDL_SYSTEM_CURSOR_NO:
64.108 + cursor_name = "not-allowed";
64.109 + break;
64.110 + case SDL_SYSTEM_CURSOR_HAND:
64.111 + cursor_name = "pointer";
64.112 + break;
64.113 + default:
64.114 + SDL_assert(0);
64.115 + return NULL;
64.116 + }
64.117 +
64.118 + cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor));
64.119 + if (!cursor) {
64.120 + SDL_OutOfMemory();
64.121 + return NULL;
64.122 + }
64.123 + curdata = (Emscripten_CursorData *) SDL_calloc(1, sizeof(*curdata));
64.124 + if (!curdata) {
64.125 + SDL_OutOfMemory();
64.126 + SDL_free(cursor);
64.127 + return NULL;
64.128 + }
64.129 +
64.130 + curdata->system_cursor = cursor_name;
64.131 + cursor->driverdata = curdata;
64.132 +
64.133 + return cursor;
64.134 +}
64.135 +
64.136 +static void
64.137 +Emscripten_FreeCursor(SDL_Cursor* cursor)
64.138 +{
64.139 + Emscripten_CursorData *curdata;
64.140 + if (cursor) {
64.141 + curdata = (Emscripten_CursorData *) cursor->driverdata;
64.142 +
64.143 + if (curdata != NULL) {
64.144 + SDL_free(cursor->driverdata);
64.145 + }
64.146 +
64.147 + SDL_free(cursor);
64.148 + }
64.149 +}
64.150 +
64.151 +static int
64.152 +Emscripten_ShowCursor(SDL_Cursor* cursor)
64.153 +{
64.154 + Emscripten_CursorData *curdata;
64.155 + if (SDL_GetMouseFocus() != NULL) {
64.156 + if(cursor && cursor->driverdata) {
64.157 + curdata = (Emscripten_CursorData *) cursor->driverdata;
64.158 +
64.159 + if(curdata->system_cursor) {
64.160 + EM_ASM_INT({
64.161 + if (Module['canvas']) {
64.162 + Module['canvas'].style['cursor'] = Module['Pointer_stringify']($0);
64.163 + }
64.164 + return 0;
64.165 + }, curdata->system_cursor);
64.166 + }
64.167 + }
64.168 + else {
64.169 + EM_ASM(
64.170 + if (Module['canvas']) {
64.171 + Module['canvas'].style['cursor'] = 'none';
64.172 + }
64.173 + );
64.174 + }
64.175 + }
64.176 + return 0;
64.177 +}
64.178 +
64.179 +static void
64.180 +Emscripten_WarpMouse(SDL_Window* window, int x, int y)
64.181 +{
64.182 + SDL_Unsupported();
64.183 +}
64.184 +
64.185 +static int
64.186 +Emscripten_SetRelativeMouseMode(SDL_bool enabled)
64.187 +{
64.188 + /* TODO: pointer lock isn't actually enabled yet */
64.189 + if(enabled) {
64.190 + if(emscripten_request_pointerlock(NULL, 1) >= EMSCRIPTEN_RESULT_SUCCESS) {
64.191 + return 0;
64.192 + }
64.193 + } else {
64.194 + if(emscripten_exit_pointerlock() >= EMSCRIPTEN_RESULT_SUCCESS) {
64.195 + return 0;
64.196 + }
64.197 + }
64.198 + return -1;
64.199 +}
64.200 +
64.201 +void
64.202 +Emscripten_InitMouse()
64.203 +{
64.204 + SDL_Mouse* mouse = SDL_GetMouse();
64.205 +
64.206 + mouse->CreateCursor = Emscripten_CreateCursor;
64.207 + mouse->ShowCursor = Emscripten_ShowCursor;
64.208 + mouse->FreeCursor = Emscripten_FreeCursor;
64.209 + mouse->WarpMouse = Emscripten_WarpMouse;
64.210 + mouse->CreateSystemCursor = Emscripten_CreateSystemCursor;
64.211 + mouse->SetRelativeMouseMode = Emscripten_SetRelativeMouseMode;
64.212 +
64.213 + SDL_SetDefaultCursor(Emscripten_CreateDefaultCursor());
64.214 +}
64.215 +
64.216 +void
64.217 +Emscripten_FiniMouse()
64.218 +{
64.219 + SDL_Mouse* mouse = SDL_GetMouse();
64.220 +
64.221 + Emscripten_FreeCursor(mouse->def_cursor);
64.222 + mouse->def_cursor = NULL;
64.223 +
64.224 + mouse->CreateCursor = NULL;
64.225 + mouse->ShowCursor = NULL;
64.226 + mouse->FreeCursor = NULL;
64.227 + mouse->WarpMouse = NULL;
64.228 + mouse->CreateSystemCursor = NULL;
64.229 + mouse->SetRelativeMouseMode = NULL;
64.230 +}
64.231 +
64.232 +#endif /* SDL_VIDEO_DRIVER_EMSCRIPTEN */
64.233 +
64.234 +/* vi: set ts=4 sw=4 expandtab: */
64.235 +
65.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
65.2 +++ b/src/video/emscripten/SDL_emscriptenmouse.h Thu Jan 15 01:15:24 2015 -0400
65.3 @@ -0,0 +1,39 @@
65.4 +/*
65.5 + Simple DirectMedia Layer
65.6 + Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
65.7 +
65.8 + This software is provided 'as-is', without any express or implied
65.9 + warranty. In no event will the authors be held liable for any damages
65.10 + arising from the use of this software.
65.11 +
65.12 + Permission is granted to anyone to use this software for any purpose,
65.13 + including commercial applications, and to alter it and redistribute it
65.14 + freely, subject to the following restrictions:
65.15 +
65.16 + 1. The origin of this software must not be misrepresented; you must not
65.17 + claim that you wrote the original software. If you use this software
65.18 + in a product, an acknowledgment in the product documentation would be
65.19 + appreciated but is not required.
65.20 + 2. Altered source versions must be plainly marked as such, and must not be
65.21 + misrepresented as being the original software.
65.22 + 3. This notice may not be removed or altered from any source distribution.
65.23 +*/
65.24 +
65.25 +
65.26 +#ifndef _SDL_emscriptenmouse_h
65.27 +#define _SDL_emscriptenmouse_h
65.28 +
65.29 +typedef struct _Emscripten_CursorData
65.30 +{
65.31 + const char *system_cursor;
65.32 +} Emscripten_CursorData;
65.33 +
65.34 +extern void
65.35 +Emscripten_InitMouse();
65.36 +
65.37 +extern void
65.38 +Emscripten_FiniMouse();
65.39 +
65.40 +#endif /* _SDL_emscriptenmouse_h */
65.41 +
65.42 +/* vi: set ts=4 sw=4 expandtab: */
66.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
66.2 +++ b/src/video/emscripten/SDL_emscriptenopengles.c Thu Jan 15 01:15:24 2015 -0400
66.3 @@ -0,0 +1,117 @@
66.4 +/*
66.5 + Simple DirectMedia Layer
66.6 + Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
66.7 +
66.8 + This software is provided 'as-is', without any express or implied
66.9 + warranty. In no event will the authors be held liable for any damages
66.10 + arising from the use of this software.
66.11 +
66.12 + Permission is granted to anyone to use this software for any purpose,
66.13 + including commercial applications, and to alter it and redistribute it
66.14 + freely, subject to the following restrictions:
66.15 +
66.16 + 1. The origin of this software must not be misrepresented; you must not
66.17 + claim that you wrote the original software. If you use this software
66.18 + in a product, an acknowledgment in the product documentation would be
66.19 + appreciated but is not required.
66.20 + 2. Altered source versions must be plainly marked as such, and must not be
66.21 + misrepresented as being the original software.
66.22 + 3. This notice may not be removed or altered from any source distribution.
66.23 +*/
66.24 +#include "../../SDL_internal.h"
66.25 +
66.26 +#if SDL_VIDEO_DRIVER_EMSCRIPTEN && SDL_VIDEO_OPENGL_EGL
66.27 +
66.28 +#include <emscripten/emscripten.h>
66.29 +#include <GLES2/gl2.h>
66.30 +
66.31 +#include "SDL_emscriptenvideo.h"
66.32 +#include "SDL_emscriptenopengles.h"
66.33 +
66.34 +#define LOAD_FUNC(NAME) _this->egl_data->NAME = NAME;
66.35 +
66.36 +/* EGL implementation of SDL OpenGL support */
66.37 +
66.38 +int
66.39 +Emscripten_GLES_LoadLibrary(_THIS, const char *path) {
66.40 + /*we can't load EGL dynamically*/
66.41 + _this->egl_data = (struct SDL_EGL_VideoData *) SDL_calloc(1, sizeof(SDL_EGL_VideoData));
66.42 + if (!_this->egl_data) {
66.43 + return SDL_OutOfMemory();
66.44 + }
66.45 +
66.46 + LOAD_FUNC(eglGetDisplay);
66.47 + LOAD_FUNC(eglInitialize);
66.48 + LOAD_FUNC(eglTerminate);
66.49 + LOAD_FUNC(eglGetProcAddress);
66.50 + LOAD_FUNC(eglChooseConfig);
66.51 + LOAD_FUNC(eglGetConfigAttrib);
66.52 + LOAD_FUNC(eglCreateContext);
66.53 + LOAD_FUNC(eglDestroyContext);
66.54 + LOAD_FUNC(eglCreateWindowSurface);
66.55 + LOAD_FUNC(eglDestroySurface);
66.56 + LOAD_FUNC(eglMakeCurrent);
66.57 + LOAD_FUNC(eglSwapBuffers);
66.58 + LOAD_FUNC(eglSwapInterval);
66.59 + LOAD_FUNC(eglWaitNative);
66.60 + LOAD_FUNC(eglWaitGL);
66.61 + LOAD_FUNC(eglBindAPI);
66.62 +
66.63 + _this->egl_data->egl_display = _this->egl_data->eglGetDisplay(EGL_DEFAULT_DISPLAY);
66.64 + if (!_this->egl_data->egl_display) {
66.65 + return SDL_SetError("Could not get EGL display");
66.66 + }
66.67 +
66.68 + if (_this->egl_data->eglInitialize(_this->egl_data->egl_display, NULL, NULL) != EGL_TRUE) {
66.69 + return SDL_SetError("Could not initialize EGL");
66.70 + }
66.71 +
66.72 + _this->gl_config.driver_loaded = 1;
66.73 +
66.74 + if (path) {
66.75 + SDL_strlcpy(_this->gl_config.driver_path, path, sizeof(_this->gl_config.driver_path) - 1);
66.76 + } else {
66.77 + *_this->gl_config.driver_path = '\0';
66.78 + }
66.79 +
66.80 + return 0;
66.81 +}
66.82 +
66.83 +void
66.84 +Emscripten_GLES_DeleteContext(_THIS, SDL_GLContext context)
66.85 +{
66.86 + /*
66.87 + WebGL contexts can't actually be deleted, so we need to reset it.
66.88 + ES2 renderer resets state on init anyway, clearing the canvas should be enough
66.89 + */
66.90 +
66.91 + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
66.92 +
66.93 + SDL_EGL_DeleteContext(_this, context);
66.94 +}
66.95 +
66.96 +SDL_EGL_CreateContext_impl(Emscripten)
66.97 +SDL_EGL_SwapWindow_impl(Emscripten)
66.98 +SDL_EGL_MakeCurrent_impl(Emscripten)
66.99 +
66.100 +void
66.101 +Emscripten_GLES_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
66.102 +{
66.103 + SDL_WindowData *data;
66.104 + if (window->driverdata) {
66.105 + data = (SDL_WindowData *) window->driverdata;
66.106 +
66.107 + if (w) {
66.108 + *w = window->w * data->pixel_ratio;
66.109 + }
66.110 +
66.111 + if (h) {
66.112 + *h = window->h * data->pixel_ratio;
66.113 + }
66.114 + }
66.115 +}
66.116 +
66.117 +#endif /* SDL_VIDEO_DRIVER_EMSCRIPTEN && SDL_VIDEO_OPENGL_EGL */
66.118 +
66.119 +/* vi: set ts=4 sw=4 expandtab: */
66.120 +
67.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
67.2 +++ b/src/video/emscripten/SDL_emscriptenopengles.h Thu Jan 15 01:15:24 2015 -0400
67.3 @@ -0,0 +1,49 @@
67.4 +/*
67.5 + Simple DirectMedia Layer
67.6 + Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
67.7 +
67.8 + This software is provided 'as-is', without any express or implied
67.9 + warranty. In no event will the authors be held liable for any damages
67.10 + arising from the use of this software.
67.11 +
67.12 + Permission is granted to anyone to use this software for any purpose,
67.13 + including commercial applications, and to alter it and redistribute it
67.14 + freely, subject to the following restrictions:
67.15 +
67.16 + 1. The origin of this software must not be misrepresented; you must not
67.17 + claim that you wrote the original software. If you use this software
67.18 + in a product, an acknowledgment in the product documentation would be
67.19 + appreciated but is not required.
67.20 + 2. Altered source versions must be plainly marked as such, and must not be
67.21 + misrepresented as being the original software.
67.22 + 3. This notice may not be removed or altered from any source distribution.
67.23 +*/
67.24 +#include "../../SDL_internal.h"
67.25 +
67.26 +#ifndef _SDL_emscriptenopengles_h
67.27 +#define _SDL_emscriptenopengles_h
67.28 +
67.29 +#if SDL_VIDEO_DRIVER_EMSCRIPTEN && SDL_VIDEO_OPENGL_EGL
67.30 +
67.31 +#include "../SDL_sysvideo.h"
67.32 +#include "../SDL_egl_c.h"
67.33 +
67.34 +/* OpenGLES functions */
67.35 +#define Emscripten_GLES_GetAttribute SDL_EGL_GetAttribute
67.36 +#define Emscripten_GLES_GetProcAddress SDL_EGL_GetProcAddress
67.37 +#define Emscripten_GLES_UnloadLibrary SDL_EGL_UnloadLibrary
67.38 +#define Emscripten_GLES_SetSwapInterval SDL_EGL_SetSwapInterval
67.39 +#define Emscripten_GLES_GetSwapInterval SDL_EGL_GetSwapInterval
67.40 +
67.41 +extern int Emscripten_GLES_LoadLibrary(_THIS, const char *path);
67.42 +extern void Emscripten_GLES_DeleteContext(_THIS, SDL_GLContext context);
67.43 +extern SDL_GLContext Emscripten_GLES_CreateContext(_THIS, SDL_Window * window);
67.44 +extern void Emscripten_GLES_SwapWindow(_THIS, SDL_Window * window);
67.45 +extern int Emscripten_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context);
67.46 +extern void Emscripten_GLES_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h);
67.47 +
67.48 +#endif /* SDL_VIDEO_DRIVER_EMSCRIPTEN && SDL_VIDEO_OPENGL_EGL */
67.49 +
67.50 +#endif /* _SDL_emscriptenopengles_h */
67.51 +
67.52 +/* vi: set ts=4 sw=4 expandtab: */
68.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
68.2 +++ b/src/video/emscripten/SDL_emscriptenvideo.c Thu Jan 15 01:15:24 2015 -0400
68.3 @@ -0,0 +1,319 @@
68.4 +/*
68.5 + Simple DirectMedia Layer
68.6 + Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
68.7 +
68.8 + This software is provided 'as-is', without any express or implied
68.9 + warranty. In no event will the authors be held liable for any damages
68.10 + arising from the use of this software.
68.11 +
68.12 + Permission is granted to anyone to use this software for any purpose,
68.13 + including commercial applications, and to alter it and redistribute it
68.14 + freely, subject to the following restrictions:
68.15 +
68.16 + 1. The origin of this software must not be misrepresented; you must not
68.17 + claim that you wrote the original software. If you use this software
68.18 + in a product, an acknowledgment in the product documentation would be
68.19 + appreciated but is not required.
68.20 + 2. Altered source versions must be plainly marked as such, and must not be
68.21 + misrepresented as being the original software.
68.22 + 3. This notice may not be removed or altered from any source distribution.
68.23 +*/
68.24 +#include "../../SDL_internal.h"
68.25 +
68.26 +#if SDL_VIDEO_DRIVER_EMSCRIPTEN
68.27 +
68.28 +#include "SDL_video.h"
68.29 +#include "SDL_mouse.h"
68.30 +#include "../SDL_sysvideo.h"
68.31 +#include "../SDL_pixels_c.h"
68.32 +#include "../SDL_egl_c.h"
68.33 +#include "../../events/SDL_events_c.h"
68.34 +
68.35 +#include "SDL_emscriptenvideo.h"
68.36 +#include "SDL_emscriptenopengles.h"
68.37 +#include "SDL_emscriptenframebuffer.h"
68.38 +#include "SDL_emscriptenevents.h"
68.39 +#include "SDL_emscriptenmouse.h"
68.40 +
68.41 +#define EMSCRIPTENVID_DRIVER_NAME "emscripten"
68.42 +
68.43 +/* Initialization/Query functions */
68.44 +static int Emscripten_VideoInit(_THIS);
68.45 +static int Emscripten_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
68.46 +static void Emscripten_VideoQuit(_THIS);
68.47 +
68.48 +static int Emscripten_CreateWindow(_THIS, SDL_Window * window);
68.49 +static void Emscripten_SetWindowSize(_THIS, SDL_Window * window);
68.50 +static void Emscripten_DestroyWindow(_THIS, SDL_Window * window);
68.51 +static void Emscripten_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
68.52 +static void Emscripten_PumpEvents(_THIS);
68.53 +
68.54 +
68.55 +/* Emscripten driver bootstrap functions */
68.56 +
68.57 +static int
68.58 +Emscripten_Available(void)
68.59 +{
68.60 + return (1);
68.61 +}
68.62 +
68.63 +static void
68.64 +Emscripten_DeleteDevice(SDL_VideoDevice * device)
68.65 +{
68.66 + SDL_free(device);
68.67 +}
68.68 +
68.69 +static SDL_VideoDevice *
68.70 +Emscripten_CreateDevice(int devindex)
68.71 +{
68.72 + SDL_VideoDevice *device;
68.73 +
68.74 + /* Initialize all variables that we clean on shutdown */
68.75 + device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
68.76 + if (!device) {
68.77 + SDL_OutOfMemory();
68.78 + return (0);
68.79 + }
68.80 +
68.81 + /* Set the function pointers */
68.82 + device->VideoInit = Emscripten_VideoInit;
68.83 + device->VideoQuit = Emscripten_VideoQuit;
68.84 + device->SetDisplayMode = Emscripten_SetDisplayMode;
68.85 +
68.86 +
68.87 + device->PumpEvents = Emscripten_PumpEvents;
68.88 +
68.89 + device->CreateWindow = Emscripten_CreateWindow;
68.90 + /*device->CreateWindowFrom = Emscripten_CreateWindowFrom;
68.91 + device->SetWindowTitle = Emscripten_SetWindowTitle;
68.92 + device->SetWindowIcon = Emscripten_SetWindowIcon;
68.93 + device->SetWindowPosition = Emscripten_SetWindowPosition;*/
68.94 + device->SetWindowSize = Emscripten_SetWindowSize;
68.95 + /*device->ShowWindow = Emscripten_ShowWindow;
68.96 + device->HideWindow = Emscripten_HideWindow;
68.97 + device->RaiseWindow = Emscripten_RaiseWindow;
68.98 + device->MaximizeWindow = Emscripten_MaximizeWindow;
68.99 + device->MinimizeWindow = Emscripten_MinimizeWindow;
68.100 + device->RestoreWindow = Emscripten_RestoreWindow;
68.101 + device->SetWindowGrab = Emscripten_SetWindowGrab;*/
68.102 + device->DestroyWindow = Emscripten_DestroyWindow;
68.103 + device->SetWindowFullscreen = Emscripten_SetWindowFullscreen;
68.104 +
68.105 + device->CreateWindowFramebuffer = Emscripten_CreateWindowFramebuffer;
68.106 + device->UpdateWindowFramebuffer = Emscripten_UpdateWindowFramebuffer;
68.107 + device->DestroyWindowFramebuffer = Emscripten_DestroyWindowFramebuffer;
68.108 +
68.109 + device->GL_LoadLibrary = Emscripten_GLES_LoadLibrary;
68.110 + device->GL_GetProcAddress = Emscripten_GLES_GetProcAddress;
68.111 + device->GL_UnloadLibrary = Emscripten_GLES_UnloadLibrary;
68.112 + device->GL_CreateContext = Emscripten_GLES_CreateContext;
68.113 + device->GL_MakeCurrent = Emscripten_GLES_MakeCurrent;
68.114 + device->GL_SetSwapInterval = Emscripten_GLES_SetSwapInterval;
68.115 + device->GL_GetSwapInterval = Emscripten_GLES_GetSwapInterval;
68.116 + device->GL_SwapWindow = Emscripten_GLES_SwapWindow;
68.117 + device->GL_DeleteContext = Emscripten_GLES_DeleteContext;
68.118 + device->GL_GetDrawableSize = Emscripten_GLES_GetDrawableSize;
68.119 +
68.120 + device->free = Emscripten_DeleteDevice;
68.121 +
68.122 + return device;
68.123 +}
68.124 +
68.125 +VideoBootStrap Emscripten_bootstrap = {
68.126 + EMSCRIPTENVID_DRIVER_NAME, "SDL emscripten video driver",
68.127 + Emscripten_Available, Emscripten_CreateDevice
68.128 +};
68.129 +
68.130 +
68.131 +int
68.132 +Emscripten_VideoInit(_THIS)
68.133 +{
68.134 + SDL_DisplayMode mode;
68.135 + double css_w, css_h;
68.136 +
68.137 + /* Use a fake 32-bpp desktop mode */
68.138 + mode.format = SDL_PIXELFORMAT_RGB888;
68.139 +
68.140 + emscripten_get_element_css_size(NULL, &css_w, &css_h);
68.141 +
68.142 + mode.w = css_w;
68.143 + mode.h = css_h;
68.144 +
68.145 + mode.refresh_rate = 0;
68.146 + mode.driverdata = NULL;
68.147 + if (SDL_AddBasicVideoDisplay(&mode) < 0) {
68.148 + return -1;
68.149 + }
68.150 +
68.151 + SDL_zero(mode);
68.152 + SDL_AddDisplayMode(&_this->displays[0], &mode);
68.153 +
68.154 + Emscripten_InitMouse();
68.155 +
68.156 + /* We're done! */
68.157 + return 0;
68.158 +}
68.159 +
68.160 +static int
68.161 +Emscripten_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
68.162 +{
68.163 + /* can't do this */
68.164 + return 0;
68.165 +}
68.166 +
68.167 +static void
68.168 +Emscripten_VideoQuit(_THIS)
68.169 +{
68.170 + Emscripten_FiniMouse();
68.171 +}
68.172 +
68.173 +static void
68.174 +Emscripten_PumpEvents(_THIS)
68.175 +{
68.176 + /* do nothing. */
68.177 +}
68.178 +
68.179 +static int
68.180 +Emscripten_CreateWindow(_THIS, SDL_Window * window)
68.181 +{
68.182 + SDL_WindowData *wdata;
68.183 + double scaled_w, scaled_h;
68.184 + double css_w, css_h;
68.185 +
68.186 + /* Allocate window internal data */
68.187 + wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
68.188 + if (wdata == NULL) {
68.189 + return SDL_OutOfMemory();
68.190 + }
68.191 +
68.192 + if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
68.193 + wdata->pixel_ratio = emscripten_get_device_pixel_ratio();
68.194 + } else {
68.195 + wdata->pixel_ratio = 1.0f;
68.196 + }
68.197 +
68.198 + scaled_w = SDL_floor(window->w * wdata->pixel_ratio);
68.199 + scaled_h = SDL_floor(window->h * wdata->pixel_ratio);
68.200 +
68.201 + emscripten_set_canvas_size(scaled_w, scaled_h);
68.202 +
68.203 + emscripten_get_element_css_size(NULL, &css_w, &css_h);
68.204 +
68.205 + wdata->external_size = css_w != scaled_w || css_h != scaled_h;
68.206 +
68.207 + if ((window->flags & SDL_WINDOW_RESIZABLE) && wdata->external_size) {
68.208 + /* external css has resized us */
68.209 + scaled_w = css_w * wdata->pixel_ratio;
68.210 + scaled_h = css_h * wdata->pixel_ratio;
68.211 +
68.212 + emscripten_set_canvas_size(scaled_w, scaled_h);
68.213 + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, css_w, css_h);
68.214 + }
68.215 +
68.216 + /* if the size is not being controlled by css, we need to scale down for hidpi */
68.217 + if (!wdata->external_size) {
68.218 + if (wdata->pixel_ratio != 1.0f) {
68.219 + /*scale canvas down*/
68.220 + emscripten_set_element_css_size(NULL, window->w, window->h);
68.221 + }
68.222 + }
68.223 +
68.224 + wdata->windowed_width = scaled_w;
68.225 + wdata->windowed_height = scaled_h;
68.226 +
68.227 + if (window->flags & SDL_WINDOW_OPENGL) {
68.228 + if (!_this->egl_data) {
68.229 + if (SDL_GL_LoadLibrary(NULL) < 0) {
68.230 + return -1;
68.231 + }
68.232 + }
68.233 + wdata->egl_surface = SDL_EGL_CreateSurface(_this, 0);
68.234 +
68.235 + if (wdata->egl_surface == EGL_NO_SURFACE) {
68.236 + return SDL_SetError("Could not create GLES window surface");
68.237 + }
68.238 + }
68.239 +
68.240 + wdata->window = window;
68.241 +
68.242 + /* Setup driver data for this window */
68.243 + window->driverdata = wdata;
68.244 +
68.245 + /* One window, it always has focus */
68.246 + SDL_SetMouseFocus(window);
68.247 + SDL_SetKeyboardFocus(window);
68.248 +
68.249 + Emscripten_RegisterEventHandlers(wdata);
68.250 +
68.251 + /* Window has been successfully created */
68.252 + return 0;
68.253 +}
68.254 +
68.255 +static void Emscripten_SetWindowSize(_THIS, SDL_Window * window)
68.256 +{
68.257 + SDL_WindowData *data;
68.258 +
68.259 + if (window->driverdata) {
68.260 + data = (SDL_WindowData *) window->driverdata;
68.261 + emscripten_set_canvas_size(window->w * data->pixel_ratio, window->h * data->pixel_ratio);
68.262 +
68.263 + /*scale canvas down*/
68.264 + if (!data->external_size && data->pixel_ratio != 1.0f) {
68.265 + emscripten_set_element_css_size(NULL, window->w, window->h);
68.266 + }
68.267 + }
68.268 +}
68.269 +
68.270 +static void
68.271 +Emscripten_DestroyWindow(_THIS, SDL_Window * window)
68.272 +{
68.273 + SDL_WindowData *data;
68.274 +
68.275 + if(window->driverdata) {
68.276 + data = (SDL_WindowData *) window->driverdata;
68.277 +
68.278 + Emscripten_UnregisterEventHandlers(data);
68.279 + if (data->egl_surface != EGL_NO_SURFACE) {
68.280 + SDL_EGL_DestroySurface(_this, data->egl_surface);
68.281 + data->egl_surface = EGL_NO_SURFACE;
68.282 + }
68.283 + SDL_free(window->driverdata);
68.284 + window->driverdata = NULL;
68.285 + }
68.286 +}
68.287 +
68.288 +static void
68.289 +Emscripten_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
68.290 +{
68.291 + SDL_WindowData *data;
68.292 + if(window->driverdata) {
68.293 + data = (SDL_WindowData *) window->driverdata;
68.294 +
68.295 + if(fullscreen) {
68.296 + data->requested_fullscreen_mode = window->flags & (SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN);
68.297 + /*unset the fullscreen flags as we're not actually fullscreen yet*/
68.298 + window->flags &= ~(SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN);
68.299 +
68.300 + EM_ASM({
68.301 + //reparent canvas (similar to Module.requestFullscreen)
68.302 + var canvas = Module['canvas'];
68.303 + if(canvas.parentNode.id != "SDLFullscreenElement") {
68.304 + var canvasContainer = document.createElement("div");
68.305 + canvasContainer.id = "SDLFullscreenElement";
68.306 + canvas.parentNode.insertBefore(canvasContainer, canvas);
68.307 + canvasContainer.appendChild(canvas);
68.308 + }
68.309 + });
68.310 +
68.311 + int is_fullscreen;
68.312 + emscripten_get_canvas_size(&data->windowed_width, &data->windowed_height, &is_fullscreen);
68.313 + emscripten_request_fullscreen("SDLFullscreenElement", 1);
68.314 + }
68.315 + else
68.316 + emscripten_exit_fullscreen();
68.317 + }
68.318 +}
68.319 +
68.320 +#endif /* SDL_VIDEO_DRIVER_EMSCRIPTEN */
68.321 +
68.322 +/* vi: set ts=4 sw=4 expandtab: */
69.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
69.2 +++ b/src/video/emscripten/SDL_emscriptenvideo.h Thu Jan 15 01:15:24 2015 -0400
69.3 @@ -0,0 +1,52 @@
69.4 +/*
69.5 + Simple DirectMedia Layer
69.6 + Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
69.7 +
69.8 + This software is provided 'as-is', without any express or implied
69.9 + warranty. In no event will the authors be held liable for any damages
69.10 + arising from the use of this software.
69.11 +
69.12 + Permission is granted to anyone to use this software for any purpose,
69.13 + including commercial applications, and to alter it and redistribute it
69.14 + freely, subject to the following restrictions:
69.15 +
69.16 + 1. The origin of this software must not be misrepresented; you must not
69.17 + claim that you wrote the original software. If you use this software
69.18 + in a product, an acknowledgment in the product documentation would be
69.19 + appreciated but is not required.
69.20 + 2. Altered source versions must be plainly marked as such, and must not be
69.21 + misrepresented as being the original software.
69.22 + 3. This notice may not be removed or altered from any source distribution.
69.23 +*/
69.24 +#include "../../SDL_internal.h"
69.25 +
69.26 +#ifndef _SDL_emscriptenvideo_h
69.27 +#define _SDL_emscriptenvideo_h
69.28 +
69.29 +#include "../SDL_sysvideo.h"
69.30 +#include <emscripten/emscripten.h>
69.31 +#include <emscripten/html5.h>
69.32 +
69.33 +#include <EGL/egl.h>
69.34 +
69.35 +typedef struct SDL_WindowData
69.36 +{
69.37 +#if SDL_VIDEO_OPENGL_EGL
69.38 + EGLSurface egl_surface;
69.39 +#endif
69.40 + SDL_Window *window;
69.41 + SDL_Surface *surface;
69.42 +
69.43 + int windowed_width;
69.44 + int windowed_height;
69.45 +
69.46 + float pixel_ratio;
69.47 +
69.48 + SDL_bool external_size;
69.49 +
69.50 + int requested_fullscreen_mode;
69.51 +} SDL_WindowData;
69.52 +
69.53 +#endif /* _SDL_emscriptenvideo_h */
69.54 +
69.55 +/* vi: set ts=4 sw=4 expandtab: */
70.1 --- a/src/video/mir/SDL_mirevents.c Thu Jan 15 01:06:14 2015 -0400
70.2 +++ b/src/video/mir/SDL_mirevents.c Thu Jan 15 01:15:24 2015 -0400
70.3 @@ -137,7 +137,7 @@
70.4 static void
70.5 HandleMouseScroll(SDL_Window* sdl_window, int hscroll, int vscroll)
70.6 {
70.7 - SDL_SendMouseWheel(sdl_window, 0, hscroll, vscroll);
70.8 + SDL_SendMouseWheel(sdl_window, 0, hscroll, vscroll, SDL_MOUSEWHEEL_NORMAL);
70.9 }
70.10
70.11 static void
71.1 --- a/src/video/nacl/SDL_naclevents.c Thu Jan 15 01:06:14 2015 -0400
71.2 +++ b/src/video/nacl/SDL_naclevents.c Thu Jan 15 01:15:24 2015 -0400
71.3 @@ -357,7 +357,7 @@
71.4 case PP_INPUTEVENT_TYPE_WHEEL:
71.5 /* FIXME: GetTicks provides high resolution scroll events */
71.6 fp = driverdata->ppb_wheel_input_event->GetDelta(event);
71.7 - SDL_SendMouseWheel(mouse->focus, mouse->mouseID, (int) fp.x, (int) fp.y);
71.8 + SDL_SendMouseWheel(mouse->focus, mouse->mouseID, (int) fp.x, (int) fp.y, SDL_MOUSEWHEEL_NORMAL);
71.9 break;
71.10
71.11 case PP_INPUTEVENT_TYPE_MOUSEENTER:
72.1 --- a/src/video/wayland/SDL_waylandevents.c Thu Jan 15 01:06:14 2015 -0400
72.2 +++ b/src/video/wayland/SDL_waylandevents.c Thu Jan 15 01:15:24 2015 -0400
72.3 @@ -184,7 +184,7 @@
72.4 return;
72.5 }
72.6
72.7 - SDL_SendMouseWheel(window->sdlwindow, 0, x, y);
72.8 + SDL_SendMouseWheel(window->sdlwindow, 0, x, y, SDL_MOUSEWHEEL_NORMAL);
72.9 }
72.10 }
72.11
73.1 --- a/src/video/wayland/SDL_waylandvideo.h Thu Jan 15 01:06:14 2015 -0400
73.2 +++ b/src/video/wayland/SDL_waylandvideo.h Thu Jan 15 01:15:24 2015 -0400
73.3 @@ -69,6 +69,6 @@
73.4 uint32_t shm_formats;
73.5 } SDL_VideoData;
73.6
73.7 -#endif /* _SDL_nullvideo_h */
73.8 +#endif /* _SDL_waylandvideo_h */
73.9
73.10 /* vi: set ts=4 sw=4 expandtab: */
74.1 --- a/src/video/windows/SDL_windowsevents.c Thu Jan 15 01:06:14 2015 -0400
74.2 +++ b/src/video/windows/SDL_windowsevents.c Thu Jan 15 01:15:24 2015 -0400
74.3 @@ -498,12 +498,12 @@
74.4 s_AccumulatedMotion += GET_WHEEL_DELTA_WPARAM(wParam);
74.5 if (s_AccumulatedMotion > 0) {
74.6 while (s_AccumulatedMotion >= WHEEL_DELTA) {
74.7 - SDL_SendMouseWheel(data->window, 0, 0, 1);
74.8 + SDL_SendMouseWheel(data->window, 0, 0, 1, SDL_MOUSEWHEEL_NORMAL);
74.9 s_AccumulatedMotion -= WHEEL_DELTA;
74.10 }
74.11 } else {
74.12 while (s_AccumulatedMotion <= -WHEEL_DELTA) {
74.13 - SDL_SendMouseWheel(data->window, 0, 0, -1);
74.14 + SDL_SendMouseWheel(data->window, 0, 0, -1, SDL_MOUSEWHEEL_NORMAL);
74.15 s_AccumulatedMotion += WHEEL_DELTA;
74.16 }
74.17 }
74.18 @@ -517,12 +517,12 @@
74.19 s_AccumulatedMotion += GET_WHEEL_DELTA_WPARAM(wParam);
74.20 if (s_AccumulatedMotion > 0) {
74.21 while (s_AccumulatedMotion >= WHEEL_DELTA) {
74.22 - SDL_SendMouseWheel(data->window, 0, 1, 0);
74.23 + SDL_SendMouseWheel(data->window, 0, 1, 0, SDL_MOUSEWHEEL_NORMAL);
74.24 s_AccumulatedMotion -= WHEEL_DELTA;
74.25 }
74.26 } else {
74.27 while (s_AccumulatedMotion <= -WHEEL_DELTA) {
74.28 - SDL_SendMouseWheel(data->window, 0, -1, 0);
74.29 + SDL_SendMouseWheel(data->window, 0, -1, 0, SDL_MOUSEWHEEL_NORMAL);
74.30 s_AccumulatedMotion += WHEEL_DELTA;
74.31 }
74.32 }
75.1 --- a/src/video/winrt/SDL_winrtpointerinput.cpp Thu Jan 15 01:06:14 2015 -0400
75.2 +++ b/src/video/winrt/SDL_winrtpointerinput.cpp Thu Jan 15 01:15:24 2015 -0400
75.3 @@ -315,7 +315,7 @@
75.4
75.5 // FIXME: This may need to accumulate deltas up to WHEEL_DELTA
75.6 short motion = pointerPoint->Properties->MouseWheelDelta / WHEEL_DELTA;
75.7 - SDL_SendMouseWheel(window, 0, 0, motion);
75.8 + SDL_SendMouseWheel(window, 0, 0, motion, SDL_MOUSEWHEEL_NORMAL);
75.9 }
75.10
75.11 void
76.1 --- a/src/video/x11/SDL_x11events.c Thu Jan 15 01:06:14 2015 -0400
76.2 +++ b/src/video/x11/SDL_x11events.c Thu Jan 15 01:15:24 2015 -0400
76.3 @@ -990,7 +990,7 @@
76.4 case ButtonPress:{
76.5 int ticks = 0;
76.6 if (X11_IsWheelEvent(display,&xevent,&ticks)) {
76.7 - SDL_SendMouseWheel(data->window, 0, 0, ticks);
76.8 + SDL_SendMouseWheel(data->window, 0, 0, ticks, SDL_MOUSEWHEEL_NORMAL);
76.9 } else {
76.10 if(xevent.xbutton.button == Button1) {
76.11 if (ProcessHitTest(_this, data, &xevent)) {
77.1 --- a/test/Makefile.in Thu Jan 15 01:06:14 2015 -0400
77.2 +++ b/test/Makefile.in Thu Jan 15 01:15:24 2015 -0400
77.3 @@ -196,6 +196,15 @@
77.4 $(CC) -o $@ $^ $(CFLAGS) $(LIBS) @XLIB@
77.5 endif
77.6
77.7 +#there's probably a better way of doing this
77.8 +ifeq (@ISMACOSX@,false)
77.9 +ifeq (@ISWINDOWS@,false)
77.10 +ifeq (@ISUNIX@,false)
77.11 +testnative$(EXE): ;
77.12 +endif
77.13 +endif
77.14 +endif
77.15 +
77.16 testoverlay2$(EXE): $(srcdir)/testoverlay2.c
77.17 $(CC) -o $@ $^ $(CFLAGS) $(LIBS)
77.18
78.1 --- a/test/checkkeys.c Thu Jan 15 01:06:14 2015 -0400
78.2 +++ b/test/checkkeys.c Thu Jan 15 01:15:24 2015 -0400
78.3 @@ -19,8 +19,14 @@
78.4 #include <stdlib.h>
78.5 #include <string.h>
78.6
78.7 +#ifdef __EMSCRIPTEN__
78.8 +#include <emscripten/emscripten.h>
78.9 +#endif
78.10 +
78.11 #include "SDL.h"
78.12
78.13 +int done;
78.14 +
78.15 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
78.16 static void
78.17 quit(int rc)
78.18 @@ -128,12 +134,37 @@
78.19 SDL_Log("Text (%s): \"%s%s\"\n", expanded, *text == '"' ? "\\" : "", text);
78.20 }
78.21
78.22 +void
78.23 +loop()
78.24 +{
78.25 + SDL_Event event;
78.26 + /* Check for events */
78.27 + /*SDL_WaitEvent(&event); emscripten does not like waiting*/
78.28 +
78.29 + while (SDL_PollEvent(&event)) {
78.30 + switch (event.type) {
78.31 + case SDL_KEYDOWN:
78.32 + //case SDL_KEYUP:
78.33 + PrintKey(&event.key.keysym, (event.key.state == SDL_PRESSED) ? SDL_TRUE : SDL_FALSE, (event.key.repeat) ? SDL_TRUE : SDL_FALSE);
78.34 + break;
78.35 + case SDL_TEXTINPUT:
78.36 + PrintText(event.text.text);
78.37 + break;
78.38 + case SDL_MOUSEBUTTONDOWN:
78.39 + /* Any button press quits the app... */
78.40 + case SDL_QUIT:
78.41 + done = 1;
78.42 + break;
78.43 + default:
78.44 + break;
78.45 + }
78.46 + }
78.47 +}
78.48 +
78.49 int
78.50 main(int argc, char *argv[])
78.51 {
78.52 SDL_Window *window;
78.53 - SDL_Event event;
78.54 - int done;
78.55
78.56 /* Enable standard application logging */
78.57 SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
78.58 @@ -163,26 +194,14 @@
78.59
78.60 /* Watch keystrokes */
78.61 done = 0;
78.62 +
78.63 +#ifdef __EMSCRIPTEN__
78.64 + emscripten_set_main_loop(loop, 0, 1);
78.65 +#else
78.66 while (!done) {
78.67 - /* Check for events */
78.68 - SDL_WaitEvent(&event);
78.69 - switch (event.type) {
78.70 - case SDL_KEYDOWN:
78.71 - case SDL_KEYUP:
78.72 - PrintKey(&event.key.keysym, (event.key.state == SDL_PRESSED) ? SDL_TRUE : SDL_FALSE, (event.key.repeat) ? SDL_TRUE : SDL_FALSE);
78.73 - break;
78.74 - case SDL_TEXTINPUT:
78.75 - PrintText(event.text.text);
78.76 - break;
78.77 - case SDL_MOUSEBUTTONDOWN:
78.78 - /* Any button press quits the app... */
78.79 - case SDL_QUIT:
78.80 - done = 1;
78.81 - break;
78.82 - default:
78.83 - break;
78.84 - }
78.85 + loop();
78.86 }
78.87 +#endif
78.88
78.89 SDL_Quit();
78.90 return (0);
79.1 --- a/test/configure Thu Jan 15 01:06:14 2015 -0400
79.2 +++ b/test/configure Thu Jan 15 01:15:24 2015 -0400
79.3 @@ -2980,6 +2980,11 @@
79.4 MATHLIB=""
79.5 SYS_GL_LIBS="-lGLES_CM"
79.6 ;;
79.7 + *-*-emscripten* )
79.8 + EXE=".bc"
79.9 + MATHLIB=""
79.10 + SYS_GL_LIBS=""
79.11 + ;;
79.12 *)
79.13 ISUNIX="true"
79.14 EXE=""
80.1 --- a/test/configure.in Thu Jan 15 01:06:14 2015 -0400
80.2 +++ b/test/configure.in Thu Jan 15 01:15:24 2015 -0400
80.3 @@ -65,6 +65,12 @@
80.4 MATHLIB=""
80.5 SYS_GL_LIBS="-lGLES_CM"
80.6 ;;
80.7 + *-*-emscripten* )
80.8 + dnl This should really be .js, but we need to specify extra flags when compiling to js
80.9 + EXE=".bc"
80.10 + MATHLIB=""
80.11 + SYS_GL_LIBS=""
80.12 + ;;
80.13 *)
80.14 dnl Oh well, call it Unix...
80.15 ISUNIX="true"
81.1 --- a/test/controllermap.c Thu Jan 15 01:06:14 2015 -0400
81.2 +++ b/test/controllermap.c Thu Jan 15 01:15:24 2015 -0400
81.3 @@ -191,7 +191,6 @@
81.4 step->button = -1;
81.5 step->hat = -1;
81.6 step->hat_value = -1;
81.7 - SDL_SetClipboardText("TESTING TESTING 123");
81.8
81.9 switch(step->marker) {
81.10 case MARKER_AXIS:
82.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
82.2 +++ b/test/emscripten/joystick-pre.js Thu Jan 15 01:15:24 2015 -0400
82.3 @@ -0,0 +1,25 @@
82.4 +Module['arguments'] = ['0'];
82.5 +//Gamepads don't appear until a button is pressed and the joystick/gamepad tests expect one to be connected
82.6 +Module['preRun'].push(function()
82.7 +{
82.8 + Module['print']("Waiting for gamepad...");
82.9 + Module['addRunDependency']("gamepad");
82.10 + window.addEventListener('gamepadconnected', function()
82.11 + {
82.12 + //OK, got one
82.13 + Module['removeRunDependency']("gamepad");
82.14 + }, false);
82.15 +
82.16 + //chrome
82.17 + if(!!navigator.webkitGetGamepads)
82.18 + {
82.19 + var timeout = function()
82.20 + {
82.21 + if(navigator.webkitGetGamepads()[0] !== undefined)
82.22 + Module['removeRunDependency']("gamepad");
82.23 + else
82.24 + setTimeout(timeout, 100);
82.25 + }
82.26 + setTimeout(timeout, 100);
82.27 + }
82.28 +});
83.1 --- a/test/loopwave.c Thu Jan 15 01:06:14 2015 -0400
83.2 +++ b/test/loopwave.c Thu Jan 15 01:15:24 2015 -0400
83.3 @@ -24,6 +24,10 @@
83.4 #include <signal.h>
83.5 #endif
83.6
83.7 +#ifdef __EMSCRIPTEN__
83.8 +#include <emscripten/emscripten.h>
83.9 +#endif
83.10 +
83.11 #include "SDL.h"
83.12 #include "SDL_audio.h"
83.13
83.14 @@ -75,6 +79,15 @@
83.15 done = 1;
83.16 }
83.17
83.18 +#ifdef __EMSCRIPTEN__
83.19 +void
83.20 +loop()
83.21 +{
83.22 + if(done || (SDL_GetAudioStatus() != SDL_AUDIO_PLAYING))
83.23 + emscripten_cancel_main_loop();
83.24 +}
83.25 +#endif
83.26 +
83.27 int
83.28 main(int argc, char *argv[])
83.29 {
83.30 @@ -131,8 +144,13 @@
83.31
83.32 /* Let the audio run */
83.33 SDL_PauseAudio(0);
83.34 +
83.35 +#ifdef __EMSCRIPTEN__
83.36 + emscripten_set_main_loop(loop, 0, 1);
83.37 +#else
83.38 while (!done && (SDL_GetAudioStatus() == SDL_AUDIO_PLAYING))
83.39 SDL_Delay(1000);
83.40 +#endif
83.41
83.42 /* Clean up on signal */
83.43 SDL_CloseAudio();
84.1 --- a/test/testautomation.c Thu Jan 15 01:06:14 2015 -0400
84.2 +++ b/test/testautomation.c Thu Jan 15 01:15:24 2015 -0400
84.3 @@ -62,7 +62,7 @@
84.4 }
84.5 else if (SDL_strcasecmp(argv[i], "--execKey") == 0) {
84.6 if (argv[i + 1]) {
84.7 - SDL_sscanf(argv[i + 1], "%llu", (long long unsigned int *)&userExecKey);
84.8 + SDL_sscanf(argv[i + 1], "%"SDL_PRIu64, (long long unsigned int *)&userExecKey);
84.9 consumed = 2;
84.10 }
84.11 }
85.1 --- a/test/testautomation_platform.c Thu Jan 15 01:06:14 2015 -0400
85.2 +++ b/test/testautomation_platform.c Thu Jan 15 01:15:24 2015 -0400
85.3 @@ -92,11 +92,7 @@
85.4
85.5 /* Test 64 swap. */
85.6 SDLTest_AssertCheck( SDL_Swap64(value64) == swapped64,
85.7 -#ifdef _MSC_VER
85.8 - "SDL_Swap64(): 64 bit swapped: 0x%I64X => 0x%I64X",
85.9 -#else
85.10 - "SDL_Swap64(): 64 bit swapped: 0x%llX => 0x%llX",
85.11 -#endif
85.12 + "SDL_Swap64(): 64 bit swapped: 0x%"SDL_PRIX64" => 0x%"SDL_PRIX64,
85.13 value64, SDL_Swap64(value64) );
85.14
85.15 return TEST_COMPLETED;
86.1 --- a/test/testautomation_rwops.c Thu Jan 15 01:06:14 2015 -0400
86.2 +++ b/test/testautomation_rwops.c Thu Jan 15 01:15:24 2015 -0400
86.3 @@ -105,7 +105,7 @@
86.4 /* Set to start. */
86.5 i = SDL_RWseek(rw, 0, RW_SEEK_SET );
86.6 SDLTest_AssertPass("Call to SDL_RWseek succeeded");
86.7 - SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %lli", i);
86.8 + SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %"SDL_PRIs64, i);
86.9
86.10 /* Test write. */
86.11 s = SDL_RWwrite(rw, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString)-1, 1);
86.12 @@ -120,12 +120,12 @@
86.13 /* Test seek to random position */
86.14 i = SDL_RWseek( rw, seekPos, RW_SEEK_SET );
86.15 SDLTest_AssertPass("Call to SDL_RWseek succeeded");
86.16 - SDLTest_AssertCheck(i == (Sint64)seekPos, "Verify seek to %i with SDL_RWseek (RW_SEEK_SET), expected %i, got %lli", seekPos, seekPos, i);
86.17 + SDLTest_AssertCheck(i == (Sint64)seekPos, "Verify seek to %i with SDL_RWseek (RW_SEEK_SET), expected %i, got %"SDL_PRIs64, seekPos, seekPos, i);
86.18
86.19 /* Test seek back to start */
86.20 i = SDL_RWseek(rw, 0, RW_SEEK_SET );
86.21 SDLTest_AssertPass("Call to SDL_RWseek succeeded");
86.22 - SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %lli", i);
86.23 + SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %"SDL_PRIs64, i);
86.24
86.25 /* Test read */
86.26 s = SDL_RWread( rw, buf, 1, sizeof(RWopsHelloWorldTestString)-1 );
86.27 @@ -144,7 +144,7 @@
86.28 SDLTest_AssertPass("Call to SDL_RWseek(...,-4,RW_SEEK_CUR) succeeded");
86.29 SDLTest_AssertCheck(
86.30 i == (Sint64)(sizeof(RWopsHelloWorldTestString)-5),
86.31 - "Verify seek to -4 with SDL_RWseek (RW_SEEK_CUR), expected %i, got %lli",
86.32 + "Verify seek to -4 with SDL_RWseek (RW_SEEK_CUR), expected %i, got %"SDL_PRIs64,
86.33 sizeof(RWopsHelloWorldTestString)-5,
86.34 i);
86.35
86.36 @@ -152,7 +152,7 @@
86.37 SDLTest_AssertPass("Call to SDL_RWseek(...,-1,RW_SEEK_END) succeeded");
86.38 SDLTest_AssertCheck(
86.39 i == (Sint64)(sizeof(RWopsHelloWorldTestString)-2),
86.40 - "Verify seek to -1 with SDL_RWseek (RW_SEEK_END), expected %i, got %lli",
86.41 + "Verify seek to -1 with SDL_RWseek (RW_SEEK_END), expected %i, got %"SDL_PRIs64,
86.42 sizeof(RWopsHelloWorldTestString)-2,
86.43 i);
86.44
86.45 @@ -161,7 +161,7 @@
86.46 SDLTest_AssertPass("Call to SDL_RWseek(...,0,invalid_whence) succeeded");
86.47 SDLTest_AssertCheck(
86.48 i == (Sint64)(-1),
86.49 - "Verify seek with SDL_RWseek (invalid_whence); expected: -1, got %lli",
86.50 + "Verify seek with SDL_RWseek (invalid_whence); expected: -1, got %"SDL_PRIs64,
86.51 i);
86.52 }
86.53
86.54 @@ -560,7 +560,7 @@
86.55
86.56 /* Compare */
86.57 SDLTest_AssertCheck(rv_mem == rv_file, "Verify returned read blocks matches for mem and file reads; got: rv_mem=%d rv_file=%d", rv_mem, rv_file);
86.58 - SDLTest_AssertCheck(sv_mem == sv_file, "Verify SEEK_END position matches for mem and file seeks; got: sv_mem=%llu sv_file=%llu", sv_mem, sv_file);
86.59 + SDLTest_AssertCheck(sv_mem == sv_file, "Verify SEEK_END position matches for mem and file seeks; got: sv_mem=%"SDL_PRIu64" sv_file=%"SDL_PRIu64, sv_mem, sv_file);
86.60 SDLTest_AssertCheck(buffer_mem[slen] == 0, "Verify mem buffer termination; expected: 0, got: %d", buffer_mem[slen]);
86.61 SDLTest_AssertCheck(buffer_file[slen] == 0, "Verify file buffer termination; expected: 0, got: %d", buffer_file[slen]);
86.62 SDLTest_AssertCheck(
86.63 @@ -668,7 +668,7 @@
86.64 /* Test seek to start */
86.65 result = SDL_RWseek( rw, 0, RW_SEEK_SET );
86.66 SDLTest_AssertPass("Call to SDL_RWseek succeeded");
86.67 - SDLTest_AssertCheck(result == 0, "Verify result from position 0 with SDL_RWseek, expected 0, got %lli", result);
86.68 + SDLTest_AssertCheck(result == 0, "Verify result from position 0 with SDL_RWseek, expected 0, got %"SDL_PRIs64, result);
86.69
86.70 /* Read test data */
86.71 BE16test = SDL_ReadBE16(rw);
86.72 @@ -679,7 +679,7 @@
86.73 SDLTest_AssertCheck(BE32test == BE32value, "Validate return value from SDL_ReadBE32, expected: %u, got: %u", BE32value, BE32test);
86.74 BE64test = SDL_ReadBE64(rw);
86.75 SDLTest_AssertPass("Call to SDL_ReadBE64()");
86.76 - SDLTest_AssertCheck(BE64test == BE64value, "Validate return value from SDL_ReadBE64, expected: %llu, got: %llu", BE64value, BE64test);
86.77 + SDLTest_AssertCheck(BE64test == BE64value, "Validate return value from SDL_ReadBE64, expected: %"SDL_PRIu64", got: %"SDL_PRIu64, BE64value, BE64test);
86.78 LE16test = SDL_ReadLE16(rw);
86.79 SDLTest_AssertPass("Call to SDL_ReadLE16()");
86.80 SDLTest_AssertCheck(LE16test == LE16value, "Validate return value from SDL_ReadLE16, expected: %hu, got: %hu", LE16value, LE16test);
86.81 @@ -688,7 +688,7 @@
86.82 SDLTest_AssertCheck(LE32test == LE32value, "Validate return value from SDL_ReadLE32, expected: %u, got: %u", LE32value, LE32test);
86.83 LE64test = SDL_ReadLE64(rw);
86.84 SDLTest_AssertPass("Call to SDL_ReadLE64()");
86.85 - SDLTest_AssertCheck(LE64test == LE64value, "Validate return value from SDL_ReadLE64, expected: %llu, got: %llu", LE64value, LE64test);
86.86 + SDLTest_AssertCheck(LE64test == LE64value, "Validate return value from SDL_ReadLE64, expected: %"SDL_PRIu64", got: %"SDL_PRIu64, LE64value, LE64test);
86.87
86.88 /* Close handle */
86.89 cresult = SDL_RWclose(rw);
87.1 --- a/test/testautomation_sdltest.c Thu Jan 15 01:06:14 2015 -0400
87.2 +++ b/test/testautomation_sdltest.c Thu Jan 15 01:15:24 2015 -0400
87.3 @@ -93,35 +93,35 @@
87.4 result = (Sint64)SDLTest_RandomUint8();
87.5 umax = (1 << 8) - 1;
87.6 SDLTest_AssertPass("Call to SDLTest_RandomUint8");
87.7 - SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%llu], got: %lld", umax, result);
87.8 + SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%"SDL_PRIu64"], got: %"SDL_PRIs64, umax, result);
87.9
87.10 result = (Sint64)SDLTest_RandomSint8();
87.11 min = 0 - (1 << 7);
87.12 max = (1 << 7) - 1;
87.13 SDLTest_AssertPass("Call to SDLTest_RandomSint8");
87.14 - SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%lld,%lld], got: %lld", min, max, result);
87.15 + SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%"SDL_PRIs64",%"SDL_PRIs64"], got: %"SDL_PRIs64, min, max, result);
87.16
87.17 result = (Sint64)SDLTest_RandomUint16();
87.18 umax = (1 << 16) - 1;
87.19 SDLTest_AssertPass("Call to SDLTest_RandomUint16");
87.20 - SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%llu], got: %lld", umax, result);
87.21 + SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%"SDL_PRIu64"], got: %"SDL_PRIs64, umax, result);
87.22
87.23 result = (Sint64)SDLTest_RandomSint16();
87.24 min = 0 - (1 << 15);
87.25 max = (1 << 15) - 1;
87.26 SDLTest_AssertPass("Call to SDLTest_RandomSint16");
87.27 - SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%lld,%lld], got: %lld", min, max, result);
87.28 + SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%"SDL_PRIs64",%"SDL_PRIs64"], got: %"SDL_PRIs64, min, max, result);
87.29
87.30 result = (Sint64)SDLTest_RandomUint32();
87.31 umax = ((Uint64)1 << 32) - 1;
87.32 SDLTest_AssertPass("Call to SDLTest_RandomUint32");
87.33 - SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%llu], got: %lld", umax, result);
87.34 + SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%"SDL_PRIu64"], got: %"SDL_PRIs64, umax, result);
87.35
87.36 result = (Sint64)SDLTest_RandomSint32();
87.37 min = 0 - ((Sint64)1 << 31);
87.38 max = ((Sint64)1 << 31) - 1;
87.39 SDLTest_AssertPass("Call to SDLTest_RandomSint32");
87.40 - SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%lld,%lld], got: %lld", min, max, result);
87.41 + SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%"SDL_PRIs64",%"SDL_PRIs64"], got: %"SDL_PRIs64, min, max, result);
87.42
87.43 uresult = SDLTest_RandomUint64();
87.44 SDLTest_AssertPass("Call to SDLTest_RandomUint64");
87.45 @@ -166,63 +166,63 @@
87.46 SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
87.47 SDLTest_AssertCheck(
87.48 uresult == 10,
87.49 - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult);
87.50 + "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, uresult);
87.51
87.52 /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
87.53 uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 11, SDL_TRUE);
87.54 SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
87.55 SDLTest_AssertCheck(
87.56 uresult == 10 || uresult == 11,
87.57 - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult);
87.58 + "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, uresult);
87.59
87.60 /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
87.61 uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 12, SDL_TRUE);
87.62 SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
87.63 SDLTest_AssertCheck(
87.64 uresult == 10 || uresult == 11 || uresult == 12,
87.65 - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult);
87.66 + "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, uresult);
87.67
87.68 /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
87.69 uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 13, SDL_TRUE);
87.70 SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
87.71 SDLTest_AssertCheck(
87.72 uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
87.73 - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult);
87.74 + "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, uresult);
87.75
87.76 /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
87.77 uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 20, SDL_TRUE);
87.78 SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
87.79 SDLTest_AssertCheck(
87.80 uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
87.81 - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
87.82 + "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult);
87.83
87.84 /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
87.85 uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(20, 10, SDL_TRUE);
87.86 SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
87.87 SDLTest_AssertCheck(
87.88 uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
87.89 - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
87.90 + "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult);
87.91
87.92 /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
87.93 uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(1, 20, SDL_FALSE);
87.94 SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
87.95 SDLTest_AssertCheck(
87.96 uresult == 0 || uresult == 21,
87.97 - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult);
87.98 + "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, uresult);
87.99
87.100 /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
87.101 uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 99, SDL_FALSE);
87.102 SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
87.103 SDLTest_AssertCheck(
87.104 uresult == 100,
87.105 - "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult);
87.106 + "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, uresult);
87.107
87.108 /* RandomUintXBoundaryValue(1, 0xff, SDL_FALSE) returns 0 (no error) */
87.109 uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(1, 255, SDL_FALSE);
87.110 SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
87.111 SDLTest_AssertCheck(
87.112 uresult == 0,
87.113 - "Validate result value for parameters (1,255,SDL_FALSE); expected: 0, got: %lld", uresult);
87.114 + "Validate result value for parameters (1,255,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult);
87.115 lastError = (char *)SDL_GetError();
87.116 SDLTest_AssertPass("SDL_GetError()");
87.117 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
87.118 @@ -232,7 +232,7 @@
87.119 SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
87.120 SDLTest_AssertCheck(
87.121 uresult == 0xff,
87.122 - "Validate result value for parameters (0,254,SDL_FALSE); expected: 0xff, got: %lld", uresult);
87.123 + "Validate result value for parameters (0,254,SDL_FALSE); expected: 0xff, got: %"SDL_PRIs64, uresult);
87.124 lastError = (char *)SDL_GetError();
87.125 SDLTest_AssertPass("SDL_GetError()");
87.126 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
87.127 @@ -242,7 +242,7 @@
87.128 SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
87.129 SDLTest_AssertCheck(
87.130 uresult == 0,
87.131 - "Validate result value for parameters(0,255,SDL_FALSE); expected: 0, got: %lld", uresult);
87.132 + "Validate result value for parameters(0,255,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult);
87.133 lastError = (char *)SDL_GetError();
87.134 SDLTest_AssertPass("SDL_GetError()");
87.135 SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
87.136 @@ -276,63 +276,63 @@
87.137 SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
87.138 SDLTest_AssertCheck(
87.139 uresult == 10,
87.140 - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult);
87.141 + "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, uresult);
87.142
87.143 /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
87.144 uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 11, SDL_TRUE);
87.145 SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
87.146 SDLTest_AssertCheck(
87.147 uresult == 10 || uresult == 11,
87.148 - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult);
87.149 + "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, uresult);
87.150
87.151 /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
87.152 uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 12, SDL_TRUE);
87.153 SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
87.154 SDLTest_AssertCheck(
87.155 uresult == 10 || uresult == 11 || uresult == 12,
87.156 - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult);
87.157 + "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, uresult);
87.158
87.159 /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
87.160 uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 13, SDL_TRUE);
87.161 SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
87.162 SDLTest_AssertCheck(
87.163 uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
87.164 - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult);
87.165 + "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, uresult);
87.166
87.167 /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
87.168 uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 20, SDL_TRUE);
87.169 SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
87.170 SDLTest_AssertCheck(
87.171 uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
87.172 - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
87.173 + "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult);
87.174
87.175 /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
87.176 uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(20, 10, SDL_TRUE);
87.177 SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
87.178 SDLTest_AssertCheck(
87.179 uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
87.180 - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
87.181 + "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult);
87.182
87.183 /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
87.184 uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(1, 20, SDL_FALSE);
87.185 SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
87.186 SDLTest_AssertCheck(
87.187 uresult == 0 || uresult == 21,
87.188 - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult);
87.189 + "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, uresult);
87.190
87.191 /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
87.192 uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 99, SDL_FALSE);
87.193 SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
87.194 SDLTest_AssertCheck(
87.195 uresult == 100,
87.196 - "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult);
87.197 + "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, uresult);
87.198
87.199 /* RandomUintXBoundaryValue(1, 0xffff, SDL_FALSE) returns 0 (no error) */
87.200 uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(1, 0xffff, SDL_FALSE);
87.201 SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
87.202 SDLTest_AssertCheck(
87.203 uresult == 0,
87.204 - "Validate result value for parameters (1,0xffff,SDL_FALSE); expected: 0, got: %lld", uresult);
87.205 + "Validate result value for parameters (1,0xffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult);
87.206 lastError = (char *)SDL_GetError();
87.207 SDLTest_AssertPass("SDL_GetError()");
87.208 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
87.209 @@ -342,7 +342,7 @@
87.210 SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
87.211 SDLTest_AssertCheck(
87.212 uresult == 0xffff,
87.213 - "Validate result value for parameters (0,0xfffe,SDL_FALSE); expected: 0xffff, got: %lld", uresult);
87.214 + "Validate result value for parameters (0,0xfffe,SDL_FALSE); expected: 0xffff, got: %"SDL_PRIs64, uresult);
87.215 lastError = (char *)SDL_GetError();
87.216 SDLTest_AssertPass("SDL_GetError()");
87.217 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
87.218 @@ -352,7 +352,7 @@
87.219 SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
87.220 SDLTest_AssertCheck(
87.221 uresult == 0,
87.222 - "Validate result value for parameters(0,0xffff,SDL_FALSE); expected: 0, got: %lld", uresult);
87.223 + "Validate result value for parameters(0,0xffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult);
87.224 lastError = (char *)SDL_GetError();
87.225 SDLTest_AssertPass("SDL_GetError()");
87.226 SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
87.227 @@ -386,63 +386,63 @@
87.228 SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
87.229 SDLTest_AssertCheck(
87.230 uresult == 10,
87.231 - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult);
87.232 + "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, uresult);
87.233
87.234 /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
87.235 uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 11, SDL_TRUE);
87.236 SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
87.237 SDLTest_AssertCheck(
87.238 uresult == 10 || uresult == 11,
87.239 - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult);
87.240 + "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, uresult);
87.241
87.242 /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
87.243 uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 12, SDL_TRUE);
87.244 SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
87.245 SDLTest_AssertCheck(
87.246 uresult == 10 || uresult == 11 || uresult == 12,
87.247 - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult);
87.248 + "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, uresult);
87.249
87.250 /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
87.251 uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 13, SDL_TRUE);
87.252 SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
87.253 SDLTest_AssertCheck(
87.254 uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
87.255 - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult);
87.256 + "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, uresult);
87.257
87.258 /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
87.259 uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 20, SDL_TRUE);
87.260 SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
87.261 SDLTest_AssertCheck(
87.262 uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
87.263 - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
87.264 + "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult);
87.265
87.266 /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
87.267 uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(20, 10, SDL_TRUE);
87.268 SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
87.269 SDLTest_AssertCheck(
87.270 uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
87.271 - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
87.272 + "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult);
87.273
87.274 /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
87.275 uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(1, 20, SDL_FALSE);
87.276 SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
87.277 SDLTest_AssertCheck(
87.278 uresult == 0 || uresult == 21,
87.279 - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult);
87.280 + "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, uresult);
87.281
87.282 /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
87.283 uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 99, SDL_FALSE);
87.284 SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
87.285 SDLTest_AssertCheck(
87.286 uresult == 100,
87.287 - "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult);
87.288 + "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, uresult);
87.289
87.290 /* RandomUintXBoundaryValue(1, 0xffffffff, SDL_FALSE) returns 0 (no error) */
87.291 uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(1, 0xffffffff, SDL_FALSE);
87.292 SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
87.293 SDLTest_AssertCheck(
87.294 uresult == 0,
87.295 - "Validate result value for parameters (1,0xffffffff,SDL_FALSE); expected: 0, got: %lld", uresult);
87.296 + "Validate result value for parameters (1,0xffffffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult);
87.297 lastError = (char *)SDL_GetError();
87.298 SDLTest_AssertPass("SDL_GetError()");
87.299 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
87.300 @@ -452,7 +452,7 @@
87.301 SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
87.302 SDLTest_AssertCheck(
87.303 uresult == 0xffffffff,
87.304 - "Validate result value for parameters (0,0xfffffffe,SDL_FALSE); expected: 0xffffffff, got: %lld", uresult);
87.305 + "Validate result value for parameters (0,0xfffffffe,SDL_FALSE); expected: 0xffffffff, got: %"SDL_PRIs64, uresult);
87.306 lastError = (char *)SDL_GetError();
87.307 SDLTest_AssertPass("SDL_GetError()");
87.308 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
87.309 @@ -462,7 +462,7 @@
87.310 SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
87.311 SDLTest_AssertCheck(
87.312 uresult == 0,
87.313 - "Validate result value for parameters(0,0xffffffff,SDL_FALSE); expected: 0, got: %lld", uresult);
87.314 + "Validate result value for parameters(0,0xffffffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult);
87.315 lastError = (char *)SDL_GetError();
87.316 SDLTest_AssertPass("SDL_GetError()");
87.317 SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
87.318 @@ -496,63 +496,63 @@
87.319 SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
87.320 SDLTest_AssertCheck(
87.321 uresult == 10,
87.322 - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult);
87.323 + "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, uresult);
87.324
87.325 /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
87.326 uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 11, SDL_TRUE);
87.327 SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
87.328 SDLTest_AssertCheck(
87.329 uresult == 10 || uresult == 11,
87.330 - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult);
87.331 + "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, uresult);
87.332
87.333 /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
87.334 uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 12, SDL_TRUE);
87.335 SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
87.336 SDLTest_AssertCheck(
87.337 uresult == 10 || uresult == 11 || uresult == 12,
87.338 - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult);
87.339 + "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, uresult);
87.340
87.341 /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
87.342 uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 13, SDL_TRUE);
87.343 SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
87.344 SDLTest_AssertCheck(
87.345 uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
87.346 - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult);
87.347 + "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, uresult);
87.348
87.349 /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
87.350 uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 20, SDL_TRUE);
87.351 SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
87.352 SDLTest_AssertCheck(
87.353 uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
87.354 - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
87.355 + "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult);
87.356
87.357 /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
87.358 uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(20, 10, SDL_TRUE);
87.359 SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
87.360 SDLTest_AssertCheck(
87.361 uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
87.362 - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
87.363 + "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult);
87.364
87.365 /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
87.366 uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(1, 20, SDL_FALSE);
87.367 SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
87.368 SDLTest_AssertCheck(
87.369 uresult == 0 || uresult == 21,
87.370 - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult);
87.371 + "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, uresult);
87.372
87.373 /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
87.374 uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, 99, SDL_FALSE);
87.375 SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
87.376 SDLTest_AssertCheck(
87.377 uresult == 100,
87.378 - "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult);
87.379 + "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, uresult);
87.380
87.381 /* RandomUintXBoundaryValue(1, 0xffffffffffffffff, SDL_FALSE) returns 0 (no error) */
87.382 uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(1, (Uint64)0xffffffffffffffffULL, SDL_FALSE);
87.383 SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
87.384 SDLTest_AssertCheck(
87.385 uresult == 0,
87.386 - "Validate result value for parameters (1,0xffffffffffffffff,SDL_FALSE); expected: 0, got: %lld", uresult);
87.387 + "Validate result value for parameters (1,0xffffffffffffffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult);
87.388 lastError = (char *)SDL_GetError();
87.389 SDLTest_AssertPass("SDL_GetError()");
87.390 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
87.391 @@ -562,7 +562,7 @@
87.392 SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
87.393 SDLTest_AssertCheck(
87.394 uresult == (Uint64)0xffffffffffffffffULL,
87.395 - "Validate result value for parameters (0,0xfffffffffffffffe,SDL_FALSE); expected: 0xffffffffffffffff, got: %lld", uresult);
87.396 + "Validate result value for parameters (0,0xfffffffffffffffe,SDL_FALSE); expected: 0xffffffffffffffff, got: %"SDL_PRIs64, uresult);
87.397 lastError = (char *)SDL_GetError();
87.398 SDLTest_AssertPass("SDL_GetError()");
87.399 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
87.400 @@ -572,7 +572,7 @@
87.401 SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
87.402 SDLTest_AssertCheck(
87.403 uresult == 0,
87.404 - "Validate result value for parameters(0,0xffffffffffffffff,SDL_FALSE); expected: 0, got: %lld", uresult);
87.405 + "Validate result value for parameters(0,0xffffffffffffffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult);
87.406 lastError = (char *)SDL_GetError();
87.407 SDLTest_AssertPass("SDL_GetError()");
87.408 SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
87.409 @@ -606,63 +606,63 @@
87.410 SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
87.411 SDLTest_AssertCheck(
87.412 sresult == 10,
87.413 - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult);
87.414 + "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, sresult);
87.415
87.416 /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
87.417 sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 11, SDL_TRUE);
87.418 SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
87.419 SDLTest_AssertCheck(
87.420 sresult == 10 || sresult == 11,
87.421 - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult);
87.422 + "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, sresult);
87.423
87.424 /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
87.425 sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 12, SDL_TRUE);
87.426 SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
87.427 SDLTest_AssertCheck(
87.428 sresult == 10 || sresult == 11 || sresult == 12,
87.429 - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult);
87.430 + "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, sresult);
87.431
87.432 /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
87.433 sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 13, SDL_TRUE);
87.434 SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
87.435 SDLTest_AssertCheck(
87.436 sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
87.437 - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult);
87.438 + "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, sresult);
87.439
87.440 /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
87.441 sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 20, SDL_TRUE);
87.442 SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
87.443 SDLTest_AssertCheck(
87.444 sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
87.445 - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
87.446 + "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult);
87.447
87.448 /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
87.449 sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(20, 10, SDL_TRUE);
87.450 SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
87.451 SDLTest_AssertCheck(
87.452 sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
87.453 - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
87.454 + "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult);
87.455
87.456 /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
87.457 sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(1, 20, SDL_FALSE);
87.458 SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
87.459 SDLTest_AssertCheck(
87.460 sresult == 0 || sresult == 21,
87.461 - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult);
87.462 + "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, sresult);
87.463
87.464 /* RandomSintXBoundaryValue(SCHAR_MIN, 99, SDL_FALSE) returns 100 */
87.465 sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, 99, SDL_FALSE);
87.466 SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
87.467 SDLTest_AssertCheck(
87.468 sresult == 100,
87.469 - "Validate result value for parameters (SCHAR_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult);
87.470 + "Validate result value for parameters (SCHAR_MIN,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, sresult);
87.471
87.472 /* RandomSintXBoundaryValue(SCHAR_MIN + 1, SCHAR_MAX, SDL_FALSE) returns SCHAR_MIN (no error) */
87.473 sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN + 1, SCHAR_MAX, SDL_FALSE);
87.474 SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
87.475 SDLTest_AssertCheck(
87.476 sresult == SCHAR_MIN,
87.477 - "Validate result value for parameters (SCHAR_MIN + 1,SCHAR_MAX,SDL_FALSE); expected: %d, got: %lld", SCHAR_MIN, sresult);
87.478 + "Validate result value for parameters (SCHAR_MIN + 1,SCHAR_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SCHAR_MIN, sresult);
87.479 lastError = (char *)SDL_GetError();
87.480 SDLTest_AssertPass("SDL_GetError()");
87.481 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
87.482 @@ -672,7 +672,7 @@
87.483 SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
87.484 SDLTest_AssertCheck(
87.485 sresult == SCHAR_MAX,
87.486 - "Validate result value for parameters (SCHAR_MIN,SCHAR_MAX - 1,SDL_FALSE); expected: %d, got: %lld", SCHAR_MAX, sresult);
87.487 + "Validate result value for parameters (SCHAR_MIN,SCHAR_MAX - 1,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SCHAR_MAX, sresult);
87.488 lastError = (char *)SDL_GetError();
87.489 SDLTest_AssertPass("SDL_GetError()");
87.490 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
87.491 @@ -682,7 +682,7 @@
87.492 SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
87.493 SDLTest_AssertCheck(
87.494 sresult == SCHAR_MIN,
87.495 - "Validate result value for parameters(SCHAR_MIN,SCHAR_MAX,SDL_FALSE); expected: %d, got: %lld", SCHAR_MIN, sresult);
87.496 + "Validate result value for parameters(SCHAR_MIN,SCHAR_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SCHAR_MIN, sresult);
87.497 lastError = (char *)SDL_GetError();
87.498 SDLTest_AssertPass("SDL_GetError()");
87.499 SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
87.500 @@ -716,63 +716,63 @@
87.501 SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
87.502 SDLTest_AssertCheck(
87.503 sresult == 10,
87.504 - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult);
87.505 + "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, sresult);
87.506
87.507 /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
87.508 sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 11, SDL_TRUE);
87.509 SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
87.510 SDLTest_AssertCheck(
87.511 sresult == 10 || sresult == 11,
87.512 - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult);
87.513 + "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, sresult);
87.514
87.515 /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
87.516 sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 12, SDL_TRUE);
87.517 SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
87.518 SDLTest_AssertCheck(
87.519 sresult == 10 || sresult == 11 || sresult == 12,
87.520 - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult);
87.521 + "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, sresult);
87.522
87.523 /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
87.524 sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 13, SDL_TRUE);
87.525 SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
87.526 SDLTest_AssertCheck(
87.527 sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
87.528 - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult);
87.529 + "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, sresult);
87.530
87.531 /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
87.532 sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 20, SDL_TRUE);
87.533 SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
87.534 SDLTest_AssertCheck(
87.535 sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
87.536 - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
87.537 + "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult);
87.538
87.539 /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
87.540 sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(20, 10, SDL_TRUE);
87.541 SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
87.542 SDLTest_AssertCheck(
87.543 sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
87.544 - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
87.545 + "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult);
87.546
87.547 /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
87.548 sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(1, 20, SDL_FALSE);
87.549 SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
87.550 SDLTest_AssertCheck(
87.551 sresult == 0 || sresult == 21,
87.552 - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult);
87.553 + "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, sresult);
87.554
87.555 /* RandomSintXBoundaryValue(SHRT_MIN, 99, SDL_FALSE) returns 100 */
87.556 sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, 99, SDL_FALSE);
87.557 SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
87.558 SDLTest_AssertCheck(
87.559 sresult == 100,
87.560 - "Validate result value for parameters (SHRT_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult);
87.561 + "Validate result value for parameters (SHRT_MIN,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, sresult);
87.562
87.563 /* RandomSintXBoundaryValue(SHRT_MIN + 1, SHRT_MAX, SDL_FALSE) returns SHRT_MIN (no error) */
87.564 sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN + 1, SHRT_MAX, SDL_FALSE);
87.565 SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
87.566 SDLTest_AssertCheck(
87.567 sresult == SHRT_MIN,
87.568 - "Validate result value for parameters (SHRT_MIN+1,SHRT_MAX,SDL_FALSE); expected: %d, got: %lld", SHRT_MIN, sresult);
87.569 + "Validate result value for parameters (SHRT_MIN+1,SHRT_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SHRT_MIN, sresult);
87.570 lastError = (char *)SDL_GetError();
87.571 SDLTest_AssertPass("SDL_GetError()");
87.572 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
87.573 @@ -782,7 +782,7 @@
87.574 SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
87.575 SDLTest_AssertCheck(
87.576 sresult == SHRT_MAX,
87.577 - "Validate result value for parameters (SHRT_MIN,SHRT_MAX - 1,SDL_FALSE); expected: %d, got: %lld", SHRT_MAX, sresult);
87.578 + "Validate result value for parameters (SHRT_MIN,SHRT_MAX - 1,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SHRT_MAX, sresult);
87.579 lastError = (char *)SDL_GetError();
87.580 SDLTest_AssertPass("SDL_GetError()");
87.581 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
87.582 @@ -792,7 +792,7 @@
87.583 SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
87.584 SDLTest_AssertCheck(
87.585 sresult == SHRT_MIN,
87.586 - "Validate result value for parameters(SHRT_MIN,SHRT_MAX,SDL_FALSE); expected: %d, got: %lld", SHRT_MIN, sresult);
87.587 + "Validate result value for parameters(SHRT_MIN,SHRT_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SHRT_MIN, sresult);
87.588 lastError = (char *)SDL_GetError();
87.589 SDLTest_AssertPass("SDL_GetError()");
87.590 SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
87.591 @@ -833,63 +833,63 @@
87.592 SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
87.593 SDLTest_AssertCheck(
87.594 sresult == 10,
87.595 - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult);
87.596 + "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, sresult);
87.597
87.598 /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
87.599 sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 11, SDL_TRUE);
87.600 SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
87.601 SDLTest_AssertCheck(
87.602 sresult == 10 || sresult == 11,
87.603 - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult);
87.604 + "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, sresult);
87.605
87.606 /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
87.607 sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 12, SDL_TRUE);
87.608 SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
87.609 SDLTest_AssertCheck(
87.610 sresult == 10 || sresult == 11 || sresult == 12,
87.611 - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult);
87.612 + "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, sresult);
87.613
87.614 /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
87.615 sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 13, SDL_TRUE);
87.616 SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
87.617 SDLTest_AssertCheck(
87.618 sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
87.619 - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult);
87.620 + "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, sresult);
87.621
87.622 /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
87.623 sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 20, SDL_TRUE);
87.624 SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
87.625 SDLTest_AssertCheck(
87.626 sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
87.627 - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
87.628 + "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult);
87.629
87.630 /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
87.631 sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(20, 10, SDL_TRUE);
87.632 SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
87.633 SDLTest_AssertCheck(
87.634 sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
87.635 - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
87.636 + "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult);
87.637
87.638 /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
87.639 sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(1, 20, SDL_FALSE);
87.640 SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
87.641 SDLTest_AssertCheck(
87.642 sresult == 0 || sresult == 21,
87.643 - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult);
87.644 + "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, sresult);
87.645
87.646 /* RandomSintXBoundaryValue(LONG_MIN, 99, SDL_FALSE) returns 100 */
87.647 sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, 99, SDL_FALSE);
87.648 SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
87.649 SDLTest_AssertCheck(
87.650 sresult == 100,
87.651 - "Validate result value for parameters (LONG_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult);
87.652 + "Validate result value for parameters (LONG_MIN,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, sresult);
87.653
87.654 /* RandomSintXBoundaryValue(LONG_MIN + 1, LONG_MAX, SDL_FALSE) returns LONG_MIN (no error) */
87.655 sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min + 1, long_max, SDL_FALSE);
87.656 SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
87.657 SDLTest_AssertCheck(
87.658 sresult == long_min,
87.659 - "Validate result value for parameters (LONG_MIN+1,LONG_MAX,SDL_FALSE); expected: %d, got: %lld", long_min, sresult);
87.660 + "Validate result value for parameters (LONG_MIN+1,LONG_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, long_min, sresult);
87.661 lastError = (char *)SDL_GetError();
87.662 SDLTest_AssertPass("SDL_GetError()");
87.663 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
87.664 @@ -899,7 +899,7 @@
87.665 SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
87.666 SDLTest_AssertCheck(
87.667 sresult == long_max,
87.668 - "Validate result value for parameters (LONG_MIN,LONG_MAX - 1,SDL_FALSE); expected: %d, got: %lld", long_max, sresult);
87.669 + "Validate result value for parameters (LONG_MIN,LONG_MAX - 1,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, long_max, sresult);
87.670 lastError = (char *)SDL_GetError();
87.671 SDLTest_AssertPass("SDL_GetError()");
87.672 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
87.673 @@ -909,7 +909,7 @@
87.674 SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
87.675 SDLTest_AssertCheck(
87.676 sresult == long_min,
87.677 - "Validate result value for parameters(LONG_MIN,LONG_MAX,SDL_FALSE); expected: %d, got: %lld", long_min, sresult);
87.678 + "Validate result value for parameters(LONG_MIN,LONG_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, long_min, sresult);
87.679 lastError = (char *)SDL_GetError();
87.680 SDLTest_AssertPass("SDL_GetError()");
87.681 SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
87.682 @@ -943,63 +943,63 @@
87.683 SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
87.684 SDLTest_AssertCheck(
87.685 sresult == 10,
87.686 - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult);
87.687 + "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, sresult);
87.688
87.689 /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
87.690 sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 11, SDL_TRUE);
87.691 SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
87.692 SDLTest_AssertCheck(
87.693 sresult == 10 || sresult == 11,
87.694 - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult);
87.695 + "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, sresult);
87.696
87.697 /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
87.698 sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 12, SDL_TRUE);
87.699 SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
87.700 SDLTest_AssertCheck(
87.701 sresult == 10 || sresult == 11 || sresult == 12,
87.702 - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult);
87.703 + "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, sresult);
87.704
87.705 /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
87.706 sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 13, SDL_TRUE);
87.707 SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
87.708 SDLTest_AssertCheck(
87.709 sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
87.710 - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult);
87.711 + "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, sresult);
87.712
87.713 /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
87.714 sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 20, SDL_TRUE);
87.715 SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
87.716 SDLTest_AssertCheck(
87.717 sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
87.718 - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
87.719 + "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult);
87.720
87.721 /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
87.722 sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(20, 10, SDL_TRUE);
87.723 SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
87.724 SDLTest_AssertCheck(
87.725 sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
87.726 - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
87.727 + "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult);
87.728
87.729 /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
87.730 sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(1, 20, SDL_FALSE);
87.731 SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
87.732 SDLTest_AssertCheck(
87.733 sresult == 0 || sresult == 21,
87.734 - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult);
87.735 + "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, sresult);
87.736
87.737 /* RandomSintXBoundaryValue(LLONG_MIN, 99, SDL_FALSE) returns 100 */
87.738 sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN, 99, SDL_FALSE);
87.739 SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
87.740 SDLTest_AssertCheck(
87.741 sresult == 100,
87.742 - "Validate result value for parameters (LLONG_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult);
87.743 + "Validate result value for parameters (LLONG_MIN,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, sresult);
87.744
87.745 /* RandomSintXBoundaryValue(LLONG_MIN + 1, LLONG_MAX, SDL_FALSE) returns LLONG_MIN (no error) */
87.746 sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN + 1, LLONG_MAX, SDL_FALSE);
87.747 SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
87.748 SDLTest_AssertCheck(
87.749 sresult == LLONG_MIN,
87.750 - "Validate result value for parameters (LLONG_MIN+1,LLONG_MAX,SDL_FALSE); expected: %lld, got: %lld", LLONG_MIN, sresult);
87.751 + "Validate result value for parameters (LLONG_MIN+1,LLONG_MAX,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, LLONG_MIN, sresult);
87.752 lastError = (char *)SDL_GetError();
87.753 SDLTest_AssertPass("SDL_GetError()");
87.754 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
87.755 @@ -1009,7 +1009,7 @@
87.756 SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
87.757 SDLTest_AssertCheck(
87.758 sresult == LLONG_MAX,
87.759 - "Validate result value for parameters (LLONG_MIN,LLONG_MAX - 1,SDL_FALSE); expected: %lld, got: %lld", LLONG_MAX, sresult);
87.760 + "Validate result value for parameters (LLONG_MIN,LLONG_MAX - 1,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, LLONG_MAX, sresult);
87.761 lastError = (char *)SDL_GetError();
87.762 SDLTest_AssertPass("SDL_GetError()");
87.763 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
87.764 @@ -1019,7 +1019,7 @@
87.765 SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
87.766 SDLTest_AssertCheck(
87.767 sresult == LLONG_MIN,
87.768 - "Validate result value for parameters(LLONG_MIN,LLONG_MAX,SDL_FALSE); expected: %lld, got: %lld", LLONG_MIN, sresult);
87.769 + "Validate result value for parameters(LLONG_MIN,LLONG_MAX,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, LLONG_MIN, sresult);
87.770 lastError = (char *)SDL_GetError();
87.771 SDLTest_AssertPass("SDL_GetError()");
87.772 SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
88.1 --- a/test/testautomation_surface.c Thu Jan 15 01:06:14 2015 -0400
88.2 +++ b/test/testautomation_surface.c Thu Jan 15 01:15:24 2015 -0400
88.3 @@ -8,6 +8,9 @@
88.4 #define _CRT_NONSTDC_NO_DEPRECATE
88.5
88.6 #include <stdio.h>
88.7 +#ifndef _MSC_VER
88.8 +#include <unistd.h>
88.9 +#endif
88.10 #include <sys/stat.h>
88.11
88.12 #include "SDL.h"
89.1 --- a/test/testautomation_timer.c Thu Jan 15 01:06:14 2015 -0400
89.2 +++ b/test/testautomation_timer.c Thu Jan 15 01:15:24 2015 -0400
89.3 @@ -42,7 +42,7 @@
89.4
89.5 result = SDL_GetPerformanceCounter();
89.6 SDLTest_AssertPass("Call to SDL_GetPerformanceCounter()");
89.7 - SDLTest_AssertCheck(result > 0, "Check result value, expected: >0, got: %llu", result);
89.8 + SDLTest_AssertCheck(result > 0, "Check result value, expected: >0, got: %"SDL_PRIu64, result);
89.9
89.10 return TEST_COMPLETED;
89.11 }
89.12 @@ -57,7 +57,7 @@
89.13
89.14 result = SDL_GetPerformanceFrequency();
89.15 SDLTest_AssertPass("Call to SDL_GetPerformanceFrequency()");
89.16 - SDLTest_AssertCheck(result > 0, "Check result value, expected: >0, got: %llu", result);
89.17 + SDLTest_AssertCheck(result > 0, "Check result value, expected: >0, got: %"SDL_PRIu64, result);
89.18
89.19 return TEST_COMPLETED;
89.20 }
90.1 --- a/test/testdraw2.c Thu Jan 15 01:06:14 2015 -0400
90.2 +++ b/test/testdraw2.c Thu Jan 15 01:15:24 2015 -0400
90.3 @@ -16,6 +16,10 @@
90.4 #include <stdio.h>
90.5 #include <time.h>
90.6
90.7 +#ifdef __EMSCRIPTEN__
90.8 +#include <emscripten/emscripten.h>
90.9 +#endif
90.10 +
90.11 #include "SDL_test_common.h"
90.12
90.13 #define NUM_OBJECTS 100
90.14 @@ -29,6 +33,8 @@
90.15 static int current_color = 255;
90.16 static SDL_BlendMode blendMode = SDL_BLENDMODE_NONE;
90.17
90.18 +int done;
90.19 +
90.20 void
90.21 DrawPoints(SDL_Renderer * renderer)
90.22 {
90.23 @@ -169,11 +175,35 @@
90.24 }
90.25 }
90.26
90.27 +void
90.28 +loop()
90.29 +{
90.30 + int i;
90.31 + SDL_Event event;
90.32 +
90.33 + /* Check for events */
90.34 + while (SDL_PollEvent(&event)) {
90.35 + SDLTest_CommonEvent(state, &event, &done);
90.36 + }
90.37 + for (i = 0; i < state->num_windows; ++i) {
90.38 + SDL_Renderer *renderer = state->renderers[i];
90.39 + if (state->windows[i] == NULL)
90.40 + continue;
90.41 + SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
90.42 + SDL_RenderClear(renderer);
90.43 +
90.44 + DrawRects(renderer);
90.45 + DrawLines(renderer);
90.46 + DrawPoints(renderer);
90.47 +
90.48 + SDL_RenderPresent(renderer);
90.49 + }
90.50 +}
90.51 +
90.52 int
90.53 main(int argc, char *argv[])
90.54 {
90.55 - int i, done;
90.56 - SDL_Event event;
90.57 + int i;
90.58 Uint32 then, now, frames;
90.59
90.60 /* Enable standard application logging */
90.61 @@ -245,26 +275,16 @@
90.62 frames = 0;
90.63 then = SDL_GetTicks();
90.64 done = 0;
90.65 +
90.66 +#ifdef __EMSCRIPTEN__
90.67 + emscripten_set_main_loop(loop, 0, 1);
90.68 +#else
90.69 while (!done) {
90.70 - /* Check for events */
90.71 ++frames;
90.72 - while (SDL_PollEvent(&event)) {
90.73 - SDLTest_CommonEvent(state, &event, &done);
90.74 + loop();
90.75 }
90.76 - for (i = 0; i < state->num_windows; ++i) {
90.77 - SDL_Renderer *renderer = state->renderers[i];
90.78 - if (state->windows[i] == NULL)
90.79 - continue;
90.80 - SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
90.81 - SDL_RenderClear(renderer);
90.82 +#endif
90.83
90.84 - DrawRects(renderer);
90.85 - DrawLines(renderer);
90.86 - DrawPoints(renderer);
90.87 -
90.88 - SDL_RenderPresent(renderer);
90.89 - }
90.90 - }
90.91
90.92 SDLTest_CommonQuit(state);
90.93
91.1 --- a/test/testdrawchessboard.c Thu Jan 15 01:06:14 2015 -0400
91.2 +++ b/test/testdrawchessboard.c Thu Jan 15 01:15:24 2015 -0400
91.3 @@ -14,8 +14,19 @@
91.4
91.5 /* Sample program: Draw a Chess Board by using SDL_CreateSoftwareRenderer API */
91.6
91.7 +#include <stdlib.h>
91.8 +#include <stdio.h>
91.9 +
91.10 +#ifdef __EMSCRIPTEN__
91.11 +#include <emscripten/emscripten.h>
91.12 +#endif
91.13 +
91.14 #include "SDL.h"
91.15
91.16 +SDL_Window *window;
91.17 +SDL_Renderer *renderer;
91.18 +int done;
91.19 +
91.20 void
91.21 DrawChessBoard(SDL_Renderer * renderer)
91.22 {
91.23 @@ -44,12 +55,33 @@
91.24 }
91.25 }
91.26
91.27 +void
91.28 +loop()
91.29 +{
91.30 + SDL_Event e;
91.31 + if (SDL_PollEvent(&e)) {
91.32 + if (e.type == SDL_QUIT) {
91.33 + done = 1;
91.34 + return;
91.35 + }
91.36 +
91.37 + if(e.key.keysym.sym == SDLK_ESCAPE) {
91.38 + done = 1;
91.39 + return;
91.40 + }
91.41 + }
91.42 +
91.43 + DrawChessBoard(renderer);
91.44 +
91.45 + /* Got everything on rendering surface,
91.46 + now Update the drawing image on window screen */
91.47 + SDL_UpdateWindowSurface(window);
91.48 +}
91.49 +
91.50 int
91.51 main(int argc, char *argv[])
91.52 {
91.53 - SDL_Window *window;
91.54 SDL_Surface *surface;
91.55 - SDL_Renderer *renderer;
91.56
91.57 /* Enable standard application logging */
91.58 SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
91.59 @@ -83,24 +115,14 @@
91.60
91.61
91.62 /* Draw the Image on rendering surface */
91.63 - while(1)
91.64 - {
91.65 - SDL_Event e;
91.66 - if (SDL_PollEvent(&e)) {
91.67 - if (e.type == SDL_QUIT)
91.68 - break;
91.69 -
91.70 - if(e.key.keysym.sym == SDLK_ESCAPE)
91.71 - break;
91.72 - }
91.73 -
91.74 - DrawChessBoard(renderer);
91.75 -
91.76 - /* Got everything on rendering surface,
91.77 - now Update the drawing image on window screen */
91.78 - SDL_UpdateWindowSurface(window);
91.79 -
91.80 + done = 0;
91.81 +#ifdef __EMSCRIPTEN__
91.82 + emscripten_set_main_loop(loop, 0, 1);
91.83 +#else
91.84 + while (!done) {
91.85 + loop();
91.86 }
91.87 +#endif
91.88
91.89 return 0;
91.90 }
92.1 --- a/test/testfilesystem.c Thu Jan 15 01:06:14 2015 -0400
92.2 +++ b/test/testfilesystem.c Thu Jan 15 01:15:24 2015 -0400
92.3 @@ -25,6 +25,25 @@
92.4 return 1;
92.5 }
92.6
92.7 + char *base_path = SDL_GetBasePath();
92.8 + if(base_path == NULL){
92.9 + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find base path: %s\n",
92.10 + SDL_GetError());
92.11 + return 0;
92.12 + }
92.13 +
92.14 + SDL_Log("base path: '%s'\n", SDL_GetBasePath());
92.15 + SDL_free(base_path);
92.16 +
92.17 + char *pref_path = SDL_GetPrefPath("libsdl", "testfilesystem");
92.18 + if(pref_path == NULL){
92.19 + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find pref path: %s\n",
92.20 + SDL_GetError());
92.21 + return 0;
92.22 + }
92.23 + SDL_Log("pref path: '%s'\n", SDL_GetPrefPath("libsdl", "testfilesystem"));
92.24 + SDL_free(pref_path);
92.25 +
92.26 SDL_Log("base path: '%s'\n", SDL_GetBasePath());
92.27 SDL_Log("pref path: '%s'\n", SDL_GetPrefPath("libsdl", "testfilesystem"));
92.28
93.1 --- a/test/testgamecontroller.c Thu Jan 15 01:06:14 2015 -0400
93.2 +++ b/test/testgamecontroller.c Thu Jan 15 01:15:24 2015 -0400
93.3 @@ -18,6 +18,10 @@
93.4
93.5 #include "SDL.h"
93.6
93.7 +#ifdef __EMSCRIPTEN__
93.8 +#include <emscripten/emscripten.h>
93.9 +#endif
93.10 +
93.11 #ifndef SDL_JOYSTICK_DISABLED
93.12
93.13 #ifdef __IPHONEOS__
93.14 @@ -28,6 +32,40 @@
93.15 #define SCREEN_HEIGHT 317
93.16 #endif
93.17
93.18 +/* This is indexed by SDL_GameControllerButton. */
93.19 +static const struct { int x; int y; } button_positions[] = {
93.20 + {387, 167}, /* A */
93.21 + {431, 132}, /* B */
93.22 + {342, 132}, /* X */
93.23 + {389, 101}, /* Y */
93.24 + {174, 132}, /* BACK */
93.25 + {233, 132}, /* GUIDE */
93.26 + {289, 132}, /* START */
93.27 + {75, 154}, /* LEFTSTICK */
93.28 + {305, 230}, /* RIGHTSTICK */
93.29 + {77, 40}, /* LEFTSHOULDER */
93.30 + {396, 36}, /* RIGHTSHOULDER */
93.31 + {154, 188}, /* DPAD_UP */
93.32 + {154, 249}, /* DPAD_DOWN */
93.33 + {116, 217}, /* DPAD_LEFT */
93.34 + {186, 217}, /* DPAD_RIGHT */
93.35 +};
93.36 +
93.37 +/* This is indexed by SDL_GameControllerAxis. */
93.38 +static const struct { int x; int y; double angle; } axis_positions[] = {
93.39 + {75, 154, 0.0}, /* LEFTX */
93.40 + {75, 154, 90.0}, /* LEFTY */
93.41 + {305, 230, 0.0}, /* RIGHTX */
93.42 + {305, 230, 90.0}, /* RIGHTY */
93.43 + {91, 0, 90.0}, /* TRIGGERLEFT */
93.44 + {375, 0, 90.0}, /* TRIGGERRIGHT */
93.45 +};
93.46 +
93.47 +SDL_Renderer *screen = NULL;
93.48 +SDL_bool retval = SDL_FALSE;
93.49 +SDL_bool done = SDL_FALSE;
93.50 +SDL_Texture *background, *button, *axis;
93.51 +
93.52 static SDL_Texture *
93.53 LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent)
93.54 {
93.55 @@ -60,50 +98,71 @@
93.56 return texture;
93.57 }
93.58
93.59 +void
93.60 +loop(void *arg)
93.61 +{
93.62 + SDL_Event event;
93.63 + int i;
93.64 + SDL_GameController *gamecontroller = (SDL_GameController *)arg;
93.65 +
93.66 + /* blank screen, set up for drawing this frame. */
93.67 + SDL_SetRenderDrawColor(screen, 0xFF, 0xFF, 0xFF, SDL_ALPHA_OPAQUE);
93.68 + SDL_RenderClear(screen);
93.69 + SDL_RenderCopy(screen, background, NULL, NULL);
93.70 +
93.71 + while (SDL_PollEvent(&event)) {
93.72 + switch (event.type) {
93.73 + case SDL_KEYDOWN:
93.74 + if (event.key.keysym.sym != SDLK_ESCAPE) {
93.75 + break;
93.76 + }
93.77 + /* Fall through to signal quit */
93.78 + case SDL_QUIT:
93.79 + done = SDL_TRUE;
93.80 + break;
93.81 + default:
93.82 + break;
93.83 + }
93.84 + }
93.85 +
93.86 + /* Update visual controller state */
93.87 + for (i = 0; i < SDL_CONTROLLER_BUTTON_MAX; ++i) {
93.88 + if (SDL_GameControllerGetButton(gamecontroller, (SDL_GameControllerButton)i) == SDL_PRESSED) {
93.89 + const SDL_Rect dst = { button_positions[i].x, button_positions[i].y, 50, 50 };
93.90 + SDL_RenderCopyEx(screen, button, NULL, &dst, 0, NULL, 0);
93.91 + }
93.92 + }
93.93 +
93.94 + for (i = 0; i < SDL_CONTROLLER_AXIS_MAX; ++i) {
93.95 + const Sint16 deadzone = 8000; /* !!! FIXME: real deadzone */
93.96 + const Sint16 value = SDL_GameControllerGetAxis(gamecontroller, (SDL_GameControllerAxis)(i));
93.97 + if (value < -deadzone) {
93.98 + const SDL_Rect dst = { axis_positions[i].x, axis_positions[i].y, 50, 50 };
93.99 + const double angle = axis_positions[i].angle;
93.100 + SDL_RenderCopyEx(screen, axis, NULL, &dst, angle, NULL, 0);
93.101 + } else if (value > deadzone) {
93.102 + const SDL_Rect dst = { axis_positions[i].x, axis_positions[i].y, 50, 50 };
93.103 + const double angle = axis_positions[i].angle + 180.0;
93.104 + SDL_RenderCopyEx(screen, axis, NULL, &dst, angle, NULL, 0);
93.105 + }
93.106 + }
93.107 +
93.108 + SDL_RenderPresent(screen);
93.109 +
93.110 + if (!SDL_GameControllerGetAttached(gamecontroller)) {
93.111 + done = SDL_TRUE;
93.112 + retval = SDL_TRUE; /* keep going, wait for reattach. */
93.113 + }
93.114 +}
93.115 +
93.116 SDL_bool
93.117 WatchGameController(SDL_GameController * gamecontroller)
93.118 {
93.119 - /* This is indexed by SDL_GameControllerButton. */
93.120 - static const struct { int x; int y; } button_positions[] = {
93.121 - {387, 167}, /* A */
93.122 - {431, 132}, /* B */
93.123 - {342, 132}, /* X */
93.124 - {389, 101}, /* Y */
93.125 - {174, 132}, /* BACK */
93.126 - {233, 132}, /* GUIDE */
93.127 - {289, 132}, /* START */
93.128 - {75, 154}, /* LEFTSTICK */
93.129 - {305, 230}, /* RIGHTSTICK */
93.130 - {77, 40}, /* LEFTSHOULDER */
93.131 - {396, 36}, /* RIGHTSHOULDER */
93.132 - {154, 188}, /* DPAD_UP */
93.133 - {154, 249}, /* DPAD_DOWN */
93.134 - {116, 217}, /* DPAD_LEFT */
93.135 - {186, 217}, /* DPAD_RIGHT */
93.136 - };
93.137 -
93.138 - /* This is indexed by SDL_GameControllerAxis. */
93.139 - static const struct { int x; int y; double angle; } axis_positions[] = {
93.140 - {75, 154, 0.0}, /* LEFTX */
93.141 - {75, 154, 90.0}, /* LEFTY */
93.142 - {305, 230, 0.0}, /* RIGHTX */
93.143 - {305, 230, 90.0}, /* RIGHTY */
93.144 - {91, 0, 90.0}, /* TRIGGERLEFT */
93.145 - {375, 0, 90.0}, /* TRIGGERRIGHT */
93.146 - };
93.147 -
93.148 const char *name = SDL_GameControllerName(gamecontroller);
93.149 const char *basetitle = "Game Controller Test: ";
93.150 const size_t titlelen = SDL_strlen(basetitle) + SDL_strlen(name) + 1;
93.151 char *title = (char *)SDL_malloc(titlelen);
93.152 - SDL_Texture *background, *button, *axis;
93.153 SDL_Window *window = NULL;
93.154 - SDL_Renderer *screen = NULL;
93.155 - SDL_bool retval = SDL_FALSE;
93.156 - SDL_bool done = SDL_FALSE;
93.157 - SDL_Event event;
93.158 - int i;
93.159 -
93.160 if (title) {
93.161 SDL_snprintf(title, titlelen, "%s%s", basetitle, name);
93.162 }
93.163 @@ -151,56 +210,13 @@
93.164 SDL_Log("Watching controller %s\n", name ? name : "Unknown Controller");
93.165
93.166 /* Loop, getting controller events! */
93.167 +#ifdef __EMSCRIPTEN__
93.168 + emscripten_set_main_loop_arg(loop, gamecontroller, 0, 1);
93.169 +#else
93.170 while (!done) {
93.171 - /* blank screen, set up for drawing this frame. */
93.172 - SDL_SetRenderDrawColor(screen, 0xFF, 0xFF, 0xFF, SDL_ALPHA_OPAQUE);
93.173 - SDL_RenderClear(screen);
93.174 - SDL_RenderCopy(screen, background, NULL, NULL);
93.175 -
93.176 - while (SDL_PollEvent(&event)) {
93.177 - switch (event.type) {
93.178 - case SDL_KEYDOWN:
93.179 - if (event.key.keysym.sym != SDLK_ESCAPE) {
93.180 - break;
93.181 - }
93.182 - /* Fall through to signal quit */
93.183 - case SDL_QUIT:
93.184 - done = SDL_TRUE;
93.185 - break;
93.186 - default:
93.187 - break;
93.188 - }
93.189 - }
93.190 -
93.191 - /* Update visual controller state */
93.192 - for (i = 0; i < SDL_CONTROLLER_BUTTON_MAX; ++i) {
93.193 - if (SDL_GameControllerGetButton(gamecontroller, (SDL_GameControllerButton)i) == SDL_PRESSED) {
93.194 - const SDL_Rect dst = { button_positions[i].x, button_positions[i].y, 50, 50 };
93.195 - SDL_RenderCopyEx(screen, button, NULL, &dst, 0, NULL, 0);
93.196 - }
93.197 - }
93.198 -
93.199 - for (i = 0; i < SDL_CONTROLLER_AXIS_MAX; ++i) {
93.200 - const Sint16 deadzone = 8000; /* !!! FIXME: real deadzone */
93.201 - const Sint16 value = SDL_GameControllerGetAxis(gamecontroller, (SDL_GameControllerAxis)(i));
93.202 - if (value < -deadzone) {
93.203 - const SDL_Rect dst = { axis_positions[i].x, axis_positions[i].y, 50, 50 };
93.204 - const double angle = axis_positions[i].angle;
93.205 - SDL_RenderCopyEx(screen, axis, NULL, &dst, angle, NULL, 0);
93.206 - } else if (value > deadzone) {
93.207 - const SDL_Rect dst = { axis_positions[i].x, axis_positions[i].y, 50, 50 };
93.208 - const double angle = axis_positions[i].angle + 180.0;
93.209 - SDL_RenderCopyEx(screen, axis, NULL, &dst, angle, NULL, 0);
93.210 - }
93.211 - }
93.212 -
93.213 - SDL_RenderPresent(screen);
93.214 -
93.215 - if (!SDL_GameControllerGetAttached(gamecontroller)) {
93.216 - done = SDL_TRUE;
93.217 - retval = SDL_TRUE; /* keep going, wait for reattach. */
93.218 - }
93.219 + loop(gamecontroller);
93.220 }
93.221 +#endif
93.222
93.223 SDL_DestroyRenderer(screen);
93.224 SDL_DestroyWindow(window);
94.1 --- a/test/testgesture.c Thu Jan 15 01:06:14 2015 -0400
94.2 +++ b/test/testgesture.c Thu Jan 15 01:15:24 2015 -0400
94.3 @@ -15,12 +15,11 @@
94.4 * l to load all touches from "./gestureSave"
94.5 */
94.6
94.7 -#include <stdio.h>
94.8 -#include <math.h>
94.9 +#include "SDL.h"
94.10
94.11 -#include "SDL.h"
94.12 -#include "SDL_touch.h"
94.13 -#include "SDL_gesture.h"
94.14 +#ifdef __EMSCRIPTEN__
94.15 +#include <emscripten/emscripten.h>
94.16 +#endif
94.17
94.18 #define WIDTH 640
94.19 #define HEIGHT 480
94.20 @@ -33,13 +32,16 @@
94.21
94.22 #define VERBOSE 0
94.23
94.24 -static SDL_Window *window;
94.25 static SDL_Event events[EVENT_BUF_SIZE];
94.26 static int eventWrite;
94.27
94.28
94.29 static int colors[7] = {0xFF,0xFF00,0xFF0000,0xFFFF00,0x00FFFF,0xFF00FF,0xFFFFFF};
94.30
94.31 +SDL_Surface *screen;
94.32 +SDL_Window *window;
94.33 +SDL_bool quitting = SDL_FALSE;
94.34 +
94.35 typedef struct {
94.36 float x,y;
94.37 } Point;
94.38 @@ -51,18 +53,6 @@
94.39
94.40 static Knob knob;
94.41
94.42 -void handler (int sig)
94.43 -{
94.44 - SDL_Log ("exiting...(%d)", sig);
94.45 - exit (0);
94.46 -}
94.47 -
94.48 -void perror_exit (char *error)
94.49 -{
94.50 - perror (error);
94.51 - handler (9);
94.52 -}
94.53 -
94.54 void setpix(SDL_Surface *screen, float _x, float _y, unsigned int col)
94.55 {
94.56 Uint32 *pixmem32;
94.57 @@ -104,7 +94,7 @@
94.58 float tx,ty;
94.59 float xr;
94.60 for(ty = (float)-SDL_fabs(r);ty <= (float)SDL_fabs((int)r);ty++) {
94.61 - xr = (float)sqrt(r*r - ty*ty);
94.62 + xr = (float)SDL_sqrt(r*r - ty*ty);
94.63 if(r > 0) { /* r > 0 ==> filled circle */
94.64 for(tx=-xr+.5f;tx<=xr-.5;tx++) {
94.65 setpix(screen,x+tx,y+ty,c);
94.66 @@ -123,7 +113,7 @@
94.67 (k.p.y+k.r/2*SDL_sinf(k.ang))*screen->h,k.r/4*screen->w,0);
94.68 }
94.69
94.70 -void DrawScreen(SDL_Surface* screen)
94.71 +void DrawScreen(SDL_Surface* screen, SDL_Window* window)
94.72 {
94.73 int i;
94.74 #if 1
94.75 @@ -165,44 +155,24 @@
94.76 SDL_UpdateWindowSurface(window);
94.77 }
94.78
94.79 -SDL_Surface* initScreen(int width,int height)
94.80 +/* Returns a new SDL_Window if window is NULL or window if not. */
94.81 +SDL_Window* initWindow(SDL_Window *window, int width,int height)
94.82 {
94.83 if (!window) {
94.84 window = SDL_CreateWindow("Gesture Test",
94.85 SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
94.86 width, height, SDL_WINDOW_RESIZABLE);
94.87 }
94.88 - if (!window) {
94.89 - return NULL;
94.90 - }
94.91 - return SDL_GetWindowSurface(window);
94.92 + return window;
94.93 }
94.94
94.95 -int main(int argc, char* argv[])
94.96 +void loop()
94.97 {
94.98 - SDL_Surface *screen;
94.99 - SDL_Event event;
94.100 - SDL_bool quitting = SDL_FALSE;
94.101 - SDL_RWops *stream;
94.102 -
94.103 - /* Enable standard application logging */
94.104 - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
94.105 + SDL_Event event;
94.106 + SDL_RWops *stream;
94.107
94.108 - /* gesture variables */
94.109 - knob.r = .1f;
94.110 - knob.ang = 0;
94.111 -
94.112 - if (SDL_Init(SDL_INIT_VIDEO) < 0 ) return 1;
94.113 -
94.114 - if (!(screen = initScreen(WIDTH,HEIGHT)))
94.115 + while(SDL_PollEvent(&event))
94.116 {
94.117 - SDL_Quit();
94.118 - return 1;
94.119 - }
94.120 -
94.121 - while(!quitting) {
94.122 - while(SDL_PollEvent(&event))
94.123 - {
94.124 /* Record _all_ events */
94.125 events[eventWrite & (EVENT_BUF_SIZE-1)] = event;
94.126 eventWrite++;
94.127 @@ -244,10 +214,11 @@
94.128 break;
94.129 case SDL_WINDOWEVENT:
94.130 if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
94.131 - if (!(screen = initScreen(event.window.data1, event.window.data2)))
94.132 + if (!(window = initWindow(window, event.window.data1, event.window.data2)) ||
94.133 + !(screen = SDL_GetWindowSurface(window)))
94.134 {
94.135 SDL_Quit();
94.136 - return 1;
94.137 + exit(1);
94.138 }
94.139 }
94.140 break;
94.141 @@ -292,9 +263,40 @@
94.142 SDL_Log("Recorded gesture: %"SDL_PRIs64"",event.dgesture.gestureId);
94.143 break;
94.144 }
94.145 - }
94.146 - DrawScreen(screen);
94.147 + }
94.148 + DrawScreen(screen, window);
94.149 +}
94.150 +
94.151 +int main(int argc, char* argv[])
94.152 +{
94.153 + window = NULL;
94.154 + screen = NULL;
94.155 + quitting = SDL_FALSE;
94.156 +
94.157 + /* Enable standard application logging */
94.158 + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
94.159 +
94.160 + /* gesture variables */
94.161 + knob.r = .1f;
94.162 + knob.ang = 0;
94.163 +
94.164 + if (SDL_Init(SDL_INIT_VIDEO) < 0 ) return 1;
94.165 +
94.166 + if (!(window = initWindow(window, WIDTH, HEIGHT)) ||
94.167 + !(screen = SDL_GetWindowSurface(window)))
94.168 + {
94.169 + SDL_Quit();
94.170 + return 1;
94.171 }
94.172 +
94.173 +#ifdef __EMSCRIPTEN__
94.174 + emscripten_set_main_loop(loop, 0, 1);
94.175 +#else
94.176 + while(!quitting) {
94.177 + loop();
94.178 + }
94.179 +#endif
94.180 +
94.181 SDL_Quit();
94.182 return 0;
94.183 }
95.1 --- a/test/testgles2.c Thu Jan 15 01:06:14 2015 -0400
95.2 +++ b/test/testgles2.c Thu Jan 15 01:15:24 2015 -0400
95.3 @@ -14,6 +14,10 @@
95.4 #include <string.h>
95.5 #include <math.h>
95.6
95.7 +#ifdef __EMSCRIPTEN__
95.8 +#include <emscripten/emscripten.h>
95.9 +#endif
95.10 +
95.11 #include "SDL_test_common.h"
95.12
95.13 #if defined(__IPHONEOS__) || defined(__ANDROID__) || defined(__NACL__)
95.14 @@ -408,17 +412,72 @@
95.15 GL_CHECK(ctx.glDrawArrays(GL_TRIANGLES, 0, 36));
95.16 }
95.17
95.18 +int done;
95.19 +Uint32 frames;
95.20 +shader_data *datas;
95.21 +
95.22 +void loop()
95.23 +{
95.24 + SDL_Event event;
95.25 + int i;
95.26 + int status;
95.27 +
95.28 + /* Check for events */
95.29 + ++frames;
95.30 + while (SDL_PollEvent(&event) && !done) {
95.31 + switch (event.type) {
95.32 + case SDL_WINDOWEVENT:
95.33 + switch (event.window.event) {
95.34 + case SDL_WINDOWEVENT_RESIZED:
95.35 + for (i = 0; i < state->num_windows; ++i) {
95.36 + if (event.window.windowID == SDL_GetWindowID(state->windows[i])) {
95.37 + int w, h;
95.38 + status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
95.39 + if (status) {
95.40 + SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
95.41 + break;
95.42 + }
95.43 + /* Change view port to the new window dimensions */
95.44 + SDL_GL_GetDrawableSize(state->windows[i], &w, &h);
95.45 + ctx.glViewport(0, 0, w, h);
95.46 + state->window_w = event.window.data1;
95.47 + state->window_h = event.window.data2;
95.48 + /* Update window content */
95.49 + Render(event.window.data1, event.window.data2, &datas[i]);
95.50 + SDL_GL_SwapWindow(state->windows[i]);
95.51 + break;
95.52 + }
95.53 + }
95.54 + break;
95.55 + }
95.56 + }
95.57 + SDLTest_CommonEvent(state, &event, &done);
95.58 + }
95.59 + if (!done) {
95.60 + for (i = 0; i < state->num_windows; ++i) {
95.61 + status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
95.62 + if (status) {
95.63 + SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
95.64 +
95.65 + /* Continue for next window */
95.66 + continue;
95.67 + }
95.68 + Render(state->window_w, state->window_h, &datas[i]);
95.69 + SDL_GL_SwapWindow(state->windows[i]);
95.70 + }
95.71 + }
95.72 +}
95.73 +
95.74 int
95.75 main(int argc, char *argv[])
95.76 {
95.77 int fsaa, accel;
95.78 int value;
95.79 - int i, done;
95.80 + int i;
95.81 SDL_DisplayMode mode;
95.82 - SDL_Event event;
95.83 - Uint32 then, now, frames;
95.84 + Uint32 then, now;
95.85 int status;
95.86 - shader_data *datas, *data;
95.87 + shader_data *data;
95.88
95.89 /* Initialize parameters */
95.90 fsaa = 0;
95.91 @@ -581,6 +640,7 @@
95.92 /* Set rendering settings for each context */
95.93 for (i = 0; i < state->num_windows; ++i) {
95.94
95.95 + int w, h;
95.96 status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
95.97 if (status) {
95.98 SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
95.99 @@ -588,7 +648,8 @@
95.100 /* Continue for next window */
95.101 continue;
95.102 }
95.103 - ctx.glViewport(0, 0, state->window_w, state->window_h);
95.104 + SDL_GL_GetDrawableSize(state->windows[i], &w, &h);
95.105 + ctx.glViewport(0, 0, w, h);
95.106
95.107 data = &datas[i];
95.108 data->angle_x = 0; data->angle_y = 0; data->angle_z = 0;
95.109 @@ -630,48 +691,14 @@
95.110 frames = 0;
95.111 then = SDL_GetTicks();
95.112 done = 0;
95.113 +
95.114 +#ifdef __EMSCRIPTEN__
95.115 + emscripten_set_main_loop(loop, 0, 1);
95.116 +#else
95.117 while (!done) {
95.118 - /* Check for events */
95.119 - ++frames;
95.120 - while (SDL_PollEvent(&event) && !done) {
95.121 - switch (event.type) {
95.122 - case SDL_WINDOWEVENT:
95.123 - switch (event.window.event) {
95.124 - case SDL_WINDOWEVENT_RESIZED:
95.125 - for (i = 0; i < state->num_windows; ++i) {
95.126 - if (event.window.windowID == SDL_GetWindowID(state->windows[i])) {
95.127 - status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
95.128 - if (status) {
95.129 - SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
95.130 - break;
95.131 - }
95.132 - /* Change view port to the new window dimensions */
95.133 - ctx.glViewport(0, 0, event.window.data1, event.window.data2);
95.134 - /* Update window content */
95.135 - Render(event.window.data1, event.window.data2, &datas[i]);
95.136 - SDL_GL_SwapWindow(state->windows[i]);
95.137 - break;
95.138 - }
95.139 - }
95.140 - break;
95.141 - }
95.142 - }
95.143 - SDLTest_CommonEvent(state, &event, &done);
95.144 - }
95.145 - if (!done) {
95.146 - for (i = 0; i < state->num_windows; ++i) {
95.147 - status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
95.148 - if (status) {
95.149 - SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
95.150 -
95.151 - /* Continue for next window */
95.152 - continue;
95.153 - }
95.154 - Render(state->window_w, state->window_h, &datas[i]);
95.155 - SDL_GL_SwapWindow(state->windows[i]);
95.156 - }
95.157 - }
95.158 + loop();
95.159 }
95.160 +#endif
95.161
95.162 /* Print out some timing information */
95.163 now = SDL_GetTicks();
96.1 --- a/test/testintersections.c Thu Jan 15 01:06:14 2015 -0400
96.2 +++ b/test/testintersections.c Thu Jan 15 01:15:24 2015 -0400
96.3 @@ -16,6 +16,10 @@
96.4 #include <stdio.h>
96.5 #include <time.h>
96.6
96.7 +#ifdef __EMSCRIPTEN__
96.8 +#include <emscripten/emscripten.h>
96.9 +#endif
96.10 +
96.11 #include "SDL_test_common.h"
96.12
96.13 #define SWAP(typ,a,b) do{typ t=a;a=b;b=t;}while(0)
96.14 @@ -30,6 +34,9 @@
96.15 static int current_color = 255;
96.16 static SDL_BlendMode blendMode = SDL_BLENDMODE_NONE;
96.17
96.18 +int mouse_begin_x = -1, mouse_begin_y = -1;
96.19 +int done;
96.20 +
96.21 void
96.22 DrawPoints(SDL_Renderer * renderer)
96.23 {
96.24 @@ -191,12 +198,71 @@
96.25 }
96.26 }
96.27
96.28 +void
96.29 +loop()
96.30 +{
96.31 + int i;
96.32 + SDL_Event event;
96.33 +
96.34 + /* Check for events */
96.35 + while (SDL_PollEvent(&event)) {
96.36 + SDLTest_CommonEvent(state, &event, &done);
96.37 + switch (event.type) {
96.38 + case SDL_MOUSEBUTTONDOWN:
96.39 + mouse_begin_x = event.button.x;
96.40 + mouse_begin_y = event.button.y;
96.41 + break;
96.42 + case SDL_MOUSEBUTTONUP:
96.43 + if (event.button.button == 3)
96.44 + add_line(mouse_begin_x, mouse_begin_y, event.button.x,
96.45 + event.button.y);
96.46 + if (event.button.button == 1)
96.47 + add_rect(mouse_begin_x, mouse_begin_y, event.button.x,
96.48 + event.button.y);
96.49 + break;
96.50 + case SDL_KEYDOWN:
96.51 + switch (event.key.keysym.sym) {
96.52 + case 'l':
96.53 + if (event.key.keysym.mod & KMOD_SHIFT)
96.54 + num_lines = 0;
96.55 + else
96.56 + add_line(rand() % 640, rand() % 480, rand() % 640,
96.57 + rand() % 480);
96.58 + break;
96.59 + case 'r':
96.60 + if (event.key.keysym.mod & KMOD_SHIFT)
96.61 + num_rects = 0;
96.62 + else
96.63 + add_rect(rand() % 640, rand() % 480, rand() % 640,
96.64 + rand() % 480);
96.65 + break;
96.66 + }
96.67 + break;
96.68 + default:
96.69 + break;
96.70 + }
96.71 + }
96.72 + for (i = 0; i < state->num_windows; ++i) {
96.73 + SDL_Renderer *renderer = state->renderers[i];
96.74 + if (state->windows[i] == NULL)
96.75 + continue;
96.76 + SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
96.77 + SDL_RenderClear(renderer);
96.78 +
96.79 + DrawRects(renderer);
96.80 + DrawPoints(renderer);
96.81 + DrawRectRectIntersections(renderer);
96.82 + DrawLines(renderer);
96.83 + DrawRectLineIntersections(renderer);
96.84 +
96.85 + SDL_RenderPresent(renderer);
96.86 + }
96.87 +}
96.88 +
96.89 int
96.90 main(int argc, char *argv[])
96.91 {
96.92 - int mouse_begin_x = -1, mouse_begin_y = -1;
96.93 - int i, done;
96.94 - SDL_Event event;
96.95 + int i;
96.96 Uint32 then, now, frames;
96.97
96.98 /* Enable standard application logging */
96.99 @@ -268,62 +334,15 @@
96.100 frames = 0;
96.101 then = SDL_GetTicks();
96.102 done = 0;
96.103 +
96.104 +#ifdef __EMSCRIPTEN__
96.105 + emscripten_set_main_loop(loop, 0, 1);
96.106 +#else
96.107 while (!done) {
96.108 - /* Check for events */
96.109 ++frames;
96.110 - while (SDL_PollEvent(&event)) {
96.111 - SDLTest_CommonEvent(state, &event, &done);
96.112 - switch (event.type) {
96.113 - case SDL_MOUSEBUTTONDOWN:
96.114 - mouse_begin_x = event.button.x;
96.115 - mouse_begin_y = event.button.y;
96.116 - break;
96.117 - case SDL_MOUSEBUTTONUP:
96.118 - if (event.button.button == 3)
96.119 - add_line(mouse_begin_x, mouse_begin_y, event.button.x,
96.120 - event.button.y);
96.121 - if (event.button.button == 1)
96.122 - add_rect(mouse_begin_x, mouse_begin_y, event.button.x,
96.123 - event.button.y);
96.124 - break;
96.125 - case SDL_KEYDOWN:
96.126 - switch (event.key.keysym.sym) {
96.127 - case 'l':
96.128 - if (event.key.keysym.mod & KMOD_SHIFT)
96.129 - num_lines = 0;
96.130 - else
96.131 - add_line(rand() % 640, rand() % 480, rand() % 640,
96.132 - rand() % 480);
96.133 - break;
96.134 - case 'r':
96.135 - if (event.key.keysym.mod & KMOD_SHIFT)
96.136 - num_rects = 0;
96.137 - else
96.138 - add_rect(rand() % 640, rand() % 480, rand() % 640,
96.139 - rand() % 480);
96.140 - break;
96.141 - }
96.142 - break;
96.143 - default:
96.144 - break;
96.145 - }
96.146 - }
96.147 - for (i = 0; i < state->num_windows; ++i) {
96.148 - SDL_Renderer *renderer = state->renderers[i];
96.149 - if (state->windows[i] == NULL)
96.150 - continue;
96.151 - SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
96.152 - SDL_RenderClear(renderer);
96.153 -
96.154 - DrawRects(renderer);
96.155 - DrawPoints(renderer);
96.156 - DrawRectRectIntersections(renderer);
96.157 - DrawLines(renderer);
96.158 - DrawRectLineIntersections(renderer);
96.159 -
96.160 - SDL_RenderPresent(renderer);
96.161 - }
96.162 + loop();
96.163 }
96.164 +#endif
96.165
96.166 SDLTest_CommonQuit(state);
96.167
97.1 --- a/test/testjoystick.c Thu Jan 15 01:06:14 2015 -0400
97.2 +++ b/test/testjoystick.c Thu Jan 15 01:15:24 2015 -0400
97.3 @@ -18,6 +18,10 @@
97.4
97.5 #include "SDL.h"
97.6
97.7 +#ifdef __EMSCRIPTEN__
97.8 +#include <emscripten/emscripten.h>
97.9 +#endif
97.10 +
97.11 #ifndef SDL_JOYSTICK_DISABLED
97.12
97.13 #ifdef __IPHONEOS__
97.14 @@ -28,6 +32,9 @@
97.15 #define SCREEN_HEIGHT 480
97.16 #endif
97.17
97.18 +SDL_Renderer *screen = NULL;
97.19 +SDL_bool retval = SDL_FALSE;
97.20 +SDL_bool done = SDL_FALSE;
97.21
97.22 static void
97.23 DrawRect(SDL_Renderer *r, const int x, const int y, const int w, const int h)
97.24 @@ -36,50 +43,15 @@
97.25 SDL_RenderFillRect(r, &area);
97.26 }
97.27
97.28 -static SDL_bool
97.29 -WatchJoystick(SDL_Joystick * joystick)
97.30 +void
97.31 +loop(void *arg)
97.32 {
97.33 - SDL_Window *window = NULL;
97.34 - SDL_Renderer *screen = NULL;
97.35 - const char *name = NULL;
97.36 - SDL_bool retval = SDL_FALSE;
97.37 - SDL_bool done = SDL_FALSE;
97.38 SDL_Event event;
97.39 int i;
97.40 -
97.41 - /* Create a window to display joystick axis position */
97.42 - window = SDL_CreateWindow("Joystick Test", SDL_WINDOWPOS_CENTERED,
97.43 - SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH,
97.44 - SCREEN_HEIGHT, 0);
97.45 - if (window == NULL) {
97.46 - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
97.47 - return SDL_FALSE;
97.48 - }
97.49 -
97.50 - screen = SDL_CreateRenderer(window, -1, 0);
97.51 - if (screen == NULL) {
97.52 - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError());
97.53 - SDL_DestroyWindow(window);
97.54 - return SDL_FALSE;
97.55 - }
97.56 + SDL_Joystick *joystick = (SDL_Joystick *)arg;
97.57
97.58 - SDL_SetRenderDrawColor(screen, 0x00, 0x00, 0x00, SDL_ALPHA_OPAQUE);
97.59 - SDL_RenderClear(screen);
97.60 - SDL_RenderPresent(screen);
97.61 - SDL_RaiseWindow(window);
97.62 -
97.63 - /* Print info about the joystick we are watching */
97.64 - name = SDL_JoystickName(joystick);
97.65 - SDL_Log("Watching joystick %d: (%s)\n", SDL_JoystickInstanceID(joystick),
97.66 - name ? name : "Unknown Joystick");
97.67 - SDL_Log("Joystick has %d axes, %d hats, %d balls, and %d buttons\n",
97.68 - SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick),
97.69 - SDL_JoystickNumBalls(joystick), SDL_JoystickNumButtons(joystick));
97.70 -
97.71 - /* Loop, getting joystick events! */
97.72 - while (!done) {
97.73 /* blank screen, set up for drawing this frame. */
97.74 - SDL_SetRenderDrawColor(screen, 0x00, 0x00, 0x00, SDL_ALPHA_OPAQUE);
97.75 + SDL_SetRenderDrawColor(screen, 0x0, 0x0, 0x0, SDL_ALPHA_OPAQUE);
97.76 SDL_RenderClear(screen);
97.77
97.78 while (SDL_PollEvent(&event)) {
97.79 @@ -197,8 +169,53 @@
97.80 done = SDL_TRUE;
97.81 retval = SDL_TRUE; /* keep going, wait for reattach. */
97.82 }
97.83 +}
97.84 +
97.85 +static SDL_bool
97.86 +WatchJoystick(SDL_Joystick * joystick)
97.87 +{
97.88 + SDL_Window *window = NULL;
97.89 + const char *name = NULL;
97.90 +
97.91 +
97.92 + /* Create a window to display joystick axis position */
97.93 + window = SDL_CreateWindow("Joystick Test", SDL_WINDOWPOS_CENTERED,
97.94 + SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH,
97.95 + SCREEN_HEIGHT, 0);
97.96 + if (window == NULL) {
97.97 + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
97.98 + return SDL_FALSE;
97.99 }
97.100
97.101 + screen = SDL_CreateRenderer(window, -1, 0);
97.102 + if (screen == NULL) {
97.103 + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError());
97.104 + SDL_DestroyWindow(window);
97.105 + return SDL_FALSE;
97.106 + }
97.107 +
97.108 + SDL_SetRenderDrawColor(screen, 0x00, 0x00, 0x00, SDL_ALPHA_OPAQUE);
97.109 + SDL_RenderClear(screen);
97.110 + SDL_RenderPresent(screen);
97.111 + SDL_RaiseWindow(window);
97.112 +
97.113 + /* Print info about the joystick we are watching */
97.114 + name = SDL_JoystickName(joystick);
97.115 + SDL_Log("Watching joystick %d: (%s)\n", SDL_JoystickInstanceID(joystick),
97.116 + name ? name : "Unknown Joystick");
97.117 + SDL_Log("Joystick has %d axes, %d hats, %d balls, and %d buttons\n",
97.118 + SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick),
97.119 + SDL_JoystickNumBalls(joystick), SDL_JoystickNumButtons(joystick));
97.120 +
97.121 + /* Loop, getting joystick events! */
97.122 +#ifdef __EMSCRIPTEN__
97.123 + emscripten_set_main_loop_arg(loop, joystick, 0, 1);
97.124 +#else
97.125 + while (!done) {
97.126 + loop(joystick);
97.127 + }
97.128 +#endif
97.129 +
97.130 SDL_DestroyRenderer(screen);
97.131 SDL_DestroyWindow(window);
97.132 return retval;
98.1 --- a/test/testmultiaudio.c Thu Jan 15 01:06:14 2015 -0400
98.2 +++ b/test/testmultiaudio.c Thu Jan 15 01:15:24 2015 -0400
98.3 @@ -13,6 +13,10 @@
98.4
98.5 #include <stdio.h> /* for fflush() and stdout */
98.6
98.7 +#ifdef __EMSCRIPTEN__
98.8 +#include <emscripten/emscripten.h>
98.9 +#endif
98.10 +
98.11 static SDL_AudioSpec spec;
98.12 static Uint8 *sound = NULL; /* Pointer to wave data */
98.13 static Uint32 soundlen = 0; /* Length of wave data */
98.14 @@ -24,6 +28,8 @@
98.15 volatile int done;
98.16 } callback_data;
98.17
98.18 +callback_data cbd[64];
98.19 +
98.20 void SDLCALL
98.21 play_through_once(void *arg, Uint8 * stream, int len)
98.22 {
98.23 @@ -44,16 +50,30 @@
98.24 }
98.25 }
98.26
98.27 +void
98.28 +loop()
98.29 +{
98.30 + if(cbd[0].done) {
98.31 +#ifdef __EMSCRIPTEN__
98.32 + emscripten_cancel_main_loop();
98.33 +#endif
98.34 + SDL_PauseAudioDevice(cbd[0].dev, 1);
98.35 + SDL_CloseAudioDevice(cbd[0].dev);
98.36 + SDL_FreeWAV(sound);
98.37 + SDL_Quit();
98.38 + }
98.39 +}
98.40 +
98.41 static void
98.42 test_multi_audio(int devcount)
98.43 {
98.44 - callback_data cbd[64];
98.45 int keep_going = 1;
98.46 int i;
98.47
98.48 #ifdef __ANDROID__
98.49 SDL_Event event;
98.50
98.51 + /* Create a Window to get fully initialized event processing for testing pause on Android. */
98.52 SDL_CreateWindow("testmultiaudio", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 320, 240, 0);
98.53 #endif
98.54
98.55 @@ -77,13 +97,19 @@
98.56 SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Open device failed: %s\n", SDL_GetError());
98.57 } else {
98.58 SDL_PauseAudioDevice(cbd[0].dev, 0);
98.59 - while (!cbd[0].done) {
98.60 -#ifdef __ANDROID__
98.61 +#ifdef __EMSCRIPTEN__
98.62 + emscripten_set_main_loop(loop, 0, 1);
98.63 +#else
98.64 + while (!cbd[0].done)
98.65 + {
98.66 + #ifdef __ANDROID__
98.67 + /* Empty queue, some application events would prevent pause. */
98.68 while (SDL_PollEvent(&event)){}
98.69 -#endif
98.70 + #endif
98.71 SDL_Delay(100);
98.72 }
98.73 SDL_PauseAudioDevice(cbd[0].dev, 1);
98.74 +#endif
98.75 SDL_Log("done.\n");
98.76 SDL_CloseAudioDevice(cbd[0].dev);
98.77 }
98.78 @@ -114,12 +140,15 @@
98.79 keep_going = 1;
98.80 }
98.81 }
98.82 -#ifdef __ANDROID__
98.83 + #ifdef __ANDROID__
98.84 + /* Empty queue, some application events would prevent pause. */
98.85 while (SDL_PollEvent(&event)){}
98.86 -#endif
98.87 + #endif
98.88 +
98.89 SDL_Delay(100);
98.90 }
98.91
98.92 +#ifndef __EMSCRIPTEN__
98.93 for (i = 0; i < devcount; i++) {
98.94 if (cbd[i].dev) {
98.95 SDL_PauseAudioDevice(cbd[i].dev, 1);
98.96 @@ -128,6 +157,7 @@
98.97 }
98.98
98.99 SDL_Log("All done!\n");
98.100 +#endif
98.101 }
98.102
98.103
99.1 --- a/test/testoverlay2.c Thu Jan 15 01:06:14 2015 -0400
99.2 +++ b/test/testoverlay2.c Thu Jan 15 01:15:24 2015 -0400
99.3 @@ -20,6 +20,10 @@
99.4 #include <stdio.h>
99.5 #include <string.h>
99.6
99.7 +#ifdef __EMSCRIPTEN__
99.8 +#include <emscripten/emscripten.h>
99.9 +#endif
99.10 +
99.11 #include "SDL.h"
99.12
99.13 #define MOOSEPIC_W 64
99.14 @@ -135,6 +139,18 @@
99.15 , {239, 206, 173}
99.16 };
99.17
99.18 +Uint8 MooseFrame[MOOSEFRAMES_COUNT][MOOSEFRAME_SIZE*2];
99.19 +SDL_Texture *MooseTexture;
99.20 +SDL_Rect displayrect;
99.21 +int window_w;
99.22 +int window_h;
99.23 +SDL_Window *window;
99.24 +SDL_Renderer *renderer;
99.25 +int paused = 0;
99.26 +int i;
99.27 +SDL_bool done = SDL_FALSE;
99.28 +Uint32 pixel_format = SDL_PIXELFORMAT_YV12;
99.29 +int fpsdelay;
99.30
99.31 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
99.32 static void
99.33 @@ -246,21 +262,65 @@
99.34 SDL_Log("\n");
99.35 }
99.36
99.37 +void
99.38 +loop()
99.39 +{
99.40 + SDL_Event event;
99.41 +
99.42 + while (SDL_PollEvent(&event)) {
99.43 + switch (event.type) {
99.44 + case SDL_WINDOWEVENT:
99.45 + if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
99.46 + SDL_RenderSetViewport(renderer, NULL);
99.47 + displayrect.w = window_w = event.window.data1;
99.48 + displayrect.h = window_h = event.window.data2;
99.49 + }
99.50 + break;
99.51 + case SDL_MOUSEBUTTONDOWN:
99.52 + displayrect.x = event.button.x - window_w / 2;
99.53 + displayrect.y = event.button.y - window_h / 2;
99.54 + break;
99.55 + case SDL_MOUSEMOTION:
99.56 + if (event.motion.state) {
99.57 + displayrect.x = event.motion.x - window_w / 2;
99.58 + displayrect.y = event.motion.y - window_h / 2;
99.59 + }
99.60 + break;
99.61 + case SDL_KEYDOWN:
99.62 + if (event.key.keysym.sym == SDLK_SPACE) {
99.63 + paused = !paused;
99.64 + break;
99.65 + }
99.66 + if (event.key.keysym.sym != SDLK_ESCAPE) {
99.67 + break;
99.68 + }
99.69 + case SDL_QUIT:
99.70 + done = SDL_TRUE;
99.71 + break;
99.72 + }
99.73 + }
99.74 +
99.75 +#ifndef __EMSCRIPTEN__
99.76 + SDL_Delay(fpsdelay);
99.77 +#endif
99.78 +
99.79 + if (!paused) {
99.80 + i = (i + 1) % MOOSEFRAMES_COUNT;
99.81 +
99.82 + SDL_UpdateTexture(MooseTexture, NULL, MooseFrame[i], MOOSEPIC_W*SDL_BYTESPERPIXEL(pixel_format));
99.83 + }
99.84 + SDL_RenderClear(renderer);
99.85 + SDL_RenderCopy(renderer, MooseTexture, NULL, &displayrect);
99.86 + SDL_RenderPresent(renderer);
99.87 +}
99.88 +
99.89 int
99.90 main(int argc, char **argv)
99.91 {
99.92 Uint8 *RawMooseData;
99.93 SDL_RWops *handle;
99.94 - int window_w;
99.95 - int window_h;
99.96 SDL_Window *window;
99.97 - SDL_Renderer *renderer;
99.98 - Uint8 MooseFrame[MOOSEFRAMES_COUNT][MOOSEFRAME_SIZE*2];
99.99 - SDL_Texture *MooseTexture;
99.100 - SDL_Rect displayrect;
99.101 - SDL_Event event;
99.102 - int paused = 0;
99.103 - int i, j;
99.104 + int j;
99.105 int fps = 12;
99.106 int fpsdelay;
99.107 int nodelay = 0;
99.108 @@ -270,7 +330,6 @@
99.109 Uint32 pixel_format = SDL_PIXELFORMAT_YV12;
99.110 #endif
99.111 int scale = 5;
99.112 - SDL_bool done = SDL_FALSE;
99.113
99.114 /* Enable standard application logging */
99.115 SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
99.116 @@ -430,50 +489,14 @@
99.117 SDL_EventState(SDL_KEYUP, SDL_IGNORE);
99.118
99.119 /* Loop, waiting for QUIT or RESIZE */
99.120 +#ifdef __EMSCRIPTEN__
99.121 + emscripten_set_main_loop(loop, nodelay ? 0 : fps, 1);
99.122 +#else
99.123 while (!done) {
99.124 - while (SDL_PollEvent(&event)) {
99.125 - switch (event.type) {
99.126 - case SDL_WINDOWEVENT:
99.127 - if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
99.128 - SDL_RenderSetViewport(renderer, NULL);
99.129 - displayrect.w = window_w = event.window.data1;
99.130 - displayrect.h = window_h = event.window.data2;
99.131 - }
99.132 - break;
99.133 - case SDL_MOUSEBUTTONDOWN:
99.134 - displayrect.x = event.button.x - window_w / 2;
99.135 - displayrect.y = event.button.y - window_h / 2;
99.136 - break;
99.137 - case SDL_MOUSEMOTION:
99.138 - if (event.motion.state) {
99.139 - displayrect.x = event.motion.x - window_w / 2;
99.140 - displayrect.y = event.motion.y - window_h / 2;
99.141 - }
99.142 - break;
99.143 - case SDL_KEYDOWN:
99.144 - if (event.key.keysym.sym == SDLK_SPACE) {
99.145 - paused = !paused;
99.146 - break;
99.147 - }
99.148 - if (event.key.keysym.sym != SDLK_ESCAPE) {
99.149 - break;
99.150 - }
99.151 - case SDL_QUIT:
99.152 - done = SDL_TRUE;
99.153 - break;
99.154 + loop();
99.155 }
99.156 - }
99.157 - SDL_Delay(fpsdelay);
99.158 -
99.159 - if (!paused) {
99.160 - i = (i + 1) % MOOSEFRAMES_COUNT;
99.161 +#endif
99.162
99.163 - SDL_UpdateTexture(MooseTexture, NULL, MooseFrame[i], MOOSEPIC_W*SDL_BYTESPERPIXEL(pixel_format));
99.164 - }
99.165 - SDL_RenderClear(renderer);
99.166 - SDL_RenderCopy(renderer, MooseTexture, NULL, &displayrect);
99.167 - SDL_RenderPresent(renderer);
99.168 - }
99.169 SDL_DestroyRenderer(renderer);
99.170 quit(0);
99.171 return 0;
100.1 --- a/test/testplatform.c Thu Jan 15 01:06:14 2015 -0400
100.2 +++ b/test/testplatform.c Thu Jan 15 01:15:24 2015 -0400
100.3 @@ -119,14 +119,8 @@
100.4 ++error;
100.5 }
100.6 if (verbose) {
100.7 -#ifdef _MSC_VER
100.8 - SDL_Log("Value 64 = 0x%I64X, swapped = 0x%I64X\n", value64,
100.9 + SDL_Log("Value 64 = 0x%"SDL_PRIX64", swapped = 0x%"SDL_PRIX64"\n", value64,
100.10 SDL_Swap64(value64));
100.11 -#else
100.12 - SDL_Log("Value 64 = 0x%llX, swapped = 0x%llX\n",
100.13 - (unsigned long long) value64,
100.14 - (unsigned long long) SDL_Swap64(value64));
100.15 -#endif
100.16 }
100.17 if (SDL_Swap64(value64) != swapped64) {
100.18 if (verbose) {
101.1 --- a/test/testrelative.c Thu Jan 15 01:06:14 2015 -0400
101.2 +++ b/test/testrelative.c Thu Jan 15 01:15:24 2015 -0400
101.3 @@ -18,8 +18,14 @@
101.4
101.5 #include "SDL_test_common.h"
101.6
101.7 +#ifdef __EMSCRIPTEN__
101.8 +#include <emscripten/emscripten.h>
101.9 +#endif
101.10
101.11 static SDLTest_CommonState *state;
101.12 +int i, done;
101.13 +SDL_Rect rect;
101.14 +SDL_Event event;
101.15
101.16 static void
101.17 DrawRects(SDL_Renderer * renderer, SDL_Rect * rect)
101.18 @@ -28,12 +34,36 @@
101.19 SDL_RenderFillRect(renderer, rect);
101.20 }
101.21
101.22 +static void
101.23 +loop(){
101.24 + /* Check for events */
101.25 + while (SDL_PollEvent(&event)) {
101.26 + SDLTest_CommonEvent(state, &event, &done);
101.27 + switch(event.type) {
101.28 + case SDL_MOUSEMOTION:
101.29 + {
101.30 + rect.x += event.motion.xrel;
101.31 + rect.y += event.motion.yrel;
101.32 + }
101.33 + break;
101.34 + }
101.35 + }
101.36 + for (i = 0; i < state->num_windows; ++i) {
101.37 + SDL_Renderer *renderer = state->renderers[i];
101.38 + if (state->windows[i] == NULL)
101.39 + continue;
101.40 + SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
101.41 + SDL_RenderClear(renderer);
101.42 +
101.43 + DrawRects(renderer, &rect);
101.44 +
101.45 + SDL_RenderPresent(renderer);
101.46 + }
101.47 +}
101.48 +
101.49 int
101.50 main(int argc, char *argv[])
101.51 {
101.52 - int i, done;
101.53 - SDL_Rect rect;
101.54 - SDL_Event event;
101.55
101.56 /* Enable standard application logging */
101.57 SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
101.58 @@ -69,32 +99,13 @@
101.59 rect.h = 10;
101.60 /* Main render loop */
101.61 done = 0;
101.62 +#ifdef __EMSCRIPTEN__
101.63 + emscripten_set_main_loop(loop, 0, 1);
101.64 +#else
101.65 while (!done) {
101.66 - /* Check for events */
101.67 - while (SDL_PollEvent(&event)) {
101.68 - SDLTest_CommonEvent(state, &event, &done);
101.69 - switch(event.type) {
101.70 - case SDL_MOUSEMOTION:
101.71 - {
101.72 - rect.x += event.motion.xrel;
101.73 - rect.y += event.motion.yrel;
101.74 - }
101.75 - break;
101.76 - }
101.77 + loop();
101.78 }
101.79 - for (i = 0; i < state->num_windows; ++i) {
101.80 - SDL_Renderer *renderer = state->renderers[i];
101.81 - if (state->windows[i] == NULL)
101.82 - continue;
101.83 - SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
101.84 - SDL_RenderClear(renderer);
101.85 -
101.86 - DrawRects(renderer, &rect);
101.87 -
101.88 - SDL_RenderPresent(renderer);
101.89 - }
101.90 - }
101.91 -
101.92 +#endif
101.93 SDLTest_CommonQuit(state);
101.94 return 0;
101.95 }
102.1 --- a/test/testrendercopyex.c Thu Jan 15 01:06:14 2015 -0400
102.2 +++ b/test/testrendercopyex.c Thu Jan 15 01:15:24 2015 -0400
102.3 @@ -15,6 +15,10 @@
102.4 #include <stdio.h>
102.5 #include <time.h>
102.6
102.7 +#ifdef __EMSCRIPTEN__
102.8 +#include <emscripten/emscripten.h>
102.9 +#endif
102.10 +
102.11 #include "SDL_test_common.h"
102.12
102.13
102.14 @@ -29,6 +33,9 @@
102.15 int scale_direction;
102.16 } DrawState;
102.17
102.18 +DrawState *drawstates;
102.19 +int done;
102.20 +
102.21 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
102.22 static void
102.23 quit(int rc)
102.24 @@ -130,12 +137,27 @@
102.25 /* SDL_Delay(10); */
102.26 }
102.27
102.28 +void loop()
102.29 +{
102.30 + int i;
102.31 + SDL_Event event;
102.32 +
102.33 + /* Check for events */
102.34 +
102.35 + while (SDL_PollEvent(&event)) {
102.36 + SDLTest_CommonEvent(state, &event, &done);
102.37 + }
102.38 + for (i = 0; i < state->num_windows; ++i) {
102.39 + if (state->windows[i] == NULL)
102.40 + continue;
102.41 + Draw(&drawstates[i]);
102.42 + }
102.43 +}
102.44 +
102.45 int
102.46 main(int argc, char *argv[])
102.47 {
102.48 - DrawState *drawstates;
102.49 - int i, done;
102.50 - SDL_Event event;
102.51 + int i;
102.52 int frames;
102.53 Uint32 then, now;
102.54
102.55 @@ -181,19 +203,15 @@
102.56 frames = 0;
102.57 then = SDL_GetTicks();
102.58 done = 0;
102.59 +
102.60 +#ifdef __EMSCRIPTEN__
102.61 + emscripten_set_main_loop(loop, 0, 1);
102.62 +#else
102.63 while (!done) {
102.64 - /* Check for events */
102.65 ++frames;
102.66 - while (SDL_PollEvent(&event)) {
102.67 - SDLTest_CommonEvent(state, &event, &done);
102.68 + loop();
102.69 }
102.70 - for (i = 0; i < state->num_windows; ++i) {
102.71 - if (state->windows[i] == NULL)
102.72 - continue;
102.73 - Draw(&drawstates[i]);
102.74 - }
102.75 - }
102.76 -
102.77 +#endif
102.78 /* Print out some timing information */
102.79 now = SDL_GetTicks();
102.80 if (now > then) {
103.1 --- a/test/testrendertarget.c Thu Jan 15 01:06:14 2015 -0400
103.2 +++ b/test/testrendertarget.c Thu Jan 15 01:15:24 2015 -0400
103.3 @@ -15,6 +15,10 @@
103.4 #include <stdio.h>
103.5 #include <time.h>
103.6
103.7 +#ifdef __EMSCRIPTEN__
103.8 +#include <emscripten/emscripten.h>
103.9 +#endif