From 430c2443455673d87af07af024caf872ff4f2b68 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Sat, 4 Jun 2005 15:51:39 +0000 Subject: 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 --- hid_darwin.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'hid_darwin.c') 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 +#include #include #include @@ -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 -- cgit v1.2.1