[PD-cvs] externals/hcs libhid.libs, NONE, 1.1 libhid.c, 1.1, 1.2 libhid-help.pd, 1.1, 1.2
Hans-Christoph Steiner
eighthave at users.sourceforge.net
Thu May 18 13:56:10 CEST 2006
- Previous message: [PD-cvs] externals/hcs libhid.c,NONE,1.1 libhid-help.pd,NONE,1.1
- Next message: [PD-cvs] externals/hcs usbhid.c, NONE, 1.1 usbhid.libs, NONE, 1.1 usbhid-help.pd, NONE, 1.1 libhid.c, 1.2, NONE libhid.libs, 1.1, NONE libhid-help.pd, 1.2, NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/pure-data/externals/hcs
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4532
Modified Files:
libhid.c libhid-help.pd
Added Files:
libhid.libs
Log Message:
first sketch of opening working
Index: libhid-help.pd
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/libhid-help.pd,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** libhid-help.pd 18 May 2006 10:16:40 -0000 1.1
--- libhid-help.pd 18 May 2006 11:56:07 -0000 1.2
***************
*** 1,6 ****
! #N canvas 338 93 585 463 10;
#X obj 111 373 libhid;
! #X msg 170 60 bang;
! #X msg 183 79 open;
#X msg 185 98 close;
#X msg 185 124 reset;
--- 1,5 ----
! #N canvas 338 93 593 471 10;
#X obj 111 373 libhid;
! #X msg 125 14 bang;
#X msg 185 98 close;
#X msg 185 124 reset;
***************
*** 13,23 ****
#X msg 250 292 set read 1 30 word 1 31 1 38;
#X msg 205 182 set read 1 30 1 31 12 38;
! #X connect 0 0 5 0;
! #X connect 0 1 6 0;
#X connect 1 0 0 0;
#X connect 2 0 0 0;
#X connect 3 0 0 0;
! #X connect 4 0 0 0;
! #X connect 9 0 0 0;
#X connect 11 0 0 0;
#X connect 12 0 0 0;
--- 12,26 ----
#X msg 250 292 set read 1 30 word 1 31 1 38;
#X msg 205 182 set read 1 30 1 31 12 38;
! #X msg 198 142 print;
! #X msg 177 78 open 1149 16392;
! #X text 298 78 Gravis/Destroyer Tiltpad;
! #X connect 0 0 4 0;
! #X connect 0 1 5 0;
#X connect 1 0 0 0;
#X connect 2 0 0 0;
#X connect 3 0 0 0;
! #X connect 8 0 0 0;
! #X connect 10 0 0 0;
#X connect 11 0 0 0;
#X connect 12 0 0 0;
+ #X connect 13 0 0 0;
--- NEW FILE: libhid.libs ---
-lusb -lhid
Index: libhid.c
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/libhid.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** libhid.c 18 May 2006 10:16:40 -0000 1.1
--- libhid.c 18 May 2006 11:56:07 -0000 1.2
***************
*** 32,35 ****
--- 32,51 ----
/*------------------------------------------------------------------------------
+ * INCLUDE HACK
+ */
+
+ /* NOTE: included from libusb/usbi.h. UGLY, i know, but so is libusb! */
+ struct usb_dev_handle {
+ int fd;
+ struct usb_bus *bus;
+ struct usb_device *device;
+ int config;
+ int interface;
+ int altsetting;
+ void *impl_info;
+ };
+
+
+ /*------------------------------------------------------------------------------
* GLOBAL VARIABLES
*/
***************
*** 42,45 ****
--- 58,62 ----
char *hid_id[32]; /* FIXME: 32 devices MAX */
+ t_int hid_id_count;
/*------------------------------------------------------------------------------
***************
*** 66,83 ****
/* outlets */
t_outlet *x_data_outlet;
! t_outlet *x_device_name_outlet;
} t_libhid;
- /* NOTE: included from libusb/usbi.h. UGLY, i know, but so is libusb! */
- struct usb_dev_handle {
- int fd;
- struct usb_bus *bus;
- struct usb_device *device;
- int config;
- int interface;
- int altsetting;
- void *impl_info;
- };
--- 83,90 ----
/* outlets */
t_outlet *x_data_outlet;
! t_outlet *x_control_outlet;
} t_libhid;
***************
*** 132,135 ****
--- 139,147 ----
hid_id[i] = (char *) malloc(strlen(usbdev->device->filename) + strlen(usbdev->bus->dirname) );
sprintf(hid_id[i], "%s/%s", usbdev->bus->dirname, usbdev->device->filename);
+ post("bus %s device %s: %d %d",
+ usbdev->bus->dirname,
+ usbdev->device->filename,
+ usbdev->device->descriptor.idVendor,
+ usbdev->device->descriptor.idProduct);
}
else /* device already seen */
***************
*** 149,155 ****
}
! /*
! This function is used in a HIDInterfaceMatcher in order to match devices by
! serial number.
*/
/* static bool match_serial_number(struct usb_dev_handle* usbdev, void* custom, unsigned int len) */
--- 161,167 ----
}
! /* -------------------------------------------------------------------------- */
! /* This function is used in a HIDInterfaceMatcher in order to match devices by
! * serial number.
*/
/* static bool match_serial_number(struct usb_dev_handle* usbdev, void* custom, unsigned int len) */
***************
*** 165,168 ****
--- 177,181 ----
+ /* -------------------------------------------------------------------------- */
/* static HIDInterface* get_device_by_number(t_int device_number) */
/* { */
***************
*** 173,176 ****
--- 186,211 ----
+ /* -------------------------------------------------------------------------- */
+ static t_int* make_hid_packet(t_int element_count, t_int argc, t_atom *argv)
+ {
+ DEBUG(post("make_hid_packet"););
+ t_int i;
+ t_int *return_array = NULL;
+
+ post("element_count %d",element_count);
+ return_array = (t_int *) getbytes(sizeof(t_int) * element_count);
+ for(i=0; i < element_count; ++i)
+ {
+ /*
+ * A libhid path component is 32 bits, the high 16 bits identify the usage page,
+ * and the low 16 bits the item number.
+ */
+ return_array[i] =
+ (atom_getintarg(i*2,argc,argv) << 16) + atom_getintarg(i*2+1,argc,argv);
+ /* TODO: print error if a symbol is found in the data list */
+ }
+ return return_array;
+ }
+
/*------------------------------------------------------------------------------
***************
*** 179,194 ****
/* -------------------------------------------------------------------------- */
! static void libhid_open(t_libhid *x)
{
DEBUG(post("libhid_open"););
! /* Microsoft 5-Button Mouse with IntelliEye(TM) */
! HIDInterfaceMatcher matcher = { 0x045e, 0x0039, NULL, NULL, 0 };
! x->x_hid_return = hid_force_open(x->x_hidinterface, 0, &matcher, 3);
! if (x->x_hid_return != HID_RET_SUCCESS) {
! error("[libhid] hid_force_open failed with return code %d\n", x->x_hid_return);
}
-
}
--- 214,234 ----
/* -------------------------------------------------------------------------- */
! static void libhid_open(t_libhid *x, t_float vendor_id, t_float product_id)
{
DEBUG(post("libhid_open"););
! HIDInterfaceMatcher matcher = { (unsigned short)vendor_id,
! (unsigned short)product_id,
! NULL,
! NULL,
! 0 };
! if ( !hid_is_opened(x->x_hidinterface) )
! {
! x->x_hid_return = hid_force_open(x->x_hidinterface, 0, &matcher, 3);
! if (x->x_hid_return != HID_RET_SUCCESS) {
! error("[libhid] hid_force_open failed with return code %d\n", x->x_hid_return);
! }
}
}
***************
*** 204,213 ****
char packet[RECEIVE_PACKET_LENGTH];
! if ( !hid_is_opened(x->x_hidinterface) )
! {
! libhid_open(x);
! }
! else
! {
x->x_hid_return = hid_get_input_report(x->x_hidinterface,
PATH_OUT,
--- 244,253 ----
char packet[RECEIVE_PACKET_LENGTH];
! /* if ( !hid_is_opened(x->x_hidinterface) ) */
! /* { */
! /* libhid_open(x); */
! /* } */
! /* else */
! /* { */
x->x_hid_return = hid_get_input_report(x->x_hidinterface,
PATH_OUT,
***************
*** 218,246 ****
error("[libhid] hid_get_input_report failed with return code %d\n",
x->x_hid_return);
! }
}
- /* -------------------------------------------------------------------------- */
- static t_int* libhid_make_packet(t_int element_count, t_int argc, t_atom *argv)
- {
- DEBUG(post("libhid_make_packet"););
- t_int i;
- t_int *return_array = NULL;
-
- post("element_count %d",element_count);
- return_array = (t_int *) getbytes(sizeof(t_int) * element_count);
- for(i=0; i < element_count; ++i)
- {
- /*
- * A libhid path component is 32 bits, the high 16 bits identify the usage page,
- * and the low 16 bits the item number.
- */
- return_array[i] =
- (atom_getintarg(i*2,argc,argv) << 16) + atom_getintarg(i*2+1,argc,argv);
- /* TODO: print error if a symbol is found in the data list */
- }
- return return_array;
- }
/* -------------------------------------------------------------------------- */
--- 258,265 ----
error("[libhid] hid_get_input_report failed with return code %d\n",
x->x_hid_return);
! /* } */
}
/* -------------------------------------------------------------------------- */
***************
*** 252,256 ****
x->x_read_element_count = argc / 2;
! x->x_read_elements = libhid_make_packet(x->x_read_element_count, argc, argv);
post("x_read_element_count %d",x->x_read_element_count);
for(i=0;i<x->x_read_element_count;++i)
--- 271,275 ----
x->x_read_element_count = argc / 2;
! x->x_read_elements = make_hid_packet(x->x_read_element_count, argc, argv);
post("x_read_element_count %d",x->x_read_element_count);
for(i=0;i<x->x_read_element_count;++i)
***************
*** 267,271 ****
x->x_write_element_count = argc / 2;
! x->x_write_elements = libhid_make_packet(x->x_write_element_count, argc, argv);
post("x_write_element_count %d",x->x_write_element_count);
for(i=0;i<x->x_write_element_count;++i)
--- 286,290 ----
x->x_write_element_count = argc / 2;
! x->x_write_elements = make_hid_packet(x->x_write_element_count, argc, argv);
post("x_write_element_count %d",x->x_write_element_count);
for(i=0;i<x->x_write_element_count;++i)
***************
*** 276,279 ****
--- 295,299 ----
/* -------------------------------------------------------------------------- */
+ /* convert a list to a HID packet and set it */
static void libhid_set(t_libhid *x, t_symbol *s, int argc, t_atom *argv)
{
***************
*** 289,292 ****
--- 309,326 ----
+ /* -------------------------------------------------------------------------- */
+ static void libhid_get(t_libhid *x, t_symbol *s, int argc, t_atom *argv)
+ {
+ DEBUG(post("libhid_get"););
+ t_symbol *subselector;
+
+ subselector = atom_getsymbol(&argv[0]);
+ /* if(strcmp(subselector->s_name,"read") == 0) */
+
+ /* if(strcmp(subselector->s_name,"write") == 0) */
+
+ }
+
+
/* -------------------------------------------------------------------------- */
***************
*** 313,318 ****
{
DEBUG(post("libhid_print"););
!
! hid_write_identification(stdout, x->x_hidinterface);
}
--- 347,362 ----
{
DEBUG(post("libhid_print"););
! t_int i;
! t_atom event_data[3];
!
! for ( i = 0 ; ( hid_id[i] != NULL ) ; i++ )
! {
! if( hid_id[i] != NULL )
! post("hid_id[%d]: %s",i,hid_id[i]);
! }
! /* SETSYMBOL(event_data, gensym(type)); /\* type *\/ */
! /* SETSYMBOL(event_data + 1, gensym(code)); /\* code *\/ */
! /* SETSYMBOL(event_data + 2, value); /\* value *\/ */
! // outlet_list(x->x_control_outlet, &s_list,
}
***************
*** 366,370 ****
/* create anything outlet used for HID data */
x->x_data_outlet = outlet_new(&x->x_obj, 0);
! x->x_device_name_outlet = outlet_new(&x->x_obj, 0);
/* hid_write_library_config(stdout); */
--- 410,414 ----
/* create anything outlet used for HID data */
x->x_data_outlet = outlet_new(&x->x_obj, 0);
! x->x_control_outlet = outlet_new(&x->x_obj, 0);
/* hid_write_library_config(stdout); */
***************
*** 393,397 ****
while ( (x->x_hid_return = hid_force_open(x->x_hidinterface, 0, &matcher, 2)) != HID_RET_DEVICE_NOT_FOUND)
{
! printf("************************************************************************\n");
/* hid_write_identification(stdout, x->x_hidinterface); */
--- 437,441 ----
while ( (x->x_hid_return = hid_force_open(x->x_hidinterface, 0, &matcher, 2)) != HID_RET_DEVICE_NOT_FOUND)
{
! /* printf("************************************************************************\n"); */
/* hid_write_identification(stdout, x->x_hidinterface); */
***************
*** 434,438 ****
class_addmethod(libhid_class,(t_method) libhid_reset,gensym("reset"),0);
class_addmethod(libhid_class,(t_method) libhid_set,gensym("set"),A_GIMME,0);
! class_addmethod(libhid_class,(t_method) libhid_open,gensym("open"),0);
class_addmethod(libhid_class,(t_method) libhid_close,gensym("close"),0);
}
--- 478,483 ----
class_addmethod(libhid_class,(t_method) libhid_reset,gensym("reset"),0);
class_addmethod(libhid_class,(t_method) libhid_set,gensym("set"),A_GIMME,0);
! class_addmethod(libhid_class,(t_method) libhid_get,gensym("get"),A_DEFSYM,0);
! class_addmethod(libhid_class,(t_method) libhid_open,gensym("open"),A_DEFFLOAT,A_DEFFLOAT,0);
class_addmethod(libhid_class,(t_method) libhid_close,gensym("close"),0);
}
- Previous message: [PD-cvs] externals/hcs libhid.c,NONE,1.1 libhid-help.pd,NONE,1.1
- Next message: [PD-cvs] externals/hcs usbhid.c, NONE, 1.1 usbhid.libs, NONE, 1.1 usbhid-help.pd, NONE, 1.1 libhid.c, 1.2, NONE libhid.libs, 1.1, NONE libhid-help.pd, 1.2, NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Pd-cvs
mailing list