[PD-cvs] externals/hcs/hid TODO, 1.25, 1.26 hid.c, 1.25, 1.26 hid.h, 1.24, 1.25 hid_darwin.c, 1.24, 1.25
Hans-Christoph Steiner
eighthave at users.sourceforge.net
Fri Jun 2 23:32:55 CEST 2006
Update of /cvsroot/pure-data/externals/hcs/hid
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29303
Modified Files:
TODO hid.c hid.h hid_darwin.c
Log Message:
added a bunch more status info in the Pd domain: device count, range for each element, etc
Index: TODO
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/TODO,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** TODO 2 Jun 2006 20:06:50 -0000 1.25
--- TODO 2 Jun 2006 21:32:53 -0000 1.26
***************
*** 1,2 ****
--- 1,9 ----
+ ______________________________________________________________________________
+ - deal with hatswitches!!
+
+ Because of the currnently implementation of the conversion of the MacOS X
+ style event to the Linux style event, an event with a value of zero is output
+ on the unchanged axis when the hatswitch is moved in along the X or Y axis (as
+ opposed to diagonally). but this might be fixed...
- fix up hatswitch logic... hmmm
***************
*** 5,15 ****
then output again (yes, its a hack).
! - add device type to [info(
! HIDGetUsageName(pCurrentHIDDevice->usagePage, pCurrentHIDDevice->usage, cstrDeviceName);
!
! i.e. cstrDeviceName
______________________________________________________________________________
--- 12,23 ----
then output again (yes, its a hack).
! - what do standard hatswitches output on the various platforms? they should
! probably always output like axes, but then the CUI will be screwed
+ ______________________________________________________________________________
+ = fix key names on Mac OS X
+ I think they are unimplemented... :-(
______________________________________________________________________________
***************
*** 58,71 ****
http://lists.apple.com/archives/mac-games-dev/2005/Oct/msg00060.html
- - for absolute axes, just output latest value. if they are not in the queue,
- I can check them manually
-
- - buttons, output everything
-
- - is this at all necessary? How often do multiple events happen in one poll
- period? ANSWER: on Mac OS X, most hid_get_events() calls fetch multiple
- events for each mouse axis, so yes, its probably necessary
-
-
______________________________________________________________________________
= [poll 1( message set to exact delay based on block size
--- 66,69 ----
***************
*** 83,88 ****
______________________________________________________________________________
! = make second inlet for poll # (for [human->pd])
______________________________________________________________________________
--- 81,91 ----
______________________________________________________________________________
! = make second inlet for specific status requests [human->pd])
+ - [vendor(, [product(
+ - [range(
+ - [poll(
+ - [name(
+ - [type(
______________________________________________________________________________
***************
*** 193,206 ****
______________________________________________________________________________
- = function return values
-
- - most functions probably do not need return values
-
-
- ______________________________________________________________________________
= check out using USB timestamp
! - use the USB timestamp to correctly space the output data (meh, probably
! unnecessary)
--- 196,204 ----
______________________________________________________________________________
= check out using USB timestamp
! - use the USB timestamp to correctly space the output data
!
! (meh, probably not useful)
***************
*** 217,221 ****
______________________________________________________________________________
! - BUG: on Mac OS X, polling starts without hid_build_device_list()
- when polling starts, hid_build_device_list() should be called before starting
--- 215,219 ----
______________________________________________________________________________
! - BUG: on Mac OS X, polling starts without hid_build_device_list() or hid_open()
- when polling starts, hid_build_device_list() should be called before starting
***************
*** 251,262 ****
- ______________________________________________________________________________
- - BUG: hatswitches on MacOS X output an event without a change in value
-
- Because of the currnently implementation of the conversion of the MacOS X
- style event to the Linux style event, an event with a value of zero is output
- on the unchanged axis when the hatswitch is moved in along the X or Y axis (as
- opposed to diagonally).
-
______________________________________________________________________________
--- 249,252 ----
Index: hid_darwin.c
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/hid_darwin.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** hid_darwin.c 2 Jun 2006 20:06:50 -0000 1.24
--- hid_darwin.c 2 Jun 2006 21:32:53 -0000 1.25
***************
*** 61,65 ****
*======================================================================== */
! extern t_int hid_instance_count;
/* store device pointers so I don't have to query them all the time */
--- 61,65 ----
*======================================================================== */
! extern t_int hid_instance_count; // in hid.h
/* store device pointers so I don't have to query them all the time */
***************
*** 433,453 ****
//case kHIDUsage_GD_Hatswitch: // hatswitches are more like buttons, so queue them
debug_print(LOG_INFO,"[hid] storing absolute axis to poll %s, %s (0x%04x 0x%04x)",
! type_name, usage_name, pCurrentHIDElement->usagePage, pCurrentHIDElement->usage);
if(HIDDequeueElement(pCurrentHIDDevice,pCurrentHIDElement) != kIOReturnSuccess)
debug_print(LOG_ERR,"[hid] could not dequeue element");
new_element->polled = 1;
break;
- default:
- debug_print(LOG_CRIT,"[hid] SKIPPED %s, %s (0x%04x 0x%04x)x", type_name, usage_name,
- pCurrentHIDElement->usagePage, pCurrentHIDElement->usage);
}
}
else
{
! debug_print(LOG_INFO,"[hid] queuing element %s, %s (0x%04x 0x%04x)",type_name, usage_name,
pCurrentHIDElement->usagePage, pCurrentHIDElement->usage);
}
! post("\tlogical min %d max %d",pCurrentHIDElement->minReport,pCurrentHIDElement->maxReport);
!
element[x->x_device_number][element_count[x->x_device_number]] = new_element;
++element_count[x->x_device_number];
--- 433,454 ----
//case kHIDUsage_GD_Hatswitch: // hatswitches are more like buttons, so queue them
debug_print(LOG_INFO,"[hid] storing absolute axis to poll %s, %s (0x%04x 0x%04x)",
! type_name, usage_name,
! pCurrentHIDElement->usagePage, pCurrentHIDElement->usage);
if(HIDDequeueElement(pCurrentHIDDevice,pCurrentHIDElement) != kIOReturnSuccess)
debug_print(LOG_ERR,"[hid] could not dequeue element");
new_element->polled = 1;
break;
}
}
else
{
! debug_print(LOG_INFO,"[hid] queuing element %s, %s (0x%04x 0x%04x)",
! type_name, usage_name,
pCurrentHIDElement->usagePage, pCurrentHIDElement->usage);
}
! new_element->min = pCurrentHIDElement->min;
! new_element->max = pCurrentHIDElement->max;
! debug_print(LOG_DEBUG,"\tlogical min %d max %d",
! pCurrentHIDElement->min,pCurrentHIDElement->max);
element[x->x_device_number][element_count[x->x_device_number]] = new_element;
++element_count[x->x_device_number];
***************
*** 520,523 ****
--- 521,525 ----
char device_type_buffer[256];
t_int i, numdevs;
+ unsigned int j;
pRecDevice pCurrentHIDDevice = NULL;
***************
*** 537,540 ****
--- 539,544 ----
HIDGetUsageName(pCurrentHIDDevice->usagePage, pCurrentHIDDevice->usage,
device_type_buffer);
+ for(j=0; j< strlen(device_type_buffer); ++j)
+ device_type_buffer[j] = tolower(device_type_buffer[j]);
post("\tdevice type: %s\tusage page: 0x%04x\tusage: 0x%04x",
device_type_buffer, pCurrentHIDDevice->usagePage,
***************
*** 552,558 ****
--- 556,564 ----
void hid_platform_specific_info(t_hid *x)
{
+ unsigned int i;
pRecDevice pCurrentHIDDevice = NULL;
char vendor_id_string[7];
char product_id_string[7];
+ char device_type_buffer[256];
t_symbol *output_symbol;
t_atom *output_atom = getbytes(sizeof(t_atom));
***************
*** 572,576 ****
outlet_anything( x->x_status_outlet, gensym("manufacturer"),
1, output_atom);
! /* serial */
if(pCurrentHIDDevice->serial != NULL)
{
--- 578,582 ----
outlet_anything( x->x_status_outlet, gensym("manufacturer"),
1, output_atom);
! /* serial number */
if(pCurrentHIDDevice->serial != NULL)
{
***************
*** 599,602 ****
--- 605,617 ----
outlet_anything( x->x_status_outlet, gensym("productID"),
1, output_atom);
+ /* type */
+ HIDGetUsageName(pCurrentHIDDevice->usagePage,
+ pCurrentHIDDevice->usage,
+ device_type_buffer);
+ for(i=0; i< strlen(device_type_buffer); ++i)
+ device_type_buffer[i] = tolower(device_type_buffer[i]);
+ SETSYMBOL(output_atom, gensym(device_type_buffer));
+ outlet_anything( x->x_status_outlet, gensym("type"),
+ 1, output_atom);
}
}
***************
*** 743,747 ****
pCurrentHIDDevice = HIDGetNextDevice(pCurrentHIDDevice);
}
!
debug_print(LOG_WARNING,"[hid] completed device list.");
}
--- 758,762 ----
pCurrentHIDDevice = HIDGetNextDevice(pCurrentHIDDevice);
}
! device_count = (unsigned int) HIDCountDevices(); // set the global variable
debug_print(LOG_WARNING,"[hid] completed device list.");
}
Index: hid.h
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/hid.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** hid.h 2 Jun 2006 20:06:50 -0000 1.24
--- hid.h 2 Jun 2006 21:32:53 -0000 1.25
***************
*** 41,53 ****
t_object x_obj;
t_int x_fd;
short x_device_number;
- // unsigned short vendor_id; // USB idVendor for current device
- // unsigned short product_id; // USB idProduct for current device
t_int x_has_ff;
- void *x_ff_device;
- t_clock *x_clock;
- t_int x_delay;
t_int x_started;
t_int x_device_open;
t_outlet *x_data_outlet;
t_outlet *x_status_outlet;
--- 41,51 ----
t_object x_obj;
t_int x_fd;
+ void *x_ff_device;
short x_device_number;
t_int x_has_ff;
t_int x_started;
t_int x_device_open;
+ t_int x_delay;
+ t_clock *x_clock;
t_outlet *x_data_outlet;
t_outlet *x_status_outlet;
***************
*** 56,66 ****
-
/*------------------------------------------------------------------------------
* GLOBAL VARIABLES
*/
! /*
! * count the number of instances of this object so that certain free()
* functions can be called only after the final instance is detroyed.
*/
--- 54,62 ----
/*------------------------------------------------------------------------------
* GLOBAL VARIABLES
*/
! /* count the number of instances of this object so that certain free()
* functions can be called only after the final instance is detroyed.
*/
***************
*** 69,76 ****
extern unsigned short global_debug_level;
! /* next I need to make a data structure to hold the data to be output for this
! * poll. This should probably be an array for efficiency */
!
!
typedef struct _hid_element
{
--- 65,69 ----
extern unsigned short global_debug_level;
! /* built up when the elements of an open device are enumerated */
typedef struct _hid_element
{
***************
*** 84,87 ****
--- 77,82 ----
unsigned char polled; // is it polled or queued? (maybe only on Mac OS X?)
unsigned char relative; // relative data gets output everytime
+ t_int min; // from device report
+ t_int max; // from device report
t_float instance; // usage page/usage instance # ([absolute throttle 2 163(
t_int value; // output the sum of events in a poll for relative axes
***************
*** 89,92 ****
--- 84,90 ----
} t_hid_element;
+ /* mostly for status querying */
+ unsigned short device_count;
+
/* store element structs to eliminate symbol table lookups, etc. */
t_hid_element *element[MAX_DEVICES][MAX_ELEMENTS];
Index: hid.c
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/hid.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** hid.c 2 Jun 2006 20:06:50 -0000 1.25
--- hid.c 2 Jun 2006 21:32:53 -0000 1.26
***************
*** 110,113 ****
--- 110,137 ----
}
+ static void output_device_count(t_hid *x)
+ {
+ output_status(x, gensym("total"), device_count);
+ }
+
+ static void output_element_ranges(t_hid *x)
+ {
+ if( (x->x_device_number > -1) && (x->x_device_open) )
+ {
+ unsigned int i;
+ t_atom output_data[4];
+
+ for(i=0;i<element_count[x->x_device_number];++i)
+ {
+ SETSYMBOL(output_data, element[x->x_device_number][i]->type);
+ SETSYMBOL(output_data + 1, element[x->x_device_number][i]->name);
+ SETFLOAT(output_data + 2, element[x->x_device_number][i]->min);
+ SETFLOAT(output_data + 3, element[x->x_device_number][i]->max);
+ outlet_anything(x->x_status_outlet, gensym("range"), 4, output_data);
+ }
+ }
+ }
+
+
static unsigned int name_to_usage(char *usage_name)
{ // output usagepage << 16 + usage
***************
*** 138,142 ****
first_argument = atom_getsymbolarg(0,argc,argv);
if(first_argument == &s_)
! { // single float arg means device
device_number = (short) atom_getfloatarg(0,argc,argv);
if(device_number < 0) device_number = -1;
--- 162,166 ----
first_argument = atom_getsymbolarg(0,argc,argv);
if(first_argument == &s_)
! { // single float arg means device #
device_number = (short) atom_getfloatarg(0,argc,argv);
if(device_number < 0) device_number = -1;
***************
*** 351,355 ****
--- 375,381 ----
output_open_status(x);
output_device_number(x);
+ output_device_count(x);
output_poll_time(x);
+ output_element_ranges(x);
hid_platform_specific_info(x);
}
More information about the Pd-cvs
mailing list