[PD-cvs] externals/input_noticer input_noticer-help.pd, NONE, 1.1 parseeventnodenum.c, NONE, 1.1 INSTALL.TXT, 1.1.1.1, 1.2 Makefile, 1.1.1.1, 1.2 README.TXT, 1.1.1.1, 1.2 input_noticer.c, 1.1.1.1, 1.2 noticer_test.pd, 1.1.1.1, 1.2

David Merrill david_merrill at users.sourceforge.net
Wed Aug 9 03:14:08 CEST 2006


Update of /cvsroot/pure-data/externals/input_noticer
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15840

Modified Files:
	INSTALL.TXT Makefile README.TXT input_noticer.c 
	noticer_test.pd 
Added Files:
	input_noticer-help.pd parseeventnodenum.c 
Log Message:
added help file that shows how to use with [hid] (almost complete), and 
parseeventnodenum.c



Index: input_noticer.c
===================================================================
RCS file: /cvsroot/pure-data/externals/input_noticer/input_noticer.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** input_noticer.c	20 Jun 2006 17:20:32 -0000	1.1.1.1
--- input_noticer.c	9 Aug 2006 01:14:06 -0000	1.2
***************
*** 262,266 ****
  	unsigned int i;
  
! 	post ("removing quotes from %s", input_str);
  		
  	if (input_str != NULL)
--- 262,266 ----
  	unsigned int i;
  
! 	// post ("removing quotes from %s", input_str);
  		
  	if (input_str != NULL)

Index: INSTALL.TXT
===================================================================
RCS file: /cvsroot/pure-data/externals/input_noticer/INSTALL.TXT,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** INSTALL.TXT	20 Jun 2006 17:20:32 -0000	1.1.1.1
--- INSTALL.TXT	9 Aug 2006 01:14:06 -0000	1.2
***************
*** 24,27 ****
  first modify the Makefile to suit your system. Then you can type:
  
! make
  make install_noticer
--- 24,27 ----
  first modify the Makefile to suit your system. Then you can type:
  
! make pd_linux
  make install_noticer

Index: Makefile
===================================================================
RCS file: /cvsroot/pure-data/externals/input_noticer/Makefile,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Makefile	20 Jun 2006 17:20:32 -0000	1.1.1.1
--- Makefile	9 Aug 2006 01:14:06 -0000	1.2
***************
*** 1,29 ****
! CC=gcc
  
! pd_linux: input_noticer.pd_linux
  
  clean: ; rm -f *.pd_linux *.o *~
! 
! # installs all compiled externals.
! # you'll want to change this to match where your externals live
! install: ; sudo cp *.pd_linux /usr/lib/pd/extra
! 
! # installs the input_noticer
! # you'll want to change this to match where your externals live
! install_noticer: ; cp input_noticer.pd_linux /usr/lib/pd/extra
  
  # ----------------------- LINUX i386 -----------------------
  
  .SUFFIXES: .pd_linux
! 
! LINUXLDFLAGS = `pkg-config --libs glib-2.0 hal dbus-glib-1` -lpthread -lgthread-2.0 -lglib-2.0
! # LINUXLDFLAGS = `pkg-config --libs glib-2.0 hal dbus-glib-1 gthread-2.0`
  
  LINUXCFLAGS = -DUNIX -DPD -O2 -funroll-loops -fomit-frame-pointer \
      -Wall -W -Wshadow -Wstrict-prototypes -Werror \
!     -Wno-unused -Wno-parentheses -Wno-switch \
      `pkg-config --cflags --libs glib-2.0 hal dbus-glib-1 gthread-2.0`
  
! LINUXINCLUDE =  -I/usr/local/lib/pd/include -I/usr/lib/pd/src -I/usr/local/include 
  
  .c.pd_linux:
--- 1,29 ----
! CC=gcc
  
! pd_linux: input_noticer.pd_linux parseeventnodenum.pd_linux
  
  clean: ; rm -f *.pd_linux *.o *~
! 
! # installs all compiled externals.
! # you'll want to change this to match where your externals live
! install: ; sudo cp *.pd_linux /usr/lib/pd/extra
! 
! # installs the input_noticer
! # you'll want to change this to match where your externals live
! install_noticer: ; cp input_noticer.pd_linux /usr/lib/pd/extra
  
  # ----------------------- LINUX i386 -----------------------
  
  .SUFFIXES: .pd_linux
