Selaa lähdekoodia

Update to latest SDL source.

woollybah 9 vuotta sitten
vanhempi
commit
aa350f99e9
50 muutettua tiedostoa jossa 1255 lisäystä ja 1213 poistoa
  1. 1 0
      sdl.mod/SDL/include/SDL_config.h.cmake
  2. 4 4
      sdl.mod/SDL/include/SDL_config_iphoneos.h
  3. 3 0
      sdl.mod/SDL/include/SDL_events.h
  4. 29 1
      sdl.mod/SDL/include/SDL_hints.h
  5. 15 0
      sdl.mod/SDL/include/SDL_joystick.h
  6. 15 22
      sdl.mod/SDL/src/core/android/SDL_android.c
  7. 1 4
      sdl.mod/SDL/src/core/android/SDL_android.h
  8. 11 1
      sdl.mod/SDL/src/core/windows/SDL_xinput.c
  9. 38 0
      sdl.mod/SDL/src/core/windows/SDL_xinput.h
  10. 1 0
      sdl.mod/SDL/src/dynapi/SDL_dynapi_overrides.h
  11. 1 0
      sdl.mod/SDL/src/dynapi/SDL_dynapi_procs.h
  12. 6 0
      sdl.mod/SDL/src/events/SDL_events.c
  13. 1 0
      sdl.mod/SDL/src/events/SDL_events_c.h
  14. 6 3
      sdl.mod/SDL/src/haptic/linux/SDL_syshaptic.c
  15. 8 0
      sdl.mod/SDL/src/joystick/SDL_gamecontrollerdb.h
  16. 28 7
      sdl.mod/SDL/src/joystick/SDL_joystick.c
  17. 2 0
      sdl.mod/SDL/src/joystick/SDL_joystick_c.h
  18. 1 0
      sdl.mod/SDL/src/joystick/SDL_sysjoystick.h
  19. 1 0
      sdl.mod/SDL/src/joystick/darwin/SDL_sysjoystick.c
  20. 1 0
      sdl.mod/SDL/src/joystick/darwin/SDL_sysjoystick_c.h
  21. 461 36
      sdl.mod/SDL/src/joystick/iphoneos/SDL_sysjoystick.m
  22. 55 0
      sdl.mod/SDL/src/joystick/iphoneos/SDL_sysjoystick_c.h
  23. 46 4
      sdl.mod/SDL/src/joystick/windows/SDL_xinputjoystick.c
  24. 1 1
      sdl.mod/SDL/src/render/direct3d11/SDL_render_d3d11.c
  25. 32 2
      sdl.mod/SDL/src/video/SDL_video.c
  26. 16 0
      sdl.mod/SDL/src/video/android/SDL_androidkeyboard.c
  27. 6 3
      sdl.mod/SDL/src/video/cocoa/SDL_cocoakeyboard.m
  28. 79 19
      sdl.mod/SDL/src/video/cocoa/SDL_cocoawindow.m
  29. 2 2
      sdl.mod/SDL/src/video/psp/SDL_pspevents.c
  30. 131 33
      sdl.mod/SDL/src/video/uikit/SDL_uikitmessagebox.m
  31. 0 2
      sdl.mod/SDL/src/video/uikit/SDL_uikitopengles.m
  32. 2 6
      sdl.mod/SDL/src/video/uikit/SDL_uikitopenglview.m
  33. 20 3
      sdl.mod/SDL/src/video/uikit/SDL_uikitview.m
  34. 0 2
      sdl.mod/SDL/src/video/uikit/SDL_uikitviewcontroller.h
  35. 0 6
      sdl.mod/SDL/src/video/uikit/SDL_uikitviewcontroller.m
  36. 18 17
      sdl.mod/SDL/src/video/windows/SDL_windowsevents.c
  37. 2 2
      sdl.mod/SDL/src/video/windows/SDL_windowskeyboard.c
  38. 6 3
      sdl.mod/SDL/src/video/windows/SDL_windowsmessagebox.c
  39. 80 80
      sdl.mod/SDL/src/video/windows/SDL_windowsmodes.c
  40. 4 4
      sdl.mod/SDL/src/video/windows/SDL_windowsmodes.h
  41. 25 3
      sdl.mod/SDL/src/video/windows/SDL_windowswindow.c
  42. 2 1
      sdl.mod/SDL/src/video/windows/SDL_windowswindow.h
  43. 2 0
      sdl.mod/SDL/src/video/x11/SDL_x11events.c
  44. 17 5
      sdl.mod/SDL/src/video/x11/SDL_x11window.c
  45. 1 1
      sdl.mod/include/android/SDL_config.h
  46. 24 328
      sdl.mod/include/emscripten/SDL_config.h
  47. 1 1
      sdl.mod/include/ios/SDL_config.h
  48. 24 303
      sdl.mod/include/linuxx64/SDL_config.h
  49. 24 303
      sdl.mod/include/linuxx86/SDL_config.h
  50. 1 1
      sdl.mod/include/macos/SDL_config.h

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

@@ -235,6 +235,7 @@
 #cmakedefine SDL_JOYSTICK_XINPUT @SDL_JOYSTICK_XINPUT@
 #cmakedefine SDL_JOYSTICK_XINPUT @SDL_JOYSTICK_XINPUT@
 #cmakedefine SDL_JOYSTICK_DUMMY @SDL_JOYSTICK_DUMMY@
 #cmakedefine SDL_JOYSTICK_DUMMY @SDL_JOYSTICK_DUMMY@
 #cmakedefine SDL_JOYSTICK_IOKIT @SDL_JOYSTICK_IOKIT@
 #cmakedefine SDL_JOYSTICK_IOKIT @SDL_JOYSTICK_IOKIT@
+#cmakedefine SDL_JOYSTICK_MFI @SDL_JOYSTICK_MFI@
 #cmakedefine SDL_JOYSTICK_LINUX @SDL_JOYSTICK_LINUX@
 #cmakedefine SDL_JOYSTICK_LINUX @SDL_JOYSTICK_LINUX@
 #cmakedefine SDL_JOYSTICK_WINMM @SDL_JOYSTICK_WINMM@
 #cmakedefine SDL_JOYSTICK_WINMM @SDL_JOYSTICK_WINMM@
 #cmakedefine SDL_JOYSTICK_USBHID @SDL_JOYSTICK_USBHID@
 #cmakedefine SDL_JOYSTICK_USBHID @SDL_JOYSTICK_USBHID@

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

@@ -115,8 +115,11 @@
 /* Enable the stub haptic driver (src/haptic/dummy/\*.c) */
 /* Enable the stub haptic driver (src/haptic/dummy/\*.c) */
 #define SDL_HAPTIC_DUMMY 1
 #define SDL_HAPTIC_DUMMY 1
 
 
+/* Enable MFi joystick support */
+#define SDL_JOYSTICK_MFI 1
+
 /* Enable Unix style SO loading */
 /* Enable Unix style SO loading */
-/* Technically this works, but it violates the iPhone developer agreement */
+/* Technically this works, but violates the iOS dev agreement prior to iOS 8 */
 /* #define SDL_LOADSO_DLOPEN 1 */
 /* #define SDL_LOADSO_DLOPEN 1 */
 
 
 /* Enable the stub shared object loader (src/loadso/dummy/\*.c) */
 /* Enable the stub shared object loader (src/loadso/dummy/\*.c) */
@@ -148,9 +151,6 @@
 /* enable iOS extended launch screen */
 /* enable iOS extended launch screen */
 #define SDL_IPHONE_LAUNCHSCREEN 1
 #define SDL_IPHONE_LAUNCHSCREEN 1
 
 
-/* enable joystick subsystem */
-#define SDL_JOYSTICK_DISABLED 0
-
 /* Set max recognized G-force from accelerometer
 /* Set max recognized G-force from accelerometer
    See src/joystick/uikit/SDL_sysjoystick.m for notes on why this is needed
    See src/joystick/uikit/SDL_sysjoystick.m for notes on why this is needed
  */
  */

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

@@ -94,6 +94,9 @@ typedef enum
     SDL_KEYUP,                  /**< Key released */
     SDL_KEYUP,                  /**< Key released */
     SDL_TEXTEDITING,            /**< Keyboard text editing (composition) */
     SDL_TEXTEDITING,            /**< Keyboard text editing (composition) */
     SDL_TEXTINPUT,              /**< Keyboard text input */
     SDL_TEXTINPUT,              /**< Keyboard text input */
+    SDL_KEYMAPCHANGED,          /**< Keymap changed due to a system event such as an
+                                     input language or keyboard layout change.
+                                */
 
 
     /* Mouse events */
     /* Mouse events */
     SDL_MOUSEMOTION    = 0x400, /**< Mouse moved */
     SDL_MOUSEMOTION    = 0x400, /**< Mouse moved */

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

@@ -185,6 +185,20 @@ extern "C" {
  */
  */
 #define SDL_HINT_VIDEO_X11_XRANDR           "SDL_VIDEO_X11_XRANDR"
 #define SDL_HINT_VIDEO_X11_XRANDR           "SDL_VIDEO_X11_XRANDR"
 
 
+/**
+ *  \brief  A variable controlling whether the X11 _NET_WM_PING protocol should be supported.
+ *
+ *  This variable can be set to the following values:
+ *    "0"       - Disable _NET_WM_PING
+ *    "1"       - Enable _NET_WM_PING
+ *
+ *  By default SDL will use _NET_WM_PING, but for applications that know they
+ *  will not always be able to respond to ping requests in a timely manner they can
+ *  turn it off to avoid the window manager thinking the app is hung.
+ *  The hint is checked in CreateWindow.
+ */
+#define SDL_HINT_VIDEO_X11_NET_WM_PING      "SDL_VIDEO_X11_NET_WM_PING"
+
 /**
 /**
  *  \brief  A variable controlling whether the window frame and title bar are interactive when the cursor is hidden 
  *  \brief  A variable controlling whether the window frame and title bar are interactive when the cursor is hidden 
  *
  *
@@ -532,14 +546,28 @@ extern "C" {
 *
 *
 */
 */
 #define SDL_HINT_MAC_BACKGROUND_APP    "SDL_MAC_BACKGROUND_APP"
 #define SDL_HINT_MAC_BACKGROUND_APP    "SDL_MAC_BACKGROUND_APP"
-    
+
 /**
 /**
  * \brief Android APK expansion main file version. Should be a string number like "1", "2" etc.
  * \brief Android APK expansion main file version. Should be a string number like "1", "2" etc.
+ *
+ * Must be set together with SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION.
+ *
+ * If both hints were set then SDL_RWFromFile() will look into expansion files
+ * after a given relative path was not found in the internal storage and assets.
+ *
+ * By default this hint is not set and the APK expansion files are not searched.
  */
  */
 #define SDL_HINT_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION "SDL_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION"
 #define SDL_HINT_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION "SDL_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION"
  
  
 /**
 /**
  * \brief Android APK expansion patch file version. Should be a string number like "1", "2" etc.
  * \brief Android APK expansion patch file version. Should be a string number like "1", "2" etc.
+ *
+ * Must be set together with SDL_HINT_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION.
+ *
+ * If both hints were set then SDL_RWFromFile() will look into expansion files
+ * after a given relative path was not found in the internal storage and assets.
+ *
+ * By default this hint is not set and the APK expansion files are not searched.
  */
  */
 #define SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION "SDL_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION"
 #define SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION "SDL_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION"
 
 

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

@@ -71,6 +71,16 @@ typedef struct {
 
 
 typedef Sint32 SDL_JoystickID;
 typedef Sint32 SDL_JoystickID;
 
 
+typedef enum
+{
+    SDL_JOYSTICK_POWER_UNKNOWN = -1,
+    SDL_JOYSTICK_POWER_EMPTY,
+    SDL_JOYSTICK_POWER_LOW,
+    SDL_JOYSTICK_POWER_MEDIUM,
+    SDL_JOYSTICK_POWER_FULL,
+    SDL_JOYSTICK_POWER_WIRED,
+    SDL_JOYSTICK_POWER_MAX
+} SDL_JoystickPowerLevel;
 
 
 /* Function prototypes */
 /* Function prototypes */
 /**
 /**
@@ -242,6 +252,11 @@ extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick,
  */
  */
 extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick * joystick);
 extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick * joystick);
 
 
+/**
+*  Return the battery level of this joystick
+*/
+extern DECLSPEC SDL_JoystickPowerLevel SDLCALL SDL_JoystickCurrentPowerLevel(SDL_Joystick * joystick);
+
 
 
 /* Ends C function definitions when using C++ */
 /* Ends C function definitions when using C++ */
 #ifdef __cplusplus
 #ifdef __cplusplus

+ 15 - 22
sdl.mod/SDL/src/core/android/SDL_android.c

@@ -71,7 +71,6 @@ static jclass mActivityClass;
 
 
 /* method signatures */
 /* method signatures */
 static jmethodID midGetNativeSurface;
 static jmethodID midGetNativeSurface;
-static jmethodID midFlipBuffers;
 static jmethodID midAudioInit;
 static jmethodID midAudioInit;
 static jmethodID midAudioWriteShortBuffer;
 static jmethodID midAudioWriteShortBuffer;
 static jmethodID midAudioWriteByteBuffer;
 static jmethodID midAudioWriteByteBuffer;
@@ -119,8 +118,6 @@ JNIEXPORT void JNICALL SDL_Android_Init(JNIEnv* mEnv, jclass cls)
 
 
     midGetNativeSurface = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
     midGetNativeSurface = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
                                 "getNativeSurface","()Landroid/view/Surface;");
                                 "getNativeSurface","()Landroid/view/Surface;");
-    midFlipBuffers = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
-                                "flipBuffers","()V");
     midAudioInit = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
     midAudioInit = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
                                 "audioInit", "(IZZI)I");
                                 "audioInit", "(IZZI)I");
     midAudioWriteShortBuffer = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
     midAudioWriteShortBuffer = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
@@ -134,7 +131,7 @@ JNIEXPORT void JNICALL SDL_Android_Init(JNIEnv* mEnv, jclass cls)
 
 
     bHasNewData = SDL_FALSE;
     bHasNewData = SDL_FALSE;
 
 
-    if(!midGetNativeSurface || !midFlipBuffers || !midAudioInit ||
+    if (!midGetNativeSurface || !midAudioInit ||
        !midAudioWriteShortBuffer || !midAudioWriteByteBuffer || !midAudioQuit || !midPollInputDevices) {
        !midAudioWriteShortBuffer || !midAudioWriteByteBuffer || !midAudioQuit || !midPollInputDevices) {
         __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL: Couldn't locate Java callbacks, check that they're named and typed correctly");
         __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL: Couldn't locate Java callbacks, check that they're named and typed correctly");
     }
     }
@@ -160,7 +157,7 @@ JNIEXPORT void JNICALL Java_org_libsdl_app_SDLActivity_onNativeResize(
 }
 }
 
 
 /* Paddown */
 /* Paddown */
-JNIEXPORT int JNICALL Java_org_libsdl_app_SDLActivity_onNativePadDown(
+JNIEXPORT jint JNICALL Java_org_libsdl_app_SDLActivity_onNativePadDown(
                                     JNIEnv* env, jclass jcls,
                                     JNIEnv* env, jclass jcls,
                                     jint device_id, jint keycode)
                                     jint device_id, jint keycode)
 {
 {
@@ -168,7 +165,7 @@ JNIEXPORT int JNICALL Java_org_libsdl_app_SDLActivity_onNativePadDown(
 }
 }
 
 
 /* Padup */
 /* Padup */
-JNIEXPORT int JNICALL Java_org_libsdl_app_SDLActivity_onNativePadUp(
+JNIEXPORT jint JNICALL Java_org_libsdl_app_SDLActivity_onNativePadUp(
                                    JNIEnv* env, jclass jcls,
                                    JNIEnv* env, jclass jcls,
                                    jint device_id, jint keycode)
                                    jint device_id, jint keycode)
 {
 {
@@ -192,7 +189,7 @@ JNIEXPORT void JNICALL Java_org_libsdl_app_SDLActivity_onNativeHat(
 }
 }
 
 
 
 
-JNIEXPORT int JNICALL Java_org_libsdl_app_SDLActivity_nativeAddJoystick(
+JNIEXPORT jint JNICALL Java_org_libsdl_app_SDLActivity_nativeAddJoystick(
     JNIEnv* env, jclass jcls,
     JNIEnv* env, jclass jcls,
     jint device_id, jstring device_name, jint is_accelerometer, 
     jint device_id, jstring device_name, jint is_accelerometer, 
     jint nbuttons, jint naxes, jint nhats, jint nballs)
     jint nbuttons, jint naxes, jint nhats, jint nballs)
@@ -207,7 +204,7 @@ JNIEXPORT int JNICALL Java_org_libsdl_app_SDLActivity_nativeAddJoystick(
     return retval;
     return retval;
 }
 }
 
 
-JNIEXPORT int JNICALL Java_org_libsdl_app_SDLActivity_nativeRemoveJoystick(
+JNIEXPORT jint JNICALL Java_org_libsdl_app_SDLActivity_nativeRemoveJoystick(
     JNIEnv* env, jclass jcls, jint device_id)
     JNIEnv* env, jclass jcls, jint device_id)
 {
 {
     return Android_RemoveJoystick(device_id);
     return Android_RemoveJoystick(device_id);
@@ -267,11 +264,6 @@ JNIEXPORT void JNICALL Java_org_libsdl_app_SDLActivity_onNativeSurfaceDestroyed(
 
 
 }
 }
 
 
-JNIEXPORT void JNICALL Java_org_libsdl_app_SDLActivity_nativeFlipBuffers(JNIEnv* env, jclass jcls)
-{
-    SDL_GL_SwapWindow(Android_Window);
-}
-
 /* Keydown */
 /* Keydown */
 JNIEXPORT void JNICALL Java_org_libsdl_app_SDLActivity_onNativeKeyDown(
 JNIEXPORT void JNICALL Java_org_libsdl_app_SDLActivity_onNativeKeyDown(
                                     JNIEnv* env, jclass jcls, jint keycode)
                                     JNIEnv* env, jclass jcls, jint keycode)
@@ -478,12 +470,6 @@ ANativeWindow* Android_JNI_GetNativeWindow(void)
     return anw;
     return anw;
 }
 }
 
 
-void Android_JNI_SwapWindow(void)
-{
-    JNIEnv *mEnv = Android_JNI_GetEnv();
-    (*mEnv)->CallStaticVoidMethod(mEnv, mActivityClass, midFlipBuffers);
-}
-
 void Android_JNI_SetActivityTitle(const char *title)
 void Android_JNI_SetActivityTitle(const char *title)
 {
 {
     jmethodID mid;
     jmethodID mid;
@@ -785,12 +771,19 @@ fallback:
                 "open", "(Ljava/lang/String;I)Ljava/io/InputStream;");
                 "open", "(Ljava/lang/String;I)Ljava/io/InputStream;");
         inputStream = (*mEnv)->CallObjectMethod(mEnv, assetManager, mid, fileNameJString, 1 /* ACCESS_RANDOM */);
         inputStream = (*mEnv)->CallObjectMethod(mEnv, assetManager, mid, fileNameJString, 1 /* ACCESS_RANDOM */);
         if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
         if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
-            // Try fallback to APK Extension files
+            /* Try fallback to APK expansion files */
             mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, context),
             mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, context),
-                "openAPKExtensionInputStream", "(Ljava/lang/String;)Ljava/io/InputStream;");
+                "openAPKExpansionInputStream", "(Ljava/lang/String;)Ljava/io/InputStream;");
+            if (!mid) {
+                SDL_SetError("No openAPKExpansionInputStream() in Java class");
+                goto failure; /* Java class is missing the required method */
+            }
             inputStream = (*mEnv)->CallObjectMethod(mEnv, context, mid, fileNameJString);
             inputStream = (*mEnv)->CallObjectMethod(mEnv, context, mid, fileNameJString);
 
 
-            if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
+            /* Exception is checked first because it always needs to be cleared.
+             * If no exception occurred then the last SDL error message is kept.
+             */
+            if (Android_JNI_ExceptionOccurred(SDL_FALSE) || !inputStream) {
                 goto failure;
                 goto failure;
             }
             }
         }
         }

+ 1 - 4
sdl.mod/SDL/src/core/android/SDL_android.h

