aboutsummaryrefslogtreecommitdiff
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
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
-rw-r--r--Makefile8
-rw-r--r--TODO7
-rw-r--r--doc/hid_menu-help.pd9
-rw-r--r--hid.c21
-rw-r--r--hid.h4
-rw-r--r--hid_darwin.c37
-rw-r--r--hid_menu.pd16
7 files changed, 86 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index 6b55819..c454bdd 100644
--- a/Makefile
+++ b/Makefile
@@ -30,8 +30,12 @@ endif
PDEXECUTABLE = ../../../pd/bin/pd
-CFLAGS = -DUNIX -DPD -O2 -funroll-loops -fomit-frame-pointer \
- -Wall -W -Wno-shadow -Wstrict-prototypes -Wno-unused
+# generic optimization
+OPT_FLAGS = -O3
+# G4 7450 optimization (gives errors)
+#OPT_FLAGS = -fast -mcpu=7450 -maltivec
+
+CFLAGS = $(OPT_FLAGS) -Wall -W -Wno-shadow -Wstrict-prototypes -Wno-unused
INCLUDE = -I./ -I../../../pd/src -I./HID\ Utilities\ Source
diff --git a/TODO b/TODO
index 7726230..487ccb9 100644
--- a/TODO
+++ b/TODO
@@ -1,3 +1,10 @@
+==============================================================================
+= make fake names in input_arrays.c
+
+Instead of having "NULL" names, make up names using the event type, and the
+code number, i.e. abs_41, rel_15
+
+
==============================================================================
= check out GDAM HID implementation
diff --git a/doc/hid_menu-help.pd b/doc/hid_menu-help.pd
new file mode 100644
index 0000000..3297a76
--- /dev/null
+++ b/doc/hid_menu-help.pd
@@ -0,0 +1,9 @@
+#N canvas 380 628 473 316 10;
+#X obj 5 2 cnv 15 450 20 empty empty [hid_menu] 2 11 1 18 -233017
+-66577 0;
+#X obj 422 3 pddp;
+#X text 27 270 (C) Copyright 2004 Hans-Christoph Steiner <hans@at.or.at>
+;
+#X text 244 284 released under the GNU GPL;
+#X text 161 235 For more info:;
+#X obj 266 234 pddp_open all_about_hid;
diff --git a/hid.c b/hid.c
index 2b69f05..2509d7b 100644
--- a/hid.c
+++ b/hid.c
@@ -50,13 +50,13 @@ static void hid_float(t_hid* x, t_floatarg f);
void hid_output_event(t_hid *x, char *type, char *code, t_float value)
{
- t_atom event_data[4];
+ t_atom event_data[3];
SETSYMBOL(event_data, gensym(type)); /* type */
SETSYMBOL(event_data + 1, gensym(code)); /* code */
SETFLOAT(event_data + 2, value); /* value */
- outlet_anything(x->x_obj.te_outlet,atom_gensym(event_data),2,event_data+1);
+ outlet_anything(x->x_data_outlet,atom_gensym(event_data),2,event_data+1);
}
void hid_set_from_float(t_hid *x, t_floatarg f)
@@ -115,10 +115,14 @@ t_int hid_close(t_hid *x)
}
-/* closed / same device open */
-/* open / same device no action */
-/* closed / different device open */
-/* open / different device close open */
+/* hid_open behavoir
+ * current state action
+ * ---------------------------------------
+ * closed / same device open
+ * open / same device no action
+ * closed / different device open
+ * open / different device close open
+ */
t_int hid_open(t_hid *x, t_float f)
{
@@ -241,8 +245,9 @@ static void *hid_new(t_float f)
x->x_clock = clock_new(x, (t_method)hid_read);
/* create anything outlet used for HID data */
- outlet_new(&x->x_obj, 0);
-
+ x->x_data_outlet = outlet_new(&x->x_obj, 0);
+ x->x_device_name_outlet = outlet_new(&x->x_obj, 0);
+
/* find and report the list of devices */
hid_build_device_list(x);
diff --git a/hid.h b/hid.h
index 80fdced..c83363d 100644
--- a/hid.h
+++ b/hid.h
@@ -14,7 +14,7 @@
#define HID_MAJOR_VERSION 0
#define HID_MINOR_VERSION 5
-static char *version = "$Revision: 1.14 $";
+static char *version = "$Revision: 1.15 $";
/*------------------------------------------------------------------------------
* CLASS DEF
@@ -30,6 +30,8 @@ typedef struct _hid
t_int x_delay;
t_int x_started;
t_int x_device_open;
+ t_outlet *x_data_outlet;
+ t_outlet *x_device_name_outlet;
} t_hid;
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);
}
diff --git a/hid_menu.pd b/hid_menu.pd
new file mode 100644
index 0000000..b4dabae
--- /dev/null
+++ b/hid_menu.pd
@@ -0,0 +1,16 @@
+#N canvas 469 172 252 29 10;
+#X obj 131 138 inlet;
+#X obj 15 350 outlet;
+#X obj 1 2 popup 250 25 grey90 HID_device none;
+#X msg 15 318 open \$1;
+#X obj 251 141 prepend append;
+#X msg 131 203 options;
+#X obj 131 176 route menu;
+#X connect 0 0 6 0;
+#X connect 2 0 3 0;
+#X connect 3 0 1 0;
+#X connect 4 0 2 0;
+#X connect 5 0 2 0;
+#X connect 6 0 5 0;
+#X connect 6 1 4 0;
+#X coords 0 0 1 1 252 29 1;