aboutsummaryrefslogtreecommitdiff
path: root/hid_darwin.c
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2005-06-04 15:51:39 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2005-06-04 15:51:39 +0000
commit430c2443455673d87af07af024caf872ff4f2b68 (patch)
treef94080772ce005a7e6ab55deedc546bb084e61a6 /hid_darwin.c
parentb6436b67c81444fe0740035474cf0fe390f5895a (diff)
updated joystick support on Mac OS X so that joystick twist is set to abs_rz and throttle is set to abs_throttle even when devices use different code pages (USB HID spec sucks!); minor code cleanups
svn path=/trunk/externals/hcs/hid/; revision=3111
Diffstat (limited to 'hid_darwin.c')
-rw-r--r--hid_darwin.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/hid_darwin.c b/hid_darwin.c
index 3c799c9..532ecd7 100644
--- a/hid_darwin.c
+++ b/hid_darwin.c
@@ -45,6 +45,7 @@
#include "HID_Utilities_External.h"
#include <IOKit/hid/IOHIDUsageTables.h>
+#include <ForceFeedback/ForceFeedback.h>
#include <mach/mach.h>
#include <mach/mach_error.h>
@@ -73,6 +74,10 @@ char *convertEventsFromDarwinToLinux(pRecElement element);
*==============================================================================
*/
+/*
+ * This function is needed to translate the USB HID relative flag into the
+ * [hid]/linux style events
+ */
void convertAxis(pRecElement element, char *linux_type, char *linux_code, char *axis)
{
if (element->relative)
@@ -116,6 +121,15 @@ void convertDarwinElementToLinuxTypeCode(pRecElement element, char *linux_type,
sprintf(linux_type,"abs");sprintf(linux_code,"abs_throttle");break;
}
break;
+ case kHIDPage_Simulation:
+ switch (element->usage)
+ {
+ case kHIDUsage_Sim_Rudder:
+ sprintf(linux_type,"abs");sprintf(linux_code,"abs_rz");break;
+ case kHIDUsage_Sim_Throttle:
+ sprintf(linux_type,"abs");sprintf(linux_code,"abs_throttle");break;
+ }
+ break;
case kHIDPage_KeyboardOrKeypad:
sprintf(linux_type, "key");
/* temporary kludge until I feel like writing the translation table */
@@ -441,6 +455,9 @@ t_int hid_open_device(t_hid *x, t_int device_number)
t_int result = 0;
pRecDevice pCurrentHIDDevice = NULL;
+ io_service_t hidDevice = NULL;
+ FFDeviceObjectReference *pDeviceReference = NULL;
+
/* rebuild device list to make sure the list is current */
if ( ! HIDHaveDeviceList() )
{
@@ -468,6 +485,16 @@ t_int hid_open_device(t_hid *x, t_int device_number)
hid_build_element_list(x);
+ if ( FFIsForceFeedback(hidDevice) == FF_OK )
+ {
+ post("device has Force Feedback support");
+ if ( FFCreateDevice(hidDevice,pDeviceReference) == FF_OK )
+ {
+ post("created FF device");
+ }
+ }
+
+
HIDQueueDevice(pCurrentHIDDevice);
// TODO: queue all elements except absolute axes, those can just be polled