@@ -33,9 +33,6 @@ extern "C" {
 #include "SDL_rect.h"
 #include "SDL_rect.h"
 
 
 /* Interface from the SDL library into the Android Java activity */
 /* Interface from the SDL library into the Android Java activity */
-/* extern SDL_bool Android_JNI_CreateContext(int majorVersion, int minorVersion, int red, int green, int blue, int alpha, int buffer, int depth, int stencil, int buffers, int samples);
-extern SDL_bool Android_JNI_DeleteContext(void); */
-extern void Android_JNI_SwapWindow(void);
 extern void Android_JNI_SetActivityTitle(const char *title);
 extern void Android_JNI_SetActivityTitle(const char *title);
 extern SDL_bool Android_JNI_GetAccelerometerValues(float values[3]);
 extern SDL_bool Android_JNI_GetAccelerometerValues(float values[3]);
 extern void Android_JNI_ShowTextInput(SDL_Rect *inputRect);
 extern void Android_JNI_ShowTextInput(SDL_Rect *inputRect);
@@ -64,7 +61,7 @@ SDL_bool Android_JNI_HasClipboardText(void);
 
 
 /* Power support */
 /* Power support */
 int Android_JNI_GetPowerInfo(int* plugged, int* charged, int* battery, int* seconds, int* percent);
 int Android_JNI_GetPowerInfo(int* plugged, int* charged, int* battery, int* seconds, int* percent);
-    
+
 /* Joystick support */
 /* Joystick support */
 void Android_JNI_PollInputDevices(void);
 void Android_JNI_PollInputDevices(void);
 
 

+ 11 - 1
sdl.mod/SDL/src/core/windows/SDL_xinput.c

@@ -29,6 +29,7 @@
 XInputGetState_t SDL_XInputGetState = NULL;
 XInputGetState_t SDL_XInputGetState = NULL;
 XInputSetState_t SDL_XInputSetState = NULL;
 XInputSetState_t SDL_XInputSetState = NULL;
 XInputGetCapabilities_t SDL_XInputGetCapabilities = NULL;
 XInputGetCapabilities_t SDL_XInputGetCapabilities = NULL;
+XInputGetBatteryInformation_t SDL_XInputGetBatteryInformation = NULL;
 DWORD SDL_XInputVersion = 0;
 DWORD SDL_XInputVersion = 0;
 
 
 static HANDLE s_pXInputDLL = 0;
 static HANDLE s_pXInputDLL = 0;
@@ -55,6 +56,7 @@ WIN_LoadXInputDLL(void)
     SDL_XInputGetState = (XInputGetState_t)XInputGetState;
     SDL_XInputGetState = (XInputGetState_t)XInputGetState;
     SDL_XInputSetState = (XInputSetState_t)XInputSetState;
     SDL_XInputSetState = (XInputSetState_t)XInputSetState;
     SDL_XInputGetCapabilities = (XInputGetCapabilities_t)XInputGetCapabilities;
     SDL_XInputGetCapabilities = (XInputGetCapabilities_t)XInputGetCapabilities;
+    SDL_XInputGetBatteryInformation = (XInputGetBatteryInformation_t)XInputGetBatteryInformation;
 
 
     /* XInput 1.4 ships with Windows 8 and 8.1: */
     /* XInput 1.4 ships with Windows 8 and 8.1: */
     SDL_XInputVersion = (1 << 16) | 4;
     SDL_XInputVersion = (1 << 16) | 4;
@@ -84,11 +86,15 @@ WIN_LoadXInputDLL(void)
     s_pXInputDLL = LoadLibrary(L"XInput1_4.dll");  /* 1.4 Ships with Windows 8. */
     s_pXInputDLL = LoadLibrary(L"XInput1_4.dll");  /* 1.4 Ships with Windows 8. */
     if (!s_pXInputDLL) {
     if (!s_pXInputDLL) {
         version = (1 << 16) | 3;
         version = (1 << 16) | 3;
-        s_pXInputDLL = LoadLibrary(L"XInput1_3.dll");  /* 1.3 Ships with Vista and Win7, can be installed as a redistributable component. */
+        s_pXInputDLL = LoadLibrary(L"XInput1_3.dll");  /* 1.3 can be installed as a redistributable component. */
     }
     }
     if (!s_pXInputDLL) {
     if (!s_pXInputDLL) {
         s_pXInputDLL = LoadLibrary(L"bin\\XInput1_3.dll");
         s_pXInputDLL = LoadLibrary(L"bin\\XInput1_3.dll");
     }
     }
+    if (!s_pXInputDLL) {
+        /* "9.1.0" Ships with Vista and Win7, and is more limited than 1.3+ (e.g. XInputGetStateEx is not available.)  */
+        s_pXInputDLL = LoadLibrary(L"XInput9_1_0.dll");
+    }
     if (!s_pXInputDLL) {
     if (!s_pXInputDLL) {
         return -1;
         return -1;
     }
     }
@@ -99,8 +105,12 @@ WIN_LoadXInputDLL(void)
 
 
     /* 100 is the ordinal for _XInputGetStateEx, which returns the same struct as XinputGetState, but with extra data in wButtons for the guide button, we think... */
     /* 100 is the ordinal for _XInputGetStateEx, which returns the same struct as XinputGetState, but with extra data in wButtons for the guide button, we think... */
     SDL_XInputGetState = (XInputGetState_t)GetProcAddress((HMODULE)s_pXInputDLL, (LPCSTR)100);
     SDL_XInputGetState = (XInputGetState_t)GetProcAddress((HMODULE)s_pXInputDLL, (LPCSTR)100);
+    if (!SDL_XInputGetState) {
+        SDL_XInputGetState = (XInputGetState_t)GetProcAddress((HMODULE)s_pXInputDLL, "XInputGetState");
+    }
     SDL_XInputSetState = (XInputSetState_t)GetProcAddress((HMODULE)s_pXInputDLL, "XInputSetState");
     SDL_XInputSetState = (XInputSetState_t)GetProcAddress((HMODULE)s_pXInputDLL, "XInputSetState");
     SDL_XInputGetCapabilities = (XInputGetCapabilities_t)GetProcAddress((HMODULE)s_pXInputDLL, "XInputGetCapabilities");
     SDL_XInputGetCapabilities = (XInputGetCapabilities_t)GetProcAddress((HMODULE)s_pXInputDLL, "XInputGetCapabilities");
+    SDL_XInputGetBatteryInformation = (XInputGetBatteryInformation_t)GetProcAddress( (HMODULE)s_pXInputDLL, "XInputGetBatteryInformation" );
     if (!SDL_XInputGetState || !SDL_XInputSetState || !SDL_XInputGetCapabilities) {
     if (!SDL_XInputGetState || !SDL_XInputSetState || !SDL_XInputGetCapabilities) {
         WIN_UnloadXInputDLL();
         WIN_UnloadXInputDLL();
         return -1;
         return -1;

+ 38 - 0
sdl.mod/SDL/src/core/windows/SDL_xinput.h

@@ -76,6 +76,29 @@
 #define XINPUT_GAMEPAD_GUIDE 0x0400
 #define XINPUT_GAMEPAD_GUIDE 0x0400
 #endif
 #endif
 
 
+#ifndef BATTERY_DEVTYPE_GAMEPAD
+#define BATTERY_DEVTYPE_GAMEPAD         0x00
+#endif
+#ifndef BATTERY_TYPE_WIRED
+#define BATTERY_TYPE_WIRED              0x01
+#endif
+
+#ifndef BATTERY_TYPE_UNKNOWN
+#define BATTERY_TYPE_UNKNOWN            0xFF
+#endif
+#ifndef BATTERY_LEVEL_EMPTY
+#define BATTERY_LEVEL_EMPTY             0x00
+#endif
+#ifndef BATTERY_LEVEL_LOW
+#define BATTERY_LEVEL_LOW               0x01
+#endif
+#ifndef BATTERY_LEVEL_MEDIUM
+#define BATTERY_LEVEL_MEDIUM            0x02
+#endif
+#ifndef BATTERY_LEVEL_FULL
+#define BATTERY_LEVEL_FULL              0x03
+#endif
+
 /* typedef's for XInput structs we use */
 /* typedef's for XInput structs we use */
 typedef struct
 typedef struct
 {
 {
@@ -95,6 +118,12 @@ typedef struct
     XINPUT_GAMEPAD_EX Gamepad;
     XINPUT_GAMEPAD_EX Gamepad;
 } XINPUT_STATE_EX;
 } XINPUT_STATE_EX;
 
 
+typedef struct _XINPUT_BATTERY_INFORMATION
+{
+    BYTE BatteryType;
+    BYTE BatteryLevel;
+} XINPUT_BATTERY_INFORMATION, *PXINPUT_BATTERY_INFORMATION;
+
 /* Forward decl's for XInput API's we load dynamically and use if available */
 /* Forward decl's for XInput API's we load dynamically and use if available */
 typedef DWORD (WINAPI *XInputGetState_t)
 typedef DWORD (WINAPI *XInputGetState_t)
     (
     (
@@ -115,17 +144,26 @@ typedef DWORD (WINAPI *XInputGetCapabilities_t)
     XINPUT_CAPABILITIES* pCapabilities  /* [out] Receives the capabilities */
     XINPUT_CAPABILITIES* pCapabilities  /* [out] Receives the capabilities */
     );
     );
 
 
+typedef DWORD (WINAPI *XInputGetBatteryInformation_t)
+    (
+    _In_  DWORD                      dwUserIndex,
+    _In_  BYTE                       devType,
+    _Out_ XINPUT_BATTERY_INFORMATION *pBatteryInformation
+    );
+
 extern int WIN_LoadXInputDLL(void);
 extern int WIN_LoadXInputDLL(void);
 extern void WIN_UnloadXInputDLL(void);
 extern void WIN_UnloadXInputDLL(void);
 
 
 extern XInputGetState_t SDL_XInputGetState;
 extern XInputGetState_t SDL_XInputGetState;
 extern XInputSetState_t SDL_XInputSetState;
 extern XInputSetState_t SDL_XInputSetState;
 extern XInputGetCapabilities_t SDL_XInputGetCapabilities;
 extern XInputGetCapabilities_t SDL_XInputGetCapabilities;
+extern XInputGetBatteryInformation_t SDL_XInputGetBatteryInformation;
 extern DWORD SDL_XInputVersion;  /* ((major << 16) & 0xFF00) | (minor & 0xFF) */
 extern DWORD SDL_XInputVersion;  /* ((major << 16) & 0xFF00) | (minor & 0xFF) */
 
 
 #define XINPUTGETSTATE          SDL_XInputGetState
 #define XINPUTGETSTATE          SDL_XInputGetState
 #define XINPUTSETSTATE          SDL_XInputSetState
 #define XINPUTSETSTATE          SDL_XInputSetState
 #define XINPUTGETCAPABILITIES   SDL_XInputGetCapabilities
 #define XINPUTGETCAPABILITIES   SDL_XInputGetCapabilities
+#define XINPUTGETBATTERYINFORMATION   SDL_XInputGetBatteryInformation
 
 
 #endif /* HAVE_XINPUT_H */
 #endif /* HAVE_XINPUT_H */
 
 

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

@@ -594,3 +594,4 @@
 #define SDL_ClearQueuedAudio SDL_ClearQueuedAudio_REAL
 #define SDL_ClearQueuedAudio SDL_ClearQueuedAudio_REAL
 #define SDL_GetGrabbedWindow SDL_GetGrabbedWindow_REAL
 #define SDL_GetGrabbedWindow SDL_GetGrabbedWindow_REAL
 #define SDL_SetWindowsMessageHook SDL_SetWindowsMessageHook_REAL
 #define SDL_SetWindowsMessageHook SDL_SetWindowsMessageHook_REAL
+#define SDL_JoystickCurrentPowerLevel SDL_JoystickCurrentPowerLevel_REAL

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

@@ -628,3 +628,4 @@ SDL_DYNAPI_PROC(SDL_Window*,SDL_GetGrabbedWindow,(void),(),return)
 SDL_DYNAPI_PROC(void,SDL_SetWindowsMessageHook,(SDL_WindowsMessageHook a, void *b),(a,b),)
 SDL_DYNAPI_PROC(void,SDL_SetWindowsMessageHook,(SDL_WindowsMessageHook a, void *b),(a,b),)
 #endif
 #endif
 SDL_DYNAPI_PROC(int,SDL_GetDisplayDPI,(int a, float *b, float *c, float *d),(a,b,c,d),return)
 SDL_DYNAPI_PROC(int,SDL_GetDisplayDPI,(int a, float *b, float *c, float *d),(a,b,c,d),return)
+SDL_DYNAPI_PROC(SDL_JoystickPowerLevel,SDL_JoystickCurrentPowerLevel,(SDL_Joystick *a),(a),return)

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

@@ -649,4 +649,10 @@ SDL_SendSysWMEvent(SDL_SysWMmsg * message)
     return (posted);
     return (posted);
 }
 }
 
 
+int
+SDL_SendKeymapChangedEvent(void)
+{
+    return SDL_SendAppEvent(SDL_KEYMAPCHANGED);
+}
+
 /* vi: set ts=4 sw=4 expandtab: */
 /* vi: set ts=4 sw=4 expandtab: */

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

@@ -38,6 +38,7 @@ extern void SDL_QuitInterrupt(void);
 
 
 extern int SDL_SendAppEvent(SDL_EventType eventType);
 extern int SDL_SendAppEvent(SDL_EventType eventType);
 extern int SDL_SendSysWMEvent(SDL_SysWMmsg * message);
 extern int SDL_SendSysWMEvent(SDL_SysWMmsg * message);
+extern int SDL_SendKeymapChangedEvent(void);
 
 
 extern int SDL_QuitInit(void);
 extern int SDL_QuitInit(void);
 extern int SDL_SendQuit(void);
 extern int SDL_SendQuit(void);

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

@@ -465,7 +465,7 @@ SDL_SYS_HapticOpen(SDL_Haptic * haptic)
     }
     }
 
 
     /* Set the fname. */
     /* Set the fname. */
-    haptic->hwdata->fname = item->fname;
+    haptic->hwdata->fname = SDL_strdup( item->fname );
     return 0;
     return 0;
 }
 }
 
 
@@ -542,11 +542,12 @@ SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
     /* Find the joystick in the haptic list. */
     /* Find the joystick in the haptic list. */
     for (item = SDL_hapticlist; item; item = item->next) {
     for (item = SDL_hapticlist; item; item = item->next) {
         if (SDL_strcmp(item->fname, joystick->hwdata->fname) == 0) {
         if (SDL_strcmp(item->fname, joystick->hwdata->fname) == 0) {
-            haptic->index = device_index;
             break;
             break;
         }
         }
         ++device_index;
         ++device_index;
     }
     }
+    haptic->index = device_index;
+
     if (device_index >= MAX_HAPTICS) {
     if (device_index >= MAX_HAPTICS) {
         return SDL_SetError("Haptic: Joystick doesn't have Haptic capabilities");
         return SDL_SetError("Haptic: Joystick doesn't have Haptic capabilities");
     }
     }
@@ -561,7 +562,8 @@ SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
         return -1;
         return -1;
     }
     }
 
 
-    haptic->hwdata->fname = item->fname;
+    haptic->hwdata->fname = SDL_strdup( joystick->hwdata->fname );
+
     return 0;
     return 0;
 }
 }
 
 
@@ -583,6 +585,7 @@ SDL_SYS_HapticClose(SDL_Haptic * haptic)
         close(haptic->hwdata->fd);
         close(haptic->hwdata->fd);
 
 
         /* Free */
         /* Free */
+        SDL_free(haptic->hwdata->fname);
         SDL_free(haptic->hwdata);
         SDL_free(haptic->hwdata);
         haptic->hwdata = NULL;
         haptic->hwdata = NULL;
     }
     }

+ 8 - 0
sdl.mod/SDL/src/joystick/SDL_gamecontrollerdb.h

@@ -36,6 +36,7 @@ static const char *s_ControllerMappings [] =
 #endif
 #endif
 #if SDL_JOYSTICK_DINPUT
 #if SDL_JOYSTICK_DINPUT
     "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
     "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
+    "e8206058000000000000504944564944,Cideko AK08b,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,",
     "ffff0000000000000000504944564944,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,",
     "ffff0000000000000000504944564944,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,",
     "6d0416c2000000000000504944564944,Generic DirectInput Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
     "6d0416c2000000000000504944564944,Generic DirectInput Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
 	"6d0419c2000000000000504944564944,Logitech F710 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* Guide button doesn't seem to be sent in DInput mode. */
 	"6d0419c2000000000000504944564944,Logitech F710 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* Guide button doesn't seem to be sent in DInput mode. */
@@ -46,6 +47,7 @@ static const char *s_ControllerMappings [] =
     "4c05c405000000000000504944564944,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
     "4c05c405000000000000504944564944,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
 #endif
 #endif
 #if defined(__MACOSX__)
 #if defined(__MACOSX__)
+    "830500000000000031b0000000000000,Cideko AK08b,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
     "0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,",
     "0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,",
     "6d0400000000000016c2000000000000,Logitech F310 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* Guide button doesn't seem to be sent in DInput mode. */
     "6d0400000000000016c2000000000000,Logitech F310 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* Guide button doesn't seem to be sent in DInput mode. */
     "6d0400000000000018c2000000000000,Logitech F510 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
     "6d0400000000000018c2000000000000,Logitech F510 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
@@ -56,6 +58,7 @@ static const char *s_ControllerMappings [] =
     "5e040000000000008e02000000000000,X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,",
     "5e040000000000008e02000000000000,X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,",
 #endif
 #endif
 #if defined(__LINUX__)
 #if defined(__LINUX__)
+    "03000000e82000006058000001010000,Cideko AK08b,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,",
     "0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,",
     "0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,",
     "03000000ba2200002010000001010000,Jess Technology USB Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,",
     "03000000ba2200002010000001010000,Jess Technology USB Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,",
     "030000006d04000019c2000010010000,Logitech Cordless RumblePad 2,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
     "030000006d04000019c2000010010000,Logitech Cordless RumblePad 2,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
@@ -65,6 +68,7 @@ static const char *s_ControllerMappings [] =
     "030000006d0400001fc2000005030000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
     "030000006d0400001fc2000005030000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
     "030000006d04000018c2000010010000,Logitech RumblePad 2,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
     "030000006d04000018c2000010010000,Logitech RumblePad 2,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
     "03000000550900001072000011010000,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,",
     "03000000550900001072000011010000,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,",
+    "050000007e0500003003000001000000,Nintendo Wii Remote Pro Controller,a:b1,b:b0,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,",
     "050000003620000100000002010000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b1,y:b2,",
     "050000003620000100000002010000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b1,y:b2,",
     "030000004c0500006802000011010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,",
     "030000004c0500006802000011010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,",
     "03000000341a00003608000011010000,PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
     "03000000341a00003608000011010000,PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
@@ -82,6 +86,10 @@ static const char *s_ControllerMappings [] =
 #if defined(__ANDROID__)
 #if defined(__ANDROID__)
     "4e564944494120436f72706f72617469,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,",
     "4e564944494120436f72706f72617469,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,",
 #endif
 #endif
+#if defined(SDL_JOYSTICK_MFI)
+    "4d466947616d65706164010000000000,MFi Extended Gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,",
+    "4d466947616d65706164020000000000,MFi Gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,rightshoulder:b5,start:b6,x:b2,y:b3,",
+#endif
 #if defined(SDL_JOYSTICK_EMSCRIPTEN)
 #if defined(SDL_JOYSTICK_EMSCRIPTEN)
     "emscripten,Standard Gamepad,a:b0,b:b1,back:b8,dpdown:b13,dpleft:b14,dpright:b15,dpup:b12,guide:b16,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,",
     "emscripten,Standard Gamepad,a:b0,b:b1,back:b8,dpdown:b13,dpleft:b14,dpright:b15,dpup:b12,guide:b16,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,",
 #endif
 #endif

+ 28 - 7
sdl.mod/SDL/src/joystick/SDL_joystick.c

@@ -178,6 +178,7 @@ SDL_JoystickOpen(int device_index)
     if (joystick->buttons) {
     if (joystick->buttons) {
         SDL_memset(joystick->buttons, 0, joystick->nbuttons * sizeof(Uint8));
         SDL_memset(joystick->buttons, 0, joystick->nbuttons * sizeof(Uint8));
     }
     }
+    joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN;
 
 
     /* Add joystick to list */
     /* Add joystick to list */
     ++joystick->ref_count;
     ++joystick->ref_count;
@@ -619,10 +620,10 @@ SDL_PrivateJoystickButton(SDL_Joystick * joystick, Uint8 button, Uint8 state)
     /* Make sure we're not getting garbage or duplicate events */
     /* Make sure we're not getting garbage or duplicate events */
     if (button >= joystick->nbuttons) {
     if (button >= joystick->nbuttons) {
         return 0;
         return 0;
-	}
-	if (state == joystick->buttons[button]) {
-		return 0;
-	}
+    }
+    if (state == joystick->buttons[button]) {
+        return 0;
+    }
 
 
     /* We ignore events if we don't have keyboard focus, except for button
     /* We ignore events if we don't have keyboard focus, except for button
      * release. */
      * release. */
@@ -669,14 +670,17 @@ SDL_JoystickUpdate(void)
             int i;
             int i;
 
 
             /* Tell the app that everything is centered/unpressed...  */
             /* Tell the app that everything is centered/unpressed...  */
-            for (i = 0; i < joystick->naxes; i++)
+            for (i = 0; i < joystick->naxes; i++) {
                 SDL_PrivateJoystickAxis(joystick, i, 0);
                 SDL_PrivateJoystickAxis(joystick, i, 0);
+            }
 
 
-            for (i = 0; i < joystick->nbuttons; i++)
+            for (i = 0; i < joystick->nbuttons; i++) {
                 SDL_PrivateJoystickButton(joystick, i, 0);
                 SDL_PrivateJoystickButton(joystick, i, 0);
+            }
 
 
-            for (i = 0; i < joystick->nhats; i++)
+            for (i = 0; i < joystick->nhats; i++) {
                 SDL_PrivateJoystickHat(joystick, i, SDL_HAT_CENTERED);
                 SDL_PrivateJoystickHat(joystick, i, SDL_HAT_CENTERED);
+            }
 
 
             joystick->force_recentering = SDL_FALSE;
             joystick->force_recentering = SDL_FALSE;
         }
         }
@@ -822,4 +826,21 @@ SDL_JoystickGUID SDL_JoystickGetGUIDFromString(const char *pchGUID)
 }
 }
 
 
 
 
+/* update the power level for this joystick */
+void SDL_PrivateJoystickBatteryLevel(SDL_Joystick * joystick, SDL_JoystickPowerLevel ePowerLevel)
+{
+    joystick->epowerlevel = ePowerLevel;
+}
+
+
+/* return its power level */
+SDL_JoystickPowerLevel SDL_JoystickCurrentPowerLevel(SDL_Joystick * joystick)
+{
+    if (!SDL_PrivateJoystickValid(joystick)) {
+        return (SDL_JOYSTICK_POWER_UNKNOWN);
+    }
+    return joystick->epowerlevel;
+}
+
+
 /* vi: set ts=4 sw=4 expandtab: */
 /* vi: set ts=4 sw=4 expandtab: */

+ 2 - 0
sdl.mod/SDL/src/joystick/SDL_joystick_c.h

