Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
First draft of darwin haptic<->joystick stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbens committed Aug 10, 2008
1 parent e64959b commit 4a0ba98
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/haptic/darwin/SDL_syshaptic.c
Expand Up @@ -447,6 +447,8 @@ SDL_SYS_HapticMouse(void)
int
SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
{
if (joystick->hwdata->ffservice != 0)
return SDL_TRUE;
return SDL_FALSE;
}

Expand All @@ -457,6 +459,8 @@ SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
int
SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
{
if (IOObjectIsEqualTo(haptic->hwdata->device, joystick->hwdata->ffservice))
return 1;
return 0;
}

Expand All @@ -467,7 +471,8 @@ SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
int
SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
{
return -1;
return SDL_SYS_HapticOpenFromService(haptic,
joystick->hwdata->ffservice);
}


Expand Down
18 changes: 16 additions & 2 deletions src/joystick/darwin/SDL_sysjoystick.c
Expand Up @@ -545,6 +545,12 @@ HIDDisposeDevice(recDevice ** ppDevice)
/* save next device prior to disposing of this device */
pDeviceNext = (*ppDevice)->pNext;

/* free posible io_service_t */
if ((*ppDevice)->ffservice) {
IOObjectRelease((*ppDevice)->ffservice);
(*ppDevice)->ffservice = 0;
}

/* free element lists */
HIDDisposeElementList(&(*ppDevice)->firstAxis);
HIDDisposeElementList(&(*ppDevice)->firstButton);
Expand Down Expand Up @@ -637,8 +643,16 @@ SDL_SYS_JoystickInit(void)
if (!device)
continue;

/* dump device object, it is no longer needed */
result = IOObjectRelease(ioHIDDeviceObject);
/* We have to do some storage of the io_service_t for
* SDL_HapticOpenFromJoystick */
if (FFIsForceFeedback(device) == FF_OK) {
device->ffservice = ioHIDDeviceObject;
}
else {
device->ffservice = 0;
/* dump device object, it is no longer needed */
result = IOObjectRelease(ioHIDDeviceObject);
}
/* if (KERN_SUCCESS != result)
HIDReportErrorNum ("IOObjectRelease error with ioHIDDeviceObject.", result);
*/
Expand Down
1 change: 1 addition & 0 deletions src/joystick/darwin/SDL_sysjoystick_c.h
Expand Up @@ -60,6 +60,7 @@ typedef struct recElement recElement;

struct joystick_hwdata
{
io_service_t ffservice; /* Interface for force feedback, 0 = no ff */
IOHIDDeviceInterface **interface; /* interface to device, NULL = no interface */

char product[256]; /* name of product */
Expand Down

0 comments on commit 4a0ba98

Please sign in to comment.