aboutsummaryrefslogtreecommitdiff
path: root/hid_darwin.c
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2005-06-06 22:39:51 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2005-06-06 22:39:51 +0000
commit0060c5e3213b60801346e9aadb2cb1523c7762b2 (patch)
treec96fc239a1e4d46abc09295019875618001b3744 /hid_darwin.c
parent2f76356218d772155f218efd2209613376e06440 (diff)
- cleaned up CFLAGS and tried higher optimization, which failed to build
- implemented a second outlet which outputs data upon [refresh( to build a popup menu to select the device by name using a [popup]. This uncovered a bug, which is not fixed, it seems that everytime you open a device, that device gets added again to the list of devices svn path=/trunk/externals/hcs/hid/; revision=3122
Diffstat (limited to 'hid_darwin.c')
-rw-r--r--hid_darwin.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/hid_darwin.c b/hid_darwin.c
index 532ecd7..9f3f854 100644
--- a/hid_darwin.c
+++ b/hid_darwin.c
@@ -52,8 +52,8 @@
#include "hid.h"
-#define DEBUG(x)
-//#define DEBUG(x) x
+//#define DEBUG(x)
+#define DEBUG(x) x
/*==============================================================================
* GLOBAL VARS
@@ -293,6 +293,21 @@ void hid_print_device_list(t_hid *x)
}
}
+void hid_output_device_name(t_hid *x, char *manufacturer, char *product)
+{
+ char *device_name;
+ t_symbol *device_name_symbol;
+
+ device_name = malloc( strlen(manufacturer) + 1 + strlen(product) + 1 );
+// device_name = malloc( 7 + strlen(manufacturer) + 1 + strlen(product) + 1 );
+// strcpy( device_name, "append " );
+ strcat( device_name, manufacturer );
+ strcat ( device_name, " ");
+ strcat( device_name, product );
+// outlet_anything( x->x_device_name_outlet, gensym( device_name ),0,NULL );
+ outlet_symbol( x->x_device_name_outlet, gensym( device_name ) );
+}
+
/* ============================================================================== */
/* Pd [hid] FUNCTIONS */
/* ============================================================================== */
@@ -477,8 +492,7 @@ t_int hid_open_device(t_hid *x, t_int device_number)
return(1);
}
-// this doesn't seem to be needed at all
-// result = HIDCreateOpenDeviceInterface(pCurrentHIDDevice);
+ hid_output_device_name( x, pCurrentHIDDevice->manufacturer, pCurrentHIDDevice->product );
post("[hid] opened device %d: %s %s",
device_number, pCurrentHIDDevice->manufacturer, pCurrentHIDDevice->product);
@@ -521,9 +535,22 @@ t_int hid_build_device_list(t_hid *x)
{
DEBUG(post("hid_build_device_list"););
- // returns false if no device found
+ pRecDevice pCurrentHIDDevice;
+ t_atom device_name_atoms[2];
+
+// returns false if no device found
if(HIDBuildDeviceList (NULL, NULL))
error("[hid]: no HID devices found\n");
+
+ /* send the [menu( msg to set the [hid_menu] to blank */
+ outlet_anything( x->x_device_name_outlet, gensym( "menu" ),0,NULL );
+
+ pCurrentHIDDevice = HIDGetFirstDevice();
+ while ( pCurrentHIDDevice != NULL )
+ {
+ hid_output_device_name( x, pCurrentHIDDevice->manufacturer, pCurrentHIDDevice->product );
+ pCurrentHIDDevice = HIDGetNextDevice(pCurrentHIDDevice);
+ }
return (0);
}