@@ -41,6 +41,8 @@ extern int SDL_PrivateJoystickHat(SDL_Joystick * joystick,
                                   Uint8 hat, Uint8 value);
                                   Uint8 hat, Uint8 value);
 extern int SDL_PrivateJoystickButton(SDL_Joystick * joystick,
 extern int SDL_PrivateJoystickButton(SDL_Joystick * joystick,
                                      Uint8 button, Uint8 state);
                                      Uint8 button, Uint8 state);
+extern void SDL_PrivateJoystickBatteryLevel( SDL_Joystick * joystick,
+    SDL_JoystickPowerLevel ePowerLevel );
 
 
 /* Internal sanity checking functions */
 /* Internal sanity checking functions */
 extern int SDL_PrivateJoystickValid(SDL_Joystick * joystick);
 extern int SDL_PrivateJoystickValid(SDL_Joystick * joystick);

+ 1 - 0
sdl.mod/SDL/src/joystick/SDL_sysjoystick.h

@@ -54,6 +54,7 @@ struct _SDL_Joystick
     int ref_count;              /* Reference count for multiple opens */
     int ref_count;              /* Reference count for multiple opens */
 
 
     SDL_bool force_recentering; /* SDL_TRUE if this device needs to have its state reset to 0 */
     SDL_bool force_recentering; /* SDL_TRUE if this device needs to have its state reset to 0 */
+    SDL_JoystickPowerLevel epowerlevel; /* power level of this joystick, SDL_JOYSTICK_POWER_UNKNOWN if not supported */
     struct _SDL_Joystick *next; /* pointer to next joystick we have allocated */
     struct _SDL_Joystick *next; /* pointer to next joystick we have allocated */
 };
 };
 
 

+ 1 - 0
sdl.mod/SDL/src/joystick/darwin/SDL_sysjoystick.c

@@ -465,6 +465,7 @@ JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender, IOHIDDevic
             curdevice = curdevice->pNext;
             curdevice = curdevice->pNext;
         }
         }
         curdevice->pNext = device;
         curdevice->pNext = device;
+        ++device_index;  /* bump by one since we counted by pNext. */
     }
     }
 
 
 /* !!! FIXME: why isn't there an SDL_PrivateJoyDeviceAdded()? */
 /* !!! FIXME: why isn't there an SDL_PrivateJoyDeviceAdded()? */

+ 1 - 0
sdl.mod/SDL/src/joystick/darwin/SDL_sysjoystick_c.h

@@ -21,6 +21,7 @@
 #include "../../SDL_internal.h"
 #include "../../SDL_internal.h"
 
 
 #ifndef SDL_JOYSTICK_IOKIT_H
 #ifndef SDL_JOYSTICK_IOKIT_H
+#define SDL_JOYSTICK_IOKIT_H
 
 
 #include <IOKit/hid/IOHIDLib.h>
 #include <IOKit/hid/IOHIDLib.h>
 
 

+ 461 - 36
sdl.mod/SDL/src/joystick/iphoneos/SDL_sysjoystick.m

@@ -21,6 +21,10 @@
 #include "../../SDL_internal.h"
 #include "../../SDL_internal.h"
 
 
 /* This is the iOS implementation of the SDL joystick API */
 /* This is the iOS implementation of the SDL joystick API */
+#include "SDL_sysjoystick_c.h"
+
+/* needed for SDL_IPHONE_MAX_GFORCE macro */
+#include "SDL_config_iphoneos.h"
 
 
 #include "SDL_joystick.h"
 #include "SDL_joystick.h"
 #include "SDL_hints.h"
 #include "SDL_hints.h"
@@ -28,15 +32,221 @@
 #include "../SDL_sysjoystick.h"
 #include "../SDL_sysjoystick.h"
 #include "../SDL_joystick_c.h"
 #include "../SDL_joystick_c.h"
 
 
+#if !SDL_EVENTS_DISABLED
+#include "../../events/SDL_events_c.h"
+#endif
+
 #import <CoreMotion/CoreMotion.h>
 #import <CoreMotion/CoreMotion.h>
 
 
-/* needed for SDL_IPHONE_MAX_GFORCE macro */
-#import "SDL_config_iphoneos.h"
+#ifdef SDL_JOYSTICK_MFI
+#import <GameController/GameController.h>
 
 
-const char *accelerometerName = "iOS Accelerometer";
+static id connectObserver = nil;
+static id disconnectObserver = nil;
+#endif /* SDL_JOYSTICK_MFI */
 
 
+static const char *accelerometerName = "iOS Accelerometer";
 static CMMotionManager *motionManager = nil;
 static CMMotionManager *motionManager = nil;
+
+static SDL_JoystickDeviceItem *deviceList = NULL;
+
 static int numjoysticks = 0;
 static int numjoysticks = 0;
+static SDL_JoystickID instancecounter = 0;
+
+static SDL_JoystickDeviceItem *
+GetDeviceForIndex(int device_index)
+{
+    SDL_JoystickDeviceItem *device = deviceList;
+    int i = 0;
+
+    while (i < device_index) {
+        if (device == NULL) {
+            return NULL;
+        }
+        device = device->next;
+        i++;
+    }
+
+    return device;
+}
+
+static void
+SDL_SYS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCController *controller)
+{
+#ifdef SDL_JOYSTICK_MFI
+    const char *name = NULL;
+    /* Explicitly retain the controller because SDL_JoystickDeviceItem is a
+     * struct, and ARC doesn't work with structs. */
+    device->controller = (__bridge GCController *) CFBridgingRetain(controller);
+
+    if (controller.vendorName) {
+        name = controller.vendorName.UTF8String;
+    }
+
+    if (!name) {
+        name = "MFi Gamepad";
+    }
+
+    device->name = SDL_strdup(name);
+
+    device->guid.data[0] = 'M';
+    device->guid.data[1] = 'F';
+    device->guid.data[2] = 'i';
+    device->guid.data[3] = 'G';
+    device->guid.data[4] = 'a';
+    device->guid.data[5] = 'm';
+    device->guid.data[6] = 'e';
+    device->guid.data[7] = 'p';
+    device->guid.data[8] = 'a';
+    device->guid.data[9] = 'd';
+
+    if (controller.extendedGamepad) {
+        device->guid.data[10] = 1;
+    } else if (controller.gamepad) {
+        device->guid.data[10] = 2;
+    }
+
+    if (controller.extendedGamepad) {
+        device->naxes = 6; /* 2 thumbsticks and 2 triggers */
+        device->nhats = 1; /* d-pad */
+        device->nbuttons = 7; /* ABXY, shoulder buttons, pause button */
+    } else if (controller.gamepad) {
+        device->naxes = 0; /* no traditional analog inputs */
+        device->nhats = 1; /* d-pad */
+        device->nbuttons = 7; /* ABXY, shoulder buttons, pause button */
+    }
+    /* TODO: Handle micro profiles on tvOS. */
+#endif
+}
+
+static void
+SDL_SYS_AddJoystickDevice(GCController *controller, SDL_bool accelerometer)
+{
+    SDL_JoystickDeviceItem *device = deviceList;
+#if !SDL_EVENTS_DISABLED
+    SDL_Event event;
+#endif
+
+    while (device != NULL) {
+        if (device->controller == controller) {
+            return;
+        }
+        device = device->next;
+    }
+
+    device = (SDL_JoystickDeviceItem *) SDL_malloc(sizeof(SDL_JoystickDeviceItem));
+    if (device == NULL) {
+        return;
+    }
+
+    SDL_zerop(device);
+
+    device->accelerometer = accelerometer;
+    device->instance_id = instancecounter++;
+
+    if (accelerometer) {
+        device->name = SDL_strdup(accelerometerName);
+        device->naxes = 3; /* Device acceleration in the x, y, and z axes. */
+        device->nhats = 0;
+        device->nbuttons = 0;
+
+        /* Use the accelerometer name as a GUID. */
+        SDL_memcpy(&device->guid.data, device->name, SDL_min(sizeof(SDL_JoystickGUID), SDL_strlen(device->name)));
+    } else if (controller) {
+        SDL_SYS_AddMFIJoystickDevice(device, controller);
+    }
+
+    if (deviceList == NULL) {
+        deviceList = device;
+    } else {
+        SDL_JoystickDeviceItem *lastdevice = deviceList;
+        while (lastdevice->next != NULL) {
+            lastdevice = lastdevice->next;
+        }
+        lastdevice->next = device;
+    }
+
+    ++numjoysticks;
+
+#if !SDL_EVENTS_DISABLED
+    event.type = SDL_JOYDEVICEADDED;
+
+    if (SDL_GetEventState(event.type) == SDL_ENABLE) {
+        event.jdevice.which = numjoysticks - 1;
+        if ((SDL_EventOK == NULL) ||
+            (*SDL_EventOK)(SDL_EventOKParam, &event)) {
+            SDL_PushEvent(&event);
+        }
+    }
+#endif /* !SDL_EVENTS_DISABLED */
+}
+
+static SDL_JoystickDeviceItem *
+SDL_SYS_RemoveJoystickDevice(SDL_JoystickDeviceItem *device)
+{
+    SDL_JoystickDeviceItem *prev = NULL;
+    SDL_JoystickDeviceItem *next = NULL;
+    SDL_JoystickDeviceItem *item = deviceList;
+#if !SDL_EVENTS_DISABLED
+    SDL_Event event;
+#endif
+
+    if (device == NULL) {
+        return NULL;
+    }
+
+    next = device->next;
+
+    while (item != NULL) {
+        if (item == device) {
+            break;
+        }
+        prev = item;
+        item = item->next;
+    }
+
+    /* Unlink the device item from the device list. */
+    if (prev) {
+        prev->next = device->next;
+    } else if (device == deviceList) {
+        deviceList = device->next;
+    }
+
+    if (device->joystick) {
+        device->joystick->hwdata = NULL;
+    }
+
+#ifdef SDL_JOYSTICK_MFI
+    @autoreleasepool {
+        if (device->controller) {
+            /* The controller was explicitly retained in the struct, so it
+             * should be explicitly released before freeing the struct. */
+            GCController *controller = CFBridgingRelease((__bridge CFTypeRef)(device->controller));
+            controller.controllerPausedHandler = nil;
+            device->controller = nil;
+        }
+    }
+#endif /* SDL_JOYSTICK_MFI */
+
+    --numjoysticks;
+
+#if !SDL_EVENTS_DISABLED
+    event.type = SDL_JOYDEVICEREMOVED;
+
+    if (SDL_GetEventState(event.type) == SDL_ENABLE) {
+        event.jdevice.which = device->instance_id;
+        if ((SDL_EventOK == NULL) ||
+            (*SDL_EventOK)(SDL_EventOKParam, &event)) {
+            SDL_PushEvent(&event);
+        }
+    }
+#endif /* !SDL_EVENTS_DISABLED */
+
+    SDL_free(device->name);
+    SDL_free(device);
+
+    return next;
+}
 
 
 /* Function to scan the system for joysticks.
 /* Function to scan the system for joysticks.
  * Joystick 0 should be the system default joystick.
  * Joystick 0 should be the system default joystick.
@@ -45,10 +255,48 @@ static int numjoysticks = 0;
 int
 int
 SDL_SYS_JoystickInit(void)
 SDL_SYS_JoystickInit(void)
 {
 {
-    const char *hint = SDL_GetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK);
-    if (!hint || SDL_atoi(hint)) {
-        /* Default behavior, accelerometer as joystick */
-        numjoysticks = 1;
+    @autoreleasepool {
+        NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
+        const char *hint = SDL_GetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK);
+
+        if (!hint || SDL_atoi(hint)) {
+            /* Default behavior, accelerometer as joystick */
+            SDL_SYS_AddJoystickDevice(nil, SDL_TRUE);
+        }
+
+#ifdef SDL_JOYSTICK_MFI
+        /* GameController.framework was added in iOS 7. */
+        if (![GCController class]) {
+            return numjoysticks;
+        }
+
+        for (GCController *controller in [GCController controllers]) {
+            SDL_SYS_AddJoystickDevice(controller, SDL_FALSE);
+        }
+
+        connectObserver = [center addObserverForName:GCControllerDidConnectNotification
+                                              object:nil
+                                               queue:nil
+                                          usingBlock:^(NSNotification *note) {
+                                              GCController *controller = note.object;
+                                              SDL_SYS_AddJoystickDevice(controller, SDL_FALSE);
+                                          }];
+
+        disconnectObserver = [center addObserverForName:GCControllerDidDisconnectNotification
+                                                 object:nil
+                                                  queue:nil
+                                             usingBlock:^(NSNotification *note) {
+                                                 GCController *controller = note.object;
+                                                 SDL_JoystickDeviceItem *device = deviceList;
+                                                 while (device != NULL) {
+                                                     if (device->controller == controller) {
+                                                         SDL_SYS_RemoveJoystickDevice(device);
+                                                         break;
+                                                     }
+                                                     device = device->next;
+                                                 }
+                                             }];
+#endif /* SDL_JOYSTICK_MFI */
     }
     }
 
 
     return numjoysticks;
     return numjoysticks;
@@ -67,13 +315,15 @@ void SDL_SYS_JoystickDetect()
 const char *
 const char *
 SDL_SYS_JoystickNameForDeviceIndex(int device_index)
 SDL_SYS_JoystickNameForDeviceIndex(int device_index)
 {
 {
-    return accelerometerName;
+    SDL_JoystickDeviceItem *device = GetDeviceForIndex(device_index);
+    return device ? device->name : "Unknown";
 }
 }
 
 
 /* Function to perform the mapping from device index to the instance id for this index */
 /* Function to perform the mapping from device index to the instance id for this index */
 SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
 SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
 {
 {
-    return device_index;
+    SDL_JoystickDeviceItem *device = GetDeviceForIndex(device_index);
+    return device ? device->instance_id : 0;
 }
 }
 
 
 /* Function to open a joystick for use.
 /* Function to open a joystick for use.
@@ -84,38 +334,80 @@ SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
 int
 int
 SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
 SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
 {
 {
-    joystick->naxes = 3;
-    joystick->nhats = 0;
+    SDL_JoystickDeviceItem *device = GetDeviceForIndex(device_index);
+    if (device == NULL) {
+        return SDL_SetError("Could not open Joystick: no hardware device for the specified index");
+    }
+
+    joystick->hwdata = device;
+    joystick->instance_id = device->instance_id;
+
+    joystick->naxes = device->naxes;
+    joystick->nhats = device->nhats;
+    joystick->nbuttons = device->nbuttons;
     joystick->nballs = 0;
     joystick->nballs = 0;
-    joystick->nbuttons = 0;
+
+    device->joystick = joystick;
 
 
     @autoreleasepool {
     @autoreleasepool {
-        if (motionManager == nil) {
-            motionManager = [[CMMotionManager alloc] init];
+        if (device->accelerometer) {
+            if (motionManager == nil) {
+                motionManager = [[CMMotionManager alloc] init];
+            }
+
+            /* Shorter times between updates can significantly increase CPU usage. */
+            motionManager.accelerometerUpdateInterval = 0.1;
+            [motionManager startAccelerometerUpdates];
+        } else {
+#ifdef SDL_JOYSTICK_MFI
+            GCController *controller = device->controller;
+            BOOL usedPlayerIndexSlots[4] = {NO, NO, NO, NO};
+
+            /* Find the player index of all other connected controllers. */
+            for (GCController *c in [GCController controllers]) {
+                if (c != controller && c.playerIndex >= 0) {
+                    usedPlayerIndexSlots[c.playerIndex] = YES;
+                }
+            }
+
+            /* Set this controller's player index to the first unused index.
+             * FIXME: This logic isn't great... but SDL doesn't expose this
+             * concept in its external API, so we don't have much to go on. */
+            for (int i = 0; i < 4; i++) {
+                if (!usedPlayerIndexSlots[i]) {
+                    controller.playerIndex = i;
+                    break;
+                }
+            }
+
+            controller.controllerPausedHandler = ^(GCController *controller) {
+                if (joystick->hwdata) {
+                    ++joystick->hwdata->num_pause_presses;
+                }
+            };
+#endif /* SDL_JOYSTICK_MFI */
         }
         }
-
-        /* Shorter times between updates can significantly increase CPU usage. */
-        motionManager.accelerometerUpdateInterval = 0.1;
-        [motionManager startAccelerometerUpdates];
     }
     }
 
 
     return 0;
     return 0;
 }
 }
 
 
 /* Function to determine if this joystick is attached to the system right now */
 /* Function to determine if this joystick is attached to the system right now */
-SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
+SDL_bool
+SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
 {
 {
-    return SDL_TRUE;
+    return joystick->hwdata != NULL;
 }
 }
 
 
-static void SDL_SYS_AccelerometerUpdate(SDL_Joystick * joystick)
+static void
+SDL_SYS_AccelerometerUpdate(SDL_Joystick * joystick)
 {
 {
     const float maxgforce = SDL_IPHONE_MAX_GFORCE;
     const float maxgforce = SDL_IPHONE_MAX_GFORCE;
     const SInt16 maxsint16 = 0x7FFF;
     const SInt16 maxsint16 = 0x7FFF;
     CMAcceleration accel;
     CMAcceleration accel;
 
 
     @autoreleasepool {
     @autoreleasepool {
-        if (!motionManager.accelerometerActive) {
+        if (!motionManager.isAccelerometerActive) {
             return;
             return;
         }
         }
 
 
@@ -144,9 +436,94 @@ static void SDL_SYS_AccelerometerUpdate(SDL_Joystick * joystick)
     accel.z = SDL_min(SDL_max(accel.z, -maxgforce), maxgforce);
     accel.z = SDL_min(SDL_max(accel.z, -maxgforce), maxgforce);
 
 
     /* pass in data mapped to range of SInt16 */
     /* pass in data mapped to range of SInt16 */
-    SDL_PrivateJoystickAxis(joystick, 0, (accel.x / maxgforce) * maxsint16);
+    SDL_PrivateJoystickAxis(joystick, 0,  (accel.x / maxgforce) * maxsint16);
     SDL_PrivateJoystickAxis(joystick, 1, -(accel.y / maxgforce) * maxsint16);
     SDL_PrivateJoystickAxis(joystick, 1, -(accel.y / maxgforce) * maxsint16);
-    SDL_PrivateJoystickAxis(joystick, 2, (accel.z / maxgforce) * maxsint16);
+    SDL_PrivateJoystickAxis(joystick, 2,  (accel.z / maxgforce) * maxsint16);
+}
+
+#ifdef SDL_JOYSTICK_MFI
+static Uint8
+SDL_SYS_MFIJoystickHatStateForDPad(GCControllerDirectionPad *dpad)
+{
+    Uint8 hat = 0;
+
+    if (dpad.up.isPressed) {
+        hat |= SDL_HAT_UP;
+    } else if (dpad.down.isPressed) {
+        hat |= SDL_HAT_DOWN;
+    }
+
+    if (dpad.left.isPressed) {
+        hat |= SDL_HAT_LEFT;
+    } else if (dpad.right.isPressed) {
+        hat |= SDL_HAT_RIGHT;
+    }
+
+    if (hat == 0) {
+        return SDL_HAT_CENTERED;
+    }
+
+    return hat;
+}
+#endif
+
+static void
+SDL_SYS_MFIJoystickUpdate(SDL_Joystick * joystick)
+{
+#ifdef SDL_JOYSTICK_MFI
+    @autoreleasepool {
+        GCController *controller = joystick->hwdata->controller;
+        Uint8 hatstate = SDL_HAT_CENTERED;
+        int i;
+
+        if (controller.extendedGamepad) {
+            GCExtendedGamepad *gamepad = controller.extendedGamepad;
+
+            /* Axis order matches the XInput Windows mappings. */
+            SDL_PrivateJoystickAxis(joystick, 0, (Sint16) (gamepad.leftThumbstick.xAxis.value * 32767));
+            SDL_PrivateJoystickAxis(joystick, 1, (Sint16) (gamepad.leftThumbstick.yAxis.value * -32767));
+            SDL_PrivateJoystickAxis(joystick, 2, (Sint16) ((gamepad.leftTrigger.value * 65535) - 32768));
+            SDL_PrivateJoystickAxis(joystick, 3, (Sint16) (gamepad.rightThumbstick.xAxis.value * 32767));
+            SDL_PrivateJoystickAxis(joystick, 4, (Sint16) (gamepad.rightThumbstick.yAxis.value * -32767));
+            SDL_PrivateJoystickAxis(joystick, 5, (Sint16) ((gamepad.rightTrigger.value * 65535) - 32768));
+
+            hatstate = SDL_SYS_MFIJoystickHatStateForDPad(gamepad.dpad);
+
+            /* Button order matches the XInput Windows mappings. */
+            SDL_PrivateJoystickButton(joystick, 0, gamepad.buttonA.isPressed);
+            SDL_PrivateJoystickButton(joystick, 1, gamepad.buttonB.isPressed);
+            SDL_PrivateJoystickButton(joystick, 2, gamepad.buttonX.isPressed);
+            SDL_PrivateJoystickButton(joystick, 3, gamepad.buttonY.isPressed);
+            SDL_PrivateJoystickButton(joystick, 4, gamepad.leftShoulder.isPressed);
+            SDL_PrivateJoystickButton(joystick, 5, gamepad.rightShoulder.isPressed);
+        } else if (controller.gamepad) {
+            GCGamepad *gamepad = controller.gamepad;
+
+            hatstate = SDL_SYS_MFIJoystickHatStateForDPad(gamepad.dpad);
+
+            /* Button order matches the XInput Windows mappings. */
+            SDL_PrivateJoystickButton(joystick, 0, gamepad.buttonA.isPressed);
+            SDL_PrivateJoystickButton(joystick, 1, gamepad.buttonB.isPressed);
+            SDL_PrivateJoystickButton(joystick, 2, gamepad.buttonX.isPressed);
+            SDL_PrivateJoystickButton(joystick, 3, gamepad.buttonY.isPressed);
+            SDL_PrivateJoystickButton(joystick, 4, gamepad.leftShoulder.isPressed);
+            SDL_PrivateJoystickButton(joystick, 5, gamepad.rightShoulder.isPressed);
+        }
+        /* TODO: Handle micro profiles on tvOS. */
+
+        SDL_PrivateJoystickHat(joystick, 0, hatstate);
+
+        for (i = 0; i < joystick->hwdata->num_pause_presses; i++) {
+            /* The pause button is always last. */
+            Uint8 pausebutton = joystick->nbuttons - 1;
+
+            SDL_PrivateJoystickButton(joystick, pausebutton, 1);
+            SDL_PrivateJoystickButton(joystick, pausebutton, 0);
+        }
+
+        joystick->hwdata->num_pause_presses = 0;
+    }
+#endif
 }
 }
 
 
 /* Function to update the state of a joystick - called as a device poll.
 /* Function to update the state of a joystick - called as a device poll.
@@ -157,15 +534,40 @@ static void SDL_SYS_AccelerometerUpdate(SDL_Joystick * joystick)
 void
 void
 SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
 SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
 {
 {
-    SDL_SYS_AccelerometerUpdate(joystick);
+    SDL_JoystickDeviceItem *device = joystick->hwdata;
+
+    if (device == NULL) {
+        return;
+    }
+
+    if (device->accelerometer) {
+        SDL_SYS_AccelerometerUpdate(joystick);
+    } else if (device->controller) {
+        SDL_SYS_MFIJoystickUpdate(joystick);
+    }
 }
 }
 
 
 /* Function to close a joystick after use */
 /* Function to close a joystick after use */
 void
 void
 SDL_SYS_JoystickClose(SDL_Joystick * joystick)
 SDL_SYS_JoystickClose(SDL_Joystick * joystick)
 {
 {
+    SDL_JoystickDeviceItem *device = joystick->hwdata;
+
+    if (device == NULL) {
+        return;
+    }
+
+    device->joystick = NULL;
+
     @autoreleasepool {
     @autoreleasepool {
-        [motionManager stopAccelerometerUpdates];
+        if (device->accelerometer) {
+            [motionManager stopAccelerometerUpdates];
+        } else if (device->controller) {
+#ifdef SDL_JOYSTICK_MFI
+            GCController *controller = device->controller;
+            controller.controllerPausedHandler = nil;
+#endif
+        }
     }
     }
 }
 }
 
 
@@ -174,29 +576,52 @@ void
 SDL_SYS_JoystickQuit(void)
 SDL_SYS_JoystickQuit(void)
 {
 {
     @autoreleasepool {
     @autoreleasepool {
+#ifdef SDL_JOYSTICK_MFI
+        NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
+
+        if (connectObserver) {
+            [center removeObserver:connectObserver name:GCControllerDidConnectNotification object:nil];
+            connectObserver = nil;
+        }
+
+        if (disconnectObserver) {
+            [center removeObserver:disconnectObserver name:GCControllerDidDisconnectNotification object:nil];
+            disconnectObserver = nil;
+        }
+#endif /* SDL_JOYSTICK_MFI */
+
+        while (deviceList != NULL) {
+            SDL_SYS_RemoveJoystickDevice(deviceList);
+        }
+
         motionManager = nil;
         motionManager = nil;
     }
     }
 
 
     numjoysticks = 0;
     numjoysticks = 0;
 }
 }
 
 
-SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index )
+SDL_JoystickGUID
+SDL_SYS_JoystickGetDeviceGUID( int device_index )
 {
 {
+    SDL_JoystickDeviceItem *device = GetDeviceForIndex(device_index);
     SDL_JoystickGUID guid;
     SDL_JoystickGUID guid;
-    /* the GUID is just the first 16 chars of the name for now */
-    const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index );
-    SDL_zero( guid );
-    SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
+    if (device) {
+        guid = device->guid;
+    } else {
+        SDL_zero(guid);
+    }
     return guid;
     return guid;
 }
 }
 
 
-SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick)
+SDL_JoystickGUID
+SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick)
 {
 {
     SDL_JoystickGUID guid;
     SDL_JoystickGUID guid;
-    /* the GUID is just the first 16 chars of the name for now */
-    const char *name = joystick->name;
-    SDL_zero( guid );
-    SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
+    if (joystick->hwdata) {
+        guid = joystick->hwdata->guid;
+    } else {
+        SDL_zero(guid);
+    }
     return guid;
     return guid;
 }
 }
 
 

+ 55 - 0
sdl.mod/SDL/src/joystick/iphoneos/SDL_sysjoystick_c.h

@@ -0,0 +1,55 @@
+/*
+  Simple DirectMedia Layer
+  Copyright (C) 1997-2015 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"
+
+#ifndef SDL_JOYSTICK_IOS_H
+#define SDL_JOYSTICK_IOS_H
+
+#include "SDL_stdinc.h"
+#include "../SDL_sysjoystick.h"
+
+@class GCController;
+
+typedef struct joystick_hwdata
+{
+    SDL_bool accelerometer;
+
+    GCController __unsafe_unretained *controller;
+    int num_pause_presses;
+
+    char *name;
+    SDL_Joystick *joystick;
+    SDL_JoystickID instance_id;
+    SDL_JoystickGUID guid;
+
+    int naxes;
+    int nbuttons;
+    int nhats;
+
+    struct joystick_hwdata *next;
+} joystick_hwdata;
+
+typedef joystick_hwdata SDL_JoystickDeviceItem;
+
+#endif /* SDL_JOYSTICK_IOS_H */
+
+
+/* vi: set ts=4 sw=4 expandtab: */

+ 46 - 4
sdl.mod/SDL/src/joystick/windows/SDL_xinputjoystick.c

@@ -221,8 +221,39 @@ SDL_XINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickde
     return 0;
     return 0;
 }
 }
 
 
+static void 
+UpdateXInputJoystickBatteryInformation(SDL_Joystick * joystick, XINPUT_BATTERY_INFORMATION *pBatteryInformation)
+{
+    if ( pBatteryInformation->BatteryType != BATTERY_TYPE_UNKNOWN )
+    {
+        SDL_JoystickPowerLevel ePowerLevel = SDL_JOYSTICK_POWER_UNKNOWN;
+        if (pBatteryInformation->BatteryType == BATTERY_TYPE_WIRED) {
+            ePowerLevel = SDL_JOYSTICK_POWER_WIRED;
+        } else {
+            switch ( pBatteryInformation->BatteryLevel )
+            {
+            case BATTERY_LEVEL_EMPTY:
+                ePowerLevel = SDL_JOYSTICK_POWER_EMPTY;
+                break;
+            case BATTERY_LEVEL_LOW:
+                ePowerLevel = SDL_JOYSTICK_POWER_LOW;
+                break;
+            case BATTERY_LEVEL_MEDIUM:
+                ePowerLevel = SDL_JOYSTICK_POWER_MEDIUM;
+                break;
+            default:
+            case BATTERY_LEVEL_FULL:
+                ePowerLevel = SDL_JOYSTICK_POWER_FULL;
+                break;
+            }
+        }
+
+        SDL_PrivateJoystickBatteryLevel( joystick, ePowerLevel );
+    }
+}
+
 static void
 static void
-UpdateXInputJoystickState_OLD(SDL_Joystick * joystick, XINPUT_STATE_EX *pXInputState)
+UpdateXInputJoystickState_OLD(SDL_Joystick * joystick, XINPUT_STATE_EX *pXInputState, XINPUT_BATTERY_INFORMATION *pBatteryInformation)
 {
 {
     static WORD s_XInputButtons[] = {
     static WORD s_XInputButtons[] = {
         XINPUT_GAMEPAD_DPAD_UP, XINPUT_GAMEPAD_DPAD_DOWN, XINPUT_GAMEPAD_DPAD_LEFT, XINPUT_GAMEPAD_DPAD_RIGHT,
         XINPUT_GAMEPAD_DPAD_UP, XINPUT_GAMEPAD_DPAD_DOWN, XINPUT_GAMEPAD_DPAD_LEFT, XINPUT_GAMEPAD_DPAD_RIGHT,
@@ -244,10 +275,12 @@ UpdateXInputJoystickState_OLD(SDL_Joystick * joystick, XINPUT_STATE_EX *pXInputS
     for (button = 0; button < SDL_arraysize(s_XInputButtons); ++button) {
     for (button = 0; button < SDL_arraysize(s_XInputButtons); ++button) {
         SDL_PrivateJoystickButton(joystick, button, (wButtons & s_XInputButtons[button]) ? SDL_PRESSED : SDL_RELEASED);
         SDL_PrivateJoystickButton(joystick, button, (wButtons & s_XInputButtons[button]) ? SDL_PRESSED : SDL_RELEASED);
     }
     }
+
+    UpdateXInputJoystickBatteryInformation( joystick, pBatteryInformation );
 }
 }
 
 
 static void
 static void
-UpdateXInputJoystickState(SDL_Joystick * joystick, XINPUT_STATE_EX *pXInputState)
+UpdateXInputJoystickState(SDL_Joystick * joystick, XINPUT_STATE_EX *pXInputState, XINPUT_BATTERY_INFORMATION *pBatteryInformation)
 {
 {
     static WORD s_XInputButtons[] = {
     static WORD s_XInputButtons[] = {
         XINPUT_GAMEPAD_A, XINPUT_GAMEPAD_B, XINPUT_GAMEPAD_X, XINPUT_GAMEPAD_Y,
         XINPUT_GAMEPAD_A, XINPUT_GAMEPAD_B, XINPUT_GAMEPAD_X, XINPUT_GAMEPAD_Y,
@@ -283,6 +316,8 @@ UpdateXInputJoystickState(SDL_Joystick * joystick, XINPUT_STATE_EX *pXInputState
         hat |= SDL_HAT_RIGHT;
         hat |= SDL_HAT_RIGHT;
     }
     }
     SDL_PrivateJoystickHat(joystick, 0, hat);
     SDL_PrivateJoystickHat(joystick, 0, hat);
+
+    UpdateXInputJoystickBatteryInformation( joystick, pBatteryInformation );
 }
 }
 
 
 void
 void
@@ -290,6 +325,7 @@ SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick)
 {
 {
     HRESULT result;
     HRESULT result;
     XINPUT_STATE_EX XInputState;
     XINPUT_STATE_EX XInputState;
+    XINPUT_BATTERY_INFORMATION XBatteryInformation;
 
 
     if (!XINPUTGETSTATE)
     if (!XINPUTGETSTATE)
         return;
         return;
@@ -301,12 +337,18 @@ SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick)
         return;
         return;
     }
     }
 
 
+    SDL_zero( XBatteryInformation );
+    if ( XINPUTGETBATTERYINFORMATION )
+    {
+        result = XINPUTGETBATTERYINFORMATION( joystick->hwdata->userid, BATTERY_DEVTYPE_GAMEPAD, &XBatteryInformation );
+    }
+
     /* only fire events if the data changed from last time */
     /* only fire events if the data changed from last time */
     if (XInputState.dwPacketNumber && XInputState.dwPacketNumber != joystick->hwdata->dwPacketNumber) {
     if (XInputState.dwPacketNumber && XInputState.dwPacketNumber != joystick->hwdata->dwPacketNumber) {
         if (SDL_XInputUseOldJoystickMapping()) {
         if (SDL_XInputUseOldJoystickMapping()) {
-            UpdateXInputJoystickState_OLD(joystick, &XInputState);
+            UpdateXInputJoystickState_OLD(joystick, &XInputState, &XBatteryInformation);
         } else {
         } else {
-            UpdateXInputJoystickState(joystick, &XInputState);
+            UpdateXInputJoystickState(joystick, &XInputState, &XBatteryInformation);
         }
         }
         joystick->hwdata->dwPacketNumber = XInputState.dwPacketNumber;
         joystick->hwdata->dwPacketNumber = XInputState.dwPacketNumber;
     }
     }

+ 1 - 1
sdl.mod/SDL/src/render/direct3d11/SDL_render_d3d11.c

@@ -2504,7 +2504,7 @@ D3D11_RenderDrawPoints(SDL_Renderer * renderer,
     a = (float)(renderer->a / 255.0f);
     a = (float)(renderer->a / 255.0f);
 
 
     vertices = SDL_stack_alloc(VertexPositionColor, count);
     vertices = SDL_stack_alloc(VertexPositionColor, count);
-    for (i = 0; i < min(count, 128); ++i) {
+    for (i = 0; i < count; ++i) {
         const VertexPositionColor v = { { points[i].x, points[i].y, 0.0f }, { 0.0f, 0.0f }, { r, g, b, a } };
         const VertexPositionColor v = { { points[i].x, points[i].y, 0.0f }, { 0.0f, 0.0f }, { r, g, b, a } };
         vertices[i] = v;
         vertices[i] = v;
     }
     }

+ 32 - 2
sdl.mod/SDL/src/video/SDL_video.c

@@ -1136,9 +1136,31 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
     /* if we are in the process of hiding don't go back to fullscreen */
     /* if we are in the process of hiding don't go back to fullscreen */
     if ( window->is_hiding && fullscreen )
     if ( window->is_hiding && fullscreen )
         return 0;
         return 0;
-    
+
 #ifdef __MACOSX__
 #ifdef __MACOSX__
+    /* if the window is going away and no resolution change is necessary,
+     do nothing, or else we may trigger an ugly double-transition
+     */
+    if (window->is_destroying && (window->last_fullscreen_flags & FULLSCREEN_MASK) == SDL_WINDOW_FULLSCREEN_DESKTOP)
+        return 0;
+    
+    /* If we're switching between a fullscreen Space and "normal" fullscreen, we need to get back to normal first. */
+    if (fullscreen && ((window->last_fullscreen_flags & FULLSCREEN_MASK) == SDL_WINDOW_FULLSCREEN_DESKTOP) && ((window->flags & FULLSCREEN_MASK) == SDL_WINDOW_FULLSCREEN)) {
+        if (!Cocoa_SetWindowFullscreenSpace(window, SDL_FALSE)) {
+            return -1;
+        }
+    } else if (fullscreen && ((window->last_fullscreen_flags & FULLSCREEN_MASK) == SDL_WINDOW_FULLSCREEN) && ((window->flags & FULLSCREEN_MASK) == SDL_WINDOW_FULLSCREEN_DESKTOP)) {
+        display = SDL_GetDisplayForWindow(window);
+        SDL_SetDisplayModeForDisplay(display, NULL);
+        if (_this->SetWindowFullscreen) {
+            _this->SetWindowFullscreen(_this, window, display, SDL_FALSE);
+        }
+    }
+
     if (Cocoa_SetWindowFullscreenSpace(window, fullscreen)) {
     if (Cocoa_SetWindowFullscreenSpace(window, fullscreen)) {
+        if (Cocoa_IsWindowInFullscreenSpace(window) != fullscreen) {
+            return -1;
+        }
         window->last_fullscreen_flags = window->flags;
         window->last_fullscreen_flags = window->flags;
         return 0;
         return 0;
     }
     }
@@ -1964,6 +1986,7 @@ SDL_RestoreWindow(SDL_Window * window)
 int
 int
 SDL_SetWindowFullscreen(SDL_Window * window, Uint32 flags)
 SDL_SetWindowFullscreen(SDL_Window * window, Uint32 flags)
 {
 {
+    Uint32 oldflags;
     CHECK_WINDOW_MAGIC(window, -1);
     CHECK_WINDOW_MAGIC(window, -1);
 
 
     flags &= FULLSCREEN_MASK;
     flags &= FULLSCREEN_MASK;
@@ -1973,10 +1996,17 @@ SDL_SetWindowFullscreen(SDL_Window * window, Uint32 flags)
     }
     }
 
 
     /* clear the previous flags and OR in the new ones */
     /* clear the previous flags and OR in the new ones */
+    oldflags = window->flags & FULLSCREEN_MASK;
     window->flags &= ~FULLSCREEN_MASK;
     window->flags &= ~FULLSCREEN_MASK;
     window->flags |= flags;
     window->flags |= flags;
 
 
-    return SDL_UpdateFullscreenMode(window, FULLSCREEN_VISIBLE(window));
+    if (SDL_UpdateFullscreenMode(window, FULLSCREEN_VISIBLE(window)) == 0) {
+        return 0;
+    }
+    
+    window->flags &= ~FULLSCREEN_MASK;
+    window->flags |= oldflags;
+    return -1;
 }
 }
 
 
 static SDL_Surface *
 static SDL_Surface *

+ 16 - 0
sdl.mod/SDL/src/video/android/SDL_androidkeyboard.c

@@ -300,6 +300,22 @@ static SDL_Scancode Android_Keycodes[] = {
     SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_MEDIA_CONTEXT_MENU */
     SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_MEDIA_CONTEXT_MENU */
     SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TIMER_PROGRAMMING */
     SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TIMER_PROGRAMMING */
     SDL_SCANCODE_HELP, /* AKEYCODE_HELP */
     SDL_SCANCODE_HELP, /* AKEYCODE_HELP */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NAVIGATE_PREVIOUS */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NAVIGATE_NEXT */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NAVIGATE_IN */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NAVIGATE_OUT */
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN,
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_SKIP_FORWARD */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_SKIP_BACKWARD */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_STEP_FORWARD */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_STEP_BACKWARD */
 };
 };
 
 
 static SDL_Scancode
 static SDL_Scancode

+ 6 - 3
sdl.mod/SDL/src/video/cocoa/SDL_cocoakeyboard.m

@@ -398,7 +398,7 @@ HandleModifiers(_THIS, unsigned short scancode, unsigned int modifierFlags)
 }
 }
 
 
 static void
 static void
-UpdateKeymap(SDL_VideoData *data)
+UpdateKeymap(SDL_VideoData *data, SDL_bool send_event)
 {
 {
     TISInputSourceRef key_layout;
     TISInputSourceRef key_layout;
     const void *chr_data;
     const void *chr_data;
@@ -454,6 +454,9 @@ UpdateKeymap(SDL_VideoData *data)
             }
             }
         }
         }
         SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
         SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
+        if (send_event) {
+            SDL_SendKeymapChangedEvent();
+        }
         return;
         return;
     }
     }
 
 
@@ -466,7 +469,7 @@ Cocoa_InitKeyboard(_THIS)
 {
 {
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
 
 
-    UpdateKeymap(data);
+    UpdateKeymap(data, SDL_FALSE);
 
 
     /* Set our own names for the platform-dependent but layout-independent keys */
     /* Set our own names for the platform-dependent but layout-independent keys */
     /* This key is NumLock on the MacBook keyboard. :) */
     /* This key is NumLock on the MacBook keyboard. :) */
@@ -564,7 +567,7 @@ Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
     case NSKeyDown:
     case NSKeyDown:
         if (![event isARepeat]) {
         if (![event isARepeat]) {
             /* See if we need to rebuild the keyboard layout */
             /* See if we need to rebuild the keyboard layout */
-            UpdateKeymap(data);
+            UpdateKeymap(data, SDL_TRUE);
         }
         }
 
 
         SDL_SendKeyboardKey(SDL_PRESSED, code);
         SDL_SendKeyboardKey(SDL_PRESSED, code);

+ 79 - 19
sdl.mod/SDL/src/video/cocoa/SDL_cocoawindow.m

@@ -282,6 +282,8 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
         [center addObserver:self selector:@selector(windowDidEnterFullScreen:) name:NSWindowDidEnterFullScreenNotification object:window];
         [center addObserver:self selector:@selector(windowDidEnterFullScreen:) name:NSWindowDidEnterFullScreenNotification object:window];
         [center addObserver:self selector:@selector(windowWillExitFullScreen:) name:NSWindowWillExitFullScreenNotification object:window];
         [center addObserver:self selector:@selector(windowWillExitFullScreen:) name:NSWindowWillExitFullScreenNotification object:window];
         [center addObserver:self selector:@selector(windowDidExitFullScreen:) name:NSWindowDidExitFullScreenNotification object:window];
         [center addObserver:self selector:@selector(windowDidExitFullScreen:) name:NSWindowDidExitFullScreenNotification object:window];
+        [center addObserver:self selector:@selector(windowDidFailToEnterFullScreen:) name:@"NSWindowDidFailToEnterFullScreenNotification" object:window];
+        [center addObserver:self selector:@selector(windowDidFailToExitFullScreen:) name:@"NSWindowDidFailToExitFullScreenNotification" object:window];
     } else {
     } else {
         [window setDelegate:self];
         [window setDelegate:self];
     }
     }
@@ -413,6 +415,8 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
         [center removeObserver:self name:NSWindowDidEnterFullScreenNotification object:window];
         [center removeObserver:self name:NSWindowDidEnterFullScreenNotification object:window];
         [center removeObserver:self name:NSWindowWillExitFullScreenNotification object:window];
         [center removeObserver:self name:NSWindowWillExitFullScreenNotification object:window];
         [center removeObserver:self name:NSWindowDidExitFullScreenNotification object:window];
         [center removeObserver:self name:NSWindowDidExitFullScreenNotification object:window];
+        [center removeObserver:self name:@"NSWindowDidFailToEnterFullScreenNotification" object:window];
+        [center removeObserver:self name:@"NSWindowDidFailToExitFullScreenNotification" object:window];
     } else {
     } else {
         [window setDelegate:nil];
         [window setDelegate:nil];
     }
     }
@@ -634,6 +638,22 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
     inFullscreenTransition = YES;
     inFullscreenTransition = YES;
 }
 }
 
 
+- (void)windowDidFailToEnterFullScreen:(NSNotification *)aNotification
+{
+    SDL_Window *window = _data->window;
+
+    if (window->is_destroying) {
+        return;
+    }
+
+    SetWindowStyle(window, GetWindowStyle(window));
+
+    isFullscreenSpace = NO;
+    inFullscreenTransition = NO;
+    
+    [self windowDidExitFullScreen:nil];
+}
+
 - (void)windowDidEnterFullScreen:(NSNotification *)aNotification
 - (void)windowDidEnterFullScreen:(NSNotification *)aNotification
 {
 {
     SDL_Window *window = _data->window;
     SDL_Window *window = _data->window;
@@ -668,6 +688,22 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
     inFullscreenTransition = YES;
     inFullscreenTransition = YES;
 }
 }
 
 
