Fixed iOS joystick support for new API
This commit is contained in:
parent
ebdb9d4f98
commit
968ccf93b1
7 changed files with 76 additions and 20 deletions
|
@ -98,6 +98,8 @@
|
||||||
56ED04E3118A8EFD00A56AA6 /* SDL_syspower.m in Sources */ = {isa = PBXBuildFile; fileRef = 56ED04E2118A8EFD00A56AA6 /* SDL_syspower.m */; };
|
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 */; };
|
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 */; };
|
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 */; };
|
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 */; };
|
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 */; };
|
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; };
|
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>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
AA628AD9159369E3005138DD /* SDL_rotate.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_rotate.c; sourceTree = "<group>"; };
|
||||||
|
@ -830,6 +834,7 @@
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
FD689EFF0E26E5B600F90B21 /* iphoneos */,
|
FD689EFF0E26E5B600F90B21 /* iphoneos */,
|
||||||
|
AA0AD06116647BBB00CE5896 /* SDL_gamecontroller.c */,
|
||||||
FD5F9D1E0E0E08B3008E885B /* SDL_joystick.c */,
|
FD5F9D1E0E0E08B3008E885B /* SDL_joystick.c */,
|
||||||
FD5F9D1F0E0E08B3008E885B /* SDL_joystick_c.h */,
|
FD5F9D1F0E0E08B3008E885B /* SDL_joystick_c.h */,
|
||||||
FD5F9D200E0E08B3008E885B /* SDL_sysjoystick.h */,
|
FD5F9D200E0E08B3008E885B /* SDL_sysjoystick.h */,
|
||||||
|
@ -914,6 +919,7 @@
|
||||||
AA7558701595D55500BBD41B /* SDL_endian.h */,
|
AA7558701595D55500BBD41B /* SDL_endian.h */,
|
||||||
AA7558711595D55500BBD41B /* SDL_error.h */,
|
AA7558711595D55500BBD41B /* SDL_error.h */,
|
||||||
AA7558721595D55500BBD41B /* SDL_events.h */,
|
AA7558721595D55500BBD41B /* SDL_events.h */,
|
||||||
|
AA0AD06416647BD400CE5896 /* SDL_gamecontroller.h */,
|
||||||
AA7558731595D55500BBD41B /* SDL_gesture.h */,
|
AA7558731595D55500BBD41B /* SDL_gesture.h */,
|
||||||
AA7558741595D55500BBD41B /* SDL_haptic.h */,
|
AA7558741595D55500BBD41B /* SDL_haptic.h */,
|
||||||
AA7558751595D55500BBD41B /* SDL_hints.h */,
|
AA7558751595D55500BBD41B /* SDL_hints.h */,
|
||||||
|
@ -1259,6 +1265,7 @@
|
||||||
AA704DD6162AA90A0076D1C1 /* SDL_dropevents_c.h in Headers */,
|
AA704DD6162AA90A0076D1C1 /* SDL_dropevents_c.h in Headers */,
|
||||||
AA9FF9511637C6E5000DF050 /* SDL_messagebox.h in Headers */,
|
AA9FF9511637C6E5000DF050 /* SDL_messagebox.h in Headers */,
|
||||||
AABCC3941640643D00AB8930 /* SDL_uikitmessagebox.h in Headers */,
|
AABCC3941640643D00AB8930 /* SDL_uikitmessagebox.h in Headers */,
|
||||||
|
AA0AD06516647BD400CE5896 /* SDL_gamecontroller.h in Headers */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
@ -1478,6 +1485,7 @@
|
||||||
AA126AD51617C5E7005ABC8F /* SDL_uikitmodes.m in Sources */,
|
AA126AD51617C5E7005ABC8F /* SDL_uikitmodes.m in Sources */,
|
||||||
AA704DD7162AA90A0076D1C1 /* SDL_dropevents.c in Sources */,
|
AA704DD7162AA90A0076D1C1 /* SDL_dropevents.c in Sources */,
|
||||||
AABCC3951640643D00AB8930 /* SDL_uikitmessagebox.m in Sources */,
|
AABCC3951640643D00AB8930 /* SDL_uikitmessagebox.m in Sources */,
|
||||||
|
AA0AD06216647BBB00CE5896 /* SDL_gamecontroller.c in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -661,13 +661,13 @@ SDL_PrivateJoystickNeedsPolling()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* return the guid for this index*/
|
/* return the guid for this index */
|
||||||
JoystickGUID SDL_JoystickGetDeviceGUID( int device_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)
|
JoystickGUID SDL_JoystickGetGUID(SDL_Joystick * joystick)
|
||||||
{
|
{
|
||||||
return SDL_SYS_PrivateJoystickGetGUID( joystick );
|
return SDL_SYS_PrivateJoystickGetGUID( joystick );
|
||||||
|
|
|
@ -107,7 +107,7 @@ extern int SDL_SYS_JoystickNeedsPolling();
|
||||||
|
|
||||||
/* Function to return the stable GUID for a plugged in device
|
/* 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
|
/* Function to return the stable GUID for a opened joystick
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1089,7 +1089,7 @@ SDL_SYS_JoystickNeedsPolling()
|
||||||
return s_bDeviceAdded;
|
return s_bDeviceAdded;
|
||||||
}
|
}
|
||||||
|
|
||||||
JoystickGUID SDL_SYS_PrivateJoystickGetDeviceID( int device_index )
|
JoystickGUID SDL_SYS_PrivateJoystickGetDeviceGUID( int device_index )
|
||||||
{
|
{
|
||||||
recDevice *device = gpDeviceList;
|
recDevice *device = gpDeviceList;
|
||||||
int index;
|
int index;
|
||||||
|
|
|
@ -37,13 +37,12 @@ const char *accelerometerName = "iPhone accelerometer";
|
||||||
int
|
int
|
||||||
SDL_SYS_JoystickInit(void)
|
SDL_SYS_JoystickInit(void)
|
||||||
{
|
{
|
||||||
SDL_numjoysticks = 1;
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Function to get the device-dependent name of a joystick */
|
/* Function to get the device-dependent name of a joystick */
|
||||||
const char *
|
const char *
|
||||||
SDL_SYS_JoystickName(int index)
|
SDL_SYS_JoystickNameForIndex(int index)
|
||||||
{
|
{
|
||||||
switch(index) {
|
switch(index) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -60,14 +59,13 @@ SDL_SYS_JoystickName(int index)
|
||||||
It returns 0, or -1 if there is an error.
|
It returns 0, or -1 if there is an error.
|
||||||
*/
|
*/
|
||||||
int
|
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->naxes = 3;
|
||||||
joystick->nhats = 0;
|
joystick->nhats = 0;
|
||||||
joystick->nballs = 0;
|
joystick->nballs = 0;
|
||||||
joystick->nbuttons = 0;
|
joystick->nbuttons = 0;
|
||||||
joystick->name = accelerometerName;
|
|
||||||
[[SDLUIAccelerationDelegate sharedDelegate] startup];
|
[[SDLUIAccelerationDelegate sharedDelegate] startup];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -107,7 +105,7 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
|
||||||
void
|
void
|
||||||
SDL_SYS_JoystickClose(SDL_Joystick * joystick)
|
SDL_SYS_JoystickClose(SDL_Joystick * joystick)
|
||||||
{
|
{
|
||||||
if (joystick->index == 0 && [[SDLUIAccelerationDelegate sharedDelegate] isRunning]) {
|
if ([[SDLUIAccelerationDelegate sharedDelegate] isRunning]) {
|
||||||
[[SDLUIAccelerationDelegate sharedDelegate] shutdown];
|
[[SDLUIAccelerationDelegate sharedDelegate] shutdown];
|
||||||
}
|
}
|
||||||
SDL_SetError("No joystick open with that index");
|
SDL_SetError("No joystick open with that index");
|
||||||
|
@ -121,4 +119,51 @@ SDL_SYS_JoystickQuit(void)
|
||||||
{
|
{
|
||||||
return;
|
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: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -513,7 +513,7 @@ SDL_SYS_JoystickNameForIndex(int index)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
static char namebuf[128];
|
static char namebuf[128];
|
||||||
char *name;
|
const char *name;
|
||||||
SDL_logical_joydecl(int oindex = index);
|
SDL_logical_joydecl(int oindex = index);
|
||||||
|
|
||||||
#ifndef NO_LOGICAL_JOYSTICKS
|
#ifndef NO_LOGICAL_JOYSTICKS
|
||||||
|
@ -1248,7 +1248,7 @@ SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int index)
|
||||||
/* Function to determine is this joystick is attached to the system right now */
|
/* Function to determine is this joystick is attached to the system right now */
|
||||||
int SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
|
int SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
|
||||||
{
|
{
|
||||||
return !joystick->closed;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_SYS_NumJoysticks()
|
int SDL_SYS_NumJoysticks()
|
||||||
|
@ -1265,24 +1265,27 @@ void SDL_SYS_JoystickDetect()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
// the GUID is just the first 16 chars of the name for now
|
||||||
const char *name = SDL_SYS_JoystickNameForIndex( device_index );
|
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;
|
return guid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
JoystickGUID SDL_SYS_PrivateJoystickGetGUID(SDL_Joystick * joystick)
|
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
|
// the GUID is just the first 16 chars of the name for now
|
||||||
const char *name = SDL_SYS_JoystickNameForIndex( joystick->name );
|
const char *name = joystick->name;
|
||||||
SDL_memcpy( &guid, name, sizeof(guid) );
|
SDL_zero( guid );
|
||||||
|
SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
|
||||||
return guid;
|
return guid;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SDL_JOYSTICK_LINUX */
|
#endif /* SDL_JOYSTICK_LINUX */
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -1651,7 +1651,7 @@ int SDL_SYS_JoystickNeedsPolling()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return the stable device guid for this device index */
|
/* 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;
|
JoyStick_DeviceData *device = SYS_Joystick;
|
||||||
int index;
|
int index;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue