Browse Source

Update to SDL 2.0.9.e1e13e154128.
Fixed D3D9 issue.

woollybah 6 năm trước cách đây
mục cha
commit
20437bab73
100 tập tin đã thay đổi với 2770 bổ sung1112 xóa
  1. 1 0
      d3d9sdlgraphics.mod/d3d9sdlgraphics.bmx
  2. 22 1
      sdl.mod/SDL/Android.mk
  3. 6 4
      sdl.mod/SDL/CMakeLists.txt
  4. 4 3
      sdl.mod/SDL/Makefile.in
  5. 137 0
      sdl.mod/SDL/Makefile.os2
  6. 0 12
      sdl.mod/SDL/VisualC/SDL/SDL.vcxproj
  7. 1 0
      sdl.mod/SDL/WhatsNew.txt
  8. 2 0
      sdl.mod/SDL/Xcode-iOS/Demos/Demos.xcodeproj/project.pbxproj
  9. 2 0
      sdl.mod/SDL/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
  10. 2 58
      sdl.mod/SDL/Xcode-iOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj
  11. 10 0
      sdl.mod/SDL/Xcode/SDL/SDL.xcodeproj/project.pbxproj
  12. 2 0
      sdl.mod/SDL/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj
  13. 1 77
      sdl.mod/SDL/android-project-ant/AndroidManifest.xml
  14. 1 0
      sdl.mod/SDL/android-project-ant/src
  15. 2 8
      sdl.mod/SDL/android-project/app/build.gradle
  16. 3 2
      sdl.mod/SDL/android-project/app/jni/Application.mk
  17. 0 3
      sdl.mod/SDL/android-project/app/src/main/AndroidManifest.xml
  18. 11 7
      sdl.mod/SDL/android-project/app/src/main/java/org/libsdl/app/HIDDeviceBLESteamController.java
  19. 76 18
      sdl.mod/SDL/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java
  20. 10 1
      sdl.mod/SDL/android-project/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java
  21. 47 0
      sdl.mod/SDL/android-project/app/src/main/java/org/libsdl/app/SDL.java
  22. 81 39
      sdl.mod/SDL/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
  23. 249 59
      sdl.mod/SDL/android-project/app/src/main/java/org/libsdl/app/SDLAudioManager.java
  24. 62 28
      sdl.mod/SDL/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java
  25. 3 1
      sdl.mod/SDL/android-project/build.gradle
  26. 1 1
      sdl.mod/SDL/android-project/gradle/wrapper/gradle-wrapper.properties
  27. 371 167
      sdl.mod/SDL/build-scripts/install-sh
  28. 2 5
      sdl.mod/SDL/build-scripts/ltmain.sh
  29. 124 61
      sdl.mod/SDL/build-scripts/mkinstalldirs
  30. 42 0
      sdl.mod/SDL/build-scripts/os2-buildbot.sh
  31. 1 1
      sdl.mod/SDL/build-scripts/raspberrypi-buildbot.sh
  32. 0 40
      sdl.mod/SDL/cmake/sdlchecks.cmake
  33. 115 153
      sdl.mod/SDL/configure
  34. 64 77
      sdl.mod/SDL/configure.in
  35. 16 3
      sdl.mod/SDL/debian/rules
  36. 28 25
      sdl.mod/SDL/docs/README-android.md
  37. 0 3
      sdl.mod/SDL/docs/README-linux.md
  38. 1 1
      sdl.mod/SDL/include/SDL_atomic.h
  39. 2 1
      sdl.mod/SDL/include/SDL_audio.h
  40. 9 0
      sdl.mod/SDL/include/SDL_bits.h
  41. 6 6
      sdl.mod/SDL/include/SDL_blendmode.h
  42. 3 1
      sdl.mod/SDL/include/SDL_config.h
  43. 0 3
      sdl.mod/SDL/include/SDL_config.h.cmake
  44. 0 3
      sdl.mod/SDL/include/SDL_config.h.in
  45. 1 1
      sdl.mod/SDL/include/SDL_config_iphoneos.h
  46. 170 0
      sdl.mod/SDL/include/SDL_config_os2.h
  47. 18 7
      sdl.mod/SDL/include/SDL_cpuinfo.h
  48. 7 0
      sdl.mod/SDL/include/SDL_gamecontroller.h
  49. 11 0
      sdl.mod/SDL/include/SDL_haptic.h
  50. 40 1
      sdl.mod/SDL/include/SDL_hints.h
  51. 13 0
      sdl.mod/SDL/include/SDL_joystick.h
  52. 2 2
      sdl.mod/SDL/include/SDL_pixels.h
  53. 28 2
      sdl.mod/SDL/include/SDL_rect.h
  54. 167 0
      sdl.mod/SDL/include/SDL_render.h
  55. 1 1
      sdl.mod/SDL/include/SDL_scancode.h
  56. 3 3
      sdl.mod/SDL/include/SDL_sensor.h
  57. 10 7
      sdl.mod/SDL/include/SDL_syswm.h
  58. 2 2
      sdl.mod/SDL/include/SDL_test_memory.h
  59. 35 1
      sdl.mod/SDL/include/SDL_thread.h
  60. 13 0
      sdl.mod/SDL/include/SDL_touch.h
  61. 3 0
      sdl.mod/SDL/include/close_code.h
  62. 6 0
      sdl.mod/SDL/src/SDL.c
  63. 1 0
      sdl.mod/SDL/src/SDL_assert.c
  64. 5 0
      sdl.mod/SDL/src/SDL_assert_c.h
  65. 4 0
      sdl.mod/SDL/src/SDL_internal.h
  66. 5 3
      sdl.mod/SDL/src/SDL_log.c
  67. 61 18
      sdl.mod/SDL/src/audio/SDL_audio.c
  68. 6 0
      sdl.mod/SDL/src/audio/SDL_audiodev_c.h
  69. 1 1
      sdl.mod/SDL/src/audio/SDL_audiotypecvt.c
  70. 3 1
      sdl.mod/SDL/src/audio/SDL_sysaudio.h
  71. 5 20
      sdl.mod/SDL/src/audio/android/SDL_androidaudio.c
  72. 1 0
      sdl.mod/SDL/src/audio/emscripten/SDL_emscriptenaudio.c
  73. 54 8
      sdl.mod/SDL/src/audio/wasapi/SDL_wasapi_win32.c
  74. 219 106
      sdl.mod/SDL/src/core/android/SDL_android.c
  75. 3 2
      sdl.mod/SDL/src/core/android/SDL_android.h
  76. 1 0
      sdl.mod/SDL/src/core/linux/SDL_evdev.c
  77. 8 5
      sdl.mod/SDL/src/core/linux/SDL_evdev_kbd.c
  78. 5 0
      sdl.mod/SDL/src/core/linux/SDL_evdev_kbd.h
  79. 111 0
      sdl.mod/SDL/src/core/linux/SDL_threadprio.c
  80. 33 8
      sdl.mod/SDL/src/cpuinfo/SDL_cpuinfo.c
  81. 1 0
      sdl.mod/SDL/src/dynapi/SDL_dynapi.c
  82. 16 0
      sdl.mod/SDL/src/dynapi/SDL_dynapi_overrides.h
  83. 28 0
      sdl.mod/SDL/src/dynapi/SDL_dynapi_procs.h
  84. 6 0
      sdl.mod/SDL/src/events/SDL_events_c.h
  85. 11 3
      sdl.mod/SDL/src/events/SDL_gesture.c
  86. 1 1
      sdl.mod/SDL/src/events/SDL_mouse.c
  87. 13 2
      sdl.mod/SDL/src/events/SDL_touch.c
  88. 2 1
      sdl.mod/SDL/src/events/SDL_touch_c.h
  89. 4 20
      sdl.mod/SDL/src/events/SDL_windowevents.c
  90. 6 0
      sdl.mod/SDL/src/events/scancodes_xfree86.h
  91. 1 0
      sdl.mod/SDL/src/file/SDL_rwops.c
  92. 8 2
      sdl.mod/SDL/src/haptic/SDL_haptic.c
  93. 5 0
      sdl.mod/SDL/src/haptic/SDL_haptic_c.h
  94. 11 1
      sdl.mod/SDL/src/haptic/android/SDL_syshaptic.c
  95. 3 3
      sdl.mod/SDL/src/haptic/linux/SDL_syshaptic.c
  96. 58 8
      sdl.mod/SDL/src/hidapi/android/hid.cpp
  97. 5 0
      sdl.mod/SDL/src/hidapi/ios/hid.m
  98. 5 0
      sdl.mod/SDL/src/hidapi/libusb/hid.c
  99. 5 0
      sdl.mod/SDL/src/hidapi/linux/hid.c
  100. 5 0
      sdl.mod/SDL/src/hidapi/mac/hid.c

+ 1 - 0
d3d9sdlgraphics.mod/d3d9sdlgraphics.bmx

@@ -121,6 +121,7 @@ End Function
 Function ResetD3DDevice()
 	If _d3dOccQuery
 		_d3dOccQuery.Release_
+		_d3dOccQuery = Null
 	Else
 		'_d3dOccQuery = New IDirect3DQuery9
 	End If

+ 22 - 1
sdl.mod/SDL/Android.mk

@@ -53,12 +53,30 @@ LOCAL_SRC_FILES := \
 LOCAL_SHARED_LIBRARIES := hidapi
 
 LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES
+LOCAL_CFLAGS += \
+	-Wall -Wextra \
+	-Wdocumentation \
+	-Wdocumentation-unknown-command \
+	-Wmissing-prototypes \
+	-Wunreachable-code-break \
+	-Wunneeded-internal-declaration \
+	-Wmissing-variable-declarations \
+	-Wfloat-conversion \
+	-Wshorten-64-to-32 \
+	-Wunreachable-code-return
+
+# Warnings we haven't fixed (yet)
+LOCAL_CFLAGS += -Wno-unused-parameter -Wno-sign-compare
+ 
+
 LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog -landroid
 
 ifeq ($(NDK_DEBUG),1)
     cmd-strip :=
 endif
 
+LOCAL_STATIC_LIBRARIES := cpufeatures
+
 include $(BUILD_SHARED_LIBRARY)
 
 ###########################
@@ -102,9 +120,12 @@ include $(CLEAR_VARS)
 
 LOCAL_CPPFLAGS += -std=c++11
 
-LOCAL_SRC_FILES := $(LOCAL_PATH)/src/hidapi/android/hid.cpp
+LOCAL_SRC_FILES := src/hidapi/android/hid.cpp
 
 LOCAL_MODULE := libhidapi
 LOCAL_LDLIBS := -llog
 
 include $(BUILD_SHARED_LIBRARY)
+
+$(call import-module,android/cpufeatures)
+

+ 6 - 4
sdl.mod/SDL/CMakeLists.txt

@@ -46,6 +46,9 @@ set(SDL_MICRO_VERSION 9)
 set(SDL_INTERFACE_AGE 0)
 set(SDL_BINARY_AGE 9)
 set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
+# the following should match the versions in Xcode project file:
+set(DYLIB_CURRENT_VERSION 10.0.0)
+set(DYLIB_COMPATIBILITY_VERSION 1.0.0)
 
 # Set defaults preventing destination file conflicts
 set(SDL_CMAKE_DEBUG_POSTFIX "d"
@@ -61,7 +64,7 @@ set(LT_REVISION "${SDL_INTERFACE_AGE}")
 set(LT_RELEASE "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}")
 set(LT_VERSION "${LT_MAJOR}.${LT_AGE}.${LT_REVISION}")
 
-message(STATUS "${LT_VERSION} :: ${LT_AGE} :: ${LT_REVISION} :: ${LT_CURRENT} :: ${LT_RELEASE}")
+#message(STATUS "${LT_VERSION} :: ${LT_AGE} :: ${LT_REVISION} :: ${LT_CURRENT} :: ${LT_RELEASE}")
 
 # General settings & flags
 set(LIBRARY_OUTPUT_DIRECTORY "build")
@@ -323,8 +326,6 @@ set_option(VIDEO_X11           "Use X11 video driver" ${UNIX_SYS})
 set_option(VIDEO_WAYLAND       "Use Wayland video driver" ${UNIX_SYS})
 dep_option(WAYLAND_SHARED      "Dynamically load Wayland support" ON "VIDEO_WAYLAND" OFF)
 dep_option(VIDEO_WAYLAND_QT_TOUCH  "QtWayland server support for Wayland video driver" ON "VIDEO_WAYLAND" OFF)
-set_option(VIDEO_MIR           "Use Mir video driver" ${UNIX_SYS})
-dep_option(MIR_SHARED          "Dynamically load Mir support" ON "VIDEO_MIR" OFF)
 set_option(VIDEO_RPI           "Use Raspberry Pi video driver" ${UNIX_SYS})
 dep_option(X11_SHARED          "Dynamically load X11 support" ON "VIDEO_X11" OFF)
 set(SDL_X11_OPTIONS Xcursor Xinerama XInput Xrandr Xscrnsaver XShape Xvm)
@@ -451,6 +452,8 @@ if(USE_GCC OR USE_CLANG)
 
   if(APPLE)
     list(APPEND EXTRA_LDFLAGS "-Wl,-undefined,error")
+    list(APPEND EXTRA_LDFLAGS "-Wl,-compatibility_version,${DYLIB_COMPATIBILITY_VERSION}")
+    list(APPEND EXTRA_LDFLAGS "-Wl,-current_version,${DYLIB_CURRENT_VERSION}")
   else()
     set(CMAKE_REQUIRED_FLAGS "-Wl,--no-undefined")
     check_c_compiler_flag("" HAVE_NO_UNDEFINED)
@@ -992,7 +995,6 @@ elseif(UNIX AND NOT APPLE AND NOT ANDROID)
     # Need to check for Raspberry PI first and add platform specific compiler flags, otherwise the test for GLES fails!
     CheckRPI()
     CheckX11()
-    CheckMir()
     CheckDirectFB()
     CheckOpenGLX11()
     CheckOpenGLESX11()

+ 4 - 3
sdl.mod/SDL/Makefile.in

@@ -125,7 +125,7 @@ LT_RELEASE  = @LT_RELEASE@
 LT_REVISION = @LT_REVISION@
 LT_LDFLAGS  = -no-undefined -rpath $(libdir) -release $(LT_RELEASE) -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
 
-all: $(srcdir)/configure Makefile $(objects) $(objects)/$(TARGET) $(objects)/$(SDLMAIN_TARGET) $(objects)/$(SDLTEST_TARGET)
+all: $(srcdir)/configure Makefile $(objects)/$(TARGET) $(objects)/$(SDLMAIN_TARGET) $(objects)/$(SDLTEST_TARGET)
 
 $(srcdir)/configure: $(srcdir)/configure.in
 	@echo "Warning, configure is out of date, please re-run autogen.sh"
@@ -135,8 +135,9 @@ Makefile: $(srcdir)/Makefile.in
 
 Makefile.in:;
 
-$(objects):
-	$(SHELL) $(auxdir)/mkinstalldirs $@
+$(objects)/.created:
+	$(SHELL) $(auxdir)/mkinstalldirs $(objects)
+	touch $@
 
 update-revision:
 	$(SHELL) $(auxdir)/updaterev.sh

+ 137 - 0
sdl.mod/SDL/Makefile.os2

@@ -0,0 +1,137 @@
+# Open Watcom makefile to build SDL2.dll for OS/2:
+# wmake -f Makefile.os2
+
+LIBNAME = SDL2
+VERSION = 2.0.9
+DESCRIPTION = Simple DirectMedia Layer 2
+
+LIBHOME = .
+LIBPATH = $(LIBHOME)/lib
+DLLFILE = $(LIBHOME)/$(LIBNAME).dll
+LIBFILE = $(LIBHOME)/$(LIBNAME).lib
+LNKFILE = $(LIBNAME).lnk
+
+INCPATH = -I"$(%WATCOM)/h/os2" -I"$(%WATCOM)/h"
+INCPATH+= -I"$(LIBHOME)/h"
+INCPATH+= -Iinclude
+
+LIBM = libm.lib
+LIBS = mmpm2.lib libuls.lib libconv.lib $(LIBM)
+
+CFLAGS = -bt=os2 -d0 -q -bm -5s -fp5 -fpi87 -sg -oteanbmier -ei
+# max warnings:
+CFLAGS+= -wx
+# building dll:
+CFLAGS+= -bd
+# the include paths :
+CFLAGS+= $(INCPATH)
+# building SDL itself (for DECLSPEC):
+CFLAGS+= -DBUILD_SDL
+
+MSRCS= e_atan2.c e_exp.c e_fmod.c e_log10.c e_log.c e_pow.c e_rem_pio2.c e_sqrt.c &
+       k_cos.c k_rem_pio2.c k_sin.c k_tan.c &
+       s_atan.c s_copysign.c s_cos.c s_fabs.c s_floor.c s_scalbn.c s_sin.c s_tan.c
+
+SRCS = SDL.c SDL_assert.c SDL_error.c SDL_log.c SDL_dataqueue.c SDL_hints.c
+SRCS+= SDL_getenv.c SDL_iconv.c SDL_malloc.c SDL_qsort.c SDL_stdlib.c SDL_string.c
+SRCS+= SDL_cpuinfo.c SDL_atomic.c SDL_spinlock.c SDL_thread.c SDL_timer.c
+SRCS+= SDL_rwops.c SDL_power.c
+SRCS+= SDL_audio.c SDL_audiocvt.c SDL_audiodev.c SDL_audiotypecvt.c SDL_mixer.c SDL_wave.c
+SRCS+= SDL_events.c SDL_quit.c SDL_keyboard.c SDL_mouse.c SDL_windowevents.c &
+       SDL_clipboardevents.c SDL_dropevents.c SDL_displayevents.c SDL_gesture.c &
+       SDL_sensor.c SDL_touch.c
+SRCS+= SDL_haptic.c SDL_gamecontroller.c SDL_joystick.c
+SRCS+= SDL_render.c yuv_rgb.c SDL_yuv.c SDL_yuv_sw.c SDL_blendfillrect.c &
+       SDL_blendline.c SDL_blendpoint.c SDL_drawline.c SDL_drawpoint.c &
+       SDL_render_sw.c SDL_rotate.c
+SRCS+= SDL_blit.c SDL_blit_0.c SDL_blit_1.c SDL_blit_A.c SDL_blit_auto.c &
+       SDL_blit_copy.c SDL_blit_N.c SDL_blit_slow.c SDL_fillrect.c SDL_bmp.c &
+       SDL_pixels.c SDL_rect.c SDL_RLEaccel.c SDL_shape.c SDL_stretch.c &
+       SDL_surface.c SDL_video.c SDL_clipboard.c SDL_vulkan_utils.c SDL_egl.c
+
+SRCS+= SDL_syscond.c SDL_sysmutex.c SDL_syssem.c SDL_systhread.c SDL_systls.c
+SRCS+= SDL_systimer.c
+SRCS+= SDL_sysloadso.c
+SRCS+= SDL_sysfilesystem.c
+SRCS+= SDL_syshaptic.c SDL_sysjoystick.c
+SRCS+= SDL_dummyaudio.c SDL_diskaudio.c
+SRCS+= SDL_nullvideo.c SDL_nullframebuffer.c SDL_nullevents.c
+SRCS+= SDL_dummysensor.c
+
+SRCS+= SDL_dynapi.c
+
+OBJS = $(SRCS:.c=.obj)
+MOBJS= $(MSRCS:.c=.obj)
+
+.extensions:
+.extensions: .lib .dll .obj .c .asm
+
+.c: ./src;./src/dynapi;./src/audio;./src/cpuinfo;./src/events;./src/file;./src/haptic;./src/joystick;./src/power;./src/render;./src/render/software;./src/sensor;./src/stdlib;./src/thread;./src/timer;./src/video;./src/video/yuv2rgb;./src/atomic;./src/audio/disk;
+.c: ./src/haptic/dummy;./src/joystick/dummy;./src/audio/dummy;./src/video/dummy;./src/sensor/dummy;
+.c: ./src/loadso/dummy;./src/filesystem/dummy;./src/timer/dummy;./src/thread/generic;
+
+all: $(DLLFILE) $(LIBFILE) .symbolic
+
+$(DLLFILE): $(OBJS) $(LIBM) $(LNKFILE)
+    @echo * Linking: $@
+    wlink @$(LNKFILE)
+
+$(LIBFILE): $(DLLFILE)
+    @echo * Creating LIB file: $@
+    wlib -q -b -n -c -pa -s -t -zld -ii -io $* $(DLLFILE)
+
+.c.obj:
+    wcc386 $(CFLAGS) -fo=$^@ $<
+
+SDL_cpuinfo.obj: SDL_cpuinfo.c
+    wcc386 $(CFLAGS) -wcd=200 -fo=$^@ $<
+
+SDL_rwops.obj: SDL_rwops.c
+    wcc386 $(CFLAGS) -wcd=136 -fo=$^@ $<
+
+SDL_blendfillrect.obj: SDL_blendfillrect.c
+    wcc386 $(CFLAGS) -wcd=200 -fo=$^@ $<
+
+SDL_blendline.obj: SDL_blendline.c
+    wcc386 $(CFLAGS) -wcd=200 -fo=$^@ $<
+
+SDL_blendpoint.obj: SDL_blendpoint.c
+    wcc386 $(CFLAGS) -wcd=200 -fo=$^@ $<
+
+SDL_RLEaccel.obj: SDL_RLEaccel.c
+    wcc386 $(CFLAGS) -wcd=201 -fo=$^@ $<
+
+.c: ./src/libm;
+$(LIBM): $(MOBJS)
+    wlib -q -b -n -c -pa -s -t -zld -ii -io $@ $(MOBJS)
+
+$(LNKFILE):
+    @echo * Creating linker file: $@
+    @%create $@
+    @%append $@ SYSTEM os2v2_dll INITINSTANCE TERMINSTANCE
+    @%append $@ NAME $(DLLFILE)
+    @for %i in ($(OBJS)) do @%append $@ FILE %i
+    @%append $@ LIBPATH $(%LIB);$(LIBPATH)
+    @for %i in ($(LIBS)) do @%append $@ LIB %i
+    @%append $@ OPTION QUIET
+    @%append $@ OPTION IMPF=$(LIBHOME)/$^&.exp
+    @%append $@ OPTION MAP=$(LIBHOME)/$^&.map
+    @%append $@ OPTION DESCRIPTION '@$#libsdl org:$(VERSION)$#@$(DESCRIPTION)'
+    @%append $@ OPTION QUIET
+    @%append $@ OPTION ELIMINATE
+    @%append $@ OPTION MANYAUTODATA
+    @%append $@ OPTION OSNAME='OS/2 and eComStation'
+    @%append $@ OPTION SHOWDEAD
+
+clean: .SYMBOLIC
+    @ echo * Clean: $(LIBNAME)
+    @if exist *.obj rm *.obj
+    @if exist *.err rm *.err
+    @if exist $(LNKFILE) rm $(LNKFILE)
+    @if exist $(LIBM) rm $(LIBM)
+
+distclean: .SYMBOLIC clean
+    @if exist $(LIBHOME)/*.exp rm $(LIBHOME)/*.exp
+    @if exist $(LIBHOME)/*.map rm $(LIBHOME)/*.map
+    @if exist $(LIBFILE) rm $(LIBFILE)
+    @if exist $(DLLFILE) rm $(DLLFILE)

+ 0 - 12
sdl.mod/SDL/VisualC/SDL/SDL.vcxproj

@@ -80,18 +80,6 @@
     <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
     <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x86;$(LibraryPath)</LibraryPath>
   </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <IncludePath>D:\dev\steam\rel\streaming_client\SDL\src\hidapi\hidapi;$(IncludePath)</IncludePath>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <IncludePath>D:\dev\steam\rel\streaming_client\SDL\src\hidapi\hidapi;$(IncludePath)</IncludePath>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
-    <IncludePath>D:\dev\steam\rel\streaming_client\SDL\src\hidapi\hidapi;$(IncludePath)</IncludePath>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
-    <IncludePath>D:\dev\steam\rel\streaming_client\SDL\src\hidapi\hidapi;$(IncludePath)</IncludePath>
-  </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <PreBuildEvent>
       <Command>

+ 1 - 0
sdl.mod/SDL/WhatsNew.txt

@@ -12,6 +12,7 @@ General:
 * Added an event SDL_DISPLAYEVENT which is sent when the display orientation changes
 * Added HIDAPI joystick drivers for more consistent support for Xbox, PS4 and Nintendo Switch Pro controller support across platforms. (Thanks to Valve for contributing the PS4 and Nintendo Switch Pro controller support)
 * Added support for many other popular game controllers
+* Added SDL_JoystickGetDevicePlayerIndex(), SDL_JoystickGetPlayerIndex(), and SDL_GameControllerGetPlayerIndex() to get the player index for a controller. For XInput controllers this returns the XInput index for the controller.
 * Added SDL_GameControllerRumble() and SDL_JoystickRumble() which allow simple rumble without using the haptics API
 * Added SDL_GameControllerMappingForDeviceIndex() to get the mapping for a controller before it's opened
 * Added the hint SDL_HINT_MOUSE_DOUBLE_CLICK_TIME to control the mouse double-click time

+ 2 - 0
sdl.mod/SDL/Xcode-iOS/Demos/Demos.xcodeproj/project.pbxproj

@@ -975,6 +975,7 @@
 		C01FCF4F08A954540054247B /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				GCC_OPTIMIZATION_LEVEL = 0;
 				HEADER_SEARCH_PATHS = ../../include;
@@ -988,6 +989,7 @@
 		C01FCF5008A954540054247B /* Release */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				HEADER_SEARCH_PATHS = ../../include;
 				PRELINK_LIBS = "";

+ 2 - 0
sdl.mod/SDL/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj

@@ -1973,6 +1973,7 @@
 		FD6526640DE8FCCB002AD96B /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
 				CLANG_ENABLE_OBJC_ARC = YES;
 				CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
 				CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
@@ -1989,6 +1990,7 @@
 		FD6526650DE8FCCB002AD96B /* Release */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
 				CLANG_ENABLE_OBJC_ARC = YES;
 				CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
 				CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;

+ 2 - 58
sdl.mod/SDL/Xcode-iOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj

@@ -26,34 +26,6 @@
 		047A63E813285C3200CD7973 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89D0E2D111A00EA573E /* Foundation.framework */; };
 		047A63E913285C3200CD7973 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89E0E2D111A00EA573E /* CoreAudio.framework */; };
 		047A63F113285CD100CD7973 /* checkkeys.c in Sources */ = {isa = PBXBuildFile; fileRef = 047A63F013285CD100CD7973 /* checkkeys.c */; };
-		55FFA91C212232BA00D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA91D212232BF00D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA91E212232BF00D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA91F212232C000D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA920212232C000D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA921212232C100D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA922212232C100D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA923212232C200D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA924212232C200D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA925212232C300D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA926212232C300D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA927212232C500D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA928212232C500D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA929212232C600D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA92A212232C600D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA92B212232C700D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA92C212232C700D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA92D212232C800D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA92E212232CA00D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA92F212232CA00D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA930212232CB00D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA931212232CB00D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA932212232CC00D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA933212232CC00D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA934212232CD00D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA935212232CE00D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA936212232CE00D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
-		55FFA937212232CF00D7CBED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */; };
 		56ED04FE118A8FE400A56AA6 /* icon.bmp in Resources */ = {isa = PBXBuildFile; fileRef = FDA8AAD90E2D33B000EA573E /* icon.bmp */; };
 		56ED0502118A8FE400A56AA6 /* libSDL2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FD1B48B80E3131CA007AB34E /* libSDL2.a */; };
 		56ED0503118A8FE400A56AA6 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A8980E2D111A00EA573E /* AudioToolbox.framework */; };
@@ -451,7 +423,6 @@
 		047A63ED13285C3200CD7973 /* checkkeys.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = checkkeys.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		047A63F013285CD100CD7973 /* checkkeys.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = checkkeys.c; sourceTree = "<group>"; };
 		1D6058910D05DD3D006BFB54 /* testwm2.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testwm2.app; sourceTree = BUILT_PRODUCTS_DIR; };
-		55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreBluetooth.framework; path = System/Library/Frameworks/CoreBluetooth.framework; sourceTree = SDKROOT; };
 		56ED050D118A8FE400A56AA6 /* testpower.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testpower.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		56ED0510118A904200A56AA6 /* testpower.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testpower.c; sourceTree = "<group>"; };
 		AA13B3261FB8AEBC00D9FEE6 /* testyuv.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testyuv.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -543,7 +514,6 @@
 				046CEF7F13254F23007AD51D /* CoreGraphics.framework in Frameworks */,
 				046CEF8013254F23007AD51D /* UIKit.framework in Frameworks */,
 				046CEF8113254F23007AD51D /* Foundation.framework in Frameworks */,
-				55FFA926212232C300D7CBED /* CoreBluetooth.framework in Frameworks */,
 				046CEF8213254F23007AD51D /* CoreAudio.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -552,7 +522,6 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				55FFA91C212232BA00D7CBED /* CoreBluetooth.framework in Frameworks */,
 				FABA34B01D8B5B6400915323 /* AVFoundation.framework in Frameworks */,
 				AA1EE470176059D00029C7A5 /* libSDL2test.a in Frameworks */,
 				047A63E213285C3200CD7973 /* libSDL2.a in Frameworks */,
@@ -575,7 +544,6 @@
 				FABA34C41D8B5BCB00915323 /* AVFoundation.framework in Frameworks */,
 				AA1EE47817605BF60029C7A5 /* libSDL2test.a in Frameworks */,
 				FDBDE5810E313465006BAC0B /* libSDL2.a in Frameworks */,
-				55FFA935212232CE00D7CBED /* CoreBluetooth.framework in Frameworks */,
 				FA684F931BAF1A8A00DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BE0196766F400F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDA8A89F0E2D111A00EA573E /* AudioToolbox.framework in Frameworks */,
@@ -602,7 +570,6 @@
 				56ED0506118A8FE400A56AA6 /* CoreGraphics.framework in Frameworks */,
 				56ED0507118A8FE400A56AA6 /* UIKit.framework in Frameworks */,
 				56ED0508118A8FE400A56AA6 /* Foundation.framework in Frameworks */,
-				55FFA92D212232C800D7CBED /* CoreBluetooth.framework in Frameworks */,
 				56ED0509118A8FE400A56AA6 /* CoreAudio.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -614,7 +581,6 @@
 				AA13B3171FB8AEBC00D9FEE6 /* AVFoundation.framework in Frameworks */,
 				AA13B3181FB8AEBC00D9FEE6 /* libSDL2test.a in Frameworks */,
 				AA13B3191FB8AEBC00D9FEE6 /* libSDL2.a in Frameworks */,
-				55FFA936212232CE00D7CBED /* CoreBluetooth.framework in Frameworks */,
 				AA13B31A1FB8AEBC00D9FEE6 /* GameController.framework in Frameworks */,
 				AA13B31B1FB8AEBC00D9FEE6 /* CoreMotion.framework in Frameworks */,
 				AA13B31C1FB8AEBC00D9FEE6 /* AudioToolbox.framework in Frameworks */,
@@ -634,7 +600,6 @@
 				FABA34BE1D8B5BB000915323 /* AVFoundation.framework in Frameworks */,
 				AA1EE47617605B9E0029C7A5 /* libSDL2test.a in Frameworks */,
 				AAE7DEE114CBB1E100DF1A0E /* libSDL2.a in Frameworks */,
-				55FFA92F212232CA00D7CBED /* CoreBluetooth.framework in Frameworks */,
 				FA684F8D1BAF1A7800DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BDA196766E200F8EB7C /* CoreMotion.framework in Frameworks */,
 				AAE7DEE214CBB1E100DF1A0E /* AudioToolbox.framework in Frameworks */,
@@ -655,7 +620,6 @@
 				FABA34BD1D8B5BAB00915323 /* AVFoundation.framework in Frameworks */,
 				AA1EE47517605B930029C7A5 /* libSDL2test.a in Frameworks */,
 				AAE7DFA614CBB54E00DF1A0E /* libSDL2.a in Frameworks */,
-				55FFA92E212232CA00D7CBED /* CoreBluetooth.framework in Frameworks */,
 				FA684F8C1BAF1A7400DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BD9196766E000F8EB7C /* CoreMotion.framework in Frameworks */,
 				AAE7DFA714CBB54E00DF1A0E /* AudioToolbox.framework in Frameworks */,
@@ -680,7 +644,6 @@
 				FA3D994D1BC4E6AD002C96C8 /* CoreGraphics.framework in Frameworks */,
 				FA3D994E1BC4E6AD002C96C8 /* UIKit.framework in Frameworks */,
 				FA3D994F1BC4E6AD002C96C8 /* Foundation.framework in Frameworks */,
-				55FFA925212232C300D7CBED /* CoreBluetooth.framework in Frameworks */,
 				FA3D99501BC4E6AD002C96C8 /* CoreAudio.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -699,7 +662,6 @@
 				FABA348A1D8B575200915323 /* CoreGraphics.framework in Frameworks */,
 				FABA348B1D8B575200915323 /* UIKit.framework in Frameworks */,
 				FABA348C1D8B575200915323 /* Foundation.framework in Frameworks */,
-				55FFA91D212232BF00D7CBED /* CoreBluetooth.framework in Frameworks */,
 				FABA348D1D8B575200915323 /* CoreAudio.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -718,7 +680,6 @@
 				FABA34A31D8B582100915323 /* CoreGraphics.framework in Frameworks */,
 				FABA34A41D8B582100915323 /* UIKit.framework in Frameworks */,
 				FABA34A51D8B582100915323 /* Foundation.framework in Frameworks */,
