Added initial support for MFi game controllers on iOS.
authorAlex Szpakowski <slime73@gmail.com>
Sun, 20 Sep 2015 23:08:36 -0300
changeset 9876 1496e502e51d
parent 9875 620024536f80
child 9877 e6fa7403893b
Added initial support for MFi game controllers on iOS.
WhatsNew.txt
Xcode-iOS/Demos/Demos.xcodeproj/project.pbxproj
Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
Xcode-iOS/Template/SDL iOS Application/___PROJECTNAME___.xcodeproj/project.pbxproj
Xcode-iOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj
configure
include/SDL_config.h.cmake
include/SDL_config_iphoneos.h
premake/README-ios.txt
premake/Xcode-iOS/Demos/happy/happy.xcodeproj/project.pbxproj
premake/projects/SDL2.lua
src/joystick/SDL_gamecontrollerdb.h
src/joystick/SDL_joystick.c
src/joystick/iphoneos/SDL_sysjoystick.m
src/joystick/iphoneos/SDL_sysjoystick_c.h
test/testgamecontroller.c
test/testjoystick.c
--- a/WhatsNew.txt	Fri Sep 18 16:22:23 2015 -0400
+++ b/WhatsNew.txt	Sun Sep 20 23:08:36 2015 -0300
@@ -67,6 +67,7 @@
 
 iOS:
 * Added support for iOS 8
+* Added support for MFi game controllers
 * Added support for the hint SDL_HINT_ACCELEROMETER_AS_JOYSTICK
 * Added sRGB OpenGL ES context support on iOS 7+
 * Added native resolution support for the iPhone 6 Plus
--- a/Xcode-iOS/Demos/Demos.xcodeproj/project.pbxproj	Fri Sep 18 16:22:23 2015 -0400
+++ b/Xcode-iOS/Demos/Demos.xcodeproj/project.pbxproj	Sun Sep 20 23:08:36 2015 -0300
@@ -17,6 +17,13 @@
 		FA8B4BA71967072800F8EB7C /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA8B4BA21967070A00F8EB7C /* CoreMotion.framework */; };
 		FA8B4BA81967073400F8EB7C /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA8B4BA21967070A00F8EB7C /* CoreMotion.framework */; };
 		FA8B4BA91967073D00F8EB7C /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA8B4BA21967070A00F8EB7C /* CoreMotion.framework */; };
+		FAE0E96A1BAF96A00098DFA4 /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAE0E9691BAF96A00098DFA4 /* GameController.framework */; };
+		FAE0E96C1BAF96A90098DFA4 /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAE0E9691BAF96A00098DFA4 /* GameController.framework */; };
+		FAE0E96D1BAF96AF0098DFA4 /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAE0E9691BAF96A00098DFA4 /* GameController.framework */; };
+		FAE0E96E1BAF96B10098DFA4 /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAE0E9691BAF96A00098DFA4 /* GameController.framework */; };
+		FAE0E96F1BAF96B50098DFA4 /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAE0E9691BAF96A00098DFA4 /* GameController.framework */; };
+		FAE0E9701BAF96B80098DFA4 /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAE0E9691BAF96A00098DFA4 /* GameController.framework */; };
+		FAE0E9711BAF96BB0098DFA4 /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAE0E9691BAF96A00098DFA4 /* GameController.framework */; };
 		FD15FD690E086911003BDF25 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
 		FD15FD6A0E086911003BDF25 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
 		FD15FD6B0E086911003BDF25 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D3623EB0D0F72F000981E51 /* CoreGraphics.framework */; };
@@ -177,6 +184,7 @@
 		1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
 		8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
 		FA8B4BA21967070A00F8EB7C /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = System/Library/Frameworks/CoreMotion.framework; sourceTree = SDKROOT; };
+		FAE0E9691BAF96A00098DFA4 /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = System/Library/Frameworks/GameController.framework; sourceTree = SDKROOT; };
 		FD15FCB20E086866003BDF25 /* Happy.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Happy.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		FD1B48920E313154007AB34E /* SDL.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SDL.xcodeproj; path = ../SDL/SDL.xcodeproj; sourceTree = SOURCE_ROOT; };
 		FD5F9BE40E0DEBEA008E885B /* Accel.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Accel.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -217,6 +225,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				FD1B48DD0E313255007AB34E /* libSDL2.a in Frameworks */,
+				FAE0E96A1BAF96A00098DFA4 /* GameController.framework in Frameworks */,
 				FA8B4BA31967070A00F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDF0D7AB0E12D53800247964 /* CoreAudio.framework in Frameworks */,
 				FDF0D7AC0E12D53800247964 /* AudioToolbox.framework in Frameworks */,
@@ -233,6 +242,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				FD1B49980E313261007AB34E /* libSDL2.a in Frameworks */,
+				FAE0E96C1BAF96A90098DFA4 /* GameController.framework in Frameworks */,
 				FA8B4BA41967071300F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDF0D7A90E12D53500247964 /* CoreAudio.framework in Frameworks */,
 				FDF0D7AA0E12D53500247964 /* AudioToolbox.framework in Frameworks */,
@@ -249,6 +259,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				FD1B499C0E313269007AB34E /* libSDL2.a in Frameworks */,
+				FAE0E96D1BAF96AF0098DFA4 /* GameController.framework in Frameworks */,
 				FA8B4BA51967071A00F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDF0D7A70E12D53200247964 /* CoreAudio.framework in Frameworks */,
 				FDF0D7A80E12D53200247964 /* AudioToolbox.framework in Frameworks */,
@@ -265,6 +276,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				FDB652000E43D1F300F688B5 /* libSDL2.a in Frameworks */,
+				FAE0E9711BAF96BB0098DFA4 /* GameController.framework in Frameworks */,
 				FA8B4BA91967073D00F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDB652020E43D1F300F688B5 /* Foundation.framework in Frameworks */,
 				FDB652030E43D1F300F688B5 /* UIKit.framework in Frameworks */,
@@ -281,6 +293,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				FD1B499E0E31326C007AB34E /* libSDL2.a in Frameworks */,
+				FAE0E96E1BAF96B10098DFA4 /* GameController.framework in Frameworks */,
 				FA8B4BA61967072100F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDF0D7950E12D52900247964 /* CoreAudio.framework in Frameworks */,
 				FDF0D7960E12D52900247964 /* AudioToolbox.framework in Frameworks */,
@@ -297,6 +310,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				FD1B49A20E313273007AB34E /* libSDL2.a in Frameworks */,
+				FAE0E9701BAF96B80098DFA4 /* GameController.framework in Frameworks */,
 				FA8B4BA81967073400F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDC52ED40E2843D6008D768C /* Foundation.framework in Frameworks */,
 				FDC52ED50E2843D6008D768C /* UIKit.framework in Frameworks */,
@@ -313,6 +327,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				FD1B49A00E313270007AB34E /* libSDL2.a in Frameworks */,
+				FAE0E96F1BAF96B50098DFA4 /* GameController.framework in Frameworks */,
 				FA8B4BA71967072800F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDF0D69C0E12D05400247964 /* Foundation.framework in Frameworks */,
 				FDF0D69D0E12D05400247964 /* UIKit.framework in Frameworks */,