! 
! LINUXLDFLAGS = `pkg-config --libs glib-2.0 hal dbus-glib-1` -lpthread -lgthread-2.0 -lglib-2.0
! # LINUXLDFLAGS = `pkg-config --libs glib-2.0 hal dbus-glib-1 gthread-2.0`
  
  LINUXCFLAGS = -DUNIX -DPD -O2 -funroll-loops -fomit-frame-pointer \
      -Wall -W -Wshadow -Wstrict-prototypes -Werror \
!     -Wno-unused -Wno-parentheses -Wno-switch \
      `pkg-config --cflags --libs glib-2.0 hal dbus-glib-1 gthread-2.0`
  
! LINUXINCLUDE =  -I/usr/local/lib/pd/include -I/usr/lib/pd/src -I/usr/local/include 
  
  .c.pd_linux:

--- NEW FILE: input_noticer-help.pd ---
#N canvas 0 25 1367 915 10;
#X obj 49 93 print A;
#X obj 49 70 route 0 1;
#X obj 107 140 print C;
#X obj 78 116 print B;
#X obj 49 10 loadbang;
#X obj 49 45 input_noticer joystick "SideWinder Dual Strike";
#X obj 110 10 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X text 549 12 INSTANTIATION ARGUMENTS:;
#X text 549 31 1) device type: for instance \, as I have entered here:
joystick;
#X text 658 182 This external takes the "joystick" that I have entered
\, and creates "input.joystick" from it \, and then asks HAL to look
for all devices that have that capability.;
#X text 659 275 In linux \, this references the HAL info.product field
for the device. The input_noticer will iterate through all devices
that HAL returns with the given Capabilities field (see above) \, and
look for the user-supplied substring. The corresponding linux.device_file
field is returned \, which will be something like "/dev/input/event6".
This can be used to connect to objects like [hid].;
#X text 127 10 <- BANG to scan for devices \, outputs any that are
found;
#X text 59 469 USING input_noticer output:;
#X text 63 489 Output from input_noticer is a list \, like 0 \, /dev/input/event5
1 \, /dev/input/event6;
#X text 61 535 Use [route] to separate the messages \, and you'll have
just the second list element \, like /dev/input/event5;
#X text 109 611 5 means /dev/input/event5;
#X text 661 60 In linux \, this references the HAL (Hardware Abstraction
Layer) Capabilities field for the device. You can have a look at what
your favorite device has by using the HAL Device Manager \, and look
at the "Device" tab of the most specific entry for your input device.
In my case \, the device tree for my joystick looks like: "SideWinder
Dual Strike" -> "USB Hid Interface" -> "Microsoft SideWinder Dual Strike
USB Version 1.0". Capabilities listed are: input \, input.joystick
;
#X text 549 236 2) product substring: for instance \, as I have entered
here: "SideWinder Dual Strike";
#X text 61 568 To feed this to [hid] \, you'll need to strip the number
from the end \, since [hid] currently wants just the number \, and
interprets the number as follows:;
#X obj 7 166 parseeventnodenum;
#X floatatom 7 188 5 0 0 0 - - -;
#X obj 37 280 hid 0;
#X msg 37 236 open \$1;
#X obj 37 301 print joystick;
#X obj 7 207 t b f;
#X msg -8 235 start;
#X connect 1 0 0 0;
#X connect 1 0 19 0;
#X connect 1 1 3 0;
#X connect 1 2 2 0;
#X connect 4 0 5 0;
#X connect 5 0 1 0;
#X connect 6 0 5 0;
#X connect 19 0 20 0;
#X connect 20 0 24 0;
#X connect 21 0 23 0;
#X connect 22 0 21 0;
#X connect 24 0 25 0;
#X connect 24 1 22 0;
#X connect 25 0 21 0;

Index: noticer_test.pd
===================================================================
RCS file: /cvsroot/pure-data/externals/input_noticer/noticer_test.pd,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** noticer_test.pd	20 Jun 2006 17:20:32 -0000	1.1.1.1
--- noticer_test.pd	9 Aug 2006 01:14:06 -0000	1.2
***************
*** 1,12 ****
  #N canvas 0 0 450 300 10;