+- (void)windowDidFailToExitFullScreen:(NSNotification *)aNotification
+{
+    SDL_Window *window = _data->window;
+    
+    if (window->is_destroying) {
+        return;
+    }
+
+    SetWindowStyle(window, (NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask));
+    
+    isFullscreenSpace = YES;
+    inFullscreenTransition = NO;
+    
+    [self windowDidEnterFullScreen:nil];
+}
+
 - (void)windowDidExitFullScreen:(NSNotification *)aNotification
 - (void)windowDidExitFullScreen:(NSNotification *)aNotification
 {
 {
     SDL_Window *window = _data->window;
     SDL_Window *window = _data->window;
@@ -1288,13 +1324,23 @@ Cocoa_SetWindowSize(_THIS, SDL_Window * window)
 {
 {
     SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
     SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
     NSWindow *nswindow = windata->nswindow;
     NSWindow *nswindow = windata->nswindow;
+    NSRect rect;
+    Uint32 moveHack;
 
 
-    NSRect frame = [nswindow frame];
-    frame.origin.y = (frame.origin.y + frame.size.height) - ((float) window->h);
-    frame.size.width = window->w;
-    frame.size.height = window->h;
+    /* Cocoa will resize the window from the bottom-left rather than the
+     * top-left when -[nswindow setContentSize:] is used, so we must set the
+     * entire frame based on the new size, in order to preserve the position.
+     */
+    rect.origin.x = window->x;
+    rect.origin.y = window->y;
+    rect.size.width = window->w;
+    rect.size.height = window->h;
+    ConvertNSRect([nswindow screen], (window->flags & FULLSCREEN_MASK), &rect);
 
 
-    [nswindow setFrame:frame display:YES];
+    moveHack = s_moveHack;
+    s_moveHack = 0;
+    [nswindow setFrame:[nswindow frameRectForContentRect:rect] display:YES];
+    s_moveHack = moveHack;
 
 
     ScheduleContextUpdates(windata);
     ScheduleContextUpdates(windata);
 }}
 }}