@@ -367,6 +382,7 @@
 		29B97323FDCFA39411CA2CEA /* Frameworks */ = {
 			isa = PBXGroup;
 			children = (
+				FAE0E9691BAF96A00098DFA4 /* GameController.framework */,
 				FA8B4BA21967070A00F8EB7C /* CoreMotion.framework */,
 				FDF0D7220E12D31800247964 /* AudioToolbox.framework */,
 				FDB96EDF0DEFC9DC00FAF19F /* QuartzCore.framework */,
--- a/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj	Fri Sep 18 16:22:23 2015 -0400
+++ b/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj	Sun Sep 20 23:08:36 2015 -0300
@@ -143,6 +143,7 @@
 		AABCC3941640643D00AB8930 /* SDL_uikitmessagebox.h in Headers */ = {isa = PBXBuildFile; fileRef = AABCC3921640643D00AB8930 /* SDL_uikitmessagebox.h */; };
 		AABCC3951640643D00AB8930 /* SDL_uikitmessagebox.m in Sources */ = {isa = PBXBuildFile; fileRef = AABCC3931640643D00AB8930 /* SDL_uikitmessagebox.m */; };
 		AADA5B8F16CCAB7C00107CF7 /* SDL_bits.h in Headers */ = {isa = PBXBuildFile; fileRef = AADA5B8E16CCAB7C00107CF7 /* SDL_bits.h */; };
+		FAD4F7021BA3C4E8008346CE /* SDL_sysjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = FAD4F7011BA3C4E8008346CE /* SDL_sysjoystick_c.h */; settings = {ASSET_TAGS = (); }; };
 		FD3F4A760DEA620800C5B771 /* SDL_getenv.c in Sources */ = {isa = PBXBuildFile; fileRef = FD3F4A700DEA620800C5B771 /* SDL_getenv.c */; };
 		FD3F4A770DEA620800C5B771 /* SDL_iconv.c in Sources */ = {isa = PBXBuildFile; fileRef = FD3F4A710DEA620800C5B771 /* SDL_iconv.c */; };
 		FD3F4A780DEA620800C5B771 /* SDL_malloc.c in Sources */ = {isa = PBXBuildFile; fileRef = FD3F4A720DEA620800C5B771 /* SDL_malloc.c */; };
@@ -339,6 +340,7 @@
 		AABCC3921640643D00AB8930 /* SDL_uikitmessagebox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_uikitmessagebox.h; sourceTree = "<group>"; };
 		AABCC3931640643D00AB8930 /* SDL_uikitmessagebox.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_uikitmessagebox.m; sourceTree = "<group>"; };
 		AADA5B8E16CCAB7C00107CF7 /* SDL_bits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_bits.h; sourceTree = "<group>"; };
+		FAD4F7011BA3C4E8008346CE /* SDL_sysjoystick_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_sysjoystick_c.h; sourceTree = "<group>"; };
 		FD0BBFEF0E3933DD00D833B1 /* SDL_uikitview.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_uikitview.h; sourceTree = "<group>"; };
 		FD3F4A700DEA620800C5B771 /* SDL_getenv.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_getenv.c; sourceTree = "<group>"; };
 		FD3F4A710DEA620800C5B771 /* SDL_iconv.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_iconv.c; sourceTree = "<group>"; };
@@ -634,6 +636,7 @@
 		FD689EFF0E26E5B600F90B21 /* iphoneos */ = {
 			isa = PBXGroup;
 			children = (
+				FAD4F7011BA3C4E8008346CE /* SDL_sysjoystick_c.h */,
 				FD689F000E26E5B600F90B21 /* SDL_sysjoystick.m */,
 			);
 			path = iphoneos;
@@ -1037,6 +1040,7 @@
 				AA7558BE1595D55500BBD41B /* SDL_scancode.h in Headers */,
 				AA7558BF1595D55500BBD41B /* SDL_shape.h in Headers */,
 				AA7558C01595D55500BBD41B /* SDL_stdinc.h in Headers */,
+				FAD4F7021BA3C4E8008346CE /* SDL_sysjoystick_c.h in Headers */,
 				AA7558C11595D55500BBD41B /* SDL_surface.h in Headers */,
 				AA7558C21595D55500BBD41B /* SDL_system.h in Headers */,
 				AA7558C31595D55500BBD41B /* SDL_syswm.h in Headers */,
@@ -1282,7 +1286,6 @@
 				GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = YES;
 				GCC_WARN_STRICT_SELECTOR_MATCH = YES;
 				GCC_WARN_UNDECLARED_SELECTOR = YES;
-				IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
 				PRODUCT_NAME = SDL2;
 				SKIP_INSTALL = YES;
 			};
@@ -1298,7 +1301,6 @@
 				GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = YES;
 				GCC_WARN_STRICT_SELECTOR_MATCH = YES;
 				GCC_WARN_UNDECLARED_SELECTOR = YES;
-				IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
 				PRODUCT_NAME = SDL2;
 				SKIP_INSTALL = YES;
 			};
--- a/Xcode-iOS/Template/SDL iOS Application/___PROJECTNAME___.xcodeproj/project.pbxproj	Fri Sep 18 16:22:23 2015 -0400
+++ b/Xcode-iOS/Template/SDL iOS Application/___PROJECTNAME___.xcodeproj/project.pbxproj	Sun Sep 20 23:08:36 2015 -0300
@@ -14,6 +14,7 @@
 		944A656F195747D90094A81E /* libSDL2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 944A656E1957463F0094A81E /* libSDL2.a */; };
 		945C4F53195AF17F00DBBF61 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 945C4F52195AF17F00DBBF61 /* Default-568h@2x.png */; };
 		FA8B4B97196703B400F8EB7C /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA8B4B96196703B400F8EB7C /* CoreMotion.framework */; };
+		FAE0E9651BAF967F0098DFA4 /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAE0E9641BAF967F0098DFA4 /* GameController.framework */; };
 		FD779EDE0E26BA1200F39101 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FD779EDD0E26BA1200F39101 /* CoreAudio.framework */; };
 		FD77A07D0E26BD8C00F39101 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = FD77A07C0E26BD8C00F39101 /* Icon.png */; };
 		FD77A07F0E26BDA900F39101 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = FD77A07E0E26BDA900F39101 /* Default.png */; };
@@ -42,6 +43,7 @@
 		944A65681957463F0094A81E /* SDL.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SDL.xcodeproj; path = ../../SDL/SDL.xcodeproj; sourceTree = "<group>"; };
 		945C4F52195AF17F00DBBF61 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = "<group>"; };
 		FA8B4B96196703B400F8EB7C /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = System/Library/Frameworks/CoreMotion.framework; sourceTree = SDKROOT; };
+		FAE0E9641BAF967F0098DFA4 /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = System/Library/Frameworks/GameController.framework; sourceTree = SDKROOT; };
 		FD779EDD0E26BA1200F39101 /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = System/Library/Frameworks/CoreAudio.framework; sourceTree = SDKROOT; };
 		FD77A07C0E26BD8C00F39101 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = "<group>"; };
 		FD77A07E0E26BDA900F39101 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = "<group>"; };
@@ -56,6 +58,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				944A656F195747D90094A81E /* libSDL2.a in Frameworks */,
+				FAE0E9651BAF967F0098DFA4 /* GameController.framework in Frameworks */,
 				1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */,
 				1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */,
 				28FD15000DC6FC520079059D /* OpenGLES.framework in Frameworks */,
@@ -112,6 +115,7 @@
 		29B97323FDCFA39411CA2CEA /* Frameworks */ = {
 			isa = PBXGroup;
 			children = (
+				FAE0E9641BAF967F0098DFA4 /* GameController.framework */,
 				FA8B4B96196703B400F8EB7C /* CoreMotion.framework */,
 				FDB8BFC50E5A0F6A00980157 /* CoreGraphics.framework */,
 				FD77A0840E26BDB800F39101 /* AudioToolbox.framework */,
--- a/Xcode-iOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj	Fri Sep 18 16:22:23 2015 -0400
+++ b/Xcode-iOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj	Sun Sep 20 23:08:36 2015 -0300
@@ -65,6 +65,30 @@
 		AAE7DFAC14CBB54E00DF1A0E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89D0E2D111A00EA573E /* Foundation.framework */; };
 		AAE7DFAD14CBB54E00DF1A0E /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89E0E2D111A00EA573E /* CoreAudio.framework */; };
 		AAE7DFB514CBB5F700DF1A0E /* testrendertarget.c in Sources */ = {isa = PBXBuildFile; fileRef = AAE7DFB414CBB5F700DF1A0E /* testrendertarget.c */; };
+		FA0EF22E1BAF4654000E07A6 /* testjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = FDA8A74E0E2D0F1600EA573E /* testjoystick.c */; settings = {ASSET_TAGS = (); }; };
+		FA684F7B1BAF1A4400DCFD1A /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA684F7A1BAF1A4400DCFD1A /* GameController.framework */; };
+		FA684F7F1BAF1A4D00DCFD1A /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA684F7A1BAF1A4400DCFD1A /* GameController.framework */; };
+		FA684F801BAF1A5000DCFD1A /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA684F7A1BAF1A4400DCFD1A /* GameController.framework */; };
+		FA684F811BAF1A5300DCFD1A /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA684F7A1BAF1A4400DCFD1A /* GameController.framework */; };
+		FA684F821BAF1A5700DCFD1A /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA684F7A1BAF1A4400DCFD1A /* GameController.framework */; };
+		FA684F831BAF1A5A00DCFD1A /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA684F7A1BAF1A4400DCFD1A /* GameController.framework */; };
+		FA684F841BAF1A5C00DCFD1A /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA684F7A1BAF1A4400DCFD1A /* GameController.framework */; };
+		FA684F851BAF1A6000DCFD1A /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA684F7A1BAF1A4400DCFD1A /* GameController.framework */; };
+		FA684F861BAF1A6200DCFD1A /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA684F7A1BAF1A4400DCFD1A /* GameController.framework */; };
+		FA684F871BAF1A6500DCFD1A /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA684F7A1BAF1A4400DCFD1A /* GameController.framework */; };
+		FA684F881BAF1A6800DCFD1A /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA684F7A1BAF1A4400DCFD1A /* GameController.framework */; };
+		FA684F891BAF1A6A00DCFD1A /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA684F7A1BAF1A4400DCFD1A /* GameController.framework */; };
+		FA684F8A1BAF1A6D00DCFD1A /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA684F7A1BAF1A4400DCFD1A /* GameController.framework */; };
+		FA684F8B1BAF1A7100DCFD1A /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA684F7A1BAF1A4400DCFD1A /* GameController.framework */; };
+		FA684F8C1BAF1A7400DCFD1A /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA684F7A1BAF1A4400DCFD1A /* GameController.framework */; };
+		FA684F8D1BAF1A7800DCFD1A /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA684F7A1BAF1A4400DCFD1A /* GameController.framework */; };
+		FA684F8E1BAF1A7B00DCFD1A /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA684F7A1BAF1A4400DCFD1A /* GameController.framework */; };
+		FA684F8F1BAF1A7E00DCFD1A /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA684F7A1BAF1A4400DCFD1A /* GameController.framework */; };
+		FA684F901BAF1A8100DCFD1A /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA684F7A1BAF1A4400DCFD1A /* GameController.framework */; };
+		FA684F911BAF1A8400DCFD1A /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA684F7A1BAF1A4400DCFD1A /* GameController.framework */; };
+		FA684F921BAF1A8700DCFD1A /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA684F7A1BAF1A4400DCFD1A /* GameController.framework */; };
+		FA684F931BAF1A8A00DCFD1A /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA684F7A1BAF1A4400DCFD1A /* GameController.framework */; };
+		FA684F941BAF1A9400DCFD1A /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA684F7A1BAF1A4400DCFD1A /* GameController.framework */; };
 		FA8B4BAD1967076F00F8EB7C /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA8B4BAC1967076F00F8EB7C /* CoreMotion.framework */; };
 		FA8B4BC9196766BC00F8EB7C /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA8B4BAC1967076F00F8EB7C /* CoreMotion.framework */; };
 		FA8B4BCD196766BF00F8EB7C /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA8B4BAC1967076F00F8EB7C /* CoreMotion.framework */; };
@@ -88,6 +112,21 @@
 		FA8B4BDF196766F100F8EB7C /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA8B4BAC1967076F00F8EB7C /* CoreMotion.framework */; };
 		FA8B4BE0196766F400F8EB7C /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA8B4BAC1967076F00F8EB7C /* CoreMotion.framework */; };
 		FA8B4BE1196766F600F8EB7C /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA8B4BAC1967076F00F8EB7C /* CoreMotion.framework */; };
+		FAE0E9821BAF9B230098DFA4 /* icon.bmp in Resources */ = {isa = PBXBuildFile; fileRef = FDA8AAD90E2D33B000EA573E /* icon.bmp */; };
+		FAE0E9861BAF9B230098DFA4 /* libSDL2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FD1B48B80E3131CA007AB34E /* libSDL2.a */; };
+		FAE0E9871BAF9B230098DFA4 /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA684F7A1BAF1A4400DCFD1A /* GameController.framework */; };
+		FAE0E9881BAF9B230098DFA4 /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA8B4BAC1967076F00F8EB7C /* CoreMotion.framework */; };
+		FAE0E9891BAF9B230098DFA4 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A8980E2D111A00EA573E /* AudioToolbox.framework */; };
+		FAE0E98A1BAF9B230098DFA4 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A8990E2D111A00EA573E /* QuartzCore.framework */; };
+		FAE0E98B1BAF9B230098DFA4 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89A0E2D111A00EA573E /* OpenGLES.framework */; };
+		FAE0E98C1BAF9B230098DFA4 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89B0E2D111A00EA573E /* CoreGraphics.framework */; };
+		FAE0E98D1BAF9B230098DFA4 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89C0E2D111A00EA573E /* UIKit.framework */; };
+		FAE0E98E1BAF9B230098DFA4 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89D0E2D111A00EA573E /* Foundation.framework */; };
+		FAE0E98F1BAF9B230098DFA4 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89E0E2D111A00EA573E /* CoreAudio.framework */; };
+		FAE0E9951BAF9B510098DFA4 /* testgamecontroller.c in Sources */ = {isa = PBXBuildFile; fileRef = FA0EF2221BAF43DE000E07A6 /* testgamecontroller.c */; settings = {ASSET_TAGS = (); }; };
+		FAE0E9961BAF9B650098DFA4 /* controllermap.bmp in Resources */ = {isa = PBXBuildFile; fileRef = FA0EF22A1BAF4487000E07A6 /* controllermap.bmp */; settings = {ASSET_TAGS = (); }; };
+		FAE0E9971BAF9B6A0098DFA4 /* button.bmp in Resources */ = {isa = PBXBuildFile; fileRef = FA0EF2291BAF4487000E07A6 /* button.bmp */; settings = {ASSET_TAGS = (); }; };
+		FAE0E9981BAF9B6E0098DFA4 /* axis.bmp in Resources */ = {isa = PBXBuildFile; fileRef = FA0EF2281BAF4487000E07A6 /* axis.bmp */; settings = {ASSET_TAGS = (); }; };
 		FDA8A79C0E2D0F9300EA573E /* testwm2.c in Sources */ = {isa = PBXBuildFile; fileRef = FDA8A75F0E2D0F1600EA573E /* testwm2.c */; };
 		FDA8A89F0E2D111A00EA573E /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A8980E2D111A00EA573E /* AudioToolbox.framework */; };
 		FDA8A8A00E2D111A00EA573E /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A8990E2D111A00EA573E /* QuartzCore.framework */; };
@@ -188,7 +227,6 @@
 		FDD2C19F0E2E534F00B7A85F /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89C0E2D111A00EA573E /* UIKit.framework */; };
 		FDD2C1A00E2E534F00B7A85F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89D0E2D111A00EA573E /* Foundation.framework */; };
 		FDD2C1A10E2E534F00B7A85F /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89E0E2D111A00EA573E /* CoreAudio.framework */; };
-		FDD2C1A80E2E536400B7A85F /* testjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = FDA8A74E0E2D0F1600EA573E /* testjoystick.c */; };
 		FDD2C4540E2E773800B7A85F /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A8980E2D111A00EA573E /* AudioToolbox.framework */; };
 		FDD2C4550E2E773800B7A85F /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A8990E2D111A00EA573E /* QuartzCore.framework */; };
 		FDD2C4560E2E773800B7A85F /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89A0E2D111A00EA573E /* OpenGLES.framework */; };
@@ -288,7 +326,13 @@
 		AAE7DF4514CBB43900DF1A0E /* testscale.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testscale.c; path = ../../test/testscale.c; sourceTree = "<group>"; };
 		AAE7DFB114CBB54E00DF1A0E /* testrendertarget.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testrendertarget.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		AAE7DFB414CBB5F700DF1A0E /* testrendertarget.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testrendertarget.c; path = ../../test/testrendertarget.c; sourceTree = "<group>"; };
+		FA0EF2221BAF43DE000E07A6 /* testgamecontroller.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testgamecontroller.c; path = ../../test/testgamecontroller.c; sourceTree = "<group>"; };
+		FA0EF2281BAF4487000E07A6 /* axis.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; name = axis.bmp; path = ../../test/axis.bmp; sourceTree = "<group>"; };
+		FA0EF2291BAF4487000E07A6 /* button.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; name = button.bmp; path = ../../test/button.bmp; sourceTree = "<group>"; };
+		FA0EF22A1BAF4487000E07A6 /* controllermap.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; name = controllermap.bmp; path = ../../test/controllermap.bmp; sourceTree = "<group>"; };
+		FA684F7A1BAF1A4400DCFD1A /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = System/Library/Frameworks/GameController.framework; sourceTree = SDKROOT; };
 		FA8B4BAC1967076F00F8EB7C /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = System/Library/Frameworks/CoreMotion.framework; sourceTree = SDKROOT; };
+		FAE0E9931BAF9B230098DFA4 /* testgamecontroller.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testgamecontroller.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		FD1B48AC0E3131CA007AB34E /* SDL.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SDL.xcodeproj; path = ../SDL/SDL.xcodeproj; sourceTree = SOURCE_ROOT; };
 		FDA8A7410E2D0F1600EA573E /* testaudioinfo.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testaudioinfo.c; path = ../../test/testaudioinfo.c; sourceTree = SOURCE_ROOT; };
 		FDA8A7470E2D0F1600EA573E /* testerror.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testerror.c; path = ../../test/testerror.c; sourceTree = SOURCE_ROOT; };
@@ -347,6 +391,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				046CEF7B13254F23007AD51D /* libSDL2.a in Frameworks */,
+				FA684F841BAF1A5C00DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BD1196766C900F8EB7C /* CoreMotion.framework in Frameworks */,
 				046CEF7C13254F23007AD51D /* AudioToolbox.framework in Frameworks */,
 				046CEF7D13254F23007AD51D /* QuartzCore.framework in Frameworks */,
@@ -364,6 +409,7 @@
 			files = (
 				AA1EE470176059D00029C7A5 /* libSDL2test.a in Frameworks */,
 				047A63E213285C3200CD7973 /* libSDL2.a in Frameworks */,
+				FA684F7B1BAF1A4400DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BAD1967076F00F8EB7C /* CoreMotion.framework in Frameworks */,
 				047A63E313285C3200CD7973 /* AudioToolbox.framework in Frameworks */,
 				047A63E413285C3200CD7973 /* QuartzCore.framework in Frameworks */,
@@ -381,6 +427,7 @@
 			files = (
 				AA1EE47817605BF60029C7A5 /* libSDL2test.a in Frameworks */,
 				FDBDE5810E313465006BAC0B /* libSDL2.a in Frameworks */,
+				FA684F931BAF1A8A00DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BE0196766F400F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDA8A89F0E2D111A00EA573E /* AudioToolbox.framework in Frameworks */,
 				FDA8A8A00E2D111A00EA573E /* QuartzCore.framework in Frameworks */,
@@ -397,6 +444,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				56ED0502118A8FE400A56AA6 /* libSDL2.a in Frameworks */,
+				FA684F8B1BAF1A7100DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BD8196766DD00F8EB7C /* CoreMotion.framework in Frameworks */,
 				56ED0503118A8FE400A56AA6 /* AudioToolbox.framework in Frameworks */,
 				56ED0504118A8FE400A56AA6 /* QuartzCore.framework in Frameworks */,
@@ -414,6 +462,7 @@
 			files = (
 				AA1EE47617605B9E0029C7A5 /* libSDL2test.a in Frameworks */,
 				AAE7DEE114CBB1E100DF1A0E /* libSDL2.a in Frameworks */,
+				FA684F8D1BAF1A7800DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BDA196766E200F8EB7C /* CoreMotion.framework in Frameworks */,
 				AAE7DEE214CBB1E100DF1A0E /* AudioToolbox.framework in Frameworks */,
 				AAE7DEE314CBB1E100DF1A0E /* QuartzCore.framework in Frameworks */,
@@ -431,6 +480,7 @@
 			files = (
 				AA1EE47517605B930029C7A5 /* libSDL2test.a in Frameworks */,
 				AAE7DFA614CBB54E00DF1A0E /* libSDL2.a in Frameworks */,
+				FA684F8C1BAF1A7400DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BD9196766E000F8EB7C /* CoreMotion.framework in Frameworks */,
 				AAE7DFA714CBB54E00DF1A0E /* AudioToolbox.framework in Frameworks */,
 				AAE7DFA814CBB54E00DF1A0E /* QuartzCore.framework in Frameworks */,
@@ -442,11 +492,29 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
+		FAE0E9851BAF9B230098DFA4 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				FAE0E9861BAF9B230098DFA4 /* libSDL2.a in Frameworks */,
+				FAE0E9871BAF9B230098DFA4 /* GameController.framework in Frameworks */,
+				FAE0E9881BAF9B230098DFA4 /* CoreMotion.framework in Frameworks */,
+				FAE0E9891BAF9B230098DFA4 /* AudioToolbox.framework in Frameworks */,
+				FAE0E98A1BAF9B230098DFA4 /* QuartzCore.framework in Frameworks */,
+				FAE0E98B1BAF9B230098DFA4 /* OpenGLES.framework in Frameworks */,
+				FAE0E98C1BAF9B230098DFA4 /* CoreGraphics.framework in Frameworks */,
+				FAE0E98D1BAF9B230098DFA4 /* UIKit.framework in Frameworks */,
+				FAE0E98E1BAF9B230098DFA4 /* Foundation.framework in Frameworks */,
+				FAE0E98F1BAF9B230098DFA4 /* CoreAudio.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 		FDA8AAAE0E2D330F00EA573E /* Frameworks */ = {
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
 				FDBDE5850E313495006BAC0B /* libSDL2.a in Frameworks */,
+				FA684F7F1BAF1A4D00DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BC9196766BC00F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDA8AAB10E2D330F00EA573E /* AudioToolbox.framework in Frameworks */,
 				FDA8AAB20E2D330F00EA573E /* QuartzCore.framework in Frameworks */,
@@ -463,6 +531,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				FDBDE58C0E3134F3006BAC0B /* libSDL2.a in Frameworks */,
+				FA684F801BAF1A5000DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BCD196766BF00F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDAAC3C30E2D47E6001DB1D8 /* AudioToolbox.framework in Frameworks */,
 				FDAAC3C40E2D47E6001DB1D8 /* QuartzCore.framework in Frameworks */,
@@ -479,6 +548,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				FDBDE59B0E31356A006BAC0B /* libSDL2.a in Frameworks */,
+				FA684F821BAF1A5700DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BCF196766C400F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDAAC5910E2D5429001DB1D8 /* AudioToolbox.framework in Frameworks */,
 				FDAAC5920E2D5429001DB1D8 /* QuartzCore.framework in Frameworks */,
@@ -495,6 +565,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				FDBDE59F0E31358D006BAC0B /* libSDL2.a in Frameworks */,
+				FA684F831BAF1A5A00DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BD0196766C600F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDAAC5BF0E2D55B5001DB1D8 /* AudioToolbox.framework in Frameworks */,
 				FDAAC5C00E2D55B5001DB1D8 /* QuartzCore.framework in Frameworks */,
@@ -512,6 +583,7 @@
 			files = (
 				AA1EE47417605B5C0029C7A5 /* libSDL2test.a in Frameworks */,
 				FDBDE57C0E313445006BAC0B /* libSDL2.a in Frameworks */,
+				FA684F851BAF1A6000DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BD2196766CB00F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDAAC61C0E2D5914001DB1D8 /* AudioToolbox.framework in Frameworks */,
 				FDAAC61D0E2D5914001DB1D8 /* QuartzCore.framework in Frameworks */,
@@ -529,6 +601,7 @@
 			files = (
 				AA1EE47117605A7F0029C7A5 /* libSDL2test.a in Frameworks */,
 				FDC42FF40F0D866D009C87E1 /* libSDL2.a in Frameworks */,
+				FA684F811BAF1A5300DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BCE196766C100F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDC42FF60F0D866D009C87E1 /* AudioToolbox.framework in Frameworks */,
 				FDC42FF70F0D866D009C87E1 /* QuartzCore.framework in Frameworks */,
@@ -545,6 +618,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				FDBDE5A90E3135C0006BAC0B /* libSDL2.a in Frameworks */,
+				FA684F901BAF1A8100DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BDD196766EB00F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDD2C1000E2E4F4B00B7A85F /* AudioToolbox.framework in Frameworks */,
 				FDD2C1010E2E4F4B00B7A85F /* QuartzCore.framework in Frameworks */,
@@ -561,6 +635,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				FDBDE5AE0E3135E6006BAC0B /* libSDL2.a in Frameworks */,
+				FA684F861BAF1A6200DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BD3196766CE00F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDD2C1770E2E52C000B7A85F /* AudioToolbox.framework in Frameworks */,
 				FDD2C1780E2E52C000B7A85F /* QuartzCore.framework in Frameworks */,
@@ -577,6 +652,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				FDBDE5B60E3135FE006BAC0B /* libSDL2.a in Frameworks */,
+				FA684F871BAF1A6500DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BD4196766D100F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDD2C19B0E2E534F00B7A85F /* AudioToolbox.framework in Frameworks */,
 				FDD2C19C0E2E534F00B7A85F /* QuartzCore.framework in Frameworks */,
@@ -593,6 +669,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				FDBDE5BC0E31364D006BAC0B /* libSDL2.a in Frameworks */,
+				FA684F881BAF1A6800DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BD5196766D400F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDD2C4540E2E773800B7A85F /* AudioToolbox.framework in Frameworks */,
 				FDD2C4550E2E773800B7A85F /* QuartzCore.framework in Frameworks */,
@@ -609,6 +686,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				FDBDE5C20E313663006BAC0B /* libSDL2.a in Frameworks */,
+				FA684F891BAF1A6A00DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BD6196766D700F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDD2C4720E2E77D700B7A85F /* AudioToolbox.framework in Frameworks */,
 				FDD2C4730E2E77D700B7A85F /* QuartzCore.framework in Frameworks */,
@@ -625,6 +703,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				FDBDE5C60E3136F1006BAC0B /* libSDL2.a in Frameworks */,
+				FA684F8A1BAF1A6D00DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BD7196766DA00F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDD2C5010E2E7F4800B7A85F /* AudioToolbox.framework in Frameworks */,
 				FDD2C5020E2E7F4800B7A85F /* QuartzCore.framework in Frameworks */,
@@ -641,6 +720,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				FDBDE5C80E313702006BAC0B /* libSDL2.a in Frameworks */,
+				FA684F8E1BAF1A7B00DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BDB196766E500F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDD2C51F0E2E807600B7A85F /* AudioToolbox.framework in Frameworks */,
 				FDD2C5200E2E807600B7A85F /* QuartzCore.framework in Frameworks */,
@@ -658,6 +738,7 @@
 			files = (
 				AA1EE47717605BAB0029C7A5 /* libSDL2test.a in Frameworks */,
 				FDBDE5CA0E313712006BAC0B /* libSDL2.a in Frameworks */,
+				FA684F8F1BAF1A7E00DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BDC196766E800F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDD2C5440E2E80E400B7A85F /* AudioToolbox.framework in Frameworks */,
 				FDD2C5450E2E80E400B7A85F /* QuartzCore.framework in Frameworks */,
@@ -674,6 +755,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				FDBDE5CC0E31372B006BAC0B /* libSDL2.a in Frameworks */,
+				FA684F911BAF1A8400DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BDE196766EE00F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDD2C57D0E2E8C7400B7A85F /* AudioToolbox.framework in Frameworks */,
 				FDD2C57E0E2E8C7400B7A85F /* QuartzCore.framework in Frameworks */,
@@ -690,6 +772,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				FDBDE5CE0E31373E006BAC0B /* libSDL2.a in Frameworks */,
+				FA684F921BAF1A8700DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BDF196766F100F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDD2C5BB0E2E8CFC00B7A85F /* AudioToolbox.framework in Frameworks */,
 				FDD2C5BC0E2E8CFC00B7A85F /* QuartzCore.framework in Frameworks */,
@@ -706,6 +789,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				FDBDE5D40E313789006BAC0B /* libSDL2.a in Frameworks */,
+				FA684F941BAF1A9400DCFD1A /* GameController.framework in Frameworks */,
 				FA8B4BE1196766F600F8EB7C /* CoreMotion.framework in Frameworks */,
 				FDD2C6EA0E2E959E00B7A85F /* AudioToolbox.framework in Frameworks */,
 				FDD2C6EB0E2E959E00B7A85F /* QuartzCore.framework in Frameworks */,
@@ -746,6 +830,7 @@
 				047A63ED13285C3200CD7973 /* checkkeys.app */,
 				AAE7DEEC14CBB1E100DF1A0E /* testscale.app */,
 				AAE7DFB114CBB54E00DF1A0E /* testrendertarget.app */,
+				FAE0E9931BAF9B230098DFA4 /* testgamecontroller.app */,
 			);
 			name = Products;
 			sourceTree = "<group>";
@@ -788,6 +873,7 @@
 				FDC430090F0D86BF009C87E1 /* testdraw2.c */,
 				FDA8A7470E2D0F1600EA573E /* testerror.c */,
 				FDA8A7480E2D0F1600EA573E /* testfile.c */,
+				FA0EF2221BAF43DE000E07A6 /* testgamecontroller.c */,
 				046CEF8913254F63007AD51D /* testgesture.c */,
 				FDAAC6290E2D5960001DB1D8 /* testgles.c */,
 				FDA8A74D0E2D0F1600EA573E /* testiconv.c */,
@@ -813,6 +899,7 @@
 		FDA8A7C30E2D10FA00EA573E /* Linked Frameworks */ = {
 			isa = PBXGroup;
 			children = (
+				FA684F7A1BAF1A4400DCFD1A /* GameController.framework */,
 				FA8B4BAC1967076F00F8EB7C /* CoreMotion.framework */,
 				FDA8A8980E2D111A00EA573E /* AudioToolbox.framework */,
 				FDA8A8990E2D111A00EA573E /* QuartzCore.framework */,
@@ -828,6 +915,9 @@
 		FDA8AAD60E2D339A00EA573E /* Resources */ = {
 			isa = PBXGroup;
 			children = (
+				FA0EF2281BAF4487000E07A6 /* axis.bmp */,
+				FA0EF2291BAF4487000E07A6 /* button.bmp */,
+				FA0EF22A1BAF4487000E07A6 /* controllermap.bmp */,
 				FDD2C18A0E2E52FE00B7A85F /* utf8.txt */,
 				FDA8AAD90E2D33B000EA573E /* icon.bmp */,
 				FDA8AADA0E2D33BA00EA573E /* moose.dat */,
@@ -943,6 +1033,23 @@
 			productReference = AAE7DFB114CBB54E00DF1A0E /* testrendertarget.app */;
 			productType = "com.apple.product-type.application";
 		};
+		FAE0E9801BAF9B230098DFA4 /* testgamecontroller */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = FAE0E9901BAF9B230098DFA4 /* Build configuration list for PBXNativeTarget "testgamecontroller" */;
+			buildPhases = (
+				FAE0E9811BAF9B230098DFA4 /* Resources */,
+				FAE0E9831BAF9B230098DFA4 /* Sources */,
+				FAE0E9851BAF9B230098DFA4 /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = testgamecontroller;
+			productName = Test;
+			productReference = FAE0E9931BAF9B230098DFA4 /* testgamecontroller.app */;
+			productType = "com.apple.product-type.application";
+		};
 		FDA8AAAA0E2D330F00EA573E /* loopwav */ = {
 			isa = PBXNativeTarget;
 			buildConfigurationList = FDA8AAB80E2D330F00EA573E /* Build configuration list for PBXNativeTarget "loopwav" */;
@@ -1270,6 +1377,7 @@
 				FDC42FEF0F0D866D009C87E1 /* testdraw2 */,
 				FDAAC58A0E2D5429001DB1D8 /* testerror */,
 				FDAAC5B80E2D55B5001DB1D8 /* testfile */,
+				FAE0E9801BAF9B230098DFA4 /* testgamecontroller */,
 				046CEF7513254F23007AD51D /* testgesture */,
 				FDAAC6150E2D5914001DB1D8 /* testgles */,
 				FDD2C1700E2E52C000B7A85F /* testiconv */,
@@ -1357,6 +1465,17 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
+		FAE0E9811BAF9B230098DFA4 /* Resources */ = {
+			isa = PBXResourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				FAE0E9961BAF9B650098DFA4 /* controllermap.bmp in Resources */,
+				FAE0E9821BAF9B230098DFA4 /* icon.bmp in Resources */,
+				FAE0E9981BAF9B6E0098DFA4 /* axis.bmp in Resources */,
+				FAE0E9971BAF9B6A0098DFA4 /* button.bmp in Resources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 		FDA8AAAB0E2D330F00EA573E /* Resources */ = {
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
@@ -1533,6 +1652,14 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
+		FAE0E9831BAF9B230098DFA4 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				FAE0E9951BAF9B510098DFA4 /* testgamecontroller.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 		FDA8AAAC0E2D330F00EA573E /* Sources */ = {
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
@@ -1601,7 +1728,7 @@
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				FDD2C1A80E2E536400B7A85F /* testjoystick.c in Sources */,
+				FA0EF22E1BAF4654000E07A6 /* testjoystick.c in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -1794,6 +1921,22 @@
 			};
 			name = Release;
 		};
+		FAE0E9911BAF9B230098DFA4 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				INFOPLIST_FILE = Info.plist;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+			};
+			name = Debug;
+		};
+		FAE0E9921BAF9B230098DFA4 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				INFOPLIST_FILE = Info.plist;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+			};
+			name = Release;
+		};
 		FDA8AAB90E2D330F00EA573E /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
@@ -2132,6 +2275,15 @@
 			defaultConfigurationIsVisible = 0;
 			defaultConfigurationName = Release;
 		};
+		FAE0E9901BAF9B230098DFA4 /* Build configuration list for PBXNativeTarget "testgamecontroller" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				FAE0E9911BAF9B230098DFA4 /* Debug */,
+				FAE0E9921BAF9B230098DFA4 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
 		FDA8AAB80E2D330F00EA573E /* Build configuration list for PBXNativeTarget "loopwav" */ = {
 			isa = XCConfigurationList;
 			buildConfigurations = (
--- a/configure	Fri Sep 18 16:22:23 2015 -0400
+++ b/configure	Sun Sep 20 23:08:36 2015 -0300
@@ -23433,6 +23433,7 @@
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreGraphics"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreMotion"
+        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,GameController"
         ;;
     *-*-darwin* )
         # This could be either full "Mac OS X", or plain "Darwin" which is
--- a/include/SDL_config.h.cmake	Fri Sep 18 16:22:23 2015 -0400
+++ b/include/SDL_config.h.cmake	Sun Sep 20 23:08:36 2015 -0300
@@ -235,6 +235,7 @@
 #cmakedefine SDL_JOYSTICK_XINPUT @SDL_JOYSTICK_XINPUT@
 #cmakedefine SDL_JOYSTICK_DUMMY @SDL_JOYSTICK_DUMMY@
 #cmakedefine SDL_JOYSTICK_IOKIT @SDL_JOYSTICK_IOKIT@
+#cmakedefine SDL_JOYSTICK_MFI @SDL_JOYSTICK_MFI@
 #cmakedefine SDL_JOYSTICK_LINUX @SDL_JOYSTICK_LINUX@
 #cmakedefine SDL_JOYSTICK_WINMM @SDL_JOYSTICK_WINMM@
 #cmakedefine SDL_JOYSTICK_USBHID @SDL_JOYSTICK_USBHID@
--- a/include/SDL_config_iphoneos.h	Fri Sep 18 16:22:23 2015 -0400
+++ b/include/SDL_config_iphoneos.h	Sun Sep 20 23:08:36 2015 -0300
@@ -115,8 +115,11 @@
 /* Enable the stub haptic driver (src/haptic/dummy/\*.c) */
 #define SDL_HAPTIC_DUMMY 1
 
+/* Enable MFi joystick support */
+#define SDL_JOYSTICK_MFI 1
+
 /* 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 */
 
 /* Enable the stub shared object loader (src/loadso/dummy/\*.c) */
@@ -148,9 +151,6 @@
 /* enable iOS extended launch screen */
 #define SDL_IPHONE_LAUNCHSCREEN 1
 
-/* enable joystick subsystem */
-#define SDL_JOYSTICK_DISABLED 0
-
 /* Set max recognized G-force from accelerometer
    See src/joystick/uikit/SDL_sysjoystick.m for notes on why this is needed
  */
--- a/premake/README-ios.txt	Fri Sep 18 16:22:23 2015 -0400
+++ b/premake/README-ios.txt	Sun Sep 20 23:08:36 2015 -0300
@@ -26,6 +26,7 @@
   -Foundation.framework
   -CoreAudio.framework
   -CoreMotion.framework
+  -GameController.framework
 
 All of these frameworks are part of the iOS SDK, not part of the core OS X
 system.
--- a/premake/Xcode-iOS/Demos/happy/happy.xcodeproj/project.pbxproj	Fri Sep 18 16:22:23 2015 -0400
+++ b/premake/Xcode-iOS/Demos/happy/happy.xcodeproj/project.pbxproj	Sun Sep 20 23:08:36 2015 -0300
@@ -3,55 +3,55 @@
 	archiveVersion = 1;
 	classes = {
 	};
-	objectVersion = 45;
+	objectVersion = 46;
 	objects = {
 
 /* Begin PBXBuildFile section */
-		43587E112FDE41E3486A5141 /* icon.bmp in Resources */ = {isa = PBXBuildFile; fileRef = 67E105821F9D19C248BF17B6 /* icon.bmp */; };
+		039E2FCB749D2AE6705435A4 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B210870772357A20E4576EE /* OpenGLES.framework */; };
+		04CE7E9842C4612763496460 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C147BCA187412202A676460 /* AudioToolbox.framework */; };
+		081D5E427A420BEA66DF6129 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 489C1A076394164C7F853083 /* Foundation.framework */; };
+		263A59BA6D20796421AC3870 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 603E37DB4001230953C943FD /* CoreGraphics.framework */; };
 		2F5A7AB72FA52C3D029335B6 /* common.c in Sources */ = {isa = PBXBuildFile; fileRef = 49AD32CF351438B316C15B7A /* common.c */; };
-		66455D1E7E3179156E546AA8 /* happy.c in Sources */ = {isa = PBXBuildFile; fileRef = 1F0270E77CC100E968633EBA /* happy.c */; };
-		04CE7E9842C4612763496460 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C147BCA187412202A676460 /* AudioToolbox.framework */; };
+		424C13DC60653FEE6370536B /* libSDL2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 327333F1228F1B0D0A582BEC /* libSDL2.a */; };
+		43587E112FDE41E3486A5141 /* icon.bmp in Resources */ = {isa = PBXBuildFile; fileRef = 67E105821F9D19C248BF17B6 /* icon.bmp */; };
 		5DC8148934C32F3407541C0F /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5DDB080C0C872DF96CEE0B62 /* QuartzCore.framework */; };
-		039E2FCB749D2AE6705435A4 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B210870772357A20E4576EE /* OpenGLES.framework */; };
-		263A59BA6D20796421AC3870 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 603E37DB4001230953C943FD /* CoreGraphics.framework */; };
+		65AC30DF305741C6521420A7 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7AF1729947305D7E10DA777D /* CoreAudio.framework */; };
+		66455D1E7E3179156E546AA8 /* happy.c in Sources */ = {isa = PBXBuildFile; fileRef = 1F0270E77CC100E968633EBA /* happy.c */; };
 		7E2000C447ED370218691A83 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 49C87CB0268927E071506CEA /* UIKit.framework */; };
-		081D5E427A420BEA66DF6129 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 489C1A076394164C7F853083 /* Foundation.framework */; };
-		65AC30DF305741C6521420A7 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7AF1729947305D7E10DA777D /* CoreAudio.framework */; };
-		424C13DC60653FEE6370536B /* libSDL2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 327333F1228F1B0D0A582BEC /* libSDL2.a */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
+		6D92213A249742C860667923 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 45B64B000539221732843506 /* SDL2.xcodeproj */;
+			proxyType = 1;
+			remoteGlobalIDString = 515D4C462ACD2DA8180E7783;
+			remoteInfo = libSDL2.a;
+		};
 		73DD36916E01179F50147B85 /* PBXContainerItemProxy */ = {
 			isa = PBXContainerItemProxy;
 			containerPortal = 45B64B000539221732843506 /* SDL2.xcodeproj */;
 			proxyType = 2;
 			remoteGlobalIDString = 224D2C85085A7BA60E532655;
-			remoteInfo = "libSDL2.a";
-		};
-		6D92213A249742C860667923 /* PBXContainerItemProxy */ = {
-			isa = PBXContainerItemProxy;
-			containerPortal = 45B64B000539221732843506 /* SDL2.xcodeproj */;
-			proxyType = 1;
-			remoteGlobalIDString = 515D4C462ACD2DA8180E7783;
-			remoteInfo = "libSDL2.a";
+			remoteInfo = libSDL2.a;
 		};
 /* End PBXContainerItemProxy section */
 
 /* Begin PBXFileReference section */
-		4E8504577F0B2DC43C2073B9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "Info.plist"; path = "../../../../Xcode-iOS/Demos/Info.plist"; sourceTree = "<group>"; };
-		67E105821F9D19C248BF17B6 /* icon.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; name = "icon.bmp"; path = "../../../../Xcode-iOS/Demos/data/icon.bmp"; sourceTree = "<group>"; };
-		49AD32CF351438B316C15B7A /* common.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = "common.c"; path = "../../../../Xcode-iOS/Demos/src/common.c"; sourceTree = "<group>"; };
-		4346585005E47029491C60D0 /* common.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "common.h"; path = "../../../../Xcode-iOS/Demos/src/common.h"; sourceTree = "<group>"; };
-		1F0270E77CC100E968633EBA /* happy.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = "happy.c"; path = "../../../../Xcode-iOS/Demos/src/happy.c"; sourceTree = "<group>"; };
-		2C147BCA187412202A676460 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "AudioToolbox.framework"; path = "System/Library/Frameworks/AudioToolbox.framework"; sourceTree = "SDKROOT"; };
-		5DDB080C0C872DF96CEE0B62 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "QuartzCore.framework"; path = "System/Library/Frameworks/QuartzCore.framework"; sourceTree = "SDKROOT"; };
-		3B210870772357A20E4576EE /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "OpenGLES.framework"; path = "System/Library/Frameworks/OpenGLES.framework"; sourceTree = "SDKROOT"; };
-		603E37DB4001230953C943FD /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "CoreGraphics.framework"; path = "System/Library/Frameworks/CoreGraphics.framework"; sourceTree = "SDKROOT"; };
-		49C87CB0268927E071506CEA /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "UIKit.framework"; path = "System/Library/Frameworks/UIKit.framework"; sourceTree = "SDKROOT"; };
-		489C1A076394164C7F853083 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "Foundation.framework"; path = "System/Library/Frameworks/Foundation.framework"; sourceTree = "SDKROOT"; };
-		7AF1729947305D7E10DA777D /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "CoreAudio.framework"; path = "System/Library/Frameworks/CoreAudio.framework"; sourceTree = "SDKROOT"; };
-		65F833BA06B514AD0EE36218 /* happy */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; name = "happy"; path = "happy"; sourceTree = BUILT_PRODUCTS_DIR; };
-		45B64B000539221732843506 /* SDL2.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "SDL2.xcodeproj"; path = "../../SDL2/SDL2.xcodeproj"; sourceTree = SOURCE_ROOT; };
+		1F0270E77CC100E968633EBA /* happy.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = happy.c; path = "../../../../Xcode-iOS/Demos/src/happy.c"; sourceTree = "<group>"; };
+		2C147BCA187412202A676460 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
+		3B210870772357A20E4576EE /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };
+		4346585005E47029491C60D0 /* common.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = common.h; path = "../../../../Xcode-iOS/Demos/src/common.h"; sourceTree = "<group>"; };
+		45B64B000539221732843506 /* SDL2.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SDL2.xcodeproj; path = ../../SDL2/SDL2.xcodeproj; sourceTree = SOURCE_ROOT; };
+		489C1A076394164C7F853083 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+		49AD32CF351438B316C15B7A /* common.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = common.c; path = "../../../../Xcode-iOS/Demos/src/common.c"; sourceTree = "<group>"; };
+		49C87CB0268927E071506CEA /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
+		4E8504577F0B2DC43C2073B9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = "../../../../Xcode-iOS/Demos/Info.plist"; sourceTree = "<group>"; };
+		5DDB080C0C872DF96CEE0B62 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
+		603E37DB4001230953C943FD /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
+		65F833BA06B514AD0EE36218 /* happy.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = happy.app; sourceTree = BUILT_PRODUCTS_DIR; };
+		67E105821F9D19C248BF17B6 /* icon.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; name = icon.bmp; path = "../../../../Xcode-iOS/Demos/data/icon.bmp"; sourceTree = "<group>"; };
+		7AF1729947305D7E10DA777D /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = System/Library/Frameworks/CoreAudio.framework; sourceTree = SDKROOT; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -73,23 +73,30 @@
 /* End PBXFrameworksBuildPhase section */
 
 /* Begin PBXGroup section */
-		3555679049400DAA17916DD7 /* happy */ = {
+		1EEF027C57A725660BCF6FB9 /* data */ = {
+			isa = PBXGroup;
+			children = (
+				67E105821F9D19C248BF17B6 /* icon.bmp */,
+			);
+			name = data;
+			sourceTree = "<group>";
+		};
+		1F3D1DBD7857554A0C1C1965 /* src */ = {
 			isa = PBXGroup;
 			children = (
-				7CFE361B495F31F009A616F6 /* Xcode-iOS */,
-				532F72873A65662513E35533 /* Frameworks */,
-				343C7E606DE365001C7D0B84 /* Products */,
-				20D87CCB7D1E6AC128B72992 /* Projects */,
+				49AD32CF351438B316C15B7A /* common.c */,
+				4346585005E47029491C60D0 /* common.h */,
+				1F0270E77CC100E968633EBA /* happy.c */,
 			);
-			name = "happy";
+			name = src;
 			sourceTree = "<group>";
 		};
-		7CFE361B495F31F009A616F6 /* Xcode-iOS */ = {
+		20D87CCB7D1E6AC128B72992 /* Projects */ = {
 			isa = PBXGroup;
 			children = (
-				224D240956AC3D2636C95904 /* Demos */,
+				45B64B000539221732843506 /* SDL2.xcodeproj */,
 			);
-			name = "Xcode-iOS";
+			name = Projects;
 			sourceTree = "<group>";
 		};
 		224D240956AC3D2636C95904 /* Demos */ = {
@@ -99,25 +106,34 @@
 				1EEF027C57A725660BCF6FB9 /* data */,
 				1F3D1DBD7857554A0C1C1965 /* src */,
 			);
-			name = "Demos";
+			name = Demos;
 			sourceTree = "<group>";
 		};
-		1EEF027C57A725660BCF6FB9 /* data */ = {
+		343C7E606DE365001C7D0B84 /* Products */ = {
+			isa = PBXGroup;
+			children = (
+				65F833BA06B514AD0EE36218 /* happy.app */,
+			);
+			name = Products;
+			sourceTree = "<group>";
+		};
+		3555679049400DAA17916DD7 /* happy */ = {
 			isa = PBXGroup;
 			children = (
-				67E105821F9D19C248BF17B6 /* icon.bmp */,
+				7CFE361B495F31F009A616F6 /* Xcode-iOS */,
+				532F72873A65662513E35533 /* Frameworks */,
+				343C7E606DE365001C7D0B84 /* Products */,
+				20D87CCB7D1E6AC128B72992 /* Projects */,
 			);
-			name = "data";
+			name = happy;
 			sourceTree = "<group>";
 		};
-		1F3D1DBD7857554A0C1C1965 /* src */ = {
+		452A4F211058019E46671F0C /* Products */ = {
 			isa = PBXGroup;
 			children = (
-				49AD32CF351438B316C15B7A /* common.c */,
-				4346585005E47029491C60D0 /* common.h */,
-				1F0270E77CC100E968633EBA /* happy.c */,
+				327333F1228F1B0D0A582BEC /* libSDL2.a */,
 			);
-			name = "src";
+			name = Products;
 			sourceTree = "<group>";
 		};
 		532F72873A65662513E35533 /* Frameworks */ = {
@@ -131,31 +147,15 @@
 				489C1A076394164C7F853083 /* Foundation.framework */,
 				7AF1729947305D7E10DA777D /* CoreAudio.framework */,
 			);
-			name = "Frameworks";
-			sourceTree = "<group>";
-		};
-		343C7E606DE365001C7D0B84 /* Products */ = {
-			isa = PBXGroup;
-			children = (
-				65F833BA06B514AD0EE36218 /* happy */,
-			);
-			name = "Products";
+			name = Frameworks;
 			sourceTree = "<group>";
 		};
-		20D87CCB7D1E6AC128B72992 /* Projects */ = {
+		7CFE361B495F31F009A616F6 /* Xcode-iOS */ = {
 			isa = PBXGroup;
 			children = (
-				45B64B000539221732843506 /* SDL2.xcodeproj */,
+				224D240956AC3D2636C95904 /* Demos */,
 			);
-			name = "Projects";
-			sourceTree = "<group>";
-		};
-		452A4F211058019E46671F0C /* Products */ = {
-			isa = PBXGroup;
-			children = (
-				327333F1228F1B0D0A582BEC /* libSDL2.a */,
-			);
-			name = Products;
+			name = "Xcode-iOS";
 			sourceTree = "<group>";
 		};
 /* End PBXGroup section */
@@ -174,10 +174,10 @@
 			dependencies = (
 				1F023F2F3EDE66E20BCC17E1 /* PBXTargetDependency */,
 			);
-			name = "happy";
+			name = happy;
 			productInstallPath = "$(HOME)/Applications";
-			productName = "happy";
-			productReference = 65F833BA06B514AD0EE36218 /* happy */;
+			productName = happy;
+			productReference = 65F833BA06B514AD0EE36218 /* happy.app */;
 			productType = "com.apple.product-type.application";
 		};
 /* End PBXNativeTarget section */
@@ -185,9 +185,15 @@
 /* Begin PBXProject section */
 		08FB7793FE84155DC02AAC07 /* Project object */ = {
 			isa = PBXProject;
+			attributes = {
+			};
 			buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "happy" */;
 			compatibilityVersion = "Xcode 3.2";
+			developmentRegion = English;
 			hasScannedForEncodings = 1;
+			knownRegions = (
+				en,
+			);
 			mainGroup = 3555679049400DAA17916DD7 /* happy */;
 			projectDirPath = "";
 			projectReferences = (
@@ -207,7 +213,7 @@
 		327333F1228F1B0D0A582BEC /* libSDL2.a */ = {
 			isa = PBXReferenceProxy;
 			fileType = archive.ar;
-			path = "Build/Debug/libSDL2.a";
+			path = libSDL2.a;
 			remoteRef = 73DD36916E01179F50147B85 /* PBXContainerItemProxy */;
 			sourceTree = BUILT_PRODUCTS_DIR;
 		};
@@ -236,50 +242,19 @@
 		};
 /* End PBXSourcesBuildPhase section */
 
-/* Begin PBXVariantGroup section */
-/* End PBXVariantGroup section */
-
 /* Begin PBXTargetDependency section */
 		1F023F2F3EDE66E20BCC17E1 /* PBXTargetDependency */ = {
 			isa = PBXTargetDependency;
-			name = "libSDL2.a";
+			name = libSDL2.a;
 			targetProxy = 6D92213A249742C860667923 /* PBXContainerItemProxy */;
 		};
 /* End PBXTargetDependency section */
 
 /* Begin XCBuildConfiguration section */
-		563C339925F445BB2F1E01DB /* Debug */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				ALWAYS_SEARCH_USER_PATHS = NO;
-				CONFIGURATION_BUILD_DIR = Build/Debug;
-				GCC_DYNAMIC_NO_PIC = NO;
-				GCC_MODEL_TUNING = G5;
-				INFOPLIST_FILE = "../../../../Xcode-iOS/Demos/Info.plist";
-				INSTALL_PATH = "$(HOME)/Applications";
-				PRODUCT_NAME = "happy";
-			};
-			name = "Debug";
-		};
-		205A208D2C4F2495443E582F /* Release */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				ALWAYS_SEARCH_USER_PATHS = NO;
-				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
-				CONFIGURATION_BUILD_DIR = Build/Release;
-				GCC_DYNAMIC_NO_PIC = NO;
-				GCC_MODEL_TUNING = G5;
-				INFOPLIST_FILE = "../../../../Xcode-iOS/Demos/Info.plist";
-				INSTALL_PATH = "$(HOME)/Applications";
-				PRODUCT_NAME = "happy";
-			};
-			name = "Release";
-		};
 		115846ED1EDF44EA13E06D02 /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