-				55FFA91F212232C000D7CBED /* CoreBluetooth.framework in Frameworks */,
 				FABA34A61D8B582100915323 /* CoreAudio.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -737,7 +698,6 @@
 				FAE0E98C1BAF9B230098DFA4 /* CoreGraphics.framework in Frameworks */,
 				FAE0E98D1BAF9B230098DFA4 /* UIKit.framework in Frameworks */,
 				FAE0E98E1BAF9B230098DFA4 /* Foundation.framework in Frameworks */,
-				55FFA924212232C200D7CBED /* CoreBluetooth.framework in Frameworks */,
 				FAE0E98F1BAF9B230098DFA4 /* CoreAudio.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -756,7 +716,6 @@
 				FDA8AAB40E2D330F00EA573E /* CoreGraphics.framework in Frameworks */,
 				FDA8AAB50E2D330F00EA573E /* UIKit.framework in Frameworks */,
 				FDA8AAB60E2D330F00EA573E /* Foundation.framework in Frameworks */,
-				55FFA91E212232BF00D7CBED /* CoreBluetooth.framework in Frameworks */,
 				FDA8AAB70E2D330F00EA573E /* CoreAudio.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -775,7 +734,6 @@
 				FDAAC3C60E2D47E6001DB1D8 /* CoreGraphics.framework in Frameworks */,
 				FDAAC3C70E2D47E6001DB1D8 /* UIKit.framework in Frameworks */,
 				FDAAC3C80E2D47E6001DB1D8 /* Foundation.framework in Frameworks */,
-				55FFA920212232C000D7CBED /* CoreBluetooth.framework in Frameworks */,
 				FDAAC3C90E2D47E6001DB1D8 /* CoreAudio.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -794,7 +752,6 @@
 				FDAAC5940E2D5429001DB1D8 /* CoreGraphics.framework in Frameworks */,
 				FDAAC5950E2D5429001DB1D8 /* UIKit.framework in Frameworks */,
 				FDAAC5960E2D5429001DB1D8 /* Foundation.framework in Frameworks */,
-				55FFA923212232C200D7CBED /* CoreBluetooth.framework in Frameworks */,
 				FDAAC5970E2D5429001DB1D8 /* CoreAudio.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -813,7 +770,6 @@
 				FDAAC5C20E2D55B5001DB1D8 /* CoreGraphics.framework in Frameworks */,
 				FDAAC5C30E2D55B5001DB1D8 /* UIKit.framework in Frameworks */,
 				FDAAC5C40E2D55B5001DB1D8 /* Foundation.framework in Frameworks */,
-				55FFA922212232C100D7CBED /* CoreBluetooth.framework in Frameworks */,
 				FDAAC5C50E2D55B5001DB1D8 /* CoreAudio.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -825,7 +781,6 @@
 				FABA34B61D8B5B8900915323 /* AVFoundation.framework in Frameworks */,
 				AA1EE47417605B5C0029C7A5 /* libSDL2test.a in Frameworks */,
 				FDBDE57C0E313445006BAC0B /* libSDL2.a in Frameworks */,
-				55FFA927212232C500D7CBED /* CoreBluetooth.framework in Frameworks */,
 				FA684F851BAF1A6000DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BD2196766CB00F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDAAC61C0E2D5914001DB1D8 /* AudioToolbox.framework in Frameworks */,
@@ -846,7 +801,6 @@
 				FABA34B21D8B5B7300915323 /* AVFoundation.framework in Frameworks */,
 				AA1EE47117605A7F0029C7A5 /* libSDL2test.a in Frameworks */,
 				FDC42FF40F0D866D009C87E1 /* libSDL2.a in Frameworks */,
-				55FFA921212232C100D7CBED /* CoreBluetooth.framework in Frameworks */,
 				FA684F811BAF1A5300DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BCE196766C100F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDC42FF60F0D866D009C87E1 /* AudioToolbox.framework in Frameworks */,
@@ -873,7 +827,6 @@
 				FDD2C1030E2E4F4B00B7A85F /* CoreGraphics.framework in Frameworks */,
 				FDD2C1040E2E4F4B00B7A85F /* UIKit.framework in Frameworks */,
 				FDD2C1050E2E4F4B00B7A85F /* Foundation.framework in Frameworks */,
-				55FFA932212232CC00D7CBED /* CoreBluetooth.framework in Frameworks */,
 				FDD2C1060E2E4F4B00B7A85F /* CoreAudio.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -892,7 +845,6 @@
 				FDD2C17A0E2E52C000B7A85F /* CoreGraphics.framework in Frameworks */,
 				FDD2C17B0E2E52C000B7A85F /* UIKit.framework in Frameworks */,
 				FDD2C17C0E2E52C000B7A85F /* Foundation.framework in Frameworks */,
-				55FFA928212232C500D7CBED /* CoreBluetooth.framework in Frameworks */,
 				FDD2C17D0E2E52C000B7A85F /* CoreAudio.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -911,7 +863,6 @@
 				FDD2C19E0E2E534F00B7A85F /* CoreGraphics.framework in Frameworks */,
 				FDD2C19F0E2E534F00B7A85F /* UIKit.framework in Frameworks */,
 				FDD2C1A00E2E534F00B7A85F /* Foundation.framework in Frameworks */,
-				55FFA929212232C600D7CBED /* CoreBluetooth.framework in Frameworks */,
 				FDD2C1A10E2E534F00B7A85F /* CoreAudio.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -930,7 +881,6 @@
 				FDD2C4570E2E773800B7A85F /* CoreGraphics.framework in Frameworks */,
 				FDD2C4580E2E773800B7A85F /* UIKit.framework in Frameworks */,
 				FDD2C4590E2E773800B7A85F /* Foundation.framework in Frameworks */,
-				55FFA92A212232C600D7CBED /* CoreBluetooth.framework in Frameworks */,
 				FDD2C45A0E2E773800B7A85F /* CoreAudio.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -949,7 +899,6 @@
 				FDD2C4750E2E77D700B7A85F /* CoreGraphics.framework in Frameworks */,
 				FDD2C4760E2E77D700B7A85F /* UIKit.framework in Frameworks */,
 				FDD2C4770E2E77D700B7A85F /* Foundation.framework in Frameworks */,
-				55FFA92B212232C700D7CBED /* CoreBluetooth.framework in Frameworks */,
 				FDD2C4780E2E77D700B7A85F /* CoreAudio.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -968,7 +917,6 @@
 				FDD2C5040E2E7F4800B7A85F /* CoreGraphics.framework in Frameworks */,
 				FDD2C5050E2E7F4800B7A85F /* UIKit.framework in Frameworks */,
 				FDD2C5060E2E7F4800B7A85F /* Foundation.framework in Frameworks */,
-				55FFA92C212232C700D7CBED /* CoreBluetooth.framework in Frameworks */,
 				FDD2C5070E2E7F4800B7A85F /* CoreAudio.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -987,7 +935,6 @@
 				FDD2C5220E2E807600B7A85F /* CoreGraphics.framework in Frameworks */,
 				FDD2C5230E2E807600B7A85F /* UIKit.framework in Frameworks */,
 				FDD2C5240E2E807600B7A85F /* Foundation.framework in Frameworks */,
-				55FFA930212232CB00D7CBED /* CoreBluetooth.framework in Frameworks */,
 				FDD2C5250E2E807600B7A85F /* CoreAudio.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -1000,7 +947,6 @@
 				FABA34C01D8B5BBA00915323 /* AVFoundation.framework in Frameworks */,
 				AA1EE47717605BAB0029C7A5 /* libSDL2test.a in Frameworks */,
 				FDBDE5CA0E313712006BAC0B /* libSDL2.a in Frameworks */,
-				55FFA931212232CB00D7CBED /* CoreBluetooth.framework in Frameworks */,
 				FA684F8F1BAF1A7E00DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BDC196766E800F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDD2C5440E2E80E400B7A85F /* AudioToolbox.framework in Frameworks */,
@@ -1027,7 +973,6 @@
 				FDD2C5800E2E8C7400B7A85F /* CoreGraphics.framework in Frameworks */,
 				FDD2C5810E2E8C7400B7A85F /* UIKit.framework in Frameworks */,
 				FDD2C5820E2E8C7400B7A85F /* Foundation.framework in Frameworks */,
-				55FFA934212232CD00D7CBED /* CoreBluetooth.framework in Frameworks */,
 				FDD2C5830E2E8C7400B7A85F /* CoreAudio.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -1046,7 +991,6 @@
 				FDD2C5BE0E2E8CFC00B7A85F /* CoreGraphics.framework in Frameworks */,
 				FDD2C5BF0E2E8CFC00B7A85F /* UIKit.framework in Frameworks */,
 				FDD2C5C00E2E8CFC00B7A85F /* Foundation.framework in Frameworks */,
-				55FFA933212232CC00D7CBED /* CoreBluetooth.framework in Frameworks */,
 				FDD2C5C10E2E8CFC00B7A85F /* CoreAudio.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -1065,7 +1009,6 @@
 				FDD2C6ED0E2E959E00B7A85F /* CoreGraphics.framework in Frameworks */,
 				FDD2C6EE0E2E959E00B7A85F /* UIKit.framework in Frameworks */,
 				FDD2C6EF0E2E959E00B7A85F /* Foundation.framework in Frameworks */,
