[PD-cvs] externals/hcs/hid TODO, 1.23, 1.24 hid.h, 1.22, 1.23 hid_darwin.c, 1.22, 1.23
Hans-Christoph Steiner
eighthave at users.sourceforge.net
Sun May 28 22:14:00 CEST 2006
Update of /cvsroot/pure-data/externals/hcs/hid
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32486
Modified Files:
TODO hid.h hid_darwin.c
Log Message:
On Mac OSX, replaced hid_get_device_by_number() by a global array of pointers, it should reduce the CPU load noticably. next I need to handle elements independently
Index: TODO
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/TODO,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** TODO 27 May 2006 23:12:51 -0000 1.23
--- TODO 28 May 2006 20:13:57 -0000 1.24
***************
*** 2,6 ****
==============================================================================
! = make second inlet for poll # (for [human->pd]
--- 2,28 ----
==============================================================================
! = output one value per poll
!
! - for relative axes, sum up all events and output one
! 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?
!
!
! ==============================================================================
! = iterate through elements and do a proper queue of the ones we want:
!
! - also, label multiple instances of the same usage
!
! http://mud.5341.com/msg/8455.html
!
!
! ==============================================================================
! = make second inlet for poll # (for [human->pd])
***************
*** 20,23 ****
--- 42,56 ----
==============================================================================
+ =
+ = autoscaling based on Logical min/max
+
+ - this is probably essential for input, the question is how to find out what
+ the data range is easily.
+
+ - output would be handy, rather than autoscale, to save on CPU
+
+
+
+ ==============================================================================
= test verbose names
***************
*** 44,47 ****
--- 77,86 ----
==============================================================================
+ = event name changes
+
+ - make key/button Type "button" rather than "key" (undecided on this one)
+
+
+ ==============================================================================
= hid/serial
***************
*** 62,69 ****
- ==============================================================================
- = open/close status outlet
-
-
==============================================================================
--- 101,104 ----
***************
*** 73,76 ****
--- 108,112 ----
CPU where it doesn't have to be
+
==============================================================================
= Report available FF effects
***************
*** 99,111 ****
==============================================================================
- = event name changes
-
- - make key/button Type "button" rather than "key" (undecided on this one)
-
-
- ==============================================================================
= check out using USB timestamp
! - use the USB timestamp to correctly space the output data
--- 135,143 ----
==============================================================================
= check out using USB timestamp
! - use the USB timestamp to correctly space the output data (meh, probably
! unnecessary)
!
Index: hid_darwin.c
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/hid_darwin.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** hid_darwin.c 28 May 2006 01:05:45 -0000 1.22
--- hid_darwin.c 28 May 2006 20:13:57 -0000 1.23
***************
*** 63,68 ****
extern t_int hid_instance_count;
/*==============================================================================
! h * FUNCTION PROTOTYPES
*==============================================================================
*/
--- 63,71 ----
extern t_int hid_instance_count;
+ /* store device pointers */
+ pRecDevice device_pointer[MAX_DEVICES];
+
/*==============================================================================
! * FUNCTION PROTOTYPES
*==============================================================================
*/
***************
*** 183,186 ****
--- 186,191 ----
t_int i, numdevs;
+ // TODO: implement this using the global array built by hid_build_device_list()
+
/*
* If the specified device is greater than the total number of devices, return
***************
*** 290,294 ****
void hid_build_element_list(t_hid *x)
{
!
}
*/
--- 295,331 ----
void hid_build_element_list(t_hid *x)
{
! if ( HIDIsValidDevice( device ) ) {
! elRec = HIDGetFirstDeviceElement( js_devices[id].device,
! kHIDElementTypeInput );
! if ( elRec ) {
! switch (elRec->usagePage) {
! case kHIDPage_GenericDesktop:
! switch ( elRec->usage ) {
! case kHIDUsage_GD_X:
! x_axis = elRec;
! break;
! case kHIDUsage_GD_Y:
! y_axis = elRec;
! break;
! case kHIDUsage_GD_GamePad:
! pad = elRec;
! break;
! //etc
! }
! }
! //if the right element was not found, continue looping through the
! //rest of the elements by calling HIDGetNextDeviceElement() until you
! //find the right one or it returns NULL
! }
!
! // only queue buttons and relative axes
! if ( HIDIsValidElement( devicePtr, elementPtr ) ) {
! HIDQueueElement (devicePtr, elementPtr);
! }
!
! // for absolute axes, poll them
! if ( HIDIsValidElement( devicePtr, elementPtr ) ) {
! value = HIDGetElementValue(devicePtr, elementPtr);
! }
}
*/
***************
*** 307,311 ****
char usage_name[256];
! pCurrentHIDDevice = hid_get_device_by_number(x->x_device_number);
if ( ! HIDIsValidDevice(pCurrentHIDDevice) )
{
--- 344,349 ----
char usage_name[256];
! // pCurrentHIDDevice = hid_get_device_by_number(x->x_device_number);
! pCurrentHIDDevice = device_pointer[x->x_device_number];
if ( ! HIDIsValidDevice(pCurrentHIDDevice) )
{
***************
*** 388,392 ****
for(i=0; i < numdevs; i++)
{
! pCurrentHIDDevice = hid_get_device_by_number(i);
debug_print(LOG_INFO,"Device %d: '%s' '%s' version %d",
i,
--- 426,431 ----
for(i=0; i < numdevs; i++)
{
! // pCurrentHIDDevice = hid_get_device_by_number(i);
! pCurrentHIDDevice = device_pointer[i];
debug_print(LOG_INFO,"Device %d: '%s' '%s' version %d",
i,
***************
*** 424,428 ****
if(x->x_device_number > -1)
{
! pCurrentHIDDevice = hid_get_device_by_number(x->x_device_number);
if(pCurrentHIDDevice != NULL)
{
--- 463,468 ----
if(x->x_device_number > -1)
{
! // pCurrentHIDDevice = hid_get_device_by_number(x->x_device_number);
! pCurrentHIDDevice = device_pointer[x->x_device_number];
if(pCurrentHIDDevice != NULL)
{
***************
*** 620,624 ****
// Boolean result;
! pCurrentHIDDevice = hid_get_device_by_number(x->x_device_number);
if(!pCurrentHIDDevice)
--- 660,665 ----
// Boolean result;
! // pCurrentHIDDevice = hid_get_device_by_number(x->x_device_number);
! pCurrentHIDDevice = device_pointer[x->x_device_number];
if(!pCurrentHIDDevice)
***************
*** 768,772 ****
if( !HIDHaveDeviceList() ) hid_build_device_list();
! pCurrentHIDDevice = hid_get_device_by_number(device_number);
if( HIDIsValidDevice(pCurrentHIDDevice) )
{
--- 809,814 ----
if( !HIDHaveDeviceList() ) hid_build_device_list();
! // pCurrentHIDDevice = hid_get_device_by_number(device_number);
! pCurrentHIDDevice = device_pointer[device_number];
if( HIDIsValidDevice(pCurrentHIDDevice) )
{
***************
*** 803,807 ****
HIDQueueDevice(pCurrentHIDDevice);
// TODO: queue all elements except absolute axes, those can just be polled
!
return(result);
}
--- 845,852 ----
HIDQueueDevice(pCurrentHIDDevice);
// TODO: queue all elements except absolute axes, those can just be polled
! /* if ( HIDIsValidElement( devicePtr, elementPtr ) ) {
! value = HIDGetElementValue(devicePtr, elementPtr);
! }
! */
return(result);
}
***************
*** 813,817 ****
t_int result = 0;
! pRecDevice pCurrentHIDDevice = hid_get_device_by_number(x->x_device_number);
HIDDequeueDevice(pCurrentHIDDevice);
--- 858,863 ----
t_int result = 0;
! // pRecDevice pCurrentHIDDevice = hid_get_device_by_number(x->x_device_number);
! pRecDevice pCurrentHIDDevice = device_pointer[x->x_device_number];
HIDDequeueDevice(pCurrentHIDDevice);
***************
*** 825,828 ****
--- 871,877 ----
void hid_build_device_list(void)
{
+ int device_number = 0;
+ pRecDevice pCurrentHIDDevice;
+
debug_print(LOG_DEBUG,"hid_build_device_list");
***************
*** 830,833 ****
--- 879,895 ----
if(HIDBuildDeviceList (0, 0))
post("[hid]: no HID devices found\n");
+
+ /* The most recently discovered HID is the first element of the list here. I
+ * want the oldest to be number 0 rather than the newest. */
+ device_number = (int) HIDCountDevices();
+ pCurrentHIDDevice = HIDGetFirstDevice();
+ while(pCurrentHIDDevice != NULL)
+ {
+ --device_number;
+ if(device_number < MAX_DEVICES)
+ device_pointer[device_number] = pCurrentHIDDevice;
+ pCurrentHIDDevice = HIDGetNextDevice(pCurrentHIDDevice);
+ }
+
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.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** hid.h 27 May 2006 23:12:51 -0000 1.22
--- hid.h 28 May 2006 20:13:57 -0000 1.23
***************
*** 19,22 ****
--- 19,31 ----
/*------------------------------------------------------------------------------
+ * GLOBAL DEFINES
+ */
+
+ #define DEFAULT_DELAY 5
+
+ /* this is set to simplify data structures (arrays instead of linked lists) */
+ #define MAX_DEVICES 128
+
+ /*------------------------------------------------------------------------------
* CLASS DEF
*/
***************
*** 26,31 ****
t_int x_fd;
t_int 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;
--- 35,40 ----
t_int x_fd;
t_int 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;
***************
*** 39,47 ****
- /*------------------------------------------------------------------------------
- * GLOBAL DEFINES
- */
-
- #define DEFAULT_DELAY 5
--- 48,51 ----
***************
*** 58,61 ****
--- 62,68 ----
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 */
+
/*------------------------------------------------------------------------------
* FUNCTION PROTOTYPES FOR DIFFERENT PLATFORMS
More information about the Pd-cvs
mailing list