-				SDKROOT = iphoneos;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
 				CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
@@ -289,27 +264,41 @@
 				GCC_ENABLE_OBJC_EXCEPTIONS = NO;
 				GCC_OPTIMIZATION_LEVEL = 0;
 				GCC_PREPROCESSOR_DEFINITIONS = (
-					"USING_PREMAKE_CONFIG_H",
-					"_DEBUG",
+					USING_PREMAKE_CONFIG_H,
+					_DEBUG,
 				);
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
 				HEADER_SEARCH_PATHS = (
-					"../..",
-					"../../../../include",
+					../..,
+					../../../../include,
 				);
-				OBJROOT = "obj/iOS/Debug";
+				OBJROOT = obj/iOS/Debug;
 				ONLY_ACTIVE_ARCH = YES;
-				SYMROOT = "Build/Debug";
+				SDKROOT = iphoneos;
+				SYMROOT = Build/Debug;
 			};
-			name = "Debug";
+			name = Debug;
+		};
+		205A208D2C4F2495443E582F /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				CONFIGURATION_BUILD_DIR = Build/Release;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_MODEL_TUNING = G5;
+				INFOPLIST_FILE = "../../../../Xcode-iOS/Demos/Info.plist";
+				INSTALL_PATH = "$(HOME)/Applications";
+				PRODUCT_NAME = happy;
+			};
+			name = Release;
 		};
 		3536279D443370B3347E7CB6 /* Release */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
