aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2006-08-15 01:50:17 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2006-08-15 01:50:17 +0000
commit52116dbc660c218a7b45c776cbd4dbd1a47fd2c2 (patch)
treebc897b3aac9047b0c40f2567cb546480c171bde5
parent6d4e94badc1044dee6eb9177c8f398fe8f736a14 (diff)
- renamed variables for clarity
- added section to test the new instance tracking in output messages svn path=/trunk/externals/hcs/hid/; revision=5600
-rw-r--r--TODO41
-rw-r--r--hid.c39
-rw-r--r--hid.h4
-rw-r--r--hid_darwin.c11
-rw-r--r--hid_linux.c18
5 files changed, 65 insertions, 48 deletions
diff --git a/TODO b/TODO
index 0bb8fa6..4a25b40 100644
--- a/TODO
+++ b/TODO
@@ -23,23 +23,6 @@ I think they are unimplemented... :-(
______________________________________________________________________________
= array lookups for symbols
-- make arrays to lookup symbols by usagepage# and usage#
-
-- advantage: much fewer symbol lookups
-
-- disadvantage: much more RAM used.
-
-implementation idea #1:
-
-make hid-specific gensym() function which checks an array for the symbol by
-#. If it doesn't exist, it looks up the symbol and adds it to the array. The
-array size should be dynamically allocated so that [hid] doesn't use massive
-amounts of memory.
-
-If no vendor-defined pages are used, then the array could be quite small. If
-only one usage page is used, then it would also be not too big. Otherwise, it
-could use 10+ megs of RAM... hmm..
-
implementation idea #2:
this array should be built by hid_build_elements_list(). Then each time it
@@ -59,6 +42,15 @@ struct _hid_element
For Linux input.h, instead void *element, store the type and code numbers to
compare against
+
+______________________________________________________________________________
+= make only the first executed instance fetch the data
+
+ the function is ugen_getsortno() -- returns
+an integer which increases eachtime DSP is restarted. You can add the
+function call (to the ugen chain for instance) each time you see
+ugen_getsortno() return an integer greater than the previous one you've
+
______________________________________________________________________________
= output one value per poll
@@ -96,6 +88,21 @@ ______________________________________________________________________________
- Logical Min/Max i.e. [range -127 127(
- device string [name Trackpad(
+______________________________________________________________________________
+= get tablets working on Mac OS X
+
+http://www.versiontracker.com/php/feedback/article.php?story=20051221163326829
+
+http://www.wacom-europe.com/forum/topic.asp?TOPIC_ID=2719&ARCHIVE=
+
+______________________________________________________________________________
+= block devices like mice/keyboards etc from outputting
+
+at least document the procedure needed
+
+Mac OS X:
+http://lists.apple.com/archives/usb/2005/Aug/msg00068.html
+
______________________________________________________________________________
diff --git a/hid.c b/hid.c
index 5f7fcdd..0fe9ade 100644
--- a/hid.c
+++ b/hid.c
@@ -149,11 +149,11 @@ static unsigned int name_to_usage(char *usage_name)
static short get_device_number_from_arguments(int argc, t_atom *argv)
{
short device_number = -1;
- unsigned short usage_number;
+ unsigned short device_type_instance;
unsigned int usage;
unsigned short vendor_id;
unsigned short product_id;
- char usage_string[MAXPDSTRING] = "";
+ char device_type_string[MAXPDSTRING] = "";
t_symbol *first_argument;
t_symbol *second_argument;
@@ -162,20 +162,19 @@ static short get_device_number_from_arguments(int argc, t_atom *argv)
first_argument = atom_getsymbolarg(0,argc,argv);
if(first_argument == &s_)
{ // single float arg means device #
+ post("first_argument == &s_");
device_number = (short) atom_getfloatarg(0,argc,argv);
if(device_number < 0) device_number = -1;
debug_print(LOG_DEBUG,"[hid] setting device# to %d",device_number);
}
else
- { // single symbol arg means first instance of usage
- debug_print(LOG_DEBUG,"[hid] setting device via usagepage/usage");
- atom_string(argv, usage_string, MAXPDSTRING-1);
- usage = name_to_usage(usage_string);
- device_number = get_device_number_from_usage_list(0,
- usage >> 16,
- usage & 0xffff);
+ { // single symbol arg means first instance of a device type
+ atom_string(argv, device_type_string, MAXPDSTRING-1);
+ usage = name_to_usage(device_type_string);
+ device_number = get_device_number_from_usage(0, usage >> 16,
+ usage & 0xffff);
debug_print(LOG_INFO,"[hid] using 0x%04x 0x%04x for %s",
- usage, usage >> 16, usage & 0xffff, usage_string);
+ usage >> 16, usage & 0xffff, device_type_string);
}
}
else if(argc == 2)
@@ -184,12 +183,12 @@ static short get_device_number_from_arguments(int argc, t_atom *argv)
second_argument = atom_getsymbolarg(1,argc,argv);
if( second_argument == &s_ )
{ /* a symbol then a float means match on usage */
- atom_string(argv, usage_string, MAXPDSTRING-1);
- usage = name_to_usage(usage_string);
- usage_number = atom_getfloatarg(1,argc,argv);
+ atom_string(argv, device_type_string, MAXPDSTRING-1);
+ usage = name_to_usage(device_type_string);
+ device_type_instance = atom_getfloatarg(1,argc,argv);
debug_print(LOG_DEBUG,"[hid] looking for %s at #%d",
- usage_string,usage_number);
- device_number = get_device_number_from_usage_list(usage_number,
+ device_type_string, device_type_instance);
+ device_number = get_device_number_from_usage(device_type_instance,
usage >> 16,
usage & 0xffff);
}
@@ -211,10 +210,20 @@ void hid_output_event(t_hid *x, t_hid_element *output_data)
if( (output_data->value != output_data->previous_value) ||
(output_data->relative) ) // relative data should always be output
{
+#if 1
+ // this is [hid] compatible
t_atom event_data[2];
SETSYMBOL(event_data, output_data->name);
SETFLOAT(event_data + 1, output_data->value);
outlet_anything(x->x_data_outlet,output_data->type,2,event_data);
+#else
+ // this outputs instance number, for [hid] v2
+ t_atom event_data[3];
+ SETSYMBOL(event_data, output_data->name);
+ SETFLOAT(event_data + 1, output_data->instance);
+ SETFLOAT(event_data + 2, output_data->value);
+ outlet_anything(x->x_data_outlet,output_data->type,3,event_data);
+#endif
}
}
diff --git a/hid.h b/hid.h
index 6a2fd8c..5469f17 100644
--- a/hid.h
+++ b/hid.h
@@ -15,7 +15,7 @@
#define HID_MAJOR_VERSION 0
#define HID_MINOR_VERSION 7
-/* static char *version = "$Revision: 1.26 $"; */
+/* static char *version = "$Revision: 1.27 $"; */
/*------------------------------------------------------------------------------
* GLOBAL DEFINES
@@ -118,7 +118,7 @@ void hid_print(t_hid* x); /* print info to the console */
void hid_platform_specific_info(t_hid* x); /* device info on the status outlet */
void hid_platform_specific_free(t_hid *x);
short get_device_number_by_id(unsigned short vendor_id, unsigned short product_id);
-short get_device_number_from_usage_list(short device_number,
+short get_device_number_from_usage(short device_number,
unsigned short usage_page,
unsigned short usage);
diff --git a/hid_darwin.c b/hid_darwin.c
index ba8e0ff..b3307d9 100644
--- a/hid_darwin.c
+++ b/hid_darwin.c
@@ -2,7 +2,7 @@
/*
* Apple Darwin HID Manager support for Pd [hid] object
*
- * some code from SuperCollider3's SC_HID.cpp by Jan Truetzschler v. Falkenstein
+ * some code from SuperCollider3's SC_HID.cpp by Jan Truetzschler Falkenstein
*
* Copyright (c) 2004 Hans-Christoph All rights reserved.
*
@@ -301,7 +301,7 @@ static t_float get_type_name_instance(t_symbol *type, t_symbol *name,
short get_device_number_by_id(unsigned short vendor_id, unsigned short product_id)
{
- debug_print(LOG_DEBUG,"get_device_number_from_usage_list");
+ debug_print(LOG_DEBUG,"get_device_number_from_usage");
pRecDevice pCurrentHIDDevice;
t_int i;
@@ -331,10 +331,11 @@ short get_device_number_by_id(unsigned short vendor_id, unsigned short product_i
return(return_device_number);
}
-short get_device_number_from_usage_list(short device_number,
- unsigned short usage_page, unsigned short usage)
+short get_device_number_from_usage(short device_number,
+ unsigned short usage_page,
+ unsigned short usage)
{
-// debug_print(LOG_DEBUG,"get_device_number_from_usage_list");
+// debug_print(LOG_DEBUG,"get_device_number_from_usage");
pRecDevice pCurrentHIDDevice;
t_int i;
diff --git a/hid_linux.c b/hid_linux.c
index 93b3b3b..7147dd6 100644
--- a/hid_linux.c
+++ b/hid_linux.c
@@ -43,14 +43,14 @@
/* LINUX-SPECIFIC SUPPORT FUNCTIONS */
/* ------------------------------------------------------------------------------ */
-/* JMZ: i changed the convert functions (and the get-event function too!) to return
- * t_symbol* instead of writing into a fixed-sized buffer (which was way too
- * small and those made this object crash)
- * in order to change as little lines as possible the callback functions to the
- * hid-object still use (char*): so we convert a char[] into a symbol and then
- * extract the (char*) out of it to make it a symbol again
- * LATER: use t_symbol's all over, since it is very flexible (with respect to length)
- * and sooner or later the strings are converted to t_symbol anyhow...
+/* JMZ: i changed the convert functions (and the get-event function too!) to
+ * return t_symbol* instead of writing into a fixed-sized buffer (which was
+ * way too small and those made this object crash) in order to change as
+ * little lines as possible the callback functions to the hid-object still use
+ * (char*): so we convert a char[] into a symbol and then extract the (char*)
+ * out of it to make it a symbol again LATER: use t_symbol's all over, since
+ * it is very flexible (with respect to length) and sooner or later the
+ * strings are converted to t_symbol anyhow...
*
* Why? bug-fixing
*/
@@ -510,7 +510,7 @@ t_int get_device_number_by_id(unsigned short vendor_id, unsigned short product_i
return -1;
}
-t_int get_device_number_from_usage_list(t_int device_number,
+t_int get_device_number_from_usage(t_int device_number,
unsigned short usage_page,
unsigned short usage)
{