--- a/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj Mon Nov 26 18:51:17 2012 -0800
+++ b/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj Mon Nov 26 21:11:28 2012 -0800
@@ -98,6 +98,8 @@
56ED04E3118A8EFD00A56AA6 /* SDL_syspower.m in Sources */ = {isa = PBXBuildFile; fileRef = 56ED04E2118A8EFD00A56AA6 /* SDL_syspower.m */; };
93CB792313FC5E5200BD3E05 /* SDL_uikitviewcontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = 93CB792213FC5E5200BD3E05 /* SDL_uikitviewcontroller.h */; };
93CB792613FC5F5300BD3E05 /* SDL_uikitviewcontroller.m in Sources */ = {isa = PBXBuildFile; fileRef = 93CB792513FC5F5300BD3E05 /* SDL_uikitviewcontroller.m */; };
+ AA0AD06216647BBB00CE5896 /* SDL_gamecontroller.c in Sources */ = {isa = PBXBuildFile; fileRef = AA0AD06116647BBB00CE5896 /* SDL_gamecontroller.c */; };
+ AA0AD06516647BD400CE5896 /* SDL_gamecontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = AA0AD06416647BD400CE5896 /* SDL_gamecontroller.h */; };
AA126AD41617C5E7005ABC8F /* SDL_uikitmodes.h in Headers */ = {isa = PBXBuildFile; fileRef = AA126AD21617C5E6005ABC8F /* SDL_uikitmodes.h */; };
AA126AD51617C5E7005ABC8F /* SDL_uikitmodes.m in Sources */ = {isa = PBXBuildFile; fileRef = AA126AD31617C5E6005ABC8F /* SDL_uikitmodes.m */; };
AA628ADB159369E3005138DD /* SDL_rotate.c in Sources */ = {isa = PBXBuildFile; fileRef = AA628AD9159369E3005138DD /* SDL_rotate.c */; };
@@ -356,6 +358,8 @@
56ED04E2118A8EFD00A56AA6 /* SDL_syspower.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDL_syspower.m; path = ../../src/power/uikit/SDL_syspower.m; sourceTree = SOURCE_ROOT; };
93CB792213FC5E5200BD3E05 /* SDL_uikitviewcontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_uikitviewcontroller.h; sourceTree = "<group>"; };
93CB792513FC5F5300BD3E05 /* SDL_uikitviewcontroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_uikitviewcontroller.m; sourceTree = "<group>"; };
+ AA0AD06116647BBB00CE5896 /* SDL_gamecontroller.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_gamecontroller.c; sourceTree = "<group>"; };
+ AA0AD06416647BD400CE5896 /* SDL_gamecontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_gamecontroller.h; sourceTree = "<group>"; };
AA126AD21617C5E6005ABC8F /* SDL_uikitmodes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_uikitmodes.h; sourceTree = "<group>"; };
AA126AD31617C5E6005ABC8F /* SDL_uikitmodes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_uikitmodes.m; sourceTree = "<group>"; };
AA628AD9159369E3005138DD /* SDL_rotate.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_rotate.c; sourceTree = "<group>"; };
@@ -830,6 +834,7 @@
isa = PBXGroup;
children = (
FD689EFF0E26E5B600F90B21 /* iphoneos */,
+ AA0AD06116647BBB00CE5896 /* SDL_gamecontroller.c */,
FD5F9D1E0E0E08B3008E885B /* SDL_joystick.c */,
FD5F9D1F0E0E08B3008E885B /* SDL_joystick_c.h */,
FD5F9D200E0E08B3008E885B /* SDL_sysjoystick.h */,
@@ -914,6 +919,7 @@
AA7558701595D55500BBD41B /* SDL_endian.h */,
AA7558711595D55500BBD41B /* SDL_error.h */,
AA7558721595D55500BBD41B /* SDL_events.h */,
+ AA0AD06416647BD400CE5896 /* SDL_gamecontroller.h */,
AA7558731595D55500BBD41B /* SDL_gesture.h */,
AA7558741595D55500BBD41B /* SDL_haptic.h */,
AA7558751595D55500BBD41B /* SDL_hints.h */,
@@ -1259,6 +1265,7 @@
AA704DD6162AA90A0076D1C1 /* SDL_dropevents_c.h in Headers */,
AA9FF9511637C6E5000DF050 /* SDL_messagebox.h in Headers */,
AABCC3941640643D00AB8930 /* SDL_uikitmessagebox.h in Headers */,
+ AA0AD06516647BD400CE5896 /* SDL_gamecontroller.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1478,6 +1485,7 @@
AA126AD51617C5E7005ABC8F /* SDL_uikitmodes.m in Sources */,
AA704DD7162AA90A0076D1C1 /* SDL_dropevents.c in Sources */,
AABCC3951640643D00AB8930 /* SDL_uikitmessagebox.m in Sources */,
+ AA0AD06216647BBB00CE5896 /* SDL_gamecontroller.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
--- a/src/joystick/SDL_joystick.c Mon Nov 26 18:51:17 2012 -0800
+++ b/src/joystick/SDL_joystick.c Mon Nov 26 21:11:28 2012 -0800
@@ -661,13 +661,13 @@
}
-/* return the guid for this index*/
+/* return the guid for this index */
JoystickGUID SDL_JoystickGetDeviceGUID( int device_index )
{
- return SDL_SYS_PrivateJoystickGetDeviceID( device_index );
+ return SDL_SYS_PrivateJoystickGetDeviceGUID( device_index );
}
-/* return the guid for this openeded device*/
+/* return the guid for this opened device */
JoystickGUID SDL_JoystickGetGUID(SDL_Joystick * joystick)
{
return SDL_SYS_PrivateJoystickGetGUID( joystick );
--- a/src/joystick/SDL_sysjoystick.h Mon Nov 26 18:51:17 2012 -0800
+++ b/src/joystick/SDL_sysjoystick.h Mon Nov 26 21:11:28 2012 -0800
@@ -107,7 +107,7 @@
/* Function to return the stable GUID for a plugged in device
*/
-extern JoystickGUID SDL_SYS_PrivateJoystickGetDeviceID( int device_index );
+extern JoystickGUID SDL_SYS_PrivateJoystickGetDeviceGUID( int device_index );
/* Function to return the stable GUID for a opened joystick
*/
--- a/src/joystick/darwin/SDL_sysjoystick.c Mon Nov 26 18:51:17 2012 -0800
+++ b/src/joystick/darwin/SDL_sysjoystick.c Mon Nov 26 21:11:28 2012 -0800
@@ -1089,7 +1089,7 @@
return s_bDeviceAdded;
}
-JoystickGUID SDL_SYS_PrivateJoystickGetDeviceID( int device_index )
+JoystickGUID SDL_SYS_PrivateJoystickGetDeviceGUID( int device_index )
{
recDevice *device = gpDeviceList;
int index;
--- a/src/joystick/iphoneos/SDL_sysjoystick.m Mon Nov 26 18:51:17 2012 -0800
+++ b/src/joystick/iphoneos/SDL_sysjoystick.m Mon Nov 26 21:11:28 2012 -0800
@@ -37,13 +37,12 @@
int
SDL_SYS_JoystickInit(void)
{
- SDL_numjoysticks = 1;
return (1);
}
/* Function to get the device-dependent name of a joystick */
const char *
-SDL_SYS_JoystickName(int index)
+SDL_SYS_JoystickNameForIndex(int index)
{
switch(index) {
case 0:
@@ -60,14 +59,13 @@
It returns 0, or -1 if there is an error.
*/
int
-SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
+SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
{
- if (joystick->index == 0) {
+ if (device_index == 0) {
joystick->naxes = 3;
joystick->nhats = 0;
joystick->nballs = 0;
joystick->nbuttons = 0;
- joystick->name = accelerometerName;
[[SDLUIAccelerationDelegate sharedDelegate] startup];
return 0;
}
@@ -107,7 +105,7 @@
void
SDL_SYS_JoystickClose(SDL_Joystick * joystick)
{
- if (joystick->index == 0 && [[SDLUIAccelerationDelegate sharedDelegate] isRunning]) {
+ if ([[SDLUIAccelerationDelegate sharedDelegate] isRunning]) {
[[SDLUIAccelerationDelegate sharedDelegate] shutdown];
}
SDL_SetError("No joystick open with that index");
@@ -121,4 +119,51 @@
{
return;
}
+
+/* Function to perform the mapping from device index to the instance id for this index */
+SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int index)
+{
+ return index;
+}
+
+/* Function to determine is this joystick is attached to the system right now */
+int SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
+{
+ return 1;
+}
+
+int SDL_SYS_NumJoysticks()
+{
+ return 1;
+}
+
+int SDL_SYS_JoystickNeedsPolling()
+{
+ return 0;
+}
+
+void SDL_SYS_JoystickDetect()
+{
+}
+
+JoystickGUID SDL_SYS_PrivateJoystickGetDeviceGUID( int device_index )
+{
+ JoystickGUID guid;
+ // the GUID is just the first 16 chars of the name for now
+ const char *name = SDL_SYS_JoystickNameForIndex( device_index );
+ SDL_zero( guid );
+ SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
+ return guid;
+}
+
+JoystickGUID SDL_SYS_PrivateJoystickGetGUID(SDL_Joystick * joystick)
+{
+ 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 ) ) );
+ return guid;
+}
+
/* vi: set ts=4 sw=4 expandtab: */
--- a/src/joystick/linux/SDL_sysjoystick.c Mon Nov 26 18:51:17 2012 -0800
+++ b/src/joystick/linux/SDL_sysjoystick.c Mon Nov 26 21:11:28 2012 -0800
@@ -513,7 +513,7 @@
{
int fd;
static char namebuf[128];
- char *name;
+ const char *name;
SDL_logical_joydecl(int oindex = index);
#ifndef NO_LOGICAL_JOYSTICKS
@@ -1248,7 +1248,7 @@
/* Function to determine is this joystick is attached to the system right now */
int SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
{
- return !joystick->closed;
+ return 1;
}
int SDL_SYS_NumJoysticks()
@@ -1265,24 +1265,27 @@
{
}
-JoystickGUID SDL_SYS_PrivateJoystickGetDeviceID( int device_index )
+JoystickGUID SDL_SYS_PrivateJoystickGetDeviceGUID( int device_index )
{
- static JoystickGUID guid;
+ JoystickGUID guid;
// the GUID is just the first 16 chars of the name for now
const char *name = SDL_SYS_JoystickNameForIndex( device_index );
- SDL_memcpy( &guid, name, sizeof(guid) );
+ SDL_zero( guid );
+ SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
return guid;
}
JoystickGUID SDL_SYS_PrivateJoystickGetGUID(SDL_Joystick * joystick)
{
- static JoystickGUID guid;
+ JoystickGUID guid;
// the GUID is just the first 16 chars of the name for now
- const char *name = SDL_SYS_JoystickNameForIndex( joystick->name );
- SDL_memcpy( &guid, name, sizeof(guid) );
+ const char *name = joystick->name;
+ SDL_zero( guid );
+ SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
return guid;
}
#endif /* SDL_JOYSTICK_LINUX */
+
/* vi: set ts=4 sw=4 expandtab: */
--- a/src/joystick/windows/SDL_dxjoystick.c Mon Nov 26 18:51:17 2012 -0800
+++ b/src/joystick/windows/SDL_dxjoystick.c Mon Nov 26 21:11:28 2012 -0800
@@ -1651,7 +1651,7 @@
}
/* return the stable device guid for this device index */
-JoystickGUID SDL_SYS_PrivateJoystickGetDeviceID( int device_index )
+JoystickGUID SDL_SYS_PrivateJoystickGetDeviceGUID( int device_index )
{
JoyStick_DeviceData *device = SYS_Joystick;
int index;