-				SDKROOT = iphoneos;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
 				CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
@@ -318,25 +307,48 @@
 				GCC_ENABLE_OBJC_EXCEPTIONS = NO;
 				GCC_OPTIMIZATION_LEVEL = 3;
 				GCC_PREPROCESSOR_DEFINITIONS = (
-					"USING_PREMAKE_CONFIG_H",
-					"NDEBUG",
+					USING_PREMAKE_CONFIG_H,
+					NDEBUG,
 				);
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
 				HEADER_SEARCH_PATHS = (
-					"../..",
-					"../../../../include",
+					../..,
+					../../../../include,
 				);
-				OBJROOT = "obj/iOS/Release";
+				OBJROOT = obj/iOS/Release;
 				ONLY_ACTIVE_ARCH = NO;
-				SYMROOT = "Build/Release";
+				SDKROOT = iphoneos;
+				SYMROOT = Build/Release;
 			};
-			name = "Release";
+			name = Release;
+		};
+		563C339925F445BB2F1E01DB /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				CONFIGURATION_BUILD_DIR = Build/Debug;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_MODEL_TUNING = G5;
+				INFOPLIST_FILE = "../../../../Xcode-iOS/Demos/Info.plist";
+				INSTALL_PATH = "$(HOME)/Applications";
+				PRODUCT_NAME = happy;
+			};
+			name = Debug;
 		};
 /* End XCBuildConfiguration section */
 
 /* Begin XCConfigurationList section */
