aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--doc/hid-help.pd124
-rw-r--r--hid.c48
-rw-r--r--hid_darwin.c27
-rw-r--r--joystick.pd123
5 files changed, 191 insertions, 135 deletions
diff --git a/Makefile b/Makefile
index 6c07330..6b55819 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ endif
# ----------------------- DARWIN -----------------------
ifeq ($(OS_NAME),Darwin)
-FRAMEWORKS = Carbon IOKit
+FRAMEWORKS = Carbon IOKit ForceFeedback
LDFLAGS = -bundle -bundle_loader $(PDEXECUTABLE) \
-L/sw/lib -L./HID\ Utilities\ Source/build \
-lHIDUtilities \
@@ -31,7 +31,7 @@ endif
PDEXECUTABLE = ../../../pd/bin/pd
CFLAGS = -DUNIX -DPD -O2 -funroll-loops -fomit-frame-pointer \
- -Wall -W -Wshadow -Wstrict-prototypes -Wno-unused
+ -Wall -W -Wno-shadow -Wstrict-prototypes -Wno-unused
INCLUDE = -I./ -I../../../pd/src -I./HID\ Utilities\ Source
diff --git a/doc/hid-help.pd b/doc/hid-help.pd
index 80ffe39..047a5db 100644
--- a/doc/hid-help.pd
+++ b/doc/hid-help.pd
@@ -1,5 +1,5 @@
-#N canvas 159 95 913 626 10;
-#X msg 455 295 syn syn_report 0;
+#N canvas 159 95 917 630 10;
+#X msg 455 295 rel rel_x -1;
#X obj 455 274 prepend set;
#X floatatom 37 484 5 0 0 0 - - -;
#X floatatom 93 484 5 0 0 0 - - -;
@@ -10,7 +10,7 @@
#X msg 275 146 open 2;
#X floatatom 84 439 7 0 0 0 - - -;
#X floatatom 138 439 7 0 0 0 - - -;
-#X obj 68 122 tgl 35 0 empty empty empty 0 -6 0 8 -24198 -1 -1 0 25
+#X obj 68 122 tgl 35 0 empty empty empty 0 -6 0 8 -24198 -1 -1 25 25
;
#X floatatom 534 356 12 0 0 1 value - -;
#X symbolatom 494 372 15 0 0 1 event_code - -;
@@ -47,13 +47,12 @@
#X text 49 588 (C) Copyright 2004 Hans-Christoph Steiner <hans@at.or.at>
;
#X text 266 602 released under the GNU GPL;
-#X text 472 589 $Revision: 1.17 $$Date: 2005-04-28 05:56:36 $;
+#X text 472 589 $Revision: 1.18 $$Date: 2005-06-04 15:51:39 $;
#X text 473 602 $Author: eighthave $;
#X floatatom 192 439 7 0 0 0 - - -;
#X msg 428 185 poll 20;
#X msg 366 185 poll 2;
#X text 362 170 start polling and set the poll delay in ms;
-#X text 387 248 event_type event_code value timestamp;
#X text 358 42 !!! This software is very much alpha \, so any aspect
of it could change without notice !!!;
#X obj 93 330 route key rel abs syn;
@@ -317,69 +316,70 @@ btn_8 btn_9;
#X obj 455 335 unpack s s f;
#X msg 248 91 open \$1;
#X obj 248 73 hradio 15 1 0 8 empty empty empty 0 -6 0 8 -262144 -1
--1 0;
+-1 2;
#X floatatom 235 94 1 0 0 0 - - -;
+#X text 387 248 event_type event_code value;
#X connect 1 0 0 0;
-#X connect 4 0 85 0;
-#X connect 5 0 85 0;
-#X connect 6 0 85 0;
-#X connect 7 0 85 0;
-#X connect 8 0 85 0;
-#X connect 11 0 85 0;
+#X connect 4 0 84 0;
+#X connect 5 0 84 0;
+#X connect 6 0 84 0;
+#X connect 7 0 84 0;
+#X connect 8 0 84 0;
+#X connect 11 0 84 0;
#X connect 32 0 31 0;
#X connect 32 0 15 0;
#X connect 33 0 32 1;
#X connect 34 0 35 1;
#X connect 35 0 34 0;
#X connect 36 0 35 0;
-#X connect 37 0 85 0;
-#X connect 38 0 85 0;
-#X connect 46 0 85 0;
-#X connect 47 0 85 0;
-#X connect 51 0 61 0;
-#X connect 51 1 93 0;
-#X connect 51 2 67 0;
-#X connect 51 3 36 0;
-#X connect 61 0 52 0;
-#X connect 61 1 53 0;
-#X connect 61 2 54 0;
-#X connect 61 3 55 0;
-#X connect 61 4 56 0;
-#X connect 61 5 57 0;
-#X connect 61 6 58 0;
-#X connect 61 7 59 0;
-#X connect 61 8 60 0;
-#X connect 61 9 62 0;
-#X connect 67 0 9 0;
-#X connect 67 1 10 0;
-#X connect 67 2 45 0;
-#X connect 67 3 68 0;
-#X connect 67 4 69 0;
-#X connect 67 5 70 0;
-#X connect 67 6 71 0;
+#X connect 37 0 84 0;
+#X connect 38 0 84 0;
+#X connect 46 0 84 0;
+#X connect 47 0 84 0;
+#X connect 50 0 60 0;
+#X connect 50 1 92 0;
+#X connect 50 2 66 0;
+#X connect 50 3 36 0;
+#X connect 60 0 51 0;
+#X connect 60 1 52 0;
+#X connect 60 2 53 0;
+#X connect 60 3 54 0;
+#X connect 60 4 55 0;
+#X connect 60 5 56 0;
+#X connect 60 6 57 0;
+#X connect 60 7 58 0;
+#X connect 60 8 59 0;
+#X connect 60 9 61 0;
+#X connect 66 0 9 0;
+#X connect 66 1 10 0;
+#X connect 66 2 45 0;
+#X connect 66 3 67 0;
+#X connect 66 4 68 0;
+#X connect 66 5 69 0;
+#X connect 66 6 70 0;
+#X connect 70 0 71 0;
+#X connect 70 1 73 0;
+#X connect 70 2 75 0;
+#X connect 70 3 77 0;
#X connect 71 0 72 0;
-#X connect 71 1 74 0;
-#X connect 71 2 76 0;
-#X connect 71 3 78 0;
-#X connect 72 0 73 0;
-#X connect 74 0 75 0;
-#X connect 76 0 77 0;
-#X connect 78 0 79 0;
-#X connect 80 0 85 0;
-#X connect 81 0 85 0;
-#X connect 84 0 85 0;
-#X connect 85 0 32 0;
-#X connect 85 0 1 0;
-#X connect 85 0 51 0;
-#X connect 85 0 95 0;
-#X connect 92 0 85 0;
-#X connect 93 0 2 0;
-#X connect 93 1 3 0;
-#X connect 93 2 66 0;
-#X connect 93 3 94 0;
-#X connect 95 0 14 0;
-#X connect 95 1 13 0;
-#X connect 95 2 12 0;
-#X connect 96 0 85 0;
-#X connect 97 0 96 0;
-#X connect 97 0 98 0;
+#X connect 73 0 74 0;
+#X connect 75 0 76 0;
+#X connect 77 0 78 0;
+#X connect 79 0 84 0;
+#X connect 80 0 84 0;
+#X connect 83 0 84 0;
+#X connect 84 0 32 0;
+#X connect 84 0 1 0;
+#X connect 84 0 50 0;
+#X connect 84 0 94 0;
+#X connect 91 0 84 0;
+#X connect 92 0 2 0;
+#X connect 92 1 3 0;
+#X connect 92 2 65 0;
+#X connect 92 3 93 0;
+#X connect 94 0 14 0;
+#X connect 94 1 13 0;
+#X connect 94 2 12 0;
+#X connect 95 0 84 0;
+#X connect 96 0 95 0;
+#X connect 96 0 97 0;
diff --git a/hid.c b/hid.c
index 92465bc..2b69f05 100644
--- a/hid.c
+++ b/hid.c
@@ -1,27 +1,27 @@
-/* ---------------------------------------------------------------------------- */
-/* */
-/* MacOS X object to use HIDs (Human Interface Devices) */
-/* Written by Hans-Christoph Steiner <hans@at.or.at> */
-/* */
-/* Copyright (c) 2004 Hans-Christoph Steiner */
-/* */
-/* This program is free software; you can redistribute it and/or */
-/* modify it under the terms of the GNU General Public License */
-/* as published by the Free Software Foundation; either version 2 */
-/* of the License, or (at your option) any later version. */
-/* */
-/* See file LICENSE for further informations on licensing terms. */
-/* */
-/* This program is distributed in the hope that it will be useful, */
-/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
-/* GNU General Public License for more details. */
-/* */
-/* You should have received a copy of the GNU General Public License */
-/* along with this program; if not, write to the Free Software */
-/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-/* */
-/* ---------------------------------------------------------------------------- */
+/* --------------------------------------------------------------------------*/
+/* */
+/* MacOS X object to use HIDs (Human Interface Devices) */
+/* Written by Hans-Christoph Steiner <hans@at.or.at> */
+/* */
+/* Copyright (c) 2004 Hans-Christoph Steiner */
+/* */
+/* This program is free software; you can redistribute it and/or */
+/* modify it under the terms of the GNU General Public License */
+/* as published by the Free Software Foundation; either version 2 */
+/* of the License, or (at your option) any later version. */
+/* */
+/* See file LICENSE for further informations on licensing terms. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program; if not, write to the Free Software Foundation, */
+/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+/* */
+/* --------------------------------------------------------------------------*/
#include "hid.h"
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
diff --git a/joystick.pd b/joystick.pd
index 23126d9..5ea64cc 100644
--- a/joystick.pd
+++ b/joystick.pd
@@ -1,53 +1,82 @@
-#N canvas 246 181 839 627 10;
-#X msg 96 64 start;
-#X msg 105 83 stop;
-#X obj 77 30 inlet;
-#X obj 207 160 print UNKNOWN_JOYSTICK_EVENT_TYPE;
-#X obj 430 289 print UNKNOWN_JOYSTICK_EVENT_CODE;
-#X obj 38 508 outlet;
-#X obj 300 342 outlet;
-#X obj 366 317 outlet;
-#X text 52 244 codes (0=X 1=Y 6=throttle 7=rudder \, 16=hat0X \, 17=hat0Y)
+#N canvas 181 117 827 593 10;
+#X msg 176 64 start;
+#X msg 185 83 stop;
+#X obj 157 30 inlet;
+#X obj 287 160 print UNKNOWN_JOYSTICK_EVENT_TYPE;
+#X obj 118 508 outlet;
+#X obj 380 342 outlet;
+#X obj 446 317 outlet;
+#X text 132 244 codes (0=X 1=Y 6=throttle 7=rudder \, 16=hat0X \, 17=hat0Y)
;
-#X obj 411 417 outlet;
-#X obj 77 107 hid \$1;
-#X obj 103 468 outlet;
-#X obj 169 428 outlet;
-#X obj 235 387 outlet;
-#X obj 221 91 print RAW;
-#X text 401 433 button code/value list;
-#X text 91 509 X-axis;
-#X text 152 468 Y-axis;
-#X text 222 430 twist;
+#X obj 625 262 outlet;
+#X obj 157 107 hid \$1;
+#X obj 183 468 outlet;
+#X obj 249 428 outlet;
+#X obj 315 387 outlet;
+#X obj 301 91 print RAW;
+#X text 574 280 button code/value list;
+#X text 171 509 X-axis;
+#X text 232 468 Y-axis;
+#X text 302 430 twist;
#X text 11 552 (C) Copyright 2004 Hans-Christoph Steiner <hans@at.or.at>
;
#X text 228 566 released under the GNU GPL;
#X text 424 566 $Author: eighthave $;
-#X text 424 553 $Revision: 1.5 $$Date: 2005-03-03 20:03:34 $;
-#X obj 38 264 route abs_x abs_y abs_rz abs_throttle abs_hat0x abs_hat0y
-;
-#X text 287 388 throttle/slider;
-#X text 346 343 hat0x;
-#X text 416 319 hat0y;
-#X obj 235 368 autoscale 0 1;
-#X obj 169 409 autoscale 0 1;
-#X obj 103 449 autoscale 0 1;
-#X obj 38 489 autoscale 0 1;
+#X text 424 553 $Revision: 1.6 $$Date: 2005-06-04 15:51:39 $;
+#X text 367 388 throttle/slider;
+#X text 426 343 hat0x;
+#X text 496 319 hat0y;
+#X obj 315 368 autoscale 0 1;
+#X obj 249 409 autoscale 0 1;
+#X obj 183 449 autoscale 0 1;
+#X obj 118 489 autoscale 0 1;
#X text 8 6 [joystick];
-#X obj 79 139 route abs key ff;
-#X connect 0 0 10 0;
-#X connect 1 0 10 0;
-#X connect 2 0 10 0;
-#X connect 10 0 32 0;
-#X connect 23 0 30 0;
-#X connect 23 1 29 0;
-#X connect 23 2 28 0;
-#X connect 23 3 27 0;
-#X connect 23 4 6 0;
-#X connect 23 5 7 0;
-#X connect 27 0 13 0;
-#X connect 28 0 12 0;
-#X connect 29 0 11 0;
-#X connect 30 0 5 0;
-#X connect 32 0 23 0;
-#X connect 32 1 9 0;
+#X obj 159 139 route abs key ff;
+#X msg 23 300 reset;
+#N canvas 657 99 454 304 reset_on_open 0;
+#X obj 37 19 inlet;
+#X obj 37 226 outlet;
+#X obj 37 116 select open;
+#X obj 37 196 spigot 0;
+#X obj 37 64 unpack symbol float;
+#X obj 165 85 t f b;
+#X obj 165 148 !=;
+#X obj 181 126 f -1;
+#X text 9 256 This object sends a bang to the outlet when getting an
+[open( message that opens a new device but not when opening the existing
+device.;
+#X connect 0 0 4 0;
+#X connect 2 0 3 0;
+#X connect 3 0 1 0;
+#X connect 4 0 2 0;
+#X connect 4 1 5 0;
+#X connect 5 0 6 0;
+#X connect 5 0 7 1;
+#X connect 5 1 7 0;
+#X connect 6 0 3 1;
+#X connect 7 0 6 1;
+#X restore 23 110 pd reset_on_open;
+#X obj 118 264 route abs_x abs_y abs_rz abs_throttle abs_hat0x abs_hat0y
+;
+#X connect 0 0 9 0;
+#X connect 1 0 9 0;
+#X connect 2 0 9 0;
+#X connect 2 0 32 0;
+#X connect 9 0 30 0;
+#X connect 25 0 12 0;
+#X connect 26 0 11 0;
+#X connect 27 0 10 0;
+#X connect 28 0 4 0;
+#X connect 30 0 33 0;
+#X connect 30 1 8 0;
+#X connect 31 0 28 0;
+#X connect 31 0 27 0;
+#X connect 31 0 26 0;
+#X connect 31 0 25 0;
+#X connect 32 0 31 0;
+#X connect 33 0 28 0;
+#X connect 33 1 27 0;
+#X connect 33 2 26 0;
+#X connect 33 3 25 0;
+#X connect 33 4 5 0;
+#X connect 33 5 6 0;