diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2004-10-22 18:49:16 +0000 |
---|---|---|
committer | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2004-10-22 18:49:16 +0000 |
commit | 9554c20806f8da1482790543f2ec5a3c91b363d0 (patch) | |
tree | 87c1653591f47f75da9e467f0d2a4fae1bb65c94 | |
parent | f59333ff17f17d8fa9e983ccee47f43cd77a3040 (diff) |
more progress generalizing for cross-platformness; Darwin stuff compiles and the object loads, but it doesn't do anything yet
svn path=/trunk/externals/hcs/hid/; revision=2141
-rw-r--r-- | Makefile | 106 | ||||
-rw-r--r-- | hid.c | 54 | ||||
-rw-r--r-- | hid.h | 33 | ||||
-rw-r--r-- | hid_darwin.c | 146 | ||||
-rw-r--r-- | hid_linux.c | 27 | ||||
-rwxr-xr-x | make-arrays-from-input.h.pl | 117 |
6 files changed, 313 insertions, 170 deletions
@@ -1,51 +1,55 @@ -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
-
+ +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 + @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- */ /* */ -/* MacOS X object to use HIDs (Human Interface Devices */ +/* MacOS X object to use HIDs (Human Interface Devices) */ /* Written by Hans-Christoph Steiner <hans@at.or.at> */ /* */ /* Copyright (c) 2004 Hans-Christoph Steiner */ @@ -21,27 +21,39 @@ /* along with this program; if not, write to the Free Software */ /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* */ -/* Based on PureData by Miller Puckette and others. */ -/* */ /* ---------------------------------------------------------------------------- */ #include "hid.h" + +#include "input_arrays.h" #include "../linuxhid.h" /*------------------------------------------------------------------------------ * IMPLEMENTATION */ +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) { clock_unset(x->x_clock); post("hid: polling stopped"); x->x_started = 0; } +#elif __APPLE__ + prHIDStopEventLoop(); +#endif + + hid_devicelist_refresh(x); } static t_int hid_close(t_hid *x) @@ -60,18 +72,17 @@ static t_int hid_close(t_hid *x) static t_int hid_open(t_hid *x, t_symbol *s) { + DEBUG(post("hid_open");); + 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)]; + struct input_event hid_input_event; + unsigned long bitmask[EV_MAX][NBITS(KEY_MAX)]; #endif - char devicename[256] = "Unknown"; - DEBUG(post("hid_open");) + char devicename[256] = "Unknown"; hid_close(x); @@ -200,7 +211,7 @@ static t_int hid_open(t_hid *x, t_symbol *s) static t_int hid_read(t_hid *x,int fd) { - t_atom event_data[5]; + t_atom event_data[5]; /* this should probably be 4, not 5 */ char *eventType; char *eventCode; #ifdef __linux__ @@ -217,18 +228,17 @@ static t_int hid_read(t_hid *x,int fd) SETFLOAT(event_data + 3, (t_float)(hid_input_event.time).tv_sec); 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); +#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); - } +/* // 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__ */ if (x->x_started) @@ -236,7 +246,7 @@ static t_int hid_read(t_hid *x,int fd) clock_delay(x->x_clock, x->x_delay); } - return 1; + return 1; /* why is this 1? */ } /* Actions */ @@ -1,9 +1,11 @@ +#ifndef _HID_H +#define _HID_H #include <m_pd.h> -#include "input_arrays.h" +#include "hid.h" -static char *version = "$Revision: 1.1 $"; +static char *version = "$Revision: 1.2 $"; /*------------------------------------------------------------------------------ * CLASS DEF @@ -24,3 +26,30 @@ typedef struct _hid t_int x_locID; } 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 */ diff --git a/hid_darwin.c b/hid_darwin.c index dc84ae2..90d9df1 100644 --- a/hid_darwin.c +++ b/hid_darwin.c @@ -1,3 +1,4 @@ +#ifdef __APPLE__ /* * Apple Darwin HID Manager support for [hid] * @@ -20,6 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + + #include <Carbon/Carbon.h> #include "HID_Utilities_External.h" @@ -53,12 +56,27 @@ #include "GC.h" */ + +#define DEBUG(x) +//#define DEBUG(x) x + +/*============================================================================== + * GLOBAL VARS + *======================================================================== */ + int gNumberOfHIDDevices = 0; EventLoopTimerRef gTimer = NULL; // timer for element data updates -void releaseHIDDevices () +/*============================================================================== + * FUNCTIONS + *============================================================================== + */ + +void releaseHIDDevices (void) { + DEBUG(post("releaseHIDDevices");); + if (gTimer) { RemoveEventLoopTimer(gTimer); @@ -69,16 +87,21 @@ void releaseHIDDevices () gNumberOfHIDDevices = 0; } -int prHIDBuildElementList() +int prHIDBuildElementList(void) { + DEBUG(post("prHIDBuildElementList");); + /* PyrSlot *a = g->sp - 1; //class PyrSlot *b = g->sp; //locID device */ - int i, locID, cookieNum; + int locID = NULL; + int cookieNum = NULL; + UInt32 i; pRecElement devElement; pRecDevice pCurrentHIDDevice; -// int err; + UInt32 numElements; + char cstrElementName [256]; // int err = slotIntVal(b, &locID); // if (err) return err; @@ -90,13 +113,12 @@ int prHIDBuildElementList() if(!pCurrentHIDDevice) return (1); devElement = HIDGetFirstDeviceElement (pCurrentHIDDevice, kHIDElementTypeInput); - UInt32 numElements = HIDCountDeviceElements (pCurrentHIDDevice, kHIDElementTypeInput); + numElements = HIDCountDeviceElements (pCurrentHIDDevice, kHIDElementTypeInput); //PyrObject* devAllElementsArray = newPyrArray(g->gc, numElements * sizeof(PyrObject), 0 , true); for(i=0; i<numElements; i++) { - char cstrElementName [256]; //PyrObject* devElementArray = newPyrArray(g->gc, 5 * sizeof(PyrObject), 0 , true); HIDGetTypeName((IOHIDElementType) devElement->type, cstrElementName); //PyrString *devstring = newPyrString(g->gc, cstrElementName, 0, true); @@ -122,8 +144,10 @@ int prHIDBuildElementList() return (0); } -int prHIDBuildDeviceList() +int prHIDBuildDeviceList(void) { + DEBUG(post("prHIDBuildDeviceList");); + int i,err; UInt32 usagePage, usage; /* @@ -210,46 +234,54 @@ int prHIDBuildDeviceList() return (0); } -/* -int prHIDGetValue(VMGlobals *g); -int prHIDGetValue(VMGlobals *g) + +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 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 (); + pRecDevice pCurrentHIDDevice = HIDGetFirstDevice (); while (pCurrentHIDDevice && (pCurrentHIDDevice->locID !=locID)) - pCurrentHIDDevice = HIDGetNextDevice (pCurrentHIDDevice); + 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); - + 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 + { + 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); + //SetInt(a, value); } - else SetNil(a); + //else SetNil(a); return (0); } -*/ -void PushQueueEvents_RawValue () + + +void PushQueueEvents_RawValue(void) { + DEBUG(post("PushQueueEvents_RawValue");); + int i; IOHIDEventStruct event; @@ -277,8 +309,11 @@ void PushQueueEvents_RawValue () } } -void PushQueueEvents_CalibratedValue () + +void PushQueueEvents_CalibratedValue(void) { + DEBUG(post("PushQueueEvents_CalibratedValue");); + int i; IOHIDEventStruct event; @@ -318,20 +353,29 @@ void PushQueueEvents_CalibratedValue () } } -static pascal void IdleTimer (EventLoopTimerRef inTimer, void* userData) + +static pascal void IdleTimer(EventLoopTimerRef inTimer, void* userData) { + DEBUG(post("IdleTimer");); + #pragma unused (inTimer, userData) PushQueueEvents_CalibratedValue (); } -int prHIDReleaseDeviceList() + +int prHIDReleaseDeviceList(void) { + DEBUG(post("prHIDReleaseDeviceList");); + releaseHIDDevices(); return (0); } -static EventLoopTimerUPP GetTimerUPP (void) + +static EventLoopTimerUPP GetTimerUPP(void) { + DEBUG(post("GetTimerUPP");); + static EventLoopTimerUPP sTimerUPP = NULL; if (sTimerUPP == NULL) @@ -350,22 +394,26 @@ void callback (void * target, IOReturn result, void * refcon, void * sender) { } */ -/* -int prHIDRunEventLoop(VMGlobals *g); -int prHIDRunEventLoop(VMGlobals *g) + +int prHIDRunEventLoop(void) { - PyrSlot *a = g->sp - 1; //class + DEBUG(post("prHIDRunEventLoop");); + + //PyrSlot *a = g->sp - 1; //class InstallEventLoopTimer (GetCurrentEventLoop(), 0, 0.001, GetTimerUPP (), 0, &gTimer); //HIDSetQueueCallback(pCurrentHIDDevice, callback); return (0); } -*/ -int prHIDQueueDevice() + +int prHIDQueueDevice(void) { - int locID, cookieNum; + DEBUG(post("prHIDQueueDevice");); + + int locID = NULL; + int cookieNum = NULL; //PyrSlot *a = g->sp - 1; //class //PyrSlot *b = g->sp; //locID device @@ -380,9 +428,13 @@ int prHIDQueueDevice() return (0); } -int prHIDQueueElement() + +int prHIDQueueElement(void) { - int locID, cookieNum; + DEBUG(post("prHIDQueueElement");); + + int locID = NULL; + int cookieNum = NULL; //PyrSlot *a = g->sp - 2; //class //PyrSlot *b = g->sp - 1; //locID device @@ -407,9 +459,13 @@ int prHIDQueueElement() return (0); } -int prHIDDequeueElement() + +int prHIDDequeueElement(void) { - int locID, cookieNum; + DEBUG(post("prHIDDequeueElement");); + + int locID = NULL; + int cookieNum = NULL; //PyrSlot *a = g->sp - 2; //class //PyrSlot *b = g->sp - 1; //locID device @@ -433,9 +489,13 @@ int prHIDDequeueElement() return (0); } -int prHIDDequeueDevice() + +int prHIDDequeueDevice(void) { - int locID, cookieNum; + DEBUG(post("prHIDDequeueDevice");); + + int locID = NULL; + int cookieNum = NULL; /* PyrSlot *a = g->sp - 1; //class @@ -452,8 +512,11 @@ int prHIDDequeueDevice() return (0); } -int prHIDStopEventLoop() + +int prHIDStopEventLoop(void) { + DEBUG(post("prHIDStopEventLoop");); + if (gTimer) RemoveEventLoopTimer(gTimer); gTimer = NULL; @@ -461,3 +524,4 @@ int prHIDStopEventLoop() } +#endif /* #ifdef __APPLE__ */ diff --git a/hid_linux.c b/hid_linux.c new file mode 100644 index 0000000..94a400b --- /dev/null +++ b/hid_linux.c @@ -0,0 +1,27 @@ +#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__ */ diff --git a/make-arrays-from-input.h.pl b/make-arrays-from-input.h.pl index 710d517..13e69d9 100755 --- a/make-arrays-from-input.h.pl +++ b/make-arrays-from-input.h.pl @@ -30,6 +30,15 @@ sub getDataFromHeaderLine } #------------------------------------------------------------------------ +# declare each array in the header +# +sub printCArrayDeclarations +{ + my @arrayToPrint = @_; + print(HEADER "char *${arrayToPrint[0]}[$#arrayToPrint];\n"); +} + +#------------------------------------------------------------------------ # print an array out in C format # sub printCArray @@ -38,19 +47,19 @@ sub printCArray # print("$arrayToPrint[0] $#arrayToPrint \n"); - print("int ${arrayToPrint[0]}_total = $#arrayToPrint; /* # of elements in array */\n"); - print("char *${arrayToPrint[0]}[$#arrayToPrint] = {"); + 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("\n "); } + if ( ($i+4)%6 == 5 ) { print(ARRAYS "\n "); } # if the array element's data is null, print NULL - if ($arrayToPrint[$i]) { print("\"$arrayToPrint[$i]\","); } - else { print("NULL,"); } + if ($arrayToPrint[$i]) { print(ARRAYS "\"$arrayToPrint[$i]\","); } + else { print(ARRAYS "NULL,"); } } - print("\"$arrayToPrint[$#arrayToPrint]\"\n };\n\n\n"); + print(ARRAYS "\"$arrayToPrint[$#arrayToPrint]\"\n };\n\n\n"); } #------------------------------------------------------------------------ @@ -86,6 +95,16 @@ sub printPdFile close(PDFILE); } +#------------------------------------------------------------------------ +# +# +sub printArray +{ + printPdFile(@_); + printCArray(@_); + printCArrayDeclarations(@_); +} + #======================================================================== # MAIN #======================================================================== @@ -95,9 +114,14 @@ $SOURCEFILENAME = "linux/input.h"; open(INPUT_H, "<$SOURCEFILENAME"); # output files -$ARRAYSFILENAME = "input_arrays.h"; +$HEADERFILENAME = "input_arrays.h"; +open(HEADER, ">$HEADERFILENAME"); +$ARRAYSFILENAME = "input_arrays.c"; open(ARRAYS, ">$ARRAYSFILENAME"); + +#---------------------------------------- +# create the arrays from INPUT_H while (<INPUT_H>) { if (m/\#define (FF_STATUS|[A-Z_]*?)_/) @@ -129,72 +153,57 @@ while (<INPUT_H>) } } -# 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); +#---------------------------------------- +# 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 -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); +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... -#printCArray("pwr",@PWR); -print("char *ev_pwr[1] = { NULL };\n\n"); -printCArray("ev_ff_status",@FF_STATUS); +#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("char **event_names[",$#EV+1,"] = {"); +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("\n "); } + if ( ($i+4)%6 == 5 ) { print(ARRAYS "\n "); } # if the array element's data is null, print NULL if ($EV[$i]) { $_ = $EV[$i]; m/(ev_[a-z_]+)/; - print("$1,"); + print(ARRAYS "$1,"); } - else { print("NULL,"); } + else { print(ARRAYS "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"; +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); |