Update of /cvsroot/pure-data/externals/hcs/hid
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19278
Modified Files:
Makefile hid.c hid.h hid_darwin.c make-arrays-from-input.h.pl
Added Files:
hid_linux.c
Log Message:
more progress generalizing for cross-platformness; Darwin stuff compiles and the object loads, but it doesn't do anything yet
Index: hid_darwin.c
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/hid_darwin.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** hid_darwin.c 22 Oct 2004 05:43:17 -0000 1.1
--- hid_darwin.c 22 Oct 2004 18:49:16 -0000 1.2
***************
*** 1,2 ****
--- 1,3 ----
+ #ifdef __APPLE__
/*
* Apple Darwin HID Manager support for [hid]
***************
*** 21,24 ****
--- 22,27 ----
*/
+
+
#include <Carbon/Carbon.h>
***************
*** 54,63 ****
*/
int gNumberOfHIDDevices = 0;
EventLoopTimerRef gTimer = NULL; // timer for element data updates
! void releaseHIDDevices ()
{
if (gTimer)
{
--- 57,81 ----
*/
+
+ #define DEBUG(x)
+ //#define DEBUG(x) x
+
+ /*==============================================================================
+ * GLOBAL VARS
+ *======================================================================== */
+
int gNumberOfHIDDevices = 0;
EventLoopTimerRef gTimer = NULL; // timer for element data updates
! /*==============================================================================
! * FUNCTIONS
! *==============================================================================
! */
!
! void releaseHIDDevices (void)
{
+ DEBUG(post("releaseHIDDevices"););
+
if (gTimer)
{
***************
*** 70,83 ****
}
! int prHIDBuildElementList()
{
/*
PyrSlot *a = g->sp - 1; //class
PyrSlot *b = g->sp; //locID device
*/
! int i, locID, cookieNum;
pRecElement devElement;
pRecDevice pCurrentHIDDevice;
! // int err;
// int err = slotIntVal(b, &locID);
--- 88,106 ----
}
! int prHIDBuildElementList(void)
{
+ DEBUG(post("prHIDBuildElementList"););
+
/*
PyrSlot *a = g->sp - 1; //class
PyrSlot *b = g->sp; //locID device
*/
! int locID = NULL;
! int cookieNum = NULL;
! UInt32 i;
pRecElement devElement;
pRecDevice pCurrentHIDDevice;
! UInt32 numElements;
! char cstrElementName [256];
// int err = slotIntVal(b, &locID);
***************
*** 91,95 ****
devElement = HIDGetFirstDeviceElement (pCurrentHIDDevice, kHIDElementTypeInput);
! UInt32 numElements = HIDCountDeviceElements (pCurrentHIDDevice, kHIDElementTypeInput);
//PyrObject* devAllElementsArray = newPyrArray(g->gc, numElements * sizeof(PyrObject), 0 , true);
--- 114,118 ----
devElement = HIDGetFirstDeviceElement (pCurrentHIDDevice, kHIDElementTypeInput);
! numElements = HIDCountDeviceElements (pCurrentHIDDevice, kHIDElementTypeInput);
//PyrObject* devAllElementsArray = newPyrArray(g->gc, numElements * sizeof(PyrObject), 0 , true);
***************
*** 97,101 ****
for(i=0; i<numElements; i++)
{
- char cstrElementName [256];
//PyrObject* devElementArray = newPyrArray(g->gc, 5 * sizeof(PyrObject), 0 , true);
HIDGetTypeName((IOHIDElementType) devElement->type, cstrElementName);
--- 120,123 ----
***************
*** 123,128 ****
}
! int prHIDBuildDeviceList()
{
int i,err;
UInt32 usagePage, usage;
--- 145,152 ----
}
! int prHIDBuildDeviceList(void)
{
+ DEBUG(post("prHIDBuildDeviceList"););
+
int i,err;
UInt32 usagePage, usage;
***************
*** 211,254 ****
}
! /*
! int prHIDGetValue(VMGlobals *g);
! int prHIDGetValue(VMGlobals *g)
{
PyrSlot *a = g->sp - 2; //class
PyrSlot *b = g->sp - 1; //locID device
PyrSlot *c = g->sp; //element cookie
- int locID, cookieNum;
int err = slotIntVal(b, &locID);
if (err) return err;
err = slotIntVal(c, &cookieNum);
if (err) return err;
IOHIDElementCookie cookie = (IOHIDElementCookie) cookieNum;
// look for the right device:
! pRecDevice pCurrentHIDDevice = HIDGetFirstDevice ();
while (pCurrentHIDDevice && (pCurrentHIDDevice->locID !=locID))
! pCurrentHIDDevice = HIDGetNextDevice (pCurrentHIDDevice);
if(!pCurrentHIDDevice) return (1);
// look for the right element:
pRecElement pCurrentHIDElement = HIDGetFirstDeviceElement (pCurrentHIDDevice, kHIDElementTypeIO);
// use gElementCookie to find current element
! while (pCurrentHIDElement && (pCurrentHIDElement->cookie != cookie))
! pCurrentHIDElement = HIDGetNextDeviceElement (pCurrentHIDElement, kHIDElementTypeIO);
!
if (pCurrentHIDElement)
! {
! SInt32 value = HIDGetElementValue (pCurrentHIDDevice, pCurrentHIDElement);
! // if it's not a button and it's not a hatswitch then calibrate
if(( pCurrentHIDElement->type != kIOHIDElementTypeInput_Button ) &&
( pCurrentHIDElement->usagePage == 0x01 && pCurrentHIDElement->usage != kHIDUsage_GD_Hatswitch))
value = HIDCalibrateValue ( value, pCurrentHIDElement );
! SetInt(a, value);
}
! else SetNil(a);
return (0);
}
! */
! void PushQueueEvents_RawValue ()
{
int i;
--- 235,286 ----
}
!
! int prHIDGetValue(void)
{
+ DEBUG(post("prHIDGetValue"););
+
+ int locID = NULL;
+ int cookieNum = NULL;
+ SInt32 value;
+ /*
PyrSlot *a = g->sp - 2; //class
PyrSlot *b = g->sp - 1; //locID device
PyrSlot *c = g->sp; //element cookie
int err = slotIntVal(b, &locID);
if (err) return err;
err = slotIntVal(c, &cookieNum);
if (err) return err;
+ */
IOHIDElementCookie cookie = (IOHIDElementCookie) cookieNum;
// look for the right device:
! pRecDevice pCurrentHIDDevice = HIDGetFirstDevice ();
while (pCurrentHIDDevice && (pCurrentHIDDevice->locID !=locID))
! pCurrentHIDDevice = HIDGetNextDevice (pCurrentHIDDevice);
if(!pCurrentHIDDevice) return (1);
// look for the right element:
pRecElement pCurrentHIDElement = HIDGetFirstDeviceElement (pCurrentHIDDevice, kHIDElementTypeIO);
// use gElementCookie to find current element
! while (pCurrentHIDElement && (pCurrentHIDElement->cookie != cookie))
! pCurrentHIDElement = HIDGetNextDeviceElement (pCurrentHIDElement, kHIDElementTypeIO);
!
if (pCurrentHIDElement)
! {
! value = HIDGetElementValue (pCurrentHIDDevice, pCurrentHIDElement);
! // if it's not a button and it's not a hatswitch then calibrate
if(( pCurrentHIDElement->type != kIOHIDElementTypeInput_Button ) &&
( pCurrentHIDElement->usagePage == 0x01 && pCurrentHIDElement->usage != kHIDUsage_GD_Hatswitch))
value = HIDCalibrateValue ( value, pCurrentHIDElement );
! //SetInt(a, value);
}
! //else SetNil(a);
return (0);
}
!
!
! void PushQueueEvents_RawValue(void)
{
+ DEBUG(post("PushQueueEvents_RawValue"););
+
int i;
***************
*** 278,283 ****
}
! void PushQueueEvents_CalibratedValue ()
{
int i;
--- 310,318 ----
}
!
! void PushQueueEvents_CalibratedValue(void)
{
+ DEBUG(post("PushQueueEvents_CalibratedValue"););
+
int i;
***************
*** 319,336 ****
}
! static pascal void IdleTimer (EventLoopTimerRef inTimer, void* userData)
{
#pragma unused (inTimer, userData)
PushQueueEvents_CalibratedValue ();
}
! int prHIDReleaseDeviceList()
{
releaseHIDDevices();
return (0);
}
! static EventLoopTimerUPP GetTimerUPP (void)
{
static EventLoopTimerUPP sTimerUPP = NULL;
--- 354,380 ----
}
!
! static pascal void IdleTimer(EventLoopTimerRef inTimer, void* userData)
{
+ DEBUG(post("IdleTimer"););
+
#pragma unused (inTimer, userData)
PushQueueEvents_CalibratedValue ();
}
!
! int prHIDReleaseDeviceList(void)
{
+ DEBUG(post("prHIDReleaseDeviceList"););
+
releaseHIDDevices();
return (0);
}
!
! static EventLoopTimerUPP GetTimerUPP(void)
{
+ DEBUG(post("GetTimerUPP"););
+
static EventLoopTimerUPP sTimerUPP = NULL;
***************
*** 351,359 ****
}
*/
! /*
! int prHIDRunEventLoop(VMGlobals *g);
! int prHIDRunEventLoop(VMGlobals *g)
{
! PyrSlot *a = g->sp - 1; //class
InstallEventLoopTimer (GetCurrentEventLoop(), 0, 0.001, GetTimerUPP (), 0, &gTimer);
--- 395,404 ----
}
*/
!
! int prHIDRunEventLoop(void)
{
! DEBUG(post("prHIDRunEventLoop"););
!
! //PyrSlot *a = g->sp - 1; //class
InstallEventLoopTimer (GetCurrentEventLoop(), 0, 0.001, GetTimerUPP (), 0, &gTimer);
***************
*** 362,370 ****
return (0);
}
- */
! int prHIDQueueDevice()
{
! int locID, cookieNum;
//PyrSlot *a = g->sp - 1; //class
--- 407,418 ----
return (0);
}
!
! int prHIDQueueDevice(void)
{
! DEBUG(post("prHIDQueueDevice"););
!
! int locID = NULL;
! int cookieNum = NULL;
//PyrSlot *a = g->sp - 1; //class
***************
*** 381,387 ****
}
! int prHIDQueueElement()
{
! int locID, cookieNum;
//PyrSlot *a = g->sp - 2; //class
--- 429,439 ----
}
!
! int prHIDQueueElement(void)
{
! DEBUG(post("prHIDQueueElement"););
!
! int locID = NULL;
! int cookieNum = NULL;
//PyrSlot *a = g->sp - 2; //class
***************
*** 408,414 ****
}
! int prHIDDequeueElement()
{
! int locID, cookieNum;
//PyrSlot *a = g->sp - 2; //class
--- 460,470 ----
}
!
! int prHIDDequeueElement(void)
{
! DEBUG(post("prHIDDequeueElement"););
!
! int locID = NULL;
! int cookieNum = NULL;
//PyrSlot *a = g->sp - 2; //class
***************
*** 434,440 ****
}
! int prHIDDequeueDevice()
{
! int locID, cookieNum;
/*
--- 490,500 ----
}
!
! int prHIDDequeueDevice(void)
{
! DEBUG(post("prHIDDequeueDevice"););
!
! int locID = NULL;
! int cookieNum = NULL;
/*
***************
*** 453,458 ****
}
! int prHIDStopEventLoop()
{
if (gTimer)
RemoveEventLoopTimer(gTimer);
--- 513,521 ----
}
!
! int prHIDStopEventLoop(void)
{
+ DEBUG(post("prHIDStopEventLoop"););
+
if (gTimer)
RemoveEventLoopTimer(gTimer);
***************
*** 462,463 ****
--- 525,527 ----
+ #endif /* #ifdef __APPLE__ */
Index: make-arrays-from-input.h.pl
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/make-arrays-from-input.h.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** make-arrays-from-input.h.pl 20 Oct 2004 02:55:12 -0000 1.3
--- make-arrays-from-input.h.pl 22 Oct 2004 18:49:16 -0000 1.4
***************
*** 31,34 ****
--- 31,43 ----
#------------------------------------------------------------------------
+ # declare each array in the header
+ #
+ sub printCArrayDeclarations
+ {
+ my @arrayToPrint = @_;
+ print(HEADER "char *${arrayToPrint[0]}[$#arrayToPrint];\n");
+ }
+
+ #------------------------------------------------------------------------
# print an array out in C format
#
***************
*** 39,55 ****
# print("$arrayToPrint[0] $#arrayToPrint \n");
! print("int ${arrayToPrint[0]}_total = $#arrayToPrint; /* # of elements in array */\n");
! print("char *${arrayToPrint[0]}[$#arrayToPrint] = {");
for($i = 1; $i < $#arrayToPrint; $i++)
{
# format nicely in sets of 6
! if ( ($i+4)%6 == 5 ) { print("\n "); }
# if the array element's data is null, print NULL
! if ($arrayToPrint[$i]) { print("\"$arrayToPrint[$i]\","); }
! else { print("NULL,"); }
}
! print("\"$arrayToPrint[$#arrayToPrint]\"\n };\n\n\n");
}
--- 48,64 ----
# print("$arrayToPrint[0] $#arrayToPrint \n");
! print(ARRAYS "int ${arrayToPrint[0]}_total = $#arrayToPrint; /* # of elements in array */\n");
! print(ARRAYS "char *${arrayToPrint[0]}[$#arrayToPrint] = {");
for($i = 1; $i < $#arrayToPrint; $i++)
{
# format nicely in sets of 6
! if ( ($i+4)%6 == 5 ) { print(ARRAYS "\n "); }
# if the array element's data is null, print NULL
! if ($arrayToPrint[$i]) { print(ARRAYS "\"$arrayToPrint[$i]\","); }
! else { print(ARRAYS "NULL,"); }
}
! print(ARRAYS "\"$arrayToPrint[$#arrayToPrint]\"\n };\n\n\n");
}
***************
*** 87,90 ****
--- 96,109 ----
}
+ #------------------------------------------------------------------------
+ #
+ #
+ sub printArray
+ {
+ printPdFile(@_);
+ printCArray(@_);
+ printCArrayDeclarations(@_);
+ }
+
#========================================================================
# MAIN
***************
*** 96,102 ****
# output files
! $ARRAYSFILENAME = "input_arrays.h";
open(ARRAYS, ">$ARRAYSFILENAME");
while (<INPUT_H>)
{
--- 115,126 ----
# output files
! $HEADERFILENAME = "input_arrays.h";
! open(HEADER, ">$HEADERFILENAME");
! $ARRAYSFILENAME = "input_arrays.c";
open(ARRAYS, ">$ARRAYSFILENAME");
+
+ #----------------------------------------
+ # create the arrays from INPUT_H
while (<INPUT_H>)
{
***************
*** 130,171 ****
}
! # generate a .pd file for each array
! printPdFile("ev",@EV);
! printPdFile("ev_syn",@SYN);
! printPdFile("ev_key",@KEY);
! printPdFile("ev_rel",@REL);
! printPdFile("ev_abs",@ABS);
! printPdFile("ev_msc",@MSC);
! printPdFile("ev_led",@LED);
! printPdFile("ev_snd",@SND);
! printPdFile("ev_rep",@REP);
! printPdFile("ev_ff",@FF);
! # there doesn't seem to be any PWR events yet...
! #printPdFile("pwr",@PWR);
! printPdFile("ev_ff_status",@FF_STATUS);
# generate a C array for each array and stick them all in the same file
! select ARRAYS;
! printCArray("ev",@EV);
! printCArray("ev_syn",@SYN);
! printCArray("ev_key",@KEY);
! printCArray("ev_rel",@REL);
! printCArray("ev_abs",@ABS);
! printCArray("ev_msc",@MSC);
! printCArray("ev_led",@LED);
! printCArray("ev_snd",@SND);
! printCArray("ev_rep",@REP);
! printCArray("ev_ff",@FF);
# there doesn't seem to be any PWR events yet...
! #printCArray("pwr",@PWR);
! print("char *ev_pwr[1] = { NULL };\n\n");
! printCArray("ev_ff_status",@FF_STATUS);
# print array of arrays
! print("char **event_names[",$#EV+1,"] = {");
for($i = 0; $i < $#EV; $i++)
{
# format nicely in sets of 6
! if ( ($i+4)%6 == 5 ) { print("\n "); }
# if the array element's data is null, print NULL
--- 154,190 ----
}
! #----------------------------------------
! # create the files from the arrays
!
! # print file headers
! print(ARRAYS "#include \"hid.h\"\n\n");
!
! print(HEADER "\#ifndef _INPUT_ARRAYS_H\n");
! print(HEADER "\#define _INPUT_ARRAYS_H\n\n\n");
# generate a C array for each array and stick them all in the same file
! printArray("ev",@EV);
! printArray("ev_syn",@SYN);
! printArray("ev_key",@KEY);
! printArray("ev_rel",@REL);
! printArray("ev_abs",@ABS);
! printArray("ev_msc",@MSC);
! printArray("ev_led",@LED);
! printArray("ev_snd",@SND);
! printArray("ev_rep",@REP);
! printArray("ev_ff",@FF);
# there doesn't seem to be any PWR events yet...
! #printArray("pwr",@PWR);
! print(ARRAYS "char *ev_pwr[1] = { NULL };\n\n");
! print(HEADER "char *ev_pwr[1];\n");
! #
! printArray("ev_ff_status",@FF_STATUS);
# print array of arrays
! print(ARRAYS "char **event_names[",$#EV+1,"] = {");
for($i = 0; $i < $#EV; $i++)
{
# format nicely in sets of 6
! if ( ($i+4)%6 == 5 ) { print(ARRAYS "\n "); }
# if the array element's data is null, print NULL
***************
*** 174,200 ****
$_ = $EV[$i];
m/(ev_[a-z_]+)/;
! print("$1,");
}
! else { print("NULL,"); }
}
$_ = $EV[$#EV];
m/(ev_[a-z_]+)/;
! print("$1\n };\n");
!
! # print "EV: $#EV \n";
! # print "SYN: $#SYN \n";
! # print "KEY: $#KEY \n";
! # print "REL: $#REL \n";
! # print "ABS: $#ABS \n";
! # print "MSC: $#MSC \n";
! # print "LED: $#LED \n";
! # print "SND: $#SND \n";
! # print "REP: $#REP \n";
! # print "FF: $#FF \n";
! # #print "PWR: $#PWR \n";
! # print "FF_STATUS: $#FF_STATUS \n";
close(ARRAYS);
close(INPUT_H);
--- 193,209 ----
$_ = $EV[$i];
m/(ev_[a-z_]+)/;
! print(ARRAYS "$1,");
}
! else { print(ARRAYS "NULL,"); }
}
$_ = $EV[$#EV];
m/(ev_[a-z_]+)/;
! print(ARRAYS "$1\n };\n");
! # print file footers
! print(HEADER "\n\n\#endif /* #ifndef _INPUT_ARRAYS_H */\n");
close(ARRAYS);
+ close(HEADER);
close(INPUT_H);
--- NEW FILE: hid_linux.c ---
#ifdef __linux__
#include <linux/input.h>
#define DEBUG(x)
//#define DEBUG(x) x
/*------------------------------------------------------------------------------
* from evtest.c from the ff-utils package
*/
#define BITS_PER_LONG (sizeof(long) * 8)
#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
#define OFF(x) ((x)%BITS_PER_LONG)
#define BIT(x) (1UL<<OFF(x))
#define LONG(x) ((x)/BITS_PER_LONG)
#define test_bit(bit, array) ((array[LONG(bit)] >> OFF(bit)) & 1)
#endif /* #ifdef __linux__ */
Index: hid.c
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/hid.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** hid.c 22 Oct 2004 05:43:17 -0000 1.4
--- hid.c 22 Oct 2004 18:49:16 -0000 1.5
***************
*** 1,5 ****
/* ---------------------------------------------------------------------------- */
/* */
! /* MacOS X object to use HIDs (Human Interface Devices */
/* Written by Hans-Christoph Steiner <hans(a)at.or.at> */
/* */
--- 1,5 ----
/* ---------------------------------------------------------------------------- */
/* */
! /* MacOS X object to use HIDs (Human Interface Devices) */
/* Written by Hans-Christoph Steiner <hans(a)at.or.at> */
/* */
***************
*** 22,30 ****
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* */
- /* Based on PureData by Miller Puckette and others. */
- /* */
/* ---------------------------------------------------------------------------- */
#include "hid.h"
#include "../linuxhid.h"
--- 22,30 ----
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* */
/* ---------------------------------------------------------------------------- */
#include "hid.h"
+
+ #include "input_arrays.h"
#include "../linuxhid.h"
***************
*** 33,40 ****
--- 33,47 ----
*/
+ void hid_devicelist_refresh(t_hid* x)
+ {
+ /* the device list should be refreshed here */
+ }
+
+
void hid_stop(t_hid* x)
{
DEBUG(post("hid_stop"););
+ #ifdef __linux__
if (x->x_fd >= 0 && x->x_started)
{
***************
*** 43,46 ****
--- 50,58 ----
x->x_started = 0;
}
+ #elif __APPLE__
+ prHIDStopEventLoop();
+ #endif
+
+ hid_devicelist_refresh(x);
}
***************
*** 61,76 ****
static t_int hid_open(t_hid *x, t_symbol *s)
{
t_int eventType, eventCode;
char *eventTypeName = "";
- #ifdef __linux__
- struct input_event hid_input_event;
- #endif
/* counts for various event types */
t_int synCount,keyCount,relCount,absCount,mscCount,ledCount,sndCount,repCount,ffCount,pwrCount,ff_statusCount;
#ifdef __gnu_linux__
! unsigned long bitmask[EV_MAX][NBITS(KEY_MAX)];
#endif
! char devicename[256] = "Unknown";
! DEBUG(post("hid_open");)
hid_close(x);
--- 73,87 ----
static t_int hid_open(t_hid *x, t_symbol *s)
{
+ DEBUG(post("hid_open"););
+
t_int eventType, eventCode;
char *eventTypeName = "";
/* counts for various event types */
t_int synCount,keyCount,relCount,absCount,mscCount,ledCount,sndCount,repCount,ffCount,pwrCount,ff_statusCount;
#ifdef __gnu_linux__
! struct input_event hid_input_event;
! unsigned long bitmask[EV_MAX][NBITS(KEY_MAX)];
#endif
! char devicename[256] = "Unknown";
hid_close(x);
***************
*** 201,205 ****
static t_int hid_read(t_hid *x,int fd)
{
! t_atom event_data[5];
char *eventType;
char *eventCode;
--- 212,216 ----
static t_int hid_read(t_hid *x,int fd)
{
! t_atom event_data[5]; /* this should probably be 4, not 5 */
char *eventType;
char *eventCode;
***************
*** 218,233 ****
outlet_anything(x->x_obj.te_outlet,atom_gensym(event_data),3,event_data+1);
}
! #endif /* #ifdef__gnu_linux__ */
! #ifdef IGNOREIGNOREIGNORE
! pRecDevice pCurrentHIDDevice = GetSetCurrentDevice (gWindow);
! pRecElement pCurrentHIDElement = GetSetCurrenstElement (gWindow);
! // if we have a good device and element which is not a collecion
! if (pCurrentHIDDevice && pCurrentHIDElement && (pCurrentHIDElement->type != kIOHIDElementTypeCollection))
! {
! SInt32 value = HIDGetElementValue (pCurrentHIDDevice, pCurrentHIDElement);
! SInt32 valueCal = HIDCalibrateValue (value, pCurrentHIDElement);
! SInt32 valueScale = HIDScaleValue (valueCal, pCurrentHIDElement);
! }
#endif /* #ifdef __APPLE__ */
--- 229,243 ----
outlet_anything(x->x_obj.te_outlet,atom_gensym(event_data),3,event_data+1);
}
! #elif __APPLE__
! /* pRecDevice pCurrentHIDDevice = GetSetCurrentDevice (gWindow); */
! /* pRecElement pCurrentHIDElement = GetSetCurrenstElement (gWindow); */
! /* // if we have a good device and element which is not a collecion */
! /* if (pCurrentHIDDevice && pCurrentHIDElement && (pCurrentHIDElement->type != kIOHIDElementTypeCollection)) */
! /* { */
! /* SInt32 value = HIDGetElementValue (pCurrentHIDDevice, pCurrentHIDElement); */
! /* SInt32 valueCal = HIDCalibrateValue (value, pCurrentHIDElement); */
! /* SInt32 valueScale = HIDScaleValue (valueCal, pCurrentHIDElement); */
! /* } */
#endif /* #ifdef __APPLE__ */
***************
*** 237,241 ****
}
! return 1;
}
--- 247,251 ----
}
! return 1; /* why is this 1? */
}
Index: Makefile
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/Makefile,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Makefile 20 Oct 2004 02:55:12 -0000 1.3
--- Makefile 22 Oct 2004 18:49:16 -0000 1.4
***************
*** 1,51 ****
! CC=gcc
!
! OS_NAME = $(shell uname -s)
!
!
! # ----------------------- GNU/LINUX i386 -----------------------
! ifeq ($(OS_NAME),Linux)
! LDFLAGS = -export_dynamic -shared
! .SUFFIXES: .pd_linux
!
! all: input_arrays pd_linux
! pd_linux: hid.pd_linux
!
! endif
!
! # ----------------------- DARWIN -----------------------
! ifeq ($(OS_NAME),Darwin)
! LDFLAGS = -bundle -bundle_loader $(PDEXECUTABLE) -L/sw/lib
! .SUFFIXES: .pd_darwin
!
! all: input_arrays pd_darwin
! pd_darwin: hid.pd_darwin
!
! endif
!
! # ----------------------- GENERAL -----------------------
!
! PDEXECUTABLE = ../../../pd/bin/pd
!
! CFLAGS = -DUNIX -DPD -O2 -funroll-loops -fomit-frame-pointer \
! -Wall -W -Wshadow -Wstrict-prototypes -Werror \
! -Wno-unused -Wno-parentheses -Wno-switch
!
! INCLUDE = -I../ -I../../../pd/src -I/usr/local/include -I./HID\ Utilities\ Source
!
! .c.pd_darwin:
! $(CC) $(CFLAGS) $(INCLUDE) -o $*.o -c $*.c
! $(CC) $(LDFLAGS) -o "$*.pd_darwin" "$*.o" -lc -lm
!
! .c.pd_linux:
! $(CC) $(CFLAGS) $(INCLUDE) -o $*.o -c $*.c
! ld $(LDFLAGS) -o $*.pd_linux $*.o -lc -lm
! strip --strip-unneeded $*.pd_linux
! rm $*.o
!
! input_arrays:
! ./make-arrays-from-input.h.pl
!
!
! clean: ; rm -f *.pd_* *.o *~ input_arrays.h ev*-list.pd
!
--- 1,55 ----
!
! OS_NAME = $(shell uname -s)
!
!
! # ----------------------- GNU/LINUX i386 -----------------------
! ifeq ($(OS_NAME),Linux)
! LDFLAGS = -export_dynamic -shared
! .SUFFIXES: .pd_linux
!
! all: input_arrays pd_linux
! pd_linux: hid.pd_linux
!
! endif
!
! # ----------------------- DARWIN -----------------------
! ifeq ($(OS_NAME),Darwin)
! FRAMEWORKS = Carbon IOKit
! LDFLAGS = -bundle -bundle_loader $(PDEXECUTABLE) \
! -L/sw/lib -L./HID\ Utilities\ Source/build \
! -lHIDUtilities \
! $(patsubst %,-framework %,$(FRAMEWORKS))
! .SUFFIXES: .pd_darwin
!
! all: input_arrays pd_darwin
! pd_darwin: hid.pd_darwin
!
! endif
!
! # ----------------------- GENERAL -----------------------
!
! PDEXECUTABLE = ../../../pd/bin/pd
!
! CFLAGS = -DUNIX -DPD -O2 -funroll-loops -fomit-frame-pointer \
! -Wall -W -Wshadow -Wstrict-prototypes \
! -Wno-unused -Wno-parentheses -Wno-switch
!
! INCLUDE = -I./ -I../../../pd/src -I./HID\ Utilities\ Source
!
! .c.o:
! $(CC) $(CFLAGS) $(INCLUDE) -c *.c
!
! .o.pd_darwin:
! $(CC) $(LDFLAGS) -o $*.pd_darwin *.o
!
! .o.pd_linux:
! ld $(LDFLAGS) -o $*.pd_linux $*.o -lc -lm
! strip --strip-unneeded $*.pd_linux
! # rm $*.o
!
! input_arrays:
! ./make-arrays-from-input.h.pl
!
!
! clean: ; rm -f *.pd_* *.o *~ input_arrays.? ev*-list.pd
!
Index: hid.h
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/hid.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** hid.h 22 Oct 2004 05:43:17 -0000 1.1
--- hid.h 22 Oct 2004 18:49:16 -0000 1.2
***************
*** 1,6 ****
#include <m_pd.h>
! #include "input_arrays.h"
static char *version = "$Revision$";
--- 1,8 ----
+ #ifndef _HID_H
+ #define _HID_H
#include <m_pd.h>
! #include "hid.h"
static char *version = "$Revision$";
***************
*** 25,26 ****
--- 27,55 ----
} t_hid;
+
+ /*------------------------------------------------------------------------------
+ * FUNCTION PROTOTYPES FOR APPLE HID MANAGER
+ */
+ #ifdef __APPLE__
+ void releaseHIDDevices (void);
+ int prHIDBuildElementList(void);
+ int prHIDBuildDeviceList(void);
+ int prHIDGetValue(void);
+ void PushQueueEvents_RawValue(void);
+ void PushQueueEvents_CalibratedValue(void);
+ //static pascal void IdleTimer(EventLoopTimerRef inTimer, void* userData);
+ int prHIDReleaseDeviceList(void);
+ //static EventLoopTimerUPP GetTimerUPP(void);
+ //void callback(void * target, IOReturn result, void * refcon, void * sender);
+ int prHIDRunEventLoop(void);
+ int prHIDQueueDevice(void);
+ int prHIDQueueElement(void);
+ int prHIDDequeueElement(void);
+ int prHIDDequeueDevice(void);
+ int prHIDStopEventLoop(void);
+ #endif /* #ifdef __APPLE__ */
+
+
+
+
+ #endif /* #ifndef _HID_H */