+		1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "happy" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				115846ED1EDF44EA13E06D02 /* Debug */,
+				3536279D443370B3347E7CB6 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Debug;
+		};
 		233F10BA36C35A146C6A4B3E /* Build configuration list for PBXNativeTarget "happy" */ = {
 			isa = XCConfigurationList;
 			buildConfigurations = (
@@ -344,19 +356,9 @@
 				205A208D2C4F2495443E582F /* Release */,
 			);
 			defaultConfigurationIsVisible = 0;
-			defaultConfigurationName = "Debug";
-		};
-		1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "happy" */ = {
-			isa = XCConfigurationList;
-			buildConfigurations = (
-				115846ED1EDF44EA13E06D02 /* Debug */,
-				3536279D443370B3347E7CB6 /* Release */,
-			);
-			defaultConfigurationIsVisible = 0;
-			defaultConfigurationName = "Debug";
+			defaultConfigurationName = Debug;
 		};
 /* End XCConfigurationList section */
-
 	};
 	rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
 }
--- a/premake/projects/SDL2.lua	Fri Sep 18 16:22:23 2015 -0400
+++ b/premake/projects/SDL2.lua	Sun Sep 20 23:08:36 2015 -0300
@@ -367,7 +367,7 @@
 		SDL_config
 		{
 			["SDL_AUDIO_DRIVER_COREAUDIO"] = 1,
-			["SDL_JOYSTICK_DISABLED"] = 0,
+			["SDL_JOYSTICK_MFI"] = 1,
 			["SDL_HAPTIC_DISABLED"] = 1,
 			["SDL_LOADSO_DISABLED"] = 1,
 			["SDL_THREAD_PTHREAD"] = 1,
@@ -404,5 +404,6 @@
 			"$(SDKROOT)/UIKit.framework",
 			"$(SDKROOT)/Foundation.framework",
 			"$(SDKROOT)/CoreAudio.framework",
-			"$(SDKROOT)/CoreMotion.framework"
+			"$(SDKROOT)/CoreMotion.framework",
+			"$(SDKROOT)/GameController.framework"
 		}
--- a/src/joystick/SDL_gamecontrollerdb.h	Fri Sep 18 16:22:23 2015 -0400
+++ b/src/joystick/SDL_gamecontrollerdb.h	Sun Sep 20 23:08:36 2015 -0300
@@ -45,6 +45,10 @@
     "25090500000000000000504944564944,PS3 DualShock,a:b2,b:b1,back:b9,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,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
+#if SDL_JOYSTICK_MFI
+    "4d466947616d65706164010000000000,MFi Extended Gamepad,a:b0,b:b1,start:b6,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,x:b2,y:b3,",
+    "4d466947616d65706164020000000000,MFi Gamepad,a:b0,b:b1,start:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,rightshoulder:b5,x:b2,y:b3,",
+#endif
 #if defined(__MACOSX__)
     "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. */
--- a/src/joystick/SDL_joystick.c	Fri Sep 18 16:22:23 2015 -0400
+++ b/src/joystick/SDL_joystick.c	Sun Sep 20 23:08:36 2015 -0300
@@ -669,14 +669,17 @@
             int i;
 
             /* 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);
+            }
 
-            for (i = 0; i < joystick->nbuttons; i++)
+            for (i = 0; i < joystick->nbuttons; i++) {
                 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);
+            }
 
             joystick->force_recentering = SDL_FALSE;
         }
--- a/src/joystick/iphoneos/SDL_sysjoystick.m	Fri Sep 18 16:22:23 2015 -0400
+++ b/src/joystick/iphoneos/SDL_sysjoystick.m	Sun Sep 20 23:08:36 2015 -0300
@@ -21,6 +21,10 @@
 #include "../../SDL_internal.h"
 
 /* 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_hints.h"
@@ -28,15 +32,221 @@
 #include "../SDL_sysjoystick.h"
 #include "../SDL_joystick_c.h"
 
+#if !SDL_EVENTS_DISABLED
+#include "../../events/SDL_events_c.h"
+#endif
+
 #import <CoreMotion/CoreMotion.h>
 
-/* needed for SDL_IPHONE_MAX_GFORCE macro */
-#import "SDL_config_iphoneos.h"
+#ifdef SDL_JOYSTICK_MFI
+#import <GameController/GameController.h>
+
+static id connectObserver = nil;
+static id disconnectObserver = nil;
+#endif /* SDL_JOYSTICK_MFI */
+
+static const char *accelerometerName = "iOS Accelerometer";
+static CMMotionManager *motionManager = nil;
+
+static SDL_JoystickDeviceItem *deviceList = NULL;
+
+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);
 
-const char *accelerometerName = "iOS Accelerometer";
+    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 */
+}
+
+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
 
-static CMMotionManager *motionManager = nil;
-static int numjoysticks = 0;
+    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 */
+
+    SDL_free(device->name);
+    SDL_free(device);
+
+    --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 */
+
+    return next;
+}
 
 /* Function to scan the system for joysticks.
  * Joystick 0 should be the system default joystick.
@@ -45,10 +255,48 @@
 int
 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;
@@ -67,13 +315,15 @@
 const char *
 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 */
 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.
@@ -84,19 +334,40 @@
 int
 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->nbuttons = 0;
+
+    device->joystick = joystick;
 
     @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];
+            /* Shorter times between updates can significantly increase CPU usage. */
+            motionManager.accelerometerUpdateInterval = 0.1;
+            [motionManager startAccelerometerUpdates];
+        } else {
+#ifdef SDL_JOYSTICK_MFI
+            GCController *controller = device->controller;
+            controller.controllerPausedHandler = ^(GCController *controller) {
+                if (joystick->hwdata) {
+                    ++joystick->hwdata->num_pause_presses;
+                }
+            };
+#endif /* SDL_JOYSTICK_MFI */
+        }
     }
 
     return 0;
@@ -105,7 +376,7 @@
 /* Function to determine if this joystick is attached to the system right now */
 SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
 {
-    return SDL_TRUE;
+    return joystick->hwdata != NULL;
 }
 
 static void SDL_SYS_AccelerometerUpdate(SDL_Joystick * joystick)
@@ -115,7 +386,7 @@
     CMAcceleration accel;
 
     @autoreleasepool {
-        if (!motionManager.accelerometerActive) {
+        if (!motionManager.isAccelerometerActive) {
             return;
         }
 
@@ -144,9 +415,94 @@
     accel.z = SDL_min(SDL_max(accel.z, -maxgforce), maxgforce);
 
     /* 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, 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 * 32767));
+            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 * 32767));
+
+            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.
@@ -157,15 +513,40 @@
 void
 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 */
 void
 SDL_SYS_JoystickClose(SDL_Joystick * joystick)
 {
+    SDL_JoystickDeviceItem *device = joystick->hwdata;
+
+    if (device == NULL) {
+        return;
+    }
+
+    device->joystick = NULL;
+
     @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,6 +555,24 @@
 SDL_SYS_JoystickQuit(void)
 {
     @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;
     }
 
@@ -182,21 +581,24 @@
 
 SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index )
 {
+    SDL_JoystickDeviceItem *device = GetDeviceForIndex(device_index);
     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;
 }
 
 SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick)
 {
     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;
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/joystick/iphoneos/SDL_sysjoystick_c.h	Sun Sep 20 23:08:36 2015 -0300
@@ -0,0 +1,55 @@
+/*
+  Simple DirectMedia Layer
+  Copyright (C) 1997-2015 Sam Lantinga <slouken@libsdl.org>
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+*/
+#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: */
--- a/test/testgamecontroller.c	Fri Sep 18 16:22:23 2015 -0400
+++ b/test/testgamecontroller.c	Sun Sep 20 23:08:36 2015 -0300
@@ -25,8 +25,8 @@
 #ifndef SDL_JOYSTICK_DISABLED
 
 #ifdef __IPHONEOS__
-#define SCREEN_WIDTH    320
-#define SCREEN_HEIGHT    480
+#define SCREEN_WIDTH    480
+#define SCREEN_HEIGHT    320
 #else
 #define SCREEN_WIDTH    512
 #define SCREEN_HEIGHT   317
--- a/test/testjoystick.c	Fri Sep 18 16:22:23 2015 -0400
+++ b/test/testjoystick.c	Sun Sep 20 23:08:36 2015 -0300
@@ -243,6 +243,8 @@
     int i;
     SDL_Joystick *joystick;
 
+    SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0");
+
     /* Enable standard application logging */
     SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);	
 
@@ -275,7 +277,7 @@
         }
     }
 
-#ifdef __ANDROID__
+#if defined(__ANDROID__) || defined(__IPHONEOS__)
     if (SDL_NumJoysticks() > 0) {
 #else
     if (argv[1]) {
@@ -284,7 +286,7 @@
         SDL_bool keepGoing = SDL_TRUE;
         SDL_Event event;
         int device;
-#ifdef __ANDROID__
+#if defined(__ANDROID__) || defined(__IPHONEOS__)
         device = 0;
 #else
         device = atoi(argv[1]);