@@ -1592,8 +1638,10 @@ Cocoa_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
     }
     }
 
 
     if ( data && (window->flags & SDL_WINDOW_FULLSCREEN) ) {
     if ( data && (window->flags & SDL_WINDOW_FULLSCREEN) ) {
-        if (SDL_ShouldAllowTopmost() && (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
+        if (SDL_ShouldAllowTopmost() && (window->flags & SDL_WINDOW_INPUT_FOCUS)
+            && ![data->listener isInFullscreenSpace]) {
             /* OpenGL is rendering to the window, so make it visible! */
             /* OpenGL is rendering to the window, so make it visible! */
+            /* Doing this in 10.11 while in a Space breaks things (bug #3152) */
             [data->nswindow setLevel:CGShieldingWindowLevel()];
             [data->nswindow setLevel:CGShieldingWindowLevel()];
         } else {
         } else {
             [data->nswindow setLevel:kCGNormalWindowLevel];
             [data->nswindow setLevel:kCGNormalWindowLevel];
@@ -1608,6 +1656,9 @@ Cocoa_DestroyWindow(_THIS, SDL_Window * window)
     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
 
 
     if (data) {
     if (data) {
+        if ([data->listener isInFullscreenSpace]) {
+            [NSMenu setMenuBarVisible:YES];
+        }
         [data->listener close];
         [data->listener close];
         [data->listener release];
         [data->listener release];
         if (data->created) {
         if (data->created) {
@@ -1662,21 +1713,30 @@ Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state)
     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
 
 
     if ([data->listener setFullscreenSpace:(state ? YES : NO)]) {
     if ([data->listener setFullscreenSpace:(state ? YES : NO)]) {
-        succeeded = SDL_TRUE;
-
-        /* Wait for the transition to complete, so application changes
-           take effect properly (e.g. setting the window size, etc.)
-         */
-        const int limit = 10000;
-        int count = 0;
-        while ([data->listener isInFullscreenSpaceTransition]) {
-            if ( ++count == limit ) {
-                /* Uh oh, transition isn't completing. Should we assert? */
-                break;
+        const int maxattempts = 3;
+        int attempt = 0;
+        while (++attempt <= maxattempts) {
+            /* Wait for the transition to complete, so application changes
+             take effect properly (e.g. setting the window size, etc.)
+             */
+            const int limit = 10000;
+            int count = 0;
+            while ([data->listener isInFullscreenSpaceTransition]) {
+                if ( ++count == limit ) {
+                    /* Uh oh, transition isn't completing. Should we assert? */
+                    break;
+                }
+                SDL_Delay(1);
+                SDL_PumpEvents();
             }
             }
-            SDL_Delay(1);
-            SDL_PumpEvents();
+            if ([data->listener isInFullscreenSpace] == (state ? YES : NO))
+                break;
+            /* Try again, the last attempt was interrupted by user gestures */
+            if (![data->listener setFullscreenSpace:(state ? YES : NO)])
+                break; /* ??? */
         }
         }
+        /* Return TRUE to prevent non-space fullscreen logic from running */
+        succeeded = SDL_TRUE;
     }
     }
 
 
     return succeeded;
     return succeeded;

+ 2 - 2
sdl.mod/SDL/src/video/psp/SDL_pspevents.c

@@ -42,7 +42,7 @@
 #define IRKBD_CONFIG_FILE     NULL    /* this will take ms0:/seplugins/pspirkeyb.ini */
 #define IRKBD_CONFIG_FILE     NULL    /* this will take ms0:/seplugins/pspirkeyb.ini */
 
 
 static int irkbd_ready = 0;
 static int irkbd_ready = 0;
-static SDLKey keymap[256];
+static SDL_Keycode keymap[256];
 #endif
 #endif
 
 
 static enum PspHprmKeys hprm = 0;
 static enum PspHprmKeys hprm = 0;
@@ -124,7 +124,7 @@ void PSP_PumpEvents(_THIS)
                 /* not tested */
                 /* not tested */
                 /* SDL_PrivateKeyboard(pressed?SDL_PRESSED:SDL_RELEASED, &sym); */
                 /* SDL_PrivateKeyboard(pressed?SDL_PRESSED:SDL_RELEASED, &sym); */
                 SDL_SendKeyboardKey((keys & keymap_psp[i].id) ?
                 SDL_SendKeyboardKey((keys & keymap_psp[i].id) ?
-                                    SDL_PRESSED : SDL_RELEASED, SDL_GetScancodeFromKey(keymap[raw]);
+                                    SDL_PRESSED : SDL_RELEASED, SDL_GetScancodeFromKey(keymap[raw]));
 
 
                 }
                 }
             }
             }

+ 131 - 33
sdl.mod/SDL/src/video/uikit/SDL_uikitmessagebox.m

@@ -24,15 +24,103 @@
 
 
 #include "SDL.h"
 #include "SDL.h"
 #include "SDL_uikitvideo.h"
 #include "SDL_uikitvideo.h"
-
+#include "SDL_uikitwindow.h"
 
 
 /* Display a UIKit message box */
 /* Display a UIKit message box */
 
 
 static SDL_bool s_showingMessageBox = SDL_FALSE;
 static SDL_bool s_showingMessageBox = SDL_FALSE;
 
 
+SDL_bool
+UIKit_ShowingMessageBox()
+{
+    return s_showingMessageBox;
+}
+
+static void
+UIKit_WaitUntilMessageBoxClosed(const SDL_MessageBoxData *messageboxdata, int *clickedindex)
+{
+    *clickedindex = messageboxdata->numbuttons;
+
+    @autoreleasepool {
+        /* Run the main event loop until the alert has finished */
+        /* Note that this needs to be done on the main thread */
+        s_showingMessageBox = SDL_TRUE;
+        while ((*clickedindex) == messageboxdata->numbuttons) {
+            [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
+        }
+        s_showingMessageBox = SDL_FALSE;
+    }
+}
+
+static BOOL
+UIKit_ShowMessageBoxAlertController(const SDL_MessageBoxData *messageboxdata, int *buttonid)
+{
+#ifdef __IPHONE_8_0
+    int i;
+    int __block clickedindex = messageboxdata->numbuttons;
+    const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons;
+    UIWindow *window = nil;
+    UIWindow *alertwindow = nil;
+
+    if (![UIAlertController class]) {
+        return NO;
+    }
+
+    UIAlertController *alert;
+    alert = [UIAlertController alertControllerWithTitle:@(messageboxdata->title)
+                                                message:@(messageboxdata->message)
+                                         preferredStyle:UIAlertControllerStyleAlert];
+
+    for (i = 0; i < messageboxdata->numbuttons; i++) {
+        UIAlertAction *action;
+        UIAlertActionStyle style = UIAlertActionStyleDefault;
+
+        if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) {
+            style = UIAlertActionStyleCancel;
+        }
+
+        action = [UIAlertAction actionWithTitle:@(buttons[i].text)
+                                          style:style
+                                        handler:^(UIAlertAction *action) {
+                                            clickedindex = i;
+                                        }];
+        [alert addAction:action];
+    }
+
+    if (messageboxdata->window) {
+        SDL_WindowData *data = (__bridge SDL_WindowData *) messageboxdata->window->driverdata;
+        window = data.uiwindow;
+    }
+
+    if (window == nil || window.rootViewController == nil) {
+        alertwindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
+        alertwindow.rootViewController = [UIViewController new];
+        alertwindow.windowLevel = UIWindowLevelAlert;
+
+        window = alertwindow;
+
+        [alertwindow makeKeyAndVisible];
+    }
+
+    [window.rootViewController presentViewController:alert animated:YES completion:nil];
+    UIKit_WaitUntilMessageBoxClosed(messageboxdata, &clickedindex);
+
+    if (alertwindow) {
+        alertwindow.hidden = YES;
+    }
+
+    *buttonid = messageboxdata->buttons[clickedindex].buttonid;
+    return YES;
+#else
+    return NO;
+#endif /* __IPHONE_8_0 */
+}
+
+/* UIAlertView is deprecated in iOS 8+ in favor of UIAlertController. */
+#if __IPHONE_OS_VERSION_MIN_REQUIRED < 80000
 @interface SDLAlertViewDelegate : NSObject <UIAlertViewDelegate>
 @interface SDLAlertViewDelegate : NSObject <UIAlertViewDelegate>
 
 
-@property (nonatomic, assign) int clickedIndex;
+@property (nonatomic, assign) int *clickedIndex;
 
 
 @end
 @end
 
 
@@ -40,52 +128,62 @@ static SDL_bool s_showingMessageBox = SDL_FALSE;
 
 
 - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
 - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
 {
 {
-    _clickedIndex = (int)buttonIndex;
+    if (_clickedIndex != NULL) {
+        *_clickedIndex = (int) buttonIndex;
+    }
 }
 }
 
 
 @end
 @end
+#endif /* __IPHONE_OS_VERSION_MIN_REQUIRED < 80000 */
 
 
-
-SDL_bool
-UIKit_ShowingMessageBox()
-{
-    return s_showingMessageBox;
-}
-
-int
-UIKit_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
+static BOOL
+UIKit_ShowMessageBoxAlertView(const SDL_MessageBoxData *messageboxdata, int *buttonid)
 {
 {
+    /* UIAlertView is deprecated in iOS 8+ in favor of UIAlertController. */
+#if __IPHONE_OS_VERSION_MIN_REQUIRED < 80000
     int i;
     int i;
+    int clickedindex = messageboxdata->numbuttons;
     const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons;
     const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons;
+    UIAlertView *alert = [[UIAlertView alloc] init];
+    SDLAlertViewDelegate *delegate = [[SDLAlertViewDelegate alloc] init];
 
 
-    @autoreleasepool {
-        UIAlertView *alert = [[UIAlertView alloc] init];
-        SDLAlertViewDelegate *delegate = [[SDLAlertViewDelegate alloc] init];
+    alert.delegate = delegate;
+    alert.title = @(messageboxdata->title);
+    alert.message = @(messageboxdata->message);
 
 
-        alert.delegate = delegate;
-        alert.title = @(messageboxdata->title);
-        alert.message = @(messageboxdata->message);
+    for (i = 0; i < messageboxdata->numbuttons; i++) {
+        [alert addButtonWithTitle:@(buttons[i].text)];
+    }
 
 
-        for (i = 0; i < messageboxdata->numbuttons; ++i) {
-            [alert addButtonWithTitle:@(buttons[i].text)];
-        }
+    delegate.clickedIndex = &clickedindex;
 
 
-        /* Set up for showing the alert */
-        delegate.clickedIndex = messageboxdata->numbuttons;
+    [alert show];
 
 
-        [alert show];
+    UIKit_WaitUntilMessageBoxClosed(messageboxdata, &clickedindex);
 
 
-        /* Run the main event loop until the alert has finished */
-        /* Note that this needs to be done on the main thread */
-        s_showingMessageBox = SDL_TRUE;
-        while (delegate.clickedIndex == messageboxdata->numbuttons) {
-            [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
-        }
-        s_showingMessageBox = SDL_FALSE;
+    alert.delegate = nil;
 
 
-        *buttonid = messageboxdata->buttons[delegate.clickedIndex].buttonid;
+    *buttonid = messageboxdata->buttons[clickedindex].buttonid;
+    return YES;
+#else
+    return NO;
+#endif /* __IPHONE_OS_VERSION_MIN_REQUIRED < 80000 */
+}
+
+int
+UIKit_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
+{
+    BOOL success = NO;
+
+    @autoreleasepool {
+        success = UIKit_ShowMessageBoxAlertController(messageboxdata, buttonid);
+        if (!success) {
+            success = UIKit_ShowMessageBoxAlertView(messageboxdata, buttonid);
+        }
+    }
 
 
-        alert.delegate = nil;
+    if (!success) {
+        return SDL_SetError("Could not show message box.");
     }
     }
 
 
     return 0;
     return 0;

+ 0 - 2
sdl.mod/SDL/src/video/uikit/SDL_uikitopengles.m

@@ -52,8 +52,6 @@
 
 
 @end
 @end
 
 
-static int UIKit_GL_Initialize(_THIS);
-
 void *
 void *
 UIKit_GL_GetProcAddress(_THIS, const char *proc)
 UIKit_GL_GetProcAddress(_THIS, const char *proc)
 {
 {

+ 2 - 6
sdl.mod/SDL/src/video/uikit/SDL_uikitopenglview.m

@@ -88,12 +88,8 @@
             GLint maxsamples = 0;
             GLint maxsamples = 0;
             glGetIntegerv(GL_MAX_SAMPLES, &maxsamples);
             glGetIntegerv(GL_MAX_SAMPLES, &maxsamples);
 
 
-            /* Verify that the sample count is supported before creating any
-             * multisample Renderbuffers, to avoid generating GL errors. */
-            if (samples > maxsamples) {
-                SDL_SetError("Failed creating OpenGL ES framebuffer: Unsupported MSAA sample count");
-                return nil;
-            }
+            /* Clamp the samples to the max supported count. */
+            samples = MIN(samples, maxsamples);
         }
         }
 
 
         if (sRGB) {
         if (sRGB) {

+ 20 - 3
sdl.mod/SDL/src/video/uikit/SDL_uikitview.m

@@ -123,9 +123,22 @@
     return point;
     return point;
 }
 }
 
 
+- (float)pressureForTouch:(UITouch *)touch
+{
+#ifdef __IPHONE_9_0
+    if ([touch respondsToSelector:@selector(force)]) {
+        return (float) touch.force;
+    }
+#endif
+
+    return 1.0f;
+}
+
 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
 {
 {
     for (UITouch *touch in touches) {
     for (UITouch *touch in touches) {
+        float pressure = [self pressureForTouch:touch];
+
         if (!firstFingerDown) {
         if (!firstFingerDown) {
             CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO];
             CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO];
 
 
@@ -140,13 +153,15 @@
 
 
         CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
         CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
         SDL_SendTouch(touchId, (SDL_FingerID)((size_t)touch),
         SDL_SendTouch(touchId, (SDL_FingerID)((size_t)touch),
-                      SDL_TRUE, locationInView.x, locationInView.y, 1.0f);
+                      SDL_TRUE, locationInView.x, locationInView.y, pressure);
     }
     }
 }
 }
 
 
 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
 {
 {
     for (UITouch *touch in touches) {
     for (UITouch *touch in touches) {
+        float pressure = [self pressureForTouch:touch];
+
         if (touch == firstFingerDown) {
         if (touch == firstFingerDown) {
             /* send mouse up */
             /* send mouse up */
             SDL_SendMouseButton(sdlwindow, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
             SDL_SendMouseButton(sdlwindow, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
@@ -155,7 +170,7 @@
 
 
         CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
         CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
         SDL_SendTouch(touchId, (SDL_FingerID)((size_t)touch),
         SDL_SendTouch(touchId, (SDL_FingerID)((size_t)touch),
-                      SDL_FALSE, locationInView.x, locationInView.y, 1.0f);
+                      SDL_FALSE, locationInView.x, locationInView.y, pressure);
     }
     }
 }
 }
 
 
@@ -167,6 +182,8 @@
 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
 {
 {
     for (UITouch *touch in touches) {
     for (UITouch *touch in touches) {
+        float pressure = [self pressureForTouch:touch];
+
         if (touch == firstFingerDown) {
         if (touch == firstFingerDown) {
             CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO];
             CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO];
 
 
@@ -176,7 +193,7 @@
 
 
         CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
         CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
         SDL_SendTouchMotion(touchId, (SDL_FingerID)((size_t)touch),
         SDL_SendTouchMotion(touchId, (SDL_FingerID)((size_t)touch),
-                            locationInView.x, locationInView.y, 1.0f);
+                            locationInView.x, locationInView.y, pressure);
     }
     }
 }
 }
 
 

+ 0 - 2
sdl.mod/SDL/src/video/uikit/SDL_uikitviewcontroller.h

@@ -47,9 +47,7 @@
 - (void)loadView;
 - (void)loadView;
 - (void)viewDidLayoutSubviews;
 - (void)viewDidLayoutSubviews;
 - (NSUInteger)supportedInterfaceOrientations;
 - (NSUInteger)supportedInterfaceOrientations;
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient;
 - (BOOL)prefersStatusBarHidden;
 - (BOOL)prefersStatusBarHidden;
-- (UIStatusBarStyle)preferredStatusBarStyle;
 
 
 #if SDL_IPHONE_KEYBOARD
 #if SDL_IPHONE_KEYBOARD
 - (void)showKeyboard;
 - (void)showKeyboard;

+ 0 - 6
sdl.mod/SDL/src/video/uikit/SDL_uikitviewcontroller.m

@@ -135,12 +135,6 @@
     return (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) != 0;
     return (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) != 0;
 }
 }
 
 
-- (UIStatusBarStyle)preferredStatusBarStyle
-{
-    /* We assume most SDL apps don't have a bright white background. */
-    return UIStatusBarStyleLightContent;
-}
-
 /*
 /*
  ---- Keyboard related functionality below this line ----
  ---- Keyboard related functionality below this line ----
  */
  */

+ 18 - 17
sdl.mod/SDL/src/video/windows/SDL_windowsevents.c

@@ -607,25 +607,26 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
         break;
         break;
 
 
     case WM_UNICHAR:
     case WM_UNICHAR:
-		if ( wParam == UNICODE_NOCHAR ) {
-			returnCode = 1;
-			break;
-		}
-		/* otherwise fall through to below */
-	case WM_CHAR:
-		{
-			char text[5];
-			if ( WIN_ConvertUTF32toUTF8( (UINT32)wParam, text ) ) {
-				SDL_SendKeyboardText( text );
-			}
-		}
-		returnCode = 0;
+        if ( wParam == UNICODE_NOCHAR ) {
+            returnCode = 1;
+            break;
+        }
+        /* otherwise fall through to below */
+    case WM_CHAR:
+        {
+            char text[5];
+            if ( WIN_ConvertUTF32toUTF8( (UINT32)wParam, text ) ) {
+                SDL_SendKeyboardText( text );
+            }
+        }
+        returnCode = 0;
         break;
         break;
 
 
 #ifdef WM_INPUTLANGCHANGE
 #ifdef WM_INPUTLANGCHANGE
     case WM_INPUTLANGCHANGE:
     case WM_INPUTLANGCHANGE:
         {
         {
             WIN_UpdateKeymap();
             WIN_UpdateKeymap();
+            SDL_SendKeymapChangedEvent();
         }
         }
         returnCode = 1;
         returnCode = 1;
         break;
         break;
@@ -735,7 +736,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
             int x, y;
             int x, y;
             int w, h;
             int w, h;
             
             
-            if (data->in_border_change) {
+            if (data->initializing || data->in_border_change) {
                 break;
                 break;
             }
             }
 
 
@@ -813,9 +814,9 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
 
     case WM_SYSCOMMAND:
     case WM_SYSCOMMAND:
         {
         {
-			if ((wParam & 0xFFF0) == SC_KEYMENU) {
-				return (0);
-			}
+            if ((wParam & 0xFFF0) == SC_KEYMENU) {
+                return (0);
+            }
 
 
 #if defined(SC_SCREENSAVE) || defined(SC_MONITORPOWER)
 #if defined(SC_SCREENSAVE) || defined(SC_MONITORPOWER)
             /* Don't start the screensaver or blank the monitor in fullscreen apps */
             /* Don't start the screensaver or blank the monitor in fullscreen apps */

+ 2 - 2
sdl.mod/SDL/src/video/windows/SDL_windowskeyboard.c

@@ -124,7 +124,7 @@ WIN_UpdateKeymap()
         /* If this key is one of the non-mappable keys, ignore it */
         /* If this key is one of the non-mappable keys, ignore it */
         /* Not mapping numbers fixes the French layout, giving numeric keycodes for the number keys, which is the expected behavior */
         /* Not mapping numbers fixes the French layout, giving numeric keycodes for the number keys, which is the expected behavior */
         if ((keymap[scancode] & SDLK_SCANCODE_MASK) ||
         if ((keymap[scancode] & SDLK_SCANCODE_MASK) ||
-			/*  scancode == SDL_SCANCODE_GRAVE || */ /* Uncomment this line to re-enable the behavior of not mapping the "`"(grave) key to the users actual keyboard layout */
+            /*  scancode == SDL_SCANCODE_GRAVE || */ /* Uncomment this line to re-enable the behavior of not mapping the "`"(grave) key to the users actual keyboard layout */
             (scancode >= SDL_SCANCODE_1 && scancode <= SDL_SCANCODE_0) ) {
             (scancode >= SDL_SCANCODE_1 && scancode <= SDL_SCANCODE_0) ) {
             continue;
             continue;
         }
         }
@@ -402,7 +402,7 @@ IME_GetReadingString(SDL_VideoData *videodata, HWND hwnd)
     INT err = 0;
     INT err = 0;
     BOOL vertical = FALSE;
     BOOL vertical = FALSE;
     UINT maxuilen = 0;
     UINT maxuilen = 0;
-	static OSVERSIONINFOA osversion;
+    static OSVERSIONINFOA osversion;
 
 
     if (videodata->ime_uiless)
     if (videodata->ime_uiless)
         return;
         return;

+ 6 - 3
sdl.mod/SDL/src/video/windows/SDL_windowsmessagebox.c

@@ -297,9 +297,12 @@ static WIN_DialogData *CreateDialogData(int w, int h, const char *caption)
 
 
         /* Font size - convert to logical font size for dialog parameter. */
         /* Font size - convert to logical font size for dialog parameter. */
         {
         {
-            HDC ScreenDC = GetDC(0);
-            WordToPass = (WORD)(-72 * NCM.lfMessageFont.lfHeight / GetDeviceCaps(ScreenDC, LOGPIXELSY));
-            ReleaseDC(0, ScreenDC);
+            HDC ScreenDC = GetDC(NULL);
+            int LogicalPixelsY = GetDeviceCaps(ScreenDC, LOGPIXELSY);
+            if (!LogicalPixelsY) /* This can happen if the application runs out of GDI handles */
+                LogicalPixelsY = 72;
+            WordToPass = (WORD)(-72 * NCM.lfMessageFont.lfHeight / LogicalPixelsY);
+            ReleaseDC(NULL, ScreenDC);
         }
         }
 
 
         if (!AddDialogData(dialog, &WordToPass, 2)) {
         if (!AddDialogData(dialog, &WordToPass, 2)) {

+ 80 - 80
sdl.mod/SDL/src/video/windows/SDL_windowsmodes.c

@@ -30,43 +30,43 @@
 #endif
 #endif
 
 
 typedef struct _WIN_GetMonitorDPIData {
 typedef struct _WIN_GetMonitorDPIData {
-	SDL_VideoData *vid_data;
-	SDL_DisplayMode *mode;
-	SDL_DisplayModeData *mode_data;
+    SDL_VideoData *vid_data;
+    SDL_DisplayMode *mode;
+    SDL_DisplayModeData *mode_data;
 } WIN_GetMonitorDPIData;
 } WIN_GetMonitorDPIData;
 
 
 static BOOL CALLBACK
 static BOOL CALLBACK
 WIN_GetMonitorDPI(HMONITOR hMonitor,
 WIN_GetMonitorDPI(HMONITOR hMonitor,
-				  HDC      hdcMonitor,
-				  LPRECT   lprcMonitor,
-				  LPARAM   dwData)
+                  HDC      hdcMonitor,
+                  LPRECT   lprcMonitor,
+                  LPARAM   dwData)
 {
 {
-	WIN_GetMonitorDPIData *data = (WIN_GetMonitorDPIData*) dwData;
-	UINT hdpi, vdpi;
-
-	if (data->vid_data->GetDpiForMonitor(hMonitor, MDT_EFFECTIVE_DPI, &hdpi, &vdpi) == S_OK &&
-		hdpi > 0 &&
-		vdpi > 0) {
-		float hsize, vsize;
-		
-		data->mode_data->HorzDPI = (float)hdpi;
-		data->mode_data->VertDPI = (float)vdpi;
-
-		// Figure out the monitor size and compute the diagonal DPI.
-		hsize = data->mode->w / data->mode_data->HorzDPI;
-		vsize = data->mode->h / data->mode_data->VertDPI;
-		
-		data->mode_data->DiagDPI = SDL_ComputeDiagonalDPI( data->mode->w,
-														   data->mode->h,
-														   hsize,
-														   vsize );
-
-		// We can only handle one DPI per display mode so end the enumeration.
-		return FALSE;
-	}
-
-	// We didn't get DPI information so keep going.
-	return TRUE;
+    WIN_GetMonitorDPIData *data = (WIN_GetMonitorDPIData*) dwData;
+    UINT hdpi, vdpi;
+
+    if (data->vid_data->GetDpiForMonitor(hMonitor, MDT_EFFECTIVE_DPI, &hdpi, &vdpi) == S_OK &&
+        hdpi > 0 &&
+        vdpi > 0) {
+        float hsize, vsize;
+        
+        data->mode_data->HorzDPI = (float)hdpi;
+        data->mode_data->VertDPI = (float)vdpi;
+
+        // Figure out the monitor size and compute the diagonal DPI.
+        hsize = data->mode->w / data->mode_data->HorzDPI;
+        vsize = data->mode->h / data->mode_data->VertDPI;
+        
+        data->mode_data->DiagDPI = SDL_ComputeDiagonalDPI( data->mode->w,
+                                                           data->mode->h,
+                                                           hsize,
+                                                           vsize );
+
+        // We can only handle one DPI per display mode so end the enumeration.
+        return FALSE;
+    }
+
+    // We didn't get DPI information so keep going.
+    return TRUE;
 }
 }
 
 
 static SDL_bool
 static SDL_bool
@@ -91,11 +91,11 @@ WIN_GetDisplayMode(_THIS, LPCTSTR deviceName, DWORD index, SDL_DisplayMode * mod
     data->DeviceMode.dmFields =
     data->DeviceMode.dmFields =
         (DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY |
         (DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY |
          DM_DISPLAYFLAGS);
          DM_DISPLAYFLAGS);
-	data->ScaleX = 1.0f;
-	data->ScaleY = 1.0f;
-	data->DiagDPI = 0.0f;
-	data->HorzDPI = 0.0f;
-	data->VertDPI = 0.0f;
+    data->ScaleX = 1.0f;
+    data->ScaleY = 1.0f;
+    data->DiagDPI = 0.0f;
+    data->HorzDPI = 0.0f;
+    data->VertDPI = 0.0f;
 
 
     /* Fill in the mode information */
     /* Fill in the mode information */
     mode->format = SDL_PIXELFORMAT_UNKNOWN;
     mode->format = SDL_PIXELFORMAT_UNKNOWN;
@@ -109,43 +109,43 @@ WIN_GetDisplayMode(_THIS, LPCTSTR deviceName, DWORD index, SDL_DisplayMode * mod
         char bmi_data[sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)];
         char bmi_data[sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)];
         LPBITMAPINFO bmi;
         LPBITMAPINFO bmi;
         HBITMAP hbm;
         HBITMAP hbm;
-		int logical_width = GetDeviceCaps( hdc, HORZRES );
-		int logical_height = GetDeviceCaps( hdc, VERTRES );
-
-		data->ScaleX = (float)logical_width / devmode.dmPelsWidth;
-		data->ScaleY = (float)logical_height / devmode.dmPelsHeight;
-		mode->w = logical_width;
-		mode->h = logical_height;
-
-		// WIN_GetMonitorDPI needs mode->w and mode->h
-		// so only call after those are set.
-		if (vid_data->GetDpiForMonitor) {
-			WIN_GetMonitorDPIData dpi_data;
+        int logical_width = GetDeviceCaps( hdc, HORZRES );
+        int logical_height = GetDeviceCaps( hdc, VERTRES );
+
+        data->ScaleX = (float)logical_width / devmode.dmPelsWidth;
+        data->ScaleY = (float)logical_height / devmode.dmPelsHeight;
+        mode->w = logical_width;
+        mode->h = logical_height;
+
+        // WIN_GetMonitorDPI needs mode->w and mode->h
+        // so only call after those are set.
+        if (vid_data->GetDpiForMonitor) {
+            WIN_GetMonitorDPIData dpi_data;
             RECT monitor_rect;
             RECT monitor_rect;
 
 
-			dpi_data.vid_data = vid_data;
-			dpi_data.mode = mode;
-			dpi_data.mode_data = data;
+            dpi_data.vid_data = vid_data;
+            dpi_data.mode = mode;
+            dpi_data.mode_data = data;
             monitor_rect.left = devmode.dmPosition.x;
             monitor_rect.left = devmode.dmPosition.x;
             monitor_rect.top = devmode.dmPosition.y;
             monitor_rect.top = devmode.dmPosition.y;
             monitor_rect.right = monitor_rect.left + 1;
             monitor_rect.right = monitor_rect.left + 1;
             monitor_rect.bottom = monitor_rect.top + 1;
             monitor_rect.bottom = monitor_rect.top + 1;
-			EnumDisplayMonitors(NULL, &monitor_rect, WIN_GetMonitorDPI, (LPARAM)&dpi_data);
-		} else {
-			// We don't have the Windows 8.1 routine so just
-			// get system DPI.
-			data->HorzDPI = (float)GetDeviceCaps( hdc, LOGPIXELSX );
-			data->VertDPI = (float)GetDeviceCaps( hdc, LOGPIXELSY );
-			if (data->HorzDPI == data->VertDPI) {
-				data->DiagDPI = data->HorzDPI;
-			} else {
-				data->DiagDPI = SDL_ComputeDiagonalDPI( mode->w,
-														mode->h,
-														(float)GetDeviceCaps( hdc, HORZSIZE ) / 25.4f,
-														(float)GetDeviceCaps( hdc, VERTSIZE ) / 25.4f );
-			}
-		}
-		
+            EnumDisplayMonitors(NULL, &monitor_rect, WIN_GetMonitorDPI, (LPARAM)&dpi_data);
+        } else {
+            // We don't have the Windows 8.1 routine so just
+            // get system DPI.
+            data->HorzDPI = (float)GetDeviceCaps( hdc, LOGPIXELSX );
+            data->VertDPI = (float)GetDeviceCaps( hdc, LOGPIXELSY );
+            if (data->HorzDPI == data->VertDPI) {
+                data->DiagDPI = data->HorzDPI;
+            } else {
+                data->DiagDPI = SDL_ComputeDiagonalDPI( mode->w,
+                                                        mode->h,
+                                                        (float)GetDeviceCaps( hdc, HORZSIZE ) / 25.4f,
+                                                        (float)GetDeviceCaps( hdc, VERTSIZE ) / 25.4f );
+            }
+        }
+        
         SDL_zero(bmi_data);
         SDL_zero(bmi_data);
         bmi = (LPBITMAPINFO) bmi_data;
         bmi = (LPBITMAPINFO) bmi_data;
         bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
         bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
@@ -175,7 +175,7 @@ WIN_GetDisplayMode(_THIS, LPCTSTR deviceName, DWORD index, SDL_DisplayMode * mod
         } else if (bmi->bmiHeader.biBitCount == 4) {
         } else if (bmi->bmiHeader.biBitCount == 4) {
             mode->format = SDL_PIXELFORMAT_INDEX4LSB;
             mode->format = SDL_PIXELFORMAT_INDEX4LSB;
         }
         }
-	} else {
+    } else {
         /* FIXME: Can we tell what this will be? */
         /* FIXME: Can we tell what this will be? */
         if ((devmode.dmFields & DM_BITSPERPEL) == DM_BITSPERPEL) {
         if ((devmode.dmFields & DM_BITSPERPEL) == DM_BITSPERPEL) {
             switch (devmode.dmBitsPerPel) {
             switch (devmode.dmBitsPerPel) {
@@ -319,17 +319,17 @@ WIN_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi,
 {
 {
     SDL_DisplayModeData *data = (SDL_DisplayModeData *) display->current_mode.driverdata;
     SDL_DisplayModeData *data = (SDL_DisplayModeData *) display->current_mode.driverdata;
 
 
-	if (ddpi) {
-		*ddpi = data->DiagDPI;
-	}
-	if (hdpi) {
-		*hdpi = data->HorzDPI;
-	}
-	if (vdpi) {
-		*vdpi = data->VertDPI;
-	}
-
-	return data->DiagDPI != 0.0f ? 0 : -1;
+    if (ddpi) {
+        *ddpi = data->DiagDPI;
+    }
+    if (hdpi) {
+        *hdpi = data->HorzDPI;
+    }
+    if (vdpi) {
+        *vdpi = data->VertDPI;
+    }
+
+    return data->DiagDPI != 0.0f ? 0 : -1;
 }
 }
 
 
 void
 void

+ 4 - 4
sdl.mod/SDL/src/video/windows/SDL_windowsmodes.h

@@ -31,11 +31,11 @@ typedef struct
 typedef struct
 typedef struct
 {
 {
     DEVMODE DeviceMode;
     DEVMODE DeviceMode;
-	float ScaleX;
-	float ScaleY;
+    float ScaleX;
+    float ScaleY;
     float DiagDPI;
     float DiagDPI;
-	float HorzDPI;
-	float VertDPI;
+    float HorzDPI;
+    float VertDPI;
 } SDL_DisplayModeData;
 } SDL_DisplayModeData;
 
 
 extern int WIN_InitModes(_THIS);
 extern int WIN_InitModes(_THIS);

+ 25 - 3
sdl.mod/SDL/src/video/windows/SDL_windowswindow.c

@@ -109,7 +109,7 @@ WIN_SetWindowPositionInternal(_THIS, SDL_Window * window, UINT flags)
     y = window->y + rect.top;
     y = window->y + rect.top;
 
 
     data->expected_resize = SDL_TRUE;
     data->expected_resize = SDL_TRUE;
-    SetWindowPos( hwnd, top, x, y, w, h, flags );
+    SetWindowPos(hwnd, top, x, y, w, h, flags);
     data->expected_resize = SDL_FALSE;
     data->expected_resize = SDL_FALSE;
 }
 }
 
 
@@ -130,6 +130,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
     data->created = created;
     data->created = created;
     data->mouse_button_flags = 0;
     data->mouse_button_flags = 0;
     data->videodata = videodata;
     data->videodata = videodata;
+    data->initializing = SDL_TRUE;
 
 
     window->driverdata = data;
     window->driverdata = data;
 
 
@@ -165,7 +166,26 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
             int h = rect.bottom;
             int h = rect.bottom;
             if ((window->w && window->w != w) || (window->h && window->h != h)) {
             if ((window->w && window->w != w) || (window->h && window->h != h)) {
                 /* We tried to create a window larger than the desktop and Windows didn't allow it.  Override! */
                 /* We tried to create a window larger than the desktop and Windows didn't allow it.  Override! */
-                WIN_SetWindowPositionInternal(_this, window, SWP_NOCOPYBITS | SWP_NOZORDER | SWP_NOACTIVATE);
+                RECT rect;
+                DWORD style;
+                BOOL menu;
+                int x, y;
+                int w, h;
+
+                /* Figure out what the window area will be */
+                style = GetWindowLong(hwnd, GWL_STYLE);
+                rect.left = 0;
+                rect.top = 0;
+                rect.right = window->w;
+                rect.bottom = window->h;
+                menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
+                AdjustWindowRectEx(&rect, style, menu, 0);
+                w = (rect.right - rect.left);
+                h = (rect.bottom - rect.top);
+                x = window->x + rect.left;
+                y = window->y + rect.top;
+
+                SetWindowPos(hwnd, HWND_NOTOPMOST, x, y, w, h, SWP_NOCOPYBITS | SWP_NOZORDER | SWP_NOACTIVATE);
             } else {
             } else {
                 window->w = w;
                 window->w = w;
                 window->h = h;
                 window->h = h;
@@ -236,6 +256,8 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
     /* Enable dropping files */
     /* Enable dropping files */
     DragAcceptFiles(hwnd, TRUE);
     DragAcceptFiles(hwnd, TRUE);
 
 
+    data->initializing = SDL_FALSE;
+
     /* All done! */
     /* All done! */
     return 0;
     return 0;
 }
 }
@@ -492,7 +514,7 @@ WIN_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
     }
     }
 
 
     data->in_border_change = SDL_TRUE;
     data->in_border_change = SDL_TRUE;
-    SetWindowLong( hwnd, GWL_STYLE, style );
+    SetWindowLong(hwnd, GWL_STYLE, style);
     WIN_SetWindowPositionInternal(_this, window, SWP_NOCOPYBITS | SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOACTIVATE);
     WIN_SetWindowPositionInternal(_this, window, SWP_NOCOPYBITS | SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOACTIVATE);
     data->in_border_change = SDL_FALSE;
     data->in_border_change = SDL_FALSE;
 }
 }

+ 2 - 1
sdl.mod/SDL/src/video/windows/SDL_windowswindow.h

@@ -37,10 +37,11 @@ typedef struct
     WNDPROC wndproc;
     WNDPROC wndproc;
     SDL_bool created;
     SDL_bool created;
     WPARAM mouse_button_flags;
     WPARAM mouse_button_flags;
+    SDL_bool initializing;
     SDL_bool expected_resize;
     SDL_bool expected_resize;
     SDL_bool in_border_change;
     SDL_bool in_border_change;
     SDL_bool in_title_click;
     SDL_bool in_title_click;
-	SDL_bool focus_click_pending;
+    SDL_bool focus_click_pending;
     struct SDL_VideoData *videodata;
     struct SDL_VideoData *videodata;
 #if SDL_VIDEO_OPENGL_EGL  
 #if SDL_VIDEO_OPENGL_EGL  
     EGLSurface egl_surface;
     EGLSurface egl_surface;

+ 2 - 0
sdl.mod/SDL/src/video/x11/SDL_x11events.c

@@ -625,6 +625,7 @@ X11_DispatchEvent(_THIS)
             }
             }
 
 
             X11_UpdateKeymap(_this);
             X11_UpdateKeymap(_this);
+            SDL_SendKeymapChangedEvent();
         }
         }
         return;
         return;
     }
     }
@@ -1143,6 +1144,7 @@ X11_DispatchEvent(_THIS)
                    notice and reinit our keymap here. This might not be the
                    notice and reinit our keymap here. This might not be the
                    right approach, but it seems to work. */
                    right approach, but it seems to work. */
                 X11_UpdateKeymap(_this);
                 X11_UpdateKeymap(_this);
+                SDL_SendKeymapChangedEvent();
             }
             }
         }
         }
         break;
         break;

+ 17 - 5
sdl.mod/SDL/src/video/x11/SDL_x11window.c

@@ -542,11 +542,23 @@ X11_CreateWindow(_THIS, SDL_Window * window)
                     (unsigned char *)&_NET_WM_BYPASS_COMPOSITOR_HINT_ON, 1);
                     (unsigned char *)&_NET_WM_BYPASS_COMPOSITOR_HINT_ON, 1);
 
 
     {
     {
-        Atom protocols[] = {
-            data->WM_DELETE_WINDOW, /* Allow window to be deleted by the WM */
-            data->_NET_WM_PING, /* Respond so WM knows we're alive */
-        };
-        X11_XSetWMProtocols(display, w, protocols, sizeof (protocols) / sizeof (protocols[0]));
+        Atom protocols[2];
+        int proto_count = 0;
+        const char *ping_hint;
+
+        protocols[proto_count] = data->WM_DELETE_WINDOW; /* Allow window to be deleted by the WM */
+        proto_count++;
+        
+        ping_hint = SDL_GetHint(SDL_HINT_VIDEO_X11_NET_WM_PING);
+        /* Default to using ping if there is no hint */
+        if (!ping_hint || SDL_atoi(ping_hint)) {
+            protocols[proto_count] = data->_NET_WM_PING; /* Respond so WM knows we're alive */
+            proto_count++;
+        }
+
+        SDL_assert(proto_count <= sizeof(protocols) / sizeof(protocols[0]));
+
+        X11_XSetWMProtocols(display, w, protocols, proto_count);
     }
     }
 
 
     if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) {
     if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) {

+ 1 - 1
sdl.mod/include/android/SDL_config.h

@@ -1,6 +1,6 @@
 /*
 /*
   Simple DirectMedia Layer
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
 
   This software is provided 'as-is', without any express or implied
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
   warranty.  In no event will the authors be held liable for any damages

+ 24 - 328
sdl.mod/include/emscripten/SDL_config.h

@@ -1,7 +1,6 @@
-/* include/SDL_config.h.  Generated from SDL_config.h.in by configure.  */
 /*
 /*
   Simple DirectMedia Layer
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
 
   This software is provided 'as-is', without any express or implied
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
   warranty.  In no event will the authors be held liable for any damages
@@ -23,337 +22,34 @@
 #ifndef _SDL_config_h
 #ifndef _SDL_config_h
 #define _SDL_config_h
 #define _SDL_config_h
 
 
-/**
- *  \file SDL_config.h.in
- *
- *  This is a set of defines to configure the SDL features
- */
-
-/* General platform specific identifiers */
 #include "SDL_platform.h"
 #include "SDL_platform.h"
 
 
-/* Make sure that this isn't included by Visual C++ */
-#ifdef _MSC_VER
-#error You should run hg revert SDL_config.h 
-#endif
-
-/* C language features */
-/* #undef const */
-/* #undef inline */
-/* #undef volatile */
+/**
+ *  \file SDL_config.h
+ */
 
 
-/* C datatypes */
-#ifdef __LP64__
-#define SIZEOF_VOIDP 8
+/* Add any platform that doesn't build using the configure system. */
+#ifdef USING_PREMAKE_CONFIG_H
+#include "SDL_config_premake.h"
+#elif defined(__WIN32__)
+#include "SDL_config_windows.h"
+#elif defined(__WINRT__)
+#include "SDL_config_winrt.h"
+#elif defined(__MACOSX__)
+#include "SDL_config_macosx.h"
+#elif defined(__IPHONEOS__)
+#include "SDL_config_iphoneos.h"
+#elif defined(__ANDROID__)
+#include "SDL_config_android.h"
+#elif defined(__PSP__)
+#include "SDL_config_psp.h"
 #else
 #else
-#define SIZEOF_VOIDP 4
-#endif
-#define HAVE_GCC_ATOMICS 1
-/* #undef HAVE_GCC_SYNC_LOCK_TEST_AND_SET */
-
-/* #undef HAVE_DDRAW_H */
-/* #undef HAVE_DINPUT_H */
-/* #undef HAVE_DSOUND_H */
-/* #undef HAVE_DXGI_H */
-/* #undef HAVE_XINPUT_H */
-
-/* Comment this if you want to build without any C library requirements */
-#define HAVE_LIBC 1
-#if HAVE_LIBC
+/* This is a minimal configuration just to get SDL running on new platforms */
+#include "SDL_config_minimal.h"
+#endif /* platform config */
 
 
-/* Useful headers */
-#define HAVE_ALLOCA_H 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_MALLOC_H 1
-#define HAVE_MEMORY_H 1
-#define HAVE_STRING_H 1
-#define HAVE_STRINGS_H 1
-#define HAVE_INTTYPES_H 1
-#define HAVE_STDINT_H 1
-#define HAVE_CTYPE_H 1
-#define HAVE_MATH_H 1
-#define HAVE_ICONV_H 1
-#define HAVE_SIGNAL_H 1
-/* #undef HAVE_ALTIVEC_H */
-/* #undef HAVE_PTHREAD_NP_H */
-/* #undef HAVE_LIBUDEV_H */
-/* #undef HAVE_DBUS_DBUS_H */
-/* #undef HAVE_IBUS_IBUS_H */
-
-/* C library functions */
-#define HAVE_MALLOC 1
-#define HAVE_CALLOC 1
-#define HAVE_REALLOC 1
-#define HAVE_FREE 1
-#define HAVE_ALLOCA 1
-#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */
-#define HAVE_GETENV 1
-#define HAVE_SETENV 1
-#define HAVE_PUTENV 1
-#define HAVE_UNSETENV 1
+#ifdef USING_GENERATED_CONFIG_H
+#error Wrong SDL_config.h, check your include path?
 #endif
 #endif
-#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_STRLEN 1
-#define HAVE_STRLCPY 1
-#define HAVE_STRLCAT 1
-#define HAVE_STRDUP 1
-/* #undef HAVE__STRREV */
-/* #undef HAVE__STRUPR */
-/* #undef HAVE__STRLWR */
-/* #undef HAVE_INDEX */
-/* #undef HAVE_RINDEX */
-#define HAVE_STRCHR 1
-#define HAVE_STRRCHR 1
-#define HAVE_STRSTR 1
-/* #undef HAVE_ITOA */
-/* #undef HAVE__LTOA */
-/* #undef HAVE__UITOA */
-/* #undef HAVE__ULTOA */
-#define HAVE_STRTOL 1
-#define HAVE_STRTOUL 1
-/* #undef HAVE__I64TOA */
-/* #undef HAVE__UI64TOA */
-#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
-/* #undef HAVE__STRICMP */
-#define HAVE_STRCASECMP 1
-/* #undef HAVE__STRNICMP */
-#define HAVE_STRNCASECMP 1
-/* #undef HAVE_SSCANF */
-#define HAVE_VSSCANF 1
-/* #undef HAVE_SNPRINTF */
-#define HAVE_VSNPRINTF 1
-#define HAVE_M_PI /**/
-#define HAVE_ATAN 1
-#define HAVE_ATAN2 1
-#define HAVE_ACOS 1
-#define HAVE_ASIN 1
-#define HAVE_CEIL 1
-#define HAVE_COPYSIGN 1
-#define HAVE_COS 1
-#define HAVE_COSF 1
-#define HAVE_FABS 1
-#define HAVE_FLOOR 1
-#define HAVE_LOG 1
-#define HAVE_POW 1
-#define HAVE_SCALBN 1
-#define HAVE_SIN 1
-#define HAVE_SINF 1
-#define HAVE_SQRT 1
-#define HAVE_SQRTF 1
-#define HAVE_TAN 1
-#define HAVE_TANF 1
-#define HAVE_FSEEKO 1
-/* #undef HAVE_FSEEKO64 */
-#define HAVE_SIGACTION 1
-#define HAVE_SA_SIGACTION 1
-#define HAVE_SETJMP 1
-#define HAVE_NANOSLEEP 1
-#define HAVE_SYSCONF 1
-#define HAVE_SYSCTLBYNAME 1
-/* #undef HAVE_CLOCK_GETTIME */
-/* #undef HAVE_GETPAGESIZE */
-#define HAVE_MPROTECT 1
-#define HAVE_ICONV 1
-/* #undef HAVE_PTHREAD_SETNAME_NP */
-/* #undef HAVE_PTHREAD_SET_NAME_NP */
-/* #undef HAVE_SEM_TIMEDWAIT */
-
-#else
-#define HAVE_STDARG_H 1
-#define HAVE_STDDEF_H 1
-#define HAVE_STDINT_H 1
-#endif /* HAVE_LIBC */
-
-/* SDL internal assertion support */
-/* #undef SDL_DEFAULT_ASSERT_LEVEL */
-
-/* Allow disabling of core subsystems */
-/* #undef SDL_ATOMIC_DISABLED */
-/* #undef SDL_AUDIO_DISABLED */
-#define SDL_CPUINFO_DISABLED 1
-/* #undef SDL_EVENTS_DISABLED */
-/* #undef SDL_FILE_DISABLED */
-/* #undef SDL_JOYSTICK_DISABLED */
-#define SDL_HAPTIC_DISABLED 1
-/* #undef SDL_LOADSO_DISABLED */
-/* #undef SDL_RENDER_DISABLED */
-#define SDL_THREADS_DISABLED 1
-/* #undef SDL_TIMERS_DISABLED */
-/* #undef SDL_VIDEO_DISABLED */
-/* #undef SDL_POWER_DISABLED */
-/* #undef SDL_FILESYSTEM_DISABLED */
-
-/* Enable various audio drivers */
-/* #undef SDL_AUDIO_DRIVER_ALSA */
-/* #undef SDL_AUDIO_DRIVER_ALSA_DYNAMIC */
-/* #undef SDL_AUDIO_DRIVER_ARTS */
-/* #undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC */
-/* #undef SDL_AUDIO_DRIVER_PULSEAUDIO */
-/* #undef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC */
-/* #undef SDL_AUDIO_DRIVER_HAIKU */
-/* #undef SDL_AUDIO_DRIVER_BSD */
-/* #undef SDL_AUDIO_DRIVER_COREAUDIO */
-#define SDL_AUDIO_DRIVER_DISK 1
-#define SDL_AUDIO_DRIVER_DUMMY 1
-/* #undef SDL_AUDIO_DRIVER_ANDROID */
-/* #undef SDL_AUDIO_DRIVER_XAUDIO2 */
-/* #undef SDL_AUDIO_DRIVER_DSOUND */
-/* #undef SDL_AUDIO_DRIVER_ESD */
-/* #undef SDL_AUDIO_DRIVER_ESD_DYNAMIC */
-/* #undef SDL_AUDIO_DRIVER_NACL */
-/* #undef SDL_AUDIO_DRIVER_NAS */
-/* #undef SDL_AUDIO_DRIVER_NAS_DYNAMIC */
-/* #undef SDL_AUDIO_DRIVER_SNDIO */
-/* #undef SDL_AUDIO_DRIVER_SNDIO_DYNAMIC */
-/* #undef SDL_AUDIO_DRIVER_OSS */
-/* #undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H */
-/* #undef SDL_AUDIO_DRIVER_PAUDIO */
-/* #undef SDL_AUDIO_DRIVER_QSA */
-/* #undef SDL_AUDIO_DRIVER_SUNAUDIO */
-/* #undef SDL_AUDIO_DRIVER_WINMM */
-/* #undef SDL_AUDIO_DRIVER_FUSIONSOUND */
-/* #undef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC */
-#define SDL_AUDIO_DRIVER_EMSCRIPTEN 1
-
-/* Enable various input drivers */
-/* #undef SDL_INPUT_LINUXEV */
-/* #undef SDL_INPUT_LINUXKD */
-/* #undef SDL_INPUT_TSLIB */
-/* #undef SDL_JOYSTICK_HAIKU */
-/* #undef SDL_JOYSTICK_DINPUT */
-/* #undef SDL_JOYSTICK_XINPUT */
-/* #undef SDL_JOYSTICK_DUMMY */
-/* #undef SDL_JOYSTICK_IOKIT */
-/* #undef SDL_JOYSTICK_LINUX */
-/* #undef SDL_JOYSTICK_ANDROID */
-/* #undef SDL_JOYSTICK_WINMM */
-/* #undef SDL_JOYSTICK_USBHID */
-/* #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H */
-#define SDL_JOYSTICK_EMSCRIPTEN 1
-/* #undef SDL_HAPTIC_DUMMY */
-/* #undef SDL_HAPTIC_LINUX */
-/* #undef SDL_HAPTIC_IOKIT */
-/* #undef SDL_HAPTIC_DINPUT */
-/* #undef SDL_HAPTIC_XINPUT */
-
-/* Enable various shared object loading systems */
-/* #undef SDL_LOADSO_HAIKU */
-#define SDL_LOADSO_DLOPEN 1
-/* #undef SDL_LOADSO_DUMMY */
-/* #undef SDL_LOADSO_LDG */
-/* #undef SDL_LOADSO_WINDOWS */
-
-/* Enable various threading systems */
-/* #undef SDL_THREAD_PTHREAD */
-/* #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX */
-/* #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP */
-/* #undef SDL_THREAD_WINDOWS */
-
-/* Enable various timer systems */
-/* #undef SDL_TIMER_HAIKU */
-/* #undef SDL_TIMER_DUMMY */
-#define SDL_TIMER_UNIX 1
-/* #undef SDL_TIMER_WINDOWS */
-
-/* Enable various video drivers */
-/* #undef SDL_VIDEO_DRIVER_HAIKU */
-/* #undef SDL_VIDEO_DRIVER_COCOA */
-/* #undef SDL_VIDEO_DRIVER_DIRECTFB */
-/* #undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC */
-#define SDL_VIDEO_DRIVER_DUMMY 1
-/* #undef SDL_VIDEO_DRIVER_WINDOWS */
-/* #undef SDL_VIDEO_DRIVER_WAYLAND */
-/* #undef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
-/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC */
-/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL */
-/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR */
-/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON */
-/* #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_ANDROID */
-#define SDL_VIDEO_DRIVER_EMSCRIPTEN 1
-/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC */
-/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT */
-/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR */
-/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA */
-/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 */
-/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR */
-/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS */
-/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE */
-/* #undef SDL_VIDEO_DRIVER_X11_XCURSOR */
-/* #undef SDL_VIDEO_DRIVER_X11_XINERAMA */
-/* #undef SDL_VIDEO_DRIVER_X11_XINPUT2 */
-/* #undef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH */
-/* #undef SDL_VIDEO_DRIVER_X11_XRANDR */
-/* #undef SDL_VIDEO_DRIVER_X11_XSCRNSAVER */
-/* #undef SDL_VIDEO_DRIVER_X11_XSHAPE */
-/* #undef SDL_VIDEO_DRIVER_X11_XVIDMODE */
-/* #undef SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS */
-/* #undef SDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32 */
-/* #undef SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY */
-/* #undef SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM */
-/* #undef SDL_VIDEO_DRIVER_NACL */
-/* #undef SDL_VIDEO_DRIVER_VIVANTE */
-/* #undef SDL_VIDEO_DRIVER_VIVANTE_VDK */
-
-/* #undef SDL_VIDEO_RENDER_D3D */
-/* #undef SDL_VIDEO_RENDER_D3D11 */
-/* #undef SDL_VIDEO_RENDER_OGL */
-/* #undef SDL_VIDEO_RENDER_OGL_ES */
-#define SDL_VIDEO_RENDER_OGL_ES2 1
-/* #undef SDL_VIDEO_RENDER_DIRECTFB */
-
-/* Enable OpenGL support */
-/* #undef SDL_VIDEO_OPENGL */
-/* #undef SDL_VIDEO_OPENGL_ES */
-#define SDL_VIDEO_OPENGL_ES2 1
-/* #undef SDL_VIDEO_OPENGL_BGL */
-/* #undef SDL_VIDEO_OPENGL_CGL */
-#define SDL_VIDEO_OPENGL_EGL 1
-/* #undef SDL_VIDEO_OPENGL_GLX */
-/* #undef SDL_VIDEO_OPENGL_WGL */
-/* #undef SDL_VIDEO_OPENGL_OSMESA */
-/* #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC */
-
-/* Enable system power support */
-/* #undef SDL_POWER_LINUX */
-/* #undef SDL_POWER_WINDOWS */
-/* #undef SDL_POWER_MACOSX */
-/* #undef SDL_POWER_HAIKU */
-/* #undef SDL_POWER_ANDROID */
-#define SDL_POWER_EMSCRIPTEN 1
-/* #undef SDL_POWER_HARDWIRED */
-
-/* Enable system filesystem support */
-/* #undef SDL_FILESYSTEM_HAIKU */
-/* #undef SDL_FILESYSTEM_COCOA */
-/* #undef SDL_FILESYSTEM_DUMMY */
-/* #undef SDL_FILESYSTEM_UNIX */
-/* #undef SDL_FILESYSTEM_WINDOWS */
-/* #undef SDL_FILESYSTEM_NACL */
-#define SDL_FILESYSTEM_EMSCRIPTEN 1
-
-/* Enable assembly routines */
-/* #undef SDL_ASSEMBLY_ROUTINES */
-/* #undef SDL_ALTIVEC_BLITTERS */
 
 
 #endif /* _SDL_config_h */
 #endif /* _SDL_config_h */

+ 1 - 1
sdl.mod/include/ios/SDL_config.h

@@ -1,6 +1,6 @@
 /*
 /*
   Simple DirectMedia Layer
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
 
   This software is provided 'as-is', without any express or implied
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
   warranty.  In no event will the authors be held liable for any damages

+ 24 - 303
sdl.mod/include/linuxx64/SDL_config.h

@@ -1,7 +1,6 @@
-/* include/SDL_config.h.  Generated from SDL_config.h.in by configure.  */
 /*
 /*
   Simple DirectMedia Layer
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
 
   This software is provided 'as-is', without any express or implied
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
   warranty.  In no event will the authors be held liable for any damages
@@ -23,312 +22,34 @@
 #ifndef _SDL_config_h
 #ifndef _SDL_config_h
 #define _SDL_config_h
 #define _SDL_config_h
 
 
-/**
- *  \file SDL_config.h.in
- *
- *  This is a set of defines to configure the SDL features
- */
-
-/* General platform specific identifiers */
 #include "SDL_platform.h"
 #include "SDL_platform.h"
 
 
-/* Make sure that this isn't included by Visual C++ */
-#ifdef _MSC_VER
-#error You should run hg revert SDL_config.h 
-#endif
-
-/* C language features */
-/* #undef const */
-/* #undef inline */
-/* #undef volatile */
+/**
+ *  \file SDL_config.h
+ */
 
 
-/* C datatypes */
-#ifdef __LP64__
-#define SIZEOF_VOIDP 8
+/* Add any platform that doesn't build using the configure system. */
+#ifdef USING_PREMAKE_CONFIG_H
+#include "SDL_config_premake.h"
+#elif defined(__WIN32__)
+#include "SDL_config_windows.h"
+#elif defined(__WINRT__)
+#include "SDL_config_winrt.h"
+#elif defined(__MACOSX__)
+#include "SDL_config_macosx.h"
+#elif defined(__IPHONEOS__)
+#include "SDL_config_iphoneos.h"
+#elif defined(__ANDROID__)
+#include "SDL_config_android.h"
+#elif defined(__PSP__)
+#include "SDL_config_psp.h"
 #else
 #else
-#define SIZEOF_VOIDP 4
-#endif
-#define HAVE_GCC_ATOMICS 1
-/* #undef HAVE_GCC_SYNC_LOCK_TEST_AND_SET */
-#define HAVE_PTHREAD_SPINLOCK 1
-
-/* Comment this if you want to build without any C library requirements */
-#define HAVE_LIBC 1
-#if HAVE_LIBC
-
-/* Useful headers */
-#define HAVE_ALLOCA_H 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_MALLOC_H 1
-#define HAVE_MEMORY_H 1
-#define HAVE_STRING_H 1
-#define HAVE_STRINGS_H 1
-#define HAVE_INTTYPES_H 1
-#define HAVE_STDINT_H 1
-#define HAVE_CTYPE_H 1
-#define HAVE_MATH_H 1
-#define HAVE_ICONV_H 1
-#define HAVE_SIGNAL_H 1
-/* #undef HAVE_ALTIVEC_H */
-/* #undef HAVE_PTHREAD_NP_H */
-#define HAVE_LIBUDEV_H 1
-#define HAVE_DBUS_DBUS_H 1
+/* This is a minimal configuration just to get SDL running on new platforms */
+#include "SDL_config_minimal.h"
+#endif /* platform config */
 
 
-/* C library functions */
-#define HAVE_MALLOC 1
-#define HAVE_CALLOC 1
-#define HAVE_REALLOC 1
-#define HAVE_FREE 1
-#define HAVE_ALLOCA 1
-#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */
-#define HAVE_GETENV 1
-#define HAVE_SETENV 1
-#define HAVE_PUTENV 1
-#define HAVE_UNSETENV 1
+#ifdef USING_GENERATED_CONFIG_H
+#error Wrong SDL_config.h, check your include path?
 #endif
 #endif
-#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_STRLEN 1
-/* #undef HAVE_STRLCPY */
-/* #undef HAVE_STRLCAT */
-#define HAVE_STRDUP 1
-/* #undef HAVE__STRREV */
-/* #undef HAVE__STRUPR */
-/* #undef HAVE__STRLWR */
-/* #undef HAVE_INDEX */
-/* #undef HAVE_RINDEX */
-#define HAVE_STRCHR 1
-#define HAVE_STRRCHR 1
-#define HAVE_STRSTR 1
-/* #undef HAVE_ITOA */
-/* #undef HAVE__LTOA */
-/* #undef HAVE__UITOA */
-/* #undef HAVE__ULTOA */
-#define HAVE_STRTOL 1
-#define HAVE_STRTOUL 1
-/* #undef HAVE__I64TOA */
-/* #undef HAVE__UI64TOA */
-#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
-/* #undef HAVE__STRICMP */
-#define HAVE_STRCASECMP 1
-/* #undef HAVE__STRNICMP */
-#define HAVE_STRNCASECMP 1
-/* #undef HAVE_SSCANF */
-#define HAVE_VSSCANF 1
-/* #undef HAVE_SNPRINTF */
-#define HAVE_VSNPRINTF 1
-#define HAVE_M_PI /**/
-#define HAVE_ATAN 1
-#define HAVE_ATAN2 1
-#define HAVE_ACOS 1
-#define HAVE_ASIN 1
-#define HAVE_CEIL 1
-#define HAVE_COPYSIGN 1
-#define HAVE_COS 1
-#define HAVE_COSF 1
-#define HAVE_FABS 1
-#define HAVE_FLOOR 1
-#define HAVE_LOG 1
-#define HAVE_POW 1
-#define HAVE_SCALBN 1
-#define HAVE_SIN 1
-#define HAVE_SINF 1
-#define HAVE_SQRT 1
-#define HAVE_FSEEKO 1
-#define HAVE_FSEEKO64 1
-#define HAVE_SIGACTION 1
-#define HAVE_SA_SIGACTION 1
-#define HAVE_SETJMP 1
-#define HAVE_NANOSLEEP 1
-#define HAVE_SYSCONF 1
-/* #undef HAVE_SYSCTLBYNAME */
-#define HAVE_CLOCK_GETTIME 1
-/* #undef HAVE_GETPAGESIZE */
-#define HAVE_MPROTECT 1
-#define HAVE_ICONV 1
-#define HAVE_PTHREAD_SETNAME_NP 1
-/* #undef HAVE_PTHREAD_SET_NAME_NP */
-#define HAVE_SEM_TIMEDWAIT 1
-
-#else
-#define HAVE_STDARG_H 1
-#define HAVE_STDDEF_H 1
-#define HAVE_STDINT_H 1
-#endif /* HAVE_LIBC */
-
-/* SDL internal assertion support */
-/* #undef SDL_DEFAULT_ASSERT_LEVEL */
-
-/* Allow disabling of core subsystems */
-/* #undef SDL_ATOMIC_DISABLED */
-/* #undef SDL_AUDIO_DISABLED */
-/* #undef SDL_CPUINFO_DISABLED */
-/* #undef SDL_EVENTS_DISABLED */
-/* #undef SDL_FILE_DISABLED */
-/* #undef SDL_JOYSTICK_DISABLED */
-/* #undef SDL_HAPTIC_DISABLED */
-/* #undef SDL_LOADSO_DISABLED */
-/* #undef SDL_RENDER_DISABLED */
-/* #undef SDL_THREADS_DISABLED */
-/* #undef SDL_TIMERS_DISABLED */
-/* #undef SDL_VIDEO_DISABLED */
-/* #undef SDL_POWER_DISABLED */
-/* #undef SDL_FILESYSTEM_DISABLED */
-
-/* Enable various audio drivers */
-#define SDL_AUDIO_DRIVER_ALSA 1
-#define SDL_AUDIO_DRIVER_ALSA_DYNAMIC "libasound.so.2"
-/* #undef SDL_AUDIO_DRIVER_ARTS */
-/* #undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC */
-#define SDL_AUDIO_DRIVER_PULSEAUDIO 1
-#define SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC "libpulse-simple.so.0"
-/* #undef SDL_AUDIO_DRIVER_HAIKU */
-/* #undef SDL_AUDIO_DRIVER_BSD */
-/* #undef SDL_AUDIO_DRIVER_COREAUDIO */
-#define SDL_AUDIO_DRIVER_DISK 1
-#define SDL_AUDIO_DRIVER_DUMMY 1
-/* #undef SDL_AUDIO_DRIVER_XAUDIO2 */
-/* #undef SDL_AUDIO_DRIVER_DSOUND */
-/* #undef SDL_AUDIO_DRIVER_ESD */
-/* #undef SDL_AUDIO_DRIVER_ESD_DYNAMIC */
-/* #undef SDL_AUDIO_DRIVER_NAS */
-/* #undef SDL_AUDIO_DRIVER_NAS_DYNAMIC */
-/* #undef SDL_AUDIO_DRIVER_SNDIO */
-/* #undef SDL_AUDIO_DRIVER_SNDIO_DYNAMIC */
-#define SDL_AUDIO_DRIVER_OSS 1
-/* #undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H */
-/* #undef SDL_AUDIO_DRIVER_PAUDIO */
-/* #undef SDL_AUDIO_DRIVER_QSA */
-/* #undef SDL_AUDIO_DRIVER_SUNAUDIO */
-/* #undef SDL_AUDIO_DRIVER_WINMM */
-/* #undef SDL_AUDIO_DRIVER_FUSIONSOUND */
-/* #undef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC */
-
-/* Enable various input drivers */
-#define SDL_INPUT_LINUXEV 1
-#define SDL_INPUT_LINUXKD 1
-/* #undef SDL_INPUT_TSLIB */
-/* #undef SDL_JOYSTICK_HAIKU */
-/* #undef SDL_JOYSTICK_DINPUT */
-/* #undef SDL_JOYSTICK_DUMMY */
-/* #undef SDL_JOYSTICK_IOKIT */
-#define SDL_JOYSTICK_LINUX 1
-/* #undef SDL_JOYSTICK_WINMM */
-/* #undef SDL_JOYSTICK_USBHID */
-/* #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H */
-/* #undef SDL_HAPTIC_DUMMY */
-#define SDL_HAPTIC_LINUX 1
-/* #undef SDL_HAPTIC_IOKIT */
-/* #undef SDL_HAPTIC_DINPUT */
-
-/* Enable various shared object loading systems */
-/* #undef SDL_LOADSO_HAIKU */
-#define SDL_LOADSO_DLOPEN 1
-/* #undef SDL_LOADSO_DUMMY */
-/* #undef SDL_LOADSO_LDG */
-/* #undef SDL_LOADSO_WINDOWS */
-
-/* Enable various threading systems */
-#define SDL_THREAD_PTHREAD 1
-#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
-/* #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP */
-/* #undef SDL_THREAD_WINDOWS */
-
-/* Enable various timer systems */
-/* #undef SDL_TIMER_HAIKU */
-/* #undef SDL_TIMER_DUMMY */
-#define SDL_TIMER_UNIX 1
-/* #undef SDL_TIMER_WINDOWS */
-
-/* Enable various video drivers */
-/* #undef SDL_VIDEO_DRIVER_HAIKU */
-/* #undef SDL_VIDEO_DRIVER_COCOA */
-/* #undef SDL_VIDEO_DRIVER_DIRECTFB */
-/* #undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC */
-#define SDL_VIDEO_DRIVER_DUMMY 1
-/* #undef SDL_VIDEO_DRIVER_WINDOWS */
-/* #undef SDL_VIDEO_DRIVER_WAYLAND */
-/* #undef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
-/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC */
-/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL */
-/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR */
-/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON */
-/* #undef SDL_VIDEO_DRIVER_MIR */
-/* #undef SDL_VIDEO_DRIVER_MIR_DYNAMIC */
-/* #undef SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON */
-#define SDL_VIDEO_DRIVER_X11 1
-/* #undef SDL_VIDEO_DRIVER_RPI */
-#define SDL_VIDEO_DRIVER_X11_DYNAMIC "libX11.so.6"
-#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "libXext.so.6"
-#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR "libXcursor.so.1"
-#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "libXinerama.so.1"
-#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "libXi.so.6"
-#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "libXrandr.so.2"
-/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS */
-#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "libXxf86vm.so.1"
-#define SDL_VIDEO_DRIVER_X11_XCURSOR 1
-#define SDL_VIDEO_DRIVER_X11_XINERAMA 1
-#define SDL_VIDEO_DRIVER_X11_XINPUT2 1
-#define SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH 1
-#define SDL_VIDEO_DRIVER_X11_XRANDR 1
-/* #undef SDL_VIDEO_DRIVER_X11_XSCRNSAVER */
-#define SDL_VIDEO_DRIVER_X11_XSHAPE 1
-#define SDL_VIDEO_DRIVER_X11_XVIDMODE 1
-#define SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1
-#define SDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32 1
-#define SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY 1
-#define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1
-
-/* #undef SDL_VIDEO_RENDER_D3D */
-/* #undef SDL_VIDEO_RENDER_D3D11 */
-#define SDL_VIDEO_RENDER_OGL 1
-/* #undef SDL_VIDEO_RENDER_OGL_ES */
-/* #undef SDL_VIDEO_RENDER_OGL_ES2 */
-/* #undef SDL_VIDEO_RENDER_DIRECTFB */
-
-/* Enable OpenGL support */
-#define SDL_VIDEO_OPENGL 1
-/* #undef SDL_VIDEO_OPENGL_ES */
-/* #undef SDL_VIDEO_OPENGL_ES2 */
-/* #undef SDL_VIDEO_OPENGL_BGL */
-/* #undef SDL_VIDEO_OPENGL_CGL */
-/* #undef SDL_VIDEO_OPENGL_EGL */
-#define SDL_VIDEO_OPENGL_GLX 1
-/* #undef SDL_VIDEO_OPENGL_WGL */
-/* #undef SDL_VIDEO_OPENGL_OSMESA */
-/* #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC */
-
-/* Enable system power support */
-#define SDL_POWER_LINUX 1
-/* #undef SDL_POWER_WINDOWS */
-/* #undef SDL_POWER_MACOSX */
-/* #undef SDL_POWER_HAIKU */
-/* #undef SDL_POWER_HARDWIRED */
-
-/* Enable system filesystem support */
-/* #undef SDL_FILESYSTEM_HAIKU */
-/* #undef SDL_FILESYSTEM_COCOA */
-/* #undef SDL_FILESYSTEM_DUMMY */
-#define SDL_FILESYSTEM_UNIX 1
-/* #undef SDL_FILESYSTEM_WINDOWS */
-
-/* Enable assembly routines */
-#define SDL_ASSEMBLY_ROUTINES 1
-/* #undef SDL_ALTIVEC_BLITTERS */
 
 
 #endif /* _SDL_config_h */
 #endif /* _SDL_config_h */

+ 24 - 303
sdl.mod/include/linuxx86/SDL_config.h

@@ -1,7 +1,6 @@
-/* include/SDL_config.h.  Generated from SDL_config.h.in by configure.  */
 /*
 /*
   Simple DirectMedia Layer
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
 
   This software is provided 'as-is', without any express or implied
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
   warranty.  In no event will the authors be held liable for any damages
@@ -23,312 +22,34 @@
 #ifndef _SDL_config_h
 #ifndef _SDL_config_h
 #define _SDL_config_h
 #define _SDL_config_h
 
 
-/**
- *  \file SDL_config.h.in
- *
- *  This is a set of defines to configure the SDL features
- */
-
-/* General platform specific identifiers */
 #include "SDL_platform.h"
 #include "SDL_platform.h"
 
 
-/* Make sure that this isn't included by Visual C++ */
-#ifdef _MSC_VER
-#error You should run hg revert SDL_config.h 
-#endif
-
-/* C language features */
-/* #undef const */
-/* #undef inline */
-/* #undef volatile */
+/**
+ *  \file SDL_config.h
+ */
 
 
-/* C datatypes */
-#ifdef __LP64__
-#define SIZEOF_VOIDP 8
+/* Add any platform that doesn't build using the configure system. */
+#ifdef USING_PREMAKE_CONFIG_H
+#include "SDL_config_premake.h"
+#elif defined(__WIN32__)
+#include "SDL_config_windows.h"
+#elif defined(__WINRT__)
+#include "SDL_config_winrt.h"
+#elif defined(__MACOSX__)
+#include "SDL_config_macosx.h"
+#elif defined(__IPHONEOS__)
+#include "SDL_config_iphoneos.h"
+#elif defined(__ANDROID__)
+#include "SDL_config_android.h"
+#elif defined(__PSP__)
+#include "SDL_config_psp.h"
 #else
 #else
-#define SIZEOF_VOIDP 4
-#endif
-#define HAVE_GCC_ATOMICS 1
-/* #undef HAVE_GCC_SYNC_LOCK_TEST_AND_SET */
-#define HAVE_PTHREAD_SPINLOCK 1
-
-/* Comment this if you want to build without any C library requirements */
-#define HAVE_LIBC 1
-#if HAVE_LIBC
-
-/* Useful headers */
-#define HAVE_ALLOCA_H 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_MALLOC_H 1
-#define HAVE_MEMORY_H 1
-#define HAVE_STRING_H 1
-#define HAVE_STRINGS_H 1
-#define HAVE_INTTYPES_H 1
-#define HAVE_STDINT_H 1
-#define HAVE_CTYPE_H 1
-#define HAVE_MATH_H 1
-#define HAVE_ICONV_H 1
-#define HAVE_SIGNAL_H 1
-/* #undef HAVE_ALTIVEC_H */
-/* #undef HAVE_PTHREAD_NP_H */
-#define HAVE_LIBUDEV_H 1
-#define HAVE_DBUS_DBUS_H 1
+/* This is a minimal configuration just to get SDL running on new platforms */
+#include "SDL_config_minimal.h"
+#endif /* platform config */
 
 
-/* C library functions */
-#define HAVE_MALLOC 1
-#define HAVE_CALLOC 1
-#define HAVE_REALLOC 1
-#define HAVE_FREE 1
-#define HAVE_ALLOCA 1
-#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */
-#define HAVE_GETENV 1
-#define HAVE_SETENV 1
-#define HAVE_PUTENV 1
-#define HAVE_UNSETENV 1
+#ifdef USING_GENERATED_CONFIG_H
+#error Wrong SDL_config.h, check your include path?
 #endif
 #endif
-#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_STRLEN 1
-/* #undef HAVE_STRLCPY */
-/* #undef HAVE_STRLCAT */
-#define HAVE_STRDUP 1
-/* #undef HAVE__STRREV */
-/* #undef HAVE__STRUPR */
-/* #undef HAVE__STRLWR */
-/* #undef HAVE_INDEX */
-/* #undef HAVE_RINDEX */
-#define HAVE_STRCHR 1
-#define HAVE_STRRCHR 1
-#define HAVE_STRSTR 1
-/* #undef HAVE_ITOA */
-/* #undef HAVE__LTOA */
-/* #undef HAVE__UITOA */
-/* #undef HAVE__ULTOA */
-#define HAVE_STRTOL 1
-#define HAVE_STRTOUL 1
-/* #undef HAVE__I64TOA */
-/* #undef HAVE__UI64TOA */
-#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
-/* #undef HAVE__STRICMP */
-#define HAVE_STRCASECMP 1
-/* #undef HAVE__STRNICMP */
-#define HAVE_STRNCASECMP 1
-/* #undef HAVE_SSCANF */
-#define HAVE_VSSCANF 1
-/* #undef HAVE_SNPRINTF */
-#define HAVE_VSNPRINTF 1
-#define HAVE_M_PI /**/
-#define HAVE_ATAN 1
-#define HAVE_ATAN2 1
-#define HAVE_ACOS 1
-#define HAVE_ASIN 1
-#define HAVE_CEIL 1
-#define HAVE_COPYSIGN 1
-#define HAVE_COS 1
-#define HAVE_COSF 1
-#define HAVE_FABS 1
-#define HAVE_FLOOR 1
-#define HAVE_LOG 1
-#define HAVE_POW 1
-#define HAVE_SCALBN 1
-#define HAVE_SIN 1
-#define HAVE_SINF 1
-#define HAVE_SQRT 1
-#define HAVE_FSEEKO 1
-#define HAVE_FSEEKO64 1
-#define HAVE_SIGACTION 1
-#define HAVE_SA_SIGACTION 1
-#define HAVE_SETJMP 1
-#define HAVE_NANOSLEEP 1
-#define HAVE_SYSCONF 1
-/* #undef HAVE_SYSCTLBYNAME */
-#define HAVE_CLOCK_GETTIME 1
-/* #undef HAVE_GETPAGESIZE */
-#define HAVE_MPROTECT 1
-#define HAVE_ICONV 1
-#define HAVE_PTHREAD_SETNAME_NP 1
-/* #undef HAVE_PTHREAD_SET_NAME_NP */
-#define HAVE_SEM_TIMEDWAIT 1
-
-#else
-#define HAVE_STDARG_H 1
-#define HAVE_STDDEF_H 1
-#define HAVE_STDINT_H 1
-#endif /* HAVE_LIBC */
-
-/* SDL internal assertion support */
-/* #undef SDL_DEFAULT_ASSERT_LEVEL */
-
-/* Allow disabling of core subsystems */
-/* #undef SDL_ATOMIC_DISABLED */
-/* #undef SDL_AUDIO_DISABLED */
-/* #undef SDL_CPUINFO_DISABLED */
-/* #undef SDL_EVENTS_DISABLED */
-/* #undef SDL_FILE_DISABLED */
-/* #undef SDL_JOYSTICK_DISABLED */
-/* #undef SDL_HAPTIC_DISABLED */
-/* #undef SDL_LOADSO_DISABLED */
-/* #undef SDL_RENDER_DISABLED */
-/* #undef SDL_THREADS_DISABLED */
-/* #undef SDL_TIMERS_DISABLED */
-/* #undef SDL_VIDEO_DISABLED */
-/* #undef SDL_POWER_DISABLED */
-/* #undef SDL_FILESYSTEM_DISABLED */
-
-/* Enable various audio drivers */
-#define SDL_AUDIO_DRIVER_ALSA 1
-#define SDL_AUDIO_DRIVER_ALSA_DYNAMIC "libasound.so.2"
-/* #undef SDL_AUDIO_DRIVER_ARTS */
-/* #undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC */
-#define SDL_AUDIO_DRIVER_PULSEAUDIO 1
-#define SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC "libpulse-simple.so.0"
-/* #undef SDL_AUDIO_DRIVER_HAIKU */
-/* #undef SDL_AUDIO_DRIVER_BSD */
-/* #undef SDL_AUDIO_DRIVER_COREAUDIO */
-#define SDL_AUDIO_DRIVER_DISK 1
-#define SDL_AUDIO_DRIVER_DUMMY 1
-/* #undef SDL_AUDIO_DRIVER_XAUDIO2 */
-/* #undef SDL_AUDIO_DRIVER_DSOUND */
-/* #undef SDL_AUDIO_DRIVER_ESD */
-/* #undef SDL_AUDIO_DRIVER_ESD_DYNAMIC */
-/* #undef SDL_AUDIO_DRIVER_NAS */
-/* #undef SDL_AUDIO_DRIVER_NAS_DYNAMIC */
-/* #undef SDL_AUDIO_DRIVER_SNDIO */
-/* #undef SDL_AUDIO_DRIVER_SNDIO_DYNAMIC */
-#define SDL_AUDIO_DRIVER_OSS 1
-/* #undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H */
-/* #undef SDL_AUDIO_DRIVER_PAUDIO */
-/* #undef SDL_AUDIO_DRIVER_QSA */
-/* #undef SDL_AUDIO_DRIVER_SUNAUDIO */
-/* #undef SDL_AUDIO_DRIVER_WINMM */
-/* #undef SDL_AUDIO_DRIVER_FUSIONSOUND */
-/* #undef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC */
-
-/* Enable various input drivers */
-#define SDL_INPUT_LINUXEV 1
-#define SDL_INPUT_LINUXKD 1
-/* #undef SDL_INPUT_TSLIB */
-/* #undef SDL_JOYSTICK_HAIKU */
-/* #undef SDL_JOYSTICK_DINPUT */
-/* #undef SDL_JOYSTICK_DUMMY */
-/* #undef SDL_JOYSTICK_IOKIT */
-#define SDL_JOYSTICK_LINUX 1
-/* #undef SDL_JOYSTICK_WINMM */
-/* #undef SDL_JOYSTICK_USBHID */
-/* #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H */
-/* #undef SDL_HAPTIC_DUMMY */
-#define SDL_HAPTIC_LINUX 1
-/* #undef SDL_HAPTIC_IOKIT */
-/* #undef SDL_HAPTIC_DINPUT */
-
-/* Enable various shared object loading systems */
-/* #undef SDL_LOADSO_HAIKU */
-#define SDL_LOADSO_DLOPEN 1
-/* #undef SDL_LOADSO_DUMMY */
-/* #undef SDL_LOADSO_LDG */
-/* #undef SDL_LOADSO_WINDOWS */
-
-/* Enable various threading systems */
-#define SDL_THREAD_PTHREAD 1
-#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
-/* #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP */
-/* #undef SDL_THREAD_WINDOWS */
-
-/* Enable various timer systems */
-/* #undef SDL_TIMER_HAIKU */
-/* #undef SDL_TIMER_DUMMY */
-#define SDL_TIMER_UNIX 1
-/* #undef SDL_TIMER_WINDOWS */
-
-/* Enable various video drivers */
-/* #undef SDL_VIDEO_DRIVER_HAIKU */
-/* #undef SDL_VIDEO_DRIVER_COCOA */
-/* #undef SDL_VIDEO_DRIVER_DIRECTFB */
-/* #undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC */
-#define SDL_VIDEO_DRIVER_DUMMY 1
-/* #undef SDL_VIDEO_DRIVER_WINDOWS */
-/* #undef SDL_VIDEO_DRIVER_WAYLAND */
-/* #undef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
-/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC */
-/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL */
-/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR */
-/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON */
-/* #undef SDL_VIDEO_DRIVER_MIR */
-/* #undef SDL_VIDEO_DRIVER_MIR_DYNAMIC */
-/* #undef SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON */
-#define SDL_VIDEO_DRIVER_X11 1
-/* #undef SDL_VIDEO_DRIVER_RPI */
-#define SDL_VIDEO_DRIVER_X11_DYNAMIC "libX11.so.6"
-#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "libXext.so.6"
-#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR "libXcursor.so.1"
-#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "libXinerama.so.1"
-#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "libXi.so.6"
-#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "libXrandr.so.2"
-/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS */
-#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "libXxf86vm.so.1"
-#define SDL_VIDEO_DRIVER_X11_XCURSOR 1
-#define SDL_VIDEO_DRIVER_X11_XINERAMA 1
-#define SDL_VIDEO_DRIVER_X11_XINPUT2 1
-#define SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH 1
-#define SDL_VIDEO_DRIVER_X11_XRANDR 1
-/* #undef SDL_VIDEO_DRIVER_X11_XSCRNSAVER */
-#define SDL_VIDEO_DRIVER_X11_XSHAPE 1
-#define SDL_VIDEO_DRIVER_X11_XVIDMODE 1
-#define SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1
-#define SDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32 1
-#define SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY 1
-#define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1
-
-/* #undef SDL_VIDEO_RENDER_D3D */
-/* #undef SDL_VIDEO_RENDER_D3D11 */
-#define SDL_VIDEO_RENDER_OGL 1
-/* #undef SDL_VIDEO_RENDER_OGL_ES */
-/* #undef SDL_VIDEO_RENDER_OGL_ES2 */
-/* #undef SDL_VIDEO_RENDER_DIRECTFB */
-
-/* Enable OpenGL support */
-#define SDL_VIDEO_OPENGL 1
-/* #undef SDL_VIDEO_OPENGL_ES */
-/* #undef SDL_VIDEO_OPENGL_ES2 */
-/* #undef SDL_VIDEO_OPENGL_BGL */
-/* #undef SDL_VIDEO_OPENGL_CGL */
-/* #undef SDL_VIDEO_OPENGL_EGL */
-#define SDL_VIDEO_OPENGL_GLX 1
-/* #undef SDL_VIDEO_OPENGL_WGL */
-/* #undef SDL_VIDEO_OPENGL_OSMESA */
-/* #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC */
-
-/* Enable system power support */
-#define SDL_POWER_LINUX 1
-/* #undef SDL_POWER_WINDOWS */
-/* #undef SDL_POWER_MACOSX */
-/* #undef SDL_POWER_HAIKU */
-/* #undef SDL_POWER_HARDWIRED */
-
-/* Enable system filesystem support */
-/* #undef SDL_FILESYSTEM_HAIKU */
-/* #undef SDL_FILESYSTEM_COCOA */
-/* #undef SDL_FILESYSTEM_DUMMY */
-#define SDL_FILESYSTEM_UNIX 1
-/* #undef SDL_FILESYSTEM_WINDOWS */
-
-/* Enable assembly routines */
-#define SDL_ASSEMBLY_ROUTINES 1
-/* #undef SDL_ALTIVEC_BLITTERS */
 
 
 #endif /* _SDL_config_h */
 #endif /* _SDL_config_h */

+ 1 - 1
sdl.mod/include/macos/SDL_config.h

@@ -1,6 +1,6 @@
 /*
 /*
   Simple DirectMedia Layer
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
 
   This software is provided 'as-is', without any express or implied
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
   warranty.  In no event will the authors be held liable for any damages