-				55FFA937212232CF00D7CBED /* CoreBluetooth.framework in Frameworks */,
 				FDD2C6F00E2E959E00B7A85F /* CoreAudio.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -1188,7 +1131,6 @@
 		FDA8A7C30E2D10FA00EA573E /* Frameworks */ = {
 			isa = PBXGroup;
 			children = (
-				55FFA91B212232BA00D7CBED /* CoreBluetooth.framework */,
 				FA684F7A1BAF1A4400DCFD1A /* GameController.framework */,
 				FA8B4BAC1967076F00F8EB7C /* CoreMotion.framework */,
 				FDA8A8980E2D111A00EA573E /* AudioToolbox.framework */,
@@ -2384,6 +2326,7 @@
 		C01FCF4F08A954540054247B /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				ENABLE_BITCODE = NO;
 				GCC_OPTIMIZATION_LEVEL = 0;
@@ -2400,6 +2343,7 @@
 		C01FCF5008A954540054247B /* Release */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				ENABLE_BITCODE = NO;
 				HEADER_SEARCH_PATHS = ../../include;

+ 10 - 0
sdl.mod/SDL/Xcode/SDL/SDL.xcodeproj/project.pbxproj

@@ -3107,6 +3107,7 @@
 		00CFA621106A567900758660 /* Release */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
 				CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
 				CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
 				CLANG_WARN_BOOL_CONVERSION = YES;
@@ -3155,6 +3156,7 @@
 		00CFA622106A567900758660 /* Release */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
 				CLANG_LINK_OBJC_RUNTIME = NO;
 				COMBINE_HIDPI_IMAGES = YES;
 				DYLIB_COMPATIBILITY_VERSION = 1.0.0;
@@ -3177,6 +3179,7 @@
 		00CFA623106A567900758660 /* Release */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
 				COMBINE_HIDPI_IMAGES = YES;
 				GCC_PREPROCESSOR_DEFINITIONS = (
 					"$(GCC_PREPROCESSOR_DEFINITIONS)",
@@ -3194,6 +3197,7 @@
 		00CFA625106A567900758660 /* Release */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
 				PRODUCT_NAME = "Standard DMG";
 				PROVISIONING_PROFILE = "";
 			};
@@ -3202,6 +3206,7 @@
 		00CFA627106A568900758660 /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
 				CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
 				CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
 				CLANG_WARN_BOOL_CONVERSION = YES;
@@ -3250,6 +3255,7 @@
 		00CFA628106A568900758660 /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
 				CLANG_LINK_OBJC_RUNTIME = NO;
 				COMBINE_HIDPI_IMAGES = YES;
 				DYLIB_COMPATIBILITY_VERSION = 1.0.0;
@@ -3272,6 +3278,7 @@
 		00CFA629106A568900758660 /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
 				COMBINE_HIDPI_IMAGES = YES;
 				GCC_PREPROCESSOR_DEFINITIONS = (
 					"$(GCC_PREPROCESSOR_DEFINITIONS)",
@@ -3289,6 +3296,7 @@
 		00CFA62B106A568900758660 /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
 				PRODUCT_NAME = "Standard DMG";
 				PROVISIONING_PROFILE = "";
 			};
@@ -3297,6 +3305,7 @@
 		DB31407517554B71006C0E22 /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
 				COMBINE_HIDPI_IMAGES = YES;
 				EXECUTABLE_PREFIX = lib;
 				GCC_PREPROCESSOR_DEFINITIONS = (
@@ -3316,6 +3325,7 @@
 		DB31407617554B71006C0E22 /* Release */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
 				COMBINE_HIDPI_IMAGES = YES;
 				EXECUTABLE_PREFIX = lib;
 				GCC_PREPROCESSOR_DEFINITIONS = (

+ 2 - 0
sdl.mod/SDL/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj

@@ -4040,6 +4040,7 @@
 		002A85B21073008E007319AE /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(SRCROOT)/../SDL/build/$(CONFIGURATION)",
 					"$(HOME)/Library/Frameworks",
@@ -4166,6 +4167,7 @@
 		002A85D41073009D007319AE /* Release */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(SRCROOT)/../SDL/build/$(CONFIGURATION)",
 					"$(HOME)/Library/Frameworks",

+ 1 - 77
sdl.mod/SDL/android-project-ant/AndroidManifest.xml

@@ -1,77 +1 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Replace com.test.game with the identifier of your game below, e.g.
-     com.gamemaker.game
--->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="org.libsdl.app"
-    android:versionCode="1"
-    android:versionName="1.0"
-    android:installLocation="auto">
-
-    <!-- Android 4.0.1 -->
-    <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="16" />
-
-    <!-- OpenGL ES 2.0 -->
-    <uses-feature android:glEsVersion="0x00020000" />
-
-    <!-- Touchscreen support -->
-    <uses-feature
-        android:name="android.hardware.touchscreen"
-        android:required="false" />
-
-    <!-- Game controller support -->
-    <uses-feature
-        android:name="android.hardware.gamepad"
-        android:required="false" />
-
-    <!-- External mouse input events -->
-    <uses-feature
-        android:name="android.hardware.type.pc"
-        android:required="false" />
-
-    <!-- Allow writing to external storage -->
-    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
-    <!-- Allow access to the vibrator -->
-    <uses-permission android:name="android.permission.VIBRATE" />
-
-    <!-- if you want to capture audio, uncomment this. -->
-    <!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->
-
-    <!-- Create a Java class extending SDLActivity and place it in a
-         directory under app/src/main/java matching the package, e.g. app/src/main/java/com/gamemaker/game/MyGame.java
- 
-         then replace "SDLActivity" with the name of your class (e.g. "MyGame")
-         in the XML below.
-
-         An example Java class can be found in README-android.md
-    -->
-    <application android:label="@string/app_name"
-        android:icon="@mipmap/ic_launcher"
-        android:allowBackup="true"
-        android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
-        android:hardwareAccelerated="true" >
-
-        <!-- Example of setting SDL hints from AndroidManifest.xml:
-        <meta-data android:name="SDL_ENV.SDL_ACCELEROMETER_AS_JOYSTICK" android:value="0"/>
-         -->
-     
-        <activity android:name="SDLActivity"
-            android:label="@string/app_name"
-            android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
-            >
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.LAUNCHER" />
-            </intent-filter>
-            <!-- Drop file event -->
-            <!--
-            <intent-filter>
-                <action android:name="android.intent.action.VIEW" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <data android:mimeType="*/*" />
-            </intent-filter>
-            -->
-        </activity>
-    </application>
-
-</manifest>
+../android-project/app/src/main/AndroidManifest.xml

+ 1 - 0
sdl.mod/SDL/android-project-ant/src

@@ -0,0 +1 @@
+../android-project/app/src/main/java

+ 2 - 8
sdl.mod/SDL/android-project/app/build.gradle

@@ -9,7 +9,6 @@ else {
 
 android {
     compileSdkVersion 26
-    buildToolsVersion "26.0.1"
     defaultConfig {
         if (buildAsApplication) {
             applicationId "org.libsdl.app"
@@ -21,10 +20,9 @@ android {
         externalNativeBuild {
             ndkBuild {
                 arguments "APP_PLATFORM=android-14"
-                abiFilters 'armeabi-v7a', 'x86'
+                abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
             }
         }
-        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
     }
     buildTypes {
         release {
@@ -61,9 +59,5 @@ android {
 }
 
 dependencies {
-    compile fileTree(include: ['*.jar'], dir: 'libs')
-    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
-        exclude group: 'com.android.support', module: 'support-annotations'
-    })
-    testCompile 'junit:junit:4.12'
+    implementation fileTree(include: ['*.jar'], dir: 'libs')
 }

+ 3 - 2
sdl.mod/SDL/android-project/app/jni/Application.mk

@@ -1,7 +1,8 @@
 
 # Uncomment this if you're using STL in your project
-# See CPLUSPLUS-SUPPORT.html in the NDK documentation for more information
-# APP_STL := stlport_static
+# You can find more information here:
+# https://developer.android.com/ndk/guides/cpp-support
+# APP_STL := c++_shared
 
 APP_ABI := armeabi-v7a arm64-v8a x86 x86_64
 

+ 0 - 3
sdl.mod/SDL/android-project/app/src/main/AndroidManifest.xml

@@ -8,9 +8,6 @@
     android:versionName="1.0"
     android:installLocation="auto">
 
-    <!-- Android 4.0.1 -->
-    <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="16" />
-
     <!-- OpenGL ES 2.0 -->
     <uses-feature android:glEsVersion="0x00020000" />
 

+ 11 - 7
sdl.mod/SDL/android-project/app/src/main/java/org/libsdl/app/HIDDeviceBLESteamController.java

@@ -12,12 +12,11 @@ import android.bluetooth.BluetoothGattService;
 import android.os.Handler;
 import android.os.Looper;
 import android.util.Log;
+import android.os.*;
 
 //import com.android.internal.util.HexDump;
 
 import java.lang.Runnable;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.UUID;
@@ -186,10 +185,13 @@ class HIDDeviceBLESteamController extends BluetoothGattCallback implements HIDDe
     // Because on Chromebooks we show up as a dual-mode device, it will attempt to connect TRANSPORT_AUTO, which will use TRANSPORT_BREDR instead
     // of TRANSPORT_LE.  Let's force ourselves to connect low energy.
     private BluetoothGatt connectGatt(boolean managed) {
-        try {
-            Method m = mDevice.getClass().getDeclaredMethod("connectGatt", Context.class, boolean.class, BluetoothGattCallback.class, int.class);
-            return (BluetoothGatt) m.invoke(mDevice, mManager.getContext(), managed, this, TRANSPORT_LE);
-        } catch (Exception e) {
+        if (Build.VERSION.SDK_INT >= 23) {
+            try {
+                return mDevice.connectGatt(mManager.getContext(), managed, this, TRANSPORT_LE);
+            } catch (Exception e) {
+                return mDevice.connectGatt(mManager.getContext(), managed, this);
+            }
+        } else {
             return mDevice.connectGatt(mManager.getContext(), managed, this);
         }
     }
@@ -577,7 +579,7 @@ class HIDDeviceBLESteamController extends BluetoothGattCallback implements HIDDe
         }
 
         // We need to skip the first byte, as that doesn't go over the air
-	byte[] actual_report = Arrays.copyOfRange(report, 1, report.length - 1);
+        byte[] actual_report = Arrays.copyOfRange(report, 1, report.length - 1);
         //Log.v(TAG, "sendFeatureReport " + HexDump.dumpHexString(actual_report));
         writeCharacteristic(reportCharacteristic, actual_report);
         return report.length;
@@ -624,6 +626,8 @@ class HIDDeviceBLESteamController extends BluetoothGattCallback implements HIDDe
 
     @Override
     public void shutdown() {
+        close();
+
         BluetoothGatt g = mGatt;
         if (g != null) {
             g.disconnect();

+ 76 - 18
sdl.mod/SDL/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java

@@ -1,5 +1,7 @@
 package org.libsdl.app;
 
+import android.app.Activity;
+import android.app.AlertDialog;
 import android.app.PendingIntent;
 import android.bluetooth.BluetoothAdapter;
 import android.bluetooth.BluetoothDevice;
@@ -8,6 +10,7 @@ import android.bluetooth.BluetoothProfile;
 import android.util.Log;
 import android.content.BroadcastReceiver;
 import android.content.Context;
+import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.SharedPreferences;
@@ -24,7 +27,28 @@ public class HIDDeviceManager {
     private static final String TAG = "hidapi";
     private static final String ACTION_USB_PERMISSION = "org.libsdl.app.USB_PERMISSION";
 
-    protected Context mContext;
+    private static HIDDeviceManager sManager;
+    private static int sManagerRefCount = 0;
+
+    public static HIDDeviceManager acquire(Context context) {
+        if (sManagerRefCount == 0) {
+            sManager = new HIDDeviceManager(context);
+        }
+        ++sManagerRefCount;
+        return sManager;
+    }
+
+    public static void release(HIDDeviceManager manager) {
+        if (manager == sManager) {
+            --sManagerRefCount;
+            if (sManagerRefCount == 0) {
+                sManager.close();
+                sManager = null;
+            }
+        }
+    }
+
+    private Context mContext;
     private HashMap<Integer, HIDDevice> mDevicesById = new HashMap<Integer, HIDDevice>();
     private HashMap<UsbDevice, HIDDeviceUSB> mUSBDevices = new HashMap<UsbDevice, HIDDeviceUSB>();
     private HashMap<BluetoothDevice, HIDDeviceBLESteamController> mBluetoothDevices = new HashMap<BluetoothDevice, HIDDeviceBLESteamController>();
@@ -77,10 +101,40 @@ public class HIDDeviceManager {
         }
     };
 
-    public HIDDeviceManager(Context context) {
+    private HIDDeviceManager(final Context context) {
         mContext = context;
 
-        HIDDeviceRegisterCallback(this);
+        // Make sure we have the HIDAPI library loaded with the native functions
+        try {
+            SDL.loadLibrary("hidapi");
+        } catch (Throwable e) {
+            Log.w(TAG, "Couldn't load hidapi: " + e.toString());
+
+            AlertDialog.Builder builder = new AlertDialog.Builder(context);
+            builder.setCancelable(false);
+            builder.setTitle("SDL HIDAPI Error");
+            builder.setMessage("Please report the following error to the SDL maintainers: " + e.getMessage());
+            builder.setNegativeButton("Quit", new DialogInterface.OnClickListener() {
+                @Override
+                public void onClick(DialogInterface dialog, int which) {
+                    try {
+                        // If our context is an activity, exit rather than crashing when we can't
+                        // call our native functions.
+                        Activity activity = (Activity)context;
+        
+                        activity.finish();
+                    }
+                    catch (ClassCastException cce) {
+                        // Context wasn't an activity, there's nothing we can do.  Give up and return.
+                    }
+                }
+            });
+            builder.show();
+
+            return;
+        }
+        
+        HIDDeviceRegisterCallback();
 
         mSharedPreferences = mContext.getSharedPreferences("hidapi", Context.MODE_PRIVATE);
         mIsChromebook = mContext.getPackageManager().hasSystemFeature("org.chromium.arc.device_management");
@@ -117,7 +171,7 @@ public class HIDDeviceManager {
         return result;
     }
 
-    protected void initializeUSB() {
+    private void initializeUSB() {
         mUsbManager = (UsbManager)mContext.getSystemService(Context.USB_SERVICE);
 
         /*
@@ -179,11 +233,15 @@ public class HIDDeviceManager {
         return mUsbManager;
     }
 
-    protected void shutdownUSB() {
-        mContext.unregisterReceiver(mUsbBroadcast);
+    private void shutdownUSB() {
+        try {
+            mContext.unregisterReceiver(mUsbBroadcast);
+        } catch (Exception e) {
+            // We may not have registered, that's okay
+        }
     }
 
-    protected boolean isHIDDeviceUSB(UsbDevice usbDevice) {
+    private boolean isHIDDeviceUSB(UsbDevice usbDevice) {
         for (int interface_number = 0; interface_number < usbDevice.getInterfaceCount(); ++interface_number) {
             if (isHIDDeviceInterface(usbDevice, interface_number)) {
                 return true;
@@ -192,7 +250,7 @@ public class HIDDeviceManager {
         return false;
     }
 
-    protected boolean isHIDDeviceInterface(UsbDevice usbDevice, int interface_number) {
+    private boolean isHIDDeviceInterface(UsbDevice usbDevice, int interface_number) {
         UsbInterface usbInterface = usbDevice.getInterface(interface_number);
         if (usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_HID) {
             return true;
@@ -205,7 +263,7 @@ public class HIDDeviceManager {
         return false;
     }
 
-    protected boolean isXbox360Controller(UsbDevice usbDevice, UsbInterface usbInterface) {
+    private boolean isXbox360Controller(UsbDevice usbDevice, UsbInterface usbInterface) {
         final int XB360_IFACE_SUBCLASS = 93;
         final int XB360_IFACE_PROTOCOL = 1; // Wired only
         final int[] SUPPORTED_VENDORS = {
@@ -244,7 +302,7 @@ public class HIDDeviceManager {
         return false;
     }
 
-    protected boolean isXboxOneController(UsbDevice usbDevice, UsbInterface usbInterface) {
+    private boolean isXboxOneController(UsbDevice usbDevice, UsbInterface usbInterface) {
         final int XB1_IFACE_SUBCLASS = 71;
         final int XB1_IFACE_PROTOCOL = 208;
         final int[] SUPPORTED_VENDORS = {
@@ -269,13 +327,13 @@ public class HIDDeviceManager {
         return false;
     }
 
-    protected void handleUsbDeviceAttached(UsbDevice usbDevice) {
+    private void handleUsbDeviceAttached(UsbDevice usbDevice) {
         if (isHIDDeviceUSB(usbDevice)) {
             connectHIDDeviceUSB(usbDevice);
         }
     }
 
-    protected void handleUsbDeviceDetached(UsbDevice usbDevice) {
+    private void handleUsbDeviceDetached(UsbDevice usbDevice) {
         HIDDeviceUSB device = mUSBDevices.get(usbDevice);
         if (device == null)
             return;
@@ -287,7 +345,7 @@ public class HIDDeviceManager {
         HIDDeviceDisconnected(id);
     }
 
-    protected void handleUsbDevicePermission(UsbDevice usbDevice, boolean permission_granted) {
+    private void handleUsbDevicePermission(UsbDevice usbDevice, boolean permission_granted) {
         HIDDeviceUSB device = mUSBDevices.get(usbDevice);
         if (device == null)
             return;
@@ -299,7 +357,7 @@ public class HIDDeviceManager {
         HIDDeviceOpenResult(device.getId(), opened);
     }
 
-    protected void connectHIDDeviceUSB(UsbDevice usbDevice) {
+    private void connectHIDDeviceUSB(UsbDevice usbDevice) {
         synchronized (this) {
             for (int interface_number = 0; interface_number < usbDevice.getInterfaceCount(); interface_number++) {
                 if (isHIDDeviceInterface(usbDevice, interface_number)) {
@@ -314,7 +372,7 @@ public class HIDDeviceManager {
         }
     }
 
-    protected void initializeBluetooth() {
+    private void initializeBluetooth() {
         Log.d(TAG, "Initializing Bluetooth");
 
         if (mContext.getPackageManager().checkPermission(android.Manifest.permission.BLUETOOTH, mContext.getPackageName()) != PackageManager.PERMISSION_GRANTED) {
@@ -365,7 +423,7 @@ public class HIDDeviceManager {
         }
     }
 
-    protected void shutdownBluetooth() {
+    private void shutdownBluetooth() {
         try {
             mContext.unregisterReceiver(mBluetoothBroadcast);
         } catch (Exception e) {
@@ -464,7 +522,7 @@ public class HIDDeviceManager {
         return bluetoothDevice.getName().equals("SteamController") && ((bluetoothDevice.getType() & BluetoothDevice.DEVICE_TYPE_LE) != 0);
     }
 
-    public void close() {
+    private void close() {
         shutdownUSB();
         shutdownBluetooth();
         synchronized (this) {
@@ -611,7 +669,7 @@ public class HIDDeviceManager {
     /////////////// Native methods
     //////////////////////////////////////////////////////////////////////////////////////////////////////
 
-    private native void HIDDeviceRegisterCallback(Object callbackHandler);
+    private native void HIDDeviceRegisterCallback();
     private native void HIDDeviceReleaseCallback();
 
     native void HIDDeviceConnected(int deviceID, String identifier, int vendorId, int productId, String serial_number, int release_number, String manufacturer_string, String product_string, int interface_number);

+ 10 - 1
sdl.mod/SDL/android-project/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java

@@ -276,7 +276,16 @@ class HIDDeviceUSB implements HIDDevice {
             int packetSize = mInputEndpoint.getMaxPacketSize();
             byte[] packet = new byte[packetSize];
             while (mRunning) {
-                int r = mConnection.bulkTransfer(mInputEndpoint, packet, packetSize, 1000);
+                int r;
+                try
+                {
+                    r = mConnection.bulkTransfer(mInputEndpoint, packet, packetSize, 1000);
+                }
+                catch (Exception e)
+                {
+                    Log.v(TAG, "Exception in UsbDeviceConnection bulktransfer: " + e);
+                    break;
+                }
                 if (r < 0) {
                     // Could be a timeout or an I/O error
                 }

+ 47 - 0
sdl.mod/SDL/android-project/app/src/main/java/org/libsdl/app/SDL.java

@@ -2,6 +2,8 @@ package org.libsdl.app;
 
 import android.content.Context;
 
+import java.lang.reflect.*;
+
 /**
     SDL library initialization
 */
@@ -33,5 +35,50 @@ public class SDL {
         return mContext;
     }
 
+    public static void loadLibrary(String libraryName) throws UnsatisfiedLinkError, SecurityException, NullPointerException {
+
+        if (libraryName == null) {
+            throw new NullPointerException("No library name provided.");
+        }
+
+        try {
+            // Let's see if we have ReLinker available in the project.  This is necessary for 
+            // some projects that have huge numbers of local libraries bundled, and thus may 
+            // trip a bug in Android's native library loader which ReLinker works around.  (If
+            // loadLibrary works properly, ReLinker will simply use the normal Android method
+            // internally.)
+            //
+            // To use ReLinker, just add it as a dependency.  For more information, see 
+            // https://github.com/KeepSafe/ReLinker for ReLinker's repository.
+            //
+            Class relinkClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker");
+            Class relinkListenerClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener");
+            Class contextClass = mContext.getClassLoader().loadClass("android.content.Context");
+            Class stringClass = mContext.getClassLoader().loadClass("java.lang.String");
+
+            // Get a 'force' instance of the ReLinker, so we can ensure libraries are reinstalled if 
+            // they've changed during updates.
+            Method forceMethod = relinkClass.getDeclaredMethod("force");
+            Object relinkInstance = forceMethod.invoke(null);
+            Class relinkInstanceClass = relinkInstance.getClass();
+
+            // Actually load the library!
+            Method loadMethod = relinkInstanceClass.getDeclaredMethod("loadLibrary", contextClass, stringClass, stringClass, relinkListenerClass);
+            loadMethod.invoke(relinkInstance, mContext, libraryName, null, null);
+        }
+        catch (final Throwable e) {
+            // Fall back
+            try {
+                System.loadLibrary(libraryName);
+            }
+            catch (final UnsatisfiedLinkError ule) {
+                throw ule;
+            }
+            catch (final SecurityException se) {
+                throw se;
+            }
+        }        
+    }
+
     protected static Context mContext;
 }

+ 81 - 39
sdl.mod/SDL/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java

@@ -86,7 +86,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
     protected static boolean mScreenKeyboardShown;
     protected static ViewGroup mLayout;
     protected static SDLClipboardHandler mClipboardHandler;
-    protected static Hashtable<Integer, Object> mCursors;
+    protected static Hashtable<Integer, PointerIcon> mCursors;
     protected static int mLastCursorID;
     protected static SDLGenericMotionListener_API12 mMotionListener;
     protected static HIDDeviceManager mHIDDeviceManager;
@@ -154,7 +154,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
     // Load the .so
     public void loadLibraries() {
        for (String lib : getLibraries()) {
-          System.loadLibrary(lib);
+          SDL.loadLibrary(lib);
        }
     }
 
@@ -176,7 +176,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
         mTextEdit = null;
         mLayout = null;
         mClipboardHandler = null;
-        mCursors = new Hashtable<Integer, Object>();
+        mCursors = new Hashtable<Integer, PointerIcon>();
         mLastCursorID = 0;
         mSDLThread = null;
         mExitCalledFromJava = false;
@@ -191,8 +191,8 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
     // Setup
     @Override
     protected void onCreate(Bundle savedInstanceState) {
-        Log.v(TAG, "Device: " + android.os.Build.DEVICE);
-        Log.v(TAG, "Model: " + android.os.Build.MODEL);
+        Log.v(TAG, "Device: " + Build.DEVICE);
+        Log.v(TAG, "Model: " + Build.MODEL);
         Log.v(TAG, "onCreate()");
         super.onCreate(savedInstanceState);
 
@@ -250,7 +250,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
             mClipboardHandler = new SDLClipboardHandler_Old();
         }
 
-        mHIDDeviceManager = new HIDDeviceManager(this);
+        mHIDDeviceManager = HIDDeviceManager.acquire(this);
 
         // Set up the surface
         mSurface = new SDLSurface(getApplication());
@@ -380,7 +380,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
         Log.v(TAG, "onDestroy()");
 
         if (mHIDDeviceManager != null) {
-            mHIDDeviceManager.close();
+            HIDDeviceManager.release(mHIDDeviceManager);
             mHIDDeviceManager = null;
         }
 
@@ -645,15 +645,54 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
         msg.obj = data;
         boolean result = commandHandler.sendMessage(msg);
 
-        // Ensure we don't return until the resize has actually happened,
-        // or 250ms have passed.
-        if (command == COMMAND_CHANGE_WINDOW_STYLE) {
-            synchronized(SDLActivity.getContext()) {
-                try {
-                    SDLActivity.getContext().wait(250);
+        if ((Build.VERSION.SDK_INT >= 19) && (command == COMMAND_CHANGE_WINDOW_STYLE)) {
+            // Ensure we don't return until the resize has actually happened,
+            // or 500ms have passed.
+
+            boolean bShouldWait = false;
+            
+            if (data instanceof Integer) {
+                // Let's figure out if we're already laid out fullscreen or not.
+                Display display = ((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
+                android.util.DisplayMetrics realMetrics = new android.util.DisplayMetrics();
+                display.getRealMetrics( realMetrics );
+        
+                boolean bFullscreenLayout = ((realMetrics.widthPixels == mSurface.getWidth()) && 
+                                             (realMetrics.heightPixels == mSurface.getHeight()));
+
+                if (((Integer)data).intValue() == 1) {
+                    // If we aren't laid out fullscreen or actively in fullscreen mode already, we're going
+                    // to change size and should wait for surfaceChanged() before we return, so the size
+                    // is right back in native code.  If we're already laid out fullscreen, though, we're
+                    // not going to change size even if we change decor modes, so we shouldn't wait for
+                    // surfaceChanged() -- which may not even happen -- and should return immediately.
+                    bShouldWait = !bFullscreenLayout;
                 }
-                catch (InterruptedException ie) {
-                    ie.printStackTrace();
+                else {
+                    // If we're laid out fullscreen (even if the status bar and nav bar are present),
+                    // or are actively in fullscreen, we're going to change size and should wait for
+                    // surfaceChanged before we return, so the size is right back in native code.
+                    bShouldWait = bFullscreenLayout;
+                }
+            }
+
+            if (bShouldWait) {
+                // We'll wait for the surfaceChanged() method, which will notify us
+                // when called.  That way, we know our current size is really the
+                // size we need, instead of grabbing a size that's still got
+                // the navigation and/or status bars before they're hidden.
+                //
+                // We'll wait for up to half a second, because some devices 
+                // take a surprisingly long time for the surface resize, but
+                // then we'll just give up and return.
+                //
+                synchronized(SDLActivity.getContext()) {
+                    try {
+                        SDLActivity.getContext().wait(500);
+                    }
+                    catch (InterruptedException ie) {
+                        ie.printStackTrace();
+                    }
                 }
             }
         }
@@ -835,6 +874,9 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
         if (Build.MANUFACTURER.equals("MINIX") && Build.MODEL.equals("NEO-U1")) {
             return true;
         }
+        if (Build.MANUFACTURER.equals("Amlogic") && Build.MODEL.equals("X96-W")) {
+            return true;
+        }
         return false;
     }
 
@@ -1337,13 +1379,14 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
     public static int createCustomCursor(int[] colors, int width, int height, int hotSpotX, int hotSpotY) {
         Bitmap bitmap = Bitmap.createBitmap(colors, width, height, Bitmap.Config.ARGB_8888);
         ++mLastCursorID;
-        // This requires API 24, so use reflection to implement this
-        try {
-            Class PointerIconClass = Class.forName("android.view.PointerIcon");
-            Class[] arg_types = new Class[] { Bitmap.class, float.class, float.class };
-            Method create = PointerIconClass.getMethod("create", arg_types);
-            mCursors.put(mLastCursorID, create.invoke(null, bitmap, hotSpotX, hotSpotY));
-        } catch (Exception e) {
+
+        if (Build.VERSION.SDK_INT >= 24) {
+            try {
+                mCursors.put(mLastCursorID, PointerIcon.create(bitmap, hotSpotX, hotSpotY));
+            } catch (Exception e) {
+                return 0;
+            }
+        } else {
             return 0;
         }
         return mLastCursorID;
@@ -1353,12 +1396,14 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
      * This method is called by SDL using JNI.
      */
     public static boolean setCustomCursor(int cursorID) {
-        // This requires API 24, so use reflection to implement this
-        try {
-            Class PointerIconClass = Class.forName("android.view.PointerIcon");
-            Method setPointerIcon = SDLSurface.class.getMethod("setPointerIcon", PointerIconClass);
-            setPointerIcon.invoke(mSurface, mCursors.get(cursorID));
-        } catch (Exception e) {
+
+        if (Build.VERSION.SDK_INT >= 24) {
+            try {
+                mSurface.setPointerIcon(mCursors.get(cursorID));
+            } catch (Exception e) {
+                return false;
+            }
+        } else {
             return false;
         }
         return true;
@@ -1407,15 +1452,12 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
             cursor_type = 1002; //PointerIcon.TYPE_HAND;
             break;
         }
-        // This requires API 24, so use reflection to implement this
-        try {
-            Class PointerIconClass = Class.forName("android.view.PointerIcon");
-            Class[] arg_types = new Class[] { Context.class, int.class };
-            Method getSystemIcon = PointerIconClass.getMethod("getSystemIcon", arg_types);
-            Method setPointerIcon = SDLSurface.class.getMethod("setPointerIcon", PointerIconClass);
-            setPointerIcon.invoke(mSurface, getSystemIcon.invoke(null, SDL.getContext(), cursor_type));
-        } catch (Exception e) {
-            return false;
+        if (Build.VERSION.SDK_INT >= 24) {
+            try {
+                mSurface.setPointerIcon(PointerIcon.getSystemIcon(SDL.getContext(), cursor_type));
+            } catch (Exception e) {
+                return false;
+            }
         }
         return true;
     }
@@ -1582,8 +1624,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
         int nDeviceHeight = height;
         try
         {
-            if ( android.os.Build.VERSION.SDK_INT >= 17 )
-            {
+            if (Build.VERSION.SDK_INT >= 17) {
                 android.util.DisplayMetrics realMetrics = new android.util.DisplayMetrics();
                 mDisplay.getRealMetrics( realMetrics );
                 nDeviceWidth = realMetrics.widthPixels;
@@ -1593,6 +1634,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
         catch ( java.lang.Throwable throwable ) {}
 
         synchronized(SDLActivity.getContext()) {
+            // In case we're waiting on a size change after going fullscreen, send a notification.
             SDLActivity.getContext().notifyAll();
         }
 

+ 249 - 59
sdl.mod/SDL/android-project/app/src/main/java/org/libsdl/app/SDLAudioManager.java

@@ -1,6 +1,7 @@
 package org.libsdl.app;
 
 import android.media.*;
+import android.os.Build;
 import android.util.Log;
 
 public class SDLAudioManager
@@ -17,41 +18,250 @@ public class SDLAudioManager
 
     // Audio
 
-    /**
-     * This method is called by SDL using JNI.
-     */
-    public static int audioOpen(int sampleRate, boolean is16Bit, boolean isStereo, int desiredFrames) {
-        int channelConfig = isStereo ? AudioFormat.CHANNEL_CONFIGURATION_STEREO : AudioFormat.CHANNEL_CONFIGURATION_MONO;
-        int audioFormat = is16Bit ? AudioFormat.ENCODING_PCM_16BIT : AudioFormat.ENCODING_PCM_8BIT;
-        int frameSize = (isStereo ? 2 : 1) * (is16Bit ? 2 : 1);
+    protected static String getAudioFormatString(int audioFormat) {
+        switch (audioFormat) {
+        case AudioFormat.ENCODING_PCM_8BIT:
+            return "8-bit";
+        case AudioFormat.ENCODING_PCM_16BIT:
+            return "16-bit";
+        case AudioFormat.ENCODING_PCM_FLOAT:
+            return "float";
+        default:
+            return Integer.toString(audioFormat);
+        }
+    }
+
+    protected static int[] open(boolean isCapture, int sampleRate, int audioFormat, int desiredChannels, int desiredFrames) {
+        int channelConfig;
+        int sampleSize;
+        int frameSize;
+
+        Log.v(TAG, "Opening " + (isCapture ? "capture" : "playback") + ", requested " + desiredFrames + " frames of " + desiredChannels + " channel " + getAudioFormatString(audioFormat) + " audio at " + sampleRate + " Hz");
+
+        /* On older devices let's use known good settings */
+        if (Build.VERSION.SDK_INT < 21) {
+            if (desiredChannels > 2) {
+                desiredChannels = 2;
+            }
+            if (sampleRate < 8000) {
+                sampleRate = 8000;
+            } else if (sampleRate > 48000) {
+                sampleRate = 48000;
+            }
+        }
 
-        Log.v(TAG, "SDL audio: wanted " + (isStereo ? "stereo" : "mono") + " " + (is16Bit ? "16-bit" : "8-bit") + " " + (sampleRate / 1000f) + "kHz, " + desiredFrames + " frames buffer");
+        if (audioFormat == AudioFormat.ENCODING_PCM_FLOAT) {
+            int minSDKVersion = (isCapture ? 23 : 21);
+            if (Build.VERSION.SDK_INT < minSDKVersion) {
+                audioFormat = AudioFormat.ENCODING_PCM_16BIT;
+            }
+        }
+        switch (audioFormat)
+        {
+        case AudioFormat.ENCODING_PCM_8BIT:
+            sampleSize = 1;
+            break;
+        case AudioFormat.ENCODING_PCM_16BIT:
+            sampleSize = 2;
+            break;
+        case AudioFormat.ENCODING_PCM_FLOAT:
+            sampleSize = 4;
+            break;
+        default:
+            Log.v(TAG, "Requested format " + audioFormat + ", getting ENCODING_PCM_16BIT");
+            audioFormat = AudioFormat.ENCODING_PCM_16BIT;
+            sampleSize = 2;
+            break;
+        }
+ 
+        if (isCapture) {
+            switch (desiredChannels) {
+            case 1:
+                channelConfig = AudioFormat.CHANNEL_IN_MONO;
+                break;
+            case 2:
+                channelConfig = AudioFormat.CHANNEL_IN_STEREO;
+                break;
+            default:
+                Log.v(TAG, "Requested " + desiredChannels + " channels, getting stereo");
+                desiredChannels = 2;
+                channelConfig = AudioFormat.CHANNEL_IN_STEREO;
+                break;
+            }
+        } else {
+            switch (desiredChannels) {
+            case 1:
+                channelConfig = AudioFormat.CHANNEL_OUT_MONO;
+                break;
+            case 2:
+                channelConfig = AudioFormat.CHANNEL_OUT_STEREO;
+                break;
+            case 3:
+                channelConfig = AudioFormat.CHANNEL_OUT_STEREO | AudioFormat.CHANNEL_OUT_FRONT_CENTER;
+                break;
+            case 4:
+                channelConfig = AudioFormat.CHANNEL_OUT_QUAD;
+                break;
+            case 5:
+                channelConfig = AudioFormat.CHANNEL_OUT_QUAD | AudioFormat.CHANNEL_OUT_FRONT_CENTER;
+                break;
+            case 6:
+                channelConfig = AudioFormat.CHANNEL_OUT_5POINT1;
+                break;
+            case 7:
+                channelConfig = AudioFormat.CHANNEL_OUT_5POINT1 | AudioFormat.CHANNEL_OUT_BACK_CENTER;
+                break;
+            case 8:
+                if (Build.VERSION.SDK_INT >= 23) {
+                    channelConfig = AudioFormat.CHANNEL_OUT_7POINT1_SURROUND;
+                } else {
+                    Log.v(TAG, "Requested " + desiredChannels + " channels, getting 5.1 surround");
+                    desiredChannels = 6;
+                    channelConfig = AudioFormat.CHANNEL_OUT_5POINT1;
+                }
+                break;
+            default:
+                Log.v(TAG, "Requested " + desiredChannels + " channels, getting stereo");
+                desiredChannels = 2;
+                channelConfig = AudioFormat.CHANNEL_OUT_STEREO;
+                break;
+            }
+
+/*
+            Log.v(TAG, "Speaker configuration (and order of channels):");
+
+            if ((channelConfig & 0x00000004) != 0) {
+                Log.v(TAG, "   CHANNEL_OUT_FRONT_LEFT");
+            }
+            if ((channelConfig & 0x00000008) != 0) {
+                Log.v(TAG, "   CHANNEL_OUT_FRONT_RIGHT");
+            }
+            if ((channelConfig & 0x00000010) != 0) {
+                Log.v(TAG, "   CHANNEL_OUT_FRONT_CENTER");
+            }
+            if ((channelConfig & 0x00000020) != 0) {
+                Log.v(TAG, "   CHANNEL_OUT_LOW_FREQUENCY");
+            }
+            if ((channelConfig & 0x00000040) != 0) {
+                Log.v(TAG, "   CHANNEL_OUT_BACK_LEFT");
+            }
+            if ((channelConfig & 0x00000080) != 0) {
+                Log.v(TAG, "   CHANNEL_OUT_BACK_RIGHT");
+            }
+            if ((channelConfig & 0x00000100) != 0) {
+                Log.v(TAG, "   CHANNEL_OUT_FRONT_LEFT_OF_CENTER");
+            }
+            if ((channelConfig & 0x00000200) != 0) {
+                Log.v(TAG, "   CHANNEL_OUT_FRONT_RIGHT_OF_CENTER");
+            }
+            if ((channelConfig & 0x00000400) != 0) {
+                Log.v(TAG, "   CHANNEL_OUT_BACK_CENTER");
+            }
+            if ((channelConfig & 0x00000800) != 0) {
+                Log.v(TAG, "   CHANNEL_OUT_SIDE_LEFT");
+            }
+            if ((channelConfig & 0x00001000) != 0) {
+                Log.v(TAG, "   CHANNEL_OUT_SIDE_RIGHT");
+            }
+*/
+        }
+        frameSize = (sampleSize * desiredChannels);
 
         // Let the user pick a larger buffer if they really want -- but ye
         // gods they probably shouldn't, the minimums are horrifyingly high
         // latency already
-        desiredFrames = Math.max(desiredFrames, (AudioTrack.getMinBufferSize(sampleRate, channelConfig, audioFormat) + frameSize - 1) / frameSize);
+        int minBufferSize;
+        if (isCapture) {
+            minBufferSize = AudioRecord.getMinBufferSize(sampleRate, channelConfig, audioFormat);
+        } else {
+            minBufferSize = AudioTrack.getMinBufferSize(sampleRate, channelConfig, audioFormat);
+        }
+        desiredFrames = Math.max(desiredFrames, (minBufferSize + frameSize - 1) / frameSize);
 
-        if (mAudioTrack == null) {
-            mAudioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, sampleRate,
-                    channelConfig, audioFormat, desiredFrames * frameSize, AudioTrack.MODE_STREAM);
+        int[] results = new int[4];
 
-            // Instantiating AudioTrack can "succeed" without an exception and the track may still be invalid
-            // Ref: https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/media/java/android/media/AudioTrack.java
-            // Ref: http://developer.android.com/reference/android/media/AudioTrack.html#getState()
+        if (isCapture) {
+            if (mAudioRecord == null) {
+                mAudioRecord = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, sampleRate,
+                        channelConfig, audioFormat, desiredFrames * frameSize);
 
-            if (mAudioTrack.getState() != AudioTrack.STATE_INITIALIZED) {
-                Log.e(TAG, "Failed during initialization of Audio Track");
-                mAudioTrack = null;
-                return -1;
+                // see notes about AudioTrack state in audioOpen(), above. Probably also applies here.
+                if (mAudioRecord.getState() != AudioRecord.STATE_INITIALIZED) {
+                    Log.e(TAG, "Failed during initialization of AudioRecord");
+                    mAudioRecord.release();
+                    mAudioRecord = null;
+                    return null;
+                }
+
+                mAudioRecord.startRecording();
+            }
+
+            results[0] = mAudioRecord.getSampleRate();
+            results[1] = mAudioRecord.getAudioFormat();
+            results[2] = mAudioRecord.getChannelCount();
+            results[3] = desiredFrames;
+
+        } else {
+            if (mAudioTrack == null) {
+                mAudioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, sampleRate, channelConfig, audioFormat, desiredFrames * frameSize, AudioTrack.MODE_STREAM);
+
+                // Instantiating AudioTrack can "succeed" without an exception and the track may still be invalid
+                // Ref: https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/media/java/android/media/AudioTrack.java
+                // Ref: http://developer.android.com/reference/android/media/AudioTrack.html#getState()
+                if (mAudioTrack.getState() != AudioTrack.STATE_INITIALIZED) {
+                    /* Try again, with safer values */
+
+                    Log.e(TAG, "Failed during initialization of Audio Track");
+                    mAudioTrack.release();
+                    mAudioTrack = null;
+                    return null;
+                }
+
+                mAudioTrack.play();
             }
 
-            mAudioTrack.play();
+            results[0] = mAudioTrack.getSampleRate();
+            results[1] = mAudioTrack.getAudioFormat();
+            results[2] = mAudioTrack.getChannelCount();
+            results[3] = desiredFrames;
         }
 
-        Log.v(TAG, "SDL audio: got " + ((mAudioTrack.getChannelCount() >= 2) ? "stereo" : "mono") + " " + ((mAudioTrack.getAudioFormat() == AudioFormat.ENCODING_PCM_16BIT) ? "16-bit" : "8-bit") + " " + (mAudioTrack.getSampleRate() / 1000f) + "kHz, " + desiredFrames + " frames buffer");
+        Log.v(TAG, "Opening " + (isCapture ? "capture" : "playback") + ", got " + results[3] + " frames of " + results[2] + " channel " + getAudioFormatString(results[1]) + " audio at " + results[0] + " Hz");
+
+        return results;
+    }
 
-        return 0;
+    /**
+     * This method is called by SDL using JNI.
+     */
+    public static int[] audioOpen(int sampleRate, int audioFormat, int desiredChannels, int desiredFrames) {
+        return open(false, sampleRate, audioFormat, desiredChannels, desiredFrames);
+    }
+
+    /**
+     * This method is called by SDL using JNI.
+     */
+    public static void audioWriteFloatBuffer(float[] buffer) {
+        if (mAudioTrack == null) {
+            Log.e(TAG, "Attempted to make audio call with uninitialized audio!");
+            return;
+        }
+
+        for (int i = 0; i < buffer.length;) {
+            int result = mAudioTrack.write(buffer, i, buffer.length - i, AudioTrack.WRITE_BLOCKING);
+            if (result > 0) {
+                i += result;
+            } else if (result == 0) {
+                try {
+                    Thread.sleep(1);
+                } catch(InterruptedException e) {
+                    // Nom nom
+                }
+            } else {
+                Log.w(TAG, "SDL audio: error return from write(float)");
+                return;
+            }
+        }
     }
 
     /**
@@ -63,7 +273,7 @@ public class SDLAudioManager
             return;
         }
 
-        for (int i = 0; i < buffer.length; ) {
+        for (int i = 0; i < buffer.length;) {
             int result = mAudioTrack.write(buffer, i, buffer.length - i);
             if (result > 0) {
                 i += result;
@@ -109,53 +319,33 @@ public class SDLAudioManager
     /**
      * This method is called by SDL using JNI.
      */
-    public static int captureOpen(int sampleRate, boolean is16Bit, boolean isStereo, int desiredFrames) {
-        int channelConfig = isStereo ? AudioFormat.CHANNEL_CONFIGURATION_STEREO : AudioFormat.CHANNEL_CONFIGURATION_MONO;
-        int audioFormat = is16Bit ? AudioFormat.ENCODING_PCM_16BIT : AudioFormat.ENCODING_PCM_8BIT;
-        int frameSize = (isStereo ? 2 : 1) * (is16Bit ? 2 : 1);
-
-        Log.v(TAG, "SDL capture: wanted " + (isStereo ? "stereo" : "mono") + " " + (is16Bit ? "16-bit" : "8-bit") + " " + (sampleRate / 1000f) + "kHz, " + desiredFrames + " frames buffer");
-
-        // Let the user pick a larger buffer if they really want -- but ye
-        // gods they probably shouldn't, the minimums are horrifyingly high
-        // latency already
-        desiredFrames = Math.max(desiredFrames, (AudioRecord.getMinBufferSize(sampleRate, channelConfig, audioFormat) + frameSize - 1) / frameSize);
-
-        if (mAudioRecord == null) {
-            mAudioRecord = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, sampleRate,
-                    channelConfig, audioFormat, desiredFrames * frameSize);
-
-            // see notes about AudioTrack state in audioOpen(), above. Probably also applies here.
-            if (mAudioRecord.getState() != AudioRecord.STATE_INITIALIZED) {
-                Log.e(TAG, "Failed during initialization of AudioRecord");
-                mAudioRecord.release();
-                mAudioRecord = null;
-                return -1;
-            }
-
-            mAudioRecord.startRecording();
-        }
-
-        Log.v(TAG, "SDL capture: got " + ((mAudioRecord.getChannelCount() >= 2) ? "stereo" : "mono") + " " + ((mAudioRecord.getAudioFormat() == AudioFormat.ENCODING_PCM_16BIT) ? "16-bit" : "8-bit") + " " + (mAudioRecord.getSampleRate() / 1000f) + "kHz, " + desiredFrames + " frames buffer");
+    public static int[] captureOpen(int sampleRate, int audioFormat, int desiredChannels, int desiredFrames) {
+        return open(true, sampleRate, audioFormat, desiredChannels, desiredFrames);
+    }
 
-        return 0;
+    /** This method is called by SDL using JNI. */
+    public static int captureReadFloatBuffer(float[] buffer, boolean blocking) {
+        return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
     }
 
     /** This method is called by SDL using JNI. */
     public static int captureReadShortBuffer(short[] buffer, boolean blocking) {
-        // !!! FIXME: this is available in API Level 23. Until then, we always block.  :(
-        //return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
-        return mAudioRecord.read(buffer, 0, buffer.length);
+        if (Build.VERSION.SDK_INT < 23) {
+            return mAudioRecord.read(buffer, 0, buffer.length);
+        } else {
+            return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
+        }
     }
 
     /** This method is called by SDL using JNI. */
     public static int captureReadByteBuffer(byte[] buffer, boolean blocking) {
-        // !!! FIXME: this is available in API Level 23. Until then, we always block.  :(
-        //return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
-        return mAudioRecord.read(buffer, 0, buffer.length);
+        if (Build.VERSION.SDK_INT < 23) {
+            return mAudioRecord.read(buffer, 0, buffer.length);
+        } else {
+            return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
+        }
     }
 
-
     /** This method is called by SDL using JNI. */
     public static void audioClose() {
         if (mAudioTrack != null) {

+ 62 - 28
sdl.mod/SDL/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java

@@ -11,7 +11,7 @@ import android.view.*;
 import android.util.Log;
 
 
-public class SDLControllerManager 
+public class SDLControllerManager
 {
 
     public static native int nativeSetupJNI();
@@ -36,23 +36,25 @@ public class SDLControllerManager
     private static final String TAG = "SDLControllerManager";
 
     public static void initialize() {
-        mJoystickHandler = null;
-        mHapticHandler = null;
-
-        SDLControllerManager.setup();
-    }
+        if (mJoystickHandler == null) {
+            if (Build.VERSION.SDK_INT >= 19) {
+                mJoystickHandler = new SDLJoystickHandler_API19();
+            } else if (Build.VERSION.SDK_INT >= 16) {
+                mJoystickHandler = new SDLJoystickHandler_API16();
+            } else if (Build.VERSION.SDK_INT >= 12) {
+                mJoystickHandler = new SDLJoystickHandler_API12();
+            } else {
+                mJoystickHandler = new SDLJoystickHandler();
+            }
+        }
 
-    public static void setup() {
-        if (Build.VERSION.SDK_INT >= 19) {
-            mJoystickHandler = new SDLJoystickHandler_API19();
-        } else if (Build.VERSION.SDK_INT >= 16) {
-            mJoystickHandler = new SDLJoystickHandler_API16();
-        } else if (Build.VERSION.SDK_INT >= 12) {
-            mJoystickHandler = new SDLJoystickHandler_API12();
-        } else {
-            mJoystickHandler = new SDLJoystickHandler();
+        if (mHapticHandler == null) {
+            if (Build.VERSION.SDK_INT >= 26) {
+                mHapticHandler = new SDLHapticHandler_API26();
+            } else {
+                mHapticHandler = new SDLHapticHandler();
+            }
         }
-        mHapticHandler = new SDLHapticHandler();
     }
 
     // Joystick glue code, just a series of stubs that redirect to the SDLJoystickHandler instance
@@ -77,8 +79,8 @@ public class SDLControllerManager
     /**
      * This method is called by SDL using JNI.
      */
-    public static void hapticRun(int device_id, int length) {
-        mHapticHandler.run(device_id, length);
+    public static void hapticRun(int device_id, float intensity, int length) {
+        mHapticHandler.run(device_id, intensity, length);
     }
 
     /**
@@ -409,6 +411,38 @@ class SDLJoystickHandler_API19 extends SDLJoystickHandler_API16 {
     }
 }
 
+class SDLHapticHandler_API26 extends SDLHapticHandler {
+    @Override
+    public void run(int device_id, float intensity, int length) {
+        SDLHaptic haptic = getHaptic(device_id);
+        if (haptic != null) {
+            Log.d("SDL", "Rtest: Vibe with intensity " + intensity + " for " + length);
+            if (intensity == 0.0f) {
+                stop(device_id);
+                return;
+            }
+
+            int vibeValue = Math.round(intensity * 255);
+
+            if (vibeValue > 255) {
+                vibeValue = 255;
+            }
+            if (vibeValue < 1) {
+                stop(device_id);
+                return;
+            }
+            try {
+                haptic.vib.vibrate(VibrationEffect.createOneShot(length, vibeValue));
+            }
+            catch (Exception e) {
+                // Fall back to the generic method, which uses DEFAULT_AMPLITUDE, but works even if
+                // something went horribly wrong with the Android 8.0 APIs.
+                haptic.vib.vibrate(length);
+            }
+        }
+    }
+}
+
 class SDLHapticHandler {
 
     class SDLHaptic {
@@ -418,15 +452,15 @@ class SDLHapticHandler {
     }
 
     private ArrayList<SDLHaptic> mHaptics;
-    
+
     public SDLHapticHandler() {
         mHaptics = new ArrayList<SDLHaptic>();
     }
 
-    public void run(int device_id, int length) {
+    public void run(int device_id, float intensity, int length) {
         SDLHaptic haptic = getHaptic(device_id);
         if (haptic != null) {
-            haptic.vib.vibrate (length);
+            haptic.vib.vibrate(length);
         }
     }
 
@@ -438,7 +472,7 @@ class SDLHapticHandler {
     }
 
     public void pollHapticDevices() {
-        
+
         final int deviceId_VIBRATOR_SERVICE = 999999;
         boolean hasVibratorService = false;
 
@@ -482,7 +516,7 @@ class SDLHapticHandler {
                     haptic = new SDLHaptic();
                     haptic.device_id = deviceId_VIBRATOR_SERVICE;
                     haptic.name = "VIBRATOR_SERVICE";
-                    haptic.vib = vib; 
+                    haptic.vib = vib;
                     mHaptics.add(haptic);
                     SDLControllerManager.nativeAddHaptic(haptic.device_id, haptic.name);
                 }
@@ -524,7 +558,7 @@ class SDLHapticHandler {
             }
         }
         return null;
-    }   
+    }
 }
 
 class SDLGenericMotionListener_API12 implements View.OnGenericMotionListener {
@@ -614,7 +648,7 @@ class SDLGenericMotionListener_API24 extends SDLGenericMotionListener_API12 {
             case InputDevice.SOURCE_GAMEPAD:
             case InputDevice.SOURCE_DPAD:
                 return SDLControllerManager.handleJoystickMotionEvent(event);
-                
+
             case InputDevice.SOURCE_MOUSE:
                 if (!SDLActivity.mSeparateMouseAndTouch) {
                     break;
@@ -705,7 +739,7 @@ class SDLGenericMotionListener_API26 extends SDLGenericMotionListener_API24 {
             case InputDevice.SOURCE_GAMEPAD:
             case InputDevice.SOURCE_DPAD:
                 return SDLControllerManager.handleJoystickMotionEvent(event);
-                
+
             case InputDevice.SOURCE_MOUSE:
             case 12290: // DeX desktop mouse cursor is a separate non-standard input type.
                 if (!SDLActivity.mSeparateMouseAndTouch) {
@@ -779,12 +813,12 @@ class SDLGenericMotionListener_API26 extends SDLGenericMotionListener_API24 {
                 SDLActivity.getContentView().requestPointerCapture();
             }
             else {
-                SDLActivity.getContentView().releasePointerCapture();            
+                SDLActivity.getContentView().releasePointerCapture();
             }
             mRelativeModeEnabled = enabled;
             return true;
         }
-        else 
+        else
         {
             return false;
         }

+ 3 - 1
sdl.mod/SDL/android-project/build.gradle

@@ -3,9 +3,10 @@
 buildscript {
     repositories {
         jcenter()
+        google()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:2.3.3'
+        classpath 'com.android.tools.build:gradle:3.2.0'
 
         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files
@@ -15,6 +16,7 @@ buildscript {
 allprojects {
     repositories {
         jcenter()
+        google()
     }
 }
 

+ 1 - 1
sdl.mod/SDL/android-project/gradle/wrapper/gradle-wrapper.properties

@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip

+ 371 - 167
sdl.mod/SDL/build-scripts/install-sh

@@ -1,7 +1,7 @@
 #!/bin/sh
 # install - install a program, script, or datafile
 
-scriptversion=2005-02-02.21
+scriptversion=2011-11-20.07; # UTC
 
 # This originates from X11R5 (mit/util/scripts/install.sh), which was
 # later released in X11R6 (xc/config/util/install.sh) with the
@@ -35,42 +35,72 @@ scriptversion=2005-02-02.21
 # FSF changes to this file are in the public domain.
 #
 # Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
+# 'make' implicit rules from creating a file called install from it
 # when there is no Makefile.
 #
 # This script is compatible with the BSD install script, but was written
-# from scratch.  It can only install one file at a time, a restriction
-# shared with many OS's install programs.
+# from scratch.
+
+nl='
+'
+IFS=" ""	$nl"
 
 # set DOITPROG to echo to test this script
 
 # Don't use :- since 4.3BSD and earlier shells don't like it.
-doit="${DOITPROG-}"
+doit=${DOITPROG-}
+if test -z "$doit"; then
+  doit_exec=exec
+else
+  doit_exec=$doit
+fi
 
-# put in absolute paths if you don't have them in your path; or use env. vars.
+# Put in absolute file names if you don't have them in your path;
+# or use environment vars.
+
+chgrpprog=${CHGRPPROG-chgrp}
+chmodprog=${CHMODPROG-chmod}
+chownprog=${CHOWNPROG-chown}
+cmpprog=${CMPPROG-cmp}
+cpprog=${CPPROG-cp}
+mkdirprog=${MKDIRPROG-mkdir}
+mvprog=${MVPROG-mv}
+rmprog=${RMPROG-rm}
+stripprog=${STRIPPROG-strip}
+
+posix_glob='?'
+initialize_posix_glob='
+  test "$posix_glob" != "?" || {
+    if (set -f) 2>/dev/null; then
+      posix_glob=
+    else
+      posix_glob=:
+    fi
+  }
+'
 
-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-mkdirprog="${MKDIRPROG-mkdir}"
+posix_mkdir=
+
+# Desired mode of installed file.
+mode=0755
 
-chmodcmd="$chmodprog 0755"
-chowncmd=
 chgrpcmd=
-stripcmd=
+chmodcmd=$chmodprog
+chowncmd=
+mvcmd=$mvprog
 rmcmd="$rmprog -f"
-mvcmd="$mvprog"
+stripcmd=
+
 src=
 dst=
 dir_arg=
-dstarg=
+dst_arg=
+
+copy_on_change=false
 no_target_directory=
 
-usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+usage="\
+Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
    or: $0 [OPTION]... SRCFILES... DIRECTORY
    or: $0 [OPTION]... -t DIRECTORY SRCFILES...
    or: $0 [OPTION]... -d DIRECTORIES...
@@ -80,108 +110,148 @@ In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
 In the 4th, create DIRECTORIES.
 
 Options:
--c         (ignored)
--d         create directories instead of installing files.
--g GROUP   $chgrpprog installed files to GROUP.
--m MODE    $chmodprog installed files to MODE.
--o USER    $chownprog installed files to USER.
--s         $stripprog installed files.
--t DIRECTORY  install into DIRECTORY.
--T         report an error if DSTFILE is a directory.
---help     display this help and exit.
---version  display version info and exit.
+     --help     display this help and exit.
+     --version  display version info and exit.
+
+  -c            (ignored)
+  -C            install only if different (preserve the last data modification time)
+  -d            create directories instead of installing files.
+  -g GROUP      $chgrpprog installed files to GROUP.
+  -m MODE       $chmodprog installed files to MODE.
+  -o USER       $chownprog installed files to USER.
+  -s            $stripprog installed files.
+  -t DIRECTORY  install into DIRECTORY.
+  -T            report an error if DSTFILE is a directory.
 
 Environment variables override the default commands:
-  CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
+  CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
+  RMPROG STRIPPROG
 "
 
-while test -n "$1"; do
+while test $# -ne 0; do
   case $1 in
-    -c) shift
-        continue;;
+    -c) ;;
+
+    -C) copy_on_change=true;;
 
-    -d) dir_arg=true
-        shift
-        continue;;
+    -d) dir_arg=true;;
 
     -g) chgrpcmd="$chgrpprog $2"
-        shift
-        shift
-        continue;;
+	shift;;
 
     --help) echo "$usage"; exit $?;;
 
-    -m) chmodcmd="$chmodprog $2"
-        shift
-        shift
-        continue;;
+    -m) mode=$2
+	case $mode in
+	  *' '* | *'	'* | *'
+'*	  | *'*'* | *'?'* | *'['*)
+	    echo "$0: invalid mode: $mode" >&2
+	    exit 1;;
+	esac
+	shift;;
 
     -o) chowncmd="$chownprog $2"
-        shift
-        shift
-        continue;;
+	shift;;
 
-    -s) stripcmd=$stripprog
-        shift
-        continue;;
+    -s) stripcmd=$stripprog;;
 
-    -t) dstarg=$2
-	shift
-	shift
-	continue;;
+    -t) dst_arg=$2
+	# Protect names problematic for 'test' and other utilities.
+	case $dst_arg in
+	  -* | [=\(\)!]) dst_arg=./$dst_arg;;
+	esac
+	shift;;
 
-    -T) no_target_directory=true
-	shift
-	continue;;
+    -T) no_target_directory=true;;
 
     --version) echo "$0 $scriptversion"; exit $?;;
 
-    *)  # When -d is used, all remaining arguments are directories to create.
-	# When -t is used, the destination is already specified.
-	test -n "$dir_arg$dstarg" && break
-        # Otherwise, the last argument is the destination.  Remove it from $@.
-	for arg
-	do
-          if test -n "$dstarg"; then
-	    # $@ is not empty: it contains at least $arg.
-	    set fnord "$@" "$dstarg"
-	    shift # fnord
-	  fi
-	  shift # arg
-	  dstarg=$arg
-	done
+    --)	shift
 	break;;
+
+    -*)	echo "$0: invalid option: $1" >&2
+	exit 1;;
+
+    *)  break;;
   esac
+  shift
 done
 
-if test -z "$1"; then
+if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
+  # When -d is used, all remaining arguments are directories to create.
+  # When -t is used, the destination is already specified.
+  # Otherwise, the last argument is the destination.  Remove it from $@.
+  for arg
+  do
+    if test -n "$dst_arg"; then
+      # $@ is not empty: it contains at least $arg.
+      set fnord "$@" "$dst_arg"
+      shift # fnord
+    fi
+    shift # arg
+    dst_arg=$arg
+    # Protect names problematic for 'test' and other utilities.
+    case $dst_arg in
+      -* | [=\(\)!]) dst_arg=./$dst_arg;;
+    esac
+  done
+fi
+
+if test $# -eq 0; then
   if test -z "$dir_arg"; then
     echo "$0: no input file specified." >&2
     exit 1
   fi
-  # It's OK to call `install-sh -d' without argument.
+  # It's OK to call 'install-sh -d' without argument.
   # This can happen when creating conditional directories.
   exit 0
 fi
 
+if test -z "$dir_arg"; then
+  do_exit='(exit $ret); exit $ret'
+  trap "ret=129; $do_exit" 1
+  trap "ret=130; $do_exit" 2
+  trap "ret=141; $do_exit" 13
+  trap "ret=143; $do_exit" 15
+
+  # Set umask so as not to create temps with too-generous modes.
+  # However, 'strip' requires both read and write access to temps.
+  case $mode in
+    # Optimize common cases.
+    *644) cp_umask=133;;
+    *755) cp_umask=22;;
+
+    *[0-7])
+      if test -z "$stripcmd"; then
+	u_plus_rw=
+      else
+	u_plus_rw='% 200'
+      fi
+      cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
+    *)
+      if test -z "$stripcmd"; then
+	u_plus_rw=
+      else
+	u_plus_rw=,u+rw
+      fi
+      cp_umask=$mode$u_plus_rw;;
+  esac
+fi
+
 for src
 do
-  # Protect names starting with `-'.
+  # Protect names problematic for 'test' and other utilities.
   case $src in
-    -*) src=./$src ;;
+    -* | [=\(\)!]) src=./$src;;
   esac
 
   if test -n "$dir_arg"; then
     dst=$src
-    src=
-
-    if test -d "$dst"; then
-      mkdircmd=:
-      chmodcmd=
-    else
-      mkdircmd=$mkdirprog
-    fi
+    dstdir=$dst
+    test -d "$dstdir"
+    dstdir_status=$?
   else
+
     # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
     # might cause directories to be created, which would be especially bad
     # if $src (and thus $dsttmp) contains '*'.
@@ -190,71 +260,194 @@ do
       exit 1
     fi
 
-    if test -z "$dstarg"; then
+    if test -z "$dst_arg"; then
       echo "$0: no destination specified." >&2
       exit 1
     fi
-
-    dst=$dstarg
-    # Protect names starting with `-'.
-    case $dst in
-      -*) dst=./$dst ;;
-    esac
+    dst=$dst_arg
 
     # If destination is a directory, append the input filename; won't work
     # if double slashes aren't ignored.
     if test -d "$dst"; then
       if test -n "$no_target_directory"; then
-	echo "$0: $dstarg: Is a directory" >&2
+	echo "$0: $dst_arg: Is a directory" >&2
 	exit 1
       fi
-      dst=$dst/`basename "$src"`
+      dstdir=$dst
+      dst=$dstdir/`basename "$src"`
+      dstdir_status=0
+    else
+      # Prefer dirname, but fall back on a substitute if dirname fails.
+      dstdir=`
+	(dirname "$dst") 2>/dev/null ||
+	expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	     X"$dst" : 'X\(//\)[^/]' \| \
+	     X"$dst" : 'X\(//\)$' \| \
+	     X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
+	echo X"$dst" |
+	    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+		   s//\1/
+		   q
+		 }
+		 /^X\(\/\/\)[^/].*/{
+		   s//\1/
+		   q
+		 }
+		 /^X\(\/\/\)$/{
+		   s//\1/
+		   q
+		 }
+		 /^X\(\/\).*/{
+		   s//\1/
+		   q
+		 }
+		 s/.*/./; q'
+      `
+
+      test -d "$dstdir"
+      dstdir_status=$?
     fi
   fi
 
-  # This sed command emulates the dirname command.
-  dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
+  obsolete_mkdir_used=false
+
+  if test $dstdir_status != 0; then
+    case $posix_mkdir in
+      '')
+	# Create intermediate dirs using mode 755 as modified by the umask.
+	# This is like FreeBSD 'install' as of 1997-10-28.
+	umask=`umask`
+	case $stripcmd.$umask in
+	  # Optimize common cases.
+	  *[2367][2367]) mkdir_umask=$umask;;
+	  .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+
+	  *[0-7])
+	    mkdir_umask=`expr $umask + 22 \
+	      - $umask % 100 % 40 + $umask % 20 \
+	      - $umask % 10 % 4 + $umask % 2
+	    `;;
+	  *) mkdir_umask=$umask,go-w;;
+	esac
+
+	# With -d, create the new directory with the user-specified mode.
+	# Otherwise, rely on $mkdir_umask.
+	if test -n "$dir_arg"; then
+	  mkdir_mode=-m$mode
+	else
+	  mkdir_mode=
+	fi
+
+	posix_mkdir=false
+	case $umask in
+	  *[123567][0-7][0-7])
+	    # POSIX mkdir -p sets u+wx bits regardless of umask, which
+	    # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+	    ;;
+	  *)
+	    tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+	    trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
+
+	    if (umask $mkdir_umask &&
+		exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+	    then
+	      if test -z "$dir_arg" || {
+		   # Check for POSIX incompatibilities with -m.
+		   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+		   # other-writable bit of parent directory when it shouldn't.
+		   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+		   ls_ld_tmpdir=`ls -ld "$tmpdir"`
+		   case $ls_ld_tmpdir in
+		     d????-?r-*) different_mode=700;;
+		     d????-?--*) different_mode=755;;
+		     *) false;;
+		   esac &&
+		   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
+		     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+		     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+		   }
+		 }
+	      then posix_mkdir=:
+	      fi
+	      rmdir "$tmpdir/d" "$tmpdir"
+	    else
+	      # Remove any dirs left behind by ancient mkdir implementations.
+	      rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
+	    fi
+	    trap '' 0;;
+	esac;;
+    esac
 
-  # Make sure that the destination directory exists.
+    if
+      $posix_mkdir && (
+	umask $mkdir_umask &&
+	$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+      )
+    then :
+    else
 
-  # Skip lots of stat calls in the usual case.
-  if test ! -d "$dstdir"; then
-    defaultIFS='
-	 '
-    IFS="${IFS-$defaultIFS}"
+      # The umask is ridiculous, or mkdir does not conform to POSIX,
+      # or it failed possibly due to a race condition.  Create the
+      # directory the slow way, step by step, checking for races as we go.
 
-    oIFS=$IFS
-    # Some sh's can't handle IFS=/ for some reason.
-    IFS='%'
-    set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
-    shift
-    IFS=$oIFS
+      case $dstdir in
+	/*) prefix='/';;
+	[-=\(\)!]*) prefix='./';;
+	*)  prefix='';;
+      esac
 
-    pathcomp=
+      eval "$initialize_posix_glob"
 
-    while test $# -ne 0 ; do
-      pathcomp=$pathcomp$1
+      oIFS=$IFS
+      IFS=/
+      $posix_glob set -f
+      set fnord $dstdir
       shift
-      if test ! -d "$pathcomp"; then
-        $mkdirprog "$pathcomp"
-	# mkdir can fail with a `File exist' error in case several
-	# install-sh are creating the directory concurrently.  This
-	# is OK.
-	test -d "$pathcomp" || exit
+      $posix_glob set +f
+      IFS=$oIFS
+
+      prefixes=
+
+      for d
+      do
+	test X"$d" = X && continue
+
+	prefix=$prefix$d
+	if test -d "$prefix"; then
+	  prefixes=
+	else
+	  if $posix_mkdir; then
+	    (umask=$mkdir_umask &&
+	     $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+	    # Don't fail if two instances are running concurrently.
+	    test -d "$prefix" || exit 1
+	  else
+	    case $prefix in
+	      *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+	      *) qprefix=$prefix;;
+	    esac
+	    prefixes="$prefixes '$qprefix'"
+	  fi
+	fi
+	prefix=$prefix/
+      done
+
+      if test -n "$prefixes"; then
+	# Don't fail if two instances are running concurrently.
+	(umask $mkdir_umask &&
+	 eval "\$doit_exec \$mkdirprog $prefixes") ||
+	  test -d "$dstdir" || exit 1
+	obsolete_mkdir_used=true
       fi
-      pathcomp=$pathcomp/
-    done
+    fi
   fi
 
   if test -n "$dir_arg"; then
-    $doit $mkdircmd "$dst" \
-      && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
-      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
-      && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
-      && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
-
+    { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
+    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
+    { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
+      test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
   else
-    dstfile=`basename "$dst"`
 
     # Make a couple of temp file names in the proper directory.
     dsttmp=$dstdir/_inst.$$_
@@ -262,10 +455,9 @@ do
 
     # Trap to clean up those temp files at exit.
     trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
-    trap '(exit $?); exit' 1 2 13 15
 
     # Copy the file name to the temp name.
-    $doit $cpprog "$src" "$dsttmp" &&
+    (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
 
     # and set any options; do chmod last to preserve setuid bits.
     #
@@ -273,51 +465,63 @@ do
     # ignore errors from any of these, just make sure not to ignore
     # errors from the above "$doit $cpprog $src $dsttmp" command.
     #
-    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
-      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
-      && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
-      && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
-
-    # Now rename the file to the real destination.
-    { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
-      || {
-	   # The rename failed, perhaps because mv can't rename something else
-	   # to itself, or perhaps because mv is so ancient that it does not
-	   # support -f.
-
-	   # Now remove or move aside any old file at destination location.
-	   # We try this two ways since rm can't unlink itself on some
-	   # systems and the destination file might be busy for other
-	   # reasons.  In this case, the final cleanup might fail but the new
-	   # file should still install successfully.
-	   {
-	     if test -f "$dstdir/$dstfile"; then
-	       $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
-	       || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
-	       || {
-		 echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
-		 (exit 1); exit 1
-	       }
-	     else
-	       :
-	     fi
-	   } &&
-
-	   # Now rename the file to the real destination.
-	   $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
-	 }
-    }
-  fi || { (exit 1); exit 1; }
+    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
+    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
+    { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
+    { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
+
+    # If -C, don't bother to copy if it wouldn't change the file.
+    if $copy_on_change &&
+       old=`LC_ALL=C ls -dlL "$dst"	2>/dev/null` &&
+       new=`LC_ALL=C ls -dlL "$dsttmp"	2>/dev/null` &&
+
+       eval "$initialize_posix_glob" &&
+       $posix_glob set -f &&
+       set X $old && old=:$2:$4:$5:$6 &&
+       set X $new && new=:$2:$4:$5:$6 &&
+       $posix_glob set +f &&
+
+       test "$old" = "$new" &&
+       $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
+    then
+      rm -f "$dsttmp"
+    else
+      # Rename the file to the real destination.
+      $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
+
+      # The rename failed, perhaps because mv can't rename something else
+      # to itself, or perhaps because mv is so ancient that it does not
+      # support -f.
+      {
+	# Now remove or move aside any old file at destination location.
+	# We try this two ways since rm can't unlink itself on some
+	# systems and the destination file might be busy for other
+	# reasons.  In this case, the final cleanup might fail but the new
+	# file should still install successfully.
+	{
+	  test ! -f "$dst" ||
+	  $doit $rmcmd -f "$dst" 2>/dev/null ||
+	  { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+	    { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+	  } ||
+	  { echo "$0: cannot unlink or rename $dst" >&2
+	    (exit 1); exit 1
+	  }
+	} &&
+
+	# Now rename the file to the real destination.
+	$doit $mvcmd "$dsttmp" "$dst"
+      }
+    fi || exit 1
+
+    trap '' 0
+  fi
 done
 
-# The final little trick to "correctly" pass the exit status to the exit trap.
-{
-  (exit 0); exit 0
-}
-
 # Local variables:
 # eval: (add-hook 'write-file-hooks 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
 # End:

+ 2 - 5
sdl.mod/SDL/build-scripts/ltmain.sh

@@ -7404,11 +7404,8 @@ func_mode_link ()
 	  # Darwin ld doesn't like 0 for these options...
 	  func_arith $current + 1
 	  minor_current=$func_arith_result
-	  #xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
-	  #verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
-	  # make the compatibility version match the Xcode project files, i.e. 1.0
-	  xlcverstring="${wl}-compatibility_version 1.0 ${wl}-current_version ${wl}$minor_current.$revision"
-	  verstring="-compatibility_version 1.0 -current_version $minor_current.$revision"
+	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
+	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
 	  ;;
 
 	freebsd-aout)

+ 124 - 61
sdl.mod/SDL/build-scripts/mkinstalldirs

@@ -1,29 +1,59 @@
 #! /bin/sh
 # mkinstalldirs --- make directory hierarchy
-# Author: Noah Friedman <[email protected]>
-# Created: 1993-05-16
-# Public domain
 
+scriptversion=2009-04-28.21; # UTC
+
+# Original author: Noah Friedman <[email protected]>
+# Created: 1993-05-16
+# Public domain.
+#
+# This file is maintained in Automake, please report
+# bugs to <[email protected]> or send patches to
+# <[email protected]>.
+
+nl='
+'
+IFS=" ""	$nl"
 errstatus=0
-dirmode=""
+dirmode=
 
 usage="\
-Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
+Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
+
+Create each directory DIR (with mode MODE, if specified), including all
+leading file name components.
+
+Report bugs to <[email protected]>."
 
 # process command line arguments
 while test $# -gt 0 ; do
-   case "${1}" in
-     -h | --help | --h* )			# -h for help
-	echo "${usage}" 1>&2; exit 0 ;;
-     -m )					# -m PERM arg
-	shift
-	test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
-	dirmode="${1}"
-	shift ;;
-     -- ) shift; break ;;			# stop option processing
-     -* ) echo "${usage}" 1>&2; exit 1 ;;	# unknown option
-     * )  break ;;				# first non-opt arg
-   esac
+  case $1 in
+    -h | --help | --h*)         # -h for help
+      echo "$usage"
+      exit $?
+      ;;
+    -m)                         # -m PERM arg
+      shift
+      test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
+      dirmode=$1
+      shift
+      ;;
+    --version)
+      echo "$0 $scriptversion"
+      exit $?
+      ;;
+    --)                         # stop option processing
+      shift
+      break
+      ;;
+    -*)                         # unknown option
+      echo "$usage" 1>&2
+      exit 1
+      ;;
+    *)                          # first non-opt arg
+      break
+      ;;
+  esac
 done
 
 for file
@@ -36,64 +66,97 @@ do
 done
 
 case $# in
-0) exit 0 ;;
+  0) exit 0 ;;
 esac
 
+# Solaris 8's mkdir -p isn't thread-safe.  If you mkdir -p a/b and
+# mkdir -p a/c at the same time, both will detect that a is missing,
+# one will create a, then the other will try to create a and die with
+# a "File exists" error.  This is a problem when calling mkinstalldirs
+# from a parallel make.  We use --version in the probe to restrict
+# ourselves to GNU mkdir, which is thread-safe.
 case $dirmode in
-'')
-  if mkdir -p -- . 2>/dev/null; then
-    echo "mkdir -p -- $*"
-    exec mkdir -p -- "$@"
-  fi ;;
-*)
-  if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
-    echo "mkdir -m $dirmode -p -- $*"
-    exec mkdir -m "$dirmode" -p -- "$@"
-  fi ;;
+  '')
+    if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
+      echo "mkdir -p -- $*"
+      exec mkdir -p -- "$@"
+    else
+      # On NextStep and OpenStep, the 'mkdir' command does not
+      # recognize any option.  It will interpret all options as
+      # directories to create, and then abort because '.' already
+      # exists.
+      test -d ./-p && rmdir ./-p
+      test -d ./--version && rmdir ./--version
+    fi
+    ;;
+  *)
+    if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
+       test ! -d ./--version; then
+      echo "mkdir -m $dirmode -p -- $*"
+      exec mkdir -m "$dirmode" -p -- "$@"
+    else
+      # Clean up after NextStep and OpenStep mkdir.
+      for d in ./-m ./-p ./--version "./$dirmode";
+      do
+        test -d $d && rmdir $d
+      done
+    fi
+    ;;
 esac
 
 for file
 do
-   set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
-   shift
-
-   pathcomp=
-   for d
-   do
-     pathcomp="$pathcomp$d"
-     case "$pathcomp" in
-       -* ) pathcomp=./$pathcomp ;;
-     esac
-
-     if test ! -d "$pathcomp"; then
-	echo "mkdir $pathcomp"
-
-	mkdir "$pathcomp" || lasterr=$?
-
-	if test ! -d "$pathcomp"; then
-	  errstatus=$lasterr
-	else
-	  if test ! -z "$dirmode"; then
-	     echo "chmod $dirmode $pathcomp"
-
-	     lasterr=""
-	     chmod "$dirmode" "$pathcomp" || lasterr=$?
-
-	     if test ! -z "$lasterr"; then
-	       errstatus=$lasterr
-	     fi
+  case $file in
+    /*) pathcomp=/ ;;
+    *)  pathcomp= ;;
+  esac
+  oIFS=$IFS
+  IFS=/
+  set fnord $file
+  shift
+  IFS=$oIFS
+
+  for d
+  do
+    test "x$d" = x && continue
+
+    pathcomp=$pathcomp$d
+    case $pathcomp in
+      -*) pathcomp=./$pathcomp ;;
+    esac
+
+    if test ! -d "$pathcomp"; then
+      echo "mkdir $pathcomp"
+
+      mkdir "$pathcomp" || lasterr=$?
+
+      if test ! -d "$pathcomp"; then
+	errstatus=$lasterr
+      else
+	if test ! -z "$dirmode"; then
+	  echo "chmod $dirmode $pathcomp"
+	  lasterr=
+	  chmod "$dirmode" "$pathcomp" || lasterr=$?
+
+	  if test ! -z "$lasterr"; then
+	    errstatus=$lasterr
 	  fi
 	fi
-     fi
+      fi
+    fi
 
-     pathcomp="$pathcomp/"
-   done
+    pathcomp=$pathcomp/
+  done
 done
 
 exit $errstatus
 
 # Local Variables:
 # mode: shell-script
-# sh-indentation: 3
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
 # End:
-# mkinstalldirs ends here

+ 42 - 0
sdl.mod/SDL/build-scripts/os2-buildbot.sh

@@ -0,0 +1,42 @@
+#!/bin/bash
+
+# This is the script buildbot.libsdl.org uses to cross-compile SDL2 from
+#  x86 Linux to OS/2, using OpenWatcom.
+
+# The final zipfile can be unpacked on any machine that supports OpenWatcom
+#  (Windows, Linux, OS/2, etc). Point the compiler at the include directory
+#  and link against the SDL2.lib file. Ship the SDL2.dll with your app.
+
+if [ -z "$WATCOM" ]; then
+    echo "This script expects \$WATCOM to be set to the OpenWatcom install dir." 1>&2
+    echo "This is often something like '/usr/local/share/watcom'" 1>&2
+    exit 1
+fi
+
+export PATH="$WATCOM/binl:$PATH"
+
+ZIPFILE="$1"
+if [ -z $1 ]; then
+    ZIPFILE=sdl-os2.zip
+fi
+ZIPDIR=SDL2-os2
+
+set -e
+set -x
+
+cd `dirname "$0"`
+cd ..
+
+rm -f $ZIPFILE
+wmake -f Makefile.os2
+rm -rf $ZIPDIR
+mkdir $ZIPDIR
+chmod a+r SDL2.lib SDL2.dll
+mv SDL2.lib SDL2.dll $ZIPDIR/
+cp -R include $ZIPDIR/
+zip -9r "$ZIPFILE" $ZIPDIR
+
+wmake -f Makefile.os2 distclean
+
+set +x
+echo "All done. Final installable is in $ZIPFILE ...";

+ 1 - 1
sdl.mod/SDL/build-scripts/raspberrypi-buildbot.sh

@@ -42,7 +42,7 @@ SYSROOT="/opt/rpi-sysroot"
 export CC="ccache /opt/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc --sysroot=$SYSROOT -I$SYSROOT/opt/vc/include -I$SYSROOT/usr/include -I$SYSROOT/opt/vc/include/interface/vcos/pthreads -I$SYSROOT/opt/vc/include/interface/vmcs_host/linux -L$SYSROOT/opt/vc/lib"
 # -L$SYSROOT/usr/lib/arm-linux-gnueabihf"
 # !!! FIXME: shouldn't have to --disable-* things here.
-../configure --with-sysroot=$SYSROOT --host=arm-raspberry-linux-gnueabihf --prefix=$PWD/rpi-sdl2-installed --disable-pulseaudio --disable-esd --disable-video-mir --disable-video-wayland
+../configure --with-sysroot=$SYSROOT --host=arm-raspberry-linux-gnueabihf --prefix=$PWD/rpi-sdl2-installed --disable-pulseaudio --disable-esd --disable-video-wayland
 $MAKE
 $MAKE install
 # Fix up a few things to a real install path on a real Raspberry Pi...

+ 0 - 40
sdl.mod/SDL/cmake/sdlchecks.cmake

@@ -564,46 +564,6 @@ macro(CheckX11)
   endif()
 endmacro()
 
-# Requires:
-# - EGL
-# - PkgCheckModules
-# Optional:
-# - MIR_SHARED opt
-# - HAVE_DLOPEN opt
-macro(CheckMir)
-    if(VIDEO_MIR)
-        find_library(MIR_LIB mirclient mircommon egl)
-        pkg_check_modules(MIR_TOOLKIT mirclient>=0.26 mircommon)
-        pkg_check_modules(EGL egl)
-        pkg_check_modules(XKB xkbcommon)
-
-        if (MIR_LIB AND MIR_TOOLKIT_FOUND AND EGL_FOUND AND XKB_FOUND)
-            set(HAVE_VIDEO_MIR TRUE)
-            set(HAVE_SDL_VIDEO TRUE)
-
-            file(GLOB MIR_SOURCES ${SDL2_SOURCE_DIR}/src/video/mir/*.c)
-            set(SOURCE_FILES ${SOURCE_FILES} ${MIR_SOURCES})
-            set(SDL_VIDEO_DRIVER_MIR 1)
-
-            list(APPEND EXTRA_CFLAGS ${MIR_TOOLKIT_CFLAGS} ${EGL_CFLAGS} ${XKB_CFLAGS})
-
-            if(MIR_SHARED)
-                if(NOT HAVE_DLOPEN)
-                    message_warn("You must have SDL_LoadObject() support for dynamic Mir loading")
-                else()
-                    FindLibraryAndSONAME(mirclient)
-                    FindLibraryAndSONAME(xkbcommon)
-                    set(SDL_VIDEO_DRIVER_MIR_DYNAMIC "\"${MIRCLIENT_LIB_SONAME}\"")
-                    set(SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON "\"${XKBCOMMON_LIB_SONAME}\"")
-                    set(HAVE_MIR_SHARED TRUE)
-                endif()
-            else()
-                set(EXTRA_LIBS ${MIR_TOOLKIT_LIBRARIES} ${EXTRA_LIBS})
-            endif()
-        endif()
-    endif()
-endmacro()
-
 macro(WaylandProtocolGen _SCANNER _XML _PROTL)
     set(_WAYLAND_PROT_C_CODE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols/${_PROTL}-protocol.c")
     set(_WAYLAND_PROT_H_CODE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols/${_PROTL}-client-protocol.h")

+ 115 - 153
sdl.mod/SDL/configure

@@ -831,8 +831,6 @@ enable_libsamplerate_shared
 enable_video_wayland
 enable_video_wayland_qt_touch
 enable_wayland_shared
-enable_video_mir
-enable_mir_shared
 enable_video_rpi
 enable_video_x11
 with_x
@@ -1576,8 +1574,6 @@ Optional Features:
                           QtWayland server support for Wayland video driver
                           [[default=yes]]
   --enable-wayland-shared dynamically load Wayland support [[default=maybe]]
-  --enable-video-mir      use Mir video driver [[default=no]]
-  --enable-mir-shared     dynamically load Mir support [[default=maybe]]
   --enable-video-rpi      use Raspberry Pi video driver [[default=yes]]
   --enable-video-x11      use X11 video driver [[default=yes]]
   --enable-x11-shared     dynamically load X11 support [[default=maybe]]
@@ -15790,6 +15786,14 @@ find_lib()
             return
         fi
     done
+    # Try again, this time allowing more than one version digit after the .so
+    for path in $env_lib_path $gcc_bin_path $gcc_lib_path $host_lib_path; do
+        lib=`ls -- $path/$1 2>/dev/null | sed -e 's,.*/,,' | sort | tail -1`
+        if test x$lib != x; then
+            echo $lib
+            return
+        fi
+    done
 }
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5
@@ -16063,6 +16067,108 @@ esac
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_no_undefined" >&5
 $as_echo "$have_no_undefined" >&6; }
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for linker option --dynamicbase" >&5
+$as_echo_n "checking for linker option --dynamicbase... " >&6; }
+have_dynamicbase=no
+case "$host" in
+    *)
+        save_LDFLAGS="$LDFLAGS"
+        LDFLAGS="$LDFLAGS -Wl,--dynamicbase"
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+int
+main ()
+{
+
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+        have_dynamicbase=yes
+        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,--dynamicbase"
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+        LDFLAGS="$save_LDFLAGS"
+        ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_dynamicbase" >&5
+$as_echo "$have_dynamicbase" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for linker option --nxcompat" >&5
+$as_echo_n "checking for linker option --nxcompat... " >&6; }
+have_nxcompat=no
+case "$host" in
+    *)
+        save_LDFLAGS="$LDFLAGS"
+        LDFLAGS="$LDFLAGS -Wl,--nxcompat"
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+int
+main ()
+{
+
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+        have_nxcompat=yes
+        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,--nxcompat"
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+        LDFLAGS="$save_LDFLAGS"
+        ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_nxcompat" >&5
+$as_echo "$have_nxcompat" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for linker option --high-entropy-va" >&5
+$as_echo_n "checking for linker option --high-entropy-va... " >&6; }
+have_high_entropy_va=no
+case "$host" in
+    *)
+        save_LDFLAGS="$LDFLAGS"
+        LDFLAGS="$LDFLAGS -Wl,--high-entropy-va"
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+int
+main ()
+{
+
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+        have_high_entropy_va=yes
+        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,--high-entropy-va"
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+        LDFLAGS="$save_LDFLAGS"
+        ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_high_entropy_va" >&5
+$as_echo "$have_high_entropy_va" >&6; }
+
 # Check whether --enable-libc was given.
 if test "${enable_libc+set}" = set; then :
   enableval=$enable_libc;
@@ -19320,151 +19426,6 @@ _ACEOF
     fi
 }
 
-CheckMir()
-{
-    # Check whether --enable-video-mir was given.
-if test "${enable_video_mir+set}" = set; then :
-  enableval=$enable_video_mir;
-else
-  enable_video_mir=no
-fi
-
-
-    if test x$enable_video = xyes -a x$enable_video_mir = xyes; then
-        # Extract the first word of "pkg-config", so it can be a program name with args.
-set dummy pkg-config; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_PKG_CONFIG+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $PKG_CONFIG in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
-  ;;
-esac
-fi
-PKG_CONFIG=$ac_cv_path_PKG_CONFIG
-if test -n "$PKG_CONFIG"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
-$as_echo "$PKG_CONFIG" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Mir support" >&5
-$as_echo_n "checking for Mir support... " >&6; }
-        video_mir=no
-        if test x$PKG_CONFIG != xno; then
-            if $PKG_CONFIG --exists mirclient egl xkbcommon ; then
-                MIR_CFLAGS=`$PKG_CONFIG --cflags mirclient egl xkbcommon`
-                MIR_LIBS=`$PKG_CONFIG --libs mirclient egl xkbcommon`
-                save_CFLAGS="$CFLAGS"
-                CFLAGS="$save_CFLAGS $MIR_CFLAGS"
-
-                                cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-                #include <mir_toolkit/mir_client_library.h>
-
-int
-main ()
-{
-
-                    MirWindowAttrib attrib = mir_window_attrib_state
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-                video_mir=yes
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-                CFLAGS="$save_CFLAGS"
-            fi
-        fi
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_mir" >&5
-$as_echo "$video_mir" >&6; }
-
-        if test x$video_mir = xyes; then
-
-$as_echo "#define SDL_VIDEO_DRIVER_MIR 1" >>confdefs.h
-
-            SOURCES="$SOURCES $srcdir/src/video/mir/*.c"
-            EXTRA_CFLAGS="$EXTRA_CFLAGS $MIR_CFLAGS"
-            # Check whether --enable-mir-shared was given.
-if test "${enable_mir_shared+set}" = set; then :
-  enableval=$enable_mir_shared;
-else
-  enable_mir_shared=maybe
-fi
-
-
-                        case "$host" in
-                *)
-                    mirclient_lib=`find_lib "libmirclient.so.*" "$MIR_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`
-                    xkbcommon_lib=`find_lib "libxkbcommon.so.*" "$MIR_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`
-                    ;;
-            esac
-
-            if test x$enable_mir_shared = xmaybe; then
-                enable_mir_shared=yes
-            fi
-            if test x$have_loadso != xyes && \
-               test x$enable_mir_shared = xyes; then
-                { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic Mir loading" >&5
-$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic Mir loading" >&2;}
-                enable_mir_shared=no
-            fi
-            if test x$have_loadso = xyes && \
-               test x$enable_mir_shared = xyes && \
-               test x$mirclient_lib != x && \
-               test x$xkbcommon_lib != x; then
-                echo "-- dynamic libmirclient -> $mirclient_lib"
-                echo "-- dynamic libxkbcommon -> $xkbcommon_lib"
-
-cat >>confdefs.h <<_ACEOF
-#define SDL_VIDEO_DRIVER_MIR_DYNAMIC "$mirclient_lib"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON "$xkbcommon_lib"
-_ACEOF
-
-                SUMMARY_video="${SUMMARY_video} mir(dynamic)"
-            else
-                enable_mir_shared=no
-                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MIR_LIBS"
-                SUMMARY_video="${SUMMARY_video} mir"
-            fi
-            have_video=yes
-        fi
-    fi
-}
 
 CheckNativeClient()
 {
@@ -21814,6 +21775,7 @@ $as_echo_n "checking for EGL support... " >&6; }
 
           #define LINUX
           #define EGL_API_FB
+          #define MESA_EGL_NO_X11_HEADERS
           #include <EGL/egl.h>
           #include <EGL/eglext.h>
 
@@ -24051,7 +24013,6 @@ case "$host" in
         CheckOpenGLX11
         CheckOpenGLESX11
         CheckVulkan
-        CheckMir
         CheckWayland
         CheckLibUDev
         CheckDBus
@@ -24222,6 +24183,7 @@ $as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h
             SOURCES="$SOURCES $srcdir/src/core/linux/SDL_evdev*.c"
         fi
         # Set up other core UNIX files
+        SOURCES="$SOURCES $srcdir/src/core/linux/SDL_threadprio.c"
         SOURCES="$SOURCES $srcdir/src/core/unix/*.c"
         ;;
     *-*-cygwin* | *-*-mingw32*)
@@ -24906,7 +24868,7 @@ DEPENDS=`echo $SOURCES | tr ' ' '\n'`
 for EXT in asm cc m c S; do
     OBJECTS=`echo "$OBJECTS" | sed 's,[^ ]*/\([^ ]*\)\.'$EXT',$(objects)/\1.lo,g'`
     DEPENDS=`echo "$DEPENDS" | sed "s,^\\([^ ]*\\)/\\([^ ]*\\)\\.$EXT\\$,\\\\
-\\$(objects)/\\2.lo: \\1/\\2.$EXT\\\\
+\\$(objects)/\\2.lo: \\1/\\2.$EXT \\$(objects)/.created\\\\
 	\\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
 done
 
@@ -24923,14 +24885,14 @@ SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES`
 SDLMAIN_DEPENDS=`echo $SDLMAIN_SOURCES`
 SDLMAIN_OBJECTS=`echo "$SDLMAIN_OBJECTS" | sed 's,[^ ]*/\([^ ]*\)\.c,$(objects)/\1.lo,g'`
 SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed "s,\\([^ ]*\\)/\\([^ ]*\\)\\.c,\\\\
-\\$(objects)/\\2.lo: \\1/\\2.c\\\\
+\\$(objects)/\\2.lo: \\1/\\2.c \\$(objects)/.created\\\\
 	\\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
 
 SDLTEST_OBJECTS=`echo $SDLTEST_SOURCES`
 SDLTEST_DEPENDS=`echo $SDLTEST_SOURCES`
 SDLTEST_OBJECTS=`echo "$SDLTEST_OBJECTS" | sed 's,[^ ]*/\([^ ]*\)\.c,$(objects)/\1.lo,g'`
 SDLTEST_DEPENDS=`echo "$SDLTEST_DEPENDS" | sed "s,\\([^ ]*\\)/\\([^ ]*\\)\\.c,\\\\
-\\$(objects)/\\2.lo: \\1/\\2.c\\\\
+\\$(objects)/\\2.lo: \\1/\\2.c \\$(objects)/.created\\\\
 	\\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
 
 # Set runtime shared library paths as needed

+ 64 - 77
sdl.mod/SDL/configure.in

@@ -156,6 +156,14 @@ find_lib()
             return
         fi
     done
+    # Try again, this time allowing more than one version digit after the .so
+    for path in $env_lib_path $gcc_bin_path $gcc_lib_path $host_lib_path; do
+        lib=[`ls -- $path/$1 2>/dev/null | sed -e 's,.*/,,' | sort | tail -1`]
+        if test x$lib != x; then
+            echo $lib
+            return
+        fi
+    done
 }
 
 dnl Check for compiler characteristics
@@ -232,6 +240,57 @@ case "$host" in
 esac
 AC_MSG_RESULT($have_no_undefined)
 
+AC_MSG_CHECKING(for linker option --dynamicbase)
+have_dynamicbase=no
+case "$host" in
+    *)
+        save_LDFLAGS="$LDFLAGS"
+        LDFLAGS="$LDFLAGS -Wl,--dynamicbase"
+        AC_TRY_LINK([
+        ],[
+        ],[
+        have_dynamicbase=yes
+        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,--dynamicbase"
+        ])
+        LDFLAGS="$save_LDFLAGS"
+        ;;
+esac
+AC_MSG_RESULT($have_dynamicbase)
+
+AC_MSG_CHECKING(for linker option --nxcompat)
+have_nxcompat=no
+case "$host" in
+    *)
+        save_LDFLAGS="$LDFLAGS"
+        LDFLAGS="$LDFLAGS -Wl,--nxcompat"
+        AC_TRY_LINK([
+        ],[
+        ],[
+        have_nxcompat=yes
+        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,--nxcompat"
+        ])
+        LDFLAGS="$save_LDFLAGS"
+        ;;
+esac
+AC_MSG_RESULT($have_nxcompat)
+
+AC_MSG_CHECKING(for linker option --high-entropy-va)
+have_high_entropy_va=no
+case "$host" in
+    *)
+        save_LDFLAGS="$LDFLAGS"
+        LDFLAGS="$LDFLAGS -Wl,--high-entropy-va"
+        AC_TRY_LINK([
+        ],[
+        ],[
+        have_high_entropy_va=yes
+        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,--high-entropy-va"
+        ])
+        LDFLAGS="$save_LDFLAGS"
+        ;;
+esac
+AC_MSG_RESULT($have_high_entropy_va)
+
 dnl See whether we are allowed to use the system C library
 AC_ARG_ENABLE(libc,
 AC_HELP_STRING([--enable-libc], [Use the system C library [[default=yes]]]),
@@ -1477,79 +1536,6 @@ AC_HELP_STRING([--enable-wayland-shared], [dynamically load Wayland support [[de
     fi
 }
 
-dnl Check for Mir
-CheckMir()
-{
-    AC_ARG_ENABLE(video-mir,
-AC_HELP_STRING([--enable-video-mir], [use Mir video driver [[default=no]]]),
-                  ,enable_video_mir=no)
-
-    if test x$enable_video = xyes -a x$enable_video_mir = xyes; then
-        AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
-        AC_MSG_CHECKING(for Mir support)
-        video_mir=no
-        if test x$PKG_CONFIG != xno; then
-            if $PKG_CONFIG --exists mirclient egl xkbcommon ; then
-                MIR_CFLAGS=`$PKG_CONFIG --cflags mirclient egl xkbcommon`
-                MIR_LIBS=`$PKG_CONFIG --libs mirclient egl xkbcommon`
-                save_CFLAGS="$CFLAGS"
-                CFLAGS="$save_CFLAGS $MIR_CFLAGS"
-
-                dnl This will disable Mir if >= v0.26 is not available
-                AC_TRY_COMPILE([
-                #include <mir_toolkit/mir_client_library.h>
-                ],[
-                    MirWindowAttrib attrib = mir_window_attrib_state
-                ],[
-                video_mir=yes
-                ])
-                CFLAGS="$save_CFLAGS"
-            fi
-        fi
-        AC_MSG_RESULT($video_mir)
-
-        if test x$video_mir = xyes; then
-            AC_DEFINE(SDL_VIDEO_DRIVER_MIR, 1, [ ])
-            SOURCES="$SOURCES $srcdir/src/video/mir/*.c"
-            EXTRA_CFLAGS="$EXTRA_CFLAGS $MIR_CFLAGS"
-            AC_ARG_ENABLE(mir-shared,
-AC_HELP_STRING([--enable-mir-shared], [dynamically load Mir support [[default=maybe]]]),
-                          , enable_mir_shared=maybe)
-
-            dnl FIXME: Do BSD and OS X need special cases?
-            case "$host" in
-                *)
-                    mirclient_lib=[`find_lib "libmirclient.so.*" "$MIR_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
-                    xkbcommon_lib=[`find_lib "libxkbcommon.so.*" "$MIR_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
-                    ;;
-            esac
-
-            if test x$enable_mir_shared = xmaybe; then
-                enable_mir_shared=yes
-            fi
-            if test x$have_loadso != xyes && \
-               test x$enable_mir_shared = xyes; then
-                AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic Mir loading])
-                enable_mir_shared=no
-            fi
-            if test x$have_loadso = xyes && \
-               test x$enable_mir_shared = xyes && \
-               test x$mirclient_lib != x && \
-               test x$xkbcommon_lib != x; then
-                echo "-- dynamic libmirclient -> $mirclient_lib"
-                echo "-- dynamic libxkbcommon -> $xkbcommon_lib"
-                AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_MIR_DYNAMIC, "$mirclient_lib", [ ])
-                AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON, "$xkbcommon_lib", [ ])
-                SUMMARY_video="${SUMMARY_video} mir(dynamic)"
-            else
-                enable_mir_shared=no
-                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MIR_LIBS"
-                SUMMARY_video="${SUMMARY_video} mir"
-            fi
-            have_video=yes
-        fi
-    fi
-}
 
 dnl Check for Native Client stuff
 CheckNativeClient()
@@ -2354,6 +2340,7 @@ CheckOpenGLESX11()
         AC_TRY_COMPILE([
           #define LINUX
           #define EGL_API_FB
+          #define MESA_EGL_NO_X11_HEADERS
           #include <EGL/egl.h>
           #include <EGL/eglext.h>
         ],[
@@ -3425,7 +3412,6 @@ case "$host" in
         CheckOpenGLX11
         CheckOpenGLESX11
         CheckVulkan
-        CheckMir
         CheckWayland
         CheckLibUDev
         CheckDBus
@@ -3568,6 +3554,7 @@ case "$host" in
             SOURCES="$SOURCES $srcdir/src/core/linux/SDL_evdev*.c"
         fi       
         # Set up other core UNIX files
+        SOURCES="$SOURCES $srcdir/src/core/linux/SDL_threadprio.c"
         SOURCES="$SOURCES $srcdir/src/core/unix/*.c"
         ;;
     *-*-cygwin* | *-*-mingw32*)
@@ -4086,7 +4073,7 @@ DEPENDS=`echo $SOURCES | tr ' ' '\n'`
 for EXT in asm cc m c S; do
     OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.'$EXT',$(objects)/\1.lo,g'`
     DEPENDS=`echo "$DEPENDS" | sed "s,^\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.$EXT\\$,\\\\
-\\$(objects)/\\2.lo: \\1/\\2.$EXT\\\\
+\\$(objects)/\\2.lo: \\1/\\2.$EXT \\$(objects)/.created\\\\
 	\\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
 done
 
@@ -4103,14 +4090,14 @@ SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES`
 SDLMAIN_DEPENDS=`echo $SDLMAIN_SOURCES`
 SDLMAIN_OBJECTS=`echo "$SDLMAIN_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
 SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.c,\\\\
-\\$(objects)/\\2.lo: \\1/\\2.c\\\\
+\\$(objects)/\\2.lo: \\1/\\2.c \\$(objects)/.created\\\\
 	\\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
 
 SDLTEST_OBJECTS=`echo $SDLTEST_SOURCES`
 SDLTEST_DEPENDS=`echo $SDLTEST_SOURCES`
 SDLTEST_OBJECTS=`echo "$SDLTEST_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
 SDLTEST_DEPENDS=`echo "$SDLTEST_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.c,\\\\
-\\$(objects)/\\2.lo: \\1/\\2.c\\\\
+\\$(objects)/\\2.lo: \\1/\\2.c \\$(objects)/.created\\\\
 	\\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
 
 # Set runtime shared library paths as needed

+ 16 - 3
sdl.mod/SDL/debian/rules

@@ -4,9 +4,22 @@ DEB_HOST_ARCH_CPU ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU)
 DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
 
 confflags = --disable-rpath --disable-video-directfb \
-            --disable-nas --disable-esd --disable-arts \
-            --disable-alsa-shared --disable-pulseaudio-shared \
-            --disable-x11-shared
+            --disable-nas --disable-esd --disable-arts
+
+# These flags can be used to create a package directly linking with external libraries and having the appropriate package dependencies
+#confflags += --disable-alsa-shared
+#confflags += --disable-arts-shared
+#confflags += --disable-directfb-shared
+#confflags += --disable-esd-shared
+#confflags += --disable-fusionsound-shared
+#confflags += --disable-jack-shared
+#confflags += --disable-kmsdrm-shared
+#confflags += --disable-libsamplerate-shared
+#confflags += --disable-nas-shared
+#confflags += --disable-pulseaudio-shared
+#confflags += --disable-sndio-shared
+#confflags += --disable-wayland-shared
+#confflags += --disable-x11-shared
 
 %:
 	dh $@ --parallel

+ 28 - 25
sdl.mod/SDL/docs/README-android.md

@@ -77,18 +77,16 @@ For more complex projects, follow these instructions:
    and rename it to the name of your project.
 2. Move or symlink this SDL directory into the "<project>/app/jni" directory
 3. Edit "<project>/app/jni/src/Android.mk" to include your source files
-4. Run 'ndk-build' (a script provided by the NDK). This compiles the C source
 
-If you want to use Android Studio (recommended), skip to the Android Studio section below.
+4a. If you want to use Android Studio, simply open your <project> directory and start building.
 
-5. Run './gradlew installDebug' in the project directory. This compiles the .java, creates an .apk with the native code embedded, and installs it on any connected Android device
+4b. If you want to build manually, run './gradlew installDebug' in the project directory. This compiles the .java, creates an .apk with the native code embedded, and installs it on any connected Android device
 
 Here's an explanation of the files in the Android project, so you can customize them:
 
     android-project/app
         build.gradle            - build info including the application version and SDK
-        src/main/AndroidManifest.xml	- package manifest. Among others, it contains the class name
-        			  of the main Activity and the package name of the application.
+        src/main/AndroidManifest.xml	- package manifest. Among others, it contains the class name of the main Activity and the package name of the application.
         jni/			- directory holding native code
         jni/Application.mk	- Application JNI settings, including target platform and STL library
         jni/Android.mk		- Android makefile that can call recursively the Android.mk files in all subdirectories
@@ -216,26 +214,10 @@ detach it.
 You can use STL in your project by creating an Application.mk file in the jni
 folder and adding the following line:
 
-    APP_STL := stlport_static
+    APP_STL := c++_shared
 
-For more information check out CPLUSPLUS-SUPPORT.html in the NDK documentation.
-
-
-================================================================================
- Additional documentation
-================================================================================
-
-The documentation in the NDK docs directory is very helpful in understanding the
-build process and how to work with native code on the Android platform.
-
-The best place to start is with docs/OVERVIEW.TXT
-
-
-================================================================================
- Using Android Studio
-================================================================================
-
-You can open your project directory with Android Studio and run it normally.
+For more information go here:
+	https://developer.android.com/ndk/guides/cpp-support
 
 
 ================================================================================
@@ -291,7 +273,10 @@ You can see the complete command line that ndk-build is using by passing V=1 on
 
     ndk-build V=1
 
-If your application crashes in native code, you can use addr2line to convert the
+If your application crashes in native code, you can use ndk-stack to get a symbolic stack trace:
+	https://developer.android.com/ndk/guides/ndk-stack
+
+If you want to go through the process manually, you can use addr2line to convert the
 addresses in the stack trace to lines in your code.
 
 For example, if your crash looks like this:
@@ -423,6 +408,24 @@ screen each frame.
 Reference: http://www.khronos.org/registry/egl/specs/EGLTechNote0001.html
 
 
+================================================================================
+ Ending your application
+================================================================================
+
+Two legitimate ways:
+
+- return from your main() function. Java side will automatically terminate the
+Activity by calling Activity.finish().
+
+- Android OS can decide to terminate your application by calling onDestroy()
+(see Activity life cycle). Your application will receive a SDL_QUIT event you 
+can handle to save things and quit.
+
+Don't call exit() as it stops the activity badly.
+
+NB: "Back button" can be handled as a SDL_KEYDOWN/UP events, with Keycode
+SDLK_AC_BACK, for any purpose.
+
 ================================================================================
  Known issues
 ================================================================================

+ 0 - 3
sdl.mod/SDL/docs/README-linux.md

@@ -25,9 +25,6 @@ fcitx-libs-dev libsamplerate0-dev libsndio-dev
 Ubuntu 16.04+ can also add "libwayland-dev libxkbcommon-dev wayland-protocols"
 to that command line for Wayland support.
 
-Ubuntu 16.10 can also add "libmirclient-dev libxkbcommon-dev" to that command
-line for Mir support.
-
 NOTES:
 - This includes all the audio targets except arts, because Ubuntu pulled the 
   artsc0-dev package, but in theory SDL still supports it.

+ 1 - 1
sdl.mod/SDL/include/SDL_atomic.h

@@ -162,7 +162,7 @@ extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void);
 #define SDL_MemoryBarrierRelease()   __asm__ __volatile__ ("dmb ish" : : : "memory")
 #define SDL_MemoryBarrierAcquire()   __asm__ __volatile__ ("dmb ish" : : : "memory")
 #elif defined(__GNUC__) && defined(__arm__)
-#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__)
+#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) || defined(__ARM_ARCH_8A__)
 #define SDL_MemoryBarrierRelease()   __asm__ __volatile__ ("dmb ish" : : : "memory")
 #define SDL_MemoryBarrierAcquire()   __asm__ __volatile__ ("dmb ish" : : : "memory")
 #elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_5TE__)

+ 2 - 1
sdl.mod/SDL/include/SDL_audio.h

@@ -140,7 +140,8 @@ typedef Uint16 SDL_AudioFormat;
 #define SDL_AUDIO_ALLOW_FREQUENCY_CHANGE    0x00000001
 #define SDL_AUDIO_ALLOW_FORMAT_CHANGE       0x00000002
 #define SDL_AUDIO_ALLOW_CHANNELS_CHANGE     0x00000004
-#define SDL_AUDIO_ALLOW_ANY_CHANGE          (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE|SDL_AUDIO_ALLOW_FORMAT_CHANGE|SDL_AUDIO_ALLOW_CHANNELS_CHANGE)
+#define SDL_AUDIO_ALLOW_SAMPLES_CHANGE      0x00000008
+#define SDL_AUDIO_ALLOW_ANY_CHANGE          (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE|SDL_AUDIO_ALLOW_FORMAT_CHANGE|SDL_AUDIO_ALLOW_CHANNELS_CHANGE|SDL_AUDIO_ALLOW_SAMPLES_CHANGE)
 /* @} */
 
 /* @} *//* Audio flags */

+ 9 - 0
sdl.mod/SDL/include/SDL_bits.h

@@ -101,6 +101,15 @@ SDL_MostSignificantBitIndex32(Uint32 x)
 #endif
 }
 
+SDL_FORCE_INLINE SDL_bool
+SDL_HasExactlyOneBitSet32(Uint32 x)
+{
+    if (x && !(x & (x - 1))) {
+        return SDL_TRUE;
+    }
+    return SDL_FALSE;
+}
+
 /* Ends C function definitions when using C++ */
 #ifdef __cplusplus
 }

+ 6 - 6
sdl.mod/SDL/include/SDL_blendmode.h

@@ -90,12 +90,12 @@ typedef enum
 /**
  *  \brief Create a custom blend mode, which may or may not be supported by a given renderer
  *
- *  \param srcColorFactor
- *  \param dstColorFactor
- *  \param colorOperation
- *  \param srcAlphaFactor
- *  \param dstAlphaFactor
- *  \param alphaOperation
+ *  \param srcColorFactor source color factor
+ *  \param dstColorFactor destination color factor
+ *  \param colorOperation color operation
+ *  \param srcAlphaFactor source alpha factor
+ *  \param dstAlphaFactor destination alpha factor
+ *  \param alphaOperation alpha operation
  *
  *  The result of the blend mode operation will be:
  *      dstRGB = dstRGB * dstColorFactor colorOperation srcRGB * srcColorFactor

+ 3 - 1
sdl.mod/SDL/include/SDL_config.h

@@ -41,8 +41,10 @@
 #include "SDL_config_android.h"
 #elif defined(__PSP__)
 #include "SDL_config_psp.h"
+#elif defined(__OS2__)
+#include "SDL_config_os2.h"
 #else
-/* This is a minimal configuration just to get SDL running on new platforms */
+/* This is a minimal configuration just to get SDL running on new platforms. */
 #include "SDL_config_minimal.h"
 #endif /* platform config */
 

+ 0 - 3
sdl.mod/SDL/include/SDL_config.h.cmake

@@ -339,9 +339,6 @@
 #cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR@
 #cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON@
 
-#cmakedefine SDL_VIDEO_DRIVER_MIR @SDL_VIDEO_DRIVER_MIR@
-#cmakedefine SDL_VIDEO_DRIVER_MIR_DYNAMIC @SDL_VIDEO_DRIVER_MIR_DYNAMIC@
-#cmakedefine SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON @SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON@
 #cmakedefine SDL_VIDEO_DRIVER_EMSCRIPTEN @SDL_VIDEO_DRIVER_EMSCRIPTEN@
 #cmakedefine SDL_VIDEO_DRIVER_X11 @SDL_VIDEO_DRIVER_X11@
 #cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC @SDL_VIDEO_DRIVER_X11_DYNAMIC@

+ 0 - 3
sdl.mod/SDL/include/SDL_config.h.in

@@ -327,9 +327,6 @@
 #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL
 #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR
 #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON
-#undef SDL_VIDEO_DRIVER_MIR
-#undef SDL_VIDEO_DRIVER_MIR_DYNAMIC
-#undef SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON
 #undef SDL_VIDEO_DRIVER_X11
 #undef SDL_VIDEO_DRIVER_RPI
 #undef SDL_VIDEO_DRIVER_KMSDRM

+ 1 - 1
sdl.mod/SDL/include/SDL_config_iphoneos.h

@@ -137,7 +137,7 @@
 
 /* Enable MFi joystick support */
 #define SDL_JOYSTICK_MFI 1
-#define SDL_JOYSTICK_HIDAPI 1
+/*#define SDL_JOYSTICK_HIDAPI 1*/
 
 #ifdef __TVOS__
 #define SDL_SENSOR_DUMMY    1

+ 170 - 0
sdl.mod/SDL/include/SDL_config_os2.h

@@ -0,0 +1,170 @@
+/*
+  Simple DirectMedia Layer
+  Copyright (C) 1997-2018 Sam Lantinga <[email protected]>
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef SDL_config_os2_h_
+#define SDL_config_os2_h_
+#define SDL_config_h_
+
+#include "SDL_platform.h"
+
+#define SDL_AUDIO_DRIVER_DUMMY 1
+#define SDL_AUDIO_DRIVER_DISK 1
+
+#define SDL_POWER_DISABLED  1
+#define SDL_JOYSTICK_DISABLED 1
+#define SDL_HAPTIC_DISABLED 1
+/*#undef SDL_JOYSTICK_HIDAPI */
+
+#define SDL_SENSOR_DUMMY 1
+#define SDL_VIDEO_DRIVER_DUMMY 1
+
+/* Enable OpenGL support */
+/* #undef SDL_VIDEO_OPENGL */
+
+/* Enable Vulkan support */
+/* #undef SDL_VIDEO_VULKAN */
+
+#define SDL_LOADSO_DISABLED 1
+#define SDL_THREADS_DISABLED 1
+#define SDL_TIMERS_DISABLED 1
+#define SDL_FILESYSTEM_DUMMY 1
+
+/* Enable assembly routines */
+#define SDL_ASSEMBLY_ROUTINES 1
+
+/* #undef HAVE_LIBSAMPLERATE_H */
+
+/* Enable dynamic libsamplerate support */
+/* #undef SDL_LIBSAMPLERATE_DYNAMIC */
+
+#define HAVE_LIBC 1
+
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_STDIO_H 1
+#define STDC_HEADERS 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STDARG_H 1
+#define HAVE_STDDEF_H 1
+#define HAVE_MALLOC_H 1
+#define HAVE_MEMORY_H 1
+#define HAVE_STRING_H 1
+#define HAVE_STRINGS_H 1
+#define HAVE_WCHAR_H 1
+#define HAVE_INTTYPES_H 1
+#define HAVE_STDINT_H 1
+#define HAVE_LIMITS_H 1
+#define HAVE_CTYPE_H 1
+#define HAVE_MATH_H 1
+#define HAVE_FLOAT_H 1
+#define HAVE_SIGNAL_H 1
+
+#define HAVE_MALLOC 1
+#define HAVE_CALLOC 1
+#define HAVE_REALLOC 1
+#define HAVE_FREE 1
+#if defined(__WATCOMC__)
+#define HAVE__FSEEKI64 1
+#define HAVE__FTELLI64 1
+#endif
+#define HAVE_ALLOCA 1
+#define HAVE_GETENV 1
+#define HAVE_SETENV 1
+#define HAVE_PUTENV 1
+#define HAVE_QSORT 1
+#define HAVE_ABS 1
+#define HAVE_BCOPY 1
+#define HAVE_MEMSET 1
+#define HAVE_MEMCPY 1
+#define HAVE_MEMMOVE 1
+#define HAVE_MEMCMP 1
+#define HAVE_WCSLEN 1
+#define HAVE_WCSLCPY 1
+#define HAVE_WCSLCAT 1
+#define HAVE_WCSCMP 1
+#define HAVE_STRLEN 1
+#define HAVE_STRLCPY 1
+#define HAVE_STRLCAT 1
+#define HAVE__STRREV 1
+#define HAVE__STRUPR 1
+#define HAVE__STRLWR 1
+#define HAVE_INDEX 1
+#define HAVE_RINDEX 1
+#define HAVE_STRCHR 1
+#define HAVE_STRRCHR 1
+#define HAVE_STRSTR 1
+#define HAVE_ITOA 1
+#define HAVE__LTOA 1
+#define HAVE__ULTOA 1
+#define HAVE_STRTOL 1
+#define HAVE_STRTOUL 1
+#define HAVE__I64TOA 1
+#define HAVE__UI64TOA 1
+#define HAVE_STRTOLL 1
+#define HAVE_STRTOULL 1
+#define HAVE_STRTOD 1
+#define HAVE_ATOI 1
+#define HAVE_ATOF 1
+#define HAVE_STRCMP 1
+#define HAVE_STRNCMP 1
+#define HAVE_STRICMP 1
+#define HAVE_STRCASECMP 1
+#define HAVE_STRNCASECMP 1
+#define HAVE_SSCANF 1
+#define HAVE_SNPRINTF 1
+#define HAVE_VSNPRINTF 1
+#define HAVE_SETJMP 1
+#define HAVE_ACOS 1
+/* #undef HAVE_ACOSF */
+#define HAVE_ASIN 1
+/* #undef HAVE_ASINF */
+#define HAVE_ATAN 1
+#define HAVE_ATAN2 1
+/* #undef HAVE_ATAN2F */
+#define HAVE_CEIL 1
+/* #undef HAVE_CEILF */
+/* #undef HAVE_COPYSIGN */
+/* #undef HAVE_COPYSIGNF */
+#define HAVE_COS 1
+/* #undef HAVE_COSF */
+#define HAVE_EXP 1
+/* #undef HAVE_EXPF */
+#define HAVE_FABS 1
+/* #undef HAVE_FABSF */
+#define HAVE_FLOOR 1
+/* #undef HAVE_FLOORF */
+#define HAVE_FMOD 1
+/* #undef HAVE_FMODF */
+#define HAVE_LOG 1
+/* #undef HAVE_LOGF */
+#define HAVE_LOG10 1
+/* #undef HAVE_LOG10F */
+#define HAVE_POW 1
+/* #undef HAVE_POWF */
+#define HAVE_SIN 1
+/* #undef HAVE_SINF */
+/* #undef HAVE_SCALBN */
+/* #undef HAVE_SCALBNF */
+#define HAVE_SQRT 1
+/* #undef HAVE_SQRTF */
+#define HAVE_TAN 1
+/* #undef HAVE_TANF */
+
+#endif /* SDL_config_os2_h_ */

+ 18 - 7
sdl.mod/SDL/include/SDL_cpuinfo.h

@@ -50,15 +50,26 @@
 #elif defined(__MINGW64_VERSION_MAJOR)
 #include <intrin.h>
 #else
-#ifdef __ALTIVEC__
-#if defined(HAVE_ALTIVEC_H) && !defined(__APPLE_ALTIVEC__) && !defined(SDL_DISABLE_ALTIVEC_H)
+/* altivec.h redefining bool causes a number of problems, see bugs 3993 and 4392, so you need to explicitly define SDL_ENABLE_ALTIVEC_H to have it included. */
+#if defined(HAVE_ALTIVEC_H) && defined(__ALTIVEC__) && !defined(__APPLE_ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC_H)
 #include <altivec.h>
-#undef pixel
-#undef bool
 #endif
-#endif
-#if defined(__ARM_NEON__) && !defined(SDL_DISABLE_ARM_NEON_H)
-#include <arm_neon.h>
+#if !defined(SDL_DISABLE_ARM_NEON_H)
+#  if defined(__ARM_NEON)
+#    include <arm_neon.h>
+#  elif defined(__WINDOWS__) || defined(__WINRT__)
+/* Visual Studio doesn't define __ARM_ARCH, but _M_ARM (if set, always 7), and _M_ARM64 (if set, always 1). */
+#    if defined(_M_ARM)
+#      include <armintr.h>
+#      include <arm_neon.h>
+#    endif
+#    if defined (_M_ARM64)
+#      include <armintr.h>
+#      include <arm_neon.h>
+#    endif
+/* Set __ARM_NEON so that it can be used elsewhere, at compile time */
+#    define __ARM_NEON 1
+#  endif
 #endif
 #if defined(__3dNOW__) && !defined(SDL_DISABLE_MM3DNOW_H)
 #include <mm3dnow.h>

+ 7 - 0
sdl.mod/SDL/include/SDL_gamecontroller.h

@@ -204,6 +204,13 @@ extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromInstanceID(SDL
  */
 extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller);
 
+/**
+ *  Get the player index of an opened game controller, or -1 if it's not available
+ *
+ *  For XInput controllers this returns the XInput user index.
+ */
+extern DECLSPEC int SDLCALL SDL_GameControllerGetPlayerIndex(SDL_GameController *gamecontroller);
+
 /**
  *  Get the USB vendor ID of an opened controller, if available.
  *  If the vendor ID isn't available this function returns 0.

+ 11 - 0
sdl.mod/SDL/include/SDL_haptic.h

@@ -117,6 +117,17 @@
 extern "C" {
 #endif /* __cplusplus */
 
+/* FIXME: For SDL 2.1, adjust all the magnitude variables to be Uint16 (0xFFFF).
+ *
+ * At the moment the magnitude variables are mixed between signed/unsigned, and
+ * it is also not made clear that ALL of those variables expect a max of 0x7FFF.
+ *
+ * Some platforms may have higher precision than that (Linux FF, Windows XInput)
+ * so we should fix the inconsistency in favor of higher possible precision,
+ * adjusting for platforms that use different scales.
+ * -flibit
+ */
+
 /**
  *  \typedef SDL_Haptic
  *

+ 40 - 1
sdl.mod/SDL/include/SDL_hints.h

@@ -339,7 +339,7 @@ extern "C" {
 #define SDL_HINT_IDLE_TIMER_DISABLED "SDL_IOS_IDLE_TIMER_DISABLED"
 
 /**
- *  \brief  A variable controlling which orientations are allowed on iOS.
+ *  \brief  A variable controlling which orientations are allowed on iOS/Android.
  *
  *  In some circumstances it is necessary to be able to explicitly control
  *  which UI orientations are allowed.
@@ -436,6 +436,16 @@ extern "C" {
  */
 #define SDL_HINT_GAMECONTROLLERCONFIG "SDL_GAMECONTROLLERCONFIG"
 
+/**
+ *  \brief  A variable that lets you provide a file with extra gamecontroller db entries.
+ *
+ *  The file should contain lines of gamecontroller config data, see SDL_gamecontroller.h
+ *
+ *  This hint must be set before calling SDL_Init(SDL_INIT_GAMECONTROLLER)
+ *  You can update mappings after the system is initialized with SDL_GameControllerMappingForGUID() and SDL_GameControllerAddMapping()
+ */
+#define SDL_HINT_GAMECONTROLLERCONFIG_FILE "SDL_GAMECONTROLLERCONFIG_FILE"
+
 /**
  *  \brief  A variable containing a list of devices to skip when scanning for game controllers.
  *
@@ -619,6 +629,10 @@ extern "C" {
 *  This is specially useful if you build SDL against a non glibc libc library (such as musl) which
 *  provides a relatively small default thread stack size (a few kilobytes versus the default 8MB glibc uses).
 *  Support for this hint is currently available only in the pthread, Windows, and PSP backend.
+*
+*  Instead of this hint, in 2.0.9 and later, you can use
+*  SDL_CreateThreadWithStackSize(). This hint only works with the classic
+*  SDL_CreateThread().
 */
 #define SDL_HINT_THREAD_STACK_SIZE              "SDL_THREAD_STACK_SIZE"
 
@@ -1039,6 +1053,31 @@ extern "C" {
  */
 #define SDL_HINT_AUDIO_CATEGORY   "SDL_AUDIO_CATEGORY"
 
+/**
+ *  \brief  A variable controlling whether the 2D render API is compatible or efficient.
+ *
+ *  This variable can be set to the following values:
+ *
+ *    "0"     - Don't use batching to make rendering more efficient.
+ *    "1"     - Use batching, but might cause problems if app makes its own direct OpenGL calls.
+ *
+ *  Up to SDL 2.0.9, the render API would draw immediately when requested. Now
+ *  it batches up draw requests and sends them all to the GPU only when forced
+ *  to (during SDL_RenderPresent, when changing render targets, by updating a
+ *  texture that the batch needs, etc). This is significantly more efficient,
+ *  but it can cause problems for apps that expect to render on top of the
+ *  render API's output. As such, SDL will disable batching if a specific
+ *  render backend is requested (since this might indicate that the app is
+ *  planning to use the underlying graphics API directly). This hint can
+ *  be used to explicitly request batching in this instance. It is a contract
+ *  that you will either never use the underlying graphics API directly, or
+ *  if you do, you will call SDL_RenderFlush() before you do so any current
+ *  batch goes to the GPU before your work begins. Not following this contract
+ *  will result in undefined behavior.
+ */
+#define SDL_HINT_RENDER_BATCHING  "SDL_RENDER_BATCHING"
+
+
 /**
  *  \brief  An enumeration of hint priorities
  */

+ 13 - 0
sdl.mod/SDL/include/SDL_joystick.h

@@ -132,6 +132,12 @@ extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
  */
 extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index);
 
+/**
+ *  Get the player index of a joystick, or -1 if it's not available
+ *  This can be called before any joysticks are opened.
+ */
+extern DECLSPEC int SDLCALL SDL_JoystickGetDevicePlayerIndex(int device_index);
+
 /**
  *  Return the GUID for the joystick at this index
  *  This can be called before any joysticks are opened.
@@ -194,6 +200,13 @@ extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromInstanceID(SDL_JoystickID
  */
 extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick * joystick);
 
+/**
+ *  Get the player index of an opened joystick, or -1 if it's not available
+ *
+ *  For XInput controllers this returns the XInput user index.
+ */
+extern DECLSPEC int SDLCALL SDL_JoystickGetPlayerIndex(SDL_Joystick * joystick);
+
 /**
  *  Return the GUID for this opened joystick
  */

+ 2 - 2
sdl.mod/SDL/include/SDL_pixels.h

@@ -168,7 +168,7 @@ enum
     ((format) && (SDL_PIXELFLAG(format) != 1))
 
 /* Note: If you modify this list, update SDL_GetPixelFormatName() */
-enum
+typedef enum
 {
     SDL_PIXELFORMAT_UNKNOWN,
     SDL_PIXELFORMAT_INDEX1LSB =
@@ -290,7 +290,7 @@ enum
         SDL_DEFINE_PIXELFOURCC('N', 'V', '2', '1'),
     SDL_PIXELFORMAT_EXTERNAL_OES =      /**< Android video texture format */
         SDL_DEFINE_PIXELFOURCC('O', 'E', 'S', ' ')
-};
+} SDL_PixelFormatEnum;
 
 typedef struct SDL_Color
 {

+ 28 - 2
sdl.mod/SDL/include/SDL_rect.h

@@ -40,7 +40,7 @@ extern "C" {
 #endif
 
 /**
- *  \brief  The structure that defines a point
+ *  \brief  The structure that defines a point (integer)
  *
  *  \sa SDL_EnclosePoints
  *  \sa SDL_PointInRect
@@ -52,7 +52,20 @@ typedef struct SDL_Point
 } SDL_Point;
 
 /**
- *  \brief A rectangle, with the origin at the upper left.
+ *  \brief  The structure that defines a point (floating point)
+ *
+ *  \sa SDL_EnclosePoints
+ *  \sa SDL_PointInRect
+ */
+typedef struct SDL_FPoint
+{
+    float x;
+    float y;
+} SDL_FPoint;
+
+
+/**
+ *  \brief A rectangle, with the origin at the upper left (integer).
  *
  *  \sa SDL_RectEmpty
  *  \sa SDL_RectEquals
@@ -67,6 +80,19 @@ typedef struct SDL_Rect
     int w, h;
 } SDL_Rect;
 
+
+/**
+ *  \brief A rectangle, with the origin at the upper left (floating point).
+ */
+typedef struct SDL_FRect
+{
+    float x;
+    float y;
+    float w;
+    float h;
+} SDL_FRect;
+
+
 /**
  *  \brief Returns true if point resides inside a rectangle.
  */

+ 167 - 0
sdl.mod/SDL/include/SDL_render.h

@@ -835,6 +835,148 @@ extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer,
                                            const SDL_Point *center,
                                            const SDL_RendererFlip flip);
 
+
+/**
+ *  \brief Draw a point on the current rendering target.
+ *
+ *  \param renderer The renderer which should draw a point.
+ *  \param x The x coordinate of the point.
+ *  \param y The y coordinate of the point.
+ *
+ *  \return 0 on success, or -1 on error
+ */
+extern DECLSPEC int SDLCALL SDL_RenderDrawPointF(SDL_Renderer * renderer,
+                                                 float x, float y);
+
+/**
+ *  \brief Draw multiple points on the current rendering target.
+ *
+ *  \param renderer The renderer which should draw multiple points.
+ *  \param points The points to draw
+ *  \param count The number of points to draw
+ *
+ *  \return 0 on success, or -1 on error
+ */
+extern DECLSPEC int SDLCALL SDL_RenderDrawPointsF(SDL_Renderer * renderer,
+                                                  const SDL_FPoint * points,
+                                                  int count);
+
+/**
+ *  \brief Draw a line on the current rendering target.
+ *
+ *  \param renderer The renderer which should draw a line.
+ *  \param x1 The x coordinate of the start point.
+ *  \param y1 The y coordinate of the start point.
+ *  \param x2 The x coordinate of the end point.
+ *  \param y2 The y coordinate of the end point.
+ *
+ *  \return 0 on success, or -1 on error
+ */
+extern DECLSPEC int SDLCALL SDL_RenderDrawLineF(SDL_Renderer * renderer,
+                                                float x1, float y1, float x2, float y2);
+
+/**
+ *  \brief Draw a series of connected lines on the current rendering target.
+ *
+ *  \param renderer The renderer which should draw multiple lines.
+ *  \param points The points along the lines
+ *  \param count The number of points, drawing count-1 lines
+ *
+ *  \return 0 on success, or -1 on error
+ */
+extern DECLSPEC int SDLCALL SDL_RenderDrawLinesF(SDL_Renderer * renderer,
+                                                const SDL_FPoint * points,
+                                                int count);
+
+/**
+ *  \brief Draw a rectangle on the current rendering target.
+ *
+ *  \param renderer The renderer which should draw a rectangle.
+ *  \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target.
+ *
+ *  \return 0 on success, or -1 on error
+ */
+extern DECLSPEC int SDLCALL SDL_RenderDrawRectF(SDL_Renderer * renderer,
+                                               const SDL_FRect * rect);
+
+/**
+ *  \brief Draw some number of rectangles on the current rendering target.
+ *
+ *  \param renderer The renderer which should draw multiple rectangles.
+ *  \param rects A pointer to an array of destination rectangles.
+ *  \param count The number of rectangles.
+ *
+ *  \return 0 on success, or -1 on error
+ */
+extern DECLSPEC int SDLCALL SDL_RenderDrawRectsF(SDL_Renderer * renderer,
+                                                 const SDL_FRect * rects,
+                                                 int count);
+
+/**
+ *  \brief Fill a rectangle on the current rendering target with the drawing color.
+ *
+ *  \param renderer The renderer which should fill a rectangle.
+ *  \param rect A pointer to the destination rectangle, or NULL for the entire
+ *              rendering target.
+ *
+ *  \return 0 on success, or -1 on error
+ */
+extern DECLSPEC int SDLCALL SDL_RenderFillRectF(SDL_Renderer * renderer,
+                                                const SDL_FRect * rect);
+
+/**
+ *  \brief Fill some number of rectangles on the current rendering target with the drawing color.
+ *
+ *  \param renderer The renderer which should fill multiple rectangles.
+ *  \param rects A pointer to an array of destination rectangles.
+ *  \param count The number of rectangles.
+ *
+ *  \return 0 on success, or -1 on error
+ */
+extern DECLSPEC int SDLCALL SDL_RenderFillRectsF(SDL_Renderer * renderer,
+                                                 const SDL_FRect * rects,
+                                                 int count);
+
+/**
+ *  \brief Copy a portion of the texture to the current rendering target.
+ *
+ *  \param renderer The renderer which should copy parts of a texture.
+ *  \param texture The source texture.
+ *  \param srcrect   A pointer to the source rectangle, or NULL for the entire
+ *                   texture.
+ *  \param dstrect   A pointer to the destination rectangle, or NULL for the
+ *                   entire rendering target.
+ *
+ *  \return 0 on success, or -1 on error
+ */
+extern DECLSPEC int SDLCALL SDL_RenderCopyF(SDL_Renderer * renderer,
+                                            SDL_Texture * texture,
+                                            const SDL_Rect * srcrect,
+                                            const SDL_FRect * dstrect);
+
+/**
+ *  \brief Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center
+ *
+ *  \param renderer The renderer which should copy parts of a texture.
+ *  \param texture The source texture.
+ *  \param srcrect   A pointer to the source rectangle, or NULL for the entire
+ *                   texture.
+ *  \param dstrect   A pointer to the destination rectangle, or NULL for the
+ *                   entire rendering target.
+ *  \param angle    An angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction
+ *  \param center   A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done around dstrect.w/2, dstrect.h/2).
+ *  \param flip     An SDL_RendererFlip value stating which flipping actions should be performed on the texture
+ *
+ *  \return 0 on success, or -1 on error
+ */
+extern DECLSPEC int SDLCALL SDL_RenderCopyExF(SDL_Renderer * renderer,
+                                            SDL_Texture * texture,
+                                            const SDL_Rect * srcrect,
+                                            const SDL_FRect * dstrect,
+                                            const double angle,
+                                            const SDL_FPoint *center,
+                                            const SDL_RendererFlip flip);
+
 /**
  *  \brief Read pixels from the current rendering target.
  *
@@ -876,6 +1018,31 @@ extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture);
  */
 extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer);
 
+/**
+ *  \brief Force the rendering context to flush any pending commands to the
+ *         underlying rendering API.
+ *
+ *  You do not need to (and in fact, shouldn't) call this function unless
+ *  you are planning to call into OpenGL/Direct3D/Metal/whatever directly
+ *  in addition to using an SDL_Renderer.
+ *
+ *  This is for a very-specific case: if you are using SDL's render API,
+ *  you asked for a specific renderer backend (OpenGL, Direct3D, etc),
+ *  you set SDL_HINT_RENDER_BATCHING to "1", and you plan to make
+ *  OpenGL/D3D/whatever calls in addition to SDL render API calls. If all of
+ *  this applies, you should call SDL_RenderFlush() between calls to SDL's
+ *  render API and the low-level API you're using in cooperation.
+ *
+ *  In all other cases, you can ignore this function. This is only here to
+ *  get maximum performance out of a specific situation. In all other cases,
+ *  SDL will do the right thing, perhaps at a performance loss.
+ *
+ *  This function is first available in SDL 2.0.10, and is not needed in
+ *  2.0.9 and earlier, as earlier versions did not queue rendering commands
+ *  at all, instead flushing them to the OS immediately.
+ */
+extern DECLSPEC int SDLCALL SDL_RenderFlush(SDL_Renderer * renderer);
+
 
 /**
  *  \brief Bind the texture to the current OpenGL/ES/ES2 context for use with

+ 1 - 1
sdl.mod/SDL/include/SDL_scancode.h

@@ -38,7 +38,7 @@
  *  SDL_Event structure.
  *
  *  The values in this enumeration are based on the USB usage page standard:
- *  http://www.usb.org/developers/hidpage/Hut1_12v2.pdf
+ *  https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf
  */
 typedef enum
 {

+ 3 - 3
sdl.mod/SDL/include/SDL_sensor.h

@@ -26,8 +26,8 @@
  *
  */
 
-#ifndef _SDL_sensor_h
-#define _SDL_sensor_h
+#ifndef SDL_sensor_h_
+#define SDL_sensor_h_
 
 #include "SDL_stdinc.h"
 #include "SDL_error.h"
@@ -246,6 +246,6 @@ extern DECLSPEC void SDLCALL SDL_SensorUpdate(void);
 #endif
 #include "close_code.h"
 
-#endif /* _SDL_sensor_h */
+#endif /* SDL_sensor_h_ */
 
 /* vi: set ts=4 sw=4 expandtab: */

+ 10 - 7
sdl.mod/SDL/include/SDL_syswm.h

@@ -34,16 +34,16 @@
 #include "SDL_version.h"
 
 /**
- *  \file SDL_syswm.h
+ *  \brief SDL_syswm.h
  *
  *  Your application has access to a special type of event ::SDL_SYSWMEVENT,
  *  which contains window-manager specific information and arrives whenever
  *  an unhandled window event occurs.  This event is ignored by default, but
  *  you can enable it with SDL_EventState().
  */
-#ifdef SDL_PROTOTYPES_ONLY
 struct SDL_SysWMinfo;
-#else
+
+#if !defined(SDL_PROTOTYPES_ONLY)
 
 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
 #ifndef WIN32_LEAN_AND_MEAN
@@ -103,6 +103,8 @@ typedef void *EGLSurface;
 #if defined(SDL_VIDEO_DRIVER_VIVANTE)
 #include "SDL_egl.h"
 #endif
+#endif /* SDL_PROTOTYPES_ONLY */
+
 
 #include "begin_code.h"
 /* Set up for C function definitions, even when using C++ */
@@ -110,6 +112,7 @@ typedef void *EGLSurface;
 extern "C" {
 #endif
 
+#if !defined(SDL_PROTOTYPES_ONLY)
 /**
  *  These are the various supported windowing subsystems
  */
@@ -122,7 +125,7 @@ typedef enum
     SDL_SYSWM_COCOA,
     SDL_SYSWM_UIKIT,
     SDL_SYSWM_WAYLAND,
-    SDL_SYSWM_MIR,
+    SDL_SYSWM_MIR,  /* no longer available, left for API/ABI compatibility. Remove in 2.1! */
     SDL_SYSWM_WINRT,
     SDL_SYSWM_ANDROID,
     SDL_SYSWM_VIVANTE,
@@ -257,11 +260,11 @@ struct SDL_SysWMinfo
             struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */
         } wl;
 #endif
-#if defined(SDL_VIDEO_DRIVER_MIR)
+#if defined(SDL_VIDEO_DRIVER_MIR)  /* no longer available, left for API/ABI compatibility. Remove in 2.1! */
         struct
         {
-            struct MirConnection *connection;  /**< Mir display server connection */
-            struct MirSurface *surface;  /**< Mir surface */
+            void *connection;  /**< Mir display server connection */
+            void *surface;  /**< Mir surface */
         } mir;
 #endif
 

+ 2 - 2
sdl.mod/SDL/include/SDL_test_memory.h

@@ -42,14 +42,14 @@ extern "C" {
  * 
  * \note This should be called before any other SDL functions for complete tracking coverage
  */
-int SDLTest_TrackAllocations();
+int SDLTest_TrackAllocations(void);
 
 /**
  * \brief Print a log of any outstanding allocations
  *
  * \note This can be called after SDL_Quit()
  */
-void SDLTest_LogAllocations();
+void SDLTest_LogAllocations(void);
 
 
 /* Ends C function definitions when using C++ */

+ 35 - 1
sdl.mod/SDL/include/SDL_thread.h

@@ -106,14 +106,24 @@ SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data,
                  pfnSDL_CurrentBeginThread pfnBeginThread,
                  pfnSDL_CurrentEndThread pfnEndThread);
 
+extern DECLSPEC SDL_Thread *SDLCALL
+SDL_CreateThreadWithStackSize(int (SDLCALL * fn) (void *),
+                 const char *name, const size_t stacksize, void *data,
+                 pfnSDL_CurrentBeginThread pfnBeginThread,
+                 pfnSDL_CurrentEndThread pfnEndThread);
+
+
 /**
  *  Create a thread.
  */
 #if defined(SDL_CreateThread) && SDL_DYNAMIC_API
 #undef SDL_CreateThread
 #define SDL_CreateThread(fn, name, data) SDL_CreateThread_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)_endthreadex)
+#undef SDL_CreateThreadWithStackSize
+#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize_REAL(fn, name, stacksize, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)_endthreadex)
 #else
 #define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)_endthreadex)
+#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)_endthreadex)
 #endif
 
 #elif defined(__OS2__)
@@ -133,15 +143,31 @@ extern DECLSPEC SDL_Thread *SDLCALL
 SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data,
                  pfnSDL_CurrentBeginThread pfnBeginThread,
                  pfnSDL_CurrentEndThread pfnEndThread);
+extern DECLSPEC SDL_Thread *SDLCALL
+SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const size_t stacksize, void *data,
+                 pfnSDL_CurrentBeginThread pfnBeginThread,
+                 pfnSDL_CurrentEndThread pfnEndThread);
 #if defined(SDL_CreateThread) && SDL_DYNAMIC_API
 #undef SDL_CreateThread
 #define SDL_CreateThread(fn, name, data) SDL_CreateThread_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthread, (pfnSDL_CurrentEndThread)_endthread)
+#undef SDL_CreateThreadWithStackSize
+#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthread, (pfnSDL_CurrentEndThread)_endthread)
 #else
 #define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthread, (pfnSDL_CurrentEndThread)_endthread)
+#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize(fn, name, stacksize, data, (pfnSDL_CurrentBeginThread)_beginthread, (pfnSDL_CurrentEndThread)_endthread)
 #endif
 
 #else
 
+/**
+ *  Create a thread with a default stack size.
+ *
+ *  This is equivalent to calling:
+ *  SDL_CreateThreadWithStackSize(fn, name, 0, data);
+ */
+extern DECLSPEC SDL_Thread *SDLCALL
+SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data);
+
 /**
  *  Create a thread.
  *
@@ -159,9 +185,17 @@ SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data,
  *   If a system imposes requirements, SDL will try to munge the string for
  *    it (truncate, etc), but the original string contents will be available
  *    from SDL_GetThreadName().
+ *
+ *   The size (in bytes) of the new stack can be specified. Zero means "use
+ *    the system default" which might be wildly different between platforms
+ *    (x86 Linux generally defaults to eight megabytes, an embedded device
+ *    might be a few kilobytes instead).
+ *
+ *   In SDL 2.1, stacksize will be folded into the original SDL_CreateThread
+ *    function.
  */
 extern DECLSPEC SDL_Thread *SDLCALL
-SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data);
+SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const size_t stacksize, void *data);
 
 #endif
 

+ 13 - 0
sdl.mod/SDL/include/SDL_touch.h

@@ -41,6 +41,14 @@ extern "C" {
 typedef Sint64 SDL_TouchID;
 typedef Sint64 SDL_FingerID;
 
+typedef enum
+{
+    SDL_TOUCH_DEVICE_INVALID = -1,
+    SDL_TOUCH_DEVICE_DIRECT,            /* touch screen with window-relative coordinates */
+    SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, /* trackpad with absolute device coordinates */
+    SDL_TOUCH_DEVICE_INDIRECT_RELATIVE  /* trackpad with screen cursor-relative coordinates */
+} SDL_TouchDeviceType;
+
 typedef struct SDL_Finger
 {
     SDL_FingerID id;
@@ -65,6 +73,11 @@ extern DECLSPEC int SDLCALL SDL_GetNumTouchDevices(void);
  */
 extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index);
 
+/**
+ * \brief Get the type of the given touch device.
+ */
+extern DECLSPEC SDL_TouchDeviceType SDLCALL SDL_GetTouchDeviceType(SDL_TouchID touchID);
+
 /**
  *  \brief Get the number of active fingers for a given touch device.
  */

+ 3 - 0
sdl.mod/SDL/include/close_code.h

@@ -26,6 +26,9 @@
  *  after you finish any function and structure declarations in your headers
  */
 
+#ifndef _begin_code_h
+#error close_code.h included without matching begin_code.h
+#endif
 #undef _begin_code_h
 
 /* Reset structure packing at previous byte alignment */

+ 6 - 0
sdl.mod/SDL/src/SDL.c

@@ -348,6 +348,12 @@ SDL_WasInit(Uint32 flags)
     int num_subsystems = SDL_arraysize(SDL_SubsystemRefCount);
     Uint32 initialized = 0;
 
+    /* Fast path for checking one flag */
+    if (SDL_HasExactlyOneBitSet32(flags)) {
+        int subsystem_index = SDL_MostSignificantBitIndex32(flags);
+        return SDL_SubsystemRefCount[subsystem_index] ? flags : 0;
+    }
+
     if (!flags) {
         flags = SDL_INIT_EVERYTHING;
     }

+ 1 - 0
sdl.mod/SDL/src/SDL_assert.c

@@ -178,6 +178,7 @@ SDL_PromptAssertion(const SDL_assert_data *data, void *userdata)
 
     (void) userdata;  /* unused in default handler. */
 
+    /* !!! FIXME: why is this using SDL_stack_alloc and not just "char message[SDL_MAX_LOG_MESSAGE];" ? */
     message = SDL_stack_alloc(char, SDL_MAX_LOG_MESSAGE);
     if (!message) {
         /* Uh oh, we're in real trouble now... */

+ 5 - 0
sdl.mod/SDL/src/SDL_assert_c.h

@@ -19,6 +19,11 @@
   3. This notice may not be removed or altered from any source distribution.
 */
 
+#ifndef SDL_assert_c_h_
+#define SDL_assert_c_h_
+
 extern void SDL_AssertionsQuit(void);
 
+#endif /* SDL_assert_c_h_ */
+
 /* vi: set ts=4 sw=4 expandtab: */

+ 4 - 0
sdl.mod/SDL/src/SDL_internal.h

@@ -35,6 +35,10 @@
 #define SDL_VARIABLE_LENGTH_ARRAY
 #endif
 
+#define SDL_MAX_SMALL_ALLOC_STACKSIZE 128
+#define SDL_small_alloc(type, count, pisstack) ( (*(pisstack) = ((sizeof(type)*(count)) < SDL_MAX_SMALL_ALLOC_STACKSIZE)), (*(pisstack) ? SDL_stack_alloc(type, count) : (type*)SDL_malloc(sizeof(type)*(count))) )
+#define SDL_small_free(ptr, isstack) if ((isstack)) { SDL_stack_free(ptr); } else { SDL_free(ptr); }
+
 #include "dynapi/SDL_dynapi.h"
 
 #if SDL_DYNAMIC_API

+ 5 - 3
sdl.mod/SDL/src/SDL_log.c

@@ -282,6 +282,7 @@ SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list
         return;
     }
 
+    /* !!! FIXME: why not just "char message[SDL_MAX_LOG_MESSAGE];" ? */
     message = SDL_stack_alloc(char, SDL_MAX_LOG_MESSAGE);
     if (!message) {
         return;
@@ -321,6 +322,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
         char *output;
         size_t length;
         LPTSTR tstr;
+        SDL_bool isstack;
 
 #if !defined(HAVE_STDIO_H) && !defined(__WINRT__)
         BOOL attachResult;
@@ -364,7 +366,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
 #endif /* !defined(HAVE_STDIO_H) && !defined(__WINRT__) */
 
         length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1 + 1 + 1;
-        output = SDL_stack_alloc(char, length);
+        output = SDL_small_alloc(char, length, &isstack);
         SDL_snprintf(output, length, "%s: %s\r\n", SDL_priority_prefixes[priority], message);
         tstr = WIN_UTF8ToString(output);
         
@@ -389,7 +391,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
 #endif /* !defined(HAVE_STDIO_H) && !defined(__WINRT__) */
 
         SDL_free(tstr);
-        SDL_stack_free(output);
+        SDL_small_free(output, isstack);
     }
 #elif defined(__ANDROID__)
     {
@@ -404,7 +406,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
     extern void SDL_NSLog(const char *text);
     {
         char *text;
-
+        /* !!! FIXME: why not just "char text[SDL_MAX_LOG_MESSAGE];" ? */
         text = SDL_stack_alloc(char, SDL_MAX_LOG_MESSAGE);
         if (text) {
             SDL_snprintf(text, SDL_MAX_LOG_MESSAGE, "%s: %s", SDL_priority_prefixes[priority], message);

+ 61 - 18
sdl.mod/SDL/src/audio/SDL_audio.c

@@ -378,21 +378,57 @@ static int
 add_audio_device(const char *name, void *handle, SDL_AudioDeviceItem **devices, int *devCount)
 {
     int retval = -1;
-    const size_t size = sizeof (SDL_AudioDeviceItem) + SDL_strlen(name) + 1;
-    SDL_AudioDeviceItem *item = (SDL_AudioDeviceItem *) SDL_malloc(size);
-    if (item == NULL) {
-        return -1;
-    }
+    SDL_AudioDeviceItem *item;
+    const SDL_AudioDeviceItem *i;
+    int dupenum = 0;
 
     SDL_assert(handle != NULL);  /* we reserve NULL, audio backends can't use it. */
+    SDL_assert(name != NULL);
 
+    item = (SDL_AudioDeviceItem *) SDL_malloc(sizeof (SDL_AudioDeviceItem));
+    if (!item) {
+        return SDL_OutOfMemory();
+    }
+
+    item->original_name = SDL_strdup(name);
+    if (!item->original_name) {
+        SDL_free(item);
+        return SDL_OutOfMemory();
+    }
+
+    item->dupenum = 0;
+    item->name = item->original_name;
     item->handle = handle;
-    SDL_strlcpy(item->name, name, size - sizeof (SDL_AudioDeviceItem));
 
     SDL_LockMutex(current_audio.detectionLock);
+
+    for (i = *devices; i != NULL; i = i->next) {
+        if (SDL_strcmp(name, i->original_name) == 0) {
+            dupenum = i->dupenum + 1;
+            break;  /* stop at the highest-numbered dupe. */
+        }
+    }
+
+    if (dupenum) {
+        const size_t len = SDL_strlen(name) + 16;
+        char *replacement = (char *) SDL_malloc(len);
+        if (!replacement) {
+            SDL_UnlockMutex(current_audio.detectionLock);
+            SDL_free(item->original_name);
+            SDL_free(item);
+            SDL_OutOfMemory();
+            return -1;
+        }
+
+        SDL_snprintf(replacement, len, "%s (%d)", name, dupenum + 1);
+        item->dupenum = dupenum;
+        item->name = replacement;
+    }
+
     item->next = *devices;
     *devices = item;
-    retval = (*devCount)++;
+    retval = (*devCount)++;   /* !!! FIXME: this should be an atomic increment */
+
     SDL_UnlockMutex(current_audio.detectionLock);
 
     return retval;
@@ -420,6 +456,11 @@ free_device_list(SDL_AudioDeviceItem **devices, int *devCount)
         if (item->handle != NULL) {
             current_audio.impl.FreeDeviceHandle(item->handle);
         }
+        /* these two pointers are the same if not a duplicate devname */
+        if (item->name != item->original_name) {
+            SDL_free(item->name);
+        }
+        SDL_free(item->original_name);
         SDL_free(item);
     }
     *devices = NULL;
@@ -977,6 +1018,11 @@ clean_out_device_list(SDL_AudioDeviceItem **devices, int *devCount, SDL_bool *re
             } else {
                 *devices = next;
             }
+            /* these two pointers are the same if not a duplicate devname */
+            if (item->name != item->original_name) {
+                SDL_free(item->name);
+            }
+            SDL_free(item->original_name);
             SDL_free(item);
         }
         item = next;
@@ -1003,7 +1049,6 @@ SDL_GetNumAudioDevices(int iscapture)
 
     if (!iscapture && current_audio.outputDevicesRemoved) {
         clean_out_device_list(&current_audio.outputDevices, &current_audio.outputDeviceCount, &current_audio.outputDevicesRemoved);
-        current_audio.outputDevicesRemoved = SDL_FALSE;
     }
 
     retval = iscapture ? current_audio.inputDeviceCount : current_audio.outputDeviceCount;
@@ -1130,8 +1175,9 @@ prepare_audiospec(const SDL_AudioSpec * orig, SDL_AudioSpec * prepared)
         }
     case 1:                    /* Mono */
     case 2:                    /* Stereo */
-    case 4:                    /* surround */
-    case 6:                    /* surround with center and lfe */
+    case 4:                    /* Quadrophonic */
+    case 6:                    /* 5.1 surround */
+    case 8:                    /* 7.1 surround */
         break;
     default:
         SDL_SetError("Unsupported number of audio channels.");
@@ -1324,15 +1370,12 @@ open_audio_device(const char *devname, int iscapture,
             build_stream = SDL_TRUE;
         }
     }
-
-    /* !!! FIXME in 2.1: add SDL_AUDIO_ALLOW_SAMPLES_CHANGE flag?
-       As of 2.0.6, we will build a stream to buffer the difference between
-       what the app wants to feed and the device wants to eat, so everyone
-       gets their way. In prior releases, SDL would force the callback to
-       feed at the rate the device requested, adjusted for resampling.
-     */
     if (device->spec.samples != obtained->samples) {
-        build_stream = SDL_TRUE;
+        if (allowed_changes & SDL_AUDIO_ALLOW_SAMPLES_CHANGE) {
+            obtained->samples = device->spec.samples;
+        } else {
+            build_stream = SDL_TRUE;
+        }
     }
 
     SDL_CalculateAudioSpec(obtained);  /* recalc after possible changes. */

+ 6 - 0
sdl.mod/SDL/src/audio/SDL_audiodev_c.h

@@ -18,6 +18,10 @@
      misrepresented as being the original software.
   3. This notice may not be removed or altered from any source distribution.
 */
+
+#ifndef SDL_audiodev_c_h_
+#define SDL_audiodev_c_h_
+
 #include "SDL.h"
 #include "../SDL_internal.h"
 #include "SDL_sysaudio.h"
@@ -35,4 +39,6 @@
 
 extern void SDL_EnumUnixAudioDevices(const int classic, int (*test)(int));
 
+#endif /* SDL_audiodev_c_h_ */
+
 /* vi: set ts=4 sw=4 expandtab: */

+ 1 - 1
sdl.mod/SDL/src/audio/SDL_audiotypecvt.c

@@ -26,7 +26,7 @@
 #include "SDL_assert.h"
 
 /* !!! FIXME: disabled until we fix https://bugzilla.libsdl.org/show_bug.cgi?id=4186 */
-#if 0 /*def __ARM_NEON__*/
+#if 0 /*def __ARM_NEON */
 #define HAVE_NEON_INTRINSICS 1
 #endif
 

+ 3 - 1
sdl.mod/SDL/src/audio/SDL_sysaudio.h

@@ -98,8 +98,10 @@ typedef struct SDL_AudioDriverImpl
 typedef struct SDL_AudioDeviceItem
 {
     void *handle;
+    char *name;
+    char *original_name;
+    int dupenum;
     struct SDL_AudioDeviceItem *next;
-    char name[SDL_VARIABLE_LENGTH_ARRAY];
 } SDL_AudioDeviceItem;
 
 

+ 5 - 20
sdl.mod/SDL/src/audio/android/SDL_androidaudio.c

@@ -57,7 +57,9 @@ ANDROIDAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
 
     test_format = SDL_FirstAudioFormat(this->spec.format);
     while (test_format != 0) { /* no "UNKNOWN" constant */
-        if ((test_format == AUDIO_U8) || (test_format == AUDIO_S16LSB)) {
+        if ((test_format == AUDIO_U8) ||
+			(test_format == AUDIO_S16) ||
+			(test_format == AUDIO_F32)) {
             this->spec.format = test_format;
             break;
         }
@@ -69,25 +71,8 @@ ANDROIDAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
         return SDL_SetError("No compatible audio format!");
     }
 
-    if (this->spec.channels > 1) {
-        this->spec.channels = 2;
-    } else {
-        this->spec.channels = 1;
-    }
-
-    if (this->spec.freq < 8000) {
-        this->spec.freq = 8000;
-    }
-    if (this->spec.freq > 48000) {
-        this->spec.freq = 48000;
-    }
-
-    /* TODO: pass in/return a (Java) device ID */
-    this->spec.samples = Android_JNI_OpenAudioDevice(iscapture, this->spec.freq, this->spec.format == AUDIO_U8 ? 0 : 1, this->spec.channels, this->spec.samples);
-
-    if (this->spec.samples == 0) {
-        /* Init failed? */
-        return SDL_SetError("Java-side initialization failed!");
+    if (Android_JNI_OpenAudioDevice(iscapture, &this->spec) < 0) {
+        return -1;
     }
 
     SDL_CalculateAudioSpec(&this->spec);

+ 1 - 0
sdl.mod/SDL/src/audio/emscripten/SDL_emscriptenaudio.c

@@ -246,6 +246,7 @@ EMSCRIPTENAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscaptu
     }
     SDL_zerop(this->hidden);
 #endif
+    this->hidden = (struct SDL_PrivateAudioData *)0x1;
 
     /* limit to native freq */
     this->spec.freq = EM_ASM_INT_V({ return SDL2.audioContext.sampleRate; });

+ 54 - 8
sdl.mod/SDL/src/audio/wasapi/SDL_wasapi_win32.c

@@ -351,10 +351,42 @@ WASAPI_ActivateDevice(_THIS, const SDL_bool isrecovery)
 }
 
 
+typedef struct
+{
+    LPWSTR devid;
+    char *devname;
+} EndpointItem;
+
+static int sort_endpoints(const void *_a, const void *_b)
+{
+    LPWSTR a = ((const EndpointItem *) _a)->devid;
+    LPWSTR b = ((const EndpointItem *) _b)->devid;
+    if (!a && b) {
+        return -1;
+    } else if (a && !b) {
+        return 1;
+    }
+
+    while (SDL_TRUE) {
+        if (*a < *b) {
+            return -1;
+        } else if (*a > *b) {
+            return 1;
+        } else if (*a == 0) {
+            break;
+        }
+        a++;
+        b++;
+    }
+
+    return 0;
+}
+
 static void
 WASAPI_EnumerateEndpointsForFlow(const SDL_bool iscapture)
 {
     IMMDeviceCollection *collection = NULL;
+    EndpointItem *items;
     UINT i, total;
 
     /* Note that WASAPI separates "adapter devices" from "audio endpoint devices"
@@ -369,22 +401,36 @@ WASAPI_EnumerateEndpointsForFlow(const SDL_bool iscapture)
         return;
     }
 
+    items = (EndpointItem *) SDL_calloc(total, sizeof (EndpointItem));
+    if (!items) {
+        return;  /* oh well. */
+    }
+
     for (i = 0; i < total; i++) {
+        EndpointItem *item = items + i;
         IMMDevice *device = NULL;
         if (SUCCEEDED(IMMDeviceCollection_Item(collection, i, &device))) {
-            LPWSTR devid = NULL;
-            if (SUCCEEDED(IMMDevice_GetId(device, &devid))) {
-                char *devname = GetWasapiDeviceName(device);
-                if (devname) {
-                    WASAPI_AddDevice(iscapture, devname, devid);
-                    SDL_free(devname);
-                }
-                CoTaskMemFree(devid);
+            if (SUCCEEDED(IMMDevice_GetId(device, &item->devid))) {
+                item->devname = GetWasapiDeviceName(device);
             }
             IMMDevice_Release(device);
         }
     }
 
+    /* sort the list of devices by their guid so list is consistent between runs */
+    SDL_qsort(items, total, sizeof (*items), sort_endpoints);
+
+    /* Send the sorted list on to the SDL's higher level. */
+    for (i = 0; i < total; i++) {
+        EndpointItem *item = items + i;
+        if ((item->devid) && (item->devname)) {
+            WASAPI_AddDevice(iscapture, item->devname, item->devid);
+        }
+        SDL_free(item->devname);
+        CoTaskMemFree(item->devid);
+    }
+
+    SDL_free(items);
     IMMDeviceCollection_Release(collection);
 }
 

+ 219 - 106
sdl.mod/SDL/src/core/android/SDL_android.c

@@ -61,6 +61,10 @@
 #define SDL_JAVA_CONTROLLER_INTERFACE(function)         CONCAT1(SDL_JAVA_PREFIX, SDLControllerManager, function)
 #define SDL_JAVA_INTERFACE_INPUT_CONNECTION(function)   CONCAT1(SDL_JAVA_PREFIX, SDLInputConnection, function)
 
+/* Audio encoding definitions */
+#define ENCODING_PCM_8BIT   3
+#define ENCODING_PCM_16BIT  2
+#define ENCODING_PCM_FLOAT  4
 
 /* Java class SDLActivity */
 JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(
@@ -248,12 +252,14 @@ static jclass mAudioManagerClass;
 
 /* method signatures */
 static jmethodID midAudioOpen;
-static jmethodID midAudioWriteShortBuffer;
 static jmethodID midAudioWriteByteBuffer;
+static jmethodID midAudioWriteShortBuffer;
+static jmethodID midAudioWriteFloatBuffer;
 static jmethodID midAudioClose;
 static jmethodID midCaptureOpen;
-static jmethodID midCaptureReadShortBuffer;
 static jmethodID midCaptureReadByteBuffer;
+static jmethodID midCaptureReadShortBuffer;
+static jmethodID midCaptureReadFloatBuffer;
 static jmethodID midCaptureClose;
 
 /* controller manager */
@@ -303,11 +309,11 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
 void checkJNIReady()
 {
     if (!mActivityClass || !mAudioManagerClass || !mControllerManagerClass) {
-        // We aren't fully initialized, let's just return.
+        /* We aren't fully initialized, let's just return. */
         return;
     }
 
-    SDL_SetMainReady();    
+    SDL_SetMainReady();
 }
 
 /* Activity initialization -- called before SDL_main() to initialize JNI bindings */
@@ -397,24 +403,28 @@ JNIEXPORT void JNICALL SDL_JAVA_AUDIO_INTERFACE(nativeSetupJNI)(JNIEnv* mEnv, jc
     mAudioManagerClass = (jclass)((*mEnv)->NewGlobalRef(mEnv, cls));
 
     midAudioOpen = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
-                                "audioOpen", "(IZZI)I");
-    midAudioWriteShortBuffer = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
-                                "audioWriteShortBuffer", "([S)V");
+                                "audioOpen", "(IIII)[I");
     midAudioWriteByteBuffer = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
                                 "audioWriteByteBuffer", "([B)V");
+    midAudioWriteShortBuffer = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
+                                "audioWriteShortBuffer", "([S)V");
+    midAudioWriteFloatBuffer = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
+                                "audioWriteFloatBuffer", "([F)V");
     midAudioClose = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
                                 "audioClose", "()V");
     midCaptureOpen = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
-                                "captureOpen", "(IZZI)I");
-    midCaptureReadShortBuffer = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
-                                "captureReadShortBuffer", "([SZ)I");
+                                "captureOpen", "(IIII)[I");
     midCaptureReadByteBuffer = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
                                 "captureReadByteBuffer", "([BZ)I");
+    midCaptureReadShortBuffer = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
+                                "captureReadShortBuffer", "([SZ)I");
+    midCaptureReadFloatBuffer = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
+                                "captureReadFloatBuffer", "([FZ)I");
     midCaptureClose = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
                                 "captureClose", "()V");
 
-    if (!midAudioOpen || !midAudioWriteShortBuffer || !midAudioWriteByteBuffer || !midAudioClose ||
-       !midCaptureOpen || !midCaptureReadShortBuffer || !midCaptureReadByteBuffer || !midCaptureClose) {
+    if (!midAudioOpen || !midAudioWriteByteBuffer || !midAudioWriteShortBuffer || !midAudioWriteFloatBuffer || !midAudioClose ||
+       !midCaptureOpen || !midCaptureReadByteBuffer || !midCaptureReadShortBuffer || !midCaptureReadFloatBuffer || !midCaptureClose) {
         __android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java callbacks, do you have the latest version of SDLAudioManager.java?");
     }
 
@@ -435,7 +445,7 @@ JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI)(JNIEnv* mEn
     midPollHapticDevices = (*mEnv)->GetStaticMethodID(mEnv, mControllerManagerClass,
                                 "pollHapticDevices", "()V");
     midHapticRun = (*mEnv)->GetStaticMethodID(mEnv, mControllerManagerClass,
-                                "hapticRun", "(II)V");
+                                "hapticRun", "(IFI)V");
     midHapticStop = (*mEnv)->GetStaticMethodID(mEnv, mControllerManagerClass,
                                 "hapticStop", "(I)V");
 
@@ -471,10 +481,11 @@ JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(JNIEnv* env, jclass cls,
             int argc;
             int len;
             char **argv;
+            SDL_bool isstack;
 
             /* Prepare the arguments. */
             len = (*env)->GetArrayLength(env, array);
-            argv = SDL_stack_alloc(char*, 1 + len + 1);
+            argv = SDL_small_alloc(char*, 1 + len + 1, &isstack);  /* !!! FIXME: check for NULL */
             argc = 0;
             /* Use the name "app_process" so PHYSFS_platformCalcBaseDir() works.
                https://bitbucket.org/MartinFelis/love-android-sdl2/issue/23/release-build-crash-on-start
@@ -507,7 +518,7 @@ JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(JNIEnv* env, jclass cls,
             for (i = 0; i < argc; ++i) {
                 SDL_free(argv[i]);
             }
-            SDL_stack_free(argv);
+            SDL_small_free(argv, isstack);
 
         } else {
             __android_log_print(ANDROID_LOG_ERROR, "SDL", "nativeRunMain(): Couldn't find function %s in library %s", function_name, library_file);
@@ -794,6 +805,13 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeResume)(
     __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "nativeResume()");
 
     if (Android_Window) {
+
+        /* Make sure SW Keyboard is restored when an app becomes foreground */
+        if (SDL_IsTextInputActive()) {
+            SDL_VideoDevice *_this = SDL_GetVideoDevice();
+            Android_StartTextInput(_this); /* Only showTextInput */
+        }
+
         SDL_SendAppEvent(SDL_APP_WILLENTERFOREGROUND);
         SDL_SendAppEvent(SDL_APP_DIDENTERFOREGROUND);
         SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0);
@@ -824,7 +842,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeGenerateScancod
     SDL_Scancode code = SDL_SCANCODE_UNKNOWN;
     uint16_t mod = 0;
 
-    // We do not care about bigger than 127.
+    /* We do not care about bigger than 127. */
     if (chUnicode < 127) {
         AndroidKeyInfo info = unicharToAndroidKeyInfoTable[chUnicode];
         code = info.code;
@@ -931,20 +949,17 @@ static void LocalReferenceHolder_Cleanup(struct LocalReferenceHolder *refholder)
     }
 }
 
-static SDL_bool LocalReferenceHolder_IsActive(void)
-{
-    return s_active > 0;
-}
-
 ANativeWindow* Android_JNI_GetNativeWindow(void)
 {
-    ANativeWindow* anw;
+    ANativeWindow *anw = NULL;
     jobject s;
     JNIEnv *env = Android_JNI_GetEnv();
 
     s = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetNativeSurface);
-    anw = ANativeWindow_fromSurface(env, s);
-    (*env)->DeleteLocalRef(env, s);
+    if (s) {
+        anw = ANativeWindow_fromSurface(env, s);
+        (*env)->DeleteLocalRef(env, s);
+    }
 
     return anw;
 }
@@ -1043,17 +1058,19 @@ int Android_JNI_SetupThread(void)
 /*
  * Audio support
  */
-static jboolean audioBuffer16Bit = JNI_FALSE;
+static int audioBufferFormat = 0;
 static jobject audioBuffer = NULL;
 static void* audioBufferPinned = NULL;
-static jboolean captureBuffer16Bit = JNI_FALSE;
+static int captureBufferFormat = 0;
 static jobject captureBuffer = NULL;
 
-int Android_JNI_OpenAudioDevice(int iscapture, int sampleRate, int is16Bit, int channelCount, int desiredBufferFrames)
+int Android_JNI_OpenAudioDevice(int iscapture, SDL_AudioSpec *spec)
 {
-    jboolean isStereo;
+    int audioformat;
     int numBufferFrames;
     jobject jbufobj = NULL;
+    jobject result;
+    int *resultElements;
     jboolean isCopy;
 
     JNIEnv *env = Android_JNI_GetEnv();
@@ -1063,78 +1080,123 @@ int Android_JNI_OpenAudioDevice(int iscapture, int sampleRate, int is16Bit, int
     }
     Android_JNI_SetupThread();
 
-    isStereo = channelCount > 1;
+    switch (spec->format) {
+    case AUDIO_U8:
+        audioformat = ENCODING_PCM_8BIT;
+        break;
+    case AUDIO_S16:
+        audioformat = ENCODING_PCM_16BIT;
+        break;
+    case AUDIO_F32:
+        audioformat = ENCODING_PCM_FLOAT;
+        break;
+    default:
+        return SDL_SetError("Unsupported audio format: 0x%x", spec->format);
+    }
 
     if (iscapture) {
         __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDL audio: opening device for capture");
-        captureBuffer16Bit = is16Bit;
-        if ((*env)->CallStaticIntMethod(env, mAudioManagerClass, midCaptureOpen, sampleRate, is16Bit, isStereo, desiredBufferFrames) != 0) {
-            /* Error during audio initialization */
-            __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL audio: error on AudioRecord initialization!");
-            return 0;
-        }
+        result = (*env)->CallStaticObjectMethod(env, mAudioManagerClass, midCaptureOpen, spec->freq, audioformat, spec->channels, spec->samples);
     } else {
         __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDL audio: opening device for output");
-        audioBuffer16Bit = is16Bit;
-        if ((*env)->CallStaticIntMethod(env, mAudioManagerClass, midAudioOpen, sampleRate, is16Bit, isStereo, desiredBufferFrames) != 0) {
-            /* Error during audio initialization */
-            __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL audio: error on AudioTrack initialization!");
-            return 0;
-        }
+        result = (*env)->CallStaticObjectMethod(env, mAudioManagerClass, midAudioOpen, spec->freq, audioformat, spec->channels, spec->samples);
+    }
+    if (result == NULL) {
+        /* Error during audio initialization, error printed from Java */
+        return SDL_SetError("Java-side initialization failed");
     }
 
+    if ((*env)->GetArrayLength(env, (jintArray)result) != 4) {
+        return SDL_SetError("Unexpected results from Java, expected 4, got %d", (*env)->GetArrayLength(env, (jintArray)result));
+    }
+    isCopy = JNI_FALSE;
+    resultElements = (*env)->GetIntArrayElements(env, (jintArray)result, &isCopy);
+    spec->freq = resultElements[0];
+    audioformat = resultElements[1];
+    switch (audioformat) {
+    case ENCODING_PCM_8BIT:
+        spec->format = AUDIO_U8;
+        break;
+    case ENCODING_PCM_16BIT:
+        spec->format = AUDIO_S16;
+        break;
+    case ENCODING_PCM_FLOAT:
+        spec->format = AUDIO_F32;
+        break;
+    default:
+        return SDL_SetError("Unexpected audio format from Java: %d\n", audioformat);
+    }
+    spec->channels = resultElements[2];
+    spec->samples = resultElements[3];
+    (*env)->ReleaseIntArrayElements(env, (jintArray)result, resultElements, JNI_ABORT);
+    (*env)->DeleteLocalRef(env, result);
+
     /* Allocating the audio buffer from the Java side and passing it as the return value for audioInit no longer works on
      * Android >= 4.2 due to a "stale global reference" error. So now we allocate this buffer directly from this side. */
-
-    if (is16Bit) {
-        jshortArray audioBufferLocal = (*env)->NewShortArray(env, desiredBufferFrames * (isStereo ? 2 : 1));
-        if (audioBufferLocal) {
-            jbufobj = (*env)->NewGlobalRef(env, audioBufferLocal);
-            (*env)->DeleteLocalRef(env, audioBufferLocal);
+    switch (audioformat) {
+    case ENCODING_PCM_8BIT:
+        {
+            jbyteArray audioBufferLocal = (*env)->NewByteArray(env, spec->samples * spec->channels);
+            if (audioBufferLocal) {
+                jbufobj = (*env)->NewGlobalRef(env, audioBufferLocal);
+                (*env)->DeleteLocalRef(env, audioBufferLocal);
+            }
         }
-    }
-    else {
-        jbyteArray audioBufferLocal = (*env)->NewByteArray(env, desiredBufferFrames * (isStereo ? 2 : 1));
-        if (audioBufferLocal) {
-            jbufobj = (*env)->NewGlobalRef(env, audioBufferLocal);
-            (*env)->DeleteLocalRef(env, audioBufferLocal);
+        break;
+    case ENCODING_PCM_16BIT:
+        {
+            jshortArray audioBufferLocal = (*env)->NewShortArray(env, spec->samples * spec->channels);
+            if (audioBufferLocal) {
+                jbufobj = (*env)->NewGlobalRef(env, audioBufferLocal);
+                (*env)->DeleteLocalRef(env, audioBufferLocal);
+            }
+        }
+        break;
+    case ENCODING_PCM_FLOAT:
+        {
+            jfloatArray audioBufferLocal = (*env)->NewFloatArray(env, spec->samples * spec->channels);
+            if (audioBufferLocal) {
+                jbufobj = (*env)->NewGlobalRef(env, audioBufferLocal);
+                (*env)->DeleteLocalRef(env, audioBufferLocal);
+            }
         }
+        break;
+    default:
+        return SDL_SetError("Unexpected audio format from Java: %d\n", audioformat);
     }
 
     if (jbufobj == NULL) {
-        __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL audio: could not allocate an audio buffer!");
-        return 0;
+        __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL audio: could not allocate an audio buffer");
+        return SDL_OutOfMemory();
     }
 
     if (iscapture) {
+        captureBufferFormat = audioformat;
         captureBuffer = jbufobj;
     } else {
+        audioBufferFormat = audioformat;
         audioBuffer = jbufobj;
     }
+    numBufferFrames = (*env)->GetArrayLength(env, (jarray)jbufobj);
 
-    isCopy = JNI_FALSE;
+    if (!iscapture) {
+        isCopy = JNI_FALSE;
 
-    if (is16Bit) {
-        if (iscapture) {
-            numBufferFrames = (*env)->GetArrayLength(env, (jshortArray)captureBuffer);
-        } else {
-            audioBufferPinned = (*env)->GetShortArrayElements(env, (jshortArray)audioBuffer, &isCopy);
-            numBufferFrames = (*env)->GetArrayLength(env, (jshortArray)audioBuffer);
-        }
-    } else {
-        if (iscapture) {
-            numBufferFrames = (*env)->GetArrayLength(env, (jbyteArray)captureBuffer);
-        } else {
+        switch (audioformat) {
+        case ENCODING_PCM_8BIT:
             audioBufferPinned = (*env)->GetByteArrayElements(env, (jbyteArray)audioBuffer, &isCopy);
-            numBufferFrames = (*env)->GetArrayLength(env, (jbyteArray)audioBuffer);
+            break;
+        case ENCODING_PCM_16BIT:
+            audioBufferPinned = (*env)->GetShortArrayElements(env, (jshortArray)audioBuffer, &isCopy);
+            break;
+        case ENCODING_PCM_FLOAT:
+            audioBufferPinned = (*env)->GetFloatArrayElements(env, (jfloatArray)audioBuffer, &isCopy);
+            break;
+        default:
+            return SDL_SetError("Unexpected audio format from Java: %d\n", audioformat);
         }
     }
-
-    if (isStereo) {
-        numBufferFrames /= 2;
-    }
-
-    return numBufferFrames;
+    return 0;
 }
 
 int Android_JNI_GetDisplayDPI(float *ddpi, float *xdpi, float *ydpi)
@@ -1178,12 +1240,22 @@ void Android_JNI_WriteAudioBuffer(void)
 {
     JNIEnv *mAudioEnv = Android_JNI_GetEnv();
 
-    if (audioBuffer16Bit) {
-        (*mAudioEnv)->ReleaseShortArrayElements(mAudioEnv, (jshortArray)audioBuffer, (jshort *)audioBufferPinned, JNI_COMMIT);
-        (*mAudioEnv)->CallStaticVoidMethod(mAudioEnv, mAudioManagerClass, midAudioWriteShortBuffer, (jshortArray)audioBuffer);
-    } else {
+    switch (audioBufferFormat) {
+    case ENCODING_PCM_8BIT:
         (*mAudioEnv)->ReleaseByteArrayElements(mAudioEnv, (jbyteArray)audioBuffer, (jbyte *)audioBufferPinned, JNI_COMMIT);
         (*mAudioEnv)->CallStaticVoidMethod(mAudioEnv, mAudioManagerClass, midAudioWriteByteBuffer, (jbyteArray)audioBuffer);
+        break;
+    case ENCODING_PCM_16BIT:
+        (*mAudioEnv)->ReleaseShortArrayElements(mAudioEnv, (jshortArray)audioBuffer, (jshort *)audioBufferPinned, JNI_COMMIT);
+        (*mAudioEnv)->CallStaticVoidMethod(mAudioEnv, mAudioManagerClass, midAudioWriteShortBuffer, (jshortArray)audioBuffer);
+        break;
+    case ENCODING_PCM_FLOAT:
+        (*mAudioEnv)->ReleaseFloatArrayElements(mAudioEnv, (jfloatArray)audioBuffer, (jfloat *)audioBufferPinned, JNI_COMMIT);
+        (*mAudioEnv)->CallStaticVoidMethod(mAudioEnv, mAudioManagerClass, midAudioWriteFloatBuffer, (jfloatArray)audioBuffer);
+        break;
+    default:
+        __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL audio: unhandled audio buffer format");
+        break;
     }
 
     /* JNI_COMMIT means the changes are committed to the VM but the buffer remains pinned */
@@ -1193,46 +1265,86 @@ int Android_JNI_CaptureAudioBuffer(void *buffer, int buflen)
 {
     JNIEnv *env = Android_JNI_GetEnv();
     jboolean isCopy = JNI_FALSE;
-    jint br;
+    jint br = -1;
 
-    if (captureBuffer16Bit) {
-        SDL_assert((*env)->GetArrayLength(env, (jshortArray)captureBuffer) == (buflen / 2));
+    switch (captureBufferFormat) {
+    case ENCODING_PCM_8BIT:
+        SDL_assert((*env)->GetArrayLength(env, (jshortArray)captureBuffer) == buflen);
+        br = (*env)->CallStaticIntMethod(env, mAudioManagerClass, midCaptureReadByteBuffer, (jbyteArray)captureBuffer, JNI_TRUE);
+        if (br > 0) {
+            jbyte *ptr = (*env)->GetByteArrayElements(env, (jbyteArray)captureBuffer, &isCopy);
+            SDL_memcpy(buffer, ptr, br);
+            (*env)->ReleaseByteArrayElements(env, (jbyteArray)captureBuffer, (jbyte *)ptr, JNI_ABORT);
+        }
+        break;
+    case ENCODING_PCM_16BIT:
+        SDL_assert((*env)->GetArrayLength(env, (jshortArray)captureBuffer) == (buflen / sizeof(Sint16)));
         br = (*env)->CallStaticIntMethod(env, mAudioManagerClass, midCaptureReadShortBuffer, (jshortArray)captureBuffer, JNI_TRUE);
         if (br > 0) {
             jshort *ptr = (*env)->GetShortArrayElements(env, (jshortArray)captureBuffer, &isCopy);
-            br *= 2;
+            br *= sizeof(Sint16);
             SDL_memcpy(buffer, ptr, br);
             (*env)->ReleaseShortArrayElements(env, (jshortArray)captureBuffer, (jshort *)ptr, JNI_ABORT);
         }
-    } else {
-        SDL_assert((*env)->GetArrayLength(env, (jshortArray)captureBuffer) == buflen);
-        br = (*env)->CallStaticIntMethod(env, mAudioManagerClass, midCaptureReadByteBuffer, (jbyteArray)captureBuffer, JNI_TRUE);
+        break;
+    case ENCODING_PCM_FLOAT:
+        SDL_assert((*env)->GetArrayLength(env, (jfloatArray)captureBuffer) == (buflen / sizeof(float)));
+        br = (*env)->CallStaticIntMethod(env, mAudioManagerClass, midCaptureReadFloatBuffer, (jfloatArray)captureBuffer, JNI_TRUE);
         if (br > 0) {
-            jbyte *ptr = (*env)->GetByteArrayElements(env, (jbyteArray)captureBuffer, &isCopy);
+            jfloat *ptr = (*env)->GetFloatArrayElements(env, (jfloatArray)captureBuffer, &isCopy);
+            br *= sizeof(float);
             SDL_memcpy(buffer, ptr, br);
-            (*env)->ReleaseByteArrayElements(env, (jbyteArray)captureBuffer, (jbyte *)ptr, JNI_ABORT);
+            (*env)->ReleaseFloatArrayElements(env, (jfloatArray)captureBuffer, (jfloat *)ptr, JNI_ABORT);
         }
+        break;
+    default:
+        __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL audio: unhandled capture buffer format");
+        break;
     }
-
-    return (int) br;
+    return br;
 }
 
 void Android_JNI_FlushCapturedAudio(void)
 {
     JNIEnv *env = Android_JNI_GetEnv();
 #if 0  /* !!! FIXME: this needs API 23, or it'll do blocking reads and never end. */
-    if (captureBuffer16Bit) {
-        const jint len = (*env)->GetArrayLength(env, (jshortArray)captureBuffer);
-        while ((*env)->CallStaticIntMethod(env, mActivityClass, midCaptureReadShortBuffer, (jshortArray)captureBuffer, JNI_FALSE) == len) { /* spin */ }
-    } else {
-        const jint len = (*env)->GetArrayLength(env, (jbyteArray)captureBuffer);
-        while ((*env)->CallStaticIntMethod(env, mActivityClass, midCaptureReadByteBuffer, (jbyteArray)captureBuffer, JNI_FALSE) == len) { /* spin */ }
+    switch (captureBufferFormat) {
+    case ENCODING_PCM_8BIT:
+        {
+            const jint len = (*env)->GetArrayLength(env, (jbyteArray)captureBuffer);
+            while ((*env)->CallStaticIntMethod(env, mActivityClass, midCaptureReadByteBuffer, (jbyteArray)captureBuffer, JNI_FALSE) == len) { /* spin */ }
+        }
+        break;
+    case ENCODING_PCM_16BIT:
+        {
+            const jint len = (*env)->GetArrayLength(env, (jshortArray)captureBuffer);
+            while ((*env)->CallStaticIntMethod(env, mActivityClass, midCaptureReadShortBuffer, (jshortArray)captureBuffer, JNI_FALSE) == len) { /* spin */ }
+        }
+        break;
+    case ENCODING_PCM_FLOAT:
+        {
+            const jint len = (*env)->GetArrayLength(env, (jfloatArray)captureBuffer);
+            while ((*env)->CallStaticIntMethod(env, mActivityClass, midCaptureReadFloatBuffer, (jfloatArray)captureBuffer, JNI_FALSE) == len) { /* spin */ }
+        }
+        break;
+    default:
+        __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL audio: flushing unhandled capture buffer format");
+        break;
     }
 #else
-    if (captureBuffer16Bit) {
-        (*env)->CallStaticIntMethod(env, mAudioManagerClass, midCaptureReadShortBuffer, (jshortArray)captureBuffer, JNI_FALSE);
-    } else {
+    switch (captureBufferFormat) {
+    case ENCODING_PCM_8BIT:
         (*env)->CallStaticIntMethod(env, mAudioManagerClass, midCaptureReadByteBuffer, (jbyteArray)captureBuffer, JNI_FALSE);
+        break;
+    case ENCODING_PCM_16BIT:
+        (*env)->CallStaticIntMethod(env, mAudioManagerClass, midCaptureReadShortBuffer, (jshortArray)captureBuffer, JNI_FALSE);
+        break;
+    case ENCODING_PCM_FLOAT:
+        (*env)->CallStaticIntMethod(env, mAudioManagerClass, midCaptureReadFloatBuffer, (jfloatArray)captureBuffer, JNI_FALSE);
+        break;
+    default:
+        __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL audio: flushing unhandled capture buffer format");
+        break;
     }
 #endif
 }
@@ -1264,7 +1376,8 @@ static SDL_bool Android_JNI_ExceptionOccurred(SDL_bool silent)
     JNIEnv *mEnv = Android_JNI_GetEnv();
     jthrowable exception;
 
-    SDL_assert(LocalReferenceHolder_IsActive());
+    /* Detect mismatch LocalReferenceHolder_Init/Cleanup */
+    SDL_assert((s_active > 0));
 
     exception = (*mEnv)->ExceptionOccurred(mEnv);
     if (exception != NULL) {
@@ -1347,13 +1460,13 @@ static int Internal_Android_JNI_FileOpen(SDL_RWops* ctx)
     }
 
     mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "getStartOffset", "()J");
-    ctx->hidden.androidio.offset = (*mEnv)->CallLongMethod(mEnv, inputStream, mid);
+    ctx->hidden.androidio.offset = (long)(*mEnv)->CallLongMethod(mEnv, inputStream, mid);
     if (Android_JNI_ExceptionOccurred(SDL_TRUE)) {
         goto fallback;
     }
 
     mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "getDeclaredLength", "()J");
-    ctx->hidden.androidio.size = (*mEnv)->CallLongMethod(mEnv, inputStream, mid);
+    ctx->hidden.androidio.size = (long)(*mEnv)->CallLongMethod(mEnv, inputStream, mid);
     if (Android_JNI_ExceptionOccurred(SDL_TRUE)) {
         goto fallback;
     }
@@ -1671,7 +1784,7 @@ Sint64 Android_JNI_FileSeek(SDL_RWops* ctx, Sint64 offset, int whence)
                 if (amount > movement) {
                     amount = movement;
                 }
-                result = Android_JNI_FileRead(ctx, buffer, 1, amount);
+                result = Android_JNI_FileRead(ctx, buffer, 1, (size_t)amount);
                 if (result <= 0) {
                     /* Failed to read/skip the required amount, so fail */
                     return -1;
@@ -1712,7 +1825,7 @@ char* Android_JNI_GetClipboardText(void)
     JNIEnv* env = Android_JNI_GetEnv();
     char* text = NULL;
     jstring string;
-    
+
     string = (*env)->CallStaticObjectMethod(env, mActivityClass, midClipboardGetText);
     if (string) {
         const char* utf = (*env)->GetStringUTFChars(env, string, 0);
@@ -1722,7 +1835,7 @@ char* Android_JNI_GetClipboardText(void)
         }
         (*env)->DeleteLocalRef(env, string);
     }
-    
+
     return (text == NULL) ? SDL_strdup("") : text;
 }
 
@@ -1898,10 +2011,10 @@ void Android_JNI_PollHapticDevices(void)
     (*env)->CallStaticVoidMethod(env, mControllerManagerClass, midPollHapticDevices);
 }
 
-void Android_JNI_HapticRun(int device_id, int length)
+void Android_JNI_HapticRun(int device_id, float intensity, int length)
 {
     JNIEnv *env = Android_JNI_GetEnv();
-    (*env)->CallStaticVoidMethod(env, mControllerManagerClass, midHapticRun, device_id, length);
+    (*env)->CallStaticVoidMethod(env, mControllerManagerClass, midHapticRun, device_id, intensity, length);
 }
 
 void Android_JNI_HapticStop(int device_id)

+ 3 - 2
sdl.mod/SDL/src/core/android/SDL_android.h

@@ -31,6 +31,7 @@ extern "C" {
 #include <EGL/eglplatform.h>
 #include <android/native_window_jni.h>
 
+#include "SDL_audio.h"
 #include "SDL_rect.h"
 
 /* Interface from the SDL library into the Android Java activity */
@@ -47,7 +48,7 @@ extern ANativeWindow* Android_JNI_GetNativeWindow(void);
 extern int Android_JNI_GetDisplayDPI(float *ddpi, float *xdpi, float *ydpi);
 
 /* Audio support */
-extern int Android_JNI_OpenAudioDevice(int iscapture, int sampleRate, int is16Bit, int channelCount, int desiredBufferFrames);
+extern int Android_JNI_OpenAudioDevice(int iscapture, SDL_AudioSpec *spec);
 extern void* Android_JNI_GetAudioBuffer(void);
 extern void Android_JNI_WriteAudioBuffer(void);
 extern int Android_JNI_CaptureAudioBuffer(void *buffer, int buflen);
@@ -83,7 +84,7 @@ void Android_JNI_PollInputDevices(void);
 
 /* Haptic support */
 void Android_JNI_PollHapticDevices(void);
-void Android_JNI_HapticRun(int device_id, int length);
+void Android_JNI_HapticRun(int device_id, float intensity, int length);
 void Android_JNI_HapticStop(int device_id);
 
 /* Video */

+ 1 - 0
sdl.mod/SDL/src/core/linux/SDL_evdev.c

@@ -475,6 +475,7 @@ SDL_EVDEV_init_touchscreen(SDL_evdevlist_item* item)
     }
 
     ret = SDL_AddTouch(item->fd, /* I guess our fd is unique enough */
+        SDL_TOUCH_DEVICE_DIRECT,
         item->touchscreen_data->name);
     if (ret < 0) {
         SDL_free(item->touchscreen_data->slots);

+ 8 - 5
sdl.mod/SDL/src/core/linux/SDL_evdev_kbd.c

@@ -198,7 +198,7 @@ static SDL_EVDEV_keyboard_state * kbd_cleanup_state = NULL;
 static int kbd_cleanup_sigactions_installed = 0;
 static int kbd_cleanup_atexit_installed = 0;
 
-static struct sigaction old_sigaction[NSIG] = { 0 };
+static struct sigaction old_sigaction[NSIG];
 
 static int fatal_signals[] =
 {
@@ -510,17 +510,19 @@ static unsigned int handle_diacr(SDL_EVDEV_keyboard_state *kbd, unsigned int ch)
 
 static int vc_kbd_led(SDL_EVDEV_keyboard_state *kbd, int flag)
 {
-    return ((kbd->ledflagstate >> flag) & 1);
+    return (kbd->ledflagstate & flag) != 0;
 }
 
 static void set_vc_kbd_led(SDL_EVDEV_keyboard_state *kbd, int flag)
 {
-    kbd->ledflagstate |= 1 << flag;
+    kbd->ledflagstate |= flag;
+    ioctl(kbd->console_fd, KDSETLED, (unsigned long)(kbd->ledflagstate));
 }
 
 static void clr_vc_kbd_led(SDL_EVDEV_keyboard_state *kbd, int flag)
 {
-    kbd->ledflagstate &= ~(1 << flag);
+    kbd->ledflagstate &= ~flag;
+    ioctl(kbd->console_fd, KDSETLED, (unsigned long)(kbd->ledflagstate));
 }
 
 static void chg_vc_kbd_lock(SDL_EVDEV_keyboard_state *kbd, int flag)
@@ -535,7 +537,8 @@ static void chg_vc_kbd_slock(SDL_EVDEV_keyboard_state *kbd, int flag)
 
 static void chg_vc_kbd_led(SDL_EVDEV_keyboard_state *kbd, int flag)
 {
-    kbd->ledflagstate ^= 1 << flag;
+    kbd->ledflagstate ^= flag;
+    ioctl(kbd->console_fd, KDSETLED, (unsigned long)(kbd->ledflagstate));
 }
 
 /*

+ 5 - 0
sdl.mod/SDL/src/core/linux/SDL_evdev_kbd.h

@@ -19,6 +19,9 @@
   3. This notice may not be removed or altered from any source distribution.
 */
 
+#ifndef SDL_evdev_kbd_h_
+#define SDL_evdev_kbd_h_
+
 struct SDL_EVDEV_keyboard_state;
 typedef struct SDL_EVDEV_keyboard_state SDL_EVDEV_keyboard_state;
 
@@ -26,4 +29,6 @@ extern SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void);
 extern void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode, int down);
 extern void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state);
 
+#endif /* SDL_evdev_kbd_h_ */
+
 /* vi: set ts=4 sw=4 expandtab: */

+ 111 - 0
sdl.mod/SDL/src/core/linux/SDL_threadprio.c

@@ -0,0 +1,111 @@
+/*
+  Simple DirectMedia Layer
+  Copyright (C) 1997-2018 Sam Lantinga <[email protected]>
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+*/
+#include "../../SDL_internal.h"
+
+#ifdef __LINUX__
+
+#if !SDL_THREADS_DISABLED
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <pthread.h>
+#include "SDL_system.h"
+
+#if SDL_USE_LIBDBUS
+#include "SDL_dbus.h"
+/* d-bus queries to org.freedesktop.RealtimeKit1. */
+#define RTKIT_DBUS_NODE "org.freedesktop.RealtimeKit1"
+#define RTKIT_DBUS_PATH "/org/freedesktop/RealtimeKit1"
+#define RTKIT_DBUS_INTERFACE "org.freedesktop.RealtimeKit1"
+
+static pthread_once_t rtkit_initialize_once = PTHREAD_ONCE_INIT;
+static Sint32 rtkit_min_nice_level = -20;
+
+static void
+rtkit_initialize()
+{
+    SDL_DBusContext *dbus = SDL_DBus_GetContext();
+
+    /* Try getting minimum nice level: this is often greater than PRIO_MIN (-20). */
+    if (!dbus || !SDL_DBus_QueryPropertyOnConnection(dbus->system_conn, RTKIT_DBUS_NODE, RTKIT_DBUS_PATH, RTKIT_DBUS_INTERFACE, "MinNiceLevel",
+                                            DBUS_TYPE_INT32, &rtkit_min_nice_level)) {
+        rtkit_min_nice_level = -20;
+    }
+}
+
+static SDL_bool
+rtkit_setpriority(pid_t thread, int nice_level)
+{
+    Uint64 ui64 = (Uint64)thread;
+    Sint32 si32 = (Sint32)nice_level;
+    SDL_DBusContext *dbus = SDL_DBus_GetContext();
+
+    pthread_once(&rtkit_initialize_once, rtkit_initialize);
+
+    if (si32 < rtkit_min_nice_level)
+        si32 = rtkit_min_nice_level;
+
+    if (!dbus || !SDL_DBus_CallMethodOnConnection(dbus->system_conn,
+            RTKIT_DBUS_NODE, RTKIT_DBUS_PATH, RTKIT_DBUS_INTERFACE, "MakeThreadHighPriority",
+            DBUS_TYPE_UINT64, &ui64, DBUS_TYPE_INT32, &si32, DBUS_TYPE_INVALID,
+            DBUS_TYPE_INVALID)) {
+        return SDL_FALSE;
+    }
+    return SDL_TRUE;
+}
+#endif /* dbus */
+#endif /* threads */
+
+
+/* this is a public symbol, so it has to exist even if threads are disabled. */
+int
+SDL_LinuxSetThreadPriority(Sint64 threadID, int priority)
+{
+#if SDL_THREADS_DISABLED
+    return SDL_Unsupported();
+#else
+    if (setpriority(PRIO_PROCESS, (id_t)threadID, priority) == 0) {
+        return 0;
+    }
+
+#if SDL_USE_LIBDBUS
+    /* Note that this fails if you're trying to set high priority
+       and you don't have root permission. BUT DON'T RUN AS ROOT!
+
+       You can grant the ability to increase thread priority by
+       running the following command on your application binary:
+          sudo setcap 'cap_sys_nice=eip' <application>
+
+       Let's try setting priority with RealtimeKit...
+
+       README and sample code at: http://git.0pointer.net/rtkit.git
+    */
+    if (rtkit_setpriority((pid_t)threadID, priority)) {
+        return 0;
+    }
+#endif
+
+    return SDL_SetError("setpriority() failed");
+#endif
+}
+
+#endif  /* __LINUX__ */
+
+/* vi: set ts=4 sw=4 expandtab: */

+ 33 - 8
sdl.mod/SDL/src/cpuinfo/SDL_cpuinfo.c

@@ -78,6 +78,12 @@
 #endif
 #endif
 
+#if defined(__ANDROID__) && defined(__ARM_ARCH) && !defined(HAVE_GETAUXVAL)
+#if __ARM_ARCH < 8
+#include <cpu-features.h>
+#endif
+#endif
+
 #define CPU_HAS_RDTSC   (1 << 0)
 #define CPU_HAS_ALTIVEC (1 << 1)
 #define CPU_HAS_MMX     (1 << 2)
@@ -320,7 +326,7 @@ CPU_haveAltiVec(void)
     return altivec;
 }
 
-#if (defined(__LINUX__) || defined(__ANDROID__)) && defined(__ARM_ARCH) && !defined(HAVE_GETAUXVAL)
+#if defined(__LINUX__) && defined(__ARM_ARCH) && !defined(HAVE_GETAUXVAL)
 static int
 readProcAuxvForNeon(void)
 {
@@ -346,8 +352,18 @@ CPU_haveNEON(void)
 {
 /* The way you detect NEON is a privileged instruction on ARM, so you have
    query the OS kernel in a platform-specific way. :/ */
-#if defined(SDL_CPUINFO_DISABLED) || !defined(__ARM_ARCH)
-    return 0;  /* disabled or not an ARM CPU at all. */
+#if defined(SDL_CPUINFO_DISABLED)
+   return 0; /* disabled */
+#elif (defined(__WINDOWS__) || defined(__WINRT__)) && (defined(_M_ARM) || defined(_M_ARM64))
+/* Visual Studio, for ARM, doesn't define __ARM_ARCH. Handle this first. */
+/* Seems to have been removed */
+#  if !defined(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE)
+#    define PF_ARM_NEON_INSTRUCTIONS_AVAILABLE 19
+#  endif
+/* All WinRT ARM devices are required to support NEON, but just in case. */
+    return IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) != 0;
+#elif !defined(__ARM_ARCH)
+    return 0;  /* not an ARM CPU at all. */
 #elif __ARM_ARCH >= 8
     return 1;  /* ARMv8 always has non-optional NEON support. */
 #elif defined(__APPLE__) && (__ARM_ARCH >= 7)
@@ -359,11 +375,20 @@ CPU_haveNEON(void)
     return SYSPAGE_ENTRY(cpuinfo)->flags & ARM_CPU_FLAG_NEON;
 #elif (defined(__LINUX__) || defined(__ANDROID__)) && defined(HAVE_GETAUXVAL)
     return ((getauxval(AT_HWCAP) & HWCAP_NEON) == HWCAP_NEON);
-#elif (defined(__LINUX__) || defined(__ANDROID__))
-    return readProcAuxvForNeon();   /* Android offers a static library for this, but it just parses /proc/self/auxv */
-#elif (defined(__WINDOWS__) || defined(__WINRT__)) && defined(_M_ARM)
-    /* All WinRT ARM devices are required to support NEON, but just in case. */
-    return IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) != 0;
+#elif defined(__LINUX__)
+    return readProcAuxvForNeon();
+#elif defined(__ANDROID__)
+    /* Use NDK cpufeatures to read either /proc/self/auxv or /proc/cpuinfo */
+    {
+        AndroidCpuFamily cpu_family = android_getCpuFamily();
+        if (cpu_family == ANDROID_CPU_FAMILY_ARM) {
+            uint64_t cpu_features = android_getCpuFeatures();
+            if ((cpu_features & ANDROID_CPU_ARM_FEATURE_NEON) != 0) {
+                return 1;
+            }
+        }
+        return 0;
+    }
 #else
 #warning SDL_HasNEON is not implemented for this ARM platform. Write me.
     return 0;

+ 1 - 0
sdl.mod/SDL/src/dynapi/SDL_dynapi.c

@@ -27,6 +27,7 @@
 #if defined(__OS2__)
 #define INCL_DOS
 #define INCL_DOSERRORS
+#include <os2.h>
 #include <dos.h>
 #endif
 

+ 16 - 0
sdl.mod/SDL/src/dynapi/SDL_dynapi_overrides.h

@@ -697,3 +697,19 @@
 #define SDL_IsTablet SDL_IsTablet_REAL
 #define SDL_GetDisplayOrientation SDL_GetDisplayOrientation_REAL
 #define SDL_HasColorKey SDL_HasColorKey_REAL
+#define SDL_CreateThreadWithStackSize SDL_CreateThreadWithStackSize_REAL
+#define SDL_JoystickGetDevicePlayerIndex SDL_JoystickGetDevicePlayerIndex_REAL
+#define SDL_JoystickGetPlayerIndex SDL_JoystickGetPlayerIndex_REAL
+#define SDL_GameControllerGetPlayerIndex SDL_GameControllerGetPlayerIndex_REAL
+#define SDL_RenderFlush SDL_RenderFlush_REAL
+#define SDL_RenderDrawPointF SDL_RenderDrawPointF_REAL
+#define SDL_RenderDrawPointsF SDL_RenderDrawPointsF_REAL
+#define SDL_RenderDrawLineF SDL_RenderDrawLineF_REAL
+#define SDL_RenderDrawLinesF SDL_RenderDrawLinesF_REAL
+#define SDL_RenderDrawRectF SDL_RenderDrawRectF_REAL
+#define SDL_RenderDrawRectsF SDL_RenderDrawRectsF_REAL
+#define SDL_RenderFillRectF SDL_RenderFillRectF_REAL
+#define SDL_RenderFillRectsF SDL_RenderFillRectsF_REAL
+#define SDL_RenderCopyF SDL_RenderCopyF_REAL
+#define SDL_RenderCopyExF SDL_RenderCopyExF_REAL
+#define SDL_GetTouchDeviceType SDL_GetTouchDeviceType_REAL

+ 28 - 0
sdl.mod/SDL/src/dynapi/SDL_dynapi_procs.h

@@ -739,3 +739,31 @@ SDL_DYNAPI_PROC(void,SDL_SensorUpdate,(void),(),)
 SDL_DYNAPI_PROC(SDL_bool,SDL_IsTablet,(void),(),return)
 SDL_DYNAPI_PROC(SDL_DisplayOrientation,SDL_GetDisplayOrientation,(int a),(a),return)
 SDL_DYNAPI_PROC(SDL_bool,SDL_HasColorKey,(SDL_Surface *a),(a),return)
+
+#ifdef SDL_CreateThreadWithStackSize
+#undef SDL_CreateThreadWithStackSize
+#endif
+
+#if defined(__WIN32__) && !defined(HAVE_LIBC)
+SDL_DYNAPI_PROC(SDL_Thread*,SDL_CreateThreadWithStackSize,(SDL_ThreadFunction a, const char *b, const size_t c, void *d, pfnSDL_CurrentBeginThread e, pfnSDL_CurrentEndThread f),(a,b,c,d,e,f),return)
+#elif defined(__OS2__)
+SDL_DYNAPI_PROC(SDL_Thread*,SDL_CreateThreadWithStackSize,(SDL_ThreadFunction a, const char *b, const size_t c, void *d, pfnSDL_CurrentBeginThread e, pfnSDL_CurrentEndThread f),(a,b,c,d,e,f),return)
+#else
+SDL_DYNAPI_PROC(SDL_Thread*,SDL_CreateThreadWithStackSize,(SDL_ThreadFunction a, const char *b, const size_t c, void *d),(a,b,c,d),return)
+#endif
+
+SDL_DYNAPI_PROC(int,SDL_JoystickGetDevicePlayerIndex,(int a),(a),return)
+SDL_DYNAPI_PROC(int,SDL_JoystickGetPlayerIndex,(SDL_Joystick *a),(a),return)
+SDL_DYNAPI_PROC(int,SDL_GameControllerGetPlayerIndex,(SDL_GameController *a),(a),return)
+SDL_DYNAPI_PROC(int,SDL_RenderFlush,(SDL_Renderer *a),(a),return)
+SDL_DYNAPI_PROC(int,SDL_RenderDrawPointF,(SDL_Renderer *a, float b, float c),(a,b,c),return)
+SDL_DYNAPI_PROC(int,SDL_RenderDrawPointsF,(SDL_Renderer *a, const SDL_FPoint *b, int c),(a,b,c),return)
+SDL_DYNAPI_PROC(int,SDL_RenderDrawLineF,(SDL_Renderer *a, float b, float c, float d, float e),(a,b,c,d,e),return)
+SDL_DYNAPI_PROC(int,SDL_RenderDrawLinesF,(SDL_Renderer *a, const SDL_FPoint *b, int c),(a,b,c),return)
+SDL_DYNAPI_PROC(int,SDL_RenderDrawRectF,(SDL_Renderer *a, const SDL_FRect *b),(a,b),return)
+SDL_DYNAPI_PROC(int,SDL_RenderDrawRectsF,(SDL_Renderer *a, const SDL_FRect *b, int c),(a,b,c),return)
+SDL_DYNAPI_PROC(int,SDL_RenderFillRectF,(SDL_Renderer *a, const SDL_FRect *b),(a,b),return)
+SDL_DYNAPI_PROC(int,SDL_RenderFillRectsF,(SDL_Renderer *a, const SDL_FRect *b, int c),(a,b,c),return)
+SDL_DYNAPI_PROC(int,SDL_RenderCopyF,(SDL_Renderer *a, SDL_Texture *b, const SDL_Rect *c, const SDL_FRect *d),(a,b,c,d),return)
+SDL_DYNAPI_PROC(int,SDL_RenderCopyExF,(SDL_Renderer *a, SDL_Texture *b, const SDL_Rect *c, const SDL_FRect *d, const double e, const SDL_FPoint *f, const SDL_RendererFlip g),(a,b,c,d,e,f,g),return)
+SDL_DYNAPI_PROC(SDL_TouchDeviceType,SDL_GetTouchDeviceType,(SDL_TouchID a),(a),return)

+ 6 - 0
sdl.mod/SDL/src/events/SDL_events_c.h

@@ -18,6 +18,10 @@
      misrepresented as being the original software.
   3. This notice may not be removed or altered from any source distribution.
 */
+
+#ifndef SDL_events_c_h_
+#define SDL_events_c_h_
+
 #include "../SDL_internal.h"
 
 /* Useful functions and variables from SDL_events.c */
@@ -49,4 +53,6 @@ extern void SDL_QuitQuit(void);
 
 extern void SDL_SendPendingQuit(void);
 
+#endif /* SDL_events_c_h_ */
+
 /* vi: set ts=4 sw=4 expandtab: */

+ 11 - 3
sdl.mod/SDL/src/events/SDL_gesture.c

@@ -279,6 +279,7 @@ int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src)
 }
 
 
+#if defined(ENABLE_DOLLAR)
 static float dollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ,float ang)
 {
     /*  SDL_FloatPoint p[DOLLARNPOINTS]; */
@@ -444,6 +445,7 @@ static float dollarRecognize(const SDL_DollarPath *path,int *bestTempl,SDL_Gestu
     }
     return bestDiff;
 }
+#endif
 
 int SDL_GestureAddTouch(SDL_TouchID touchId)
 {
@@ -509,6 +511,7 @@ static int SDL_SendGestureMulti(SDL_GestureTouch* touch,float dTheta,float dDist
     return SDL_PushEvent(&event) > 0;
 }
 
+#if defined(ENABLE_DOLLAR)
 static int SDL_SendGestureDollar(SDL_GestureTouch* touch,
                           SDL_GestureID gestureId,float error)
 {
@@ -533,14 +536,17 @@ static int SDL_SendDollarRecord(SDL_GestureTouch* touch,SDL_GestureID gestureId)
     event.dgesture.gestureId = gestureId;
     return SDL_PushEvent(&event) > 0;
 }
+#endif
 
 
 void SDL_GestureProcessEvent(SDL_Event* event)
 {
     float x,y;
+#if defined(ENABLE_DOLLAR)
     int index;
     int i;
     float pathDx, pathDy;
+#endif
     SDL_FloatPoint lastP;
     SDL_FloatPoint lastCentroid;
     float lDist;
@@ -561,11 +567,13 @@ void SDL_GestureProcessEvent(SDL_Event* event)
 
         /* Finger Up */
         if (event->type == SDL_FINGERUP) {
+#if defined(ENABLE_DOLLAR)
             SDL_FloatPoint path[DOLLARNPOINTS];
+#endif
 
             inTouch->numDownFingers--;
 
-#ifdef ENABLE_DOLLAR
+#if defined(ENABLE_DOLLAR)
             if (inTouch->recording) {
                 inTouch->recording = SDL_FALSE;
                 dollarNormalize(&inTouch->dollarPath,path);
@@ -610,7 +618,7 @@ void SDL_GestureProcessEvent(SDL_Event* event)
         else if (event->type == SDL_FINGERMOTION) {
             float dx = event->tfinger.dx;
             float dy = event->tfinger.dy;
-#ifdef ENABLE_DOLLAR
+#if defined(ENABLE_DOLLAR)
             SDL_DollarPath* path = &inTouch->dollarPath;
             if (path->numPoints < MAXPATHSIZE) {
                 path->p[path->numPoints].x = inTouch->centroid.x;
@@ -687,7 +695,7 @@ void SDL_GestureProcessEvent(SDL_Event* event)
             /* printf("Finger Down: (%f,%f). Centroid: (%f,%f\n",x,y,
                  inTouch->centroid.x,inTouch->centroid.y); */
 
-#ifdef ENABLE_DOLLAR
+#if defined(ENABLE_DOLLAR)
             inTouch->dollarPath.length = 0;
             inTouch->dollarPath.p[0].x = x;
             inTouch->dollarPath.p[0].y = y;

+ 1 - 1
sdl.mod/SDL/src/events/SDL_mouse.c

@@ -545,7 +545,7 @@ SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, float x, float y, S
         SDL_SetMouseFocus(window);
     }
 
-    if (!x && !y) {
+    if (x == 0.0f && y == 0.0f) {
         return 0;
     }
 

+ 13 - 2
sdl.mod/SDL/src/events/SDL_touch.c

@@ -86,6 +86,16 @@ SDL_GetTouch(SDL_TouchID id)
     return SDL_touchDevices[index];
 }
 
+SDL_TouchDeviceType
+SDL_GetTouchDeviceType(SDL_TouchID id)
+{
+    SDL_Touch *touch = SDL_GetTouch(id);
+    if (touch) {
+        return touch->type;
+    }
+    return SDL_TOUCH_DEVICE_INVALID;
+}
+
 static int
 SDL_GetFingerIndex(const SDL_Touch * touch, SDL_FingerID fingerid)
 {
@@ -133,7 +143,7 @@ SDL_GetTouchFinger(SDL_TouchID touchID, int index)
 }
 
 int
-SDL_AddTouch(SDL_TouchID touchID, const char *name)
+SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name)
 {
     SDL_Touch **touchDevices;
     int index;
@@ -163,6 +173,7 @@ SDL_AddTouch(SDL_TouchID touchID, const char *name)
 
     /* we're setting the touch properties */
     SDL_touchDevices[index]->id = touchID;
+    SDL_touchDevices[index]->type = type;
     SDL_touchDevices[index]->num_fingers = 0;
     SDL_touchDevices[index]->max_fingers = 0;
     SDL_touchDevices[index]->fingers = NULL;
@@ -304,7 +315,7 @@ SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid,
     prel = pressure - finger->pressure;
 
     /* Drop events that don't change state */
-    if (!xrel && !yrel && !prel) {
+    if (xrel == 0.0f && yrel == 0.0f && prel == 0.0f) {
 #if 0
         printf("Touch event didn't change state - dropped!\n");
 #endif

+ 2 - 1
sdl.mod/SDL/src/events/SDL_touch_c.h

@@ -27,6 +27,7 @@
 typedef struct SDL_Touch
 {
     SDL_TouchID id;
+    SDL_TouchDeviceType type;
     int num_fingers;
     int max_fingers;
     SDL_Finger** fingers;
@@ -37,7 +38,7 @@ typedef struct SDL_Touch
 extern int SDL_TouchInit(void);
 
 /* Add a touch, returning the index of the touch, or -1 if there was an error. */
-extern int SDL_AddTouch(SDL_TouchID id, const char *name);
+extern int SDL_AddTouch(SDL_TouchID id, SDL_TouchDeviceType type, const char *name);
 
 /* Get the touch with a given id */
 extern SDL_Touch *SDL_GetTouch(SDL_TouchID id);

+ 4 - 20
sdl.mod/SDL/src/events/SDL_windowevents.c

@@ -28,26 +28,13 @@
 
 
 static int SDLCALL
-RemovePendingResizedEvents(void * userdata, SDL_Event *event)
+RemovePendingSizeChangedAndResizedEvents(void * userdata, SDL_Event *event)
 {
     SDL_Event *new_event = (SDL_Event *)userdata;
 
     if (event->type == SDL_WINDOWEVENT &&
-        event->window.event == SDL_WINDOWEVENT_RESIZED &&
-        event->window.windowID == new_event->window.windowID) {
-        /* We're about to post a new size event, drop the old one */
-        return 0;
-    }
-    return 1;
-}
-
-static int SDLCALL
-RemovePendingSizeChangedEvents(void * userdata, SDL_Event *event)
-{
-    SDL_Event *new_event = (SDL_Event *)userdata;
-
-    if (event->type == SDL_WINDOWEVENT &&
-        event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED &&
+        (event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED ||
+         event->window.event == SDL_WINDOWEVENT_RESIZED) &&
         event->window.windowID == new_event->window.windowID) {
         /* We're about to post a new size event, drop the old one */
         return 0;
@@ -199,11 +186,8 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1,
         event.window.windowID = window->id;
 
         /* Fixes queue overflow with resize events that aren't processed */
-        if (windowevent == SDL_WINDOWEVENT_RESIZED) {
-            SDL_FilterEvents(RemovePendingResizedEvents, &event);
-        }
         if (windowevent == SDL_WINDOWEVENT_SIZE_CHANGED) {
-            SDL_FilterEvents(RemovePendingSizeChangedEvents, &event);
+            SDL_FilterEvents(RemovePendingSizeChangedAndResizedEvents, &event);
         }
         if (windowevent == SDL_WINDOWEVENT_MOVED) {
             SDL_FilterEvents(RemovePendingMoveEvents, &event);

+ 6 - 0
sdl.mod/SDL/src/events/scancodes_xfree86.h

@@ -18,6 +18,10 @@
      misrepresented as being the original software.
   3. This notice may not be removed or altered from any source distribution.
 */
+
+#ifndef scancodes_xfree86_h_
+#define scancodes_xfree86_h_
+
 #include "../../include/SDL_scancode.h"
 
 /* XFree86 key code to SDL scancode mapping table
@@ -503,4 +507,6 @@ static const SDL_Scancode xvnc_scancode_table[] = {
     /*  80 */   SDL_SCANCODE_F12,
 };
 
+#endif /* scancodes_xfree86_h_ */
+
 /* *INDENT-ON* */

+ 1 - 0
sdl.mod/SDL/src/file/SDL_rwops.c

@@ -528,6 +528,7 @@ SDL_RWFromFile(const char *file, const char *mode)
         char *path;
         FILE *fp;
 
+        /* !!! FIXME: why not just "char path[PATH_MAX];" ? */
         path = SDL_stack_alloc(char, PATH_MAX);
         if (path) {
             SDL_snprintf(path, PATH_MAX, "%s/%s",

+ 8 - 2
sdl.mod/SDL/src/haptic/SDL_haptic.c

@@ -26,7 +26,11 @@
 #include "SDL_assert.h"
 
 /* Global for SDL_windowshaptic.c */
+#if (defined(SDL_HAPTIC_DINPUT) && SDL_HAPTIC_DINPUT) || (defined(SDL_HAPTIC_XINPUT) && SDL_HAPTIC_XINPUT)
 SDL_Haptic *SDL_haptics = NULL;
+#else 
+static SDL_Haptic *SDL_haptics = NULL;
+#endif
 
 /*
  * Initializes the Haptic devices.
@@ -389,9 +393,11 @@ SDL_HapticClose(SDL_Haptic * haptic)
 void
 SDL_HapticQuit(void)
 {
+    while (SDL_haptics) {
+        SDL_HapticClose(SDL_haptics);
+    }
+
     SDL_SYS_HapticQuit();
-    SDL_assert(SDL_haptics == NULL);
-    SDL_haptics = NULL;
 }
 
 /*

+ 5 - 0
sdl.mod/SDL/src/haptic/SDL_haptic_c.h

@@ -19,7 +19,12 @@
   3. This notice may not be removed or altered from any source distribution.
 */
 
+#ifndef SDL_haptic_c_h_
+#define SDL_haptic_c_h_
+
 extern int SDL_HapticInit(void);
 extern void SDL_HapticQuit(void);
 
+#endif /* SDL_haptic_c_h_ */
+
 /* vi: set ts=4 sw=4 expandtab: */

+ 11 - 1
sdl.mod/SDL/src/haptic/android/SDL_syshaptic.c

@@ -195,6 +195,10 @@ SDL_SYS_HapticClose(SDL_Haptic * haptic)
 void
 SDL_SYS_HapticQuit(void)
 {
+/* We don't have any way to scan for joysticks (and their vibrators) at init, so don't wipe the list
+ * of joysticks here in case this is a reinit.
+ */
+#if 0
     SDL_hapticlist_item *item = NULL;
     SDL_hapticlist_item *next = NULL;
 
@@ -206,6 +210,7 @@ SDL_SYS_HapticQuit(void)
     SDL_hapticlist = SDL_hapticlist_tail = NULL;
     numhaptics = 0;
     return;
+#endif
 }
 
 
@@ -230,7 +235,12 @@ int
 SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
                         Uint32 iterations)
 {
-    Android_JNI_HapticRun (((SDL_hapticlist_item *)haptic->hwdata)->device_id, effect->effect.leftright.length);
+    float large = effect->effect.leftright.large_magnitude / 32767.0f;
+    float small = effect->effect.leftright.small_magnitude / 32767.0f;
+
+    float total = (large * 0.6f) + (small * 0.4f);
+
+    Android_JNI_HapticRun (((SDL_hapticlist_item *)haptic->hwdata)->device_id, total, effect->effect.leftright.length);
     return 0;
 }
 

+ 3 - 3
sdl.mod/SDL/src/haptic/linux/SDL_syshaptic.c

@@ -908,9 +908,9 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src)
         dest->trigger.button = 0;
         dest->trigger.interval = 0;
 
-        /* Rumble */
-        dest->u.rumble.strong_magnitude = leftright->large_magnitude;
-        dest->u.rumble.weak_magnitude = leftright->small_magnitude;
+        /* Rumble (Linux expects 0-65535, so multiply by 2) */
+        dest->u.rumble.strong_magnitude = CLAMP(leftright->large_magnitude) * 2;
+        dest->u.rumble.weak_magnitude = CLAMP(leftright->small_magnitude) * 2;
 
         break;
 

+ 58 - 8
sdl.mod/SDL/src/hidapi/android/hid.cpp

@@ -14,6 +14,10 @@
 #include <string.h>	// For memcpy()
 
 #define TAG "hidapi"
+
+// Have error log always available
+#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__)
+
 #ifdef DEBUG
 #define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, TAG, __VA_ARGS__)
 #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__)
@@ -398,6 +402,33 @@ public:
 		return m_pDevice;
 	}
 
+	void ExceptionCheck( JNIEnv *env, const char *pszMethodName )
+	{
+		if ( env->ExceptionCheck() )
+		{
+			// Get our exception
+			jthrowable jExcept = env->ExceptionOccurred();
+
+			// Clear the exception so we can call JNI again
+			env->ExceptionClear();
+
+			// Get our exception message
+			jclass jExceptClass = env->GetObjectClass( jExcept );
+			jmethodID jMessageMethod = env->GetMethodID( jExceptClass, "getMessage", "()Ljava/lang/String;" );
+			jstring jMessage = (jstring)( env->CallObjectMethod( jExcept, jMessageMethod ) );
+			const char *pszMessage = env->GetStringUTFChars( jMessage, NULL );
+
+			// ...and log it.
+			LOGE( "CHIDDevice::%s threw an exception: %s", pszMethodName, pszMessage );
+
+			// Cleanup
+			env->ReleaseStringUTFChars( jMessage, pszMessage );
+			env->DeleteLocalRef( jMessage );
+			env->DeleteLocalRef( jExceptClass );
+			env->DeleteLocalRef( jExcept );
+		}
+	}
+
 	bool BOpen()
 	{
 		// Make sure thread is attached to JVM/env
@@ -407,6 +438,7 @@ public:
 
 		m_bIsWaitingForOpen = false;
 		m_bOpenResult = env->CallBooleanMethod( g_HIDDeviceManagerCallbackHandler, g_midHIDDeviceManagerOpen, m_nId );
+		ExceptionCheck( env, "BOpen" );
 
 		if ( m_bIsWaitingForOpen )
 		{
@@ -515,6 +547,8 @@ public:
 
 		jbyteArray pBuf = NewByteArray( env, pData, nDataLen );
 		int nRet = env->CallIntMethod( g_HIDDeviceManagerCallbackHandler, g_midHIDDeviceManagerSendOutputReport, m_nId, pBuf );
+		ExceptionCheck( env, "SendOutputReport" );
+
 		env->DeleteLocalRef( pBuf );
 		return nRet;
 	}
@@ -528,6 +562,7 @@ public:
 
 		jbyteArray pBuf = NewByteArray( env, pData, nDataLen );
 		int nRet = env->CallIntMethod( g_HIDDeviceManagerCallbackHandler, g_midHIDDeviceManagerSendFeatureReport, m_nId, pBuf );
+		ExceptionCheck( env, "SendFeatureReport" );
 		env->DeleteLocalRef( pBuf );
 		return nRet;
 	}
@@ -564,6 +599,7 @@ public:
 
 		jbyteArray pBuf = NewByteArray( env, pData, nDataLen );
 		int nRet = env->CallBooleanMethod( g_HIDDeviceManagerCallbackHandler, g_midHIDDeviceManagerGetFeatureReport, m_nId, pBuf ) ? 0 : -1;
+		ExceptionCheck( env, "GetFeatureReport" );
 		env->DeleteLocalRef( pBuf );
 		if ( nRet < 0 )
 		{
@@ -622,7 +658,8 @@ public:
 		pthread_setspecific( g_ThreadKey, (void*)env );
 
 		env->CallVoidMethod( g_HIDDeviceManagerCallbackHandler, g_midHIDDeviceManagerClose, m_nId );
-
+		ExceptionCheck( env, "Close" );
+	
 		hid_mutex_guard dataLock( &m_dataLock );
 		m_vecData.clear();
 
@@ -696,7 +733,7 @@ static void ThreadDestroyed(void* value)
 
 
 extern "C"
-JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE(HIDDeviceRegisterCallback)(JNIEnv *env, jobject thiz, jobject callbackHandler);
+JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE(HIDDeviceRegisterCallback)(JNIEnv *env, jobject thiz);
 
 extern "C"
 JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE(HIDDeviceReleaseCallback)(JNIEnv *env, jobject thiz);
@@ -721,7 +758,7 @@ JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE(HIDDeviceFeatureReport)
 
 
 extern "C"
-JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE(HIDDeviceRegisterCallback)(JNIEnv *env, jobject thiz, jobject callbackHandler)
+JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE(HIDDeviceRegisterCallback)(JNIEnv *env, jobject thiz )
 {
 	LOGV( "HIDDeviceRegisterCallback()");
 
@@ -735,11 +772,19 @@ JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE(HIDDeviceRegisterCallba
 		__android_log_print(ANDROID_LOG_ERROR, TAG, "Error initializing pthread key");
 	}
 
-	g_HIDDeviceManagerCallbackHandler = env->NewGlobalRef( callbackHandler );
-	jclass objClass = env->GetObjectClass( callbackHandler );
+	if ( g_HIDDeviceManagerCallbackHandler != NULL )
+	{
+		env->DeleteGlobalRef( g_HIDDeviceManagerCallbackClass );
+		g_HIDDeviceManagerCallbackClass = NULL;
+		env->DeleteGlobalRef( g_HIDDeviceManagerCallbackHandler );
+		g_HIDDeviceManagerCallbackHandler = NULL;
+	}
+
+	g_HIDDeviceManagerCallbackHandler = env->NewGlobalRef( thiz );
+	jclass objClass = env->GetObjectClass( thiz );
 	if ( objClass )
 	{
-		g_HIDDeviceManagerCallbackClass = reinterpret_cast< jclass >( env->NewGlobalRef(objClass) );
+		g_HIDDeviceManagerCallbackClass = reinterpret_cast< jclass >( env->NewGlobalRef( objClass ) );
 		g_midHIDDeviceManagerOpen = env->GetMethodID( g_HIDDeviceManagerCallbackClass, "openDevice", "(I)Z" );
 		if ( !g_midHIDDeviceManagerOpen )
 		{
@@ -773,8 +818,13 @@ extern "C"
 JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE(HIDDeviceReleaseCallback)(JNIEnv *env, jobject thiz)
 {
 	LOGV("HIDDeviceReleaseCallback");
-	env->DeleteGlobalRef( g_HIDDeviceManagerCallbackClass );
-	env->DeleteGlobalRef( g_HIDDeviceManagerCallbackHandler );
+	if ( env->IsSameObject( thiz, g_HIDDeviceManagerCallbackHandler ) )
+	{
+		env->DeleteGlobalRef( g_HIDDeviceManagerCallbackClass );
+		g_HIDDeviceManagerCallbackClass = NULL;
+		env->DeleteGlobalRef( g_HIDDeviceManagerCallbackHandler );
+		g_HIDDeviceManagerCallbackHandler = NULL;
+	}
 }
 
 extern "C"

+ 5 - 0
sdl.mod/SDL/src/hidapi/ios/hid.m

@@ -3,6 +3,9 @@
 // Purpose: HID device abstraction temporary stub
 //
 //=============================================================================
+#include "../../SDL_internal.h"
+
+#ifdef SDL_JOYSTICK_HIDAPI
 
 #include <CoreBluetooth/CoreBluetooth.h>
 #include <QuartzCore/QuartzCore.h>
@@ -907,3 +910,5 @@ int HID_API_EXPORT hid_read_timeout(hid_device *dev, unsigned char *data, size_t
 #endif
 	return result;
 }
+
+#endif /* SDL_JOYSTICK_HIDAPI */

+ 5 - 0
sdl.mod/SDL/src/hidapi/libusb/hid.c

@@ -22,6 +22,9 @@
  code repository located at:
         http://github.com/signal11/hidapi .
 ********************************************************/
+#include "../../SDL_internal.h"
+
+#ifdef SDL_JOYSTICK_HIDAPI
 
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE /* needed for wcsdup() before glibc 2.10 */
@@ -1613,3 +1616,5 @@ uint16_t get_usb_code_for_current_locale(void)
 #ifdef NAMESPACE
 }
 #endif
+
+#endif /* SDL_JOYSTICK_HIDAPI */

+ 5 - 0
sdl.mod/SDL/src/hidapi/linux/hid.c

@@ -20,6 +20,9 @@
  code repository located at:
         http://github.com/signal11/hidapi .
 ********************************************************/
+#include "../../SDL_internal.h"
+
+#ifdef SDL_JOYSTICK_HIDAPI
 
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE /* needed for wcsdup() before glibc 2.10 */
@@ -891,3 +894,5 @@ HID_API_EXPORT const wchar_t * HID_API_CALL  hid_error(hid_device *dev)
 #ifdef NAMESPACE
 }
 #endif
+
+#endif /* SDL_JOYSTICK_HIDAPI */

+ 5 - 0
sdl.mod/SDL/src/hidapi/mac/hid.c

@@ -19,6 +19,9 @@
  code repository located at:
  http://github.com/signal11/hidapi .
  ********************************************************/
+#include "../../SDL_internal.h"
+
+#ifdef SDL_JOYSTICK_HIDAPI
 
 /* See Apple Technical Note TN2187 for details on IOHidManager. */
 
@@ -1184,3 +1187,5 @@ int main(void)
 	return 0;
 }
 #endif
+
+#endif /* SDL_JOYSTICK_HIDAPI */

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác