Update of /cvsroot/pure-data/externals/hcs/hid
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6592
Modified Files:
Makefile hid.c make-arrays-from-input.h.pl
Log Message:
[hid] now outputs downcased event names from input.h and Makefile should work on MacOSX and GNU/Linux
Index: Makefile
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/Makefile,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Makefile 18 Oct 2004 03:55:33 -0000 1.1
--- Makefile 18 Oct 2004 21:10:48 -0000 1.2
***************
*** 1,14 ****
CC=gcc
! all: input_arrays pd_darwin
- pd_darwin: hid.pd_darwin macosxhid.pd_darwin
! clean: ; rm -f *.pd_darwin *.o *~ input_arrays.h
! # ----------------------- DARWIN i386 -----------------------
.SUFFIXES: .pd_darwin
PDEXECUTABLE = ../../../pd/bin/pd
--- 1,29 ----
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
***************
*** 19,28 ****
INCLUDE = -I../ -I../../../pd/src -I/usr/local/include -I./HID\ Utilities\ Source
- LDFLAGS = -bundle -bundle_loader $(PDEXECUTABLE) -L/sw/lib
-
.c.pd_darwin:
$(CC) $(CFLAGS) $(INCLUDE) -o $*.o -c $*.c
$(CC) $(LDFLAGS) -o "$*.pd_darwin" "$*.o" -lc -lm
input_arrays:
./make-arrays-from-input.h.pl > input_arrays.h
--- 34,51 ----
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 > input_arrays.h
+
+
+ clean: ; rm -f *.pd_* *.o *~ input_arrays.h
+
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.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** make-arrays-from-input.h.pl 18 Oct 2004 03:55:33 -0000 1.1
--- make-arrays-from-input.h.pl 18 Oct 2004 21:10:49 -0000 1.2
***************
*** 31,35 ****
{
$returnArray[0] = $index;
! $returnArray[1] = "$1";
return @returnArray;
}
--- 31,35 ----
{
$returnArray[0] = $index;
! $returnArray[1] = lc("$1");
return @returnArray;
}
***************
*** 48,52 ****
# print("$arrayToPrint[0] $#arrayToPrint \n");
! print("int ${arrayToPrint[0]}_TOTAL = $#arrayToPrint; /* # of elements in array */\n");
print("char *${arrayToPrint[0]}[$#arrayToPrint] = {");
--- 48,52 ----
# print("$arrayToPrint[0] $#arrayToPrint \n");
! print("int ${arrayToPrint[0]}_total = $#arrayToPrint; /* # of elements in array */\n");
print("char *${arrayToPrint[0]}[$#arrayToPrint] = {");
***************
*** 71,86 ****
open(INPUT_H, "<$FILENAME");
! while(<INPUT_H>)
{
! if (m/#define (FF_STATUS|[A-Z_]*?)_/)
{
# filter EV_VERSION and *_MAX
! m/#define\s+(EV_VERSION|[A-Z_]+_MAX)\s+/;
# print "$1 \n";
switch ($1)
{
! # types
case "EV" { ($index, $value) = getDataFromHeaderLine($_); $EV[$index] = $value; }
! # codes
case "SYN" { ($index, $value) = getDataFromHeaderLine($_); $SYN[$index] = $value; }
case "KEY" { ($index, $value) = getDataFromHeaderLine($_); $KEY[$index] = $value; }
--- 71,86 ----
open(INPUT_H, "<$FILENAME");
! while (<INPUT_H>)
{
! if (m/\#define (FF_STATUS|[A-Z_]*?)_/)
{
# filter EV_VERSION and *_MAX
! m/\#define\s+(EV_VERSION|[A-Z_]+_MAX)\s+/;
# print "$1 \n";
switch ($1)
{
! # types
case "EV" { ($index, $value) = getDataFromHeaderLine($_); $EV[$index] = $value; }
! # codes
case "SYN" { ($index, $value) = getDataFromHeaderLine($_); $SYN[$index] = $value; }
case "KEY" { ($index, $value) = getDataFromHeaderLine($_); $KEY[$index] = $value; }
***************
*** 95,99 ****
case "FF" { ($index, $value) = getDataFromHeaderLine($_); $FF[$index] = $value; }
# there doesn't seem to be any PWR events yet...
! case "PWR" { ($index, $value) = getDataFromHeaderLine($_); $PWR[$index] = $value; }
case "FF_STATUS" { ($index, $value) = getDataFromHeaderLine($_); $FF_STATUS[$index] = $value; }
# else { print " none $_"; }
--- 95,99 ----
case "FF" { ($index, $value) = getDataFromHeaderLine($_); $FF[$index] = $value; }
# there doesn't seem to be any PWR events yet...
! # case "PWR" { ($index, $value) = getDataFromHeaderLine($_); $PWR[$index] = $value; }
case "FF_STATUS" { ($index, $value) = getDataFromHeaderLine($_); $FF_STATUS[$index] = $value; }
# else { print " none $_"; }
***************
*** 102,120 ****
}
! printCArray("EV",@EV);
! printCArray("SYN",@SYN);
! printCArray("KEY",@KEY);
! printCArray("REL",@REL);
! printCArray("ABS",@ABS);
! printCArray("MSC",@MSC);
! printCArray("LED",@LED);
! printCArray("SND",@SND);
! printCArray("REP",@REP);
! printCArray("FF",@FF);
! printCArray("PWR",@PWR);
! printCArray("FF_STATUS",@FF_STATUS);
# print array of arrays
! print("char **EVENTNAMES[",$#EV+1,"] = {");
for($i = 0; $i < $#EV; $i++)
{
--- 102,122 ----
}
! 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++)
{
***************
*** 126,130 ****
{
$_ = $EV[$i];
! m/EV_([A-Z_]+)/;
print("$1,");
}
--- 128,132 ----
{
$_ = $EV[$i];
! m/(ev_[a-z_]+)/;
print("$1,");
}
***************
*** 132,136 ****
}
$_ = $EV[$#EV];
! m/EV_([A-Z_]+)/;
print("$1\n };\n");
--- 134,138 ----
}
$_ = $EV[$#EV];
! m/(ev_[a-z_]+)/;
print("$1\n };\n");
Index: hid.c
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/hid.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** hid.c 18 Oct 2004 03:55:33 -0000 1.1
--- hid.c 18 Oct 2004 21:10:48 -0000 1.2
***************
*** 157,206 ****
/* cycle through all possible event types */
! for (eventType = 0; eventType < EV_MAX; eventType++) {
! if (test_bit(eventType, bitmask[0])) {
! post(" %s (type %d) ", events[eventType] ? events[eventType] : "?", eventType);
! // post("Event type %d",eventType);
!
! /* get bitmask representing supported button types */
! ioctl(x->x_fd, EVIOCGBIT(eventType, KEY_MAX), bitmask[eventType]);
!
! /* cycle through all possible event codes (axes, keys, etc.)
! * testing to see which are supported
! */
! for (eventCode = 0; eventCode < KEY_MAX; eventCode++)
! if (test_bit(eventCode, bitmask[eventType])) {
! post(" Event code %d (%s)", eventCode, names[eventType] ? (names[eventType][eventCode] ? names[eventType][eventCode] : "?") : "?");
!
! switch(eventType) {
// the API changed at some point...
#ifdef EV_RST
! case EV_RST:
! break;
#else
! case EV_SYN:
! break;
#endif
! case EV_KEY:
! buttons++;
! break;
! case EV_REL:
! rel_axes++;
! break;
! case EV_ABS:
! abs_axes++;
! break;
! case EV_MSC:
! break;
! case EV_LED:
! break;
! case EV_SND:
! break;
! case EV_REP:
! break;
! case EV_FF:
! ff++;
! break;
! }
! }
}
}
--- 157,210 ----
/* cycle through all possible event types */
! for (eventType = 0; eventType < EV_MAX; eventType++)
! {
! if (test_bit(eventType, bitmask[0]))
! {
! post(" %s (type %d) ", ev[eventType] ? ev[eventType] : "?", eventType);
! // post("Event type %d",eventType);
!
! /* get bitmask representing supported button types */
! ioctl(x->x_fd, EVIOCGBIT(eventType, KEY_MAX), bitmask[eventType]);
!
! /* cycle through all possible event codes (axes, keys, etc.)
! * testing to see which are supported
! */
! for (eventCode = 0; eventCode < KEY_MAX; eventCode++)
! if (test_bit(eventCode, bitmask[eventType]))
! {
! post(" Event code %s (%d)", event_names[eventType] ? (event_names[eventType][eventCode] ? event_names[eventType][eventCode] : "?") : "?", eventCode);
! /* post(" Event code %d (%s)", eventCode, names[eventType] ? (names[eventType][eventCode] ? names[eventType][eventCode] : "?") : "?"); */
!
! switch(eventType) {
// the API changed at some point...
#ifdef EV_RST
! case EV_RST:
! break;
#else
! case EV_SYN:
! break;
#endif
! case EV_KEY:
! buttons++;
! break;
! case EV_REL:
! rel_axes++;
! break;
! case EV_ABS:
! abs_axes++;
! break;
! case EV_MSC:
! break;
! case EV_LED:
! break;
! case EV_SND:
! break;
! case EV_REP:
! break;
! case EV_FF:
! ff++;
! break;
! }
! }
}
}
***************
*** 224,233 ****
while (read (x->x_fd, &(x->x_input_event), sizeof(struct input_event)) > -1) {
outlet_float (x->x_input_event_value_outlet, (int)x->x_input_event.value);
! outlet_float (x->x_input_event_code_outlet, x->x_input_event.code);
! outlet_float (x->x_input_event_type_outlet, x->x_input_event.type);
/* input_event.time is a timeval struct from <sys/time.h> */
/* outlet_float (x->x_input_event_time_outlet, x->x_input_event.time); */
}
! #else defined (__APPLE__)
pRecDevice pCurrentHIDDevice = GetSetCurrentDevice (gWindow);
pRecElement pCurrentHIDElement = GetSetCurrentElement (gWindow);
--- 228,238 ----
while (read (x->x_fd, &(x->x_input_event), sizeof(struct input_event)) > -1) {
outlet_float (x->x_input_event_value_outlet, (int)x->x_input_event.value);
! outlet_symbol (x->x_input_event_code_outlet, gensym(event_names[x->x_input_event.type][x->x_input_event.code]));
! outlet_symbol (x->x_input_event_type_outlet, gensym(ev[x->x_input_event.type]));
/* input_event.time is a timeval struct from <sys/time.h> */
/* outlet_float (x->x_input_event_time_outlet, x->x_input_event.time); */
}
! #endif
! #ifdef __APPLE__
pRecDevice pCurrentHIDDevice = GetSetCurrentDevice (gWindow);
pRecElement pCurrentHIDElement = GetSetCurrentElement (gWindow);
***************
*** 308,312 ****
x->x_started = 0;
x->x_delay = DEFAULT_DELAY;
! x->x_devname = gensym(HID_DEVICE);
x->x_clock = clock_new(x, (t_method)hid_read);
--- 313,317 ----
x->x_started = 0;
x->x_delay = DEFAULT_DELAY;
! x->x_devname = gensym("/dev/input/event0");
x->x_clock = clock_new(x, (t_method)hid_read);