! #X obj 108 188 print A;
! #X obj 49 45 input_noticer joystick SideWinder;
! #X obj 133 137 route 0 1;
! #X obj 197 186 print C;
! #X obj 149 215 print B;
! #X obj 50 22 loadbang;
! #X connect 1 0 2 0;
! #X connect 2 0 0 0;
! #X connect 2 1 4 0;
! #X connect 2 2 3 0;
  #X connect 5 0 1 0;
--- 1,15 ----
  #N canvas 0 0 450 300 10;
! #X obj 49 93 print A;
! #X obj 49 70 route 0 1;
! #X obj 107 140 print C;
! #X obj 78 116 print B;
! #X obj 49 10 loadbang;
! #X obj 49 45 input_noticer joystick "SideWinder Dual Strike";
! #X obj 110 10 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
! -1;
! #X connect 1 0 0 0;
! #X connect 1 1 3 0;
! #X connect 1 2 2 0;
! #X connect 4 0 5 0;
  #X connect 5 0 1 0;
+ #X connect 6 0 5 0;

--- NEW FILE: parseeventnodenum.c ---
/* 
 * author: David Merrill <dmerrill at media.mit.edu>
 * based on code from Tom Schouten, found online at:
 * http://lists.puredata.info/pipermail/pd-list/2002-02/004871.html
 */

#include "m_pd.h"
#include <stdio.h>

#define MAXHEAD 1024

typedef struct{
    char buffer[MAXHEAD];
} t_parseeventnodenum_data;
 
typedef struct parseeventnodenum
{
  t_object t_ob;
  t_outlet *x_out;  
  t_outlet *x_out_error;
} t_parseeventnodenum;

void penn_any_method(t_parseeventnodenum *x, t_symbol *s, int argc, t_atom *argv)
{
    char* p = s->s_name;
    int eventnodenum = -1, rv = 0;

    if (sscanf(p,"/dev/input/event%i",&eventnodenum)) {

	// success, send the float to the left outlet
	outlet_float(x->x_out, eventnodenum);
    } else {

	// failure, send the input symbol to the right outlet
	outlet_symbol(x->x_out_error, gensym(p));
    }
}

void parseeventnodenum_free(void)
{
}

t_class *parseeventnodenum_class;

void *parseeventnodenum_new(void)
{
    t_parseeventnodenum *x = (t_parseeventnodenum *)pd_new(parseeventnodenum_class);

    // left outlet is where the parsed number will come out
    x->x_out = outlet_new(&x->t_ob, gensym("float"));

    // right outlet is where the original string will come out if an error occured
    x->x_out_error = outlet_new(&x->t_ob, gensym("symbol"));


    return (void *)x;
}

void parseeventnodenum_setup(void)
{
    parseeventnodenum_class = class_new(gensym("parseeventnodenum"), (t_newmethod)parseeventnodenum_new,
    	(t_method)parseeventnodenum_free, sizeof(t_parseeventnodenum), 0, 0);
    class_addanything(parseeventnodenum_class, penn_any_method);
}


Index: README.TXT
===================================================================
RCS file: /cvsroot/pure-data/externals/input_noticer/README.TXT,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** README.TXT	20 Jun 2006 17:20:32 -0000	1.1.1.1
--- README.TXT	9 Aug 2006 01:14:06 -0000	1.2
***************
*** 40,43 ****
--- 40,50 ----
  you plug, or un-plug a joystick.
  
+ dmerrill at dmerrill-t40:~/externals/input_noticer$ ./test_noticer
+ device added, udi = /org/freedesktop/Hal/devices/usb_device_45e_28_noserial
+ device added, udi = /org/freedesktop/Hal/devices/usb_device_45e_28_noserial_if0
+ device added, udi = /org/freedesktop/Hal/devices/usb_device_45e_28_noserial_usbraw
+ device added, udi = /org/freedesktop/Hal/devices/usb_device_45e_28_noserial_if0_logicaldev_input
+ found the joystick at: /dev/input/event6
+ 
  Thanks to Dan Willmans, Seth Nickell, and David Zeuthen for their 
  invaluable help with the whole dbus/hal part. Also, thanks to Hans-Christoph





More information about the Pd-cvs mailing list